adddir ./docs adddir ./examples adddir ./examples/conf adddir ./examples/conf/simple adddir ./examples/conf/simple/api adddir ./examples/conf/simple/prog adddir ./examples/dynload adddir ./examples/dynload/io adddir ./examples/dynload/io/api adddir ./examples/dynload/io/prog adddir ./examples/dynload/poly adddir ./examples/dynload/poly/api adddir ./examples/dynload/poly/prog adddir ./examples/dynload/should_fail adddir ./examples/dynload/should_fail/api adddir ./examples/dynload/should_fail/prog adddir ./examples/dynload/should_fail_1 adddir ./examples/dynload/should_fail_1/api adddir ./examples/dynload/should_fail_1/prog adddir ./examples/dynload/should_fail_2 adddir ./examples/dynload/should_fail_2/api adddir ./examples/dynload/should_fail_2/prog adddir ./examples/dynload/should_fail_3 adddir ./examples/dynload/should_fail_3/api adddir ./examples/dynload/should_fail_3/prog adddir ./examples/dynload/simple adddir ./examples/dynload/simple/api adddir ./examples/dynload/simple/prog adddir ./examples/eval adddir ./examples/eval/eval1 adddir ./examples/eval/eval2 adddir ./examples/eval/eval3 adddir ./examples/eval/eval_ adddir ./examples/eval/eval_fn adddir ./examples/eval/eval_fn1 adddir ./examples/eval/foreign_eval adddir ./examples/eval/foreign_eval1 adddir ./examples/eval/foreign_should_fail adddir ./examples/eval/foreign_should_fail_illtyped adddir ./examples/eval/unsafeidir adddir ./examples/eval/unsafeidir/a adddir ./examples/hier adddir ./examples/hier/hier1 adddir ./examples/hier/hier1/Modules adddir ./examples/hier/hier1/api adddir ./examples/hier/hier1/prog adddir ./examples/hier/hier2 adddir ./examples/hier/hier2/A adddir ./examples/hier/hier2/A/B adddir ./examples/hier/hier2/A/B/C adddir ./examples/hier/hier2/api adddir ./examples/hier/hier2/prog adddir ./examples/hier/hier3 adddir ./examples/hier/hier4 adddir ./examples/hmake adddir ./examples/hmake/lib-plugs adddir ./examples/hmake/one-shot adddir ./examples/iface adddir ./examples/iface/null adddir ./examples/load adddir ./examples/load/io adddir ./examples/load/io/api adddir ./examples/load/io/prog adddir ./examples/load/load_0 adddir ./examples/load/load_0/api adddir ./examples/load/load_0/prog adddir ./examples/load/loadpkg adddir ./examples/load/null adddir ./examples/load/null/api adddir ./examples/load/null/prog adddir ./examples/load/rawload adddir ./examples/load/thiemann0 adddir ./examples/load/thiemann0/api adddir ./examples/load/thiemann0/prog adddir ./examples/load/thiemann2 adddir ./examples/load/thiemann2/api adddir ./examples/load/thiemann2/prog adddir ./examples/load/unloadpkg adddir ./examples/make adddir ./examples/make/makeall001 adddir ./examples/make/makeall001/api adddir ./examples/make/makeall001/prog adddir ./examples/make/null adddir ./examples/make/null/api adddir ./examples/make/null/prog adddir ./examples/make/o adddir ./examples/make/o/api adddir ./examples/make/o/prog adddir ./examples/make/odir adddir ./examples/make/odir/api adddir ./examples/make/odir/prog adddir ./examples/make/remake001 adddir ./examples/make/remake001_should_fail adddir ./examples/make/simple adddir ./examples/make/simple/api adddir ./examples/make/simple/prog adddir ./examples/makewith adddir ./examples/makewith/global_pragma adddir ./examples/makewith/global_pragma/api adddir ./examples/makewith/global_pragma/prog adddir ./examples/makewith/io adddir ./examples/makewith/io/api adddir ./examples/makewith/io/prog adddir ./examples/makewith/merge00 adddir ./examples/makewith/mergeto0 adddir ./examples/makewith/module_name adddir ./examples/makewith/multi_make adddir ./examples/makewith/should_fail_0 adddir ./examples/makewith/should_fail_0/api adddir ./examples/makewith/should_fail_0/prog adddir ./examples/makewith/tiny adddir ./examples/makewith/tiny/api adddir ./examples/makewith/tiny/prog adddir ./examples/makewith/unsafeio adddir ./examples/makewith/unsafeio/api adddir ./examples/makewith/unsafeio/prog adddir ./examples/misc adddir ./examples/misc/mkstemps adddir ./examples/multi adddir ./examples/multi/3plugins adddir ./examples/multi/3plugins/api adddir ./examples/multi/3plugins/prog adddir ./examples/objc adddir ./examples/objc/expression_parser adddir ./examples/objc/expression_parser/English.lproj adddir ./examples/objc/expression_parser/English.lproj/MainMenu.nib adddir ./examples/objc/expression_parser/English.lproj/MyDocument.nib adddir ./examples/objc/expression_parser/PluginExpressionParser.xcode adddir ./examples/pdynload adddir ./examples/pdynload/badint adddir ./examples/pdynload/badint/api adddir ./examples/pdynload/badint/prog adddir ./examples/pdynload/null adddir ./examples/pdynload/null/api adddir ./examples/pdynload/null/prog adddir ./examples/pdynload/numclass adddir ./examples/pdynload/numclass/api adddir ./examples/pdynload/numclass/prog adddir ./examples/pdynload/poly adddir ./examples/pdynload/poly/api adddir ./examples/pdynload/poly/prog adddir ./examples/pdynload/poly1 adddir ./examples/pdynload/poly1/api adddir ./examples/pdynload/poly1/prog adddir ./examples/pdynload/should_fail0 adddir ./examples/pdynload/should_fail0/api adddir ./examples/pdynload/should_fail0/prog adddir ./examples/pdynload/should_fail1 adddir ./examples/pdynload/should_fail1/api adddir ./examples/pdynload/should_fail1/prog adddir ./examples/pdynload/small adddir ./examples/pdynload/small/api adddir ./examples/pdynload/small/prog adddir ./examples/pdynload/spj1 adddir ./examples/pdynload/spj1/api adddir ./examples/pdynload/spj1/prog adddir ./examples/pdynload/spj2 adddir ./examples/pdynload/spj2/api adddir ./examples/pdynload/spj2/prog adddir ./examples/pdynload/spj3 adddir ./examples/pdynload/spj3/api adddir ./examples/pdynload/spj3/prog adddir ./examples/pdynload/spj4 adddir ./examples/pdynload/spj4/api adddir ./examples/pdynload/spj4/prog adddir ./examples/pdynload/typealias adddir ./examples/pdynload/typealias/api adddir ./examples/pdynload/typealias/prog adddir ./examples/pdynload/univquant adddir ./examples/pdynload/univquant/api adddir ./examples/pdynload/univquant/prog adddir ./examples/pkgconf adddir ./examples/pkgconf/null adddir ./examples/pkgconf/null/api adddir ./examples/pkgconf/null/prog adddir ./examples/popen adddir ./examples/popen/test1 adddir ./examples/printf adddir ./examples/printf/000 adddir ./examples/printf/001 adddir ./examples/printf/002 adddir ./examples/printf/should_fail_000 adddir ./examples/printf/should_fail_001 adddir ./examples/reload adddir ./examples/reload/null adddir ./examples/reload/null/api adddir ./examples/reload/null/prog adddir ./examples/shell adddir ./examples/shell/shell adddir ./examples/shell/simple adddir ./examples/typecase adddir ./examples/typecase/000 adddir ./examples/unload adddir ./examples/unload/null adddir ./examples/unload/null/api adddir ./examples/unload/null/prog adddir ./examples/unload/sjwtrap adddir ./examples/unload/sjwtrap/api adddir ./examples/unload/sjwtrap/prog adddir ./scripts adddir ./scripts/openbsd-port adddir ./scripts/openbsd-port/pkg adddir ./src adddir ./src/altdata adddir ./src/altdata/AltData adddir ./src/eval adddir ./src/eval/Eval adddir ./src/hi adddir ./src/hi/Hi adddir ./src/plugins adddir ./src/plugins/Plugins adddir ./src/printf adddir ./src/printf/Printf addfile ./AUTHORS addfile ./BUILDING.CVS addfile ./LICENSE addfile ./Makefile addfile ./README addfile ./TODO addfile ./VERSION addfile ./autogen.sh addfile ./config.guess addfile ./config.h.in addfile ./config.mk.in addfile ./config.sub addfile ./configure.ac addfile ./docs/Makefile addfile ./docs/haskell.sty addfile ./docs/hs-plugins.1 addfile ./docs/hs-plugins.hdir addfile ./docs/hs-plugins.tex addfile ./docs/munge.sed addfile ./docs/tex2page.sty addfile ./docs/tex2page.tex addfile ./examples/README addfile ./examples/TIMINGS addfile ./examples/build.mk addfile ./examples/check.mk addfile ./examples/conf/simple/Mailrc.conf addfile ./examples/conf/simple/Mailrc.stub addfile ./examples/conf/simple/Makefile addfile ./examples/conf/simple/api/API.hs addfile ./examples/conf/simple/prog/Main.hs addfile ./examples/conf/simple/prog/expected addfile ./examples/dynload/io/Makefile addfile ./examples/dynload/io/TestIO.hs addfile ./examples/dynload/io/api/API.hs addfile ./examples/dynload/io/prog/Main.hs addfile ./examples/dynload/io/prog/expected addfile ./examples/dynload/poly/Makefile addfile ./examples/dynload/poly/Plugin.hs addfile ./examples/dynload/poly/api/API.hs addfile ./examples/dynload/poly/prog/Main.hs addfile ./examples/dynload/poly/prog/expected addfile ./examples/dynload/should_fail/Makefile addfile ./examples/dynload/should_fail/Plugin.hs addfile ./examples/dynload/should_fail/api/API.hs addfile ./examples/dynload/should_fail/prog/Main.hs addfile ./examples/dynload/should_fail/prog/expected addfile ./examples/dynload/should_fail_1/Makefile addfile ./examples/dynload/should_fail_1/Plugin.hs addfile ./examples/dynload/should_fail_1/api/API.hs addfile ./examples/dynload/should_fail_1/prog/Main.hs addfile ./examples/dynload/should_fail_1/prog/expected addfile ./examples/dynload/should_fail_2/Makefile addfile ./examples/dynload/should_fail_2/Plugin.in addfile ./examples/dynload/should_fail_2/Plugin.stub addfile ./examples/dynload/should_fail_2/api/API.hs addfile ./examples/dynload/should_fail_2/prog/Main.hs addfile ./examples/dynload/should_fail_2/prog/expected addfile ./examples/dynload/should_fail_2/prog/expected.604 addfile ./examples/dynload/should_fail_3/Makefile addfile ./examples/dynload/should_fail_3/Plugin.in addfile ./examples/dynload/should_fail_3/Plugin.stub addfile ./examples/dynload/should_fail_3/api/API.hs addfile ./examples/dynload/should_fail_3/prog/Main.hs addfile ./examples/dynload/should_fail_3/prog/expected addfile ./examples/dynload/should_fail_3/prog/expected.604 addfile ./examples/dynload/simple/Makefile addfile ./examples/dynload/simple/Plugin.hs addfile ./examples/dynload/simple/api/API.hs addfile ./examples/dynload/simple/prog/Main.hs addfile ./examples/dynload/simple/prog/expected addfile ./examples/eval.mk addfile ./examples/eval/eval1/Main.hs addfile ./examples/eval/eval1/Makefile addfile ./examples/eval/eval1/expected addfile ./examples/eval/eval2/Main.hs addfile ./examples/eval/eval2/Makefile addfile ./examples/eval/eval2/expected addfile ./examples/eval/eval3/Main.hs addfile ./examples/eval/eval3/Makefile addfile ./examples/eval/eval3/expected addfile ./examples/eval/eval_/Main.hs addfile ./examples/eval/eval_/Makefile addfile ./examples/eval/eval_/expected addfile ./examples/eval/eval_fn/Main.hs addfile ./examples/eval/eval_fn/Makefile addfile ./examples/eval/eval_fn/expected addfile ./examples/eval/eval_fn1/Main.hs addfile ./examples/eval/eval_fn1/Makefile addfile ./examples/eval/eval_fn1/Poly.hs addfile ./examples/eval/eval_fn1/expected addfile ./examples/eval/foreign_eval/Makefile addfile ./examples/eval/foreign_eval/README addfile ./examples/eval/foreign_eval/expected addfile ./examples/eval/foreign_eval/main.c addfile ./examples/eval/foreign_eval1/Makefile addfile ./examples/eval/foreign_eval1/expected addfile ./examples/eval/foreign_eval1/main.c addfile ./examples/eval/foreign_should_fail/Makefile addfile ./examples/eval/foreign_should_fail/expected addfile ./examples/eval/foreign_should_fail/expected.604 addfile ./examples/eval/foreign_should_fail/main.c addfile ./examples/eval/foreign_should_fail_illtyped/Makefile addfile ./examples/eval/foreign_should_fail_illtyped/expected addfile ./examples/eval/foreign_should_fail_illtyped/expected.604 addfile ./examples/eval/foreign_should_fail_illtyped/main.c addfile ./examples/eval/unsafeidir/Main.hs addfile ./examples/eval/unsafeidir/Makefile addfile ./examples/eval/unsafeidir/a/Extra.hs addfile ./examples/eval/unsafeidir/expected addfile ./examples/foreign.mk addfile ./examples/hier/hier1/Makefile addfile ./examples/hier/hier1/Modules/Flags.hs addfile ./examples/hier/hier1/Modules/Makefile addfile ./examples/hier/hier1/Plugin.hs addfile ./examples/hier/hier1/api/API.hs addfile ./examples/hier/hier1/prog/Main.hs addfile ./examples/hier/hier1/prog/expected addfile ./examples/hier/hier2/A/B/C/Module.hs addfile ./examples/hier/hier2/A/Makefile addfile ./examples/hier/hier2/Makefile addfile ./examples/hier/hier2/api/API.hs addfile ./examples/hier/hier2/prog/Main.hs addfile ./examples/hier/hier2/prog/expected addfile ./examples/hier/hier3/Main.hs addfile ./examples/hier/hier3/Makefile addfile ./examples/hier/hier3/One.hs addfile ./examples/hier/hier3/Two.hs addfile ./examples/hier/hier3/expected addfile ./examples/hier/hier4/A.hs addfile ./examples/hier/hier4/B.hs addfile ./examples/hier/hier4/C.hs addfile ./examples/hier/hier4/D.hs addfile ./examples/hier/hier4/Main.hs addfile ./examples/hier/hier4/Makefile addfile ./examples/hier/hier4/expected addfile ./examples/hmake/lib-plugs/Main.hs addfile ./examples/hmake/lib-plugs/Makefile addfile ./examples/hmake/lib-plugs/expected addfile ./examples/hmake/lib-plugs/test.in addfile ./examples/hmake/one-shot/Main.hs addfile ./examples/hmake/one-shot/Makefile addfile ./examples/hmake/one-shot/expected addfile ./examples/hmake/one-shot/test.in addfile ./examples/iface/null/A.hs addfile ./examples/iface/null/B.hs addfile ./examples/iface/null/Main.hs addfile ./examples/iface/null/Makefile addfile ./examples/iface/null/expected addfile ./examples/iface/null/expected.604 addfile ./examples/load/io/Makefile addfile ./examples/load/io/TestIO.hs addfile ./examples/load/io/api/API.hs addfile ./examples/load/io/prog/Main.hs addfile ./examples/load/io/prog/expected addfile ./examples/load/load_0/Makefile addfile ./examples/load/load_0/Test.hs addfile ./examples/load/load_0/api/API.hs addfile ./examples/load/load_0/prog/Main.hs addfile ./examples/load/load_0/prog/expected addfile ./examples/load/loadpkg/Main.hs addfile ./examples/load/loadpkg/Makefile addfile ./examples/load/loadpkg/expected addfile ./examples/load/null/Makefile addfile ./examples/load/null/Null.hs addfile ./examples/load/null/api/API.hs addfile ./examples/load/null/prog/Main.hs addfile ./examples/load/null/prog/expected addfile ./examples/load/rawload/Main.hs addfile ./examples/load/rawload/Makefile addfile ./examples/load/rawload/t.c addfile ./examples/load/thiemann0/Makefile addfile ./examples/load/thiemann0/Test.hs addfile ./examples/load/thiemann0/api/API.hs addfile ./examples/load/thiemann0/prog/Main.hs addfile ./examples/load/thiemann0/prog/expected addfile ./examples/load/thiemann2/C.hs addfile ./examples/load/thiemann2/Makefile addfile ./examples/load/thiemann2/api/API.hs addfile ./examples/load/thiemann2/prog/A.hs addfile ./examples/load/thiemann2/prog/B.hs addfile ./examples/load/thiemann2/prog/Main.hs addfile ./examples/load/thiemann2/prog/expected addfile ./examples/load/unloadpkg/Main.hs addfile ./examples/load/unloadpkg/Makefile addfile ./examples/load/unloadpkg/expected addfile ./examples/make/makeall001/A.hs addfile ./examples/make/makeall001/B.hs addfile ./examples/make/makeall001/C.hs addfile ./examples/make/makeall001/Makefile addfile ./examples/make/makeall001/Tiny.hs addfile ./examples/make/makeall001/api/API.hs addfile ./examples/make/makeall001/prog/Main.hs addfile ./examples/make/makeall001/prog/expected addfile ./examples/make/null/Makefile addfile ./examples/make/null/Null.hs addfile ./examples/make/null/api/API.hs addfile ./examples/make/null/prog/Main.hs addfile ./examples/make/null/prog/expected addfile ./examples/make/o/Makefile addfile ./examples/make/o/Plugin.hs addfile ./examples/make/o/api/API.hs addfile ./examples/make/o/prog/Main.hs addfile ./examples/make/o/prog/expected addfile ./examples/make/odir/Makefile addfile ./examples/make/odir/Plugin.hs addfile ./examples/make/odir/api/API.hs addfile ./examples/make/odir/prog/Main.hs addfile ./examples/make/odir/prog/expected addfile ./examples/make/remake001/Bar.hs addfile ./examples/make/remake001/Foo.hs addfile ./examples/make/remake001/Main.hs addfile ./examples/make/remake001/Makefile addfile ./examples/make/remake001/expected addfile ./examples/make/remake001_should_fail/Bar.hs addfile ./examples/make/remake001_should_fail/Foo.hs addfile ./examples/make/remake001_should_fail/Main.hs addfile ./examples/make/remake001_should_fail/Makefile addfile ./examples/make/remake001_should_fail/expected addfile ./examples/make/simple/Makefile addfile ./examples/make/simple/Tiny.hs addfile ./examples/make/simple/api/API.hs addfile ./examples/make/simple/prog/Main.hs addfile ./examples/make/simple/prog/expected addfile ./examples/makewith/global_pragma/Makefile addfile ./examples/makewith/global_pragma/Plugin.hs addfile ./examples/makewith/global_pragma/api/API.hs addfile ./examples/makewith/global_pragma/prog/Main.hs addfile ./examples/makewith/global_pragma/prog/expected addfile ./examples/makewith/io/Makefile addfile ./examples/makewith/io/README addfile ./examples/makewith/io/TestIO.conf addfile ./examples/makewith/io/TestIO.stub addfile ./examples/makewith/io/api/API.hs addfile ./examples/makewith/io/prog/Main.hs addfile ./examples/makewith/io/prog/expected addfile ./examples/makewith/merge00/Bar.hs addfile ./examples/makewith/merge00/Foo.hs addfile ./examples/makewith/merge00/Main.hs addfile ./examples/makewith/merge00/Makefile addfile ./examples/makewith/merge00/expected addfile ./examples/makewith/mergeto0/Bar.hs addfile ./examples/makewith/mergeto0/Foo.hs addfile ./examples/makewith/mergeto0/Main.hs addfile ./examples/makewith/mergeto0/Makefile addfile ./examples/makewith/mergeto0/expected addfile ./examples/makewith/module_name/Bar.hs addfile ./examples/makewith/module_name/Foo.hs addfile ./examples/makewith/module_name/Main.hs addfile ./examples/makewith/module_name/Makefile addfile ./examples/makewith/module_name/expected addfile ./examples/makewith/multi_make/Bar.hs addfile ./examples/makewith/multi_make/Foo.hs addfile ./examples/makewith/multi_make/Main.hs addfile ./examples/makewith/multi_make/Makefile addfile ./examples/makewith/multi_make/Stub.hs addfile ./examples/makewith/multi_make/expected addfile ./examples/makewith/should_fail_0/Makefile addfile ./examples/makewith/should_fail_0/Plugin.in addfile ./examples/makewith/should_fail_0/Plugin.stub addfile ./examples/makewith/should_fail_0/api/API.hs addfile ./examples/makewith/should_fail_0/prog/Main.hs addfile ./examples/makewith/should_fail_0/prog/expected addfile ./examples/makewith/tiny/Makefile addfile ./examples/makewith/tiny/Tiny.conf addfile ./examples/makewith/tiny/Tiny.stub addfile ./examples/makewith/tiny/api/API.hs addfile ./examples/makewith/tiny/prog/Main.hs addfile ./examples/makewith/tiny/prog/expected addfile ./examples/makewith/unsafeio/Makefile addfile ./examples/makewith/unsafeio/README addfile ./examples/makewith/unsafeio/Unsafe.conf addfile ./examples/makewith/unsafeio/Unsafe.stub addfile ./examples/makewith/unsafeio/api/API.hs addfile ./examples/makewith/unsafeio/prog/Main.hs addfile ./examples/makewith/unsafeio/prog/README addfile ./examples/makewith/unsafeio/prog/expected addfile ./examples/misc/mkstemps/Main.hs addfile ./examples/misc/mkstemps/Makefile addfile ./examples/misc/mkstemps/expected addfile ./examples/multi/3plugins/Makefile addfile ./examples/multi/3plugins/Plugin1.hs addfile ./examples/multi/3plugins/Plugin2.hs addfile ./examples/multi/3plugins/Plugin3.hs addfile ./examples/multi/3plugins/api/API.hs addfile ./examples/multi/3plugins/prog/Main.hs addfile ./examples/multi/3plugins/prog/expected addfile ./examples/objc/expression_parser/ArithmeticExpressionParser.hs addfile ./examples/objc/expression_parser/English.lproj/Credits.rtf addfile ./examples/objc/expression_parser/English.lproj/InfoPlist.strings addfile ./examples/objc/expression_parser/English.lproj/MainMenu.nib/classes.nib addfile ./examples/objc/expression_parser/English.lproj/MainMenu.nib/info.nib addfile ./examples/objc/expression_parser/English.lproj/MainMenu.nib/objects.nib addfile ./examples/objc/expression_parser/English.lproj/MyDocument.nib/classes.nib addfile ./examples/objc/expression_parser/English.lproj/MyDocument.nib/info.nib addfile ./examples/objc/expression_parser/English.lproj/MyDocument.nib/keyedobjects.nib addfile ./examples/objc/expression_parser/English.lproj/MyDocument.nib/objects.nib addfile ./examples/objc/expression_parser/Info.plist addfile ./examples/objc/expression_parser/KeyValueParser.hs addfile ./examples/objc/expression_parser/Makefile addfile ./examples/objc/expression_parser/MyDocument.h addfile ./examples/objc/expression_parser/MyDocument.m addfile ./examples/objc/expression_parser/PluginEvalAux.hs addfile ./examples/objc/expression_parser/PluginExpressionParser.xcode/project.pbxproj addfile ./examples/objc/expression_parser/PluginExpressionParser_Prefix.pch addfile ./examples/objc/expression_parser/README addfile ./examples/objc/expression_parser/RunHaskell.h addfile ./examples/objc/expression_parser/dont_test addfile ./examples/objc/expression_parser/main.m addfile ./examples/objc/expression_parser/version.plist addfile ./examples/pdynload/badint/Makefile addfile ./examples/pdynload/badint/Plugin.hs addfile ./examples/pdynload/badint/api/API.hs addfile ./examples/pdynload/badint/prog/Main.hs addfile ./examples/pdynload/badint/prog/expected addfile ./examples/pdynload/null/Makefile addfile ./examples/pdynload/null/Plugin.hs addfile ./examples/pdynload/null/api/API.hs addfile ./examples/pdynload/null/prog/Main.hs addfile ./examples/pdynload/null/prog/expected addfile ./examples/pdynload/numclass/Makefile addfile ./examples/pdynload/numclass/Plugin.hs addfile ./examples/pdynload/numclass/api/API.hs addfile ./examples/pdynload/numclass/prog/Main.hs addfile ./examples/pdynload/numclass/prog/expected addfile ./examples/pdynload/poly/Makefile addfile ./examples/pdynload/poly/Plugin.hs addfile ./examples/pdynload/poly/api/API.hs addfile ./examples/pdynload/poly/prog/Main.hs addfile ./examples/pdynload/poly/prog/expected addfile ./examples/pdynload/poly1/Makefile addfile ./examples/pdynload/poly1/Plugin.hs addfile ./examples/pdynload/poly1/api/API.hs addfile ./examples/pdynload/poly1/prog/Main.hs addfile ./examples/pdynload/poly1/prog/expected addfile ./examples/pdynload/should_fail0/Makefile addfile ./examples/pdynload/should_fail0/Plugin.hs addfile ./examples/pdynload/should_fail0/api/API.hs addfile ./examples/pdynload/should_fail0/prog/Main.hs addfile ./examples/pdynload/should_fail0/prog/expected addfile ./examples/pdynload/should_fail1/Makefile addfile ./examples/pdynload/should_fail1/Plugin.hs addfile ./examples/pdynload/should_fail1/api/API.hs addfile ./examples/pdynload/should_fail1/prog/Main.hs addfile ./examples/pdynload/should_fail1/prog/expected addfile ./examples/pdynload/small/Makefile addfile ./examples/pdynload/small/Plugin.hs addfile ./examples/pdynload/small/api/API.hs addfile ./examples/pdynload/small/prog/Main.hs addfile ./examples/pdynload/small/prog/expected addfile ./examples/pdynload/spj1/Makefile addfile ./examples/pdynload/spj1/Plugin.hs addfile ./examples/pdynload/spj1/api/API.hs addfile ./examples/pdynload/spj1/dont_test addfile ./examples/pdynload/spj1/prog/Main.hs addfile ./examples/pdynload/spj1/prog/expected addfile ./examples/pdynload/spj2/Makefile addfile ./examples/pdynload/spj2/Plugin.hs addfile ./examples/pdynload/spj2/api/API.hs addfile ./examples/pdynload/spj2/prog/Main.hs addfile ./examples/pdynload/spj2/prog/expected addfile ./examples/pdynload/spj3/Makefile addfile ./examples/pdynload/spj3/Plugin.hs addfile ./examples/pdynload/spj3/api/API.hs addfile ./examples/pdynload/spj3/prog/Main.hs addfile ./examples/pdynload/spj3/prog/expected addfile ./examples/pdynload/spj3/prog/expected.604 addfile ./examples/pdynload/spj4/Makefile addfile ./examples/pdynload/spj4/Plugin.hs addfile ./examples/pdynload/spj4/api/API.hs addfile ./examples/pdynload/spj4/prog/Main.hs addfile ./examples/pdynload/spj4/prog/expected addfile ./examples/pdynload/typealias/Makefile addfile ./examples/pdynload/typealias/Plugin.hs addfile ./examples/pdynload/typealias/api/API.hs addfile ./examples/pdynload/typealias/prog/Main.hs addfile ./examples/pdynload/typealias/prog/expected addfile ./examples/pdynload/univquant/Makefile addfile ./examples/pdynload/univquant/Plugin.hs addfile ./examples/pdynload/univquant/api/API.hs addfile ./examples/pdynload/univquant/prog/Main.hs addfile ./examples/pdynload/univquant/prog/expected addfile ./examples/pkgconf/null/Makefile addfile ./examples/pkgconf/null/Null.hs addfile ./examples/pkgconf/null/api/API.hs addfile ./examples/pkgconf/null/api/package.conf.in addfile ./examples/pkgconf/null/dont_test addfile ./examples/pkgconf/null/prog/Main.hs addfile ./examples/popen/test1/Main.hs addfile ./examples/popen/test1/Makefile addfile ./examples/popen/test1/expected addfile ./examples/printf/000/Main.hs addfile ./examples/printf/000/Makefile addfile ./examples/printf/000/expected addfile ./examples/printf/000/printf.sh addfile ./examples/printf/001/Main.hs addfile ./examples/printf/001/Makefile addfile ./examples/printf/001/expected addfile ./examples/printf/002/Main.hs addfile ./examples/printf/002/Makefile addfile ./examples/printf/002/expected addfile ./examples/printf/should_fail_000/Main.hs addfile ./examples/printf/should_fail_000/Makefile addfile ./examples/printf/should_fail_000/expected addfile ./examples/printf/should_fail_000/expected.604 addfile ./examples/printf/should_fail_001/Main.hs addfile ./examples/printf/should_fail_001/Makefile addfile ./examples/printf/should_fail_001/expected addfile ./examples/printf/should_fail_001/expected.604 addfile ./examples/reload/null/Makefile addfile ./examples/reload/null/Null.hs addfile ./examples/reload/null/api/API.hs addfile ./examples/reload/null/prog/Main.hs addfile ./examples/reload/null/prog/expected addfile ./examples/shell/shell/API.hs addfile ./examples/shell/shell/Main.hs addfile ./examples/shell/shell/Makefile addfile ./examples/shell/shell/Plugin.hs addfile ./examples/shell/shell/Plugin.stub addfile ./examples/shell/shell/README addfile ./examples/shell/shell/dont_test addfile ./examples/shell/simple/Main.hs addfile ./examples/shell/simple/Makefile addfile ./examples/shell/simple/Plugin.hs addfile ./examples/shell/simple/Plugin.stub addfile ./examples/shell/simple/README addfile ./examples/shell/simple/StringProcessorAPI.hs addfile ./examples/shell/simple/dont_test addfile ./examples/typecase/000/Main.hs addfile ./examples/typecase/000/Makefile addfile ./examples/typecase/000/expected addfile ./examples/unload/null/Makefile addfile ./examples/unload/null/Null.hs addfile ./examples/unload/null/api/API.hs addfile ./examples/unload/null/prog/Main.hs addfile ./examples/unload/null/prog/expected addfile ./examples/unload/sjwtrap/Makefile addfile ./examples/unload/sjwtrap/Null.hs addfile ./examples/unload/sjwtrap/api/API.hs addfile ./examples/unload/sjwtrap/prog/Main.hs addfile ./examples/unload/sjwtrap/prog/expected addfile ./install-sh addfile ./scripts/openbsd-port/Makefile addfile ./scripts/openbsd-port/distinfo addfile ./scripts/openbsd-port/pkg/DESCR addfile ./scripts/openbsd-port/pkg/PLIST addfile ./src/Makefile addfile ./src/README addfile ./src/altdata/AltData.hs addfile ./src/altdata/AltData/Dynamic.hs addfile ./src/altdata/AltData/Typeable.hs addfile ./src/altdata/Makefile addfile ./src/altdata/altdata.conf.in.cpp addfile ./src/build.mk addfile ./src/eval/Eval.hs addfile ./src/eval/Eval/Haskell.hs addfile ./src/eval/Eval/Meta.hs addfile ./src/eval/Eval/Utils.hs addfile ./src/eval/Makefile addfile ./src/eval/eval.conf.in.cpp addfile ./src/hi/Hi.hs addfile ./src/hi/Hi/Binary.hs addfile ./src/hi/Hi/FastMutInt.hs addfile ./src/hi/Hi/FastString.hs addfile ./src/hi/Hi/Parser.hs addfile ./src/hi/Hi/PrimPacked.hs addfile ./src/hi/Hi/Syntax.hs addfile ./src/hi/Hi/hschooks.c addfile ./src/hi/Hi/hschooks.h addfile ./src/hi/Makefile addfile ./src/hi/hi.conf.in.cpp addfile ./src/plugins/Makefile addfile ./src/plugins/Plugins.hs addfile ./src/plugins/Plugins/Consts.hs addfile ./src/plugins/Plugins/Env.hs addfile ./src/plugins/Plugins/Load.hs addfile ./src/plugins/Plugins/Make.hs addfile ./src/plugins/Plugins/MkTemp.hs addfile ./src/plugins/Plugins/Package.hs addfile ./src/plugins/Plugins/PackageAPI.hs addfile ./src/plugins/Plugins/ParsePkgConfCabal.hs addfile ./src/plugins/Plugins/ParsePkgConfCabal.y addfile ./src/plugins/Plugins/ParsePkgConfLite.hs addfile ./src/plugins/Plugins/ParsePkgConfLite.y addfile ./src/plugins/Plugins/Parser.hs addfile ./src/plugins/Plugins/Utils.hs addfile ./src/plugins/plugins.conf.in.cpp addfile ./src/printf/Makefile addfile ./src/printf/Printf.hs addfile ./src/printf/Printf/Compile.hs addfile ./src/printf/Printf/Lexer.hs addfile ./src/printf/Printf/Lexer.x addfile ./src/printf/Printf/Parser.hs addfile ./src/printf/Printf/Parser.y addfile ./src/printf/printf.conf.in.cpp hunk ./AUTHORS 1 + +Don Stewart +Sean Seefried +Andre Pang + hunk ./BUILDING.CVS 1 +CVS BUILDING INSTRUCTIONS +========================= + +These are build instructions if you've checked out hs-plugins +from CVS (instead of downloading a source distribution tarball). + +1. Execute autogen.sh to generate the GNU ./configure script: + + ./autogen.sh + +2. Build hs-plugins as usual with ./configure && make + + +cvsps +===== + +For people who are used to more modern revision control systems +(such as Darcs, Subversion and Arch) and miss working with +'patchsets' instead of the disjoint per-file patches that CVS +uses, take a look at cvsps , +a patchset manager for CVS. While it doesn't, by any means, give +you the many advantages that more modern source control systems +offer you, it certainly makes using CVS and managing patches far +easier! + hunk ./LICENSE 1 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + hunk ./Makefile 1 +# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) + +# cut down reimplementation of $fptools/mk directory + +.PHONY: build all + +all: headers runplugs plugs + +build: + cd src && $(MAKE) + +plugs: build + ( cd examples/hmake/lib-plugs ; $(MAKE) build ) + cp examples/hmake/lib-plugs/plugs ./ + +runplugs: build + ( cd examples/hmake/one-shot ; $(MAKE) build ) + cp examples/hmake/one-shot/runplugs ./ + +headers: build + cp src/eval/Eval/Haskell_stub.h EvalHaskell.h + +# +# installing +# + +# TODO put these in subdirs +install: + $(INSTALL_DATA_DIR) $(LIBDIR)/include + $(INSTALL_DATA) EvalHaskell.h $(LIBDIR)/include + @(cd src && $(MAKE) install) + $(INSTALL_DATA_DIR) $(PREFIX)/bin + $(INSTALL_PROGRAM) plugs $(PREFIX)/bin/ + $(INSTALL_PROGRAM) runplugs $(PREFIX)/bin/ + +# +# and register the library with ghc package system +# Use this target if installing by hand. May need to be performed as root +# +register: + env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/altdata/altdata.conf.in + env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/hi/hi.conf.in + env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/plugins/plugins.conf.in + env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/eval/eval.conf.in + env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/printf/printf.conf.in + +# and unregister the packages +unregister: + $(GHC_PKG) -r printf + $(GHC_PKG) -r eval + $(GHC_PKG) -r plugins + $(GHC_PKG) -r hi + $(GHC_PKG) -r altdata + +# +# regress check. TODO check expected output +# +check: + @if [ ! -f EvalHaskell.h ] ; then \ + echo "run 'make' first" ; \ + exit 1 ;\ + fi + @( d=/tmp/plugins.tmp.$$$$ ; mkdir $$d ; export TMPDIR=$$d ;\ + for i in `find examples ! -name CVS -type d -maxdepth 2 -mindepth 2` ; do \ + printf "=== testing %-50s ... " "$$i" ; \ + ( cd $$i ; if [ -f dont_test ] ; then \ + echo "ignored." ;\ + else ${MAKE} -sk && ${MAKE} -ksi check |\ + sed '/^Compil/d;/^Load/d;/Read/d;/Expan/d;/Savi/d;/Writ/d' ;\ + ${MAKE} -sk clean ;\ + fi ) 2> /dev/null ;\ + done ; rm -rf $$d ) + + +# +# making clean +# + +CLEAN_FILES += *.conf.*.old *~ +EXTRA_CLEANS+=*.conf.inplace* *.conf.in *.h autom4te.cache \ + config.h config.mk config.log config.status configure + +clean: + cd docs && $(MAKE) clean + cd src && $(MAKE) clean + rm -rf $(CLEAN_FILES) + find examples -name '*.a' -exec rm {} \; + find examples -name '*~' -exec rm {} \; + find examples -name 'a.out' -exec rm {} \; + find examples -name '*.hi' -exec rm {} \; + find examples -name '*.o' -exec rm {} \; + find examples -name '*.core' -exec rm {} \; + find examples -name 'package.conf' -exec rm {} \; + rm -rf plugs + rm -rf runplugs + rm -rf examples/hmake/lib-plugs/plugs + rm -rf examples/hmake/one-shot/runplugs + rm -f EvalHaskell.h + +distclean: clean + rm -rf $(EXTRA_CLEANS) + +include config.mk hunk ./README 1 + +------------------------------------------------------------------------ + hs-plugins +------------------------------------------------------------------------ + +Compiler and tool support for compiling and loading, and evaluating +Haskell at runtime. + +The library provides a convenient interface to GHC's runtime loader +and linker, letting you load compiled Haskell code. + +It also provides a `make' system for compiling plugin source +automagically and for combining the user's .hs file with a stub of +standard declarations and syntax, saving the user from having to write +standard code themselves. + +It provides an eval() function, for generating new, well-typed, +compiled code from a Haskell source string. + +It also provides a new variation of printf for Haskell-- a runtime +generated, dynamically-typed printf. + +Read the documentation in doc/ for more. + +------------------------------------------------------------------------ +DEPENDENCIES: + +* Requires GNU make or BSD make to build +* Requires GHC > 6.2 (for Typeable.h) +* 'plugs' requires a working readline library. + +* If you wish to use TH in plugins, or to run load()-programs in GHCi, + you require a patch to GHC's linker, that was committed into ghc + 6.3, and ghc 6.2 -stable branch, and is available from 6.2.2 onwards. + +* If you need to regenerate ./configure you need >= autoconf-2.53 + +------------------------------------------------------------------------ +BUILDING: + $ ./configure --prefix=/usr/local + $ make + $ make install + +If you wish to register the libraries as official ghc pkg (probably as +root): + $ make register + +And to unregister (maybe as root). Note that the unistall order +matters: + + $ ghc-pkg -r printf + $ ghc-pkg -r eval + $ ghc-pkg -r plugins + $ ghc-pkg -r hi + $ ghc-pkg -r altdata + +Once it is registered, you can link against the library by just adding +-package plugins or, e.g. -package eval, to your command line. + +The documentation relies on latex, dvips, tex2page: + + $ cd doc && make + +EXAMPLES: + +Have a look in the examples/ directory for many examples of how to +arrange your code. + +LICENSE: + +This library is distributed under the terms of the LGPL. The runtime +loader code is based on code written by André Pang, and others, and is +distributed under the BSD-style Glasgow University license. + +PORTABILITY: + +Requires GHC 6.2 or greater, though most testing has be done on 6.3. +They dynamic loader requires a functional GHCi implementation. + +---------------------+-------------------------------------------------- + Platform | Works Should work* Unknown Won't work +---------------------+-------------------------------------------------- +i386-*-linux | X +i386-*-freebsd | X +i386-*-openbsd | X +powerpc-apple-darwin | X +sparc-*-solaris2 | X +ia64-*-linux | # +i386-*-solaris2 | X +sparc-*-linux | X +sparc-*-openbsd | X +i386-*-netbsd | X +amd64-*-openbsd | X +mips64-sgi-irix | X +---------------------+-------------------------------------------------- + +# .hi file parsing is currently broken hunk ./TODO 1 +For 0.1 +---------- + ++ have eval, printf return errors as arguments, not to stdout + ++ nice functions for cleaning up /tmp files, given a module name + ++ PORTABILITY -- pretty much all of this is in main/SysTools.lhs in GHC + -- where to /tmp files go? Use SysTools code from GHC + -- need to dosify file names on in and out + -- try to confirm the implementation of forkProcess + ++ write a script to strip down the release code. + ++ .hi file parser is broken on Itanium, again. + ++ Implement hs_eval by marshalling Dynamics across to the C side for + checking. + ++ Make data structures used by the library Storable, for C programs + ++ insert iface info into the state, building up a dependency graph like + hram's. use this to allow cascading unloading. Does anyone want this? + ++ enable more .hi interface code to provide full GHC-like :t options + to plugs. + ++ replace the String interface to eval with an ExpQ interface. + ++ build way=p and way='' hunk ./VERSION 1 +hs-plugins 0.9.8 hunk ./autogen.sh 1 +#!/bin/sh -x + +# this is the world's most complicated autogen.sh script :) + +exec autoconf + hunk ./config.guess 1 +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002 Free Software Foundation, Inc. + +timestamp='2002-07-23' + +# 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. + +# This shell variable is my proudest work .. or something. --bje + +set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ; +(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old) + || (echo "$me: cannot create $tmpdir" >&2 && exit 1) ; +dummy=$tmpdir/dummy ; +files="$dummy.c $dummy.o $dummy.rel $dummy" ; +trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $files ; + 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 ; +unset files' + +# 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 + +# 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 + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # 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 + # 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. + eval $set_cc_for_build + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; + 3-1307) + UNAME_MACHINE="alphaev7" + ;; + esac + fi + rm -f $dummy.s $dummy && rmdir $tmpdir + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + 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_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 $dummy.c -o $dummy \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 + rm -f $dummy.c $dummy && rmdir $tmpdir + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:*:*: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 $dummy.c -o $dummy && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 + rm -f $dummy.c $dummy && rmdir $tmpdir + 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 $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy && rmdir $tmpdir + fi ;; + esac + 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 $dummy.c -o $dummy && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 + rm -f $dummy.c $dummy && rmdir $tmpdir + 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*T3D:*:*:*) + echo alpha-cray-unicosmk${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 ;; + 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:*:*) + # 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=` + rm -f $dummy.c && rmdir $tmpdir + 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*:3*) + echo i386-pc-interix3 + 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 i386-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 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-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=` + rm -f $dummy.c && rmdir $tmpdir + test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-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}-ibm-linux + 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-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=` + rm -f $dummy.c && rmdir $tmpdir + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-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:*: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 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + 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 ;; + 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) + 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 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + 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 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-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-[GKLNPTVW]: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 ;; + 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 ;; + *: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 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + 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 $dummy.c -o $dummy 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 +rm -f $dummy.c $dummy && rmdir $tmpdir + +# 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: hunk ./config.h.in 1 +/* + * Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons + * LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) + */ + +/* symbols that must be assigned to variables in Haskell code */ + +/* NOTE: this is not the same as symbols needed for cpp of .hs code */ + +/* path to ghc */ +#define GHC "@GHC@" + +/* path to GHC libraries */ +#define GHC_LIB_PATH "@GHC_LIB_PATH@" + +#define TOP "@TOP@" + +#define LEADING_UNDERSCORE @LEADING_UNDERSCORE@ + +#define CABAL @CABAL@ + hunk ./config.mk.in 1 +# +# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +# + +# +# config.mk.in : +# variables that need to be visible in Makefiles +# + +# all is the default rule for everyone +default: all + +PACKAGE = plugins +UPACKAGE = Plugins + +TOP = @TOP@ + +PREFIX = @PREFIX@ +LIBDIR = $(PREFIX)/lib/hs-$(PACKAGE) +BINDIR = $(PREFIX)/bin + +WHOLE_ARCHIVE_FLAG = @WHOLE_ARCHIVE_FLAG@ + +# Are we using the new Cabal packages? +CABAL = @CABAL@ + + +GHC = @GHC@ +GHC_LIB_PATH = @GHC_LIB_PATH@ +GHC_VERSION = @GHC_VERSION@ +GLASGOW_HASKELL = @GLASGOW_HASKELL@ +GHC_EXTRA_OPTS = @SYMS@ @DEBUG_OPTS@ +GHC_LD_OPTS = + +GHC_PKG = @GHCPKG@-@GHC_VERSION@ + +LD = @LD@ +LD_X = -x + +HAPPY = @HAPPY@ +HAPPY_OPTS = -a -g -c +ALEX = @ALEX@ +ALEX_OPTS = --ghc +HADDOCK = @HADDOCK@ + +AR = @AR@ +RANLIB = @RANLIB@ + +RM = @RM@ + +INSTALL = @INSTALL@ + +# A few aliases +INSTALL_PROGRAM = ${INSTALL} -s -m 755 +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_DATA_DIR= ${INSTALL} -d -m 755 hunk ./config.sub 1 +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002 Free Software Foundation, Inc. + +timestamp='2002-07-03' + +# 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* | storm-chaos* | os2-emx* | windows32-* | 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 \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | 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-* | c54x-* \ + | 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-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipstx39 | mipstx39el \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* | tic30-* | tic54x-* | 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 + ;; + 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 + ;; + 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) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-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-*) + basic_machine=i686-`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 + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + 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 + ;; + t3d) + basic_machine=alpha-cray + os=-unicos + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-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 + ;; + windows32) + basic_machine=i386-pc + os=-windows32-msvcrt + ;; + 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 | sh3eb | sh4eb | sh[1234]le | sh3ele) + 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 + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-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* | -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*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-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 + ;; + -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 + ;; + # 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: hunk ./configure.ac 1 +# +# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +# + +# sanity test +AC_INIT(src/plugins/Plugins.hs) + +# untested on earlier than 2.52, but it won't work anyway +AC_PREREQ(2.53) + +# Find out what type of system we're running on +AC_CANONICAL_BUILD + +PREFIX="$prefix" +if test "$prefix" = "NONE" +then + PREFIX="$ac_default_prefix" +fi +AC_SUBST(PREFIX) + +Platform="$build_cpu-$build_vendor-$build_os" + +case $Platform in +powerpc-apple-darwin*) + MACOSX=yes + ;; +*) + MACOSX=no + ;; +esac +if test "$MACOSX" = "yes" +then + WHOLE_ARCHIVE_FLAG=-all_load + LEADING_UNDERSCORE=1 +else + WHOLE_ARCHIVE_FLAG=--whole-archive + LEADING_UNDERSCORE=0 +fi + +AC_SUBST(WHOLE_ARCHIVE_FLAG) +AC_SUBST(LEADING_UNDERSCORE) + + +TOP=`pwd` +AC_SUBST(TOP) + +# necessary tools + +# allow user supplied haskell compiler +AC_ARG_WITH(ghc, + AC_HELP_STRING([--with-ghc=],[use a specific Haskell compiler]), + [ GHC="$withval" + if test ! -f "$GHC" ; then + AC_MSG_ERROR([$GHC not found. You need GHC to build this project]) + fi + ], + [ AC_CHECK_PROG(GHC,ghc,ghc) + if test -z "$GHC" ; then + AC_MSG_ERROR([You need GHC to build this project]) + fi + ] + ) +AC_SUBST(GHC) + +# find path to GHC libs, for runtime_loader +if test -n "$GHC" ; then + AC_MSG_CHECKING([for ghc library directory]) + GHC_LIB_PATH=`$GHC --print-libdir` + AC_MSG_RESULT([$GHC_LIB_PATH]) +fi +AC_SUBST(GHC_LIB_PATH) + +# check ghc version here +if test -n "$GHC" ; then + AC_MSG_CHECKING([for ghc version]) + GHC_VERSION=`$GHC --numeric-version` + AC_MSG_RESULT([$GHC_VERSION]) +fi +AC_SUBST(GHC_VERSION) + +# Work out value of __GLASGOW_HASKELL__ +if test -n "$GHC" ; then + AC_MSG_CHECKING([for value of __GLASGOW_HASKELL__]) + echo "main = print __GLASGOW_HASKELL__" > t.hs + GLASGOW_HASKELL=`echo 'main' | "$GHC" --interactive -v0 -cpp t.hs` + rm t.hs + AC_MSG_RESULT([$GLASGOW_HASKELL]) +fi +AC_SUBST(GLASGOW_HASKELL) + +dnl ** quote char breaks sed +changequote(, )dnl +MAJOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\1/'` +MINOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\2/'` +changequote([, ])dnl + +if test "$MAJOR" -lt "6"; then + AC_MSG_ERROR(Found major $MAJOR. You need a ghc version >= 6.2) ; +fi +if test "$MINOR" -lt "2"; then + AC_MSG_ERROR(You need a ghc version >= 6.2) ; +fi + +#Allow plugins to be built with Cabal libraries +AC_ARG_ENABLE(cabal, + [ --enable-cabal Enable use of Cabal packages in pluggable-1-branch + of GHC], + [ CABAL=1 ], + [ CABAL=0 ]) + +# used by the Makefile`s to alter dependencies. +if test "$MAJOR" -ge "6" -a "$MINOR" -ge "4"; then + CABAL=1 +fi + +AC_SUBST(CABAL) + +# Allow a debugging version of hs-plugins to be built +AC_ARG_ENABLE(debug, + [ --enable-debug Enable a debug version of hs-plugins to be built], + [ DEBUG_OPTS=-DDEBUG ], + [ DEBUG_OPTS= ]) + +AC_SUBST(DEBUG_OPTS) + +# allow user supplied haskell package manager +AC_ARG_WITH(ghc-pkg, + AC_HELP_STRING([--with-ghc-pkg=],[use a specific ghc-pkg]), + [ GHCPKG="$withval" + if test ! -f "$GHCPKG" ; then + AC_MSG_ERROR([$GHCPKG not found. You need ghc-pkg]) + fi + ], + [ AC_CHECK_PROG(GHCPKG,ghc-pkg,ghc-pkg) + if test -z "$GHCPKG" ; then + AC_MSG_ERROR([You need ghc-pkg]) + fi + ] + ) + +AC_SUBST(GHCPKG) + +AC_CHECK_PROG(HADDOCK,haddock,haddock) +if test -z "$HADDOCK" ; then + AC_MSG_WARN(You need Haddock if you want developer documentation) +fi + +AC_CHECK_PROG(HAPPY,happy,happy) +if test -z "$HAPPY" ; then + AC_MSG_WARN(If you change or remove the parser you'll need Happy) +fi + +AC_CHECK_PROG(ALEX,alex,alex) +if test -z "$ALEX" ; then + AC_MSG_WARN(If you change or remove the lexer files you'll need alex) +fi + +AC_CHECK_PROG(LD,ld,ld) +if test -z "$LD" ; then + AC_MSG_WARN(You need ld -export-dynamic) +fi + +AC_CHECK_PROG(AR,ar,ar) +if test -z "$AR" ; then + AC_MSG_WARN(You need ar to build the library) +fi + +AC_CHECK_PROG(RANLIB,ranlib,ranlib) +if test -z "$RANLIB" ; then + AC_MSG_WARN(You need randlib to build the library) +fi + +AC_CHECK_PROG(RM,rm,rm) +if test -z "$RM" ; then + AC_MSG_WARN(You need rm!) +fi + +AC_CHECK_PROG(TEX,tex,tex) +if test -z "$TEX" ; then + AC_MSG_WARN(You'll need tex if you wish to build the documentation) +fi +AC_CHECK_PROG(TEX2PAGE,tex2page,tex2page) +if test -z "$TEX2PAGE" ; then + AC_MSG_WARN(You'll need tex2page if you wish to build the + documentation: http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html) +fi + +AC_CHECK_FUNC(arc4random, [SYMS="$SYMS -DHAVE_ARC4RANDOM"]) + +AC_SUBST(SYMS) + +AC_PROG_INSTALL + +AC_CONFIG_FILES(config.mk config.h) + +AC_OUTPUT + hunk ./docs/Makefile 1 +# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) + +.PHONY: build clean html + +SRC = hs-plugins + +build: $(SRC).ps html + +$(SRC).ps: $(SRC).dvi + dvips -f $(SRC).dvi > $@ + +html: $(SRC).tex + tex2page $(SRC) + tex2page $(SRC) + ./munge.sed < $(SRC)/$(SRC).html > tmp.out + mv tmp.out $(SRC)/$(SRC).html + cp $(SRC)/$(SRC).html $(SRC)/index.html + tar czf $(SRC).html.tar.gz $(SRC) + mv $(SRC).html.tar.gz $(SRC)/ + +$(SRC).dvi: $(SRC).tex + latex $(SRC).tex && latex $(SRC).tex + +CLEANS= *.{ps,dvi,aux,log} *~ hs-plugins *-Z-* *.toc + +clean: + rm -rf $(CLEANS) + +all: doc + hunk ./docs/haskell.sty 1 +%%% This is a LaTeX2e style file. +%%% +%%% It supports setting functional languages like Haskell. +%%% +%%% Manuel M. T. Chakravarty [1998..2000] +%%% +%%% $Id: haskell.sty,v 1.2 2004/05/16 08:20:09 dons Exp $ +%%% +%%% 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 file 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. +%%% +%%% Acknowledegments ========================================================== +%%% +%%% Thanks to Gabriele Keller for beta testing and +%%% code contributions. Thanks to the LaTeX3 project for improving the LaTeX +%%% sources (which helped me writing this code). Furthermore, I am grateful +%%% to Martin Erwig for feedback and +%%% suggestions, and to Conal Elliott for pointing out +%%% a tricky bug. +%%% +%%% TODO ====================================================================== +%%% +%%% B ~ bug; F ~ feature +%%% +%%% * F: Along the lines of the discussion with Martin Erwig add support for +%%% keywords etc (see the emails) +%%% +%%% * B: If we have as input +%%% +%%% \ +%%% +%%% there won't be a `\hsap' inserted!! (Can this be solved by using +%%% \obeylines in \<...\>?) +%%% +%%% * B: A \relax is needed after a & if it immediately followed by a \hsbody{} +%%% (See TeXbook, S.240) +%%% +%%% * F: Implement a \hstext{...} as \(\text{...}\). +%%% +%%% * We would like hswhere* etc that are like haskell* (\hsalign already +%%% supports this, ie, there is a \hsalign*). +%%% +%%% * Star-Versions of if, let etc that use a single line layout (maybe not +%%% with star, because of the above). +%%% +%%% * Support for enforcing and prohibiting breaks in `haskell' displays. +%%% +%%% * Comments in a let-in should be aligned in the same way for the bindings +%%% and the body. +%%% +%%% * It would be nice to have different styles (indentation after in of +%%% let-in or not) etc; either to be set with a package option or in the +%%% preamble (the latter probably makes more sense). +%%% +%%% * Literate programming facility: Variant of the `haskell' env (maybe +%%% `hschunk', which is named and can be used in other chunks). But maybe +%%% it is not necessary to provide a chunk-based reordering mechanism, +%%% because most of the Haskell stuff can be in any order anyway... +%%% Important is to provide a way to define visually pleasing layout +%%% together with the raw Haskell form for program output. (Maybe `haskell*' +%%% as Haskell env that outputs its contents?) +%%% + +%% Initialization +%% ============== + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{haskell}[2000/10/05 v1.0e Chilli's Haskell Style] + + +%% Parameters +%% ========== + +\newskip\hsmargin +\hsmargin\leftmargini + + +%% Main macros and environments +%% ============================ + +% applications +% +\newcommand{\hsap}{% % application by juxtaposition + \unskip\mskip 4mu plus 1mu} % only the last \hsap counts + +% commands to start and stop setting spaces as \hsap +% +{\obeyspaces\gdef\@hsSpaceToApp{\obeyspaces\let =\hsap}} % spaces matter!!! +{\obeyspaces\gdef\@hsNormalSpace{\let =\space}} + +% commands to start and stop treating numbers specially, ie, we don't want +% them to be affected by font changing commands in Haskell contexts as this +% would give italic numerals; the trick is to redefine their math code such +% that they go into math class 0 and thus don't change families (cf. `The +% TeXbook', Chapter 17, pp152) +% +\newcommand{\@hsRmNumbers}{% + \mathcode`0="0030 + \mathcode`1="0031 + \mathcode`2="0032 + \mathcode`3="0033 + \mathcode`4="0034 + \mathcode`5="0035 + \mathcode`6="0036 + \mathcode`7="0037 + \mathcode`8="0038 + \mathcode`9="0039 + } +\newcommand{\@hsNormalNumbers}{% + \mathcode`0="7030 + \mathcode`1="7031 + \mathcode`2="7032 + \mathcode`3="7033 + \mathcode`4="7034 + \mathcode`5="7035 + \mathcode`6="7036 + \mathcode`7="7037 + \mathcode`8="7038 + \mathcode`9="7039 + } + +% Save the bindings of the standard math commands +% +% This is somewhat subtle as we want to able to enter the original math mode +% within Haskell mode and we have to ensure that the different opening +% commands are matched by the correct versions of the closing commands. +% +\let\@hsmathorg=\( +\let\@hsmathendorg=\) +\let\hs@crorg=\\ +\newcommand{\@hsmath}{% + \relax\hbox\bgroup + \@hsNormalSpace + \@hsNormalNumbers + \let\(=\@hsmathorgx + \let\)=\@hsmathend + \def\\{\hs@crorg}% + \@hsmathorg + } +\newcommand{\@hsmathend}{% + \@hsmathendorg + \egroup + } +\newcommand{\@hsmathorgx}{% + \relax\@hsmathorg + \let\)=\@hsmathendorg + } + +%% Typesetting of Haskell +%% ====================== + +% Inline Haskell phrases are delimited by `\<' and `\>'. +% +% Note: `\>' is only locally redefined. +% +\newcommand{\<}{% + \@hsmathorg + \mathit\bgroup + \@hsSpaceToApp + \@hsRmNumbers + \let\>=\@endhs + \let\(=\@hsmath + \def\\{\cr} % for Haskell alignments + } +\newcommand{\@endhs}{% + \egroup + \@hsmathendorg + } + +% Displayed Haskell (environment `haskell' and `haskell*') +% +% There are two kind of preambles for \halign: \hs@preambleNorm is for +% `amsmath' style alignments and \hs@preambleStar for `equation' style +% alignments (but with an unbound number of columns to its right) +% +% We need #### to get a ## in the \edef building the \halign command. +% +% first the preambles (also used in \hs@align below): +% +\def\hs@preambleNorm{% + \noexpand\<####\unskip\noexpand\>\hfil&&\noexpand% + \<{}####\unskip\noexpand\>\hfil} +\def\hs@preambleStar{% + \noexpand\<####\unskip\noexpand\>\hfil&\hfil\noexpand% + \<{}####\unskip{}\noexpand\>\hfil&&\noexpand\<{}####\noexpand\>\hfil} +% +% the environments: +% +\newenvironment{haskell}{% + \@haskell\hs@preambleNorm}{% + \@endhaskell + } +\newenvironment{haskell*}{% + \@haskell\hs@preambleStar}{% + \@endhaskell + } +% +% auxiliary definition getting the preamble as its first argument and starting +% the environment: +% +\def\@haskell#1{% + \bgroup + \vspace\abovedisplayskip + \let\(=\@hsmath % Important when `\(' occurs after `&'! + \edef\@preamble{% + \halign\bgroup\hskip\hsmargin#1\cr} + \@preamble + } +% +% Auxiliary definition ending environment: +% +\def\@endhaskell{% + \crcr\egroup + \vspace\belowdisplayskip + \egroup\noindent\ignorespaces\global\@ignoretrue% + } + +% single line comment and keyword style +% +\newcommand{\hscom}[1]{% + \relax\(\quad\textnormal{--- #1}\)} +\newcommand{\hskwd}[1]{% + \mathbf{#1}} + +% informal description +% +\newcommand{\hsinf}[1]{% + \(\langle\textnormal{#1}\rangle\)} + +% literals and some special symbols +% +\newcommand{\hschar}[1]{\textrm'\mathrm{#1}\textrm'} % character literals +\newcommand{\hsstr}[1]{"\mathrm{#1}"} % strings literals +\newcommand{\hsfrom}{\leftarrow} % <- + +% aligned subphrases +% +% check for an optional star and combine prefix (in #1) with one of the two +% preambles (with star means to center the material between the first and +% second &) +% +\def\hs@align#1{% + \@ifstar + {\hs@align@pre{#1\hs@preambleStar}}% + {\hs@align@pre{#1\hs@preambleNorm}}% + } +% +% test for optional argument; #1: preamble +% +\def\hs@align@pre#1{% + \@testopt{\hs@align@prealign#1}t} +% +% got all arguments, now for the real code; #1: preamble; #2: alignment; +% #3: body (the material set by the \halign) +% +\def\hs@align@prealign#1[#2]#3{% + \relax\( + \edef\@preamble{% + \halign\bgroup#1\cr} + \if #2t\vtop \else \if#2b\vbox \else \vcenter \fi\fi + \bgroup% + \@preamble + #3% + \crcr\egroup% + \egroup\) + } +% +% user-level command: alignment without a prefix +% +\newcommand{\hsalign}{% + \relax + \hs@align\relax% + } + +% subphrase breaking the surrounding alignment being flushed left +% +\newcommand{\hsnoalign}[1]{% + \noalign{% + \hs@align{\hskip\hsmargin}{#1}% + }% + } + +% body expression breaking the surrounding alignment +% +% * setting \hsmargin to 0pt within the preamble (and _after_ it is used in +% the preamble) is crucial, as we want \hsmargin only to be applied in +% _outermost_ alignments +% +\newcommand{\hsbody}[1]{% + {}\\ + \noalign{% + \hs@align{\hskip\hsmargin\quad\hsmargin0pt}{#1}% + }% + } + + +%% Defining commands for use in the Haskell mode +%% ============================================= +%% +%% We use some of the low-level machinery defined in LaTeX's source file +%% `ltdefns.dtx'. +%% +%% \hscommand is similar to \newcommand, but there is no *-version. +%% +%% We use our own definitions here to insert a strategic `\relax' (see below) +%% and to obey spaces within the bodies of Haskell definitions. + +\newcommand{\hscommand}[1]{\@testopt{\hs@newcommand#1}0} +\def\hs@newcommand#1[#2]{% + \obeyspaces % spaces count in Haskell macros + \@ifnextchar [{\hs@xargdef#1[#2]}% + {\hs@argdef#1[#2]}} + +% All this trouble only to be able to add the `\relax' into the expansion +% process. If we don't that, commands without optional arguments when +% invoked after an alignment character & don't work properly (actually, the +% \obeyspaces doesn't work). I am sure that has to do with the scanning for +% \omit etc in \halign (TeXbook, p240), but I don't understand yet why it +% is problematic in this case. +% +% Furthermore, we switch off \obeyspaces in the end. +% +\long\def\hs@argdef#1[#2]#3{% + \@ifdefinable#1{% + \expandafter\def\expandafter#1\expandafter{% + \relax % in order to stop token expansion after & + \csname\string#1\expandafter\endcsname}% + \expandafter\@yargdef + \csname\string#1\endcsname + \@ne + {#2}% + {#3}}% + \catcode`\ =10% % stop obeying spaces now + } + +% Switch off \obeyspaces in the end. +% +\long\def\hs@xargdef#1[#2][#3]#4{% + \@ifdefinable#1{% + \expandafter\def\expandafter#1\expandafter{% + \expandafter + \@protected@testopt + \expandafter + #1% + \csname\string#1\expandafter\endcsname + {#3}}% + \expandafter\@yargdef + \csname\string#1\endcsname + \tw@ + {#2}% + {#4}}% + \catcode`\ =10% % stop obeying spaces now + } + + +%% Abbreviations +%% ============= + +% infix operators +% +\newcommand{\hsapp}{\mathbin{+\mkern-7mu+}} +\newcommand{\hsifix}[1]{\mathbin{\string`#1\string`}} + +% let expression +% +\hscommand{\hslet}[3][t]{% + \hsalign[#1]{% + \hskwd{let}\\ + \quad\hsalign{#2}\\ + \hskwd{in}\\ + #3 + }% + } + +% if expression +% +\hscommand{\hsif}[4][t]{% + \hsalign[#1]{% + \hskwd{if} #2 \hskwd{then}\\ + \quad\hsalign{#3}\\ + \hskwd{else}\\ + \quad\hsalign{#4}% + }% + } + +% case expression +% +\hscommand{\hscase}[3][t]{% + \hsalign[#1]{% + \hskwd{case} #2 \hskwd{of}\\ + \quad\hsalign{#3}% + }% + } + +% where clause +% +% * it is important to take the \quad into the preamble, so that nested +% \noaligns can break it +% +\hscommand{\hswhere}[1]{% + \hsbody{% + \hskwd{where}\\ + \hs@align{\quad}{#1}% + }% + } + +% do expression +% +\hscommand{\hsdo}[2][t]{% + \hsalign[#1]{% + \hskwd{do}\\ + \quad\hsalign{#2}\\ + }% + } + + +%% Extensions for Distributed Haskell (Goffin) +%% =========================================== +%% +%% These definitions may change in the future. + +\hscommand{\hsunif}{\mathbin{:=:}} +\hscommand{\hsalias}{\mathrel{\sim}} +\hscommand{\hsoutof}{\twoheadleftarrow} +\hscommand{\hsinto}{\twoheadrightarrow} +\hscommand{\hsparc}{\binampersand} +\hscommand{\hsseq}{\Longrightarrow} +\hscommand{\hsex}[2]{{\hskwd{ex} #1 \hskwd{in} #2}} + +\hscommand{\hsexin}[3][t]{% + \hsalign[#1]{% + \hskwd{ex} #2 \hskwd{in}\\ + \quad\hsalign{#3}\\ + }% + } + +\hscommand{\hschoice}[2][t]{% + \hsalign[#1]{% + \hskwd{choice}\\ + \quad\hsalign{#2}\\ + }% + } + + hunk ./docs/hs-plugins.1 1 +.TH HS-PLUGINS 1 2005-03-26 "hs-plugins version 0.9.8" "User Manual" + +.SH NAME +hs-plugins \- dynamic linker library for Haskell + +.SH DESCRIPTION +.ds c \fIhs-plugins\fP +\*c is a library for loading plugins written in Haskell into an +application at runtime. It also provides a mechanism for (re)compiling +Haskell source at runtime. Thirdly, a combination of runtime compilation +and dynamic loading provides a suite of eval functions. Values exported +by plugins are transparently available to Haskell host applications, and +bindings exist to use Haskell plugins from at least C and Objective C +programs. hs-plugins requires ghc-6.2.2 or greater. + +.SH DOCUMENTATION +The hs-plugins user manual is distributed in html format, and may be +found at + +.SH BUGS +Bug reports, and any other feedback, should be sent to +Don Stewart +.SH COPYRIGHT +Copyright \(co 2004-2005 Don Stewart +.PP +The hs-plugins library modules are distributed under the terms of the +LGPL. +.SH "SEE ALSO" +.BR dlopen (3) + +.SH AUTHOR + +This manual page was written by Don Stewart, based on the man page for +cpphs (written by Ian Lynagh). + + hunk ./docs/hs-plugins.hdir 1 +hs-plugins hunk ./docs/hs-plugins.tex 1 +\documentclass{article} + +\usepackage{url} +\usepackage{tex2page} + +% typeset math as ascii +\htmlmathstyle{no-in-text-image no-display-image} + +% something other than | +\verbescapechar\& + +\cssblock +h1 {font-size: 16pt} +h2 {font-size: 15pt} +\endcssblock + +% color of verbatim elements +\cssblock +.verbatim {color: grey20} + +.scheme .variable {color: grey20} +.scheme .keyword {color: navy} +.scheme .builtin {color: maroon} +\endcssblock + +% add some extra keywords +\scmkeyword{as case class data default deriving do else hiding if} +\scmkeyword{import in infix infixl infixr instance let module newtype} +\scmkeyword{of qualified then type where forall \\ } +\scmbuiltin{: :: = -> <- @ ~ => - >>= >> } + +\newcommand{\code}[1]{{\texttt{#1}}} +\newcommand{\hsplugins}{{\texttt{hs-plugins}}} + +\title{hs-plugins\\ + Dynamically Loaded Haskell Modules} + +\author{\urlh{http://www.cse.unsw.edu.au/~dons}{Don Stewart}} + +\begin{document} + +\maketitle + +\medskip +% +{\htmlonly \textbf{Download \endhtmlonly +\urlh{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.8.tar.gz} + {version 0.9.8}} +% +\medskip + +\hsplugins{} is a library for loading plugins written in Haskell into an +application at runtime. It also provides a mechanism for (re)compiling +Haskell source at runtime. Thirdly, a combination of runtime compilation +and dynamic loading provides a suite of \code{eval} functions. Values +exported by plugins are transparently available to Haskell host +applications, and bindings exist to use Haskell plugins from at least C +and Objective C programs. \hsplugins{} currently requires ghc-6.2.2. + +\medskip + +% grr. double spaced. + +\tableofcontents + +\newpage + +\section{Download} + +\begin{itemize} + +\item +Download the latest stable release:\\ +\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.8.tar.gz} + + +\item +Nightly cvs src snapshots are available at:\\ +\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/snapshots/} + + +\item +A tarball of the document you are reading:\\ +\url{http://www.cse.unsw.edu.au/~dons/hs-plugins/hs-plugins.html.tar.gz} + + +\item +A postscript version of the document you are reading:\\ +\url{http://www.cse.unsw.edu.au/~dons/hs-plugins/hs-plugins.ps.gz} + + +\item +A paper on interesting uses of \hsplugins{} to enable Haskell to be used +as an application extension language:\\ +\url{http://www.cse.unsw.edu.au/~dons/hs-plugins/paper} + +\end{itemize} + +It is known to run on \code{i386-\{linux,freebsd,openbsd\}}, +\code{ia64-linux}, \code{sparc-solaris2} and \code{powerpc}'s running +Mac OSX. It should run on any machine with a working GHCi +implementation. + +\section{History} + +\begin{itemize} + \item v0.9.8 + \begin{itemize} + \item Fix bug in .hi parsing. + \item Add reloading of packages. + \item Fix bug in canonical module names + (fixing problems with "Foo.o" and "./Foo.o" + \item Fix for hierarchical names, don't guess them, + read them from the .hi file. + \item Add new varients of load. + \item Fix bug in makeAll, such that dependent module + changes were not noticed. + \item Add varient of eval:\code{ unsafeEval\_}, returing + Either. + \item Better, bigger testsuite. + \item Better api. + \end{itemize} + + \item Septemeber 2004. + \begin{itemize} + \item makeAll + \item Better return type for make. + \end{itemize} + + \item Mid August 2004, v0.9.6 release. + \begin{itemize} + \item More portable, thanks to debugging by Niklas Broberg. + \item Other small fixes to the interfaces. + \item Provides a runtime-generated printf. + \end{itemize} + + \item Mid July 2004, added new pdynload strategy. + + \item Mid-June 2004, v0.9.5 release. + \begin{itemize} + \item dynamic typing is working + + \item static typing of interfaces is working + + \item Adds \code{eval}, and \code{hs\_eval} + + \item bugs fixed. + \end{itemize} + + \item Early-June 2004, v0.9.4 release. + \begin{itemize} + + \item Adds a .hi file parser. We use this to work out + plugin dependencies directly, meaning no more + \code{.dep} files or \code{ghcp}. + + \item It also adds a package.conf parser, meaning we + can properly handle packages that either aren't stored + in the normal location, don't have a canonical name, + or are found using a -package-conf argument. Thanks to + Sean for this work. + + \item the interface to load() has changed to allow a + list of package.conf files to search for packages. + + \item the interace to make() has changed, so that you + can get back any stderr output produced during plugin + compilation. + + \item It solves a bug whereby a package that is + required by another package would not be loaded unless + the plugin itself depended on this indirect package. + + \item more stable, more examples. + \end{itemize} + + \item May 2004, v0.9.3 released, adding support for dependency + conflict resolution between multiple plugins. Several plugins with + shared dependencies can now be safely loaded at once. --prefix is now + respected in ./configure. Thanks to Sean for this patch. + + \item v0.9.2 change licence to LGPL + + \item v0.9.1 expand on the documentation + + \item v0.9 released, initial source release + +\end{itemize} + +\section{Acknowledgements} + +\begin{itemize} + +\item Andr\'e Pang's \code{runtime\_loader} was the inspiration and basis +of the dynamic loader (\url{http://www.algorithm.com.au}). +\hsplugins{} has benefited from many discussions with him, +particularly to do with dependency checking and dynamic typing, and +bug reports. Andr\'e wrote an objective C binding to hs-plugins, and +helped with the design of eval(). He also fixed GHC so we could load +the dynamic loader dynamically. + +\item Sean Seefried (\url{http://www.cse.unsw.edu.au/~sseefried}) was +the first user of \hsplugins{} and his code and feedback have helped +make the library much more useful and powerful. + +\item Manuel Chakravarty's \code{take} system provided the basis for +\code{make}, and helped with several issues to do with safety of +plugins, apis and the applications that use them. +Manuel also helped with the design of eval(), and on how to +successfully evaluate polymorphic functions using rank-N types. + +\item Simon Marlow helped with several issues to do with linking and +loading static and dynamic code, and provided many useful suggestions. + +\item Hampus Ram's dynamic loader +(\url{http://www.dtek.chalmers.se/~d00ram/dynamic/}) provided the +design of the state maintained by the loader, and for thread safety +issues relating to this. + +\item Shae Erisson provided several insights into more powerful uses +of the library. Thanks to everyone on \#haskell who provided +discussion about the library. + +\item Malcolm Wallace's \code{hmake} provided some useful insights in +how to compile Haskell source in a way that makes it appear like an +interpreter, used in the interactive environment: \code{plugs}. + +\item Niklas Broberg helped a lot by testing, and providing feedback for +the new make and load API. Thanks Niklas. + +\item Finally, thanks to everyone who has worked on GHC and its +libraries: for GHCi, the .hi interface parser, the package system, and +all the other code the \hsplugins{} depends on. + +\end{itemize} + +\newpage + +\section{Overview} + +\hsplugins{} is a library for compiling and loading Haskell code into a +program at runtime. It allows you to write a Haskell program (which may +be spread over multiple modules) and have an application (implemented in +any language with a Haskell FFI binding, including Haskell) load your +code at runtime, and use the values found within. + +\hsplugins{} provides 3 major features: +% +\begin{itemize} + \item a dynamic loader, + \item a compilation manager, and + \item a Haskell evaluator +\end{itemize} + +The \emph{dynamic loader} loads objects into the address space of an +application, along with any dependencies the plugin may have. The +loader is a binding to the GHC loader, which does single object +loading. GHC also performs the necessary linking of new objects into +the running process. On top of the GHC loader is our Haskell layer +that arranges for module and package dependencies to be found prior to +loading individual modules. + +The \emph{compilation manager} is a \code{make}-like system for +compiling Haskell source code into a form suitable for loading +dynamically. While plugins are normally thought of as strictly object +code, there are a variety of scenarios where it is desirable to be +able to inspect the source code of a plugin, or to be able to +recompile a plugin at runtime. The compilation manager fills this +role. It is particularly useful in the implementation of \code{eval}, +and \code{printf}. + +The \emph{evaluator}, \code{eval}, is a client of the loader and +compilation manager. When passed a string of Haskell code, it compiles +the string to object code, loads the result, and returns a Haskell +value representing the compiled string to the caller. It can be +considered a Haskell interpreter, implemented as a library. + +\section{Dynamic Loader} + +The interface to the \hsplugins{} library can be divided into a number +of sections representing the functional units of the library. +Additionally, depending on the level of trust the application places +in the plugins, a variety of additional checks can be made on the +plugin as it is loaded. The levels of type safety possible are +summarised at the end of Section \ref{sec:compilation-manger} section. +The dynamic loader is available by using \code{-package plugins}. + +\subsection*{Interface} +% +\begin{quote} +\scm{ +load :: FilePath + -> [FilePath] + -> [PackageConf] + -> Symbol + -> IO (LoadStatus a) +} + +\scm{ +load_ :: FilePath + -> [FilePath] + -> Symbol + -> IO (LoadStatus a) +} + +\scm{ +data LoadStatus a + = LoadSuccess Module a + | LoadFailure Errors +} +\end{quote} +% +Example: +% +\begin{quote} +\scm{ +do mv <- load "Plugin.o" ["api"] [] "resource" + case mv of + LoadFailure msg -> print msg + LoadSuccess _ v -> return v +} +\end{quote} +% +This is the basic interface to the dynamic loader. Load the object file +specified by the first argument into the address space (the library will +preload any module or package dependencies). The second argument is an +include path to any additional objects to load (possibly the API of the +plugin). The third argument is a list of paths to any user-defined +\code{package.conf} files, specifying packages unknown to the GHC +package system. \code{Symbol} is a string specifying the symbol name you +wish to lookup. \code{load} returns a \code{LoadStatus} value representing +failure, or an abstract representation of the module (for calls to +\code{unload} or \code{reload}) with the symbol as a Haskell value. The +value returned must be given an explicit type signature, or provided +with appropriate type constraints such that GHC can determine the +expected type returned by \code{load}, as the return type is notionally +polymorphic. + +\code{load\_} is provided for the common situation where no user-defined +package.conf files are required. + +\begin{quote} +\scm{ +dynload :: Typeable a + => FilePath + -> [FilePath] + -> [PackageConf] + -> Symbol + -> IO (LoadStatus a) +} +\end{quote} +% +Example: +% +\begin{quote} +\scm{ +do mv <- dynload "Plugin.o" ["api"] ["plugins.conf.inplace"] "resource" + case mv of + LoadFailure msg -> print msg + LoadSuccess _ v -> putStrLn v +} +\end{quote} +% +\code{dynload} is a safer form of \code{load}. It uses dynamic types +to perform a check on the value returned by \code{load} at runtime, to +ensure that it has the type the application expects it to have. +\code{pdynload} is on average 7\% slower than an unchecked load. + +In order to use \code{dynload}, the symbol the plugin exports must be +of type \code{AltData.Dynamic:Dynamic}. (See the \code{AltData} library +distributed with \hsplugins{}, and the \hsplugins{} +\code{examples/dynload} directory. References to \code{Typeable} and +\code{Dynamic} refer to the \hsplugins{} reimplementation of these +libraries. \code{AltData.Dynamic} is used at the moment, as there is a +limitation in the existing Data.Dynamic library in the presence of +dynamic loading. This will be fixed soon). + +The value wrapped up in the \code{Dynamic} must be an instance of +\code{AltData.Typeable}. If the value exported by the plugin \emph{is} +of type \code{Dynamic}, and the value wrapped by the \code{Dynamic} +does not match the type expected of it by the application, +\code{dynload} will return \code{Nothing}, indicating that the plugin +is not typesafe with respect to the application. If the value passes +the typecheck, \code{dynload} will return \code{LoadSuccess}. If the value +exported by the plugin is \emph{not} of type \code{Dynamic}, +\code{dynload} will crash---this is a limitation of the existing +\code{Dynamic} library, it can only type-check \code{Dynamic} values. +Additionally, Data.Dynamic is limited to monomorphic types, or must be +wrapped inside a rank-N type to hide the polymorphism from the +typechecker. This is a bit cumbersome. An alternative typesafe +\code{load} is available via the \code{pdynload} interface, which is +able to enforce the type of the plugin using GHC's type inference +mechanism, and is not restricted in its expressiveness (at the cost of greater load +times): + +\begin{quote} +\scm{ +pdynload :: FilePath + -> [FilePath] + -> [PackageConf] + -> Type + -> Symbol + -> IO (LoadStatus a) +} +\end{quote} +% +Example: +% +\begin{quote} +\scm{ +do v <- pdynload "Plugin.o" ["api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "yay!" + _ -> putStrLn "type error" +} +\end{quote} +% +\code{pdynload} is a replacement for \code{dynload}, which provides a +solution to the various problems caused by the existing dynamics +library in Haskell. Rather than use normal dynamics, which constrain +us to monomorphic types only (or rank-N types), it instead uses GHC's +type inference to unify the plugin's export value with that provided +by the api (via its .hi file). It is a form of \emph{staged type inference} +for module interfaces, allowing plugins to use any type definable in Haskell. +\code{pdynload} is like \code{dynload}, but requires a new \code{Type} +argument. This can be considered a type annotation on the value the plugin +should be constrained to. + +The type of the plugin's resource field must be equivalent to the +\code{Type}. Prior to loading the object, \code{pdynload} generates a +tiny Haskell source file containing, for example: +% +\begin{quote} +\scm{ +module APITypeConstraint where +import qualified API +import qualified Plugin + +_ = Plugin.resource :: API.Interface +} +\end{quote} +% +It then calls GHC's type checker on this file, which runs the full +Haskell type inference machinery. If the file typecheckes, then the +plugin type is correct, and the plugin is safe to load, otherwise it +is an error. + +Because we use the full Haskell type checker, we can have a form of +dynamic typechecking, on any type expressable in Haskell. A plugin's +value may, for example, have class constraints -- something not +checkable using the standard Dyanmic type. The cost is that +\code{pdynload} is roughly 46\% slower than an unchecked load. + +\begin{quote} +\scm{ +unload :: Module -> IO () +} +\end{quote} + +Unload an object, \emph{but not its dependencies} from the address +space. + +\begin{quote} +\scm{ +reload :: Module -> Symbol -> IO (LoadStatus a) +} +\end{quote} + +Unload, and then reload a module that must have been previously +loaded. Doesn't reload the dependencies. \code{reload} is useful in +conjunction with \code{make}---a call to \code{reload} can be +performed if \code{make} has recompiled the plugin source. + +Additionally, some support is provided to manipulation of +libraries of Haskell modules (usually known as packages): + +\begin{quote} +\scm{ +loadPackage :: String -> IO () + +unloadPackage :: String -> IO () + +loadPackageWith :: String -> [PackageConf] -> IO () +} +\end{quote} + +\code{loadPackage} explcitly pulls in a library (which must be visible +in the current package namespace. \code{unloadPackage} unloads it. +\code{loadPackageWith} behaves like \code{loadPackage}, but you are able +to supply extra package.confs to augment the library search path. + +Examples: +\begin{quote} +\scm{ +do loadPackageWith "yi" ["yi.conf"] + unloadPackage "yi" +} +\end{quote} + +\newpage + +\section{Compilation Manager} + +The compilation manager is the system by which Haskell source code is +compiled to object code suitable for loading. + +\subsection*{Interface} + +\begin{quote} +\scm{ +make :: FilePath + -> [Arg] + -> IO MakeStatus + +makeAll :: FilePath + -> [Arg] + -> IO MakeStatus + +data MakeStatus + = MakeSuccess MakeCode FilePath + | MakeFailure Errors + +data MakeCode = ReComp | NotReq +} +\end{quote} + +Compile a Haskell source file to an object file, with any arguments +specified in the argument list passed through to GHC. Returns the +build status. + +\code{make} generates a GHC \code{.hi} file containing a list of +package and objects that the source depends on. Subsequent calls to +\code{load} will use this interface file to load module and library +dependencies prior to loading the object itself. \code{makeAll} also +recursively compiles any dependencies it can find using GHC's +\code{--make} flag. + +\begin{quote} +\scm{ +merge :: FilePath -> FilePath -> IO MergeStatus + +mergeTo :: FilePath -> FilePath -> FilePath -> IO MergeStatus + +data MergeStatus + = MergeSuccess MergeCode Args FilePath + | MergeFailure Errors + +type MergeCode = MakeCode +} +\end{quote} + +The merging operation is extremely useful for providing extra default +syntax. An EDSL user then need not worry about declaring module names, +or having required imports. In this way, the stub file can also be +used to provide syntax declarations that would be inconvenient to +require of the plugin author. \code{merge} will include any import and +export declarations written in the stub, as well as any module name, +so that plugin author's need not worry about this compulsory syntax. +Additionally, if a plugin requires some non-standard library, which +must be provided as a \code{-package} flag to GHC, they may specify +this using the non-standard \code{GLOBALOPTIONS} pragma. Options +specified in the source this way will be added to the command line. +This is useful for users who wish to use GHC flags that cannot be +specified using the conventional \code{OPTIONS} pragma. + +\begin{quote} +\scm{ +makeWith :: FilePath + -> FilePath + -> [Arg] + -> IO MakeStatus +} +\end{quote} + +This is a variety of \code{make} that first calls \code{merge} to +combine the plugin source with a syntax stub. The result is then +compiled. This is the preferred interface to EDSL authors who wish to +add extra syntax to a user's source. It is important to note that the +module and types from the second file argument are used to override +any of those that appear in the first argument. For example, consider +the following source files: + +\begin{quote} +\scm{ +module A where + +a :: Integer +a = 1 +} +\end{quote} + +\begin{quote} +\scm{ +module B where + +a :: Int +} +\end{quote} + +Calling \code{makeWith "A" "B" []} will merge the module name and types +from module B into module A, generating a third file: + +\begin{quote} +\scm{ +{-# LINE 1 "A.hs" #-} +module MxYz123 where + +{-# LINE 3 "B.hs" #-} +a :: Int +{-# LINE 4 "A.hs" #-} +a = 1 +} +\end{quote} + +Leading to the desired result that we can ignore user-supplied module +names and types. Knowing the module name, in particular, is important +for dynamic loading, which requires the module name be known when +searching for symbols. + +\subsection*{Levels of Safety} + +The normal dynamic loader, using \code{load} on object files only, +places full trust in the author of the plugin to provide a type-safe +object file, containing valid code. This can be mitigated somewhat via +the use of \code{make} to ensure that the plugin is at least Haskell +code that is well-typed internally (if we trust GHC to compile it +correctly). + +If we trust the user to provide an interface of \code{Dynamic} type, we +can check the plugin type at runtime, but the plugin's value must be +\code{Typeable}, which restricts it to be a monomorphic type (or to +using rank-N tricks). + +The greatest safety can be obtained by using \code{pdynload}, at the +cost of increased load times. \code{pdynload} essentially performs full +type inference on the plugin interface at runtime. The type safety of +the plugin, using \code{pdynload}, is then as safe as if the plugin was +statically compiled into the application. It does not provide any +\emph{further} safety than exists in static compilation. For example, it +does not preclude the use of (evil) \code{unsafeCoerce\#} to defeat +type-checking, either statically or at runtime. An extensive discussion +of type safe plugin loading is available in the \hsplugins{} paper +\urlh{http://www.cse.unsw.edu.au/~dons/hs-plugins/paper}{here}. + +\newpage + +\section{Eval.Haskell} + +\code{eval}, and its siblings, provide a mechanism to compile and run +Haskell code at runtime, in the form of a String. It is provided as a +separate package to the plugins package, and needs to be linked +against using \code{-package eval}. The general framework is that the +string is used to create a plugin source file, which is compiled and +loaded, and type checked against its use. The resulting value is +returned to the caller. It resembles the \code{eval} primitives of +scripting languages. + +\subsection*{Interface} + +\begin{quote} +\scm{ +eval :: Typeable a => String -> [Import] -> IO (Maybe a) +} +\end{quote} + +\code{eval} takes a string, and a list of import module names, and +returns a \code{Maybe} value. \code{Nothing} means the code did not +compile. \code{Just v} gives you \code{v}, the result of evaluating +your code. It is interesting to note that \code{eval} has the type of +an interpreter. The \code{Typeable} constraint is used to type check +the evaluated code when it is loaded, using \code{dynload}. The +existing \code{Data.Dynamic} library requires that only monomorphic +values are \code{Typeable}, so in order to evaluate polymorphic +functions you need to wrap them up using rank-N types. Some +examples: +% +\begin{quote} +\scm{ +import Eval.Haskell + +main = do i <- eval "1 + 6 :: Int" [] :: IO (Maybe Int) + if isJust i then putStrLn (show (fromJust i)) else return () +} +\end{quote} + +When executed this program calls \code{eval} to compile and load the +simple arithmetic expression, returning the result, which is +displayed. If the value loaded is not of type \code{Int}, +\code{dynload} will throw an exception. + +The following example, due to Manuel Chakravarty, shows how to +evaluate a polymorphic function. Polymorphic values are not easily +made dynamically typeable, but this example shows how to do it. The +module \code{Poly} is imported as the second argument, providing the +type of the polymorphic function: +% +\begin{quote} +\scm{ +import Poly +import Eval.Haskell + +main = do m_f <- eval "Fn (\\x y -> x == y)" ["Poly"] + when (isJust m_f) $ do + let (Fn f) = fromJust m_f + putStrLn $ show (f True True) + putStrLn $ show (f 1 2) +} +\end{quote} +% +And the type of \code{Fn}: +% +\begin{quote} +\scm{ +{-# OPTIONS -fglasgow-exts #-} +module Poly where + +import AltData.Typeable + +data Fn = Fn {fn :: forall t. Eq t => t -> t -> Bool} + +instance Typeable Fn where + typeOf _ = mkAppTy (mkTyCon "Poly.Fn") [] +} +\end{quote} +% +When executed, this program produces: +% +\begin{quote} +\begin{verbatim} +$ ./a.out +True +False +\end{verbatim} +\end{quote} + +We thus get dynamically typeable polymorphic functions. + +\begin{quote} +\scm{ +unsafeEval :: String -> [Import] -> IO (Maybe a) + +unsafeEval_ :: String + -> [Import] + -> [String] + -> [FilePath] + -> IO (Either [String] a) +} +\end{quote} + +Wrapping up polymorphic values can be annoying, so we provide a +\code{unsafeEval} function for people who like to live on the edge, +which dispenses with dynamic typing, relying instead on the +application to provide the correct type annotation on the call to +\code{eval}. If the type loaded by \code{eval} is wrong, +\code{unsafeEval} will crash. However, its lets us remove some +restrictions on what types can be evaluated, which can be useful. + +{unsafeEval\_} lets the application have full control over the import +environment and load flags to the eval call, which is useful for +applications that wish to script themselves, and require specific +modules and packages to be in scope in the eval-generated module. + +This example maps a \code{toUpper} over a list: +% +\begin{quote} +\scm{ +import Eval.Haskell + +main = do s <- unsafeEval "map toUpper \"haskell\"" ["Data.Char"] + when (isJust s) $ putStrLn (fromJust s) +} +\end{quote} + +And here we evaluate a lambda abstraction, applying the result to +construct a tuple. Note the type information that must be supplied in +order for Haskell to type the usage of \code{fn}: +% +\begin{quote} +\scm{ +import Eval.Haskell + +main = do fn <- unsafeEval "(\\(x::Int) -> (x,x))" [] :: IO (Maybe (Int -> (Int,Int))) + when (isJust fn) $ putStrLn $ show $ (fromJust fn) 7 +} +\end{quote} + +\subsection{Foreign Eval} + +A preliminary binding to \code{eval} has been implemented to allow C +(and Objective C) programs access to the evaluator. Foreign bindings +to the compilation manager and dynamic loader are yet to be +implemented, but shouldn't be too hard. An foreign binding to a +Haskell module that wraps up calls to \code{make} and \code{load} +would be fairly trivial. + +At the moment we have an ad-hoc binding to \code{eval}, so that C +programmers who know the type of value that will be returned by +Haskell can call the appropriate hook into the evaluator. If they get +the type wrong, a nullPtr will be returned (so calling Haskell is +still typesafe). The foreign bindings to \code{eval} all return +\code{NULL} if an error occurred, otherwise a pointer to the value is +returned. + +\begin{quote} +\scm{ +foreign export ccall hs_eval_b :: CString -> IO (Ptr CInt) + +foreign export ccall hs_eval_c :: CString -> IO (Ptr CChar) + +foreign export ccall hs_eval_i :: CString -> IO (Ptr CInt) + +foreign export ccall hs_eval_s :: CString -> IO CString +} +\end{quote} + +An example C program for compiling and evaluating Haskell code at +runtime follows. This program calculates a fibonacci number, returning +it as a \code{CString} to the C program: +% +\begin{quote} +\begin{verbatim} +#include "EvalHaskell.h" +#include + +int main(int argc, char *argv[]) +{ + char *p; + hs_init(&argc, &argv); + p = hs_eval_s("show $ let fibs = 1:1:zipWith (+) fibs (tail fibs) in fibs !! 20"); + if (p != NULL) + printf("%s\n",p); + else + printf("error in code\n"); + hs_exit(); + return 0; +} +\end{verbatim} +\end{quote} + +\subsection{Eval.Printf} + +It has been noted that \code{printf} format strings are the concrete syntax +of a string formatting interpreter (over 1000 lines long in libc!). By +combining runtime generation of new Haskell code, with dynamic typing, +it becomes possible to implement a typesafe \code{printf} for Haskell. + +This has already been achieved in at least 3 different ways. A standard +solution (Hinze, Danvey) begins by supplying printf with the abstract +syntax of the formatting string, resolving the issue of the lack of +typing in the raw fmt string. An alternative solution (see Ian Lynagh's +Printf library) uses Template Haskell to transform a printf format +string into a new Haskell function at compile time, however this +requires that the format string is known at compile time. By using +runtime compilation we can take a similar approach, but instead generate +the print function at runtime! To make this safe, we then need to use +dynamic typing to check the newly-generated print function against its +arguments. + +\subsection*{Printf Interface} + +The \code{Printf} library implements a reasonable amount of the C +printf's functionality. + +\begin{quote} +\scm{ +printf :: String -> [Dynamic] -> IO () +} +\end{quote} + +\begin{quote} +\scm{ +sprintf :: String -> [Dynamic] -> IO String +} +\end{quote} + +Because the arguments to printf are of differing types, and the number +of arguments is not known at compile time, we simulate variadic +functions by using a heterogenous list of arguments. A special list +constructor, \code{!}, is provided for this. An example, noting the +syntax for constructing a heterogenous argument list: + +\begin{quote} +\scm{ +import Eval.Printf + +main = do printf "%d\n" $ (42::Int) ! [] + printf "0x%X\n" $ (42::Int) ! [] + printf "%f\n" $ (42.1234 :: Double) ! [] + printf "%c:%c:%c\n" $ 'a' ! 'b' ! 'c' ! [] + printf "%s\n" $ "haskell" ! [] + printf "%010.4f\n" $ (42.1234 :: Double) ! [] + printf "%10.4s\n" $ "haskell" ! [] + printf "%-10.4s\n" $ "haskell" ! [] +} +\end{quote} + +Compiling this program against \code{-package eval}, and running it +produces the following output: +% +\begin{quote} +\begin{verbatim} +42 +0x2A +42.123400 +a:b:c +haskell +00042.1234 + hask +hask +\end{verbatim} +\end{quote} + +If you mismatch the types specified in the format string, and the +types you apply printf to, printf will generate an exception, like so: + +\begin{quote} +\scm{ +import Eval.Printf + +main = printf "%d\n" ("badstring" ! []) +} +\end{quote} + +The above code will generate this error, indicating that you attempted +to apply a string to a function that expected an Int: +% +\begin{quote} +\begin{verbatim} +paprika$ ./a.out +Fail: Type error in dynamic application. +Can't apply function [Char]> to argument <[Char]> +\end{verbatim} +\end{quote} + +Note that this isn't the fastest printf implementation in the world. A +call to printf invokes GHC to transform the printf format string into +a Haskell code fragment, which is compiled and dynamically linked back +into the application, and then applied to its arguments. If you need +to use the same printf function against multiple times, you can save +recompilation, in which case printf runs as fast as other native code. + +Additionally, it only implements the most common modifiers to the +basic conversion specifiers, and they have not all been fully tested. + +\section{RTS Binding} + +The low level interface is the binding to GHC's Linker.c. Therefore, +\hsplugins{} only works on platforms with a working GHCi. This library +is based on code from André Pang's runtime loader. The low level +interface is as follows: + +\begin{itemize} + \item \code{initLinker} \em start the linker up + \item \code{loadObject} \em load a vanilla .o + \item \code{loadPackage} \em load a GHC library and its cbits + \item \code{loadShared } \em load a .so object file + \item \code{resolveObjs} \em and resolve symbols +\end{itemize} + +Additionally, \code{Hi.Parser} provides an interface to a GHC +\code{.hi} file parser. Currently we only parse just the dependency +information, import and export information from \code{.hi} files, but +all the code is there for an application to extract other information +from \code{.hi} files. + +\newpage + +\section{Dynamic Loader Implementation} + +The dynamic loader is the system by which modules, and their +dependencies can be loaded, unloaded or reloaded at runtime, and +through which we access the functions we need. + +At its lowest level, the \hsplugins{} loader is a binding to the GHC +runtime loader and linker. This layer is a direct reimplementation of +Andre Pang's \code{runtime\_loader} (barely any code changed). The +code at this level can only load single modules, or packages/archives +(which are just objects too). Any dependency resolution must be +performed by hand. + +On top of Andre's interface is a more convenient interface through +which user's should interact with the dynamic loader. The most +significant extension to Andre's work is the automatic calculation and +loading of a plugin's package or module dependencies via .hi file +information. It also handles initialisation of the loader, and +retrieval of values from the plugin in a more convenient way. Some +state is also stored in the loader to keep track of which modules and +packages have been loaded, to prevent unnecessary (actually, fatal) +loading of object files and packages already loaded. Thus you can +safely load several plugins at once, that share common dependencies, +without worrying about the dependencies being loaded multiple times. +We also store package.conf information in the state, so we can work +out where a package lives and what it depends on. + +The ability to remember which packages and objects have been loaded is +based on ideas in Hampus Ram's dynamic loader, which has a more +advanced dependency tracking system, with the ability to unload the +dependencies of a plugin. \hsplugins{} doesn't provide ``cascading +unloading''. The advantage \hsplugins{} has over Hampus' loader seems +to be the automatic dependency resolution via vanilla .hi files and +the dynamic recompilation stuff. + +Using \code{load}, any library packages, or any \code{.o} files, that a +plugin depends upon will be automatically loaded prior to loading the +module itself. \code{load} then looks up a symbol from the object file, +and returns the value associated with the symbol as a conventional +Haskell value. It should also be possible to load a GHCi-style \code{.o} +archive of object files this way, although there is currently no way +to extract multple plugin interfaces from a archive of objects. + +The application writer is not required to recalculate dependencies if +the plugin changes, and the plugin author does not need to specify +what dependencies exist, as is required in the lower level interface. +This is achieved by using the dependency information calculated by GHC +itself, stored in .hi files, to work out which modules and packages to +load, and in what order. A plugin in \hsplugins{} is really a pair of +an object file (or archive) and a \code{.hi} file, containing package +and module dependency information. + +The \code{.hi} file is created by GHC when the plugin is compiled, +either by hand or via \code{make}. \code{load} uses a binary parser to +extract the relevant information from the \code{.hi} data. Because the +dependency information is stored in a separate file to the application +that loads the plugin, such information can be recalculated without +having to modify the application. Becaues of this, it was easy to +extend the load to support recompilation of module source, even if +dependencies change, because dependencies are no longer hard-coded +into the application source itself, but are specified by the plugin. + +Assuming we have a plugin exporting some data, ``resource'', with a +record name \code{field :: String}, here is an example call to \code{load}: +% +\begin{quote} +\scm{ +do m_v <- load "Test.o" ["."] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v +} +\end{quote} + +This loads the object file \code{Test.o}, and any packages or objects +\code{Test.o} depends on. It resolves undefined symbols, and returns +from the object file the Haskell value named ``resource'', as the +value ``v''. This must be a value exported by the plugin. We then +retrieve the \code{field} component of \code{v}, and print it out. + +This simple usage assumes that the plugin to load is in the same +directory as the application, and that the api defining the interface +between plugin and application is also in the current directory (hence +the ``.'' in the 2nd argument to \code{load}). + +\subsection*{Dynamically Loading the Dynamic Loader} + +It is also possible to load the \code{plugins} or \code{eval} +libraries in GHC. A couple of recent patches to the linker have made +this possible (available in ghc-6.2.2 or in the head branch). Here, +for example, we load the \code{plugs} interactive environment in GHCi, +and evaluated some code. The source to \code{plugs} is in Appendix +\ref{sec:plugs}. +% +\begin{quote} +\begin{verbatim} +paprika$ ghci -package-conf ../../../plugins.conf.inplace -package eval + ___ ___ _ + / _ \ /\ /\/ __(_) + / /_\// /_/ / / | | GHC Interactive, version 6.3, for Haskell 98. +/ /_\\/ __ / /___| | http://www.haskell.org/ghc/ +\____/\/ /_/\____/|_| Type :? for help. + +Loading package base ... linking ... done. +Loading package altdata ... linking ... done. +Loading package unix ... linking ... done. +Loading package mtl ... linking ... done. +Loading package lang ... linking ... done. +Loading package posix ... linking ... done. +Loading package haskell98 ... linking ... done. +Loading package haskell-src ... linking ... done. +Loading package plugins ... linking ... done. +Loading package eval ... linking ... done. +Prelude> :l Main +Skipping Main ( Main.hs, Main.o ) +Ok, modules loaded: Main. +Prelude Main> main +Loading package readline ... linking ... done. + __ + ____ / /_ ______ ______ + / __ \/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98 + / /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins + / .___/_/\__,_/\__, /____/ Type :? for help +/_/ /____/ + +Loading package base ... linking ... done +plugs> map (\x -> x + 1) [0..10] +[1,2,3,4,5,6,7,8,9,10,11] +plugs> :t "haskell" +"haskell" :: [Char] +plugs> :q +*** Exception: exit: ExitSuccess +Prelude Main> :q +Leaving GHCi. +\end{verbatim} +\end{quote} + +\subsection*{Dynamic Typing} + +Support is also provided to unwrap and check the type of dynamically +typed plugin values (those wrapper in a \code{toDyn}) via +\code{dynload}. This is the same as \code{load}, except that instead +of a returning the value it finds, it unwraps a dynamically typed +value, checks the type, and returns the unwrapped value. This is to +provide further trust that the symbol you are retrieving from the +plugin is of the type you think it is, beyond that trust you have by +knowing that the plugin was compiled against a shared API. By using +\code{dynload} it is not enough for an object file to just have the +same symbol name as the function you require, it must also carry the +\code{Data.Dynamic} representation of the type, too. \code{pdynload} +rectifies most of \code{dynload}'s limitations, but at the cost of +additional running time. + +\section{Compilation Manager Implementation} + +Along side the dynamic loader is the compilation manager. This is a +\code{make}-like system for compiling Haskell source, prior to loading +it. \code{make} checks if a source file is newer than its associated +object file. If so, the source is recompiled to an object file, and a +new dependency file is created, in case the dependencies have changed +in the source. This module can then be loaded. The idea is to allow +EDSL authors to write plugins without having to touch a compiler: it +is all transparent. It also allows us to enforce type safety in the +plugin by injecting type constraints into the plugin source, as has +been discussed eariler. + +The effect is much like \emph{hi} (Hmake Interactive), funnily enough. +An application using both \code{make} and \code{load} behaves like a +Haskell interpreter, using \code{eval}. You modify your plugin, and +the application notices the change, recompiles it (possibly issuing +type errors) and then reloads the object file, providing the +application with the latest version of the code. + +An example: +% +\begin{quote} +\scm{ +do status <- make "Plugin.hs" [] + obj <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "failed" + + m_v <- load obj ["api"] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v +} +\end{quote} + +\code{make} accepts a source file as an argument, and a (usually empty) +list of GHC flags needed to compile the object file. It then checks to +see if compilation is required, and if so, it calls GHC to compile the +code, with and arguments supplied. If any errors were generated by +GHC, they are returned as the third component of the triple. + +Usually it will be necessary to ensure that GHC can find the plugin +API to compile against. This can be done by either making sure the API +is in the same directory as the plugin, or by adding a \code{-i} flag to +\code{make}'s arguments. If the API is created as a ``package'' with a +package.conf file, \code{make} can be given \code{-package-conf} arguments +to the same effect. + +Normally, \code{make} generates the \code{.o} and \code{.hi} files in +the same directory as the source file. This is not always desirable, +particularly for interpreter-like applications. To solve this, you can +pass \code{[''-odir'', path]} as elements of the arg list to +\code{make}, and it will respect these arguments, generating the +object and interface file in the directory specified. GHC's argument +\code{''-o''} is also respected in a similar manner, so you could also +say \code{[''-o'', obj]} for the same effect. + +\code{make} is entirely optional. All user's have to do to use the +loader on its own is make sure they only load object files that also +have a \code{.hi} file. This will usually be the case if the plugin is +compiled with GHC. + +\subsection*{makeWith} + +\code{makeWith} merges two source files together, using the function +and value declarations from one file, with any syntax in the second, +creating a new third source file. It then compiles this source file +via \code{make}. + +This function exists as a benefit to EDSL authors and is related to +the original motivation for \hsplugins{}, as a .conf file language +library. Configuration files need to be clean and simple, and you +can't rely, or trust, the user to get all the compulsory details +correct. So the solution is to factor out any compulsory syntax, such +as module names, imports, and also to provide a default instance of +the API, and store this code in a separate file provided by the +application writer, not the user. \code{makeWith} then merges +whatever the user has written, with the syntax stub, generating a +complete Haskell plugin source, with the correct module names and +import declarations. We also ensure the plugin only exports a single +interface value while we are here. + +\code{makeWith} thus requires a Haskell parser to parse two source files +and merge the results. We are merging abstract syntax here. This is +implemented using the Language.Haskell parser library. Unfortunately, +this library doesn't implement all of GHC's extensions, so if you wish +to use \code{makeWith} you can only write Haskell source that can be +parsed by this library, which is just H98 and a few extensions. This +is another short coming in the current design that will be overcome +with \code{-package ghc}. Remember, however, for normal uses of +\code{make} and \code{load} you are unrestricted in what Haskell you use. +This is the same restriction present in happy, the Haskell parser, +placed on the code you can provide in the \code{.y} source. + +\code{makeWith} also makes use of line pragmas. If the merged file +fails to compile, the judicious use of line number pragmas ensure that +the user receives errors messages reported with reference to their +source file, and not line number in the merged file. This is a +property of the Language.Haskell parser that we can make use of. + +An example of \code{makeWith}: +% +\begin{quote} +\scm{ +do status <- makeWith "Plugin.in" "Plugin.stub" [] + obj <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess _ o -> return o + m_v <- load obj [apipath] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v +} +\end{quote} + +We combine the user's file (\code{Plugin.in}) with a stub of syntax +generating a new, third Haskell file in the default tmpdir. This is +compiled as per usual, producing object and interface files. The +object is then loaded, and we extract the value exported. + +Using \code{makeWith} it is possible to write very simple, clear +Haskell plugins, that appear not to be Haskell at all. It is an easy +way to get EDSL user's writing plugins that are actually Haskell +programs, for .e.g, configuration files. See the examples that come +with the src. + +\newpage + +\section{An Example} + +This is an introductory example. + +\subsection*{API} + +First we need an interface between the application and the plugin. +This module needs to be visible to both the app and the plugin, in the +interest of clear and well-defined interfaces: +% +\begin{quote} +\scm{ +module StringProcAPI (Interface(..), plugin) where + +data Interface = Interface { + stringProcessor :: String -> String +} + +plugin :: Interface +plugin = Interface { stringProcessor = id } +} +\end{quote} + +Here we define \code{Interface} as the inteface signature for the +object passed between plugin and application. We'll use the record +syntax as it looks intuitive in the plugin. We provide a default +instance, the \code{plugin} value, that can be overwritten in the +actual plugin, ensuring sensible behaviour in the absence of any +plugins. The API should theoretically be compiled with \code{-Onot} to +avoid interface details leaking out into the \code{.hi} file. + +\subsection*{The Plugin} + +This is our plugin. Note that the plugin will be compiled entirely +seperately from the application. It must only rely on the API, and +nothing in the application source. +% +\begin{quote} +\scm{ +module StringProcPlugin (resource) where + +import StringProcAPI (plugin) + +resource = plugin { + stringProcessor = reverse +} +} +\end{quote} + +Using the record syntax we overwrite the \code{function} field with our +own value, \code{reverse}. The value \code{resource} is the magic symbol +that must be defined, and which the application will use to find the +data the plugin exports. + +Now, we can make this even easier on the plugin writer by the use of a +``stub'' file. \code{makeWith} lets you merge a plugin source with +another Haskell file, and compiles the result into the actual plugin +object. So the application can provide a stub file containing module +declarations and imports, and a default plugin value. Here is an +application-provided stub, factoring out compulsory syntax and type +declarations from the plugin: +% +\begin{quote} +\scm{ +module StringProcPlugin ( resource ) where + +import StringProcAPI + +resource :: Interface +resource = plugin +} +\end{quote} + +By factoring out compulsory syntax, the plugin author only has to +provide an overriding instance of the \code{resource} field. So all +the plugin actually consists of, is: +% +\begin{quote} +\scm{ +resource = plugin { + stringProcessor = reverse +} +} +\end{quote} + +That is all the code we need! This file may be called anything at all. + +More complex APIs may have more fields, of course. The nice thing +about this arrangement is that the user will write some simple syntax, +which will nonetheless by typechecked safely against the API. Errors +are also reported using line numbers from the source file, not the +stub, which makes things less confusing. + +\subsection*{The Application} + +Now we need to write an application that can use values of the kind +defined in the API, and which can compile and load plugins. The basic +mechanism to compile and load a plugin is as follows: +% +\begin{quote} +\scm{ +do status <- make "StringProcPlugin.hs" [] + obj <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "failed" + + m_v <- load obj ["."] [] "resource" + val <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" +} +\end{quote} +% +This code calls \code{make} to compile the plugin source, yielding +wrapper around a handle to an object file. The object can then be loaded +using \code{load}, and the code associated with the symbol +\code{resource} is retrieved. + +We embed this code in a simple shell-like loop, applying the function +exported by the plugin: +% +\begin{quote} +\scm{ +import Plugins +import StringProcessorAPI +import System.Console.Readline +import System.Exit + +source = "Plugin.hs" +stub = "Plugin.stub" +symbol = "resource" + +main = do s <- makeWith source stub [] + o <- case s of + MakeSuccess _ obj -> do + ls <- load obj ["."] [] symbol + case ls of LoadSuccess m v -> return (m,v) + LoadFailure err -> error "load failed" + MakeFailure e -> mapM_ putStrLn e >> error "compile failed" + shell o + +shell o@(m,plugin) = do + s <- readline "> " + cmd <- case s of + Nothing -> exitWith ExitSuccess + Just (':':'q':_) -> exitWith ExitSuccess + Just s -> addHistory s >> return s + + s <- makeWith source stub [] -- maybe recompile the source + o' <- case s of + MakeSuccess ReComp o -> do + ls <- reload m symbol + case ls of LoadSuccess m' v' -> return (m',v') + LoadFailure err -> error "reload failed" + MakeSuccess NotReq _ -> return o + MakeFailure e -> mapM_ putStrLn e >> shell o + eval cmd o' + shell o' + +eval ":?" _ = putStrLn ":?\n:q\n" + +eval s (_,plugin) = let fn = (stringProcessor plugin) in putStrLn (fn s) +} +\end{quote} + +We have to import the hs-plugins library, and the API. The main loop +proceeds by compiling and loading the plugin for the first time, and +then calls \code{shell}, the interpeter loop. This loop lets us apply +the function in the plugin to strings we supply. We have to pass +around the \code{(Module, a)} pair we get back from \code{reload}, so +that we can pass it to \code{eval} to do the real work. The first +\code{eval} case is where we use the record syntax to select the +\code{function} field out of \code{v}, the plugin interface object, +and we apply it to s. Try it out: +% +\begin{quote} +\begin{verbatim} +paprika$ ./a.out +Loading package base ... linking ... done +Loading objects API Plugin ... done +> :? +":?" +":q" +"" +> abcdefg +gfedcba +\end{verbatim} +\end{quote} + +Now, if we edit the plugin while the shell is running, the next time +we type something at the prompt the plugin will be unloaded, +recompiled and reloaded. Because the plugin is really an EDSL, we can +use any Haskell we want, so we'll change the plugin to: +% +\begin{quote} +\scm{ +import Data.Char + +resource = plugin { + stringProcessor = my_fn +} + +my_fn s = map toUpper (reverse s) +} +\end{quote} + +Back to the shell: +% +\begin{quote} +\begin{verbatim} +> abcdefg +Compiling plugin ... done +Reloading Plugin ... done +GFEDCBA +\end{verbatim} +\end{quote} + +And that's it: dynamically recompiled and reload Haskell code! + +\section{Multiple Plugins} + +It is quite easy to load multiple plugins, that all implement the +common plugin API, and that all export the same value (though +implemented differently). This make \hsplugins{} suitable for +applications that wish to allow an arbitrary number of plugins. The +main problem with multiple plugins is that they may share +dependencies, and if \code{load} na\"ively loaded all dependencies +found in the set of \code{.hi} files associated with all the plugins, +the GHC rts would crash. To solve this the \hsplugins{} dynamic loader +maintains state storing a list of what modules and packages have been +loaded already. If \code{load} is called on a module that is already +loaded, or dependencies are attempted to load, that have already been +loaded, the dynamic loader ignores these extra dependencies. This +makes it quite easy to write an application that will allows an +arbitrary number of plugins to be loaded. An example follows. + +\subsection*{Definition} + +First we need to define the API that a plugin must type check against, +in order to be valid. +% +\begin{quote} +\scm{ +module API where + +data Interface = Interface { + valueOf :: String -> String +} + +plugin :: Interface +plugin = Interface { valueOf = id } +} +\end{quote} + +We can then implement a number of plugins that provide values of type +"Interface". We show three plugins that export string manipulation functions: +% +\begin{quote} +\scm{ +module Plugin1 where + +import API +import Data.Char + +resource = plugin { + valueOf = \s -> map toUpper s +} +} +\end{quote} + +\begin{quote} +\scm{ +module Plugin2 where + +import API +import Data.Char + +resource = plugin { + valueOf = \s -> map toLower s +} +} +\end{quote} + +\begin{quote} +\scm{ +module Plugin3 where + +import API + +resource = plugin { + valueOf = reverse +} +} +\end{quote} + +And finally we need to write an application that would use these +plugins. Remember that the application is written without knowledge of +the plugins, and the plugins are written without knowledge of the +application. They are each implemented only in terms of the API, a +shared module and \code{.hi} file. An application needs to make the +API interface available to plugin authors, by distributing the API +object file and \code{.hi} file with the application. +% +\begin{quote} +\scm{ +import Plugins +import API + +main = do + let plist = ["Plugin1.o", "Plugin2.o", "Plugin3.o"] + plugins <- mapM (\p -> load p ["."] [] "resource") plist + let functions = map (valueOf . fromLoadSuc) plugins + mapM_ (\f -> putStrLn $ f "haskell is for hackers") functions + +fromLoadSuc (LoadFailure _) = error "load failed" +fromLoadSuc (LoadSuccess _ v) = v + +} +\end{quote} + +This application simply loads all the plugins and retrieves the +functions they export. It then applies each of these functions to a +string, printing the result. We assume for this example that the +plugins are compiled once only, and are not compiled dynamically via +\code{make}. This implies that you have to use \code{GHC} to generate +the \code{.hi} file for each plugin. A sample Makefile to compile the +plugins, and the api: +% +\begin{quote} +\begin{verbatim} +all: + ghc -Onot -c API.hs + ghc -O -c Plugin1.hs + ghc -O -c Plugin2.hs + ghc -O -c Plugin3.hs +\end{verbatim} +\end{quote} + +Ghc creates \code{.hi} files for each plugin, which can be inspected +using the \code{Plugins.BinIface.readBinIface} function. It parses the +\code{.hi} file, generating, roughly, the following: +% +\begin{quote} +\begin{verbatim} +interface "Main" Main +module dependencies: A, B +package dependencies: base, haskell98, lang, unix +\end{verbatim} +\end{quote} + +which says that the plugin depends upon a variety of system packages, +and the modules A and B. All these dependencies must be loaded before +the plugin itself. + +You then need to compile the application against the API, and against +the \hsplugins{} library: +% +\begin{quote} +\begin{verbatim} +ghc -O --make -package plugins Main.hs +\end{verbatim} +\end{quote} + +Running the application produces the following result. Note that the +verbose output can be switched off by compiling \hsplugins{} without +the \code{-DDEBUG} flag. If you look at the \code{.hi} file, using +\code{ghc --show-iface}, you'll see that they all depend on the base +package, and on the API, but the state stored in the dynamic loader +ensures that these shared modules are only loaded once: +% +\begin{quote} +\begin{verbatim} +Loading package base ... linking ... done +Loading object API Plugin1 ... done +Loading object Plugin2 ... done +Loading object Plugin3 ... done + +HASKELL IS FOR HACKERS +haskell is for hackers +srekcah rof si lleksah +\end{verbatim} +\end{quote} + +Archives of plugins can be loaded in one go if they have been linked +into a .o GHCi package, see \code{loadPackage}. + +\newpage + +\appendix + +\section{License} + +This library is distributed under the terms of the LGPL: + +\begin{quote} + +Copyright 2004, Don Stewart - \url{http://www.cse.unsw.edu.au/~dons} + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA + +\end{quote} + +\section{Portability} + +The library tries to be portable. There are two major points that +limit easy portabilty. The first is the dependence on the GHC dynamic +linker. \hsplugins{} is thus limited to platforms to which GHC's dyn +linker has been ported (this is essentially the same as the platforms +that can run GHCi). + +Other than this, there are 3 platform specific items that need to be +defined for new platforms: +\begin{itemize} + \item Where tmp files should be created. Define the + \code{tmpDir} variable in \code{Plugins/Consts.hs} + + \item Process creation, such that we can read stdin and stderr + from the process (this is the POpen library for Posix + systems). For Windows, \hsplugins{} carries Simon + Marlow's \code{forkProcess} library. + + \item Dealing with backslashes in Dos-style path names +\end{itemize} + +I plan to solve the above 3 problems (and thus have a Windows port) once +GHC 6.4 is out. + +\newpage + +\section{A Haskell Interpreter using Plugins} +% \label{sec:plugs} + +Here is a full length example of a Haskell interpreter/compiler in the +style of Malcolm Wallace's \code{hi}. Rather than compiling the +user's code to an executable, we use \hsplugins{} to instead load an +object file and execute that instead, using the \code{eval} interface. +This cuts out the linking phase from the process, making turnaround at +the prompt around twice as fast as \code{hi}. + +\subsection*{Source of Plugs} + +\begin{quote} +\scm{ +import Eval.Haskell +import Plugins.Load + +import System.Exit ( ExitCode(..), exitWith ) +import System.IO +import System.Console.Readline ( readline, addHistory ) + +symbol = "resource" + +main = do + putStrLn banner + putStr "Loading package base" >> hFlush stdout + loadPackage "base" + putStr " ... linking ... " >> hFlush stdout + resolveObjs + putStrLn "done" + + shell [] + +shell :: [String] -> IO () +shell imps = do + s <- readline "plugs> " + cmd <- case s of + Nothing -> exitWith ExitSuccess + Just (':':'q':_) -> exitWith ExitSuccess + Just s -> addHistory s >> return s + imps' <- run cmd imps + shell imps' + +run :: String -> [String] -> IO [String] +run "" is = return is +run ":?" is = putStrLn help >> return is + +run ":l" _ = return [] +run (':':'l':' ':m) is = return (m:is) + +run (':':'t':' ':s) is = do + ty <- typeOf s is + when (not $ null ty) (putStrLn $ s ++ " :: " ++ ty) + return is + +run (':':_) is = putStrLn help >> return is + +run s is = do + s <- unsafeEval ("show $ "++s) is + when (isJust s) (putStrLn (fromJust s)) + return is + +banner = "\ +\ __ \n\ +\ ____ / /_ ______ ______ \n\ +\ / __ \\/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98\n\ +\ / /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins\n\ +\ / .___/_/\\__,_/\\__, /____/ Type :? for help \n\ +\/_/ /____/ \n" + +help = "\ +\Commands :\n\ +\ evaluate expression\n\ +\ :t show type of expression (monomorphic only)\n\ +\ :l module bring module in to scope\n\ +\ :l clear module list\n\ +\ :quit quit\n\ +\ :? display this list of commands" +} +\end{quote} + +\subsection*{A Transcript} + +And a transcript: +% +\begin{quote} +\begin{verbatim} +$ ./plugs + __ + ____ / /_ ______ ______ + / __ \/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98 + / /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins + / .___/_/\__,_/\__, /____/ Type :? for help +/_/ /____/ + +Loading package base ... linking ... done +plugs> 1 +1 +plugs> let x = 1 + 2 in x +3 +plugs> :l Data.List +plugs> case [1,3,2] of x -> sort x +[1,2,3] +plugs> reverse [1,3,2] +[2,3,1] +plugs> map (\x -> (x,2^x)) [1,2,3,4,5,6,7,8,9,10] +[(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256),(9,512),(10,1024)] +plugs> :t "haskell" +"haskell" :: [Char] +plugs> :quit +\end{verbatim} +\end{quote} + +\end{document} hunk ./docs/munge.sed 1 +#!/usr/bin/sed -f + +# de-boldify and

-ify the Contents. + +/Contents/ { + :loop + /Go to/ { + b end + } + s,

,, + s,,, + s,,, + s,

,, + n + b loop +} +:end hunk ./docs/tex2page.sty 1 +% tex2page.sty +% Dorai Sitaram + +% Loading this file in a LaTeX document +% gives it all the macros of tex2page.tex, +% but via a more LaTeX-convenient filename. + +\input{tex2page} + hunk ./docs/tex2page.tex 1 +% tex2page.tex +% Dorai Sitaram + +% TeX files using these macros +% can be converted by the program +% tex2page into HTML + +\message{version 2003-10-26} % last change + +\let\texonly\relax +\let\endtexonly\relax + +\texonly + +\newcount\evalQauxfilecount +\evalQauxfilecount=0 + +\def\eval{\begingroup + \ifx\evalfortexQport\UNDEFINED + \expandafter\csname newwrite\endcsname + \evalfortexQport + \immediate\openout\evalfortexQport + \jobname.eval4tex + \immediate\write\evalfortexQport + {\string\ifx\string\shipout\string\UNDEFINED + \string\eval{(eval-for-tex-only)}% + \string\else\string\endinput\string\fi}% + \fi + \global\advance\evalQauxfilecount by 1 + \edef\evalQauxfile{\jobname-Z-E-\the\evalQauxfilecount}% + {\immediate\openin0=\evalQauxfile.tex + \ifeof0 \immediate\closein0 + \else \input \evalQauxfile.tex \fi}% + \def\do##1{\catcode`##1=12 }\dospecials + \catcode`\{=1 \catcode`\}=2 + \catcode`\^^M=12 + \newlinechar=`\^^M% + \evalQii} + +\def\evalQii#1{% + \immediate\write\evalfortexQport{\string\eval{#1}}% + \endgroup} + +%\def\verbwritefile#1 {\relax} +%\let\verbwrite\gobbleencl + +\def\verbwritefile{% + \ifx\verbwritefileQport\UNDEFINED + \expandafter\csname newwrite\endcsname\verbwritefileQport + \else\immediate\closeout\verbwritefileQport + \fi + \futurelet\verbwritefileQnext\verbwritefileQcheckchar} + +\def\verbwritefileQcheckchar{% + \ifx\verbwritefileQnext\bgroup + \let\verbwritefileQnext\verbwritefileQbracedfile + \else + \let\verbwritefileQnext\verbwritefileQspacedfile + \fi\verbwritefileQnext} + +\def\verbwritefileQspacedfile#1 {% + \immediate\openout\verbwritefileQport #1 +} + +\def\verbwritefileQbracedfile#1{% + \verbwritefileQspacedfile #1 +} + +\def\verbwrite{% + \ifx\verbwritefileQport\UNDEFINED + \verbwritefile \jobname.txt \fi + \begingroup + \def\do##1{\catcode`##1=12 }\dospecials + \catcode`\{=1 \catcode`\}=2 + \catcode`\^^M=12 \newlinechar=`\^^M% + \futurelet\verbwriteQopeningchar\verbwriteQii} + +\def\verbwriteQii{\ifx\verbwriteQopeningchar\bgroup + \let\verbwriteQiii\verbwriteQbrace\else + \let\verbwriteQiii\verbwriteQnonbrace\fi + \verbwriteQiii} + +\def\verbwriteQbrace#1{\immediate + \write\verbwritefileQport{#1}\endgroup} + +\def\verbwriteQnonbrace#1{% + \catcode`\{12 \catcode`\}12 + \def\verbwriteQnonbraceQii##1#1{% + \immediate\write\verbwritefileQport{##1}\endgroup}% + \verbwriteQnonbraceQii} + +\ifx\loadonlyQevalfortex1% + \let\maybeloadfollowing\endinput +\else + \let\maybeloadfollowing\relax +\fi\maybeloadfollowing + +\ifx\slatexignorecurrentfile\UNDEFINED\relax\fi + +\edef\atcatcodebeforetiip{\the\catcode`\@ } +\catcode`\@11 + +% margins + +\def\sidemargin{\afterassignment\sidemarginQadjustoffset + \hoffset} + +\def\sidemarginQadjustoffset{% + \advance\hoffset -1true in + \advance\hsize -2\hoffset} + +\def\vertmargin{\afterassignment\vertmarginQadjustoffset + \voffset} + +\def\vertmarginQadjustoffset{% + \advance\voffset -1true in + \advance\vsize -2\voffset} + +% + +\def\defcsactive#1{\defnumactive{`#1}} + +\def\defnumactive#1{\catcode#1\active + \begingroup\lccode`\~#1% + \lowercase{\endgroup\def~}} + +% gobblegobblegobble + +\def\gobblegroup{\bgroup + \def\do##1{\catcode`##1=9 }\dospecials + \catcode`\{1 \catcode`\}2 \catcode`\^^M=9 + \gobblegroupI} + +\def\gobblegroupI#1{\egroup} + +\def\gobbleencl{\bgroup + \def\do##1{\catcode`##1=12 }\dospecials + \catcode`\{1 \catcode`\}2 \catcode`\^^M=9 + \futurelet\gobbleenclnext\gobbleenclI} + +\def\gobbleenclI{\ifx\gobbleenclnext\bgroup + \let\gobbleenclnext\gobblegroupI + \else\let\gobbleenclnext\gobbleenclII\fi + \gobbleenclnext} + +\def\gobbleenclII#1{% + \def\gobbleenclIII##1#1{\egroup}% + \gobbleenclIII} + +% \verb +% Usage: \verb{...lines...} or \verb|...lines...| +% In the former case, | can be used as escape char within +% the verbatim text + +\let\verbhook\relax + +\def\verbfont{\tt} +%\hyphenchar\tentt-1 + +\def\verbsetup{\frenchspacing + \def\do##1{\catcode`##1=12 }\dospecials + \catcode`\|=12 % needed? + \verbfont + \edef\verbQoldhyphenchar{\the\hyphenchar\font}% + \hyphenchar\font-1 + \def\verbQendgroup{\hyphenchar\font\verbQoldhyphenchar\endgroup}% +} + +% The current font is cmtt iff fontdimen3 = 0 _and_ +% fontdimen7 != 0 + +\def\checkifusingcmtt{\let\usingcmtt n% + \ifdim\the\fontdimen3\the\font=0.0pt + \ifdim\the\fontdimen7\the\font=0.0pt + \else\let\usingcmtt y\fi\fi} + +% In a nonmonospaced font, - followed by a letter +% is a regular hyphen. Followed by anything else, it is a +% typewriter hyphen. + +\def\variablelengthhyphen{\futurelet\variablelengthhyphenI + \variablelengthhyphenII} + +\def\variablelengthhyphenII{\ifcat\noexpand\variablelengthhyphenI + a-\else{\tt\char`\-}\fi} + +\def\verbavoidligs{% avoid ligatures + \defcsactive\`{\relax\lq}% + \defcsactive\ {\leavevmode\ }% + \defcsactive\^^I{\leavevmode\ \ \ \ \ \ \ \ }% + \defcsactive\^^M{\leavevmode\endgraf}% + \checkifusingcmtt + \ifx\usingcmtt n% + \defcsactive\<{\relax\char`\<}% + \defcsactive\>{\relax\char`\>}% + \defcsactive\-{\variablelengthhyphen}% + \fi} + +\def\verbinsertskip{% + \let\firstpar y% + \defcsactive\^^M{\ifx\firstpar y% + \let\firstpar n% + \verbdisplayskip + \parskip 0pt + \aftergroup\verbdisplayskip + \else\leavevmode\fi\endgraf}% + \verbhook} + +\ifx\verb\UnDeFiNeD\else +% Save LaTeX's \verb away, because +% we'll be defining our own \verb +\let\LaTeXverb\verb +\fi + +%\def\verb{\begingroup +% \verbsetup\verbI} + +\def\verb{\begingroup + \verbsetup\verbavoidligs\verbQcheckstar} + +\def\verbQcheckstar{% + \futurelet\verbQcheckstarQnext\verbQcheckstarQii} + +\def\verbQcheckstarQii{% + \if\verbQcheckstarQnext*% + \let\verbQcheckstarQnext\verbQcheckstarQiii + \else + \let\verbQcheckstarQnext\verbI + \fi + \verbQcheckstarQnext} + +\def\verbQcheckstarQiii#1{% + \defcsactive\ {\relax\char`\ }% + \verbI} + +\def\verbc{\begingroup + \verbsetup\afterassignment\verbcI + \let\verbcII=} + +\def\verbcI{{\verbfont\verbcII}\endgroup} + +\let\E\verbc + +\newcount\verbbracebalancecount + +\def\verblbrace{\char`\{} +\def\verbrbrace{\char`\}} + +\def\verbescapechar#1{% + \def\escapifyverbescapechar{\catcode`#1=0 }} + +\verbescapechar\| + +{\catcode`\[1 \catcode`\]2 +\catcode`\{12 \catcode`\}12 +\gdef\verbI#1[%\verbavoidligs + \verbinsertskip\verbhook + %\edef\verbQoldhyphenchar{\the\hyphenchar\tentt}% + %\hyphenchar\tentt=-1 + %\def\verbQendgroup{\hyphenchar\tentt\verbQoldhyphenchar\endgroup}% + %\let\verbQendgroup\endgroup% + \if#1{\escapifyverbescapechar + \def\{[\char`\{]% + \def\}[\char`\}]% + \def\|[\char`\|]% + \verbbracebalancecount0 + \defcsactive\{[\advance\verbbracebalancecount by 1 + \verblbrace]% + \defcsactive\}[\ifnum\verbbracebalancecount=0 + \let\verbrbracenext\verbQendgroup\else + \advance\verbbracebalancecount by -1 + \let\verbrbracenext\verbrbrace\fi + \verbrbracenext]\else + \defcsactive#1[\verbQendgroup]\fi + \verbII +]] + +\def\verbII{\futurelet\verbIInext\verbIII} + +{\catcode`\^^M\active% +\gdef\verbIII{\ifx\verbIInext^^M\else% + \defcsactive\^^M{\leavevmode\ }\fi}} + +\let\verbdisplayskip\medbreak + +% \verbatiminput FILENAME +% displays contents of file FILENAME verbatim. + +%\def\verbatiminput#1 {{\verbsetup\verbavoidligs\verbhook +% \input #1 }} + +% ^ original \verbatiminput + +\ifx\verbatiminput\UNDEFINED +% LaTeX's (optional) verbatim package defines a \verbatiminput -- +% don't clobber it +\def\verbatiminput{% + \futurelet\verbatiminputQnext\verbatiminputQcheckchar}% +\fi + +\def\verbatiminputQcheckchar{% + \ifx\verbatiminputQnext\bgroup + \let\verbatiminputQnext\verbatiminputQbracedfile + \else + \let\verbatiminputQnext\verbatiminputQspacedfile + \fi\verbatiminputQnext} + +\def\verbatiminputQbracedfile#1{\verbatiminputQdoit{#1}} + +\def\verbatiminputQspacedfile#1 {\verbatiminputQdoit{#1}} + +\def\verbatiminputQdoit#1{{\verbsetup + \verbavoidligs\verbhook + \input #1 }} + + +% \url{URL} becomes +% URL in HTML, and +% URL in DVI. + +% A-VERY-VERY-LONG-URL in a .bib file +% could be split by BibTeX +% across a linebreak, with % before the newline. +% To accommodate this, %-followed-by-newline will +% be ignored in the URL argument of \url and related +% macros. + +\ifx\url\UnDeFiNeD +\def\url{\bgroup\urlsetup\let\dummy=}% +\fi + +\def\urlsetup{\verbsetup\urlfont\verbavoidligs + \catcode`\{1 \catcode`\}2 + \defcsactive\%{\urlpacifybibtex}% + \defcsactive\ {\relax}% + \defcsactive\^^M{\relax}% + \defcsactive\.{\discretionary{}{\char`\.}{\char`\.}}% + \defcsactive\/{\discretionary{\char`\/}{}{\char`\/}}% + \defcsactive\`{\relax\lq}} + +\let\urlfont\relax + +\def\urlpacifybibtex{\futurelet\urlpacifybibtexnext\urlpacifybibtexI} + +\def\urlpacifybibtexI{\ifx\urlpacifybibtexnext^^M% + \else\%\fi} + +% \mailto{ADDRESS} becomes +% ADDRESS in HTML, and +% ADDRESS in DVI. + +\let\mailto\url + +% \urlh{URL}{TEXT} becomes +% TEXT in HTML, and +% TEXT in DVI. + +% If TEXT contains \\, the part after \\ appears in +% the DVI only. If, further, this part contains \1, +% the latter is replaced by a fixed-width representation +% of URL. + +\def\urlh{\bgroup\urlsetup + \afterassignment\urlhI + \gdef\urlhQurlarg} + +\def\urlhI{\egroup + \bgroup + \let\\\relax + \def\1{{\urlsetup\urlhQurlarg}}% + \let\dummy=} + +\def\urlp#1{{#1} \bgroup\urlsetup + \afterassignment\urlpQwrapparens + \gdef\urlpQurlarg} + +\def\urlpQwrapparens{\egroup + {\rm(}{\urlsetup\urlpQurlarg}{\rm)}} + +% \urlhd{URL}{HTML-TEXT}{DVI-TEXT} becomes +% HTML-TEXT in HTML, and +% DVI-TEXT in DVI + +\def\urlhd{\bgroup + \def\do##1{\catcode`##1=12 }\dospecials + \catcode`\{1 \catcode`\}2 + \urlhdQeaturlhtmlargs} + +\def\urlhdQeaturlhtmlargs#1#2{\egroup} + +\ifx\hyperref\UnDeFiNeD +\let\href\urlh +\let\hypertarget\gobblegroup +\let\hyperlink\gobblegroup +\def\hyperref#1#2#3#4{#2\ref{#4}#3} +\fi + +% + +\let\ignorenextinputtimestamp\relax + +% don't let caps disable end-of-sentence spacing + +\def\nocapdot{% +\count255=`\A +\loop +\sfcode\the\count255=1000 +\ifnum\count255<`\Z +\advance\count255 by 1 +\repeat +} + +% + +%\ifx\newenvironment\UnDeFiNeD +\let\htmlonly\iffalse +\let\endhtmlonly\fi +%\else +%\usepackage{comment} +%\excludecomment{htmlonly} +%\fi + +\def\rawhtml{\errmessage{Can't occur outside + \string\htmlonly}} +\def\endrawhtml{\errmessage{Can't occur outside + \string\htmlonly}} + +\let\htmlheadonly\iffalse +\let\endhtmlheadonly\fi + +\let\cssblock\iffalse +\let\endcssblock\fi + +\def\inputcss#1 {\relax} +\let\htmlstylesheet\inputcss +\let\htmladdimg\gobblegroup + +\def\htmlref{\bgroup\aftergroup\gobblegroup\let\dummy=} + +% + +\let\htmlcolophon\gobblegroup +\let\htmlmathstyle\gobblegroup +\let\htmladvancedentities\relax + +% Scheme + +\let\scm\verb +\let\scminput\verbatiminput + +\let\scmwritefile\verbwritefile +\let\scmwrite\verbwrite +\let\scmdribble\scm + +\ifx\slatexversion\UNDEFINED +% SLaTeX compat +\let\scmkeyword\gobblegroup +\let\scmbuiltin\gobblegroup +\let\scmconstant\scmbuiltin +\let\scmvariable\scmbuiltin +\let\setbuiltin\scmbuiltin +\let\setconstant\scmbuiltin +\let\setkeyword\scmkeyword +\let\setvariable\scmvariable +\def\schemedisplay{\begingroup + \verbsetup\verbavoidligs + \verbinsertskip + \schemedisplayI}% +\def\schemeresponse{\begingroup + \verbsetup\verbavoidligs + \verbinsertskip + \schemeresponseI}% +{\catcode`\|0 |catcode`|\12 + |long|gdef|schemedisplayI#1\endschemedisplay{% + #1|endgroup}% + |long|gdef|schemeresponseI#1\endschemeresponse{% + #1|endgroup}}% +\fi + +\let\slatexlikecomments\relax +\let\noslatexlikecomments\relax + +% definitions (useful in reference manuals) + +\ifx\@@line\UnDeFiNeD +\let\@@line\line +\fi + +\def\defun#1{\def\defuntype{#1}% +\medbreak +\@@line\bgroup + \hbox\bgroup + \aftergroup\enddefun + \vrule width .5ex \thinspace + \vrule \enspace + \vbox\bgroup\setbox0=\hbox{\defuntype}% + \advance\hsize-\wd0 + \advance\hsize-1em + \obeylines + \parindent=0pt + \aftergroup\egroup + \strut + \let\dummy=} + +\def\enddefun{\hfil\defuntype\egroup\smallskip} + + +% Images + +\let\imgdef\def + +%\def\imgpreamble{\let\magnificationoutsideimgpreamble\magnification +% \def\magnification{\count255=}} +% +%\def\endimgpreamble{\let\magnification\magnificationoutsideimgpreamble} + + +\let\imgpreamble\iffalse +\let\endimgpreamble\fi + +\let\makehtmlimage\relax + + +% Tally control sequences are cheap count +% registers: they doesn't use up TeX's limited number of +% real count registers. + +% A tally is a macro that expands to the +% number kept track of. Thus \edef\kount{0} defines a +% tally \kount that currently contains 0. + +% \advancetally\kount n increments \kount by n. +% \globaladvancetally increments the global \kount. +% If \kount is not defined, the \[global]advancetally +% macros define it to be 0 before proceeding with the +% incrementation. + +\def\newtally#1{\edef#1{0}} + +\def\advancetallyhelper#1#2#3{% + \ifx#2\UNDEFINED + #1\edef#2{0}\fi + \edef\setcountCCLV{\count255=#2 }% + \setcountCCLV + \advance\count255 by #3 + #1\edef#2{\the\count255 }} + +\def\advancetally{\advancetallyhelper\relax} +\def\globaladvancetally{\advancetallyhelper\global} + +% plain's \beginsection splits pages too easily + +%\def\beginsection#1\par{\sectionhelp{1}{}{#1}} + +\def\beginsection{\vskip-\lastskip + \bigbreak\noindent + \bgroup\bf + \let\par\sectionafterskip} + +\def\beginsectionstar*{\beginsection} + +% plain's \{left,center,right}line can't handle catcode change +% within their argument + +\def\leftline{\@@line\bgroup\bgroup + \aftergroup\leftlinefinish + \let\dummy=} + +\def\leftlinefinish{\hss\egroup} + +\def\centerline{\@@line\bgroup\bgroup + \aftergroup\leftlinefinish + \hss\let\dummy=} + +\def\rightline{\@@line\bgroup\hss\let\dummy=} + +% + +\let\strike\fiverm % can be much better! + +% + +\let\htmlpagebreak\relax + +\let\htmlpagelabel\gobblegroup + +\def\htmlpageref{\errmessage{Can't occur except inside + \string\htmlonly}} + +% Miscellaneous stuff + +%\def\hr{$$\hbox{---}$$} +\def\hr{\medbreak\centerline{---}\medbreak} +%\def\hr{\par\centerline{$*$}\par} +%\def\hr{\smallskip\@@line{\leaders\hbox{~.~}\hfill}\smallskip} + +%Commonplace math that doesn't require image files. (Avoiding $ +%here because $ triggers image-file generation.) + +\let\nohtmlmathimg\relax +\let\nohtmlmathintextimg\relax +\let\nohtmlmathdisplayimg\relax + +\let\htmlimageformat\gobblegroup +\let\htmlimgmagnification\gobblegroup + +\let\externaltitle\gobblegroup + +\def\mathg{$\bgroup\aftergroup\closemathg\let\dummy=} +\def\closemathg{$} + +\let\mathp\mathg + +\def\mathdg{$$\bgroup\aftergroup\closemathdg\let\dummy=} +\def\closemathdg{$$} + +% + + +\let\evalh\gobblegroup +\let\evalq\gobblegroup + +% Backward compatible stuff + +\let\endgifpreamble\endimgpreamble +\let\endhtmlgif\relax +\let\endhtmlimg\relax +\let\gifdef\imgdef +\let\gifpreamble\imgpreamble +%\let\href\urlh +\let\htmlgif\relax +\let\htmlimg\relax +\let\htmlimgformat\htmlimageformat +\let\n\noindent +\let\p\verb +\let\q\scm +\let\schemeeval\eval +\let\scmfile\scmdribble +\let\scmfileonly\scmwrite +\let\scmp\scm +%\let\scmverbatim\scm +\let\scmverbatimfile\scminput +\let\setverbatimescapechar\verbescapechar +%\let\verbatim\verb +\let\verbatimfile\verbatiminput +\let\verbinput\verbatiminput +\let\verbfilename\verbwritefile +\let\scmfilename\scmwritefile + +% uppercase version of \romannumeral + +\def\Romannumeral{\afterassignment\RomannumeralI\count255=} + +\def\RomannumeralI{\uppercase\expandafter{\romannumeral\the\count255 }} + +\def\f{\footnote} + +\ifx\label\UnDeFiNeD +\else +\def\tag#1#2{\@bsphack + \protected@write\@auxout{}% + {\string\newlabel{#1}{{#2}{\thepage}}}% +\@esphack}% +\let\tagref\ref +\fi + +\def\inputexternallabels#1 {\relax} +\def\includeexternallabels#1 {\relax} + +% The rest of the file isn't needed for LaTeX + +\ifx\section\UnDeFiNeD +\let\maybeloadfollowing\relax +\else +\catcode`\@\atcatcodebeforetiip +\let\maybeloadfollowing\endinput +\fi\maybeloadfollowing + +% LaTeX stops loading here! + +% Title + +\newwrite\sectionscratchfileport + +\def\subject{% + \immediate\openout\sectionscratchfileport Z-sec-temp + \begingroup + \def\do##1{\catcode`##1=11 }\dospecials + \catcode`\{=1 \catcode`\}=2 + \subjectI} + +\def\subjectI#1{\endgroup + \immediate\write\sectionscratchfileport {#1}% + \immediate\closeout\sectionscratchfileport + $$\vbox{\bf \def\\{\cr}% + \halign{\hfil##\hfil\cr + \input Z-sec-temp + \cr}}$$% + \medskip} + +\let\title\subject + +% Sections + +\def\tracksectionchangeatlevel#1{% + \expandafter\let\expandafter\thiscount\csname + sectionnumber#1\endcsname + \ifx\thiscount\relax + \expandafter\edef\csname sectionnumber#1\endcsname{0}% + \fi + \expandafter\advancetally + \csname sectionnumber#1\endcsname 1% + \ifx\doingappendix0% + \edef\recentlabel{\csname sectionnumber1\endcsname}% + \else + %\count255=\expandafter\csname sectionnumber1\endcsname + \edef\recentlabel{\char\csname sectionnumber1\endcsname}% + \fi + \count255=0 + \loop + \advance\count255 by 1 + \ifnum\count255=1 + \else\edef\recentlabel{\recentlabel.\csname + sectionnumber\the\count255\endcsname}\fi + \ifnum\count255<#1% + \repeat + \loop + \advance\count255 by 1 + \expandafter\let\expandafter\nextcount\csname + sectionnumber\the\count255\endcsname + \ifx\nextcount\relax + \let\continue0% + \else + \expandafter\edef\csname + sectionnumber\the\count255\endcsname{0}% + \let\continue1\fi + \ifx\continue1% + \repeat} + +% Vanilla section-header look -- change this macro for new look + +\newcount\secnumdepth + +\secnumdepth=10 + +\def\sectiond#1{\count255=#1% + \ifx\usingchapters1\advance\count255 by 1 \fi + \edef\sectiondlvl{\the\count255 }% + \futurelet\sectionnextchar\sectiondispatch} + +\def\sectiondispatch{\ifx\sectionnextchar*% + \def\sectioncontinue{\sectionstar{\sectiondlvl}}\else + \ifnum\sectiondlvl>\secnumdepth + \def\sectioncontinue{\sectionhelp{\sectiondlvl}{}}\else + \tracksectionchangeatlevel{\sectiondlvl} + \def\sectioncontinue{\sectionhelp{\sectiondlvl}% + {\recentlabel\enspace}}\fi\fi + \sectioncontinue} + +\def\sectionstar#1*{\sectionhelp{#1}{}} + + +\def\sectionhelp#1#2{% + \edef\sectiondepth{#1}% + \def\sectionnr{#2}% + \immediate\openout\sectionscratchfileport Z-sec-temp + \begingroup + \def\do##1{\catcode`##1=11 }\dospecials + \catcode`\{=1 \catcode`\}= 2 + \sectionheader} + +\def\sectionheader#1{\endgroup + \immediate\write\sectionscratchfileport {#1}% + \immediate\closeout\sectionscratchfileport + \vskip -\lastskip + \ifnum\sectiondepth>\tocdepth\else + \tocactivate + {\let\folio0% + \edef\temp{\write\tocout + {\string\tocentry{\sectiondepth}{\sectionnr}{#1}{\folio}}}% + \temp}\fi + \vskip1.5\bigskipamount +\goodbreak %??? + \noindent + \hbox{\vtop{\pretolerance 10000 + \raggedright + \noindent\bf\sectionnr + \input Z-sec-temp }}% + \bgroup\let\par\sectionafterskip} + +% \edef\temp{\write\tocout{\string\hskip#1\space em\string\relax\space #2% +% \string\vtop{\string\hsize=.7\string\hsize +% \string\noindent\string\raggedright\space #3}\string\par}}\temp + +\def\sectionafterskip{\egroup\nobreak\par\noindent} + +\def\section{\sectiond1} +\def\subsection{\sectiond2} +\def\subsubsection{\sectiond3} +\def\paragraph{\sectiond4} +\def\subparagraph{\sectiond5} + +\let\usingchapters0 + +\def\chapter{\global\let\usingchapters1% +\futurelet\chapternextchar\chapterdispatch} + +\def\chapterdispatch{\ifx\chapternextchar*% + \let\chaptercontinue\chapterstar\else + \tracksectionchangeatlevel{1}% + \def\chaptercontinue{\chapterhelp{\recentlabel\enspace}}\fi + \chaptercontinue} + +\def\chapterstar*{\chapterhelp{}} + +\def\chapterhelp#1{% + % #1=number #2=heading-text + \def\chapternr{#1}% + \immediate\openout\sectionscratchfileport Z-sec-temp + \begingroup + \def\do##1{\catcode`##1=11 }\dospecials + \catcode`\{=1 \catcode`\}=2 + \chapterheader} + +\def\chapterheader#1{\endgroup + \immediate\write\sectionscratchfileport {#1}% + \immediate\closeout\sectionscratchfileport + \tocactivate + {\let\folio0% + \edef\temp{\write\tocout{\string\tocentry{1}{\chapternr}{#1}{\folio}}}% + \temp}% + \vfill\eject + \null\vskip3em + \noindent + \ifx\chapternr\empty\hbox{~}\else + \ifx\doingappendix0% + \hbox{\bf Chapter \chapternr}\else + \hbox{\bf Appendix \chapternr}\fi\fi + \vskip 1em + \noindent + \hbox{\bf\vtop{%\hsize=.7\hsize + \pretolerance 10000 + \noindent\raggedright\input Z-sec-temp }}% + \bgroup\let\par\chapterafterskip} + +\def\chapterafterskip{\egroup\nobreak\vskip3em \noindent} + +\let\doingappendix=0 + +\def\appendix{\let\doingappendix=1% + \count255=`\A% + \advance\count255 by -1 + \expandafter\edef\csname + sectionnumber1\endcsname{\the\count255 }} + + +% toc + +\let\tocactive0 + +\newcount\tocdepth + +\tocdepth=10 + +\def\tocoutensure{\ifx\tocout\UNDEFINED + \csname newwrite\endcsname\tocout\fi} + +\def\tocactivate{\ifx\tocactive0% + \tocoutensure + \tocsave + \openout\tocout \jobname.toc + \global\let\tocactive1\fi} + +\def\tocspecials{\def\do##1{\catcode`##1=12 }\dospecials} + +\def\tocsave{\openin0=\jobname.toc + \ifeof0 \closein0 \else + \openout\tocout Z-T-\jobname.tex + \let\tocsaved 0% + \loop + \ifeof0 \closeout\tocout + \let\tocsaved1% + \else{\tocspecials + \read0 to \tocsaveline + \edef\temp{\write\tocout{\tocsaveline}}\temp}% + \fi + \ifx\tocsaved0% + \repeat + \fi + \closein0 } + +\def\tocentry#1#2{% + %#1=depth #2=secnum + \ifnum#1=1 + \ifnum\tocdepth>2 + \medbreak\begingroup\bf + \else\begingroup\fi + \else\begingroup\fi + \vtop\bgroup\raggedright + \noindent\hskip #1 em + #2% + \bgroup + \aftergroup\tocentryI + %read section title + \let\dummy=} + +\def\tocentryI#1{% + %#1=page nr + , #1\strut\egroup + \endgroup\par +} + +\def\tableofcontents{% + \ifx\tocactive0% + \openin0 \jobname.toc + \ifeof0 \closein0 \else + \closein0 \input \jobname.toc + \fi + \tocoutensure + \openout\tocout \jobname.toc + \global\let\tocactive1% + \else + \input Z-T-\jobname.tex + \fi} + +% allow {thebibliography} to be used directly +% in (plain-TeX) source document without +% generating it via BibTeX + +\ifx\thebibliography\UnDeFiNeD +\def\thebibliography#1{\vskip-\lastskip + \begingroup + \def\endthebibliography{\endgroup\endgroup}% + \def\input##1 ##2{\relax}% + \setbox0=\hbox{\biblabelcontents{#1}}% + \biblabelwidth=\wd0 + \@readbblfile}% +\fi + +% Cross-references + +% \openxrefout loads all the TAG-VALUE associations in +% \jobname.xrf and then opens \jobname.xrf as an +% output channel that \tag can use + +\def\openxrefout{% + \openin0=\jobname.xrf + \ifeof0 \closein0 + \else \closein0 {\catcode`\\0 \input \jobname.xrf }% + \fi + \expandafter\csname newwrite\endcsname\xrefout + \openout\xrefout=\jobname.xrf +} + +% I'd like to call \openxrefout lazily, but +% unfortunately it produces a bug in MiKTeX. +% So let's call it up front. + +\openxrefout + +% \tag{TAG}{VALUE} associates TAG with VALUE. +% Hereafter, \ref{TAG} will output VALUE. +% \tag stores its associations in \xrefout. +% \tag calls \openxrefout if \jobname.xrf hasn't +% already been opened + +\def\tag#1#2{\ifx\xrefout\UNDEFINED\openxrefout\fi + {\let\folio0% + \edef\temp{% + \write\xrefout{\string\expandafter\string\gdef + \string\csname\space XREF#1\string\endcsname + {#2}\string\relax}}% + \temp}} + +% \tagref{TAG} outputs VALUE, assuming \tag put such +% an association into \xrefout. \tagref calls +% \openxrefout if \jobname.xrf hasn't already +% been opened + +% Later, we will \let \ref = \tagref after making +% sure we aren't in eplain, which uses the ctlseq +% \ref differently + +\def\tagref#1{\ifx\xrefout\UNDEFINED\openxrefout\fi + \expandafter\ifx\csname XREF#1\endcsname\relax + %\message or \write16 ? + \message{\the\inputlineno: Unresolved label `#1'.}?\else + \csname XREF#1\endcsname\fi} + +% \label, as in LaTeX + +\let\recentlabel\relax + +% The sectioning commands +% define \recentlabel so a subsequent call to \label will pick up the +% right label. + +\def\label#1{\tag{#1}{\recentlabel}% + \tag{PAGE#1}{\folio}} + +% \pageref, as in LaTeX + +\def\pageref#1{\ref{PAGE#1}} + +% eplain users see the \ref they are used to. Others +% have \ref = \tagref + +\ifx\eplain\UnDeFiNeD +\let\ref\tagref +\fi + +% + +\ifx\IfFileExists\UnDeFiNeD +\def\IfFileExists#1#2#3{% + \openin0 #1 % + \ifeof0 % + #3% + \else + #2\fi + \closein0 }% +\fi + +\ifx\InputIfFileExists\UnDeFiNeD +\def\InputIfFileExists#1#2#3{% + \IfFileExists{#1}{#2\input #1 }{#3}}% +\fi + +\let\iffileexists\IfFileExists + +% + +% dummy def to let load dvipsnam.def + +\ifx\ProvidesFile\UnDeFiNeD +\def\ProvidesFile#1[#2]{}% +\fi + +% + +% Index generation +% +% Your TeX source contains \index{NAME} to +% signal that NAME should be included in the index. +% Check the makeindex documentation to see the various +% ways NAME can be specified, eg, for subitems, for +% explicitly specifying the alphabetization for a name +% involving TeX control sequences, etc. +% +% The first run of TeX will create \jobname.idx. +% makeindex on \jobname[.idx] will create the sorted +% index \jobname.ind. +% +% Use \inputindex (without arguments) to include this +% sorted index, typically somewhere to the end of your +% document. This will produce the items and subitems. +% It won't produce a section heading however -- you +% will have to typeset one yourself. +% +% Use \printindex instead of \inputindex if you want +% the section heading ``Index'' automatically generated. + +\def\sanitizeidxletters{\def\do##1{\catcode`##1=11 }% + \do\\\do\$\do\&\do\#\do\^\do\_\do\%\do\~% + \do\@\do\"\do\!\do\|\do\-\do\ \do\'} + +\def\index{%\unskip + \ifx\indexout\UNDEFINED + \csname newwrite\endcsname\indexout + \openout\indexout \jobname.idx\fi + \begingroup + \sanitizeidxletters + \indexI} + +\def\indexI#1{\endgroup + \write\indexout{\string\indexentry{#1}{\folio}}% + \ignorespaces} + +% The following index style indents subitems on a +% separate lines + +\def\theindex{\begingroup + \parskip0pt \parindent0pt + \def\indexitem##1{\par\hangindent30pt \hangafter1 + \hskip ##1 }% + \def\item{\indexitem{0em}}% + \def\subitem{\indexitem{2em}}% + \def\subsubitem{\indexitem{4em}}% + \def\see{{\it see} \bgroup\aftergroup\gobblegroup\let\dummy=}% + \let\indexspace\medskip} + +\def\endtheindex{\endgroup} + +% \packindex declares that subitems be bundled into one +% semicolon-separated paragraph + +\def\packindex{% + \def\theindex{\begingroup + \parskip0pt \parindent0pt + \def\item{\par\hangindent20pt \hangafter1 }% + \def\subitem{\unskip; }% + \def\subsubitem{\unskip; }% + \def\see{\bgroup\it see \aftergroup\gobblegroup\let\dummy=}% + \let\indexspace\medskip}} + +\def\inputindex{% + \openin0 \jobname.ind + \ifeof0 \closein0 + \message{\jobname.ind missing.}% + \else\closein0 + \begingroup + \def\begin##1{\csname##1\endcsname}% + \def\end##1{\csname end##1\endcsname}% + \input\jobname.ind + \endgroup\fi} + +\def\printindex{\csname beginsection\endcsname Index\par + \inputindex} + +% + +\def\italiccorrection{\futurelet\italiccorrectionI + \italiccorrectionII} + +\def\italiccorrectionII{% + \if\noexpand\italiccorrectionI,\else + \if\noexpand\italiccorrectionI.\else + \/\fi\fi} + +\def\em{\it\ifmmode\else\aftergroup\italiccorrection\fi} + +%\def\emph{\bgroup\it +% \ifmmode\else\aftergroup\italiccorrection\fi +% \let\dummy=} + +\def\quote{\bgroup\narrower\smallbreak} +\def\endquote{\smallbreak\egroup} + +\def\begin#1{\begingroup + \def\end##1{\csname end#1\endcsname\endgroup}% + \csname #1\endcsname} + +\def\raggedleft{% + \leftskip 0pt plus 1fil + \parfillskip 0pt +} + +\def\r#1{{\accent23 #1}} + + +\ifx\strip@pt\UNDEFINED +\begingroup + \catcode`P 12 \catcode`T 12 + \lowercase{\endgroup + \gdef\strip@pt#1PT{#1}}% +\fi + +% color + +\ifx\color\UnDeFiNeD +% +\ifx\pdfoutput\UnDeFiNeD % PostScript +% +\def\colorCurrentColor{color cmyk 0 0 0 1}% +% +\def\colorRestoreCurrentColor{% +\special{\colorCurrentColor}\egroup\egroup}% +% +\def\colorWithModelrgb#1{\bgroup +\def\colorCurrentColor{color rgb #1}% +\special{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor}% +% +\def\colorWithModelRGBaux#1 #2 #3\end{\bgroup +\dimen0=#1pt \divide\dimen0 by 255 +\edef\red{\expandafter\strip@pt\the\dimen0 }% +\dimen0=#2pt \divide\dimen0 by 255 +\edef\green{\expandafter\strip@pt\the\dimen0 }% +\dimen0=#3pt \divide\dimen0 by 255 +\edef\blue{\expandafter\strip@pt\the\dimen0 }% +\def\colorCurrentColor{color rgb \red\space \green\space \blue}% +\special{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor +\ignorespaces} +% +\def\colorWithModelcmyk#1{\bgroup +\def\colorCurrentColor{color cmyk #1}% +\special{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor}% +% +\def\colorWithModelgray#1{\bgroup +\def\colorCurrentColor{color gray #1}% +\special{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor}% +% +\def\colorWithModelnamed#1{\bgroup +\edef\colorCurrentColor{\csname +ColorNamed#1\endcsname}% +\special{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor}% +% +\def\definecolorWithModelrgb#1#2{\egroup +\expandafter\def\csname ColorNamed#1\endcsname +{color rgb #2}}% +% +\def\definecolorWithModelcmyk#1#2{\egroup +\expandafter\def\csname ColorNamed#1\endcsname +{color cmyk #2}}% +% +\def\definecolorWithModelgray#1#2{\egroup +\expandafter\def\csname ColorNamed#1\endcsname +{color gray #2}}% +% +\else % PDF +% +\def\colorCurrentColor{0 0 0 1 k}% +% +\def\colorRestoreCurrentColor{% +\pdfliteral{\colorCurrentColor}\egroup\egroup}% +% +\def\colorWithModelrgb#1{\bgroup +\def\colorCurrentColor{#1 rg}% +\pdfliteral{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor +\ignorespaces}% +% +\def\colorWithModelRGBaux#1 #2 #3\end{\bgroup +\dimen0=#1pt \divide\dimen0 by 255 +\edef\red{\expandafter\strip@pt\the\dimen0 }% +\dimen0=#2pt \divide\dimen0 by 255 +\edef\green{\expandafter\strip@pt\the\dimen0 }% +\dimen0=#3pt \divide\dimen0 by 255 +\edef\blue{\expandafter\strip@pt\the\dimen0 }% +\def\colorCurrentColor{\red\space \green\space \blue\space rg}% +\pdfliteral{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor +\ignorespaces} +% +\def\colorWithModelcmyk#1{\bgroup +\def\colorCurrentColor{#1 k}% +\pdfliteral{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor +\ignorespaces}% +% +\def\colorWithModelgray#1{\bgroup +\def\colorCurrentColor{#1 g}% +\pdfliteral{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor +\ignorespaces}% +% +\def\colorWithModelnamed#1{\bgroup +\edef\colorCurrentColor{\csname +ColorNamed#1\endcsname}% +\pdfliteral{\colorCurrentColor}% +\aftergroup\colorRestoreCurrentColor +\ignorespaces}% +% +\def\definecolorWithModelrgb#1#2{\egroup +\expandafter\def\csname ColorNamed#1\endcsname +{#2 rg}}% +% +\def\definecolorWithModelcmyk#1#2{\egroup +\expandafter\def\csname ColorNamed#1\endcsname +{#2 k}}% +% +\def\definecolorWithModelgray#1#2{\egroup +\expandafter\def\csname ColorNamed#1\endcsname +{#2 g}}% +% +\fi +% +\def\color{\futurelet\colorQpeekchar\colorQpossiblynamed}% +% +\def\colorQpossiblynamed{\bgroup +\defcsactive\,{ }% +\if\colorQpeekchar[% +\let\colorQproceed\colorQexplicitmodel\else +\let\colorQproceed\colorWithModelnamed\fi +\colorQproceed}% +% +\def\colorQexplicitmodel[#1]{% +\csname colorWithModel#1\endcsname}% +% +\def\colorWithModelRGB#1{% +\colorWithModelRGBaux#1\end}% +% +\def\definecolor#1#2{\bgroup +\defcsactive\,{ }% +\csname definecolorWithModel#2\endcsname{#1}}% +% +% foll lets load texmf/tex/latex/graphics/dvipsnam.def +\def\DefineNamedColor#1{\definecolor}% +% +% these colors are standard in latex +\definecolor{red}{rgb}{1 0 0}% +\definecolor{green}{rgb}{0 1 0}% +\definecolor{blue}{rgb}{0 1 1}% +\definecolor{cyan}{cmyk}{1 0 0 0}% +\definecolor{magenta}{cmyk}{0 1 0 0}% +\definecolor{yellow}{cmyk}{0 0 1 0}% +\definecolor{black}{cmyk}{0 0 0 1}% +\definecolor{white}{rgb}{1 1 1}% +% +\fi + +%the rest of the file isn't needed for eplain? + +\def\itemize{\par\begingroup + \advance\leftskip\parindent + \smallbreak + \def\item{\smallbreak\noindent + \llap{$\bullet$\enspace}\ignorespaces}} + +\def\enditemize{\smallbreak\smallbreak\endgroup\par} + +\newtally\enumeratelevel + +\def\enumerate{\par\begingroup + \advancetally\enumeratelevel1% + \newtally\enumeratenumber + \advance\leftskip\parindent + \smallbreak + \def\item{\smallbreak\noindent + \advancetally\enumeratenumber1% + \ifnum\enumeratelevel=1 + \edef\enumeratemark{\enumeratenumber}\else + \ifnum\enumeratelevel=2 + \count255=\enumeratenumber + \advance\count255 by -1 \advance\count255 by `a + \edef\enumeratemark{\noexpand\char\the\count255 }\else + \ifnum\enumeratelevel=3 + \edef\enumeratemark{\romannumeral\enumeratenumber}\else + \ifnum\enumeratelevel=4 + \count255=\enumeratenumber + \advance\count255 by -1 \advance\count255 by `A + \edef\enumeratemark{\noexpand\char\the\count255 }\else + \edef\enumeratemark{\enumeratenumber}\fi\fi\fi\fi + \edef\recentlabel{\enumeratemark}% needed? + \llap{\enumeratemark.\enspace}\ignorespaces}} + +\def\endenumerate{\smallbreak\smallbreak\endgroup\par} + +% Numbered footnotes + +\ifx\plainfootnote\UNDEFINED + \let\plainfootnote\footnote +\fi + +\newtally\footnotenumber + +\def\numfootnote{\globaladvancetally\footnotenumber 1% + \bgroup\csname footnotehook\endcsname + \plainfootnote{$^{\footnotenumber}$}\bgroup + \edef\recentlabel{\footnotenumber}% + \aftergroup\egroup + \let\dummy=} + +\let\f\numfootnote + +\ifx\frac\UnDeFiNeD +\def\frac#1/#2{{#1\over#2}}% +\fi + +% \path is like \verb except that its argument +% can break across lines at `.' and `/'. + +\ifx\path\UnDeFiNeD +\def\path{\begingroup\verbsetup + \pathfont + \defcsactive\.{\discretionary{\char`\.}{}{\char`\.}}% + \defcsactive\/{\discretionary{\char`\/}{}{\char`\/}}% + \verbI}% +\fi + +\let\pathfont\relax + +\catcode`\@\atcatcodebeforetiip + +\endtexonly + +% end of file hunk ./examples/README 1 +These examples illustrate the various uses of hs-plugins. + +conf a configuration file edsl using plugins +dynload dynamically typed load +eval runtime evaluation of haskell strings, from Haskell and C +hmake the 'plugs' haskell interpreter +iface test the interface file parser +load load a plugin +make build a Haskell file +makewith merge and build a Haskell file +multi load multiple plugins at once +objc load Haskell plugins into object C programs +pkgconf test package.conf parsing +popen test popen +reload reload a plugin when it changes +shell a simple string filter +unload test unloading of plugins hunk ./examples/TIMINGS 1 +Method: + * "pdynload" + comes from pdynload/small + * "load + ghc" + comes from pdynload/null, with lines 13-14 + uncommented from prog/Main.hs + * "dynload" + from dynload/simple + * "load, no check" + from pdynload/null, with lines 13-14 of prog/Main.hs + commented out + +For example, to run the "pdynload" test: + $ cd pdynload/small + $ make + $ make check # to prime caches, etc. + $ time make check + $ time make check + $ time make check # run 'time make check' until value converges + +The converged value is entered into the "Raw" timings, and then the +scaled timing is calculated for each machine. These scaled values were +then averaged over the number of machines, yielding the final +"Average" scores -- the average over a number of machines and os. + +Raw timing: +pdynload load+ghc dynload load, no check + +0.33 0.25 0.22 0.21 -- P4 2.6 , OpenBSD +0.38 0.31 0.29 0.27 -- P4 2.66, Linux +0.84 0.77 0.64 0.55 -- Quad P4 2.4, Linux +0.76 0.60 0.52 0.50 -- AMD 1.1G, Linux +0.95 0.83 0.75 0.72 -- G5 2.0G, Mac OS X + -- Quad Itanium 1,Linux + +Scaled: +1.57 1.19 1.05 1 +1.40 1.15 1.07 +1.52 1.4 1.16 +1.52 1.2 1.04 +1.32 1.15 1.04 + +Average: +=1.46 = 1.218 = 1.07 + hunk ./examples/build.mk 1 +# how to build the default projects + +include $(TOP)/config.mk +include $(TOP)/examples/check.mk + +BIN= prog/a.out +OBJ= prog/Main.o +SRC= prog/Main.hs + +BINDIR= prog +REALBIN= ./a.out + +API_OBJ= api/API.o + +INCLUDES= -i$(TOP)/examples/$(TEST)/api +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package plugins +GHCFLAGS= -Onot -cpp -fglasgow-exts + +.SUFFIXES : .o .hs .hi .lhs .hc .s + +all: $(BIN) + +$(BIN) : $(PRIOR_OBJS) $(API_OBJ) $(SRC) $(EXTRA_OBJS) + @rm -f $@ + @$(GHC) --make -o $@ $(INCLUDES) $(PKGFLAGS) $(GHCFLAGS) $(EXTRAFLAGS) $(API) $(SRC) + +# Standard suffix rules +.o.hi: + @: +.hs.o: + @$(GHC) $(INCLUDES) $(PKGFLAGS) $(GHCFLAGS) $(EXTRAFLAGS) -c $< + +clean: + find . -name '*~' -exec rm {} \; + rm -rf *.{o,hi,dep} + rm -rf */*.{hi,o,old} */a.out + rm -rf */*core + rm -rf */*.a + rm -rf */package.conf + rm -rf *.a + hunk ./examples/check.mk 1 +include $(TOP)/config.mk + +check: $(BIN) + @(cd $(BINDIR) ;\ + expected="expected" ;\ + if [ -f "expected" -o -f "expected.$(GLASGOW_HASKELL)" ] ;\ + then \ + actual_out="/tmp/hs-plugins-actual.out.$$$$" ;\ + diff_out="/tmp/hs-plugins.diff.$$$$" ;\ + $(REALBIN) > $$actual_out 2>&1 || true ;\ + if [ -f "expected.$(GLASGOW_HASKELL)" ] ; then \ + expected="expected.$(GLASGOW_HASKELL)" ;\ + fi ;\ + diff -u $$expected $$actual_out > $$diff_out || true ;\ + if [ -s "$$diff_out" ] ; then \ + echo "failed with:" ;\ + cat "$$diff_out" | sed '1,3d' ;\ + else \ + echo "ok." ;\ + fi ;\ + rm $$actual_out $$diff_out ;\ + else \ + $(REALBIN) 2>&1 || true ;\ + fi) hunk ./examples/conf/simple/Mailrc.conf 1 +import System.Directory + +resource = mail { +-- editor = do b <- doesFileExist "/usr/bin/emacs" +-- return $ if b then "emacs" else "vi" , + editor = do b <- doesFileExist "/bin/sh" + return "sh", + + attribution = \name -> "Today, "++name++" wrote :" +} + hunk ./examples/conf/simple/Mailrc.stub 1 +module Mailrc ( resource ) where + +import API + +resource :: Interface +resource = mail + + + + + + + + + + + + + + + + + + + + + + hunk ./examples/conf/simple/Makefile 1 +TEST= conf/simple + +TOP=../../.. +include ../../build.mk hunk ./examples/conf/simple/api/API.hs 1 +-- +-- the configuration file interface. +-- + +module API where + +data Color = Black | Grey | Green | Cyan | Yellow | Magenta | Red + +data Interface = Interface { + editor :: IO String, + attribution :: String -> String, + header_color :: Color, + colorize :: [String], + include :: Bool + } + +-- Default settings +mail :: Interface +mail = Interface { + editor = return "vi", + + attribution = (\user -> user ++ " wrote:"), + header_color = Grey, + colorize = [], + include = True + } + hunk ./examples/conf/simple/prog/Main.hs 1 + +import Plugins +import API + +conf = "../Mailrc.conf" +stub = "../Mailrc.stub" +apipath = "../api" + +main = do + status <- makeWith conf stub ["-i"++apipath] + o <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess _ o -> return o + status <- load o [apipath] [] "resource" + v <- case status of + LoadFailure err -> mapM_ putStrLn err >> error "no" + LoadSuccess _ v -> return v + + user_editor <- editor v + putStrLn user_editor + makeCleaner o + hunk ./examples/conf/simple/prog/expected 1 +sh hunk ./examples/dynload/io/Makefile 1 +TEST=dynload/io + +EXTRA_OBJS=TestIO.o + +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/io/TestIO.hs 1 +{-# OPTIONS -fglasgow-exts -cpp #-} +-- +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +-- + +module TestIO ( resource_dyn ) where + +import API +import AltData + +import System.IO +import System.Posix.Types ( ProcessID, Fd ) +import System.Posix.Process ( forkProcess, executeFile, getProcessID ) +import System.Posix.IO ( createPipe, stdInput, + stdOutput, fdToHandle, closeFd, dupTo ) + +resource_dyn :: Dynamic +resource_dyn = toDyn resource + +resource :: TestIO +resource = testio { field = date } + + +-- +-- call a shell command , returning it's output +-- +date :: IO String +date = do (hdl,_,_) <- catch (popen "/bin/date") (\_->error "popen failed") + hGetLine hdl + +------------------------------------------------------------------------ +-- +-- my implementation of $val = `cmd`; (if this was perl) +-- +-- provide similar functionality to popen(3), +-- along with bidirectional ipc via pipes +-- return's the pid of the child process +-- +-- there are two different forkProcess functions. the pre-620 was a +-- unix-fork style function, and the modern function has semantics more +-- like the Awkward-Squad paper. We provide implementations of popen +-- using both versions, depending on which GHC the user wants to try. +-- + +popen :: FilePath -> IO (Handle, Handle, ProcessID) +popen cmd = do + (pr, pw) <- createPipe + (cr, cw) <- createPipe + + -- parent -- + let parent = do closeFd cw + closeFd pr + -- child -- + let child = do closeFd pw + closeFd cr + exec cmd (pr,cw) + error "exec cmd failed!" -- typing only + +-- if the parser front end understood cpp, this would work +-- #if __GLASGOW_HASKELL__ >= 601 + pid <- forkProcess child -- fork child + parent -- and run parent code +-- #else +-- p <- forkProcess +-- pid <- case p of +-- Just pid -> parent >> return pid +-- Nothing -> child +-- #endif + + hcr <- fdToHandle cr + hpw <- fdToHandle pw + + return (hcr,hpw,pid) + +-- +-- execve cmd in the child process, dup'ing the file descriptors passed +-- as arguments to become the child's stdin and stdout. +-- +exec :: FilePath -> (Fd,Fd) -> IO () +exec cmd (pr,cw) = do + dupTo pr stdInput + dupTo cw stdOutput + executeFile cmd False [] Nothing + +------------------------------------------------------------------------ hunk ./examples/dynload/io/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import AltData + +data TestIO = TestIO { + field :: IO String + } + +instance Typeable TestIO where +#if __GLASGOW_HASKELL__ >= 603 + typeOf i = mkTyConApp (mkTyCon "API.TestIO") [] +#else + typeOf i = mkAppTy (mkTyCon "API.TestIO") [] +#endif + +testio :: TestIO +testio = TestIO { field = return "default value" } hunk ./examples/dynload/io/prog/Main.hs 1 + +import Plugins +import API + +main = do + m_v <- dynload "../TestIO.o" ["../api"] + ["../../../../plugins.conf.inplace"] "resource_dyn" + case m_v of + LoadFailure _ -> error "couldn't compile" + LoadSuccess _ v -> do + s <- field v + if s /= [] then print True else print False hunk ./examples/dynload/io/prog/expected 1 +True hunk ./examples/dynload/poly/Makefile 1 +TEST=dynload/poly +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/poly/Plugin.hs 1 +module Plugin where + +import API +import AltData + +my_fun = plugin { + equals = \x y -> (x /= y) -- a strange equals function :) + } + +resource_dyn :: Dynamic +resource_dyn = toDyn my_fun + hunk ./examples/dynload/poly/api/API.hs 1 +{-# OPTIONS -cpp #-} + +module API where + +import AltData + +data Interface = Interface { + equals :: forall t. Eq t => t -> t -> Bool + } + +-- +-- see how it hides the internal type.. but to compile GHC still checks +-- the type. +-- +instance Typeable Interface where +#if __GLASGOW_HASKELL__ >= 603 + typeOf i = mkTyConApp (mkTyCon "API.Interface") [] +#else + typeOf i = mkAppTy (mkTyCon "API.Interface") [] +#endif + +plugin :: Interface +plugin = Interface { equals = (==) } + hunk ./examples/dynload/poly/prog/Main.hs 1 +{-# OPTIONS -cpp #-} + +#include "../../../../config.h" + +import Plugins +import API + +main = do + m_v <- dynload "../Plugin.o" ["../api"] + ["../../../../plugins.conf.inplace"] + "resource_dyn" + case m_v of + LoadFailure _ -> error "didn't compile" + LoadSuccess _ (Interface eq) -> do + putStrLn $ show $ 1 `eq` 2 + putStrLn $ show $ 'a' `eq` 'b' + hunk ./examples/dynload/poly/prog/expected 1 +True +True hunk ./examples/dynload/should_fail/Makefile 1 +TEST= dynload/should_fail +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/should_fail/Plugin.hs 1 +{-# OPTIONS -fglasgow-exts #-} +module Plugin where + +import API +import AltData + +v :: Int +v = 0xdeadbeef + +resource_dyn :: Dynamic +resource_dyn = toDyn v + hunk ./examples/dynload/should_fail/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import AltData + +data Interface = Interface { + function :: String + } + +instance Typeable Interface where +#if __GLASGOW_HASKELL__ >= 603 + typeOf i = mkTyConApp (mkTyCon "API.Interface") [] +#else + typeOf i = mkAppTy (mkTyCon "API.Interface") [] +#endif + +plugin :: Interface +plugin = Interface { function = "goodbye" } + hunk ./examples/dynload/should_fail/prog/Main.hs 1 + +import Plugins +import API + +main = do + m_v <- dynload "../Plugin.o" + ["../api"] + ["../../../../plugins.conf.inplace"] + "resource_dyn" + + case m_v of + LoadFailure _ -> putStrLn "didn't compile" + LoadSuccess _ v -> putStrLn $ function v + hunk ./examples/dynload/should_fail/prog/expected 1 +Couldn't match `API.Interface' against `Int' + Expected type: API.Interface + Inferred type: Int +didn't compile hunk ./examples/dynload/should_fail_1/Makefile 1 +TEST= dynload/should_fail_1 +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/should_fail_1/Plugin.hs 1 +-- +-- trying to be really mean. +-- + +module Plugin where + +import API +import AltData + +v :: Int -> Int +v = \x -> 0xdeadbeef + +resource_dyn :: Dynamic +resource_dyn = toDyn v + hunk ./examples/dynload/should_fail_1/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import AltData + +data Interface = Interface { + function :: String + } + +instance Typeable Interface where +#if __GLASGOW_HASKELL__ >= 603 + typeOf i = mkTyConApp (mkTyCon "API.Interface") [] +#else + typeOf i = mkAppTy (mkTyCon "API.Interface") [] +#endif + +plugin :: Interface +plugin = Interface { function = "goodbye" } + hunk ./examples/dynload/should_fail_1/prog/Main.hs 1 + +import Plugins +import API + +main = do + m_v <- dynload "../Plugin.o" ["../api"] + ["../../../../plugins.conf.inplace"] "resource_dyn" + case m_v of + LoadFailure _ -> putStrLn "didn't compile" + LoadSuccess _ v -> putStrLn $ (function v) + hunk ./examples/dynload/should_fail_1/prog/expected 1 +Couldn't match `API.Interface' against `Int -> Int' + Expected type: API.Interface + Inferred type: Int -> Int +didn't compile hunk ./examples/dynload/should_fail_2/Makefile 1 +TEST= dynload/should_fail_2 + +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/should_fail_2/Plugin.in 1 +-- +-- the plugin doesn't even make the resource_dyn a Dynamic. +-- +-- let's hope that makeWith strips out the invalid declarations +-- + +{-# OPTIONS -fglasgow-exts #-} + +module Plugin where + +import API +import AltData +import GHC.Base + +v :: Int +v = 0xdeadbeef + +resource_dyn = (typeOf v, unsafeCoerce v) + hunk ./examples/dynload/should_fail_2/Plugin.stub 1 +{-# OPTIONS -fglasgow-exts #-} + +module Plugin ( resource_dyn ) where + +import API +import AltData + +resource = plugin + +resource_dyn :: Dynamic +resource_dyn = toDyn resource + hunk ./examples/dynload/should_fail_2/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import AltData +import GHC.Base + +data Interface = Interface { + function :: String + } + +instance Typeable Interface where +#if __GLASGOW_HASKELL__ >= 603 + typeOf i = mkTyConApp (mkTyCon "API.Interface") [] +#else + typeOf i = mkAppTy (mkTyCon "API.Interface") [] +#endif + +plugin :: Interface +plugin = Interface { function = "goodbye" } + +unsafeCoerce = unsafeCoerce# hunk ./examples/dynload/should_fail_2/prog/Main.hs 1 + +import Plugins +import API + +conf = "../Plugin.in" +stub = "../Plugin.stub" + +main = do + status <- makeWith conf stub ["-i../api", "-i../../../../src/altdata/"] + case status of + MakeFailure e -> mapM_ putStrLn e >> putStrLn "failed" + MakeSuccess _ o -> do { + ; m_v <- dynload o ["../api"] [] "resource_dyn" + ; makeCleaner o + ; case m_v of + LoadFailure _ -> putStrLn "didn't load" + LoadSuccess _ v -> putStrLn $ (function v) + } + hunk ./examples/dynload/should_fail_2/prog/expected 1 + +../Plugin.in:18: + Couldn't match `Dynamic' against `(t, t1)' + Expected type: Dynamic + Inferred type: (t, t1) + In the definition of `resource_dyn': + resource_dyn = (typeOf v, unsafeCoerce v) +failed hunk ./examples/dynload/should_fail_2/prog/expected.604 1 + +../Plugin.in:18:15: + Couldn't match `Dynamic' against `(a, b)' + Expected type: Dynamic + Inferred type: (a, b) + In the definition of `resource_dyn': resource_dyn = (typeOf v, unsafeCoerce v) +failed hunk ./examples/dynload/should_fail_3/Makefile 1 +TEST= dynload/should_fail_3 + +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/should_fail_3/Plugin.in 1 +-- +-- the plugin doesn't even make the resource_dyn a Dynamic. +-- let's hope that makeWith strips out the invalid declarations +-- + +{-# OPTIONS -fglasgow-exts #-} + +module Plugin where + +import API + +import AltData +import GHC.Base + +v :: Int +v = 0xdeadbeef + +resource_dyn = (typeOf plugin, unsafeCoerce v) + hunk ./examples/dynload/should_fail_3/Plugin.stub 1 +{-# OPTIONS -fglasgow-exts #-} + +module Plugin ( resource_dyn ) where + +import API +import AltData.Dynamic + +resource = plugin + +resource_dyn :: Dynamic +resource_dyn = toDyn resource + hunk ./examples/dynload/should_fail_3/api/API.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} + +module API where + +import AltData +import GHC.Base + +data Interface = Interface { + function :: String + } + +instance Typeable Interface where +#if __GLASGOW_HASKELL__ >= 603 + typeOf _ = mkTyConApp (mkTyCon "API.Interface") [] +#else + typeOf _ = mkAppTy (mkTyCon "API.Interface") [] +#endif + +plugin :: Interface +plugin = Interface { function = "goodbye" } + +unsafeCoerce = unsafeCoerce# hunk ./examples/dynload/should_fail_3/prog/Main.hs 1 + +import Plugins +import API + +conf = "../Plugin.in" +stub = "../Plugin.stub" + +main = do + status <- makeWith conf stub ["-i../api", "-i../../../../src/altdata"] + o <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess _ o -> return o + m_v <- dynload o ["../api"] [] "resource_dyn" + case m_v of + LoadFailure _ -> error "didn't compile" + LoadSuccess _ v -> do putStrLn $ (function v) + makeCleaner o + hunk ./examples/dynload/should_fail_3/prog/expected 1 + +../Plugin.in:18: + Couldn't match `Dynamic' against `(t, t1)' + Expected type: Dynamic + Inferred type: (t, t1) + In the definition of `resource_dyn': + resource_dyn = (typeOf plugin, unsafeCoerce v) + +Fail: failed hunk ./examples/dynload/should_fail_3/prog/expected.604 1 + +../Plugin.in:18:15: + Couldn't match `Dynamic' against `(a, b)' + Expected type: Dynamic + Inferred type: (a, b) + In the definition of `resource_dyn': + resource_dyn = (typeOf plugin, unsafeCoerce v) +a.out: failed hunk ./examples/dynload/simple/Makefile 1 +TEST=dynload/simple +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/dynload/simple/Plugin.hs 1 +{-# OPTIONS -fglasgow-exts #-} +module Plugin where + +import API +import AltData + +my_fun = plugin { function = "plugin says \"hello\"" } + +resource_dyn :: Dynamic +resource_dyn = toDyn my_fun + hunk ./examples/dynload/simple/api/API.hs 1 +{-# OPTIONS -cpp #-} + +module API where + +import AltData + +data Interface = Interface { + function :: String + } + +instance Typeable Interface where +#if __GLASGOW_HASKELL__ >= 603 + typeOf i = mkTyConApp (mkTyCon "API.Interface") [] +#else + typeOf i = mkAppTy (mkTyCon "API.Interface") [] +#endif + +plugin :: Interface +plugin = Interface { function = "goodbye" } + hunk ./examples/dynload/simple/prog/Main.hs 1 +{-# OPTIONS -cpp #-} + +#include "../../../../config.h" + +import Plugins +import API + +main = do + m_v <- dynload "../Plugin.o" ["../api"] + ["../../../../plugins.conf.inplace"] + "resource_dyn" + case m_v of + LoadFailure _ -> error "didn't compile" + LoadSuccess _ v -> putStrLn $ (function v) + hunk ./examples/dynload/simple/prog/expected 1 +plugin says "hello" hunk ./examples/eval/eval1/Main.hs 1 + +import Eval.Haskell + +main = do i <- eval "1 + 6 :: Int" [] :: IO (Maybe Int) + if isJust i then putStrLn $ show (fromJust i) else return () hunk ./examples/eval/eval1/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/eval1/expected 1 +7 hunk ./examples/eval/eval2/Main.hs 1 +import Eval.Haskell + +main = do m_s <- eval "map toUpper \"haskell\"" ["Data.Char"] + case m_s of + Nothing -> putStrLn "typechecking failed" + Just s -> putStrLn s hunk ./examples/eval/eval2/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/eval2/expected 1 +HASKELL hunk ./examples/eval/eval3/Main.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Should evaluate to '3', unless something goes wrong. +-- +-- Not so bad to use AltData, as it is already derived for all the basic +-- types. Then, just replace deriving Typeable, with hand-derived +-- instance of Typeable (see hs-plugins/examples/eval/eval_fn1/Poly.hs +-- +-- + +#include "../../../config.h" + +import Eval.Haskell +import AltData.Dynamic + +-- import Data.Dynamic + +pkgconf = TOP ++ "/plugins.conf.inplace" + +main = do + a <- return $ toDyn (3::Int) + + m_b <- unsafeEval_ "\\dyn -> fromMaybe (7 :: Int) (fromDyn dyn)" + ["AltData.Dynamic","Data.Maybe"] -- imports + + [ "-package-conf "++pkgconf , "-package altdata" ] + + [ pkgconf ] + [] + + +{- +-- should work, but doesn't. type check fails +-- (due to static vs dynamic typing issue) + + m_b <- unsafeEval_ "\\dyn -> fromMaybe (7 :: Int) (fromDynamic dyn)" + ["Data.Dynamic","Data.Maybe"] [] [] +-} + + case m_b of + Left s -> mapM_ putStrLn s + Right b -> putStrLn $ show (b a :: Int) hunk ./examples/eval/eval3/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/eval3/expected 1 +3 hunk ./examples/eval/eval_/Main.hs 1 + +import Eval.Haskell + +main = do i <- eval_ "Just (7 :: Int)" + ["Maybe"] + ["-fglasgow-exts"] + [] + [] :: IO (Either [String] (Maybe (Maybe Int))) + print i hunk ./examples/eval/eval_/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/eval_/expected 1 +Right (Just (Just 7)) hunk ./examples/eval/eval_fn/Main.hs 1 +-- +-- lambda abstraction! +-- +-- +-- needs unsafeEval because eval has a broken Dynamic check +-- +import Eval.Haskell + +main = do fn <- unsafeEval "(\\(x::Int) -> (x,x))" [] :: IO (Maybe (Int -> (Int,Int))) + when (isJust fn) $ putStrLn $ show $ (fromJust fn) 7 hunk ./examples/eval/eval_fn/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/eval_fn/expected 1 +(7,7) hunk ./examples/eval/eval_fn1/Main.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- +-- polymorphic eval! +-- + +module Main where + +import Poly +import Eval.Haskell + +main = do m_f <- eval "Fn (\\x y -> x == y)" ["Poly"] + when (isJust m_f) $ do + let (Fn f) = fromJust m_f + putStrLn $ show (f True True) + putStrLn $ show (f 1 2) hunk ./examples/eval/eval_fn1/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/eval_fn1/Poly.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +module Poly where + +import AltData.Typeable + +data Fn = Fn {fn :: forall t. Eq t => t -> t -> Bool} + +-- +-- ignore type inside the Fn... is this correct? +-- +instance Typeable Fn where +#if __GLASGOW_HASKELL__ >= 603 + typeOf _ = mkTyConApp (mkTyCon "Poly.Fn") [] +#else + typeOf _ = mkAppTy (mkTyCon "Poly.Fn") [] +#endif hunk ./examples/eval/eval_fn1/expected 1 +True +False hunk ./examples/eval/foreign_eval/Makefile 1 +TOP=../../.. +include ../../foreign.mk hunk ./examples/eval/foreign_eval/README 1 +run a string of Haskell code from a C program. hunk ./examples/eval/foreign_eval/expected 1 +10946 hunk ./examples/eval/foreign_eval/main.c 1 +#include + +#include "EvalHaskell.h" + +int main(int argc, char *argv[]) +{ + int *p; + hs_init(&argc, &argv); + p = hs_eval_i("let fibs = 1:1:zipWith (+) fibs (tail fibs) in fibs !! 20 :: Int"); + if (p == NULL) + printf("failed!\n"); + else + printf("%d\n",*p); + hs_exit(); + return 0; +} hunk ./examples/eval/foreign_eval1/Makefile 1 +TOP=../../.. +include ../../foreign.mk hunk ./examples/eval/foreign_eval1/expected 1 +10946 hunk ./examples/eval/foreign_eval1/main.c 1 +#include + +#include "EvalHaskell.h" + +int main(int argc, char *argv[]) +{ + char *p; + hs_init(&argc, &argv); + p = hs_eval_s("show $ let fibs = 1:1:zipWith (+) fibs (tail fibs) in fibs !! 20"); + if (p == NULL) + printf("failed!\n"); + else + printf("%s\n",p); + hs_exit(); + return 0; +} hunk ./examples/eval/foreign_should_fail/Makefile 1 +TOP=../../.. +include ../../foreign.mk hunk ./examples/eval/foreign_should_fail/expected 1 +:1: parse error on input `in' +failed! hunk ./examples/eval/foreign_should_fail/expected.604 1 +failed! hunk ./examples/eval/foreign_should_fail/main.c 1 +#include + +#include "EvalHaskell.h" + +int main(int argc, char *argv[]) +{ + int *p; + hs_init(&argc, &argv); + p = hs_eval_i("show $ case 1 + 2 in{-wrong-} x -> x"); + if (p == NULL) + printf("failed!\n"); + else + printf("%d\n",*p); + hs_exit(); + return 0; +} hunk ./examples/eval/foreign_should_fail_illtyped/Makefile 1 +TOP=../../.. +include ../../foreign.mk hunk ./examples/eval/foreign_should_fail_illtyped/expected 1 +Couldn't match `Int' against `[Char]' + Expected type: Int + Inferred type: [Char] +failed! hunk ./examples/eval/foreign_should_fail_illtyped/expected.604 1 +failed! hunk ./examples/eval/foreign_should_fail_illtyped/main.c 1 +#include + +#include "EvalHaskell.h" + +int main(int argc, char *argv[]) +{ + int *p; + hs_init(&argc, &argv); + p = hs_eval_i("\"an ill-typed string\""); + if (p == NULL) + printf("failed!\n"); + else + printf("%d\n",*p); + hs_exit(); + return 0; +} hunk ./examples/eval/unsafeidir/Main.hs 1 + +import Plugins.Make +import Eval.Haskell + +main = do make "a/Extra.hs" [] + + i <- unsafeEval_ "show (Just (1 + 6 :: Int)) ++ extra" + ["Data.Maybe", "Extra"] + ["-ia"] -- no make flags + [] -- no package.confs + ["a"] -- include paths to load from + :: IO (Either [String] String) + + case i of + Right i -> putStrLn $ show i + Left es -> mapM_ putStrLn es hunk ./examples/eval/unsafeidir/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/eval/unsafeidir/a/Extra.hs 1 +module Extra where + +extra = "an extra value" hunk ./examples/eval/unsafeidir/expected 1 +"Just 7an extra value" hunk ./examples/eval.mk 1 +include $(TOP)/config.mk +include $(TOP)/examples/check.mk + +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package eval -package plugins -package printf + +BIN=a.out +SRC=Main.hs + +BINDIR= "." +REALBIN= ./$(BIN) + +.SUFFIXES : .o .hs .hi .lhs .hc .s + +all: $(BIN) + +$(BIN): $(SRC) $(OBJS) + @rm -f $@ + @$(GHC) --make -fglasgow-exts $(GHCFLAGS) $(PKGFLAGS) $(EXTRAFLAGS) $(SRC) + +# Standard suffix rules +.o.hi: + @: +.hs.o: + @$(GHC) $(INCLUDES) $(PKGFLAGS) $(GHCFLAGS) $(EXTRAFLAGS) -c $< + +clean: + rm -rf *.hi *.o *~ $(BIN) hunk ./examples/foreign.mk 1 +include $(TOP)/config.mk +include $(TOP)/examples/check.mk + + +INCLUDES= -I$(TOP) +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package eval + +# compile with GHC to save us setting all the necessary include and +# lib flags. use ghc -v to find out what these are if you wish to go +# via gcc. +BIN=./a.out +SRC=main.c + +BINDIR= "." +REALBIN= $(BIN) + +all: $(BIN) + +$(BIN): $(SRC) + @$(GHC) $(INCLUDES) $(PKGFLAGS) $(SRC) + +clean: + rm -rf *.hi *.o *~ $(BIN) hunk ./examples/hier/hier1/Makefile 1 +TEST= hier/hier1 + +EXTRA_OBJS=Plugin.o +PRIOR_OBJS=Modules/Flags.o +EXTRAFLAGS= + +TOP=../../.. +include ../../build.mk hunk ./examples/hier/hier1/Modules/Flags.hs 1 +-- +-- A simple module +-- + +module Modules.Flags where + + +data FlagRec = FlagRec { + f1 :: Int, + f2 :: Int +} + + +foo :: FlagRec -> Int +foo x = f1 x hunk ./examples/hier/hier1/Modules/Makefile 1 + +all: + ghc -O -c Flags.hs + +clean: + rm -f *.hi *.o hunk ./examples/hier/hier1/Plugin.hs 1 +-- +-- Plugin +-- + +module Plugin where + +import API +import Modules.Flags as Flags + + +resource = plugin { + dbFunc = (\x -> Flags.f1 x) +} + hunk ./examples/hier/hier1/api/API.hs 1 +-- +-- API for plugin test +-- + +module API where + +import Modules.Flags as Flags + +data Interface = Interface { + dbFunc :: Flags.FlagRec -> Int +} + + +plugin :: Interface +plugin = Interface { dbFunc = (\x -> 1) } + hunk ./examples/hier/hier1/prog/Main.hs 1 +-- +-- Test multiple plugins +-- + + +module Main where + +import Plugins +import API +import Modules.Flags as Flags + + +rec = Flags.FlagRec { Flags.f1 = 4, Flags.f2 = 10 } + + +main = do + status <- load "../Plugin.o" ["../api",".."] [] "resource" + case status of + LoadFailure _ -> error "load failed" + LoadSuccess _ v -> do let func = dbFunc v + print (func rec) hunk ./examples/hier/hier1/prog/expected 1 +4 hunk ./examples/hier/hier2/A/B/C/Module.hs 1 +-- +-- A simple module +-- + +module A.B.C.Module where + +symbol = "You found me" + hunk ./examples/hier/hier2/A/Makefile 1 + +all: + ghc -c B/C/Module.hs + + +clean: + rm -f B/C/*.hi B/C/*.o hunk ./examples/hier/hier2/Makefile 1 +TEST= hier/hier2 + +PRIOR_OBJS=A/B/C/Module.o +EXTRAFLAGS= + +TOP=../../.. +include ../../build.mk hunk ./examples/hier/hier2/api/API.hs 1 +module API where + +-- just a dummy for the build system + hunk ./examples/hier/hier2/prog/Main.hs 1 +-- +-- Test if we can load a module with a hierarchical name from some weird +-- path. Tests our the module name handling in the .hi file parser. +-- + + +module Main where + +import Plugins + +main = do + status <- load "../A/B/C/Module.o" [".."] [] "symbol" + case status of + LoadFailure ers -> mapM_ putStrLn ers + LoadSuccess _ v -> print (v :: String) hunk ./examples/hier/hier2/prog/expected 1 +"You found me" hunk ./examples/hier/hier3/Main.hs 1 +module Main where + +import Plugins + +main = do + + makeAll "One.hs" [] + + load2 "Two.o" + + load2 "./Two.o" -- shouldn't load + load2 "../hier3/Two.o" -- shouldn't load + load2 "././././Two.o" -- shouldn't load + + -- and this one pulls in "../hier3/Two.o" as a dep + y <- load "One.o" ["../hier3"] [] "resource" + case y of + LoadSuccess _ s -> putStrLn $ "One plugin: " ++ s + LoadFailure _ -> putStrLn "Failure: y" + +load2 f = do + x <- load f [".", "../hier3", ""] [] "resource" -- depend on One.o + case x of + LoadSuccess _ s -> putStrLn $ "Two plugin: " ++ s + LoadFailure _ -> putStrLn "Failure: x" hunk ./examples/hier/hier3/Makefile 1 +TEST= hier/hier3 + +EXTRA_OBJS=One.o Two.o +EXTRAFLAGS= + +TOP=../../.. +include ../../eval.mk hunk ./examples/hier/hier3/One.hs 1 + +module One where + +import qualified Two + +resource = "This is the sub-plugin of (" ++ Two.resource ++ ")" + hunk ./examples/hier/hier3/Two.hs 1 +module Two where + +resource = "This is the top plugin" + hunk ./examples/hier/hier3/expected 1 +Two plugin: This is the top plugin +Two plugin: This is the top plugin +Two plugin: This is the top plugin +Two plugin: This is the top plugin +One plugin: This is the sub-plugin of (This is the top plugin) hunk ./examples/hier/hier4/A.hs 1 + +-- now, the question is: is it possible to not depend on a module or +-- package, but nonetheless have an orphan to it? this could cause +-- problems.... + +module A where + +import B + +u :: Int +u = undefined hunk ./examples/hier/hier4/B.hs 1 +module B where + +import C () -- instances, to make available to those who use B + hunk ./examples/hier/hier4/C.hs 1 + +-- try to construct an orphan module == an instance decl-only module, +-- that uses classes and types not defined in this module + +module C (C) where + +import D + +instance C a => D (T a) where + +class C a where + hunk ./examples/hier/hier4/D.hs 1 + +module D where + +class D a where + +data T a = T hunk ./examples/hier/hier4/Main.hs 1 +module Main where + +import Plugins + +main = do + + makeAll "A.hs" [] + + y <- load "A.o" ["."] [] "u" + case y of + LoadSuccess _ _ -> putStrLn $ "YES" + LoadFailure e -> mapM_ putStrLn e hunk ./examples/hier/hier4/Makefile 1 +TEST= hier/hier4 + +TOP=../../.. +include ../../eval.mk hunk ./examples/hier/hier4/expected 1 +YES hunk ./examples/hmake/lib-plugs/Main.hs 1 +-- +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html) +-- + +import Eval.Haskell +import Plugins.Load + +import System.Exit ( ExitCode(..), exitWith ) +import System.IO +import System.Console.Readline ( readline, addHistory ) + +symbol = "resource" + +main = do + putStrLn banner + putStr "Loading package base" >> hFlush stdout + loadPackage "base" + putStr " ... linking ... " >> hFlush stdout + resolveObjs + putStrLn "done" + + shell [] + +shell :: [String] -> IO () +shell imps = do + s <- readline "plugs> " + cmd <- case s of + Nothing -> exitWith ExitSuccess + Just (':':'q':_) -> exitWith ExitSuccess + Just s -> addHistory s >> return s + imps' <- run cmd imps + shell imps' + +run :: String -> [String] -> IO [String] +run "" is = return is +run ":?" is = putStrLn help >> return is + +run ":l" _ = return [] +run (':':'l':' ':m) is = return (m:is) + +run (':':'t':' ':s) is = do + ty <- typeOf s is + when (not $ null ty) (putStrLn $ s ++ " :: " ++ ty) + return is + +run (':':_) is = putStrLn help >> return is + +run s is = do + s <- unsafeEval ("show $ "++s) is + when (isJust s) (putStrLn (fromJust s)) + return is + +banner = "\ +\ __ \n\ +\ ____ / /_ ______ ______ \n\ +\ / __ \\/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98\n\ +\ / /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins\n\ +\ / .___/_/\\__,_/\\__, /____/ Type :? for help \n\ +\/_/ /____/ \n" + +help = "\ +\Commands :\n\ +\ evaluate expression\n\ +\ :t show type of expression (monomorphic only)\n\ +\ :l module bring module in to scope\n\ +\ :l clear module list\n\ +\ :quit quit\n\ +\ :? display this list of commands" hunk ./examples/hmake/lib-plugs/Makefile 1 +GHCFLAGS= -O +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace +PKGFLAGS+= -package eval -package readline + +all: build + +build: + @$(GHC) $(GHCFLAGS) $(PKGFLAGS) $(EXTRAFLAGS) Main.hs -o plugs +check: build + @(if [ -f "expected" ] ;\ + then \ + actual_out="/tmp/hs-plugins-actual.out.$$$$" ;\ + diff_out="/tmp/hs-plugins.diff.$$$$" ;\ + cat test.in | ./plugs > $$actual_out 2>&1 || true ;\ + diff -u expected $$actual_out > $$diff_out || true ;\ + if [ -s "$$diff_out" ] ; then \ + echo "failed with:" ;\ + cat "$$diff_out" | sed '1,3d' ;\ + else \ + echo "ok." ;\ + fi ;\ + rm $$actual_out ;\ + else \ + cat test.in | ./plugs 2>&1 || true ;\ + fi) +clean: + rm -rf *.hi *.o *~ *.dep ./plugs + +include ../../../config.mk hunk ./examples/hmake/lib-plugs/expected 1 + __ + ____ / /_ ______ ______ + / __ \/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98 + / /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins + / .___/_/\__,_/\__, /____/ Type :? for help +/_/ /____/ + +Loading package base ... linking ... plugs> plugs> done +453973694165307953197296969697410619233826 hunk ./examples/hmake/lib-plugs/test.in 1 +let fibs = 1 : 1 : zipWith (+) fibs (tail fibs) in fibs !! 200 +:quit hunk ./examples/hmake/one-shot/Main.hs 1 +-- +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html) +-- + +import Eval.Haskell (unsafeEval) + +import Data.Maybe (isJust, fromJust) +import Control.Monad (when) + +import System.Exit (exitWith, ExitCode(ExitSuccess)) +import System.IO (getContents, putStrLn) +import System.Posix.Resource (setResourceLimit, + Resource(ResourceCPUTime), + ResourceLimits(ResourceLimits), + ResourceLimit(ResourceLimit)) + +rlimit = ResourceLimit 3 + +context = prehier ++ datas ++ controls + +prehier = ["Char", "List", "Maybe", "Numeric", "Random" ] + +datas = map ("Data." ++) [ + "Bits", "Bool", "Char", "Dynamic", "Either", + "FiniteMap", "Graph", "Int", "Ix", "List", + "Maybe", "Ratio", "Set", "Tree", "Tuple", "Typeable", "Word" + ] + +controls = map ("Control." ++) ["Monad", "Arrow"] + +main = do + setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit) + s <- getContents + when (not . null $ s) $ do + s <- unsafeEval ("(take 2048 (show ("++s++")))") context + when (isJust s) (putStrLn (fromJust s)) + exitWith ExitSuccess + hunk ./examples/hmake/one-shot/Makefile 1 +GHCFLAGS= -O +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace +PKGFLAGS+= -package eval -package unix + +all: build + +build: + @$(GHC) $(GHCFLAGS) $(PKGFLAGS) $(EXTRAFLAGS) Main.hs -o runplugs +include ../../../config.mk +check: build + @(if [ -f "expected" ] ;\ + then \ + actual_out="/tmp/hs-plugins-actual.out.$$$$" ;\ + diff_out="/tmp/hs-plugins.diff.$$$$" ;\ + cat test.in | ./runplugs > $$actual_out 2>&1 || true ;\ + diff -u expected $$actual_out > $$diff_out || true ;\ + if [ -s "$$diff_out" ] ; then \ + echo "failed with:" ;\ + cat "$$diff_out" | sed '1,3d' ;\ + else \ + echo "ok." ;\ + fi ;\ + rm $$actual_out ;\ + else \ + cat test.in | ./runplugs 2>&1 || true ;\ + fi) +clean: + rm -rf *.hi *.o *~ *.dep ./runplugs + +include ../../../config.mk hunk ./examples/hmake/one-shot/expected 1 +453973694165307953197296969697410619233826 hunk ./examples/hmake/one-shot/test.in 1 +let fibs = 1 : 1 : zipWith (+) fibs (tail fibs) in fibs !! 200 hunk ./examples/iface/null/A.hs 1 +module A where hunk ./examples/iface/null/B.hs 1 +module B where hunk ./examples/iface/null/Main.hs 1 +module Main ( main ) where + +import Hi.Parser + +import A +import B + +main = do iface <- readIface "Main.hi" + putStrLn (showIface iface) hunk ./examples/iface/null/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/iface/null/expected 1 +interface "Main" Main +module dependencies: A, B +package dependencies: base, haskell98, hi +import A +import B hunk ./examples/iface/null/expected.604 1 +interface "unknown" Main +module dependencies: A, B +package dependencies: base-1.0, haskell98-1.0, hi-1.0 +import B +import A hunk ./examples/load/io/Makefile 1 +TEST= load/io + +EXTRA_OBJS=TestIO.o + +TOP=../../.. +include ../../build.mk hunk ./examples/load/io/TestIO.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +-- + +module TestIO ( resource, resource_dyn ) where + +import API +import Data.Dynamic + +import System.IO +import System.Posix.Types ( ProcessID, Fd ) +import System.Posix.Process ( forkProcess, executeFile, getProcessID ) +import System.Posix.IO ( createPipe, stdInput, + stdOutput, fdToHandle, closeFd, dupTo ) + +resource = testio { field = date } + +resource_dyn :: Dynamic +resource_dyn = toDyn resource + +-- +-- call a shell command , returning it's output +-- +date :: IO String +date = do (hdl,_,_) <- catch (popen "/bin/date") (\_->error "popen failed") + hGetLine hdl + +------------------------------------------------------------------------ +-- +-- my implementation of $val = `cmd`; (if this was perl) +-- +-- provide similar functionality to popen(3), +-- along with bidirectional ipc via pipes +-- return's the pid of the child process +-- +-- there are two different forkProcess functions. the pre-620 was a +-- unix-fork style function, and the modern function has semantics more +-- like the Awkward-Squad paper. We provide implementations of popen +-- using both versions, depending on which GHC the user wants to try. +-- + +popen :: FilePath -> IO (Handle, Handle, ProcessID) +popen cmd = do + (pr, pw) <- createPipe + (cr, cw) <- createPipe + + -- parent -- + let parent = do closeFd cw + closeFd pr + -- child -- + let child = do closeFd pw + closeFd cr + exec cmd (pr,cw) + error "exec cmd failed!" -- typing only + +-- if the parser front end understood cpp, this would work +-- #if __GLASGOW_HASKELL__ >= 601 + pid <- forkProcess child -- fork child + parent -- and run parent code +-- #else +-- p <- forkProcess +-- pid <- case p of +-- Just pid -> parent >> return pid +-- Nothing -> child +-- #endif + + hcr <- fdToHandle cr + hpw <- fdToHandle pw + + return (hcr,hpw,pid) + +-- +-- execve cmd in the child process, dup'ing the file descriptors passed +-- as arguments to become the child's stdin and stdout. +-- +exec :: FilePath -> (Fd,Fd) -> IO () +exec cmd (pr,cw) = do + dupTo pr stdInput + dupTo cw stdOutput + executeFile cmd False [] Nothing + +------------------------------------------------------------------------ hunk ./examples/load/io/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data TestIO = TestIO { + field :: IO String + } + deriving (Typeable, Show) + +instance Show (IO String) where + show _ = "<>" + +testio :: TestIO +testio = TestIO { field = return "default value" } hunk ./examples/load/io/prog/Main.hs 1 +{-# OPTIONS -cpp #-} + +#include "../../../../config.h" + +import Plugins +import API + +main :: IO () +main = do + m_v <- load "../TestIO.o" ["../api"] [] "resource" + v <- case m_v of + LoadFailure _ -> error "load failed" + LoadSuccess _ v -> return v + s <- field v + if null s then print False else print True hunk ./examples/load/io/prog/expected 1 +True hunk ./examples/load/load_0/Makefile 1 +TEST= load/load_0 + +EXTRA_OBJS=Test.o + +TOP=../../.. +include ../../build.mk hunk ./examples/load/load_0/Test.hs 1 + +module Test where + +import API + +resource = test { field = "success" } hunk ./examples/load/load_0/api/API.hs 1 +module API where + +data Test = Test { + field :: String + } + +test :: Test +test = Test { field = "default value" } hunk ./examples/load/load_0/prog/Main.hs 1 + +import Plugins +import API + +main = do + m_v <- load_ "../Test.o" ["../api"] "resource" + v <- case m_v of + LoadFailure _ -> error "load failed" + LoadSuccess _ v -> return v + let s = field v + print s hunk ./examples/load/load_0/prog/expected 1 +"success" hunk ./examples/load/loadpkg/Main.hs 1 + +import Plugins + +main = loadPackageWith "posix" [] hunk ./examples/load/loadpkg/Makefile 1 +TEST= load/loadpkg + +TOP=../../.. +include ../../eval.mk hunk ./examples/load/null/Makefile 1 +TEST= load/null +EXTRA_OBJS=Null.o +TOP=../../.. +include ../../build.mk hunk ./examples/load/null/Null.hs 1 +module Null ( resource, resource_dyn ) where + +import API +import Data.Dynamic +import Prelude hiding (null) + +resource = null + +-- ! this has to be special: it can't be overridden by the user. +resource_dyn :: Dynamic +resource_dyn = toDyn resource hunk ./examples/load/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Null = Null { a, b :: Int } + deriving (Typeable, Show) + +null :: Null +null = Null { a = 42 , b = 1 } + hunk ./examples/load/null/prog/Main.hs 1 +{-# OPTIONS -cpp #-} + +#include "../../../../config.h" + +import Plugins +import API + +-- an example where we just want to load an object and run it + +main = do + let includes = [TOP ++ "/examples/load/null/api"] + m_v <- load "../Null.o" includes [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + + putStrLn ( show (a v) ) hunk ./examples/load/null/prog/expected 1 +42 hunk ./examples/load/rawload/Main.hs 1 + +import Plugins + +main = do + m <- loadRawObject "t.o" + print (path m) + resolveObjs +-- loadFunction m "sym" hunk ./examples/load/rawload/Makefile 1 +TEST= load/rawload + +EXTRA_OBJS=c.o + +TOP=../../.. +include ../../eval.mk hunk ./examples/load/rawload/t.c 1 +int sym(void) { return 1; } hunk ./examples/load/thiemann0/Makefile 1 +TEST= load/thiemann0 + +#EXTRA_OBJS=Test.o + +TOP=../../.. +include ../../build.mk hunk ./examples/load/thiemann0/Test.hs 1 + +-- P.Thiemann reports that 'import Char' leads to undefined symbol for +-- __stginit_Char_. + +module Test where + +import API +import Char + +resource = test { field = map toUpper "success" } + hunk ./examples/load/thiemann0/api/API.hs 1 +module API where + +data Test = Test { + field :: String + } + +test :: Test +test = Test { field = "default value" } hunk ./examples/load/thiemann0/prog/Main.hs 1 + +import Plugins +import API + +main = do + status <- make "../Test.hs" ["-i../api"] + obj <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "failed" + + m_v <- load_ obj ["../api"] "resource" + v <- case m_v of + LoadFailure _ -> error "load failed" + LoadSuccess _ v -> return v + let s = field v + print s hunk ./examples/load/thiemann0/prog/expected 1 +"SUCCESS" hunk ./examples/load/thiemann2/C.hs 1 +module C where + +import API +import qualified A + +resource = let Test s = A.resource in Test { field = s } hunk ./examples/load/thiemann2/Makefile 1 +TEST= load/thiemann2 +EXTRAFLAGS+=-iprog + +TOP=../../.. +include ../../build.mk + hunk ./examples/load/thiemann2/api/API.hs 1 +module API where + +data Test = Test { + field :: String + } + +test :: Test +test = Test { field = "default value" } hunk ./examples/load/thiemann2/prog/A.hs 1 +module A where + +import API + +import qualified B + +resource = Test { field = B.resource } + hunk ./examples/load/thiemann2/prog/B.hs 1 +module B where + +resource = "i'm in b" hunk ./examples/load/thiemann2/prog/Main.hs 1 + +import Plugins +import API + +import A + +main = do + -- compile C (A and B are already compiled) + status <- makeAll "../C.hs" ["-i../api"] + obj <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "failed" + + -- should load C + m_v <- load_ obj ["../api","."] "resource" + v <- case m_v of + LoadFailure _ -> error "load failed" + LoadSuccess _ v -> return v + let s = field v + print s hunk ./examples/load/thiemann2/prog/expected 1 +"i'm in b" hunk ./examples/load/unloadpkg/Main.hs 1 + +import Plugins + +main = do loadPackage "posix" + unloadPackage "posix" + loadPackage "posix" hunk ./examples/load/unloadpkg/Makefile 1 +TEST= load/unloadpkg + +TOP=../../.. +include ../../eval.mk hunk ./examples/make/makeall001/A.hs 1 +module A where + +a = "a" hunk ./examples/make/makeall001/B.hs 1 +module B where + +b = "b" hunk ./examples/make/makeall001/C.hs 1 +module C where + +c = "c" hunk ./examples/make/makeall001/Makefile 1 +TEST= make/makeall001 +TOP=../../.. +include ../../build.mk hunk ./examples/make/makeall001/Tiny.hs 1 +module Tiny ( resource ) where + +import API + +import A +import B +import C + +resource = tiny { + + field = a ++ b ++ c + +} hunk ./examples/make/makeall001/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- ^ needed to derive Typeable + +module API where + +import Data.Dynamic + +data Tiny = Tiny { field :: String } + deriving (Typeable, Show) + +tiny :: Tiny +tiny = Tiny { field = "default value" } + hunk ./examples/make/makeall001/prog/Main.hs 1 + +-- little more complex. use the path to the obj file we get back from +-- 'make'. load() uses this to find the .hi file + +import Plugins +import API + +main = do + status <- makeAll "../Tiny.hs" ["-i../api"] + o <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "failed" + m_v <- load o [".."] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v + hunk ./examples/make/makeall001/prog/expected 1 +abc hunk ./examples/make/null/Makefile 1 +TEST= make/null + +TOP=../../.. +include ../../build.mk hunk ./examples/make/null/Null.hs 1 +module Null ( resource, resource_dyn ) where + +import API +import Data.Dynamic +import Prelude hiding (null) + +resource = null + +-- ! this has to be special: it can't be overridden by the user. +resource_dyn :: Dynamic +resource_dyn = toDyn resource hunk ./examples/make/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Null = Null { a, b :: Int } + deriving (Typeable, Show) + +null :: Null +null = Null { a = 42 , b = 1 } + hunk ./examples/make/null/prog/Main.hs 1 + +-- an example where we want to compile and load a file + +import Plugins +import API + +main = do + make "../Null.hs" ["-i../api"] + m_v <- load "../Null.o" ["../api"] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn ( show (a v) ) hunk ./examples/make/null/prog/expected 1 +42 hunk ./examples/make/o/Makefile 1 +TEST=make/o +TOP =../../.. +include ../../build.mk hunk ./examples/make/o/Plugin.hs 1 +module Plugin ( resource ) where + +import API + +resource = plugin { + field = "hello out there" +} hunk ./examples/make/o/api/API.hs 1 +module API where + +data Interface = Interface { + field :: String +} + +plugin :: Interface +plugin = Interface { field = undefined } hunk ./examples/make/o/prog/Main.hs 1 +import Plugins +import API + +import System.Directory + +-- note: the name of the original *source* module is used to find +-- symbols in the *object* file. load works out what the source file +-- name was by looking at the object file name, i.e. it assumes they +-- have the same name. so, if you are going to store objects in a +-- tmpdir, you should make a tmp directory, and store them inside that, +-- rather than mkstemp'ing the name of the object file yourself. +-- +-- this should go away once we can read .hi files. + +main = do + make "../Plugin.hs" [ "-i../api", "-o", "/tmp/Plugin.o" ] + m_v <- load "/tmp/Plugin.o" ["../api"] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v + + mapM_ removeFile [ "/tmp/Plugin.o" , "/tmp/Plugin.hi" ] hunk ./examples/make/o/prog/expected 1 +hello out there hunk ./examples/make/odir/Makefile 1 +TEST= make/odir +TOP=../../.. +include ../../build.mk hunk ./examples/make/odir/Plugin.hs 1 +module Plugin ( resource ) where + +import API + +resource = plugin { + field = "hello out there" +} hunk ./examples/make/odir/api/API.hs 1 +module API where + +data Interface = Interface { + field :: String +} + +plugin :: Interface +plugin = Interface { field = undefined } hunk ./examples/make/odir/prog/Main.hs 1 +import Plugins +import API +import System.Directory + +main = do + status <- make "../Plugin.hs" [ "-i../api", "-odir", "/tmp" ] + o <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "didn't compile" + m_v <- load o ["../api"] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v + mapM_ removeFile ["/tmp/Plugin.hi", "/tmp/Plugin.o" ] + hunk ./examples/make/odir/prog/expected 1 +hello out there hunk ./examples/make/remake001/Bar.hs 1 +module Bar where + +bar = undefined hunk ./examples/make/remake001/Foo.hs 1 +module Foo where + +foo = undefined hunk ./examples/make/remake001/Main.hs 1 +-- +-- expected output: +-- $ ./a.out +-- True +-- False +-- True +-- False +-- + +import Plugins +import System.Directory + +main = do + status <- make "Foo.hs" [] -- should make + print status + + status <- make "Foo.hs" [] -- shouldn't make + print status + + status <- merge "Foo.hs" "Bar.hs" + case status of + MergeFailure e -> error $ show e + MergeSuccess _ _ fp -> do { + + ;status <- make fp [] -- should make + ;() <- case status of + MakeSuccess c _ -> print c + MakeFailure e -> error $ show e + + ;status <- make fp [] -- shouldn't make + ;case status of + MakeSuccess c _ -> print c + MakeFailure e -> error $ show e + ;removeFile "Foo.o" + } + hunk ./examples/make/remake001/Makefile 1 +TEST= merge/remake001 + +TOP=../../.. +include ../../eval.mk hunk ./examples/make/remake001/expected 1 +MakeSuccess ReComp "Foo.o" +MakeSuccess NotReq "Foo.o" +ReComp +NotReq hunk ./examples/make/remake001_should_fail/Bar.hs 1 +module Bar where + +bar = undef {- error -} hunk ./examples/make/remake001_should_fail/Foo.hs 1 +module Foo where + +foo = undefined hunk ./examples/make/remake001_should_fail/Main.hs 1 + +import Plugins + +import System.Directory + +main = do + status <- make "Foo.hs" [] -- should make + print status + + status <- make "Foo.hs" [] -- shouldn't make + print status + + status <- merge "Foo.hs" "Bar.hs" + case status of + MergeFailure e -> error $ show e + MergeSuccess _ _ fp -> do { + + ;status <- make fp [] -- should make + ;() <- case status of + MakeSuccess c _ -> print c + MakeFailure _ -> print "make failure" + + ;status <- make fp [] -- shouldn't make + ;case status of + MakeSuccess c _ -> print c + MakeFailure _ -> print "make failure" + + ;removeFile "Foo.o" -- make test deterministic + } + + hunk ./examples/make/remake001_should_fail/Makefile 1 +TEST= make/remake001_should_fail + +TOP=../../.. +include ../../eval.mk hunk ./examples/make/remake001_should_fail/expected 1 +MakeSuccess ReComp "Foo.o" +MakeSuccess NotReq "Foo.o" +"make failure" +"make failure" hunk ./examples/make/simple/Makefile 1 +TEST= make/simple +TOP=../../.. +include ../../build.mk hunk ./examples/make/simple/Tiny.hs 1 +module Tiny ( resource, resource_dyn ) where + +import API +import Data.Dynamic + +resource = tiny { + + field = "hello strange world" + +} + +resource_dyn :: Dynamic +resource_dyn = toDyn resource + hunk ./examples/make/simple/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- ^ needed to derive Typeable + +module API where + +import Data.Dynamic + +data Tiny = Tiny { field :: String } + deriving (Typeable, Show) + +tiny :: Tiny +tiny = Tiny { field = "default value" } + hunk ./examples/make/simple/prog/Main.hs 1 + +-- little more complex. use the path to the obj file we get back from +-- 'make'. load() uses this to find the .hi file + +import Plugins +import API + +main = do + status <- make "../Tiny.hs" ["-i../api"] + o <- case status of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> error "failed" + + m_v <- load o ["../api"] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v + hunk ./examples/make/simple/prog/expected 1 +hello strange world hunk ./examples/makewith/global_pragma/Makefile 1 + +TEST=makewith/global_pragma + +TOP=../../.. +include ../../build.mk hunk ./examples/makewith/global_pragma/Plugin.hs 1 +{-# GLOBALOPTIONS -package posix #-} + +module M ( resource ) where + +import System.IO.Unsafe +import API +import System.Process +import System.IO + +resource = tiny { field = date } + +date :: String +date = unsafePerformIO $ do + (_,outh,_,proc) <- runInteractiveProcess "echo" ["hello"] Nothing Nothing + waitForProcess proc + s <- hGetContents outh + return s hunk ./examples/makewith/global_pragma/api/API.hs 1 + +module API where + +data Tiny = Tiny { field :: String } + +tiny :: Tiny +tiny = Tiny { field = "default value" } + hunk ./examples/makewith/global_pragma/prog/Main.hs 1 + +import Plugins +import API + +conf = "../Plugin.hs" +apipath = "../api" + +main = do + status <- makeWith conf conf ["-i"++apipath] + o <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "compile failed" + MakeSuccess _ o -> return o + m_v <- load o [apipath] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + LoadFailure ers -> mapM_ putStrLn ers >> error "load failed" + putStr $ field v + makeCleaner o + hunk ./examples/makewith/global_pragma/prog/expected 1 +hello hunk ./examples/makewith/io/Makefile 1 +TEST=makewith/io + +TOP=../../.. +include ../../build.mk hunk ./examples/makewith/io/README 1 +An example using IO monad fields in the .conf file. + hunk ./examples/makewith/io/TestIO.conf 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +-- + +import System.IO +import System.Posix.Types ( ProcessID, Fd ) +import System.Posix.Process ( forkProcess, executeFile, getProcessID ) +import System.Posix.IO ( createPipe, stdInput, + stdOutput, fdToHandle, closeFd, dupTo ) + +resource = testio { field = date } + +-- +-- call a shell command , returning it's output +-- +date :: IO String +date = do (hdl,_,_) <- catch (popen "/bin/date") (\_->error "popen failed") + hGetLine hdl + +------------------------------------------------------------------------ +-- +-- my implementation of $val = `cmd`; (if this was perl) +-- +-- provide similar functionality to popen(3), +-- along with bidirectional ipc via pipes +-- return's the pid of the child process +-- +-- there are two different forkProcess functions. the pre-620 was a +-- unix-fork style function, and the modern function has semantics more +-- like the Awkward-Squad paper. We provide implementations of popen +-- using both versions, depending on which GHC the user wants to try. +-- + +popen :: FilePath -> IO (Handle, Handle, ProcessID) +popen cmd = do + (pr, pw) <- createPipe + (cr, cw) <- createPipe + + -- parent -- + let parent = do closeFd cw + closeFd pr + -- child -- + let child = do closeFd pw + closeFd cr + exec cmd (pr,cw) + error "exec cmd failed!" -- typing only + +-- if the parser front end understood cpp, this would work +-- #if __GLASGOW_HASKELL__ >= 601 + pid <- forkProcess child -- fork child + parent -- and run parent code +-- #else +-- p <- forkProcess +-- pid <- case p of +-- Just pid -> parent >> return pid +-- Nothing -> child +-- #endif + + hcr <- fdToHandle cr + hpw <- fdToHandle pw + + return (hcr,hpw,pid) + +-- +-- execve cmd in the child process, dup'ing the file descriptors passed +-- as arguments to become the child's stdin and stdout. +-- +exec :: FilePath -> (Fd,Fd) -> IO () +exec cmd (pr,cw) = do + dupTo pr stdInput + dupTo cw stdOutput + executeFile cmd False [] Nothing + +------------------------------------------------------------------------ hunk ./examples/makewith/io/TestIO.stub 1 + +module TestIO ( resource, resource_dyn ) where + +import API +import Data.Dynamic + +resource = testio + +resource_dyn :: Dynamic +resource_dyn = toDyn resource hunk ./examples/makewith/io/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data TestIO = TestIO { + field :: IO String + } + deriving (Typeable, Show) + +instance Show (IO String) where + show _ = "<>" + +testio :: TestIO +testio = TestIO { field = return "default value" } hunk ./examples/makewith/io/prog/Main.hs 1 + +import Plugins +import API + +conf = "../TestIO.conf" +stub = "../TestIO.stub" +apipath = "../api" + +main = do + status <- makeWith conf stub ["-i"++apipath] + o <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess _ o -> return o + m_v <- load o [apipath] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + s <- field v + + makeCleaner o + if null s then print False else print True hunk ./examples/makewith/io/prog/expected 1 +True hunk ./examples/makewith/merge00/Bar.hs 1 +module Bar where + +resource :: Int hunk ./examples/makewith/merge00/Foo.hs 1 +module Foo where + +resource :: Integer +resource = 0xBAD hunk ./examples/makewith/merge00/Main.hs 1 + +import Plugins + +import System.Directory + +a = "Foo.hs" -- uesr code +b = "Bar.hs" -- trusted code. Result is "Bar.o" + +main = do + status <- merge a b + f <- case status of + MergeFailure e -> error "merge failure" + MergeSuccess _ _ f -> return f + + status <- merge a b + f' <- case status of + MergeFailure e -> error "merge failure" + MergeSuccess ReComp _ f -> error "unnec. merge" + MergeSuccess NotReq _ f -> return f + + print ( f == f' ) + + status <- make f' [] + o <- case status of + MakeFailure e -> error "make failed" + MakeSuccess _ o -> return o + + m_v <- load o [] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ show $ (v :: Int) + + removeFile o + return () + + makeCleaner f + hunk ./examples/makewith/merge00/Makefile 1 +TEST=makewith/merge00 + +TOP=../../.. +include ../../eval.mk hunk ./examples/makewith/merge00/expected 1 +True +2989 hunk ./examples/makewith/mergeto0/Bar.hs 1 +module Bar where + +resource :: Int hunk ./examples/makewith/mergeto0/Foo.hs 1 +module Foo where + +resource :: Integer +resource = 0xBAD hunk ./examples/makewith/mergeto0/Main.hs 1 + +import Plugins + +import System.Directory + +a = "Foo.hs" -- uesr code +b = "Bar.hs" -- trusted code. Result is "Bar.o" +c = "Out.hs" + +main = do + status <- mergeTo a b c + f <- case status of + MergeFailure e -> error "mergeto failure" + MergeSuccess _ _ f -> return f + print $ f == c + + status <- mergeTo a b c + f' <- case status of + MergeFailure e -> error "mergeto failure" + MergeSuccess ReComp _ f -> error "unnec. mergeto" + MergeSuccess NotReq _ f -> return f -- good, not req + + print $ f == f' && f == c + + status <- make f' [] + o <- case status of + MakeFailure e -> error "make failed" + MakeSuccess _ o -> return o + + m_v <- load o [] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ show $ (v :: Int) + + makeCleaner c + hunk ./examples/makewith/mergeto0/Makefile 1 +TEST=makewith/mergeto0 + +TOP=../../.. +include ../../eval.mk hunk ./examples/makewith/mergeto0/expected 1 +True +True +2989 hunk ./examples/makewith/module_name/Bar.hs 1 +module Bar where + +resource :: Int hunk ./examples/makewith/module_name/Foo.hs 1 +module Foo where + +resource :: Integer +resource = 1 hunk ./examples/makewith/module_name/Main.hs 1 + +import Plugins + +import System.Directory + +a = "Foo.hs" -- uesr code +b = "Bar.hs" -- trusted code. Result is "Bar.o" + +main = do + status <- makeWith a b [] + s <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + status <- makeWith a b [] + s' <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + status <- makeWith a b [] + s'' <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + print $ (s == s') && (s' == s'') + + m_v <- load s [] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ show $ (v :: Int) + + makeCleaner s'' hunk ./examples/makewith/module_name/Makefile 1 +TEST=makewith/module_name + +TOP=../../.. +include ../../eval.mk hunk ./examples/makewith/module_name/expected 1 +ReComp +NotReq +NotReq +True +1 hunk ./examples/makewith/multi_make/Bar.hs 1 +module Bar where + +resource :: Int +resource = 2 hunk ./examples/makewith/multi_make/Foo.hs 1 +module Foo where + +resource :: Integer +resource = 1 hunk ./examples/makewith/multi_make/Main.hs 1 + +import Plugins + +import System.Directory + +a = "Foo.hs" -- user code +b = "Bar.hs" -- more user code +z = "Stub.hs" -- and a stub + +main = do + status <- makeWith a z [] + s <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + status <- makeWith b z [] + s' <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + -- shouldn't need to remerge (a,z) + status <- makeWith a z [] + t <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + -- shouldn't need to remerge (b,z) + status <- makeWith b z [] + t' <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess n s -> print n >> return s + + print $ s /= s' -- test we got unique modules + print $ t /= t' -- test we got unique modules + + mapM_ makeCleaner [s,s'] + hunk ./examples/makewith/multi_make/Makefile 1 +TEST=makewith/multi_make + +TOP=../../.. +include ../../eval.mk hunk ./examples/makewith/multi_make/Stub.hs 1 +module Stub where + +resource :: Int + hunk ./examples/makewith/multi_make/expected 1 +ReComp +ReComp +NotReq +NotReq +True +True hunk ./examples/makewith/should_fail_0/Makefile 1 +TEST=makewith/should_fail_0 + +TOP=../../.. +include ../../build.mk hunk ./examples/makewith/should_fail_0/Plugin.in 1 +module Plugin where + +resource = 0xBAD :: Int hunk ./examples/makewith/should_fail_0/Plugin.stub 1 +module Plugin ( resource ) where + +import API + +resource :: Interface +resource = plugin hunk ./examples/makewith/should_fail_0/api/API.hs 1 + +module API where + +data Interface = Interface { + function :: String + } + +plugin :: Interface +plugin = Interface { function = "goodbye" } + hunk ./examples/makewith/should_fail_0/prog/Main.hs 1 + +import Plugins +import API + +conf = "../Plugin.in" +stub = "../Plugin.stub" + +main = do + status <- makeWith conf stub ["-i../api"] + case status of + MakeFailure e -> putStrLn "make failed" + MakeSuccess _ o -> do + m_v <- load o ["../api"] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ (function v) + makeCleaner o + hunk ./examples/makewith/should_fail_0/prog/expected 1 +make failed hunk ./examples/makewith/tiny/Makefile 1 + +TEST=makewith/tiny + +TOP=../../.. +include ../../build.mk hunk ./examples/makewith/tiny/Tiny.conf 1 +resource = tiny { + + field = "hello strange world" + +} + + + hunk ./examples/makewith/tiny/Tiny.stub 1 +module Tiny ( resource, resource_dyn ) where + +import API +import Data.Dynamic + +resource = tiny + +resource_dyn :: Dynamic +resource_dyn = toDyn resource + + + + + + + + + + + + + + + + + + + + + + hunk ./examples/makewith/tiny/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- ^ needed to derive Typeable + +module API where + +import Data.Dynamic + +data Tiny = Tiny { field :: String } + deriving (Typeable, Show) + +tiny :: Tiny +tiny = Tiny { field = "default value" } + hunk ./examples/makewith/tiny/prog/Main.hs 1 + +import Plugins +import API +import Data.Either + +conf = "../Tiny.conf" +stub = "../Tiny.stub" +apipath = "../api" + +main = do + status <- makeWith conf stub ["-i"++apipath] + o <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess _ o -> return o + m_v <- load o [apipath] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn $ field v + makeCleaner o + hunk ./examples/makewith/tiny/prog/expected 1 +hello strange world hunk ./examples/makewith/unsafeio/Makefile 1 + +TEST=makewith/unsafeio + +TOP=../../.. +include ../../build.mk hunk ./examples/makewith/unsafeio/README 1 +hmm. on 6.3 we need to add 'mtl' to a package dependency, other +HSlang complains of a missing symbol. Is this a bug in the +package.conf for HSlang? hunk ./examples/makewith/unsafeio/Unsafe.conf 1 +{-# GLOBALOPTIONS -package posix #-} +-- illustrates the use of static options in pragmas + +import System.IO.Unsafe +import System.IO +import System.Process + +resource = unsafe { field = date } + +-- illustrates the use of the devil's work +date :: String +date = unsafePerformIO $ do + (_,outh,_,proc) <- runInteractiveProcess "date" [] Nothing Nothing + waitForProcess proc + s <- hGetContents outh + return s + hunk ./examples/makewith/unsafeio/Unsafe.stub 1 + +module Unsafe ( resource, resource_dyn ) where + +import API +import Data.Dynamic + +resource = unsafe + +-- +-- special +-- +resource_dyn :: Dynamic +resource_dyn = toDyn resource hunk ./examples/makewith/unsafeio/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Unsafe = Unsafe { + field :: String + } + deriving (Typeable, Show) + +unsafe :: Unsafe +unsafe = Unsafe { field = "default value" } hunk ./examples/makewith/unsafeio/prog/Main.hs 1 +import Plugins +import API +import Data.Either + +conf = "../Unsafe.conf" +stub = "../Unsafe.stub" +apipath = "../api" + +main = do + status <- makeWith conf stub ["-i"++apipath] + o <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed" + MakeSuccess _ o -> return o + m_v <- load o [apipath] [] "resource" + v <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + let s = field v + makeCleaner o + if null s then print False else print True hunk ./examples/makewith/unsafeio/prog/README 1 +this is an example of an application that uses the HSConf library to +dynamically load compiled conf files. + +We use the .conf file in the parent directory, and communicate with +the plugin via the API in the api_package/ directory. + +The plugin is a .o file +The api is a GHC package archive hunk ./examples/makewith/unsafeio/prog/expected 1 +True hunk ./examples/misc/mkstemps/Main.hs 1 + +import Plugins.MkTemp + +import Data.Maybe + +import System.IO +import System.Directory + +main = do + createDirectory "t" + + ------------------------------------------------------------------------ + -- Try mkstemp with simple template + -- + ts <- mapM (\_ -> mkstemp "t/t.X" ) [0..(26+26)] -- 1+26+26 files + () <- if (not $ all isJust ts) + then putStrLn $ "mkstemp couldn't create all expected files" + else putStrLn $ "created "++(show $ length $ catMaybes ts)++" files" + closeAll ts + + -- next one shouldn't be possible + t <- mkstemp "t/t.X" + () <- if (not $ isNothing t) + then putStrLn $ "shouldn't have been able to create this file" + else putStrLn $ "correctly ran out of permutations" + closeAll [t] + + rmAll (t:ts) + + ------------------------------------------------------------------------ + -- Try again with large tmp + -- + ts <- mapM (\_->do v <- mkstemp "t/t.XXXXXXXXXX" + case v of Just (t,h) -> hClose h >> return v + _ -> return v ) [1..10000] + + () <- if (not $ all isJust ts) + then putStrLn $ "mkstemp couldn't create all expected files" + else putStrLn $ "mkstemp: created "++(show $ length $ catMaybes ts)++" files" + rmAll ts + + ------------------------------------------------------------------------ + -- test mkstemps + -- + ts <- mapM (\_->do v <- mkstemps "t/t.XXXXXXXXXX.hs" 3 + case v of Just (t,h) -> hClose h >> return v + _ -> return v ) [1..2000] + () <- if (not $ all isJust ts) + then putStrLn $ "mkstemps couldn't create all expected files" + else putStrLn $ "mkstemps: created "++(show $ length $ catMaybes ts)++" files" + rmAll ts + + ------------------------------------------------------------------------ + -- mkdtemp + -- + ts <- mapM (\_ -> mkdtemp "t/XXXXXXXXXX") [1..2000] + () <- if (not $ all isJust ts) + then putStrLn $ "mkdtemp: couldn't create all expected directories" + else putStrLn $ "mkdtemp: created "++(show $ length $ catMaybes ts)++" directories" + rmAllDirs ts + + ------------------------------------------------------------------------ + + removeDirectory "t" + + where + closeAll ts = mapM_ hClose $ map snd $ catMaybes ts + rmAll ts = mapM_ removeFile $ map fst $ catMaybes ts + rmAllDirs ts = mapM_ removeDirectory $ catMaybes ts hunk ./examples/misc/mkstemps/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/misc/mkstemps/expected 1 +created 53 files +correctly ran out of permutations +mkstemp: created 10000 files +mkstemps: created 2000 files +mkdtemp: created 2000 directories hunk ./examples/multi/3plugins/Makefile 1 +TEST= multi/3plugins + +EXTRA_OBJS=Plugin1.o Plugin2.o Plugin3.o + +TOP=../../.. +include ../../build.mk hunk ./examples/multi/3plugins/Plugin1.hs 1 +module Plugin1 where + +import API +import Data.Char + +resource = plugin { + valueOf = map toUpper +} hunk ./examples/multi/3plugins/Plugin2.hs 1 +module Plugin2 where + +import API +import Data.Char + +resource = plugin { + valueOf = \s -> show $ map ord s +} + hunk ./examples/multi/3plugins/Plugin3.hs 1 +module Plugin3 where + +import API + +resource = plugin { + valueOf = reverse +} hunk ./examples/multi/3plugins/api/API.hs 1 +module API where + +data Interface = Interface { + valueOf :: String -> String +} + +plugin :: Interface +plugin = Interface { valueOf = id } + hunk ./examples/multi/3plugins/prog/Main.hs 1 +import Plugins +import API + +main = do + let plist = ["../Plugin1.o", "../Plugin2.o", "../Plugin3.o"] + plugins <- mapM (\p -> load p ["../api"] [] "resource") plist + let functions = map (valueOf . fromLoadSuc) plugins + + -- apply the function from each plugin in turn + mapM_ (\f -> putStrLn $ f "haskell is for hackers") functions + +fromLoadSuc (LoadFailure _) = error "load failed" +fromLoadSuc (LoadSuccess _ v) = v hunk ./examples/multi/3plugins/prog/expected 1 +HASKELL IS FOR HACKERS +[104,97,115,107,101,108,108,32,105,115,32,102,111,114,32,104,97,99,107,101,114,115] +srekcah rof si lleksah hunk ./examples/objc/expression_parser/ArithmeticExpressionParser.hs 1 +module ArithmeticExpressionParser where + +import Text.ParserCombinators.Parsec +import Text.ParserCombinators.Parsec.Expr + +resource :: String -> IO String +resource text = do + parsedText <- mapM parseString (lines text) + return (unlines parsedText) + +parseString s = do + case (parse expr "" s) of + Left err -> return ("Error " ++ show err) + Right num -> return (show num) + +expr :: Parser Integer +expr = buildExpressionParser table factor "expression" + +table = [ [op "*" (*) AssocLeft, op "/" div AssocLeft] + , [op "+" (+) AssocLeft, op "-" (-) AssocLeft] ] + where + op s f assoc = Infix (do { string s; return f }) assoc + +factor = do { char '('; x <- expr; char ')'; return x } + <|> number + "simple expression" + +number :: Parser Integer +number = do { ds <- many1 digit; return (read ds) } "number" + hunk ./examples/objc/expression_parser/English.lproj/Credits.rtf 1 +{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} +{\colortbl;\red255\green255\blue255;} +\paperw9840\paperh8400 +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\b\fs24 \cf0 Engineering: +\b0 \ + Some people\ +\ + +\b Human Interface Design: +\b0 \ + Some other people\ +\ + +\b Testing: +\b0 \ + Hopefully not nobody\ +\ + +\b Documentation: +\b0 \ + Whoever\ +\ + +\b With special thanks to: +\b0 \ + Mom\ +} binary ./examples/objc/expression_parser/English.lproj/InfoPlist.strings oldhex * newhex *feff002f002a0020004c006f00630061006c0069007a0065006400200076006500720073006900 *6f006e00730020006f006600200049006e0066006f002e0070006c0069007300740020006b0065 *007900730020002a002f000a000a0043004600420075006e0064006c0065004e0061006d006500 *20003d002000220050006c007500670069006e00450078007000720065007300730069006f006e *0050006100720073006500720022003b000a0043004600420075006e0064006c00650053006800 *6f0072007400560065007200730069006f006e0053007400720069006e00670020003d00200022 *0030002e00310022003b000a0043004600420075006e0064006c00650047006500740049006e00 *66006f0053007400720069006e00670020003d002000220050006c007500670069006e00450078 *007000720065007300730069006f006e0050006100720073006500720020007600650072007300 *69006f006e00200030002e0031002c00200043006f007000790072006900670068007400200032 *0030003000340020005f005f004d00790043006f006d00700061006e0079004e0061006d006500 *5f005f002e0022003b000a004e005300480075006d0061006e005200650061006400610062006c *00650043006f00700079007200690067006800740020003d002000220043006f00700079007200 *69006700680074002000320030003000340020005f005f004d00790043006f006d00700061006e *0079004e0061006d0065005f005f002e0022003b000a hunk ./examples/objc/expression_parser/English.lproj/MainMenu.nib/classes.nib 1 - +{ + IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); + IBVersion = 1; +} hunk ./examples/objc/expression_parser/English.lproj/MainMenu.nib/info.nib 1 + + + + + IBDocumentLocation + 116 123 356 240 0 0 1600 1178 + IBEditorPositions + + 29 + 117 405 318 44 0 0 1600 1178 + + IBFramework Version + 328.0 + IBOpenObjects + + 29 + + IBSystem Version + 7B8 + + binary ./examples/objc/expression_parser/English.lproj/MainMenu.nib/objects.nib oldhex * newhex *040b747970656473747265616d8103e88401408484840e4e5349424f626a656374446174618100 *e08484084e534f626a6563740085928484840e4e53437573746f6d4f626a656374299484024040 *8484840f4e534d757461626c65537472696e67018484084e53537472696e67019484012b0d4e53 *4170706c69636174696f6e8685868401693e968484840a4e534d656e754974656d81029f949284 *8484064e534d656e758100cc94840469404040008498990446696e64868484840e4e534d757461 *626c654172726179008484074e53417272617900949a0592849b929c840d694040494969404040 *403a6940008499990746696e64e280a6868499990166868200100000827fffffff008584848410 *4e53437573746f6d5265736f75726365299496849999074e53496d616765868499990f4e534d65 *6e75436865636b6d61726b86868584a696a7849999104e534d656e754d69786564537461746586 *86850185928592858692849b929ca0008499990946696e64204e65787486849999016786820010 *0000827fffffff0085a585a9850285928592858692849b929ca0008499990d46696e6420507265 *76696f7573868499990147868200100000827fffffff0085a585a9850385928592858692849b92 *9ca000849999165573652053656c656374696f6e20666f722046696e6486849999016586820010 *0000827fffffff0085a585a98507859285928586929a868586a000849999114a756d7020746f20 *53656c656374696f6e86849999016a868200100000827fffffff0085a585a98500859285928586 *9c96ab9c96849b92849d9d008498990657696e646f778684a09a0492b692849b92b7a000849999 *084d696e696d697a6586849999016d868200100000827fffffff0085a585a98500859285928586 *92849b92b7a082c00000008499990086be8200100000827fffffff0085a585a985008592859285 *8692849b92b7a000849999124272696e6720416c6c20746f2046726f6e7486be8200100000827f *ffffff0085a585a98500859285928586868499990e5f4e5357696e646f77734d656e758686a000 *849999045a6f6f6d86be8200100000827fffffff0085a585a98500859285928586b796849b9284 *9d9d00849999084d61696e4d656e758684a09a0592849b92c4a0008499990e4e65774170706c69 *636174696f6e86be8200100000827fffffff0085a585a9840e7375626d656e75416374696f6e3a *0085928592849d9d00c884a09a0b92849b92c9a0008499991441626f7574204e65774170706c69 *636174696f6e86be00827fffffff0085a585a9850085928592858692849b92c9a082c0000000be *be8200100000827fffffff0085a585a9850085928592858692849b92c9a0008499990e50726566 *6572656e636573e280a686849999012c868200100000827fffffff0085a585a985008592859285 *8692849b92c9a082c0000000bebe8200100000827fffffff0085a585a985008592859285869284 *9b92c9a00084999908536572766963657386be8200100000827fffffff0085a585a9a200859285 *92849d9d008498990853657276696365738684a09a00868499990f5f4e5353657276696365734d *656e7586868692849b92c9a082c0000000bebe8200100000827fffffff0085a585a98500859285 *92858692849b92c9a0008499991348696465204e65774170706c69636174696f6e868499990168 *868200100000827fffffff0085a585a9850085928592858692849b92c9a0008499990b48696465 *204f7468657273868499990168868200180000827fffffff0085a585a985008592859285869284 *9b92c9a0008499990853686f7720416c6c86be8200100000827fffffff0085a585a98500859285 *92858692849b92c9a082c0000000bebe8200100000827fffffff0085a585a98500859285928586 *92849b92c9a0008499991351756974204e65774170706c69636174696f6e868499990171868200 *100000827fffffff0085a585a98500859285928586868499990c5f4e534170706c654d656e7586 *868692849b92c4a0008499990446696c6586be8200100000827fffffff0085a585a9a200859285 *92849d9d008498990446696c658684a09a0b92849b92e8a000849999034e657786849999016e86 *8200100000827fffffff0085a585a9850085928592858692849b92e8a000849999074f70656ee2 *80a686849999016f868200100000827fffffff0085a585a9850085928592858692849b92e8a000 *8499990b4f70656e20526563656e7486be8200100000827fffffff0085a585a9a2008592859284 *9d9d008498990b4f70656e20526563656e748684a09a0192849b92f3a0008499990a436c656172 *204d656e7586be8200100000827fffffff0085a585a9850085928592858686849999165f4e5352 *6563656e74446f63756d656e74734d656e7586868692849b92e8a082c0000000bebe8200100000 *827fffffff0085a585a9850085928592858692849b92e8a00084999905436c6f73658684999901 *77868200100000827fffffff0085a585a9850085928592858692849b92e8a00084999904536176 *65868499990173868200100000827fffffff0085a585a9850085928592858692849b92e8a00084 *99990a53617665204173e280a6868499990153868200100000827fffffff0085a585a985008592 *8592858692849b92e8a0008499990652657665727486be00827fffffff0085a585a98500859285 *92858692849b92e8a082c0000000bebe8200100000827fffffff0085a585a98500859285928586 *92849b92e8a0008499990d50616765205365747570e280a6868499990150868200100000827fff *ffff0085a585a9850085928592858692849b92e8a000849999085072696e74e280a68684999901 *70868200100000827fffffff0085a585a985008592859285868685868692849b92c4a000849999 *044564697486be8200100000827fffffff0085a585a9a20085928592849d9d0084989904456469 *748684a09a0b92849b920ea00084999904556e646f86849999017a868200100000827fffffff00 *85a585a9850085928592858692849b920ea000849999045265646f86849999015a868200100000 *827fffffff0085a585a9850085928592858692849b920ea08240000000bebe8200100000827fff *ffff0085a585a9850085928592858692849b920ea0008499990343757486849999017886820010 *0000827fffffff0085a585a9850085928592858692849b920ea00084999904436f707986849999 *0163868200100000827fffffff0085a585a9850085928592858692849b920ea000849999055061 *737465868499990176868200100000827fffffff0085a585a9850085928592858692849b920ea0 *008499990644656c65746586be8200100000827fffffff0085a585a9850085928592858692849b *920ea0008499990a53656c65637420416c6c868499990161868200100000827fffffff0085a585 *a9850085928592858692849b920ea08240000000bebe8200100000827fffffff0085a585a98500 *85928592858692849b920ea0008499990446696e6486be8200100000827fffffff0085a585a9a2 *00859285929c8692849b920ea000849999085370656c6c696e6786be8200100000827fffffff00 *85a585a9a20085928592849d9d002a84a09a0392849b922ba0008499990b5370656c6c696e67e2 *80a686849999013a868200100000827fffffff0085a585a9850085928592858692849b922ba000 *8499990e436865636b205370656c6c696e6786849999013b868200100000827fffffff0085a585 *a9850085928592858692849b922ba0008499991a436865636b205370656c6c696e672061732059 *6f75205479706586be8200100000827fffffff0085a585a9850085928592858686858686868586 *8692849b92c4a0008499990657696e646f7786be8200100000827fffffff0085a585a9a2008592 *8592b78692c3868499990b5f4e534d61696e4d656e758686a0008499990448656c7086be820010 *0000827fffffff0085a585a9a20085928592849d9d008498990448656c708684a09a0192849b92 *39a000849999134e65774170706c69636174696f6e2048656c7086849999013f86820010000082 *7fffffff0085a585a9850085928592858686858686c496d9c996270e96bdb796d2c99639c396e8 *e69600e896210e96c4959635c496e2c996180e96ebe896cdc996bfb79609e896ae9c96302b969c *2796f3f196c7c496dcc996d4d2963c399603e896110e96cec996230e961b0e96f9e896290e96ee *e896dfc996b19c96140e96b73596a29c96f6f396c9c7960cc49605e896fae896260e96bab796f1 *e896d1c9961e0e96fde896332b96cbc996d8c9962b2996e6c496e1c996170e9606e8960e0c962d *2b9a2c96ee8498990086969a8499990b4e534d656e754974656d318696fa84989901318696c484 *9899084d61696e4d656e7586960c8499990a4e534d656e754974656d869639849899013286961b *8499990b4e534d656e754974656d318696178499990a4e534d656e754974656d86960084989901 *388696218499990b4e534d656e754974656d348696c3849899013186969c849999064e534d656e *758696ce8499990331323186960684989901358696308499990b4e534d656e754974656d388696 *eb84989901398696ab8499990b4e534d656e754974656d348696b78596268499990c4e534d656e *754974656d31328696118499990b4e534d656e754974656d328696b18499990b4e534d656e7549 *74656d3286960e849999064e534d656e7586962b849999064e534d656e758696338499990a4e53 *4d656e754974656d8696958498990c46696c652773204f776e65728696f984989901378696e63f *96148499990c4e534d656e754974656d31318696188499990b4e534d656e754974656d3386961e *8499990b4e534d656e754974656d3986963c3f96e284999904313131318696278499990b4e534d *656e754974656d3786962d8499990b4e534d656e754974656d368696238499990c4e534d656e75 *4974656d31308696fd84989901338696a28499990a4e534d656e754974656d8696e83f96bd3f96 *038498990231308696ae8499990b4e534d656e754974656d338696098498990136869605849899 *01328696298499990c4e534d656e754974656d313386928484840c4e534d757461626c65536574 *008484054e53536574009484014900869284a09a2192848484154e534e6962436f6e74726f6c43 *6f6e6e6563746f728100cf84840e4e534e6962436f6e6e6563746f7211948403404040ba858498 *9913706572666f726d4d696e6961747572697a653a868692846ba8bf858498990f617272616e67 *65496e46726f6e743a868692846ba806858498990e72756e506167654c61796f75743a86869284 *6ba83c858498990973686f7748656c703a868692846ba8f68584989915636c656172526563656e *74446f63756d656e74733a868692846ba8e2958498990a7465726d696e6174653a868692846ba8 *cb958498991d6f7264657246726f6e745374616e6461726441626f757450616e656c3a86869284 *6ba8dc9584999916686964654f746865724170706c69636174696f6e733a868692846ba8d99584 *999905686964653a868692846ba8df9584999916756e68696465416c6c4170706c69636174696f *6e733a868692846ba81885849899046375743a868692846ba81e858498990670617374653a8686 *92846ba81485849899057265646f3a868692846ba823858498990a73656c656374416c6c3a8686 *92846ba8118584989905756e646f3a868692846ba81b8584989905636f70793a868692846ba82d *858498990f73686f77477565737350616e656c3a868692846ba830858498990e636865636b5370 *656c6c696e673a868692846ba833858499991e746f67676c65436f6e74696e756f75735370656c *6c436865636b696e673a868692846ba8fa858499990d706572666f726d436c6f73653a86869284 *6ba8eb858499990c6e6577446f63756d656e743a868692846ba8ee858499990d6f70656e446f63 *756d656e743a868692846ba8fd858499990d73617665446f63756d656e743a868692846ba80085 *8499990f73617665446f63756d656e7441733a868692846ba8038584999916726576657274446f *63756d656e74546f53617665643a868692846ba809858499990e7072696e74446f63756d656e74 *3a868692846ba821858499990764656c6574653a868692846ba8b6858499990c706572666f726d *5a6f6f6d3a868692846ba8a28584999917706572666f726d46696e6450616e656c416374696f6e *3a868692846ba8ab8584999917706572666f726d46696e6450616e656c416374696f6e3a868692 *846ba8ae8584999917706572666f726d46696e6450616e656c416374696f6e3a868692846ba8b1 *8584999917706572666f726d46696e6450616e656c416374696f6e3a868692846ba89a85849999 *1d63656e74657253656c656374696f6e496e56697369626c65417265613a86868692859a608402 *40698100a48100cda9188100a0a98100928100c1a981009e8100c8a9ba17a9ae8100a2a981008c *8100bca9d2810083a98100808100afa97057a91181009ea9bf05a9cd8100caa9396aa9218100a4 *a9f67ea9278100a8a90e8100a9a9ee48a98100aa8100d0a9e653a98100908100c0a9b718a90370 *a9c738a9e2810088a98100828100b0a9747fa9d8810090a981009a8100c5a98100948100c2a981 *00a08100c9a96a25a9ab8100a7a9f94fa9cb3aa9054aa97681008ba97c810098a98100a68100ce *a98100868100b3a9dc810091a97a810092a91781009ca91e8100aba9f37da90050a96e27a98100 *8a8100b5a9d181008fa9eb52a9e851a99501a98100ac8100d1a9bd5ca99a81009ba981009c8100 *c6a90c8100a3a9a281009aa9268100aea981008e8100bea98100968100c3a9308100bda98100a2 *8100cca9e1810095a92b8100b9a97e810099a9727aa9148100ada9ce810081a91b81009da9d981 *0086a9094ea9f17ca9c41da9c367a98100a88100cfa9b18100a1a9298100b8a9d4810082a98100 *848100b2a97881008ea9338100bfa92d8100bba93c6fa9238100aca99c81009fa93513a9fa49a9 *064da9b68100cba9fd4ba9c939a9df810096a98100888100b4a98100988100c49a8100d29a0092 *849899104942436f636f614672616d65776f726b8686 hunk ./examples/objc/expression_parser/English.lproj/MyDocument.nib/classes.nib 1 - +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {chooseParser = id; evaluateExpression = id; }; + CLASS = MyDocument; + LANGUAGE = ObjC; + OUTLETS = {evaluation = id; expressionEntry = id; parser = id; }; + SUPERCLASS = NSDocument; + } + ); + IBVersion = 1; +} hunk ./examples/objc/expression_parser/English.lproj/MyDocument.nib/info.nib 1 + + + + + IBDocumentLocation + 79 43 356 240 0 0 1280 832 + IBFramework Version + 349.0 + IBOpenObjects + + 21 + + IBSystem Version + 7F44 + + binary ./examples/objc/expression_parser/English.lproj/MyDocument.nib/keyedobjects.nib oldhex * newhex *62706c6973743030d40001000200030004000500060007000a5924617263686976657258247665 *7273696f6e5424746f7058246f626a656374735f100f4e534b6579656441726368697665721200 *0186a0d1000800095d49422e6f626a656374646174618001af10ca000b000c002b002f00300036 *003a003e0043005b005c005d005e006000670072007a007b00930094009c009d00a000a100a200 *a700ad00b100b200ba00bb00c500c600c700cb00cd00d000d100d300d600da00dd00de00e000e1 *00e400e500e9009c00ed00ee00f100f200f500f600f900fa00fd00fe00ff010e0110011d011f01 *2d012e0136013d0140014101450147014b014d014f015a015c00b400bc016501670168016a016b *016e017500bc008c01760179017c017d017e0182018301880189018b018e019701980199019c01 *a1019801a201a301a601ac01ae01b201b401ba01bb01bd01c001c201c301c501c800b400bc01cc *017500bc008c017c01d201d301d40197019801d701a1019801da01db01dc01de01df01e001e101 *e401e801f101f701f801fc01fe01ff02010202020502060209020b020c020e020f021102120215 *02170219021b02290130022a00a9022b022c022d022e022f013002310232023302350236023802 *4e024f00500250025102520253008c025402550256025702580259025a025b025c025d025e025f *026055246e756c6cdf100f000d000e000f0010001100120013001400150016001700180019001a *001b001c001d001e001f0020002100220023002400250026002700280029002a5b4e534e616d65 *734b6579735b4e534672616d65776f726b5f100f4e534f626a6563747356616c7565735d4e534e *616d657356616c7565735d4e53436f6e6e656374696f6e735d4e53466f6e744d616e6167657256 *4e53526f6f74594e534e6578744f69645f10104e5356697369626c6557696e646f77735d4e534f *626a656374734b6579735d4e53436c61737365734b6579735a4e534f6964734b6579735c4e534f *69647356616c7565735624636c6173735f100f4e53436c617373657356616c75657380a3800580 *a280a4808f8000800211011f800780a080b180b380b480c980b2d2001a002c002d002e5b4e5343 *6c6173734e616d65800480035a4d79446f63756d656e74d200310032003300345824636c617373 *65735a24636c6173736e616d65a2003400355e4e53437573746f6d4f626a656374584e534f626a *656374d20037001a00380039594e532e737472696e675f10104942436f636f614672616d65776f *726b8006d200310032003b003ca3003c003d00355f100f4e534d757461626c65537472696e6758 *4e53537472696e67d2003f001a004000425a4e532e6f626a65637473a100418008808edc004400 *450046004700480049004a004b004c004d001a004e004f00500051005200530054005500560057 *00580059005a5f10114e5357696e646f775374796c654d61736b5f100f4e5357696e646f774261 *636b696e67594e534d696e53697a655d4e5357696e646f775469746c655d4e5357696e646f7743 *6c6173735c4e5357696e646f77526563745c4e5353637265656e52656374594e534d617853697a *655c4e5357696e646f7756696577594e535754466c6167735b4e5356696577436c617373100e10 *02808b800a800b8009808a808c800d1270280000808d800c5f10187b7b3130372c203237357d2c *207b3237332c203438307d7d5f10194861736b656c6c2045787072657373696f6e205061727365 *72584e5357696e646f77d20037001a005f00395456696577d4006100620063001a006400210065 *00665a4e5353756276696577735f100f4e534e657874526573706f6e646572574e534672616d65 *800e80888089d2003f001a00680071a80069006a006b006c006d006e006f0070800f801a802880 *2c80328036803b806b8047d60062007300630074001a00750057005700760077007800795b4e53 *537570657276696577594e53456e61626c6564564e5343656c6c801009801980115f10157b7b39 *302c203134367d2c207b39332c2033327d7ddd007c007d007e007f0080008100820083001a0084 *00850086008700880089008a0089008b0069008c008d008e008f0090009100925f10124e535065 *72696f646963496e74657276616c5f10104e53416c7465726e617465496d6167655f10134e5341 *6c7465726e617465436f6e74656e7473594e53537570706f72745a4e53436f6e74656e74735d4e *53436f6e74726f6c566965775e4e53427574746f6e466c616773325d4e53427574746f6e466c61 *67735f100f4e53506572696f64696344656c61795b4e5343656c6c466c6167735f100f4e534b65 *794571756976616c656e745c4e5343656c6c466c616773321019801380168012100113ffffffff *868240ff801810c8120401fe0080171208000000584576616c75617465d400950096001a009700 *980099009a009b564e5353697a65564e534e616d65584e5366466c616773224150000080148015 *10145c4c75636964614772616e6465d200310032009e009fa2009f0035564e53466f6e7450d200 *37001a00a00039d20031003200a300a4a500a400a500a6007500355c4e53427574746f6e43656c *6c5d254e53427574746f6e43656c6c5c4e53416374696f6e43656c6cd20031003200a800a9a500 *a900aa00ab00ac0035584e53427574746f6e594e53436f6e74726f6c564e53566965775b4e5352 *6573706f6e646572d60062007300630074001a00750057005700ae007700af00b0801b8027801c *5f10167b7b38322c203239357d2c207b3131342c2031377d7dd800b3007f00800081001a008500 *b4008700b5008900b6006a00b7009000b800b95b4e5354657874436f6c6f725f10114e53426163 *6b67726f756e64436f6c6f728023801d8026801e12084000005b45787072657373696f6e3ad500 *bc00bd00be00bf001a00c000c100c200c300c4574e53436f6c6f725b4e53436f6c6f724e616d65 *5c4e53436f6c6f7253706163655d4e53436174616c6f674e616d65802180201006801f80225653 *797374656d5c636f6e74726f6c436f6c6f72d300c800be001a00c900ca00c4574e535768697465 *4b302e3636363636363639001003d20031003200cc00bca200bc0035d500bc00bd00be00bf001a *00ce00cf00c200c300c4802580245f1010636f6e74726f6c54657874436f6c6f72d300c800be00 *1a00d200ca00c4423000d20031003200d400d5a400d500a6007500355f100f4e53546578744669 *656c6443656c6cd20031003200d700d8a600d800d900aa00ab00ac00355b4e5354657874466965 *6c645c254e53546578744669656c64d60062007300630074001a00750057005700db007700af00 *dc8029802a5f10167b7b37392c203131377d2c207b3131342c2031377d7dd800b3007f00800081 *001a008500b4008700b5008900df006b00b7009000b800b9802b5d4576616c756174657320746f *3ad60062007300630074001a00750057005700e2007700af00e3802d802e5f10167b7b31372c20 *3332307d2c207b3234352c2036317d7dd900b3007f0080008100e6001a008500b4008700b500e7 *008a006c00e800b7009000b800b95f10134e53506c616365686f6c646572537472696e67802f80 *31d400950096001a009700ea00eb009a00ec22413000008030101c5f101f286e6f206578707265 *7373696f6e207061727365722073656c656374656429d60062007300630074001a007500570057 *00ef007700af00f0803380345f10167b7b34392c203434317d2c207b3137322c2031397d7dd800 *b3007f00800081001a008500b4008700b5008900f3006d00b700f400b800b98035120411fe405f *101943686f6f73652045787072657373696f6e205061727365723ad60062007300630074001a00 *750057005700f70077007800f8803780385f10167b7b37302c203339337d2c207b3133302c2033 *327d7ddd007c007d007e007f0080008100820083001a008400850086008700880089008a008900 *fb006e008c008d008e008f009000fc00928039803a5d43686f6f736520506172736572d2003700 *1a00a00039db0061006200730100006301010102010301040105001a0106005700570107010801 *09010a010b010c0107010d5d4e534e6578744b6579566965775b4e53485363726f6c6c6572584e *5376466c616773584e5373466c6167735b4e53565363726f6c6c65725d4e53436f6e74656e7456 *696577803c803d806980661101001102128062806ad2003f001a010f0071a30107010c0109db00 *61006200730100011101120113011400630102001a0115006f006f01160117011601180119011a *011b011c594e534247436f6c6f72594e53446f6356696577594e536376466c616773584e534375 *72736f72803e803f804b1004805e805d1109008061d2003f001a011e0071a10116db0120006200 *7301210122004b012301240102001a0125012601070107012701280129002100c2012a012b012c *5b4e534672616d6553697a65584e534d696e697a655c4e53536861726564446174615a4e534465 *6c6567617465594e535456466c6167735f100f4e5354657874436f6e7461696e65728040805b80 *4a805a110812805c8041597b3233312c2033397dd5012f013001310132001a013301160134008c *0135574e5357696474685a4e5354657874566965775f100f4e534c61796f75744d616e61676572 *594e535443466c616773224367000080428049d5013701380123001a0139013a00c20021013b01 *3c5d4e535465787453746f72616765594e534c4d466c6167735f10104e5354657874436f6e7461 *696e657273804380488046d30123001a003d0021013e013f80458044d20037001a00a00039d200 *31003201420137a401370143014400355f10194e534d757461626c654174747269627574656453 *7472696e675f10124e5341747472696275746564537472696e67d2003f001a01460071a1012cd2 *0031003201480149a30149014a00355e4e534d757461626c654172726179574e534172726179d2 *00310032014c0131a201310035d200310032014e0125a201250035d80150015101520153015400 *1a015500b40156015700ce002101580159002101175f10144e5353656c65637465644174747269 *6275746573574e53466c6167735f10104e53496e73657274696f6e436f6c6f725f10174e534465 *6661756c745061726167726170685374796c655f10104e534c696e6b417474726962757465735f *10124e534d61726b656441747472696275746573804c112be780548059d300c800be001a015b00 *ca00c4423100d3003f015d001a015e01610164574e532e6b657973a2015f0160804f8051a20162 *0163804d804e8053d500bc00bd00be00bf001a00c0016600c200c300c480505f101b73656c6563 *746564546578744261636b67726f756e64436f6c6f72d500bc00bd00be00bf001a00ce016900c2 *00c300c480525f101173656c656374656454657874436f6c6f72d200310032016c016da2016d00 *355c4e5344696374696f6e617279d3003f015d001a016f01720164a20170017180578058a20173 *0174805580565b4e53556e6465726c696e65d3017700be001a0178008c00c4554e535247424630 *2030203100d200310032017a017ba2017b00355f10144e53546578745669657753686172656444 *6174615c7b3233312c2031652b30377d597b3131342c2033397dd200310032017f0130a6013001 *80018100ab00ac00355b254e535465787456696577564e53546578745f10137b7b312c20317d2c *207b3233312c2039317d7dd301840185001a0186008c0187594e53486f7453706f745c4e534375 *72736f7254797065805f8060577b342c202d357dd200310032018a0114a201140035d200310032 *018c018da4018d00ab00ac00355a4e53436c697056696577d800620073018f019000630102001a *0191006f006f0192006f01930194019501965a4e5343757256616c7565584e5354617267657458 *4e53416374696f6e223f800000806313ffffffff80000100806580645f10147b7b2d33302c2031 *7d2c207b31352c2039317d7d5c5f646f5363726f6c6c65723ad200310032019a019ba5019b00aa *00ab00ac00355a4e535363726f6c6c6572da00620073018f0190006301020103001a019d019100 *6f006f0192006f019e010a008c0195019f01a0594e5350657263656e748067223f72164380685f *10187b7b2d3130302c202d3130307d2c207b38372c2031387d7d5f10167b7b32302c203139347d *2c207b3233332c2039337d7dd20031003201a401a5a401a500ab00ac00355c4e535363726f6c6c *56696577db0061006200730100006301010102010301040105001a01a70057005701a801a901aa *010a010b01ab01a8010d806c806d808780848081d2003f001a01ad0071a301a801ab01aadb0061 *006200730100011101120113011400630102001a01af0070007001b0011701b00118011901b101 *1b011c806e806f8080d2003f001a01b30071a101b0db01200062007301210122004b0123012401 *02001a012501b501a801a801b601b701b8002100c2012a012b01b98070807f8076807e8071597b *3233312c2033357dd5012f013001310132001a013301b001bc008c01358072d501370138012300 *1a013901be00c20021013b01bf80738075d30123001a003d0021013e01c18074d20037001a00a0 *0039d2003f001a01c40071a101b9d801500151015201530154001a015500b401c6015700ce0021 *01c70159002101178077807ad3003f015d001a015e01c90164a201ca01cb80788079d3003f015d *001a01cd01cf0164a201ce0171807da201d001d1807b807c597b3131342c2032367d5f10137b7b *312c20317d2c207b3233312c2038377d7dd800620073018f019000630102001a01910070007001 *92007001d50194019501d680828083da00620073018f0190006301020103001a019d0191007000 *700192007001d8010a008c0195019f01d9808580865f10157b7b32302c2032307d2c207b323333 *2c2038397d7d5f10147b7b312c20397d2c207b3237332c203438307d7dd20031003201dd00aba3 *00ab00ac00355f10157b7b302c20307d2c207b313238302c203833327d7d5a7b3231332c203132 *397d5f101a7b332e3430323832652b33382c20332e3430323832652b33387dd20031003201e201 *e3a201e300355f10104e5357696e646f7754656d706c617465d20031003201e501e6a301e601e7 *00355c4e534d757461626c65536574554e53536574d2003f001a01e90071a701ea01eb01ec01ed *01ee01ef01f08090809380958097809a809c809ed401f201f3001a01f4002201f501f600415d4e *5344657374696e6174696f6e574e534c6162656c584e53536f75726365809180925864656c6567 *617465d20031003201f901faa301fa01fb00355f10144e534e69624f75746c6574436f6e6e6563 *746f725e4e534e6962436f6e6e6563746f72d401f201f3001a01f4004101fd01f6002280945677 *696e646f77d401f201f3001a01f4006c020001f60022809656706172736572d401f201f3001a01 *f40022020302040069809880995f10126576616c7561746545787072657373696f6ed200310032 *02070208a3020801fb00355f10154e534e6962436f6e74726f6c436f6e6e6563746f72d401f201 *f3001a01f40022020a0204006e809b5c63686f6f7365506172736572d401f201f3001a01f401b0 *020d01f60022809d5a6576616c756174696f6ed401f201f3001a01f40116021001f60022809f5f *100f65787072657373696f6e456e747279d2003f001a02130214ac006d0069006e006b01b00070 *0041006f0116006a0057006c80a1d2003100320216014aa2014a0035d2003f001a02180214ac00 *570057005700570070005700220057006f005700410057d2003f001a021a0214ac006e0116006c *0069006a006d0041006f002201b00070006bd2003f001a021c0214ac021d021e021f0220022102 *2202230224022502260227022880a580a680a780a880a980aa80ab80ac80ad80ae80af80b0594e *53427574746f6e315d4e53546578744669656c6431315d4e53546578744669656c6432315e4e53 *546578744669656c643231325657696e646f775d4e535363726f6c6c5669657732d20037001a02 *3000395c46696c652773204f776e65725e4e535363726f6c6c5669657732315e4e535465787446 *69656c64323131d2003f001a02340214a0d2003f001a02340214d2003f001a02370214af101401 *ed01ee0057006a0070006f01f00022006e006901ef006c006b01ec006d01eb011601ea004101b0 *d2003f001a02390214af1014023a023b023c023d023e023f024002410242024302440245024602 *4702480249024a024b024c024d80b580b680b780b880b980ba80bb80bc80bd80be80bf80c080c1 *80c280c380c480c580c680c780c811011511011610f911011c11011911011e11010710f711011d *11010510fa11011411010611011211011a110110101511011bd20031003202610262a202620035 *5e4e5349424f626a65637444617461000800190023002c0031003a004c005100560064006601fd *02030242024e025a026c027a02880296029d02a702ba02c802d602e102ee02f503070309030b03 *0d030f0311031303150318031a031c031e0320032203240326032f033b033d033f034a0353035c *0367036c037b0384038d039703aa03ac03b503bc03ce03d703e003eb03ee03f003f20423043704 *4904530461046f047c0489049304a004aa04b604b804ba04bc04be04c004c204c404c604c804cd *04cf04d104ec05080511051a051f0530053b054d055505570559055b0564057505770579057b05 *7d057f058105830585058705a005ac05b605bd05bf05c005c205c405dc061106260639064f0659 *066406720681068f06a106ad06bf06cc06ce06d006d206d406d606df06e106e306e806ea06ef06 *f80709071007170720072507270729072b073807410746074d074e07570760076b077807860793 *079c07a707b007ba07c107cd07e607e807ea07ec08050826083208460848084a084c084e085308 *5f0874087c0888089508a308a508a708a908ab08ad08b408c108ce08d608e208e408ed08f20907 *0909090b091e092b092e093709400952095b096809740981099a099c099e09b709d809da09e80a *010a030a050a1e0a430a590a5b0a5d0a6e0a730a750a770a990ab20ab40ab60acf0af00af20af7 *0b130b2c0b2e0b300b490b7e0b800b820b900b990bc60bd40be00be90bf20bfe0c0c0c0e0c100c *120c140c170c1a0c1c0c1e0c270c2e0c5b0c650c6f0c790c820c840c860c880c8a0c8c0c8e0c91 *0c930c9c0c9f0ccc0cd80ce10cee0cf90d030d150d170d190d1b0d1d0d200d220d240d2e0d430d *4b0d560d680d720d770d790d7b0d900d9e0da80dbb0dbd0dbf0dc10dce0dd00dd20ddb0de40ded *0e090e1e0e270e2a0e330e3a0e490e510e5a0e5f0e680e6d0e8e0ea50ead0ec00eda0eed0f020f *040f070f090f0b0f180f1b0f280f300f350f370f390f3e0f400f420f440f590f5b0f790f8e0f90 *0fa40fad0fb20fbf0fcc0fd10fd30fd50fda0fdc0fde0fea0ff70ffd1004100d10121029103610 *401049105610621069107f108c109610a310a510a710af10b810bd10c610cf10da10fb1106110f *1118111d111f1128112a112c1143115011591164116f119811a211a411a911ab11c611df11e811 *f111fe122b122d122f123112331235123e124512721274127612781281128412b112b312b512b7 *12b912bb12c512da12dc12f112f312f513021304130d13161319133a133c133e134b1350135213 *54136113661368136d136f1371137b139113b213b413b613df13e113e313fb1412141b1422143a *14451462146b14701483148c149314a014a614af14be14c014c214c414c614c814ca14cc14dd14 *eb14f314fc14fe15001509151215191530153f155015521559156a156c1573158415861588159d *15a615ad15c515d615d815e515f615f816031614161616281631164a164c1655165a1663167c16 *85169e16a716c016c216c416c616c816ca16cc16ce16d016d216d416d616d816e216f016fe170d *17141722172b173817471756175f176017691772179d17a617d117d317d517d717d917db17dd17 *df17e117e317e517e717e917eb17ed17ef17f117f317f517f717f917fc17ff180118041807180a *180d180f181218151817181a181d1820182318261828182b183418390000000000000202000000 *000000026300000000000000000000000000001848 binary ./examples/objc/expression_parser/English.lproj/MyDocument.nib/objects.nib oldhex * newhex *040b747970656473747265616d8103e88401408484840e4e5349424f626a656374446174618100 *e08484084e534f626a6563740085928484840e4e53437573746f6d4f626a656374299484024040 *848484084e53537472696e67019484012b0a4d79446f63756d656e748685868401690c96848484 *0b4e53546578744669656c64198484094e53436f6e74726f6c298484064e53566965772984840b *4e53526573706f6e646572009492849c92859900840c4040404066666666666666668484840e4e *534d757461626c654172726179008484074e5341727261790094990892848484084e5342757474 *6f6e009b929e99009e858585855a8100925d2000005d20929e9285928592858404696363400001 *008484840c4e53427574746f6e43656c6c3f84840c4e53416374696f6e43656c6c118484064e53 *43656c6c419484026969820401fe008208000000840440404040849898084576616c7561746586 *848484064e53466f6e741594992484055b3336635d060000001a000000feff004c007500630069 *00640061004700720061006e0064006500008401660d84016300ab01ab00ab048685858402693a *0085928592a284097373696940404040408100c8190182868240ff84989800868484840f4e534d *757461626c65537472696e67019898008685a985868692849a929e99009e858585855281012772 *1100007211929e928592859285a20001008484840f4e53546578744669656c6443656c6c3ea6a6 *820401fe008208400000a78498980b45787072657373696f6e3a86a98585ac0085928592ae8403 *63404000848484074e53436f6c6f720094ab0684034040408498980653797374656d868498980c *636f6e74726f6c436f6c6f728684b3ab0384026666833f2aaaab01868684b3ab06b2b484989810 *636f6e74726f6c54657874436f6c6f728684b3ab03b30001868686928584013a858692849a929e *99009e858585854f75721100007211929e928592859285a200010084b0a6820401fe0082084000 *00a78498980d4576616c756174657320746f3a86a98585ac0085928592bab000b2b7869285b485 *8692849a929e99009e85858585118101408100f53d00008100f53d929e928592859285a2000100 *84b0a6820401fe008208400000a7ab84aa9924a9060000001a000000feff004c00750063006900 *640061004700720061006e006400650000aa0bab00ab01ab00ab0c868585ac0085928592bdb000 *b2b7869285b4858692999284a3929e99009e858585854681018981008220000081008220929e92 *8592859285a200010084a5a6820401fe008208000000a78498980d43686f6f7365205061727365 *7286a98585ac0085928592c0ad8100c8190182868240ffab84ad98008685a9858686928484840c *4e535363726f6c6c566965778100e29c929e9982008000009e84a09903928484840a4e53436c69 *70566965773a9c92c4998200c000009e84a0990192848484124e53546578745669657754656d70 *6c6174658101c684840e4e535669657754656d706c6174652e9c92c79982124000009e85858585 *00008100e72700008100e72792c7928592859285928498980a4e53546578745669657786928592 *84b3ab03b3010186928484840c4e5344696374696f6e6172790094990292849898114e53426163 *6b67726f756e64436f6c6f72869284b3ab06b2b48498981b73656c656374656454657874426163 *6b67726f756e64436f6c6f7286b68692849898074e53436f6c6f72869284b3ab06b2b484989811 *73656c656374656454657874436f6c6f7286b9868692b9b38100e78200989680b37227b38100e7 *82009896809285ab01ab01ab01ab01ab00ab00ab01ab00ab01ab00ab01ab00ab01ab009284d099 *0192849898074e53436f6c6f72869284b3ab06b2b48498980974657874436f6c6f7286b9868686 *8685858501018100e75b00008100e75b92c4928592ca928592ca84054040636363ce848484084e *53437572736f721194b304fb9285ab00ab008600000186928484840a4e535363726f6c6c657281 *00d39b92c49982008008009e85858585e2010f5b00000f5b92c4928592859285a20000008592c4 *840366663a0100840c5f646f5363726f6c6c65723aab00ab00869284de92c49982008000009e85 *8585859c9c57120000571292c4928592859285a20000008592c4bd01833f721643beab01ab0086 *86858585148100c28100e95d00008100e95d929e928592c7928592dd92df92c792859285840566 *666666690a0a0a0a8284008000869284c5929e9982008000009e84a099039284c892e0998200c0 *00009e84a099019284cb92e29982124000009e8585858500008100e72300008100e72392e29285 *92859285928498980a4e53546578745669657786928592ce9284d0990292849898114e53426163 *6b67726f756e64436f6c6f728692d292849898074e53436f6c6f728692d58692b9b38100e78200 *989680b3721ab38100e782009896809285ab01ab01ab01ab01ab00ab00ab01ab00ab01ab00ab01 *ab00ab01ab009285868685858501018100e75700008100e75792e0928592e4928592e4bacedb00 *0001869284de92e09982008008009e85858585e2010f5b00000f5b92e0928592859285a2000000 *8592e0bd0100beab00ab00869284de92e09982008000009e858585859c9c57120000571292e092 *8592859285a20000008592e0bd01833f721643beab01ab00868685858514148100e95900008100 *e959929e928592e2928592e992ea92e292859285bf0a0a0a0a8284008000868685858501098101 *118101e000008101118101e092859285928592858699009e85858585318101b98100ac13000081 *00ac13929e928592859285a200010084b0a6820411fe408208400000a78498981943686f6f7365 *2045787072657373696f6e205061727365723a86a98585ac008592859299b000b2b7869285b485 *869e96a29e96c09e96ba9e96e4e096e09e96848484104e5357696e646f7754656d706c61746581 *01f894840d696966666666694040404040630e026b8101138101118101e0827028000084989819 *4861736b656c6c2045787072657373696f6e2050617273657286849898084e5357696e646f7786 *84ad980456696577869e85018404666666660000810500810340ab01b38100d58100819285ab02 *b3837f7fffee837f7fffee869596c49e96cac496ae9e969eed96bd9e990c96c0849898094e5342 *7574746f6e318696ca8498980a4e5354657874566965778696bd8498980d4e5354657874466965 *6c6431318696a2849898084e53427574746f6e8696ae8498980d4e53546578744669656c643231 *8696998498980e4e53546578744669656c643231328696ed8498980657696e646f778696c48498 *980d4e535363726f6c6c566965773286969584ad980c46696c652773204f776e65728696e48498 *980a4e5354657874566965778696e08498980e4e535363726f6c6c5669657732318696ba849898 *0e4e53546578744669656c6432313186928484840c4e534d757461626c65536574008484054e53 *53657400948401490192ed869284a0990792848484144e534e69624f75746c6574436f6e6e6563 *746f728100cf84840e4e534e6962436f6e6e6563746f721194b2ed958498980864656c65676174 *658686928403b295ed8498980677696e646f778686928403b295bd849898067061727365728686 *92848484154e534e6962436f6e74726f6c436f6e6e6563746f728100cf04b2a295849898126576 *616c7561746545787072657373696f6e868692840bb2c0958498980c63686f6f73655061727365 *728686928403b295e48498980a6576616c756174696f6e8686928403b295ca8498980f65787072 *657373696f6e456e74727986868692859914840240690a810115c90d810116c99e02c9ae8100f9 *c9e081011cc9c4810119c91181011ec99501c9c0810107c9a28100f7c90f81011dc9bd810105c9 *ba8100fac908810114c999810106c906810112c9ca81011ac902810110c9ed15c9e481011b9981 *011f99009284ad98104942436f636f614672616d65776f726b8686 hunk ./examples/objc/expression_parser/Info.plist 1 + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + ???? + + CFBundleTypeIconFile + + CFBundleTypeName + DocumentType + CFBundleTypeOSTypes + + ???? + + CFBundleTypeRole + Editor + NSDocumentClass + MyDocument + + + CFBundleExecutable + PluginExpressionParser + CFBundleIconFile + + CFBundleIdentifier + com.apple.yourCocoaDocApp + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 0.1 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + hunk ./examples/objc/expression_parser/KeyValueParser.hs 1 +module KeyValueParser where + +import Text.ParserCombinators.Parsec + +parseKeyValue = do + key <- parseKey + char '=' + value <- parseValue + return (key, value) + +parseKey = many1 letter + +parseValue = + do + openQuote <- char '"' <|> char '\'' + value <- many1 letter + char openQuote + return value + <|> + do + value <- many1 letter + return value + +parseString s = do + case (parse parseKeyValue "" s) of + Left err -> return ("Error " ++ show err) + Right (key, value) -> return ("Key: " ++ key ++ ", Value: " ++ value) + +resource :: String -> IO String +resource text = do + parsedText <- mapM parseString (lines text) + return (unlines parsedText) + hunk ./examples/objc/expression_parser/Makefile 1 +APP_DIR = build/PluginExpressionParser.app +APP_CONTENTS_DIR = $(APP_DIR)/Contents +APP_ARCH_EXEC_DIR = $(APP_CONTENTS_DIR)/MacOS +APP_RESOURCES_DIR = $(APP_CONTENTS_DIR)/Resources +EXECUTABLE = $(APP_ARCH_EXEC_DIR)/PluginExpressionParser + +OBJECT_FILES = main.o MyDocument.o PluginEvalAux.o +BUILD_OBJECT_FILES = $(addprefix build/,$(OBJECT_FILES)) \ + build/PluginEvalAux_stub.o + +HOST = $(shell uname) + +ifeq ($(HOST),Darwin) +default: app +else +default: no_app +endif + +app: $(APP_CONTENTS_DIR) $(APP_RESOURCES_DIR) $(EXECUTABLE) + +# + +$(EXECUTABLE): $(APP_ARCH_EXEC_DIR) $(BUILD_OBJECT_FILES) + ghc \ + -o "$(EXECUTABLE)" \ + -framework Cocoa \ + -package-conf ../../../plugins.conf.inplace \ + -package plugins \ + -no-hs-main \ + $(BUILD_OBJECT_FILES) + +build/MyDocument.o: MyDocument.m MyDocument.h + gcc -c -o "$@" -Wall -I`ghc --print-libdir`/include "$<" + +build/main.o: main.m + gcc -c -o "$@" -Wall -I`ghc --print-libdir`/include "$<" + +build/PluginEvalAux.o: PluginEvalAux.hs + ghc --make \ + -package-conf ../../../plugins.conf.inplace \ + -package plugins \ + -odir build/ \ + -hidir build/ \ + "$<" + +# + +$(APP_DIR): + mkdir -p "$@" + +$(APP_ARCH_EXEC_DIR): $(APP_DIR) + mkdir -p "$@" + +$(APP_CONTENTS_DIR): $(APP_DIR) Info.plist + mkdir -p "$(APP_CONTENTS_DIR)" + cp Info.plist "$@" + echo -n 'APPL????' > "$@"/PkgInfo + +$(APP_RESOURCES_DIR): $(APP_DIR) English.lproj + mkdir -p "$(APP_RESOURCES_DIR)" + cp -R English.lproj "$@" + +# + +clean: + -rm -rf build *_stub.? + hunk ./examples/objc/expression_parser/MyDocument.h 1 +/* MyDocument */ + +#import + +#include "RunHaskell.h" + +@interface MyDocument : NSDocument +{ + IBOutlet id evaluation; + IBOutlet id expressionEntry; + IBOutlet id parser; +} +- (IBAction)chooseParser:(id)sender; +- (IBAction)evaluateExpression:(id)sender; + +@end hunk ./examples/objc/expression_parser/MyDocument.m 1 +#import "MyDocument.h" + +@implementation MyDocument + +- (NSString *)windowNibName { + return @"MyDocument"; +} + +- (NSData *)dataRepresentationOfType:(NSString *)type { + return nil; +} + +- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type { + return NO; +} + + +- (IBAction)chooseParser:(id)sender +{ + int result; + NSArray *fileTypes = [NSArray arrayWithObject:@"hs"]; + NSOpenPanel *oPanel = [NSOpenPanel openPanel]; + + result = [oPanel runModalForDirectory:nil file:nil types:fileTypes]; + if (result == NSOKButton) + { + NSArray *filesToOpen = [oPanel filenames]; + [parser setStringValue:[filesToOpen objectAtIndex:0]]; + } +} + +- (IBAction)evaluateExpression:(id)sender +{ + NSLog(@"evaluateExpression"); + NSString *filePathNSS = [parser stringValue]; + char *filePath = [filePathNSS cString]; + + NSString *expressionNSS = [[expressionEntry textStorage] string]; + char *expression = [expressionNSS cString]; + + NSLog (@"filePath:%s expression:%s", filePath, expression); + + char *result = evalhaskell_CString(filePath, expression); + NSString *resultNSS = [NSString stringWithCString:result]; + NSAttributedString *resultNSAS = [[NSAttributedString alloc] + initWithString:resultNSS + attributes:nil]; + [[evaluation textStorage] setAttributedString:resultNSAS]; + +} + +@end hunk ./examples/objc/expression_parser/PluginEvalAux.hs 1 +{-# OPTIONS -fglasgow-exts -fffi #-} + +module PluginEvalAux where + +import Plugins.Make +import Plugins.Load +import Plugins.Utils + +import Foreign.C +import Control.Exception ( evaluate ) +import System.IO +import System.Directory ( renameFile, removeFile ) + +symbol = "resource" + +evalWithStringResult :: FilePath -> String -> IO String +evalWithStringResult srcFile s = do + status <- make srcFile ["-Onot"] + case status of + MakeFailure err -> putStrLn "error occured" >> return (show err) + MakeSuccess _ obj -> load' obj + where + load' obj = do + loadResult <- load obj [] [] symbol + case loadResult of + LoadFailure errs -> putStrLn "load error" >> return (show errs) + LoadSuccess m (rsrc :: String -> IO String) -> do + v' <- rsrc s + unload m + mapM_ removeFile [ obj, replaceSuffix obj ".hi" ] + return v' + +foreign export ccall evalhaskell_CString :: CString -> CString -> IO CString + +evalhaskell_CString :: CString -> CString -> IO CString +evalhaskell_CString filePathCS sCS = do + s <- peekCString sCS + filePath <- peekCString filePathCS + retval <- evalWithStringResult filePath s + newCString retval + +-- vi:sw=2 sts=2 + hunk ./examples/objc/expression_parser/PluginExpressionParser.xcode/project.pbxproj 1 +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + 089C165FFE840EACC02AAC07 = { + children = ( + 089C1660FE840EACC02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 089C1660FE840EACC02AAC07 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; +//080 +//081 +//082 +//083 +//084 +//100 +//101 +//102 +//103 +//104 + 1058C7A6FEA54F5311CA2CBB = { + children = ( + 1058C7A7FEA54F5311CA2CBB, + ); + isa = PBXGroup; + name = "Linked Frameworks"; + refType = 4; + sourceTree = ""; + }; + 1058C7A7FEA54F5311CA2CBB = { + fallbackIsa = PBXFileReference; + isa = PBXFrameworkReference; + lastKnownFileType = wrapper.framework; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + sourceTree = ""; + }; + 1058C7A8FEA54F5311CA2CBB = { + children = ( + 2A37F4C5FDCFA73011CA2CEA, + 2A37F4C4FDCFA73011CA2CEA, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + sourceTree = ""; + }; +//100 +//101 +//102 +//103 +//104 +//190 +//191 +//192 +//193 +//194 + 19C28FB0FE9D524F11CA2CBB = { + children = ( + 8D15AC370486D014006FF6A4, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; +//190 +//191 +//192 +//193 +//194 +//2A0 +//2A1 +//2A2 +//2A3 +//2A4 + 2A37F4A9FDCFA73011CA2CEA = { + buildSettings = { + }; + buildStyles = ( + 4A9504D0FFE6A4CB11CA0CBA, + 4A9504D1FFE6A4CB11CA0CBA, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 2A37F4AAFDCFA73011CA2CEA; + projectDirPath = ""; + targets = ( + 8D15AC270486D014006FF6A4, + 7B5F81A4067389B000AC9FA4, + ); + }; + 2A37F4AAFDCFA73011CA2CEA = { + children = ( + 7B5F81A1067383A700AC9FA4, + 7B5F81980673839D00AC9FA4, + 2A37F4ABFDCFA73011CA2CEA, + 2A37F4AFFDCFA73011CA2CEA, + 2A37F4B8FDCFA73011CA2CEA, + 2A37F4C3FDCFA73011CA2CEA, + 19C28FB0FE9D524F11CA2CBB, + ); + isa = PBXGroup; + name = PluginExpressionParser; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4ABFDCFA73011CA2CEA = { + children = ( + 2A37F4AEFDCFA73011CA2CEA, + 2A37F4ACFDCFA73011CA2CEA, + ); + isa = PBXGroup; + name = Classes; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4ACFDCFA73011CA2CEA = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = MyDocument.m; + refType = 4; + sourceTree = ""; + }; + 2A37F4AEFDCFA73011CA2CEA = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = MyDocument.h; + refType = 4; + sourceTree = ""; + }; + 2A37F4AFFDCFA73011CA2CEA = { + children = ( + 7B5F81990673839D00AC9FA4, + 32DBCF750370BD2300C91783, + 7B5F819506737AAC00AC9FA4, + 2A37F4B0FDCFA73011CA2CEA, + ); + isa = PBXGroup; + name = "Other Sources"; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4B0FDCFA73011CA2CEA = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = main.m; + refType = 4; + sourceTree = ""; + }; + 2A37F4B4FDCFA73011CA2CEA = { + children = ( + 2A37F4B5FDCFA73011CA2CEA, + ); + isa = PBXVariantGroup; + name = MyDocument.nib; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4B5FDCFA73011CA2CEA = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = English; + path = English.lproj/MyDocument.nib; + refType = 4; + sourceTree = ""; + }; + 2A37F4B6FDCFA73011CA2CEA = { + children = ( + 2A37F4B7FDCFA73011CA2CEA, + ); + isa = PBXVariantGroup; + name = MainMenu.nib; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4B7FDCFA73011CA2CEA = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = English; + path = English.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + 2A37F4B8FDCFA73011CA2CEA = { + children = ( + 2A37F4B9FDCFA73011CA2CEA, + 2A37F4B6FDCFA73011CA2CEA, + 2A37F4B4FDCFA73011CA2CEA, + 8D15AC360486D014006FF6A4, + 089C165FFE840EACC02AAC07, + ); + isa = PBXGroup; + name = Resources; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4B9FDCFA73011CA2CEA = { + children = ( + 2A37F4BAFDCFA73011CA2CEA, + ); + isa = PBXVariantGroup; + name = Credits.rtf; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4BAFDCFA73011CA2CEA = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = English; + path = English.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + 2A37F4C3FDCFA73011CA2CEA = { + children = ( + 1058C7A6FEA54F5311CA2CBB, + 1058C7A8FEA54F5311CA2CBB, + ); + isa = PBXGroup; + name = Frameworks; + path = ""; + refType = 4; + sourceTree = ""; + }; + 2A37F4C4FDCFA73011CA2CEA = { + fallbackIsa = PBXFileReference; + isa = PBXFrameworkReference; + lastKnownFileType = wrapper.framework; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + sourceTree = ""; + }; + 2A37F4C5FDCFA73011CA2CEA = { + fallbackIsa = PBXFileReference; + isa = PBXFrameworkReference; + lastKnownFileType = wrapper.framework; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + sourceTree = ""; + }; +//2A0 +//2A1 +//2A2 +//2A3 +//2A4 +//320 +//321 +//322 +//323 +//324 + 32DBCF750370BD2300C91783 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = PluginExpressionParser_Prefix.pch; + refType = 4; + sourceTree = ""; + }; +//320 +//321 +//322 +//323 +//324 +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 + 4A9504D0FFE6A4CB11CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + DEBUGGING_SYMBOLS = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + OPTIMIZATION_CFLAGS = "-O0"; + ZERO_LINK = YES; + }; + isa = PBXBuildStyle; + name = Development; + }; + 4A9504D1FFE6A4CB11CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + ZERO_LINK = NO; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 +//7B0 +//7B1 +//7B2 +//7B3 +//7B4 + 7B5F819506737AAC00AC9FA4 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = RunHaskell.h; + refType = 4; + sourceTree = ""; + }; + 7B5F819606737AAC00AC9FA4 = { + fileRef = 7B5F819506737AAC00AC9FA4; + isa = PBXBuildFile; + settings = { + }; + }; + 7B5F81970673839D00AC9FA4 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.haskell; + path = KeyValueParser.hs; + refType = 4; + sourceTree = ""; + }; + 7B5F81980673839D00AC9FA4 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.make; + path = Makefile; + refType = 4; + sourceTree = ""; + }; + 7B5F81990673839D00AC9FA4 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.haskell; + path = PluginEvalAux.hs; + refType = 4; + sourceTree = ""; + }; + 7B5F819A0673839D00AC9FA4 = { + fileRef = 7B5F81970673839D00AC9FA4; + isa = PBXBuildFile; + settings = { + }; + }; + 7B5F819B0673839D00AC9FA4 = { + fileRef = 7B5F81980673839D00AC9FA4; + isa = PBXBuildFile; + settings = { + }; + }; + 7B5F819C0673839D00AC9FA4 = { + fileRef = 7B5F81990673839D00AC9FA4; + isa = PBXBuildFile; + settings = { + }; + }; + 7B5F819D067383A400AC9FA4 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.haskell; + path = ArithmeticExpressionParser.hs; + refType = 4; + sourceTree = ""; + }; + 7B5F819E067383A400AC9FA4 = { + fileRef = 7B5F819D067383A400AC9FA4; + isa = PBXBuildFile; + settings = { + }; + }; + 7B5F81A1067383A700AC9FA4 = { + children = ( + 7B5F819D067383A400AC9FA4, + 7B5F81970673839D00AC9FA4, + ); + isa = PBXGroup; + name = Parsers; + refType = 4; + sourceTree = ""; + }; + 7B5F81A4067389B000AC9FA4 = { + buildArgumentsString = "$(ACTION)"; + buildPhases = ( + ); + buildSettings = { + OPTIMIZATION_CFLAGS = ""; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = "PluginExpressionParser (GNU make)"; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + buildToolPath = /usr/bin/make; + dependencies = ( + ); + isa = PBXLegacyTarget; + name = "PluginExpressionParser (GNU make)"; + passBuildSettingsInEnvironment = 1; + productName = "PluginExpressionParser (GNU make)"; + }; +//7B0 +//7B1 +//7B2 +//7B3 +//7B4 +//8D0 +//8D1 +//8D2 +//8D3 +//8D4 + 8D15AC270486D014006FF6A4 = { + buildPhases = ( + 8D15AC280486D014006FF6A4, + 8D15AC2B0486D014006FF6A4, + 8D15AC300486D014006FF6A4, + 8D15AC330486D014006FF6A4, + ); + buildRules = ( + ); + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ""; + GCC_ENABLE_TRIGRAPHS = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = PluginExpressionParser_Prefix.pch; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = NO; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = PluginExpressionParser; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = app; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = PluginExpressionParser; + productInstallPath = "$(HOME)/Applications"; + productName = PluginExpressionParser; + productReference = 8D15AC370486D014006FF6A4; + productType = "com.apple.product-type.application"; + }; + 8D15AC280486D014006FF6A4 = { + buildActionMask = 2147483647; + files = ( + 8D15AC290486D014006FF6A4, + 8D15AC2A0486D014006FF6A4, + 7B5F819606737AAC00AC9FA4, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D15AC290486D014006FF6A4 = { + fileRef = 32DBCF750370BD2300C91783; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC2A0486D014006FF6A4 = { + fileRef = 2A37F4AEFDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC2B0486D014006FF6A4 = { + buildActionMask = 2147483647; + files = ( + 8D15AC2C0486D014006FF6A4, + 8D15AC2D0486D014006FF6A4, + 8D15AC2E0486D014006FF6A4, + 8D15AC2F0486D014006FF6A4, + 7B5F819A0673839D00AC9FA4, + 7B5F819B0673839D00AC9FA4, + 7B5F819C0673839D00AC9FA4, + 7B5F819E067383A400AC9FA4, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D15AC2C0486D014006FF6A4 = { + fileRef = 2A37F4B9FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC2D0486D014006FF6A4 = { + fileRef = 2A37F4B6FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC2E0486D014006FF6A4 = { + fileRef = 2A37F4B4FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC2F0486D014006FF6A4 = { + fileRef = 089C165FFE840EACC02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC300486D014006FF6A4 = { + buildActionMask = 2147483647; + files = ( + 8D15AC310486D014006FF6A4, + 8D15AC320486D014006FF6A4, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D15AC310486D014006FF6A4 = { + fileRef = 2A37F4ACFDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 8D15AC320486D014006FF6A4 = { + fileRef = 2A37F4B0FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 8D15AC330486D014006FF6A4 = { + buildActionMask = 2147483647; + files = ( + 8D15AC340486D014006FF6A4, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D15AC340486D014006FF6A4 = { + fileRef = 1058C7A7FEA54F5311CA2CBB; + isa = PBXBuildFile; + settings = { + }; + }; + 8D15AC360486D014006FF6A4 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = text.plist; + path = Info.plist; + refType = 4; + sourceTree = ""; + }; + 8D15AC370486D014006FF6A4 = { + explicitFileType = wrapper.application; + includeInIndex = 0; + isa = PBXFileReference; + path = PluginExpressionParser.app; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + }; + rootObject = 2A37F4A9FDCFA73011CA2CEA; +} hunk ./examples/objc/expression_parser/PluginExpressionParser_Prefix.pch 1 +// +// Prefix header for all source files of the 'PluginExpressionParser' target in the 'PluginExpressionParser' project +// + +#ifdef __OBJC__ + #import +#endif hunk ./examples/objc/expression_parser/README 1 +This little application is an example of using hs-plugins to embed a Haskell +'interpreter' inside an Objective-C, Cocoa-based program. You will need Mac OS +X for this to be of any use! + +To build it, type 'make', which will build a .app bundle in the build/ directory. Or, 'open *.xcode', and hit the build button in there. + hunk ./examples/objc/expression_parser/RunHaskell.h 1 +#include "HsFFI.h" + +extern HsPtr evalhaskell_CString(HsPtr a1, HsPtr a2); + hunk ./examples/objc/expression_parser/main.m 1 +// +// main.m +// PluginExpressionParser +// +// Created by AndrŽ Pang on Mon Jun 07 2004. +// Copyright (c) 2004 __MyCompanyName__. All rights reserved. +// + +#import + +#include "HsFFI.h" + +extern void __stginit_PluginEvalAux (void); + +int main(int argc, char *argv[]) +{ + hs_init(&argc, &argv); + hs_add_root(__stginit_PluginEvalAux); + const char *c_argv = (const char *) argv; + int retval = NSApplicationMain(argc, &c_argv); + hs_exit(); + return retval; +} + +/* vi:sw=4 */ + hunk ./examples/objc/expression_parser/version.plist 1 + + + + + BuildVersion + 17 + CFBundleShortVersionString + 0.1 + CFBundleVersion + 0.1 + ProjectName + NibPBTemplates + SourceVersion + 1150000 + + hunk ./examples/pdynload/badint/Makefile 1 + +TEST=pdynload/badint + +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/badint/Plugin.hs 1 +module Plugin where + +resource :: Num t => t +resource = 0xBAD hunk ./examples/pdynload/badint/api/API.hs 1 +module API where + +data Interface = Interface { + transform :: String -> String + } + +rsrc :: Interface +rsrc = Interface { transform = id } + hunk ./examples/pdynload/badint/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e-> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn $ (transform a) "foo" + _ -> putStrLn "wrong types" + hunk ./examples/pdynload/badint/prog/expected 1 +wrong types hunk ./examples/pdynload/null/Makefile 1 + +TEST= pdynload/null +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/null/Plugin.hs 1 +module Plugin where + +import API + +resource = D 1 hunk ./examples/pdynload/null/api/API.hs 1 + +module API where + +data Num t => Interface t = D t + hunk ./examples/pdynload/null/prog/Main.hs 1 + +import Plugins +import Plugins.Utils +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e-> mapM_ putStrLn e + + where f = do v <- load "../Plugin.o" ["../api"] [] "resource" + -- (i,_) <- exec "ghc" ["--numeric-version"] + -- mapM_ putStrLn i + putStrLn "done." + hunk ./examples/pdynload/null/prog/expected 1 +done. hunk ./examples/pdynload/numclass/Makefile 1 + +TEST= pdynload/numclass +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/numclass/Plugin.hs 1 +module Plugin where + +-- import API + +resource = "error" hunk ./examples/pdynload/numclass/api/API.hs 1 + +module API where + +data Num t => Interface t = D t + hunk ./examples/pdynload/numclass/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeFailure _ -> putStrLn "make failed" + MakeSuccess _ _ -> do { + + ;v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface Integer" "resource" + ;case v of + LoadSuccess _ a -> let D i = snd a in putStrLn $ show i + _ -> putStrLn "wrong types" + + } hunk ./examples/pdynload/numclass/prog/expected 1 +wrong types hunk ./examples/pdynload/poly/Makefile 1 + +TEST=pdynload/poly + +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/poly/Plugin.hs 1 +module Plugin where + +import Data.Generics.Schemes + +import API + +resource = rsrc { + field = id listify +} hunk ./examples/pdynload/poly/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- a really nasty type: + +module API where + +import Data.Generics + +data Interface = Interface { field :: Typeable r => (r -> Bool) -> GenericQ [r] } + +rsrc :: Interface +rsrc = Interface { field = listify } + hunk ./examples/pdynload/poly/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "loaded .. yay!" + _ -> putStrLn "wrong types" hunk ./examples/pdynload/poly/prog/expected 1 +loaded .. yay! hunk ./examples/pdynload/poly1/Makefile 1 +TEST= pdynload/poly1 +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/poly1/Plugin.hs 1 +module Plugin where + +import API + +resource = plugin { function = (+) } hunk ./examples/pdynload/poly1/api/API.hs 1 +module API where + +data Interface = Interface { + function :: (Num a) => a -> a -> a +} + +plugin :: Interface +plugin = Interface { function = error "no function defined" } + hunk ./examples/pdynload/poly1/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> let fn = function a in putStrLn $ show $ 1 `fn` 2 + _ -> putStrLn "wrong types" + hunk ./examples/pdynload/poly1/prog/expected 1 +3 hunk ./examples/pdynload/should_fail0/Makefile 1 +TEST= pdynload/should_fail0 +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/should_fail0/Plugin.hs 1 +module Plugin where + +import API + +resource = 0xBAD :: Int + +-- resource = tiny { +-- field = "hello strange world" +-- } hunk ./examples/pdynload/should_fail0/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- ^ needed to derive Typeable + +module API where + +import Data.Dynamic + +data Interface = Interface { field :: String } + deriving (Show) + +rsrc :: Interface +rsrc = Interface { field = "default value" } + hunk ./examples/pdynload/should_fail0/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + where + f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "loaded .. yay!" + _ -> putStrLn "wrong types" + hunk ./examples/pdynload/should_fail0/prog/expected 1 +wrong types hunk ./examples/pdynload/should_fail1/Makefile 1 +# Missing class constraint... can't do that in Clean + +TEST= pdynload/should_fail1 +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/should_fail1/Plugin.hs 1 +module Plugin where + +data I = I Int + +resource = I 1 hunk ./examples/pdynload/should_fail1/api/API.hs 1 + +module API where + +newtype Interface = I Int + +rsrc :: Interface +rsrc = I 1 + hunk ./examples/pdynload/should_fail1/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "loaded .. yay!" + _ -> putStrLn "wrong types" hunk ./examples/pdynload/should_fail1/prog/expected 1 +wrong types hunk ./examples/pdynload/small/Makefile 1 +TEST= pdynload/small +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/small/Plugin.hs 1 +module Plugin where + +import API + +resource = plugin { function = "good" } hunk ./examples/pdynload/small/api/API.hs 1 +module API where + +data Interface = Interface { + function :: String +} + +plugin :: Interface +plugin = Interface { function = "goodbye" } + hunk ./examples/pdynload/small/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "loaded .. yay!" + _ -> putStrLn "wrong types" + hunk ./examples/pdynload/small/prog/expected 1 +loaded .. yay! hunk ./examples/pdynload/spj1/Makefile 1 + +TEST=pdynload/spj1 + +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/spj1/Plugin.hs 1 +module Plugin where + +-- user doesn't import the API +-- and provides a polymorphic value + +-- import API +-- resource :: Interface + +-- +-- should pass type check, and dump core +-- +-- resource :: Num a => a + +-- import API + +resource :: Num a => a +resource = 7 hunk ./examples/pdynload/spj1/api/API.hs 1 + +module API where + +-- data Interface = Interface { field :: Int } + +-- newtype Interface = Interface Int + +type Interface = Int + hunk ./examples/pdynload/spj1/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ (a :: Interface) -> print $ a -- will crash + LoadFailure es -> putStrLn $ show es hunk ./examples/pdynload/spj2/Makefile 1 + +TEST=pdynload/spj1 + +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/spj2/Plugin.hs 1 +module Plugin where + +-- user doesn't import the API +-- and provides a polymorphic value + +import API +resource :: Interface + +-- +-- should pass type check, and dump core +-- +-- resource :: Num a => a +resource = 7 hunk ./examples/pdynload/spj2/api/API.hs 1 + +module API where + +-- simple type +type Interface = Int + hunk ./examples/pdynload/spj2/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ (a :: Interface) -> putStrLn $ show a -- will crash + LoadFailure es -> putStrLn $ show es hunk ./examples/pdynload/spj2/prog/expected 1 +7 hunk ./examples/pdynload/spj3/Makefile 1 +TEST= pdynload/spj3 +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/spj3/Plugin.hs 1 +module Plugin where + +import API + +resource = plugin { function = (+) :: Int -> Int -> Int } hunk ./examples/pdynload/spj3/api/API.hs 1 +module API where + +data Interface = Interface { + function :: (Num a) => a -> a -> a +} + +plugin :: Interface +plugin = Interface { function = error "no function defined" } + hunk ./examples/pdynload/spj3/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> let fn = function a in putStrLn $ show $ 1 `fn` 2 + _ -> putStrLn "wrong types" + hunk ./examples/pdynload/spj3/prog/expected 1 + +../Plugin.hs:5: + Cannot unify the type-signature variable `a' with the type `Int' + Expected type: a -> a -> a + Inferred type: Int -> Int -> Int + When checking the type signature of the expression: + (+) :: Int -> Int -> Int + In the `function' field of a record hunk ./examples/pdynload/spj3/prog/expected.604 1 + +../Plugin.hs:5:31: + Couldn't match the rigid variable `a' against `Int' + `a' is bound by the polymorphic type `forall a. (Num a) => a -> a -> a' + at ../Plugin.hs:5:11-56 + Expected type: a -> a -> a + Inferred type: Int -> Int -> Int + In the expression: (+) :: Int -> Int -> Int + In the `function' field of a record hunk ./examples/pdynload/spj4/Makefile 1 + +TEST=pdynload/spj4 + +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/spj4/Plugin.hs 1 +module Plugin where + +-- user doesn't import the API +-- and provides a polymorphic value + +-- import API +-- resource :: Interface + +-- +-- should pass type check, and dump core +-- +-- resource :: Num a => a + +import API + +resource = Interface { field = 7 :: Num a => a } hunk ./examples/pdynload/spj4/api/API.hs 1 + +module API where + +newtype Interface = Interface { field :: Int } + hunk ./examples/pdynload/spj4/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> error "there was a type error" + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ (a :: Interface) -> print $ field a -- will crash + LoadFailure es -> mapM_ putStrLn es hunk ./examples/pdynload/spj4/prog/expected 1 +7 hunk ./examples/pdynload/typealias/Makefile 1 +# Missing class constraint... can't do that in Clean + +TEST= pdynload/typealias +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/typealias/Plugin.hs 1 +module Plugin where + +resource = 1 :: Int hunk ./examples/pdynload/typealias/api/API.hs 1 + +module API where + +type Interface = Int + +rsrc :: Interface +rsrc = 1 + hunk ./examples/pdynload/typealias/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "loaded .. yay!" + _ -> putStrLn "wrong types" + + hunk ./examples/pdynload/typealias/prog/expected 1 +loaded .. yay! hunk ./examples/pdynload/univquant/Makefile 1 +TEST= pdynload/univquant +EXTRA_OBJS=Plugin.o +TOP=../../.. +include ../../build.mk hunk ./examples/pdynload/univquant/Plugin.hs 1 +module Plugin where + +import API + +resource = plugin { function = my_id } + +my_id :: forall a. a -> a +my_id x = x hunk ./examples/pdynload/univquant/api/API.hs 1 +module API where + +data Interface = Interface { + function :: forall a. a -> a +} + +plugin :: Interface +plugin = Interface { function = id } + hunk ./examples/pdynload/univquant/prog/Main.hs 1 + +import Plugins +import API + +src = "../Plugin.hs" +wrap = "../Wrapper.hs" +apipath = "../api" + +main = do status <- make src ["-i"++apipath] + case status of + MakeSuccess _ _ -> f + MakeFailure e -> mapM_ putStrLn e + + where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource" + case v of + LoadSuccess _ a -> putStrLn "loaded .. yay!" + _ -> putStrLn "wrong types" hunk ./examples/pdynload/univquant/prog/expected 1 +loaded .. yay! hunk ./examples/pkgconf/null/Makefile 1 +all: + @echo "test disabled" + +#true_api:: +# ( cd api ;\ +# $(GHC) -Onot $(EXTRAFLAGS) -c $(API).hs ;\ +# $(RM) -f libHSapi.a ;\ +# $(AR) cq libHSapi.a API.o ;\ +# $(RANLIB) libHSapi.a ;\ +# $(LD) -r $(LD_X) $(WHOLE_ARCHIVE_FLAG) -o HSapi.o libHSapi.a ;\ +# rm API.o ;\ +# echo [] > package.conf ;\ +# env PREFIX=`pwd` $(GHC_PKG) -f package.conf -u < package.conf.in ) +# $(GHC) -package-conf ${TOP}/plugins.conf.inplace -package plugins \ +# -package-conf api/package.conf -package api \ +# -O $(EXTRAFLAGS) -c Null.hs hunk ./examples/pkgconf/null/Null.hs 1 +module Null ( resource ) where + +import API + +resource = plugin { a = 7 } + hunk ./examples/pkgconf/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +data Null = Null { a, b :: Int } + deriving Show + +plugin :: Null +plugin = Null { a = 42 , b = 1 } + hunk ./examples/pkgconf/null/api/package.conf.in 1 +Package { + name = "api", + auto = False, + + import_dirs = [ "${PREFIX}" ], + library_dirs = [ "${PREFIX}" ], + hs_libraries = [ "HSapi" ], + + include_dirs = [], + c_includes = [], + source_dirs = [], + extra_libraries = [], + package_deps = [], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [] +} + hunk ./examples/pkgconf/null/prog/Main.hs 1 +{-# OPTIONS -cpp #-} + +#include "../../../../config.h" + +import Plugins +import API + +main = do + let includes = TOP ++ "/examples/load/null/api" + (_,v) <- load "../Null.o" ["."] ["../api/package.conf"] "resource" + putStrLn ( show (a v) ) + hunk ./examples/popen/test1/Main.hs 1 +-- +-- test the popen function +-- + +import Plugins.Utils +import System.IO + +main = do + (sout,serr) <- exec "date" [] + mapM_ putStrLn serr hunk ./examples/popen/test1/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/printf/000/Main.hs 1 +import Printf + +main = do printf "%d\n" $> (42::Int) ! [] + printf "%u\n" $> (42::Int) ! [] + printf "0%o\n" $> (42::Int) ! [] + printf "0x%x\n" $> (42::Int) ! [] + printf "0x%X\n" $> (42::Int) ! [] + + printf "%e\n" $> (42.1234 :: Double) ! [] + printf "%E\n" $> (42.1234 :: Double) ! [] + printf "%g\n" $> (42.1234 :: Double) ! [] + printf "%G\n" $> (42.1234 :: Double) ! [] + printf "%f\n" $> (42.1234 :: Double) ! [] + + printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! [] + printf "%s\n" $> "printf" ! [] + + printf "%+d\n" $> (42::Int) ! [] + printf "%+0d\n" $> (42::Int) ! [] + printf "%0+d\n" $> (42::Int) ! [] + printf "%10d\n" $> (42::Int) ! [] + printf "%-010d\n" $> (42::Int) ! [] + printf "%-010.2d\n" $> (42::Int) ! [] + + printf "%+f\n" $> (42.1234 :: Double) ! [] + printf "%+0f\n" $> (42.1234 :: Double) ! [] + printf "%0+f\n" $> (42.1234 :: Double) ! [] + printf "%10f\n" $> (42.1234 :: Double) ! [] + printf "%-010f\n" $> (42.1234 :: Double) ! [] + printf "%-010.2f\n" $> (42.1234 :: Double) ! [] + + printf "%10s\n" $> "printf" ! [] + printf "%-10s\n" $> "printf" ! [] + printf "%10.2s\n" $> "printf" ! [] + printf "%2.10s\n" $> "printf" ! [] + printf "%-2.10s\n" $> "printf" ! [] + printf "%-10.2s\n" $> "printf" ! [] hunk ./examples/printf/000/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/printf/000/expected 1 +42 +42 +052 +0x2a +0x2A +4.212340e1 +4.212340E1 +42.123400 +42.123400 +42.123400 +a:b:c +printf ++42 ++42 ++42 + 42 +42 +42 ++42.123400 ++42.123400 ++42.123400 + 42.123400 +42.123400 +42.12 + printf +printf + pr +printf +printf +pr hunk ./examples/printf/000/printf.sh 1 +#!/bin/sh +printf "%d\n" 42 +printf "%u\n" 42 +printf "0%o\n" 42 +printf "0x%x\n" 42 +printf "0x%X\n" 42 + +printf "%e\n" 42.1234 +printf "%E\n" 42.1234 +printf "%g\n" 42.1234 +printf "%G\n" 42.1234 +printf "%f\n" 42.1234 + +printf "%c:%c:%c\n" 'a' 'b' 'c' +printf "%s\n" "printf" + +printf "%+d\n" 42 +printf "%+0d\n" 42 +printf "%0+d\n" 42 +printf "%10d\n" 42 +printf "%-010d\n" 42 +printf "%-010.2d\n" 42 + +printf "%+f\n" 42.1234 +printf "%+0f\n" 42.1234 +printf "%0+f\n" 42.1234 +printf "%10f\n" 42.1234 +printf "%-010f\n" 42.1234 +printf "%-010.2f\n" 42.1234 + +printf "%10s\n" "printf" +printf "%-10s\n" "printf" +printf "%10.2s\n" "printf" +printf "%2.10s\n" "printf" +printf "%-2.10s\n" "printf" +printf "%-10.2s\n" "printf" hunk ./examples/printf/001/Main.hs 1 +import Printf + +main = do + printf "%d\n" $> (42 :: Int) ! [] + printf "0x%X\n" $> (42 :: Int) ! [] + printf "%f\n" $> (42.1234 :: Double) ! [] + printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! [] + printf "%s\n" $> "haskell" ! [] + printf "%-010.4d\n" $> (42 :: Int) ! [] + printf "%010.4f\n" $> (42.1234 :: Double) ! [] + printf "%10.4s\n" $> (show (7 :: Int)) ! [] + printf "%-10.4s\n" $> "haskell" ! [] + hunk ./examples/printf/001/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/printf/001/expected 1 +42 +0x2A +42.123400 +a:b:c +haskell +42 +00042.1234 + 7 +hask hunk ./examples/printf/002/Main.hs 1 +import Printf +import Control.Exception ( evaluate ) + +main = do + fn <- evaluate $! printf "%10.4f\n" + fn $> (10.0 :: Double) ! [] + fn $> (-10.0 :: Double) ! [] + fn $> (10.1010 :: Double) ! [] + fn $> (0.0 :: Double) ! [] + fn $> (0.987654321 :: Double) ! [] + fn $> (987654321 :: Double) ! [] + fn $> (-987654321 :: Double) ! [] hunk ./examples/printf/002/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/printf/002/expected 1 + 10.0000 + -10.0000 + 10.1010 + 0.0000 + 0.9877 +987654321.0000 +-987654321.0000 hunk ./examples/printf/should_fail_000/Main.hs 1 +import Printf + +main = printf "%x\n" $> "badstring" ! [] hunk ./examples/printf/should_fail_000/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/printf/should_fail_000/expected 1 + +Fail: Type error in dynamic application. +Can't apply function [Char]> to argument <[Char]> hunk ./examples/printf/should_fail_000/expected.604 1 +a.out: Type error in dynamic application. +Can't apply function [Char]> to argument <[Char]> hunk ./examples/printf/should_fail_001/Main.hs 1 +import Printf + +main = do + printf "%d\n" $> (42 :: Int) ! [] + printf "0x%X\n" $> (42 :: Int) ! [] + printf "%f\n" $> (42.1234 :: Double) ! [] + printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! [] + printf "%s\n" $> "haskell" ! [] + printf "%-010.4d\n" $> (42 :: Int) ! [] + printf "%010.4f\n" $> (42.1234 :: Double) ! [] + printf "%10.4s\n" $> (7 :: Int)! [] + printf "%-10.4s\n" $> "haskell" ! [] + hunk ./examples/printf/should_fail_001/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/printf/should_fail_001/expected 1 +42 +0x2A +42.123400 +a:b:c +haskell +42 +00042.1234 + +Fail: Type error in dynamic application. +Can't apply function <[Char] -> [Char]> to argument hunk ./examples/printf/should_fail_001/expected.604 1 +42 +0x2A +42.123400 +a:b:c +haskell +42 +00042.1234 +a.out: Type error in dynamic application. +Can't apply function <[Char] -> [Char]> to argument hunk ./examples/reload/null/Makefile 1 +TEST= reload/null +EXTRA_OBJS=Null.o +TOP=../../.. +include ../../build.mk hunk ./examples/reload/null/Null.hs 1 +module Null ( resource, resource_dyn ) where + +import API +import Data.Dynamic +import Prelude hiding (null) + +resource = null + +-- ! this has to be special: it can't be overridden by the user. +resource_dyn :: Dynamic +resource_dyn = toDyn resource hunk ./examples/reload/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Null = Null { a, b :: Int } + deriving (Typeable, Show) + +null :: Null +null = Null { a = 42 , b = 1 } + hunk ./examples/reload/null/prog/Main.hs 1 + +import Plugins +import API + +-- an example where we just want to load an object and run it + +main = do + m_v <- load "../Null.o" ["../api"] [] "resource" + (m,v) <- case m_v of + LoadSuccess m v -> return (m,v) + _ -> error "load failed" + putStrLn ( show (a v) ) + + m_v <- reload m "resource" -- get a new version + v' <- case m_v of + LoadSuccess _ v -> return v + _ -> error "load failed" + putStrLn ( show (a v') ) + hunk ./examples/reload/null/prog/expected 1 +42 +42 hunk ./examples/shell/shell/API.hs 1 +module API where + +-- the interface between the app and the plugin +data Interface = Interface { function :: String -> String } + +-- default values for the interface +plugin :: Interface +plugin = Interface { function = id } hunk ./examples/shell/shell/Main.hs 1 +-- +-- a simple shell for loading plugins and evaluating their functions +-- + +import Plugins +import API + +import Data.Either +import Data.Char +import Control.Monad ( when ) +import System.Console.Readline ( readline ) +import System.Exit ( ExitCode(..), exitWith ) + + +source = "Plugin.hs" +stub = "Plugin.stub" + +sym = "resource" + +main = do + status <- makeWith source stub [] + p <- case status of + MakeFailure e -> mapM_ putStrLn e >> error "failed to compile" + MakeSuccess _ obj -> do + m_v <- load obj ["."] [] sym + case m_v of + LoadSuccess m v -> return (m,v) + LoadFailure e -> do mapM_ putStrLn e + error "failed to load" + shell p + + where + shell p@(m,v) = do + + s <- readline "> " + cmd <- case s of + Nothing -> exitWith ExitSuccess + Just ":q" -> exitWith ExitSuccess + Just s -> return (chomp s) + + status <- makeWith source stub [] + case status of + MakeFailure e -> do + mapM_ putStrLn e + shell p -- print error and back to prompt + + MakeSuccess NotReq o -> do + p' <- eval cmd p + shell p' -- eval str again + + MakeSuccess ReComp o -> do + m_v' <- reload m sym + case m_v' of + LoadFailure e -> mapM_ putStrLn e >> error "failed to load" + LoadSuccess _ v' -> do + let p' = (m,v') + p'' <- eval cmd p' + shell p'' + +-- +-- shell commands +-- +eval "" p = return p + +eval ":clear" p = do + let loop i = when (i < 40) (do putStr "\n" ; loop $! i+1) + loop 0 + return p + +eval ":?" p = do + putStrLn$"\":?\"\n" ++ + "\":quit\"\n" ++ + "\":clear\"\n" ++ + "\"foo\"" + return p + +eval s (m,v) = putStrLn ((function v) s) >> return (m,v) + +-- +-- strip trailing whitespace +-- +chomp :: String -> String +chomp [] = [] +chomp s | isSpace (last s) = chomp $! init s + | otherwise = s hunk ./examples/shell/shell/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/shell/shell/Plugin.hs 1 + +resource = plugin { + function = map toUpper +} + hunk ./examples/shell/shell/Plugin.stub 1 +-- +-- this is a "stub" file, containing default syntax we don't +-- want the user to have to write +-- +-- for example, it constrains the module name and force the API to be +-- imported + +module Plugin ( resource ) where + +import API +import Data.Char +import Data.List + +-- this is a default definition of 'resource'. it will be overridden +-- by anything the user writes. useful for default values + +resource :: Interface +resource = plugin + hunk ./examples/shell/shell/README 1 +$ make +$ ./a.out +Compiling plugin ... done +Loading package base ... linking ... done +Loading objects API Plugin ... done +> ? +"?" +"quit" +"clear" +"filter foo" +> filter adf adsf +fsda fda +> filter asd faSDFADSF +FSDAFDSaf dsa + +-- at this point I edit the plugin and save the source + +> filter asfdaSDFASD +Compiling plugin ... done +Reloading Plugin ... done +DSAFDSADFSA + +-- it compiled and reloaded it for me. nice. hunk ./examples/shell/simple/Main.hs 1 +import Plugins +import StringProcessorAPI +import System.Console.Readline +import System.Exit + +source = "Plugin.hs" +stub = "Plugin.stub" +symbol = "resource" + +main = do s <- makeWith source stub [] + o <- case s of + MakeSuccess _ obj -> do + ls <- load obj ["."] [] symbol + case ls of LoadSuccess m v -> return (m,v) + LoadFailure err -> error "load failed" + MakeFailure e -> mapM_ putStrLn e >> error "compile failed" + shell o + +shell o@(m,plugin) = do + s <- readline "> " + cmd <- case s of + Nothing -> exitWith ExitSuccess + Just (':':'q':_) -> exitWith ExitSuccess + Just s -> addHistory s >> return s + + s <- makeWith source stub [] -- maybe recompile the source + o' <- case s of + MakeSuccess ReComp o -> do + ls <- reload m symbol + case ls of LoadSuccess m' v' -> return (m',v') + LoadFailure err -> error "reload failed" + MakeSuccess NotReq _ -> return o + MakeFailure e -> mapM_ putStrLn e >> shell o + eval cmd o' + shell o' + +eval ":?" _ = putStrLn ":?\n:q\n" + +eval s (_,plugin) = let fn = (stringProcessor plugin) in putStrLn (fn s) + + hunk ./examples/shell/simple/Makefile 1 +OBJS=StringProcessorAPI.o +TOP=../../.. +include ../../eval.mk + +#all: +# @echo test disabled hunk ./examples/shell/simple/Plugin.hs 1 +import Char + +resource = plugin { + stringProcessor = map toUpper +} hunk ./examples/shell/simple/Plugin.stub 1 +-- +-- this is a "stub" file, containing default syntax we don't +-- want the user to have to write +-- +-- for example, it constrains the module name and force the API to be +-- imported + +module Plugin ( resource ) where + +import StringProcessorAPI +import Data.Char +import Data.List + +-- this is a default definition of 'resource'. it will be overridden +-- by anything the user writes. useful for default values + +resource :: Interface +resource = plugin + hunk ./examples/shell/simple/README 1 +$ make +$ ./a.out +Compiling plugin ... done +Loading package base ... linking ... done +Loading objects API Plugin ... done +> ? +"?" +"quit" +"clear" +"filter foo" +> filter adf adsf +fsda fda +> filter asd faSDFADSF +FSDAFDSaf dsa + +-- at this point I edit the plugin and save the source + +> filter asfdaSDFASD +Compiling plugin ... done +Reloading Plugin ... done +DSAFDSADFSA + +-- it compiled and reloaded it for me. nice. hunk ./examples/shell/simple/StringProcessorAPI.hs 1 +module StringProcessorAPI where + +data Interface = Interface { + stringProcessor :: String -> String +} + +plugin :: Interface +plugin = Interface { stringProcessor = id } hunk ./examples/typecase/000/Main.hs 1 +import AltData +import Data.Char + +main = putStrLn f + +f = let v = toDyn (7 :: Int) + in typecase (v) [ + _Bool --> \(b::Bool) -> show (not b)++" :: Bool", + _Char --> \(c::Char) -> show (toUpper c)++" :: Char", + _Int --> \(i::Int) -> show (-i)++" :: Int", + _String --> \(s::String) -> show (reverse s)++" :: [Char]", + _IntToInt --> \(f::Int->Int) -> show (f 7) ++":: Int -> Int" + ] ("couldn't find a typing") + hunk ./examples/typecase/000/Makefile 1 +TOP=../../.. +include ../../eval.mk hunk ./examples/typecase/000/expected 1 +-7 :: Int hunk ./examples/unload/null/Makefile 1 +TEST= unload/null +EXTRA_OBJS=Null.o +TOP=../../.. +include ../../build.mk hunk ./examples/unload/null/Null.hs 1 +module Null ( resource, resource_dyn ) where + +import API +import Data.Dynamic +import Prelude hiding (null) + +resource = null + +-- ! this has to be special: it can't be overridden by the user. +resource_dyn :: Dynamic +resource_dyn = toDyn resource hunk ./examples/unload/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Null = Null { a, b :: Int } + deriving (Typeable, Show) + +null :: Null +null = Null { a = 42 , b = 1 } + hunk ./examples/unload/null/prog/Main.hs 1 + +import Plugins +import API + +-- an example where we just want to load an object and run it + +main = do + m_v <- load "../Null.o" ["../api"] [] "resource" + case m_v of + LoadFailure _ -> error "load failed" + LoadSuccess m v -> do putStrLn ( show (a v) ) ; unload m hunk ./examples/unload/null/prog/expected 1 +42 hunk ./examples/unload/sjwtrap/Makefile 1 +TEST= unload/sjwtrap +EXTRA_OBJS=Null.o +TOP=../../.. +include ../../build.mk hunk ./examples/unload/sjwtrap/Null.hs 1 +module Null where + +import qualified Prelude +import API + +resource = null hunk ./examples/unload/sjwtrap/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +data Null = Null { a, b :: Int } + +null :: Null +null = Null { a = 42 , b = 1 } + hunk ./examples/unload/sjwtrap/prog/Main.hs 1 + +import Plugins +import API + +-- +-- what happens if we try to use code that has been unloaded? +-- + +main = do + m_v <- load "../Null.o" ["../api"] [] "resource" + (m,v) <- case m_v of + LoadSuccess m v -> return (m,v) + _ -> error "load failed" + putStrLn ( show (a v) ) + unload m hunk ./examples/unload/sjwtrap/prog/expected 1 +42 hunk ./install-sh 1 +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# 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="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + 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 [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -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 [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# 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. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 hunk ./scripts/openbsd-port/Makefile 1 +# $OpenBSD$ + +COMMENT= "dynamic link library for Haskell" + +V= 0.9.8 +DISTNAME= hs-plugins-${V} +CATEGORIES= devel +MAINTAINER= Don Stewart +HOMEPAGE= http://www.cse.unsw.edu.au/~dons/hs-plugins-0.9.8/ +MASTER_SITES= ${HOMEPAGE} + +MODULES= ghc +CONFIGURE_STYLE= gnu dest + +# LGPL +PERMIT_PACKAGE_CDROM= Yes +PERMIT_PACKAGE_FTP= Yes +PERMIT_DISTFILES_CDROM= Yes +PERMIT_DISTFILES_FTP= Yes + +.include hunk ./scripts/openbsd-port/distinfo 1 +MD5 (hs-plugins-0.9.4.tar.gz) = 120f38ca532b187ee52798f5c36cc920 +RMD160 (hs-plugins-0.9.4.tar.gz) = 219eaf70e4bc0f1abc8a782d1bbd64ad2c5f8e86 +SHA1 (hs-plugins-0.9.4.tar.gz) = ad38b9f4e5b90c1361c6c96bd94e2a9270ad3d78 hunk ./scripts/openbsd-port/pkg/DESCR 1 +hs-plugins is a library for dynamic loading and compilation of Haskell +code. It provides typesafe "plugins" for Haskell. The interface is +general enough that it can be used to create conventional plugins, +hmake-like Haskell interpreters embedded in applications, or to script +an application with Haskell (or a Haskell EDSL) as the extension +language. hunk ./scripts/openbsd-port/pkg/PLIST 1 +@comment $OpenBSD$ +lib/hs-plugins/imports/Plugins.hi +lib/hs-plugins/imports/Plugins/BinIface.hi +lib/hs-plugins/imports/Plugins/Binary.hi +lib/hs-plugins/imports/Plugins/Consts.hi +lib/hs-plugins/imports/Plugins/Env.hi +lib/hs-plugins/imports/Plugins/FastMutInt.hi +lib/hs-plugins/imports/Plugins/FastString.hi +lib/hs-plugins/imports/Plugins/Iface.hi +lib/hs-plugins/imports/Plugins/Load.hi +lib/hs-plugins/imports/Plugins/Make.hi +lib/hs-plugins/imports/Plugins/Package.hi +lib/hs-plugins/imports/Plugins/ParsePkgConfLite.hi +lib/hs-plugins/imports/Plugins/Parser.hi +lib/hs-plugins/imports/Plugins/PrimPacked.hi +lib/hs-plugins/imports/Plugins/Utils.hi +lib/hs-plugins/include/hschooks.h +lib/hs-plugins/libHSplugins.a +lib/hs-plugins/libHSplugins_cbits.a +lib/hs-plugins/plugins.conf.in +@dirrm lib/hs-plugins/include +@dirrm lib/hs-plugins/imports/Plugins +@dirrm lib/hs-plugins/imports +@dirrm lib/hs-plugins +@exec /bin/cat %D/lib/hs-plugins/plugins.conf.in | /usr/bin/env PREFIX=%D %D/bin/ghc-pkg -u +@exec /bin/rm -f %D/lib/ghc-6.2.1/package.conf.old +@unexec %D/bin/ghc-pkg -r plugins +@unexec /bin/rm -f %D/lib/ghc-6.2.1/package.conf.old hunk ./src/Makefile 1 + +# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +# GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html) + +.PHONY: all build altdata hi plugins eval printf +.PHONY: install i_altdata i_hi i_plugins i_eval i_printf + +build: altdata hi plugins eval printf + +altdata: + @cd altdata && $(MAKE) +hi: + @cd hi && $(MAKE) +plugins: + @cd plugins && $(MAKE) +eval: + @cd eval && $(MAKE) +printf: + @cd printf && $(MAKE) + +install: i_altdata i_hi i_plugins i_eval i_printf + @true + +i_altdata: + @cd altdata && $(MAKE) install +i_hi: + @cd hi && $(MAKE) install +i_plugins: + @cd plugins && $(MAKE) install +i_eval: + @cd eval && $(MAKE) install +i_printf: + @cd printf && $(MAKE) install + +all: build + +TOP=.. +include build.mk hunk ./src/README 1 +Don's Haskell Libraries +----------------------- + +* altdata +An alternative implementation of Typeable and Dynamic that +works in the presence of (completely) separate compilation + +* hi +A parser for .hi files + +* plugins +A dynamic loader for GHC-produce object files. Also provides type +checking of object interfaces via dynamic typing. + +* eval +A system for reflecting strings of Haskell source into native code at +runtime, via runtime compilation and dynamic linking. +Also implements a staged computation doo-hickey. + +* printf +An implementation of printf(3) that uses eval to generate new Haskell +functions from format strings, at runtime, and dynamic typing to +retain type safety. hunk ./src/altdata/AltData/Dynamic.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- reimplement the Data.Dynamic library to use equality over the +-- canonical name of a type, rather than on integer keys. The later is +-- how the Haskell library works, and is broken for our situation: +-- static versus dynamic instances of the same type seem to generate +-- different keys, meaning equal types are not detected as such. +-- + +module AltData.Dynamic ( + + Dynamic, -- must be abstract + toDyn, -- :: Typeable a => a -> Dynamic + fromDyn, -- :: Typeable a => Dynamic -> Maybe a + fromDynamic, + dynApp, + dynApply, + dynAppHList, + + typecase, + (-->), + + _Int, + _Char, + _Bool, + _String, + _IntToInt, + + ) where + +import AltData.Typeable +import Data.Maybe +import System.IO.Unsafe ( unsafePerformIO ) +import GHC.Base ( unsafeCoerce# ) +import Data.List + +data Dynamic = Dynamic TypeRep Obj + +type Obj = forall a . a + +instance Show Dynamic where + -- the instance just prints the type representation. + showsPrec _ (Dynamic t _) = + showString "<" . + showsPrec 0 t . + showString ">" + +instance Typeable Dynamic where +#if __GLASGOW_HASKELL__ >= 603 + typeOf _ = mkTyConApp (mkTyCon "AltData.Dynamic") [] +#else + typeOf _ = mkAppTy (mkTyCon "AltData.Dyanmic") [] +#endif + +-- +-- must be monomophic, see Data.Dynamic +-- +toDyn :: Typeable a => a -> Dynamic +toDyn v = Dynamic (typeOf v) (unsafeCoerce# v) + +-- +-- Converts a 'Dynamic' object back into an ordinary Haskell value of +-- the correct type. (this is the same as fromDynamic) +-- +-- Uses string comparison of the name of the type, rather than the +-- hashed key of the type, which doesn't work for plugins, which mix +-- static and dynamic loaded code. +-- +-- TypeRep is abstract, unfortunately. +-- +fromDyn :: Typeable a => Dynamic -> Maybe a + +fromDyn (Dynamic t v) = + case unsafeCoerce# v of + r | t == typeOf r -> Just r + | otherwise -> unsafePerformIO (putStrLn $ + "Couldn't match `" ++show(typeOf r) ++ + "' against `" ++show t ++"'"++ + "\n\tExpected type: " ++show(typeOf r) ++ + "\n\tInferred type: " ++show t + ) `seq` Nothing + +fromDynamic d = case fromDyn d of + Just v -> v + Nothing -> error ("\nType error in dynamic unwrapping.\n" ++ + "In value `" ++ show d ++ "'") + +dynApp :: Dynamic -> Dynamic -> Dynamic +dynApp f x = case dynApply f x of + Just r -> r + Nothing -> error ("Type error in dynamic application.\n" ++ + "Can't apply function " ++ show f ++ + " to argument " ++ show x) + +-- +-- (f::(a->b)) `dynApply` (x::a) = (f a)::b +-- +dynApply :: Dynamic -> Dynamic -> Maybe Dynamic +dynApply (Dynamic t1 f) (Dynamic t2 x) = +#if __GLASGOW_HASKELL__ >= 603 + case funResultTy t1 t2 of +#else + case applyTy t1 t2 of +#endif + Just t3 -> Just (Dynamic t3 ((unsafeCoerce# f) x)) + Nothing -> Nothing + + +-- +-- hmm +-- +dynAppHList :: Dynamic -> [Dynamic] -> Dynamic +dynAppHList fn [] = fn -- partial applicaiton +dynAppHList fn (x:xs) = (fn `dynApp` x) `dynAppHList` xs + +-- --------------------------------------------------------------------- +-- +-- Implementation of typecase, without patterns, based on "Dynamic +-- typing in a statically typed language". Mart\'in Abadi, Luca +-- Cardelli, Benjamin Pierce and Gordon Plotkin. ACM Trans. Prog. Lang. +-- and Syst. 13(2):237-268, 1991. +-- +-- Doesn't provide the behaviour that if the value is not a Dynamic, +-- then typecase returns a error. Need low-level ops for that. +-- + +-- typecase :: Typeable u => Dynamic -> [(TypeRep, Dynamic)] -> u -> u + +typecase :: Typeable u + => Dynamic -- selector + -> [(Dynamic, Dynamic)] -- branches + -> u -- else arm + -> u -- return type + +typecase dv@(Dynamic ty _) alts dflt = + case find (hasType ty) alts of + Nothing -> dflt + Just v -> fromDynamic $ snd v `dynApp` dv + + where hasType t ((Dynamic u _),_) = t == u + +infixl 6 --> +(-->) :: Typeable b => a -> b -> (a,Dynamic) +a --> b = (a,toDyn b) + +-- +-- need a way to generate a Dynamic prelude +-- +_Int = toDyn ( undefined :: Int ) +_Char = toDyn ( undefined :: Char ) +_Bool = toDyn ( undefined :: Bool ) +_String = toDyn ( undefined :: [Char] ) +_IntToInt = toDyn ( undefined :: Int -> Int ) + +------------------------------------------------------------------------ hunk ./src/altdata/AltData/Typeable.hs 1 +{-# OPTIONS -cpp -fglasgow-exts -fno-implicit-prelude #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- Based on: +-- +-- | +-- Module : Data.Typeable +-- Copyright : (c) The University of Glasgow, CWI 2001--2004 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : portable +-- +-- The Typeable class reifies types to some extent by associating type +-- representations to types. These type representations can be compared, +-- and one can in turn define a type-safe cast operation. To this end, +-- an unsafe cast is guarded by a test for type (representation) +-- equivalence. The module Data.Dynamic uses Typeable for an +-- implementation of dynamics. The module Data.Generics uses Typeable +-- and type-safe cast (but not dynamics) to support the \"Scrap your +-- boilerplate\" style of generic programming. +-- + +module AltData.Typeable + +#if __GLASGOW_HASKELL__ >= 603 + ( + + -- * The Typeable class + Typeable( typeOf ), -- :: a -> TypeRep + + -- * Type-safe cast + cast, -- :: (Typeable a, Typeable b) => a -> Maybe b + gcast, -- a generalisation of cast + + -- * Type representations + TypeRep, -- abstract, instance of: Eq, Show, Typeable + TyCon, -- abstract, instance of: Eq, Show, Typeable + + -- * Construction of type representations + mkTyCon, -- :: String -> TyCon + mkTyConApp, -- :: TyCon -> [TypeRep] -> TypeRep + mkAppTy, -- :: TypeRep -> TypeRep -> TypeRep + mkFunTy, -- :: TypeRep -> TypeRep -> TypeRep + + -- * Observation of type representations + splitTyConApp, -- :: TypeRep -> (TyCon, [TypeRep]) + funResultTy, -- :: TypeRep -> TypeRep -> Maybe TypeRep + typeRepTyCon, -- :: TypeRep -> TyCon + typeRepArgs, -- :: TypeRep -> [TypeRep] + tyConString, -- :: TyCon -> String + + -- * The other Typeable classes + -- | /Note:/ The general instances are provided for GHC only. + Typeable1( typeOf1 ), -- :: t a -> TypeRep + Typeable2( typeOf2 ), -- :: t a b -> TypeRep + Typeable3( typeOf3 ), -- :: t a b c -> TypeRep + Typeable4( typeOf4 ), -- :: t a b c d -> TypeRep + Typeable5( typeOf5 ), -- :: t a b c d e -> TypeRep + Typeable6( typeOf6 ), -- :: t a b c d e f -> TypeRep + Typeable7( typeOf7 ), -- :: t a b c d e f g -> TypeRep + gcast1, -- :: ... => c (t a) -> Maybe (c (t' a)) + gcast2, -- :: ... => c (t a b) -> Maybe (c (t' a b)) + + -- * Default instances + -- | /Note:/ These are not needed by GHC, for which these instances + -- are generated by general instance declarations. + typeOfDefault, -- :: (Typeable1 t, Typeable a) => t a -> TypeRep + typeOf1Default, -- :: (Typeable2 t, Typeable a) => t a b -> TypeRep + typeOf2Default, -- :: (Typeable3 t, Typeable a) => t a b c -> TypeRep + typeOf3Default, -- :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep + typeOf4Default, -- :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep + typeOf5Default, -- :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep + typeOf6Default -- :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep + + ) where + +import qualified Data.HashTable as HT +import Data.Maybe +import Data.Either +import Data.Int +import Data.Word +import Data.List( foldl ) + +import GHC.Base +import GHC.Show +import GHC.Err +import GHC.Num +import GHC.Float +import GHC.Real( rem, Ratio ) +import GHC.IOBase +import GHC.Ptr -- So we can give Typeable instance for Ptr +import GHC.Stable -- So we can give Typeable instance for StablePtr + +unsafeCoerce :: a -> b +unsafeCoerce = unsafeCoerce# + +#include "Typeable.h" + +------------------------------------------------------------- +-- +-- Type representations +-- +------------------------------------------------------------- + +-- | A concrete representation of a (monomorphic) type. 'TypeRep' +-- supports reasonably efficient equality. +-- +-- equality of keys doesn't work for dynamically loaded code, so we +-- revert back to canonical type names. +-- +data TypeRep = TypeRep !Key TyCon [TypeRep] + +-- Compare keys for equality +instance Eq TypeRep where + (TypeRep _ t1 a1) == (TypeRep _ t2 a2) = t1 == t2 && a1 == a2 + +-- | An abstract representation of a type constructor. 'TyCon' objects can +-- be built using 'mkTyCon'. +data TyCon = TyCon !Key String + +instance Eq TyCon where + (TyCon _ s1) == (TyCon _ s2) = s1 == s2 + + -- + -- let fTy = mkTyCon "Foo" in show (mkTyConApp (mkTyCon ",,") + -- [fTy,fTy,fTy]) + -- + -- returns "(Foo,Foo,Foo)" + -- + -- The TypeRep Show instance promises to print tuple types + -- correctly. Tuple type constructors are specified by a + -- sequence of commas, e.g., (mkTyCon ",,,,") returns + -- the 5-tuple tycon. + +----------------- Construction -------------------- + +-- | Applies a type constructor to a sequence of types +mkTyConApp :: TyCon -> [TypeRep] -> TypeRep +mkTyConApp tc@(TyCon tc_k _) args + = TypeRep (appKeys tc_k arg_ks) tc args + where + arg_ks = [k | TypeRep k _ _ <- args] + +-- | A special case of 'mkTyConApp', which applies the function +-- type constructor to a pair of types. +mkFunTy :: TypeRep -> TypeRep -> TypeRep +mkFunTy f a = mkTyConApp funTc [f,a] + +-- | Splits a type constructor application +splitTyConApp :: TypeRep -> (TyCon,[TypeRep]) +splitTyConApp (TypeRep _ tc trs) = (tc,trs) + +-- | Applies a type to a function type. Returns: @'Just' u@ if the +-- first argument represents a function of type @t -> u@ and the +-- second argument represents a function of type @t@. Otherwise, +-- returns 'Nothing'. +funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep +funResultTy trFun trArg + = case splitTyConApp trFun of + (tc, [t1,t2]) | tc == funTc && t1 == trArg -> Just t2 + _ -> Nothing + +-- | Adds a TypeRep argument to a TypeRep. +mkAppTy :: TypeRep -> TypeRep -> TypeRep +mkAppTy (TypeRep tr_k tc trs) arg_tr + = let (TypeRep arg_k _ _) = arg_tr + in TypeRep (appKey tr_k arg_k) tc (trs++[arg_tr]) + +-- If we enforce the restriction that there is only one +-- @TyCon@ for a type & it is shared among all its uses, +-- we can map them onto Ints very simply. The benefit is, +-- of course, that @TyCon@s can then be compared efficiently. + +-- Provided the implementor of other @Typeable@ instances +-- takes care of making all the @TyCon@s CAFs (toplevel constants), +-- this will work. + +-- If this constraint does turn out to be a sore thumb, changing +-- the Eq instance for TyCons is trivial. + +-- | Builds a 'TyCon' object representing a type constructor. An +-- implementation of "Data.Typeable" should ensure that the following holds: +-- +-- > mkTyCon "a" == mkTyCon "a" +-- + +mkTyCon :: String -- ^ the name of the type constructor (should be unique + -- in the program, so it might be wise to use the + -- fully qualified name). + -> TyCon -- ^ A unique 'TyCon' object +mkTyCon str = TyCon (mkTyConKey str) str + +----------------- Observation --------------------- + +-- | Observe the type constructor of a type representation +typeRepTyCon :: TypeRep -> TyCon +typeRepTyCon (TypeRep _ tc _) = tc + +-- | Observe the argument types of a type representation +typeRepArgs :: TypeRep -> [TypeRep] +typeRepArgs (TypeRep _ _ args) = args + +-- | Observe string encoding of a type representation +tyConString :: TyCon -> String +tyConString (TyCon _ str) = str + +----------------- Showing TypeReps -------------------- + +instance Show TypeRep where + showsPrec p (TypeRep _ tycon tys) = + case tys of + [] -> showsPrec p tycon + [x] | tycon == listTc -> showChar '[' . shows x . showChar ']' + [a,r] | tycon == funTc -> showParen (p > 8) $ + showsPrec 9 a . + showString " -> " . + showsPrec 8 r + xs | isTupleTyCon tycon -> showTuple tycon xs + | otherwise -> + showParen (p > 9) $ + showsPrec p tycon . + showChar ' ' . + showArgs tys + +instance Show TyCon where + showsPrec _ (TyCon _ s) = showString s + +isTupleTyCon :: TyCon -> Bool +isTupleTyCon (TyCon _ (',':_)) = True +isTupleTyCon _ = False + +-- Some (Show.TypeRep) helpers: + +showArgs :: Show a => [a] -> ShowS +showArgs [] = id +showArgs [a] = showsPrec 10 a +showArgs (a:as) = showsPrec 10 a . showString " " . showArgs as + +showTuple :: TyCon -> [TypeRep] -> ShowS +showTuple (TyCon _ str) args = showChar '(' . go str args + where + go [] [a] = showsPrec 10 a . showChar ')' + go _ [] = showChar ')' -- a failure condition, really. + go (',':xs) (a:as) = showsPrec 10 a . showChar ',' . go xs as + go _ _ = showChar ')' + +------------------------------------------------------------- +-- +-- The Typeable class and friends +-- +------------------------------------------------------------- + +-- | The class 'Typeable' allows a concrete representation of a type to +-- be calculated. +class Typeable a where + typeOf :: a -> TypeRep + -- ^ Takes a value of type @a@ and returns a concrete representation + -- of that type. The /value/ of the argument should be ignored by + -- any instance of 'Typeable', so that it is safe to pass 'undefined' as + -- the argument. + +-- | Variant for unary type constructors +class Typeable1 t where + typeOf1 :: t a -> TypeRep + +-- | For defining a 'Typeable' instance from any 'Typeable1' instance. +typeOfDefault :: (Typeable1 t, Typeable a) => t a -> TypeRep +typeOfDefault x = typeOf1 x `mkAppTy` typeOf (argType x) + where + argType :: t a -> a + argType = undefined + +-- | Variant for binary type constructors +class Typeable2 t where + typeOf2 :: t a b -> TypeRep + +-- | For defining a 'Typeable1' instance from any 'Typeable2' instance. +typeOf1Default :: (Typeable2 t, Typeable a) => t a b -> TypeRep +typeOf1Default x = typeOf2 x `mkAppTy` typeOf (argType x) + where + argType :: t a b -> a + argType = undefined + +-- | Variant for 3-ary type constructors +class Typeable3 t where + typeOf3 :: t a b c -> TypeRep + +-- | For defining a 'Typeable2' instance from any 'Typeable3' instance. +typeOf2Default :: (Typeable3 t, Typeable a) => t a b c -> TypeRep +typeOf2Default x = typeOf3 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c -> a + argType = undefined + +-- | Variant for 4-ary type constructors +class Typeable4 t where + typeOf4 :: t a b c d -> TypeRep + +-- | For defining a 'Typeable3' instance from any 'Typeable4' instance. +typeOf3Default :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep +typeOf3Default x = typeOf4 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d -> a + argType = undefined + +-- | Variant for 5-ary type constructors +class Typeable5 t where + typeOf5 :: t a b c d e -> TypeRep + +-- | For defining a 'Typeable4' instance from any 'Typeable5' instance. +typeOf4Default :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep +typeOf4Default x = typeOf5 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d e -> a + argType = undefined + +-- | Variant for 6-ary type constructors +class Typeable6 t where + typeOf6 :: t a b c d e f -> TypeRep + +-- | For defining a 'Typeable5' instance from any 'Typeable6' instance. +typeOf5Default :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep +typeOf5Default x = typeOf6 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d e f -> a + argType = undefined + +-- | Variant for 7-ary type constructors +class Typeable7 t where + typeOf7 :: t a b c d e f g -> TypeRep + +-- | For defining a 'Typeable6' instance from any 'Typeable7' instance. +typeOf6Default :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep +typeOf6Default x = typeOf7 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d e f g -> a + argType = undefined + +-- Given a @Typeable@/n/ instance for an /n/-ary type constructor, +-- define the instances for partial applications. +-- Programmers using non-GHC implementations must do this manually +-- for each type constructor. +-- (The INSTANCE_TYPEABLE/n/ macros in Typeable.h include this.) + +-- | One Typeable instance for all Typeable1 instances +instance (Typeable1 s, Typeable a) + => Typeable (s a) where + typeOf = typeOfDefault + +-- | One Typeable1 instance for all Typeable2 instances +instance (Typeable2 s, Typeable a) + => Typeable1 (s a) where + typeOf1 = typeOf1Default + +-- | One Typeable2 instance for all Typeable3 instances +instance (Typeable3 s, Typeable a) + => Typeable2 (s a) where + typeOf2 = typeOf2Default + +-- | One Typeable3 instance for all Typeable4 instances +instance (Typeable4 s, Typeable a) + => Typeable3 (s a) where + typeOf3 = typeOf3Default + +-- | One Typeable4 instance for all Typeable5 instances +instance (Typeable5 s, Typeable a) + => Typeable4 (s a) where + typeOf4 = typeOf4Default + +-- | One Typeable5 instance for all Typeable6 instances +instance (Typeable6 s, Typeable a) + => Typeable5 (s a) where + typeOf5 = typeOf5Default + +-- | One Typeable6 instance for all Typeable7 instances +instance (Typeable7 s, Typeable a) + => Typeable6 (s a) where + typeOf6 = typeOf6Default + +------------------------------------------------------------- +-- +-- Type-safe cast +-- +------------------------------------------------------------- + +-- | The type-safe cast operation +cast :: (Typeable a, Typeable b) => a -> Maybe b +cast x = r + where + r = if typeOf x == typeOf (fromJust r) + then Just $ unsafeCoerce x + else Nothing + +-- | A flexible variation parameterised in a type constructor +gcast :: (Typeable a, Typeable b) => c a -> Maybe (c b) +gcast x = r + where + r = if typeOf (getArg x) == typeOf (getArg (fromJust r)) + then Just $ unsafeCoerce x + else Nothing + getArg :: c x -> x + getArg = undefined + +-- | Cast for * -> * +gcast1 :: (Typeable1 t, Typeable1 t') => c (t a) -> Maybe (c (t' a)) +gcast1 x = r + where + r = if typeOf1 (getArg x) == typeOf1 (getArg (fromJust r)) + then Just $ unsafeCoerce x + else Nothing + getArg :: c x -> x + getArg = undefined + +-- | Cast for * -> * -> * +gcast2 :: (Typeable2 t, Typeable2 t') => c (t a b) -> Maybe (c (t' a b)) +gcast2 x = r + where + r = if typeOf2 (getArg x) == typeOf2 (getArg (fromJust r)) + then Just $ unsafeCoerce x + else Nothing + getArg :: c x -> x + getArg = undefined + +------------------------------------------------------------- +-- +-- Instances of the Typeable classes for Prelude types +-- +------------------------------------------------------------- + +INSTANCE_TYPEABLE1([],listTc,"[]") +INSTANCE_TYPEABLE1(Maybe,maybeTc,"Maybe") +INSTANCE_TYPEABLE1(Ratio,ratioTc,"Ratio") +INSTANCE_TYPEABLE2(Either,eitherTc,"Either") +INSTANCE_TYPEABLE2((->),funTc,"->") +INSTANCE_TYPEABLE1(IO,ioTc,"IO") +INSTANCE_TYPEABLE0((),unitTc,"()") + +INSTANCE_TYPEABLE2((,),pairTc,",") +INSTANCE_TYPEABLE3((,,),tup3Tc,",,") + +tup4Tc :: TyCon +tup4Tc = mkTyCon ",,," + +instance Typeable4 (,,,) where + typeOf4 _ = mkTyConApp tup4Tc [] + +tup5Tc :: TyCon +tup5Tc = mkTyCon ",,,," + +instance Typeable5 (,,,,) where + typeOf5 _ = mkTyConApp tup5Tc [] + +tup6Tc :: TyCon +tup6Tc = mkTyCon ",,,,," + +instance Typeable6 (,,,,,) where + typeOf6 _ = mkTyConApp tup6Tc [] + +tup7Tc :: TyCon +tup7Tc = mkTyCon ",,,,," + +instance Typeable7 (,,,,,,) where + typeOf7 _ = mkTyConApp tup7Tc [] + +INSTANCE_TYPEABLE1(Ptr,ptrTc,"Foreign.Ptr.Ptr") +INSTANCE_TYPEABLE1(StablePtr,stableptrTc,"Foreign.StablePtr.StablePtr") +INSTANCE_TYPEABLE1(IORef,iorefTc,"Data.IORef.IORef") + +------------------------------------------------------- +-- +-- Generate Typeable instances for standard datatypes +-- +------------------------------------------------------- + +INSTANCE_TYPEABLE0(Bool,boolTc,"Bool") +INSTANCE_TYPEABLE0(Char,charTc,"Char") +INSTANCE_TYPEABLE0(Float,floatTc,"Float") +INSTANCE_TYPEABLE0(Double,doubleTc,"Double") +INSTANCE_TYPEABLE0(Int,intTc,"Int") +INSTANCE_TYPEABLE0(Integer,integerTc,"Integer") +INSTANCE_TYPEABLE0(Ordering,orderingTc,"Ordering") +INSTANCE_TYPEABLE0(Handle,handleTc,"Handle") + +INSTANCE_TYPEABLE0(Int8,int8Tc,"Int8") +INSTANCE_TYPEABLE0(Int16,int16Tc,"Int16") +INSTANCE_TYPEABLE0(Int32,int32Tc,"Int32") +INSTANCE_TYPEABLE0(Int64,int64Tc,"Int64") + +INSTANCE_TYPEABLE0(Word8,word8Tc,"Word8" ) +INSTANCE_TYPEABLE0(Word16,word16Tc,"Word16") +INSTANCE_TYPEABLE0(Word32,word32Tc,"Word32") +INSTANCE_TYPEABLE0(Word64,word64Tc,"Word64") + +INSTANCE_TYPEABLE0(TyCon,tyconTc,"TyCon") +INSTANCE_TYPEABLE0(TypeRep,typeRepTc,"TypeRep") + +INSTANCE_TYPEABLE0(Word,wordTc,"Word" ) + +#else /* GHC < 6.3 */ + + ( + -- * The Typeable class + Typeable( typeOf ), -- :: a -> TypeRep + + -- * Type-safe cast + cast, -- :: (Typeable a, Typeable b) => a -> Maybe b + castss, -- a cast for kind "* -> *" + castarr, -- another convenient variation + + -- * Type representations + TypeRep, -- abstract, instance of: Eq, Show, Typeable + TyCon, -- abstract, instance of: Eq, Show, Typeable + + -- * Construction of type representations + mkTyCon, -- :: String -> TyCon + mkAppTy, -- :: TyCon -> [TypeRep] -> TypeRep + mkFunTy, -- :: TypeRep -> TypeRep -> TypeRep + applyTy, -- :: TypeRep -> TypeRep -> Maybe TypeRep + + -- * Observation of type representations + typerepTyCon, -- :: TypeRep -> TyCon + typerepArgs, -- :: TypeRep -> [TypeRep] + tyconString -- :: TyCon -> String + + + ) where + +import qualified Data.HashTable as HT +import Data.Maybe +import Data.Either +import Data.Int +import Data.Word +import Data.List( foldl ) + +import GHC.Base +import GHC.Show +import GHC.Err +import GHC.Num +import GHC.Float +import GHC.Real( rem, Ratio ) +import GHC.IOBase +import GHC.Ptr -- So we can give Typeable instance for Ptr +import GHC.Stable -- So we can give Typeable instance for StablePtr + +unsafeCoerce :: a -> b +unsafeCoerce = unsafeCoerce# + +#include "Typeable.h" + + +------------------------------------------------------------- +-- +-- Type representations +-- +------------------------------------------------------------- + + +-- | A concrete representation of a (monomorphic) type. 'TypeRep' +-- supports reasonably efficient equality. +data TypeRep = TypeRep !Key TyCon [TypeRep] + +-- Compare keys for equality +instance Eq TypeRep where + (TypeRep _ t1 a1) == (TypeRep _ t2 a2) = t1 == t2 && a1 == a2 + +-- | An abstract representation of a type constructor. 'TyCon' objects can +-- be built using 'mkTyCon'. +data TyCon = TyCon !Key String + +instance Eq TyCon where + (TyCon _ s1) == (TyCon _ s2) = s1 == s2 + + -- + -- let fTy = mkTyCon "Foo" in show (mkAppTy (mkTyCon ",,") + -- [fTy,fTy,fTy]) + -- + -- returns "(Foo,Foo,Foo)" + -- + -- The TypeRep Show instance promises to print tuple types + -- correctly. Tuple type constructors are specified by a + -- sequence of commas, e.g., (mkTyCon ",,,,") returns + -- the 5-tuple tycon. + +----------------- Construction -------------------- + +-- | Applies a type constructor to a sequence of types +mkAppTy :: TyCon -> [TypeRep] -> TypeRep +mkAppTy tc@(TyCon tc_k _) args + = TypeRep (appKeys tc_k arg_ks) tc args + where + arg_ks = [k | TypeRep k _ _ <- args] + +funTc :: TyCon +funTc = mkTyCon "->" + +-- | A special case of 'mkAppTy', which applies the function +-- type constructor to a pair of types. +mkFunTy :: TypeRep -> TypeRep -> TypeRep +mkFunTy f a = mkAppTy funTc [f,a] + +-- | Applies a type to a function type. Returns: @'Just' u@ if the +-- first argument represents a function of type @t -> u@ and the +-- second argument represents a function of type @t@. Otherwise, +-- returns 'Nothing'. +applyTy :: TypeRep -> TypeRep -> Maybe TypeRep +applyTy (TypeRep _ tc [t1,t2]) t3 + | tc == funTc && t1 == t3 = Just t2 +applyTy _ _ = Nothing + +-- If we enforce the restriction that there is only one +-- @TyCon@ for a type & it is shared among all its uses, +-- we can map them onto Ints very simply. The benefit is, +-- of course, that @TyCon@s can then be compared efficiently. + +-- Provided the implementor of other @Typeable@ instances +-- takes care of making all the @TyCon@s CAFs (toplevel constants), +-- this will work. + +-- If this constraint does turn out to be a sore thumb, changing +-- the Eq instance for TyCons is trivial. + +-- | Builds a 'TyCon' object representing a type constructor. An +-- implementation of "Data.Typeable" should ensure that the following holds: +-- +-- > mkTyCon "a" == mkTyCon "a" +-- + +mkTyCon :: String -- ^ the name of the type constructor (should be unique + -- in the program, so it might be wise to use the + -- fully qualified name). + -> TyCon -- ^ A unique 'TyCon' object +mkTyCon str = TyCon (mkTyConKey str) str + + + +----------------- Observation --------------------- + + +-- | Observe the type constructor of a type representation +typerepTyCon :: TypeRep -> TyCon +typerepTyCon (TypeRep _ tc _) = tc + + +-- | Observe the argument types of a type representation +typerepArgs :: TypeRep -> [TypeRep] +typerepArgs (TypeRep _ _ args) = args + + +-- | Observe string encoding of a type representation +tyconString :: TyCon -> String +tyconString (TyCon _ str) = str + + +----------------- Showing TypeReps -------------------- + +instance Show TypeRep where + showsPrec p (TypeRep _ tycon tys) = + case tys of + [] -> showsPrec p tycon + [x] | tycon == listTc -> showChar '[' . shows x . showChar ']' + [a,r] | tycon == funTc -> showParen (p > 8) $ + showsPrec 9 a . showString " -> " . showsPrec 8 r + xs | isTupleTyCon tycon -> showTuple tycon xs + | otherwise -> + showParen (p > 9) $ + showsPrec p tycon . + showChar ' ' . + showArgs tys + +instance Show TyCon where + showsPrec _ (TyCon _ s) = showString s + +isTupleTyCon :: TyCon -> Bool +isTupleTyCon (TyCon _ (',':_)) = True +isTupleTyCon _ = False + +-- Some (Show.TypeRep) helpers: + +showArgs :: Show a => [a] -> ShowS +showArgs [] = id +showArgs [a] = showsPrec 10 a +showArgs (a:as) = showsPrec 10 a . showString " " . showArgs as + +showTuple :: TyCon -> [TypeRep] -> ShowS +showTuple (TyCon _ str) args = showChar '(' . go str args + where + go [] [a] = showsPrec 10 a . showChar ')' + go _ [] = showChar ')' -- a failure condition, really. + go (',':xs) (a:as) = showsPrec 10 a . showChar ',' . go xs as + go _ _ = showChar ')' + + +------------------------------------------------------------- +-- +-- The Typeable class +-- +------------------------------------------------------------- + +-- | The class 'Typeable' allows a concrete representation of a type to +-- be calculated. +class Typeable a where + typeOf :: a -> TypeRep + -- ^ Takes a value of type @a@ and returns a concrete representation + -- of that type. The /value/ of the argument should be ignored by + -- any instance of 'Typeable', so that it is safe to pass 'undefined' as + -- the argument. + + +------------------------------------------------------------- +-- +-- Type-safe cast +-- +------------------------------------------------------------- + +-- | The type-safe cast operation +cast :: (Typeable a, Typeable b) => a -> Maybe b +cast x = r + where + r = if typeOf x == typeOf (fromJust r) + then Just $ unsafeCoerce x + else Nothing + + +-- | A convenient variation for kind "* -> *" +castss :: (Typeable a, Typeable b) => t a -> Maybe (t b) +castss x = r + where + r = if typeOf (get x) == typeOf (get (fromJust r)) + then Just $ unsafeCoerce x + else Nothing + get :: t c -> c + get = undefined + + +-- | Another variation +castarr :: (Typeable a, Typeable b, Typeable c, Typeable d) + => (a -> t b) -> Maybe (c -> t d) +castarr x = r + where + r = if typeOf (get x) == typeOf (get (fromJust r)) + then Just $ unsafeCoerce x + else Nothing + get :: (e -> t f) -> (e, f) + get = undefined + +{- + +The variations castss and castarr are arguably not really needed. +Let's discuss castss in some detail. To get rid of castss, we can +require "Typeable (t a)" and "Typeable (t b)" rather than just +"Typeable a" and "Typeable b". In that case, the ordinary cast would +work. Eventually, all kinds of library instances should become +Typeable. (There is another potential use of variations as those given +above. It allows quantification on type constructors. + +-} + + +------------------------------------------------------------- +-- +-- Instances of the Typeable class for Prelude types +-- +------------------------------------------------------------- + +listTc :: TyCon +listTc = mkTyCon "[]" + +instance Typeable a => Typeable [a] where + typeOf ls = mkAppTy listTc [typeOf ((undefined :: [a] -> a) ls)] + -- In GHC we can say + -- typeOf (undefined :: a) + -- using scoped type variables, but we use the + -- more verbose form here, for compatibility with Hugs + +unitTc :: TyCon +unitTc = mkTyCon "()" + +instance Typeable () where + typeOf _ = mkAppTy unitTc [] + +tup2Tc :: TyCon +tup2Tc = mkTyCon "," + +instance (Typeable a, Typeable b) => Typeable (a,b) where + typeOf tu = mkAppTy tup2Tc [typeOf ((undefined :: (a,b) -> a) tu), + typeOf ((undefined :: (a,b) -> b) tu)] + +tup3Tc :: TyCon +tup3Tc = mkTyCon ",," + +instance ( Typeable a , Typeable b , Typeable c) => Typeable (a,b,c) where + typeOf tu = mkAppTy tup3Tc [typeOf ((undefined :: (a,b,c) -> a) tu), + typeOf ((undefined :: (a,b,c) -> b) tu), + typeOf ((undefined :: (a,b,c) -> c) tu)] + +tup4Tc :: TyCon +tup4Tc = mkTyCon ",,," + +instance ( Typeable a + , Typeable b + , Typeable c + , Typeable d) => Typeable (a,b,c,d) where + typeOf tu = mkAppTy tup4Tc [typeOf ((undefined :: (a,b,c,d) -> a) tu), + typeOf ((undefined :: (a,b,c,d) -> b) tu), + typeOf ((undefined :: (a,b,c,d) -> c) tu), + typeOf ((undefined :: (a,b,c,d) -> d) tu)] +tup5Tc :: TyCon +tup5Tc = mkTyCon ",,,," + +instance ( Typeable a + , Typeable b + , Typeable c + , Typeable d + , Typeable e) => Typeable (a,b,c,d,e) where + typeOf tu = mkAppTy tup5Tc [typeOf ((undefined :: (a,b,c,d,e) -> a) tu), + typeOf ((undefined :: (a,b,c,d,e) -> b) tu), + typeOf ((undefined :: (a,b,c,d,e) -> c) tu), + typeOf ((undefined :: (a,b,c,d,e) -> d) tu), + typeOf ((undefined :: (a,b,c,d,e) -> e) tu)] + +instance (Typeable a, Typeable b) => Typeable (a -> b) where + typeOf f = mkFunTy (typeOf ((undefined :: (a -> b) -> a) f)) + (typeOf ((undefined :: (a -> b) -> b) f)) + + + +------------------------------------------------------- +-- +-- Generate Typeable instances for standard datatypes +-- +------------------------------------------------------- + +INSTANCE_TYPEABLE0(Bool,boolTc,"Bool") +INSTANCE_TYPEABLE0(Char,charTc,"Char") +INSTANCE_TYPEABLE0(Float,floatTc,"Float") +INSTANCE_TYPEABLE0(Double,doubleTc,"Double") +INSTANCE_TYPEABLE0(Int,intTc,"Int") +INSTANCE_TYPEABLE0(Integer,integerTc,"Integer") +INSTANCE_TYPEABLE1(Ratio,ratioTc,"Ratio") +INSTANCE_TYPEABLE2(Either,eitherTc,"Either") +INSTANCE_TYPEABLE1(IO,ioTc,"IO") +INSTANCE_TYPEABLE1(Maybe,maybeTc,"Maybe") +INSTANCE_TYPEABLE0(Ordering,orderingTc,"Ordering") +INSTANCE_TYPEABLE0(Handle,handleTc,"Handle") +INSTANCE_TYPEABLE1(Ptr,ptrTc,"Ptr") +INSTANCE_TYPEABLE1(StablePtr,stablePtrTc,"StablePtr") + +INSTANCE_TYPEABLE0(Int8,int8Tc,"Int8") +INSTANCE_TYPEABLE0(Int16,int16Tc,"Int16") +INSTANCE_TYPEABLE0(Int32,int32Tc,"Int32") +INSTANCE_TYPEABLE0(Int64,int64Tc,"Int64") + +INSTANCE_TYPEABLE0(Word8,word8Tc,"Word8" ) +INSTANCE_TYPEABLE0(Word16,word16Tc,"Word16") +INSTANCE_TYPEABLE0(Word32,word32Tc,"Word32") +INSTANCE_TYPEABLE0(Word64,word64Tc,"Word64") + +INSTANCE_TYPEABLE0(TyCon,tyconTc,"TyCon") +INSTANCE_TYPEABLE0(TypeRep,typeRepTc,"TypeRep") + +INSTANCE_TYPEABLE1(IORef,ioRefTc,"IORef") + +#endif /* GHC < 6.3 */ + + +--------------------------------------------- +-- +-- Internals +-- +--------------------------------------------- + +newtype Key = Key Int deriving( Eq ) + +data KeyPr = KeyPr !Key !Key deriving( Eq ) + +hashKP :: KeyPr -> Int32 +hashKP (KeyPr (Key k1) (Key k2)) = (HT.hashInt k1 + HT.hashInt k2) `rem` HT.prime + +data Cache = Cache { next_key :: !(IORef Key), + tc_tbl :: !(HT.HashTable String Key), + ap_tbl :: !(HT.HashTable KeyPr Key) } + +{-# NOINLINE cache #-} +cache :: Cache +cache = unsafePerformIO $ do + empty_tc_tbl <- HT.new (==) HT.hashString + empty_ap_tbl <- HT.new (==) hashKP + key_loc <- newIORef (Key 1) + return (Cache { next_key = key_loc, + tc_tbl = empty_tc_tbl, + ap_tbl = empty_ap_tbl }) + +newKey :: IORef Key -> IO Key +newKey _ = do i <- genSym; return (Key i) + + +-- In GHC we use the RTS's genSym function to get a new unique, +-- because in GHCi we might have two copies of the Data.Typeable +-- library running (one in the compiler and one in the running +-- program), and we need to make sure they don't share any keys. +-- +-- This is really a hack. A better solution would be to centralise the +-- whole mutable state used by this module, i.e. both hashtables. But +-- the current solution solves the immediate problem, which is that +-- dynamics generated in one world with one type were erroneously +-- being recognised by the other world as having a different type. +-- +-- dons: SimonM says we need to unify the hashes by storing them in a +-- variable in the rts. +-- +foreign import ccall unsafe "genSymZh" + genSym :: IO Int + +mkTyConKey :: String -> Key +mkTyConKey str + = unsafePerformIO $ do + let Cache {next_key = kloc, tc_tbl = tbl} = cache + mb_k <- HT.lookup tbl str + case mb_k of + Just k -> return k + Nothing -> do { k <- newKey kloc ; + HT.insert tbl str k ; + return k } + +appKey :: Key -> Key -> Key +appKey k1 k2 + = unsafePerformIO $ do + let Cache {next_key = kloc, ap_tbl = tbl} = cache + mb_k <- HT.lookup tbl kpr + case mb_k of + Just k -> return k + Nothing -> do { k <- newKey kloc ; + HT.insert tbl kpr k ; + return k } + where + kpr = KeyPr k1 k2 + +appKeys :: Key -> [Key] -> Key +appKeys k ks = foldl appKey k ks hunk ./src/altdata/AltData.hs 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module AltData ( module AltData.Dynamic, + module AltData.Typeable + ) where +import AltData.Dynamic {-all-} +import AltData.Typeable {-all-} hunk ./src/altdata/Makefile 1 +PKG = altdata +UPKG = AltData + +TOP=../.. +include ../build.mk + +install: install-me hunk ./src/altdata/altdata.conf.in.cpp 1 +#if CABAL == 0 && GLASGOW_HASKELL < 604 +Package { + name = "altdata", + auto = False, + hs_libraries = [ "HSaltdata" ], +#ifdef INSTALLING + import_dirs = [ "${LIBDIR}/imports" ], + library_dirs = [ "${LIBDIR}" ], +#else + import_dirs = [ "${TOP}/src/altdata" ], + library_dirs = [ "${TOP}/src/altdata" ], +#endif + include_dirs = [], + c_includes = [], + source_dirs = [], + extra_libraries = [], + package_deps = [ "base" ], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [] +} +#else +name: altdata +version: 0.9.8 +license: LGPL +maintainer: dons@cse.unsw.edu.au +exposed: True +exposed-modules: + AltData.Dynamic, + AltData.Typeable, + AltData + +hidden-modules: +#ifdef INSTALLING +import-dirs: LIBDIR/imports +library-dirs: LIBDIR +#else +import-dirs: TOP/src/altdata +library-dirs: TOP/src/altdata +#endif +hs-libraries: HSaltdata +extra-libraries: +include-dirs: +includes: +depends: base +hugs-options: +cc-options: +ld-options: +framework-dirs: +frameworks: +haddock-interfaces: +haddock-html: +#endif hunk ./src/build.mk 1 +# +# Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons +# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +# + +include $(TOP)/config.mk + +MAIN = $(UPKG).hs +LIBRARY = libHS$(PKG).a +GHCI_LIBRARY = HS$(PKG).o +OBJS = $(UPKG).o $(UPKG)/*.o + +HC_OPTS = -package-name $(PKG) +HC_OPTS += -O -Wall -Werror -fno-warn-missing-signatures $(GHC_EXTRA_OPTS) + +CLEANS += $(LIBRARY) $(GHCI_LIBRARY) +CLEAN_FILES += *.conf.inplace* *.conf.*.old *.conf.in *.h *.in + +.PHONY: clean all alt_objs inplace-pkg-conf happy banner + +all : $(LIBRARY) inplace-pkg-conf $(PKG).conf.in + +# libraries +$(LIBRARY): banner $(COBJ) $(XOBJ) $(YOBJ) objs + @$(RM) -f $@ + @$(AR) cq $@ $(OBJS) + @$(RANLIB) $@ + +banner: + @echo "=========== building $(PKG) =============" + +# happy files +$(YOBJ): $(YSRC) + $(HAPPY) $(HAPPY_OPTS) -o $@ $(YSRC) + +# alex files +$(XOBJ): $(XSRC) + $(ALEX) $(ALEX_OPTS) -o $@ $(XSRC) + +# objects +objs:: + $(GHC) $(HC_OPTS) --make -no-hs-main -no-link $(MAIN) + +$(COBJ): $(CSRC) + $(GHC) -c $(CSRC) -o $@ + +# package.confs and friends +# ghc-6.2.2 needs TOP as env var. +inplace-pkg-conf: $(LIBRARY) + @rm -f $(GHCI_LIBRARY) + @cpp -DTOP=$(TOP) -DGLASGOW_HASKELL=$(GLASGOW_HASKELL) -DCABAL=$(CABAL) -undef < $(PKG).conf.in.cpp | sed -e 's/""//g' -e 's/\[ *,/[ /g' -e '/^#/d' > $(PKG).conf.inplace.in + @(cd $(TOP) ;\ + if [ ! -f plugins.conf.inplace ]; then echo [] > plugins.conf.inplace; fi;\ + env TOP=$(TOP) $(GHC_PKG) -g -f plugins.conf.inplace -u < src/$(PKG)/$(PKG).conf.inplace.in) + +# installation pkg.confs +$(PKG).conf.in : $(PKG).conf.in.cpp + @cpp -DLIBDIR=$(LIBDIR) -DGLASGOW_HASKELL=$(GLASGOW_HASKELL) -DCABAL=$(CABAL) -DINSTALLING -Uunix < $(PKG).conf.in.cpp | sed -e 's/""//g' -e 's/\[ *,/[ /g' -e '/^#/d' > $@ + +# +# todo. need to re-ranlib the library +# +.PHONY: install install-me +install-me: + $(INSTALL_DATA_DIR) $(LIBDIR)/imports/$(UPKG) + @for i in $(TOP)/src/$(PKG)/*.hi ; do \ + echo $(INSTALL_DATA) $$i $(LIBDIR)/imports/ ; \ + $(INSTALL_DATA) $$i $(LIBDIR)/imports/ ; \ + done + @for i in $(TOP)/src/$(PKG)/$(UPKG)/*.hi ; do \ + echo $(INSTALL_DATA) $$i $(LIBDIR)/imports/$(UPKG)/ ; \ + $(INSTALL_DATA) $$i $(LIBDIR)/imports/$(UPKG)/ ; \ + done + $(INSTALL_DATA) $(TOP)/src/$(PKG)/libHS$(PKG).a $(LIBDIR) + $(RANLIB) $(LIBDIR)/libHS$(PKG).a + $(INSTALL_DATA) $(TOP)/src/$(PKG)/HS$(PKG).o $(LIBDIR) + $(INSTALL_DATA) $(TOP)/src/$(PKG)/$(PKG).conf.in $(LIBDIR) + +clean: + rm -f $(CLEAN_FILES) + find . -name '*.a' -exec rm {} \; + find . -name '*.in' -exec rm {} \; + find . -name '*~' -exec rm {} \; + find . -name 'a.out' -exec rm {} \; + find . -name '*.hi' -exec rm {} \; + find . -name '*.o' -exec rm {} \; + find . -name '*.old' -exec rm {} \; + find . -name '*.core' -exec rm {} \; + find . -name '*_stub.c' -exec rm {} \; + find . -name '*_stub.h' -exec rm {} \; + hunk ./src/eval/Eval/Haskell.hs 1 +{-# OPTIONS -fglasgow-exts -fffi #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- compile and run haskell strings at runtime. +-- + +module Eval.Haskell ( + eval, + eval_, + unsafeEval, + unsafeEval_, + typeOf, + + hs_eval_b, -- return a Bool + hs_eval_c, -- return a CChar + hs_eval_i, -- return a CInt + hs_eval_s, -- return a CString + + module Eval.Utils, + + ) where + +import Eval.Utils + +import Plugins.Make +import Plugins.Load + +import AltData.Dynamic +import AltData.Typeable ( Typeable ) + +import Data.Either + +import System.IO +import System.Directory + +import Foreign.C +import Foreign + +-- +-- ok. the idea is: the have either installed the library, in which case +-- is is registered, and the path to altdata is known to ghc, so just +-- saying "-package altdata" will work. if not, we search in the build +-- dir just in case. this should work for inplace work. +-- +-- TODO could have a few extra package.conf search paths in here, +-- including PREFIX. +-- + +-- --------------------------------------------------------------------- +-- return a compiled value, and type check it first +-- +-- TODO make this faster. +-- +eval :: Typeable a => String -> [Import] -> IO (Maybe a) +eval src mods = do + pwd <- getCurrentDirectory + (cmdline,loadpath) <- getPaths + tmpf <- mkUniqueWith dynwrap src mods + status <- make tmpf cmdline + m_rsrc <- case status of + MakeSuccess _ obj -> do + m_v <- dynload obj [pwd] loadpath symbol + case m_v of LoadFailure _ -> return Nothing + LoadSuccess _ rsrc -> return $ Just rsrc + MakeFailure err -> mapM_ putStrLn err >> return Nothing + makeCleaner tmpf + return m_rsrc + +-- --------------------------------------------------------------------- +-- Version of eval with all the buttons available. +eval_ :: Typeable a => + String -- ^ code to compile + -> [Import] -- ^ any imports + -> [String] -- ^ extra make flags + -> [FilePath] -- ^ (package.confs) for load + -> [FilePath] -- ^ include paths load is to search in + -> IO (Either [String] (Maybe a)) -- ^ either errors, or maybe a well typed value + +eval_ src mods args ldflags incs = do + pwd <- getCurrentDirectory + (cmdline,loadpath) <- getPaths -- find path to altdata + tmpf <- mkUniqueWith dynwrap src mods + status <- make tmpf $ ["-Onot"] ++ cmdline ++ args + m_rsrc <- case status of + MakeSuccess _ obj -> do + m_v <- dynload obj (pwd:incs) (loadpath++ldflags) symbol + return $ case m_v of LoadFailure e -> Left e + LoadSuccess _ rsrc -> Right (Just rsrc) + MakeFailure err -> return $ Left err + makeCleaner tmpf + return m_rsrc + +-- --------------------------------------------------------------------- +-- unsafe because it doesn't use Dynamic types +-- useful for not having to provide type constraints to values, or when +-- you want to easily deal with polymorphic values. +-- +unsafeEval :: String -> [Import] -> IO (Maybe a) +unsafeEval src mods = do + pwd <- getCurrentDirectory + tmpf <- mkUniqueWith wrap src mods + status <- make tmpf ["-Onot"] + m_rsrc <- case status of + MakeSuccess _ obj -> do + m_v <- load obj [pwd] [] symbol + case m_v of LoadFailure _ -> return Nothing + LoadSuccess _ rsrc -> return $ Just rsrc + MakeFailure err -> mapM_ putStrLn err >> return Nothing +-- makeCleaner tmpf + return m_rsrc + +-- +-- like unsafeEval, except you can supply extra args to make and load, +-- and the error messages are returned too. +-- +-- Need to be able to specify a search path to look in. +-- +unsafeEval_ :: String -- ^ code to compile + -> [Import] -- ^ any imports + -> [String] -- ^ make flags + -> [FilePath] -- ^ (package.confs) for load + -> [FilePath] -- ^ include paths load is to search in + -> IO (Either [String] a) + +unsafeEval_ src mods args ldflags incs = do + pwd <- getCurrentDirectory + tmpf <- mkUniqueWith wrap src mods + status <- make tmpf $ ["-Onot"] ++ args + e_rsrc <- case status of + MakeSuccess _ obj -> do + m_v <- load obj (pwd:incs) ldflags symbol + case m_v of LoadFailure e -> return $ Left e + LoadSuccess _ rsrc -> return $ Right rsrc + MakeFailure err -> return $ Left err + makeCleaner tmpf + return e_rsrc + +------------------------------------------------------------------------ +-- +-- return a compiled value's type, by using Dynamic to get a +-- representation of the inferred type. +-- +typeOf :: String -> [Import] -> IO String +typeOf src mods = do + pwd <- getCurrentDirectory + (cmdline,loadpath) <- getPaths + tmpf <- mkUniqueWith dynwrap src mods + status <- make tmpf cmdline + ty <- case status of + MakeSuccess _ obj -> do + m_v <- load obj [pwd] loadpath symbol + case m_v of + LoadFailure _ -> return "" + LoadSuccess _ (v::Dynamic) -> return $ (init . tail) $ show v + + MakeFailure err -> mapM_ putStrLn err >> return [] + makeCleaner tmpf + return ty + +-- +-- note that the wrapper uses our altdata library for dynamic typing. +-- hence it needs to see the path to the altdata package. grr. is it +-- installed or not? what path does it have? +-- +dynwrap :: String -> String -> [Import] -> String +dynwrap expr nm mods = + "module "++nm++ "( resource ) where\n" ++ + concatMap (\m-> "import "++m++"\n") mods ++ + "import AltData.Dynamic\n" ++ + "resource = let { v = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn v" + +-- --------------------------------------------------------------------- +-- unsafe wrapper +-- +wrap :: String -> String -> [Import] -> String +wrap expr nm mods = + "module "++nm++ "( resource ) where\n" ++ + concatMap (\m-> "import "++m++"\n") mods ++ + "resource = let { v = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in v" + +------------------------------------------------------------------------ +-- +-- And for our friends in foreign parts +-- +-- TODO needs to accept char** to import list +-- + +-- +-- return NULL pointer if an error occured. +-- + +foreign export ccall hs_eval_b :: CString -> IO (Ptr CInt) +foreign export ccall hs_eval_c :: CString -> IO (Ptr CChar) +foreign export ccall hs_eval_i :: CString -> IO (Ptr CInt) +foreign export ccall hs_eval_s :: CString -> IO CString + +------------------------------------------------------------------------ +-- +-- TODO implement a marshalling for Dynamics, so that we can pass that +-- over to the C side for checking. +-- + +hs_eval_b :: CString -> IO (Ptr CInt) +hs_eval_b s = do m_v <- eval_cstring s + case m_v of Nothing -> return nullPtr + Just v -> new (fromBool v) + +hs_eval_c :: CString -> IO (Ptr CChar) +hs_eval_c s = do m_v <- eval_cstring s + case m_v of Nothing -> return nullPtr + Just v -> new (castCharToCChar v) + +-- should be Integral +hs_eval_i :: CString -> IO (Ptr CInt) +hs_eval_i s = do m_v <- eval_cstring s :: IO (Maybe Int) + case m_v of Nothing -> return nullPtr + Just v -> new (fromIntegral v :: CInt) + +hs_eval_s :: CString -> IO CString +hs_eval_s s = do m_v <- eval_cstring s + case m_v of Nothing -> return nullPtr + Just v -> newCString v + +-- +-- convenience +-- +eval_cstring :: Typeable a => CString -> IO (Maybe a) +eval_cstring cs = do s <- peekCString cs + eval s [] -- TODO use eval() + hunk ./src/eval/Eval/Meta.hs 1 +{-# OPTIONS -cpp -fth #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- an implementation of the staged compilation primitives from +-- "Dynamic Typing as Staged Type Inference" +-- Shields, Sheard and Jones, 1998 +-- http://doi.acm.org/10.1145/268946.268970 +-- + +module Eval.Meta ( + + run, + defer, + splice, + + ) where + +import Eval.Haskell ( eval ) +import AltData.Typeable ( Typeable ) + +#if __GLASGOW_HASKELL__ > 602 +import Language.Haskell.TH ( ExpQ, pprint, runQ ) +#else +import Language.Haskell.THSyntax ( ExpQ, pprExp, runQ ) +import Text.PrettyPrint ( render ) +#endif + +import System.IO.Unsafe ( unsafePerformIO ) + +type ExpR = String -- hack for splicing + +-- +-- defer the evaluation of an expression by one stage. +-- uses [| |] just for the nice syntax. +-- +-- defer [| 1 + 1 |] --> (1 + 1) +-- +defer :: ExpQ -> ExpR +#if __GLASGOW_HASKELL__ > 602 +defer e = pprint (unsafePerformIO (runQ e)) +#else +defer e = render $ pprExp (unsafePerformIO (runQ e)) +#endif + +-- +-- evaluate 'e' to a deferred expression, and evaluate the result. +-- +-- run( defer [|1+1|] ) --> 2 +-- +run :: (Show t, Typeable t) => ExpR -> t +run e = case unsafePerformIO (eval e imports) of + Nothing -> error "source failed to compile" + Just a -> a + +-- +-- evaluate 'e' to a deferred expression. then splice the result back in +-- to the surrounding deferred expression. splice() is only legal within +-- deferred expressions. +-- +-- let code = defer [| 1 + 1 |] in defer [| splice(code) + 2 |] +-- --> +-- defer [| 1 + 1 + 2 |] +-- +-- defer( "\x -> " ++ splice (v) ) +-- +splice :: Show t => t -> ExpR +splice e = show e + +-- +-- libraries needed +-- +imports = + [ + "GHC.Base", + "GHC.Num", + "GHC.List" + ] + hunk ./src/eval/Eval/Utils.hs 1 +{-# OPTIONS -fglasgow-exts -fffi -cpp #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- compile and run haskell strings at runtime. +-- + +module Eval.Utils ( + + Import, + symbol, + escape, + getPaths, + find_altdata_pkgconf, + + mkUniqueWith, + cleanup, + + module Data.Maybe, + module Control.Monad, + + ) where + +import Plugins.Load ( Symbol ) +import Plugins.Utils +import Plugins.Consts ( top {- :{ -} ) + +import System.IO +import System.Directory + +import Data.Char + +-- +-- we export these so that eval() users have a nice time +-- +import Data.Maybe +import Control.Monad + +-- +-- imports Foo's +-- +type Import = String + +-- +-- distinguished symbol name +-- +symbol :: Symbol +symbol = "resource" + +-- +-- turn a Haskell string into a printable version of the same string +-- +escape s = concatMap (\c -> showLitChar c $ "") s + +-- +-- For Dynamic eval's, work out the compile and load command lines +-- +getPaths :: IO ([String],[String]) +getPaths = do + m_pkg <- find_altdata_pkgconf + let load_path = if isJust m_pkg then fromJust m_pkg else [] + let make_line = + let compulsory = ["-Onot","-fglasgow-exts","-package","altdata"] + in if not $ null load_path + then "-package-conf":load_path:compulsory + else compulsory + let load_path' = if null load_path then [] else [load_path] + return (make_line,load_path') + +-- --------------------------------------------------------------------- +-- if we are in-tree eval() needs to use the inplace package.conf to +-- find altdata, otherwise we need it to be in the ghc package system. +-- +-- fixing Typeable/Dynamic in ghc obsoletes this code. as would adding +-- an extra param to eval, which I don't want to do. +-- +find_altdata_pkgconf :: IO (Maybe String) +find_altdata_pkgconf = do + let f = top "plugins.conf.inplace" + b <- doesFileExist f + return $ if b + then Just f + else Nothing + +-- --------------------------------------------------------------------- +-- create the tmp file, and write source into it, using wrapper to +-- create extra .hs src. +-- +mkUniqueWith :: (String -> String -> [Import] -> String) + -> String + -> [Import] -> IO FilePath + +mkUniqueWith wrapper src mods = do + (tmpf,hdl) <- hMkUnique + let nm = mkModid (basename tmpf) -- used as a module name + src' = wrapper src nm mods + hPutStr hdl src' >> hFlush hdl >> hClose hdl >> return tmpf + +-- +-- remove all the tmp files +-- +cleanup :: String -> String -> IO () +cleanup a b = mapM_ removeFile [a, b, replaceSuffix b ".hi"] + hunk ./src/eval/Eval.hs 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Eval ( + module Eval.Haskell, + module Eval.Meta, + ) where + +import Eval.Haskell {-all-} +import Eval.Meta {-all-} + hunk ./src/eval/Makefile 1 +PKG = eval +UPKG = Eval + +TOP=../.. +include ../build.mk + +HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace +HC_OPTS += -package plugins + +GHC6_3_HC_OPTS += -package template-haskell + +install: install-me hunk ./src/eval/eval.conf.in.cpp 1 +#if CABAL == 0 && GLASGOW_HASKELL < 604 +Package { + name = "eval", + auto = False, + hs_libraries = [ "HSeval" ], +#ifdef INSTALLING + import_dirs = [ "${LIBDIR}/imports" ], + library_dirs = [ "${LIBDIR}/" ], +#else + import_dirs = [ "${TOP}/src/eval" ], + library_dirs = [ "${TOP}/src/eval" ], +#endif + include_dirs = [], + c_includes = [], + source_dirs = [], + extra_libraries = [], + package_deps = [ "plugins" +#if GLASGOW_HASKELL >= 603 + , "template-haskell" +#endif + ], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [] +} +#else + +name: eval +version: 0.9.8 +license: LGPL +maintainer: dons@cse.unsw.edu.au +exposed: True +exposed-modules: + Eval.Haskell, + Eval.Meta, + Eval.Utils, + Eval + +hidden-modules: +#ifdef INSTALLING +import-dirs: LIBDIR/imports +library-dirs: LIBDIR +#else +import-dirs: TOP/src/eval +library-dirs: TOP/src/eval +#endif +hs-libraries: HSeval +extra-libraries: +include-dirs: +includes: +depends: plugins, template-haskell +hugs-options: +cc-options: +ld-options: +framework-dirs: +frameworks: +haddock-interfaces: +haddock-html: + +#endif hunk ./src/hi/Hi/Binary.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS -fno-warn-unused-imports -fno-warn-name-shadowing #-} +{-# OPTIONS -fno-warn-unused-matches -fno-warn-unused-binds #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA + +-- Based on $fptools/ghc/compiler/utils/Binary.hs: +-- (c) The University of Glasgow 2002 +-- +-- Binary I/O library, with special tweaks for GHC +-- +-- Based on the nhc98 Binary library, which is copyright +-- (c) Malcolm Wallace and Colin Runciman, University of York, 1998. +-- Under the terms of the license for that software, we must tell you +-- where you can obtain the original version of the Binary library, namely +-- http://www.cs.york.ac.uk/fp/nhc98/ +-- +-- We never have to write stuff, so I've scrubbed all the put* code. +-- + +module Hi.Binary ( + {-type-} Bin, + {-class-} Binary(..), + {-type-} BinHandle, + + openBinIO, openBinIO_, + openBinMem, +-- closeBin, + + seekBin, + tellBin, + castBin, + + readBinMem, + + isEOFBin, + + -- for writing instances: + getByte, + + -- lazy Bin I/O + lazyGet, + + -- GHC only: + ByteArray(..), + getByteArray, + + getBinFileWithDict, -- :: Binary a => FilePath -> IO a + + ) where + +-- The *host* architecture version: +#include "MachDeps.h" + +-- import Hi.Utils -- ? + +import Hi.FastMutInt +import Hi.FastString + +#if __GLASGOW_HASKELL__ < 604 +import Data.FiniteMap +#else +import qualified Data.Map as M +#endif + +import Data.Unique + +import Data.Array.IO +import Data.Array +import Data.Bits +import Data.Int +import Data.Word +import Data.IORef +import Data.Char ( ord, chr ) +import Data.Array.Base ( unsafeRead, unsafeWrite ) +import Control.Monad ( when ) +import System.IO +import System.IO.Unsafe ( unsafeInterleaveIO ) +import System.IO.Error ( mkIOError, eofErrorType ) +import GHC.Real ( Ratio(..) ) +import GHC.Exts +import GHC.IOBase ( IO(..) ) +import GHC.Word ( Word8(..) ) +#if __GLASGOW_HASKELL__ < 601 +import GHC.Handle ( openFileEx, IOModeEx(..) ) +#endif + +#if __GLASGOW_HASKELL__ < 601 +openBinaryFile f mode = openFileEx f (BinaryMode mode) +#endif + +type BinArray = IOUArray Int Word8 + +--------------------------------------------------------------- +-- BinHandle +--------------------------------------------------------------- + +data BinHandle + = BinMem { -- binary data stored in an unboxed array + bh_usr :: UserData, -- sigh, need parameterized modules :-) + off_r :: !FastMutInt, -- the current offset + sz_r :: !FastMutInt, -- size of the array (cached) + arr_r :: !(IORef BinArray) -- the array (bounds: (0,size-1)) + } + -- XXX: should really store a "high water mark" for dumping out + -- the binary data to a file. + + | BinIO { -- binary data stored in a file + bh_usr :: UserData, + off_r :: !FastMutInt, -- the current offset (cached) + hdl :: !Handle -- the file handle (must be seekable) + } + -- cache the file ptr in BinIO; using hTell is too expensive + -- to call repeatedly. If anyone else is modifying this Handle + -- at the same time, we'll be screwed. + +getUserData :: BinHandle -> UserData +getUserData bh = bh_usr bh + +setUserData :: BinHandle -> UserData -> BinHandle +setUserData bh us = bh { bh_usr = us } + + +--------------------------------------------------------------- +-- Bin +--------------------------------------------------------------- + +newtype Bin a = BinPtr Int + deriving (Eq, Ord, Show, Bounded) + +castBin :: Bin a -> Bin b +castBin (BinPtr i) = BinPtr i + +--------------------------------------------------------------- +-- class Binary +--------------------------------------------------------------- + +class Binary a where + get :: BinHandle -> IO a + +getAt :: Binary a => BinHandle -> Bin a -> IO a +getAt bh p = do seekBin bh p; get bh + +openBinIO_ :: Handle -> IO BinHandle +openBinIO_ h = openBinIO h + +openBinIO :: Handle -> IO BinHandle +openBinIO h = do + r <- newFastMutInt + writeFastMutInt r 0 + return (BinIO noUserData r h) + +openBinMem :: Int -> IO BinHandle +openBinMem size + | size <= 0 = error "Hi.Binary.openBinMem: size must be >= 0" + | otherwise = do + arr <- newArray_ (0,size-1) + arr_r <- newIORef arr + ix_r <- newFastMutInt + writeFastMutInt ix_r 0 + sz_r <- newFastMutInt + writeFastMutInt sz_r size + return (BinMem noUserData ix_r sz_r arr_r) + +tellBin :: BinHandle -> IO (Bin a) +tellBin (BinIO _ r _) = do ix <- readFastMutInt r; return (BinPtr ix) +tellBin (BinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) + +seekBin :: BinHandle -> Bin a -> IO () +seekBin (BinIO _ ix_r h) (BinPtr p) = do + writeFastMutInt ix_r p + hSeek h AbsoluteSeek (fromIntegral p) +seekBin h@(BinMem _ ix_r sz_r a) (BinPtr p) = do + sz <- readFastMutInt sz_r + if (p >= sz) + then do expandBin h p; writeFastMutInt ix_r p + else writeFastMutInt ix_r p + +isEOFBin :: BinHandle -> IO Bool +isEOFBin (BinMem _ ix_r sz_r a) = do + ix <- readFastMutInt ix_r + sz <- readFastMutInt sz_r + return (ix >= sz) +isEOFBin (BinIO _ ix_r h) = hIsEOF h + +readBinMem :: FilePath -> IO BinHandle +-- Return a BinHandle with a totally undefined State +readBinMem filename = do + h <- openBinaryFile filename ReadMode + filesize' <- hFileSize h + let filesize = fromIntegral filesize' + arr <- newArray_ (0,filesize-1) + count <- hGetArray h arr filesize + when (count /= filesize) + (error ("Hi.Binary.readBinMem: only read " ++ show count ++ " bytes")) + hClose h + arr_r <- newIORef arr + ix_r <- newFastMutInt + writeFastMutInt ix_r 0 + sz_r <- newFastMutInt + writeFastMutInt sz_r filesize + return (BinMem noUserData ix_r sz_r arr_r) + +-- expand the size of the array to include a specified offset +expandBin :: BinHandle -> Int -> IO () +expandBin (BinMem _ ix_r sz_r arr_r) off = do + sz <- readFastMutInt sz_r + let sz' = head (dropWhile (<= off) (iterate (* 2) sz)) + arr <- readIORef arr_r + arr' <- newArray_ (0,sz'-1) + sequence_ [ unsafeRead arr i >>= unsafeWrite arr' i + | i <- [ 0 .. sz-1 ] ] + writeFastMutInt sz_r sz' + writeIORef arr_r arr' +#ifdef DEBUG + hPutStrLn stderr ("Binary: expanding to size: " ++ show sz') +#endif + return () +expandBin (BinIO _ _ _) _ = return () + -- no need to expand a file, we'll assume they expand by themselves. + +-- ----------------------------------------------------------------------------- +-- Low-level reading/writing of bytes + +getWord8 :: BinHandle -> IO Word8 +getWord8 (BinMem _ ix_r sz_r arr_r) = do + ix <- readFastMutInt ix_r + sz <- readFastMutInt sz_r + when (ix >= sz) $ +#if __GLASGOW_HASKELL__ <= 408 + throw (mkIOError eofErrorType "Hi.Binary.getWord8" Nothing Nothing) +#else + ioError (mkIOError eofErrorType "Hi.Binary.getWord8" Nothing Nothing) +#endif + arr <- readIORef arr_r + w <- unsafeRead arr ix + writeFastMutInt ix_r (ix+1) + return w +getWord8 (BinIO _ ix_r h) = do + ix <- readFastMutInt ix_r + c <- hGetChar h + writeFastMutInt ix_r (ix+1) + return $! (fromIntegral (ord c)) -- XXX not really correct + +getByte :: BinHandle -> IO Word8 +getByte = getWord8 + +-- ----------------------------------------------------------------------------- +-- Primitve Word writes + +instance Binary Word8 where + get = getWord8 + +instance Binary Word16 where + get h = do + w1 <- getWord8 h + w2 <- getWord8 h + return $! ((fromIntegral w1 `shiftL` 8) .|. fromIntegral w2) + +instance Binary Word32 where + get h = do + w1 <- getWord8 h + w2 <- getWord8 h + w3 <- getWord8 h + w4 <- getWord8 h + return $! ((fromIntegral w1 `shiftL` 24) .|. + (fromIntegral w2 `shiftL` 16) .|. + (fromIntegral w3 `shiftL` 8) .|. + (fromIntegral w4)) + +instance Binary Word64 where + get h = do + w1 <- getWord8 h + w2 <- getWord8 h + w3 <- getWord8 h + w4 <- getWord8 h + w5 <- getWord8 h + w6 <- getWord8 h + w7 <- getWord8 h + w8 <- getWord8 h + return $! ((fromIntegral w1 `shiftL` 56) .|. + (fromIntegral w2 `shiftL` 48) .|. + (fromIntegral w3 `shiftL` 40) .|. + (fromIntegral w4 `shiftL` 32) .|. + (fromIntegral w5 `shiftL` 24) .|. + (fromIntegral w6 `shiftL` 16) .|. + (fromIntegral w7 `shiftL` 8) .|. + (fromIntegral w8)) + +-- ----------------------------------------------------------------------------- +-- Primitve Int writes + +instance Binary Int8 where + get h = do w <- get h; return $! (fromIntegral (w::Word8)) + +instance Binary Int16 where + get h = do w <- get h; return $! (fromIntegral (w::Word16)) + +instance Binary Int32 where + get h = do w <- get h; return $! (fromIntegral (w::Word32)) + +instance Binary Int64 where + get h = do w <- get h; return $! (fromIntegral (w::Word64)) + +-- ----------------------------------------------------------------------------- +-- Instances for standard types + +instance Binary () where + get _ = return () + +instance Binary Bool where + get bh = do x <- getWord8 bh; return $! (toEnum (fromIntegral x)) + +instance Binary Char where + get bh = do x <- get bh; return $! (chr (fromIntegral (x :: Word32))) + +instance Binary Int where +#if SIZEOF_HSINT == 4 + get bh = do + x <- get bh + return $! (fromIntegral (x :: Int32)) +#elif SIZEOF_HSINT == 8 + get bh = do + x <- get bh + return $! (fromIntegral (x :: Int64)) +#else +#error "unsupported sizeof(HsInt)" +#endif + +instance Binary a => Binary [a] where + get bh = do h <- getWord8 bh + case h of + 0 -> return [] + _ -> do x <- get bh + xs <- get bh + return (x:xs) + +instance (Binary a, Binary b) => Binary (a,b) where + get bh = do a <- get bh + b <- get bh + return (a,b) + +instance (Binary a, Binary b, Binary c) => Binary (a,b,c) where + get bh = do a <- get bh + b <- get bh + c <- get bh + return (a,b,c) + +instance (Binary a, Binary b, Binary c, Binary d) => Binary (a,b,c,d) where + get bh = do a <- get bh + b <- get bh + c <- get bh + d <- get bh + return (a,b,c,d) + +instance Binary a => Binary (Maybe a) where + get bh = do h <- getWord8 bh + case h of + 0 -> return Nothing + _ -> do x <- get bh; return (Just x) + +instance (Binary a, Binary b) => Binary (Either a b) where + get bh = do h <- getWord8 bh + case h of + 0 -> do a <- get bh ; return (Left a) + _ -> do b <- get bh ; return (Right b) + +#ifdef __GLASGOW_HASKELL__ +instance Binary Integer where + get bh = do + b <- getByte bh + case b of + 0 -> do (I# i#) <- get bh + return (S# i#) + _ -> do (I# s#) <- get bh + sz <- get bh + (BA a#) <- getByteArray bh sz + return (J# s# a#) + +getByteArray :: BinHandle -> Int -> IO ByteArray +getByteArray bh (I# sz) = do + (MBA arr) <- newByteArray sz + let loop n + | n ==# sz = return () + | otherwise = do + w <- getByte bh + writeByteArray arr n w + loop (n +# 1#) + loop 0# + freezeByteArray arr + + +data ByteArray = BA ByteArray# +data MBA = MBA (MutableByteArray# RealWorld) + +newByteArray :: Int# -> IO MBA +newByteArray sz = IO $ \s -> + case newByteArray# sz s of { (# s, arr #) -> + (# s, MBA arr #) } + +freezeByteArray :: MutableByteArray# RealWorld -> IO ByteArray +freezeByteArray arr = IO $ \s -> + case unsafeFreezeByteArray# arr s of { (# s, arr #) -> + (# s, BA arr #) } + +#if __GLASGOW_HASKELL__ < 503 +writeByteArray arr i w8 = IO $ \s -> + case word8ToWord w8 of { W# w# -> + case writeCharArray# arr i (chr# (word2Int# w#)) s of { s -> + (# s , () #) }} +#else +writeByteArray arr i (W8# w) = IO $ \s -> + case writeWord8Array# arr i w s of { s -> + (# s, () #) } +#endif + +#if __GLASGOW_HASKELL__ < 503 +indexByteArray a# n# = fromIntegral (I# (ord# (indexCharArray# a# n#))) +#else +indexByteArray a# n# = W8# (indexWord8Array# a# n#) +#endif + +instance (Integral a, Binary a) => Binary (Ratio a) where + get bh = do a <- get bh; b <- get bh; return (a :% b) +#endif + +instance Binary (Bin a) where + get bh = do i <- get bh; return (BinPtr i) + +-- ----------------------------------------------------------------------------- +-- Lazy reading/writing + +lazyGet :: Binary a => BinHandle -> IO a +lazyGet bh = do + p <- get bh -- a BinPtr + p_a <- tellBin bh + a <- unsafeInterleaveIO (getAt bh p_a) + seekBin bh p -- skip over the object for now + return a + +-- -------------------------------------------------------------- +-- Main wrappers: getBinFileWithDict, putBinFileWithDict +-- +-- This layer is built on top of the stuff above, +-- and should not know anything about BinHandles +-- -------------------------------------------------------------- + +initBinMemSize = (1024*1024) :: Int +binaryInterfaceMagic = 0x1face :: Word32 + +getBinFileWithDict :: Binary a => FilePath -> IO a +getBinFileWithDict file_path = do + bh <- Hi.Binary.readBinMem file_path + + -- Read the magic number to check that this really is a GHC .hi file + -- (This magic number does not change when we change + -- GHC interface file format) + magic <- get bh + + when (magic /= binaryInterfaceMagic) $ + error "magic number mismatch: old/corrupt interface file?" + + -- Read the dictionary + -- The next word in the file is a pointer to where the dictionary is + -- (probably at the end of the file) + dict_p <- Hi.Binary.get bh -- Get the dictionary ptr + data_p <- tellBin bh -- Remember where we are now + seekBin bh dict_p + dict <- getDictionary bh + + seekBin bh data_p -- Back to where we were before + + -- Initialise the user-data field of bh + let bh' = setUserData bh (initReadState dict) + + -- At last, get the thing + get bh' + +-- ----------------------------------------------------------------------------- +-- UserData +-- ----------------------------------------------------------------------------- + +data UserData = + UserData { -- This field is used only when reading + ud_dict :: Dictionary, + + -- The next two fields are only used when writing + ud_next :: IORef Int, -- The next index to use +#if __GLASGOW_HASKELL__ < 604 + ud_map :: IORef (FiniteMap Unique (Int,FastString)) +#else + ud_map :: IORef (M.Map Unique (Int,FastString)) +#endif + } + +noUserData = error "Hi.Binary.UserData: no user data" + +initReadState :: Dictionary -> UserData +initReadState dict = UserData{ ud_dict = dict, + ud_next = undef "next", + ud_map = undef "map" } + +newWriteState :: IO UserData +newWriteState = do + j_r <- newIORef 0 +#if __GLASGOW_HASKELL__ < 604 + out_r <- newIORef emptyFM +#else + out_r <- newIORef M.empty +#endif + return (UserData { ud_dict = error "dict", + ud_next = j_r, + ud_map = out_r }) + + +undef s = error ("Hi.Binary.UserData: no " ++ s) + +--------------------------------------------------------- +-- The Dictionary +--------------------------------------------------------- + +type Dictionary = Array Int FastString -- The dictionary + -- Should be 0-indexed + +getDictionary :: BinHandle -> IO Dictionary +getDictionary bh = do + sz <- get bh + elems <- sequence (take sz (repeat (getFS bh))) + return (listArray (0,sz-1) elems) + +#if __GLASGOW_HASKELL__ < 604 +constructDictionary :: Int -> FiniteMap Unique (Int,FastString) -> Dictionary +constructDictionary j fm = array (0,j-1) (eltsFM fm) +#else +constructDictionary :: Int -> M.Map Unique (Int,FastString) -> Dictionary +constructDictionary j fm = array (0,j-1) (M.elems fm) +#endif + +--------------------------------------------------------- +-- Reading and writing FastStrings +--------------------------------------------------------- + +getFS bh = do + (I# l) <- get bh + (BA ba) <- getByteArray bh (I# l) + return $! (mkFastSubStringBA# ba 0# l) + +instance Binary FastString where + get bh = do j <- get bh -- Int + return $! (ud_dict (getUserData bh) ! j) + hunk ./src/hi/Hi/FastMutInt.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS -fno-warn-name-shadowing #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- +-- Based on code from $fptools/ghc/compiler/utils/FastMutInt.lhs +-- +-- (c) Copyright 2002, The University Court of the University of Glasgow. + +-- +-- Unboxed mutable Ints +-- + +module Hi.FastMutInt ( + FastMutInt, + newFastMutInt, + readFastMutInt, + writeFastMutInt, + incFastMutInt, + incFastMutIntBy + ) where + +#include "MachDeps.h" + +#if __GLASGOW_HASKELL__ < 503 +import GlaExts +import PrelIOBase +#else +import GHC.Base +import GHC.IOBase +#endif + +#if __GLASGOW_HASKELL__ < 411 +newByteArray# = newCharArray# +#endif + +data FastMutInt = FastMutInt (MutableByteArray# RealWorld) + +newFastMutInt :: IO FastMutInt +newFastMutInt = IO $ \s -> + case newByteArray# size s of { (# s, arr #) -> + (# s, FastMutInt arr #) } + where I# size = SIZEOF_HSINT + +readFastMutInt :: FastMutInt -> IO Int +readFastMutInt (FastMutInt arr) = IO $ \s -> + case readIntArray# arr 0# s of { (# s, i #) -> + (# s, I# i #) } + +writeFastMutInt :: FastMutInt -> Int -> IO () +writeFastMutInt (FastMutInt arr) (I# i) = IO $ \s -> + case writeIntArray# arr 0# i s of { s -> + (# s, () #) } + +incFastMutInt :: FastMutInt -> IO Int -- Returns original value +incFastMutInt (FastMutInt arr) = IO $ \s -> + case readIntArray# arr 0# s of { (# s, i #) -> + case writeIntArray# arr 0# (i +# 1#) s of { s -> + (# s, I# i #) } } + +incFastMutIntBy :: FastMutInt -> Int -> IO Int -- Returns original value +incFastMutIntBy (FastMutInt arr) (I# n) = IO $ \s -> + case readIntArray# arr 0# s of { (# s, i #) -> + case writeIntArray# arr 0# (i +# n) s of { s -> + (# s, I# i #) } } + hunk ./src/hi/Hi/FastString.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS -fno-warn-name-shadowing -fno-warn-unused-matches #-} + +{-# OPTIONS -#include "hschooks.h" #-} + +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- +-- Based on $fptools/ghc/compiler/utils/FastString.lhs +-- +-- (c) The GRASP/AQUA Project, Glasgow University, 1997-1998 +-- +-- Fast strings +-- +-- Compact representations of character strings with +-- unique identifiers (hash-cons'ish). +-- + +module Hi.FastString + ( + FastString(..), -- not abstract, for now. + + mkFastString, -- :: String -> FastString + mkFastStringNarrow, -- :: String -> FastString + mkFastSubString, -- :: Addr -> Int -> Int -> FastString + + mkFastString#, -- :: Addr# -> FastString + mkFastSubStringBA#, -- :: ByteArray# -> Int# -> Int# -> FastString + + mkFastStringInt, -- :: [Int] -> FastString + + uniqueOfFS, -- :: FastString -> Int# + lengthFS, -- :: FastString -> Int + nullFastString, -- :: FastString -> Bool + + unpackFS, -- :: FastString -> String + unpackIntFS, -- :: FastString -> [Int] + appendFS, -- :: FastString -> FastString -> FastString + headFS, -- :: FastString -> Char + headIntFS, -- :: FastString -> Int + tailFS, -- :: FastString -> FastString + concatFS, -- :: [FastString] -> FastString + consFS, -- :: Char -> FastString -> FastString + indexFS, -- :: FastString -> Int -> Char + nilFS, -- :: FastString + + hPutFS, -- :: Handle -> FastString -> IO () + + LitString, + mkLitString# -- :: Addr# -> LitString + ) where + +import Hi.PrimPacked + +import IO +import Char ( chr, ord ) + +import GHC.Exts +import GHC.IOBase +import GHC.Arr ( STArray(..), newSTArray ) +import GHC.Handle + +import Foreign.C + +-- import System.IO.Unsafe ( unsafePerformIO ) +-- import Control.Monad.ST ( stToIO ) +-- import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) + + +#define hASH_TBL_SIZE 993 + +{- +@FastString@s are packed representations of strings +with a unique id for fast comparisons. The unique id +is assigned when creating the @FastString@, using +a hash table to map from the character string representation +to the unique ID. +-} + +data FastString + = FastString -- packed repr. on the heap. + Int# -- unique id + -- 0 => string literal, comparison + -- will + Int# -- length + ByteArray# -- stuff + + | UnicodeStr -- if contains characters outside '\1'..'\xFF' + Int# -- unique id + [Int] -- character numbers + +instance Eq FastString where + -- shortcut for real FastStrings + (FastString u1 _ _) == (FastString u2 _ _) = u1 ==# u2 + a == b = case cmpFS a b of { LT -> False; EQ -> True; GT -> False } + + (FastString u1 _ _) /= (FastString u2 _ _) = u1 /=# u2 + a /= b = case cmpFS a b of { LT -> True; EQ -> False; GT -> True } + +instance Ord FastString where + -- Compares lexicographically, not by unique + a <= b = case cmpFS a b of { LT -> True; EQ -> True; GT -> False } + a < b = case cmpFS a b of { LT -> True; EQ -> False; GT -> False } + a >= b = case cmpFS a b of { LT -> False; EQ -> True; GT -> True } + a > b = case cmpFS a b of { LT -> False; EQ -> False; GT -> True } + max x y | x >= y = x + | otherwise = y + min x y | x <= y = x + | otherwise = y + compare a b = cmpFS a b + +lengthFS :: FastString -> Int +lengthFS (FastString _ l# _) = I# l# +lengthFS (UnicodeStr _ s) = length s + +nullFastString :: FastString -> Bool +nullFastString (FastString _ l# _) = l# ==# 0# +nullFastString (UnicodeStr _ []) = True +nullFastString (UnicodeStr _ (_:_)) = False + +unpackFS :: FastString -> String +unpackFS (FastString _ l# ba#) = unpackNBytesBA (BA ba#) (I# l#) +unpackFS (UnicodeStr _ s) = map chr s + +unpackIntFS :: FastString -> [Int] +unpackIntFS (UnicodeStr _ s) = s +unpackIntFS fs = map ord (unpackFS fs) + +appendFS :: FastString -> FastString -> FastString +appendFS fs1 fs2 = mkFastStringInt (unpackIntFS fs1 ++ unpackIntFS fs2) + +concatFS :: [FastString] -> FastString +concatFS ls = mkFastStringInt (concat (map unpackIntFS ls)) -- ToDo: do better + +headFS :: FastString -> Char +headFS (FastString _ l# ba#) = + if l# ># 0# then C# (indexCharArray# ba# 0#) else error ("headFS: empty FS") +headFS (UnicodeStr _ (c:_)) = chr c +headFS (UnicodeStr _ []) = error ("headFS: empty FS") + +headIntFS :: FastString -> Int +headIntFS (UnicodeStr _ (c:_)) = c +headIntFS fs = ord (headFS fs) + +indexFS :: FastString -> Int -> Char +indexFS f i@(I# i#) = + case f of + FastString _ l# ba# + | l# ># 0# && l# ># i# -> C# (indexCharArray# ba# i#) + | otherwise -> error (msg (I# l#)) + UnicodeStr _ s -> chr (s!!i) + where + msg l = "indexFS: out of range: " ++ show (l,i) + +tailFS :: FastString -> FastString +tailFS (FastString _ l# ba#) = mkFastSubStringBA# ba# 1# (l# -# 1#) +tailFS fs = mkFastStringInt (tail (unpackIntFS fs)) + +consFS :: Char -> FastString -> FastString +consFS c fs = mkFastStringInt (ord c : unpackIntFS fs) + +uniqueOfFS :: FastString -> Int# +uniqueOfFS (FastString u# _ _) = u# +uniqueOfFS (UnicodeStr u# _) = u# + +nilFS = mkFastString "" + +{- +GHC-related stuff: + +Internally, the compiler will maintain a fast string symbol +table, providing sharing and fast comparison. Creation of +new @FastString@s then covertly does a lookup, re-using the +@FastString@ if there was a hit. + +Caution: mkFastStringUnicode assumes that if the string is in the +table, it sits under the UnicodeStr constructor. Other mkFastString +variants analogously assume the FastString constructor. +-} + +data FastStringTable = + FastStringTable + Int# + (MutableArray# RealWorld [FastString]) + +type FastStringTableVar = IORef FastStringTable + +string_table :: FastStringTableVar +string_table = + unsafePerformIO ( + stToIO (newSTArray (0::Int,hASH_TBL_SIZE) []) + >>= \ (STArray _ _ arr#) -> + newIORef (FastStringTable 0# arr#)) + +lookupTbl :: FastStringTable -> Int# -> IO [FastString] +lookupTbl (FastStringTable _ arr#) i# = + IO ( \ s# -> + readArray# arr# i# s#) + +updTbl :: FastStringTableVar -> FastStringTable -> Int# -> [FastString] -> IO () +updTbl fs_table_var (FastStringTable uid# arr#) i# ls = + IO (\ s# -> case writeArray# arr# i# ls s# of { s2# -> + (# s2#, () #) }) >> + writeIORef fs_table_var (FastStringTable (uid# +# 1#) arr#) + +mkFastString# :: Addr# -> FastString +mkFastString# a# = + case strLength (Ptr a#) of { (I# len#) -> mkFastStringLen# a# len# } + +mkFastStringLen# :: Addr# -> Int# -> FastString +mkFastStringLen# a# len# = + unsafePerformIO ( + readIORef string_table >>= \ ft@(FastStringTable uid# tbl#) -> + let + h = hashStr a# len# + in +-- _trace ("hashed: "++show (I# h)) $ + lookupTbl ft h >>= \ lookup_result -> + case lookup_result of + [] -> + -- no match, add it to table by copying out the + -- the string into a ByteArray + -- _trace "empty bucket" $ + case copyPrefixStr a# (I# len#) of + BA barr# -> + let f_str = FastString uid# len# barr# in + updTbl string_table ft h [f_str] >> + ({- _trace ("new: " ++ show f_str) $ -} return f_str) + ls -> + -- non-empty `bucket', scan the list looking + -- entry with same length and compare byte by byte. + -- _trace ("non-empty bucket"++show ls) $ + case bucket_match ls len# a# of + Nothing -> + case copyPrefixStr a# (I# len#) of + BA barr# -> + let f_str = FastString uid# len# barr# in + updTbl string_table ft h (f_str:ls) >> + ( {- _trace ("new: " ++ show f_str) $ -} return f_str) + Just v -> {- _trace ("re-use: "++show v) $ -} return v) + where + bucket_match [] _ _ = Nothing + bucket_match (v@(FastString _ l# ba#):ls) len# a# = + if len# ==# l# && eqStrPrefix a# ba# l# then + Just v + else + bucket_match ls len# a# + bucket_match (UnicodeStr _ _ : ls) len# a# = + bucket_match ls len# a# + +mkFastSubStringBA# :: ByteArray# -> Int# -> Int# -> FastString +mkFastSubStringBA# barr# start# len# = + unsafePerformIO ( + readIORef string_table >>= \ ft@(FastStringTable uid# tbl#) -> + let + h = hashSubStrBA barr# start# len# + in +-- _trace ("hashed(b): "++show (I# h)) $ + lookupTbl ft h >>= \ lookup_result -> + case lookup_result of + [] -> + -- no match, add it to table by copying out the + -- the string into a ByteArray + -- _trace "empty bucket(b)" $ + case copySubStrBA (BA barr#) (I# start#) (I# len#) of + BA ba# -> + let f_str = FastString uid# len# ba# in + updTbl string_table ft h [f_str] >> + -- _trace ("new(b): " ++ show f_str) $ + return f_str + ls -> + -- non-empty `bucket', scan the list looking + -- entry with same length and compare byte by byte. + -- _trace ("non-empty bucket(b)"++show ls) $ + case bucket_match ls start# len# barr# of + Nothing -> + case copySubStrBA (BA barr#) (I# start#) (I# len#) of + BA ba# -> + let f_str = FastString uid# len# ba# in + updTbl string_table ft h (f_str:ls) >> + -- _trace ("new(b): " ++ show f_str) $ + return f_str + Just v -> + -- _trace ("re-use(b): "++show v) $ + return v + ) + where + bucket_match [] _ _ _ = Nothing + bucket_match (v:ls) start# len# ba# = + case v of + FastString _ l# barr# -> + if len# ==# l# && eqStrPrefixBA barr# ba# start# len# then + Just v + else + bucket_match ls start# len# ba# + UnicodeStr _ _ -> bucket_match ls start# len# ba# + +mkFastStringUnicode :: [Int] -> FastString +mkFastStringUnicode s = + unsafePerformIO ( + readIORef string_table >>= \ ft@(FastStringTable uid# tbl#) -> + let + h = hashUnicode s + in +-- _trace ("hashed(b): "++show (I# h)) $ + lookupTbl ft h >>= \ lookup_result -> + case lookup_result of + [] -> + -- no match, add it to table by copying out the + -- the string into a [Int] + let f_str = UnicodeStr uid# s in + updTbl string_table ft h [f_str] >> + -- _trace ("new(b): " ++ show f_str) $ + return f_str + ls -> + -- non-empty `bucket', scan the list looking + -- entry with same length and compare byte by byte. + -- _trace ("non-empty bucket(b)"++show ls) $ + case bucket_match ls of + Nothing -> + let f_str = UnicodeStr uid# s in + updTbl string_table ft h (f_str:ls) >> + -- _trace ("new(b): " ++ show f_str) $ + return f_str + Just v -> + -- _trace ("re-use(b): "++show v) $ + return v + ) + where + bucket_match [] = Nothing + bucket_match (v@(UnicodeStr _ s'):ls) = + if s' == s then Just v else bucket_match ls + bucket_match (FastString _ _ _ : ls) = bucket_match ls + +mkFastStringNarrow :: String -> FastString +mkFastStringNarrow str = + case packString str of { (I# len#, BA frozen#) -> + mkFastSubStringBA# frozen# 0# len# + } + {- 0-indexed array, len# == index to one beyond end of string, + i.e., (0,1) => empty string. -} + +mkFastString :: String -> FastString +mkFastString str = if all good str + then mkFastStringNarrow str + else mkFastStringUnicode (map ord str) + where + good c = c >= '\1' && c <= '\xFF' + +mkFastStringInt :: [Int] -> FastString +mkFastStringInt str = if all good str + then mkFastStringNarrow (map chr str) + else mkFastStringUnicode str + where + good c = c >= 1 && c <= 0xFF + +mkFastSubString :: Addr# -> Int -> Int -> FastString +mkFastSubString a# (I# start#) (I# len#) = + mkFastStringLen# (a# `plusAddr#` start#) len# + +hashStr :: Addr# -> Int# -> Int# + -- use the Addr to produce a hash value between 0 & m (inclusive) +hashStr a# len# = + case len# of + 0# -> 0# + 1# -> ((ord# c0 *# 631#) +# len#) `remInt#` hASH_TBL_SIZE# + 2# -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# len#) `remInt#` hASH_TBL_SIZE# + _ -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# (ord# c2 *# 43#) +# len#) `remInt#` hASH_TBL_SIZE# + where + c0 = indexCharOffAddr# a# 0# + c1 = indexCharOffAddr# a# (len# `quotInt#` 2# -# 1#) + c2 = indexCharOffAddr# a# (len# -# 1#) +{- + c1 = indexCharOffAddr# a# 1# + c2 = indexCharOffAddr# a# 2# +-} + +hashSubStrBA :: ByteArray# -> Int# -> Int# -> Int# + -- use the byte array to produce a hash value between 0 & m (inclusive) +hashSubStrBA ba# start# len# = + case len# of + 0# -> 0# + 1# -> ((ord# c0 *# 631#) +# len#) `remInt#` hASH_TBL_SIZE# + 2# -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# len#) `remInt#` hASH_TBL_SIZE# + _ -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# (ord# c2 *# 43#) +# len#) `remInt#` hASH_TBL_SIZE# + where + c0 = indexCharArray# ba# (start# +# 0#) + c1 = indexCharArray# ba# (start# +# (len# `quotInt#` 2# -# 1#)) + c2 = indexCharArray# ba# (start# +# (len# -# 1#)) + +-- c1 = indexCharArray# ba# 1# +-- c2 = indexCharArray# ba# 2# + +hashUnicode :: [Int] -> Int# + -- use the Addr to produce a hash value between 0 & m (inclusive) +hashUnicode [] = 0# +hashUnicode [I# c0] = ((c0 *# 631#) +# 1#) `remInt#` hASH_TBL_SIZE# +hashUnicode [I# c0, I# c1] = ((c0 *# 631#) +# (c1 *# 217#) +# 2#) `remInt#` hASH_TBL_SIZE# +hashUnicode s = ((c0 *# 631#) +# (c1 *# 217#) +# (c2 *# 43#) +# len#) `remInt#` hASH_TBL_SIZE# + where + I# len# = length s + I# c0 = s !! 0 + I# c1 = s !! (I# (len# `quotInt#` 2# -# 1#)) + I# c2 = s !! (I# (len# -# 1#)) + +cmpFS :: FastString -> FastString -> Ordering +cmpFS (UnicodeStr u1# s1) (UnicodeStr u2# s2) = if u1# ==# u2# then EQ + else compare s1 s2 +cmpFS (UnicodeStr _ s1) s2 = compare s1 (unpackIntFS s2) +cmpFS s1 (UnicodeStr _ s2) = compare (unpackIntFS s1) s2 +cmpFS (FastString u1# l1# b1#) (FastString u2# l2# b2#) = + if u1# ==# u2# then EQ else + let l# = if l1# <=# l2# then l1# else l2# in + unsafePerformIO ( + memcmp b1# b2# l# >>= \ (I# res) -> + return ( + if res <# 0# then LT + else if res ==# 0# then + if l1# ==# l2# then EQ + else if l1# <# l2# then LT else GT + else GT + )) + +foreign import ccall unsafe "memcmp" + memcmp :: ByteArray# -> ByteArray# -> Int# -> IO Int + +-- ----------------------------------------------------------------------------- +-- Outputting 'FastString's + +#if __GLASGOW_HASKELL__ >= 504 + +-- this is our own version of hPutBuf for FastStrings, because in +-- 5.04+ we don't have mutable byte arrays and therefore hPutBufBA. +-- The closest is hPutArray in Data.Array.IO, but that does some extra +-- range checks that we want to avoid here. + +foreign import ccall unsafe "__hscore_memcpy_dst_off" + memcpy_baoff_ba :: RawBuffer -> Int -> RawBuffer -> CSize -> IO (Ptr ()) + +hPutFS handle (FastString _ l# ba#) + | l# ==# 0# = return () + | otherwise + = do wantWritableHandle "hPutFS" handle $ + \ handle_@Handle__{ haFD=fd, haBuffer=ref, haIsStream=stream } -> do + + old_buf@Buffer{ bufBuf=old_raw, bufRPtr=r, bufWPtr=w, bufSize=size } + <- readIORef ref + + let count = I# l# + raw = unsafeCoerce# ba# :: MutableByteArray# RealWorld + + -- enough room in handle buffer? + if (size - w > count) + -- There's enough room in the buffer: + -- just copy the data in and update bufWPtr. + then do memcpy_baoff_ba old_raw w raw (fromIntegral count) + writeIORef ref old_buf{ bufWPtr = w + count } + return () + + -- else, we have to flush + else do flushed_buf <- flushWriteBuffer fd stream old_buf + writeIORef ref flushed_buf + let this_buf = + Buffer{ bufBuf=raw, bufState=WriteBuffer, + bufRPtr=0, bufWPtr=count, bufSize=count } + flushWriteBuffer fd stream this_buf + return () + +#else + +hPutFS :: Handle -> FastString -> IO () +hPutFS handle (FastString _ l# ba#) + | l# ==# 0# = return () + | otherwise = do mba <- stToIO $ unsafeThawByteArray (ByteArray (bot::Int) bot ba#) + hPutBufBAFull handle mba (I# l#) + where + bot = error "hPutFS.ba" + +#endif + +-- ONLY here for debugging the NCG (so -ddump-stix works for string +-- literals); no idea if this is really necessary. JRS, 010131 +hPutFS handle (UnicodeStr _ is) + = hPutStr handle ("(UnicodeStr " ++ show is ++ ")") + +-- ----------------------------------------------------------------------------- +-- LitStrings, here for convenience only. + +type LitString = Ptr () +-- ToDo: make it a Ptr when we don't have to support 4.08 any more + +mkLitString# :: Addr# -> LitString +mkLitString# a# = Ptr a# hunk ./src/hi/Hi/Parser.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-name-shadowing #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- Based on $fptools/ghc/compiler/iface/BinIface.hs +-- +-- (c) The University of Glasgow 2002 +-- +-- Binary interface file support. +-- + +-- +-- This provides the "Binary" instances for the Iface type such that we +-- can parse binary representations of that type. i.e. from .hi files +-- +-- The main problem we have is that all the stuff we don't care about, +-- we just want to read in to a string. So this has to be hand-hacked +-- somewhat. +-- +-- The "Binary" class for hs-plugins only includes a get method. We +-- don't do any writing. Saves us having to properly reconstruct the +-- abstract syntax, which would pull in *way* too much of GHC. +-- + + + +module Hi.Parser ( readIface, module Hi.Syntax ) where + +import Hi.Syntax +import Hi.Binary +import Hi.FastString + +import GHC.Word + +#include "../../../config.h" + +-- --------------------------------------------------------------------------- +-- how to get there from here + +readIface :: FilePath -> IO Iface +readIface hi_path = getBinFileWithDict hi_path + +-- --------------------------------------------------------------------- +-- All the Binary instances +-- +-- Reading a binary interface into ParsedIface +-- +-- We pull the trick of only reading up to the point we need +-- + +instance Binary Iface where + get bh = do + version <- get bh :: IO String + build_tag <- get bh :: IO Word8 -- 'way' flag + +#if __GLASGOW_HASKELL__ >= 604 + mod_name <- get bh :: IO FastString + _is_boot <- get bh :: IO Bool + let pkg_name = mkFastString "unknown" -- >=604 has no package field +#elif CABAL == 1 && __GLASGOW_HASKELL__ == 603 + mod_name <- get bh :: IO FastString + let pkg_name = mkFastString "unknown" +#else /* <= 622 */ + mod_name <- get bh :: IO FastString + pkg_name <- get bh :: IO FastString +#endif + mod_vers <- get bh :: IO Version + orphan <- get bh :: IO Bool + deps <- get bh :: IO Dependencies + + get bh :: IO (Bin Int) -- fake a lazyGet for [Usage] + usages <- get bh :: IO [Usage] + + exports <- get bh :: IO [IfaceExport] + +-- (exp_vers :: Version) <- get bh +-- (fixities :: [(OccName,Fixity)]) <- get bh +-- (deprecs :: [IfaceDeprec]) <- get bh + +-- (decls :: [(Version,IfaceDecl)])<- get bh + +-- (insts :: [IfaceInst]) <- get bh +-- (rules :: [IfaceRule]) <- get bh +-- (rule_vers :: Version) <- get bh + + return $ Iface { + mi_package = unpackFS pkg_name, + mi_module = unpackFS mod_name, + mi_deps = deps , + mi_usages = usages, + mi_exports = exports {-,-} + +-- mi_mod_vers = mod_vers, +-- mi_boot = False, -- .hi files are never .hi-boot files! +-- mi_orphan = orphan, +-- mi_usages = usages, +-- mi_exports = exports, +-- mi_exp_vers = exp_vers, +-- mi_fixities = fixities, +-- mi_deprecs = deprecs, +-- mi_decls = decls, +-- mi_insts = insts, +-- mi_rules = rules, +-- mi_rule_vers = rule_vers + } + +------------------------------------------------------------------------ +-- +-- Types from: Iface.hs, HscTypes +-- + +-- fake a lazyGet +instance Binary Dependencies where + get bh = do get bh :: IO (Bin Int) -- really a BinPtr Int + ms <- get bh :: IO [(FastString,Bool)] + ps <- get bh :: IO [FastString] + _ <- get bh :: IO [FastString] -- !!orphans + return Deps { dep_mods = map unpackFS $! map fst ms, + dep_pkgs = map unpackFS ps {-,-} + } + +------------------------------------------------------------------------ +-- Usages +------------------------------------------------------------------------ + +instance Binary OccName where + get bh = do aa <- get bh :: IO NameSpace + ab <- get bh :: IO FastString + return $ OccName aa (unpackFS ab) + +instance Binary NameSpace where + get bh = do h <- getByte bh + case h of + 0 -> return VarName + 1 -> return DataName + 2 -> return TvName + _ -> return TcClsName + +instance Binary Usage where + get bh = do (nm :: FastString) <- get bh + (mod :: Version) <- get bh + (exps :: Maybe Version) <- get bh + (ents :: [(OccName,Version)]) <- get bh + (rules :: Version) <- get bh + return $ Usage {usg_name = (unpackFS nm), + usg_mod = mod, + usg_exports = exps, + usg_entities = ents, + usg_rules = rules } + +------------------------------------------------------------------------ +-- Exports + +instance (Binary name) => Binary (GenAvailInfo name) where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: name) <- get bh + return $ Avail aa + _ -> do (ab :: name) <- get bh + (ac :: [name]) <- get bh + return $ AvailTC ab ac + +{- +instance Binary a => Binary (Deprecs a) where + get bh = do + h <- getByte bh + case h of + 0 -> return Deprecs + 1 -> do (aa :: FastString) <- get bh + return Deprecs + _ -> do (ab :: a) <- get bh + return Deprecs +-} + +------------------------------------------------------------------------- +-- Types from: BasicTypes +------------------------------------------------------------------------- + +{- +instance Binary Activation where + get bh = do + h <- getByte bh + case h of + 0 -> return Activation + 1 -> return Activation + 2 -> do (aa :: Int) <- get bh ; return Activation + _ -> do (ab :: Int) <- get bh ; return Activation + +instance Binary StrictnessMark where + get bh = do + h <- getByte bh + case h of + 0 -> return StrictnessMark + 1 -> return StrictnessMark + _ -> return StrictnessMark + +instance Binary Boxity where + get bh = do + h <- getByte bh + case h of + 0 -> return Boxity + _ -> return Boxity + +instance Binary TupCon where + get bh = do + (ab :: Boxity) <- get bh + (ac :: Arity) <- get bh + return TupCon + +instance Binary RecFlag where + get bh = do + h <- getByte bh + case h of + 0 -> return RecFlag + _ -> return RecFlag + +instance Binary DefMeth where + get bh = do + h <- getByte bh + case h of + 0 -> return DefMeth + 1 -> return DefMeth + _ -> return DefMeth + +instance Binary FixityDirection where + get bh = do + h <- getByte bh + case h of + 0 -> return FixityDirection + 1 -> return FixityDirection + _ -> return FixityDirection + +instance Binary Fixity where + get bh = do + (aa :: Int) <- get bh + (ab :: FixityDirection) <- get bh + return Fixity + +instance (Binary name) => Binary (IPName name) where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: name) <- get bh ; return IPName + _ -> do (ab :: name) <- get bh ; return IPName + +------------------------------------------------------------------------- +-- Types from: basicTypes/NewDemand +------------------------------------------------------------------------- + +instance Binary DmdType where + -- Ignore DmdEnv when spitting out the DmdType + get bh = do (ds :: [Demand]) <- get bh + (dr :: DmdResult) <- get bh + return DmdType + +instance Binary Demand where + get bh = do + h <- getByte bh + case h of + 0 -> return Demand + 1 -> return Demand + 2 -> do (aa :: Demand) <- get bh ; return Demand + 3 -> do (ab :: Demands) <- get bh ; return Demand + 4 -> do (ac :: Demands) <- get bh ; return Demand + 5 -> do (ad :: Demand) <- get bh ; return Demand + _ -> return Demand + +instance Binary Demands where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: Demand) <- get bh + return Demands + _ -> do (ab :: [Demand]) <- get bh + return Demands + +instance Binary DmdResult where + get bh = do + h <- getByte bh + case h of + 0 -> return DmdResult + 1 -> return DmdResult + _ -> return DmdResult + +instance Binary StrictSig where + get bh = do (aa :: DmdType) <- get bh ; return StrictSig +-} + +------------------------------------------------------------------------- +-- Types from: CostCentre, from profiling/CostCentre.lhs +------------------------------------------------------------------------- + +{- +instance Binary IsCafCC where + get bh = do + h <- getByte bh + case h of + 0 -> return IsCafCC + _ -> return IsCafCC + +instance Binary IsDupdCC where + get bh = do + h <- getByte bh + case h of + 0 -> return IsDupdCC + _ -> return IsDupdCC + +instance Binary CostCentre where + get bh = do + h <- getByte bh + case h of + 0 -> do return CostCentre + 1 -> do (aa :: CcName) <- get bh + (ab :: ModuleName) <- get bh + (ac :: IsDupdCC) <- get bh + (ad :: IsCafCC) <- get bh + return CostCentre + _ -> do (ae :: ModuleName) <- get bh + return CostCentre +-} + +------------------------------------------------------------------------- +-- IfaceTypes and friends, from IfaceType.lhs +------------------------------------------------------------------------- + +{- +instance Binary IfaceExtName where + get bh = do + h <- getByte bh + case h of + 0 -> do (mod :: ModuleName) <- get bh + (occ :: OccName) <- get bh + return IfaceExtName + 1 -> do (mod :: ModuleName) <- get bh + (occ :: OccName) <- get bh + (vers :: Version) <- get bh + return IfaceExtName + _ -> do (occ :: OccName) <- get bh + return IfaceExtName + +instance Binary IfaceBndr where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: IfaceIdBndr) <- get bh ; return IfaceBndr + _ -> do (ab :: IfaceTvBndr) <- get bh ; return IfaceBndr + +instance Binary Kind where + get bh = do + h <- getByte bh + case h of + 0 -> return Kind + 1 -> return Kind + 2 -> return Kind + 3 -> return Kind + 4 -> return Kind + _ -> do (k1 :: Kind) <- get bh + (k2 :: Kind) <- get bh + return Kind + +instance Binary IfaceType where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: IfaceTvBndr) <- get bh + (ab :: IfaceType) <- get bh + return IfaceType + 1 -> do (ad :: OccName) <- get bh + return IfaceType + 2 -> do (ae :: IfaceType) <- get bh + (af :: IfaceType) <- get bh + return IfaceType + 3 -> do (ag :: IfaceType) <- get bh + (ah :: IfaceType) <- get bh + return IfaceType + 5 -> do (ap :: IfacePredType) <- get bh + return IfaceType + + -- Now the special cases for TyConApp + 6 -> return IfaceType + 7 -> return IfaceType + 8 -> return IfaceType + 9 -> do (ty :: IfaceType) <- get bh + return IfaceType + 10 -> return IfaceType + 11 -> do (t1 :: IfaceType) <- get bh + (t2 :: IfaceType) <- get bh + return IfaceType + 12 -> do (tc :: IfaceExtName) <- get bh + (tys :: [IfaceType]) <- get bh + return IfaceType + _ -> do (tc :: IfaceTyCon) <- get bh + (tys :: [IfaceType]) <- get bh + return IfaceType + +instance Binary IfaceTyCon where + get bh = do + h <- getByte bh + case h of + 1 -> return IfaceTyCon + 2 -> return IfaceTyCon + _ -> do (bx :: Boxity) <- get bh + (ar :: Arity) <- get bh + return IfaceTyCon + +instance Binary IfacePredType where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: IfaceExtName) <- get bh + (ab :: [IfaceType]) <- get bh + return IfacePredType + _ -> do (ac :: (IPName OccName)) <- get bh + (ad :: IfaceType) <- get bh + return IfacePredType + +instance Binary IfaceExpr where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: OccName) <- get bh + return IfaceExpr + 1 -> do (ab :: IfaceType) <- get bh + return IfaceExpr + 2 -> do (ac :: Boxity) <- get bh + (ad :: [IfaceExpr]) <- get bh + return IfaceExpr + 3 -> do (ae :: IfaceBndr) <- get bh + (af :: IfaceExpr) <- get bh + return IfaceExpr + 4 -> do (ag :: IfaceExpr) <- get bh + (ah :: IfaceExpr) <- get bh + return IfaceExpr + 5 -> do (ai :: IfaceExpr) <- get bh + (aj :: OccName) <- get bh + (ak :: [IfaceAlt]) <- get bh + return IfaceExpr + 6 -> do (al :: IfaceBinding) <- get bh + (am :: IfaceExpr) <- get bh + return IfaceExpr + 7 -> do (an :: IfaceNote) <- get bh + (ao :: IfaceExpr) <- get bh + return IfaceExpr + 8 -> do (ap :: Literal) <- get bh + return IfaceExpr + 9 -> do (as :: ForeignCall) <- get bh + (at :: IfaceType) <- get bh + return IfaceExpr + _ -> do (aa :: IfaceExtName) <- get bh + return IfaceExpr + +instance Binary IfaceConAlt where + get bh = do + h <- getByte bh + case h of + 0 -> return IfaceConAlt + 1 -> do (aa :: OccName) <- get bh + return IfaceConAlt + 2 -> do (ab :: Boxity) <- get bh + return IfaceConAlt + _ -> do (ac :: Literal) <- get bh + return IfaceConAlt + +instance Binary IfaceBinding where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: IfaceIdBndr) <- get bh + (ab :: IfaceExpr) <- get bh + return IfaceBinding + _ -> do (ac :: [(IfaceIdBndr,IfaceExpr)]) <- get bh + return IfaceBinding + +instance Binary IfaceIdInfo where + get bh = do + h <- getByte bh + case h of + 0 -> return IfaceIdInfo + _ -> do (info :: [IfaceInfoItem]) <- lazyGet bh + return IfaceIdInfo + +instance Binary IfaceInfoItem where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: Arity) <- get bh + return IfaceInfoItem + 1 -> do (ab :: StrictSig) <- get bh + return IfaceInfoItem + 2 -> do (ac :: Activation) <- get bh + (ad :: IfaceExpr) <- get bh + return IfaceInfoItem + 3 -> return IfaceInfoItem + _ -> do (ae :: IfaceExtName) <- get bh + (af :: Arity) <- get bh + return IfaceInfoItem + +instance Binary IfaceNote where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: CostCentre) <- get bh + return IfaceNote + 1 -> do (ab :: IfaceType ) <- get bh + return IfaceNote + 2 -> return IfaceNote + 3 -> return IfaceNote + _ -> do (ac :: String) <- get bh + return IfaceNote + +instance Binary IfaceDecl where + get bh = do + h <- getByte bh + case h of + 0 -> do + (name :: OccName) <- get bh + (ty :: IfaceType) <- get bh + (idinfo :: IfaceIdInfo) <- get bh + return IfaceDecl + 1 -> error "Binary.get(TyClDecl): ForeignType" + 2 -> do + (a1 :: IfaceContext) <- get bh + (a2 :: OccName) <- get bh + (a3 :: [IfaceTvBndr]) <- get bh + (a4 :: IfaceConDecls) <- get bh + (a5 :: RecFlag) <- get bh + (a6 :: ArgVrcs) <- get bh + (a7 :: Bool) <- get bh + return IfaceDecl + 3 -> do + (aq :: OccName) <- get bh + (ar :: [IfaceTvBndr]) <- get bh + (as :: ArgVrcs) <- get bh + (at :: IfaceType) <- get bh + return IfaceDecl + _ -> do + (a1 :: IfaceContext) <- get bh + (a2 :: OccName) <- get bh + (a3 :: [IfaceTvBndr]) <- get bh + (a4 :: [FunDep OccName])<- get bh + (a5 :: [IfaceClassOp]) <- get bh + (a6 :: RecFlag) <- get bh + (a7 :: ArgVrcs) <- get bh + return IfaceDecl + +instance Binary IfaceInst where + get bh = do + (ty :: IfaceType) <- get bh + (dfun :: OccName) <- get bh + return IfaceInst + +instance Binary IfaceConDecls where + get bh = do + h <- getByte bh + case h of + 0 -> return IfaceConDecls + 1 -> do (aa :: [IfaceConDecl]) <- get bh + return IfaceConDecls + _ -> do (aa :: IfaceConDecl) <- get bh + return IfaceConDecls + +instance Binary IfaceConDecl where + get bh = do + (a1 :: OccName) <- get bh + (a2 :: [IfaceTvBndr]) <- get bh + (a3 :: IfaceContext) <- get bh + (a4 :: [IfaceType]) <- get bh + (a5 :: [StrictnessMark])<- get bh + (a6 :: [OccName]) <- get bh + return IfaceConDecl + +instance Binary IfaceClassOp where + get bh = do + (n :: OccName) <- get bh + (def :: DefMeth) <- get bh + (ty :: IfaceType) <- get bh + return IfaceClassOp + +instance Binary IfaceRule where + get bh = do + (a1 :: RuleName) <- get bh + (a2 :: Activation) <- get bh + (a3 :: [IfaceBndr]) <- get bh + (a4 :: IfaceExtName) <- get bh + (a5 :: [IfaceExpr]) <- get bh + (a6 :: IfaceExpr) <- get bh + return IfaceRule + +-} + +------------------------------------------------------------------------ +-- from Literal +------------------------------------------------------------------------ + +{- +instance Binary Literal where + get bh = do + h <- getByte bh + case h of + 0 -> do + (aa :: Char) <- get bh + return Literal + 1 -> do + (ab :: FastString) <- get bh + return Literal + 2 -> do return Literal + 3 -> do + (ad :: Integer) <- get bh + return Literal + 4 -> do + (ae :: Integer) <- get bh + return Literal + 5 -> do + (af :: Integer) <- get bh + return Literal + 6 -> do + (ag :: Integer) <- get bh + return Literal + 7 -> do + (ah :: Rational) <- get bh + return Literal + 8 -> do + (ai :: Rational) <- get bh + return Literal + 9 -> do + (aj :: FastString) <- get bh + (mb :: Maybe Int) <- get bh + return Literal + _ -> return Literal -- ? + +-} + +------------------------------------------------------------------------ +-- prelude/ForeignCall.lhs +------------------------------------------------------------------------ + +{- +instance Binary ForeignCall where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: CCallSpec) <- get bh + return ForeignCall + _ -> do (ab :: DNCallSpec) <- get bh + return ForeignCall + +instance Binary Safety where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: Bool) <- get bh + return Safety + _ -> return Safety + +instance Binary CExportSpec where + get bh = do + (aa :: CLabelString) <- get bh + (ab :: CCallConv) <- get bh + return CExportSpec + +instance Binary CCallSpec where + get bh = do + (aa :: CCallTarget) <- get bh + (ab :: CCallConv) <- get bh + (ac :: Safety) <- get bh + return CCallSpec + +instance Binary CCallTarget where + get bh = do + h <- getByte bh + case h of + 0 -> do (aa :: CLabelString) <- get bh + return CCallTarget + _ -> return CCallTarget + +instance Binary CCallConv where + get bh = do + h <- getByte bh + case h of + 0 -> return CCallConv + _ -> return CCallConv + +instance Binary DNCallSpec where + get bh = do + (isStatic :: Bool) <- get bh + (kind :: DNKind) <- get bh + (ass :: String) <- get bh + (nm :: String) <- get bh + return DNCallSpec + +instance Binary DNKind where + get bh = do + h <- getByte bh + case h of + _ -> return DNKind + +instance Binary DNType where + get bh = do + h <- getByte bh + case h of + _ -> return DNType + +-} hunk ./src/hi/Hi/PrimPacked.hs 1 +{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS -fno-warn-name-shadowing -fno-warn-unused-matches #-} + +{-# OPTIONS -#include "hschooks.h" #-} + +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- +-- Based on $fptools/ghc/compiler/utils/PrimPacked.lhs +-- +-- (c) The GRASP/AQUA Project, Glasgow University, 1997-1998 +-- +-- +-- Basic ops on packed representations +-- +-- Some basic operations for working on packed representations of series +-- of bytes (character strings). Used by the interface lexer input +-- subsystem, mostly. + +{-# OPTIONS -optc-DNON_POSIX_SOURCE #-} + +module Hi.PrimPacked ( + Ptr(..), nullPtr, plusAddr#, + BA(..), + packString, -- :: String -> (Int, BA) + unpackNBytesBA, -- :: BA -> Int -> [Char] + strLength, -- :: Ptr CChar -> Int + copyPrefixStr, -- :: Addr# -> Int -> BA + copySubStrBA, -- :: BA -> Int -> Int -> BA + eqStrPrefix, -- :: Addr# -> ByteArray# -> Int# -> Bool + eqStrPrefixBA, -- :: ByteArray# -> ByteArray# -> Int# -> Int# -> Bool + ) where + +import Foreign +import GHC.Exts +import GHC.ST + +-- Wrapper types for bytearrays + +data BA = BA ByteArray# +data MBA s = MBA (MutableByteArray# s) + +packString :: String -> (Int, BA) +packString str = (l, arr) + where + l@(I# length#) = length str + + arr = runST (do + ch_array <- new_ps_array length# + -- fill in packed string from "str" + fill_in ch_array 0# str + -- freeze the puppy: + freeze_ps_array ch_array length# + ) + + fill_in :: MBA s -> Int# -> [Char] -> ST s () + fill_in arr_in# idx [] = + return () + fill_in arr_in# idx (C# c : cs) = + write_ps_array arr_in# idx c >> + fill_in arr_in# (idx +# 1#) cs + +-- Unpacking a string + +unpackNBytesBA :: BA -> Int -> [Char] +unpackNBytesBA (BA bytes) (I# len) + = unpack 0# + where + unpack nh + | nh >=# len = [] + | otherwise = C# ch : unpack (nh +# 1#) + where + ch = indexCharArray# bytes nh + +-- Copying a char string prefix into a byte array. + +copyPrefixStr :: Addr# -> Int -> BA +copyPrefixStr a# len@(I# length#) = copy' length# + where + copy' length# = runST (do + {- allocate an array that will hold the string + -} + ch_array <- new_ps_array length# + {- Revert back to Haskell-only solution for the moment. + _ccall_ memcpy ch_array (A# a) len >>= \ () -> + write_ps_array ch_array length# (chr# 0#) >> + -} + -- fill in packed string from "addr" + fill_in ch_array 0# + -- freeze the puppy: + freeze_ps_array ch_array length# + ) + + fill_in :: MBA s -> Int# -> ST s () + fill_in arr_in# idx + | idx ==# length# + = return () + | otherwise + = case (indexCharOffAddr# a# idx) of { ch -> + write_ps_array arr_in# idx ch >> + fill_in arr_in# (idx +# 1#) } + +-- Copying out a substring, assume a 0-indexed string: +-- (and positive lengths, thank you). + +copySubStrBA :: BA -> Int -> Int -> BA +copySubStrBA (BA barr#) (I# start#) len@(I# length#) = ba + where + ba = runST (do + -- allocate an array that will hold the string + ch_array <- new_ps_array length# + -- fill in packed string from "addr" + fill_in ch_array 0# + -- freeze the puppy: + freeze_ps_array ch_array length# + ) + + fill_in :: MBA s -> Int# -> ST s () + fill_in arr_in# idx + | idx ==# length# + = return () + | otherwise + = case (indexCharArray# barr# (start# +# idx)) of { ch -> + write_ps_array arr_in# idx ch >> + fill_in arr_in# (idx +# 1#) } + +-- (Very :-) ``Specialised'' versions of some CharArray things... +-- [Copied from PackBase; no real reason -- UGH] + +new_ps_array :: Int# -> ST s (MBA s) +write_ps_array :: MBA s -> Int# -> Char# -> ST s () +freeze_ps_array :: MBA s -> Int# -> ST s BA + +#if __GLASGOW_HASKELL__ < 411 +#define NEW_BYTE_ARRAY newCharArray# +#else +#define NEW_BYTE_ARRAY newByteArray# +#endif + +new_ps_array size = ST $ \ s -> + case (NEW_BYTE_ARRAY size s) of { (# s2#, barr# #) -> + (# s2#, MBA barr# #) } + +write_ps_array (MBA barr#) n ch = ST $ \ s# -> + case writeCharArray# barr# n ch s# of { s2# -> + (# s2#, () #) } + +-- same as unsafeFreezeByteArray +freeze_ps_array (MBA arr#) len# = ST $ \ s# -> + case unsafeFreezeByteArray# arr# s# of { (# s2#, frozen# #) -> + (# s2#, BA frozen# #) } + +-- Compare two equal-length strings for equality: + +eqStrPrefix :: Addr# -> ByteArray# -> Int# -> Bool +eqStrPrefix a# barr# len# = + unsafePerformIO $ do + x <- memcmp_ba a# barr# (I# len#) + return (x == 0) + +eqStrPrefixBA :: ByteArray# -> ByteArray# -> Int# -> Int# -> Bool +eqStrPrefixBA b1# b2# start# len# = + unsafePerformIO $ do + x <- memcmp_baoff_ba b2# (I# start#) b1# (I# len#) + return (x == 0) + +------------------------------------------------------------------------ +-- in hschooks +-- + +foreign import ccall unsafe "plugin_strlen" + strLength :: Ptr () -> Int + +foreign import ccall unsafe "plugin_memcmp" + memcmp_ba :: Addr# -> ByteArray# -> Int -> IO Int + +foreign import ccall unsafe "plugin_memcmp_off" + memcmp_baoff_ba :: ByteArray# -> Int -> ByteArray# -> Int -> IO Int + hunk ./src/hi/Hi/Syntax.hs 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- +-- Based on code from $fptools/ghc/compiler/main/HscTypes.lhs +-- (c) The University of Glasgow 2002 +-- + +module Hi.Syntax where + +import Hi.FastString + +import Data.List ( intersperse ) + +-- --------------------------------------------------------------------- +-- An Iface, the representation of an .hi file. +-- +-- The abstract syntax that we don't need is blanked with a default +-- type, however we must be careful in BinIface to still parse the +-- correct number of bytes for each data type. This involves leaving the +-- code alone, other than to add the types of the sub-constructors of +-- the types we have blanked out (because they can't be inferred +-- anymore). +-- + +data Iface = Iface { + mi_package :: String, -- what package is this? + mi_module :: String, -- what module is this? + mi_deps :: Dependencies, + mi_usages :: [Usage], + mi_exports :: [IfaceExport] {-,-} + +-- mi_decls :: [(Version,IfaceDecl)] {-,-} + +-- mi_mod_vers :: !Version, +-- mi_orphan :: !Bool, +-- mi_boot :: !Bool, +-- mi_exp_vers :: !Version, +-- mi_fixities :: [(OccName,Fixity)], +-- mi_deprecs :: [IfaceDeprec], +-- mi_insts :: [IfaceInst], +-- mi_rules :: [IfaceRule], +-- mi_rule_vers :: !Version, + } + +emptyIface = Iface { + mi_package = undefined, + mi_module = undefined, + mi_deps = noDependencies, + mi_usages = undefined, + mi_exports = undefined + } + +-- --------------------------------------------------------------------- +-- pretty-print an interface +-- +showIface :: Iface -> String +showIface (Iface { mi_package = p, mi_module = m, + mi_deps = deps, mi_usages = us }) = + "interface \"" ++ p ++ "\" " ++ m ++ + "\n" ++ pprDeps deps ++ + "\n" ++ (concat $ intersperse "\n" (map pprUsage us)) + -- "\n" ++ (concat $ intersperse "\n" (map pprExport es)) + +pprDeps :: Dependencies -> String +pprDeps (Deps { dep_mods = mods, dep_pkgs = pkgs }) + = "module dependencies: " ++ (concat $ intersperse ", " mods) ++ + "\npackage dependencies: " ++ (concat $ intersperse ", " pkgs) + +pprUsage :: Usage -> String +pprUsage usage = hsep ["import", usg_name usage] + +pprExport :: IfaceExport -> String +pprExport (fsmod, items) + = hsep [ "export", unpackFS fsmod, hsep (map pp_avail items) ] + where + pp_avail :: GenAvailInfo OccName -> String + pp_avail (Avail nm) = ppr_occ nm + pp_avail (AvailTC _ []) = empty + pp_avail (AvailTC n (n':ns)) + | n==n' = (ppr_occ n) ++ pp_export ns + | otherwise = (ppr_occ n) ++ "|" ++ pp_export (n':ns) + + pp_export [] = empty + pp_export names = "{" ++ (hsep (map ppr_occ names)) ++ "}" + + ppr_occ (OccName _ s) = s + +-- +-- TODO bring in the Pretty library +-- +hsep = \ss -> concat (intersperse " " ss) +empty = "" + +-- --------------------------------------------------------------------- +-- +-- Dependency info about modules and packages below this one +-- in the import hierarchy. See TcRnTypes.ImportAvails for details. +-- +-- Invariant: the dependencies of a module M never includes M +-- Invariant: the lists are unordered, with no duplicates +-- +-- The fields are: +-- Home-package module dependencies +-- External package dependencies +-- Orphan modules (whether home or external pkg) + +data Dependencies = Deps { + dep_mods :: [ModuleName], + dep_pkgs :: [PackageName] {-,-} + } deriving (Show) + +noDependencies :: Dependencies +noDependencies = Deps [] [] + +-- +-- Type aliases need to have a real type so the parser can work out how +-- to parse them. You have to find what these are by reading GHC. +-- +type ModuleName = String {- was FastString -} -- Module +type PackageName = String {- was FastString -} -- Packages +type Version = Int -- BasicTypes +type EncodedFS = FastString -- FastString +type IfaceExport = (EncodedFS, [GenAvailInfo OccName]) -- HscTypes + +data GenAvailInfo name + = Avail name -- An ordinary identifier + | AvailTC name -- The name of the type or class + [name] -- The available pieces of type/class. + -- NB: If the type or class is itself + -- to be in scope, it must be in this list. + -- Thus, typically: AvailTC Eq [Eq, ==, /=] + deriving Show + +data OccName = OccName NameSpace String {- was EncodedFS -} + deriving Show + +instance Eq OccName where + (OccName sp1 s1) == (OccName sp2 s2) = s1 == s2 && sp1 == sp2 + +data NameSpace = VarName -- variables, and "source" data constructors + | DataName -- "real" data constructors + | TvName -- tyvars + | TcClsName -- type constructors and classes + deriving (Eq, Show) + +data Usage + = Usage { usg_name :: ModuleName, -- Name of the module + usg_mod :: Version, -- Module version + usg_exports :: Maybe Version, -- Export-list version, if we depend on it + usg_entities :: [(OccName,Version)],-- Sorted by occurrence name + usg_rules :: Version -- Orphan-rules version (for non-orphan + -- modules this will always be initialVersion) + } deriving Show + +------------------------------------------------------------------------ +-- TODO parsing type and decl information out of the .hi file +-- complex data structure... +-- + +{- +data IfaceExtName + = ExtPkg ModuleName OccName -- From an external package; no version # + -- Also used for wired-in things regardless + -- of whether they are home-pkg or not + + | HomePkg ModuleName OccName Version -- From another module in home package; + -- has version # + + | LocalTop OccName -- Top-level from the same module as + -- the enclosing IfaceDecl + + | LocalTopSub -- Same as LocalTop, but for a class method or constr + OccName -- Class-meth/constr name + OccName -- Parent class/datatype name + -- LocalTopSub is written into iface files as LocalTop; the parent + -- info is only used when computing version information in MkIface + +data IfaceTyCon -- Abbreviations for common tycons with known names + = IfaceTc IfaceExtName -- The common case + | IfaceIntTc | IfaceBoolTc | IfaceCharTc + | IfaceListTc | IfacePArrTc + | IfaceTupTc Boxity Arity + +type Arity = Int -- BasicTypes + +data Boxity + = Boxed + | Unboxed + +type IfaceContext = [IfacePredType] + +data IfacePredType -- NewTypes are handled as ordinary TyConApps + = IfaceClassP IfaceExtName [IfaceType] + | IfaceIParam (IPName OccName) IfaceType + +data IPName name + = Dupable name -- ?x: you can freely duplicate this implicit parameter + | Linear name -- %x: you must use the splitting function to duplicate it + deriving( Eq, Ord ) -- Ord is used in the IP name cache finite map + -- (used in HscTypes.OrigIParamCache) + +data IfaceType + = IfaceTyVar OccName -- Type variable only, not tycon + | IfaceAppTy IfaceType IfaceType + | IfaceForAllTy IfaceTvBndr IfaceType + | IfacePredTy IfacePredType + | IfaceTyConApp IfaceTyCon [IfaceType] -- Not necessarily saturated + -- Includes newtypes, synonyms, tuples + | IfaceFunTy IfaceType IfaceType + +data IfaceBndr -- Local (non-top-level) binders + = IfaceIdBndr IfaceIdBndr + | IfaceTvBndr IfaceTvBndr + +type IfaceIdBndr = (OccName, IfaceType) -- OccName, because always local +type IfaceTvBndr = (OccName, IfaceKind) +type IfaceKind = Kind -- Re-use the Kind type, but no KindVars in it + +data IfaceIdInfo + = NoInfo -- When writing interface file without -O + | HasInfo [IfaceInfoItem] -- Has info, and here it is + +data IfaceInfoItem + = HsArity Arity + | HsStrictness StrictSig + | HsUnfold Activation IfaceExpr + | HsNoCafRefs + | HsWorker IfaceExtName Arity -- Worker, if any see IdInfo.WorkerInfo + -- for why we want arity here. + -- NB: we need IfaceExtName (not just OccName) because the worker + -- can simplify to a function in another module. +-- NB: Specialisations and rules come in separately and are +-- only later attached to the Id. Partial reason: some are orphans. + +newtype StrictSig = StrictSig DmdType + +data IfaceDecl + = IfaceId { ifName :: OccName, + ifType :: IfaceType, + ifIdInfo :: IfaceIdInfo } + + | IfaceData { ifCtxt :: IfaceContext, -- Context + ifName :: OccName, -- Type constructor + ifTyVars :: [IfaceTvBndr], -- Type variables + ifCons :: IfaceConDecls, -- Includes new/data info + ifRec :: RecFlag, -- Recursive or not? + ifVrcs :: ArgVrcs, + ifGeneric :: Bool -- True <=> generic converter functions available + } -- We need this for imported data decls, since the + -- imported modules may have been compiled with + -- different flags to the current compilation unit + + | IfaceSyn { ifName :: OccName, -- Type constructor + ifTyVars :: [IfaceTvBndr], -- Type variables + ifVrcs :: ArgVrcs, + ifSynRhs :: IfaceType -- synonym expansion + } + + | IfaceClass { ifCtxt :: IfaceContext, -- Context... + ifName :: OccName, -- Name of the class + ifTyVars :: [IfaceTvBndr], -- Type variables + ifFDs :: [FunDep OccName], -- Functional dependencies + ifSigs :: [IfaceClassOp], -- Method signatures + ifRec :: RecFlag, -- Is newtype/datatype associated with the class recursive? + ifVrcs :: ArgVrcs -- ... and what are its argument variances ... + } + + | IfaceForeign { ifName :: OccName, -- Needs expanding when we move beyond .NET + ifExtName :: Maybe FastString } +-} + +------------------------------------------------------------------------ +-- +-- all this stuff may be enabled if we ever want other information out +-- + +{- +type ArgVrcs = [(Bool,Bool)] -- TyCon +type CLabelString = FastString -- CStrings +type CcName = EncodedFS -- CostCentre +type DeprecTxt = FastString -- BasicTypes +type FunDep a = ([a],[a]) -- Class +type IfaceAlt = (IfaceConAlt,[OccName],IfaceExpr) -- IfaceSyn +type IfaceContext = [IfacePredType] -- IfaceType +type IfaceDeprec = Deprecs [(OccName,DeprecTxt)] -- HscTypes +type IfaceIdBndr = (OccName, IfaceType) -- IfaceType +type IfaceKind = Kind -- IfaceType +type IfaceTvBndr = (OccName, IfaceKind) -- IfaceType +type RuleName = FastString -- CoreSyn + +-- +-- Empty definitions for the various types we need, but whose results we +-- don't care about. +-- +-- 'data' types that have a parsing method associated with them +-- This list corresponds to each instance in BinIface +-- +-- Try to keep this list ordered by the order they appear in BinIface +-- +data Deprecs a = Deprecs +data Activation = Activation +data StrictnessMark = StrictnessMark +data Boxity = Boxity +data TupCon = TupCon +data RecFlag = RecFlag +data DefMeth = DefMeth +data FixityDirection = FixityDirection +data Fixity = Fixity +data DmdType = DmdType +data Demand = Demand +data Demands = Demands +data DmdResult = DmdResult +data StrictSig = StrictSig +data IsCafCC = IsCafCC +data IsDupdCC = IsDupdCC +data CostCentre = CostCentre +data IfaceExtName = IfaceExtName +data IfaceBndr = IfaceBndr +data Kind = Kind +data IfaceTyCon = IfaceTyCon +data IfacePredType = IfacePredType +data IfaceExpr = IfaceExpr +data IfaceConAlt = IfaceConAlt +data IfaceBinding = IfaceBinding +data IfaceIdInfo = IfaceIdInfo +data IfaceNoteItem = IfaceNoteItem +data IfaceInfoItem = IfaceInfoItem +data IfaceNote = IfaceNote +data IfaceInst = IfaceInst +data IfaceConDecls = IfaceConDecls +data IfaceConDecl = IfaceConDecl +data IfaceClassOp = IfaceClassOp +data IfaceRule = IfaceRule +data Literal = Literal +data ForeignCall = ForeignCall +data Safety = Safety +data CExportSpec = CExportSpec +data CCallSpec = CCallSpec +data CCallTarget = CCallTarget +data CCallConv = CCallConv +data DNCallSpec = DNCallSpec +data DNKind = DNKind +data DNType = DNType + +-} hunk ./src/hi/Hi/hschooks.c 1 +/* +These routines customise the error messages +for various bits of the RTS. They are linked +in instead of the defaults. +*/ + +#include + +/* For GHC 4.08, we are relying on the fact that RtsFlags has + * compatibile layout with the current version, because we're + * #including the current version of RtsFlags.h below. 4.08 didn't + * ship with its own RtsFlags.h, unfortunately. For later GHC + * versions, we #include the correct RtsFlags.h. + */ + +#include "Rts.h" +#include "RtsFlags.h" + +#include "HsFFI.h" + +HsInt +plugin_strlen( HsAddr a ) +{ + return (strlen((char *)a)); +} + +HsInt +plugin_memcmp( HsAddr a1, HsAddr a2, HsInt len ) +{ + return (memcmp((char *)a1, a2, len)); +} + +HsInt +plugin_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len ) +{ + return (memcmp((char *)a1 + i, a2, len)); +} + hunk ./src/hi/Hi/hschooks.h 1 +/* ----------------------------------------------------------------------------- + * $ Id: hschooks.h,v 1.1.1.1 2004/05/24 09:35:39 dons Exp $ + * + * Hooks into the RTS from the compiler. + * + * -------------------------------------------------------------------------- */ + +#include "HsFFI.h" + +// Out-of-line string functions, see PrimPacked.lhs +HsInt plugin_strlen( HsAddr a ); +HsInt plugin_memcmp( HsAddr a1, HsAddr a2, HsInt len ); +HsInt plugin_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len ); hunk ./src/hi/Hi.hs 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Hi ( + module Hi.Parser + ) where + +import Hi.Parser {-all-} + hunk ./src/hi/Makefile 1 +PKG = hi +UPKG = Hi + +CSRC = $(UPKG)/hschooks.c +COBJ = $(UPKG)/hschooks.o + +TOP=../.. +include ../build.mk + +HC_OPTS += -I$(UPKG) + +install: install-me hunk ./src/hi/hi.conf.in.cpp 1 +#if CABAL == 0 && GLASGOW_HASKELL < 604 +Package { + name = "hi", + auto = False, + hs_libraries = [ "HShi" ], +#ifdef INSTALLING + import_dirs = [ "${LIBDIR}/imports" ], + library_dirs = [ "${LIBDIR}/" ], +#else + import_dirs = [ "${TOP}/src/hi" ], + library_dirs = [ "${TOP}/src/hi" ], +#endif + include_dirs = [], + c_includes = [], + source_dirs = [], + extra_libraries = [], + package_deps = [ "base", "haskell98" ], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [] +} +#else +name: hi +version: 1.0 +license: BSD3 +maintainer: libraries@haskell.org +exposed: True +exposed-modules: + Hi.Binary, + Hi.FastMutInt, + Hi.FastString, + Hi.Parser, + Hi.PrimPacked, + Hi.Syntax, + Hi + +hidden-modules: +#ifdef INSTALLING +import-dirs: LIBDIR/imports +library-dirs: LIBDIR +#else +import-dirs: TOP/src/hi +library-dirs: TOP/src/hi +#endif +hs-libraries: HShi +extra-libraries: +include-dirs: +includes: +depends: base, haskell98 +hugs-options: +cc-options: +ld-options: +framework-dirs: +frameworks: +haddock-interfaces: +haddock-html: +#endif hunk ./src/plugins/Makefile 1 +PKG = plugins +UPKG = Plugins + +TOP=../.. +include $(TOP)/config.mk + +ifeq ($(CABAL),1) +YOBJ = $(UPKG)/ParsePkgConfCabal.hs +YSRC = $(UPKG)/ParsePkgConfCabal.y +else +YOBJ = $(UPKG)/ParsePkgConfLite.hs +YSRC = $(UPKG)/ParsePkgConfLite.y +endif + +include ../build.mk + +HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace +HC_OPTS += -package altdata -package hi -package posix +HC_OPTS += -O -funbox-strict-fields +HC_OPTS += -Wall -fno-warn-missing-signatures + +install: install-me hunk ./src/plugins/Plugins/Consts.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Plugins.Consts where + +#include "../../../config.h" + +-- | path to *build* dir, used by eval() for testing the examples +top = TOP + +-- | what is ghc called? +ghc = GHC + +-- | path to standard ghc libraries +ghcLibraryPath = GHC_LIB_PATH + +-- | name of the system package.conf file +sysPkgConf = "package.conf" + +-- | This code is from runtime_loader: +-- The extension used by system modules. +sysPkgSuffix = ".o" +objSuf = sysPkgSuffix +hiSuf = ".hi" +hsSuf = ".hs" + +-- | The prefix used by system modules. This, in conjunction with +-- 'systemModuleExtension', will result in a module filename that looks +-- like \"HSconcurrent.o\" +sysPkgPrefix = "HS" + +-- | '_' on a.out, and Darwin +#if LEADING_UNDERSCORE == 1 +prefixUnderscore = "_" +#else +prefixUnderscore = "" +#endif + +-- | Define tmpDir to where tmp files should be created on your platform +#if !defined(__MINGW32__) +tmpDir = "/tmp" +#else +tmpDir = error "tmpDir not defined for this platform. Try setting the TMPDIR env var" +#endif + hunk ./src/plugins/Plugins/Env.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Plugins.Env ( + withModEnv, + withPkgEnvs, + withMerged, + modifyModEnv, + modifyPkgEnv, + modifyMerged, + addModule, + rmModule, + addModules, + isLoaded, + loaded, + isMerged, + lookupMerged, + addMerge, + addPkgConf, + union, + grabDefaultPkgConf, + readPackageConf, + lookupPkg + + ) where + +#include "../../../config.h" + +import Plugins.PackageAPI {- everything -} +#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 +import Plugins.ParsePkgConfCabal( parsePkgConf ) +#else +import Plugins.ParsePkgConfLite ( parsePkgConf ) +#endif +import Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix ) + +import Data.IORef ( writeIORef, readIORef, newIORef, IORef() ) +import Data.Maybe ( isJust ) +import Data.List ( isPrefixOf, nub ) + +import System.IO.Unsafe ( unsafePerformIO ) +import System.Directory ( doesFileExist ) + +import Control.Concurrent.MVar ( MVar(), newMVar, withMVar ) + +#if __GLASGOW_HASKELL__ < 604 +import Data.FiniteMap + +#else +import qualified Data.Map as M + +-- +-- and map Data.Map terms to FiniteMap terms +-- +type FiniteMap k e = M.Map k e + +emptyFM :: FiniteMap key elt +emptyFM = M.empty + +addToFM :: (Ord key) => FiniteMap key elt -> key -> elt -> FiniteMap key elt +addToFM = \m k e -> M.insert k e m + +delFromFM :: (Ord key) => FiniteMap key elt -> key -> FiniteMap key elt +delFromFM = flip M.delete + +lookupFM :: (Ord key) => FiniteMap key elt -> key -> Maybe elt +lookupFM = flip M.lookup + +#endif + +-- +-- We need to record what modules and packages we have loaded, so if we +-- read a .hi file that wants to load something already loaded, we can +-- safely ignore that request. We're in the IO monad anyway, so we can +-- add some extra state of our own. +-- +-- The state is a FiniteMap String Bool (a hash of package/object names +-- to whether they have been loaded or not). +-- +-- It also contains the package.conf information, so that if there is a +-- package dependency we can find it correctly, even if it has a +-- non-standard path or name, and if it isn't an official package (but +-- rather one provided via -package-conf). This is stored as a +-- FiniteMap PackageName PackageConfig. The problem then is whether a +-- user's package.conf, that uses the same package name as an existing +-- GHC package, should be allowed, or should shadow a library package? +-- I don't know, but I'm inclined to have the GHC package shadow the +-- user's package. +-- +-- This idea is based on *Hampus Ram's dynamic loader* dependency +-- tracking system. He uses state to record dependency trees to allow +-- clean unloading and other fun. This is quite cool. We're just using +-- state to make sure we don't load the same package twice. Implementing +-- the full dependency tree idea would be nice, though not fully +-- necessary as we have the dependency information store in .hi files, +-- unlike in hram's loader. +-- + +type ModEnv = FiniteMap String Bool + +-- represents a package.conf file +type PkgEnv = FiniteMap PackageName PackageConfig + +-- record dependencies between (src,stub) -> merged modid +type MergeEnv = FiniteMap (FilePath,FilePath) FilePath + +-- multiple package.conf's kept in separate namespaces +type PkgEnvs = [PkgEnv] + +type Env = (MVar (), + IORef ModEnv, + IORef PkgEnvs, + IORef MergeEnv) + +-- +-- our environment, contains a set of loaded objects, and a map of known +-- packages and their informations. Initially all we know is the default +-- package.conf information. +-- +env = unsafePerformIO $ do + mvar <- newMVar () + ref1 <- newIORef emptyFM -- loaded objects + p <- grabDefaultPkgConf + ref2 <- newIORef p -- package.conf info + ref3 <- newIORef emptyFM -- merged files + return (mvar, ref1, ref2, ref3) +{-# NOINLINE env #-} + +-- ----------------------------------------------------------- +-- +-- apply 'f' to the loaded objects Env +-- apply 'f' to the package.conf FM +-- *locks up the MVar* so you can't recursively call a function inside a +-- with*Env function. Nice and threadsafe +-- +withModEnv :: Env -> (ModEnv -> IO a) -> IO a +withPkgEnvs :: Env -> (PkgEnvs -> IO a) -> IO a +withMerged :: Env -> (MergeEnv -> IO a) -> IO a + +withModEnv (mvar,ref,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withPkgEnvs (mvar,_,ref,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withMerged (mvar,_,_,ref) f = withMVar mvar (\_ -> readIORef ref >>= f) + +-- ----------------------------------------------------------- +-- +-- write an object name +-- write a new PackageConfig +-- +modifyModEnv :: Env -> (ModEnv -> IO ModEnv) -> IO () +modifyPkgEnv :: Env -> (PkgEnvs -> IO PkgEnvs) -> IO () +modifyMerged :: Env -> (MergeEnv -> IO MergeEnv)-> IO () + +modifyModEnv (mvar,ref,_,_) f = lockAndWrite mvar ref f +modifyPkgEnv (mvar,_,ref,_) f = lockAndWrite mvar ref f +modifyMerged (mvar,_,_,ref) f = lockAndWrite mvar ref f + +-- private +lockAndWrite mvar ref f = withMVar mvar (\_->readIORef ref>>=f>>=writeIORef ref) + +-- ----------------------------------------------------------- +-- +-- insert a loaded module name into the environment +-- +addModule :: String -> IO () +addModule s = modifyModEnv env $ \fm -> return $ addToFM fm s True + +-- +-- remove a module name from the environment +-- +rmModule :: String -> IO () +rmModule s = modifyModEnv env $ \fm -> return $ delFromFM fm s + +-- +-- insert a list of module names all in one go +-- +addModules :: [String] -> IO () +addModules ns = modifyModEnv env $ \fm -> return $ unionL fm ns + where + unionL :: ModEnv -> [String] -> ModEnv + unionL fm ss = foldr (\s fm' -> addToFM fm' s True) fm ss + +-- +-- is a module/package already loaded? +-- +isLoaded :: String -> IO Bool +isLoaded s = withModEnv env $ \fm -> return $ isJust (lookupFM fm s) + +-- +-- confusing! only for filter. +-- +loaded :: String -> IO Bool +loaded m = do t <- isLoaded m ; return (not t) + +-- ----------------------------------------------------------- +-- Package management stuff +-- +-- insert a single package.conf (containing multiple configs) +-- means: create a new FM. insert packages into FM. add FM to end of +-- list of FM stored in the environment. +-- +addPkgConf :: FilePath -> IO () +addPkgConf f = do + ps <- readPackageConf f + modifyPkgEnv env $ \ls -> return $ union ls ps + +-- +-- add a new FM for the package.conf to the list of existing ones +-- +union :: PkgEnvs -> [PackageConfig] -> PkgEnvs +union ls ps' = + let fm = emptyFM -- new FM for this package.conf + in ls ++ [foldr (\p fm' -> addToFM fm' (packageName p) p) fm ps'] + +-- +-- generate a PkgEnv from the system package.conf +-- * the path to the default package.conf was determined by ./configure * +-- This imposes a constraint that you must build your plugins with the +-- same ghc you use to build hs-plugins. This is reasonable, we feel. +-- + +grabDefaultPkgConf :: IO PkgEnvs +grabDefaultPkgConf = do + pkgs <- readPackageConf $ ghcLibraryPath sysPkgConf + return $ union [] pkgs + +-- +-- parse a source file, expanding any $libdir we see. +-- +readPackageConf :: FilePath -> IO [PackageConfig] +readPackageConf f = do + s <- readFile f + let p = parsePkgConf s + return $! map expand_libdir p + + where + expand_libdir :: PackageConfig -> PackageConfig + expand_libdir pk = + let pk' = updImportDirs (\idirs -> map expand idirs) pk + pk'' = updLibraryDirs (\ldirs -> map expand ldirs) pk' + in pk'' + + expand :: FilePath -> FilePath + expand s | "$libdir" `isPrefixOf` s = ghcLibraryPath ++ drop 7 s + expand s = s + + +-- +-- Package path, given a package name, look it up in the environment and +-- return the path to all the libraries needed to load this package. +-- +-- What do we need to load? With the library_dirs as prefix paths: +-- * anything in the hs_libraries fields, $libdir expanded +-- * anything in the extra_libraries fields (i.e. cbits), expanded, +-- which includes system .so files. Ignore these for now +-- * also load any dependencies now, because of that weird mtl +-- library that lang depends upon, but which doesn't show up in the +-- interfaces for some reason. +-- +-- ToDo At present this does not handle extra_libraries correctly. It +-- only find those extra libraries that live in the directory specfied +-- by the library_dirs field of the package.conf entry. But +-- extra_libraries can contain any libraries supported by the system's +-- linker. For this library they must be, of course, be dynamic. The +-- extensions for such libraries are different on various platforms. +-- This would need to be checked for by configure.ac. (Scary - dons) +-- +-- We return all the package paths that possibly exist, and the leave it +-- up to loadObject not to load the same ones twice... +-- +lookupPkg :: PackageName -> IO [FilePath] +lookupPkg p = do + t <- lookupPkg' p + case t of ([],f) -> return f + (ps,f) -> do gss <- mapM lookupPkg ps + return $ nub $ (concat gss) ++ f + +-- +-- return any stuff to load for this package, plus the list of packages +-- this package depends on. which includes stuff we have to then load +-- too. +-- +lookupPkg' :: PackageName -> IO ([PackageName],[FilePath]) +lookupPkg' p = withPkgEnvs env $ \fms -> go fms p + where + go [] _ = return ([],[]) + go (fm:fms) q = case lookupFM fm q of + Nothing -> go fms q -- look in other pkgs + + Just package -> do + let libdirs = libraryDirs package + hslibs = hsLibraries package + extras = extraLibraries package + deppkgs = packageDeps package + libs <- mapM (findHSlib libdirs) (hslibs ++ extras) + + -- don't care if there are 'Nothings', that usually + -- means that they refer to system libraries. Can't do + -- anything about that. + return (deppkgs, filterJust libs ) + + -- a list elimination form for the Maybe type + filterJust :: [Maybe a] -> [a] + filterJust [] = [] + filterJust (Just x:xs) = x:filterJust xs + filterJust (Nothing:xs) = filterJust xs + + -- + -- Check that a path to a library actually reaches a library + -- Problem: sysPkgSuffix is ".o", but extra libraries could be + -- ".so" -- what to do? + -- + findHSlib :: [FilePath] -> String -> IO (Maybe FilePath) + findHSlib [] _ = return Nothing + findHSlib (dir:dirs) lib = do + let l = dir lib ++ sysPkgSuffix + b <- doesFileExist l + if b then return $ Just l -- found it! + else findHSlib dirs lib + +------------------------------------------------------------------------ +-- do we have a Module name for this merge? +-- +isMerged :: FilePath -> FilePath -> IO Bool +isMerged a b = withMerged env $ \fm -> return $ isJust (lookupFM fm (a,b)) + +lookupMerged :: FilePath -> FilePath -> IO (Maybe FilePath) +lookupMerged a b = withMerged env $ \fm -> return $ lookupFM fm (a,b) + +-- +-- insert a new merge pair into env +-- +addMerge :: FilePath -> FilePath -> FilePath -> IO () +addMerge a b z = modifyMerged env $ \fm -> return $ addToFM fm (a,b) z + +------------------------------------------------------------------------ +-- break a module cycle +-- private: +-- +() :: FilePath -> FilePath -> FilePath +[] b = b +a b = a ++ "/" ++ b hunk ./src/plugins/Plugins/Load.hs 1 +{-# OPTIONS -#include "Linker.h" #-} +{-# OPTIONS -fglasgow-exts -cpp #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Plugins.Load ( + +-- high level interface + load , load_ + , dynload + , pdynload , pdynload_ + , unload + , reload + , Module(..) + + , LoadStatus(..) + +-- low level interface + , initLinker -- start it up + , loadModule -- load a vanilla .o + , loadFunction -- retrieve a function from an object + , loadPackage -- load a ghc library and its cbits + , unloadPackage -- unload a ghc library and its cbits + , loadPackageWith -- load a pkg using the package.conf provided + , loadShared -- load a .so object file + , resolveObjs -- and resolve symbols + + , loadRawObject -- load a bare .o. no dep chasing, no .hi file reading + + , Symbol + + ) where + +import Plugins.Make ( build ) +import Plugins.Env +import Plugins.Utils +import Plugins.Consts ( sysPkgSuffix, hiSuf, prefixUnderscore ) + +import Hi.Parser + +import AltData.Dynamic ( fromDyn, Dynamic ) +import AltData.Typeable ( Typeable ) + +import Data.List ( isSuffixOf, nub, nubBy ) +import Control.Monad ( when, filterM, liftM ) +import System.Directory ( doesFileExist, removeFile ) +import Foreign.C.String ( CString, withCString, peekCString ) + +import GHC.Ptr ( Ptr(..), nullPtr ) +import GHC.Exts ( addrToHValue# ) +import GHC.Prim ( unsafeCoerce# ) + +#if DEBUG +import System.IO ( hFlush, stdout ) +#endif + +-- TODO need a loadPackage p package.conf :: IO () primitive + +-- --------------------------------------------------------------------- + +type Symbol = String +type Type = String +type Errors = [String] +type PackageConf = FilePath + +data Module = Module { path :: !FilePath + , mname :: !String + , kind :: !ObjType + , iface :: Iface -- cache the iface + , key :: Key + } + +data ObjType = Vanilla | Shared deriving Eq + +-- --------------------------------------------------------------------- +-- return status of all *load functions: +-- +data LoadStatus a + = LoadSuccess Module a + | LoadFailure Errors + +-- --------------------------------------------------------------------- +-- | load an object file into the address space, returning the closure +-- associated with the symbol requested, after removing its dynamism. +-- +-- Recursively loads the specified modules, and all the modules they +-- depend on. +-- +load :: FilePath -- ^ object file + -> [FilePath] -- ^ any include paths + -> [PackageConf] -- ^ list of package.conf paths + -> Symbol -- ^ symbol to find + -> IO (LoadStatus a) + +load obj incpaths pkgconfs sym = do + initLinker + + -- load extra package information + mapM_ addPkgConf pkgconfs + hif <- loadDepends obj incpaths + + -- why is this the package name? +#if DEBUG + putStr (' ':(decode $ mi_module hif)) >> hFlush stdout +#endif + + m' <- loadObject obj (Object (mi_module hif)) + let m = m' { iface = hif } + resolveObjs + +#if DEBUG + putStrLn " ... done" >> hFlush stdout +#endif + + v <- loadFunction m sym + return $ case v of + Nothing -> LoadFailure ["load: couldn't find symbol <<"++sym++">>"] + Just a -> LoadSuccess m a + +-- +-- | Like load, but doesn't want a package.conf arg (they are rarely used) +-- +load_ :: FilePath -> [FilePath] -> Symbol -> IO (LoadStatus a) +load_ o i s = load o i [] s + +-- +-- A work-around for Dynamics. The keys used to compare two TypeReps are +-- somehow not equal for the same type in hs-plugin's loaded objects. +-- Solution: implement our own dynamics... +-- +-- The problem with dynload is that it requires the plugin to export +-- a value that is a Dynamic (in our case a (TypeRep,a) pair). If this +-- is not the case, we core dump. Use pdynload if you don't trust the +-- user to supply you with a Dynamic +-- +dynload :: Typeable a + => FilePath + -> [FilePath] + -> [PackageConf] + -> Symbol + -> IO (LoadStatus a) + +dynload obj incpaths pkgconfs sym = do + s <- load obj incpaths pkgconfs sym + case s of e@(LoadFailure _) -> return e + LoadSuccess m dyn_v -> return $ + case fromDyn (unsafeCoerce# dyn_v :: Dynamic) of + Just v' -> LoadSuccess m v' + Nothing -> LoadFailure ["Mismatched types in interface"] + +------------------------------------------------------------------------ +-- +-- The super-replacement for dynload +-- +-- Use GHC at runtime so we get staged type inference, providing full +-- power dynamics, *on module interfaces only*. This is quite suitable +-- for plugins, of coures :) +-- +-- TODO where does the .hc file go in the call to build() ? +-- + +pdynload :: FilePath -- ^ object to load + -> [FilePath] -- ^ include paths + -> [PackageConf] -- ^ package confs + -> Type -- ^ API type + -> Symbol -- ^ symbol + -> IO (LoadStatus a) + +pdynload object incpaths pkgconfs ty sym = do +#if DEBUG + putStr "Checking types ... " >> hFlush stdout +#endif + errors <- unify object incpaths [] ty sym +#if DEBUG + putStrLn "done" +#endif + if null errors + then load object incpaths pkgconfs sym + else return $ LoadFailure errors + +-- +-- | Like pdynload, but you can specify extra arguments to the +-- typechecker. +-- +pdynload_ :: FilePath -- ^ object to load + -> [FilePath] -- ^ include paths for loading + -> [PackageConf] -- ^ any extra package.conf files + -> [Arg] -- ^ extra arguments to ghc, when typechecking + -> Type -- ^ expected type + -> Symbol -- ^ symbol to load + -> IO (LoadStatus a) + +pdynload_ object incpaths pkgconfs args ty sym = do +#if DEBUG + putStr "Checking types ... " >> hFlush stdout +#endif + errors <- unify object incpaths args ty sym +#if DEBUG + putStrLn "done" +#endif + if null errors + then load object incpaths pkgconfs sym + else return $ LoadFailure errors + +------------------------------------------------------------------------ +-- run the typechecker over the constraint file +-- +-- .hc into /dev/null, .hi into /dev/null +-- +-- NON_PORTABLE == /dev/null +-- +-- Problem: if the user depends on a non-auto package to build the +-- module, then that package will not be in scope when we try to build +-- the module, when performing `unify'. Normally make() will handle this +-- (as it takes extra ghc args). pdynload ignores these, atm -- but it +-- shouldn't. Consider a pdynload() that accepts extra -package flags? +-- +-- Also, pdynload() should accept extra in-scope modules. +-- Maybe other stuff we want to hack in here. +-- +unify obj incs args ty sym = do + (tmpf,hdl) <- mkTemp + + let nm = mkModid (basename tmpf) + src = mkTest nm (mkModid obj) (fst $ break (=='.') ty) ty sym + is = map (\s -> "-i"++s) incs -- api + i = "-i" ++ dirname obj -- plugin + + hWrite hdl src + e <- build tmpf "/dev/null" (i:is++args++["-fno-code","-ohi/dev/null"]) + removeFile tmpf + return e + +mkTest modnm plugin api ty sym = + "module "++ modnm ++" where" ++ + "\nimport qualified " ++ plugin ++ + "\nimport qualified " ++ api ++ + "{-# LINE 1 \"\" #-}" ++ + "\n_ = "++ plugin ++"."++ sym ++" :: "++ty + +------------------------------------------------------------------------ +{- +-- +-- old version that tried to rip stuff from .hi files +-- +pdynload obj incpaths pkgconfs sym ty = do + (m, v) <- load obj incpaths pkgconfs sym + ty' <- mungeIface sym obj + if ty == ty' + then return $ Just (m, v) + else return Nothing -- mismatched types + + where + -- grab the iface output from GHC. find the line relevant to our + -- symbol. grab the string rep of the type. + mungeIface sym o = do + let hi = replaceSuffix o hiSuf + (out,_) <- exec ghc ["--show-iface", hi] + case find (\s -> (sym ++ " :: ") `isPrefixOf` s) out of + Nothing -> return undefined + Just v -> do let v' = drop 3 $ dropWhile (/= ':') v + return v' + +-} + +{- +-- +-- a version of load the also unwraps and types a Dynamic object +-- +dynload2 :: Typeable a => + FilePath -> + FilePath -> + Maybe [PackageConf] -> + Symbol -> + IO (Module, a) + +dynload2 obj incpath pkgconfs sym = do + (m, v) <- load obj incpath pkgconfs sym + case fromDynamic v of + Nothing -> panic $ "load: couldn't type "++(show v) + Just a -> return (m,a) +-} + +------------------------------------------------------------------------ +-- +-- | unload a module (not it's dependencies) +-- we have the dependencies, so cascaded unloading is possible +-- +-- once you unload it, you can't 'load' it again, you have to 'reload' +-- it. Cause we don't unload all the dependencies +-- +unload :: Module -> IO () +unload = unloadObj + +-- +-- | this will be nice for panTHeon, needs thinking about the interface +-- reload a single object file. don't care about depends, assume they +-- are loaded. (should use state to store all this) +-- +-- assumes you've already done a 'load' +-- +-- should factor the code +-- +reload :: Module -> Symbol -> IO (LoadStatus a) +reload m@(Module{path = p, iface = hi}) sym = do + unloadObj m -- unload module (and delete) +#if DEBUG + putStr ("Reloading "++(mname m)++" ... ") >> hFlush stdout +#endif + m_ <- loadObject p (Object $ mi_module hi) -- load object at path p + let m' = m_ { iface = hi } + + resolveObjs +#if DEBUG + putStrLn "done" >> hFlush stdout +#endif + v <- loadFunction m' sym + return $ case v of + Nothing -> LoadFailure ["load: couldn't find symbol <<"++sym++">>"] + Just a -> LoadSuccess m' a + +-- --------------------------------------------------------------------- +-- This is a stripped-down version of André Pang's runtime_loader, +-- which in turn is based on GHC's ghci/ObjLinker.lhs binding +-- +-- Load and unload\/Haskell modules at runtime. This is not really +-- \'dynamic loading\', as such -- that implies that you\'re working +-- with proper shared libraries, whereas this is far more simple and +-- only loads object files. But it achieves the same goal: you can +-- load a Haskell module at runtime, load a function from it, and run +-- the function. I have no idea if this works for types, but that +-- doesn\'t mean that you can\'t try it :). +-- +-- read $fptools/ghc/compiler/ghci/ObjLinker.lhs for how to use this stuff +-- +------------------------------------------------------------------------ + +-- | Call the initLinker function first, before calling any of the other +-- functions in this module - otherwise you\'ll get unresolved symbols. + +-- initLinker :: IO () +-- our initLinker transparently calls the one in GHC + +-- +-- | Load a function from a module (which must be loaded and resolved first). +-- +loadFunction :: Module -- ^ The module the value is in + -> String -- ^ Symbol name of value + -> IO (Maybe a) -- ^ The value you want + +loadFunction (Module { iface = i }) valsym + = do let m = mi_module i + symbol = symbolise m +#if DEBUG + putStrLn $ "Looking for <<"++symbol++">>" +#endif + ptr@(~(Ptr addr)) <- withCString symbol c_lookupSymbol + if (ptr == nullPtr) + then return Nothing + else case addrToHValue# addr of + (# hval #) -> return ( Just hval ) + where + symbolise m = prefixUnderscore++m++"_"++(encode valsym)++"_closure" + + + +-- +-- | Load a GHC-compiled Haskell vanilla object file. +-- The first arg is the path to the object file +-- +-- We make it idempotent to stop the nasty problem of loading the same +-- .o twice. Also the rts is a very special package that is already +-- loaded, even if we ask it to be loaded. N.B. we should insert it in +-- the list of known packages. +-- +-- NB the environment stores the *full path* to an object. So if you +-- want to know if a module is already loaded, you need to supply the +-- *path* to that object, not the name. +-- +-- NB -- let's try just the module name. +-- +-- loadObject loads normal .o objs, and packages too. .o objs come with +-- a nice canonical Z-encoded modid. packages just have a simple name. +-- Do we want to ensure they won't clash? Probably. +-- + +-- +-- the second argument to loadObject is a string to use as the unique +-- identifier for this object. For normal .o objects, it should be the +-- Z-encoded modid from the .hi file. For archives/packages, we can +-- probably get away with the package name +-- +data Key = Object String | Package String + +loadObject :: FilePath -> Key -> IO Module +loadObject p ky@(Object k) = loadObject' p ky k +loadObject p ky@(Package k) = loadObject' p ky k + +loadObject' :: FilePath -> Key -> String -> IO Module +loadObject' p ky k + | ("HSrts"++sysPkgSuffix) `isSuffixOf` p = return (emptyMod p) + + | otherwise + = do alreadyLoaded <- isLoaded k + when (not alreadyLoaded) $ do + r <- withCString p c_loadObj + when (not r) (panic $ "Could not load module `"++p++"'") + addModule k -- needs to Z-encode module name + return (emptyMod p) + + where emptyMod q = Module q (mkModid q) Vanilla emptyIface ky + +-- +-- load a single object. no dependencies. You should know what you're +-- doing. +-- +loadModule :: FilePath -> IO Module +loadModule obj = do + let hifile = replaceSuffix obj hiSuf + exists <- doesFileExist hifile + if (not exists) + then error $ "No .hi file found for "++show obj + else do hiface <- readIface hifile + loadObject obj (Object (mi_module hiface)) + +-- +-- | Load a generic .o file, good for loading C objects. +-- You should know what you're doing.. +-- Returns a fairly meaningless iface value. +-- +loadRawObject :: FilePath -> IO Module +loadRawObject obj = loadObject obj (Object k) + where + k = encode (mkModid obj) -- Z-encoded module name + +-- +-- | Resolve (link) the modules loaded by the 'loadObject' function. +-- +resolveObjs :: IO () +resolveObjs = do + r <- c_resolveObjs + when (not r) $ + panic $ "resolveObjs failed with <<" ++ show r ++ ">>" + + +-- | Unload a module +unloadObj :: Module -> IO () +unloadObj (Module { path = p, kind = k, key = ky }) = case k of + Vanilla -> withCString p $ \c_p -> do + r <- c_unloadObj c_p + when (not r) (panic "unloadObj: failed") + rmModule $ case ky of Object s -> s ; Package pk -> pk + + Shared -> return () -- can't unload .so? + +-- +-- | from ghci/ObjLinker.c +-- +-- Load a .so type object file. +-- +loadShared :: FilePath -> IO Module +loadShared str = do + maybe_errmsg <- withCString str $ \dll -> c_addDLL dll + if maybe_errmsg == nullPtr + then return (Module str (mkModid str) Shared emptyIface (Package (mkModid str))) + else do e <- peekCString maybe_errmsg + panic $ "loadShared: couldn't load `"++str++"\' because "++e + +-- +-- Load a -package that we might need, implicitly loading the cbits too +-- The argument is the name of package (e.g. \"concurrent\") +-- +-- How to find a package is determined by the package.conf info we store +-- in the environment. It is just a matter of looking it up. +-- +-- Not printing names of dependent pkgs +-- +loadPackage :: String -> IO () +loadPackage p = do +#if DEBUG + putStr (' ':p) >> hFlush stdout +#endif + libs <- lookupPkg p + mapM_ (\l -> loadObject l (Package (mkModid l))) libs + +-- +-- Unload a -package, that has already been loaded. Unload the cbits +-- too. The argument is the name of the package. +-- +-- May need to check if it exists. +-- +-- Note that we currently need to unload everything. grumble grumble. +-- +-- We need to add the version number to the package name with 6.4 and +-- over. "yi-0.1" for example. This is a bug really. +-- +unloadPackage :: String -> IO () +unloadPackage pkg = do + let pkg' = takeWhile (/= '-') pkg -- in case of *-0.1 + libs <- liftM (filter (isSublistOf pkg')) (lookupPkg pkg) + flip mapM_ libs $ \p -> withCString p $ \c_p -> do + r <- c_unloadObj c_p + when (not r) (panic "unloadObj: failed") + rmModule (mkModid p) -- unrecord this module + +-- +-- load a package using the given package.conf to help +-- TODO should report if it doesn't actually load the package, instead +-- of mapM_ doing nothing like above. +-- +loadPackageWith :: String -> [PackageConf] -> IO () +loadPackageWith p pkgconfs = do +#if DEBUG + putStr "Loading package" >> hFlush stdout +#endif + mapM_ addPkgConf pkgconfs + loadPackage p +#if DEBUG + putStrLn " done" +#endif + + +-- --------------------------------------------------------------------- +-- module dependency loading +-- +-- given an Foo.o vanilla object file, supposed to be a plugin compiled +-- by our library, find the associated .hi file. If this is found, load +-- the dependencies, packages first, then the modules. If it doesn't +-- exist, assume the user knows what they are doing and continue. The +-- linker will crash on them anyway. Second argument is any include +-- paths to search in +-- +-- ToDo problem with absolute and relative paths, and different forms of +-- relative paths. A user may cause a dependency to be loaded, which +-- will search the incpaths, and perhaps find "./Foo.o". The user may +-- then explicitly load "Foo.o". These are the same, and the loader +-- should ignore the second load request. However, isLoaded will say +-- that "Foo.o" is not loaded, as the full string is used as a key to +-- the modenv fm. We need a canonical form for the keys -- is basename +-- good enough? +-- +loadDepends :: FilePath -> [FilePath] -> IO Iface +loadDepends obj incpaths = do + let hifile = replaceSuffix obj hiSuf + exists <- doesFileExist hifile + if (not exists) + then do +#if DEBUG + putStrLn "No .hi file found." >> hFlush stdout +#endif + return emptyIface -- could be considered fatal + + else do hiface <- readIface hifile + let ds = mi_deps hiface + + -- remove ones that we've already loaded + ds' <- filterM loaded (dep_mods ds) + + -- now, try to generate a path to the actual .o file + -- fix up hierachical names + let mods_ = map (\s -> (s, map (\c -> + if c == '.' then '/' else c) $ decode s)) ds' + + -- construct a list of possible dependent modules to load + let mods = concatMap (\p -> + map (\(hi,m) -> (hi,p m++".o")) mods_) incpaths + + -- remove modules that don't exist + mods' <- filterM (\(_,y) -> doesFileExist y) $ + nubBy (\v u -> snd v == snd u) mods + + -- now remove duplicate valid paths to the same object + let mods'' = nubBy (\v u -> fst v == fst u) mods' + + -- and find some packages to load, as well. + let ps = dep_pkgs ds + ps' <- filterM loaded (nub ps) + +#if DEBUG + when (not (null ps')) $ + putStr "Loading package" >> hFlush stdout +#endif + mapM_ loadPackage ps' +#if DEBUG + when (not (null ps')) $ + putStr " ... linking ... " >> hFlush stdout +#endif + resolveObjs +#if DEBUG + when (not (null ps')) $ putStrLn "done" + putStr "Loading object" + mapM_ (\(m,_) -> putStr (" "++(decode m)) >> hFlush stdout) mods'' +#endif + mapM_ (\(hi,m) -> loadObject m (Object hi)) mods'' + return hiface + +-- --------------------------------------------------------------------- +-- C interface +-- +foreign import ccall unsafe "lookupSymbol" + c_lookupSymbol :: CString -> IO (Ptr a) + +foreign import ccall unsafe "loadObj" + c_loadObj :: CString -> IO Bool + +foreign import ccall unsafe "unloadObj" + c_unloadObj :: CString -> IO Bool + +foreign import ccall unsafe "resolveObjs" + c_resolveObjs :: IO Bool + +foreign import ccall unsafe "addDLL" + c_addDLL :: CString -> IO CString + +foreign import ccall unsafe "initLinker" + initLinker :: IO () hunk ./src/plugins/Plugins/Make.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Plugins.Make ( + + make, + makeAll, + makeWith, + MakeStatus(..), + MakeCode(..), + + merge, + mergeTo, + mergeToDir, + MergeStatus(..), + MergeCode, + + makeClean, + makeCleaner, + + build, {- internal -} + + ) where + +import Plugins.Utils +import Plugins.Parser +import Plugins.Consts ( ghc, hiSuf, objSuf, hsSuf ) +import Plugins.Env ( lookupMerged, addMerge ) + +import System.IO +import System.Directory ( doesFileExist, removeFile ) + +import Control.Exception ( handleJust ) +import GHC.IOBase ( Exception(IOException) ) + +#if __GLASGOW_HASKELL__ >= 604 +import System.IO.Error ( isDoesNotExistError ) +#endif + +------------------------------------------------------------------------ +-- +-- A better compiler status. +-- +data MakeStatus + = MakeSuccess MakeCode FilePath + | MakeFailure Errors + deriving (Eq,Show) + +data MakeCode = ReComp | NotReq + deriving (Eq,Show) + +------------------------------------------------------------------------ +-- +-- An equivalent status for the preprocessor (merge) +-- +data MergeStatus + = MergeSuccess MergeCode Args FilePath + | MergeFailure Errors + deriving (Eq,Show) + +type MergeCode = MakeCode + +type Args = [Arg] +type Errors = [String] + +-- --------------------------------------------------------------------- +-- | Standard make. Compile a single module, unconditionally. +-- Behaves like ghc -c +-- +make :: FilePath -> [Arg] -> IO MakeStatus +make src args = rawMake src ("-c":args) True + +-- | Recursive make. Compile a module, and its dependencies if we can +-- find them. Takes the top-level file as the first argument. +-- Behaves like ghc --make +-- +makeAll :: FilePath -> [Arg] -> IO MakeStatus +makeAll src args = + rawMake src ( "--make":"-no-hs-main":"-no-link":"-v0":args ) False + +-- | merge two files; then make them. will leave a .o and .hi file in tmpDir. +-- +makeWith :: FilePath -- ^ a src file + -> FilePath -- ^ a syntax stub file + -> [Arg] -- ^ any required args + -> IO MakeStatus -- ^ path to an object file + +makeWith src stub args = do + status <- merge src stub + case status of + MergeFailure errs -> return $ MakeFailure ("merge failed:\n":errs) + MergeSuccess _ args' tmpf -> do + status' <- rawMake tmpf ("-c": args' ++ args) True + return status' + +-- --------------------------------------------------------------------- +-- rawMake : really do the compilation +-- Conditional on file modification times, compile a .hs file +-- When using 'make', the name of the src file must be the name of the +-- .o file you are expecting back +-- +-- Problem: we use GHC producing stdout to indicate compilation failure. +-- We should instead check the error conditions. I.e. --make will +-- produce output, but of course compiles correctly. TODO +-- So, e.g. --make requires -v0 to stop spurious output confusing +-- rawMake +-- +-- Problem :: makeAll incorrectly refuses to recompile if the top level +-- src isn't new. +-- + +rawMake :: FilePath -- ^ src + -> [Arg] -- ^ any compiler args + -> Bool -- ^ do our own recompilation checking + -> IO MakeStatus + +rawMake src args docheck = do + src_exists <- doesFileExist src + if not src_exists + then return $ MakeFailure ["Source file does not exist: "++src] + else do { + ; let (obj,_) = outFilePath src args + ; src_changed <- if docheck then src `newer` obj else return True + ; if not src_changed + then return $ MakeSuccess NotReq obj + else do +#if DEBUG + putStr "Compiling object ... " >> hFlush stdout +#endif + err <- build src obj args +#if DEBUG + putStrLn "done" +#endif + return $ if null err + then MakeSuccess ReComp obj + else MakeFailure err + } + +-- +-- compile a .hs file to a .o file +-- +-- If the plugin needs to import an api (which should be almost +-- everyone) then the ghc flags to find the api need to be provided as +-- arguments +-- +build :: FilePath -- path to .hs source + -> FilePath -- path to object file + -> [String] -- any extra cmd line flags + -> IO [String] + +build src obj extra_opts = do + + let odir = dirname obj -- *always* put the .hi file next to the .o file + + let ghc_opts = [ "-Onot" ] + output = [ "-o", obj, "-odir", odir, + "-hidir", odir, "-i" ++ odir ] + + let flags = ghc_opts ++ output ++ extra_opts ++ [src] + +#if DEBUG + -- env. + putStr $ show $ ghc : flags +#endif + (_,err) <- exec ghc flags -- this is a fork() + + obj_exists <- doesFileExist obj -- sanity + return $ if not obj_exists && null err -- no errors, but no object? + then ["Compiled, but didn't create object file `"++obj++"'!"] + else err + +-- --------------------------------------------------------------------- +-- | Merge to source files into a temporary file. If we've tried to +-- merge these two stub files before, then reuse the module name (helps +-- recompilation checking) +-- +merge :: FilePath -> FilePath -> IO MergeStatus +merge src stb = do + m_mod <- lookupMerged src stb + (out,domerge) <- case m_mod of + Nothing -> do out <- mkUnique + addMerge src stb (dropSuffix out) + return (out, True) -- definitely out of date + Just nm -> return $ (nm <> hsSuf, False) + rawMerge src stb out domerge + +-- | Merge to source files and store them in the specified output file, +-- instead of a temp file as merge does. +-- +mergeTo :: FilePath -> FilePath -> FilePath -> IO MergeStatus +mergeTo src stb out = rawMerge src stb out False + +mergeToDir :: FilePath -> FilePath -> FilePath -> IO MergeStatus +mergeToDir src stb dir = do + out <- mkUniqueIn dir + rawMerge src stb out True + +-- --------------------------------------------------------------------- +-- Conditional on file modification times, merge a src file with a +-- syntax stub file into a result file. +-- +-- Merge should only occur if the srcs has changed since last time. +-- Parser errors result in MergeFailure, and are reported to the client +-- +-- Also returns a list of cmdline flags found in pragmas in the src of +-- the files. This last feature exists as OPTION pragmas aren't handled +-- (for obvious reasons, relating to the implementation of OPTIONS +-- parsing in GHC) by the library parser, and, also, we want a way for +-- the user to introduce *dynamic* cmd line flags in the .conf file. +-- This is achieved via the GLOBALOPTIONS pragma : an extension to ghc +-- pragma syntax +-- +rawMerge :: FilePath -> FilePath -> FilePath -> Bool -> IO MergeStatus +rawMerge src stb out always_merge = do + src_exists <- doesFileExist src + stb_exists <- doesFileExist stb + case () of {_ + | not src_exists -> return $ + MergeFailure ["Source file does not exist : "++src] + | not stb_exists -> return $ + MergeFailure ["Source file does not exist : "++stb] + | otherwise -> do { + + ;do_merge <- do src_changed <- src `newer` out + stb_changed <- stb `newer` out + return $ src_changed || stb_changed + + ;if not do_merge && not always_merge + then return $ MergeSuccess NotReq [] out + else do + src_str <- readFile src + stb_str <- readFile stb + + let (a,a') = parsePragmas src_str + (b,b') = parsePragmas stb_str + opts = a ++ a' ++ b ++ b' + + let e_src_syn = parse src src_str + e_stb_syn = parse stb stb_str + + -- check if there were parser errors + case (e_src_syn,e_stb_syn) of + (Left e, _) -> return $ MergeFailure [e] + (_ , Left e) -> return $ MergeFailure [e] + (Right src_syn, Right stb_syn) -> do { + + ;let mrg_syn = mergeModules src_syn stb_syn + mrg_syn'= replaceModName mrg_syn (mkModid $ basename out) + mrg_str = pretty mrg_syn' + + ;hdl <- openFile out WriteMode -- overwrite! + ;hPutStr hdl mrg_str ; hClose hdl + ;return $ MergeSuccess ReComp opts out -- must have recreated file + }}} + +-- --------------------------------------------------------------------- +-- | makeClean : assuming we some element of [f.hs,f.hi,f.o], remove the +-- .hi and .o components. Silently ignore any missing components. *Does +-- not remove .hs files*. To do that use makeCleaner. This would be +-- useful for merged files, for example. +-- +makeClean :: FilePath -> IO () +makeClean f = let f_hi = dropSuffix f <> hiSuf + f_o = dropSuffix f <> objSuf + in mapM_ rm_f [f_hi, f_o] + +makeCleaner :: FilePath -> IO () +makeCleaner f = makeClean f >> rm_f (dropSuffix f <> hsSuf) + +-- internal: +-- try to remove a file, ignoring if it didn't exist in the first place +-- Doesn't seem to be able to remove all files in all circumstances, why? +-- +rm_f f = handleJust doesntExist (\_->return ()) (removeFile f) + where + doesntExist (IOException ioe) + | isDoesNotExistError ioe = Just () + | otherwise = Nothing + doesntExist _ = Nothing + hunk ./src/plugins/Plugins/MkTemp.hs 1 +{-# OPTIONS -cpp -fffi -fglasgow-exts #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- A Haskell reimplementation of the C mktemp/mkstemp/mkstemps library +-- based on the algorithms in: +-- "$ OpenBSD: mktemp.c,v 1.17 2003/06/02 20:18:37 millert Exp $" +-- which are available under the BSD license. +-- + +module Plugins.MkTemp ( + + mktemp, -- :: FilePath -> FilePath + mkstemp, -- :: FilePath -> (FilePath, Handle) + mkstemps, -- :: FilePath -> Int -> (FilePath,Handle) + mkdtemp, -- :: FilePath -> FilePath + + ) where + +import Data.List +import Data.Char + +import Control.Monad ( liftM ) +import Control.Exception ( handleJust ) + +#if __GLASGOW_HASKELL__ < 604 +import System.IO ( isAlreadyExistsError, Handle ) +#else +import System.IO ( Handle ) +import System.IO.Error ( isAlreadyExistsError ) +#endif + +import System.Directory ( doesDirectoryExist, doesFileExist ) + +import GHC.IOBase ( Exception(IOException) ) + +-- Fix this. +#ifndef __MINGW32__ +import System.Posix.IO +import System.Posix.Files +import qualified System.Posix.Directory ( createDirectory ) +import qualified System.Posix.Internals ( c_getpid ) +#endif + +#ifndef HAVE_ARC4RANDOM +import System.Random ( getStdRandom, Random(randomR) ) +#else +import GHC.Base +import GHC.Int +#endif + +-- --------------------------------------------------------------------- + +mkstemps :: FilePath -> Int -> IO (Maybe (FilePath,Handle)) +mkstemp :: FilePath -> IO (Maybe (FilePath,Handle)) +mktemp :: FilePath -> IO (Maybe FilePath) +mkdtemp :: FilePath -> IO (Maybe FilePath) + +mkstemps path slen = gettemp path True False slen + +mkstemp path = gettemp path True False 0 + +mktemp path = do v <- gettemp path False False 0 + return $ case v of Just (path',_) -> Just path'; _ -> Nothing + +mkdtemp path = do v <- gettemp path False True 0 + return $ case v of Just (path',_) -> Just path'; _ -> Nothing + +-- --------------------------------------------------------------------- + +gettemp :: FilePath -> Bool -> Bool -> Int -> IO (Maybe (FilePath, Handle)) + +gettemp [] _ _ _ = return Nothing +gettemp _ True True _ = return Nothing + +gettemp path doopen domkdir slen = do + -- + -- firstly, break up the path and extract the template + -- + let (pref,tmpl,suff) = let (r,s) = splitAt (length path - slen) path + (p,t) = break (== 'X') r + in (p,t,s) + -- + -- an error if there is only a suffix, it seems + -- + if null pref && null tmpl then return Nothing else do { + -- + -- replace end of template with process id, and rest with randomness + -- + ;pid <- liftM show $ getProcessID + ;let (rest, xs) = merge tmpl pid + ;as <- randomise rest + ;let tmpl' = as ++ xs + path' = pref ++ tmpl' ++ suff + -- + -- just check if we can get at the directory we might need + -- + ;dir_ok <- if doopen || domkdir + then let d = reverse $ dropWhile (/= '/') $ reverse path' + in doesDirectoryExist d + else return True + + ;if not dir_ok then return Nothing else do { + -- + -- We need a function for looking for appropriate temp files + -- + ;let fn p + | doopen = handleJust isInUse (\_ -> return Nothing) $ + do h <- open0600 p ; return $ Just h + | domkdir = handleJust alreadyExists (\_ -> return Nothing) $ + do mkdir0700 p ; return $ Just undefined + | otherwise = do b <- doesFileExist p + return $ if b then Nothing else Just undefined + + -- + -- now, try to create the tmp file, permute if we can't + -- once we've tried all permutations, give up + -- + ;let tryIt p t i = + do v <- fn p + case v of Just h -> return $ Just (p,h) -- it worked + Nothing -> let (i',t') = tweak i t + in if null t' + then return Nothing -- no more + else tryIt (pref++t'++suff) t' i' + ;tryIt path' tmpl' 0 + + }} + +-- +-- Replace X's with pid digits. Complete rewrite +-- +merge :: String -> String -> (String,String) +merge t [] = (t ,[]) +merge [] _ = ([] ,[]) +merge (_:ts) (p:ps) = (ts',p:ps') + where (ts',ps') = merge ts ps + +-- +-- And replace remaining X's with random chars +-- randomR is pretty slow, oh well. +-- +randomise :: String -> IO String +randomise [] = return [] +randomise ('X':xs) = do p <- getRandom () + let c = chr $! if p < 26 + then p + (ord 'A') + else (p - 26) + (ord 'a') + xs' <- randomise xs + return (c : xs') +randomise s = return s + +-- +-- "tricky little algorithm for backward compatibility" +-- could do with a Haskellish rewrite +-- +tweak :: Int -> String -> (Int,String) +tweak i s + | i > length s - 1 = (i,[]) -- no more + | s !! i == 'Z' = if i == length s - 1 + then (i,[]) -- no more + else let s' = splice (i+1) 'a' + in tweak (i+1) s' -- loop + | otherwise = let c = s !! i in case () of {_ + | isDigit c -> (i, splice i 'a' ) + | c == 'z' -> (i, splice i 'A' ) + | otherwise -> let c' = chr $ (ord c) + 1 in (i,splice i c') + } + where + splice j c = let (a,b) = splitAt j s in a ++ [c] ++ tail b + +-- --------------------------------------------------------------------- + +alreadyExists e@(IOException ioe) + | isAlreadyExistsError ioe = Just e + | otherwise = Nothing +alreadyExists _ = Nothing + +#ifndef __MINGW32__ +isInUse (IOException ioe) + | isAlreadyExistsError ioe = Just () + | otherwise = Nothing +isInUse _ = Nothing +#else +isInUse (IOException ioe) + | isAlreadyInUseError ioe = Just () + | isPermissionError ioe = Just () + | isAlreadyExistsError ioe = Just () -- we throw this + | otherwise = Nothing +isInUse _ = Nothing +#endif + +-- --------------------------------------------------------------------- +-- Create a file mode 0600 if possible +-- +open0600 :: FilePath -> IO Handle + +#ifndef __MINGW32__ + +-- open(path, O_CREAT|O_EXCL|O_RDWR, 0600) + +open0600 f = do + openFd f ReadWrite (Just o600) excl >>= fdToHandle + where + o600 = ownerReadMode `unionFileModes` ownerWriteMode + excl = defaultFileFlags { exclusive = True } +#else + +-- N.B. race condition between testing existence and opening + +open0600 f = do + b <- doesFileExist f + if b then ioException err -- race + else openFile f ReadWriteMode + where + err = IOError Nothing AlreadyExists "open0600" "already exists" Nothing +#endif + +-- +-- create a directory mode 0700 if possible +-- +mkdir0700 :: FilePath -> IO () +mkdir0700 dir = +#ifndef __MINGW32__ + System.Posix.Directory.createDirectory dir ownerModes +#else + createDirectory dir +#endif + +-- --------------------------------------------------------------------- +-- | getProcessId, stolen from GHC + +#ifdef __MINGW32__ +foreign import ccall unsafe "_getpid" getProcessID :: IO Int +#elif __GLASGOW_HASKELL__ > 504 +getProcessID :: IO Int +getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral +#else +getProcessID :: IO Int +getProcessID = Posix.getProcessID +#endif + +-- --------------------------------------------------------------------- +-- | Use a variety of random functions, if you like. +-- +getRandom :: () -> IO Int + +#ifndef HAVE_ARC4RANDOM +getRandom _ = getStdRandom (randomR (0,51)) +#else +-- +-- +-- OpenBSD: "The arc4random() function provides a high quality 32-bit +-- pseudo-random number very quickly. arc4random() seeds itself on a +-- regular basis from the kernel strong random number subsystem +-- described in random(4)." Also, it is a bit faster than getStdRandom +-- +getRandom _ = do + (I32# i) <- c_arc4random + return (I# (word2Int# + ((int2Word# i `and#` int2Word# 0xffff#) `remWord#` int2Word# 52#))) + +foreign import ccall unsafe "arc4random" c_arc4random :: IO Int32 +#endif hunk ./src/plugins/Plugins/Package.hs 1 +-- +-- Copyright (C) 2004 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA + +-- +-- Read information from a package.conf +-- + +module Plugins.Package {-everything-} where + +type PackageName = String + +-- +-- Take directly from ghc/utils/ghc-pkg/Package.hs +-- + +data PackageConfig = Package { + name :: PackageName, + auto :: Bool, + import_dirs :: [FilePath], + source_dirs :: [FilePath], + library_dirs :: [FilePath], + hs_libraries :: [String], + extra_libraries :: [String], + include_dirs :: [FilePath], + c_includes :: [String], + package_deps :: [String], + extra_ghc_opts :: [String], + extra_cc_opts :: [String], + extra_ld_opts :: [String], + framework_dirs :: [FilePath], -- ignored everywhere but on Darwin/MacOS X + extra_frameworks:: [String] -- ignored everywhere but on Darwin/MacOS X + } deriving Show + + +defaultPackageConfig = Package { + name = error "defaultPackage", + auto = False, + import_dirs = [], + source_dirs = [], + library_dirs = [], + hs_libraries = [], + extra_libraries = [], + include_dirs = [], + c_includes = [], + package_deps = [], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [], + framework_dirs = [], + extra_frameworks= [] + } + hunk ./src/plugins/Plugins/PackageAPI.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (C) 2005 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA + +-- +-- We export an abstract interface to package conf`s because we have +-- to handle either traditional or Cabal style package conf`s. +-- + +module Plugins.PackageAPI ( + PackageName + , PackageConfig + , packageName + , packageName_ + , importDirs + , hsLibraries + , libraryDirs + , extraLibraries + , packageDeps + , updImportDirs + , updLibraryDirs + ) where + +#include "../../../config.h" + +#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 +import Distribution.InstalledPackageInfo +import Distribution.Package +#else +import Plugins.Package +#endif + +packageName :: PackageConfig -> PackageName +packageDeps :: PackageConfig -> [PackageName] +updImportDirs :: ([FilePath] -> [FilePath]) -> PackageConfig -> PackageConfig +updLibraryDirs :: ([FilePath] -> [FilePath]) -> PackageConfig -> PackageConfig + +-- We use different package.conf parsers when running on 6.2.x or 6.4 +#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 + +type PackageName = String + +type PackageConfig = InstalledPackageInfo + +packageName = showPackageId . package +packageName_ = pkgName . package +packageDeps = (map showPackageId) . depends + +updImportDirs f pk@(InstalledPackageInfo { importDirs = idirs }) = + pk { importDirs = f idirs } +updLibraryDirs f pk@(InstalledPackageInfo { libraryDirs = ldirs }) = + pk { libraryDirs = f ldirs } +#else + +packageName = name +packageName_ = name +packageDeps = package_deps + +updImportDirs f pk@(Package {import_dirs = idirs}) + = pk {import_dirs = f idirs} + +updLibraryDirs f pk@(Package {library_dirs = ldirs}) + = pk {library_dirs = f ldirs} + +importDirs :: PackageConfig -> [FilePath] +importDirs = import_dirs + +hsLibraries :: PackageConfig -> [String] +hsLibraries = hs_libraries + +libraryDirs :: PackageConfig -> [FilePath] +libraryDirs = library_dirs + +extraLibraries :: PackageConfig -> [String] +extraLibraries = extra_libraries + +#endif hunk ./src/plugins/Plugins/ParsePkgConfCabal.hs 1 +{-# OPTIONS -fglasgow-exts -cpp -w #-} +-- parser produced by Happy Version 1.14 + + + +module Plugins.ParsePkgConfCabal ( + parsePkgConf, parseOnePkgConf + ) where + +import Distribution.InstalledPackageInfo +import Distribution.Package +import Distribution.Version + +import Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) +import List ( break ) +import Array +#if __GLASGOW_HASKELL__ >= 503 +import GHC.Exts +#else +import GlaExts +#endif + +newtype HappyAbsSyn = HappyAbsSyn (() -> ()) +happyIn5 :: ([ PackageConfig ]) -> (HappyAbsSyn ) +happyIn5 x = unsafeCoerce# x +{-# INLINE happyIn5 #-} +happyOut5 :: (HappyAbsSyn ) -> ([ PackageConfig ]) +happyOut5 x = unsafeCoerce# x +{-# INLINE happyOut5 #-} +happyIn6 :: ([ PackageConfig ]) -> (HappyAbsSyn ) +happyIn6 x = unsafeCoerce# x +{-# INLINE happyIn6 #-} +happyOut6 :: (HappyAbsSyn ) -> ([ PackageConfig ]) +happyOut6 x = unsafeCoerce# x +{-# INLINE happyOut6 #-} +happyIn7 :: (PackageConfig) -> (HappyAbsSyn ) +happyIn7 x = unsafeCoerce# x +{-# INLINE happyIn7 #-} +happyOut7 :: (HappyAbsSyn ) -> (PackageConfig) +happyOut7 x = unsafeCoerce# x +{-# INLINE happyOut7 #-} +happyIn8 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) +happyIn8 x = unsafeCoerce# x +{-# INLINE happyIn8 #-} +happyOut8 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) +happyOut8 x = unsafeCoerce# x +{-# INLINE happyOut8 #-} +happyIn9 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) +happyIn9 x = unsafeCoerce# x +{-# INLINE happyIn9 #-} +happyOut9 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) +happyOut9 x = unsafeCoerce# x +{-# INLINE happyOut9 #-} +happyIn10 :: (PackageIdentifier) -> (HappyAbsSyn ) +happyIn10 x = unsafeCoerce# x +{-# INLINE happyIn10 #-} +happyOut10 :: (HappyAbsSyn ) -> (PackageIdentifier) +happyOut10 x = unsafeCoerce# x +{-# INLINE happyOut10 #-} +happyIn11 :: (Version) -> (HappyAbsSyn ) +happyIn11 x = unsafeCoerce# x +{-# INLINE happyIn11 #-} +happyOut11 :: (HappyAbsSyn ) -> (Version) +happyOut11 x = unsafeCoerce# x +{-# INLINE happyOut11 #-} +happyIn12 :: ([PackageIdentifier]) -> (HappyAbsSyn ) +happyIn12 x = unsafeCoerce# x +{-# INLINE happyIn12 #-} +happyOut12 :: (HappyAbsSyn ) -> ([PackageIdentifier]) +happyOut12 x = unsafeCoerce# x +{-# INLINE happyOut12 #-} +happyIn13 :: ([PackageIdentifier]) -> (HappyAbsSyn ) +happyIn13 x = unsafeCoerce# x +{-# INLINE happyIn13 #-} +happyOut13 :: (HappyAbsSyn ) -> ([PackageIdentifier]) +happyOut13 x = unsafeCoerce# x +{-# INLINE happyOut13 #-} +happyIn14 :: ([Int]) -> (HappyAbsSyn ) +happyIn14 x = unsafeCoerce# x +{-# INLINE happyIn14 #-} +happyOut14 :: (HappyAbsSyn ) -> ([Int]) +happyOut14 x = unsafeCoerce# x +{-# INLINE happyOut14 #-} +happyIn15 :: ([Int]) -> (HappyAbsSyn ) +happyIn15 x = unsafeCoerce# x +{-# INLINE happyIn15 #-} +happyOut15 :: (HappyAbsSyn ) -> ([Int]) +happyOut15 x = unsafeCoerce# x +{-# INLINE happyOut15 #-} +happyIn16 :: ([String]) -> (HappyAbsSyn ) +happyIn16 x = unsafeCoerce# x +{-# INLINE happyIn16 #-} +happyOut16 :: (HappyAbsSyn ) -> ([String]) +happyOut16 x = unsafeCoerce# x +{-# INLINE happyOut16 #-} +happyIn17 :: ([String]) -> (HappyAbsSyn ) +happyIn17 x = unsafeCoerce# x +{-# INLINE happyIn17 #-} +happyOut17 :: (HappyAbsSyn ) -> ([String]) +happyOut17 x = unsafeCoerce# x +{-# INLINE happyOut17 #-} +happyInTok :: Token -> (HappyAbsSyn ) +happyInTok x = unsafeCoerce# x +{-# INLINE happyInTok #-} +happyOutTok :: (HappyAbsSyn ) -> Token +happyOutTok x = unsafeCoerce# x +{-# INLINE happyOutTok #-} + +happyActOffsets :: HappyAddr +happyActOffsets = HappyA# "\x50\x00\x4a\x00\x4c\x00\x49\x00\x46\x00\x4b\x00\x45\x00\x0a\x00\x1e\x00\x00\x00\x00\x00\x44\x00\x16\x00\x00\x00\x43\x00\x00\x00\x42\x00\x00\x00\x03\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x01\x00\x00\x00\x40\x00\x00\x00\x3e\x00\x3d\x00\x1c\x00\x00\x00\x3f\x00\x00\x00\x00\x00\x3b\x00\x00\x00\x3a\x00\x39\x00\x35\x00\x00\x00\x00\x00\x38\x00\x31\x00\x34\x00\x33\x00\x37\x00\x36\x00\x28\x00\x00\x00\x30\x00\x32\x00\x2f\x00\x09\x00\x2d\x00\x00\x00\x2e\x00\x26\x00\x2c\x00\x22\x00\x00\x00\x00\x00\x2b\x00\x29\x00\x0d\x00\x00\x00\x00\x00"# + +happyGotoOffsets :: HappyAddr +happyGotoOffsets = HappyA# "\x2a\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\xfe\xff\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x04\x00\x00\x00\xfb\xff\x00\x00\x00\x00"# + +happyDefActions :: HappyAddr +happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xfd\xff\x00\x00\x00\x00\xf8\xff\x00\x00\xfc\xff\x00\x00\xfa\xff\x00\x00\xf9\xff\x00\x00\xf7\xff\xf6\xff\xf1\xff\xf2\xff\x00\x00\xf4\xff\xf5\xff\x00\x00\xf3\xff\xed\xff\x00\x00\x00\x00\xe7\xff\x00\x00\xe5\xff\xe6\xff\x00\x00\xee\xff\x00\x00\x00\x00\x00\x00\xec\xff\xe4\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xeb\xff\xe9\xff\x00\x00\x00\x00\x00\x00\xea\xff\xe8\xff\x00\x00\x00\x00\x00\x00\xef\xff"# + +happyCheck :: HappyAddr +happyCheck = HappyA# "\xff\xff\x05\x00\x01\x00\x05\x00\x08\x00\x07\x00\x03\x00\x0c\x00\x0c\x00\x0b\x00\x09\x00\x08\x00\x09\x00\x04\x00\x04\x00\x0b\x00\x04\x00\x04\x00\x08\x00\x0a\x00\x08\x00\x09\x00\x09\x00\x05\x00\x02\x00\x0a\x00\x08\x00\x05\x00\x03\x00\x04\x00\x01\x00\x02\x00\x04\x00\x05\x00\x04\x00\x05\x00\x0a\x00\x04\x00\x06\x00\x02\x00\x09\x00\x02\x00\x00\x00\x02\x00\x0a\x00\x07\x00\x03\x00\x07\x00\xff\xff\x04\x00\x06\x00\x05\x00\x05\x00\x03\x00\x06\x00\x01\x00\x07\x00\x02\x00\x06\x00\x08\x00\xff\xff\x05\x00\x09\x00\x06\x00\x01\x00\x04\x00\x08\x00\x05\x00\x09\x00\xff\xff\xff\xff\x07\x00\x07\x00\x06\x00\x08\x00\x07\x00\x01\x00\x04\x00\xff\xff\x03\x00\x0b\x00\x0b\x00\x08\x00\x03\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# + +happyTable :: HappyAddr +happyTable = HappyA# "\x00\x00\x1e\x00\x1d\x00\x16\x00\x1f\x00\x17\x00\x1a\x00\x20\x00\x20\x00\x18\x00\x1e\x00\x1b\x00\x1c\x00\x3a\x00\x0b\x00\x41\x00\x22\x00\x22\x00\x06\x00\x3b\x00\x23\x00\x24\x00\x24\x00\x1e\x00\x14\x00\x3f\x00\x2a\x00\x15\x00\x0c\x00\x0d\x00\x08\x00\x09\x00\x25\x00\x26\x00\x10\x00\x11\x00\x38\x00\x15\x00\x30\x00\x11\x00\x36\x00\x04\x00\x06\x00\x44\x00\x3b\x00\x3d\x00\x43\x00\x35\x00\x00\x00\x3f\x00\x41\x00\x3e\x00\x3c\x00\x38\x00\x36\x00\x33\x00\x2f\x00\x34\x00\x30\x00\x32\x00\x00\x00\x2e\x00\x2d\x00\x2a\x00\x1d\x00\x27\x00\x23\x00\x28\x00\x2c\x00\x00\x00\x00\x00\x29\x00\x0f\x00\x13\x00\x06\x00\x0f\x00\x0c\x00\x0b\x00\x00\x00\x04\x00\xff\xff\xff\xff\x06\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# + +happyReduceArr = array (2, 27) [ + (2 , happyReduce_2), + (3 , happyReduce_3), + (4 , happyReduce_4), + (5 , happyReduce_5), + (6 , happyReduce_6), + (7 , happyReduce_7), + (8 , happyReduce_8), + (9 , happyReduce_9), + (10 , happyReduce_10), + (11 , happyReduce_11), + (12 , happyReduce_12), + (13 , happyReduce_13), + (14 , happyReduce_14), + (15 , happyReduce_15), + (16 , happyReduce_16), + (17 , happyReduce_17), + (18 , happyReduce_18), + (19 , happyReduce_19), + (20 , happyReduce_20), + (21 , happyReduce_21), + (22 , happyReduce_22), + (23 , happyReduce_23), + (24 , happyReduce_24), + (25 , happyReduce_25), + (26 , happyReduce_26), + (27 , happyReduce_27) + ] + +happy_n_terms = 12 :: Int +happy_n_nonterms = 13 :: Int + +happyReduce_2 = happySpecReduce_2 0# happyReduction_2 +happyReduction_2 happy_x_2 + happy_x_1 + = happyIn5 + ([] + ) + +happyReduce_3 = happySpecReduce_3 0# happyReduction_3 +happyReduction_3 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn5 + (reverse happy_var_2 + )} + +happyReduce_4 = happySpecReduce_1 1# happyReduction_4 +happyReduction_4 happy_x_1 + = case happyOut7 happy_x_1 of { happy_var_1 -> + happyIn6 + ([ happy_var_1 ] + )} + +happyReduce_5 = happySpecReduce_3 1# happyReduction_5 +happyReduction_5 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut7 happy_x_3 of { happy_var_3 -> + happyIn6 + (happy_var_3 : happy_var_1 + )}} + +happyReduce_6 = happyReduce 4# 2# happyReduction_6 +happyReduction_6 (happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut8 happy_x_3 of { happy_var_3 -> + happyIn7 + (happy_var_3 defaultPackageConfig + ) `HappyStk` happyRest} + +happyReduce_7 = happySpecReduce_1 3# happyReduction_7 +happyReduction_7 happy_x_1 + = case happyOut9 happy_x_1 of { happy_var_1 -> + happyIn8 + (\p -> happy_var_1 p + )} + +happyReduce_8 = happySpecReduce_3 3# happyReduction_8 +happyReduction_8 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut9 happy_x_3 of { happy_var_3 -> + happyIn8 + (\p -> happy_var_1 (happy_var_3 p) + )}} + +happyReduce_9 = happySpecReduce_3 4# happyReduction_9 +happyReduction_9 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut10 happy_x_3 of { happy_var_3 -> + happyIn9 + (\p -> case happy_var_1 of + "package" -> p {package = happy_var_3} + _ -> error "unknown key in config file" + )}} + +happyReduce_10 = happySpecReduce_3 4# happyReduction_10 +happyReduction_10 happy_x_3 + happy_x_2 + happy_x_1 + = happyIn9 + (id + ) + +happyReduce_11 = happySpecReduce_3 4# happyReduction_11 +happyReduction_11 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOutTok happy_x_3 of { (ITconid happy_var_3) -> + happyIn9 + (case happy_var_1 of { + "exposed" -> + case happy_var_3 of { + "True" -> (\p -> p {exposed=True}); + "False" -> (\p -> p {exposed=False}); + _ -> error "exposed must be either True or False" }; + "license" -> id; -- not interested + _ -> error "unknown constructor" } + )}} + +happyReduce_12 = happyReduce 4# 4# happyReduction_12 +happyReduction_12 (happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = happyIn9 + (id + ) `HappyStk` happyRest + +happyReduce_13 = happySpecReduce_3 4# happyReduction_13 +happyReduction_13 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut16 happy_x_3 of { happy_var_3 -> + happyIn9 + (\p -> case happy_var_1 of + "exposedModules" -> p{exposedModules = happy_var_3} + "hiddenModules" -> p{hiddenModules = happy_var_3} + "importDirs" -> p{importDirs = happy_var_3} + "libraryDirs" -> p{libraryDirs = happy_var_3} + "hsLibraries" -> p{hsLibraries = happy_var_3} + "extraLibraries" -> p{extraLibraries = happy_var_3} + "includeDirs" -> p{includeDirs = happy_var_3} + "includes" -> p{includes = happy_var_3} + "hugsOptions" -> p{hugsOptions = happy_var_3} + "ccOptions" -> p{ccOptions = happy_var_3} + "ldOptions" -> p{ldOptions = happy_var_3} + "frameworkDirs" -> p{frameworkDirs = happy_var_3} + "frameworks" -> p{frameworks = happy_var_3} + "haddockInterfaces" -> p{haddockInterfaces = happy_var_3} + "haddockHTMLs" -> p{haddockHTMLs = happy_var_3} + "depends" -> p{depends = []} + -- empty list only, non-empty handled below + other -> p + )}} + +happyReduce_14 = happySpecReduce_3 4# happyReduction_14 +happyReduction_14 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut12 happy_x_3 of { happy_var_3 -> + happyIn9 + (case happy_var_1 of + "depends" -> (\p -> p{depends = happy_var_3}) + _other -> error "unknown key in config file" + )}} + +happyReduce_15 = happyReduce 10# 5# happyReduction_15 +happyReduction_15 (happy_x_10 `HappyStk` + happy_x_9 `HappyStk` + happy_x_8 `HappyStk` + happy_x_7 `HappyStk` + happy_x_6 `HappyStk` + happy_x_5 `HappyStk` + happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOutTok happy_x_5 of { (ITstring happy_var_5) -> + case happyOut11 happy_x_9 of { happy_var_9 -> + happyIn10 + (PackageIdentifier{ pkgName = happy_var_5, + pkgVersion = happy_var_9 } + ) `HappyStk` happyRest}} + +happyReduce_16 = happyReduce 10# 6# happyReduction_16 +happyReduction_16 (happy_x_10 `HappyStk` + happy_x_9 `HappyStk` + happy_x_8 `HappyStk` + happy_x_7 `HappyStk` + happy_x_6 `HappyStk` + happy_x_5 `HappyStk` + happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut14 happy_x_5 of { happy_var_5 -> + case happyOut16 happy_x_9 of { happy_var_9 -> + happyIn11 + (Version{ versionBranch=happy_var_5, versionTags=happy_var_9 } + ) `HappyStk` happyRest}} + +happyReduce_17 = happySpecReduce_3 7# happyReduction_17 +happyReduction_17 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut13 happy_x_2 of { happy_var_2 -> + happyIn12 + (happy_var_2 + )} + +happyReduce_18 = happySpecReduce_1 8# happyReduction_18 +happyReduction_18 happy_x_1 + = case happyOut10 happy_x_1 of { happy_var_1 -> + happyIn13 + ([ happy_var_1 ] + )} + +happyReduce_19 = happySpecReduce_3 8# happyReduction_19 +happyReduction_19 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut10 happy_x_1 of { happy_var_1 -> + case happyOut13 happy_x_3 of { happy_var_3 -> + happyIn13 + (happy_var_1 : happy_var_3 + )}} + +happyReduce_20 = happySpecReduce_2 9# happyReduction_20 +happyReduction_20 happy_x_2 + happy_x_1 + = happyIn14 + ([] + ) + +happyReduce_21 = happySpecReduce_3 9# happyReduction_21 +happyReduction_21 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut15 happy_x_2 of { happy_var_2 -> + happyIn14 + (happy_var_2 + )} + +happyReduce_22 = happySpecReduce_1 10# happyReduction_22 +happyReduction_22 happy_x_1 + = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> + happyIn15 + ([ fromIntegral happy_var_1 ] + )} + +happyReduce_23 = happySpecReduce_3 10# happyReduction_23 +happyReduction_23 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> + case happyOut15 happy_x_3 of { happy_var_3 -> + happyIn15 + (fromIntegral happy_var_1 : happy_var_3 + )}} + +happyReduce_24 = happySpecReduce_2 11# happyReduction_24 +happyReduction_24 happy_x_2 + happy_x_1 + = happyIn16 + ([] + ) + +happyReduce_25 = happySpecReduce_3 11# happyReduction_25 +happyReduction_25 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut17 happy_x_2 of { happy_var_2 -> + happyIn16 + (reverse happy_var_2 + )} + +happyReduce_26 = happySpecReduce_1 12# happyReduction_26 +happyReduction_26 happy_x_1 + = case happyOutTok happy_x_1 of { (ITstring happy_var_1) -> + happyIn17 + ([ happy_var_1 ] + )} + +happyReduce_27 = happySpecReduce_3 12# happyReduction_27 +happyReduction_27 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut17 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> + happyIn17 + (happy_var_3 : happy_var_1 + )}} + +happyNewToken action sts stk [] = + happyDoAction 11# (error "reading EOF!") action sts stk [] + +happyNewToken action sts stk (tk:tks) = + let cont i = happyDoAction i tk action sts stk tks in + case tk of { + ITocurly -> cont 1#; + ITccurly -> cont 2#; + ITobrack -> cont 3#; + ITcbrack -> cont 4#; + ITcomma -> cont 5#; + ITequal -> cont 6#; + ITvarid happy_dollar_dollar -> cont 7#; + ITconid happy_dollar_dollar -> cont 8#; + ITstring happy_dollar_dollar -> cont 9#; + ITinteger happy_dollar_dollar -> cont 10#; + _ -> happyError tks + } + +happyThen = \m k -> k m +happyReturn = \a -> a +happyThen1 = happyThen +happyReturn1 = \a tks -> a + +parse tks = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) + +parseOne tks = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) + +happySeq = happyDontSeq + +type PackageConfig = InstalledPackageInfo + +defaultPackageConfig = emptyInstalledPackageInfo + +data Token + = ITocurly + | ITccurly + | ITobrack + | ITcbrack + | ITcomma + | ITequal + | ITvarid String + | ITconid String + | ITstring String + | ITinteger Int + +lexer :: String -> [Token] + +lexer [] = [] +lexer ('{':cs) = ITocurly : lexer cs +lexer ('}':cs) = ITccurly : lexer cs +lexer ('[':cs) = ITobrack : lexer cs +lexer (']':cs) = ITcbrack : lexer cs +lexer (',':cs) = ITcomma : lexer cs +lexer ('=':cs) = ITequal : lexer cs +lexer ('"':cs) = lexString cs "" +lexer (c:cs) + | isSpace c = lexer cs + | isAlpha c = lexID (c:cs) + | isDigit c = lexInt (c:cs) +lexer _ = error ( "Unexpected token") + +lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest + where + (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs + +lexInt cs = let (intStr, rest) = span isDigit cs + in ITinteger (read intStr) : lexer rest + + +lexString ('"':cs) s = ITstring (reverse s) : lexer cs +lexString ('\\':c:cs) s = lexString cs (c:s) +lexString (c:cs) s = lexString cs (c:s) + +happyError _ = error "Couldn't parse package configuration." + +parsePkgConf :: String -> [PackageConfig] +parsePkgConf = parse . lexer + +parseOnePkgConf :: String -> PackageConfig +parseOnePkgConf = parseOne . lexer +{-# LINE 1 "GenericTemplate.hs" #-} +{-# LINE 1 "" #-} +{-# LINE 1 "" #-} +{-# LINE 1 "GenericTemplate.hs" #-} +-- $Id: ParsePkgConfCabal.hs,v 1.1 2005/04/22 08:58:28 dons Exp $ + + +{-# LINE 28 "GenericTemplate.hs" #-} + + +data Happy_IntList = HappyCons Int# Happy_IntList + + + + + + +{-# LINE 49 "GenericTemplate.hs" #-} + + +{-# LINE 59 "GenericTemplate.hs" #-} + + + + + + + + + + +infixr 9 `HappyStk` +data HappyStk a = HappyStk a (HappyStk a) + +----------------------------------------------------------------------------- +-- starting the parse + +happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll + +----------------------------------------------------------------------------- +-- Accepting the parse + +happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j (happyTcHack st)) + + (happyReturn1 ans) + +----------------------------------------------------------------------------- +-- Arrays only: do the next action + + + +happyDoAction i tk st + = {- nothing -} + + + case action of + 0# -> {- nothing -} + happyFail i tk st + -1# -> {- nothing -} + happyAccept i tk st + n | (n <# (0# :: Int#)) -> {- nothing -} + + (happyReduceArr ! rule) i tk st + where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) + n -> {- nothing -} + + + happyShift new_state i tk st + where new_state = (n -# (1# :: Int#)) + where off = indexShortOffAddr happyActOffsets st + off_i = (off +# i) + check = if (off_i >=# (0# :: Int#)) + then (indexShortOffAddr happyCheck off_i ==# i) + else False + action | check = indexShortOffAddr happyTable off_i + | otherwise = indexShortOffAddr happyDefActions st + + + + + + + + + + + +indexShortOffAddr (HappyA# arr) off = +#if __GLASGOW_HASKELL__ > 500 + narrow16Int# i +#elif __GLASGOW_HASKELL__ == 500 + intToInt16# i +#else + (i `iShiftL#` 16#) `iShiftRA#` 16# +#endif + where +#if __GLASGOW_HASKELL__ >= 503 + i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) +#else + i = word2Int# ((high `shiftL#` 8#) `or#` low) +#endif + high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + low = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 2# + + + + + +data HappyAddr = HappyA# Addr# + + + + +----------------------------------------------------------------------------- +-- HappyState data type (not arrays) + +{-# LINE 166 "GenericTemplate.hs" #-} + +----------------------------------------------------------------------------- +-- Shifting a token + +happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = + let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in +-- trace "shifting the error token" $ + happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) + +happyShift new_state i tk st sts stk = + happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) + +-- happyReduce is specialised for the common cases. + +happySpecReduce_0 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_0 nt fn j tk st@((action)) sts stk + = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) + +happySpecReduce_1 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') + = let r = fn v1 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_2 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') + = let r = fn v1 v2 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_3 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') + = let r = fn v1 v2 v3 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happyReduce k i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyReduce k nt fn j tk st sts stk + = case happyDrop (k -# (1# :: Int#)) sts of + sts1@((HappyCons (st1@(action)) (_))) -> + let r = fn stk in -- it doesn't hurt to always seq here... + happyDoSeq r (happyGoto nt j tk st1 sts1 r) + +happyMonadReduce k nt fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyMonadReduce k nt fn j tk st sts stk = + happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) + where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) + drop_stk = happyDropStk k stk + +happyDrop 0# l = l +happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t + +happyDropStk 0# l = l +happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs + +----------------------------------------------------------------------------- +-- Moving to a new state after a reduction + + +happyGoto nt j tk st = + {- nothing -} + happyDoAction j tk new_state + where off = indexShortOffAddr happyGotoOffsets st + off_i = (off +# nt) + new_state = indexShortOffAddr happyTable off_i + + + + +----------------------------------------------------------------------------- +-- Error recovery (0# is the error token) + +-- parse error if we are in recovery and we fail again +happyFail 0# tk old_st _ stk = +-- trace "failing" $ + happyError + + +{- We don't need state discarding for our restricted implementation of + "error". In fact, it can cause some bogus parses, so I've disabled it + for now --SDM + +-- discard a state +happyFail 0# tk old_st (HappyCons ((action)) (sts)) + (saved_tok `HappyStk` _ `HappyStk` stk) = +-- trace ("discarding state, depth " ++ show (length stk)) $ + happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) +-} + +-- Enter error recovery: generate an error token, +-- save the old token and carry on. +happyFail i tk (action) sts stk = +-- trace "entering error recovery" $ + happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) + +-- Internal happy errors: + +notHappyAtAll = error "Internal Happy error\n" + +----------------------------------------------------------------------------- +-- Hack to get the typechecker to accept our action functions + + +happyTcHack :: Int# -> a -> a +happyTcHack x y = y +{-# INLINE happyTcHack #-} + + +----------------------------------------------------------------------------- +-- Seq-ing. If the --strict flag is given, then Happy emits +-- happySeq = happyDoSeq +-- otherwise it emits +-- happySeq = happyDontSeq + +happyDoSeq, happyDontSeq :: a -> b -> b +happyDoSeq a b = a `seq` b +happyDontSeq a b = b + +----------------------------------------------------------------------------- +-- Don't inline any functions from the template. GHC has a nasty habit +-- of deciding to inline happyGoto everywhere, which increases the size of +-- the generated parser quite a bit. + + +{-# NOINLINE happyDoAction #-} +{-# NOINLINE happyTable #-} +{-# NOINLINE happyCheck #-} +{-# NOINLINE happyActOffsets #-} +{-# NOINLINE happyGotoOffsets #-} +{-# NOINLINE happyDefActions #-} + +{-# NOINLINE happyShift #-} +{-# NOINLINE happySpecReduce_0 #-} +{-# NOINLINE happySpecReduce_1 #-} +{-# NOINLINE happySpecReduce_2 #-} +{-# NOINLINE happySpecReduce_3 #-} +{-# NOINLINE happyReduce #-} +{-# NOINLINE happyMonadReduce #-} +{-# NOINLINE happyGoto #-} +{-# NOINLINE happyFail #-} + +-- end of Happy Template. hunk ./src/plugins/Plugins/ParsePkgConfCabal.y 1 +-- +-- Copyright (C) 2005 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- Taken (apart from the most minor of alterations) from +-- ghc/utils/ghc-pkg/ParsePkgConfLite.hs from GHC 6.2.2 source tree +-- and then modified to mimic the behaviour of the parser within +-- ghc/compiler/main/ParsePkgConf.y in GHC 6.4, without importing +-- heavy-weight infrastructure from the GHC source tree such as module +-- FastString, Lexer, etc. +-- +-- (c) Copyright 2002, The University Court of the University of Glasgow. +-- + +{ +{-# OPTIONS -w #-} + +module Plugins.ParsePkgConfCabal ( + parsePkgConf, parseOnePkgConf + ) where + +import Distribution.InstalledPackageInfo +import Distribution.Package +import Distribution.Version + +import Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) +import List ( break ) + +} + +%token + '{' { ITocurly } + '}' { ITccurly } + '[' { ITobrack } + ']' { ITcbrack } + ',' { ITcomma } + '=' { ITequal } + VARID { ITvarid $$ } + CONID { ITconid $$ } + STRING { ITstring $$ } + INT { ITinteger $$ } + +%name parse pkgconf +%name parseOne pkg +%tokentype { Token } +%% + +pkgconf :: { [ PackageConfig ] } + : '[' ']' { [] } + | '[' pkgs ']' { reverse $2 } + +pkgs :: { [ PackageConfig ] } + : pkg { [ $1 ] } + | pkgs ',' pkg { $3 : $1 } + +pkg :: { PackageConfig } + : CONID '{' fields '}' { $3 defaultPackageConfig } + +fields :: { PackageConfig -> PackageConfig } + : field { \p -> $1 p } + | fields ',' field { \p -> $1 ($3 p) } + +field :: { PackageConfig -> PackageConfig } + : VARID '=' pkgid + {\p -> case $1 of + "package" -> p {package = $3} + _ -> error "unknown key in config file" } + + | VARID '=' STRING { id } + -- we aren't interested in the string fields, they're all + -- boring (copyright, maintainer etc.) + + | VARID '=' CONID + { case $1 of { + "exposed" -> + case $3 of { + "True" -> (\p -> p {exposed=True}); + "False" -> (\p -> p {exposed=False}); + _ -> error "exposed must be either True or False" }; + "license" -> id; -- not interested + _ -> error "unknown constructor" } + } + + | VARID '=' CONID STRING { id } + -- another case of license + + | VARID '=' strlist + {\p -> case $1 of + "exposedModules" -> p{exposedModules = $3} + "hiddenModules" -> p{hiddenModules = $3} + "importDirs" -> p{importDirs = $3} + "libraryDirs" -> p{libraryDirs = $3} + "hsLibraries" -> p{hsLibraries = $3} + "extraLibraries" -> p{extraLibraries = $3} + "includeDirs" -> p{includeDirs = $3} + "includes" -> p{includes = $3} + "hugsOptions" -> p{hugsOptions = $3} + "ccOptions" -> p{ccOptions = $3} + "ldOptions" -> p{ldOptions = $3} + "frameworkDirs" -> p{frameworkDirs = $3} + "frameworks" -> p{frameworks = $3} + "haddockInterfaces" -> p{haddockInterfaces = $3} + "haddockHTMLs" -> p{haddockHTMLs = $3} + "depends" -> p{depends = []} + -- empty list only, non-empty handled below + other -> p + } + | VARID '=' pkgidlist + { case $1 of + "depends" -> (\p -> p{depends = $3}) + _other -> error "unknown key in config file" + } + + +pkgid :: { PackageIdentifier } + : CONID '{' VARID '=' STRING ',' VARID '=' version '}' + { PackageIdentifier{ pkgName = $5, + pkgVersion = $9 } } + +version :: { Version } + : CONID '{' VARID '=' intlist ',' VARID '=' strlist '}' + { Version{ versionBranch=$5, versionTags=$9 } } + +pkgidlist :: { [PackageIdentifier] } + : '[' pkgids ']' { $2 } + -- empty list case is covered by strlist, to avoid conflicts + +pkgids :: { [PackageIdentifier] } + : pkgid { [ $1 ] } + | pkgid ',' pkgids { $1 : $3 } + +intlist :: { [Int] } + : '[' ']' { [] } + | '[' ints ']' { $2 } + +ints :: { [Int] } + : INT { [ fromIntegral $1 ] } + | INT ',' ints { fromIntegral $1 : $3 } + +strlist :: { [String] } + : '[' ']' { [] } + | '[' strs ']' { reverse $2 } + +strs :: { [String] } + : STRING { [ $1 ] } + | strs ',' STRING { $3 : $1 } + +{ + +type PackageConfig = InstalledPackageInfo + +defaultPackageConfig = emptyInstalledPackageInfo + +data Token + = ITocurly + | ITccurly + | ITobrack + | ITcbrack + | ITcomma + | ITequal + | ITvarid String + | ITconid String + | ITstring String + | ITinteger Int + +lexer :: String -> [Token] + +lexer [] = [] +lexer ('{':cs) = ITocurly : lexer cs +lexer ('}':cs) = ITccurly : lexer cs +lexer ('[':cs) = ITobrack : lexer cs +lexer (']':cs) = ITcbrack : lexer cs +lexer (',':cs) = ITcomma : lexer cs +lexer ('=':cs) = ITequal : lexer cs +lexer ('"':cs) = lexString cs "" +lexer (c:cs) + | isSpace c = lexer cs + | isAlpha c = lexID (c:cs) + | isDigit c = lexInt (c:cs) +lexer _ = error ( "Unexpected token") + +lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest + where + (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs + +lexInt cs = let (intStr, rest) = span isDigit cs + in ITinteger (read intStr) : lexer rest + + +lexString ('"':cs) s = ITstring (reverse s) : lexer cs +lexString ('\\':c:cs) s = lexString cs (c:s) +lexString (c:cs) s = lexString cs (c:s) + +happyError _ = error "Couldn't parse package configuration." + +parsePkgConf :: String -> [PackageConfig] +parsePkgConf = parse . lexer + +parseOnePkgConf :: String -> PackageConfig +parseOnePkgConf = parseOne . lexer + +} hunk ./src/plugins/Plugins/ParsePkgConfLite.hs 1 +{-# OPTIONS -fglasgow-exts -cpp -w #-} +-- parser produced by Happy Version 1.14 + + + +module Plugins.ParsePkgConfLite ( + parsePkgConf, parseOnePkgConf + ) where + +import Plugins.Package ( PackageConfig(..), defaultPackageConfig ) + +import Char ( isSpace, isAlpha, isAlphaNum, isUpper ) +import List ( break ) +import Array +#if __GLASGOW_HASKELL__ >= 503 +import GHC.Exts +#else +import GlaExts +#endif + +newtype HappyAbsSyn = HappyAbsSyn (() -> ()) +happyIn5 :: ([ PackageConfig ]) -> (HappyAbsSyn ) +happyIn5 x = unsafeCoerce# x +{-# INLINE happyIn5 #-} +happyOut5 :: (HappyAbsSyn ) -> ([ PackageConfig ]) +happyOut5 x = unsafeCoerce# x +{-# INLINE happyOut5 #-} +happyIn6 :: ([ PackageConfig ]) -> (HappyAbsSyn ) +happyIn6 x = unsafeCoerce# x +{-# INLINE happyIn6 #-} +happyOut6 :: (HappyAbsSyn ) -> ([ PackageConfig ]) +happyOut6 x = unsafeCoerce# x +{-# INLINE happyOut6 #-} +happyIn7 :: (PackageConfig) -> (HappyAbsSyn ) +happyIn7 x = unsafeCoerce# x +{-# INLINE happyIn7 #-} +happyOut7 :: (HappyAbsSyn ) -> (PackageConfig) +happyOut7 x = unsafeCoerce# x +{-# INLINE happyOut7 #-} +happyIn8 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) +happyIn8 x = unsafeCoerce# x +{-# INLINE happyIn8 #-} +happyOut8 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) +happyOut8 x = unsafeCoerce# x +{-# INLINE happyOut8 #-} +happyIn9 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) +happyIn9 x = unsafeCoerce# x +{-# INLINE happyIn9 #-} +happyOut9 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) +happyOut9 x = unsafeCoerce# x +{-# INLINE happyOut9 #-} +happyIn10 :: ([String]) -> (HappyAbsSyn ) +happyIn10 x = unsafeCoerce# x +{-# INLINE happyIn10 #-} +happyOut10 :: (HappyAbsSyn ) -> ([String]) +happyOut10 x = unsafeCoerce# x +{-# INLINE happyOut10 #-} +happyIn11 :: ([String]) -> (HappyAbsSyn ) +happyIn11 x = unsafeCoerce# x +{-# INLINE happyIn11 #-} +happyOut11 :: (HappyAbsSyn ) -> ([String]) +happyOut11 x = unsafeCoerce# x +{-# INLINE happyOut11 #-} +happyIn12 :: (Bool) -> (HappyAbsSyn ) +happyIn12 x = unsafeCoerce# x +{-# INLINE happyIn12 #-} +happyOut12 :: (HappyAbsSyn ) -> (Bool) +happyOut12 x = unsafeCoerce# x +{-# INLINE happyOut12 #-} +happyInTok :: Token -> (HappyAbsSyn ) +happyInTok x = unsafeCoerce# x +{-# INLINE happyInTok #-} +happyOutTok :: (HappyAbsSyn ) -> Token +happyOutTok x = unsafeCoerce# x +{-# INLINE happyOutTok #-} + +happyActOffsets :: HappyAddr +happyActOffsets = HappyA# "\x1f\x00\x1e\x00\x1d\x00\x1b\x00\x1a\x00\x1c\x00\x19\x00\x01\x00\x0e\x00\x00\x00\x00\x00\x17\x00\x08\x00\x00\x00\x16\x00\x00\x00\x13\x00\x00\x00\xfe\xff\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00"# + +happyGotoOffsets :: HappyAddr +happyGotoOffsets = HappyA# "\x18\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\xfd\xff\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# + +happyDefActions :: HappyAddr +happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xfd\xff\x00\x00\x00\x00\xf8\xff\x00\x00\xfc\xff\x00\x00\xfa\xff\x00\x00\xf9\xff\x00\x00\xf7\xff\xf4\xff\xf5\xff\x00\x00\xef\xff\xf6\xff\x00\x00\xf3\xff\xf1\xff\xf2\xff\x00\x00\xf0\xff"# + +happyCheck :: HappyAddr +happyCheck = HappyA# "\xff\xff\x03\x00\x05\x00\x04\x00\x07\x00\x04\x00\x08\x00\x09\x00\x09\x00\x08\x00\x02\x00\x01\x00\x02\x00\x05\x00\x03\x00\x04\x00\x04\x00\x05\x00\x04\x00\x05\x00\x04\x00\x06\x00\x02\x00\x02\x00\x00\x00\x07\x00\x09\x00\x08\x00\x06\x00\x01\x00\x07\x00\x04\x00\x03\x00\xff\xff\x03\x00\x0a\x00\x0a\x00\xff\xff\x08\x00\xff\xff\xff\xff\xff\xff"# + +happyTable :: HappyAddr +happyTable = HappyA# "\x00\x00\x19\x00\x16\x00\x1d\x00\x17\x00\x0b\x00\x1a\x00\x1b\x00\x1e\x00\x06\x00\x14\x00\x08\x00\x09\x00\x15\x00\x0c\x00\x0d\x00\x1f\x00\x20\x00\x10\x00\x11\x00\x15\x00\x1b\x00\x11\x00\x04\x00\x06\x00\x0f\x00\x21\x00\x06\x00\x13\x00\x0c\x00\x0f\x00\x0b\x00\x04\x00\x00\x00\x08\x00\xff\xff\xff\xff\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00"# + +happyReduceArr = array (2, 16) [ + (2 , happyReduce_2), + (3 , happyReduce_3), + (4 , happyReduce_4), + (5 , happyReduce_5), + (6 , happyReduce_6), + (7 , happyReduce_7), + (8 , happyReduce_8), + (9 , happyReduce_9), + (10 , happyReduce_10), + (11 , happyReduce_11), + (12 , happyReduce_12), + (13 , happyReduce_13), + (14 , happyReduce_14), + (15 , happyReduce_15), + (16 , happyReduce_16) + ] + +happy_n_terms = 11 :: Int +happy_n_nonterms = 8 :: Int + +happyReduce_2 = happySpecReduce_2 0# happyReduction_2 +happyReduction_2 happy_x_2 + happy_x_1 + = happyIn5 + ([] + ) + +happyReduce_3 = happySpecReduce_3 0# happyReduction_3 +happyReduction_3 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn5 + (reverse happy_var_2 + )} + +happyReduce_4 = happySpecReduce_1 1# happyReduction_4 +happyReduction_4 happy_x_1 + = case happyOut7 happy_x_1 of { happy_var_1 -> + happyIn6 + ([ happy_var_1 ] + )} + +happyReduce_5 = happySpecReduce_3 1# happyReduction_5 +happyReduction_5 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut7 happy_x_3 of { happy_var_3 -> + happyIn6 + (happy_var_3 : happy_var_1 + )}} + +happyReduce_6 = happyReduce 4# 2# happyReduction_6 +happyReduction_6 (happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut8 happy_x_3 of { happy_var_3 -> + happyIn7 + (happy_var_3 defaultPackageConfig + ) `HappyStk` happyRest} + +happyReduce_7 = happySpecReduce_1 3# happyReduction_7 +happyReduction_7 happy_x_1 + = case happyOut9 happy_x_1 of { happy_var_1 -> + happyIn8 + (\p -> happy_var_1 p + )} + +happyReduce_8 = happySpecReduce_3 3# happyReduction_8 +happyReduction_8 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut9 happy_x_3 of { happy_var_3 -> + happyIn8 + (\p -> happy_var_1 (happy_var_3 p) + )}} + +happyReduce_9 = happySpecReduce_3 4# happyReduction_9 +happyReduction_9 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> + happyIn9 + (\p -> case happy_var_1 of + "name" -> p{name = happy_var_3} + _ -> error "unknown key in config file" + )}} + +happyReduce_10 = happySpecReduce_3 4# happyReduction_10 +happyReduction_10 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut12 happy_x_3 of { happy_var_3 -> + happyIn9 + (\p -> case happy_var_1 of { + "auto" -> p{auto = happy_var_3}; + _ -> p } + )}} + +happyReduce_11 = happySpecReduce_3 4# happyReduction_11 +happyReduction_11 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut10 happy_x_3 of { happy_var_3 -> + happyIn9 + (\p -> case happy_var_1 of + "import_dirs" -> p{import_dirs = happy_var_3} + "library_dirs" -> p{library_dirs = happy_var_3} + "hs_libraries" -> p{hs_libraries = happy_var_3} + "extra_libraries" -> p{extra_libraries = happy_var_3} + "include_dirs" -> p{include_dirs = happy_var_3} + "c_includes" -> p{c_includes = happy_var_3} + "package_deps" -> p{package_deps = happy_var_3} + "extra_ghc_opts" -> p{extra_ghc_opts = happy_var_3} + "extra_cc_opts" -> p{extra_cc_opts = happy_var_3} + "extra_ld_opts" -> p{extra_ld_opts = happy_var_3} + "framework_dirs" -> p{framework_dirs = happy_var_3} + "extra_frameworks"-> p{extra_frameworks= happy_var_3} + _other -> p + )}} + +happyReduce_12 = happySpecReduce_2 5# happyReduction_12 +happyReduction_12 happy_x_2 + happy_x_1 + = happyIn10 + ([] + ) + +happyReduce_13 = happySpecReduce_3 5# happyReduction_13 +happyReduction_13 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut11 happy_x_2 of { happy_var_2 -> + happyIn10 + (reverse happy_var_2 + )} + +happyReduce_14 = happySpecReduce_1 6# happyReduction_14 +happyReduction_14 happy_x_1 + = case happyOutTok happy_x_1 of { (ITstring happy_var_1) -> + happyIn11 + ([ happy_var_1 ] + )} + +happyReduce_15 = happySpecReduce_3 6# happyReduction_15 +happyReduction_15 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut11 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> + happyIn11 + (happy_var_3 : happy_var_1 + )}} + +happyReduce_16 = happyMonadReduce 1# 7# happyReduction_16 +happyReduction_16 (happy_x_1 `HappyStk` + happyRest) + = happyThen (case happyOutTok happy_x_1 of { (ITconid happy_var_1) -> + case happy_var_1 of { + "True" -> True; + "False" -> False; + _ -> error ("unknown constructor in config file: " ++ happy_var_1) }} + ) (\r -> happyReturn (happyIn12 r)) + +happyNewToken action sts stk [] = + happyDoAction 10# (error "reading EOF!") action sts stk [] + +happyNewToken action sts stk (tk:tks) = + let cont i = happyDoAction i tk action sts stk tks in + case tk of { + ITocurly -> cont 1#; + ITccurly -> cont 2#; + ITobrack -> cont 3#; + ITcbrack -> cont 4#; + ITcomma -> cont 5#; + ITequal -> cont 6#; + ITvarid happy_dollar_dollar -> cont 7#; + ITconid happy_dollar_dollar -> cont 8#; + ITstring happy_dollar_dollar -> cont 9#; + _ -> happyError tks + } + +happyThen = \m k -> k m +happyReturn = \a -> a +happyThen1 = happyThen +happyReturn1 = \a tks -> a + +parse tks = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) + +parseOne tks = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) + +happySeq = happyDontSeq + +data Token + = ITocurly + | ITccurly + | ITobrack + | ITcbrack + | ITcomma + | ITequal + | ITvarid String + | ITconid String + | ITstring String + +lexer :: String -> [Token] + +lexer [] = [] +lexer ('{':cs) = ITocurly : lexer cs +lexer ('}':cs) = ITccurly : lexer cs +lexer ('[':cs) = ITobrack : lexer cs +lexer (']':cs) = ITcbrack : lexer cs +lexer (',':cs) = ITcomma : lexer cs +lexer ('=':cs) = ITequal : lexer cs +lexer ('"':cs) = lexString cs "" +lexer (c:cs) + | isSpace c = lexer cs + | isAlpha c = lexID (c:cs) where +lexer _ = error "Unexpected token" + +lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest + where + (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs + +lexString ('"':cs) s = ITstring (reverse s) : lexer cs +lexString ('\\':c:cs) s = lexString cs (c:s) +lexString (c:cs) s = lexString cs (c:s) + +happyError _ = error "Couldn't parse package configuration." + +parsePkgConf :: String -> [PackageConfig] +parsePkgConf = parse . lexer + +parseOnePkgConf :: String -> PackageConfig +parseOnePkgConf = parseOne . lexer +{-# LINE 1 "GenericTemplate.hs" #-} +-- $Id: ParsePkgConfLite.hs,v 1.3 2004/06/19 01:28:56 dons Exp $ + + + + + + + + + + + + + +{-# LINE 27 "GenericTemplate.hs" #-} + + + +data Happy_IntList = HappyCons Int# Happy_IntList + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +infixr 9 `HappyStk` +data HappyStk a = HappyStk a (HappyStk a) + +----------------------------------------------------------------------------- +-- starting the parse + +happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll + +----------------------------------------------------------------------------- +-- Accepting the parse + +happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j + (happyTcHack st)) + (happyReturn1 ans) + +----------------------------------------------------------------------------- +-- Arrays only: do the next action + + + +happyDoAction i tk st + = {- nothing -} + + + case action of + 0# -> {- nothing -} + happyFail i tk st + -1# -> {- nothing -} + happyAccept i tk st + n | (n <# (0# :: Int#)) -> {- nothing -} + + (happyReduceArr ! rule) i tk st + where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) + n -> {- nothing -} + + + happyShift new_state i tk st + where new_state = (n -# (1# :: Int#)) + where off = indexShortOffAddr happyActOffsets st + off_i = (off +# i) + check = if (off_i >=# (0# :: Int#)) + then (indexShortOffAddr happyCheck off_i ==# i) + else False + action | check = indexShortOffAddr happyTable off_i + | otherwise = indexShortOffAddr happyDefActions st + + + + + + + + + + + +indexShortOffAddr (HappyA# arr) off = +#if __GLASGOW_HASKELL__ > 500 + narrow16Int# i +#elif __GLASGOW_HASKELL__ == 500 + intToInt16# i +#else + (i `iShiftL#` 16#) `iShiftRA#` 16# +#endif + where +#if __GLASGOW_HASKELL__ >= 503 + i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) +#else + i = word2Int# ((high `shiftL#` 8#) `or#` low) +#endif + high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + low = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 2# + + + + + +data HappyAddr = HappyA# Addr# + + + + +----------------------------------------------------------------------------- +-- HappyState data type (not arrays) + +{-# LINE 165 "GenericTemplate.hs" #-} + + +----------------------------------------------------------------------------- +-- Shifting a token + +happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = + let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in +-- trace "shifting the error token" $ + happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) + +happyShift new_state i tk st sts stk = + happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) + +-- happyReduce is specialised for the common cases. + +happySpecReduce_0 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_0 nt fn j tk st@((action)) sts stk + = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) + +happySpecReduce_1 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') + = let r = fn v1 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_2 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') + = let r = fn v1 v2 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_3 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') + = let r = fn v1 v2 v3 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happyReduce k i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyReduce k nt fn j tk st sts stk + = case happyDrop (k -# (1# :: Int#)) sts of + sts1@((HappyCons (st1@(action)) (_))) -> + let r = fn stk in -- it doesn't hurt to always seq here... + happyDoSeq r (happyGoto nt j tk st1 sts1 r) + +happyMonadReduce k nt fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyMonadReduce k nt fn j tk st sts stk = + happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) + where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) + drop_stk = happyDropStk k stk + +happyDrop 0# l = l +happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t + +happyDropStk 0# l = l +happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs + +----------------------------------------------------------------------------- +-- Moving to a new state after a reduction + + +happyGoto nt j tk st = + {- nothing -} + happyDoAction j tk new_state + where off = indexShortOffAddr happyGotoOffsets st + off_i = (off +# nt) + new_state = indexShortOffAddr happyTable off_i + + + + +----------------------------------------------------------------------------- +-- Error recovery (0# is the error token) + +-- parse error if we are in recovery and we fail again +happyFail 0# tk old_st _ stk = +-- trace "failing" $ + happyError + + +{- We don't need state discarding for our restricted implementation of + "error". In fact, it can cause some bogus parses, so I've disabled it + for now --SDM + +-- discard a state +happyFail 0# tk old_st (HappyCons ((action)) (sts)) + (saved_tok `HappyStk` _ `HappyStk` stk) = +-- trace ("discarding state, depth " ++ show (length stk)) $ + happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) +-} + +-- Enter error recovery: generate an error token, +-- save the old token and carry on. +happyFail i tk (action) sts stk = +-- trace "entering error recovery" $ + happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) + +-- Internal happy errors: + +notHappyAtAll = error "Internal Happy error\n" + +----------------------------------------------------------------------------- +-- Hack to get the typechecker to accept our action functions + + +happyTcHack :: Int# -> a -> a +happyTcHack x y = y +{-# INLINE happyTcHack #-} + + +----------------------------------------------------------------------------- +-- Seq-ing. If the --strict flag is given, then Happy emits +-- happySeq = happyDoSeq +-- otherwise it emits +-- happySeq = happyDontSeq + +happyDoSeq, happyDontSeq :: a -> b -> b +happyDoSeq a b = a `seq` b +happyDontSeq a b = b + +----------------------------------------------------------------------------- +-- Don't inline any functions from the template. GHC has a nasty habit +-- of deciding to inline happyGoto everywhere, which increases the size of +-- the generated parser quite a bit. + + +{-# NOINLINE happyDoAction #-} +{-# NOINLINE happyTable #-} +{-# NOINLINE happyCheck #-} +{-# NOINLINE happyActOffsets #-} +{-# NOINLINE happyGotoOffsets #-} +{-# NOINLINE happyDefActions #-} + +{-# NOINLINE happyShift #-} +{-# NOINLINE happySpecReduce_0 #-} +{-# NOINLINE happySpecReduce_1 #-} +{-# NOINLINE happySpecReduce_2 #-} +{-# NOINLINE happySpecReduce_3 #-} +{-# NOINLINE happyReduce #-} +{-# NOINLINE happyMonadReduce #-} +{-# NOINLINE happyGoto #-} +{-# NOINLINE happyFail #-} + +-- end of Happy Template. hunk ./src/plugins/Plugins/ParsePkgConfLite.y 1 +-- +-- Copyright (C) 2004 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- Taken (apart from the most minor of alterations) from +-- ghc/utils/ghc-pkg/ParsePkgConfLite.hs: +-- +-- (c) Copyright 2002, The University Court of the University of Glasgow. +-- + +{ + +{-# OPTIONS -w #-} + +module Plugins.ParsePkgConfLite ( + parsePkgConf, parseOnePkgConf + ) where + +import Plugins.Package ( PackageConfig(..), defaultPackageConfig ) + +import Char ( isSpace, isAlpha, isAlphaNum, isUpper ) +import List ( break ) + +} + +%token + '{' { ITocurly } + '}' { ITccurly } + '[' { ITobrack } + ']' { ITcbrack } + ',' { ITcomma } + '=' { ITequal } + VARID { ITvarid $$ } + CONID { ITconid $$ } + STRING { ITstring $$ } + +%name parse pkgconf +%name parseOne pkg +%tokentype { Token } +%% + +pkgconf :: { [ PackageConfig ] } + : '[' ']' { [] } + | '[' pkgs ']' { reverse $2 } + +pkgs :: { [ PackageConfig ] } + : pkg { [ $1 ] } + | pkgs ',' pkg { $3 : $1 } + +pkg :: { PackageConfig } + : CONID '{' fields '}' { $3 defaultPackageConfig } + +fields :: { PackageConfig -> PackageConfig } + : field { \p -> $1 p } + | fields ',' field { \p -> $1 ($3 p) } + +field :: { PackageConfig -> PackageConfig } + : VARID '=' STRING + {\p -> case $1 of + "name" -> p{name = $3} + _ -> error "unknown key in config file" } + + | VARID '=' bool + {\p -> case $1 of { + "auto" -> p{auto = $3}; + _ -> p } } + + | VARID '=' strlist + {\p -> case $1 of + "import_dirs" -> p{import_dirs = $3} + "library_dirs" -> p{library_dirs = $3} + "hs_libraries" -> p{hs_libraries = $3} + "extra_libraries" -> p{extra_libraries = $3} + "include_dirs" -> p{include_dirs = $3} + "c_includes" -> p{c_includes = $3} + "package_deps" -> p{package_deps = $3} + "extra_ghc_opts" -> p{extra_ghc_opts = $3} + "extra_cc_opts" -> p{extra_cc_opts = $3} + "extra_ld_opts" -> p{extra_ld_opts = $3} + "framework_dirs" -> p{framework_dirs = $3} + "extra_frameworks"-> p{extra_frameworks= $3} + _other -> p + } + +strlist :: { [String] } + : '[' ']' { [] } + | '[' strs ']' { reverse $2 } + +strs :: { [String] } + : STRING { [ $1 ] } + | strs ',' STRING { $3 : $1 } + +bool :: { Bool } + : CONID {% case $1 of { + "True" -> True; + "False" -> False; + _ -> error ("unknown constructor in config file: " ++ $1) } } + +{ + +data Token + = ITocurly + | ITccurly + | ITobrack + | ITcbrack + | ITcomma + | ITequal + | ITvarid String + | ITconid String + | ITstring String + +lexer :: String -> [Token] + +lexer [] = [] +lexer ('{':cs) = ITocurly : lexer cs +lexer ('}':cs) = ITccurly : lexer cs +lexer ('[':cs) = ITobrack : lexer cs +lexer (']':cs) = ITcbrack : lexer cs +lexer (',':cs) = ITcomma : lexer cs +lexer ('=':cs) = ITequal : lexer cs +lexer ('"':cs) = lexString cs "" +lexer (c:cs) + | isSpace c = lexer cs + | isAlpha c = lexID (c:cs) where +lexer _ = error "Unexpected token" + +lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest + where + (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs + +lexString ('"':cs) s = ITstring (reverse s) : lexer cs +lexString ('\\':c:cs) s = lexString cs (c:s) +lexString (c:cs) s = lexString cs (c:s) + +happyError _ = error "Couldn't parse package configuration." + +parsePkgConf :: String -> [PackageConfig] +parsePkgConf = parse . lexer + +parseOnePkgConf :: String -> PackageConfig +parseOnePkgConf = parseOne . lexer + +} hunk ./src/plugins/Plugins/Parser.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- 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. +-- + +module Plugins.Parser ( + parse, mergeModules, pretty, parsePragmas, + HsModule(..) , + replaceModName + ) where + +import Data.List +import Data.Char +import Data.Either + +import Language.Haskell.Parser +import Language.Haskell.Syntax +import Language.Haskell.Pretty + +-- +-- | parse a file (as a string) as Haskell src +-- +parse :: FilePath -- ^ module name + -> String -- ^ haskell src + -> Either String HsModule -- ^ abstract syntax + +parse f fsrc = + case parseModuleWithMode (ParseMode f) fsrc of + ParseOk src -> Right src + ParseFailed loc _ -> Left $ srcmsg loc + where + srcmsg loc = "parse error in " ++ f ++ "\n" ++ + "line: " ++ (show $ srcLine loc) ++ + ", col: " ++ (show $ srcColumn loc)++ "\n" + +-- +-- | pretty print haskell src +-- +-- doesn't handle operators with '#' at the end. i.e. unsafeCoerce# +-- +pretty :: HsModule -> String +pretty code = prettyPrintWithMode (defaultMode { linePragmas = True }) code + + +-- | +-- mergeModules : generate a full Haskell src file, give a .hs config +-- file, and a stub to take default syntax and decls from. Mostly we +-- just ensure they don't do anything bad, and that the names are +-- correct for the module. +-- +-- Transformations: +-- +-- * Take src location pragmas from the conf file (1st file) +-- * Use the template's (2nd argument) module name +-- * Only use export list from template (2nd arg) +-- * Merge top-level decls +-- * need to force the type of the plugin to match the stub, +-- overwriting any type they supply. +-- +mergeModules :: HsModule -> -- ^ Configure module + HsModule -> -- ^ Template module + HsModule -- ^ A merge of the two + +mergeModules (HsModule l _ _ is ds ) + (HsModule _ m' es' is' ds') + = (HsModule l m' es' + (mImps m' is is') + (mDecl ds ds') ) + +-- +-- replace Module name with String. +-- +replaceModName :: HsModule -> String -> HsModule +replaceModName (HsModule l _ es is ds) nm = (HsModule l (Module nm) es is ds) + +-- +-- | merge import declarations: +-- +-- * ensure that the config file doesn't import the stub name +-- * merge import lists uniquely, and when they match, merge their decls +-- +-- TODO : we don't merge imports of the same module from both files. +-- We should, and then merge the decls in their import list +-- ** rename args, too confusing. +-- +-- quick fix: strip all type signatures from the source. +-- +mImps :: Module -> -- ^ plugin module name + [HsImportDecl] -> -- ^ conf file imports + [HsImportDecl] -> -- ^ stub file imports + [HsImportDecl] + +mImps plug_mod cimps timps = + case filter (!~ self) cimps of cimps' -> unionBy (=~) cimps' timps + where + self = ( HsImportDecl undefined plug_mod undefined undefined undefined ) + +-- +-- | merge top-level declarations +-- +-- Remove decls found in template, using those from the config file. +-- Need to sort decls by types, then decls first, in both. +-- +-- * could we write a pass to handle "editor, foo :: String" ? +-- +-- we must keep the type from the template. +-- +mDecl ds es = let ds' = filter (\t->not $ typeDecl t) ds -- rm type sigs from plugin + in sortBy decls $! unionBy (=~) ds' es + where + decls a b = compare (encoding a) (encoding b) + + typeDecl :: HsDecl -> Bool + typeDecl (HsTypeSig _ _ _) = True + typeDecl _ = False + + encoding :: HsDecl -> Int + encoding d = case d of + HsFunBind _ -> 1 + HsPatBind _ _ _ _ -> 1 + _ -> 0 + +-- +-- syntactic equality over the useful Haskell abstract syntax +-- this may be extended if we try to merge the files more thoroughly +-- +class SynEq a where + (=~) :: a -> a -> Bool + (!~) :: a -> a -> Bool + n !~ m = not (n =~ m) + +instance SynEq HsDecl where + (HsPatBind _ (HsPVar n) _ _) =~ (HsPatBind _ (HsPVar m) _ _) = n == m + (HsTypeSig _ (n:_) _) =~ (HsTypeSig _ (m:_) _) = n == m + _ =~ _ = False + +instance SynEq HsImportDecl where + (HsImportDecl _ m _ _ _) =~ (HsImportDecl _ n _ _ _) = n == m + + +-- +-- | Parsing option pragmas. +-- +-- This is not a type checker. If the user supplies bogus options, +-- they'll get slightly mystical error messages. Also, we *want* to +-- handle -package options, and other *static* flags. This is more than +-- GHC. +-- +-- GHC user's guide : +-- "OPTIONS pragmas are only looked for at the top of your source +-- files, upto the first (non-literate,non-empty) line not +-- containing OPTIONS. Multiple OPTIONS pragmas are recognised." +-- +-- based on getOptionsFromSource(), in main/DriverUtil.hs +-- +parsePragmas :: String -- ^ input src + -> ([String],[String]) -- ^ normal options, global options + +parsePragmas s = look $ lines s + where + look [] = ([],[]) + look (l':ls) = + let l = remove_spaces l' + in case () of + () | null l -> look ls + | prefixMatch "#" l -> look ls + | prefixMatch "{-# LINE" l -> look ls + | Just (Option o) <- matchPragma l + -> let (as,bs) = look ls in (words o ++ as,bs) + | Just (Global g) <- matchPragma l + -> let (as,bs) = look ls in (as,words g ++ bs) + | otherwise -> ([],[]) + +-- +-- based on main/DriverUtil.hs +-- +-- extended to handle dynamic options too +-- + +data Pragma = Option !String | Global !String + +matchPragma :: String -> Maybe Pragma +matchPragma s + | Just s1 <- maybePrefixMatch "{-#" s, -- -} + Just s2 <- maybePrefixMatch "OPTIONS" (remove_spaces s1), + Just s3 <- maybePrefixMatch "}-#" (reverse s2) + = Just (Option (reverse s3)) + + | Just s1 <- maybePrefixMatch "{-#" s, -- -} + Just s2 <- maybePrefixMatch "GLOBALOPTIONS" (remove_spaces s1), + Just s3 <- maybePrefixMatch "}-#" (reverse s2) + = Just (Global (reverse s3)) + + | otherwise + = Nothing + +remove_spaces :: String -> String +remove_spaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace + +-- +-- verbatim from utils/Utils.lhs +-- +prefixMatch :: Eq a => [a] -> [a] -> Bool +prefixMatch [] _str = True +prefixMatch _pat [] = False +prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss + | otherwise = False + +maybePrefixMatch :: String -> String -> Maybe String +maybePrefixMatch [] rest = Just rest +maybePrefixMatch (_:_) [] = Nothing +maybePrefixMatch (p:pat) (r:rest) + | p == r = maybePrefixMatch pat rest + | otherwise = Nothing hunk ./src/plugins/Plugins/Utils.hs 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +#include "../../../config.h" + +module Plugins.Utils ( + Arg, + + hWrite, + + mkUnique, + hMkUnique, + mkUniqueIn, + hMkUniqueIn, + + mkTemp, mkTempIn, {- internal -} + + replaceSuffix, + outFilePath, + dropSuffix, + mkModid, + + isSublistOf, -- :: Eq a => [a] -> [a] -> Bool + + dirname, + basename, + + (), (<.>), (<+>), (<>), + + newer, + + encode, + decode, + EncodedString, + + exec, + panic + + ) where + +import Plugins.Env ( isLoaded ) +import Plugins.Consts ( objSuf, hiSuf, tmpDir ) +import qualified Plugins.MkTemp ( mkstemps ) + +import Data.Char +import Data.List + +import System.IO +import System.Environment ( getEnv ) +import System.Directory + +-- +-- The fork library +-- +#if CABAL == 0 && __GLASGOW_HASKELL__ < 604 +import POpen ( popen ) +import System.Posix.Process ( getProcessStatus ) +#else +import System.Process +#endif + +-- --------------------------------------------------------------------- +-- some misc types we use + +type Arg = String + +-- --------------------------------------------------------------------- +-- | useful +-- +panic s = ioError ( userError s ) + +-- --------------------------------------------------------------------- +-- | writeFile for Handles +-- +hWrite :: Handle -> String -> IO () +hWrite hdl src = hPutStr hdl src >> hClose hdl >> return () + + +-- --------------------------------------------------------------------- +-- | mkstemps. +-- +-- We use the Haskell version now... it is faster than calling into +-- mkstemps(3). +-- + +mkstemps :: String -> Int -> IO (String,Handle) +mkstemps path slen = do + m_v <- Plugins.MkTemp.mkstemps path slen + case m_v of Nothing -> error "mkstemps : couldn't create temp file" + Just v' -> return v' + +{- + +mkstemps path slen = do + withCString path $ \ ptr -> do + let c_slen = fromIntegral $ slen+1 + fd <- throwErrnoIfMinus1 "mkstemps" $ c_mkstemps ptr c_slen + name <- peekCString ptr + hdl <- fdToHandle fd + return (name, hdl) + +foreign import ccall unsafe "mkstemps" c_mkstemps :: CString -> CInt -> IO Fd + +-} + +-- --------------------------------------------------------------------- +-- | create a new temp file, returning name and handle. +-- bit like the mktemp shell utility +-- +mkTemp :: IO (String,Handle) +mkTemp = do tmpd <- catch (getEnv "TMPDIR") (\_ -> return tmpDir) + mkTempIn tmpd + +mkTempIn :: String -> IO (String, Handle) +mkTempIn tmpd = do + (tmpf,hdl) <- mkstemps (tmpd++"/MXXXXXXXXX.hs") 3 + let modname = mkModid $ dropSuffix tmpf + if and $ map (\c -> isAlphaNum c && c /= '_') modname + then return (tmpf,hdl) + else panic $ "Illegal characters in temp file: `"++tmpf++"'" + +-- --------------------------------------------------------------------- +-- | Get a new temp file, unique from those in /tmp, and from those +-- modules already loaded. Very nice for merge/eval uses. +-- +-- Will run for a long time if we can't create a temp file, luckily +-- mkstemps gives us a pretty big search space +-- +mkUnique :: IO FilePath +mkUnique = do (t,h) <- hMkUnique + hClose h >> return t + +hMkUnique :: IO (FilePath,Handle) +hMkUnique = do (t,h) <- mkTemp + alreadyLoaded <- isLoaded t -- not unique! + if alreadyLoaded + then hClose h >> removeFile t >> hMkUnique + else return (t,h) + +mkUniqueIn :: FilePath -> IO FilePath +mkUniqueIn dir = do (t,h) <- hMkUniqueIn dir + hClose h >> return t + +hMkUniqueIn :: FilePath -> IO (FilePath,Handle) +hMkUniqueIn dir = do (t,h) <- mkTempIn dir + alreadyLoaded <- isLoaded t -- not unique! + if alreadyLoaded + then hClose h >> removeFile t >> hMkUniqueIn dir + else return (t,h) + +-- --------------------------------------------------------------------- +-- +-- | execute a command and it's arguments, returning the +-- (stdout,stderr), waiting for it to exit, too. +-- + +exec :: String -> [String] -> IO ([String],[String]) + +#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 +-- +-- Use the forkProcess library +-- +exec prog args = do + (_,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing + b <- waitForProcess proc_hdl -- wait + out <- hGetContents outh + err <- hGetContents errh + case b of + _exit_status -> return ( lines $ out, lines $ err ) + +#else +-- +-- 6.2.2 Posix version. +-- +exec prog args = do + (out,err,pid) <- popen prog args Nothing + b <- getProcessStatus True False pid -- wait + case b of + Nothing -> return ([], ["process `"++prog++"' has disappeared"]) + _ -> return ( lines $! out, lines $! err ) +#endif + +-- --------------------------------------------------------------------- +-- some filename manipulation stuff + +-- +-- | , <.> : join two path components +-- +infixr 6 +infixr 6 <.> + +(), (<.>), (<+>), (<>) :: FilePath -> FilePath -> FilePath +[] b = b +a b = a ++ "/" ++ b + +[] <.> b = b +a <.> b = a ++ "." ++ b + +[] <+> b = b +a <+> b = a ++ " " ++ b + +[] <> b = b +a <> b = a ++ b + +-- +-- | dirname : return the directory portion of a file path +-- if null, return "." +-- +dirname :: FilePath -> FilePath +dirname p = + case reverse $ dropWhile (/= '/') $ reverse p of + [] -> "." + p' -> p' + +-- +-- | basename : return the filename portion of a path +-- +basename :: FilePath -> FilePath +basename p = reverse $ takeWhile (/= '/') $ reverse p + +-- +-- drop suffix +-- +dropSuffix :: FilePath -> FilePath +dropSuffix f = reverse . tail . dropWhile (/= '.') $ reverse f + +-- +-- | work out the mod name from a filepath +mkModid :: String -> String +mkModid = (takeWhile (/= '.')) . reverse . (takeWhile (/= '/')) . reverse + +-- | return the object file, given the .conf file +-- i.e. /home/dons/foo.rc -> /home/dons/foo.o +-- +-- we depend on the suffix we are given having a lead '.' +-- +replaceSuffix :: FilePath -> String -> FilePath +replaceSuffix [] _ = [] -- ? +replaceSuffix f suf = + case reverse $ dropWhile (/= '.') $ reverse f of + [] -> f ++ suf -- no '.' in file name + f' -> f' ++ tail suf + +-- +-- Normally we create the .hi and .o files next to the .hs files. +-- For some uses this is annoying (i.e. true EDSL users don't actually +-- want to know that their code is compiled at all), and for hmake-like +-- applications. +-- +-- This code checks if "-o foo" or "-odir foodir" are supplied as args +-- to make(), and if so returns a modified file path, otherwise it +-- uses the source file to determing the path to where the object and +-- .hi file will be put. +-- +outFilePath :: FilePath -> [Arg] -> (FilePath,FilePath) +outFilePath src args = + let objs = find_o args -- user sets explicit object path + paths = find_p args -- user sets a directory to put stuff in + in case () of { _ + | not (null objs) + -> let obj = last objs in (obj, mk_hi obj) + + | not (null paths) + -> let obj = last paths mk_o (basename src) in (obj, mk_hi obj) + + | otherwise + -> (mk_o src, mk_hi src) + } + where + outpath = "-o" + outdir = "-odir" + + mk_hi s = replaceSuffix s hiSuf + mk_o s = replaceSuffix s objSuf + + find_o [] = [] + find_o (f:f':fs) | f == outpath = [f'] + | otherwise = find_o $! f':fs + find_o _ = [] + + find_p [] = [] + find_p (f:f':fs) | f == outdir = [f'] + | otherwise = find_p $! f':fs + find_p _ = [] + +------------------------------------------------------------------------ + +-- +-- | is file1 newer than file2? +-- +-- needs some fixing to work with 6.0.x series. (is this true?) +-- +-- fileExist still seems to throw exceptions on some platforms: ia64 in +-- particular. +-- +-- invarient : we already assume the first file, 'a', exists +-- +newer :: FilePath -> FilePath -> IO Bool +newer a b = do + a_t <- getModificationTime a + b_exists <- doesFileExist b + if not b_exists + then return True -- needs compiling + else do b_t <- getModificationTime b + return ( a_t > b_t ) -- maybe need recompiling + +------------------------------------------------------------------------ +-- +-- | return the Z-Encoding of the string. +-- +-- Stolen from GHC. Use -package ghc as soon as possible +-- +type EncodedString = String + +encode :: String -> EncodedString +encode [] = [] +encode (c:cs) = encode_ch c ++ encode cs + +unencodedChar :: Char -> Bool -- True for chars that don't need encoding +unencodedChar 'Z' = False +unencodedChar 'z' = False +unencodedChar c = c >= 'a' && c <= 'z' + || c >= 'A' && c <= 'Z' + || c >= '0' && c <= '9' + +-- +-- Decode is used for user printing. +-- +decode :: EncodedString -> String +decode [] = [] +decode ('Z' : d : rest) | isDigit d = decode_tuple d rest + | otherwise = decode_upper d : decode rest +decode ('z' : d : rest) | isDigit d = decode_num_esc d rest + | otherwise = decode_lower d : decode rest +decode (c : rest) = c : decode rest + +decode_upper, decode_lower :: Char -> Char + +decode_upper 'L' = '(' +decode_upper 'R' = ')' +decode_upper 'M' = '[' +decode_upper 'N' = ']' +decode_upper 'C' = ':' +decode_upper 'Z' = 'Z' +decode_upper ch = error $ "decode_upper can't handle this char `"++[ch]++"'" + +decode_lower 'z' = 'z' +decode_lower 'a' = '&' +decode_lower 'b' = '|' +decode_lower 'c' = '^' +decode_lower 'd' = '$' +decode_lower 'e' = '=' +decode_lower 'g' = '>' +decode_lower 'h' = '#' +decode_lower 'i' = '.' +decode_lower 'l' = '<' +decode_lower 'm' = '-' +decode_lower 'n' = '!' +decode_lower 'p' = '+' +decode_lower 'q' = '\'' +decode_lower 'r' = '\\' +decode_lower 's' = '/' +decode_lower 't' = '*' +decode_lower 'u' = '_' +decode_lower 'v' = '%' +decode_lower ch = error $ "decode_lower can't handle this char `"++[ch]++"'" + +-- Characters not having a specific code are coded as z224U +decode_num_esc :: Char -> [Char] -> String +decode_num_esc d cs + = go (digitToInt d) cs + where + go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest + go n ('U' : rest) = chr n : decode rest + go _ other = error $ + "decode_num_esc can't handle this: \""++other++"\"" + + +encode_ch :: Char -> EncodedString +encode_ch c | unencodedChar c = [c] -- Common case first + +-- Constructors +encode_ch '(' = "ZL" -- Needed for things like (,), and (->) +encode_ch ')' = "ZR" -- For symmetry with ( +encode_ch '[' = "ZM" +encode_ch ']' = "ZN" +encode_ch ':' = "ZC" +encode_ch 'Z' = "ZZ" + +-- Variables +encode_ch 'z' = "zz" +encode_ch '&' = "za" +encode_ch '|' = "zb" +encode_ch '^' = "zc" +encode_ch '$' = "zd" +encode_ch '=' = "ze" +encode_ch '>' = "zg" +encode_ch '#' = "zh" +encode_ch '.' = "zi" +encode_ch '<' = "zl" +encode_ch '-' = "zm" +encode_ch '!' = "zn" +encode_ch '+' = "zp" +encode_ch '\'' = "zq" +encode_ch '\\' = "zr" +encode_ch '/' = "zs" +encode_ch '*' = "zt" +encode_ch '_' = "zu" +encode_ch '%' = "zv" +encode_ch c = 'z' : shows (ord c) "U" + +decode_tuple :: Char -> EncodedString -> String +decode_tuple d cs + = go (digitToInt d) cs + where + go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest + go 0 ['T'] = "()" + go n ['T'] = '(' : replicate (n-1) ',' ++ ")" + go 1 ['H'] = "(# #)" + go n ['H'] = '(' : '#' : replicate (n-1) ',' ++ "#)" + go _ other = error $ "decode_tuple \'"++other++"'" + +-- --------------------------------------------------------------------- + +-- +-- 'isSublistOf' takes two arguments and returns 'True' iff the first +-- list is a sublist of the second list. This means that the first list +-- is wholly contained within the second list. Both lists must be +-- finite. + +isSublistOf :: Eq a => [a] -> [a] -> Bool +isSublistOf [] _ = True +isSublistOf _ [] = False +isSublistOf x y@(_:ys) + | isPrefixOf x y = True + | otherwise = isSublistOf x ys + hunk ./src/plugins/Plugins.hs 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Plugins ( + + -- $Description + + module Plugins.Make, + module Plugins.Load, + + ) where + +import Plugins.Make {-all-} +import Plugins.Load {-all-} + +-- +-- $Description +-- +-- [@NAME@] hs-plugins library : compile and load Haskell code at runtime +-- + hunk ./src/plugins/plugins.conf.in.cpp 1 +#if CABAL == 0 && GLASGOW_HASKELL < 604 +Package { + name = "plugins", + auto = False, +#ifdef INSTALLING + import_dirs = [ "${LIBDIR}/imports" ], + library_dirs = [ "${LIBDIR}/" ], +#else + import_dirs = [ "${TOP}/src/plugins" ], + library_dirs = [ "${TOP}/src/plugins" ], +#endif + hs_libraries = [ "HSplugins" ], + c_includes = [ "Linker.h" ], + include_dirs = [], + source_dirs = [], + extra_libraries = [], + package_deps = [ "altdata", "hi", "unix", "haskell-src", "posix" ], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [] +} + +#else + +name: plugins +version: 0.9.8 +license: LGPL +maintainer: dons@cse.unsw.edu.au +exposed: True +exposed-modules: + Plugins.Consts, + Plugins.Env, + Plugins.Load, + Plugins.Make, + Plugins.MkTemp, + Plugins.PackageAPI, + Plugins.ParsePkgConfCabal, + Plugins.Parser, + Plugins.Utils, + Plugins + +hidden-modules: +#ifdef INSTALLING +import-dirs: LIBDIR/imports +library-dirs: LIBDIR +#else +import-dirs: TOP/src/plugins +library-dirs: TOP/src/plugins +#endif +hs-libraries: HSplugins +extra-libraries: +include-dirs: +includes: Linker.h +depends: altdata, hi, unix, haskell-src, posix, Cabal +hugs-options: +cc-options: +ld-options: +framework-dirs: +frameworks: +haddock-interfaces: +haddock-html: + +#endif hunk ./src/printf/Makefile 1 +PKG = printf +UPKG = Printf + +YOBJ = $(UPKG)/Parser.hs +YSRC = $(UPKG)/Parser.y + +XOBJ = $(UPKG)/Lexer.hs +XSRC = $(UPKG)/Lexer.x + +TOP=../.. +include ../build.mk + +HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace +HC_OPTS += -package eval + +install: install-me hunk ./src/printf/Printf/Compile.hs 1 +{-# OPTIONS -fglasgow-exts #-} +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +-- +-- compile and run haskell strings at runtime. +-- +-- Some of the backend code is based on Ian Lynagh's TH version of +-- Printf. +-- +-- The specification of this implementation is taken from +-- the OpenBSD 3.5 man page for printf(3) +-- + +module Printf.Compile ( + printf, + (!), + ($>), ($<), + ) where + +import Printf.Lexer +import Printf.Parser + +import Eval.Haskell ( eval ) +import Eval.Utils ( escape ) +import Plugins.Utils ( (<>), (<+>) ) + +import AltData.Dynamic +import AltData.Typeable hiding ( typeOf ) + +import Data.List +import Data.Maybe ( isNothing, isJust ) + +import System.IO.Unsafe ( unsafePerformIO ) + +type Type = String +type Code = String + +-- --------------------------------------------------------------------- +-- +-- Generate a new Haskell function, as compiled native-code, from a +-- printf format string. It isn't applied to its arguments yet. +-- The function will return a String, but we won't typecheck this till +-- application. +-- +printf :: String -> Dynamic -- ([Dynamic] -> String) +printf fmt = run src ["Data.Char","Numeric"] + where + src = compile . parse . scan' . escape $ fmt + scan' s = either (error "lexer failed") (id) (scan s) + + run e i = case unsafePerformIO (eval e i) of + Nothing -> error "source failed to compile" + Just a -> a + +-- +-- application shortcuts. these expect all arguments to be supplied, and +-- if this is so, we can then give the result a type. +-- partial application means type annotations, or retaining everything +-- as a Dynamic +-- + +-- +-- sprintf +-- Apply a new fn to a arg list, returning a String +-- +infixr 0 $< +($<) :: Dynamic -> [Dynamic] -> String +f $< as = fromDynamic $! f `dynAppHList` as + +-- +-- printf +-- Apply a new fn to a arg list, printing out the result +-- +infixr 0 $> +($>) :: Dynamic -> [Dynamic] -> IO () +f $> as = putStr (fromDynamic $! f `dynAppHList` as) + +-- --------------------------------------------------------------------- +-- a printf code generator +-- +-- ToDo handle all the different specifiers +-- +-- Compile a printf format syntax tree into a Haskell string +-- representing a Haskell function to implement this printf. +-- +compile :: [Format] -> String +compile fmt = + let (tys,src) = compile' fmt 0 + in "toDyn $ \\" <> + spacify (map (\(ty,i) -> parens('x':show i <+> "::" <+> ty)) + (zip tys [0..length src])) <+> "->" <+> consify src + + where spacify s = concat (intersperse " " s) + consify s = concat (intersperse "++" s) + +-- --------------------------------------------------------------------- +-- +-- Compile an individual format or string literal + +compile' :: [Format] -> Int -> ([String],[String]) +compile' [] _ = ([],[]) + +compile' ((StrLit s):xs) i = ( ts, ( '"':s++"\"" ):ss ) + where (ts,ss) = compile' xs i + +compile' ((ConvSp _ _ _ _ Percent):xs) i = (ts, "\"%\"":ss) + where (ts,ss) = compile' xs $! i+1 + +compile' (c@(ConvSp _ _ _ _ t):xs) i = + (typeOf t:ts, parens( + (snd.plus.pad.alt.trunc.codeOf) c -- apply transformations + <+> ident i) : ss) + + where (ts, ss) = compile' xs $! i+1 + +-- --------------------------------------------------------------------- +-- +-- What argument type does a conversion specifier generate? +-- should be a FM +-- +typeOf :: Conv -> Type +typeOf x = case x of + D -> "Int" + O -> "Int" + Xx -> "Int" + XX -> "Int" + U -> "Int" + C -> "Char" + S -> "String" + F -> "Double" + Ee -> "Double" + EE -> "Double" + Gg -> "Double" + GG -> "Double" + Percent -> error "typeOf %: conversion specifier has no argument type" + +-- --------------------------------------------------------------------- +-- +-- Generate Haskell code for each particular format +-- +codeOf :: Format -> (Format,Code) +codeOf c@(ConvSp _ _ p _ f) = case f of + +-- diouxX The int (or appropriate variant) argument is converted to signed +-- decimal (d and i), unsigned octal (o), unsigned decimal (u), or +-- unsigned hexadecimal (x and X) notation. The letters abcdef are +-- used for x conversions; the letters ABCDEF are used for X conver- +-- sions. The precision, if any, gives the minimum number of digits +-- that must appear; if the converted value requires fewer digits, +-- it is padded on the left with zeros. + + D -> (c,"(show)") + U -> (c,"(show)") + O -> (c,"(\\v -> showOct v [])") + Xx -> (c,"(\\v -> showHex v [])") + XX -> (c,"(\\v -> map toUpper (showHex v []))") + +-- eE The double argument is rounded and converted in the style +-- [-]d.ddde+-dd where there is one digit before the decimal-point +-- character and the number of digits after it is equal to the pre- +-- cision; if the precision is missing, it is taken as 6; if the +-- precision is zero, no decimal-point character appears. An E con- +-- version uses the letter E (rather than e) to introduce the expo- +-- nent. The exponent always contains at least two digits; if the +-- value is zero, the exponent is 00. + +-- TODO prints exponent differently to printf(3) + + Ee -> let prec = if isNothing p then "Just 6" else show p + in (c,"(\\v->(showEFloat("++prec++")v)[])") + + EE -> let prec = if isNothing p then "Just 6" else show p + in (c,"(\\v->map toUpper((showEFloat ("++prec++")v)[]))") + +-- gG The double argument is converted in style f or e (or E for G con- +-- versions). The precision specifies the number of significant +-- digits. If the precision is missing, 6 digits are given; if the +-- precision is zero, it is treated as 1. Style e is used if the +-- exponent from its conversion is less than -4 or greater than or +-- equal to the precision. Trailing zeros are removed from the +-- fractional part of the result; a decimal point appears only if it +-- is followed by at least one digit. + +-- TODO unimplemented + + Gg -> let prec = if isNothing p then "Just 6" else show p + in (c,"(\\v->(showGFloat("++prec++")v)[])") + + GG -> let prec = if isNothing p then "Just 6" else show p + in (c,"(\\v->map toUpper((showGFloat ("++prec++")v)[]))") + +-- f The double argument is rounded and converted to decimal notation +-- in the style [-]ddd.ddd, where the number of digits after the +-- decimal-point character is equal to the precision specification. +-- If the precision is missing, it is taken as 6; if the precision +-- is explicitly zero, no decimal-point character appears. If a +-- decimal point appears, at least one digit appears before it. + + F -> let prec = if isNothing p then "Just 6" else show p + in (c, "(\\v -> (showFFloat ("++prec++") v) [])") + +-- c The int argument is converted to an unsigned char, and the re- +-- sulting character is written. + + C -> (c,"(\\c -> (showLitChar c) [])") + +-- s The char * argument is expected to be a pointer to an array of +-- character type (pointer to a string). Characters from the array +-- are written up to (but not including) a terminating NUL charac- +-- ter; if a precision is specified, no more than the number speci- +-- fied are written. If a precision is given, no null character +-- need be present; if the precision is not specified, or is greater +-- than the size of the array, the array must contain a terminating +-- NUL character. + + S -> (c,"(id)") + +-- % A `%' is written. No argument is converted. The complete con- +-- version specification is `%%'. + + Percent -> (c,"%") + +codeOf _ = error "codeOf: unknown conversion specifier" + +-- --------------------------------------------------------------------- +-- +-- Do we need a leading + ? +-- +-- A `+' character specifying that a sign always be placed before a +-- number produced by a signed conversion. A `+' overrides a space +-- if both are used. +-- +plus :: (Format, Code) -> (Format, Code) +plus p@(StrLit _,_) = p +plus a@(c@(ConvSp fs _w _ _ x), code) = case x of + D -> prefix + Ee-> prefix + EE-> prefix + Gg-> prefix + GG-> prefix + F -> prefix + _ -> a + + where prefix = let pref | Signed `elem` fs = "\"+\"" + | Space `elem` fs = "\" \"" + | otherwise = "[]" + in (c,parens("\\v ->"<+>pref<+>"++ v") <$> code) + + {- munge = case w of + Just w' | w' > 0 -> "tail" + _ -> "" -} + +-- --------------------------------------------------------------------- +-- Work out padding. +-- +-- A negative field width flag `-' indicates the converted value is +-- to be left adjusted on the field boundary. Except for n conver- +-- sions, the converted value is padded on the right with blanks, +-- rather than on the left with blanks or zeros. A `-' overrides a +-- `0' if both are given. +-- +-- A zero `0' character specifying zero padding. For all conver- +-- sions except n, the converted value is padded on the left with +-- zeros rather than blanks. If a precision is given with a numeric +-- conversion (d, i, o, u, x, and X), the `0' flag is ignored. +-- +pad :: (Format,Code) -> (Format,Code) +pad (c@(ConvSp fs (Just w) p _ x),code) + + | LeftAdjust `elem` fs + = (c, parens(parens("\\i c s -> if length s < i"<+> + "then s ++ take (i-length s) (repeat c) else s") + <+>show w<+>"' '")<$>code ) + + | otherwise + = (c, parens(parens("\\i c s -> if length s < i"<+> + "then take (i-length s) (repeat c) ++ s else s") + <+>show w<+>pad_chr)<$>code) + + where pad_chr | isNumeric x && isJust p = "' '" + | LeadZero `elem` fs = "'0'" + | otherwise = "' '" + +pad (c@(ConvSp _ Nothing _ _ _),code) = (c,code) + +pad ((StrLit _),_) = error "pad: can't pad str lit" + +isNumeric :: Conv -> Bool +isNumeric x = case x of + D -> True + O -> True + U -> True + Xx -> True + XX -> True + _ -> False + +-- --------------------------------------------------------------------- +-- +-- Check the 'alternate' modifier +-- +-- A hash `#' character specifying that the value should be convert- +-- ed to an ``alternate form''. For c, d, i, n, p, s, and u conver- +-- sions, this option has no effect. For o conversions, the preci- +-- sion of the number is increased to force the first character of +-- the output string to a zero (except if a zero value is printed +-- with an explicit precision of zero). For x and X conversions, a +-- non-zero result has the string `0x' (or `0X' for X conversions) +-- prepended to it. For e, E, f, g, and G conversions, the result +-- will always contain a decimal point, even if no digits follow it +-- (normally, a decimal point appears in the results of those con- +-- versions only if a digit follows). For g and G conversions, +-- trailing zeros are not removed from the result as they would oth- +-- erwise be. +-- + +alt :: (Format,Code) -> (Format,Code) +alt a@(c@(ConvSp fs _ _ _ x), code) | Alt `elem` fs = case x of + + Xx -> (c,parens("\\v->if fst (head (readHex v)) /= 0"<+> + "then \"0x\"++v else v")<$>code) + + XX -> (c,parens("\\v->if fst (head (readHex v)) /= 0"<+> + "then \"0X\"++v else v")<$>code) + + O -> (c,parens("\\v->if fst(head(readOct v)) /= 0"<+> + "then \"0\"++v else v")<$>code) + _ -> a + +alt a = a + +-- --------------------------------------------------------------------- +-- +-- Handle precision. Involves truncating strings and decimal points +-- +-- An optional precision, in the form of a period `.' followed by an op- +-- tional digit string. If the digit string is omitted, the precision +-- is taken as zero. This gives the minimum number of digits to appear +-- for d, i, o, u, x, and X conversions, the number of digits to appear +-- after the decimal-point for e, E, and f conversions, the maximum num- +-- ber of significant digits for g and G conversions, or the maximum +-- number of characters to be printed from a string for s conversions. +-- +trunc :: (Format,Code) -> (Format,Code) +trunc (c@(ConvSp _ _ (Just i) _ x), code) = case x of + S -> (c, parens("(\\i s -> if length s > i"<+> + "then take i s else s)"<+>show i)<$>code) + + _ | isNumeric x -> {-TODO-} (c, code) + | otherwise -> (c, code) + +trunc c = c + +-- --------------------------------------------------------------------- +-- make a new variable +ident i = 'x':show i + +-- wrap in parens +parens p = "("++p++")" + +-- lazy operator +infixr 6 <$> +(<$>) :: String -> String -> String +[] <$> a = a +a <$> b = a ++ " $ " ++ b + +-- --------------------------------------------------------------------- +-- +-- This bit of syntax constructs a [Dynamic]. +-- +infixr 6 ! +(!) :: Typeable a => a -> [Dynamic] -> [Dynamic] +a ! xs = toDyn a : xs + hunk ./src/printf/Printf/Lexer.hs 1 +{-# OPTIONS -fglasgow-exts -cpp #-} +{-# LINE 25 "Printf/Lexer.x" #-} + +{-# OPTIONS -w #-} +-- ^ don't want to see all the warns alex templates produce + +module Printf.Lexer ( scan, Token(..) ) where + + +#if __GLASGOW_HASKELL__ >= 503 +import Data.Array +import Data.Char (ord) +import Data.Array.Base (unsafeAt) +#else +import Array +import Char (ord) +#endif +#if __GLASGOW_HASKELL__ >= 503 +import GHC.Exts +#else +import GlaExts +#endif +alex_base :: AlexAddr +alex_base = AlexA# "\xf7\xff\xe2\xff\xef\xff\xf9\xff\x04\x00\x00\x00\xe6\xff\xfa\xff\x00\x00\x00\x00\x00\x00"# + +alex_table :: AlexAddr +alex_table = AlexA# "\x00\x00\xff\xff\x06\x00\xff\xff\x00\x00\x06\x00\x06\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x06\x00\xff\xff\x06\x00\x00\x00\x06\x00\x06\x00\x06\x00\x0a\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x08\x00\xff\xff\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\xff\xff\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x0a\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x0a\x00\x0a\x00\x0a\x00\x0a\x00\x09\x00\x0a\x00\x00\x00\x00\x00\x09\x00\x00\x00\x0a\x00\x0a\x00\x0a\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# + +alex_check :: AlexAddr +alex_check = AlexA# "\xff\xff\x0a\x00\x20\x00\x0a\x00\xff\xff\x23\x00\x20\x00\xff\xff\xff\xff\x23\x00\xff\xff\xff\xff\xff\xff\x2b\x00\x0a\x00\x2d\x00\xff\xff\x2b\x00\x30\x00\x2d\x00\x25\x00\xff\xff\x30\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x2e\x00\x25\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x25\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x45\x00\xff\xff\x47\x00\xff\xff\xff\xff\xff\xff\xff\xff\x4c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x58\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\xff\xff\xff\xff\x6c\x00\xff\xff\x6e\x00\x6f\x00\x70\x00\xff\xff\xff\xff\x73\x00\xff\xff\x75\x00\xff\xff\xff\xff\x78\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# + +alex_deflt :: AlexAddr +alex_deflt = AlexA# "\x04\x00\xff\xff\xff\xff\x04\x00\x04\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# + +alex_accept = listArray (0::Int,10) [[],[(AlexAcc (alex_action_2))],[],[],[(AlexAcc (alex_action_0))],[(AlexAcc (alex_action_1))],[(AlexAcc (alex_action_2))],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_4))],[(AlexAcc (alex_action_5))],[(AlexAcc (alex_action_6))]] +{-# LINE 54 "Printf/Lexer.x" #-} + + +mkflags, mkconv, mklength, mkint, mkstr, mkdot :: AlexInput -> Int -> Alex Token + +mkflags (_,_,input) len = return (FlagT (take len input)) +mkconv (_,_,(c:_)) _ = return (ConvT c) +mklength (_,_,(c:_)) _ = return (LengthT c) +mkint (_,_,input) len = return (IntT (read (take len input))) +mkstr (_,_,input) len = return (StrT (take len input)) +mkdot _ _ = return DotT + +alexEOF = return EOFT + +data Token + = FlagT [Char] + | ConvT Char + | LengthT Char + | IntT Int + | StrT String + | DotT + | EOFT + deriving (Eq, Show) + +scan :: String -> Either String [Token] +scan str = runAlex str $ do + let loop tks = do + tok <- alexMonadScan; + if tok == EOFT then do return $! reverse tks + else loop $! (tok:tks) + loop [] + + + +flag,fmt :: Int +flag = 1 +fmt = 2 +alex_action_0 = mkstr +alex_action_1 = begin flag +alex_action_2 = mkflags `andBegin` fmt +alex_action_3 = mkint +alex_action_4 = mkdot +alex_action_5 = mklength +alex_action_6 = mkconv `andBegin` 0 +{-# LINE 1 "GenericTemplate.hs" #-} +-- ----------------------------------------------------------------------------- +-- ALEX TEMPLATE +-- +-- This code is in the PUBLIC DOMAIN; you may copy it freely and use +-- it for any purpose whatsoever. + +-- ----------------------------------------------------------------------------- +-- INTERNALS and main scanner engine + + + + + + + + + + + + + +{-# LINE 34 "GenericTemplate.hs" #-} + + + + + + + + + + + + +data AlexAddr = AlexA# Addr# + +{-# INLINE alexIndexShortOffAddr #-} +alexIndexShortOffAddr (AlexA# arr) off = +#if __GLASGOW_HASKELL__ > 500 + narrow16Int# i +#elif __GLASGOW_HASKELL__ == 500 + intToInt16# i +#else + (i `iShiftL#` 16#) `iShiftRA#` 16# +#endif + where +#if __GLASGOW_HASKELL__ >= 503 + i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) +#else + i = word2Int# ((high `shiftL#` 8#) `or#` low) +#endif + high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + low = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 2# + + + + +-- ----------------------------------------------------------------------------- +-- Main lexing routines + +data AlexReturn a + = AlexEOF + | AlexError !AlexInput + | AlexSkip !AlexInput !Int + | AlexToken !AlexInput !Int a + +-- alexScan :: AlexInput -> StartCode -> Maybe (AlexInput,Int,act) +alexScan input (I# (sc)) + = alexScanUser undefined input (I# (sc)) + +alexScanUser user input (I# (sc)) + = case alex_scan_tkn user input 0# input sc AlexNone of + (AlexNone, input') -> + case alexGetChar input of + Nothing -> + + + + AlexEOF + Just _ -> + + + + AlexError input + + (AlexLastSkip input len, _) -> + + + + AlexSkip input len + + (AlexLastAcc k input len, _) -> + + + + AlexToken input len k + + +-- Push the input through the DFA, remembering the most recent accepting +-- state it encountered. + +alex_scan_tkn user orig_input len input s last_acc = + input `seq` -- strict in the input + case s of + -1# -> (last_acc, input) + _ -> alex_scan_tkn' user orig_input len input s last_acc + +alex_scan_tkn' user orig_input len input s last_acc = + let + new_acc = check_accs (alex_accept `unsafeAt` (I# (s))) + in + new_acc `seq` + case alexGetChar input of + Nothing -> (new_acc, input) + Just (c, new_input) -> + + + + let + base = alexIndexShortOffAddr alex_base s + (I# (ord_c)) = ord c + offset = (base +# ord_c) + check = alexIndexShortOffAddr alex_check offset + + new_s = if (offset >=# 0#) && (check ==# ord_c) + then alexIndexShortOffAddr alex_table offset + else alexIndexShortOffAddr alex_deflt s + in + alex_scan_tkn user orig_input (len +# 1#) new_input new_s new_acc + + where + check_accs [] = last_acc + check_accs (AlexAcc a : _) = AlexLastAcc a input (I# (len)) + check_accs (AlexAccSkip : _) = AlexLastSkip input (I# (len)) + check_accs (AlexAccPred a pred : rest) + | pred user orig_input (I# (len)) input + = AlexLastAcc a input (I# (len)) + check_accs (AlexAccSkipPred pred : rest) + | pred user orig_input (I# (len)) input + = AlexLastSkip input (I# (len)) + check_accs (_ : rest) = check_accs rest + +data AlexLastAcc a + = AlexNone + | AlexLastAcc a !AlexInput !Int + | AlexLastSkip !AlexInput !Int + +data AlexAcc a user + = AlexAcc a + | AlexAccSkip + | AlexAccPred a (AlexAccPred user) + | AlexAccSkipPred (AlexAccPred user) + +type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool + +-- ----------------------------------------------------------------------------- +-- Predicates on a rule + +alexAndPred p1 p2 user in1 len in2 + = p1 user in1 len in2 && p2 user in1 len in2 + +--alexPrevCharIsPred :: Char -> AlexAccPred _ +alexPrevCharIs c _ input _ _ = c == alexInputPrevChar input + +--alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _ +alexPrevCharIsOneOf arr _ input _ _ = arr ! alexInputPrevChar input + +--alexRightContext :: Int -> AlexAccPred _ +alexRightContext (I# (sc)) user _ _ input = + case alex_scan_tkn user input 0# input sc AlexNone of + (AlexNone, _) -> False + _ -> True + -- TODO: there's no need to find the longest + -- match when checking the right context, just + -- the first match will do. + +-- used by wrappers +iUnbox (I# (i)) = i +{-# LINE 1 "wrappers.hs" #-} +-- ----------------------------------------------------------------------------- +-- Alex wrapper code. +-- +-- This code is in the PUBLIC DOMAIN; you may copy it freely and use +-- it for any purpose whatsoever. + +-- ----------------------------------------------------------------------------- +-- The input type + + +type AlexInput = (AlexPosn, -- current position, + Char, -- previous char + String) -- current input string + +alexInputPrevChar :: AlexInput -> Char +alexInputPrevChar (p,c,s) = c + +alexGetChar :: AlexInput -> Maybe (Char,AlexInput) +alexGetChar (p,c,[]) = Nothing +alexGetChar (p,_,(c:s)) = let p' = alexMove p c in p' `seq` + Just (c, (p', c, s)) + +-- ----------------------------------------------------------------------------- +-- Token positions + +-- `Posn' records the location of a token in the input text. It has three +-- fields: the address (number of chacaters preceding the token), line number +-- and column of a token within the file. `start_pos' gives the position of the +-- start of the file and `eof_pos' a standard encoding for the end of file. +-- `move_pos' calculates the new position after traversing a given character, +-- assuming the usual eight character tab stops. + +data AlexPosn = AlexPn !Int !Int !Int + deriving (Eq,Show) + +alexStartPos :: AlexPosn +alexStartPos = AlexPn 0 1 1 + +alexMove :: AlexPosn -> Char -> AlexPosn +alexMove (AlexPn a l c) '\t' = AlexPn (a+1) l (((c+7) `div` 8)*8+1) +alexMove (AlexPn a l c) '\n' = AlexPn (a+1) (l+1) 1 +alexMove (AlexPn a l c) _ = AlexPn (a+1) l (c+1) + + +-- ----------------------------------------------------------------------------- +-- Default monad + + +data AlexState = AlexState { + alex_pos :: !AlexPosn, -- position at current input location + alex_inp :: String, -- the current input + alex_chr :: !Char, -- the character before the input + alex_scd :: !Int -- the current startcode + } + +-- Compile with -funbox-strict-fields for best results! + +runAlex :: String -> Alex a -> Either String a +runAlex input (Alex f) + = case f (AlexState {alex_pos = alexStartPos, + alex_inp = input, + alex_chr = '\n', + alex_scd = 0}) of Left msg -> Left msg + Right ( _, a ) -> Right a + +newtype Alex a = Alex { unAlex :: AlexState -> Either String (AlexState, a) } + +instance Monad Alex where + m >>= k = Alex $ \s -> case unAlex m s of + Left msg -> Left msg + Right (s',a) -> unAlex (k a) s' + return a = Alex $ \s -> Right (s,a) + +alexGetInput :: Alex AlexInput +alexGetInput + = Alex $ \s@AlexState{alex_pos=pos,alex_chr=c,alex_inp=inp} -> + Right (s, (pos,c,inp)) + +alexSetInput :: AlexInput -> Alex () +alexSetInput (pos,c,inp) + = Alex $ \s -> case s{alex_pos=pos,alex_chr=c,alex_inp=inp} of + s@(AlexState{}) -> Right (s, ()) + +alexError :: String -> Alex a +alexError message = Alex $ \s -> Left message + +alexGetStartCode :: Alex Int +alexGetStartCode = Alex $ \s@AlexState{alex_scd=sc} -> Right (s, sc) + +alexSetStartCode :: Int -> Alex () +alexSetStartCode sc = Alex $ \s -> Right (s{alex_scd=sc}, ()) + +alexMonadScan = do + inp <- alexGetInput + sc <- alexGetStartCode + case alexScan inp sc of + AlexEOF -> alexEOF + AlexError inp' -> alexError "lexical error" + AlexSkip inp' len -> do + alexSetInput inp' + alexMonadScan + AlexToken inp' len action -> do + alexSetInput inp' + action inp len + +-- ----------------------------------------------------------------------------- +-- Useful token actions + +type AlexAction result = AlexInput -> Int -> result + +-- just ignore this token and scan another one +-- skip :: AlexAction result +skip input len = alexMonadScan + +-- ignore this token, but set the start code to a new value +-- begin :: Int -> AlexAction result +begin code input len = do alexSetStartCode code; alexMonadScan + +-- perform an action for this token, and set the start code to a new value +-- andBegin :: AlexAction result -> Int -> AlexAction result +(action `andBegin` code) input len = do alexSetStartCode code; action input len + +-- token :: (String -> Int -> token) -> AlexAction token +token t input len = return (t input len) + + +-- ----------------------------------------------------------------------------- +-- Basic wrapper + +{-# LINE 146 "wrappers.hs" #-} + + +-- ----------------------------------------------------------------------------- +-- Posn wrapper + +-- Adds text positions to the basic model. + +{-# LINE 162 "wrappers.hs" #-} + + +-- ----------------------------------------------------------------------------- +-- GScan wrapper + +-- For compatibility with previous versions of Alex, and because we can. + +{-# LINE 180 "wrappers.hs" #-} + hunk ./src/printf/Printf/Lexer.x 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- 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. +-- + +-- +-- Lexer for printf format strings +-- Based on B1.2 Formatted Output, from Kernighan and Ritchie. +-- + +{ + +{-# OPTIONS -w #-} +-- ^ don't want to see all the warns alex templates produce + +module Printf.Lexer ( scan, Token(..) ) where + +} + +%wrapper "monad" + +$digit = 0-9 +$conv = [dioxXucsfeEgGpn\%] +$len = [hlL] +$flag = [\-\+\ 0\#] +$str = [. # \%] + +printf :- + +<0> $str+ { mkstr } +<0> \% { begin flag } + + $flag* { mkflags `andBegin` fmt } + + $digit+ { mkint } + \. { mkdot } + $len { mklength } + $conv { mkconv `andBegin` 0 } + +{ + + +mkflags, mkconv, mklength, mkint, mkstr, mkdot :: AlexInput -> Int -> Alex Token + +mkflags (_,_,input) len = return (FlagT (take len input)) +mkconv (_,_,(c:_)) _ = return (ConvT c) +mklength (_,_,(c:_)) _ = return (LengthT c) +mkint (_,_,input) len = return (IntT (read (take len input))) +mkstr (_,_,input) len = return (StrT (take len input)) +mkdot _ _ = return DotT + +alexEOF = return EOFT + +data Token + = FlagT [Char] + | ConvT Char + | LengthT Char + | IntT Int + | StrT String + | DotT + | EOFT + deriving (Eq, Show) + +scan :: String -> Either String [Token] +scan str = runAlex str $ do + let loop tks = do + tok <- alexMonadScan; + if tok == EOFT then do return $! reverse tks + else loop $! (tok:tks) + loop [] + +} hunk ./src/printf/Printf/Parser.hs 1 +{-# OPTIONS -fglasgow-exts -cpp -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-unused-binds -fno-warn-unused-matches -fno-warn-incomplete-patterns #-} +-- parser produced by Happy Version 1.14 + + +-- ^ grr. happy needs them all on one line + +module Printf.Parser where + +import Printf.Lexer +import Array +#if __GLASGOW_HASKELL__ >= 503 +import GHC.Exts +#else +import GlaExts +#endif + +newtype HappyAbsSyn = HappyAbsSyn (() -> ()) +happyIn4 :: ([Format]) -> (HappyAbsSyn ) +happyIn4 x = unsafeCoerce# x +{-# INLINE happyIn4 #-} +happyOut4 :: (HappyAbsSyn ) -> ([Format]) +happyOut4 x = unsafeCoerce# x +{-# INLINE happyOut4 #-} +happyIn5 :: (Format) -> (HappyAbsSyn ) +happyIn5 x = unsafeCoerce# x +{-# INLINE happyIn5 #-} +happyOut5 :: (HappyAbsSyn ) -> (Format) +happyOut5 x = unsafeCoerce# x +{-# INLINE happyOut5 #-} +happyIn6 :: (Format) -> (HappyAbsSyn ) +happyIn6 x = unsafeCoerce# x +{-# INLINE happyIn6 #-} +happyOut6 :: (HappyAbsSyn ) -> (Format) +happyOut6 x = unsafeCoerce# x +{-# INLINE happyOut6 #-} +happyIn7 :: (Format) -> (HappyAbsSyn ) +happyIn7 x = unsafeCoerce# x +{-# INLINE happyIn7 #-} +happyOut7 :: (HappyAbsSyn ) -> (Format) +happyOut7 x = unsafeCoerce# x +{-# INLINE happyOut7 #-} +happyIn8 :: ([Flag]) -> (HappyAbsSyn ) +happyIn8 x = unsafeCoerce# x +{-# INLINE happyIn8 #-} +happyOut8 :: (HappyAbsSyn ) -> ([Flag]) +happyOut8 x = unsafeCoerce# x +{-# INLINE happyOut8 #-} +happyIn9 :: (Maybe Prec) -> (HappyAbsSyn ) +happyIn9 x = unsafeCoerce# x +{-# INLINE happyIn9 #-} +happyOut9 :: (HappyAbsSyn ) -> (Maybe Prec) +happyOut9 x = unsafeCoerce# x +{-# INLINE happyOut9 #-} +happyIn10 :: (Maybe Width) -> (HappyAbsSyn ) +happyIn10 x = unsafeCoerce# x +{-# INLINE happyIn10 #-} +happyOut10 :: (HappyAbsSyn ) -> (Maybe Width) +happyOut10 x = unsafeCoerce# x +{-# INLINE happyOut10 #-} +happyIn11 :: (Length) -> (HappyAbsSyn ) +happyIn11 x = unsafeCoerce# x +{-# INLINE happyIn11 #-} +happyOut11 :: (HappyAbsSyn ) -> (Length) +happyOut11 x = unsafeCoerce# x +{-# INLINE happyOut11 #-} +happyIn12 :: (Conv) -> (HappyAbsSyn ) +happyIn12 x = unsafeCoerce# x +{-# INLINE happyIn12 #-} +happyOut12 :: (HappyAbsSyn ) -> (Conv) +happyOut12 x = unsafeCoerce# x +{-# INLINE happyOut12 #-} +happyInTok :: Token -> (HappyAbsSyn ) +happyInTok x = unsafeCoerce# x +{-# INLINE happyInTok #-} +happyOutTok :: (HappyAbsSyn ) -> Token +happyOutTok x = unsafeCoerce# x +{-# INLINE happyOutTok #-} + +happyActOffsets :: HappyAddr +happyActOffsets = HappyA# "\x0f\x00\x00\x00\x14\x00\x0f\x00\x00\x00\x00\x00\x16\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x15\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00"# + +happyGotoOffsets :: HappyAddr +happyGotoOffsets = HappyA# "\x0a\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf9\xff\x00\x00\x00\x00"# + +happyDefActions :: HappyAddr +happyDefActions = HappyA# "\xfe\xff\x00\x00\x00\x00\xfe\xff\xfc\xff\xfb\xff\xf3\xff\xfa\xff\xf7\xff\xef\xff\xf4\xff\xfd\xff\x00\x00\xf2\xff\xf1\xff\xf0\xff\xf5\xff\xef\xff\xf6\xff\xf8\xff\xee\xff\xed\xff\xec\xff\xeb\xff\xea\xff\xe9\xff\xe8\xff\xe7\xff\xe6\xff\xe5\xff\xe4\xff\xe3\xff\xe2\xff\xe1\xff\x00\x00\xf9\xff"# + +happyCheck :: HappyAddr +happyCheck = HappyA# "\xff\xff\x08\x00\x01\x00\x02\x00\x03\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x01\x00\x02\x00\x03\x00\x07\x00\x12\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x05\x00\x14\x00\x15\x00\x06\x00\x08\x00\x07\x00\x13\x00\x13\x00\x16\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# + +happyTable :: HappyAddr +happyTable = HappyA# "\x00\x00\x23\x00\x0e\x00\x0f\x00\x10\x00\x0b\x00\x03\x00\x04\x00\x05\x00\x06\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x0e\x00\x0f\x00\x10\x00\x22\x00\x11\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x11\x00\x08\x00\x09\x00\x09\x00\x13\x00\x0c\x00\x13\x00\x0b\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# + +happyReduceArr = array (1, 30) [ + (1 , happyReduce_1), + (2 , happyReduce_2), + (3 , happyReduce_3), + (4 , happyReduce_4), + (5 , happyReduce_5), + (6 , happyReduce_6), + (7 , happyReduce_7), + (8 , happyReduce_8), + (9 , happyReduce_9), + (10 , happyReduce_10), + (11 , happyReduce_11), + (12 , happyReduce_12), + (13 , happyReduce_13), + (14 , happyReduce_14), + (15 , happyReduce_15), + (16 , happyReduce_16), + (17 , happyReduce_17), + (18 , happyReduce_18), + (19 , happyReduce_19), + (20 , happyReduce_20), + (21 , happyReduce_21), + (22 , happyReduce_22), + (23 , happyReduce_23), + (24 , happyReduce_24), + (25 , happyReduce_25), + (26 , happyReduce_26), + (27 , happyReduce_27), + (28 , happyReduce_28), + (29 , happyReduce_29), + (30 , happyReduce_30) + ] + +happy_n_terms = 23 :: Int +happy_n_nonterms = 9 :: Int + +happyReduce_1 = happySpecReduce_0 0# happyReduction_1 +happyReduction_1 = happyIn4 + ([] + ) + +happyReduce_2 = happySpecReduce_2 0# happyReduction_2 +happyReduction_2 happy_x_2 + happy_x_1 + = case happyOut5 happy_x_1 of { happy_var_1 -> + case happyOut4 happy_x_2 of { happy_var_2 -> + happyIn4 + (happy_var_1 : happy_var_2 + )}} + +happyReduce_3 = happySpecReduce_1 1# happyReduction_3 +happyReduction_3 happy_x_1 + = case happyOut6 happy_x_1 of { happy_var_1 -> + happyIn5 + (happy_var_1 + )} + +happyReduce_4 = happySpecReduce_1 1# happyReduction_4 +happyReduction_4 happy_x_1 + = case happyOut7 happy_x_1 of { happy_var_1 -> + happyIn5 + (happy_var_1 + )} + +happyReduce_5 = happySpecReduce_1 2# happyReduction_5 +happyReduction_5 happy_x_1 + = case happyOutTok happy_x_1 of { (StrT happy_var_1) -> + happyIn6 + (StrLit happy_var_1 + )} + +happyReduce_6 = happyReduce 6# 3# happyReduction_6 +happyReduction_6 (happy_x_6 `HappyStk` + happy_x_5 `HappyStk` + happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut10 happy_x_2 of { happy_var_2 -> + case happyOut9 happy_x_4 of { happy_var_4 -> + case happyOut11 happy_x_5 of { happy_var_5 -> + case happyOut12 happy_x_6 of { happy_var_6 -> + happyIn7 + (ConvSp happy_var_1 happy_var_2 happy_var_4 happy_var_5 happy_var_6 + ) `HappyStk` happyRest}}}}} + +happyReduce_7 = happyReduce 4# 3# happyReduction_7 +happyReduction_7 (happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut10 happy_x_2 of { happy_var_2 -> + case happyOut11 happy_x_3 of { happy_var_3 -> + case happyOut12 happy_x_4 of { happy_var_4 -> + happyIn7 + (ConvSp happy_var_1 happy_var_2 Nothing happy_var_3 happy_var_4 + ) `HappyStk` happyRest}}}} + +happyReduce_8 = happySpecReduce_1 4# happyReduction_8 +happyReduction_8 happy_x_1 + = case happyOutTok happy_x_1 of { (FlagT happy_var_1) -> + happyIn8 + (mkFlags happy_var_1 + )} + +happyReduce_9 = happySpecReduce_1 5# happyReduction_9 +happyReduction_9 happy_x_1 + = case happyOutTok happy_x_1 of { (IntT happy_var_1) -> + happyIn9 + (Just happy_var_1 + )} + +happyReduce_10 = happySpecReduce_0 5# happyReduction_10 +happyReduction_10 = happyIn9 + (Nothing + ) + +happyReduce_11 = happySpecReduce_1 6# happyReduction_11 +happyReduction_11 happy_x_1 + = case happyOutTok happy_x_1 of { (IntT happy_var_1) -> + happyIn10 + (Just happy_var_1 + )} + +happyReduce_12 = happySpecReduce_0 6# happyReduction_12 +happyReduction_12 = happyIn10 + (Nothing + ) + +happyReduce_13 = happySpecReduce_1 7# happyReduction_13 +happyReduction_13 happy_x_1 + = happyIn11 + (Short + ) + +happyReduce_14 = happySpecReduce_1 7# happyReduction_14 +happyReduction_14 happy_x_1 + = happyIn11 + (Long + ) + +happyReduce_15 = happySpecReduce_1 7# happyReduction_15 +happyReduction_15 happy_x_1 + = happyIn11 + (Double + ) + +happyReduce_16 = happySpecReduce_0 7# happyReduction_16 +happyReduction_16 = happyIn11 + (Default + ) + +happyReduce_17 = happySpecReduce_1 8# happyReduction_17 +happyReduction_17 happy_x_1 + = happyIn12 + (D + ) + +happyReduce_18 = happySpecReduce_1 8# happyReduction_18 +happyReduction_18 happy_x_1 + = happyIn12 + (D + ) + +happyReduce_19 = happySpecReduce_1 8# happyReduction_19 +happyReduction_19 happy_x_1 + = happyIn12 + (O + ) + +happyReduce_20 = happySpecReduce_1 8# happyReduction_20 +happyReduction_20 happy_x_1 + = happyIn12 + (Xx + ) + +happyReduce_21 = happySpecReduce_1 8# happyReduction_21 +happyReduction_21 happy_x_1 + = happyIn12 + (XX + ) + +happyReduce_22 = happySpecReduce_1 8# happyReduction_22 +happyReduction_22 happy_x_1 + = happyIn12 + (U + ) + +happyReduce_23 = happySpecReduce_1 8# happyReduction_23 +happyReduction_23 happy_x_1 + = happyIn12 + (C + ) + +happyReduce_24 = happySpecReduce_1 8# happyReduction_24 +happyReduction_24 happy_x_1 + = happyIn12 + (S + ) + +happyReduce_25 = happySpecReduce_1 8# happyReduction_25 +happyReduction_25 happy_x_1 + = happyIn12 + (F + ) + +happyReduce_26 = happySpecReduce_1 8# happyReduction_26 +happyReduction_26 happy_x_1 + = happyIn12 + (Ee + ) + +happyReduce_27 = happySpecReduce_1 8# happyReduction_27 +happyReduction_27 happy_x_1 + = happyIn12 + (EE + ) + +happyReduce_28 = happySpecReduce_1 8# happyReduction_28 +happyReduction_28 happy_x_1 + = happyIn12 + (Gg + ) + +happyReduce_29 = happySpecReduce_1 8# happyReduction_29 +happyReduction_29 happy_x_1 + = happyIn12 + (GG + ) + +happyReduce_30 = happySpecReduce_1 8# happyReduction_30 +happyReduction_30 happy_x_1 + = happyIn12 + (Percent + ) + +happyNewToken action sts stk [] = + happyDoAction 22# (error "reading EOF!") action sts stk [] + +happyNewToken action sts stk (tk:tks) = + let cont i = happyDoAction i tk action sts stk tks in + case tk of { + LengthT 'h' -> cont 1#; + LengthT 'l' -> cont 2#; + LengthT 'L' -> cont 3#; + ConvT 'd' -> cont 4#; + ConvT 'i' -> cont 5#; + ConvT 'o' -> cont 6#; + ConvT 'x' -> cont 7#; + ConvT 'X' -> cont 8#; + ConvT 'u' -> cont 9#; + ConvT 'c' -> cont 10#; + ConvT 's' -> cont 11#; + ConvT 'f' -> cont 12#; + ConvT 'e' -> cont 13#; + ConvT 'E' -> cont 14#; + ConvT 'g' -> cont 15#; + ConvT 'G' -> cont 16#; + ConvT '%' -> cont 17#; + DotT -> cont 18#; + IntT happy_dollar_dollar -> cont 19#; + StrT happy_dollar_dollar -> cont 20#; + FlagT happy_dollar_dollar -> cont 21#; + _ -> happyError tks + } + +happyThen = \m k -> k m +happyReturn = \a -> a +happyThen1 = happyThen +happyReturn1 = \a tks -> a + +parse tks = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut4 x)) + +happySeq = happyDontSeq + +------------------------------------------------------------------------ +-- +-- abstract syntax for printf format strings +-- +data Format + = StrLit String + | ConvSp { flags :: [Flag], + width :: (Maybe Width), + precision :: (Maybe Prec ), + lenght :: Length, + conv :: Conv } + deriving (Show, Eq) + +type Width = Int +type Prec = Int + +data Flag + = LeftAdjust -- - + | Signed -- + + | Space -- ' ' + | LeadZero -- 0 + | Alt -- # + deriving (Show, Eq) + +data Length + = Short -- h + | Long -- l + | Double -- L + | Default + deriving (Show, Eq) + +data Conv + = D + | O + | Xx | XX + | U + | C + | S + | F + | Ee | EE + | Gg | GG + | Percent + deriving (Show, Eq) + +mkFlags :: [Char] -> [Flag] +mkFlags [] = [] +mkFlags (c:cs) = (case c of + '-' -> LeftAdjust + '+' -> Signed + ' ' -> Space + '0' -> LeadZero + '#' -> Alt) : mkFlags cs + +happyError :: [Token] -> a +happyError [] = error "Parser" "parse error" +happyError tks = error $ "Parser: " ++ show tks +{-# LINE 1 "GenericTemplate.hs" #-} +-- $Id: Parser.hs,v 1.1 2004/06/28 03:56:01 dons Exp $ + + + + + + + + + + + + + +{-# LINE 27 "GenericTemplate.hs" #-} + + + +data Happy_IntList = HappyCons Int# Happy_IntList + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +infixr 9 `HappyStk` +data HappyStk a = HappyStk a (HappyStk a) + +----------------------------------------------------------------------------- +-- starting the parse + +happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll + +----------------------------------------------------------------------------- +-- Accepting the parse + +happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j + (happyTcHack st)) + (happyReturn1 ans) + +----------------------------------------------------------------------------- +-- Arrays only: do the next action + + + +happyDoAction i tk st + = {- nothing -} + + + case action of + 0# -> {- nothing -} + happyFail i tk st + -1# -> {- nothing -} + happyAccept i tk st + n | (n <# (0# :: Int#)) -> {- nothing -} + + (happyReduceArr ! rule) i tk st + where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) + n -> {- nothing -} + + + happyShift new_state i tk st + where new_state = (n -# (1# :: Int#)) + where off = indexShortOffAddr happyActOffsets st + off_i = (off +# i) + check = if (off_i >=# (0# :: Int#)) + then (indexShortOffAddr happyCheck off_i ==# i) + else False + action | check = indexShortOffAddr happyTable off_i + | otherwise = indexShortOffAddr happyDefActions st + + + + + + + + + + + +indexShortOffAddr (HappyA# arr) off = +#if __GLASGOW_HASKELL__ > 500 + narrow16Int# i +#elif __GLASGOW_HASKELL__ == 500 + intToInt16# i +#else + (i `iShiftL#` 16#) `iShiftRA#` 16# +#endif + where +#if __GLASGOW_HASKELL__ >= 503 + i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) +#else + i = word2Int# ((high `shiftL#` 8#) `or#` low) +#endif + high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + low = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 2# + + + + + +data HappyAddr = HappyA# Addr# + + + + +----------------------------------------------------------------------------- +-- HappyState data type (not arrays) + +{-# LINE 165 "GenericTemplate.hs" #-} + + +----------------------------------------------------------------------------- +-- Shifting a token + +happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = + let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in +-- trace "shifting the error token" $ + happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) + +happyShift new_state i tk st sts stk = + happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) + +-- happyReduce is specialised for the common cases. + +happySpecReduce_0 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_0 nt fn j tk st@((action)) sts stk + = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) + +happySpecReduce_1 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') + = let r = fn v1 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_2 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') + = let r = fn v1 v2 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_3 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') + = let r = fn v1 v2 v3 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happyReduce k i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyReduce k nt fn j tk st sts stk + = case happyDrop (k -# (1# :: Int#)) sts of + sts1@((HappyCons (st1@(action)) (_))) -> + let r = fn stk in -- it doesn't hurt to always seq here... + happyDoSeq r (happyGoto nt j tk st1 sts1 r) + +happyMonadReduce k nt fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyMonadReduce k nt fn j tk st sts stk = + happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) + where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) + drop_stk = happyDropStk k stk + +happyDrop 0# l = l +happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t + +happyDropStk 0# l = l +happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs + +----------------------------------------------------------------------------- +-- Moving to a new state after a reduction + + +happyGoto nt j tk st = + {- nothing -} + happyDoAction j tk new_state + where off = indexShortOffAddr happyGotoOffsets st + off_i = (off +# nt) + new_state = indexShortOffAddr happyTable off_i + + + + +----------------------------------------------------------------------------- +-- Error recovery (0# is the error token) + +-- parse error if we are in recovery and we fail again +happyFail 0# tk old_st _ stk = +-- trace "failing" $ + happyError + + +{- We don't need state discarding for our restricted implementation of + "error". In fact, it can cause some bogus parses, so I've disabled it + for now --SDM + +-- discard a state +happyFail 0# tk old_st (HappyCons ((action)) (sts)) + (saved_tok `HappyStk` _ `HappyStk` stk) = +-- trace ("discarding state, depth " ++ show (length stk)) $ + happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) +-} + +-- Enter error recovery: generate an error token, +-- save the old token and carry on. +happyFail i tk (action) sts stk = +-- trace "entering error recovery" $ + happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) + +-- Internal happy errors: + +notHappyAtAll = error "Internal Happy error\n" + +----------------------------------------------------------------------------- +-- Hack to get the typechecker to accept our action functions + + +happyTcHack :: Int# -> a -> a +happyTcHack x y = y +{-# INLINE happyTcHack #-} + + +----------------------------------------------------------------------------- +-- Seq-ing. If the --strict flag is given, then Happy emits +-- happySeq = happyDoSeq +-- otherwise it emits +-- happySeq = happyDontSeq + +happyDoSeq, happyDontSeq :: a -> b -> b +happyDoSeq a b = a `seq` b +happyDontSeq a b = b + +----------------------------------------------------------------------------- +-- Don't inline any functions from the template. GHC has a nasty habit +-- of deciding to inline happyGoto everywhere, which increases the size of +-- the generated parser quite a bit. + + +{-# NOINLINE happyDoAction #-} +{-# NOINLINE happyTable #-} +{-# NOINLINE happyCheck #-} +{-# NOINLINE happyActOffsets #-} +{-# NOINLINE happyGotoOffsets #-} +{-# NOINLINE happyDefActions #-} + +{-# NOINLINE happyShift #-} +{-# NOINLINE happySpecReduce_0 #-} +{-# NOINLINE happySpecReduce_1 #-} +{-# NOINLINE happySpecReduce_2 #-} +{-# NOINLINE happySpecReduce_3 #-} +{-# NOINLINE happyReduce #-} +{-# NOINLINE happyMonadReduce #-} +{-# NOINLINE happyGoto #-} +{-# NOINLINE happyFail #-} + +-- end of Happy Template. hunk ./src/printf/Printf/Parser.y 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- 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. +-- + +-- +-- Parser for printf format strings +-- Based on B1.2 Formatted Output, from Kernighan and Ritchie. +-- + +{ + +{-# OPTIONS -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-unused-binds -fno-warn-unused-matches -fno-warn-incomplete-patterns #-} +-- ^ grr. happy needs them all on one line + +module Printf.Parser where + +import Printf.Lexer + +} + +%name parse +%tokentype { Token } +%token + + 'h' { LengthT 'h' } + 'l' { LengthT 'l' } + 'L' { LengthT 'L' } + + 'd' { ConvT 'd' } + 'i' { ConvT 'i' } + 'o' { ConvT 'o' } + 'x' { ConvT 'x' } + 'X' { ConvT 'X' } + 'u' { ConvT 'u' } + 'c' { ConvT 'c' } + 's' { ConvT 's' } + 'f' { ConvT 'f' } + 'e' { ConvT 'e' } + 'E' { ConvT 'E' } + 'g' { ConvT 'g' } + 'G' { ConvT 'G' } + '%' { ConvT '%' } + + '.' { DotT } + + INT { IntT $$ } + STRING { StrT $$ } + FLAGS { FlagT $$ } + +%% + +printf :: { [Format] } + : {- epsilon -} { [] } + | format0 printf { $1 : $2 } + +format0 :: { Format } + : string { $1 } + | format { $1 } + +string :: { Format } + : STRING { StrLit $1 } + +format :: { Format } + : flags width '.' precision length conv { ConvSp $1 $2 $4 $5 $6 } + | flags width length conv { ConvSp $1 $2 Nothing $3 $4 } + +flags :: { [Flag] } + : FLAGS { mkFlags $1 } + +precision :: { Maybe Prec } + : INT { Just $1 } + | {- epsilon -} { Nothing } + +width :: { Maybe Width } + : INT { Just $1 } + | {- epsilon -} { Nothing } + +length :: { Length } + : 'h' { Short } + | 'l' { Long } + | 'L' { Double } + | {- epsilon -} { Default} + +conv :: { Conv } + : 'd' { D } + | 'i' { D } -- n.b + | 'o' { O } + | 'x' { Xx } + | 'X' { XX } + | 'u' { U } + | 'c' { C } + | 's' { S } + | 'f' { F } + | 'e' { Ee } + | 'E' { EE } + | 'g' { Gg } + | 'G' { GG } + | '%' { Percent } + +{ + +------------------------------------------------------------------------ +-- +-- abstract syntax for printf format strings +-- +data Format + = StrLit String + | ConvSp { flags :: [Flag], + width :: (Maybe Width), + precision :: (Maybe Prec ), + lenght :: Length, + conv :: Conv } + deriving (Show, Eq) + +type Width = Int +type Prec = Int + +data Flag + = LeftAdjust -- - + | Signed -- + + | Space -- ' ' + | LeadZero -- 0 + | Alt -- # + deriving (Show, Eq) + +data Length + = Short -- h + | Long -- l + | Double -- L + | Default + deriving (Show, Eq) + +data Conv + = D + | O + | Xx | XX + | U + | C + | S + | F + | Ee | EE + | Gg | GG + | Percent + deriving (Show, Eq) + +mkFlags :: [Char] -> [Flag] +mkFlags [] = [] +mkFlags (c:cs) = (case c of + '-' -> LeftAdjust + '+' -> Signed + ' ' -> Space + '0' -> LeadZero + '#' -> Alt) : mkFlags cs + +happyError :: [Token] -> a +happyError [] = error "Parser" "parse error" +happyError tks = error $ "Parser: " ++ show tks + +} hunk ./src/printf/Printf.hs 1 +-- +-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library 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 +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +-- USA +-- + +module Printf ( + module Printf.Compile + ) where + +import Printf.Compile {-all-} + hunk ./src/printf/printf.conf.in.cpp 1 +#if CABAL == 0 && GLASGOW_HASKELL < 604 +Package { + name = "printf", + auto = False, + hs_libraries = [ "HSprintf" ], +#ifdef INSTALLING + import_dirs = [ "${LIBDIR}/imports" ], + library_dirs = [ "${LIBDIR}/" ], +#else + import_dirs = [ "${TOP}/src/printf" ], + library_dirs = [ "${TOP}/src/printf" ], +#endif + include_dirs = [], + c_includes = [], + source_dirs = [], + extra_libraries = [], + package_deps = [ "eval" ], + extra_ghc_opts = [], + extra_cc_opts = [], + extra_ld_opts = [] +} +#else +name: printf +version: 0.9.8 +license: LGPL +maintainer: dons@cse.unsw.edu.au +exposed: False +exposed-modules: + Printf.Compile, + Printf.Lexer, + Printf.Parser, + Printf + +hidden-modules: +#ifdef INSTALLING +import-dirs: LIBDIR/imports +library-dirs: LIBDIR +#else +import-dirs: TOP/src/printf +library-dirs: TOP/src/printf +#endif +hs-libraries: HSprintf +extra-libraries: +include-dirs: +includes: +depends: eval +hugs-options: +cc-options: +ld-options: +framework-dirs: +frameworks: +haddock-interfaces: +haddock-html: +#endif hunk ./examples/hmake/one-shot/Main.hs 6 +-- +-- | Runplugs: use hs-plugins to run a Haskell expression under +-- controlled conditions. +-- hunk ./examples/hmake/one-shot/Main.hs 30 - "FiniteMap", "Graph", "Int", "Ix", "List", - "Maybe", "Ratio", "Set", "Tree", "Tuple", "Typeable", "Word" + "Map", "Graph", "Int", "Ix", "List", "Maybe", + "Ratio", "Set", "Tree", "Tuple", "Typeable", "Word" move ./examples/hmake ./examples/plugs move ./examples/plugs/lib-plugs ./examples/plugs/plugs move ./examples/plugs/one-shot ./examples/plugs/runplugs hunk ./examples/eval/eval_fn/Main.hs 9 -main = do fn <- unsafeEval "(\\(x::Int) -> (x,x))" [] :: IO (Maybe (Int -> (Int,Int))) +main = do fn <- unsafeEval "(\\x -> (x,x::Int))" [] :: IO (Maybe (Int -> (Int,Int))) hunk ./Makefile 6 +MAKEFLAGS += --no-builtin-rules +.SUFFIXES: + hunk ./Makefile 11 -all: headers runplugs plugs +all: build headers hunk ./Makefile 16 -plugs: build - ( cd examples/hmake/lib-plugs ; $(MAKE) build ) - cp examples/hmake/lib-plugs/plugs ./ - -runplugs: build - ( cd examples/hmake/one-shot ; $(MAKE) build ) - cp examples/hmake/one-shot/runplugs ./ - hunk ./Makefile 29 - $(INSTALL_PROGRAM) plugs $(PREFIX)/bin/ - $(INSTALL_PROGRAM) runplugs $(PREFIX)/bin/ hunk ./Makefile 88 - rm -rf plugs - rm -rf runplugs hunk ./examples/load/rawload/Main.hs 1 - -import Plugins - -main = do - m <- loadRawObject "t.o" - print (path m) - resolveObjs --- loadFunction m "sym" rmfile ./examples/load/rawload/Main.hs hunk ./examples/load/rawload/Makefile 1 -TEST= load/rawload - -EXTRA_OBJS=c.o - -TOP=../../.. -include ../../eval.mk rmfile ./examples/load/rawload/Makefile hunk ./examples/load/rawload/t.c 1 -int sym(void) { return 1; } rmfile ./examples/load/rawload/t.c rmdir ./examples/load/rawload hunk ./config.mk.in 14 -PACKAGE = plugins -UPACKAGE = Plugins +PACKAGE = plugins +UPACKAGE = Plugins hunk ./config.mk.in 17 -TOP = @TOP@ +TOP = @TOP@ hunk ./config.mk.in 20 -LIBDIR = $(PREFIX)/lib/hs-$(PACKAGE) -BINDIR = $(PREFIX)/bin +LIBDIR = $(PREFIX)/lib/hs-$(PACKAGE) +BINDIR = $(PREFIX)/bin hunk ./config.mk.in 34 -GHC_LD_OPTS = +GHC_LD_OPTS = hunk ./config.mk.in 43 -ALEX = @ALEX@ -ALEX_OPTS = --ghc +ALEX = @ALEX@ +ALEX_OPTS = --ghc hunk ./config.mk.in 52 -INSTALL = @INSTALL@ +INSTALL = @INSTALL@ hunk ./config.mk.in 55 -INSTALL_PROGRAM = ${INSTALL} -s -m 755 -INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} -s -m 755 +INSTALL_DATA = ${INSTALL} -m 644 hunk ./src/plugins/Plugins/MkTemp.hs 2 +-- +-- glaexts for I# ops hunk ./src/plugins/Plugins/MkTemp.hs 5 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./src/plugins/Plugins/MkTemp.hs 26 --- "$ OpenBSD: mktemp.c,v 1.17 2003/06/02 20:18:37 millert Exp $" +-- > $ OpenBSD: mktemp.c,v 1.17 2003/06/02 20:18:37 millert Exp $ hunk ./src/plugins/Plugins/MkTemp.hs 32 - mktemp, -- :: FilePath -> FilePath - mkstemp, -- :: FilePath -> (FilePath, Handle) - mkstemps, -- :: FilePath -> Int -> (FilePath,Handle) - mkdtemp, -- :: FilePath -> FilePath + mktemp, -- :: FilePath -> IO Maybe FilePath + mkstemp, -- :: FilePath -> IO Maybe (FilePath, Handle) + mkstemps, -- :: FilePath -> Int -> IO Maybe (FilePath,Handle) + mkdtemp, -- :: FilePath -> IO Maybe FilePath hunk ./src/plugins/Plugins/MkTemp.hs 38 + +#include "config.h" hunk ./src/plugins/Plugins/MkTemp.hs 42 -import Data.Char - +import Data.Char ( chr, ord, isDigit ) hunk ./src/plugins/Plugins/MkTemp.hs 45 - -#if __GLASGOW_HASKELL__ < 604 -import System.IO ( isAlreadyExistsError, Handle ) -#else -import System.IO ( Handle ) +import System.Directory ( doesDirectoryExist, doesFileExist, createDirectory ) +import System.IO hunk ./src/plugins/Plugins/MkTemp.hs 48 -#endif - -import System.Directory ( doesDirectoryExist, doesFileExist ) hunk ./src/plugins/Plugins/MkTemp.hs 49 -import GHC.IOBase ( Exception(IOException) ) +import GHC.IOBase ( IOException(IOError), + Exception(IOException), + IOErrorType(AlreadyExists) ) hunk ./src/plugins/Plugins/MkTemp.hs 53 --- Fix this. hunk ./src/plugins/Plugins/MkTemp.hs 54 -import System.Posix.IO -import System.Posix.Files -import qualified System.Posix.Directory ( createDirectory ) hunk ./src/plugins/Plugins/MkTemp.hs 57 -#ifndef HAVE_ARC4RANDOM -import System.Random ( getStdRandom, Random(randomR) ) -#else -import GHC.Base +#ifdef HAVE_ARC4RANDOM +import GHC.Base hiding ( ord, chr ) hunk ./src/plugins/Plugins/MkTemp.hs 60 +#else +import System.Random ( getStdRandom, Random(randomR) ) hunk ./src/plugins/Plugins/MkTemp.hs 64 --- --------------------------------------------------------------------- +------------------------------------------------------------------------ hunk ./src/plugins/Plugins/MkTemp.hs 81 --- --------------------------------------------------------------------- +------------------------------------------------------------------------ hunk ./src/plugins/Plugins/MkTemp.hs 186 +alreadyExists :: Exception -> Maybe Exception hunk ./src/plugins/Plugins/MkTemp.hs 192 +isInUse :: Exception -> Maybe () hunk ./src/plugins/Plugins/MkTemp.hs 209 +-- +-- N.B. race condition between testing existence and opening +-- But we can live with that to avoid a posix dependency, right? hunk ./src/plugins/Plugins/MkTemp.hs 214 - -#ifndef __MINGW32__ +open0600 f = do + b <- doesFileExist f + if b then ioError err -- race + else openFile f ReadWriteMode + where + err = IOError Nothing AlreadyExists "open0600" "already exists" Nothing hunk ./src/plugins/Plugins/MkTemp.hs 221 +{- hunk ./src/plugins/Plugins/MkTemp.hs 223 - +-- hunk ./src/plugins/Plugins/MkTemp.hs 229 -#else - --- N.B. race condition between testing existence and opening - -open0600 f = do - b <- doesFileExist f - if b then ioException err -- race - else openFile f ReadWriteMode - where - err = IOError Nothing AlreadyExists "open0600" "already exists" Nothing -#endif +-} hunk ./src/plugins/Plugins/MkTemp.hs 235 -mkdir0700 dir = -#ifndef __MINGW32__ +mkdir0700 dir = createDirectory dir +{- hunk ./src/plugins/Plugins/MkTemp.hs 238 -#else - createDirectory dir -#endif +-} hunk ./src/plugins/Plugins/MkTemp.hs 240 --- --------------------------------------------------------------------- hunk ./src/plugins/Plugins/MkTemp.hs 241 - +-- hunk ./src/plugins/Plugins/MkTemp.hs 244 -#elif __GLASGOW_HASKELL__ > 504 -getProcessID :: IO Int -getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral hunk ./src/plugins/Plugins/MkTemp.hs 246 -getProcessID = Posix.getProcessID +getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral hunk ./src/plugins/Plugins/MkTemp.hs 257 --- hunk ./src/plugins/Plugins/MkTemp.hs 264 - (I32# i) <- c_arc4random - return (I# (word2Int# - ((int2Word# i `and#` int2Word# 0xffff#) `remWord#` int2Word# 52#))) + (I32# i) <- c_arc4random + return (I# (word2Int# ((int2Word# i `and#` int2Word# 0xffff#) + `remWord#` int2Word# 52#))) hunk ./src/plugins/Plugins/MkTemp.hs 268 -foreign import ccall unsafe "arc4random" c_arc4random :: IO Int32 +foreign import ccall unsafe "stdlib.h arc4random" c_arc4random :: IO Int32 hunk ./src/build.mk 15 +HC_OPTS += -threaded hunk ./src/eval/Eval/Haskell.hs 3 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./src/eval/Eval/Haskell.hs 118 - pwd <- getCurrentDirectory - tmpf <- mkUniqueWith wrap src mods - status <- make tmpf ["-Onot"] + pwd <- getCurrentDirectory + tmpf <- mkUniqueWith wrap src mods + status <- make tmpf [] hunk ./src/eval/Eval/Haskell.hs 127 --- makeCleaner tmpf + makeCleaner tmpf hunk ./src/eval/Eval/Haskell.hs 146 - status <- make tmpf $ ["-Onot"] ++ args + status <- make tmpf args hunk ./src/plugins/Plugins/Utils.hs 66 -import System.Environment ( getEnv ) +import System.Environment ( getEnv ) hunk ./src/plugins/Plugins/Utils.hs 73 -import POpen ( popen ) -import System.Posix.Process ( getProcessStatus ) +import POpen ( popen ) +import System.Posix.Process ( getProcessStatus ) hunk ./src/plugins/Plugins/Utils.hs 77 +import Control.Concurrent ( forkIO ) +import qualified Control.Exception ( evaluate ) hunk ./src/plugins/Plugins/Utils.hs 180 --- Use the forkProcess library +-- Use the forkProcess library, adapted from lambdabot's PosixCompat +-- Needs to be compiled with -threaded for waitForProcess not to block hunk ./src/plugins/Plugins/Utils.hs 184 - (_,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing - b <- waitForProcess proc_hdl -- wait - out <- hGetContents outh - err <- hGetContents errh - case b of - _exit_status -> return ( lines $ out, lines $ err ) + (_,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing + output <- hGetContents outh + errput <- hGetContents errh + forkIO (Control.Exception.evaluate (length output) >> return ()) + forkIO (Control.Exception.evaluate (length errput) >> return ()) + waitForProcess proc_hdl + return ( lines $ output, lines $ errput ) hunk ./examples/plugs/runplugs/Main.hs 1 +{-# OPTIONS -cpp #-} hunk ./examples/plugs/runplugs/Main.hs 3 --- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./examples/plugs/runplugs/Main.hs 31 - "Map", "Graph", "Int", "Ix", "List", "Maybe", + "Graph", "Int", "Ix", "List", "Maybe", +#if __GLASGOW_HASKELL__ >= 604 + "Map", +#else + "FiniteMap", +#endif hunk ./src/plugins/Plugins/MkTemp.hs 38 - -#include "config.h" hunk ./src/plugins/plugins.conf.in.cpp 54 -depends: altdata, hi, unix, haskell-src, posix, Cabal +depends: altdata, hi, haskell-src, Cabal hunk ./src/plugins/Makefile 1 -PKG = plugins -UPKG = Plugins +PKG = plugins +UPKG = Plugins hunk ./src/plugins/Makefile 8 -YOBJ = $(UPKG)/ParsePkgConfCabal.hs -YSRC = $(UPKG)/ParsePkgConfCabal.y +YOBJ = $(UPKG)/ParsePkgConfCabal.hs +YSRC = $(UPKG)/ParsePkgConfCabal.y hunk ./src/plugins/Makefile 11 -YOBJ = $(UPKG)/ParsePkgConfLite.hs -YSRC = $(UPKG)/ParsePkgConfLite.y +YOBJ = $(UPKG)/ParsePkgConfLite.hs +YSRC = $(UPKG)/ParsePkgConfLite.y hunk ./src/plugins/Makefile 17 -HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace -HC_OPTS += -package altdata -package hi -package posix -HC_OPTS += -O -funbox-strict-fields -HC_OPTS += -Wall -fno-warn-missing-signatures +HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace +HC_OPTS += -package altdata -package hi +HC_OPTS += -O -funbox-strict-fields +HC_OPTS += -Wall -fno-warn-missing-signatures hunk ./Makefile 28 - $(INSTALL_DATA_DIR) $(PREFIX)/bin hunk ./src/plugins/Makefile 22 +ifeq ($(GLASGOW_HASKELL),602) +HC_OPTS += -package posix +endif + hunk ./Makefile 6 -MAKEFLAGS += --no-builtin-rules -.SUFFIXES: - hunk ./Makefile 8 -all: build headers +all: build EvalHaskell.h hunk ./Makefile 10 -build: +build:: hunk ./Makefile 13 -headers: build - cp src/eval/Eval/Haskell_stub.h EvalHaskell.h +EvalHaskell.h: build + cp src/eval/Eval/Haskell_stub.h $@ hunk ./Makefile 25 + $(INSTALL_DATA_DIR) $(PREFIX)/bin hunk ./config.mk.in 39 -LD_X = -x +LD_X = @LD@ -x hunk ./src/Makefile 14 -plugins: +plugins: altdata hi hunk ./src/Makefile 16 -eval: +eval: plugins hunk ./src/Makefile 18 -printf: +printf: plugins hunk ./src/altdata/Makefile 4 +ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) + hunk ./src/altdata/Makefile 10 + +-include depend hunk ./src/build.mk 6 +MAKEFLAGS += --no-builtin-rules +.SUFFIXES: + hunk ./src/build.mk 11 +# If $(way) is set then we define $(way_) and $(_way) from it in the +# obvious fashion. +ifeq "$(way)" "p" + way_ := $(way)_ + _way := _$(way) +endif + +# +# building the profiled way +# +ifeq "$(way)" "p" +PROF_OPTS = -prof -auto-all -Icbits +LD_OPTS += $(PROF_OPTS) +HC_OPTS += $(PROF_OPTS) +HC_OPTS += -hisuf $(way_)hi -hcsuf $(way_)hc -osuf $(way_)o +endif + hunk ./src/build.mk 29 -LIBRARY = libHS$(PKG).a -GHCI_LIBRARY = HS$(PKG).o +LIBRARY = libHS$(PKG)$(_way).a +GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY)) hunk ./src/build.mk 33 -HC_OPTS = -package-name $(PKG) +HC_OPTS += -package-name $(PKG) hunk ./src/build.mk 35 -HC_OPTS += -threaded +HC_OPTS += -threaded hunk ./src/build.mk 40 -.PHONY: clean all alt_objs inplace-pkg-conf happy banner +OBJS= $(addsuffix .$(way_)o,$(basename $(ALL_SRCS))) + +.PHONY: clean all alt_objs plugins.conf.inplace happy banner hunk ./src/build.mk 44 -all : $(LIBRARY) inplace-pkg-conf $(PKG).conf.in +all : $(LIBRARY) $(TOP)/plugins.conf.inplace $(PKG).conf.in hunk ./src/build.mk 47 -$(LIBRARY): banner $(COBJ) $(XOBJ) $(YOBJ) objs +$(LIBRARY): depend $(COBJ) $(XOBJ) $(YOBJ) $(OBJS) hunk ./src/build.mk 49 - @$(AR) cq $@ $(OBJS) + @$(AR) cq $@ $(OBJS) $(COBJ) $(STUBOBJS) hunk ./src/build.mk 51 + +$(GHCI_LIBRARY) : $(OBJS) + $(LD_X) -r -o $@ $(OBJS) $(COBJ) $(STUBOBJS) + +# +# Dependency generation +# +depend: $(ALL_SRCS) + @echo -n "Rebuilding dependencies ... " + @$(GHC) -cpp $(HC_OPTS) $(PKG_OPTS) $(HTOOLKIT) -M -optdep-f \ + -optdepdepend $(ALL_SRCS) || rm depend + @echo "done." + +%.$(way_)hi : %.$(way_)o + @: hunk ./src/build.mk 67 -banner: - @echo "=========== building $(PKG) =============" +%.$(way_)o: %.hs + $(GHC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi hunk ./src/build.mk 77 - -# objects -objs:: - $(GHC) $(HC_OPTS) --make -no-hs-main -no-link $(MAIN) hunk ./src/build.mk 83 -inplace-pkg-conf: $(LIBRARY) - @rm -f $(GHCI_LIBRARY) +$(TOP)/plugins.conf.inplace: $(PKG).conf.in.cpp $(LIBRARY) $(GHCI_LIBRARY) hunk ./src/build.mk 86 - if [ ! -f plugins.conf.inplace ]; then echo [] > plugins.conf.inplace; fi;\ - env TOP=$(TOP) $(GHC_PKG) -g -f plugins.conf.inplace -u < src/$(PKG)/$(PKG).conf.inplace.in) + if [ ! -f $(TOP)/plugins.conf.inplace ]; then echo [] > $(TOP)/plugins.conf.inplace; fi;\ + env TOP=$(TOP) $(GHC_PKG) --force -f $@ -u < src/$(PKG)/$(PKG).conf.inplace.in) hunk ./src/build.mk 99 - @for i in $(TOP)/src/$(PKG)/*.hi ; do \ + @for i in $(TOP)/src/$(PKG)/*.$(way_)hi ; do \ hunk ./src/build.mk 103 - @for i in $(TOP)/src/$(PKG)/$(UPKG)/*.hi ; do \ + @for i in $(TOP)/src/$(PKG)/$(UPKG)/*.$(way_)hi ; do \ hunk ./src/build.mk 107 - $(INSTALL_DATA) $(TOP)/src/$(PKG)/libHS$(PKG).a $(LIBDIR) + $(INSTALL_DATA) $(TOP)/src/$(PKG)/libHS$(PKG)$(_way).a $(LIBDIR) hunk ./src/build.mk 115 + find . -name depend -exec rm {} \; hunk ./src/build.mk 120 + find . -name '*.p_hi' -exec rm {} \; hunk ./src/build.mk 122 + find . -name '*.p_o' -exec rm {} \; hunk ./src/eval/Makefile 4 +ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) + +STUBOBJS =Eval/Haskell_stub.o + hunk ./src/eval/Makefile 17 + +-include depend hunk ./src/hi/Makefile 7 +ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) + hunk ./src/hi/Makefile 15 + +-include depend hunk ./src/plugins/Makefile 15 +ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) + hunk ./src/plugins/Makefile 29 + +-include depend hunk ./src/printf/Makefile 10 +ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) + hunk ./src/printf/Makefile 19 + +-include depend hunk ./Makefile 25 - $(INSTALL_DATA_DIR) $(PREFIX)/bin hunk ./src/plugins/Makefile 10 +OTHER = $(UPKG)/ParsePkgConfLite.hs hunk ./src/plugins/Makefile 14 +OTHER = $(UPKG)/ParsePkgConfCabal.hs hunk ./src/plugins/Makefile 17 -ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) +ALL_SRCS= $(filter-out $(OTHER), \ + $(wildcard $(patsubst ./%, %, \ + $(patsubst %, %/*.hs, . $(UPKG))))) hunk ./Makefile 12 + @find src -name depend -exec rm {} \; + cd src && $(MAKE) way=p hunk ./Makefile 26 - @(cd src && $(MAKE) install) + @(cd src && $(MAKE) install && $(MAKE) install way=p) hunk ./src/eval/Makefile 6 -STUBOBJS =Eval/Haskell_stub.o +STUBOBJS =Eval/Haskell_stub.$(way_)o hunk ./configure.ac 44 - -TOP=`pwd` +# Find pwd, in a cygwin friendly way. +# Suggested by: http://www.haskell.org/ghc/docs/latest/html/users_guide/ch11s04.html +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghci -ignore-dot-ghci -v0` hunk ./configure.ac 87 - GLASGOW_HASKELL=`echo 'main' | "$GHC" --interactive -v0 -cpp t.hs` + GLASGOW_HASKELL=`echo 'main' | "$GHC" --interactive -ignore-dot-ghci -v0 -cpp t.hs` hunk ./config.mk.in 36 -GHC_PKG = @GHCPKG@-@GHC_VERSION@ +GHC_PKG = @GHCPKG@ hunk ./configure.ac 136 - [ AC_CHECK_PROG(GHCPKG,ghc-pkg,ghc-pkg) - if test -z "$GHCPKG" ; then - AC_MSG_ERROR([You need ghc-pkg]) - fi + [ AC_MSG_CHECKING([for ghc-pkg]) + if ghc-pkg-$GHC_VERSION -V > /dev/null ; then + GHCPKG=ghc-pkg-$GHC_VERSION + elif test ghc-pkg -V > /dev/null ; then + GHCPKG=ghc-pkg + else + AC_MSG_ERROR(You need ghc-pkg) + fi + AC_MSG_RESULT([$GHCPKG]) hunk ./configure.ac 147 - hunk ./configure.ac 15 +# This isn't right for cygwin. hunk ./configure.ac 138 - if ghc-pkg-$GHC_VERSION -V > /dev/null ; then + if ghc-pkg-$GHC_VERSION -V > /dev/null 2>&1 ; then hunk ./configure.ac 140 - elif test ghc-pkg -V > /dev/null ; then + elif test ghc-pkg -V > /dev/null 2>&1 ; then hunk ./configure.ac 129 -# allow user supplied haskell package manager -AC_ARG_WITH(ghc-pkg, - AC_HELP_STRING([--with-ghc-pkg=],[use a specific ghc-pkg]), - [ GHCPKG="$withval" - if test ! -f "$GHCPKG" ; then - AC_MSG_ERROR([$GHCPKG not found. You need ghc-pkg]) +# Search for ghc-pkg +AC_MSG_CHECKING([for ghc-pkg]) +ghc_pkg_guess=`echo $GHC | sed 's,ghc\(@<:@^/\\@:>@*\)$,ghc-pkg\1,'` +if "$ghc_pkg_guess" -l > /dev/null 2>&1; then + matching_ghc_pkg=$ghc_pkg_guess +else + matching_ghc_pkg=no +fi +if test x"$matching_ghc_pkg" = xno; then + AC_CHECK_PROG([GHCPKG], [ghc-pkg]) + if test -z "$GHCPKG" ; then + AC_MSG_ERROR([ghc-pkg not found.]) hunk ./configure.ac 142 - ], - [ AC_MSG_CHECKING([for ghc-pkg]) - if ghc-pkg-$GHC_VERSION -V > /dev/null 2>&1 ; then - GHCPKG=ghc-pkg-$GHC_VERSION - elif test ghc-pkg -V > /dev/null 2>&1 ; then - GHCPKG=ghc-pkg - else - AC_MSG_ERROR(You need ghc-pkg) - fi - AC_MSG_RESULT([$GHCPKG]) - ] - ) +else + GHCPKG=$matching_ghc_pkg +fi +AC_MSG_RESULT([$GHCPKG]) hunk ./src/plugins/Plugins/MkTemp.hs 100 - ;pid <- liftM show $ getProcessID + ;pid <- liftM show $ do {v <- getProcessID ; return $ abs v} -- getProcessID returns a negative number? why, dunno, but the minus sign screws up Module header names, illegal char. +-- ;pid <- liftM show $ getProcessID hunk ./src/plugins/Plugins/MkTemp.hs 100 - ;pid <- liftM show $ do {v <- getProcessID ; return $ abs v} -- getProcessID returns a negative number? why, dunno, but the minus sign screws up Module header names, illegal char. --- ;pid <- liftM show $ getProcessID + ;pid <- liftM show $ abs `fmap` getProcessID + -- getProcessID returns a negative number? why, dunno, but the minus + -- sign screws up Module header names, illegal char. hunk ./src/plugins/Plugins/MkTemp.hs 240 --- | getProcessId, stolen from GHC +-- | getProcessId, stolen from GHC (main/SysTools.lhs) hunk ./src/plugins/Plugins/MkTemp.hs 243 -foreign import ccall unsafe "_getpid" getProcessID :: IO Int +-- relies on Int == Int32 on Windows +foreign import ccall unsafe "_getpid" getProcessID :: IO Int hunk ./src/plugins/Plugins/Env.hs 287 -lookupPkg :: PackageName -> IO [FilePath] +lookupPkg :: PackageName -> IO ([FilePath],[FilePath]) hunk ./src/plugins/Plugins/Env.hs 290 - case t of ([],f) -> return f - (ps,f) -> do gss <- mapM lookupPkg ps - return $ nub $ (concat gss) ++ f + case t of ([],(f,g)) -> return (f,g) + (ps,(f,g)) -> do gss <- mapM lookupPkg ps + let (f',g') = unzip gss + return $ (nub $ (concat f') ++ f,nub $ (concat g') ++ g) hunk ./src/plugins/Plugins/Env.hs 300 -lookupPkg' :: PackageName -> IO ([PackageName],[FilePath]) +lookupPkg' :: PackageName -> IO ([PackageName],([FilePath],[FilePath])) hunk ./src/plugins/Plugins/Env.hs 303 - go [] _ = return ([],[]) + go [] _ = return ([],([],[])) hunk ./src/plugins/Plugins/Env.hs 317 - return (deppkgs, filterJust libs ) + return (deppkgs, (filterJust libs,filterJust libs') ) + + -- replace $topdir + fix_topdir [] = [] + fix_topdir (x:xs) = replace_topdir x : fix_topdir xs + + replace_topdir [] = [] + replace_topdir ('$':xs) + | take 6 xs == "topdir" = ghcLibraryPath ++ (drop 6 xs) + | otherwise = '$' : replace_topdir xs + replace_topdir (x:xs) = x : replace_topdir xs hunk ./src/plugins/Plugins/Env.hs 347 + + findDLL :: FilePath -> String -> IO (Maybe FilePath) + findDLL dir lib = do + let l = dir ++ "/" ++ lib ++ ".dll" + b <- doesFileExist l + if b then return $ Just l + else return $ Nothing hunk ./src/plugins/Plugins/Load.hs 456 -resolveObjs = do +resolveObjs = do hunk ./src/plugins/Plugins/Load.hs 483 - panic $ "loadShared: couldn't load `"++str++"\' because "++e + panic $ "loadShared: couldn't load `"++str'++"\' because "++e hunk ./src/plugins/Plugins/Load.hs 501 - + mapM_ loadShared dlls hunk ./src/plugins/Plugins/Load.hs 516 - libs <- liftM (filter (isSublistOf pkg')) (lookupPkg pkg) + libs <- liftM (\(a,_) -> (filter (isSublistOf pkg') ) a) (lookupPkg pkg) hunk ./src/plugins/Plugins/Load.hs 571 - + hunk ./src/plugins/Plugins/Env.hs 312 - libs <- mapM (findHSlib libdirs) (hslibs ++ extras) + libs <- mapM (findHSlib $ fix_topdir libdirs) (hslibs ++ extras) + libs' <- mapM (findDLL $ "C:/WINDOWS/SYSTEM") extras hunk ./src/plugins/Plugins/Load.hs 479 - maybe_errmsg <- withCString str $ \dll -> c_addDLL dll + str' <- return $ (reverse . drop 1 . dropWhile (/= '.') . reverse) str + maybe_errmsg <- withCString str' $ \dll -> c_addDLL dll hunk ./src/plugins/Plugins/Load.hs 500 - libs <- lookupPkg p + (libs,dlls) <- lookupPkg p hunk ./configure.ac 43 +AC_SUBST(LEADING_UNDERSCORE) + +if test "$build-os" = "cygwin" +then + LEADING_UNDERSCORE=1 +fi hunk ./configure.ac 45 -if test "$build-os" = "cygwin" +if test "$build_os" = "cygwin" hunk ./configure.ac 48 + SYMS="$SYMS -DCYGWIN" hunk ./configure.ac 51 +AC_SUBST(SYMS) hunk ./src/plugins/Plugins/Consts.hs 43 +#ifdef CYGWIN +dllSuf = ".dll" +#else +dllSuf = ".so" +#endif hunk ./src/plugins/Plugins/Env.hs 52 -import Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix ) +import Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix, dllSuf ) hunk ./src/plugins/Plugins/Env.hs 60 +#ifdef CYGWIN +import System.Environment ( getEnv ) + +import Control.Monad ( liftM ) +#endif hunk ./src/plugins/Plugins/Env.hs 313 +#ifdef CYGWIN + let libdirs = fix_topdir $ libraryDirs package +#else hunk ./src/plugins/Plugins/Env.hs 317 +#endif hunk ./src/plugins/Plugins/Env.hs 321 - libs <- mapM (findHSlib $ fix_topdir libdirs) (hslibs ++ extras) - libs' <- mapM (findDLL $ "C:/WINDOWS/SYSTEM") extras - + libs <- mapM (findHSlib libdirs) (hslibs ++ extras) +#ifdef CYGWIN + syslibdir <- liftM ( \x -> x ++ "/SYSTEM") (getEnv "SYSTEMROOT") + libs' <- mapM (findDLL $ syslibdir : libdirs) extras +#else + libs' <- mapM (findDLL libdirs) extras +#endif hunk ./src/plugins/Plugins/Env.hs 333 +#ifdef CYGWIN hunk ./src/plugins/Plugins/Env.hs 343 - +#endif hunk ./src/plugins/Plugins/Env.hs 363 - findDLL :: FilePath -> String -> IO (Maybe FilePath) - findDLL dir lib = do - let l = dir ++ "/" ++ lib ++ ".dll" + findDLL :: [FilePath] -> String -> IO (Maybe FilePath) + findDLL [] _ = return Nothing + findDLL (dir:dirs) lib = do + let l = dir lib ++ dllSuf hunk ./src/plugins/Plugins/Env.hs 369 - else return $ Nothing + else findDLL dirs lib hunk ./src/plugins/Plugins/MkTemp.hs 100 - ;pid <- liftM show $ abs `fmap` getProcessID - -- getProcessID returns a negative number? why, dunno, but the minus - -- sign screws up Module header names, illegal char. + ;pid <- liftM show $ do {v <- getProcessID ; return $ abs v} -- getProcessID returns a negative number? why, dunno, but the minus sign screws up Module header names, illegal char. +-- ;pid <- liftM show $ getProcessID hunk ./src/plugins/Plugins/MkTemp.hs 246 +#ifdef CYGWIN +getProcessID = System.Posix.Internals.c_getpid >>= return . abs . fromIntegral +#else hunk ./src/plugins/Plugins/MkTemp.hs 250 +#endif hunk ./src/plugins/Plugins/MkTemp.hs 100 - ;pid <- liftM show $ do {v <- getProcessID ; return $ abs v} -- getProcessID returns a negative number? why, dunno, but the minus sign screws up Module header names, illegal char. --- ;pid <- liftM show $ getProcessID + ;pid <- liftM show $ getProcessID hunk ./examples/make/o/prog/Main.hs 16 - make "../Plugin.hs" [ "-i../api", "-o", "/tmp/Plugin.o" ] - m_v <- load "/tmp/Plugin.o" ["../api"] [] "resource" +#if __GLASGOW_HASKELL__ >= 604 + tmpDir <- getTemporaryDirectory +#else + let tmpDir = "/tmp" +#endif + make "../Plugin.hs" [ "-i../api", "-o", (tmpDir ++ "/Plugin.o") ] + m_v <- load (tmpDir ++ "/Plugin.o") ["../api"] [] "resource" hunk ./examples/make/o/prog/Main.hs 28 - mapM_ removeFile [ "/tmp/Plugin.o" , "/tmp/Plugin.hi" ] + mapM_ removeFile [ (tmpDir ++ "/Plugin.hi"), (tmpDir ++ "/Plugin.o") ] hunk ./examples/make/odir/prog/Main.hs 6 - status <- make "../Plugin.hs" [ "-i../api", "-odir", "/tmp" ] +#if __GLASGOW_HASKELL__ >= 604 + tmpDir <- getTemporaryDirectory +#else + let tmpDir = "/tmp" +#endif + status <- make "../Plugin.hs" [ "-i../api", "-odir", tmpDir ] hunk ./examples/make/odir/prog/Main.hs 20 - mapM_ removeFile ["/tmp/Plugin.hi", "/tmp/Plugin.o" ] + mapM_ removeFile [(tmpDir ++ "/Plugin.hi"), (tmpDir ++ "/Plugin.o") ] hunk ./src/plugins/Plugins/Consts.hs 25 + +#if __GLASGOW_HASKELL__ >= 604 +import System.Directory ( getTemporaryDirectory ) +import System.IO.Unsafe ( unsafePerformIO ) +#endif + + hunk ./src/plugins/Plugins/Consts.hs 50 -#ifdef CYGWIN +#if defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/Plugins/Consts.hs 69 + +#if __GLASGOW_HASKELL__ >= 604 +tmpDir = unsafePerformIO getTemporaryDirectory +{-# NOINLINE tmpDir #-} +#else hunk ./src/plugins/Plugins/Consts.hs 79 - +#endif hunk ./src/plugins/Plugins/Load.hs 246 +#if defined(CYGWIN) || defined(__MINGW32__) + e <- build tmpf "nul" (i:is++args++["-fno-code","-ohi nul"]) +#else hunk ./src/plugins/Plugins/Load.hs 250 +#endif hunk ./examples/makewith/io/TestIO.conf 8 -import System.Posix.Types ( ProcessID, Fd ) -import System.Posix.Process ( forkProcess, executeFile, getProcessID ) -import System.Posix.IO ( createPipe, stdInput, - stdOutput, fdToHandle, closeFd, dupTo ) +import System.Process hunk ./examples/makewith/io/TestIO.conf 16 -date = do (hdl,_,_) <- catch (popen "/bin/date") (\_->error "popen failed") - hGetLine hdl - ------------------------------------------------------------------------- --- --- my implementation of $val = `cmd`; (if this was perl) --- --- provide similar functionality to popen(3), --- along with bidirectional ipc via pipes --- return's the pid of the child process --- --- there are two different forkProcess functions. the pre-620 was a --- unix-fork style function, and the modern function has semantics more --- like the Awkward-Squad paper. We provide implementations of popen --- using both versions, depending on which GHC the user wants to try. --- - -popen :: FilePath -> IO (Handle, Handle, ProcessID) -popen cmd = do - (pr, pw) <- createPipe - (cr, cw) <- createPipe - - -- parent -- - let parent = do closeFd cw - closeFd pr - -- child -- - let child = do closeFd pw - closeFd cr - exec cmd (pr,cw) - error "exec cmd failed!" -- typing only - --- if the parser front end understood cpp, this would work --- #if __GLASGOW_HASKELL__ >= 601 - pid <- forkProcess child -- fork child - parent -- and run parent code --- #else --- p <- forkProcess --- pid <- case p of --- Just pid -> parent >> return pid --- Nothing -> child --- #endif - - hcr <- fdToHandle cr - hpw <- fdToHandle pw - - return (hcr,hpw,pid) - --- --- execve cmd in the child process, dup'ing the file descriptors passed --- as arguments to become the child's stdin and stdout. --- -exec :: FilePath -> (Fd,Fd) -> IO () -exec cmd (pr,cw) = do - dupTo pr stdInput - dupTo cw stdOutput - executeFile cmd False [] Nothing - ------------------------------------------------------------------------- +date = do (_,out,_,_) <- catch (runInteractiveCommand "/bin/date") (\_->error "popen failed") + hGetLine out hunk ./examples/makewith/unsafeio/Unsafe.conf 1 -{-# GLOBALOPTIONS -package posix #-} +{-# GLOBALOPTIONS -package mtl #-} hunk ./src/plugins/Plugins/Parser.hs 31 -import Language.Haskell.Parser -import Language.Haskell.Syntax -import Language.Haskell.Pretty +import Language.Haskell.Hsx hunk ./src/plugins/Plugins/Parser.hs 41 - case parseModuleWithMode (ParseMode f) fsrc of + case parseFileContentsWithMode (ParseMode f) fsrc of hunk ./src/plugins/plugins.conf.in.cpp 17 - package_deps = [ "altdata", "hi", "unix", "haskell-src", "posix" ], + package_deps = [ "altdata", "hi", "unix", "haskell-src-exts", "posix" ], hunk ./src/plugins/plugins.conf.in.cpp 54 -depends: altdata, hi, haskell-src, Cabal +depends: altdata, hi, haskell-src-exts, Cabal hunk ./Makefile 13 - cd src && $(MAKE) way=p + @#cd src && $(MAKE) way=p hunk ./README 28 +* Requires HSX, Niklas Broberg's Haskell parser library, available at: + http://www.cs.chalmers.se/~d00nibro/haskell-src-exts + Read the README with this package for how to install it (quite simple) + hunk ./configure.ac 15 -# This isn't right for cygwin. +Platform="$build_cpu-$build_vendor-$build_os" + +# This isn't right for msys mingw. hunk ./configure.ac 21 - PREFIX="$ac_default_prefix" + if test "$build_os" = "cygwin" + then + PREFIX="c:/cygwin$ac_default_prefix" + else + PREFIX="$ac_default_prefix" + fi hunk ./configure.ac 30 -Platform="$build_cpu-$build_vendor-$build_os" - hunk ./configure.ac 49 + +if test "$build_os" = "mingw32" +then + LEADING_UNDERSCORE=1 + SYMS="$SYMS -D__MINGW32__" +fi +AC_SUBST(LEADING_UNDERSCORE) +AC_SUBST(SYMS) hunk ./examples/makewith/global_pragma/Plugin.hs 1 -{-# GLOBALOPTIONS -package posix #-} +{-# GLOBALOPTIONS -package mtl #-} hunk ./src/plugins/Plugins/Env.hs 60 -#ifdef CYGWIN +#if defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/Plugins/Env.hs 313 -#ifdef CYGWIN +#if defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/Plugins/Env.hs 322 -#ifdef CYGWIN +#if defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/Plugins/Env.hs 333 -#ifdef CYGWIN +#if defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/Plugins/MkTemp.hs 45 +#ifndef __MINGW32__ hunk ./src/plugins/Plugins/MkTemp.hs 47 +#else +import System.IO.Error ( isAlreadyExistsError, isAlreadyInUseError, isPermissionError ) +#endif hunk ./README 28 +* Requires GHC > 6.2 (for Typeable.h) +* Requires GNU make or BSD make to build hunk ./README 31 - http://www.cs.chalmers.se/~d00nibro/haskell-src-exts + darcs get http://www.cs.chalmers.se/~d00nibro/haskell-src-exts hunk ./README 34 -* Requires GNU make or BSD make to build -* Requires GHC > 6.2 (for Typeable.h) +------------------------------------------------------------------------ + hunk ./Makefile 26 - @(cd src && $(MAKE) install && $(MAKE) install way=p) + @(cd src && $(MAKE) install) adddir ./src/plugins/System move ./src/eval/Eval ./src/plugins/System/Eval move ./src/eval/Eval.hs ./src/plugins/System/Eval.hs move ./src/plugins/Plugins ./src/plugins/System/Plugins move ./src/plugins/Plugins.hs ./src/plugins/System/Plugins.hs hunk ./src/eval/Makefile 1 -PKG = eval -UPKG = Eval - -ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) - -STUBOBJS =Eval/Haskell_stub.$(way_)o - -TOP=../.. -include ../build.mk - -HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace -HC_OPTS += -package plugins - -GHC6_3_HC_OPTS += -package template-haskell - -install: install-me - --include depend rmfile ./src/eval/Makefile hunk ./src/eval/eval.conf.in.cpp 1 -#if CABAL == 0 && GLASGOW_HASKELL < 604 -Package { - name = "eval", - auto = False, - hs_libraries = [ "HSeval" ], -#ifdef INSTALLING - import_dirs = [ "${LIBDIR}/imports" ], - library_dirs = [ "${LIBDIR}/" ], -#else - import_dirs = [ "${TOP}/src/eval" ], - library_dirs = [ "${TOP}/src/eval" ], -#endif - include_dirs = [], - c_includes = [], - source_dirs = [], - extra_libraries = [], - package_deps = [ "plugins" -#if GLASGOW_HASKELL >= 603 - , "template-haskell" -#endif - ], - extra_ghc_opts = [], - extra_cc_opts = [], - extra_ld_opts = [] -} -#else - -name: eval -version: 0.9.8 -license: LGPL -maintainer: dons@cse.unsw.edu.au -exposed: True -exposed-modules: - Eval.Haskell, - Eval.Meta, - Eval.Utils, - Eval - -hidden-modules: -#ifdef INSTALLING -import-dirs: LIBDIR/imports -library-dirs: LIBDIR -#else -import-dirs: TOP/src/eval -library-dirs: TOP/src/eval -#endif -hs-libraries: HSeval -extra-libraries: -include-dirs: -includes: -depends: plugins, template-haskell -hugs-options: -cc-options: -ld-options: -framework-dirs: -frameworks: -haddock-interfaces: -haddock-html: - -#endif rmfile ./src/eval/eval.conf.in.cpp rmdir ./src/eval adddir ./src/hi/Language move ./src/hi/Hi ./src/hi/Language/Hi move ./src/hi/Hi.hs ./src/hi/Language/Hi.hs move ./src/plugins/System/Plugins/MkTemp.hs ./src/plugins/System/MkTemp.hs hunk ./src/hi/Language/Hi.hs 1 --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - -module Hi ( - module Hi.Parser - ) where - -import Hi.Parser {-all-} - rmfile ./src/hi/Language/Hi.hs hunk ./src/plugins/System/Eval/Meta.hs 1 -{-# OPTIONS -cpp -fth #-} --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- --- an implementation of the staged compilation primitives from --- "Dynamic Typing as Staged Type Inference" --- Shields, Sheard and Jones, 1998 --- http://doi.acm.org/10.1145/268946.268970 --- - -module Eval.Meta ( - - run, - defer, - splice, - - ) where - -import Eval.Haskell ( eval ) -import AltData.Typeable ( Typeable ) - -#if __GLASGOW_HASKELL__ > 602 -import Language.Haskell.TH ( ExpQ, pprint, runQ ) -#else -import Language.Haskell.THSyntax ( ExpQ, pprExp, runQ ) -import Text.PrettyPrint ( render ) -#endif - -import System.IO.Unsafe ( unsafePerformIO ) - -type ExpR = String -- hack for splicing - --- --- defer the evaluation of an expression by one stage. --- uses [| |] just for the nice syntax. --- --- defer [| 1 + 1 |] --> (1 + 1) --- -defer :: ExpQ -> ExpR -#if __GLASGOW_HASKELL__ > 602 -defer e = pprint (unsafePerformIO (runQ e)) -#else -defer e = render $ pprExp (unsafePerformIO (runQ e)) -#endif - --- --- evaluate 'e' to a deferred expression, and evaluate the result. --- --- run( defer [|1+1|] ) --> 2 --- -run :: (Show t, Typeable t) => ExpR -> t -run e = case unsafePerformIO (eval e imports) of - Nothing -> error "source failed to compile" - Just a -> a - --- --- evaluate 'e' to a deferred expression. then splice the result back in --- to the surrounding deferred expression. splice() is only legal within --- deferred expressions. --- --- let code = defer [| 1 + 1 |] in defer [| splice(code) + 2 |] --- --> --- defer [| 1 + 1 + 2 |] --- --- defer( "\x -> " ++ splice (v) ) --- -splice :: Show t => t -> ExpR -splice e = show e - --- --- libraries needed --- -imports = - [ - "GHC.Base", - "GHC.Num", - "GHC.List" - ] - rmfile ./src/plugins/System/Eval/Meta.hs hunk ./src/printf/Printf/Compile.hs 1 -{-# OPTIONS -fglasgow-exts #-} --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- --- compile and run haskell strings at runtime. --- --- Some of the backend code is based on Ian Lynagh's TH version of --- Printf. --- --- The specification of this implementation is taken from --- the OpenBSD 3.5 man page for printf(3) --- - -module Printf.Compile ( - printf, - (!), - ($>), ($<), - ) where - -import Printf.Lexer -import Printf.Parser - -import Eval.Haskell ( eval ) -import Eval.Utils ( escape ) -import Plugins.Utils ( (<>), (<+>) ) - -import AltData.Dynamic -import AltData.Typeable hiding ( typeOf ) - -import Data.List -import Data.Maybe ( isNothing, isJust ) - -import System.IO.Unsafe ( unsafePerformIO ) - -type Type = String -type Code = String - --- --------------------------------------------------------------------- --- --- Generate a new Haskell function, as compiled native-code, from a --- printf format string. It isn't applied to its arguments yet. --- The function will return a String, but we won't typecheck this till --- application. --- -printf :: String -> Dynamic -- ([Dynamic] -> String) -printf fmt = run src ["Data.Char","Numeric"] - where - src = compile . parse . scan' . escape $ fmt - scan' s = either (error "lexer failed") (id) (scan s) - - run e i = case unsafePerformIO (eval e i) of - Nothing -> error "source failed to compile" - Just a -> a - --- --- application shortcuts. these expect all arguments to be supplied, and --- if this is so, we can then give the result a type. --- partial application means type annotations, or retaining everything --- as a Dynamic --- - --- --- sprintf --- Apply a new fn to a arg list, returning a String --- -infixr 0 $< -($<) :: Dynamic -> [Dynamic] -> String -f $< as = fromDynamic $! f `dynAppHList` as - --- --- printf --- Apply a new fn to a arg list, printing out the result --- -infixr 0 $> -($>) :: Dynamic -> [Dynamic] -> IO () -f $> as = putStr (fromDynamic $! f `dynAppHList` as) - --- --------------------------------------------------------------------- --- a printf code generator --- --- ToDo handle all the different specifiers --- --- Compile a printf format syntax tree into a Haskell string --- representing a Haskell function to implement this printf. --- -compile :: [Format] -> String -compile fmt = - let (tys,src) = compile' fmt 0 - in "toDyn $ \\" <> - spacify (map (\(ty,i) -> parens('x':show i <+> "::" <+> ty)) - (zip tys [0..length src])) <+> "->" <+> consify src - - where spacify s = concat (intersperse " " s) - consify s = concat (intersperse "++" s) - --- --------------------------------------------------------------------- --- --- Compile an individual format or string literal - -compile' :: [Format] -> Int -> ([String],[String]) -compile' [] _ = ([],[]) - -compile' ((StrLit s):xs) i = ( ts, ( '"':s++"\"" ):ss ) - where (ts,ss) = compile' xs i - -compile' ((ConvSp _ _ _ _ Percent):xs) i = (ts, "\"%\"":ss) - where (ts,ss) = compile' xs $! i+1 - -compile' (c@(ConvSp _ _ _ _ t):xs) i = - (typeOf t:ts, parens( - (snd.plus.pad.alt.trunc.codeOf) c -- apply transformations - <+> ident i) : ss) - - where (ts, ss) = compile' xs $! i+1 - --- --------------------------------------------------------------------- --- --- What argument type does a conversion specifier generate? --- should be a FM --- -typeOf :: Conv -> Type -typeOf x = case x of - D -> "Int" - O -> "Int" - Xx -> "Int" - XX -> "Int" - U -> "Int" - C -> "Char" - S -> "String" - F -> "Double" - Ee -> "Double" - EE -> "Double" - Gg -> "Double" - GG -> "Double" - Percent -> error "typeOf %: conversion specifier has no argument type" - --- --------------------------------------------------------------------- --- --- Generate Haskell code for each particular format --- -codeOf :: Format -> (Format,Code) -codeOf c@(ConvSp _ _ p _ f) = case f of - --- diouxX The int (or appropriate variant) argument is converted to signed --- decimal (d and i), unsigned octal (o), unsigned decimal (u), or --- unsigned hexadecimal (x and X) notation. The letters abcdef are --- used for x conversions; the letters ABCDEF are used for X conver- --- sions. The precision, if any, gives the minimum number of digits --- that must appear; if the converted value requires fewer digits, --- it is padded on the left with zeros. - - D -> (c,"(show)") - U -> (c,"(show)") - O -> (c,"(\\v -> showOct v [])") - Xx -> (c,"(\\v -> showHex v [])") - XX -> (c,"(\\v -> map toUpper (showHex v []))") - --- eE The double argument is rounded and converted in the style --- [-]d.ddde+-dd where there is one digit before the decimal-point --- character and the number of digits after it is equal to the pre- --- cision; if the precision is missing, it is taken as 6; if the --- precision is zero, no decimal-point character appears. An E con- --- version uses the letter E (rather than e) to introduce the expo- --- nent. The exponent always contains at least two digits; if the --- value is zero, the exponent is 00. - --- TODO prints exponent differently to printf(3) - - Ee -> let prec = if isNothing p then "Just 6" else show p - in (c,"(\\v->(showEFloat("++prec++")v)[])") - - EE -> let prec = if isNothing p then "Just 6" else show p - in (c,"(\\v->map toUpper((showEFloat ("++prec++")v)[]))") - --- gG The double argument is converted in style f or e (or E for G con- --- versions). The precision specifies the number of significant --- digits. If the precision is missing, 6 digits are given; if the --- precision is zero, it is treated as 1. Style e is used if the --- exponent from its conversion is less than -4 or greater than or --- equal to the precision. Trailing zeros are removed from the --- fractional part of the result; a decimal point appears only if it --- is followed by at least one digit. - --- TODO unimplemented - - Gg -> let prec = if isNothing p then "Just 6" else show p - in (c,"(\\v->(showGFloat("++prec++")v)[])") - - GG -> let prec = if isNothing p then "Just 6" else show p - in (c,"(\\v->map toUpper((showGFloat ("++prec++")v)[]))") - --- f The double argument is rounded and converted to decimal notation --- in the style [-]ddd.ddd, where the number of digits after the --- decimal-point character is equal to the precision specification. --- If the precision is missing, it is taken as 6; if the precision --- is explicitly zero, no decimal-point character appears. If a --- decimal point appears, at least one digit appears before it. - - F -> let prec = if isNothing p then "Just 6" else show p - in (c, "(\\v -> (showFFloat ("++prec++") v) [])") - --- c The int argument is converted to an unsigned char, and the re- --- sulting character is written. - - C -> (c,"(\\c -> (showLitChar c) [])") - --- s The char * argument is expected to be a pointer to an array of --- character type (pointer to a string). Characters from the array --- are written up to (but not including) a terminating NUL charac- --- ter; if a precision is specified, no more than the number speci- --- fied are written. If a precision is given, no null character --- need be present; if the precision is not specified, or is greater --- than the size of the array, the array must contain a terminating --- NUL character. - - S -> (c,"(id)") - --- % A `%' is written. No argument is converted. The complete con- --- version specification is `%%'. - - Percent -> (c,"%") - -codeOf _ = error "codeOf: unknown conversion specifier" - --- --------------------------------------------------------------------- --- --- Do we need a leading + ? --- --- A `+' character specifying that a sign always be placed before a --- number produced by a signed conversion. A `+' overrides a space --- if both are used. --- -plus :: (Format, Code) -> (Format, Code) -plus p@(StrLit _,_) = p -plus a@(c@(ConvSp fs _w _ _ x), code) = case x of - D -> prefix - Ee-> prefix - EE-> prefix - Gg-> prefix - GG-> prefix - F -> prefix - _ -> a - - where prefix = let pref | Signed `elem` fs = "\"+\"" - | Space `elem` fs = "\" \"" - | otherwise = "[]" - in (c,parens("\\v ->"<+>pref<+>"++ v") <$> code) - - {- munge = case w of - Just w' | w' > 0 -> "tail" - _ -> "" -} - --- --------------------------------------------------------------------- --- Work out padding. --- --- A negative field width flag `-' indicates the converted value is --- to be left adjusted on the field boundary. Except for n conver- --- sions, the converted value is padded on the right with blanks, --- rather than on the left with blanks or zeros. A `-' overrides a --- `0' if both are given. --- --- A zero `0' character specifying zero padding. For all conver- --- sions except n, the converted value is padded on the left with --- zeros rather than blanks. If a precision is given with a numeric --- conversion (d, i, o, u, x, and X), the `0' flag is ignored. --- -pad :: (Format,Code) -> (Format,Code) -pad (c@(ConvSp fs (Just w) p _ x),code) - - | LeftAdjust `elem` fs - = (c, parens(parens("\\i c s -> if length s < i"<+> - "then s ++ take (i-length s) (repeat c) else s") - <+>show w<+>"' '")<$>code ) - - | otherwise - = (c, parens(parens("\\i c s -> if length s < i"<+> - "then take (i-length s) (repeat c) ++ s else s") - <+>show w<+>pad_chr)<$>code) - - where pad_chr | isNumeric x && isJust p = "' '" - | LeadZero `elem` fs = "'0'" - | otherwise = "' '" - -pad (c@(ConvSp _ Nothing _ _ _),code) = (c,code) - -pad ((StrLit _),_) = error "pad: can't pad str lit" - -isNumeric :: Conv -> Bool -isNumeric x = case x of - D -> True - O -> True - U -> True - Xx -> True - XX -> True - _ -> False - --- --------------------------------------------------------------------- --- --- Check the 'alternate' modifier --- --- A hash `#' character specifying that the value should be convert- --- ed to an ``alternate form''. For c, d, i, n, p, s, and u conver- --- sions, this option has no effect. For o conversions, the preci- --- sion of the number is increased to force the first character of --- the output string to a zero (except if a zero value is printed --- with an explicit precision of zero). For x and X conversions, a --- non-zero result has the string `0x' (or `0X' for X conversions) --- prepended to it. For e, E, f, g, and G conversions, the result --- will always contain a decimal point, even if no digits follow it --- (normally, a decimal point appears in the results of those con- --- versions only if a digit follows). For g and G conversions, --- trailing zeros are not removed from the result as they would oth- --- erwise be. --- - -alt :: (Format,Code) -> (Format,Code) -alt a@(c@(ConvSp fs _ _ _ x), code) | Alt `elem` fs = case x of - - Xx -> (c,parens("\\v->if fst (head (readHex v)) /= 0"<+> - "then \"0x\"++v else v")<$>code) - - XX -> (c,parens("\\v->if fst (head (readHex v)) /= 0"<+> - "then \"0X\"++v else v")<$>code) - - O -> (c,parens("\\v->if fst(head(readOct v)) /= 0"<+> - "then \"0\"++v else v")<$>code) - _ -> a - -alt a = a - --- --------------------------------------------------------------------- --- --- Handle precision. Involves truncating strings and decimal points --- --- An optional precision, in the form of a period `.' followed by an op- --- tional digit string. If the digit string is omitted, the precision --- is taken as zero. This gives the minimum number of digits to appear --- for d, i, o, u, x, and X conversions, the number of digits to appear --- after the decimal-point for e, E, and f conversions, the maximum num- --- ber of significant digits for g and G conversions, or the maximum --- number of characters to be printed from a string for s conversions. --- -trunc :: (Format,Code) -> (Format,Code) -trunc (c@(ConvSp _ _ (Just i) _ x), code) = case x of - S -> (c, parens("(\\i s -> if length s > i"<+> - "then take i s else s)"<+>show i)<$>code) - - _ | isNumeric x -> {-TODO-} (c, code) - | otherwise -> (c, code) - -trunc c = c - --- --------------------------------------------------------------------- --- make a new variable -ident i = 'x':show i - --- wrap in parens -parens p = "("++p++")" - --- lazy operator -infixr 6 <$> -(<$>) :: String -> String -> String -[] <$> a = a -a <$> b = a ++ " $ " ++ b - --- --------------------------------------------------------------------- --- --- This bit of syntax constructs a [Dynamic]. --- -infixr 6 ! -(!) :: Typeable a => a -> [Dynamic] -> [Dynamic] -a ! xs = toDyn a : xs - rmfile ./src/printf/Printf/Compile.hs hunk ./src/printf/Printf/Lexer.hs 1 -{-# OPTIONS -fglasgow-exts -cpp #-} -{-# LINE 25 "Printf/Lexer.x" #-} - -{-# OPTIONS -w #-} --- ^ don't want to see all the warns alex templates produce - -module Printf.Lexer ( scan, Token(..) ) where - - -#if __GLASGOW_HASKELL__ >= 503 -import Data.Array -import Data.Char (ord) -import Data.Array.Base (unsafeAt) -#else -import Array -import Char (ord) -#endif -#if __GLASGOW_HASKELL__ >= 503 -import GHC.Exts -#else -import GlaExts -#endif -alex_base :: AlexAddr -alex_base = AlexA# "\xf7\xff\xe2\xff\xef\xff\xf9\xff\x04\x00\x00\x00\xe6\xff\xfa\xff\x00\x00\x00\x00\x00\x00"# - -alex_table :: AlexAddr -alex_table = AlexA# "\x00\x00\xff\xff\x06\x00\xff\xff\x00\x00\x06\x00\x06\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x06\x00\xff\xff\x06\x00\x00\x00\x06\x00\x06\x00\x06\x00\x0a\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x08\x00\xff\xff\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\xff\xff\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x0a\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x0a\x00\x0a\x00\x0a\x00\x0a\x00\x09\x00\x0a\x00\x00\x00\x00\x00\x09\x00\x00\x00\x0a\x00\x0a\x00\x0a\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# - -alex_check :: AlexAddr -alex_check = AlexA# "\xff\xff\x0a\x00\x20\x00\x0a\x00\xff\xff\x23\x00\x20\x00\xff\xff\xff\xff\x23\x00\xff\xff\xff\xff\xff\xff\x2b\x00\x0a\x00\x2d\x00\xff\xff\x2b\x00\x30\x00\x2d\x00\x25\x00\xff\xff\x30\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x2e\x00\x25\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x25\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x45\x00\xff\xff\x47\x00\xff\xff\xff\xff\xff\xff\xff\xff\x4c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x58\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\xff\xff\xff\xff\x6c\x00\xff\xff\x6e\x00\x6f\x00\x70\x00\xff\xff\xff\xff\x73\x00\xff\xff\x75\x00\xff\xff\xff\xff\x78\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# - -alex_deflt :: AlexAddr -alex_deflt = AlexA# "\x04\x00\xff\xff\xff\xff\x04\x00\x04\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# - -alex_accept = listArray (0::Int,10) [[],[(AlexAcc (alex_action_2))],[],[],[(AlexAcc (alex_action_0))],[(AlexAcc (alex_action_1))],[(AlexAcc (alex_action_2))],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_4))],[(AlexAcc (alex_action_5))],[(AlexAcc (alex_action_6))]] -{-# LINE 54 "Printf/Lexer.x" #-} - - -mkflags, mkconv, mklength, mkint, mkstr, mkdot :: AlexInput -> Int -> Alex Token - -mkflags (_,_,input) len = return (FlagT (take len input)) -mkconv (_,_,(c:_)) _ = return (ConvT c) -mklength (_,_,(c:_)) _ = return (LengthT c) -mkint (_,_,input) len = return (IntT (read (take len input))) -mkstr (_,_,input) len = return (StrT (take len input)) -mkdot _ _ = return DotT - -alexEOF = return EOFT - -data Token - = FlagT [Char] - | ConvT Char - | LengthT Char - | IntT Int - | StrT String - | DotT - | EOFT - deriving (Eq, Show) - -scan :: String -> Either String [Token] -scan str = runAlex str $ do - let loop tks = do - tok <- alexMonadScan; - if tok == EOFT then do return $! reverse tks - else loop $! (tok:tks) - loop [] - - - -flag,fmt :: Int -flag = 1 -fmt = 2 -alex_action_0 = mkstr -alex_action_1 = begin flag -alex_action_2 = mkflags `andBegin` fmt -alex_action_3 = mkint -alex_action_4 = mkdot -alex_action_5 = mklength -alex_action_6 = mkconv `andBegin` 0 -{-# LINE 1 "GenericTemplate.hs" #-} --- ----------------------------------------------------------------------------- --- ALEX TEMPLATE --- --- This code is in the PUBLIC DOMAIN; you may copy it freely and use --- it for any purpose whatsoever. - --- ----------------------------------------------------------------------------- --- INTERNALS and main scanner engine - - - - - - - - - - - - - -{-# LINE 34 "GenericTemplate.hs" #-} - - - - - - - - - - - - -data AlexAddr = AlexA# Addr# - -{-# INLINE alexIndexShortOffAddr #-} -alexIndexShortOffAddr (AlexA# arr) off = -#if __GLASGOW_HASKELL__ > 500 - narrow16Int# i -#elif __GLASGOW_HASKELL__ == 500 - intToInt16# i -#else - (i `iShiftL#` 16#) `iShiftRA#` 16# -#endif - where -#if __GLASGOW_HASKELL__ >= 503 - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) -#else - i = word2Int# ((high `shiftL#` 8#) `or#` low) -#endif - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# - - - - --- ----------------------------------------------------------------------------- --- Main lexing routines - -data AlexReturn a - = AlexEOF - | AlexError !AlexInput - | AlexSkip !AlexInput !Int - | AlexToken !AlexInput !Int a - --- alexScan :: AlexInput -> StartCode -> Maybe (AlexInput,Int,act) -alexScan input (I# (sc)) - = alexScanUser undefined input (I# (sc)) - -alexScanUser user input (I# (sc)) - = case alex_scan_tkn user input 0# input sc AlexNone of - (AlexNone, input') -> - case alexGetChar input of - Nothing -> - - - - AlexEOF - Just _ -> - - - - AlexError input - - (AlexLastSkip input len, _) -> - - - - AlexSkip input len - - (AlexLastAcc k input len, _) -> - - - - AlexToken input len k - - --- Push the input through the DFA, remembering the most recent accepting --- state it encountered. - -alex_scan_tkn user orig_input len input s last_acc = - input `seq` -- strict in the input - case s of - -1# -> (last_acc, input) - _ -> alex_scan_tkn' user orig_input len input s last_acc - -alex_scan_tkn' user orig_input len input s last_acc = - let - new_acc = check_accs (alex_accept `unsafeAt` (I# (s))) - in - new_acc `seq` - case alexGetChar input of - Nothing -> (new_acc, input) - Just (c, new_input) -> - - - - let - base = alexIndexShortOffAddr alex_base s - (I# (ord_c)) = ord c - offset = (base +# ord_c) - check = alexIndexShortOffAddr alex_check offset - - new_s = if (offset >=# 0#) && (check ==# ord_c) - then alexIndexShortOffAddr alex_table offset - else alexIndexShortOffAddr alex_deflt s - in - alex_scan_tkn user orig_input (len +# 1#) new_input new_s new_acc - - where - check_accs [] = last_acc - check_accs (AlexAcc a : _) = AlexLastAcc a input (I# (len)) - check_accs (AlexAccSkip : _) = AlexLastSkip input (I# (len)) - check_accs (AlexAccPred a pred : rest) - | pred user orig_input (I# (len)) input - = AlexLastAcc a input (I# (len)) - check_accs (AlexAccSkipPred pred : rest) - | pred user orig_input (I# (len)) input - = AlexLastSkip input (I# (len)) - check_accs (_ : rest) = check_accs rest - -data AlexLastAcc a - = AlexNone - | AlexLastAcc a !AlexInput !Int - | AlexLastSkip !AlexInput !Int - -data AlexAcc a user - = AlexAcc a - | AlexAccSkip - | AlexAccPred a (AlexAccPred user) - | AlexAccSkipPred (AlexAccPred user) - -type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool - --- ----------------------------------------------------------------------------- --- Predicates on a rule - -alexAndPred p1 p2 user in1 len in2 - = p1 user in1 len in2 && p2 user in1 len in2 - ---alexPrevCharIsPred :: Char -> AlexAccPred _ -alexPrevCharIs c _ input _ _ = c == alexInputPrevChar input - ---alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _ -alexPrevCharIsOneOf arr _ input _ _ = arr ! alexInputPrevChar input - ---alexRightContext :: Int -> AlexAccPred _ -alexRightContext (I# (sc)) user _ _ input = - case alex_scan_tkn user input 0# input sc AlexNone of - (AlexNone, _) -> False - _ -> True - -- TODO: there's no need to find the longest - -- match when checking the right context, just - -- the first match will do. - --- used by wrappers -iUnbox (I# (i)) = i -{-# LINE 1 "wrappers.hs" #-} --- ----------------------------------------------------------------------------- --- Alex wrapper code. --- --- This code is in the PUBLIC DOMAIN; you may copy it freely and use --- it for any purpose whatsoever. - --- ----------------------------------------------------------------------------- --- The input type - - -type AlexInput = (AlexPosn, -- current position, - Char, -- previous char - String) -- current input string - -alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar (p,c,s) = c - -alexGetChar :: AlexInput -> Maybe (Char,AlexInput) -alexGetChar (p,c,[]) = Nothing -alexGetChar (p,_,(c:s)) = let p' = alexMove p c in p' `seq` - Just (c, (p', c, s)) - --- ----------------------------------------------------------------------------- --- Token positions - --- `Posn' records the location of a token in the input text. It has three --- fields: the address (number of chacaters preceding the token), line number --- and column of a token within the file. `start_pos' gives the position of the --- start of the file and `eof_pos' a standard encoding for the end of file. --- `move_pos' calculates the new position after traversing a given character, --- assuming the usual eight character tab stops. - -data AlexPosn = AlexPn !Int !Int !Int - deriving (Eq,Show) - -alexStartPos :: AlexPosn -alexStartPos = AlexPn 0 1 1 - -alexMove :: AlexPosn -> Char -> AlexPosn -alexMove (AlexPn a l c) '\t' = AlexPn (a+1) l (((c+7) `div` 8)*8+1) -alexMove (AlexPn a l c) '\n' = AlexPn (a+1) (l+1) 1 -alexMove (AlexPn a l c) _ = AlexPn (a+1) l (c+1) - - --- ----------------------------------------------------------------------------- --- Default monad - - -data AlexState = AlexState { - alex_pos :: !AlexPosn, -- position at current input location - alex_inp :: String, -- the current input - alex_chr :: !Char, -- the character before the input - alex_scd :: !Int -- the current startcode - } - --- Compile with -funbox-strict-fields for best results! - -runAlex :: String -> Alex a -> Either String a -runAlex input (Alex f) - = case f (AlexState {alex_pos = alexStartPos, - alex_inp = input, - alex_chr = '\n', - alex_scd = 0}) of Left msg -> Left msg - Right ( _, a ) -> Right a - -newtype Alex a = Alex { unAlex :: AlexState -> Either String (AlexState, a) } - -instance Monad Alex where - m >>= k = Alex $ \s -> case unAlex m s of - Left msg -> Left msg - Right (s',a) -> unAlex (k a) s' - return a = Alex $ \s -> Right (s,a) - -alexGetInput :: Alex AlexInput -alexGetInput - = Alex $ \s@AlexState{alex_pos=pos,alex_chr=c,alex_inp=inp} -> - Right (s, (pos,c,inp)) - -alexSetInput :: AlexInput -> Alex () -alexSetInput (pos,c,inp) - = Alex $ \s -> case s{alex_pos=pos,alex_chr=c,alex_inp=inp} of - s@(AlexState{}) -> Right (s, ()) - -alexError :: String -> Alex a -alexError message = Alex $ \s -> Left message - -alexGetStartCode :: Alex Int -alexGetStartCode = Alex $ \s@AlexState{alex_scd=sc} -> Right (s, sc) - -alexSetStartCode :: Int -> Alex () -alexSetStartCode sc = Alex $ \s -> Right (s{alex_scd=sc}, ()) - -alexMonadScan = do - inp <- alexGetInput - sc <- alexGetStartCode - case alexScan inp sc of - AlexEOF -> alexEOF - AlexError inp' -> alexError "lexical error" - AlexSkip inp' len -> do - alexSetInput inp' - alexMonadScan - AlexToken inp' len action -> do - alexSetInput inp' - action inp len - --- ----------------------------------------------------------------------------- --- Useful token actions - -type AlexAction result = AlexInput -> Int -> result - --- just ignore this token and scan another one --- skip :: AlexAction result -skip input len = alexMonadScan - --- ignore this token, but set the start code to a new value --- begin :: Int -> AlexAction result -begin code input len = do alexSetStartCode code; alexMonadScan - --- perform an action for this token, and set the start code to a new value --- andBegin :: AlexAction result -> Int -> AlexAction result -(action `andBegin` code) input len = do alexSetStartCode code; action input len - --- token :: (String -> Int -> token) -> AlexAction token -token t input len = return (t input len) - - --- ----------------------------------------------------------------------------- --- Basic wrapper - -{-# LINE 146 "wrappers.hs" #-} - - --- ----------------------------------------------------------------------------- --- Posn wrapper - --- Adds text positions to the basic model. - -{-# LINE 162 "wrappers.hs" #-} - - --- ----------------------------------------------------------------------------- --- GScan wrapper - --- For compatibility with previous versions of Alex, and because we can. - -{-# LINE 180 "wrappers.hs" #-} - rmfile ./src/printf/Printf/Lexer.hs hunk ./src/printf/Printf/Lexer.x 1 --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- 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. --- - --- --- Lexer for printf format strings --- Based on B1.2 Formatted Output, from Kernighan and Ritchie. --- - -{ - -{-# OPTIONS -w #-} --- ^ don't want to see all the warns alex templates produce - -module Printf.Lexer ( scan, Token(..) ) where - -} - -%wrapper "monad" - -$digit = 0-9 -$conv = [dioxXucsfeEgGpn\%] -$len = [hlL] -$flag = [\-\+\ 0\#] -$str = [. # \%] - -printf :- - -<0> $str+ { mkstr } -<0> \% { begin flag } - - $flag* { mkflags `andBegin` fmt } - - $digit+ { mkint } - \. { mkdot } - $len { mklength } - $conv { mkconv `andBegin` 0 } - -{ - - -mkflags, mkconv, mklength, mkint, mkstr, mkdot :: AlexInput -> Int -> Alex Token - -mkflags (_,_,input) len = return (FlagT (take len input)) -mkconv (_,_,(c:_)) _ = return (ConvT c) -mklength (_,_,(c:_)) _ = return (LengthT c) -mkint (_,_,input) len = return (IntT (read (take len input))) -mkstr (_,_,input) len = return (StrT (take len input)) -mkdot _ _ = return DotT - -alexEOF = return EOFT - -data Token - = FlagT [Char] - | ConvT Char - | LengthT Char - | IntT Int - | StrT String - | DotT - | EOFT - deriving (Eq, Show) - -scan :: String -> Either String [Token] -scan str = runAlex str $ do - let loop tks = do - tok <- alexMonadScan; - if tok == EOFT then do return $! reverse tks - else loop $! (tok:tks) - loop [] - -} rmfile ./src/printf/Printf/Lexer.x hunk ./src/printf/Printf/Parser.hs 1 -{-# OPTIONS -fglasgow-exts -cpp -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-unused-binds -fno-warn-unused-matches -fno-warn-incomplete-patterns #-} --- parser produced by Happy Version 1.14 - - --- ^ grr. happy needs them all on one line - -module Printf.Parser where - -import Printf.Lexer -import Array -#if __GLASGOW_HASKELL__ >= 503 -import GHC.Exts -#else -import GlaExts -#endif - -newtype HappyAbsSyn = HappyAbsSyn (() -> ()) -happyIn4 :: ([Format]) -> (HappyAbsSyn ) -happyIn4 x = unsafeCoerce# x -{-# INLINE happyIn4 #-} -happyOut4 :: (HappyAbsSyn ) -> ([Format]) -happyOut4 x = unsafeCoerce# x -{-# INLINE happyOut4 #-} -happyIn5 :: (Format) -> (HappyAbsSyn ) -happyIn5 x = unsafeCoerce# x -{-# INLINE happyIn5 #-} -happyOut5 :: (HappyAbsSyn ) -> (Format) -happyOut5 x = unsafeCoerce# x -{-# INLINE happyOut5 #-} -happyIn6 :: (Format) -> (HappyAbsSyn ) -happyIn6 x = unsafeCoerce# x -{-# INLINE happyIn6 #-} -happyOut6 :: (HappyAbsSyn ) -> (Format) -happyOut6 x = unsafeCoerce# x -{-# INLINE happyOut6 #-} -happyIn7 :: (Format) -> (HappyAbsSyn ) -happyIn7 x = unsafeCoerce# x -{-# INLINE happyIn7 #-} -happyOut7 :: (HappyAbsSyn ) -> (Format) -happyOut7 x = unsafeCoerce# x -{-# INLINE happyOut7 #-} -happyIn8 :: ([Flag]) -> (HappyAbsSyn ) -happyIn8 x = unsafeCoerce# x -{-# INLINE happyIn8 #-} -happyOut8 :: (HappyAbsSyn ) -> ([Flag]) -happyOut8 x = unsafeCoerce# x -{-# INLINE happyOut8 #-} -happyIn9 :: (Maybe Prec) -> (HappyAbsSyn ) -happyIn9 x = unsafeCoerce# x -{-# INLINE happyIn9 #-} -happyOut9 :: (HappyAbsSyn ) -> (Maybe Prec) -happyOut9 x = unsafeCoerce# x -{-# INLINE happyOut9 #-} -happyIn10 :: (Maybe Width) -> (HappyAbsSyn ) -happyIn10 x = unsafeCoerce# x -{-# INLINE happyIn10 #-} -happyOut10 :: (HappyAbsSyn ) -> (Maybe Width) -happyOut10 x = unsafeCoerce# x -{-# INLINE happyOut10 #-} -happyIn11 :: (Length) -> (HappyAbsSyn ) -happyIn11 x = unsafeCoerce# x -{-# INLINE happyIn11 #-} -happyOut11 :: (HappyAbsSyn ) -> (Length) -happyOut11 x = unsafeCoerce# x -{-# INLINE happyOut11 #-} -happyIn12 :: (Conv) -> (HappyAbsSyn ) -happyIn12 x = unsafeCoerce# x -{-# INLINE happyIn12 #-} -happyOut12 :: (HappyAbsSyn ) -> (Conv) -happyOut12 x = unsafeCoerce# x -{-# INLINE happyOut12 #-} -happyInTok :: Token -> (HappyAbsSyn ) -happyInTok x = unsafeCoerce# x -{-# INLINE happyInTok #-} -happyOutTok :: (HappyAbsSyn ) -> Token -happyOutTok x = unsafeCoerce# x -{-# INLINE happyOutTok #-} - -happyActOffsets :: HappyAddr -happyActOffsets = HappyA# "\x0f\x00\x00\x00\x14\x00\x0f\x00\x00\x00\x00\x00\x16\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x15\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00"# - -happyGotoOffsets :: HappyAddr -happyGotoOffsets = HappyA# "\x0a\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf9\xff\x00\x00\x00\x00"# - -happyDefActions :: HappyAddr -happyDefActions = HappyA# "\xfe\xff\x00\x00\x00\x00\xfe\xff\xfc\xff\xfb\xff\xf3\xff\xfa\xff\xf7\xff\xef\xff\xf4\xff\xfd\xff\x00\x00\xf2\xff\xf1\xff\xf0\xff\xf5\xff\xef\xff\xf6\xff\xf8\xff\xee\xff\xed\xff\xec\xff\xeb\xff\xea\xff\xe9\xff\xe8\xff\xe7\xff\xe6\xff\xe5\xff\xe4\xff\xe3\xff\xe2\xff\xe1\xff\x00\x00\xf9\xff"# - -happyCheck :: HappyAddr -happyCheck = HappyA# "\xff\xff\x08\x00\x01\x00\x02\x00\x03\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x01\x00\x02\x00\x03\x00\x07\x00\x12\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x05\x00\x14\x00\x15\x00\x06\x00\x08\x00\x07\x00\x13\x00\x13\x00\x16\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# - -happyTable :: HappyAddr -happyTable = HappyA# "\x00\x00\x23\x00\x0e\x00\x0f\x00\x10\x00\x0b\x00\x03\x00\x04\x00\x05\x00\x06\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x0e\x00\x0f\x00\x10\x00\x22\x00\x11\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x11\x00\x08\x00\x09\x00\x09\x00\x13\x00\x0c\x00\x13\x00\x0b\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# - -happyReduceArr = array (1, 30) [ - (1 , happyReduce_1), - (2 , happyReduce_2), - (3 , happyReduce_3), - (4 , happyReduce_4), - (5 , happyReduce_5), - (6 , happyReduce_6), - (7 , happyReduce_7), - (8 , happyReduce_8), - (9 , happyReduce_9), - (10 , happyReduce_10), - (11 , happyReduce_11), - (12 , happyReduce_12), - (13 , happyReduce_13), - (14 , happyReduce_14), - (15 , happyReduce_15), - (16 , happyReduce_16), - (17 , happyReduce_17), - (18 , happyReduce_18), - (19 , happyReduce_19), - (20 , happyReduce_20), - (21 , happyReduce_21), - (22 , happyReduce_22), - (23 , happyReduce_23), - (24 , happyReduce_24), - (25 , happyReduce_25), - (26 , happyReduce_26), - (27 , happyReduce_27), - (28 , happyReduce_28), - (29 , happyReduce_29), - (30 , happyReduce_30) - ] - -happy_n_terms = 23 :: Int -happy_n_nonterms = 9 :: Int - -happyReduce_1 = happySpecReduce_0 0# happyReduction_1 -happyReduction_1 = happyIn4 - ([] - ) - -happyReduce_2 = happySpecReduce_2 0# happyReduction_2 -happyReduction_2 happy_x_2 - happy_x_1 - = case happyOut5 happy_x_1 of { happy_var_1 -> - case happyOut4 happy_x_2 of { happy_var_2 -> - happyIn4 - (happy_var_1 : happy_var_2 - )}} - -happyReduce_3 = happySpecReduce_1 1# happyReduction_3 -happyReduction_3 happy_x_1 - = case happyOut6 happy_x_1 of { happy_var_1 -> - happyIn5 - (happy_var_1 - )} - -happyReduce_4 = happySpecReduce_1 1# happyReduction_4 -happyReduction_4 happy_x_1 - = case happyOut7 happy_x_1 of { happy_var_1 -> - happyIn5 - (happy_var_1 - )} - -happyReduce_5 = happySpecReduce_1 2# happyReduction_5 -happyReduction_5 happy_x_1 - = case happyOutTok happy_x_1 of { (StrT happy_var_1) -> - happyIn6 - (StrLit happy_var_1 - )} - -happyReduce_6 = happyReduce 6# 3# happyReduction_6 -happyReduction_6 (happy_x_6 `HappyStk` - happy_x_5 `HappyStk` - happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut8 happy_x_1 of { happy_var_1 -> - case happyOut10 happy_x_2 of { happy_var_2 -> - case happyOut9 happy_x_4 of { happy_var_4 -> - case happyOut11 happy_x_5 of { happy_var_5 -> - case happyOut12 happy_x_6 of { happy_var_6 -> - happyIn7 - (ConvSp happy_var_1 happy_var_2 happy_var_4 happy_var_5 happy_var_6 - ) `HappyStk` happyRest}}}}} - -happyReduce_7 = happyReduce 4# 3# happyReduction_7 -happyReduction_7 (happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut8 happy_x_1 of { happy_var_1 -> - case happyOut10 happy_x_2 of { happy_var_2 -> - case happyOut11 happy_x_3 of { happy_var_3 -> - case happyOut12 happy_x_4 of { happy_var_4 -> - happyIn7 - (ConvSp happy_var_1 happy_var_2 Nothing happy_var_3 happy_var_4 - ) `HappyStk` happyRest}}}} - -happyReduce_8 = happySpecReduce_1 4# happyReduction_8 -happyReduction_8 happy_x_1 - = case happyOutTok happy_x_1 of { (FlagT happy_var_1) -> - happyIn8 - (mkFlags happy_var_1 - )} - -happyReduce_9 = happySpecReduce_1 5# happyReduction_9 -happyReduction_9 happy_x_1 - = case happyOutTok happy_x_1 of { (IntT happy_var_1) -> - happyIn9 - (Just happy_var_1 - )} - -happyReduce_10 = happySpecReduce_0 5# happyReduction_10 -happyReduction_10 = happyIn9 - (Nothing - ) - -happyReduce_11 = happySpecReduce_1 6# happyReduction_11 -happyReduction_11 happy_x_1 - = case happyOutTok happy_x_1 of { (IntT happy_var_1) -> - happyIn10 - (Just happy_var_1 - )} - -happyReduce_12 = happySpecReduce_0 6# happyReduction_12 -happyReduction_12 = happyIn10 - (Nothing - ) - -happyReduce_13 = happySpecReduce_1 7# happyReduction_13 -happyReduction_13 happy_x_1 - = happyIn11 - (Short - ) - -happyReduce_14 = happySpecReduce_1 7# happyReduction_14 -happyReduction_14 happy_x_1 - = happyIn11 - (Long - ) - -happyReduce_15 = happySpecReduce_1 7# happyReduction_15 -happyReduction_15 happy_x_1 - = happyIn11 - (Double - ) - -happyReduce_16 = happySpecReduce_0 7# happyReduction_16 -happyReduction_16 = happyIn11 - (Default - ) - -happyReduce_17 = happySpecReduce_1 8# happyReduction_17 -happyReduction_17 happy_x_1 - = happyIn12 - (D - ) - -happyReduce_18 = happySpecReduce_1 8# happyReduction_18 -happyReduction_18 happy_x_1 - = happyIn12 - (D - ) - -happyReduce_19 = happySpecReduce_1 8# happyReduction_19 -happyReduction_19 happy_x_1 - = happyIn12 - (O - ) - -happyReduce_20 = happySpecReduce_1 8# happyReduction_20 -happyReduction_20 happy_x_1 - = happyIn12 - (Xx - ) - -happyReduce_21 = happySpecReduce_1 8# happyReduction_21 -happyReduction_21 happy_x_1 - = happyIn12 - (XX - ) - -happyReduce_22 = happySpecReduce_1 8# happyReduction_22 -happyReduction_22 happy_x_1 - = happyIn12 - (U - ) - -happyReduce_23 = happySpecReduce_1 8# happyReduction_23 -happyReduction_23 happy_x_1 - = happyIn12 - (C - ) - -happyReduce_24 = happySpecReduce_1 8# happyReduction_24 -happyReduction_24 happy_x_1 - = happyIn12 - (S - ) - -happyReduce_25 = happySpecReduce_1 8# happyReduction_25 -happyReduction_25 happy_x_1 - = happyIn12 - (F - ) - -happyReduce_26 = happySpecReduce_1 8# happyReduction_26 -happyReduction_26 happy_x_1 - = happyIn12 - (Ee - ) - -happyReduce_27 = happySpecReduce_1 8# happyReduction_27 -happyReduction_27 happy_x_1 - = happyIn12 - (EE - ) - -happyReduce_28 = happySpecReduce_1 8# happyReduction_28 -happyReduction_28 happy_x_1 - = happyIn12 - (Gg - ) - -happyReduce_29 = happySpecReduce_1 8# happyReduction_29 -happyReduction_29 happy_x_1 - = happyIn12 - (GG - ) - -happyReduce_30 = happySpecReduce_1 8# happyReduction_30 -happyReduction_30 happy_x_1 - = happyIn12 - (Percent - ) - -happyNewToken action sts stk [] = - happyDoAction 22# (error "reading EOF!") action sts stk [] - -happyNewToken action sts stk (tk:tks) = - let cont i = happyDoAction i tk action sts stk tks in - case tk of { - LengthT 'h' -> cont 1#; - LengthT 'l' -> cont 2#; - LengthT 'L' -> cont 3#; - ConvT 'd' -> cont 4#; - ConvT 'i' -> cont 5#; - ConvT 'o' -> cont 6#; - ConvT 'x' -> cont 7#; - ConvT 'X' -> cont 8#; - ConvT 'u' -> cont 9#; - ConvT 'c' -> cont 10#; - ConvT 's' -> cont 11#; - ConvT 'f' -> cont 12#; - ConvT 'e' -> cont 13#; - ConvT 'E' -> cont 14#; - ConvT 'g' -> cont 15#; - ConvT 'G' -> cont 16#; - ConvT '%' -> cont 17#; - DotT -> cont 18#; - IntT happy_dollar_dollar -> cont 19#; - StrT happy_dollar_dollar -> cont 20#; - FlagT happy_dollar_dollar -> cont 21#; - _ -> happyError tks - } - -happyThen = \m k -> k m -happyReturn = \a -> a -happyThen1 = happyThen -happyReturn1 = \a tks -> a - -parse tks = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut4 x)) - -happySeq = happyDontSeq - ------------------------------------------------------------------------- --- --- abstract syntax for printf format strings --- -data Format - = StrLit String - | ConvSp { flags :: [Flag], - width :: (Maybe Width), - precision :: (Maybe Prec ), - lenght :: Length, - conv :: Conv } - deriving (Show, Eq) - -type Width = Int -type Prec = Int - -data Flag - = LeftAdjust -- - - | Signed -- + - | Space -- ' ' - | LeadZero -- 0 - | Alt -- # - deriving (Show, Eq) - -data Length - = Short -- h - | Long -- l - | Double -- L - | Default - deriving (Show, Eq) - -data Conv - = D - | O - | Xx | XX - | U - | C - | S - | F - | Ee | EE - | Gg | GG - | Percent - deriving (Show, Eq) - -mkFlags :: [Char] -> [Flag] -mkFlags [] = [] -mkFlags (c:cs) = (case c of - '-' -> LeftAdjust - '+' -> Signed - ' ' -> Space - '0' -> LeadZero - '#' -> Alt) : mkFlags cs - -happyError :: [Token] -> a -happyError [] = error "Parser" "parse error" -happyError tks = error $ "Parser: " ++ show tks -{-# LINE 1 "GenericTemplate.hs" #-} --- $Id: Parser.hs,v 1.1 2004/06/28 03:56:01 dons Exp $ - - - - - - - - - - - - - -{-# LINE 27 "GenericTemplate.hs" #-} - - - -data Happy_IntList = HappyCons Int# Happy_IntList - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -infixr 9 `HappyStk` -data HappyStk a = HappyStk a (HappyStk a) - ------------------------------------------------------------------------------ --- starting the parse - -happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll - ------------------------------------------------------------------------------ --- Accepting the parse - -happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j - (happyTcHack st)) - (happyReturn1 ans) - ------------------------------------------------------------------------------ --- Arrays only: do the next action - - - -happyDoAction i tk st - = {- nothing -} - - - case action of - 0# -> {- nothing -} - happyFail i tk st - -1# -> {- nothing -} - happyAccept i tk st - n | (n <# (0# :: Int#)) -> {- nothing -} - - (happyReduceArr ! rule) i tk st - where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) - n -> {- nothing -} - - - happyShift new_state i tk st - where new_state = (n -# (1# :: Int#)) - where off = indexShortOffAddr happyActOffsets st - off_i = (off +# i) - check = if (off_i >=# (0# :: Int#)) - then (indexShortOffAddr happyCheck off_i ==# i) - else False - action | check = indexShortOffAddr happyTable off_i - | otherwise = indexShortOffAddr happyDefActions st - - - - - - - - - - - -indexShortOffAddr (HappyA# arr) off = -#if __GLASGOW_HASKELL__ > 500 - narrow16Int# i -#elif __GLASGOW_HASKELL__ == 500 - intToInt16# i -#else - (i `iShiftL#` 16#) `iShiftRA#` 16# -#endif - where -#if __GLASGOW_HASKELL__ >= 503 - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) -#else - i = word2Int# ((high `shiftL#` 8#) `or#` low) -#endif - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# - - - - - -data HappyAddr = HappyA# Addr# - - - - ------------------------------------------------------------------------------ --- HappyState data type (not arrays) - -{-# LINE 165 "GenericTemplate.hs" #-} - - ------------------------------------------------------------------------------ --- Shifting a token - -happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = - let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in --- trace "shifting the error token" $ - happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) - -happyShift new_state i tk st sts stk = - happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) - --- happyReduce is specialised for the common cases. - -happySpecReduce_0 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_0 nt fn j tk st@((action)) sts stk - = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) - -happySpecReduce_1 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') - = let r = fn v1 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_2 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') - = let r = fn v1 v2 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_3 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') - = let r = fn v1 v2 v3 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happyReduce k i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyReduce k nt fn j tk st sts stk - = case happyDrop (k -# (1# :: Int#)) sts of - sts1@((HappyCons (st1@(action)) (_))) -> - let r = fn stk in -- it doesn't hurt to always seq here... - happyDoSeq r (happyGoto nt j tk st1 sts1 r) - -happyMonadReduce k nt fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyMonadReduce k nt fn j tk st sts stk = - happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) - where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) - drop_stk = happyDropStk k stk - -happyDrop 0# l = l -happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t - -happyDropStk 0# l = l -happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs - ------------------------------------------------------------------------------ --- Moving to a new state after a reduction - - -happyGoto nt j tk st = - {- nothing -} - happyDoAction j tk new_state - where off = indexShortOffAddr happyGotoOffsets st - off_i = (off +# nt) - new_state = indexShortOffAddr happyTable off_i - - - - ------------------------------------------------------------------------------ --- Error recovery (0# is the error token) - --- parse error if we are in recovery and we fail again -happyFail 0# tk old_st _ stk = --- trace "failing" $ - happyError - - -{- We don't need state discarding for our restricted implementation of - "error". In fact, it can cause some bogus parses, so I've disabled it - for now --SDM - --- discard a state -happyFail 0# tk old_st (HappyCons ((action)) (sts)) - (saved_tok `HappyStk` _ `HappyStk` stk) = --- trace ("discarding state, depth " ++ show (length stk)) $ - happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) --} - --- Enter error recovery: generate an error token, --- save the old token and carry on. -happyFail i tk (action) sts stk = --- trace "entering error recovery" $ - happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) - --- Internal happy errors: - -notHappyAtAll = error "Internal Happy error\n" - ------------------------------------------------------------------------------ --- Hack to get the typechecker to accept our action functions - - -happyTcHack :: Int# -> a -> a -happyTcHack x y = y -{-# INLINE happyTcHack #-} - - ------------------------------------------------------------------------------ --- Seq-ing. If the --strict flag is given, then Happy emits --- happySeq = happyDoSeq --- otherwise it emits --- happySeq = happyDontSeq - -happyDoSeq, happyDontSeq :: a -> b -> b -happyDoSeq a b = a `seq` b -happyDontSeq a b = b - ------------------------------------------------------------------------------ --- Don't inline any functions from the template. GHC has a nasty habit --- of deciding to inline happyGoto everywhere, which increases the size of --- the generated parser quite a bit. - - -{-# NOINLINE happyDoAction #-} -{-# NOINLINE happyTable #-} -{-# NOINLINE happyCheck #-} -{-# NOINLINE happyActOffsets #-} -{-# NOINLINE happyGotoOffsets #-} -{-# NOINLINE happyDefActions #-} - -{-# NOINLINE happyShift #-} -{-# NOINLINE happySpecReduce_0 #-} -{-# NOINLINE happySpecReduce_1 #-} -{-# NOINLINE happySpecReduce_2 #-} -{-# NOINLINE happySpecReduce_3 #-} -{-# NOINLINE happyReduce #-} -{-# NOINLINE happyMonadReduce #-} -{-# NOINLINE happyGoto #-} -{-# NOINLINE happyFail #-} - --- end of Happy Template. rmfile ./src/printf/Printf/Parser.hs hunk ./src/printf/Printf/Parser.y 1 --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- 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. --- - --- --- Parser for printf format strings --- Based on B1.2 Formatted Output, from Kernighan and Ritchie. --- - -{ - -{-# OPTIONS -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-unused-binds -fno-warn-unused-matches -fno-warn-incomplete-patterns #-} --- ^ grr. happy needs them all on one line - -module Printf.Parser where - -import Printf.Lexer - -} - -%name parse -%tokentype { Token } -%token - - 'h' { LengthT 'h' } - 'l' { LengthT 'l' } - 'L' { LengthT 'L' } - - 'd' { ConvT 'd' } - 'i' { ConvT 'i' } - 'o' { ConvT 'o' } - 'x' { ConvT 'x' } - 'X' { ConvT 'X' } - 'u' { ConvT 'u' } - 'c' { ConvT 'c' } - 's' { ConvT 's' } - 'f' { ConvT 'f' } - 'e' { ConvT 'e' } - 'E' { ConvT 'E' } - 'g' { ConvT 'g' } - 'G' { ConvT 'G' } - '%' { ConvT '%' } - - '.' { DotT } - - INT { IntT $$ } - STRING { StrT $$ } - FLAGS { FlagT $$ } - -%% - -printf :: { [Format] } - : {- epsilon -} { [] } - | format0 printf { $1 : $2 } - -format0 :: { Format } - : string { $1 } - | format { $1 } - -string :: { Format } - : STRING { StrLit $1 } - -format :: { Format } - : flags width '.' precision length conv { ConvSp $1 $2 $4 $5 $6 } - | flags width length conv { ConvSp $1 $2 Nothing $3 $4 } - -flags :: { [Flag] } - : FLAGS { mkFlags $1 } - -precision :: { Maybe Prec } - : INT { Just $1 } - | {- epsilon -} { Nothing } - -width :: { Maybe Width } - : INT { Just $1 } - | {- epsilon -} { Nothing } - -length :: { Length } - : 'h' { Short } - | 'l' { Long } - | 'L' { Double } - | {- epsilon -} { Default} - -conv :: { Conv } - : 'd' { D } - | 'i' { D } -- n.b - | 'o' { O } - | 'x' { Xx } - | 'X' { XX } - | 'u' { U } - | 'c' { C } - | 's' { S } - | 'f' { F } - | 'e' { Ee } - | 'E' { EE } - | 'g' { Gg } - | 'G' { GG } - | '%' { Percent } - -{ - ------------------------------------------------------------------------- --- --- abstract syntax for printf format strings --- -data Format - = StrLit String - | ConvSp { flags :: [Flag], - width :: (Maybe Width), - precision :: (Maybe Prec ), - lenght :: Length, - conv :: Conv } - deriving (Show, Eq) - -type Width = Int -type Prec = Int - -data Flag - = LeftAdjust -- - - | Signed -- + - | Space -- ' ' - | LeadZero -- 0 - | Alt -- # - deriving (Show, Eq) - -data Length - = Short -- h - | Long -- l - | Double -- L - | Default - deriving (Show, Eq) - -data Conv - = D - | O - | Xx | XX - | U - | C - | S - | F - | Ee | EE - | Gg | GG - | Percent - deriving (Show, Eq) - -mkFlags :: [Char] -> [Flag] -mkFlags [] = [] -mkFlags (c:cs) = (case c of - '-' -> LeftAdjust - '+' -> Signed - ' ' -> Space - '0' -> LeadZero - '#' -> Alt) : mkFlags cs - -happyError :: [Token] -> a -happyError [] = error "Parser" "parse error" -happyError tks = error $ "Parser: " ++ show tks - -} rmfile ./src/printf/Printf/Parser.y rmdir ./src/printf/Printf hunk ./src/printf/Makefile 1 -PKG = printf -UPKG = Printf - -YOBJ = $(UPKG)/Parser.hs -YSRC = $(UPKG)/Parser.y - -XOBJ = $(UPKG)/Lexer.hs -XSRC = $(UPKG)/Lexer.x - -ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) - -TOP=../.. -include ../build.mk - -HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace -HC_OPTS += -package eval - -install: install-me - --include depend rmfile ./src/printf/Makefile hunk ./src/printf/Printf.hs 1 --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - -module Printf ( - module Printf.Compile - ) where - -import Printf.Compile {-all-} - rmfile ./src/printf/Printf.hs hunk ./src/printf/printf.conf.in.cpp 1 -#if CABAL == 0 && GLASGOW_HASKELL < 604 -Package { - name = "printf", - auto = False, - hs_libraries = [ "HSprintf" ], -#ifdef INSTALLING - import_dirs = [ "${LIBDIR}/imports" ], - library_dirs = [ "${LIBDIR}/" ], -#else - import_dirs = [ "${TOP}/src/printf" ], - library_dirs = [ "${TOP}/src/printf" ], -#endif - include_dirs = [], - c_includes = [], - source_dirs = [], - extra_libraries = [], - package_deps = [ "eval" ], - extra_ghc_opts = [], - extra_cc_opts = [], - extra_ld_opts = [] -} -#else -name: printf -version: 0.9.8 -license: LGPL -maintainer: dons@cse.unsw.edu.au -exposed: False -exposed-modules: - Printf.Compile, - Printf.Lexer, - Printf.Parser, - Printf - -hidden-modules: -#ifdef INSTALLING -import-dirs: LIBDIR/imports -library-dirs: LIBDIR -#else -import-dirs: TOP/src/printf -library-dirs: TOP/src/printf -#endif -hs-libraries: HSprintf -extra-libraries: -include-dirs: -includes: -depends: eval -hugs-options: -cc-options: -ld-options: -framework-dirs: -frameworks: -haddock-interfaces: -haddock-html: -#endif rmfile ./src/printf/printf.conf.in.cpp rmdir ./src/printf hunk ./configure.ac 7 -AC_INIT(src/plugins/Plugins.hs) +AC_INIT(src/plugins/System/Plugins.hs) hunk ./src/Makefile 5 -.PHONY: all build altdata hi plugins eval printf -.PHONY: install i_altdata i_hi i_plugins i_eval i_printf +.PHONY: all build altdata hi plugins +.PHONY: install i_altdata i_hi i_plugins hunk ./src/Makefile 8 -build: altdata hi plugins eval printf +build: altdata hi plugins hunk ./src/Makefile 16 -eval: plugins - @cd eval && $(MAKE) -printf: plugins - @cd printf && $(MAKE) hunk ./src/Makefile 17 -install: i_altdata i_hi i_plugins i_eval i_printf +install: i_altdata i_hi i_plugins hunk ./src/Makefile 26 -i_eval: - @cd eval && $(MAKE) install -i_printf: - @cd printf && $(MAKE) install hunk ./src/hi/Language/Hi/Binary.hs 36 -module Hi.Binary ( +module Language.Hi.Binary ( hunk ./src/hi/Language/Hi/Binary.hs 72 -import Hi.FastMutInt -import Hi.FastString +import Language.Hi.FastMutInt +import Language.Hi.FastString hunk ./src/hi/Language/Hi/Binary.hs 468 - bh <- Hi.Binary.readBinMem file_path + bh <- Language.Hi.Binary.readBinMem file_path hunk ./src/hi/Language/Hi/Binary.hs 481 - dict_p <- Hi.Binary.get bh -- Get the dictionary ptr + dict_p <- Language.Hi.Binary.get bh -- Get the dictionary ptr hunk ./src/hi/Language/Hi/FastMutInt.hs 29 -module Hi.FastMutInt ( +module Language.Hi.FastMutInt ( hunk ./src/hi/Language/Hi/FastString.hs 34 -module Hi.FastString +module Language.Hi.FastString hunk ./src/hi/Language/Hi/FastString.hs 68 -import Hi.PrimPacked +import Language.Hi.PrimPacked hunk ./src/hi/Language/Hi/Parser.hs 45 -module Hi.Parser ( readIface, module Hi.Syntax ) where +module Language.Hi.Parser ( readIface, module Language.Hi.Syntax ) where hunk ./src/hi/Language/Hi/Parser.hs 47 -import Hi.Syntax -import Hi.Binary -import Hi.FastString +import Language.Hi.Syntax +import Language.Hi.Binary +import Language.Hi.FastString hunk ./src/hi/Language/Hi/Parser.hs 53 -#include "../../../config.h" +#include "../../../../config.h" hunk ./src/hi/Language/Hi/PrimPacked.hs 37 -module Hi.PrimPacked ( +module Language.Hi.PrimPacked ( hunk ./src/hi/Language/Hi/Syntax.hs 23 -module Hi.Syntax where +module Language.Hi.Syntax where hunk ./src/hi/Language/Hi/Syntax.hs 25 -import Hi.FastString +import Language.Hi.FastString hunk ./src/hi/Makefile 4 -CSRC = $(UPKG)/hschooks.c -COBJ = $(UPKG)/hschooks.o +CSRC = Language/$(UPKG)/hschooks.c +COBJ = Language/$(UPKG)/hschooks.o hunk ./src/hi/Makefile 7 -ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) +ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, Language Language/$(UPKG)))) hunk ./src/hi/Makefile 12 -HC_OPTS += -I$(UPKG) +HC_OPTS += -ILanguage/$(UPKG) hunk ./src/hi/hi.conf.in.cpp 29 - Hi.Binary, - Hi.FastMutInt, - Hi.FastString, - Hi.Parser, - Hi.PrimPacked, - Hi.Syntax, - Hi + Language.Hi.Parser hunk ./src/hi/hi.conf.in.cpp 32 + Language.Hi.Binary, + Language.Hi.FastString, + Language.Hi.Syntax, + Language.Hi.FastMutInt, + Language.Hi.PrimPacked + hunk ./src/plugins/Makefile 8 -YOBJ = $(UPKG)/ParsePkgConfCabal.hs -YSRC = $(UPKG)/ParsePkgConfCabal.y -OTHER = $(UPKG)/ParsePkgConfLite.hs +YOBJ = System/$(UPKG)/ParsePkgConfCabal.hs +YSRC = System/$(UPKG)/ParsePkgConfCabal.y +OTHER = System/$(UPKG)/ParsePkgConfLite.hs hunk ./src/plugins/Makefile 12 -YOBJ = $(UPKG)/ParsePkgConfLite.hs -YSRC = $(UPKG)/ParsePkgConfLite.y -OTHER = $(UPKG)/ParsePkgConfCabal.hs +YOBJ = System/$(UPKG)/ParsePkgConfLite.hs +YSRC = System/$(UPKG)/ParsePkgConfLite.y +OTHER = System/$(UPKG)/ParsePkgConfCabal.hs hunk ./src/plugins/Makefile 17 +STUBOBJS =System/Eval/Haskell_stub.$(way_)o + hunk ./src/plugins/Makefile 21 - $(patsubst %, %/*.hs, . $(UPKG))))) + $(patsubst %, %/*.hs, System System/$(UPKG))))) hunk ./src/plugins/System/Eval/Haskell.hs 25 -module Eval.Haskell ( +module System.Eval.Haskell ( hunk ./src/plugins/System/Eval/Haskell.hs 37 - module Eval.Utils, + module System.Eval.Utils, hunk ./src/plugins/System/Eval/Haskell.hs 41 -import Eval.Utils - -import Plugins.Make -import Plugins.Load +import System.Eval.Utils +import System.Plugins.Make +import System.Plugins.Load hunk ./src/plugins/System/Eval/Utils.hs 25 -module Eval.Utils ( +module System.Eval.Utils ( hunk ./src/plugins/System/Eval/Utils.hs 41 -import Plugins.Load ( Symbol ) -import Plugins.Utils -import Plugins.Consts ( top {- :{ -} ) +import System.Plugins.Load ( Symbol ) +import System.Plugins.Utils +import System.Plugins.Consts ( top {- :{ -} ) hunk ./src/plugins/System/Eval.hs 20 -module Eval ( - module Eval.Haskell, - module Eval.Meta, +module System.Eval ( + module System.Eval.Haskell, hunk ./src/plugins/System/Eval.hs 24 -import Eval.Haskell {-all-} -import Eval.Meta {-all-} +import System.Eval.Haskell {-all-} hunk ./src/plugins/System/MkTemp.hs 30 -module Plugins.MkTemp ( +module System.MkTemp ( hunk ./src/plugins/System/Plugins/Consts.hs 21 -module Plugins.Consts where +module System.Plugins.Consts where hunk ./src/plugins/System/Plugins/Consts.hs 23 -#include "../../../config.h" +#include "../../../../config.h" hunk ./src/plugins/System/Plugins/Env.hs 21 -module Plugins.Env ( +module System.Plugins.Env ( hunk ./src/plugins/System/Plugins/Env.hs 44 -#include "../../../config.h" +#include "../../../../config.h" hunk ./src/plugins/System/Plugins/Env.hs 46 -import Plugins.PackageAPI {- everything -} +import System.Plugins.PackageAPI {- everything -} hunk ./src/plugins/System/Plugins/Env.hs 48 -import Plugins.ParsePkgConfCabal( parsePkgConf ) +import System.Plugins.ParsePkgConfCabal( parsePkgConf ) hunk ./src/plugins/System/Plugins/Env.hs 50 -import Plugins.ParsePkgConfLite ( parsePkgConf ) +import System.Plugins.ParsePkgConfLite ( parsePkgConf ) hunk ./src/plugins/System/Plugins/Env.hs 52 -import Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix, dllSuf ) +import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix, dllSuf ) hunk ./src/plugins/System/Plugins/Load.hs 22 -module Plugins.Load ( +module System.Plugins.Load ( hunk ./src/plugins/System/Plugins/Load.hs 50 -import Plugins.Make ( build ) -import Plugins.Env -import Plugins.Utils -import Plugins.Consts ( sysPkgSuffix, hiSuf, prefixUnderscore ) +import System.Plugins.Make ( build ) +import System.Plugins.Env +import System.Plugins.Utils +import System.Plugins.Consts ( sysPkgSuffix, hiSuf, prefixUnderscore ) hunk ./src/plugins/System/Plugins/Load.hs 55 -import Hi.Parser +import Language.Hi.Parser hunk ./src/plugins/System/Plugins/Make.hs 21 -module Plugins.Make ( +module System.Plugins.Make ( hunk ./src/plugins/System/Plugins/Make.hs 42 -import Plugins.Utils -import Plugins.Parser -import Plugins.Consts ( ghc, hiSuf, objSuf, hsSuf ) -import Plugins.Env ( lookupMerged, addMerge ) +import System.Plugins.Utils +import System.Plugins.Parser +import System.Plugins.Consts ( ghc, hiSuf, objSuf, hsSuf ) +import System.Plugins.Env ( lookupMerged, addMerge ) hunk ./src/plugins/System/Plugins/Package.hs 23 -module Plugins.Package {-everything-} where +module System.Plugins.Package {-everything-} where hunk ./src/plugins/System/Plugins/PackageAPI.hs 25 -module Plugins.PackageAPI ( +module System.Plugins.PackageAPI ( hunk ./src/plugins/System/Plugins/PackageAPI.hs 39 -#include "../../../config.h" +#include "../../../../config.h" hunk ./src/plugins/System/Plugins/PackageAPI.hs 45 -import Plugins.Package +import System.Plugins.Package hunk ./src/plugins/System/Plugins/ParsePkgConfCabal.hs 6 -module Plugins.ParsePkgConfCabal ( +module System.Plugins.ParsePkgConfCabal ( hunk ./src/plugins/System/Plugins/ParsePkgConfCabal.hs 518 --- $Id: ParsePkgConfCabal.hs,v 1.1 2005/04/22 08:58:28 dons Exp $ +-- $Id$ hunk ./src/plugins/System/Plugins/ParsePkgConfCabal.y 34 -module Plugins.ParsePkgConfCabal ( +module System.Plugins.ParsePkgConfCabal ( hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 6 -module Plugins.ParsePkgConfLite ( +module System.Plugins.ParsePkgConfLite ( hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 10 -import Plugins.Package ( PackageConfig(..), defaultPackageConfig ) +import System.Plugins.Package ( PackageConfig(..), defaultPackageConfig ) hunk ./src/plugins/System/Plugins/ParsePkgConfLite.y 31 -module Plugins.ParsePkgConfLite ( +module System.Plugins.ParsePkgConfLite ( hunk ./src/plugins/System/Plugins/ParsePkgConfLite.y 35 -import Plugins.Package ( PackageConfig(..), defaultPackageConfig ) +import System.Plugins.Package ( PackageConfig(..), defaultPackageConfig ) hunk ./src/plugins/System/Plugins/Parser.hs 21 -module Plugins.Parser ( +module System.Plugins.Parser ( hunk ./src/plugins/System/Plugins/Utils.hs 21 -#include "../../../config.h" +#include "../../../../config.h" hunk ./src/plugins/System/Plugins/Utils.hs 23 -module Plugins.Utils ( +module System.Plugins.Utils ( hunk ./src/plugins/System/Plugins/Utils.hs 58 -import Plugins.Env ( isLoaded ) -import Plugins.Consts ( objSuf, hiSuf, tmpDir ) -import qualified Plugins.MkTemp ( mkstemps ) +import System.Plugins.Env ( isLoaded ) +import System.Plugins.Consts ( objSuf, hiSuf, tmpDir ) +import qualified System.MkTemp ( mkstemps ) hunk ./src/plugins/System/Plugins/Utils.hs 107 - m_v <- Plugins.MkTemp.mkstemps path slen + m_v <- System.MkTemp.mkstemps path slen hunk ./src/plugins/System/Plugins.hs 20 -module Plugins ( +module System.Plugins ( hunk ./src/plugins/System/Plugins.hs 24 - module Plugins.Make, - module Plugins.Load, + module System.Plugins.Make, + module System.Plugins.Load, hunk ./src/plugins/System/Plugins.hs 29 -import Plugins.Make {-all-} -import Plugins.Load {-all-} +import System.Plugins.Make {-all-} +import System.Plugins.Load {-all-} hunk ./src/plugins/plugins.conf.in.cpp 31 - Plugins.Consts, - Plugins.Env, - Plugins.Load, - Plugins.Make, - Plugins.MkTemp, - Plugins.PackageAPI, - Plugins.ParsePkgConfCabal, - Plugins.Parser, - Plugins.Utils, - Plugins + System.Plugins.Load, + System.Plugins.Make, + System.Plugins, + System.MkTemp, + System.Eval.Haskell, + System.Eval hunk ./src/plugins/plugins.conf.in.cpp 39 + System.Plugins.Consts, + System.Plugins.Env, + System.Plugins.Package, + System.Plugins.PackageAPI, + System.Plugins.ParsePkgConfCabal, + System.Plugins.ParsePkgConfLite, + System.Plugins.Parser, + System.Plugins.Utils, + System.Eval.Utils + hunk ./Makefile 16 - cp src/eval/Eval/Haskell_stub.h $@ + cp src/plugins/System/Eval/Haskell_stub.h $@ hunk ./Makefile 36 - env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/eval/eval.conf.in - env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/printf/printf.conf.in hunk ./Makefile 39 - $(GHC_PKG) -r printf - $(GHC_PKG) -r eval hunk ./examples/printf/000/Main.hs 1 -import Printf - -main = do printf "%d\n" $> (42::Int) ! [] - printf "%u\n" $> (42::Int) ! [] - printf "0%o\n" $> (42::Int) ! [] - printf "0x%x\n" $> (42::Int) ! [] - printf "0x%X\n" $> (42::Int) ! [] - - printf "%e\n" $> (42.1234 :: Double) ! [] - printf "%E\n" $> (42.1234 :: Double) ! [] - printf "%g\n" $> (42.1234 :: Double) ! [] - printf "%G\n" $> (42.1234 :: Double) ! [] - printf "%f\n" $> (42.1234 :: Double) ! [] - - printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! [] - printf "%s\n" $> "printf" ! [] - - printf "%+d\n" $> (42::Int) ! [] - printf "%+0d\n" $> (42::Int) ! [] - printf "%0+d\n" $> (42::Int) ! [] - printf "%10d\n" $> (42::Int) ! [] - printf "%-010d\n" $> (42::Int) ! [] - printf "%-010.2d\n" $> (42::Int) ! [] - - printf "%+f\n" $> (42.1234 :: Double) ! [] - printf "%+0f\n" $> (42.1234 :: Double) ! [] - printf "%0+f\n" $> (42.1234 :: Double) ! [] - printf "%10f\n" $> (42.1234 :: Double) ! [] - printf "%-010f\n" $> (42.1234 :: Double) ! [] - printf "%-010.2f\n" $> (42.1234 :: Double) ! [] - - printf "%10s\n" $> "printf" ! [] - printf "%-10s\n" $> "printf" ! [] - printf "%10.2s\n" $> "printf" ! [] - printf "%2.10s\n" $> "printf" ! [] - printf "%-2.10s\n" $> "printf" ! [] - printf "%-10.2s\n" $> "printf" ! [] rmfile ./examples/printf/000/Main.hs hunk ./examples/printf/000/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/printf/000/Makefile hunk ./examples/printf/000/expected 1 -42 -42 -052 -0x2a -0x2A -4.212340e1 -4.212340E1 -42.123400 -42.123400 -42.123400 -a:b:c -printf -+42 -+42 -+42 - 42 -42 -42 -+42.123400 -+42.123400 -+42.123400 - 42.123400 -42.123400 -42.12 - printf -printf - pr -printf -printf -pr rmfile ./examples/printf/000/expected hunk ./examples/printf/000/printf.sh 1 -#!/bin/sh -printf "%d\n" 42 -printf "%u\n" 42 -printf "0%o\n" 42 -printf "0x%x\n" 42 -printf "0x%X\n" 42 - -printf "%e\n" 42.1234 -printf "%E\n" 42.1234 -printf "%g\n" 42.1234 -printf "%G\n" 42.1234 -printf "%f\n" 42.1234 - -printf "%c:%c:%c\n" 'a' 'b' 'c' -printf "%s\n" "printf" - -printf "%+d\n" 42 -printf "%+0d\n" 42 -printf "%0+d\n" 42 -printf "%10d\n" 42 -printf "%-010d\n" 42 -printf "%-010.2d\n" 42 - -printf "%+f\n" 42.1234 -printf "%+0f\n" 42.1234 -printf "%0+f\n" 42.1234 -printf "%10f\n" 42.1234 -printf "%-010f\n" 42.1234 -printf "%-010.2f\n" 42.1234 - -printf "%10s\n" "printf" -printf "%-10s\n" "printf" -printf "%10.2s\n" "printf" -printf "%2.10s\n" "printf" -printf "%-2.10s\n" "printf" -printf "%-10.2s\n" "printf" rmfile ./examples/printf/000/printf.sh rmdir ./examples/printf/000 hunk ./examples/printf/002/Main.hs 1 -import Printf -import Control.Exception ( evaluate ) - -main = do - fn <- evaluate $! printf "%10.4f\n" - fn $> (10.0 :: Double) ! [] - fn $> (-10.0 :: Double) ! [] - fn $> (10.1010 :: Double) ! [] - fn $> (0.0 :: Double) ! [] - fn $> (0.987654321 :: Double) ! [] - fn $> (987654321 :: Double) ! [] - fn $> (-987654321 :: Double) ! [] rmfile ./examples/printf/002/Main.hs hunk ./examples/printf/002/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/printf/002/Makefile hunk ./examples/printf/002/expected 1 - 10.0000 - -10.0000 - 10.1010 - 0.0000 - 0.9877 -987654321.0000 --987654321.0000 rmfile ./examples/printf/002/expected rmdir ./examples/printf/002 hunk ./examples/printf/001/Main.hs 1 -import Printf - -main = do - printf "%d\n" $> (42 :: Int) ! [] - printf "0x%X\n" $> (42 :: Int) ! [] - printf "%f\n" $> (42.1234 :: Double) ! [] - printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! [] - printf "%s\n" $> "haskell" ! [] - printf "%-010.4d\n" $> (42 :: Int) ! [] - printf "%010.4f\n" $> (42.1234 :: Double) ! [] - printf "%10.4s\n" $> (show (7 :: Int)) ! [] - printf "%-10.4s\n" $> "haskell" ! [] - rmfile ./examples/printf/001/Main.hs hunk ./examples/printf/001/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/printf/001/Makefile hunk ./examples/printf/001/expected 1 -42 -0x2A -42.123400 -a:b:c -haskell -42 -00042.1234 - 7 -hask rmfile ./examples/printf/001/expected hunk ./examples/printf/should_fail_000/Main.hs 1 -import Printf - -main = printf "%x\n" $> "badstring" ! [] rmfile ./examples/printf/should_fail_000/Main.hs hunk ./examples/printf/should_fail_000/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/printf/should_fail_000/Makefile hunk ./examples/printf/should_fail_000/expected 1 - -Fail: Type error in dynamic application. -Can't apply function [Char]> to argument <[Char]> rmfile ./examples/printf/should_fail_000/expected hunk ./examples/printf/should_fail_000/expected.604 1 -a.out: Type error in dynamic application. -Can't apply function [Char]> to argument <[Char]> rmfile ./examples/printf/should_fail_000/expected.604 rmdir ./examples/printf/should_fail_000 hunk ./examples/printf/should_fail_001/Main.hs 1 -import Printf - -main = do - printf "%d\n" $> (42 :: Int) ! [] - printf "0x%X\n" $> (42 :: Int) ! [] - printf "%f\n" $> (42.1234 :: Double) ! [] - printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! [] - printf "%s\n" $> "haskell" ! [] - printf "%-010.4d\n" $> (42 :: Int) ! [] - printf "%010.4f\n" $> (42.1234 :: Double) ! [] - printf "%10.4s\n" $> (7 :: Int)! [] - printf "%-10.4s\n" $> "haskell" ! [] - rmfile ./examples/printf/should_fail_001/Main.hs hunk ./examples/printf/should_fail_001/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/printf/should_fail_001/Makefile hunk ./examples/printf/should_fail_001/expected 1 -42 -0x2A -42.123400 -a:b:c -haskell -42 -00042.1234 - -Fail: Type error in dynamic application. -Can't apply function <[Char] -> [Char]> to argument rmfile ./examples/printf/should_fail_001/expected hunk ./examples/printf/should_fail_001/expected.604 1 -42 -0x2A -42.123400 -a:b:c -haskell -42 -00042.1234 -a.out: Type error in dynamic application. -Can't apply function <[Char] -> [Char]> to argument rmfile ./examples/printf/should_fail_001/expected.604 rmdir ./examples/printf/should_fail_001 rmdir ./examples/printf/001 hunk ./src/altdata/AltData.hs 1 --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - -module AltData ( module AltData.Dynamic, - module AltData.Typeable - ) where -import AltData.Dynamic {-all-} -import AltData.Typeable {-all-} rmfile ./src/altdata/AltData.hs hunk ./src/altdata/altdata.conf.in.cpp 30 - AltData.Typeable, - AltData + AltData.Typeable hunk ./src/plugins/Makefile 21 - $(patsubst %, %/*.hs, System System/$(UPKG))))) + $(patsubst %, %/*.hs, System System/$(UPKG) System/Eval)))) hunk ./src/plugins/plugins.conf.in.cpp 35 - System.Eval.Haskell, - System.Eval + System.Eval, + System.Eval.Haskell rmdir ./examples/printf hunk ./examples/popen/test1/Main.hs 1 --- --- test the popen function --- - -import Plugins.Utils -import System.IO - -main = do - (sout,serr) <- exec "date" [] - mapM_ putStrLn serr rmfile ./examples/popen/test1/Main.hs hunk ./examples/popen/test1/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/popen/test1/Makefile rmfile ./examples/popen/test1/expected rmdir ./examples/popen/test1 rmdir ./examples/popen hunk ./examples/conf/simple/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/dynload/io/TestIO.hs 10 -import AltData +import AltData.Dynamic hunk ./examples/dynload/io/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/io/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/dynload/poly/Plugin.hs 4 -import AltData +import AltData.Dynamic hunk ./examples/dynload/poly/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/poly/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/dynload/should_fail/Plugin.hs 5 -import AltData +import AltData.Dynamic hunk ./examples/dynload/should_fail/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/should_fail/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/dynload/should_fail_1/Plugin.hs 8 -import AltData +import AltData.Dynamic hunk ./examples/dynload/should_fail_1/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/should_fail_1/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/dynload/should_fail_2/Plugin.in 12 -import AltData +import AltData.Typeable hunk ./examples/dynload/should_fail_2/Plugin.stub 6 -import AltData +import AltData.Dynamic hunk ./examples/dynload/should_fail_2/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/should_fail_2/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/dynload/should_fail_2/prog/expected.604 2 -../Plugin.in:18:15: +../Plugin.in:13:15: hunk ./examples/dynload/should_fail_3/Plugin.in 12 -import AltData +import AltData.Typeable hunk ./examples/dynload/should_fail_3/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/should_fail_3/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/dynload/should_fail_3/prog/expected.604 2 -../Plugin.in:18:15: +../Plugin.in:12:15: hunk ./examples/dynload/simple/Plugin.hs 5 -import AltData +import AltData.Dynamic hunk ./examples/dynload/simple/api/API.hs 5 -import AltData +import AltData.Typeable hunk ./examples/dynload/simple/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/eval/eval1/Main.hs 2 -import Eval.Haskell +import System.Eval.Haskell hunk ./examples/eval/eval2/Main.hs 1 -import Eval.Haskell +import System.Eval.Haskell hunk ./examples/eval/eval3/Main.hs 13 -import Eval.Haskell +import System.Eval.Haskell hunk ./examples/eval/eval_/Main.hs 2 -import Eval.Haskell +import System.Eval.Haskell hunk ./examples/eval/eval_fn/Main.hs 7 -import Eval.Haskell +import System.Eval.Haskell hunk ./examples/eval/eval_fn1/Main.hs 9 -import Eval.Haskell +import System.Eval.Haskell hunk ./examples/eval/unsafeidir/Main.hs 2 -import Plugins.Make -import Eval.Haskell +import System.Plugins.Make +import System.Eval.Haskell hunk ./examples/eval.mk 4 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package eval -package plugins -package printf +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package plugins hunk ./examples/eval.mk 27 - rm -rf *.hi *.o *~ $(BIN) + @rm -rf *.hi *.o *~ $(BIN) hunk ./examples/foreign.mk 6 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package eval +PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package plugins hunk ./examples/hier/hier1/prog/Main.hs 8 -import Plugins +import System.Plugins hunk ./examples/hier/hier2/prog/Main.hs 9 -import Plugins +import System.Plugins hunk ./examples/hier/hier3/Main.hs 3 -import Plugins +import System.Plugins hunk ./examples/hier/hier4/Main.hs 3 -import Plugins +import System.Plugins hunk ./examples/iface/null/Main.hs 3 -import Hi.Parser +import Language.Hi.Parser hunk ./examples/load/io/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/load/load_0/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/load/loadpkg/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/load/null/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/load/thiemann0/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/load/thiemann2/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/load/unloadpkg/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/make/makeall001/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/make/null/prog/Main.hs 4 -import Plugins +import System.Plugins hunk ./examples/make/o/prog/Main.hs 1 -import Plugins +import System.Plugins hunk ./examples/make/odir/prog/Main.hs 1 -import Plugins +import System.Plugins hunk ./examples/make/remake001/Main.hs 10 -import Plugins +import System.Plugins hunk ./examples/make/remake001_should_fail/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/make/simple/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/makewith/global_pragma/Plugin.hs 5 -import System.IO.Unsafe hunk ./examples/makewith/global_pragma/Plugin.hs 6 +import System.IO.Unsafe hunk ./examples/makewith/global_pragma/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/io/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/merge00/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/mergeto0/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/module_name/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/multi_make/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/should_fail_0/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/tiny/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/makewith/unsafeio/prog/Main.hs 1 -import Plugins +import System.Plugins hunk ./examples/misc/mkstemps/Main.hs 2 -import Plugins.MkTemp +import System.MkTemp hunk ./examples/multi/3plugins/prog/Main.hs 1 -import Plugins +import System.Plugins hunk ./examples/objc/expression_parser/PluginEvalAux.hs 5 -import Plugins.Make -import Plugins.Load -import Plugins.Utils +import System.Plugins.Make +import System.Plugins.Load +import System.Plugins.Utils hunk ./examples/pdynload/badint/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/null/prog/Main.hs 2 -import Plugins -import Plugins.Utils +import System.Plugins +-- import System.Plugins.Utils hunk ./examples/pdynload/numclass/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/poly/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/poly1/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/should_fail0/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/should_fail1/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/small/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/spj1/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/spj2/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/spj3/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/spj4/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/typealias/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pdynload/univquant/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/pkgconf/null/prog/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/plugs/plugs/Main.hs 6 -import Eval.Haskell -import Plugins.Load +import System.Eval.Haskell +import System.Plugins.Load hunk ./examples/plugs/plugs/Makefile 3 -PKGFLAGS+= -package eval -package readline +PKGFLAGS+= -package plugins -package readline hunk ./examples/plugs/runplugs/Main.hs 11 -import Eval.Haskell (unsafeEval) +import System.Eval.Haskell (unsafeEval) hunk ./examples/plugs/runplugs/Makefile 3 -PKGFLAGS+= -package eval -package unix +PKGFLAGS+= -package plugins -package unix hunk ./examples/reload/null/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/shell/shell/Main.hs 5 -import Plugins +import System.Plugins hunk ./examples/shell/simple/Main.hs 1 -import Plugins +import System.Plugins hunk ./examples/typecase/000/Main.hs 1 -import AltData +import AltData.Dynamic hunk ./examples/unload/null/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./examples/unload/sjwtrap/prog/Main.hs 2 -import Plugins +import System.Plugins hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 335 --- $Id: ParsePkgConfLite.hs,v 1.3 2004/06/19 01:28:56 dons Exp $ +{-# LINE 1 "" #-} +{-# LINE 1 "" #-} +{-# LINE 1 "GenericTemplate.hs" #-} +-- $Id$ hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 341 +{-# LINE 28 "GenericTemplate.hs" #-} hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 344 - - - - - - - - - -{-# LINE 27 "GenericTemplate.hs" #-} - - - hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 351 +{-# LINE 49 "GenericTemplate.hs" #-} hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 354 +{-# LINE 59 "GenericTemplate.hs" #-} hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 365 - - - - - - - - - - - - - - - - - - - - hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 376 -happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j - (happyTcHack st)) +happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j (happyTcHack st)) + hunk ./src/plugins/System/Plugins/ParsePkgConfLite.hs 451 -{-# LINE 165 "GenericTemplate.hs" #-} - +{-# LINE 166 "GenericTemplate.hs" #-} hunk ./src/altdata/Makefile 3 +PATHS = AltData hunk ./src/build.mk 98 - $(INSTALL_DATA_DIR) $(LIBDIR)/imports/$(UPKG) - @for i in $(TOP)/src/$(PKG)/*.$(way_)hi ; do \ - echo $(INSTALL_DATA) $$i $(LIBDIR)/imports/ ; \ - $(INSTALL_DATA) $$i $(LIBDIR)/imports/ ; \ - done - @for i in $(TOP)/src/$(PKG)/$(UPKG)/*.$(way_)hi ; do \ - echo $(INSTALL_DATA) $$i $(LIBDIR)/imports/$(UPKG)/ ; \ - $(INSTALL_DATA) $$i $(LIBDIR)/imports/$(UPKG)/ ; \ - done + @for i in $(PATHS) ; do \ + $(INSTALL_DATA_DIR) $(LIBDIR)/imports/$$i ;\ + for j in $(TOP)/src/$(PKG)/$$i/*.$(way_)hi ; do \ + echo $(INSTALL_DATA) $$j $(LIBDIR)/imports/$$i/ ; \ + $(INSTALL_DATA) $$j $(LIBDIR)/imports/$$i/ ; \ + done ;\ + done hunk ./src/hi/Makefile 7 +PATHS = Language Language/$(UPKG) + hunk ./src/plugins/Makefile 4 +PATHS = System System/Eval System/Plugins + hunk ./src/build.mk 96 +HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(ALL_SRCS))) + hunk ./src/build.mk 102 - for j in $(TOP)/src/$(PKG)/$$i/*.$(way_)hi ; do \ - echo $(INSTALL_DATA) $$j $(LIBDIR)/imports/$$i/ ; \ - $(INSTALL_DATA) $$j $(LIBDIR)/imports/$$i/ ; \ - done ;\ - done + done + @for j in $(HS_IFACES) ; do \ + echo $(INSTALL_DATA) $(TOP)/src/$(PKG)/$$j $(LIBDIR)/imports/$$j ; \ + $(INSTALL_DATA) $(TOP)/src/$(PKG)/$$j $(LIBDIR)/imports/$$j ; \ + done addfile ./configure hunk ./configure 1 +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# 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. +## --------------------- ## +## 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 + + +# 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= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="src/plugins/System/Plugins.hs" +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 build build_cpu build_vendor build_os PREFIX WHOLE_ARCHIVE_FLAG LEADING_UNDERSCORE SYMS TOP GHC GHC_LIB_PATH GHC_VERSION GLASGOW_HASKELL CABAL DEBUG_OPTS GHCPKG HADDOCK HAPPY ALEX LD AR RANLIB RM TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA 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 + +# +# 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 this package 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] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-cabal Enable use of Cabal packages in pluggable-1-branch + of GHC + --enable-debug Enable a debug version of hs-plugins to be built + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-ghc= use a specific Haskell compiler + +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 + +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 + +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 $as_me, 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 + + + + + + + + + + + + + + + + + + + + +# untested on earlier than 2.52, but it won't work anyway + + +# Find out what type of system we're running on +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; 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 $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&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. + +# 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/'` + + + +Platform="$build_cpu-$build_vendor-$build_os" + +# This isn't right for msys mingw. +PREFIX="$prefix" +if test "$prefix" = "NONE" +then + if test "$build_os" = "cygwin" + then + PREFIX="c:/cygwin$ac_default_prefix" + else + PREFIX="$ac_default_prefix" + fi +fi + + +case $Platform in +powerpc-apple-darwin*) + MACOSX=yes + ;; +*) + MACOSX=no + ;; +esac +if test "$MACOSX" = "yes" +then + WHOLE_ARCHIVE_FLAG=-all_load + LEADING_UNDERSCORE=1 +else + WHOLE_ARCHIVE_FLAG=--whole-archive + LEADING_UNDERSCORE=0 +fi + + + + +if test "$build_os" = "mingw32" +then + LEADING_UNDERSCORE=1 + SYMS="$SYMS -D__MINGW32__" +fi + + + +if test "$build_os" = "cygwin" +then + LEADING_UNDERSCORE=1 + SYMS="$SYMS -DCYGWIN" +fi + + + +# Find pwd, in a cygwin friendly way. +# Suggested by: http://www.haskell.org/ghc/docs/latest/html/users_guide/ch11s04.html +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghci -ignore-dot-ghci -v0` + + +# necessary tools + +# allow user supplied haskell compiler + +# Check whether --with-ghc or --without-ghc was given. +if test "${with_ghc+set}" = set; then + withval="$with_ghc" + GHC="$withval" + if test ! -f "$GHC" ; then + { { echo "$as_me:$LINENO: error: $GHC not found. You need GHC to build this project" >&5 +echo "$as_me: error: $GHC not found. You need GHC to build this project" >&2;} + { (exit 1); exit 1; }; } + fi + +else + # Extract the first word of "ghc", so it can be a program name with args. +set dummy ghc; 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_GHC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$GHC"; then + ac_cv_prog_GHC="$GHC" # 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_GHC="ghc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +GHC=$ac_cv_prog_GHC +if test -n "$GHC"; then + echo "$as_me:$LINENO: result: $GHC" >&5 +echo "${ECHO_T}$GHC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + if test -z "$GHC" ; then + { { echo "$as_me:$LINENO: error: You need GHC to build this project" >&5 +echo "$as_me: error: You need GHC to build this project" >&2;} + { (exit 1); exit 1; }; } + fi + + +fi; + + +# find path to GHC libs, for runtime_loader +if test -n "$GHC" ; then + echo "$as_me:$LINENO: checking for ghc library directory" >&5 +echo $ECHO_N "checking for ghc library directory... $ECHO_C" >&6 + GHC_LIB_PATH=`$GHC --print-libdir` + echo "$as_me:$LINENO: result: $GHC_LIB_PATH" >&5 +echo "${ECHO_T}$GHC_LIB_PATH" >&6 +fi + + +# check ghc version here +if test -n "$GHC" ; then + echo "$as_me:$LINENO: checking for ghc version" >&5 +echo $ECHO_N "checking for ghc version... $ECHO_C" >&6 + GHC_VERSION=`$GHC --numeric-version` + echo "$as_me:$LINENO: result: $GHC_VERSION" >&5 +echo "${ECHO_T}$GHC_VERSION" >&6 +fi + + +# Work out value of __GLASGOW_HASKELL__ +if test -n "$GHC" ; then + echo "$as_me:$LINENO: checking for value of __GLASGOW_HASKELL__" >&5 +echo $ECHO_N "checking for value of __GLASGOW_HASKELL__... $ECHO_C" >&6 + echo "main = print __GLASGOW_HASKELL__" > t.hs + GLASGOW_HASKELL=`echo 'main' | "$GHC" --interactive -ignore-dot-ghci -v0 -cpp t.hs` + rm t.hs + echo "$as_me:$LINENO: result: $GLASGOW_HASKELL" >&5 +echo "${ECHO_T}$GLASGOW_HASKELL" >&6 +fi + + +MAJOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\1/'` +MINOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\2/'` + +if test "$MAJOR" -lt "6"; then + { { echo "$as_me:$LINENO: error: Found major $MAJOR. You need a ghc version >= 6.2" >&5 +echo "$as_me: error: Found major $MAJOR. You need a ghc version >= 6.2" >&2;} + { (exit 1); exit 1; }; } ; +fi +if test "$MINOR" -lt "2"; then + { { echo "$as_me:$LINENO: error: You need a ghc version >= 6.2" >&5 +echo "$as_me: error: You need a ghc version >= 6.2" >&2;} + { (exit 1); exit 1; }; } ; +fi + +#Allow plugins to be built with Cabal libraries +# Check whether --enable-cabal or --disable-cabal was given. +if test "${enable_cabal+set}" = set; then + enableval="$enable_cabal" + CABAL=1 +else + CABAL=0 +fi; + +# used by the Makefile`s to alter dependencies. +if test "$MAJOR" -ge "6" -a "$MINOR" -ge "4"; then + CABAL=1 +fi + + + +# Allow a debugging version of hs-plugins to be built +# Check whether --enable-debug or --disable-debug was given. +if test "${enable_debug+set}" = set; then + enableval="$enable_debug" + DEBUG_OPTS=-DDEBUG +else + DEBUG_OPTS= +fi; + + + +# Search for ghc-pkg +echo "$as_me:$LINENO: checking for ghc-pkg" >&5 +echo $ECHO_N "checking for ghc-pkg... $ECHO_C" >&6 +ghc_pkg_guess=`echo $GHC | sed 's,ghc\([^/\\]*\)$,ghc-pkg\1,'` +if "$ghc_pkg_guess" -l > /dev/null 2>&1; then + matching_ghc_pkg=$ghc_pkg_guess +else + matching_ghc_pkg=no +fi +if test x"$matching_ghc_pkg" = xno; then + # Extract the first word of "ghc-pkg", so it can be a program name with args. +set dummy ghc-pkg; 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_GHCPKG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$GHCPKG"; then + ac_cv_prog_GHCPKG="$GHCPKG" # 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_GHCPKG="" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +GHCPKG=$ac_cv_prog_GHCPKG +if test -n "$GHCPKG"; then + echo "$as_me:$LINENO: result: $GHCPKG" >&5 +echo "${ECHO_T}$GHCPKG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + if test -z "$GHCPKG" ; then + { { echo "$as_me:$LINENO: error: ghc-pkg not found." >&5 +echo "$as_me: error: ghc-pkg not found." >&2;} + { (exit 1); exit 1; }; } + fi +else + GHCPKG=$matching_ghc_pkg +fi +echo "$as_me:$LINENO: result: $GHCPKG" >&5 +echo "${ECHO_T}$GHCPKG" >&6 + + +# Extract the first word of "haddock", so it can be a program name with args. +set dummy haddock; 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_HADDOCK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$HADDOCK"; then + ac_cv_prog_HADDOCK="$HADDOCK" # 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_HADDOCK="haddock" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +HADDOCK=$ac_cv_prog_HADDOCK +if test -n "$HADDOCK"; then + echo "$as_me:$LINENO: result: $HADDOCK" >&5 +echo "${ECHO_T}$HADDOCK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$HADDOCK" ; then + { echo "$as_me:$LINENO: WARNING: You need Haddock if you want developer documentation" >&5 +echo "$as_me: WARNING: You need Haddock if you want developer documentation" >&2;} +fi + +# Extract the first word of "happy", so it can be a program name with args. +set dummy happy; 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_HAPPY+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$HAPPY"; then + ac_cv_prog_HAPPY="$HAPPY" # 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_HAPPY="happy" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +HAPPY=$ac_cv_prog_HAPPY +if test -n "$HAPPY"; then + echo "$as_me:$LINENO: result: $HAPPY" >&5 +echo "${ECHO_T}$HAPPY" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$HAPPY" ; then + { echo "$as_me:$LINENO: WARNING: If you change or remove the parser you'll need Happy" >&5 +echo "$as_me: WARNING: If you change or remove the parser you'll need Happy" >&2;} +fi + +# Extract the first word of "alex", so it can be a program name with args. +set dummy alex; 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_ALEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ALEX"; then + ac_cv_prog_ALEX="$ALEX" # 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_ALEX="alex" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ALEX=$ac_cv_prog_ALEX +if test -n "$ALEX"; then + echo "$as_me:$LINENO: result: $ALEX" >&5 +echo "${ECHO_T}$ALEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$ALEX" ; then + { echo "$as_me:$LINENO: WARNING: If you change or remove the lexer files you'll need alex" >&5 +echo "$as_me: WARNING: If you change or remove the lexer files you'll need alex" >&2;} +fi + +# Extract the first word of "ld", so it can be a program name with args. +set dummy ld; 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_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LD"; then + ac_cv_prog_LD="$LD" # 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_LD="ld" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LD=$ac_cv_prog_LD +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$LD" ; then + { echo "$as_me:$LINENO: WARNING: You need ld -export-dynamic" >&5 +echo "$as_me: WARNING: You need ld -export-dynamic" >&2;} +fi + +# 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_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="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 + +if test -z "$AR" ; then + { echo "$as_me:$LINENO: WARNING: You need ar to build the library" >&5 +echo "$as_me: WARNING: You need ar to build the library" >&2;} +fi + +# 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_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="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 + +if test -z "$RANLIB" ; then + { echo "$as_me:$LINENO: WARNING: You need randlib to build the library" >&5 +echo "$as_me: WARNING: You need randlib to build the library" >&2;} +fi + +# Extract the first word of "rm", so it can be a program name with args. +set dummy rm; 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_RM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RM"; then + ac_cv_prog_RM="$RM" # 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_RM="rm" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RM=$ac_cv_prog_RM +if test -n "$RM"; then + echo "$as_me:$LINENO: result: $RM" >&5 +echo "${ECHO_T}$RM" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$RM" ; then + { echo "$as_me:$LINENO: WARNING: You need rm!" >&5 +echo "$as_me: WARNING: You need rm!" >&2;} +fi + +# Extract the first word of "tex", so it can be a program name with args. +set dummy tex; 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_TEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$TEX"; then + ac_cv_prog_TEX="$TEX" # 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_TEX="tex" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +TEX=$ac_cv_prog_TEX +if test -n "$TEX"; then + echo "$as_me:$LINENO: result: $TEX" >&5 +echo "${ECHO_T}$TEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$TEX" ; then + { echo "$as_me:$LINENO: WARNING: You'll need tex if you wish to build the documentation" >&5 +echo "$as_me: WARNING: You'll need tex if you wish to build the documentation" >&2;} +fi +# Extract the first word of "tex2page", so it can be a program name with args. +set dummy tex2page; 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_TEX2PAGE+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$TEX2PAGE"; then + ac_cv_prog_TEX2PAGE="$TEX2PAGE" # 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_TEX2PAGE="tex2page" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +TEX2PAGE=$ac_cv_prog_TEX2PAGE +if test -n "$TEX2PAGE"; then + echo "$as_me:$LINENO: result: $TEX2PAGE" >&5 +echo "${ECHO_T}$TEX2PAGE" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$TEX2PAGE" ; then + { echo "$as_me:$LINENO: WARNING: You'll need tex2page if you wish to build the + documentation: http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&5 +echo "$as_me: WARNING: You'll need tex2page if you wish to build the + documentation: http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&2;} +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 +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 + + +echo "$as_me:$LINENO: checking for arc4random" >&5 +echo $ECHO_N "checking for arc4random... $ECHO_C" >&6 +if test "${ac_cv_func_arc4random+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 arc4random to an innocuous variant, in case declares arc4random. + For example, HP-UX 11i declares gettimeofday. */ +#define arc4random innocuous_arc4random + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char arc4random (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef arc4random + +/* 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 arc4random (); +/* 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_arc4random) || defined (__stub___arc4random) +choke me +#else +char (*f) () = arc4random; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != arc4random; + ; + 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_arc4random=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_arc4random=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_arc4random" >&5 +echo "${ECHO_T}$ac_cv_func_arc4random" >&6 +if test $ac_cv_func_arc4random = yes; then + SYMS="$SYMS -DHAVE_ARC4RANDOM" +fi + + + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + + ac_config_files="$ac_config_files config.mk config.h" + + +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 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +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 $as_me, 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 + +Configuration files: +$config_files + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +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 +INSTALL="$INSTALL" +_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. + "config.mk" ) CONFIG_FILES="$CONFIG_FILES config.mk" ;; + "config.h" ) CONFIG_FILES="$CONFIG_FILES config.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 +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,@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,@PREFIX@,$PREFIX,;t t +s,@WHOLE_ARCHIVE_FLAG@,$WHOLE_ARCHIVE_FLAG,;t t +s,@LEADING_UNDERSCORE@,$LEADING_UNDERSCORE,;t t +s,@SYMS@,$SYMS,;t t +s,@TOP@,$TOP,;t t +s,@GHC@,$GHC,;t t +s,@GHC_LIB_PATH@,$GHC_LIB_PATH,;t t +s,@GHC_VERSION@,$GHC_VERSION,;t t +s,@GLASGOW_HASKELL@,$GLASGOW_HASKELL,;t t +s,@CABAL@,$CABAL,;t t +s,@DEBUG_OPTS@,$DEBUG_OPTS,;t t +s,@GHCPKG@,$GHCPKG,;t t +s,@HADDOCK@,$HADDOCK,;t t +s,@HAPPY@,$HAPPY,;t t +s,@ALEX@,$ALEX,;t t +s,@LD@,$LD,;t t +s,@AR@,$AR,;t t +s,@RANLIB@,$RANLIB,;t t +s,@RM@,$RM,;t t +s,@TEX@,$TEX,;t t +s,@TEX2PAGE@,$TEX2PAGE,;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,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;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 + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + 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 +s,@INSTALL@,$ac_INSTALL,;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 + +{ (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 + + hunk ./Makefile 69 - config.h config.mk config.log config.status configure + config.h config.mk config.log config.status hunk ./src/plugins/System/Plugins/Load.hs 72 +import System.IO ( hClose ) hunk ./src/plugins/System/Plugins/Load.hs 225 --- .hc into /dev/null, .hi into /dev/null --- --- NON_PORTABLE == /dev/null --- hunk ./src/plugins/System/Plugins/Load.hs 235 - (tmpf,hdl) <- mkTemp + (tmpf,hdl) <- mkTemp + (tmpf1,hdl1) <- mkTemp -- and send .hi file here. + hClose hdl1 hunk ./src/plugins/System/Plugins/Load.hs 245 -#if defined(CYGWIN) || defined(__MINGW32__) - e <- build tmpf "nul" (i:is++args++["-fno-code","-ohi nul"]) -#else - e <- build tmpf "/dev/null" (i:is++args++["-fno-code","-ohi/dev/null"]) -#endif +-- was need for cygwin, should be ok now: +-- e <- build tmpf "nul" (i:is++args++["-fno-code","-ohi nul"]) + + e <- build tmpf tmpf1 (i:is++args++["-fno-code","-ohi "++tmpf1]) hunk ./src/plugins/System/Plugins/Load.hs 250 + removeFile tmpf1 hunk ./src/altdata/AltData/Dynamic.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} +----------------------------------------------------------------------------- +-- | +-- Module : Data.Dynamic +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) hunk ./src/altdata/AltData/Dynamic.hs 8 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : portable +-- +-- The Dynamic interface provides basic support for dynamic types. hunk ./src/altdata/AltData/Dynamic.hs 14 --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. +-- Operations for injecting values of arbitrary type into +-- a dynamically typed value, Dynamic, are provided, together +-- with operations for converting dynamic values into a concrete +-- (monomorphic) type. hunk ./src/altdata/AltData/Dynamic.hs 19 --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- +----------------------------------------------------------------------------- hunk ./src/altdata/AltData/Dynamic.hs 21 --- --- reimplement the Data.Dynamic library to use equality over the --- canonical name of a type, rather than on integer keys. The later is --- how the Haskell library works, and is broken for our situation: --- static versus dynamic instances of the same type seem to generate --- different keys, meaning equal types are not detected as such. --- +module Data.Dynamic + ( hunk ./src/altdata/AltData/Dynamic.hs 24 -module AltData.Dynamic ( + -- Module Data.Typeable re-exported for convenience + module Data.Typeable, hunk ./src/altdata/AltData/Dynamic.hs 27 - Dynamic, -- must be abstract - toDyn, -- :: Typeable a => a -> Dynamic - fromDyn, -- :: Typeable a => Dynamic -> Maybe a - fromDynamic, - dynApp, - dynApply, - dynAppHList, + -- * The @Dynamic@ type + Dynamic, -- abstract, instance of: Show, Typeable hunk ./src/altdata/AltData/Dynamic.hs 30 - typecase, - (-->), + -- * Converting to and from @Dynamic@ + toDyn, -- :: Typeable a => a -> Dynamic + fromDyn, -- :: Typeable a => Dynamic -> a -> a + fromDynamic, -- :: Typeable a => Dynamic -> Maybe a + + -- * Applying functions of dynamic type + dynApply, + dynApp, + dynTypeRep hunk ./src/altdata/AltData/Dynamic.hs 40 - _Int, - _Char, - _Bool, - _String, - _IntToInt, + ) where hunk ./src/altdata/AltData/Dynamic.hs 42 - ) where hunk ./src/altdata/AltData/Dynamic.hs 45 -import System.IO.Unsafe ( unsafePerformIO ) -import GHC.Base ( unsafeCoerce# ) -import Data.List hunk ./src/altdata/AltData/Dynamic.hs 46 +#ifdef __GLASGOW_HASKELL__ +import GHC.Base +import GHC.Show +import GHC.Err +import GHC.Num +#endif + +#ifdef __HUGS__ +import Hugs.Prelude +import Hugs.IO +import Hugs.IORef +import Hugs.IOExts +#endif + +#ifdef __GLASGOW_HASKELL__ +unsafeCoerce :: a -> b +unsafeCoerce = unsafeCoerce# +#endif + +#ifdef __NHC__ +import NonStdUnsafeCoerce (unsafeCoerce) +import NHC.IOExtras (IORef,newIORef,readIORef,writeIORef,unsafePerformIO) +#endif + +#include "Typeable.h" + +------------------------------------------------------------- +-- +-- The type Dynamic +-- +------------------------------------------------------------- + +{-| + A value of type 'Dynamic' is an object encapsulated together with its type. + + A 'Dynamic' may only represent a monomorphic value; an attempt to + create a value of type 'Dynamic' from a polymorphically-typed + expression will result in an ambiguity error (see 'toDyn'). + + 'Show'ing a value of type 'Dynamic' returns a pretty-printed representation + of the object\'s type; useful for debugging. +-} +#ifndef __HUGS__ hunk ./src/altdata/AltData/Dynamic.hs 90 +#endif hunk ./src/altdata/AltData/Dynamic.hs 92 -type Obj = forall a . a +INSTANCE_TYPEABLE0(Dynamic,dynamicTc,"Dynamic") hunk ./src/altdata/AltData/Dynamic.hs 97 - showString "<" . + showString "<<" . hunk ./src/altdata/AltData/Dynamic.hs 99 - showString ">" + showString ">>" hunk ./src/altdata/AltData/Dynamic.hs 101 -instance Typeable Dynamic where -#if __GLASGOW_HASKELL__ >= 603 - typeOf _ = mkTyConApp (mkTyCon "AltData.Dynamic") [] -#else - typeOf _ = mkAppTy (mkTyCon "AltData.Dyanmic") [] +#ifdef __GLASGOW_HASKELL__ +type Obj = forall a . a + -- Dummy type to hold the dynamically typed value. + -- + -- In GHC's new eval/apply execution model this type must + -- be polymorphic. It can't be a constructor, because then + -- GHC will use the constructor convention when evaluating it, + -- and this will go wrong if the object is really a function. On + -- the other hand, if we use a polymorphic type, GHC will use + -- a fallback convention for evaluating it that works for all types. + -- (using a function type here would also work). +#elif !defined(__HUGS__) +data Obj = Obj hunk ./src/altdata/AltData/Dynamic.hs 116 +-- | Converts an arbitrary value into an object of type 'Dynamic'. hunk ./src/altdata/AltData/Dynamic.hs 118 --- must be monomophic, see Data.Dynamic +-- The type of the object must be an instance of 'Typeable', which +-- ensures that only monomorphically-typed objects may be converted to +-- 'Dynamic'. To convert a polymorphic object into 'Dynamic', give it +-- a monomorphic type signature. For example: hunk ./src/altdata/AltData/Dynamic.hs 123 +-- > toDyn (id :: Int -> Int) +-- hunk ./src/altdata/AltData/Dynamic.hs 126 -toDyn v = Dynamic (typeOf v) (unsafeCoerce# v) +toDyn v = Dynamic (typeOf v) (unsafeCoerce v) hunk ./src/altdata/AltData/Dynamic.hs 128 --- --- Converts a 'Dynamic' object back into an ordinary Haskell value of --- the correct type. (this is the same as fromDynamic) --- --- Uses string comparison of the name of the type, rather than the --- hashed key of the type, which doesn't work for plugins, which mix --- static and dynamic loaded code. --- --- TypeRep is abstract, unfortunately. --- -fromDyn :: Typeable a => Dynamic -> Maybe a +-- | Converts a 'Dynamic' object back into an ordinary Haskell value of +-- the correct type. See also 'fromDynamic'. +fromDyn :: Typeable a + => Dynamic -- ^ the dynamically-typed object + -> a -- ^ a default value + -> a -- ^ returns: the value of the first argument, if + -- it has the correct type, otherwise the value of + -- the second argument. +fromDyn (Dynamic t v) def + | typeOf def == t = unsafeCoerce v + | otherwise = def hunk ./src/altdata/AltData/Dynamic.hs 140 -fromDyn (Dynamic t v) = - case unsafeCoerce# v of +-- | Converts a 'Dynamic' object back into an ordinary Haskell value of +-- the correct type. See also 'fromDyn'. +fromDynamic + :: Typeable a + => Dynamic -- ^ the dynamically-typed object + -> Maybe a -- ^ returns: @'Just' a@, if the dynamically-typed + -- object has the correct type (and @a@ is its value), + -- or 'Nothing' otherwise. +fromDynamic (Dynamic t v) = + case unsafeCoerce v of hunk ./src/altdata/AltData/Dynamic.hs 151 - | otherwise -> unsafePerformIO (putStrLn $ - "Couldn't match `" ++show(typeOf r) ++ - "' against `" ++show t ++"'"++ - "\n\tExpected type: " ++show(typeOf r) ++ - "\n\tInferred type: " ++show t - ) `seq` Nothing + | otherwise -> Nothing hunk ./src/altdata/AltData/Dynamic.hs 153 -fromDynamic d = case fromDyn d of - Just v -> v - Nothing -> error ("\nType error in dynamic unwrapping.\n" ++ - "In value `" ++ show d ++ "'") +-- (f::(a->b)) `dynApply` (x::a) = (f a)::b +dynApply :: Dynamic -> Dynamic -> Maybe Dynamic +dynApply (Dynamic t1 f) (Dynamic t2 x) = + case funResultTy t1 t2 of + Just t3 -> Just (Dynamic t3 ((unsafeCoerce f) x)) + Nothing -> Nothing hunk ./src/altdata/AltData/Dynamic.hs 167 --- --- (f::(a->b)) `dynApply` (x::a) = (f a)::b --- -dynApply :: Dynamic -> Dynamic -> Maybe Dynamic -dynApply (Dynamic t1 f) (Dynamic t2 x) = -#if __GLASGOW_HASKELL__ >= 603 - case funResultTy t1 t2 of -#else - case applyTy t1 t2 of -#endif - Just t3 -> Just (Dynamic t3 ((unsafeCoerce# f) x)) - Nothing -> Nothing - - --- --- hmm --- -dynAppHList :: Dynamic -> [Dynamic] -> Dynamic -dynAppHList fn [] = fn -- partial applicaiton -dynAppHList fn (x:xs) = (fn `dynApp` x) `dynAppHList` xs - --- --------------------------------------------------------------------- --- --- Implementation of typecase, without patterns, based on "Dynamic --- typing in a statically typed language". Mart\'in Abadi, Luca --- Cardelli, Benjamin Pierce and Gordon Plotkin. ACM Trans. Prog. Lang. --- and Syst. 13(2):237-268, 1991. --- --- Doesn't provide the behaviour that if the value is not a Dynamic, --- then typecase returns a error. Need low-level ops for that. --- - --- typecase :: Typeable u => Dynamic -> [(TypeRep, Dynamic)] -> u -> u - -typecase :: Typeable u - => Dynamic -- selector - -> [(Dynamic, Dynamic)] -- branches - -> u -- else arm - -> u -- return type - -typecase dv@(Dynamic ty _) alts dflt = - case find (hasType ty) alts of - Nothing -> dflt - Just v -> fromDynamic $ snd v `dynApp` dv - - where hasType t ((Dynamic u _),_) = t == u - -infixl 6 --> -(-->) :: Typeable b => a -> b -> (a,Dynamic) -a --> b = (a,toDyn b) - --- --- need a way to generate a Dynamic prelude --- -_Int = toDyn ( undefined :: Int ) -_Char = toDyn ( undefined :: Char ) -_Bool = toDyn ( undefined :: Bool ) -_String = toDyn ( undefined :: [Char] ) -_IntToInt = toDyn ( undefined :: Int -> Int ) - ------------------------------------------------------------------------- +dynTypeRep :: Dynamic -> TypeRep +dynTypeRep (Dynamic tr _) = tr hunk ./examples/typecase/000/Main.hs 1 -import AltData.Dynamic -import Data.Char - -main = putStrLn f - -f = let v = toDyn (7 :: Int) - in typecase (v) [ - _Bool --> \(b::Bool) -> show (not b)++" :: Bool", - _Char --> \(c::Char) -> show (toUpper c)++" :: Char", - _Int --> \(i::Int) -> show (-i)++" :: Int", - _String --> \(s::String) -> show (reverse s)++" :: [Char]", - _IntToInt --> \(f::Int->Int) -> show (f 7) ++":: Int -> Int" - ] ("couldn't find a typing") - rmfile ./examples/typecase/000/Main.hs hunk ./examples/typecase/000/Makefile 1 -TOP=../../.. -include ../../eval.mk rmfile ./examples/typecase/000/Makefile hunk ./examples/typecase/000/expected 1 --7 :: Int rmfile ./examples/typecase/000/expected rmdir ./examples/typecase/000 rmdir ./examples/typecase hunk ./TODO 4 ++ Cascading unload/reload + hunk ./examples/eval/eval3/Main.hs 13 -import System.Eval.Haskell +import System.Eval hunk ./examples/eval/eval3/Main.hs 16 --- import Data.Dynamic - hunk ./examples/eval/eval3/Main.hs 19 - a <- return $ toDyn (3::Int) + a <- return $ toDyn (3::Integer) hunk ./examples/eval/eval3/Main.hs 21 - m_b <- unsafeEval_ "\\dyn -> fromMaybe (7 :: Int) (fromDyn dyn)" - ["AltData.Dynamic","Data.Maybe"] -- imports - + -- so, we try to compile a function that takes a dyn. + -- looks like with GHC 6.4, we need to make sure the package.confs work: + m_b <- unsafeEval_ "\\dyn -> fromDyn dyn (7 :: Integer)" + ["AltData.Dynamic"] hunk ./examples/eval/eval3/Main.hs 26 - hunk ./examples/eval/eval3/Main.hs 28 - hunk ./examples/eval/eval3/Main.hs 29 + case m_b of + Left s -> mapM_ putStrLn s + Right b -> putStrLn $ show (b a :: Integer) -- now apply it + hunk ./examples/eval/eval3/Main.hs 41 - case m_b of - Left s -> mapM_ putStrLn s - Right b -> putStrLn $ show (b a :: Int) hunk ./src/altdata/AltData/Dynamic.hs 1 -{-# OPTIONS_GHC -fno-implicit-prelude #-} +{-# OPTIONS -fglasgow-exts -cpp #-} hunk ./src/altdata/AltData/Dynamic.hs 21 -module Data.Dynamic - ( +module AltData.Dynamic ( hunk ./src/altdata/AltData/Dynamic.hs 24 - module Data.Typeable, + module AltData.Typeable, hunk ./src/altdata/AltData/Dynamic.hs 41 - hunk ./src/altdata/AltData/Dynamic.hs 44 -#ifdef __GLASGOW_HASKELL__ +import System.IO.Unsafe (unsafePerformIO) + hunk ./src/altdata/AltData/Dynamic.hs 49 -import GHC.Num -#endif - -#ifdef __HUGS__ -import Hugs.Prelude -import Hugs.IO -import Hugs.IORef -import Hugs.IOExts -#endif hunk ./src/altdata/AltData/Dynamic.hs 50 -#ifdef __GLASGOW_HASKELL__ hunk ./src/altdata/AltData/Dynamic.hs 52 -#endif - -#ifdef __NHC__ -import NonStdUnsafeCoerce (unsafeCoerce) -import NHC.IOExtras (IORef,newIORef,readIORef,writeIORef,unsafePerformIO) -#endif - -#include "Typeable.h" hunk ./src/altdata/AltData/Dynamic.hs 69 -#ifndef __HUGS__ hunk ./src/altdata/AltData/Dynamic.hs 70 + +instance Typeable Dynamic where +#if __GLASGOW_HASKELL__ >= 603 + typeOf _ = mkTyConApp (mkTyCon "AltData.Dynamic") [] +#else + typeOf _ = mkAppTy (mkTyCon "AltData.Dynamic") [] hunk ./src/altdata/AltData/Dynamic.hs 77 - -INSTANCE_TYPEABLE0(Dynamic,dynamicTc,"Dynamic") hunk ./src/altdata/AltData/Dynamic.hs 85 -#ifdef __GLASGOW_HASKELL__ hunk ./src/altdata/AltData/Dynamic.hs 95 -#elif !defined(__HUGS__) -data Obj = Obj -#endif hunk ./src/altdata/AltData/Dynamic.hs 131 - | otherwise -> Nothing + | otherwise -> unsafePerformIO (putStrLn $ + "Couldn't match `" ++show(typeOf r) ++ + "' against `" ++show t ++"'"++ + "\n\tExpected type: " ++show(typeOf r) ++ + "\n\tInferred type: " ++show t + ) `seq` Nothing hunk ./src/build.mk 70 +# Now a rule for hs-boot files. +%.$(way_)o-boot : %.hs-boot + $(GHC) $(HC_OPTS) $(PKG_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi-boot + hunk ./src/plugins/System/Eval/Haskell.hs 45 -import AltData.Dynamic +import AltData.Dynamic ( Dynamic ) hunk ./src/plugins/System/Plugins/Load.hs 57 -import AltData.Dynamic ( fromDyn, Dynamic ) +import AltData.Dynamic ( fromDynamic, Dynamic ) hunk ./src/plugins/System/Plugins/Load.hs 164 - case fromDyn (unsafeCoerce# dyn_v :: Dynamic) of + case fromDynamic (unsafeCoerce# dyn_v :: Dynamic) of hunk ./src/plugins/System/Plugins/Env.hs 23 + withDepEnv, hunk ./src/plugins/System/Plugins/Env.hs 27 + modifyDepEnv, hunk ./src/plugins/System/Plugins/Env.hs 35 + addModuleDeps, + getModuleDeps, + rmModuleDeps, hunk ./src/plugins/System/Plugins/Env.hs 51 +import System.Plugins.LoadTypes hunk ./src/plugins/System/Plugins/Env.hs 61 -import Data.Maybe ( isJust ) +import Data.Maybe ( isJust, isNothing ) hunk ./src/plugins/System/Plugins/Env.hs 127 -type ModEnv = FiniteMap String Bool +type ModEnv = FiniteMap String (Module,Int) + +type DepEnv = FiniteMap Module [Module] hunk ./src/plugins/System/Plugins/Env.hs 141 - IORef ModEnv, + IORef ModEnv, + IORef DepEnv, hunk ./src/plugins/System/Plugins/Env.hs 154 + ref2 <- newIORef emptyFM hunk ./src/plugins/System/Plugins/Env.hs 156 - ref2 <- newIORef p -- package.conf info - ref3 <- newIORef emptyFM -- merged files - return (mvar, ref1, ref2, ref3) + ref3 <- newIORef p -- package.conf info + ref4 <- newIORef emptyFM -- merged files + return (mvar, ref1, ref2, ref3, ref4) hunk ./src/plugins/System/Plugins/Env.hs 169 +withDepEnv :: Env -> (DepEnv -> IO a) -> IO a hunk ./src/plugins/System/Plugins/Env.hs 173 -withModEnv (mvar,ref,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) -withPkgEnvs (mvar,_,ref,_) f = withMVar mvar (\_ -> readIORef ref >>= f) -withMerged (mvar,_,_,ref) f = withMVar mvar (\_ -> readIORef ref >>= f) +withModEnv (mvar,ref,_,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withDepEnv (mvar,_,ref,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withPkgEnvs (mvar,_,_,ref,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withMerged (mvar,_,_,_,ref) f = withMVar mvar (\_ -> readIORef ref >>= f) hunk ./src/plugins/System/Plugins/Env.hs 184 +modifyDepEnv :: Env -> (DepEnv -> IO DepEnv) -> IO () hunk ./src/plugins/System/Plugins/Env.hs 188 -modifyModEnv (mvar,ref,_,_) f = lockAndWrite mvar ref f -modifyPkgEnv (mvar,_,ref,_) f = lockAndWrite mvar ref f -modifyMerged (mvar,_,_,ref) f = lockAndWrite mvar ref f +modifyModEnv (mvar,ref,_,_,_) f = lockAndWrite mvar ref f +modifyDepEnv (mvar,_,ref,_,_) f = lockAndWrite mvar ref f +modifyPkgEnv (mvar,_,_,ref,_) f = lockAndWrite mvar ref f +modifyMerged (mvar,_,_,_,ref) f = lockAndWrite mvar ref f hunk ./src/plugins/System/Plugins/Env.hs 200 -addModule :: String -> IO () -addModule s = modifyModEnv env $ \fm -> return $ addToFM fm s True +addModule :: String -> Module -> IO () +addModule s m = modifyModEnv env $ \fm -> let c = maybe 0 snd (lookupFM fm s) + in return $ addToFM fm s (m,c+1) + +--getModule :: String -> IO (Maybe Module) +--getModule s = withModEnv env $ \fm -> return (lookupFM fm s) hunk ./src/plugins/System/Plugins/Env.hs 208 --- remove a module name from the environment +-- remove a module name from the environment. Returns True if the module was actually removed. hunk ./src/plugins/System/Plugins/Env.hs 210 -rmModule :: String -> IO () -rmModule s = modifyModEnv env $ \fm -> return $ delFromFM fm s +rmModule :: String -> IO Bool +rmModule s = do modifyModEnv env $ \fm -> let c = maybe 1 snd (lookupFM fm s) + fm' = delFromFM fm s + in if c-1 <= 0 + then return fm' + else return fm + withModEnv env $ \fm -> return (isNothing (lookupFM fm s)) hunk ./src/plugins/System/Plugins/Env.hs 221 -addModules :: [String] -> IO () -addModules ns = modifyModEnv env $ \fm -> return $ unionL fm ns - where - unionL :: ModEnv -> [String] -> ModEnv - unionL fm ss = foldr (\s fm' -> addToFM fm' s True) fm ss +addModules :: [(String,Module)] -> IO () +addModules ns = mapM_ (uncurry addModule) ns hunk ./src/plugins/System/Plugins/Env.hs 235 + +-- ----------------------------------------------------------- +-- +-- module dependency stuff +-- + +-- +-- set the dependencies of a Module. +-- +addModuleDeps :: Module -> [Module] -> IO () +addModuleDeps m deps = modifyDepEnv env $ \fm -> return $ addToFM fm m deps + +-- +-- Get module dependencies. Nothing if none have been recored. +-- +getModuleDeps :: Module -> IO (Maybe [Module]) +getModuleDeps m = withDepEnv env $ \fm -> return $ lookupFM fm m + + +-- +-- Unrecord a module from the environment. +-- +rmModuleDeps :: Module -> IO () +rmModuleDeps m = modifyDepEnv env $ \fm -> return $ delFromFM fm m hunk ./src/plugins/System/Plugins/Load.hs 29 + , unloadAll hunk ./src/plugins/System/Plugins/Load.hs 62 +import Data.Maybe ( fromMaybe ) hunk ./src/plugins/System/Plugins/Load.hs 80 -type Symbol = String -type Type = String -type Errors = [String] -type PackageConf = FilePath - -data Module = Module { path :: !FilePath - , mname :: !String - , kind :: !ObjType - , iface :: Iface -- cache the iface - , key :: Key - } - -data ObjType = Vanilla | Shared deriving Eq +import System.Plugins.LoadTypes hunk ./src/plugins/System/Plugins/Load.hs 107 - hif <- loadDepends obj incpaths + (hif,moduleDeps) <- loadDepends obj incpaths hunk ./src/plugins/System/Plugins/Load.hs 121 - + addModuleDeps m' moduleDeps hunk ./src/plugins/System/Plugins/Load.hs 302 -unload = unloadObj +unload m = rmModuleDeps m >> unloadObj m + +unloadAll :: Module -> IO () +unloadAll m = do moduleDeps <- fmap (fromMaybe []) (getModuleDeps m) + rmModuleDeps m + mapM_ unloadAll moduleDeps + unload m hunk ./src/plugins/System/Plugins/Load.hs 408 -data Key = Object String | Package String + hunk ./src/plugins/System/Plugins/Load.hs 423 - addModule k -- needs to Z-encode module name + addModule k (emptyMod p) -- needs to Z-encode module name hunk ./src/plugins/System/Plugins/Load.hs 465 - r <- c_unloadObj c_p - when (not r) (panic "unloadObj: failed") - rmModule $ case ky of Object s -> s ; Package pk -> pk - + removed <- rmModule name + when (removed) $ do r <- c_unloadObj c_p + when (not r) (panic "unloadObj: failed") hunk ./src/plugins/System/Plugins/Load.hs 469 - + where name = case ky of Object s -> s ; Package pk -> pk hunk ./src/plugins/System/Plugins/Load.hs 557 -loadDepends :: FilePath -> [FilePath] -> IO Iface +loadDepends :: FilePath -> [FilePath] -> IO (Iface,[Module]) hunk ./src/plugins/System/Plugins/Load.hs 566 - return emptyIface -- could be considered fatal + return (emptyIface,[]) -- could be considered fatal hunk ./src/plugins/System/Plugins/Load.hs 570 - + hunk ./src/plugins/System/Plugins/Load.hs 609 - mapM_ (\(hi,m) -> loadObject m (Object hi)) mods'' - return hiface + moduleDeps <- mapM (\(hi,m) -> loadObject m (Object hi)) mods'' + return (hiface,moduleDeps) addfile ./src/plugins/System/Plugins/LoadTypes.hs hunk ./src/plugins/System/Plugins/LoadTypes.hs 1 - +module System.Plugins.LoadTypes + ( Key (..) + , Symbol + , Type + , Errors + , PackageConf + , Module (..) + , ObjType (..) + ) where + +import Language.Hi.Parser + +data Key = Object String | Package String +type Symbol = String +type Type = String +type Errors = [String] +type PackageConf = FilePath + +data Module = Module { path :: !FilePath + , mname :: !String + , kind :: !ObjType + , iface :: Iface -- cache the iface + , key :: Key + } +instance Ord Module where + compare m1 m2 = mname m1 `compare` mname m2 + +instance Eq Module where + m1 == m2 = mname m1 == mname m2 + +data ObjType = Vanilla | Shared deriving Eq hunk ./src/plugins/plugins.conf.in.cpp 32 + System.Plugins.LoadTypes, adddir ./examples/unloadAll adddir ./examples/unloadAll/null adddir ./examples/unloadAll/null/api adddir ./examples/unloadAll/null/prog addfile ./examples/unloadAll/null/Dep.hs hunk ./examples/unloadAll/null/Dep.hs 1 +module Dep ( resource ) where + +import API +import Data.Dynamic +import Prelude hiding (null) + +resource = null addfile ./examples/unloadAll/null/Makefile hunk ./examples/unloadAll/null/Makefile 1 +TEST= unloadAll/null +EXTRA_OBJS=Null.o Dep.o +TOP=../../.. +include ../../build.mk addfile ./examples/unloadAll/null/Null.hs hunk ./examples/unloadAll/null/Null.hs 1 +module Null ( resource ) where + +import API +import Data.Dynamic +import Prelude hiding (null) +import qualified Dep + +resource = Dep.resource + +-- ! this has to be special: it can't be overridden by the user. +resource_dyn :: Dynamic +resource_dyn = toDyn resource addfile ./examples/unloadAll/null/api/API.hs hunk ./examples/unloadAll/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Null = Null { a, b :: Int } + deriving (Typeable, Show) + +null :: Null +null = Null { a = 42 , b = 1 } + addfile ./examples/unloadAll/null/prog/Main.hs hunk ./examples/unloadAll/null/prog/Main.hs 1 + +import System.Plugins +import API + +-- an example where we just want to load an object and run it + +main = do + m_v <- load_ "../Null.o" ["../api",".."] "resource" + t <- load_ "../Dep.o" ["../api"] "resource" + case m_v of + LoadFailure err -> error (unlines err) + LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m + case t of + LoadFailure err -> error (unlines err) + LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m addfile ./examples/unloadAll/null/prog/expected hunk ./examples/unloadAll/null/prog/expected 1 +42 +42 hunk ./examples/unloadAll/null/Makefile 2 -EXTRA_OBJS=Null.o Dep.o +EXTRA_OBJS=Dep.o Null.o hunk ./src/plugins/System/Plugins/Load.hs 55 +import System.Plugins.LoadTypes hunk ./src/plugins/System/Plugins/Load.hs 78 - --- --------------------------------------------------------------------- - -import System.Plugins.LoadTypes hunk ./src/plugins/System/Plugins/LoadTypes.hs 1 +-- +-- Copyright (c) 2005 Lemmih +-- Copyright (c) 2005 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- +-- 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. +-- + hunk ./src/plugins/System/Plugins/LoadTypes.hs 34 + hunk ./src/plugins/System/Plugins/LoadTypes.hs 53 + hunk ./src/plugins/System/Plugins/Env.hs 51 -import System.Plugins.LoadTypes +import System.Plugins.LoadTypes (Module) hunk ./src/plugins/System/Plugins/Env.hs 58 -import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix, dllSuf ) +import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix ) hunk ./src/plugins/System/Plugins/Env.hs 105 --- The state is a FiniteMap String Bool (a hash of package/object names --- to whether they have been loaded or not). +-- The state is a FiniteMap String (Module,Int) (a hash of package/object names +-- to Modules and how many times they've been loaded). hunk ./src/plugins/System/Plugins/Load.hs 292 --- | unload a module (not it's dependencies) +-- | unload a module (not its dependencies) hunk ./src/plugins/System/Plugins/Load.hs 301 +------------------------------------------------------------------------ +-- +-- | unload a module and its dependencies +-- we have the dependencies, so cascaded unloading is possible +-- hunk ./src/plugins/System/Plugins/Env.hs 344 +data LibrarySpec + = DLL String -- -lLib + | DLLPath FilePath -- -Lpath + +classifyLdInput :: FilePath -> IO (Maybe LibrarySpec) +classifyLdInput ('-':'l':lib) = return (Just (DLL lib)) +classifyLdInput ('-':'L':path) = return (Just (DLLPath path)) +classifyLdInput _ = return Nothing + +#if defined(darwin_TARGET_OS) +mkSOName root = "lib" ++ root ++ ".dylib" +#elif defined(mingw32_TARGET_OS) +-- Win32 DLLs have no .dll extension here, because addDLL tries +-- both foo.dll and foo.drv +mkSOName root = root +#else +mkSOName root = "lib" ++ root ++ ".so" +#endif + + hunk ./src/plugins/System/Plugins/Env.hs 377 + let hslibs = hsLibraries package + extras' = extraLibraries package + cbits = filter (\e -> reverse (take (length "_cbits") (reverse e)) == "_cbits") extras' + extras = filter (not . flip elem cbits) extras' + ldopts = ldOptions package + deppkgs = packageDeps package + ldInput <- mapM classifyLdInput ldopts + let ldOptsLibs = [ path | Just (DLL path) <- ldInput ] + ldOptsPaths = [ path | Just (DLLPath path) <- ldInput ] + dlls = map mkSOName (extras ++ ldOptsLibs) hunk ./src/plugins/System/Plugins/Env.hs 388 - let libdirs = fix_topdir $ libraryDirs package + libdirs = fix_topdir (libraryDirs package) ++ ldOptsPaths hunk ./src/plugins/System/Plugins/Env.hs 390 - let libdirs = libraryDirs package + libdirs = libraryDirs package ++ ldOptsPaths hunk ./src/plugins/System/Plugins/Env.hs 392 - hslibs = hsLibraries package - extras = extraLibraries package - deppkgs = packageDeps package - libs <- mapM (findHSlib libdirs) (hslibs ++ extras) + libs <- mapM (findHSlib libdirs) (hslibs ++ cbits) hunk ./src/plugins/System/Plugins/Env.hs 395 - libs' <- mapM (findDLL $ syslibdir : libdirs) extras + libs' <- mapM (findDLL $ syslibdir : libdirs) dlls hunk ./src/plugins/System/Plugins/Env.hs 397 - libs' <- mapM (findDLL libdirs) extras + libs' <- mapM (findDLL libdirs) dlls hunk ./src/plugins/System/Plugins/Env.hs 399 - -- don't care if there are 'Nothings', that usually - -- means that they refer to system libraries. Can't do - -- anything about that. - return (deppkgs, (filterJust libs,filterJust libs') ) + return (deppkgs, (filterRight libs,map (either id id) libs') ) hunk ./src/plugins/System/Plugins/Env.hs 413 - filterJust :: [Maybe a] -> [a] - filterJust [] = [] - filterJust (Just x:xs) = x:filterJust xs - filterJust (Nothing:xs) = filterJust xs + filterRight :: [Either left right] -> [right] + filterRight [] = [] + filterRight (Right x:xs) = x:filterRight xs + filterRight (Left _:xs) = filterRight xs hunk ./src/plugins/System/Plugins/Env.hs 423 - findHSlib :: [FilePath] -> String -> IO (Maybe FilePath) - findHSlib [] _ = return Nothing + findHSlib :: [FilePath] -> String -> IO (Either String FilePath) + findHSlib [] lib = return (Left lib) hunk ./src/plugins/System/Plugins/Env.hs 428 - if b then return $ Just l -- found it! + if b then return $ Right l -- found it! hunk ./src/plugins/System/Plugins/Env.hs 431 - findDLL :: [FilePath] -> String -> IO (Maybe FilePath) - findDLL [] _ = return Nothing + findDLL :: [FilePath] -> String -> IO (Either String FilePath) + findDLL [] lib = return (Left lib) hunk ./src/plugins/System/Plugins/Env.hs 434 - let l = dir lib ++ dllSuf + let l = dir lib hunk ./src/plugins/System/Plugins/Env.hs 436 - if b then return $ Just l + if b then return $ Right l hunk ./src/plugins/System/Plugins/Load.hs 479 - str' <- return $ (reverse . drop 1 . dropWhile (/= '.') . reverse) str - maybe_errmsg <- withCString str' $ \dll -> c_addDLL dll - if maybe_errmsg == nullPtr +#if DEBUG + putStrLn $ " shared: " ++ str +#endif + maybe_errmsg <- withCString str $ \dll -> c_addDLL dll + if maybe_errmsg == nullPtr hunk ./src/plugins/System/Plugins/Load.hs 486 - panic $ "loadShared: couldn't load `"++str'++"\' because "++e + panic $ "loadShared: couldn't load `"++str++"\' because "++e + hunk ./src/plugins/System/Plugins/Load.hs 505 +#if DEBUG + putStr (' ':show dlls) +#endif hunk ./src/plugins/System/Plugins/Load.hs 509 + + + hunk ./src/plugins/System/Plugins/PackageAPI.hs 34 + , ldOptions hunk ./src/plugins/System/Plugins/PackageAPI.hs 92 + +ldOptions :: PackageConfig -> [String] +ldOptions = extra_ld_opts adddir ./examples/loadCLib adddir ./examples/loadCLib/null adddir ./examples/loadCLib/null/api adddir ./examples/loadCLib/null/prog addfile ./examples/loadCLib/null/Makefile hunk ./examples/loadCLib/null/Makefile 1 +TEST= unloadAll/null +EXTRA_OBJS=Null.o Dep.o +TOP=../../.. +include ../../build.mk addfile ./examples/loadCLib/null/Null.hs hunk ./examples/loadCLib/null/Null.hs 1 +module Null ( resource ) where + +import API +import Data.Dynamic +import Prelude hiding (null) +import Graphics.Rendering.OpenGL + +resource = null + +-- ! this has to be special: it can't be overridden by the user. +resource_dyn :: Dynamic +resource_dyn = toDyn resource addfile ./examples/loadCLib/null/api/API.hs hunk ./examples/loadCLib/null/api/API.hs 1 +{-# OPTIONS -fglasgow-exts #-} + +module API where + +import Data.Dynamic + +data Null = Null { a, b :: Int } + deriving (Typeable, Show) + +null :: Null +null = Null { a = 42 , b = 1 } + addfile ./examples/loadCLib/null/prog/Main.hs hunk ./examples/loadCLib/null/prog/Main.hs 1 + +import System.Plugins +import API + +-- an example where we just want to load an object and run it + +main = do + m_v <- load_ "../Null.o" ["../api",".."] "resource" + case m_v of + LoadFailure err -> error (unlines err) + LoadSuccess m v -> do putStrLn ( show (a v) ) ; unload m addfile ./examples/loadCLib/null/prog/expected hunk ./examples/loadCLib/null/prog/expected 1 +42 hunk ./examples/unloadAll/null/prog/Main.hs 12 - LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m + LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m -- unloads Null.o but not Dep.o since we're still using it. hunk ./examples/loadCLib/null/Makefile 1 -TEST= unloadAll/null -EXTRA_OBJS=Null.o Dep.o +TEST= loadCLib/null +EXTRA_OBJS=Null.o hunk ./README 50 +* On cygwin/windows you may need to make sure that cygwin paths appear + before windows paths in your $PATH variable, otherwise windows 'find' + will be used over the cygwin find. + hunk ./README 50 -* On cygwin/windows you may need to make sure that cygwin paths appear - before windows paths in your $PATH variable, otherwise windows 'find' - will be used over the cygwin find. +* On cygwin/windows you (a) make sure the cygwin "find" is before the + windows "find" on your PATH, and (b) to give the windows-style path + (e.g., "c:/cygwin/usr/local") in the ./configure --prefix=foo/bar + step hunk ./src/plugins/System/Plugins/Env.hs 353 +-- TODO need to define a MAC/DARWIN symbol hunk ./src/plugins/System/Plugins/Env.hs 356 -#elif defined(mingw32_TARGET_OS) +#if defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/System/Plugins/Env.hs 356 -#if defined(CYGWIN) || defined(__MINGW32__) +#elif defined(CYGWIN) || defined(__MINGW32__) hunk ./src/plugins/System/Plugins/Env.hs 364 - hunk ./src/plugins/System/Plugins/Env.hs 380 - extras = filter (not . flip elem cbits) extras' + extras = filter (not . flip elem (cbits++["m","gmp"])) extras' hunk ./configure 1350 + SYMS="$SYMS -DMACOSX" hunk ./configure.ac 42 + SYMS="$SYMS -DMACOSX" hunk ./src/plugins/System/Plugins/Env.hs 354 -#if defined(darwin_TARGET_OS) +#if defined(MACOSX) hunk ./Makefile 82 + rm -f examples/makewith/io/TestIO.conf + rm -f examples/makewith/unsafeio/Unsafe.conf hunk ./configure 3039 - ac_config_files="$ac_config_files config.mk config.h" +# System.Process uses cmd or command.com shell on Windows, doen't use Cygwin or MSYS shell + ac_config_files="$ac_config_files config.mk config.h examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" hunk ./configure 3596 + "examples/makewith/io/TestIO.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/io/TestIO.conf" ;; + "examples/makewith/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/unsafeio/Unsafe.conf" ;; hunk ./configure.ac 221 -AC_CONFIG_FILES(config.mk config.h) +# System.Process uses cmd or command.com shell on Windows, doen't use Cygwin or MSYS shell +AC_CONFIG_FILES(config.mk config.h examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf) hunk ./examples/makewith/io/TestIO.conf 1 -{-# OPTIONS -cpp #-} --- --- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) --- - -import System.IO -import System.Process - -resource = testio { field = date } - --- --- call a shell command , returning it's output --- -date :: IO String -date = do (_,out,_,_) <- catch (runInteractiveCommand "/bin/date") (\_->error "popen failed") - hGetLine out rmfile ./examples/makewith/io/TestIO.conf addfile ./examples/makewith/io/TestIO.conf.in hunk ./examples/makewith/io/TestIO.conf.in 1 +{-# OPTIONS -cpp #-} +-- +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) +-- + +import System.IO +import System.Process + +resource = testio { field = date } + +-- +-- call a shell command , returning it's output +-- +date :: IO String +date = do +#if !defined(CYGWIN) || !defined(__MINGW32__) + (_,out,_,_) <- catch (runInteractiveCommand "/bin/date") (\_->error "popen failed") +#else + (_,out,_,_) <- catch (runInteractiveCommand "@PREFIX@/../../bin/date") (\_->error "popen failed") +#endif + hGetLine out hunk ./examples/makewith/unsafeio/Unsafe.conf 1 -{-# GLOBALOPTIONS -package mtl #-} --- illustrates the use of static options in pragmas - -import System.IO.Unsafe -import System.IO -import System.Process - -resource = unsafe { field = date } - --- illustrates the use of the devil's work -date :: String -date = unsafePerformIO $ do - (_,outh,_,proc) <- runInteractiveProcess "date" [] Nothing Nothing - waitForProcess proc - s <- hGetContents outh - return s - rmfile ./examples/makewith/unsafeio/Unsafe.conf addfile ./examples/makewith/unsafeio/Unsafe.conf.in hunk ./examples/makewith/unsafeio/Unsafe.conf.in 1 +{-# GLOBALOPTIONS -package mtl #-} +-- illustrates the use of static options in pragmas + +import System.IO.Unsafe +import System.IO +import System.Process + +resource = unsafe { field = date } + +-- illustrates the use of the devil's work +date :: String +date = unsafePerformIO $ do +#if !defined(CYGWIN) || !defined(__MINGW32__) + (_,outh,_,proc) <- runInteractiveProcess "date" [] Nothing Nothing +#else + (_,outh,_,proc) <- runInteractiveProcess "@PREFIX@/../../bin/date" [] Nothing Nothing +#endif + waitForProcess proc + s <- hGetContents outh + return s + hunk ./src/plugins/System/Plugins/Env.hs 61 -import Data.Maybe ( isJust, isNothing ) +import Data.Maybe ( isJust, isNothing, fromMaybe ) hunk ./src/plugins/System/Plugins/Env.hs 250 -getModuleDeps :: Module -> IO (Maybe [Module]) -getModuleDeps m = withDepEnv env $ \fm -> return $ lookupFM fm m +getModuleDeps :: Module -> IO [Module] +getModuleDeps m = withDepEnv env $ \fm -> return $ fromMaybe [] (lookupFM fm m) hunk ./src/plugins/System/Plugins/Load.hs 30 + , hasChanged + , hasChanged' hunk ./src/plugins/System/Plugins/Load.hs 65 -import Data.Maybe ( fromMaybe ) hunk ./src/plugins/System/Plugins/Load.hs 77 +import System.Directory ( getModificationTime ) hunk ./src/plugins/System/Plugins/Load.hs 309 -unloadAll m = do moduleDeps <- fmap (fromMaybe []) (getModuleDeps m) +unloadAll m = do moduleDeps <- getModuleDeps m hunk ./src/plugins/System/Plugins/Load.hs 314 +-- | Changes the extension of a file path. +changeFileExt :: FilePath -- ^ The path information to modify. + -> String -- ^ The new extension (without a leading period). + -- Specify an empty string to remove an existing + -- extension from path. + -> FilePath -- ^ A string containing the modified path information. +changeFileExt fpath ext = joinFileExt name ext + where + (name,_) = splitFileExt fpath + +-- | The 'joinFileExt' function is the opposite of 'splitFileExt'. +-- It joins a file name and an extension to form a complete file path. +-- +-- The general rule is: +-- +-- > filename `joinFileExt` ext == path +-- > where +-- > (filename,ext) = splitFileExt path +joinFileExt :: String -> String -> FilePath +joinFileExt fpath "" = fpath +joinFileExt fpath ext = fpath ++ '.':ext + +-- | Split the path into file name and extension. If the file doesn\'t have extension, +-- the function will return empty string. The extension doesn\'t include a leading period. +-- +-- Examples: +-- +-- > splitFileExt "foo.ext" == ("foo", "ext") +-- > splitFileExt "foo" == ("foo", "") +-- > splitFileExt "." == (".", "") +-- > splitFileExt ".." == ("..", "") +-- > splitFileExt "foo.bar."== ("foo.bar.", "") +splitFileExt :: FilePath -> (String, String) +splitFileExt p = + case break (== '.') fname of + (suf@(_:_),_:pre) -> (reverse (pre++fpath), reverse suf) + _ -> (p, []) + where + (fname,fpath) = break isPathSeparator (reverse p) + +-- | Checks whether the character is a valid path separator for the host +-- platform. The valid character is a 'pathSeparator' but since the Windows +-- operating system also accepts a slash (\"\/\") since DOS 2, the function +-- checks for it on this platform, too. +isPathSeparator :: Char -> Bool +isPathSeparator ch = +#if defined(CYGWIN) || defined(__MINGW32__) + ch == '/' || ch == '\\' +#else + ch == '/' +#endif + + +-- +-- |Returns @True@ if the module or any of its dependencies have older object files than source files. +-- +hasChanged :: Module -> IO Bool +hasChanged = hasChanged' ["hs","lhs"] + +hasChanged' :: [String] -> Module -> IO Bool +hasChanged' suffices m@(Module {path = p}) + = do mbFile <- findFile suffices p + case mbFile of + Nothing -> return False + Just f -> do srcT <- getModificationTime f + objT <- getModificationTime p + if srcT > objT + then return True + else do deps <- getModuleDeps m + depsStatus <- mapM (hasChanged' suffices) deps + return (or depsStatus) + where findFile :: [String] -> FilePath -> IO (Maybe FilePath) + findFile [] _ = return Nothing + findFile (ext:exts) file + = do let l = changeFileExt file ext + b <- doesFileExist l + if b then return $ Just l + else findFile exts file hunk ./src/plugins/System/Plugins/Env.hs 320 --- which includes system .so files. Ignore these for now +-- which includes system .so files. hunk ./src/plugins/System/Plugins/Env.hs 324 --- --- ToDo At present this does not handle extra_libraries correctly. It --- only find those extra libraries that live in the directory specfied --- by the library_dirs field of the package.conf entry. But --- extra_libraries can contain any libraries supported by the system's --- linker. For this library they must be, of course, be dynamic. The --- extensions for such libraries are different on various platforms. --- This would need to be checked for by configure.ac. (Scary - dons) hunk ./docs/hs-plugins.tex 100 -\code{ia64-linux}, \code{sparc-solaris2} and \code{powerpc}'s running -Mac OSX. It should run on any machine with a working GHCi -implementation. +\code{ia64-linux}, \code{sparc-solaris2} and \code{powerpc-\{macosx,linux\}}. hunk ./src/plugins/System/Plugins/Load.hs 375 - = do mbFile <- findFile suffices p + = do modFile <- doesFileExist p + mbFile <- findFile suffices p hunk ./src/plugins/System/Plugins/Load.hs 378 - Nothing -> return False - Just f -> do srcT <- getModificationTime f - objT <- getModificationTime p - if srcT > objT - then return True - else do deps <- getModuleDeps m - depsStatus <- mapM (hasChanged' suffices) deps - return (or depsStatus) + Just f | modFile + -> do srcT <- getModificationTime f + objT <- getModificationTime p + if srcT > objT + then return True + else do deps <- getModuleDeps m + depsStatus <- mapM (hasChanged' suffices) deps + return (or depsStatus) + _ -> return False hunk ./src/plugins/System/Plugins/Load.hs 30 - , hasChanged - , hasChanged' hunk ./src/plugins/System/Plugins/Load.hs 75 -import System.Directory ( getModificationTime ) hunk ./src/plugins/System/Plugins/Load.hs 311 --- | Changes the extension of a file path. -changeFileExt :: FilePath -- ^ The path information to modify. - -> String -- ^ The new extension (without a leading period). - -- Specify an empty string to remove an existing - -- extension from path. - -> FilePath -- ^ A string containing the modified path information. -changeFileExt fpath ext = joinFileExt name ext - where - (name,_) = splitFileExt fpath hunk ./src/plugins/System/Plugins/Load.hs 312 --- | The 'joinFileExt' function is the opposite of 'splitFileExt'. --- It joins a file name and an extension to form a complete file path. --- --- The general rule is: --- --- > filename `joinFileExt` ext == path --- > where --- > (filename,ext) = splitFileExt path -joinFileExt :: String -> String -> FilePath -joinFileExt fpath "" = fpath -joinFileExt fpath ext = fpath ++ '.':ext - --- | Split the path into file name and extension. If the file doesn\'t have extension, --- the function will return empty string. The extension doesn\'t include a leading period. --- --- Examples: --- --- > splitFileExt "foo.ext" == ("foo", "ext") --- > splitFileExt "foo" == ("foo", "") --- > splitFileExt "." == (".", "") --- > splitFileExt ".." == ("..", "") --- > splitFileExt "foo.bar."== ("foo.bar.", "") -splitFileExt :: FilePath -> (String, String) -splitFileExt p = - case break (== '.') fname of - (suf@(_:_),_:pre) -> (reverse (pre++fpath), reverse suf) - _ -> (p, []) - where - (fname,fpath) = break isPathSeparator (reverse p) - --- | Checks whether the character is a valid path separator for the host --- platform. The valid character is a 'pathSeparator' but since the Windows --- operating system also accepts a slash (\"\/\") since DOS 2, the function --- checks for it on this platform, too. -isPathSeparator :: Char -> Bool -isPathSeparator ch = -#if defined(CYGWIN) || defined(__MINGW32__) - ch == '/' || ch == '\\' -#else - ch == '/' -#endif - - --- --- |Returns @True@ if the module or any of its dependencies have older object files than source files. --- -hasChanged :: Module -> IO Bool -hasChanged = hasChanged' ["hs","lhs"] - -hasChanged' :: [String] -> Module -> IO Bool -hasChanged' suffices m@(Module {path = p}) - = do modFile <- doesFileExist p - mbFile <- findFile suffices p - case mbFile of - Just f | modFile - -> do srcT <- getModificationTime f - objT <- getModificationTime p - if srcT > objT - then return True - else do deps <- getModuleDeps m - depsStatus <- mapM (hasChanged' suffices) deps - return (or depsStatus) - _ -> return False - where findFile :: [String] -> FilePath -> IO (Maybe FilePath) - findFile [] _ = return Nothing - findFile (ext:exts) file - = do let l = changeFileExt file ext - b <- doesFileExist l - if b then return $ Just l - else findFile exts file hunk ./src/plugins/System/Plugins/Make.hs 23 + hasChanged, + hasChanged', + recompileAll, + recompileAll', + hunk ./src/plugins/System/Plugins/Make.hs 49 +import System.Plugins.LoadTypes ( Module (Module, path) ) hunk ./src/plugins/System/Plugins/Make.hs 51 -import System.Plugins.Env ( lookupMerged, addMerge ) +import System.Plugins.Env ( lookupMerged, addMerge + , getModuleDeps) + +#if DEBUG +import System.IO (hFlush, stdout, openFile, IOMode(..),hClose, hPutStr) +#else +import System.IO (openFile, IOMode(..),hClose,hPutStr) +#endif hunk ./src/plugins/System/Plugins/Make.hs 60 -import System.IO -import System.Directory ( doesFileExist, removeFile ) +import System.Directory ( doesFileExist, removeFile + , getModificationTime ) hunk ./src/plugins/System/Plugins/Make.hs 69 + hunk ./src/plugins/System/Plugins/Make.hs 96 + +-- +-- |Returns @True@ if the module or any of its dependencies have older object files than source files. +-- Defaults to @True@ if some files couldn't be located. +-- +hasChanged :: Module -> IO Bool +hasChanged = hasChanged' ["hs","lhs"] + +hasChanged' :: [String] -> Module -> IO Bool +hasChanged' suffices m@(Module {path = p}) + = do modFile <- doesFileExist p + mbFile <- findFile suffices p + case mbFile of + Just f | modFile + -> do srcT <- getModificationTime f + objT <- getModificationTime p + if srcT > objT + then return True + else do deps <- getModuleDeps m + depsStatus <- mapM (hasChanged' suffices) deps + return (or depsStatus) + _ -> return True + +-- +-- |Like 'makeAll' but with better recompilation checks since module dependencies are known. +-- +recompileAll :: Module -> [Arg] -> IO MakeStatus +recompileAll = recompileAll' ["hs","lhs"] + +recompileAll' :: [String] -> Module -> [Arg] -> IO MakeStatus +recompileAll' suffices m args + = do changed <- hasChanged m + if not changed + then do mbSource <- findFile suffices (path m) + case mbSource of + Nothing + -> error $ "Couldn't find source for object file: " ++ path m + Just source + -> makeAll source args + else return (MakeSuccess NotReq (path m)) hunk ./src/plugins/System/Plugins/Utils.hs 33 + findFile, + hunk ./src/plugins/System/Plugins/Utils.hs 41 - + changeFileExt, + joinFileExt, + splitFileExt, + hunk ./src/plugins/System/Plugins/Utils.hs 175 +findFile :: [String] -> FilePath -> IO (Maybe FilePath) +findFile [] _ = return Nothing +findFile (ext:exts) file + = do let l = changeFileExt file ext + b <- doesFileExist l + if b then return $ Just l + else findFile exts file + + + hunk ./src/plugins/System/Plugins/Utils.hs 267 + + +----------------------------------------------------------- +-- Code from Cabal ---------------------------------------- + +-- | Changes the extension of a file path. +changeFileExt :: FilePath -- ^ The path information to modify. + -> String -- ^ The new extension (without a leading period). + -- Specify an empty string to remove an existing + -- extension from path. + -> FilePath -- ^ A string containing the modified path information. +changeFileExt fpath ext = joinFileExt name ext + where + (name,_) = splitFileExt fpath + +-- | The 'joinFileExt' function is the opposite of 'splitFileExt'. +-- It joins a file name and an extension to form a complete file path. +-- +-- The general rule is: +-- +-- > filename `joinFileExt` ext == path +-- > where +-- > (filename,ext) = splitFileExt path +joinFileExt :: String -> String -> FilePath +joinFileExt fpath "" = fpath +joinFileExt fpath ext = fpath ++ '.':ext + +-- | Split the path into file name and extension. If the file doesn\'t have extension, +-- the function will return empty string. The extension doesn\'t include a leading period. +-- +-- Examples: +-- +-- > splitFileExt "foo.ext" == ("foo", "ext") +-- > splitFileExt "foo" == ("foo", "") +-- > splitFileExt "." == (".", "") +-- > splitFileExt ".." == ("..", "") +-- > splitFileExt "foo.bar."== ("foo.bar.", "") +splitFileExt :: FilePath -> (String, String) +splitFileExt p = + case break (== '.') fname of + (suf@(_:_),_:pre) -> (reverse (pre++fpath), reverse suf) + _ -> (p, []) + where + (fname,fpath) = break isPathSeparator (reverse p) + +-- | Checks whether the character is a valid path separator for the host +-- platform. The valid character is a 'pathSeparator' but since the Windows +-- operating system also accepts a slash (\"\/\") since DOS 2, the function +-- checks for it on this platform, too. +isPathSeparator :: Char -> Bool +isPathSeparator ch = +#if defined(CYGWIN) || defined(__MINGW32__) + ch == '/' || ch == '\\' +#else + ch == '/' +#endif + +-- Code from Cabal end ------------------------------------ +----------------------------------------------------------- + hunk ./src/plugins/System/Plugins/Make.hs 120 --- |Like 'makeAll' but with better recompilation checks since module dependencies are known. +-- |Same as 'makeAll' but with better recompilation checks since module dependencies are known. hunk ./src/plugins/System/Plugins/Make.hs 128 - if not changed + if changed hunk ./src/plugins/Makefile 29 +HC_OPTS += -package Cabal hunk ./configure 913 - cd $ac_popdir + cd "$ac_popdir" hunk ./configure 2499 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2557 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2673 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2727 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2772 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2816 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2921 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 3877 - 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 hunk ./configure 3915 + + 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 hunk ./configure 1377 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghci -ignore-dot-ghci -v0` +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghcii.sh -ignore-dot-ghci -v0` hunk ./configure.ac 69 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghci -ignore-dot-ghci -v0` +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghcii.sh -ignore-dot-ghci -v0` hunk ./configure.ac 69 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghcii.sh -ignore-dot-ghci -v0` +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0` hunk ./configure 1377 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghcii.sh -ignore-dot-ghci -v0` +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0` hunk ./docs/hs-plugins.tex 784 - +\subsection{Utilities for use with eval} +\code{hs-plugins} proves the following utilities for use with \code{eval}: +\begin{itemize} +\item +\code{mkHsValues} is a helper function for converting \code{Data.Map}s +of names and values into Haskell code. It relies on the assumption +that the passed values' Show instances produce valid Haskell +literals (this is true for all prelude types). It's type is as follows: +\begin{quote} +\scm{ +mkHsValues :: (Show a) => Data.Map String a -> String +} +\end{quote} +\end{itemize} hunk ./src/plugins/System/Eval/Haskell.hs 31 + mkHsValues, hunk ./src/plugins/System/Eval/Haskell.hs 50 +import Data.Map as Map hunk ./src/plugins/System/Eval/Haskell.hs 156 - +------------------------------------------------------------------------ +-- +-- Convenience function for use with eval (and friends). Returns a +-- string of Haskell code with the Data.Map passed as values. +-- +mkHsValues :: (Show a) => Map.Map String a -> String +mkHsValues values = concat $ elems $ Map.mapWithKey convertToHs values + where convertToHs :: (Show a) => String -> a -> String + convertToHs name value = name ++ " = " ++ show value ++ "\n" hunk ./src/plugins/System/MkTemp.hs 246 -foreign import ccall unsafe "_getpid" getProcessID :: IO Int +foreign import ccall unsafe "_getpid" getProcessID' :: IO Int +getProcessID :: IO Int +getProcessID = liftM abs getProcessID' hunk ./src/plugins/System/Plugins/Env.hs 68 - -import Control.Monad ( liftM ) +import System.IO.Error ( catch, ioError, isDoesNotExistError ) hunk ./src/plugins/System/Plugins/Env.hs 385 - syslibdir <- liftM ( \x -> x ++ "/SYSTEM") (getEnv "SYSTEMROOT") + sysroot <- catch (getEnv "SYSTEMROOT") + (\e -> if isDoesNotExistError e then return "C:/windows" else ioError e) -- guess at a reasonable default + let syslibdir = sysroot ++ "/SYSTEM" hunk ./src/plugins/System/Plugins/Env.hs 67 +import Prelude hiding ( catch, ioError ) hunk ./src/plugins/System/Plugins/Env.hs 386 + windowsos <- catch (getEnv "OS") + (\e -> if isDoesNotExistError e then return "Windows_98" else ioError e) + windowsdir <- + if windowsos == "Windows_9X" -- I don't know Windows 9X has OS system variable + then return "C:/windows" + else return "C:/winnt" hunk ./src/plugins/System/Plugins/Env.hs 393 - (\e -> if isDoesNotExistError e then return "C:/windows" else ioError e) -- guess at a reasonable default - let syslibdir = sysroot ++ "/SYSTEM" + (\e -> if isDoesNotExistError e then return windowsdir else ioError e) -- guess at a reasonable default + let syslibdir = sysroot ++ (if windowsos == "Windows_9X" then "/SYSTEM" else "/SYSTEM32") hunk ./docs/Makefile 16 - ./munge.sed < $(SRC)/$(SRC).html > tmp.out + sed -f munge.sed < $(SRC)/$(SRC).html > tmp.out hunk ./docs/munge.sed 1 -#!/usr/bin/sed -f hunk ./docs/hs-plugins.tex 851 +\subsection{Notes} + +Be careful if you're calling eval from a forked thread. This can +introduce races between the thread and the forked process used by eval +to compile its code. + hunk ./TODO 4 -+ Cascading unload/reload - -+ have eval, printf return errors as arguments, not to stdout - hunk ./TODO 6 -+ PORTABILITY -- pretty much all of this is in main/SysTools.lhs in GHC - -- where to /tmp files go? Use SysTools code from GHC - -- need to dosify file names on in and out - -- try to confirm the implementation of forkProcess - hunk ./TODO 10 -+ Implement hs_eval by marshalling Dynamics across to the C side for - checking. ++ build way=p and way='' hunk ./TODO 12 -+ Make data structures used by the library Storable, for C programs +Cabal +-------- hunk ./TODO 15 -+ insert iface info into the state, building up a dependency graph like - hram's. use this to allow cascading unloading. Does anyone want this? - -+ enable more .hi interface code to provide full GHC-like :t options - to plugs. - -+ replace the String interface to eval with an ExpQ interface. - -+ build way=p and way='' +What we'd like is a cabalMake version of make, so rather than just +compiling simple plugins, we let cabalMake rebuild whole Haskell apps -- +like Yi! hunk ./src/plugins/System/Plugins/Load.hs 226 - src = mkTest nm (mkModid obj) (fst $ break (=='.') ty) ty sym + src = mkTest nm (hierize' . mkModid . hierize $ obj) + (fst $ break (=='.') ty) ty sym hunk ./src/plugins/System/Plugins/Load.hs 232 --- was need for cygwin, should be ok now: --- e <- build tmpf "nul" (i:is++args++["-fno-code","-ohi nul"]) hunk ./src/plugins/System/Plugins/Load.hs 234 - removeFile tmpf + -- removeFile tmpf hunk ./src/plugins/System/Plugins/Load.hs 237 + + where + -- fix up hierarchical names + hierize [] = [] + hierize ('/':cs) = '\\' : hierize cs + hierize (c:cs) = c : hierize cs + + hierize'[] = [] + hierize' ('\\':cs) = '.' : hierize' cs + hierize' (c:cs) = c : hierize' cs hunk ./src/plugins/System/Plugins/Make.hs 137 +-- touch. + hunk ./src/plugins/System/Plugins/Utils.hs 246 -dirname p = - case reverse $ dropWhile (/= '/') $ reverse p of - [] -> "." - p' -> p' +dirname p = + let x = findIndices (== '\\') p + y = findIndices (== '/') p + in + if not $ null x + then if not $ null y + then if (maximum x) > (maximum y) then dirname' '\\' p else dirname' '/' p + else dirname' '\\' p + else dirname' '/' p + where + dirname' chara pa = + case reverse $ dropWhile (/= chara) $ reverse pa of + [] -> "." + pa' -> pa' hunk ./src/plugins/System/Plugins/Utils.hs 265 -basename p = reverse $ takeWhile (/= '/') $ reverse p +basename p = + let x = findIndices (== '\\') p + y = findIndices (== '/') p + in + if not $ null x + then if not $ null y + then if (maximum x) > (maximum y) then basename' '\\' p else basename' '/' p + else basename' '\\' p + else basename' '/' p + where + basename' chara pa = reverse $ takeWhile (/= chara) $ reverse pa hunk ./examples/plugs/runplugs/Main.hs 18 +#if !defined(CYGWIN) && !defined(__MINGW32__) hunk ./examples/plugs/runplugs/Main.hs 25 +#endif hunk ./examples/plugs/runplugs/Main.hs 45 +#if !defined(CYGWIN) && defined(__MINGW32__) hunk ./examples/plugs/runplugs/Main.hs 47 +#endif hunk ./examples/plugs/runplugs/Makefile 1 -GHCFLAGS= -O +GHCFLAGS= -O $(GHC_EXTRA_OPTS) hunk ./examples/plugs/runplugs/Makefile 3 -PKGFLAGS+= -package plugins -package unix +PKGFLAGS+= -package plugins hunk ./src/plugins/System/Plugins/Utils.hs 286 -mkModid = (takeWhile (/= '.')) . reverse . (takeWhile (/= '/')) . reverse +mkModid = (takeWhile (/= '.')) . reverse . (takeWhile (\x -> ('/'/= x) && ('\\' /= x))) . reverse hunk ./src/plugins/System/Plugins/Load.hs 49 + , getImports + hunk ./src/plugins/System/Plugins/Load.hs 633 + +-- --------------------------------------------------------------------- +-- Nice interface to .hi parser +-- +getImports :: String -> IO [String] +getImports m = do + hi <- readIface (m ++ hiSuf) + return $ dep_mods (mi_deps hi) hunk ./configure 913 - cd "$ac_popdir" + cd $ac_popdir hunk ./configure 2499 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2558 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2675 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2730 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2776 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2821 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2927 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 3884 + 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 hunk ./configure 3927 - - 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 hunk ./examples/plugs/runplugs/Makefile 2 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace +PKGFLAGS= -package posix -package-conf $(TOP)/plugins.conf.inplace hunk ./src/plugins/System/Plugins/Utils.hs 73 +import qualified Control.Exception as Control.Exception (handle) hunk ./src/plugins/System/Plugins/Utils.hs 200 - (_,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing + Control.Exception.handle (\e -> return ([], [show e])) $ do + + (_inh,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing + hunk ./docs/hs-plugins.1 1 -.TH HS-PLUGINS 1 2005-03-26 "hs-plugins version 0.9.8" "User Manual" +.TH HS-PLUGINS 1 2005-07-06 "hs-plugins version 0.9.10" "User Manual" hunk ./docs/hs-plugins.1 8 -\*c is a library for loading plugins written in Haskell into an -application at runtime. It also provides a mechanism for (re)compiling -Haskell source at runtime. Thirdly, a combination of runtime compilation -and dynamic loading provides a suite of eval functions. Values exported -by plugins are transparently available to Haskell host applications, and -bindings exist to use Haskell plugins from at least C and Objective C -programs. hs-plugins requires ghc-6.2.2 or greater. +\*c is a library for loading code written in Haskell into an +application at runtime, in the form of plugins. It also provides a +mechanism for (re-)compiling Haskell source at runtime. Thirdly, a +combination of runtime compilation and dynamic loading provides a set +of eval functions. Values exported by plugins are transparently +available to Haskell host applications, and bindings exist to use +Haskell plugins from at least C and Objective C programs. hs-plugins +requires GHC 6.2.2 or later. hunk ./docs/hs-plugins.1 36 - hunk ./docs/hs-plugins.tex 47 -\urlh{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.8.tar.gz} - {version 0.9.8}} +\urlh{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.10.tar.gz} + {version 0.9.10}} hunk ./docs/hs-plugins.tex 52 -\hsplugins{} is a library for loading plugins written in Haskell into an -application at runtime. It also provides a mechanism for (re)compiling -Haskell source at runtime. Thirdly, a combination of runtime compilation -and dynamic loading provides a suite of \code{eval} functions. Values -exported by plugins are transparently available to Haskell host +\hsplugins{} is a library for loading code written in Haskell into an +application at runtime, in the form of plugins. It also provides a +mechanism for (re-)compiling Haskell source at runtime. Thirdly, a +combination of runtime compilation and dynamic loading provides a set +of \code{eval} functions-- a form of runtime metaprogramming. Values +exported by Haskell plugins are transparently available to Haskell host hunk ./docs/hs-plugins.tex 59 -and Objective C programs. \hsplugins{} currently requires ghc-6.2.2. +and Objective C programs. \hsplugins{} requires GHC 6.2.2 or later. hunk ./docs/hs-plugins.tex 75 -\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.8.tar.gz} - +\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.10.tar.gz} hunk ./docs/hs-plugins.tex 78 -Nightly cvs src snapshots are available at:\\ -\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/snapshots/} - +Darcs repository of the latest code:\\ +\url{darcs get http://www.cse.unsw.edu.au/~dons/code/hs-plugins} hunk ./docs/hs-plugins.tex 84 - hunk ./docs/hs-plugins.tex 88 - hunk ./docs/hs-plugins.tex 90 -A paper on interesting uses of \hsplugins{} to enable Haskell to be used +Papers: +\begin{itemize} +\item A paper on interesting uses of \hsplugins{} to enable Haskell to be used hunk ./docs/hs-plugins.tex 94 -\url{http://www.cse.unsw.edu.au/~dons/hs-plugins/paper} +\url{http://www.cse.unsw.edu.au/~dons/papers/PSSC04.html} + +\item +A paper on dynamic applications in Haskell, utilizing \hsplugins{}:\\ +\url{http://www.cse.unsw.edu.au/~dons/papers/SC05.html} +\end{itemize} hunk ./docs/hs-plugins.tex 104 -\code{ia64-linux}, \code{sparc-solaris2} and \code{powerpc-\{macosx,linux\}}. +\code{sparc-solaris2}, \code{powerpc-\{macosx,linux\}} and flavours of +Windows. hunk ./docs/hs-plugins.tex 110 - \item v0.9.8 + \item June 2005, v0.9.10 + \begin{itemize} + \item Support for GHC 6.4, with help from Sean + Seefried for the package.conf parser. + \item Ported to Windows of various flavours thanks to Vivian McPhail and Shelarcy + \item Removed posix and unix dependencies + \item Now uses HSX parser, thanks to Niklas Broberg + \item Extended load interface, thanks to Lemmih + \item Source now in a darcs repository + \item Supports building with GNU make -jN + \item Simplified module hierarchy, moved under System.* namespace + \item Miscellaneous bug fixes + \end{itemize} + + \item February 2005, v0.9.8 hunk ./docs/hs-plugins.tex 141 - \item Septemeber 2004. + \item September 2004. hunk ./docs/hs-plugins.tex 259 -program at runtime. It allows you to write a Haskell program (which may -be spread over multiple modules) and have an application (implemented in -any language with a Haskell FFI binding, including Haskell) load your -code at runtime, and use the values found within. +program at runtime. It allows you to write Haskell code (which may +be spread over multiple modules), and have an application (implemented in +any language with a Haskell FFI binding, including Haskell) load and use +your code at runtime. hunk ./docs/hs-plugins.tex 274 -loader is a binding to the GHC loader, which does single object -loading. GHC also performs the necessary linking of new objects into -the running process. On top of the GHC loader is our Haskell layer -that arranges for module and package dependencies to be found prior to -loading individual modules. +loader is a binding to the GHC runtime system's dynamic linker, which +does single object loading. GHC also performs the necessary linking of +new objects into the running process. On top of the GHC loader is a +Haskell layer that arranges for module and package dependencies to be +found prior to loading individual modules. hunk ./docs/hs-plugins.tex 281 -compiling Haskell source code into a form suitable for loading -dynamically. While plugins are normally thought of as strictly object -code, there are a variety of scenarios where it is desirable to be -able to inspect the source code of a plugin, or to be able to -recompile a plugin at runtime. The compilation manager fills this -role. It is particularly useful in the implementation of \code{eval}, -and \code{printf}. +compiling Haskell source code into a form suitable for loading. While +plugins are normally thought of as strictly object code, there are a +variety of scenarios where it is desirable to be able to inspect the +source code of a plugin, or to be able to recompile a plugin at runtime. +The compilation manager fills this role. It is particularly useful in +the implementation of \code{eval}. hunk ./docs/hs-plugins.tex 288 -The \emph{evaluator}, \code{eval}, is a client of the loader and -compilation manager. When passed a string of Haskell code, it compiles -the string to object code, loads the result, and returns a Haskell -value representing the compiled string to the caller. It can be -considered a Haskell interpreter, implemented as a library. +The \emph{evaluator}, \code{eval}, utilizes the loader and compilation +manager. When passed a string of Haskell code, it compiles the string to +object code, loads the result, and returns a Haskell value representing +the compiled string to the caller. It can be considered a Haskell +interpreter, implemented as a library. hunk ./docs/hs-plugins.tex 308 +import System.Plugins + hunk ./docs/hs-plugins.tex 394 -dynamic loading. This will be fixed soon). +dynamic loading). hunk ./docs/hs-plugins.tex 422 +} + +\scm{ +pdynload_ :: FilePath + -> [FilePath] + -> [PackageConf] + -> [Arg] + -> Type + -> Symbol + -> IO (LoadStatus a) hunk ./docs/hs-plugins.tex 458 -\code{Type}. Prior to loading the object, \code{pdynload} generates a -tiny Haskell source file containing, for example: +\code{Type}. There are some restrictions on the arguments that may be +passed to pdynload. Currently, we require: + \begin{itemize} + \item TODO + \end{itemize} + +Prior to loading the object, \code{pdynload} generates a tiny Haskell +source file containing, for example: hunk ./docs/hs-plugins.tex 491 +} + +\scm{ +unloadAll :: Module -> IO () hunk ./docs/hs-plugins.tex 499 -space. +space. \code{unloadAll} performs cascading unloading of a module +\emph{and} its dependencies. hunk ./docs/hs-plugins.tex 550 +import System.Plugins + hunk ./docs/hs-plugins.tex 559 + +recompileAll :: Module + -> [Arg] + -> IO MakeStatus hunk ./docs/hs-plugins.tex 582 + +\code{recompileAll} is like \code{makeAll}, but rather than relying on +\code{ghc --make}, we explicitly check a module's dependencies. hunk ./docs/hs-plugins.tex 591 + +mergeToDir :: FilePath -> FilePath -> FilePath -> IO MergeStatus hunk ./docs/hs-plugins.tex 614 -specified using the conventional \code{OPTIONS} pragma. +specified using the conventional \code{OPTIONS} pragma. The merging +operation uses the HSX parser library to parse Haskell source files. + +\code{mergeTo} behaves like \code{merge}, but we can specify the file in +which to place output. \code{mergeToDir} lets you specify a directory in +which to place merged files. hunk ./docs/hs-plugins.tex 674 + +\begin{quote} +\scm{ +hasChanged :: Module -> IO Bool +} +\end{quote} + +\code{hasChanged} returns \code{True} if the module or any of its +dependencies have older object files than source files. Defaults to +\code{True} if some files couldn't be located. hunk ./docs/hs-plugins.tex 715 -Haskell code at runtime, in the form of a String. It is provided as a -separate package to the plugins package, and needs to be linked -against using \code{-package eval}. The general framework is that the -string is used to create a plugin source file, which is compiled and -loaded, and type checked against its use. The resulting value is -returned to the caller. It resembles the \code{eval} primitives of -scripting languages. +Haskell code at runtime, in the form of a String. The general framework +is that the string is used to create a plugin source file, which is +compiled and loaded, and type checked against its use. The resulting +value is returned to the caller. It resembles a runtime metaprogramming +\code{run} operator for closed code fragments. hunk ./docs/hs-plugins.tex 725 +import System.Eval.Haskell + hunk ./docs/hs-plugins.tex 728 + +eval_ :: Typeable a => + String -- code to compile + -> [Import] -- any imports + -> [String] -- extra ghc flags + -> [FilePath] -- extra package.conf files + -> [FilePath] -- include search paths + -> IO (Either [String] (Maybe a)) hunk ./docs/hs-plugins.tex 744 -the evaluated code when it is loaded, using \code{dynload}. The -existing \code{Data.Dynamic} library requires that only monomorphic +the evaluated code when it is loaded, using \code{dynload}. +As usual, \code{eval_} is a version of \code{eval} that lets you pass +extra flags to ghc and to the dynamic loader. + +The existing \code{Data.Dynamic} library requires that only monomorphic hunk ./docs/hs-plugins.tex 750 -functions you need to wrap them up using rank-N types. Some -examples: +functions you need to wrap them up using rank-N types. Some examples: hunk ./docs/hs-plugins.tex 754 -import Eval.Haskell +import System.Eval.Haskell hunk ./docs/hs-plugins.tex 775 -import Eval.Haskell +import System.Eval.Haskell hunk ./docs/hs-plugins.tex 855 -import Eval.Haskell +import System.Eval.Haskell hunk ./docs/hs-plugins.tex 933 - -\subsection{Eval.Printf} - -It has been noted that \code{printf} format strings are the concrete syntax -of a string formatting interpreter (over 1000 lines long in libc!). By -combining runtime generation of new Haskell code, with dynamic typing, -it becomes possible to implement a typesafe \code{printf} for Haskell. - -This has already been achieved in at least 3 different ways. A standard -solution (Hinze, Danvey) begins by supplying printf with the abstract -syntax of the formatting string, resolving the issue of the lack of -typing in the raw fmt string. An alternative solution (see Ian Lynagh's -Printf library) uses Template Haskell to transform a printf format -string into a new Haskell function at compile time, however this -requires that the format string is known at compile time. By using -runtime compilation we can take a similar approach, but instead generate -the print function at runtime! To make this safe, we then need to use -dynamic typing to check the newly-generated print function against its -arguments. - -\subsection*{Printf Interface} - -The \code{Printf} library implements a reasonable amount of the C -printf's functionality. - -\begin{quote} -\scm{ -printf :: String -> [Dynamic] -> IO () -} -\end{quote} - -\begin{quote} -\scm{ -sprintf :: String -> [Dynamic] -> IO String -} -\end{quote} - -Because the arguments to printf are of differing types, and the number -of arguments is not known at compile time, we simulate variadic -functions by using a heterogenous list of arguments. A special list -constructor, \code{!}, is provided for this. An example, noting the -syntax for constructing a heterogenous argument list: - -\begin{quote} -\scm{ -import Eval.Printf - -main = do printf "%d\n" $ (42::Int) ! [] - printf "0x%X\n" $ (42::Int) ! [] - printf "%f\n" $ (42.1234 :: Double) ! [] - printf "%c:%c:%c\n" $ 'a' ! 'b' ! 'c' ! [] - printf "%s\n" $ "haskell" ! [] - printf "%010.4f\n" $ (42.1234 :: Double) ! [] - printf "%10.4s\n" $ "haskell" ! [] - printf "%-10.4s\n" $ "haskell" ! [] -} -\end{quote} - -Compiling this program against \code{-package eval}, and running it -produces the following output: -% -\begin{quote} -\begin{verbatim} -42 -0x2A -42.123400 -a:b:c -haskell -00042.1234 - hask -hask -\end{verbatim} -\end{quote} - -If you mismatch the types specified in the format string, and the -types you apply printf to, printf will generate an exception, like so: - -\begin{quote} -\scm{ -import Eval.Printf - -main = printf "%d\n" ("badstring" ! []) -} -\end{quote} - -The above code will generate this error, indicating that you attempted -to apply a string to a function that expected an Int: -% -\begin{quote} -\begin{verbatim} -paprika$ ./a.out -Fail: Type error in dynamic application. -Can't apply function [Char]> to argument <[Char]> -\end{verbatim} -\end{quote} - -Note that this isn't the fastest printf implementation in the world. A -call to printf invokes GHC to transform the printf format string into -a Haskell code fragment, which is compiled and dynamically linked back -into the application, and then applied to its arguments. If you need -to use the same printf function against multiple times, you can save -recompilation, in which case printf runs as fast as other native code. - -Additionally, it only implements the most common modifiers to the -basic conversion specifiers, and they have not all been fully tested. hunk ./docs/hs-plugins.tex 1365 -import Plugins +import System.Plugins hunk ./docs/hs-plugins.tex 1547 -import Plugins +import System.Plugins hunk ./docs/hs-plugins.tex 1698 -import Eval.Haskell -import Plugins.Load +import System.Eval.Haskell +import System.Plugins hunk ./src/plugins/System/Plugins/Make.hs 23 - hasChanged, - hasChanged', - recompileAll, - recompileAll', - hunk ./src/plugins/System/Plugins/Make.hs 29 + hasChanged, + hasChanged', + recompileAll, + recompileAll', + hunk ./src/plugins/System/Plugins/Make.hs 36 - mergeToDir, + mergeToDir, hunk ./docs/hs-plugins.tex 121 + \item pdynload clarifications, thanks to Alistair Bayley hunk ./docs/hs-plugins.tex 457 - -The type of the plugin's resource field must be equivalent to the -\code{Type}. There are some restrictions on the arguments that may be -passed to pdynload. Currently, we require: - \begin{itemize} - \item TODO - \end{itemize} hunk ./docs/hs-plugins.tex 481 + +The type of the plugin's resource field must be equivalent to the +\code{Type}. There are some restrictions on the arguments that may be +passed to pdynload. Currently, we require: + \begin{itemize} + \item The object name has the suffix (.o) removed and this + becomes a qualified module name in the generated type-checker + input file. + + \item The type name must be a single fully-qualified + type-identifier, as the module name is stripped off (i.e. + everything up to the last ".") and used as a qualified import. + This means that you can't use, for example, \code{"Int -> + String"} as a type (type synonyms are fine, though). + +\end{itemize} + +For example, \code{pdynload "API2.o" ["./"] [] "API.PluginAPI" +"doAction"} generates: + +\begin{quote} +\scm{ +module where +import qualified API -- comes from API.PluginAPI argument +import qualified API2 -- comes from API2.o argument +_ = API2.doAction :: API.PluginAPI +} +\end{quote} hunk ./docs/hs-plugins.tex 767 -As usual, \code{eval_} is a version of \code{eval} that lets you pass +As usual, \code{eval\_} is a version of \code{eval} that lets you pass hunk ./docs/hs-plugins.tex 1682 -limit easy portabilty. The first is the dependence on the GHC dynamic +limit easy portabilty. The main issue is a dependence on the GHC dynamic hunk ./docs/hs-plugins.tex 1686 - -Other than this, there are 3 platform specific items that need to be -defined for new platforms: -\begin{itemize} - \item Where tmp files should be created. Define the - \code{tmpDir} variable in \code{Plugins/Consts.hs} - - \item Process creation, such that we can read stdin and stderr - from the process (this is the POpen library for Posix - systems). For Windows, \hsplugins{} carries Simon - Marlow's \code{forkProcess} library. - - \item Dealing with backslashes in Dos-style path names -\end{itemize} - -I plan to solve the above 3 problems (and thus have a Windows port) once -GHC 6.4 is out. hunk ./src/altdata/altdata.conf.in.cpp 24 -version: 0.9.8 +version: 0.9.10 hunk ./src/hi/hi.conf.in.cpp 24 -version: 1.0 +version: 0.9.10 hunk ./src/plugins/plugins.conf.in.cpp 26 -version: 0.9.8 +version: 0.9.10 hunk ./examples/plugs/runplugs/Main.hs 11 -import System.Eval.Haskell (unsafeEval) +import System.Eval.Haskell (unsafeEval_) hunk ./examples/plugs/runplugs/Main.hs 15 +import Control.Exception (evaluate) + hunk ./examples/plugs/runplugs/Main.hs 19 -import System.IO (getContents, putStrLn) +import System.IO (hGetContents, hPutStrLn, putStrLn, hClose, stdin, stdout, stderr) hunk ./examples/plugs/runplugs/Main.hs 25 +import Control.Concurrent ( forkIO ) +import qualified Control.Exception ( evaluate ) hunk ./examples/plugs/runplugs/Main.hs 48 +-- +-- with ghc 6.4, ghc doesn't seem to be able to call gcc, setNoFDBlocking fails. +-- +-- *** Assembler +-- gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o +-- +-- Failed: gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o +-- gcc: setNonBlockingFD: invalid argument (Bad file descriptor) +-- hunk ./examples/plugs/runplugs/Main.hs 61 - s <- getContents + s <- hGetContents stdin hunk ./examples/plugs/runplugs/Main.hs 63 - s <- unsafeEval ("(take 2048 (show ("++s++")))") context - when (isJust s) (putStrLn (fromJust s)) + s <- unsafeEval_ ("(take 2048 (show ("++s++")))") context ["-v"] [] [] + case s of + Left errs -> mapM_ putStrLn errs + Right s -> putStrLn s hunk ./examples/plugs/runplugs/Makefile 1 -GHCFLAGS= -O $(GHC_EXTRA_OPTS) +GHCFLAGS= -Onot $(GHC_EXTRA_OPTS) hunk ./VERSION 1 -hs-plugins 0.9.8 +hs-plugins 0.9.10 addfile ./scripts/mkrelease.sh hunk ./Makefile 26 + $(INSTALL_DATA_DIR) $(MANDIR)/man1 + $(INSTALL_DATA) docs/hs-plugins.1 $(MANDIR)/man1 hunk ./config.mk.in 22 +MANDIR = $(PREFIX)/man hunk ./scripts/mkrelease.sh 1 +#!/bin/sh + +cd /tmp +rm -rf hs-plugins-0.9.10* + +darcs get --set-scripts-executable /home/dons/hs-plugins +cd hs-plugins +rm -rf _darcs +cd .. +mv hs-plugins hs-plugins-0.9.10 +tar czf hs-plugins-0.9.10.tar.gz hs-plugins-0.9.10 hunk ./scripts/openbsd-port/Makefile 5 -V= 0.9.8 +V= 0.9.10 hunk ./scripts/openbsd-port/Makefile 9 -HOMEPAGE= http://www.cse.unsw.edu.au/~dons/hs-plugins-0.9.8/ +HOMEPAGE= http://www.cse.unsw.edu.au/~dons/hs-plugins/ hunk ./examples/iface/null/expected.604 3 -package dependencies: base-1.0, haskell98-1.0, hi-1.0 +package dependencies: base-1.0, haskell98-1.0, hi-0.9.10 addfile ./examples/plugs/runplugs/dont_test hunk ./src/altdata/AltData/Dynamic.hs 34 +#if __GLASGOW_HASKELL__ >= 603 hunk ./src/altdata/AltData/Dynamic.hs 40 +#endif hunk ./src/altdata/AltData/Dynamic.hs 50 +#if __GLASGOW_HASKELL__ >= 603 hunk ./src/altdata/AltData/Dynamic.hs 52 +#endif hunk ./src/altdata/AltData/Dynamic.hs 142 +#if __GLASGOW_HASKELL__ >= 603 + hunk ./src/altdata/AltData/Dynamic.hs 151 + hunk ./src/altdata/AltData/Dynamic.hs 161 + +#endif hunk ./src/plugins/Makefile 29 -HC_OPTS += -package Cabal hunk ./src/plugins/Makefile 34 +else +HC_OPTS += -package Cabal hunk ./docs/hs-plugins.tex 59 -and Objective C programs. \hsplugins{} requires GHC 6.2.2 or later. +and Objective C programs. \hsplugins{} requires GHC 6.4 or later. hunk ./docs/hs-plugins.tex 1068 -libraries in GHC. A couple of recent patches to the linker have made -this possible (available in ghc-6.2.2 or in the head branch). Here, -for example, we load the \code{plugs} interactive environment in GHCi, -and evaluated some code. The source to \code{plugs} is in Appendix +libraries in GHC. Here, for example, we load the \code{plugs} +interactive environment in GHCi, and evaluated some code. The source to +\code{plugs} is in Appendix hunk ./README 28 -* Requires GHC > 6.2 (for Typeable.h) +* Requires GHC >= 6.4 hunk ./README 59 -And to unregister (maybe as root). Note that the unistall order -matters: - - $ ghc-pkg -r printf - $ ghc-pkg -r eval - $ ghc-pkg -r plugins - $ ghc-pkg -r hi - $ ghc-pkg -r altdata +And to unregister (maybe as root): + $ make unregister hunk ./README 63 --package plugins or, e.g. -package eval, to your command line. +-package plugins to your command line. hunk ./README 82 -Requires GHC 6.2 or greater, though most testing has be done on 6.3. +Requires GHC 6.4 or greater, though most testing has be done on 6.4. hunk ./README 92 +powerpc-*-linux | X hunk ./TODO 4 -+ nice functions for cleaning up /tmp files, given a module name - -+ write a script to strip down the release code. - hunk ./BUILDING.CVS 7 -1. Execute autogen.sh to generate the GNU ./configure script: - - ./autogen.sh +1. Use autoconf to generate the GNU ./configure script: hunk ./autogen.sh 1 -#!/bin/sh -x - -# this is the world's most complicated autogen.sh script :) - -exec autoconf - rmfile ./autogen.sh hunk ./src/plugins/Makefile 35 -HC_OPTS += -package Cabal +#HC_OPTS += -package Cabal hunk ./src/hi/Language/Hi/Parser.hs 51 -import GHC.Word hunk ./src/hi/Language/Hi/Parser.hs 71 - build_tag <- get bh :: IO Word8 -- 'way' flag + build_tag <- get bh :: IO String -- 'way' flag hunk ./src/hi/Language/Hi/Binary.hs 346 +#if __GLASGOW_HASKELL__ < 605 hunk ./src/hi/Language/Hi/Binary.hs 353 +#else + get bh = do + b <- getByte bh + len <- if b == 0xff + then get bh + else return (fromIntegral b :: Word32) + let loop 0 = return [] + loop n = do a <- get bh; as <- loop (n-1); return (a:as) + loop len +#endif hunk ./scripts/mkrelease.sh 6 -darcs get --set-scripts-executable /home/dons/hs-plugins +darcs get --partial --set-scripts-executable /home/dons/hs-plugins move ./src/altdata/AltData ./src/plugins/AltData move ./src/hi/Language ./src/plugins/Language move ./src/plugins ./plugins hunk ./BUILDING.CVS 1 -CVS BUILDING INSTRUCTIONS -========================= - -These are build instructions if you've checked out hs-plugins -from CVS (instead of downloading a source distribution tarball). - -1. Use autoconf to generate the GNU ./configure script: - -2. Build hs-plugins as usual with ./configure && make - - -cvsps -===== - -For people who are used to more modern revision control systems -(such as Darcs, Subversion and Arch) and miss working with -'patchsets' instead of the disjoint per-file patches that CVS -uses, take a look at cvsps , -a patchset manager for CVS. While it doesn't, by any means, give -you the many advantages that more modern source control systems -offer you, it certainly makes using CVS and managing patches far -easier! - rmfile ./BUILDING.CVS hunk ./plugins/Makefile 1 -PKG = plugins -UPKG = Plugins - -PATHS = System System/Eval System/Plugins - -TOP=../.. -include $(TOP)/config.mk - -ifeq ($(CABAL),1) -YOBJ = System/$(UPKG)/ParsePkgConfCabal.hs -YSRC = System/$(UPKG)/ParsePkgConfCabal.y -OTHER = System/$(UPKG)/ParsePkgConfLite.hs -else -YOBJ = System/$(UPKG)/ParsePkgConfLite.hs -YSRC = System/$(UPKG)/ParsePkgConfLite.y -OTHER = System/$(UPKG)/ParsePkgConfCabal.hs -endif - -STUBOBJS =System/Eval/Haskell_stub.$(way_)o - -ALL_SRCS= $(filter-out $(OTHER), \ - $(wildcard $(patsubst ./%, %, \ - $(patsubst %, %/*.hs, System System/$(UPKG) System/Eval)))) - -include ../build.mk - -HC_OPTS += -package-conf $(TOP)/plugins.conf.inplace -HC_OPTS += -package altdata -package hi -HC_OPTS += -O -funbox-strict-fields -HC_OPTS += -Wall -fno-warn-missing-signatures - -ifeq ($(GLASGOW_HASKELL),602) -HC_OPTS += -package posix -else -#HC_OPTS += -package Cabal -endif - -install: install-me - --include depend rmfile ./plugins/Makefile hunk ./plugins/plugins.conf.in.cpp 1 -#if CABAL == 0 && GLASGOW_HASKELL < 604 -Package { - name = "plugins", - auto = False, -#ifdef INSTALLING - import_dirs = [ "${LIBDIR}/imports" ], - library_dirs = [ "${LIBDIR}/" ], -#else - import_dirs = [ "${TOP}/src/plugins" ], - library_dirs = [ "${TOP}/src/plugins" ], -#endif - hs_libraries = [ "HSplugins" ], - c_includes = [ "Linker.h" ], - include_dirs = [], - source_dirs = [], - extra_libraries = [], - package_deps = [ "altdata", "hi", "unix", "haskell-src-exts", "posix" ], - extra_ghc_opts = [], - extra_cc_opts = [], - extra_ld_opts = [] -} - -#else - -name: plugins -version: 0.9.10 -license: LGPL -maintainer: dons@cse.unsw.edu.au -exposed: True -exposed-modules: - System.Plugins.Load, - System.Plugins.LoadTypes, - System.Plugins.Make, - System.Plugins, - System.MkTemp, - System.Eval, - System.Eval.Haskell - -hidden-modules: - System.Plugins.Consts, - System.Plugins.Env, - System.Plugins.Package, - System.Plugins.PackageAPI, - System.Plugins.ParsePkgConfCabal, - System.Plugins.ParsePkgConfLite, - System.Plugins.Parser, - System.Plugins.Utils, - System.Eval.Utils - -#ifdef INSTALLING -import-dirs: LIBDIR/imports -library-dirs: LIBDIR -#else -import-dirs: TOP/src/plugins -library-dirs: TOP/src/plugins -#endif -hs-libraries: HSplugins -extra-libraries: -include-dirs: -includes: Linker.h -depends: altdata, hi, haskell-src-exts, Cabal -hugs-options: -cc-options: -ld-options: -framework-dirs: -frameworks: -haddock-interfaces: -haddock-html: - -#endif rmfile ./plugins/plugins.conf.in.cpp hunk ./src/Makefile 1 - -# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons -# GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html) - -.PHONY: all build altdata hi plugins -.PHONY: install i_altdata i_hi i_plugins - -build: altdata hi plugins - -altdata: - @cd altdata && $(MAKE) -hi: - @cd hi && $(MAKE) -plugins: altdata hi - @cd plugins && $(MAKE) - -install: i_altdata i_hi i_plugins - @true - -i_altdata: - @cd altdata && $(MAKE) install -i_hi: - @cd hi && $(MAKE) install -i_plugins: - @cd plugins && $(MAKE) install - -all: build - -TOP=.. -include build.mk rmfile ./src/Makefile hunk ./src/README 1 -Don's Haskell Libraries ------------------------ - -* altdata -An alternative implementation of Typeable and Dynamic that -works in the presence of (completely) separate compilation - -* hi -A parser for .hi files - -* plugins -A dynamic loader for GHC-produce object files. Also provides type -checking of object interfaces via dynamic typing. - -* eval -A system for reflecting strings of Haskell source into native code at -runtime, via runtime compilation and dynamic linking. -Also implements a staged computation doo-hickey. - -* printf -An implementation of printf(3) that uses eval to generate new Haskell -functions from format strings, at runtime, and dynamic typing to -retain type safety. rmfile ./src/README hunk ./src/altdata/Makefile 1 -PKG = altdata -UPKG = AltData -PATHS = AltData - -ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, . $(UPKG)))) - -TOP=../.. -include ../build.mk - -install: install-me - --include depend rmfile ./src/altdata/Makefile hunk ./src/altdata/altdata.conf.in.cpp 1 -#if CABAL == 0 && GLASGOW_HASKELL < 604 -Package { - name = "altdata", - auto = False, - hs_libraries = [ "HSaltdata" ], -#ifdef INSTALLING - import_dirs = [ "${LIBDIR}/imports" ], - library_dirs = [ "${LIBDIR}" ], -#else - import_dirs = [ "${TOP}/src/altdata" ], - library_dirs = [ "${TOP}/src/altdata" ], -#endif - include_dirs = [], - c_includes = [], - source_dirs = [], - extra_libraries = [], - package_deps = [ "base" ], - extra_ghc_opts = [], - extra_cc_opts = [], - extra_ld_opts = [] -} -#else -name: altdata -version: 0.9.10 -license: LGPL -maintainer: dons@cse.unsw.edu.au -exposed: True -exposed-modules: - AltData.Dynamic, - AltData.Typeable - -hidden-modules: -#ifdef INSTALLING -import-dirs: LIBDIR/imports -library-dirs: LIBDIR -#else -import-dirs: TOP/src/altdata -library-dirs: TOP/src/altdata -#endif -hs-libraries: HSaltdata -extra-libraries: -include-dirs: -includes: -depends: base -hugs-options: -cc-options: -ld-options: -framework-dirs: -frameworks: -haddock-interfaces: -haddock-html: -#endif rmfile ./src/altdata/altdata.conf.in.cpp rmdir ./src/altdata hunk ./src/build.mk 1 -# -# Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons -# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) -# - -MAKEFLAGS += --no-builtin-rules -.SUFFIXES: - -include $(TOP)/config.mk - -# If $(way) is set then we define $(way_) and $(_way) from it in the -# obvious fashion. -ifeq "$(way)" "p" - way_ := $(way)_ - _way := _$(way) -endif - -# -# building the profiled way -# -ifeq "$(way)" "p" -PROF_OPTS = -prof -auto-all -Icbits -LD_OPTS += $(PROF_OPTS) -HC_OPTS += $(PROF_OPTS) -HC_OPTS += -hisuf $(way_)hi -hcsuf $(way_)hc -osuf $(way_)o -endif - -MAIN = $(UPKG).hs -LIBRARY = libHS$(PKG)$(_way).a -GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY)) -OBJS = $(UPKG).o $(UPKG)/*.o - -HC_OPTS += -package-name $(PKG) -HC_OPTS += -O -Wall -Werror -fno-warn-missing-signatures $(GHC_EXTRA_OPTS) -HC_OPTS += -threaded - -CLEANS += $(LIBRARY) $(GHCI_LIBRARY) -CLEAN_FILES += *.conf.inplace* *.conf.*.old *.conf.in *.h *.in - -OBJS= $(addsuffix .$(way_)o,$(basename $(ALL_SRCS))) - -.PHONY: clean all alt_objs plugins.conf.inplace happy banner - -all : $(LIBRARY) $(TOP)/plugins.conf.inplace $(PKG).conf.in - -# libraries -$(LIBRARY): depend $(COBJ) $(XOBJ) $(YOBJ) $(OBJS) - @$(RM) -f $@ - @$(AR) cq $@ $(OBJS) $(COBJ) $(STUBOBJS) - @$(RANLIB) $@ - -$(GHCI_LIBRARY) : $(OBJS) - $(LD_X) -r -o $@ $(OBJS) $(COBJ) $(STUBOBJS) - -# -# Dependency generation -# -depend: $(ALL_SRCS) - @echo -n "Rebuilding dependencies ... " - @$(GHC) -cpp $(HC_OPTS) $(PKG_OPTS) $(HTOOLKIT) -M -optdep-f \ - -optdepdepend $(ALL_SRCS) || rm depend - @echo "done." - -%.$(way_)hi : %.$(way_)o - @: - -%.$(way_)o: %.hs - $(GHC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi - -# Now a rule for hs-boot files. -%.$(way_)o-boot : %.hs-boot - $(GHC) $(HC_OPTS) $(PKG_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi-boot - -# happy files -$(YOBJ): $(YSRC) - $(HAPPY) $(HAPPY_OPTS) -o $@ $(YSRC) - -# alex files -$(XOBJ): $(XSRC) - $(ALEX) $(ALEX_OPTS) -o $@ $(XSRC) - -$(COBJ): $(CSRC) - $(GHC) -c $(CSRC) -o $@ - -# package.confs and friends -# ghc-6.2.2 needs TOP as env var. -$(TOP)/plugins.conf.inplace: $(PKG).conf.in.cpp $(LIBRARY) $(GHCI_LIBRARY) - @cpp -DTOP=$(TOP) -DGLASGOW_HASKELL=$(GLASGOW_HASKELL) -DCABAL=$(CABAL) -undef < $(PKG).conf.in.cpp | sed -e 's/""//g' -e 's/\[ *,/[ /g' -e '/^#/d' > $(PKG).conf.inplace.in - @(cd $(TOP) ;\ - if [ ! -f $(TOP)/plugins.conf.inplace ]; then echo [] > $(TOP)/plugins.conf.inplace; fi;\ - env TOP=$(TOP) $(GHC_PKG) --force -f $@ -u < src/$(PKG)/$(PKG).conf.inplace.in) - -# installation pkg.confs -$(PKG).conf.in : $(PKG).conf.in.cpp - @cpp -DLIBDIR=$(LIBDIR) -DGLASGOW_HASKELL=$(GLASGOW_HASKELL) -DCABAL=$(CABAL) -DINSTALLING -Uunix < $(PKG).conf.in.cpp | sed -e 's/""//g' -e 's/\[ *,/[ /g' -e '/^#/d' > $@ - -# -# todo. need to re-ranlib the library -# -HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(ALL_SRCS))) - -.PHONY: install install-me -install-me: - @for i in $(PATHS) ; do \ - $(INSTALL_DATA_DIR) $(LIBDIR)/imports/$$i ;\ - done - @for j in $(HS_IFACES) ; do \ - echo $(INSTALL_DATA) $(TOP)/src/$(PKG)/$$j $(LIBDIR)/imports/$$j ; \ - $(INSTALL_DATA) $(TOP)/src/$(PKG)/$$j $(LIBDIR)/imports/$$j ; \ - done - $(INSTALL_DATA) $(TOP)/src/$(PKG)/libHS$(PKG)$(_way).a $(LIBDIR) - $(RANLIB) $(LIBDIR)/libHS$(PKG).a - $(INSTALL_DATA) $(TOP)/src/$(PKG)/HS$(PKG).o $(LIBDIR) - $(INSTALL_DATA) $(TOP)/src/$(PKG)/$(PKG).conf.in $(LIBDIR) - -clean: - rm -f $(CLEAN_FILES) - find . -name '*.a' -exec rm {} \; - find . -name depend -exec rm {} \; - find . -name '*.in' -exec rm {} \; - find . -name '*~' -exec rm {} \; - find . -name 'a.out' -exec rm {} \; - find . -name '*.hi' -exec rm {} \; - find . -name '*.p_hi' -exec rm {} \; - find . -name '*.o' -exec rm {} \; - find . -name '*.p_o' -exec rm {} \; - find . -name '*.old' -exec rm {} \; - find . -name '*.core' -exec rm {} \; - find . -name '*_stub.c' -exec rm {} \; - find . -name '*_stub.h' -exec rm {} \; - rmfile ./src/build.mk hunk ./src/hi/Makefile 1 -PKG = hi -UPKG = Hi - -CSRC = Language/$(UPKG)/hschooks.c -COBJ = Language/$(UPKG)/hschooks.o - -PATHS = Language Language/$(UPKG) - -ALL_SRCS=$(wildcard $(patsubst ./%, %, $(patsubst %, %/*.hs, Language Language/$(UPKG)))) - -TOP=../.. -include ../build.mk - -HC_OPTS += -ILanguage/$(UPKG) - -install: install-me - --include depend rmfile ./src/hi/Makefile hunk ./src/hi/hi.conf.in.cpp 1 -#if CABAL == 0 && GLASGOW_HASKELL < 604 -Package { - name = "hi", - auto = False, - hs_libraries = [ "HShi" ], -#ifdef INSTALLING - import_dirs = [ "${LIBDIR}/imports" ], - library_dirs = [ "${LIBDIR}/" ], -#else - import_dirs = [ "${TOP}/src/hi" ], - library_dirs = [ "${TOP}/src/hi" ], -#endif - include_dirs = [], - c_includes = [], - source_dirs = [], - extra_libraries = [], - package_deps = [ "base", "haskell98" ], - extra_ghc_opts = [], - extra_cc_opts = [], - extra_ld_opts = [] -} -#else -name: hi -version: 0.9.10 -license: BSD3 -maintainer: libraries@haskell.org -exposed: True -exposed-modules: - Language.Hi.Parser - -hidden-modules: - Language.Hi.Binary, - Language.Hi.FastString, - Language.Hi.Syntax, - Language.Hi.FastMutInt, - Language.Hi.PrimPacked - -#ifdef INSTALLING -import-dirs: LIBDIR/imports -library-dirs: LIBDIR -#else -import-dirs: TOP/src/hi -library-dirs: TOP/src/hi -#endif -hs-libraries: HShi -extra-libraries: -include-dirs: -includes: -depends: base, haskell98 -hugs-options: -cc-options: -ld-options: -framework-dirs: -frameworks: -haddock-interfaces: -haddock-html: -#endif rmfile ./src/hi/hi.conf.in.cpp rmdir ./src/hi rmdir ./src hunk ./Makefile 11 - cd src && $(MAKE) - @find src -name depend -exec rm {} \; - @#cd src && $(MAKE) way=p + cd plugins ;\ + $(GHC) -o setup --make Setup.hs ;\ + ./setup configure --prefix=$(PREFIX) --with-happy=$(TOP)/happy.sh ;\ + ./setup build hunk ./Makefile 17 - cp src/plugins/System/Eval/Haskell_stub.h $@ + cp plugins/System/Eval/Haskell_stub.h $@ hunk ./Makefile 29 - @(cd src && $(MAKE) install) - -# -# and register the library with ghc package system -# Use this target if installing by hand. May need to be performed as root -# -register: - env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/altdata/altdata.conf.in - env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/hi/hi.conf.in - env LIBDIR=${LIBDIR} $(GHC_PKG) -u < src/plugins/plugins.conf.in - -# and unregister the packages -unregister: - $(GHC_PKG) -r plugins - $(GHC_PKG) -r hi - $(GHC_PKG) -r altdata + cd plugins && ./setup install hunk ./Makefile 40 - for i in `find examples ! -name CVS -type d -maxdepth 2 -mindepth 2` ; do \ + for i in `find examples ! -name CVS -type d -maxdepth 2 -mindepth 2 | sort` ; do \ hunk ./Makefile 50 - hunk ./Makefile 55 -EXTRA_CLEANS+=*.conf.inplace* *.conf.in *.h autom4te.cache \ - config.h config.mk config.log config.status hunk ./Makefile 58 - cd src && $(MAKE) clean + cd plugins && ./setup clean 2> /dev/null || true + cd plugins && rm -rf dist Setup.hi Setup.o setup hunk ./Makefile 74 +EXTRA_CLEANS+=*.conf.inplace* *.conf.in *.h autom4te.cache \ + config.h config.mk config.log config.status hunk ./Makefile 79 -include config.mk +-include config.mk hunk ./config.h.in 1 -/* - * Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons - * LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) - */ +/* config.h.in. Generated from configure.ac by autoheader. */ hunk ./config.h.in 3 -/* symbols that must be assigned to variables in Haskell code */ +/* Defined if compiling with mingw */ +#undef CYGWIN hunk ./config.h.in 6 -/* NOTE: this is not the same as symbols needed for cpp of .hs code */ +/* Defined if a debugging version is to be built */ +#undef DEBUG hunk ./config.h.in 9 -/* path to ghc */ -#define GHC "@GHC@" +/* Path to ghc libraries */ +#undef GHC_LIB_PATH hunk ./config.h.in 12 -/* path to GHC libraries */ -#define GHC_LIB_PATH "@GHC_LIB_PATH@" +/* Define to 1 if you have the `arc4random' function. */ +#undef HAVE_ARC4RANDOM hunk ./config.h.in 15 -#define TOP "@TOP@" +/* Whether symbols are prefixed with a leading underscore */ +#undef LEADING_UNDERSCORE hunk ./config.h.in 18 -#define LEADING_UNDERSCORE @LEADING_UNDERSCORE@ +/* Defined if compiling on the mac */ +#undef MACOSX hunk ./config.h.in 21 -#define CABAL @CABAL@ +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT hunk ./config.h.in 24 +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Path to top of build tree */ +#undef TOP + +/* Which ghc to use */ +#undef WITH_GHC + +/* Defined if compiling with mingw */ +#undef __MINGW32__ hunk ./config.mk.in 1 -# -# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons -# LGPL version 2.1 or later (see http://www.gnu.org/copyleft/lesser.html) -# - -# -# config.mk.in : -# variables that need to be visible in Makefiles -# - -# all is the default rule for everyone hunk ./config.mk.in 3 +VERSION = 0.9.10 hunk ./config.mk.in 5 -UPACKAGE = Plugins hunk ./config.mk.in 9 -LIBDIR = $(PREFIX)/lib/hs-$(PACKAGE) +LIBDIR = $(PREFIX)/lib/$(PACKAGE)-$(VERSION) hunk ./config.mk.in 12 - -WHOLE_ARCHIVE_FLAG = @WHOLE_ARCHIVE_FLAG@ - -# Are we using the new Cabal packages? -CABAL = @CABAL@ - hunk ./config.mk.in 14 -GHC_LIB_PATH = @GHC_LIB_PATH@ -GHC_VERSION = @GHC_VERSION@ hunk ./config.mk.in 15 -GHC_EXTRA_OPTS = @SYMS@ @DEBUG_OPTS@ -GHC_LD_OPTS = - -GHC_PKG = @GHCPKG@ - -LD = @LD@ -LD_X = @LD@ -x - -HAPPY = @HAPPY@ -HAPPY_OPTS = -a -g -c -ALEX = @ALEX@ -ALEX_OPTS = --ghc -HADDOCK = @HADDOCK@ - -AR = @AR@ -RANLIB = @RANLIB@ - -RM = @RM@ - -INSTALL = @INSTALL@ hunk ./config.mk.in 17 +INSTALL = @INSTALL@ hunk ./configure 274 -ac_unique_file="src/plugins/System/Plugins.hs" -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 build build_cpu build_vendor build_os PREFIX WHOLE_ARCHIVE_FLAG LEADING_UNDERSCORE SYMS TOP GHC GHC_LIB_PATH GHC_VERSION GLASGOW_HASKELL CABAL DEBUG_OPTS GHCPKG HADDOCK HAPPY ALEX LD AR RANLIB RM TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' +ac_unique_file="plugins/System/Plugins.hs" +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 build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' hunk ./configure 805 - --enable-cabal Enable use of Cabal packages in pluggable-1-branch - of GHC hunk ./configure 1239 + + hunk ./configure 1259 +# Prepare to generate the config.h.in file + ac_config_headers="$ac_config_headers config.h" hunk ./configure 1343 + +cat >>confdefs.h <<_ACEOF +#define MACOSX 1 +_ACEOF + + LEADING_UNDERSCORE=1 hunk ./configure 1352 + LEADING_UNDERSCORE=0 hunk ./configure 1355 -if test "$MACOSX" = "yes" -then - WHOLE_ARCHIVE_FLAG=-all_load - LEADING_UNDERSCORE=1 - SYMS="$SYMS -DMACOSX" -else - WHOLE_ARCHIVE_FLAG=--whole-archive - LEADING_UNDERSCORE=0 -fi - - - hunk ./configure 1358 + +cat >>confdefs.h <<\_ACEOF +#define __MINGW32__ 1 +_ACEOF + hunk ./configure 1364 - SYMS="$SYMS -D__MINGW32__" hunk ./configure 1365 - - hunk ./configure 1368 + +cat >>confdefs.h <<\_ACEOF +#define CYGWIN 1 +_ACEOF + hunk ./configure 1374 - SYMS="$SYMS -DCYGWIN" hunk ./configure 1375 + hunk ./configure 1377 +cat >>confdefs.h <<_ACEOF +#define LEADING_UNDERSCORE $LEADING_UNDERSCORE +_ACEOF hunk ./configure 1385 + + +cat >>confdefs.h <<_ACEOF +#define TOP "$TOP" +_ACEOF + hunk ./configure 1451 - - -# find path to GHC libs, for runtime_loader -if test -n "$GHC" ; then - echo "$as_me:$LINENO: checking for ghc library directory" >&5 -echo $ECHO_N "checking for ghc library directory... $ECHO_C" >&6 - GHC_LIB_PATH=`$GHC --print-libdir` - echo "$as_me:$LINENO: result: $GHC_LIB_PATH" >&5 -echo "${ECHO_T}$GHC_LIB_PATH" >&6 -fi hunk ./configure 1452 +cat >>confdefs.h <<_ACEOF +#define WITH_GHC $GHC +_ACEOF hunk ./configure 1456 -# check ghc version here -if test -n "$GHC" ; then - echo "$as_me:$LINENO: checking for ghc version" >&5 -echo $ECHO_N "checking for ghc version... $ECHO_C" >&6 - GHC_VERSION=`$GHC --numeric-version` - echo "$as_me:$LINENO: result: $GHC_VERSION" >&5 -echo "${ECHO_T}$GHC_VERSION" >&6 -fi hunk ./configure 1467 -fi - - -MAJOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\1/'` -MINOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\2/'` - -if test "$MAJOR" -lt "6"; then - { { echo "$as_me:$LINENO: error: Found major $MAJOR. You need a ghc version >= 6.2" >&5 -echo "$as_me: error: Found major $MAJOR. You need a ghc version >= 6.2" >&2;} - { (exit 1); exit 1; }; } ; -fi -if test "$MINOR" -lt "2"; then - { { echo "$as_me:$LINENO: error: You need a ghc version >= 6.2" >&5 -echo "$as_me: error: You need a ghc version >= 6.2" >&2;} - { (exit 1); exit 1; }; } ; hunk ./configure 1469 -#Allow plugins to be built with Cabal libraries -# Check whether --enable-cabal or --disable-cabal was given. -if test "${enable_cabal+set}" = set; then - enableval="$enable_cabal" - CABAL=1 -else - CABAL=0 -fi; hunk ./configure 1470 -# used by the Makefile`s to alter dependencies. -if test "$MAJOR" -ge "6" -a "$MINOR" -ge "4"; then - CABAL=1 +# find path to GHC libs, for runtime_loader +if test -n "$GHC" ; then + echo "$as_me:$LINENO: checking for ghc library directory" >&5 +echo $ECHO_N "checking for ghc library directory... $ECHO_C" >&6 + GHC_LIB_PATH=`$GHC --print-libdir` + echo "$as_me:$LINENO: result: $GHC_LIB_PATH" >&5 +echo "${ECHO_T}$GHC_LIB_PATH" >&6 hunk ./configure 1479 +cat >>confdefs.h <<_ACEOF +#define GHC_LIB_PATH "$GHC_LIB_PATH" +_ACEOF hunk ./configure 1488 - DEBUG_OPTS=-DDEBUG -else - DEBUG_OPTS= -fi; - - - -# Search for ghc-pkg -echo "$as_me:$LINENO: checking for ghc-pkg" >&5 -echo $ECHO_N "checking for ghc-pkg... $ECHO_C" >&6 -ghc_pkg_guess=`echo $GHC | sed 's,ghc\([^/\\]*\)$,ghc-pkg\1,'` -if "$ghc_pkg_guess" -l > /dev/null 2>&1; then - matching_ghc_pkg=$ghc_pkg_guess -else - matching_ghc_pkg=no -fi -if test x"$matching_ghc_pkg" = xno; then - # Extract the first word of "ghc-pkg", so it can be a program name with args. -set dummy ghc-pkg; 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_GHCPKG+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$GHCPKG"; then - ac_cv_prog_GHCPKG="$GHCPKG" # 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_GHCPKG="" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -GHCPKG=$ac_cv_prog_GHCPKG -if test -n "$GHCPKG"; then - echo "$as_me:$LINENO: result: $GHCPKG" >&5 -echo "${ECHO_T}$GHCPKG" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - if test -z "$GHCPKG" ; then - { { echo "$as_me:$LINENO: error: ghc-pkg not found." >&5 -echo "$as_me: error: ghc-pkg not found." >&2;} - { (exit 1); exit 1; }; } - fi -else - GHCPKG=$matching_ghc_pkg -fi -echo "$as_me:$LINENO: result: $GHCPKG" >&5 -echo "${ECHO_T}$GHCPKG" >&6 - - -# Extract the first word of "haddock", so it can be a program name with args. -set dummy haddock; 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_HADDOCK+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$HADDOCK"; then - ac_cv_prog_HADDOCK="$HADDOCK" # 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_HADDOCK="haddock" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -HADDOCK=$ac_cv_prog_HADDOCK -if test -n "$HADDOCK"; then - echo "$as_me:$LINENO: result: $HADDOCK" >&5 -echo "${ECHO_T}$HADDOCK" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$HADDOCK" ; then - { echo "$as_me:$LINENO: WARNING: You need Haddock if you want developer documentation" >&5 -echo "$as_me: WARNING: You need Haddock if you want developer documentation" >&2;} -fi - -# Extract the first word of "happy", so it can be a program name with args. -set dummy happy; 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_HAPPY+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$HAPPY"; then - ac_cv_prog_HAPPY="$HAPPY" # 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_HAPPY="happy" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -HAPPY=$ac_cv_prog_HAPPY -if test -n "$HAPPY"; then - echo "$as_me:$LINENO: result: $HAPPY" >&5 -echo "${ECHO_T}$HAPPY" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$HAPPY" ; then - { echo "$as_me:$LINENO: WARNING: If you change or remove the parser you'll need Happy" >&5 -echo "$as_me: WARNING: If you change or remove the parser you'll need Happy" >&2;} -fi - -# Extract the first word of "alex", so it can be a program name with args. -set dummy alex; 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_ALEX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ALEX"; then - ac_cv_prog_ALEX="$ALEX" # 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_ALEX="alex" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ALEX=$ac_cv_prog_ALEX -if test -n "$ALEX"; then - echo "$as_me:$LINENO: result: $ALEX" >&5 -echo "${ECHO_T}$ALEX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$ALEX" ; then - { echo "$as_me:$LINENO: WARNING: If you change or remove the lexer files you'll need alex" >&5 -echo "$as_me: WARNING: If you change or remove the lexer files you'll need alex" >&2;} -fi - -# Extract the first word of "ld", so it can be a program name with args. -set dummy ld; 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_LD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$LD"; then - ac_cv_prog_LD="$LD" # 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_LD="ld" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -LD=$ac_cv_prog_LD -if test -n "$LD"; then - echo "$as_me:$LINENO: result: $LD" >&5 -echo "${ECHO_T}$LD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$LD" ; then - { echo "$as_me:$LINENO: WARNING: You need ld -export-dynamic" >&5 -echo "$as_me: WARNING: You need ld -export-dynamic" >&2;} -fi - -# 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_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="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 - -if test -z "$AR" ; then - { echo "$as_me:$LINENO: WARNING: You need ar to build the library" >&5 -echo "$as_me: WARNING: You need ar to build the library" >&2;} -fi - -# 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_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="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 hunk ./configure 1489 -if test -z "$RANLIB" ; then - { echo "$as_me:$LINENO: WARNING: You need randlib to build the library" >&5 -echo "$as_me: WARNING: You need randlib to build the library" >&2;} -fi +cat >>confdefs.h <<_ACEOF +#define DEBUG 1 +_ACEOF hunk ./configure 1493 -# Extract the first word of "rm", so it can be a program name with args. -set dummy rm; 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_RM+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$RM"; then - ac_cv_prog_RM="$RM" # Let the user override the test. hunk ./configure 1494 -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_RM="rm" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + : +fi; hunk ./configure 1497 -fi -fi -RM=$ac_cv_prog_RM -if test -n "$RM"; then - echo "$as_me:$LINENO: result: $RM" >&5 -echo "${ECHO_T}$RM" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi hunk ./configure 1498 -if test -z "$RM" ; then - { echo "$as_me:$LINENO: WARNING: You need rm!" >&5 -echo "$as_me: WARNING: You need rm!" >&2;} -fi hunk ./configure 2509 + hunk ./configure 2512 -echo "$as_me:$LINENO: checking for arc4random" >&5 -echo $ECHO_N "checking for arc4random... $ECHO_C" >&6 -if test "${ac_cv_func_arc4random+set}" = set; then +for ac_func in arc4random +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then hunk ./configure 2526 -/* Define arc4random to an innocuous variant, in case declares arc4random. +/* Define $ac_func to an innocuous variant, in case declares $ac_func. hunk ./configure 2528 -#define arc4random innocuous_arc4random +#define $ac_func innocuous_$ac_func hunk ./configure 2531 - which can conflict with char arc4random (); below. + which can conflict with char $ac_func (); below. hunk ./configure 2541 -#undef arc4random +#undef $ac_func hunk ./configure 2550 -char arc4random (); +char $ac_func (); hunk ./configure 2554 -#if defined (__stub_arc4random) || defined (__stub___arc4random) +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) hunk ./configure 2557 -char (*f) () = arc4random; +char (*f) () = $ac_func; hunk ./configure 2566 -return f != arc4random; +return f != $ac_func; hunk ./configure 2593 - ac_cv_func_arc4random=yes + eval "$as_ac_var=yes" hunk ./configure 2598 -ac_cv_func_arc4random=no +eval "$as_ac_var=no" hunk ./configure 2603 -echo "$as_me:$LINENO: result: $ac_cv_func_arc4random" >&5 -echo "${ECHO_T}$ac_cv_func_arc4random" >&6 -if test $ac_cv_func_arc4random = yes; then - SYMS="$SYMS -DHAVE_ARC4RANDOM" +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + hunk ./configure 2611 - - +done hunk ./configure 2695 - ac_config_files="$ac_config_files config.mk config.h examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" - + ac_config_files="$ac_config_files config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" hunk ./configure 2770 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then we branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -cat >confdef2opt.sed <<\_ACEOF -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g -t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g -t quote -d -: quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g -s,\[,\\&,g -s,\],\\&,g -s,\$,$$,g -p -_ACEOF -# We use echo to avoid assuming a particular line-breaking character. -# The extra dot is to prevent the shell from consuming trailing -# line-breaks from the sub-command output. A line-break within -# single-quotes doesn't work because, if this script is created in a -# platform that uses two characters for line-breaks (e.g., DOS), tr -# would break. -ac_LF_and_DOT=`echo; echo .` -DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` -rm -f confdef2opt.sed hunk ./configure 2771 +DEFS=-DHAVE_CONFIG_H hunk ./configure 3105 + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE hunk ./configure 3110 + +Configuration headers: +$config_headers hunk ./configure 3223 - "config.h" ) CONFIG_FILES="$CONFIG_FILES config.h" ;; hunk ./configure 3225 + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; hunk ./configure 3238 + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers hunk ./configure 3315 -s,@WHOLE_ARCHIVE_FLAG@,$WHOLE_ARCHIVE_FLAG,;t t -s,@LEADING_UNDERSCORE@,$LEADING_UNDERSCORE,;t t -s,@SYMS@,$SYMS,;t t hunk ./configure 3317 -s,@GHC_LIB_PATH@,$GHC_LIB_PATH,;t t -s,@GHC_VERSION@,$GHC_VERSION,;t t hunk ./configure 3318 -s,@CABAL@,$CABAL,;t t -s,@DEBUG_OPTS@,$DEBUG_OPTS,;t t -s,@GHCPKG@,$GHCPKG,;t t -s,@HADDOCK@,$HADDOCK,;t t -s,@HAPPY@,$HAPPY,;t t -s,@ALEX@,$ALEX,;t t -s,@LD@,$LD,;t t -s,@AR@,$AR,;t t -s,@RANLIB@,$RANLIB,;t t -s,@RM@,$RM,;t t hunk ./configure 3566 + 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 hunk ./configure 3740 + 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; }; }; } hunk ./configure 3784 + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi hunk ./configure.ac 2 -# Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +# Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./configure.ac 5 + +# SUBSTs go into config.mk.in (TOP,PREFIX,GHC,INSTAlL) +# AC_DEFINES go into config.h +# only AC_DEFINES are visible in Haskell src hunk ./configure.ac 11 -AC_INIT(src/plugins/System/Plugins.hs) +AC_INIT(plugins/System/Plugins.hs) + +# Prepare to generate the config.h.in file +AC_CONFIG_HEADERS([config.h]) hunk ./configure.ac 40 + AC_DEFINE_UNQUOTED(MACOSX, [1], [Defined if compiling on the mac]) + LEADING_UNDERSCORE=1 hunk ./configure.ac 45 + LEADING_UNDERSCORE=0 hunk ./configure.ac 48 -if test "$MACOSX" = "yes" -then - WHOLE_ARCHIVE_FLAG=-all_load - LEADING_UNDERSCORE=1 - SYMS="$SYMS -DMACOSX" -else - WHOLE_ARCHIVE_FLAG=--whole-archive - LEADING_UNDERSCORE=0 -fi - -AC_SUBST(WHOLE_ARCHIVE_FLAG) -AC_SUBST(LEADING_UNDERSCORE) hunk ./configure.ac 51 + AC_DEFINE(__MINGW32__,[1],[Defined if compiling with mingw]) hunk ./configure.ac 53 - SYMS="$SYMS -D__MINGW32__" hunk ./configure.ac 54 -AC_SUBST(LEADING_UNDERSCORE) -AC_SUBST(SYMS) hunk ./configure.ac 57 + AC_DEFINE(CYGWIN,[1],[Defined if compiling with mingw]) hunk ./configure.ac 59 - SYMS="$SYMS -DCYGWIN" hunk ./configure.ac 60 -AC_SUBST(LEADING_UNDERSCORE) -AC_SUBST(SYMS) + +AC_DEFINE_UNQUOTED(LEADING_UNDERSCORE, $LEADING_UNDERSCORE, + [Whether symbols are prefixed with a leading underscore]) hunk ./configure.ac 67 + +AC_DEFINE_UNQUOTED(TOP, "$TOP", [Path to top of build tree]) hunk ./configure.ac 87 +AC_DEFINE_UNQUOTED(WITH_GHC, $GHC, [Which ghc to use]) hunk ./configure.ac 89 - -# find path to GHC libs, for runtime_loader -if test -n "$GHC" ; then - AC_MSG_CHECKING([for ghc library directory]) - GHC_LIB_PATH=`$GHC --print-libdir` - AC_MSG_RESULT([$GHC_LIB_PATH]) -fi -AC_SUBST(GHC_LIB_PATH) - -# check ghc version here -if test -n "$GHC" ; then - AC_MSG_CHECKING([for ghc version]) - GHC_VERSION=`$GHC --numeric-version` - AC_MSG_RESULT([$GHC_VERSION]) -fi -AC_SUBST(GHC_VERSION) hunk ./configure.ac 99 - -dnl ** quote char breaks sed -changequote(, )dnl -MAJOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\1/'` -MINOR=`echo "$GHC_VERSION" | sed 's/^\([^\.]*\)\.\([^\.]*\).*/\2/'` -changequote([, ])dnl - -if test "$MAJOR" -lt "6"; then - AC_MSG_ERROR(Found major $MAJOR. You need a ghc version >= 6.2) ; -fi -if test "$MINOR" -lt "2"; then - AC_MSG_ERROR(You need a ghc version >= 6.2) ; -fi - -#Allow plugins to be built with Cabal libraries -AC_ARG_ENABLE(cabal, - [ --enable-cabal Enable use of Cabal packages in pluggable-1-branch - of GHC], - [ CABAL=1 ], - [ CABAL=0 ]) hunk ./configure.ac 100 -# used by the Makefile`s to alter dependencies. -if test "$MAJOR" -ge "6" -a "$MINOR" -ge "4"; then - CABAL=1 +# find path to GHC libs, for runtime_loader +if test -n "$GHC" ; then + AC_MSG_CHECKING([for ghc library directory]) + GHC_LIB_PATH=`$GHC --print-libdir` + AC_MSG_RESULT([$GHC_LIB_PATH]) hunk ./configure.ac 106 - -AC_SUBST(CABAL) +AC_DEFINE_UNQUOTED(GHC_LIB_PATH, "$GHC_LIB_PATH", [Path to ghc libraries]) hunk ./configure.ac 111 - [ DEBUG_OPTS=-DDEBUG ], - [ DEBUG_OPTS= ]) - -AC_SUBST(DEBUG_OPTS) - -# Search for ghc-pkg -AC_MSG_CHECKING([for ghc-pkg]) -ghc_pkg_guess=`echo $GHC | sed 's,ghc\(@<:@^/\\@:>@*\)$,ghc-pkg\1,'` -if "$ghc_pkg_guess" -l > /dev/null 2>&1; then - matching_ghc_pkg=$ghc_pkg_guess -else - matching_ghc_pkg=no -fi -if test x"$matching_ghc_pkg" = xno; then - AC_CHECK_PROG([GHCPKG], [ghc-pkg]) - if test -z "$GHCPKG" ; then - AC_MSG_ERROR([ghc-pkg not found.]) - fi -else - GHCPKG=$matching_ghc_pkg -fi -AC_MSG_RESULT([$GHCPKG]) -AC_SUBST(GHCPKG) - -AC_CHECK_PROG(HADDOCK,haddock,haddock) -if test -z "$HADDOCK" ; then - AC_MSG_WARN(You need Haddock if you want developer documentation) -fi - -AC_CHECK_PROG(HAPPY,happy,happy) -if test -z "$HAPPY" ; then - AC_MSG_WARN(If you change or remove the parser you'll need Happy) -fi - -AC_CHECK_PROG(ALEX,alex,alex) -if test -z "$ALEX" ; then - AC_MSG_WARN(If you change or remove the lexer files you'll need alex) -fi - -AC_CHECK_PROG(LD,ld,ld) -if test -z "$LD" ; then - AC_MSG_WARN(You need ld -export-dynamic) -fi - -AC_CHECK_PROG(AR,ar,ar) -if test -z "$AR" ; then - AC_MSG_WARN(You need ar to build the library) -fi + [ AC_DEFINE_UNQUOTED(DEBUG, [1], [Defined if a debugging version is to be built]) ], + [ : ]) hunk ./configure.ac 114 -AC_CHECK_PROG(RANLIB,ranlib,ranlib) -if test -z "$RANLIB" ; then - AC_MSG_WARN(You need randlib to build the library) -fi hunk ./configure.ac 115 -AC_CHECK_PROG(RM,rm,rm) -if test -z "$RM" ; then - AC_MSG_WARN(You need rm!) -fi hunk ./configure.ac 125 - -AC_CHECK_FUNC(arc4random, [SYMS="$SYMS -DHAVE_ARC4RANDOM"]) hunk ./configure.ac 126 -AC_SUBST(SYMS) +AC_CHECK_FUNCS(arc4random) hunk ./configure.ac 131 -AC_CONFIG_FILES(config.mk config.h examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf) - +AC_CONFIG_FILES([config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) hunk ./examples/build.mk 16 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package plugins hunk ./examples/conf/simple/prog/Main.hs 11 + print status + return () +{- hunk ./examples/conf/simple/prog/Main.hs 26 +-} hunk ./examples/dynload/io/prog/Main.hs 7 - ["../../../../plugins.conf.inplace"] "resource_dyn" + [] "resource_dyn" hunk ./examples/dynload/poly/prog/Main.hs 10 - ["../../../../plugins.conf.inplace"] + [] hunk ./examples/dynload/should_fail/prog/Main.hs 8 - ["../../../../plugins.conf.inplace"] + [] hunk ./examples/dynload/should_fail_1/prog/Main.hs 7 - ["../../../../plugins.conf.inplace"] "resource_dyn" + [] "resource_dyn" hunk ./examples/dynload/simple/prog/Main.hs 10 - ["../../../../plugins.conf.inplace"] + [] hunk ./examples/eval.mk 4 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package plugins - hunk ./examples/foreign.mk 6 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace -package plugins hunk ./plugins/Language/Hi/Parser.hs 51 - -#include "../../../../config.h" +#include "../../../config.h" hunk ./plugins/System/Eval/Utils.hs 31 - find_altdata_pkgconf, hunk ./plugins/System/Eval/Utils.hs 42 -import System.Plugins.Consts ( top {- :{ -} ) hunk ./plugins/System/Eval/Utils.hs 75 - m_pkg <- find_altdata_pkgconf - let load_path = if isJust m_pkg then fromJust m_pkg else [] - let make_line = - let compulsory = ["-Onot","-fglasgow-exts","-package","altdata"] - in if not $ null load_path - then "-package-conf":load_path:compulsory - else compulsory - let load_path' = if null load_path then [] else [load_path] - return (make_line,load_path') - --- --------------------------------------------------------------------- --- if we are in-tree eval() needs to use the inplace package.conf to --- find altdata, otherwise we need it to be in the ghc package system. --- --- fixing Typeable/Dynamic in ghc obsoletes this code. as would adding --- an extra param to eval, which I don't want to do. --- -find_altdata_pkgconf :: IO (Maybe String) -find_altdata_pkgconf = do - let f = top "plugins.conf.inplace" - b <- doesFileExist f - return $ if b - then Just f - else Nothing + let make_line = ["-Onot","-fglasgow-exts","-package","plugins"] + return (make_line,[]) hunk ./plugins/System/Plugins/Consts.hs 23 -#include "../../../../config.h" +#include "../../../config.h" hunk ./plugins/System/Plugins/Consts.hs 36 -ghc = GHC +ghc = WITH_GHC hunk ./plugins/System/Plugins/Env.hs 49 -#include "../../../../config.h" +#include "../../../config.h" hunk ./plugins/System/Plugins/Load.hs 53 +#include "../../../config.h" + hunk ./plugins/System/Plugins/PackageAPI.hs 40 -#include "../../../../config.h" +#include "../../../config.h" hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 1 -{-# OPTIONS -fglasgow-exts -cpp -w #-} --- parser produced by Happy Version 1.14 - - +{-# OPTIONS -fglasgow-exts -cpp #-} +{-# OPTIONS -w #-} hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 18 + +-- parser produced by Happy Version 1.15 hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 254 -happyReduce_16 = happyMonadReduce 1# 7# happyReduction_16 -happyReduction_16 (happy_x_1 `HappyStk` - happyRest) - = happyThen (case happyOutTok happy_x_1 of { (ITconid happy_var_1) -> - case happy_var_1 of { +happyReduce_16 = happySpecReduce_1 7# happyReduction_16 +happyReduction_16 happy_x_1 + = case happyOutTok happy_x_1 of { (ITconid happy_var_1) -> + happyIn12 + ( case happy_var_1 of { hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 261 - _ -> error ("unknown constructor in config file: " ++ happy_var_1) }} - ) (\r -> happyReturn (happyIn12 r)) + _ -> error ("unknown constructor in config file: " ++ happy_var_1) } + )} hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 279 - _ -> happyError tks + _ -> happyError' (tk:tks) hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 281 + +happyError_ tk tks = happyError' (tk:tks) + +newtype HappyIdentity a = HappyIdentity a +happyIdentity = HappyIdentity +happyRunIdentity (HappyIdentity a) = a + +instance Monad HappyIdentity where + return = HappyIdentity + (HappyIdentity p) >>= q = q p hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 292 -happyThen = \m k -> k m -happyReturn = \a -> a -happyThen1 = happyThen -happyReturn1 = \a tks -> a +happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b +happyThen = (>>=) +happyReturn :: () => a -> HappyIdentity a +happyReturn = (return) +happyThen1 m k tks = (>>=) m (\a -> k a tks) +happyReturn1 :: () => a -> b -> HappyIdentity a +happyReturn1 = \a tks -> (return) a +happyError' :: () => [Token] -> HappyIdentity a +happyError' = HappyIdentity . happyError hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 302 -parse tks = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) +parse tks = happyRunIdentity happySomeParser where + happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 305 -parseOne tks = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) +parseOne tks = happyRunIdentity happySomeParser where + happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 392 - -happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j (happyTcHack st)) hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 393 - (happyReturn1 ans) +-- If the current token is 0#, it means we've just accepted a partial +-- parse (a %partial parser). We must ignore the saved token on the top of +-- the stack in this case. +happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = + happyReturn1 ans +happyAccept j tk st sts (HappyStk ans _) = + (happyTcHack j (happyTcHack st)) (happyReturn1 ans) hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 472 -{-# LINE 166 "GenericTemplate.hs" #-} +{-# LINE 170 "GenericTemplate.hs" #-} hunk ./plugins/System/Plugins/ParsePkgConfLite.hs 551 - happyError - + happyError_ tk hunk ./plugins/System/Plugins/Utils.hs 21 -#include "../../../../config.h" - hunk ./plugins/System/Plugins/Utils.hs 60 + +#include "../../../config.h" addfile ./happy.sh hunk ./happy.sh 1 +#!/bin/sh +happy -a -g -c $* addfile ./plugins/Setup.hs hunk ./plugins/Setup.hs 1 +import Distribution.Simple +main = defaultMain addfile ./plugins/plugins.cabal hunk ./plugins/plugins.cabal 1 +name: plugins +version: 0.9.10 +license: LGPL +License-file: LICENSE +author: Don Stewart +maintainer: dons@cse.unsw.edu.au +exposed-modules: + AltData.Dynamic, + AltData.Typeable, + Language.Hi.Binary, + Language.Hi.FastMutInt, + Language.Hi.FastString, + Language.Hi.Parser, + Language.Hi.PrimPacked, + Language.Hi.Syntax, + System.Eval, + System.Eval.Haskell, + System.Eval.Utils, + System.MkTemp, + System.Plugins, + System.Plugins.Consts, + System.Plugins.Env, + System.Plugins.Load, + System.Plugins.LoadTypes, + System.Plugins.Make, + System.Plugins.Package, + System.Plugins.PackageAPI, + System.Plugins.ParsePkgConfCabal, + System.Plugins.Parser, + System.Plugins.Utils +c-sources: + Language/Hi/hschooks.c +includes: Linker.h +Build-Depends: haskell-src-exts>=0.2, Cabal +ghc-options: -Wall -Werror -O -fno-warn-missing-signatures -threaded -funbox-strict-fields + move ./plugins ./src hunk ./Makefile 11 - cd plugins ;\ + cd src ;\ hunk ./Makefile 17 - cp plugins/System/Eval/Haskell_stub.h $@ + cp src/System/Eval/Haskell_stub.h $@ hunk ./Makefile 29 - cd plugins && ./setup install + cd src && ./setup install hunk ./Makefile 58 - cd plugins && ./setup clean 2> /dev/null || true - cd plugins && rm -rf dist Setup.hi Setup.o setup + cd src && ./setup clean 2> /dev/null || true + cd src && rm -rf dist Setup.hi Setup.o setup hunk ./configure 274 -ac_unique_file="plugins/System/Plugins.hs" +ac_unique_file="src/System/Plugins.hs" hunk ./configure.ac 11 -AC_INIT(plugins/System/Plugins.hs) +AC_INIT(src/System/Plugins.hs) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 1 -{-# OPTIONS -fglasgow-exts -cpp -w #-} --- parser produced by Happy Version 1.14 - - +{-# OPTIONS -fglasgow-exts -cpp #-} +{-# OPTIONS -w #-} hunk ./src/System/Plugins/ParsePkgConfCabal.hs 20 + +-- parser produced by Happy Version 1.15 hunk ./src/System/Plugins/ParsePkgConfCabal.hs 449 - _ -> happyError tks + _ -> happyError' (tk:tks) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 451 + +happyError_ tk tks = happyError' (tk:tks) + +newtype HappyIdentity a = HappyIdentity a +happyIdentity = HappyIdentity +happyRunIdentity (HappyIdentity a) = a + +instance Monad HappyIdentity where + return = HappyIdentity + (HappyIdentity p) >>= q = q p hunk ./src/System/Plugins/ParsePkgConfCabal.hs 462 -happyThen = \m k -> k m -happyReturn = \a -> a -happyThen1 = happyThen -happyReturn1 = \a tks -> a +happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b +happyThen = (>>=) +happyReturn :: () => a -> HappyIdentity a +happyReturn = (return) +happyThen1 m k tks = (>>=) m (\a -> k a tks) +happyReturn1 :: () => a -> b -> HappyIdentity a +happyReturn1 = \a tks -> (return) a +happyError' :: () => [Token] -> HappyIdentity a +happyError' = HappyIdentity . happyError hunk ./src/System/Plugins/ParsePkgConfCabal.hs 472 -parse tks = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) +parse tks = happyRunIdentity happySomeParser where + happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 475 -parseOne tks = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) +parseOne tks = happyRunIdentity happySomeParser where + happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 572 - -happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j (happyTcHack st)) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 573 - (happyReturn1 ans) +-- If the current token is 0#, it means we've just accepted a partial +-- parse (a %partial parser). We must ignore the saved token on the top of +-- the stack in this case. +happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = + happyReturn1 ans +happyAccept j tk st sts (HappyStk ans _) = + (happyTcHack j (happyTcHack st)) (happyReturn1 ans) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 652 -{-# LINE 166 "GenericTemplate.hs" #-} +{-# LINE 170 "GenericTemplate.hs" #-} hunk ./src/System/Plugins/ParsePkgConfCabal.hs 731 - happyError - + happyError_ tk hunk ./Makefile 13 - ./setup configure --prefix=$(PREFIX) --with-happy=$(TOP)/happy.sh ;\ + ./setup configure --prefix=$(PREFIX) ;\ hunk ./happy.sh 1 -#!/bin/sh -happy -a -g -c $* rmfile ./happy.sh hunk ./src/plugins.cabal 30 + System.Plugins.Process, hunk ./src/plugins.cabal 36 -ghc-options: -Wall -Werror -O -fno-warn-missing-signatures -threaded -funbox-strict-fields +ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures -threaded hunk ./src/System/Plugins/ParsePkgConfCabal.hs 1 -{-# OPTIONS -fglasgow-exts -cpp #-} -{-# OPTIONS -w #-} - -module System.Plugins.ParsePkgConfCabal ( - parsePkgConf, parseOnePkgConf - ) where - -import Distribution.InstalledPackageInfo -import Distribution.Package -import Distribution.Version - -import Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) -import List ( break ) -import Array -#if __GLASGOW_HASKELL__ >= 503 -import GHC.Exts -#else -import GlaExts -#endif - --- parser produced by Happy Version 1.15 - -newtype HappyAbsSyn = HappyAbsSyn (() -> ()) -happyIn5 :: ([ PackageConfig ]) -> (HappyAbsSyn ) -happyIn5 x = unsafeCoerce# x -{-# INLINE happyIn5 #-} -happyOut5 :: (HappyAbsSyn ) -> ([ PackageConfig ]) -happyOut5 x = unsafeCoerce# x -{-# INLINE happyOut5 #-} -happyIn6 :: ([ PackageConfig ]) -> (HappyAbsSyn ) -happyIn6 x = unsafeCoerce# x -{-# INLINE happyIn6 #-} -happyOut6 :: (HappyAbsSyn ) -> ([ PackageConfig ]) -happyOut6 x = unsafeCoerce# x -{-# INLINE happyOut6 #-} -happyIn7 :: (PackageConfig) -> (HappyAbsSyn ) -happyIn7 x = unsafeCoerce# x -{-# INLINE happyIn7 #-} -happyOut7 :: (HappyAbsSyn ) -> (PackageConfig) -happyOut7 x = unsafeCoerce# x -{-# INLINE happyOut7 #-} -happyIn8 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) -happyIn8 x = unsafeCoerce# x -{-# INLINE happyIn8 #-} -happyOut8 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) -happyOut8 x = unsafeCoerce# x -{-# INLINE happyOut8 #-} -happyIn9 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) -happyIn9 x = unsafeCoerce# x -{-# INLINE happyIn9 #-} -happyOut9 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) -happyOut9 x = unsafeCoerce# x -{-# INLINE happyOut9 #-} -happyIn10 :: (PackageIdentifier) -> (HappyAbsSyn ) -happyIn10 x = unsafeCoerce# x -{-# INLINE happyIn10 #-} -happyOut10 :: (HappyAbsSyn ) -> (PackageIdentifier) -happyOut10 x = unsafeCoerce# x -{-# INLINE happyOut10 #-} -happyIn11 :: (Version) -> (HappyAbsSyn ) -happyIn11 x = unsafeCoerce# x -{-# INLINE happyIn11 #-} -happyOut11 :: (HappyAbsSyn ) -> (Version) -happyOut11 x = unsafeCoerce# x -{-# INLINE happyOut11 #-} -happyIn12 :: ([PackageIdentifier]) -> (HappyAbsSyn ) -happyIn12 x = unsafeCoerce# x -{-# INLINE happyIn12 #-} -happyOut12 :: (HappyAbsSyn ) -> ([PackageIdentifier]) -happyOut12 x = unsafeCoerce# x -{-# INLINE happyOut12 #-} -happyIn13 :: ([PackageIdentifier]) -> (HappyAbsSyn ) -happyIn13 x = unsafeCoerce# x -{-# INLINE happyIn13 #-} -happyOut13 :: (HappyAbsSyn ) -> ([PackageIdentifier]) -happyOut13 x = unsafeCoerce# x -{-# INLINE happyOut13 #-} -happyIn14 :: ([Int]) -> (HappyAbsSyn ) -happyIn14 x = unsafeCoerce# x -{-# INLINE happyIn14 #-} -happyOut14 :: (HappyAbsSyn ) -> ([Int]) -happyOut14 x = unsafeCoerce# x -{-# INLINE happyOut14 #-} -happyIn15 :: ([Int]) -> (HappyAbsSyn ) -happyIn15 x = unsafeCoerce# x -{-# INLINE happyIn15 #-} -happyOut15 :: (HappyAbsSyn ) -> ([Int]) -happyOut15 x = unsafeCoerce# x -{-# INLINE happyOut15 #-} -happyIn16 :: ([String]) -> (HappyAbsSyn ) -happyIn16 x = unsafeCoerce# x -{-# INLINE happyIn16 #-} -happyOut16 :: (HappyAbsSyn ) -> ([String]) -happyOut16 x = unsafeCoerce# x -{-# INLINE happyOut16 #-} -happyIn17 :: ([String]) -> (HappyAbsSyn ) -happyIn17 x = unsafeCoerce# x -{-# INLINE happyIn17 #-} -happyOut17 :: (HappyAbsSyn ) -> ([String]) -happyOut17 x = unsafeCoerce# x -{-# INLINE happyOut17 #-} -happyInTok :: Token -> (HappyAbsSyn ) -happyInTok x = unsafeCoerce# x -{-# INLINE happyInTok #-} -happyOutTok :: (HappyAbsSyn ) -> Token -happyOutTok x = unsafeCoerce# x -{-# INLINE happyOutTok #-} - -happyActOffsets :: HappyAddr -happyActOffsets = HappyA# "\x50\x00\x4a\x00\x4c\x00\x49\x00\x46\x00\x4b\x00\x45\x00\x0a\x00\x1e\x00\x00\x00\x00\x00\x44\x00\x16\x00\x00\x00\x43\x00\x00\x00\x42\x00\x00\x00\x03\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x01\x00\x00\x00\x40\x00\x00\x00\x3e\x00\x3d\x00\x1c\x00\x00\x00\x3f\x00\x00\x00\x00\x00\x3b\x00\x00\x00\x3a\x00\x39\x00\x35\x00\x00\x00\x00\x00\x38\x00\x31\x00\x34\x00\x33\x00\x37\x00\x36\x00\x28\x00\x00\x00\x30\x00\x32\x00\x2f\x00\x09\x00\x2d\x00\x00\x00\x2e\x00\x26\x00\x2c\x00\x22\x00\x00\x00\x00\x00\x2b\x00\x29\x00\x0d\x00\x00\x00\x00\x00"# - -happyGotoOffsets :: HappyAddr -happyGotoOffsets = HappyA# "\x2a\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\xfe\xff\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x04\x00\x00\x00\xfb\xff\x00\x00\x00\x00"# - -happyDefActions :: HappyAddr -happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xfd\xff\x00\x00\x00\x00\xf8\xff\x00\x00\xfc\xff\x00\x00\xfa\xff\x00\x00\xf9\xff\x00\x00\xf7\xff\xf6\xff\xf1\xff\xf2\xff\x00\x00\xf4\xff\xf5\xff\x00\x00\xf3\xff\xed\xff\x00\x00\x00\x00\xe7\xff\x00\x00\xe5\xff\xe6\xff\x00\x00\xee\xff\x00\x00\x00\x00\x00\x00\xec\xff\xe4\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xeb\xff\xe9\xff\x00\x00\x00\x00\x00\x00\xea\xff\xe8\xff\x00\x00\x00\x00\x00\x00\xef\xff"# - -happyCheck :: HappyAddr -happyCheck = HappyA# "\xff\xff\x05\x00\x01\x00\x05\x00\x08\x00\x07\x00\x03\x00\x0c\x00\x0c\x00\x0b\x00\x09\x00\x08\x00\x09\x00\x04\x00\x04\x00\x0b\x00\x04\x00\x04\x00\x08\x00\x0a\x00\x08\x00\x09\x00\x09\x00\x05\x00\x02\x00\x0a\x00\x08\x00\x05\x00\x03\x00\x04\x00\x01\x00\x02\x00\x04\x00\x05\x00\x04\x00\x05\x00\x0a\x00\x04\x00\x06\x00\x02\x00\x09\x00\x02\x00\x00\x00\x02\x00\x0a\x00\x07\x00\x03\x00\x07\x00\xff\xff\x04\x00\x06\x00\x05\x00\x05\x00\x03\x00\x06\x00\x01\x00\x07\x00\x02\x00\x06\x00\x08\x00\xff\xff\x05\x00\x09\x00\x06\x00\x01\x00\x04\x00\x08\x00\x05\x00\x09\x00\xff\xff\xff\xff\x07\x00\x07\x00\x06\x00\x08\x00\x07\x00\x01\x00\x04\x00\xff\xff\x03\x00\x0b\x00\x0b\x00\x08\x00\x03\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# - -happyTable :: HappyAddr -happyTable = HappyA# "\x00\x00\x1e\x00\x1d\x00\x16\x00\x1f\x00\x17\x00\x1a\x00\x20\x00\x20\x00\x18\x00\x1e\x00\x1b\x00\x1c\x00\x3a\x00\x0b\x00\x41\x00\x22\x00\x22\x00\x06\x00\x3b\x00\x23\x00\x24\x00\x24\x00\x1e\x00\x14\x00\x3f\x00\x2a\x00\x15\x00\x0c\x00\x0d\x00\x08\x00\x09\x00\x25\x00\x26\x00\x10\x00\x11\x00\x38\x00\x15\x00\x30\x00\x11\x00\x36\x00\x04\x00\x06\x00\x44\x00\x3b\x00\x3d\x00\x43\x00\x35\x00\x00\x00\x3f\x00\x41\x00\x3e\x00\x3c\x00\x38\x00\x36\x00\x33\x00\x2f\x00\x34\x00\x30\x00\x32\x00\x00\x00\x2e\x00\x2d\x00\x2a\x00\x1d\x00\x27\x00\x23\x00\x28\x00\x2c\x00\x00\x00\x00\x00\x29\x00\x0f\x00\x13\x00\x06\x00\x0f\x00\x0c\x00\x0b\x00\x00\x00\x04\x00\xff\xff\xff\xff\x06\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# - -happyReduceArr = array (2, 27) [ - (2 , happyReduce_2), - (3 , happyReduce_3), - (4 , happyReduce_4), - (5 , happyReduce_5), - (6 , happyReduce_6), - (7 , happyReduce_7), - (8 , happyReduce_8), - (9 , happyReduce_9), - (10 , happyReduce_10), - (11 , happyReduce_11), - (12 , happyReduce_12), - (13 , happyReduce_13), - (14 , happyReduce_14), - (15 , happyReduce_15), - (16 , happyReduce_16), - (17 , happyReduce_17), - (18 , happyReduce_18), - (19 , happyReduce_19), - (20 , happyReduce_20), - (21 , happyReduce_21), - (22 , happyReduce_22), - (23 , happyReduce_23), - (24 , happyReduce_24), - (25 , happyReduce_25), - (26 , happyReduce_26), - (27 , happyReduce_27) - ] - -happy_n_terms = 12 :: Int -happy_n_nonterms = 13 :: Int - -happyReduce_2 = happySpecReduce_2 0# happyReduction_2 -happyReduction_2 happy_x_2 - happy_x_1 - = happyIn5 - ([] - ) - -happyReduce_3 = happySpecReduce_3 0# happyReduction_3 -happyReduction_3 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut6 happy_x_2 of { happy_var_2 -> - happyIn5 - (reverse happy_var_2 - )} - -happyReduce_4 = happySpecReduce_1 1# happyReduction_4 -happyReduction_4 happy_x_1 - = case happyOut7 happy_x_1 of { happy_var_1 -> - happyIn6 - ([ happy_var_1 ] - )} - -happyReduce_5 = happySpecReduce_3 1# happyReduction_5 -happyReduction_5 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut6 happy_x_1 of { happy_var_1 -> - case happyOut7 happy_x_3 of { happy_var_3 -> - happyIn6 - (happy_var_3 : happy_var_1 - )}} - -happyReduce_6 = happyReduce 4# 2# happyReduction_6 -happyReduction_6 (happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut8 happy_x_3 of { happy_var_3 -> - happyIn7 - (happy_var_3 defaultPackageConfig - ) `HappyStk` happyRest} - -happyReduce_7 = happySpecReduce_1 3# happyReduction_7 -happyReduction_7 happy_x_1 - = case happyOut9 happy_x_1 of { happy_var_1 -> - happyIn8 - (\p -> happy_var_1 p - )} - -happyReduce_8 = happySpecReduce_3 3# happyReduction_8 -happyReduction_8 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut8 happy_x_1 of { happy_var_1 -> - case happyOut9 happy_x_3 of { happy_var_3 -> - happyIn8 - (\p -> happy_var_1 (happy_var_3 p) - )}} - -happyReduce_9 = happySpecReduce_3 4# happyReduction_9 -happyReduction_9 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut10 happy_x_3 of { happy_var_3 -> - happyIn9 - (\p -> case happy_var_1 of - "package" -> p {package = happy_var_3} - _ -> error "unknown key in config file" - )}} - -happyReduce_10 = happySpecReduce_3 4# happyReduction_10 -happyReduction_10 happy_x_3 - happy_x_2 - happy_x_1 - = happyIn9 - (id - ) - -happyReduce_11 = happySpecReduce_3 4# happyReduction_11 -happyReduction_11 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOutTok happy_x_3 of { (ITconid happy_var_3) -> - happyIn9 - (case happy_var_1 of { - "exposed" -> - case happy_var_3 of { - "True" -> (\p -> p {exposed=True}); - "False" -> (\p -> p {exposed=False}); - _ -> error "exposed must be either True or False" }; - "license" -> id; -- not interested - _ -> error "unknown constructor" } - )}} - -happyReduce_12 = happyReduce 4# 4# happyReduction_12 -happyReduction_12 (happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = happyIn9 - (id - ) `HappyStk` happyRest - -happyReduce_13 = happySpecReduce_3 4# happyReduction_13 -happyReduction_13 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut16 happy_x_3 of { happy_var_3 -> - happyIn9 - (\p -> case happy_var_1 of - "exposedModules" -> p{exposedModules = happy_var_3} - "hiddenModules" -> p{hiddenModules = happy_var_3} - "importDirs" -> p{importDirs = happy_var_3} - "libraryDirs" -> p{libraryDirs = happy_var_3} - "hsLibraries" -> p{hsLibraries = happy_var_3} - "extraLibraries" -> p{extraLibraries = happy_var_3} - "includeDirs" -> p{includeDirs = happy_var_3} - "includes" -> p{includes = happy_var_3} - "hugsOptions" -> p{hugsOptions = happy_var_3} - "ccOptions" -> p{ccOptions = happy_var_3} - "ldOptions" -> p{ldOptions = happy_var_3} - "frameworkDirs" -> p{frameworkDirs = happy_var_3} - "frameworks" -> p{frameworks = happy_var_3} - "haddockInterfaces" -> p{haddockInterfaces = happy_var_3} - "haddockHTMLs" -> p{haddockHTMLs = happy_var_3} - "depends" -> p{depends = []} - -- empty list only, non-empty handled below - other -> p - )}} - -happyReduce_14 = happySpecReduce_3 4# happyReduction_14 -happyReduction_14 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut12 happy_x_3 of { happy_var_3 -> - happyIn9 - (case happy_var_1 of - "depends" -> (\p -> p{depends = happy_var_3}) - _other -> error "unknown key in config file" - )}} - -happyReduce_15 = happyReduce 10# 5# happyReduction_15 -happyReduction_15 (happy_x_10 `HappyStk` - happy_x_9 `HappyStk` - happy_x_8 `HappyStk` - happy_x_7 `HappyStk` - happy_x_6 `HappyStk` - happy_x_5 `HappyStk` - happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOutTok happy_x_5 of { (ITstring happy_var_5) -> - case happyOut11 happy_x_9 of { happy_var_9 -> - happyIn10 - (PackageIdentifier{ pkgName = happy_var_5, - pkgVersion = happy_var_9 } - ) `HappyStk` happyRest}} - -happyReduce_16 = happyReduce 10# 6# happyReduction_16 -happyReduction_16 (happy_x_10 `HappyStk` - happy_x_9 `HappyStk` - happy_x_8 `HappyStk` - happy_x_7 `HappyStk` - happy_x_6 `HappyStk` - happy_x_5 `HappyStk` - happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut14 happy_x_5 of { happy_var_5 -> - case happyOut16 happy_x_9 of { happy_var_9 -> - happyIn11 - (Version{ versionBranch=happy_var_5, versionTags=happy_var_9 } - ) `HappyStk` happyRest}} - -happyReduce_17 = happySpecReduce_3 7# happyReduction_17 -happyReduction_17 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut13 happy_x_2 of { happy_var_2 -> - happyIn12 - (happy_var_2 - )} - -happyReduce_18 = happySpecReduce_1 8# happyReduction_18 -happyReduction_18 happy_x_1 - = case happyOut10 happy_x_1 of { happy_var_1 -> - happyIn13 - ([ happy_var_1 ] - )} - -happyReduce_19 = happySpecReduce_3 8# happyReduction_19 -happyReduction_19 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut10 happy_x_1 of { happy_var_1 -> - case happyOut13 happy_x_3 of { happy_var_3 -> - happyIn13 - (happy_var_1 : happy_var_3 - )}} - -happyReduce_20 = happySpecReduce_2 9# happyReduction_20 -happyReduction_20 happy_x_2 - happy_x_1 - = happyIn14 - ([] - ) - -happyReduce_21 = happySpecReduce_3 9# happyReduction_21 -happyReduction_21 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut15 happy_x_2 of { happy_var_2 -> - happyIn14 - (happy_var_2 - )} - -happyReduce_22 = happySpecReduce_1 10# happyReduction_22 -happyReduction_22 happy_x_1 - = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> - happyIn15 - ([ fromIntegral happy_var_1 ] - )} - -happyReduce_23 = happySpecReduce_3 10# happyReduction_23 -happyReduction_23 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> - case happyOut15 happy_x_3 of { happy_var_3 -> - happyIn15 - (fromIntegral happy_var_1 : happy_var_3 - )}} - -happyReduce_24 = happySpecReduce_2 11# happyReduction_24 -happyReduction_24 happy_x_2 - happy_x_1 - = happyIn16 - ([] - ) - -happyReduce_25 = happySpecReduce_3 11# happyReduction_25 -happyReduction_25 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut17 happy_x_2 of { happy_var_2 -> - happyIn16 - (reverse happy_var_2 - )} - -happyReduce_26 = happySpecReduce_1 12# happyReduction_26 -happyReduction_26 happy_x_1 - = case happyOutTok happy_x_1 of { (ITstring happy_var_1) -> - happyIn17 - ([ happy_var_1 ] - )} - -happyReduce_27 = happySpecReduce_3 12# happyReduction_27 -happyReduction_27 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut17 happy_x_1 of { happy_var_1 -> - case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> - happyIn17 - (happy_var_3 : happy_var_1 - )}} - -happyNewToken action sts stk [] = - happyDoAction 11# (error "reading EOF!") action sts stk [] - -happyNewToken action sts stk (tk:tks) = - let cont i = happyDoAction i tk action sts stk tks in - case tk of { - ITocurly -> cont 1#; - ITccurly -> cont 2#; - ITobrack -> cont 3#; - ITcbrack -> cont 4#; - ITcomma -> cont 5#; - ITequal -> cont 6#; - ITvarid happy_dollar_dollar -> cont 7#; - ITconid happy_dollar_dollar -> cont 8#; - ITstring happy_dollar_dollar -> cont 9#; - ITinteger happy_dollar_dollar -> cont 10#; - _ -> happyError' (tk:tks) - } - -happyError_ tk tks = happyError' (tk:tks) - -newtype HappyIdentity a = HappyIdentity a -happyIdentity = HappyIdentity -happyRunIdentity (HappyIdentity a) = a - -instance Monad HappyIdentity where - return = HappyIdentity - (HappyIdentity p) >>= q = q p - -happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b -happyThen = (>>=) -happyReturn :: () => a -> HappyIdentity a -happyReturn = (return) -happyThen1 m k tks = (>>=) m (\a -> k a tks) -happyReturn1 :: () => a -> b -> HappyIdentity a -happyReturn1 = \a tks -> (return) a -happyError' :: () => [Token] -> HappyIdentity a -happyError' = HappyIdentity . happyError - -parse tks = happyRunIdentity happySomeParser where - happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) - -parseOne tks = happyRunIdentity happySomeParser where - happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) - -happySeq = happyDontSeq - -type PackageConfig = InstalledPackageInfo - -defaultPackageConfig = emptyInstalledPackageInfo - -data Token - = ITocurly - | ITccurly - | ITobrack - | ITcbrack - | ITcomma - | ITequal - | ITvarid String - | ITconid String - | ITstring String - | ITinteger Int - -lexer :: String -> [Token] - -lexer [] = [] -lexer ('{':cs) = ITocurly : lexer cs -lexer ('}':cs) = ITccurly : lexer cs -lexer ('[':cs) = ITobrack : lexer cs -lexer (']':cs) = ITcbrack : lexer cs -lexer (',':cs) = ITcomma : lexer cs -lexer ('=':cs) = ITequal : lexer cs -lexer ('"':cs) = lexString cs "" -lexer (c:cs) - | isSpace c = lexer cs - | isAlpha c = lexID (c:cs) - | isDigit c = lexInt (c:cs) -lexer _ = error ( "Unexpected token") - -lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest - where - (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs - -lexInt cs = let (intStr, rest) = span isDigit cs - in ITinteger (read intStr) : lexer rest - - -lexString ('"':cs) s = ITstring (reverse s) : lexer cs -lexString ('\\':c:cs) s = lexString cs (c:s) -lexString (c:cs) s = lexString cs (c:s) - -happyError _ = error "Couldn't parse package configuration." - -parsePkgConf :: String -> [PackageConfig] -parsePkgConf = parse . lexer - -parseOnePkgConf :: String -> PackageConfig -parseOnePkgConf = parseOne . lexer -{-# LINE 1 "GenericTemplate.hs" #-} -{-# LINE 1 "" #-} -{-# LINE 1 "" #-} -{-# LINE 1 "GenericTemplate.hs" #-} --- $Id$ - - -{-# LINE 28 "GenericTemplate.hs" #-} - - -data Happy_IntList = HappyCons Int# Happy_IntList - - - - - - -{-# LINE 49 "GenericTemplate.hs" #-} - - -{-# LINE 59 "GenericTemplate.hs" #-} - - - - - - - - - - -infixr 9 `HappyStk` -data HappyStk a = HappyStk a (HappyStk a) - ------------------------------------------------------------------------------ --- starting the parse - -happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll - ------------------------------------------------------------------------------ --- Accepting the parse - --- If the current token is 0#, it means we've just accepted a partial --- parse (a %partial parser). We must ignore the saved token on the top of --- the stack in this case. -happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = - happyReturn1 ans -happyAccept j tk st sts (HappyStk ans _) = - (happyTcHack j (happyTcHack st)) (happyReturn1 ans) - ------------------------------------------------------------------------------ --- Arrays only: do the next action - - - -happyDoAction i tk st - = {- nothing -} - - - case action of - 0# -> {- nothing -} - happyFail i tk st - -1# -> {- nothing -} - happyAccept i tk st - n | (n <# (0# :: Int#)) -> {- nothing -} - - (happyReduceArr ! rule) i tk st - where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) - n -> {- nothing -} - - - happyShift new_state i tk st - where new_state = (n -# (1# :: Int#)) - where off = indexShortOffAddr happyActOffsets st - off_i = (off +# i) - check = if (off_i >=# (0# :: Int#)) - then (indexShortOffAddr happyCheck off_i ==# i) - else False - action | check = indexShortOffAddr happyTable off_i - | otherwise = indexShortOffAddr happyDefActions st - - - - - - - - - - - -indexShortOffAddr (HappyA# arr) off = -#if __GLASGOW_HASKELL__ > 500 - narrow16Int# i -#elif __GLASGOW_HASKELL__ == 500 - intToInt16# i -#else - (i `iShiftL#` 16#) `iShiftRA#` 16# -#endif - where -#if __GLASGOW_HASKELL__ >= 503 - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) -#else - i = word2Int# ((high `shiftL#` 8#) `or#` low) -#endif - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# - - - - - -data HappyAddr = HappyA# Addr# - - - - ------------------------------------------------------------------------------ --- HappyState data type (not arrays) - -{-# LINE 170 "GenericTemplate.hs" #-} - ------------------------------------------------------------------------------ --- Shifting a token - -happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = - let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in --- trace "shifting the error token" $ - happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) - -happyShift new_state i tk st sts stk = - happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) - --- happyReduce is specialised for the common cases. - -happySpecReduce_0 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_0 nt fn j tk st@((action)) sts stk - = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) - -happySpecReduce_1 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') - = let r = fn v1 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_2 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') - = let r = fn v1 v2 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_3 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') - = let r = fn v1 v2 v3 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happyReduce k i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyReduce k nt fn j tk st sts stk - = case happyDrop (k -# (1# :: Int#)) sts of - sts1@((HappyCons (st1@(action)) (_))) -> - let r = fn stk in -- it doesn't hurt to always seq here... - happyDoSeq r (happyGoto nt j tk st1 sts1 r) - -happyMonadReduce k nt fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyMonadReduce k nt fn j tk st sts stk = - happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) - where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) - drop_stk = happyDropStk k stk - -happyDrop 0# l = l -happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t - -happyDropStk 0# l = l -happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs - ------------------------------------------------------------------------------ --- Moving to a new state after a reduction - - -happyGoto nt j tk st = - {- nothing -} - happyDoAction j tk new_state - where off = indexShortOffAddr happyGotoOffsets st - off_i = (off +# nt) - new_state = indexShortOffAddr happyTable off_i - - - - ------------------------------------------------------------------------------ --- Error recovery (0# is the error token) - --- parse error if we are in recovery and we fail again -happyFail 0# tk old_st _ stk = --- trace "failing" $ - happyError_ tk - -{- We don't need state discarding for our restricted implementation of - "error". In fact, it can cause some bogus parses, so I've disabled it - for now --SDM - --- discard a state -happyFail 0# tk old_st (HappyCons ((action)) (sts)) - (saved_tok `HappyStk` _ `HappyStk` stk) = --- trace ("discarding state, depth " ++ show (length stk)) $ - happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) --} - --- Enter error recovery: generate an error token, --- save the old token and carry on. -happyFail i tk (action) sts stk = --- trace "entering error recovery" $ - happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) - --- Internal happy errors: - -notHappyAtAll = error "Internal Happy error\n" - ------------------------------------------------------------------------------ --- Hack to get the typechecker to accept our action functions - - -happyTcHack :: Int# -> a -> a -happyTcHack x y = y -{-# INLINE happyTcHack #-} - - ------------------------------------------------------------------------------ --- Seq-ing. If the --strict flag is given, then Happy emits --- happySeq = happyDoSeq --- otherwise it emits --- happySeq = happyDontSeq - -happyDoSeq, happyDontSeq :: a -> b -> b -happyDoSeq a b = a `seq` b -happyDontSeq a b = b - ------------------------------------------------------------------------------ --- Don't inline any functions from the template. GHC has a nasty habit --- of deciding to inline happyGoto everywhere, which increases the size of --- the generated parser quite a bit. - - -{-# NOINLINE happyDoAction #-} -{-# NOINLINE happyTable #-} -{-# NOINLINE happyCheck #-} -{-# NOINLINE happyActOffsets #-} -{-# NOINLINE happyGotoOffsets #-} -{-# NOINLINE happyDefActions #-} - -{-# NOINLINE happyShift #-} -{-# NOINLINE happySpecReduce_0 #-} -{-# NOINLINE happySpecReduce_1 #-} -{-# NOINLINE happySpecReduce_2 #-} -{-# NOINLINE happySpecReduce_3 #-} -{-# NOINLINE happyReduce #-} -{-# NOINLINE happyMonadReduce #-} -{-# NOINLINE happyGoto #-} -{-# NOINLINE happyFail #-} - --- end of Happy Template. rmfile ./src/System/Plugins/ParsePkgConfCabal.hs addfile ./src/System/Plugins/Process.hs hunk ./src/System/Plugins/Make.hs 51 +import System.Plugins.Process ( exec ) hunk ./src/System/Plugins/Make.hs 235 + hunk ./src/System/Plugins/Make.hs 240 - (_,err) <- exec ghc flags -- this is a fork() + + (out,err) <- exec ghc flags -- this is a fork() + print $ "OUT = " ++ show out + print $ "ERR = " ++ show err hunk ./src/System/Plugins/Process.hs 1 +{-# OPTIONS -cpp #-} +-- +-- | A Posix.popen compatibility mapping. +-- +-- If we use this, we should build -threaded +-- +module System.Plugins.Process (exec, popen) where + +#if __GLASGOW_HASKELL__ >= 604 +import System.IO +import System.Process +import Control.Concurrent (forkIO) +#else +import qualified Posix as P +#endif + +import qualified Control.Exception + +-- +-- slight wrapper over popen for calls that don't care about stdin to the program +-- +exec :: String -> [String] -> IO ([String],[String]) +exec f as = do + (a,b,_) <- popen f as (Just []) + return (lines a, lines b) + +#if __GLASGOW_HASKELL__ >= 604 + +type ProcessID = ProcessHandle + +-- +-- Ignoring exit status for now. +-- +-- XXX there are still issues. Large amounts of output can cause what +-- seems to be a dead lock on the pipe write from runplugs, for example. +-- Posix.popen doesn't have this problem, so maybe we can reproduce its +-- pipe handling somehow. +-- +popen :: FilePath -> [String] -> Maybe String -> IO (String,String,ProcessID) +popen file args minput = + Control.Exception.handle (\e -> return ([],show e,error (show e))) $ do + + (inp,out,err,pid) <- runInteractiveProcess file args Nothing Nothing + + case minput of + Just input -> hPutStr inp input >> hClose inp -- importante! + Nothing -> return () + + -- Now, grab the input + output <- hGetContents out + errput <- hGetContents err + + -- SimonM sez: + -- ... avoids blocking the main thread, but ensures that all the + -- data gets pulled as it becomes available. you have to force the + -- output strings before waiting for the process to terminate. + -- + forkIO (Control.Exception.evaluate (length output) >> return ()) + forkIO (Control.Exception.evaluate (length errput) >> return ()) + + -- And now we wait. We must wait after we read, unsurprisingly. + waitForProcess pid -- blocks without -threaded, you're warned. + + return (output,errput,pid) + +#else + +-- +-- catch so that we can deal with forkProcess failing gracefully. and +-- getProcessStatus is needed so as not to get a bunch of zombies, +-- leading to forkProcess failing. +-- +-- Large amounts of input will cause problems with blocking as we wait +-- on the process to finish. Make sure no lambdabot processes will +-- generate 1000s of lines of output. +-- +popen :: FilePath -> [String] -> Maybe String -> IO (String,String,P.ProcessID) +popen f s m = + Control.Exception.handle (\e -> return ([], show e, error $ show e )) $ do + x@(_,_,pid) <- P.popen f s m + b <- P.getProcessStatus True False pid -- wait + return $ case b of + Nothing -> ([], "process has disappeared", pid) + _ -> x + +#endif hunk ./src/System/Plugins/Utils.hs 56 - exec, hunk ./src/System/Plugins/Utils.hs 74 --- --- The fork library --- -#if CABAL == 0 && __GLASGOW_HASKELL__ < 604 -import POpen ( popen ) -import System.Posix.Process ( getProcessStatus ) -#else -import System.Process -import Control.Concurrent ( forkIO ) -import qualified Control.Exception ( evaluate ) -#endif - hunk ./src/System/Plugins/Utils.hs 170 - - - --- --------------------------------------------------------------------- --- --- | execute a command and it's arguments, returning the --- (stdout,stderr), waiting for it to exit, too. --- - -exec :: String -> [String] -> IO ([String],[String]) - -#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 --- --- Use the forkProcess library, adapted from lambdabot's PosixCompat --- Needs to be compiled with -threaded for waitForProcess not to block --- -exec prog args = do - Control.Exception.handle (\e -> return ([], [show e])) $ do - - (_inh,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing - - output <- hGetContents outh - errput <- hGetContents errh - forkIO (Control.Exception.evaluate (length output) >> return ()) - forkIO (Control.Exception.evaluate (length errput) >> return ()) - waitForProcess proc_hdl - return ( lines $ output, lines $ errput ) - -#else --- --- 6.2.2 Posix version. --- -exec prog args = do - (out,err,pid) <- popen prog args Nothing - b <- getProcessStatus True False pid -- wait - case b of - Nothing -> return ([], ["process `"++prog++"' has disappeared"]) - _ -> return ( lines $! out, lines $! err ) -#endif hunk ./src/plugins.cabal 35 -Build-Depends: haskell-src-exts>=0.2, Cabal +Build-Depends: base, haskell-src-exts>=0.2, Cabal hunk ./configure 1453 -#define WITH_GHC $GHC +#define WITH_GHC "$GHC" hunk ./configure.ac 87 -AC_DEFINE_UNQUOTED(WITH_GHC, $GHC, [Which ghc to use]) +AC_DEFINE_UNQUOTED(WITH_GHC, "$GHC", [Which ghc to use]) hunk ./src/Language/Hi/FastString.hs 70 -import IO -import Char ( chr, ord ) +import System.IO +import Data.Char ( chr, ord ) hunk ./src/System/Plugins/ParsePkgConfCabal.y 42 -import Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) -import List ( break ) +import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) +import Data.List ( break ) hunk ./src/plugins.cabal 35 -Build-Depends: base, haskell-src-exts>=0.2, Cabal +Build-Depends: base, haskell98, Cabal, haskell-src-exts>=0.2 addfile ./examples/dynload/should_fail_2/prog/expected.605 addfile ./examples/dynload/should_fail_3/prog/expected.605 addfile ./examples/iface/null/expected.605 addfile ./examples/pdynload/spj3/prog/expected.605 hunk ./examples/conf/simple/prog/Main.hs 11 - print status - return () -{- hunk ./examples/conf/simple/prog/Main.hs 23 --} hunk ./examples/dynload/should_fail_2/prog/expected.605 1 + +../Plugin.in:13:15: + Couldn't match `Dynamic' against `(a, b)' + Expected type: Dynamic + Inferred type: (a, b) + In the definition of `resource_dyn': resource_dyn = (typeOf v, unsafeCoerce v) +failed hunk ./examples/dynload/should_fail_3/prog/expected.605 1 + +../Plugin.in:12:15: + Couldn't match `Dynamic' against `(a, b)' + Expected type: Dynamic + Inferred type: (a, b) + In the definition of `resource_dyn': + resource_dyn = (typeOf plugin, unsafeCoerce v) +a.out: failed hunk ./examples/eval/eval3/Main.hs 16 -pkgconf = TOP ++ "/plugins.conf.inplace" - hunk ./examples/eval/eval3/Main.hs 23 - [ "-package-conf "++pkgconf , "-package altdata" ] - [ pkgconf ] + [ ] + [ ] hunk ./examples/iface/null/expected.605 1 +interface "unknown" Main +module dependencies: A, B +package dependencies: base-1.0, plugins-0.9.10 +import B +import A hunk ./examples/pdynload/spj3/prog/expected.605 1 + +../Plugin.hs:5:31: + Couldn't match the rigid variable `a' against `Int' + `a' is bound by the polymorphic type `forall a. (Num a) => a -> a -> a' + at ../Plugin.hs:5:11-56 + Expected type: a -> a -> a + Inferred type: Int -> Int -> Int + In the expression: (+) :: Int -> Int -> Int + In the `function' field of a record hunk ./src/System/Plugins/Make.hs 242 - print $ "OUT = " ++ show out - print $ "ERR = " ++ show err hunk ./examples/dynload/should_fail_2/prog/expected.605 2 -../Plugin.in:13:15: +../Plugin.in:18:15: hunk ./examples/dynload/should_fail_3/prog/expected.605 2 -../Plugin.in:12:15: +../Plugin.in:18:15: move ./src/plugins.cabal ./src/plugins.cabal.in hunk ./README 26 + +BUILDING: + $ ./configure --prefix=/usr/local + $ make + $ make install + +------------------------------------------------------------------------ + hunk ./README 37 -* Requires GNU make or BSD make to build -* Requires HSX, Niklas Broberg's Haskell parser library, available at: - darcs get http://www.cs.chalmers.se/~d00nibro/haskell-src-exts - Read the README with this package for how to install it (quite simple) +* Requires Cabal hunk ./README 41 -* 'plugs' requires a working readline library. +* Optional: + If you are doing a lot of `merge'-related operations, and require + an extended haskell parser, you can compile hs-plugins to use + HSX, Niklas Broberg's Haskell parser library, available at: hunk ./README 46 -* If you wish to use TH in plugins, or to run load()-programs in GHCi, - you require a patch to GHC's linker, that was committed into ghc - 6.3, and ghc 6.2 -stable branch, and is available from 6.2.2 onwards. + darcs get http://www.cs.chalmers.se/~d00nibro/haskell-src-exts hunk ./README 48 -* If you need to regenerate ./configure you need >= autoconf-2.53 + To get hs-plugins to use HSX, use the --enable-hsx to ./configure. + Make sure to install HSX first though :) hunk ./README 52 -BUILDING: - $ ./configure --prefix=/usr/local - $ make - $ make install hunk ./README 58 -If you wish to register the libraries as official ghc pkg (probably as -root): - $ make register +* 'plugs' requires a working readline library. hunk ./README 60 -And to unregister (maybe as root): - $ make unregister +* If you wish to use TH in plugins, or to run load()-programs in GHCi, + you require a patch to GHC's linker, that was committed into ghc + 6.3, and ghc 6.2 -stable branch, and is available from 6.2.2 onwards. hunk ./README 64 -Once it is registered, you can link against the library by just adding --package plugins to your command line. +* If you need to regenerate ./configure you need >= autoreconf-2.53 hunk ./README 66 -The documentation relies on latex, dvips, tex2page: +* The documentation relies on latex, dvips, tex2page: hunk ./README 69 + +------------------------------------------------------------------------ hunk ./config.h.in 42 +/* Defined if hs-plugins is to be built with Niklas Broberg's HSX parser */ +#undef WITH_HSX + hunk ./configure 275 -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 build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' +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 build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL HASKELL_SRC TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' hunk ./configure 806 + --enable-hsx Enable a debug version of hs-plugins to be built hunk ./configure 1489 + hunk ./configure 1497 +fi; + +# Allow a debugging version of hs-plugins to be built +# Check whether --enable-hsx or --disable-hsx was given. +if test "${enable_hsx+set}" = set; then + enableval="$enable_hsx" + HASKELL_SRC=haskell-src-exts ; + +cat >>confdefs.h <<_ACEOF +#define WITH_HSX 1 +_ACEOF + +else + HASKELL_SRC=haskell-src hunk ./configure 2711 - ac_config_files="$ac_config_files config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" + ac_config_files="$ac_config_files config.mk src/plugins.cabal examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" hunk ./configure 3239 + "src/plugins.cabal" ) CONFIG_FILES="$CONFIG_FILES src/plugins.cabal" ;; hunk ./configure 3335 +s,@HASKELL_SRC@,$HASKELL_SRC,;t t hunk ./configure.ac 111 - [ AC_DEFINE_UNQUOTED(DEBUG, [1], [Defined if a debugging version is to be built]) ], + [ + AC_DEFINE_UNQUOTED(DEBUG, [1], [Defined if a debugging version is to be built]) ], hunk ./configure.ac 115 +# Allow a debugging version of hs-plugins to be built +AC_ARG_ENABLE(hsx, + [ --enable-hsx Enable a debug version of hs-plugins to be built], + [ HASKELL_SRC=haskell-src-exts ; + AC_DEFINE_UNQUOTED(WITH_HSX, [1], + [Defined if hs-plugins is to be built with Niklas Broberg's HSX parser]) ], + [ HASKELL_SRC=haskell-src ]) hunk ./configure.ac 123 +AC_SUBST(HASKELL_SRC) hunk ./configure.ac 140 -AC_CONFIG_FILES([config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) +AC_CONFIG_FILES([config.mk src/plugins.cabal examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) hunk ./src/System/Plugins/Parser.hs 1 -{-# OPTIONS -fglasgow-exts #-} +{-# OPTIONS -cpp -fglasgow-exts #-} hunk ./src/System/Plugins/Parser.hs 27 +#include "../../../config.h" + hunk ./src/System/Plugins/Parser.hs 33 +#if defined(WITH_HSX) hunk ./src/System/Plugins/Parser.hs 35 +#else +import Language.Haskell.Parser +import Language.Haskell.Syntax +import Language.Haskell.Pretty +#endif hunk ./src/System/Plugins/Parser.hs 49 +#if defined(WITH_HSX) hunk ./src/System/Plugins/Parser.hs 51 +#else + case parseModuleWithMode (ParseMode f) fsrc of +#endif hunk ./src/System/Plugins/Utils.hs 72 -import qualified Control.Exception as Control.Exception (handle) hunk ./src/plugins.cabal.in 35 -Build-Depends: base, haskell98, Cabal, haskell-src-exts>=0.2 +Build-Depends: base, haskell98, Cabal, @HASKELL_SRC@ addfile ./examples/eval/foreign_should_fail/expected.605 hunk ./examples/eval/foreign_should_fail/expected.605 1 +failed! addfile ./examples/eval/foreign_should_fail_illtyped/expected.605 hunk ./examples/eval/foreign_should_fail_illtyped/expected.605 1 +failed! hunk ./examples/plugs/plugs/Makefile 2 -PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace hunk ./examples/plugs/runplugs/Main.hs 1 -{-# OPTIONS -cpp #-} hunk ./examples/plugs/runplugs/Main.hs 2 --- Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./examples/plugs/runplugs/Main.hs 10 -import System.Eval.Haskell (unsafeEval_) +import System.Eval.Haskell (unsafeEval) hunk ./examples/plugs/runplugs/Main.hs 14 -import Control.Exception (evaluate) - hunk ./examples/plugs/runplugs/Main.hs 16 -import System.IO (hGetContents, hPutStrLn, putStrLn, hClose, stdin, stdout, stderr) -#if !defined(CYGWIN) && !defined(__MINGW32__) +import System.IO (getContents, putStrLn) hunk ./examples/plugs/runplugs/Main.hs 21 -import Control.Concurrent ( forkIO ) -import qualified Control.Exception ( evaluate ) hunk ./examples/plugs/runplugs/Main.hs 23 -#endif hunk ./examples/plugs/runplugs/Main.hs 24 -context = prehier ++ datas ++ controls +context = prehier ++ datas ++ qualifieds ++ controls hunk ./examples/plugs/runplugs/Main.hs 27 + +qualifieds = ["qualified Data.Map as M", "qualified Data.Set as S"] hunk ./examples/plugs/runplugs/Main.hs 32 - "Graph", "Int", "Ix", "List", "Maybe", -#if __GLASGOW_HASKELL__ >= 604 - "Map", -#else - "FiniteMap", -#endif - "Ratio", "Set", "Tree", "Tuple", "Typeable", "Word" + "Graph", "Int", "Ix", "List", + "Maybe", "Ratio", "Tree", "Tuple", "Typeable", "Word" hunk ./examples/plugs/runplugs/Main.hs 36 -controls = map ("Control." ++) ["Monad", "Arrow"] +controls = map ("Control." ++) ["Monad", "Monad.Reader", "Monad.Fix", "Arrow"] hunk ./examples/plugs/runplugs/Main.hs 38 --- --- with ghc 6.4, ghc doesn't seem to be able to call gcc, setNoFDBlocking fails. --- --- *** Assembler --- gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o --- --- Failed: gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o --- gcc: setNonBlockingFD: invalid argument (Bad file descriptor) --- hunk ./examples/plugs/runplugs/Main.hs 39 -#if !defined(CYGWIN) && defined(__MINGW32__) hunk ./examples/plugs/runplugs/Main.hs 40 -#endif - s <- hGetContents stdin + s <- getContents hunk ./examples/plugs/runplugs/Main.hs 42 - s <- unsafeEval_ ("(take 2048 (show ("++s++")))") context ["-v"] [] [] - case s of - Left errs -> mapM_ putStrLn errs - Right s -> putStrLn s + s <- unsafeEval ("(take 2048 (show ("++s++")))") context + when (isJust s) (putStrLn (fromJust s)) hunk ./examples/plugs/runplugs/Makefile 2 -PKGFLAGS= -package posix -package-conf $(TOP)/plugins.conf.inplace +PKGFLAGS= -package posix rmfile ./examples/plugs/runplugs/dont_test hunk ./examples/foreign.mk 19 - @$(GHC) $(INCLUDES) $(PKGFLAGS) $(SRC) + $(GHC) -package plugins $(INCLUDES) $(PKGFLAGS) $(SRC) hunk ./src/System/Plugins/Make.hs 241 - (out,err) <- exec ghc flags -- this is a fork() + (_out,err) <- exec ghc flags -- this is a fork() hunk ./examples/iface/null/expected.604 3 -package dependencies: base-1.0, haskell98-1.0, hi-0.9.10 +package dependencies: base-1.0, plugins-0.9.10 hunk ./examples/dynload/should_fail_2/prog/expected.604 2 -../Plugin.in:13:15: +../Plugin.in:18:15: hunk ./examples/dynload/should_fail_3/prog/expected.604 2 -../Plugin.in:12:15: +../Plugin.in:18:15: hunk ./Makefile 75 - config.h config.mk config.log config.status + config.h config.mk config.log config.status src/plugins.cabal + hunk ./src/plugins.cabal.in 36 -ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures -threaded +ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures hunk ./src/System/Plugins/Load.hs 116 - resolveObjs + resolveObjs (mapM_ unloadAll (m:moduleDeps)) hunk ./src/System/Plugins/Load.hs 343 - resolveObjs + resolveObjs (unloadAll m) hunk ./src/System/Plugins/Load.hs 469 -resolveObjs :: IO () -resolveObjs = do - r <- c_resolveObjs - when (not r) $ - panic $ "resolveObjs failed with <<" ++ show r ++ ">>" +resolveObjs :: IO a -> IO () +resolveObjs unloadLoaded + = do r <- c_resolveObjs + when (not r) $ unloadLoaded >> panic "resolvedObjs failed." hunk ./src/System/Plugins/Load.hs 626 - resolveObjs + resolveObjs (mapM_ unloadPackage ps') hunk ./src/System/Plugins/Process.hs 9 +import System.Exit hunk ./src/System/Plugins/Process.hs 63 - waitForProcess pid -- blocks without -threaded, you're warned. - - return (output,errput,pid) + exitCode <- waitForProcess pid -- blocks without -threaded, you're warned. + case exitCode of + ExitFailure code + | null errput -> let errMsg = file ++ ": failed with error code " ++ show code + in return ([],errMsg,error errMsg) + _ -> return (output,errput,pid) adddir ./examples/pdynload/bayley1 adddir ./examples/pdynload/bayley1/Sub adddir ./examples/pdynload/bayley1/api adddir ./examples/pdynload/bayley1/prog addfile ./examples/pdynload/bayley1/Load.hs hunk ./examples/pdynload/bayley1/Load.hs 1 +module Load where + +import API +import System.Plugins + +testload = do + + s <- make "../Plugin1.hs" ["-i../api"] + o1 <- case s of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> fail "o1" + + s <- make "../Sub/Plugin2.hs" ["-i../api"] + o2 <- case s of + MakeSuccess _ o -> return o + MakeFailure e -> mapM_ putStrLn e >> fail "o2" + + fc <- pdynload o1 ["..","../api"] [] "API.PluginAPI" "action" + + case fc of + LoadFailure msg -> mapM_ putStrLn msg + LoadSuccess modul proc -> do + let ac :: API.PluginAPI; ac = proc + let s = proc 42 + print s + + print o2 + fc <- pdynload o2 ["..","../api"] [] "API.PluginAPI" "action" + case fc of + LoadFailure msg -> mapM_ putStrLn msg + LoadSuccess modul proc -> do + let ac :: API.PluginAPI; ac = proc + let s = proc 42 + print s addfile ./examples/pdynload/bayley1/Makefile hunk ./examples/pdynload/bayley1/Makefile 1 + +TEST=pdynload/bayley1 + +TOP=../../.. +include ../../build.mk addfile ./examples/pdynload/bayley1/Plugin1.hs hunk ./examples/pdynload/bayley1/Plugin1.hs 1 +module Plugin1 where + +import qualified API +action :: API.PluginAPI +action i = show i + addfile ./examples/pdynload/bayley1/Sub/Plugin2.hs hunk ./examples/pdynload/bayley1/Sub/Plugin2.hs 1 +module Sub.Plugin2 where + +import qualified API +action :: API.PluginAPI +action i = show i + addfile ./examples/pdynload/bayley1/api/API.hs hunk ./examples/pdynload/bayley1/api/API.hs 1 +module API where + +type PluginAPI = Int -> String +action :: PluginAPI +action i = show i + addfile ./examples/pdynload/bayley1/prog/Main.hs hunk ./examples/pdynload/bayley1/prog/Main.hs 1 +module Main where +import Load +main = testload + hunk ./examples/plugs/plugs/Main.hs 20 - resolveObjs + resolveObjs (return ()) hunk ./README 86 -They dynamic loader requires a functional GHCi implementation. +The dynamic loader requires a functional GHCi implementation. move ./src/AltData ./AltData move ./src/Language ./Language move ./src/Setup.hs ./Setup.hs move ./src/System ./System move ./src/plugins.cabal.in ./plugins.cabal.in addfile ./plugins.cabal addfile ./plugins.cabal.hsx hunk ./AltData/Typeable.hs 129 +-- +-- could use packed strings here. hunk ./Language/Hi/Parser.hs 51 -#include "../../../config.h" +#include "../../config.h" hunk ./Makefile 10 -build:: - cd src ;\ - $(GHC) -o setup --make Setup.hs ;\ - ./setup configure --prefix=$(PREFIX) ;\ - ./setup build - hunk ./Makefile 11 - cp src/System/Eval/Haskell_stub.h $@ + cp System/Eval/Haskell_stub.h $@ hunk ./Makefile 52 - cd src && ./setup clean 2> /dev/null || true - cd src && rm -rf dist Setup.hi Setup.o setup + runhaskell Setup.hs clean 2> /dev/null || true hunk ./Makefile 68 - config.h config.mk config.log config.status src/plugins.cabal + config.h config.mk config.log config.status hunk ./Setup.hs 2 -main = defaultMain +main = defaultMainWithHooks defaultUserHooks hunk ./System/Plugins/Consts.hs 1 -{-# OPTIONS -cpp #-} hunk ./System/Plugins/Consts.hs 22 -#include "../../../config.h" +#include "../../config.h" hunk ./System/Plugins/Env.hs 49 -#include "../../../config.h" +#include "../../config.h" hunk ./System/Plugins/Load.hs 53 -#include "../../../config.h" +#include "../../config.h" hunk ./System/Plugins/PackageAPI.hs 40 -#include "../../../config.h" +#include "../../config.h" hunk ./System/Plugins/Parser.hs 27 -#include "../../../config.h" +#include "../../config.h" hunk ./System/Plugins/Utils.hs 60 -#include "../../../config.h" +#include "../../config.h" hunk ./configure 274 -ac_unique_file="src/System/Plugins.hs" +ac_unique_file="System/Plugins.hs" hunk ./configure 2711 - ac_config_files="$ac_config_files config.mk src/plugins.cabal examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" + ac_config_files="$ac_config_files config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" hunk ./configure 3239 - "src/plugins.cabal" ) CONFIG_FILES="$CONFIG_FILES src/plugins.cabal" ;; hunk ./configure.ac 11 -AC_INIT(src/System/Plugins.hs) +AC_INIT(System/Plugins.hs) hunk ./configure.ac 140 -AC_CONFIG_FILES([config.mk src/plugins.cabal examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) +AC_CONFIG_FILES([config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) hunk ./plugins.cabal 1 +name: plugins +version: 0.9.10 +license: LGPL +License-file: LICENSE +author: Don Stewart +maintainer: dons@cse.unsw.edu.au +exposed-modules: + AltData.Dynamic, + AltData.Typeable, + Language.Hi.Binary, + Language.Hi.FastMutInt, + Language.Hi.FastString, + Language.Hi.Parser, + Language.Hi.PrimPacked, + Language.Hi.Syntax, + System.Eval, + System.Eval.Haskell, + System.Eval.Utils, + System.MkTemp, + System.Plugins, + System.Plugins.Consts, + System.Plugins.Env, + System.Plugins.Load, + System.Plugins.LoadTypes, + System.Plugins.Make, + System.Plugins.Package, + System.Plugins.PackageAPI, + System.Plugins.ParsePkgConfCabal, + System.Plugins.Parser, + System.Plugins.Process, + System.Plugins.Utils +c-sources: + Language/Hi/hschooks.c +includes: Linker.h +extensions: CPP, ForeignFunctionInterface +Build-Depends: base, haskell98, Cabal, haskell-src +ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures + hunk ./plugins.cabal.hsx 1 +name: plugins +version: 0.9.10 +license: LGPL +License-file: LICENSE +author: Don Stewart +maintainer: dons@cse.unsw.edu.au +exposed-modules: + AltData.Dynamic, + AltData.Typeable, + Language.Hi.Binary, + Language.Hi.FastMutInt, + Language.Hi.FastString, + Language.Hi.Parser, + Language.Hi.PrimPacked, + Language.Hi.Syntax, + System.Eval, + System.Eval.Haskell, + System.Eval.Utils, + System.MkTemp, + System.Plugins, + System.Plugins.Consts, + System.Plugins.Env, + System.Plugins.Load, + System.Plugins.LoadTypes, + System.Plugins.Make, + System.Plugins.Package, + System.Plugins.PackageAPI, + System.Plugins.ParsePkgConfCabal, + System.Plugins.Parser, + System.Plugins.Process, + System.Plugins.Utils +c-sources: + Language/Hi/hschooks.c +includes: Linker.h +Build-Depends: base, haskell98, Cabal, haskell-src-exts +ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures + hunk ./plugins.cabal.in 1 -name: plugins -version: 0.9.10 -license: LGPL -License-file: LICENSE -author: Don Stewart -maintainer: dons@cse.unsw.edu.au -exposed-modules: - AltData.Dynamic, - AltData.Typeable, - Language.Hi.Binary, - Language.Hi.FastMutInt, - Language.Hi.FastString, - Language.Hi.Parser, - Language.Hi.PrimPacked, - Language.Hi.Syntax, - System.Eval, - System.Eval.Haskell, - System.Eval.Utils, - System.MkTemp, - System.Plugins, - System.Plugins.Consts, - System.Plugins.Env, - System.Plugins.Load, - System.Plugins.LoadTypes, - System.Plugins.Make, - System.Plugins.Package, - System.Plugins.PackageAPI, - System.Plugins.ParsePkgConfCabal, - System.Plugins.Parser, - System.Plugins.Process, - System.Plugins.Utils -c-sources: - Language/Hi/hschooks.c -includes: Linker.h -Build-Depends: base, haskell98, Cabal, @HASKELL_SRC@ -ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures - rmfile ./plugins.cabal.in hunk ./Makefile 50 +EXTRA_CLEANS+=*.conf.inplace* *.conf.in *.h autom4te.cache \ + config.h config.mk config.log config.status + hunk ./Makefile 69 - -EXTRA_CLEANS+=*.conf.inplace* *.conf.in *.h autom4te.cache \ - config.h config.mk config.log config.status - -distclean: clean hunk ./README 28 - $ ./configure --prefix=/usr/local - $ make - $ make install + $ runhaskell Setup.hs configure --prefix=/usr/local + $ runhaskell Setup.hs build + $ runhaskell Setup.hs install hunk ./README 48 - To get hs-plugins to use HSX, use the --enable-hsx to ./configure. + To get hs-plugins to use HSX, use: + + $ runhaskell Setup.hs configure --enable-hsx + hunk ./System/MkTemp.hs 242 --- | getProcessId, stolen from GHC (main/SysTools.lhs) +-- | getProcessId, stolen from GHC /main\/SysTools.lhs/ hunk ./System/Plugins/Env.hs 1 -{-# OPTIONS -cpp #-} hunk ./System/Plugins/Env.hs 2 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./System/Plugins/Env.hs 99 --- We need to record what modules and packages we have loaded, so if we --- read a .hi file that wants to load something already loaded, we can --- safely ignore that request. We're in the IO monad anyway, so we can --- add some extra state of our own. +-- | We need to record what modules and packages we have loaded, so if +-- we read a .hi file that wants to load something already loaded, we +-- can safely ignore that request. We're in the IO monad anyway, so we +-- can add some extra state of our own. hunk ./System/Plugins/Env.hs 104 --- The state is a FiniteMap String (Module,Int) (a hash of package/object names --- to Modules and how many times they've been loaded). +-- The state is a FiniteMap String (Module,Int) (a hash of +-- package\/object names to Modules and how many times they've been +-- loaded). hunk ./System/Plugins/Env.hs 111 --- rather one provided via -package-conf). This is stored as a --- FiniteMap PackageName PackageConfig. The problem then is whether a --- user's package.conf, that uses the same package name as an existing --- GHC package, should be allowed, or should shadow a library package? --- I don't know, but I'm inclined to have the GHC package shadow the +-- rather one provided via -package-conf). This is stored as a FiniteMap +-- PackageName PackageConfig. The problem then is whether a user's +-- package.conf, that uses the same package name as an existing GHC +-- package, should be allowed, or should shadow a library package? I +-- don't know, but I'm inclined to have the GHC package shadow the hunk ./System/Plugins/Env.hs 118 --- This idea is based on *Hampus Ram's dynamic loader* dependency +-- This idea is based on /Hampus Ram's dynamic loader/ dependency hunk ./System/Plugins/Env.hs 163 --- apply 'f' to the loaded objects Env --- apply 'f' to the package.conf FM --- *locks up the MVar* so you can't recursively call a function inside a --- with*Env function. Nice and threadsafe +-- | apply 'f' to the loaded objects Env, apply 'f' to the package.conf +-- FM /locks up the MVar/ so you can't recursively call a function +-- inside a with any -Env function. Nice and threadsafe hunk ./System/Plugins/Env.hs 197 --- insert a loaded module name into the environment +-- | insert a loaded module name into the environment hunk ./System/Plugins/Env.hs 207 --- remove a module name from the environment. Returns True if the module was actually removed. +-- | remove a module name from the environment. Returns True if the +-- module was actually removed. hunk ./System/Plugins/Env.hs 219 --- insert a list of module names all in one go +-- | insert a list of module names all in one go hunk ./System/Plugins/Env.hs 225 --- is a module/package already loaded? +-- | is a module\/package already loaded? hunk ./System/Plugins/Env.hs 242 --- set the dependencies of a Module. +-- | Set the dependencies of a Module. hunk ./System/Plugins/Env.hs 248 --- Get module dependencies. Nothing if none have been recored. +-- | Get module dependencies. Nothing if none have been recored. hunk ./System/Plugins/Env.hs 255 --- Unrecord a module from the environment. +-- | Unrecord a module from the environment. hunk ./System/Plugins/Env.hs 262 + hunk ./System/Plugins/Env.hs 264 --- insert a single package.conf (containing multiple configs) --- means: create a new FM. insert packages into FM. add FM to end of --- list of FM stored in the environment. +-- | Insert a single package.conf (containing multiple configs) means: +-- create a new FM. insert packages into FM. add FM to end of list of FM +-- stored in the environment. hunk ./System/Plugins/Env.hs 274 --- add a new FM for the package.conf to the list of existing ones +-- | add a new FM for the package.conf to the list of existing ones hunk ./System/Plugins/Env.hs 282 --- generate a PkgEnv from the system package.conf --- * the path to the default package.conf was determined by ./configure * +-- | generate a PkgEnv from the system package.conf +-- The path to the default package.conf was determined by /configure/ hunk ./System/Plugins/Env.hs 319 --- * anything in the hs_libraries fields, $libdir expanded --- * anything in the extra_libraries fields (i.e. cbits), expanded, +-- . anything in the hs_libraries fields, libdir expanded +-- +-- . anything in the extra_libraries fields (i.e. cbits), expanded, +-- hunk ./System/Plugins/Env.hs 324 --- * also load any dependencies now, because of that weird mtl +-- +-- . also load any dependencies now, because of that weird mtl hunk ./System/Plugins/Env.hs 349 --- TODO need to define a MAC/DARWIN symbol +-- TODO need to define a MAC\/DARWIN symbol hunk ./System/Plugins/Load.hs 2 -{-# OPTIONS -fglasgow-exts -cpp #-} +{-# OPTIONS -fglasgow-exts #-} hunk ./System/Plugins/Load.hs 4 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./System/Plugins/Load.hs 354 --- which in turn is based on GHC's ghci/ObjLinker.lhs binding +-- which in turn is based on GHC's ghci\/ObjLinker.lhs binding hunk ./System/Plugins/Load.hs 364 --- read $fptools/ghc/compiler/ghci/ObjLinker.lhs for how to use this stuff +-- read $fptools\/ghc\/compiler\/ghci\/ObjLinker.lhs for how to use this stuff hunk ./System/Plugins/Load.hs 420 --- Z-encoded modid from the .hi file. For archives/packages, we can +-- Z-encoded modid from the .hi file. For archives\/packages, we can hunk ./System/Plugins/Load.hs 485 --- | from ghci/ObjLinker.c +-- | from ghci\/ObjLinker.c hunk ./System/Plugins/Make.hs 1 -{-# OPTIONS -cpp #-} hunk ./System/Plugins/Make.hs 2 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./System/Plugins/Make.hs 226 - let odir = dirname obj -- *always* put the .hi file next to the .o file + let odir = dirname obj -- always put the .hi file next to the .o file hunk ./System/Plugins/Parser.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} +{-# OPTIONS -fglasgow-exts #-} hunk ./System/Plugins/Parser.hs 3 --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./System/Plugins/Parser.hs 70 --- | --- mergeModules : generate a full Haskell src file, give a .hs config +-- | mergeModules : generate a full Haskell src file, give a .hs config hunk ./System/Plugins/Parser.hs 75 --- Transformations: +-- Transformations: hunk ./System/Plugins/Parser.hs 77 --- * Take src location pragmas from the conf file (1st file) --- * Use the template's (2nd argument) module name --- * Only use export list from template (2nd arg) --- * Merge top-level decls --- * need to force the type of the plugin to match the stub, +-- . Take src location pragmas from the conf file (1st file) +-- . Use the template's (2nd argument) module name +-- . Only use export list from template (2nd arg) +-- . Merge top-level decls +-- . need to force the type of the plugin to match the stub, hunk ./System/Plugins/Parser.hs 84 -mergeModules :: HsModule -> -- ^ Configure module - HsModule -> -- ^ Template module - HsModule -- ^ A merge of the two +mergeModules :: HsModule -> -- Configure module + HsModule -> -- Template module + HsModule -- A merge of the two hunk ./System/Plugins/Parser.hs 95 --- replace Module name with String. +-- | replace Module name with String. hunk ./System/Plugins/Parser.hs 106 --- TODO : we don't merge imports of the same module from both files. +-- TODO * we don't merge imports of the same module from both files. hunk ./System/Plugins/Parser.hs 108 --- ** rename args, too confusing. +-- * rename args, too confusing. hunk ./System/Plugins/Parser.hs 112 -mImps :: Module -> -- ^ plugin module name - [HsImportDecl] -> -- ^ conf file imports - [HsImportDecl] -> -- ^ stub file imports +mImps :: Module -> -- plugin module name + [HsImportDecl] -> -- conf file imports + [HsImportDecl] -> -- stub file imports hunk ./System/Plugins/Parser.hs 128 --- * could we write a pass to handle "editor, foo :: String" ? +-- Could we write a pass to handle editor, foo :: String ? +-- We must keep the type from the template. hunk ./System/Plugins/Parser.hs 131 --- we must keep the type from the template. --- -mDecl ds es = let ds' = filter (\t->not $ typeDecl t) ds -- rm type sigs from plugin +mDecl ds es = let ds' = filter (not.typeDecl) ds hunk ./System/Plugins/Parser.hs 168 --- they'll get slightly mystical error messages. Also, we *want* to --- handle -package options, and other *static* flags. This is more than +-- they'll get slightly mystical error messages. Also, we /want/ to +-- handle -package options, and other /static/ flags. This is more than hunk ./System/Plugins/Parser.hs 173 --- "OPTIONS pragmas are only looked for at the top of your source --- files, upto the first (non-literate,non-empty) line not --- containing OPTIONS. Multiple OPTIONS pragmas are recognised." hunk ./System/Plugins/Parser.hs 174 --- based on getOptionsFromSource(), in main/DriverUtil.hs +-- > OPTIONS pragmas are only looked for at the top of your source +-- > files, up to the first (non-literate,non-empty) line not +-- > containing OPTIONS. Multiple OPTIONS pragmas are recognised. +-- +-- based on getOptionsFromSource(), in main\/DriverUtil.hs hunk ./System/Plugins/Parser.hs 199 --- based on main/DriverUtil.hs +-- based on main\/DriverUtil.hs hunk ./System/Plugins/Parser.hs 225 --- verbatim from utils/Utils.lhs +-- verbatim from utils\/Utils.lhs addfile ./System/Plugins/ParsePkgConfCabal.hs hunk ./System/Plugins/ParsePkgConfCabal.hs 1 +{-# OPTIONS -fglasgow-exts -cpp #-} +{-# OPTIONS -w #-} + +module System.Plugins.ParsePkgConfCabal ( + parsePkgConf, parseOnePkgConf + ) where + +import Distribution.InstalledPackageInfo +import Distribution.Package +import Distribution.Version + +import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) +import Data.List ( break ) +import Data.Array +#if __GLASGOW_HASKELL__ >= 503 +import GHC.Exts +#else +import GlaExts +#endif + +-- parser produced by Happy Version 1.15 + +newtype HappyAbsSyn = HappyAbsSyn (() -> ()) +happyIn5 :: ([ PackageConfig ]) -> (HappyAbsSyn ) +happyIn5 x = unsafeCoerce# x +{-# INLINE happyIn5 #-} +happyOut5 :: (HappyAbsSyn ) -> ([ PackageConfig ]) +happyOut5 x = unsafeCoerce# x +{-# INLINE happyOut5 #-} +happyIn6 :: ([ PackageConfig ]) -> (HappyAbsSyn ) +happyIn6 x = unsafeCoerce# x +{-# INLINE happyIn6 #-} +happyOut6 :: (HappyAbsSyn ) -> ([ PackageConfig ]) +happyOut6 x = unsafeCoerce# x +{-# INLINE happyOut6 #-} +happyIn7 :: (PackageConfig) -> (HappyAbsSyn ) +happyIn7 x = unsafeCoerce# x +{-# INLINE happyIn7 #-} +happyOut7 :: (HappyAbsSyn ) -> (PackageConfig) +happyOut7 x = unsafeCoerce# x +{-# INLINE happyOut7 #-} +happyIn8 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) +happyIn8 x = unsafeCoerce# x +{-# INLINE happyIn8 #-} +happyOut8 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) +happyOut8 x = unsafeCoerce# x +{-# INLINE happyOut8 #-} +happyIn9 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) +happyIn9 x = unsafeCoerce# x +{-# INLINE happyIn9 #-} +happyOut9 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) +happyOut9 x = unsafeCoerce# x +{-# INLINE happyOut9 #-} +happyIn10 :: (PackageIdentifier) -> (HappyAbsSyn ) +happyIn10 x = unsafeCoerce# x +{-# INLINE happyIn10 #-} +happyOut10 :: (HappyAbsSyn ) -> (PackageIdentifier) +happyOut10 x = unsafeCoerce# x +{-# INLINE happyOut10 #-} +happyIn11 :: (Version) -> (HappyAbsSyn ) +happyIn11 x = unsafeCoerce# x +{-# INLINE happyIn11 #-} +happyOut11 :: (HappyAbsSyn ) -> (Version) +happyOut11 x = unsafeCoerce# x +{-# INLINE happyOut11 #-} +happyIn12 :: ([PackageIdentifier]) -> (HappyAbsSyn ) +happyIn12 x = unsafeCoerce# x +{-# INLINE happyIn12 #-} +happyOut12 :: (HappyAbsSyn ) -> ([PackageIdentifier]) +happyOut12 x = unsafeCoerce# x +{-# INLINE happyOut12 #-} +happyIn13 :: ([PackageIdentifier]) -> (HappyAbsSyn ) +happyIn13 x = unsafeCoerce# x +{-# INLINE happyIn13 #-} +happyOut13 :: (HappyAbsSyn ) -> ([PackageIdentifier]) +happyOut13 x = unsafeCoerce# x +{-# INLINE happyOut13 #-} +happyIn14 :: ([Int]) -> (HappyAbsSyn ) +happyIn14 x = unsafeCoerce# x +{-# INLINE happyIn14 #-} +happyOut14 :: (HappyAbsSyn ) -> ([Int]) +happyOut14 x = unsafeCoerce# x +{-# INLINE happyOut14 #-} +happyIn15 :: ([Int]) -> (HappyAbsSyn ) +happyIn15 x = unsafeCoerce# x +{-# INLINE happyIn15 #-} +happyOut15 :: (HappyAbsSyn ) -> ([Int]) +happyOut15 x = unsafeCoerce# x +{-# INLINE happyOut15 #-} +happyIn16 :: ([String]) -> (HappyAbsSyn ) +happyIn16 x = unsafeCoerce# x +{-# INLINE happyIn16 #-} +happyOut16 :: (HappyAbsSyn ) -> ([String]) +happyOut16 x = unsafeCoerce# x +{-# INLINE happyOut16 #-} +happyIn17 :: ([String]) -> (HappyAbsSyn ) +happyIn17 x = unsafeCoerce# x +{-# INLINE happyIn17 #-} +happyOut17 :: (HappyAbsSyn ) -> ([String]) +happyOut17 x = unsafeCoerce# x +{-# INLINE happyOut17 #-} +happyInTok :: Token -> (HappyAbsSyn ) +happyInTok x = unsafeCoerce# x +{-# INLINE happyInTok #-} +happyOutTok :: (HappyAbsSyn ) -> Token +happyOutTok x = unsafeCoerce# x +{-# INLINE happyOutTok #-} + +happyActOffsets :: HappyAddr +happyActOffsets = HappyA# "\x50\x00\x4a\x00\x4c\x00\x49\x00\x46\x00\x4b\x00\x45\x00\x0a\x00\x1e\x00\x00\x00\x00\x00\x44\x00\x16\x00\x00\x00\x43\x00\x00\x00\x42\x00\x00\x00\x03\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x01\x00\x00\x00\x40\x00\x00\x00\x3e\x00\x3d\x00\x1c\x00\x00\x00\x3f\x00\x00\x00\x00\x00\x3b\x00\x00\x00\x3a\x00\x39\x00\x35\x00\x00\x00\x00\x00\x38\x00\x31\x00\x34\x00\x33\x00\x37\x00\x36\x00\x28\x00\x00\x00\x30\x00\x32\x00\x2f\x00\x09\x00\x2d\x00\x00\x00\x2e\x00\x26\x00\x2c\x00\x22\x00\x00\x00\x00\x00\x2b\x00\x29\x00\x0d\x00\x00\x00\x00\x00"# + +happyGotoOffsets :: HappyAddr +happyGotoOffsets = HappyA# "\x2a\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\xfe\xff\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x04\x00\x00\x00\xfb\xff\x00\x00\x00\x00"# + +happyDefActions :: HappyAddr +happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xfd\xff\x00\x00\x00\x00\xf8\xff\x00\x00\xfc\xff\x00\x00\xfa\xff\x00\x00\xf9\xff\x00\x00\xf7\xff\xf6\xff\xf1\xff\xf2\xff\x00\x00\xf4\xff\xf5\xff\x00\x00\xf3\xff\xed\xff\x00\x00\x00\x00\xe7\xff\x00\x00\xe5\xff\xe6\xff\x00\x00\xee\xff\x00\x00\x00\x00\x00\x00\xec\xff\xe4\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xeb\xff\xe9\xff\x00\x00\x00\x00\x00\x00\xea\xff\xe8\xff\x00\x00\x00\x00\x00\x00\xef\xff"# + +happyCheck :: HappyAddr +happyCheck = HappyA# "\xff\xff\x05\x00\x01\x00\x05\x00\x08\x00\x07\x00\x03\x00\x0c\x00\x0c\x00\x0b\x00\x09\x00\x08\x00\x09\x00\x04\x00\x04\x00\x0b\x00\x04\x00\x04\x00\x08\x00\x0a\x00\x08\x00\x09\x00\x09\x00\x05\x00\x02\x00\x0a\x00\x08\x00\x05\x00\x03\x00\x04\x00\x01\x00\x02\x00\x04\x00\x05\x00\x04\x00\x05\x00\x0a\x00\x04\x00\x06\x00\x02\x00\x09\x00\x02\x00\x00\x00\x02\x00\x0a\x00\x07\x00\x03\x00\x07\x00\xff\xff\x04\x00\x06\x00\x05\x00\x05\x00\x03\x00\x06\x00\x01\x00\x07\x00\x02\x00\x06\x00\x08\x00\xff\xff\x05\x00\x09\x00\x06\x00\x01\x00\x04\x00\x08\x00\x05\x00\x09\x00\xff\xff\xff\xff\x07\x00\x07\x00\x06\x00\x08\x00\x07\x00\x01\x00\x04\x00\xff\xff\x03\x00\x0b\x00\x0b\x00\x08\x00\x03\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# + +happyTable :: HappyAddr +happyTable = HappyA# "\x00\x00\x1e\x00\x1d\x00\x16\x00\x1f\x00\x17\x00\x1a\x00\x20\x00\x20\x00\x18\x00\x1e\x00\x1b\x00\x1c\x00\x3a\x00\x0b\x00\x41\x00\x22\x00\x22\x00\x06\x00\x3b\x00\x23\x00\x24\x00\x24\x00\x1e\x00\x14\x00\x3f\x00\x2a\x00\x15\x00\x0c\x00\x0d\x00\x08\x00\x09\x00\x25\x00\x26\x00\x10\x00\x11\x00\x38\x00\x15\x00\x30\x00\x11\x00\x36\x00\x04\x00\x06\x00\x44\x00\x3b\x00\x3d\x00\x43\x00\x35\x00\x00\x00\x3f\x00\x41\x00\x3e\x00\x3c\x00\x38\x00\x36\x00\x33\x00\x2f\x00\x34\x00\x30\x00\x32\x00\x00\x00\x2e\x00\x2d\x00\x2a\x00\x1d\x00\x27\x00\x23\x00\x28\x00\x2c\x00\x00\x00\x00\x00\x29\x00\x0f\x00\x13\x00\x06\x00\x0f\x00\x0c\x00\x0b\x00\x00\x00\x04\x00\xff\xff\xff\xff\x06\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# + +happyReduceArr = array (2, 27) [ + (2 , happyReduce_2), + (3 , happyReduce_3), + (4 , happyReduce_4), + (5 , happyReduce_5), + (6 , happyReduce_6), + (7 , happyReduce_7), + (8 , happyReduce_8), + (9 , happyReduce_9), + (10 , happyReduce_10), + (11 , happyReduce_11), + (12 , happyReduce_12), + (13 , happyReduce_13), + (14 , happyReduce_14), + (15 , happyReduce_15), + (16 , happyReduce_16), + (17 , happyReduce_17), + (18 , happyReduce_18), + (19 , happyReduce_19), + (20 , happyReduce_20), + (21 , happyReduce_21), + (22 , happyReduce_22), + (23 , happyReduce_23), + (24 , happyReduce_24), + (25 , happyReduce_25), + (26 , happyReduce_26), + (27 , happyReduce_27) + ] + +happy_n_terms = 12 :: Int +happy_n_nonterms = 13 :: Int + +happyReduce_2 = happySpecReduce_2 0# happyReduction_2 +happyReduction_2 happy_x_2 + happy_x_1 + = happyIn5 + ([] + ) + +happyReduce_3 = happySpecReduce_3 0# happyReduction_3 +happyReduction_3 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn5 + (reverse happy_var_2 + )} + +happyReduce_4 = happySpecReduce_1 1# happyReduction_4 +happyReduction_4 happy_x_1 + = case happyOut7 happy_x_1 of { happy_var_1 -> + happyIn6 + ([ happy_var_1 ] + )} + +happyReduce_5 = happySpecReduce_3 1# happyReduction_5 +happyReduction_5 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut7 happy_x_3 of { happy_var_3 -> + happyIn6 + (happy_var_3 : happy_var_1 + )}} + +happyReduce_6 = happyReduce 4# 2# happyReduction_6 +happyReduction_6 (happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut8 happy_x_3 of { happy_var_3 -> + happyIn7 + (happy_var_3 defaultPackageConfig + ) `HappyStk` happyRest} + +happyReduce_7 = happySpecReduce_1 3# happyReduction_7 +happyReduction_7 happy_x_1 + = case happyOut9 happy_x_1 of { happy_var_1 -> + happyIn8 + (\p -> happy_var_1 p + )} + +happyReduce_8 = happySpecReduce_3 3# happyReduction_8 +happyReduction_8 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut9 happy_x_3 of { happy_var_3 -> + happyIn8 + (\p -> happy_var_1 (happy_var_3 p) + )}} + +happyReduce_9 = happySpecReduce_3 4# happyReduction_9 +happyReduction_9 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut10 happy_x_3 of { happy_var_3 -> + happyIn9 + (\p -> case happy_var_1 of + "package" -> p {package = happy_var_3} + _ -> error "unknown key in config file" + )}} + +happyReduce_10 = happySpecReduce_3 4# happyReduction_10 +happyReduction_10 happy_x_3 + happy_x_2 + happy_x_1 + = happyIn9 + (id + ) + +happyReduce_11 = happySpecReduce_3 4# happyReduction_11 +happyReduction_11 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOutTok happy_x_3 of { (ITconid happy_var_3) -> + happyIn9 + (case happy_var_1 of { + "exposed" -> + case happy_var_3 of { + "True" -> (\p -> p {exposed=True}); + "False" -> (\p -> p {exposed=False}); + _ -> error "exposed must be either True or False" }; + "license" -> id; -- not interested + _ -> error "unknown constructor" } + )}} + +happyReduce_12 = happyReduce 4# 4# happyReduction_12 +happyReduction_12 (happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = happyIn9 + (id + ) `HappyStk` happyRest + +happyReduce_13 = happySpecReduce_3 4# happyReduction_13 +happyReduction_13 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut16 happy_x_3 of { happy_var_3 -> + happyIn9 + (\p -> case happy_var_1 of + "exposedModules" -> p{exposedModules = happy_var_3} + "hiddenModules" -> p{hiddenModules = happy_var_3} + "importDirs" -> p{importDirs = happy_var_3} + "libraryDirs" -> p{libraryDirs = happy_var_3} + "hsLibraries" -> p{hsLibraries = happy_var_3} + "extraLibraries" -> p{extraLibraries = happy_var_3} + "includeDirs" -> p{includeDirs = happy_var_3} + "includes" -> p{includes = happy_var_3} + "hugsOptions" -> p{hugsOptions = happy_var_3} + "ccOptions" -> p{ccOptions = happy_var_3} + "ldOptions" -> p{ldOptions = happy_var_3} + "frameworkDirs" -> p{frameworkDirs = happy_var_3} + "frameworks" -> p{frameworks = happy_var_3} + "haddockInterfaces" -> p{haddockInterfaces = happy_var_3} + "haddockHTMLs" -> p{haddockHTMLs = happy_var_3} + "depends" -> p{depends = []} + -- empty list only, non-empty handled below + other -> p + )}} + +happyReduce_14 = happySpecReduce_3 4# happyReduction_14 +happyReduction_14 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> + case happyOut12 happy_x_3 of { happy_var_3 -> + happyIn9 + (case happy_var_1 of + "depends" -> (\p -> p{depends = happy_var_3}) + _other -> error "unknown key in config file" + )}} + +happyReduce_15 = happyReduce 10# 5# happyReduction_15 +happyReduction_15 (happy_x_10 `HappyStk` + happy_x_9 `HappyStk` + happy_x_8 `HappyStk` + happy_x_7 `HappyStk` + happy_x_6 `HappyStk` + happy_x_5 `HappyStk` + happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOutTok happy_x_5 of { (ITstring happy_var_5) -> + case happyOut11 happy_x_9 of { happy_var_9 -> + happyIn10 + (PackageIdentifier{ pkgName = happy_var_5, + pkgVersion = happy_var_9 } + ) `HappyStk` happyRest}} + +happyReduce_16 = happyReduce 10# 6# happyReduction_16 +happyReduction_16 (happy_x_10 `HappyStk` + happy_x_9 `HappyStk` + happy_x_8 `HappyStk` + happy_x_7 `HappyStk` + happy_x_6 `HappyStk` + happy_x_5 `HappyStk` + happy_x_4 `HappyStk` + happy_x_3 `HappyStk` + happy_x_2 `HappyStk` + happy_x_1 `HappyStk` + happyRest) + = case happyOut14 happy_x_5 of { happy_var_5 -> + case happyOut16 happy_x_9 of { happy_var_9 -> + happyIn11 + (Version{ versionBranch=happy_var_5, versionTags=happy_var_9 } + ) `HappyStk` happyRest}} + +happyReduce_17 = happySpecReduce_3 7# happyReduction_17 +happyReduction_17 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut13 happy_x_2 of { happy_var_2 -> + happyIn12 + (happy_var_2 + )} + +happyReduce_18 = happySpecReduce_1 8# happyReduction_18 +happyReduction_18 happy_x_1 + = case happyOut10 happy_x_1 of { happy_var_1 -> + happyIn13 + ([ happy_var_1 ] + )} + +happyReduce_19 = happySpecReduce_3 8# happyReduction_19 +happyReduction_19 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut10 happy_x_1 of { happy_var_1 -> + case happyOut13 happy_x_3 of { happy_var_3 -> + happyIn13 + (happy_var_1 : happy_var_3 + )}} + +happyReduce_20 = happySpecReduce_2 9# happyReduction_20 +happyReduction_20 happy_x_2 + happy_x_1 + = happyIn14 + ([] + ) + +happyReduce_21 = happySpecReduce_3 9# happyReduction_21 +happyReduction_21 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut15 happy_x_2 of { happy_var_2 -> + happyIn14 + (happy_var_2 + )} + +happyReduce_22 = happySpecReduce_1 10# happyReduction_22 +happyReduction_22 happy_x_1 + = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> + happyIn15 + ([ fromIntegral happy_var_1 ] + )} + +happyReduce_23 = happySpecReduce_3 10# happyReduction_23 +happyReduction_23 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> + case happyOut15 happy_x_3 of { happy_var_3 -> + happyIn15 + (fromIntegral happy_var_1 : happy_var_3 + )}} + +happyReduce_24 = happySpecReduce_2 11# happyReduction_24 +happyReduction_24 happy_x_2 + happy_x_1 + = happyIn16 + ([] + ) + +happyReduce_25 = happySpecReduce_3 11# happyReduction_25 +happyReduction_25 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut17 happy_x_2 of { happy_var_2 -> + happyIn16 + (reverse happy_var_2 + )} + +happyReduce_26 = happySpecReduce_1 12# happyReduction_26 +happyReduction_26 happy_x_1 + = case happyOutTok happy_x_1 of { (ITstring happy_var_1) -> + happyIn17 + ([ happy_var_1 ] + )} + +happyReduce_27 = happySpecReduce_3 12# happyReduction_27 +happyReduction_27 happy_x_3 + happy_x_2 + happy_x_1 + = case happyOut17 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> + happyIn17 + (happy_var_3 : happy_var_1 + )}} + +happyNewToken action sts stk [] = + happyDoAction 11# (error "reading EOF!") action sts stk [] + +happyNewToken action sts stk (tk:tks) = + let cont i = happyDoAction i tk action sts stk tks in + case tk of { + ITocurly -> cont 1#; + ITccurly -> cont 2#; + ITobrack -> cont 3#; + ITcbrack -> cont 4#; + ITcomma -> cont 5#; + ITequal -> cont 6#; + ITvarid happy_dollar_dollar -> cont 7#; + ITconid happy_dollar_dollar -> cont 8#; + ITstring happy_dollar_dollar -> cont 9#; + ITinteger happy_dollar_dollar -> cont 10#; + _ -> happyError' (tk:tks) + } + +happyError_ tk tks = happyError' (tk:tks) + +newtype HappyIdentity a = HappyIdentity a +happyIdentity = HappyIdentity +happyRunIdentity (HappyIdentity a) = a + +instance Monad HappyIdentity where + return = HappyIdentity + (HappyIdentity p) >>= q = q p + +happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b +happyThen = (>>=) +happyReturn :: () => a -> HappyIdentity a +happyReturn = (return) +happyThen1 m k tks = (>>=) m (\a -> k a tks) +happyReturn1 :: () => a -> b -> HappyIdentity a +happyReturn1 = \a tks -> (return) a +happyError' :: () => [Token] -> HappyIdentity a +happyError' = HappyIdentity . happyError + +parse tks = happyRunIdentity happySomeParser where + happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) + +parseOne tks = happyRunIdentity happySomeParser where + happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) + +happySeq = happyDoSeq + +type PackageConfig = InstalledPackageInfo + +defaultPackageConfig = emptyInstalledPackageInfo + +data Token + = ITocurly + | ITccurly + | ITobrack + | ITcbrack + | ITcomma + | ITequal + | ITvarid String + | ITconid String + | ITstring String + | ITinteger Int + +lexer :: String -> [Token] + +lexer [] = [] +lexer ('{':cs) = ITocurly : lexer cs +lexer ('}':cs) = ITccurly : lexer cs +lexer ('[':cs) = ITobrack : lexer cs +lexer (']':cs) = ITcbrack : lexer cs +lexer (',':cs) = ITcomma : lexer cs +lexer ('=':cs) = ITequal : lexer cs +lexer ('"':cs) = lexString cs "" +lexer (c:cs) + | isSpace c = lexer cs + | isAlpha c = lexID (c:cs) + | isDigit c = lexInt (c:cs) +lexer _ = error ( "Unexpected token") + +lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest + where + (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs + +lexInt cs = let (intStr, rest) = span isDigit cs + in ITinteger (read intStr) : lexer rest + + +lexString ('"':cs) s = ITstring (reverse s) : lexer cs +lexString ('\\':c:cs) s = lexString cs (c:s) +lexString (c:cs) s = lexString cs (c:s) + +happyError _ = error "Couldn't parse package configuration." + +parsePkgConf :: String -> [PackageConfig] +parsePkgConf = parse . lexer + +parseOnePkgConf :: String -> PackageConfig +parseOnePkgConf = parseOne . lexer +{-# LINE 1 "GenericTemplate.hs" #-} +{-# LINE 1 "" #-} +{-# LINE 1 "" #-} +{-# LINE 1 "GenericTemplate.hs" #-} +-- $Id$ + + +{-# LINE 28 "GenericTemplate.hs" #-} + + +data Happy_IntList = HappyCons Int# Happy_IntList + + + + + + +{-# LINE 49 "GenericTemplate.hs" #-} + + +{-# LINE 59 "GenericTemplate.hs" #-} + + + + + + + + + + +infixr 9 `HappyStk` +data HappyStk a = HappyStk a (HappyStk a) + +----------------------------------------------------------------------------- +-- starting the parse + +happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll + +----------------------------------------------------------------------------- +-- Accepting the parse + +-- If the current token is 0#, it means we've just accepted a partial +-- parse (a %partial parser). We must ignore the saved token on the top of +-- the stack in this case. +happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = + happyReturn1 ans +happyAccept j tk st sts (HappyStk ans _) = + (happyTcHack j (happyTcHack st)) (happyReturn1 ans) + +----------------------------------------------------------------------------- +-- Arrays only: do the next action + + + +happyDoAction i tk st + = {- nothing -} + + + case action of + 0# -> {- nothing -} + happyFail i tk st + -1# -> {- nothing -} + happyAccept i tk st + n | (n <# (0# :: Int#)) -> {- nothing -} + + (happyReduceArr ! rule) i tk st + where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) + n -> {- nothing -} + + + happyShift new_state i tk st + where new_state = (n -# (1# :: Int#)) + where off = indexShortOffAddr happyActOffsets st + off_i = (off +# i) + check = if (off_i >=# (0# :: Int#)) + then (indexShortOffAddr happyCheck off_i ==# i) + else False + action | check = indexShortOffAddr happyTable off_i + | otherwise = indexShortOffAddr happyDefActions st + + + + + + + + + + + +indexShortOffAddr (HappyA# arr) off = +#if __GLASGOW_HASKELL__ > 500 + narrow16Int# i +#elif __GLASGOW_HASKELL__ == 500 + intToInt16# i +#else + (i `iShiftL#` 16#) `iShiftRA#` 16# +#endif + where +#if __GLASGOW_HASKELL__ >= 503 + i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) +#else + i = word2Int# ((high `shiftL#` 8#) `or#` low) +#endif + high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) + low = int2Word# (ord# (indexCharOffAddr# arr off')) + off' = off *# 2# + + + + + +data HappyAddr = HappyA# Addr# + + + + +----------------------------------------------------------------------------- +-- HappyState data type (not arrays) + +{-# LINE 170 "GenericTemplate.hs" #-} + +----------------------------------------------------------------------------- +-- Shifting a token + +happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = + let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in +-- trace "shifting the error token" $ + happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) + +happyShift new_state i tk st sts stk = + happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) + +-- happyReduce is specialised for the common cases. + +happySpecReduce_0 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_0 nt fn j tk st@((action)) sts stk + = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) + +happySpecReduce_1 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') + = let r = fn v1 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_2 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') + = let r = fn v1 v2 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_3 i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') + = let r = fn v1 v2 v3 in + happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) + +happyReduce k i fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyReduce k nt fn j tk st sts stk + = case happyDrop (k -# (1# :: Int#)) sts of + sts1@((HappyCons (st1@(action)) (_))) -> + let r = fn stk in -- it doesn't hurt to always seq here... + happyDoSeq r (happyGoto nt j tk st1 sts1 r) + +happyMonadReduce k nt fn 0# tk st sts stk + = happyFail 0# tk st sts stk +happyMonadReduce k nt fn j tk st sts stk = + happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) + where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) + drop_stk = happyDropStk k stk + +happyDrop 0# l = l +happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t + +happyDropStk 0# l = l +happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs + +----------------------------------------------------------------------------- +-- Moving to a new state after a reduction + + +happyGoto nt j tk st = + {- nothing -} + happyDoAction j tk new_state + where off = indexShortOffAddr happyGotoOffsets st + off_i = (off +# nt) + new_state = indexShortOffAddr happyTable off_i + + + + +----------------------------------------------------------------------------- +-- Error recovery (0# is the error token) + +-- parse error if we are in recovery and we fail again +happyFail 0# tk old_st _ stk = +-- trace "failing" $ + happyError_ tk + +{- We don't need state discarding for our restricted implementation of + "error". In fact, it can cause some bogus parses, so I've disabled it + for now --SDM + +-- discard a state +happyFail 0# tk old_st (HappyCons ((action)) (sts)) + (saved_tok `HappyStk` _ `HappyStk` stk) = +-- trace ("discarding state, depth " ++ show (length stk)) $ + happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) +-} + +-- Enter error recovery: generate an error token, +-- save the old token and carry on. +happyFail i tk (action) sts stk = +-- trace "entering error recovery" $ + happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) + +-- Internal happy errors: + +notHappyAtAll = error "Internal Happy error\n" + +----------------------------------------------------------------------------- +-- Hack to get the typechecker to accept our action functions + + +happyTcHack :: Int# -> a -> a +happyTcHack x y = y +{-# INLINE happyTcHack #-} + + +----------------------------------------------------------------------------- +-- Seq-ing. If the --strict flag is given, then Happy emits +-- happySeq = happyDoSeq +-- otherwise it emits +-- happySeq = happyDontSeq + +happyDoSeq, happyDontSeq :: a -> b -> b +happyDoSeq a b = a `seq` b +happyDontSeq a b = b + +----------------------------------------------------------------------------- +-- Don't inline any functions from the template. GHC has a nasty habit +-- of deciding to inline happyGoto everywhere, which increases the size of +-- the generated parser quite a bit. + + +{-# NOINLINE happyDoAction #-} +{-# NOINLINE happyTable #-} +{-# NOINLINE happyCheck #-} +{-# NOINLINE happyActOffsets #-} +{-# NOINLINE happyGotoOffsets #-} +{-# NOINLINE happyDefActions #-} + +{-# NOINLINE happyShift #-} +{-# NOINLINE happySpecReduce_0 #-} +{-# NOINLINE happySpecReduce_1 #-} +{-# NOINLINE happySpecReduce_2 #-} +{-# NOINLINE happySpecReduce_3 #-} +{-# NOINLINE happyReduce #-} +{-# NOINLINE happyMonadReduce #-} +{-# NOINLINE happyGoto #-} +{-# NOINLINE happyFail #-} + +-- end of Happy Template. move ./System/Plugins/ParsePkgConfCabal.y ./System/Plugins/ParsePkgConfCabal.y_in rmdir ./src hunk ./Makefile 6 -.PHONY: build all - -all: build EvalHaskell.h - -EvalHaskell.h: build - cp System/Eval/Haskell_stub.h $@ - hunk ./System/Eval/Haskell.hs 1 -{-# OPTIONS -fglasgow-exts -fffi #-} hunk ./System/Eval/Haskell.hs 30 - mkHsValues, + mkHsValues, hunk ./System/Eval/Haskell.hs 32 +{- hunk ./System/Eval/Haskell.hs 37 +-} hunk ./System/Eval/Haskell.hs 211 +{- hunk ./System/Eval/Haskell.hs 262 +-} hunk ./plugins.cabal 1 -name: plugins -version: 0.9.10 -license: LGPL -License-file: LICENSE +name: plugins +version: 0.9.10 +license: LGPL +License-file: LICENSE hunk ./plugins.cabal 6 -maintainer: dons@cse.unsw.edu.au +maintainer: dons@cse.unsw.edu.au hunk ./plugins.cabal 8 - AltData.Dynamic, - AltData.Typeable, + AltData.Dynamic, + AltData.Typeable, hunk ./plugins.cabal 34 -includes: Linker.h +includes: Linker.h hunk ./plugins.cabal 36 -Build-Depends: base, haskell98, Cabal, haskell-src +Build-Depends: base, Cabal, haskell-src hunk ./plugins.cabal 38 - hunk ./plugins.cabal.hsx 1 -name: plugins -version: 0.9.10 -license: LGPL -License-file: LICENSE +name: plugins +version: 0.9.10 +license: LGPL +License-file: LICENSE hunk ./plugins.cabal.hsx 6 -maintainer: dons@cse.unsw.edu.au +maintainer: dons@cse.unsw.edu.au hunk ./plugins.cabal.hsx 8 - AltData.Dynamic, - AltData.Typeable, + AltData.Dynamic, + AltData.Typeable, hunk ./plugins.cabal.hsx 34 -includes: Linker.h -Build-Depends: base, haskell98, Cabal, haskell-src-exts +includes: Linker.h +extensions: CPP, ForeignFunctionInterface +Build-Depends: base, Cabal, haskell-src-exts move ./examples ./testsuite addfile ./testsuite/eval/foreign_eval/dont_test addfile ./testsuite/eval/foreign_eval1/dont_test addfile ./testsuite/eval/foreign_should_fail/dont_test addfile ./testsuite/eval/foreign_should_fail_illtyped/dont_test hunk ./testsuite/build.mk 4 -include $(TOP)/examples/check.mk +include $(TOP)/testsuite/check.mk hunk ./testsuite/build.mk 15 -INCLUDES= -i$(TOP)/examples/$(TEST)/api +INCLUDES= -i$(TOP)/testsuite/$(TEST)/api hunk ./testsuite/eval/eval3/Main.hs 7 --- instance of Typeable (see hs-plugins/examples/eval/eval_fn1/Poly.hs +-- instance of Typeable (see hs-plugins/testsuite/eval/eval_fn1/Poly.hs hunk ./testsuite/eval.mk 2 -include $(TOP)/examples/check.mk +include $(TOP)/testsuite/check.mk hunk ./testsuite/foreign.mk 2 -include $(TOP)/examples/check.mk +include $(TOP)/testsuite/check.mk hunk ./testsuite/load/null/prog/Main.hs 11 - let includes = [TOP ++ "/examples/load/null/api"] + let includes = [TOP ++ "/testsuite/load/null/api"] hunk ./testsuite/makewith/io/prog/expected 1 -True +merge failed: + +parse error in ../TestIO.conf +line: 17, col: 1 + +a.out: failed hunk ./testsuite/makewith/unsafeio/prog/expected 1 -True +merge failed: + +parse error in ../Unsafe.conf +line: 13, col: 1 + +a.out: failed hunk ./testsuite/pkgconf/null/prog/Main.hs 9 - let includes = TOP ++ "/examples/load/null/api" + let includes = TOP ++ "/testsuite/load/null/api" hunk ./configure.ac 140 -AC_CONFIG_FILES([config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) +AC_CONFIG_FILES([config.mk testsuite/makewith/io/TestIO.conf testsuite/makewith/unsafeio/Unsafe.conf]) hunk ./Makefile 4 -# cut down reimplementation of $fptools/mk directory - -# -# installing -# - -# TODO put these in subdirs -install: - $(INSTALL_DATA_DIR) $(LIBDIR)/include - $(INSTALL_DATA) EvalHaskell.h $(LIBDIR)/include - $(INSTALL_DATA_DIR) $(MANDIR)/man1 - $(INSTALL_DATA) docs/hs-plugins.1 $(MANDIR)/man1 - cd src && ./setup install - hunk ./Makefile 8 - @if [ ! -f EvalHaskell.h ] ; then \ - echo "run 'make' first" ; \ - exit 1 ;\ - fi hunk ./Makefile 9 - for i in `find examples ! -name CVS -type d -maxdepth 2 -mindepth 2 | sort` ; do \ + for i in `find testsuite ! -name CVS -type d -maxdepth 2 -mindepth 2 | sort` ; do \ hunk ./Makefile 32 - find examples -name '*.a' -exec rm {} \; - find examples -name '*~' -exec rm {} \; - find examples -name 'a.out' -exec rm {} \; - find examples -name '*.hi' -exec rm {} \; - find examples -name '*.o' -exec rm {} \; - find examples -name '*.core' -exec rm {} \; - find examples -name 'package.conf' -exec rm {} \; - rm -f examples/makewith/io/TestIO.conf - rm -f examples/makewith/unsafeio/Unsafe.conf - rm -rf examples/hmake/lib-plugs/plugs - rm -rf examples/hmake/one-shot/runplugs - rm -f EvalHaskell.h + find testsuite -name '*.a' -exec rm {} \; + find testsuite -name '*~' -exec rm {} \; + find testsuite -name 'a.out' -exec rm {} \; + find testsuite -name '*.hi' -exec rm {} \; + find testsuite -name '*.o' -exec rm {} \; + find testsuite -name '*.core' -exec rm {} \; + find testsuite -name 'package.conf' -exec rm {} \; + rm -f testsuite/makewith/io/TestIO.conf + rm -f testsuite/makewith/unsafeio/Unsafe.conf + rm -rf testsuite/plugs/plugs/plugs + rm -rf testsuite/plugs/plugs/runplugs hunk ./Makefile 45 --include config.mk hunk ./README 77 -Have a look in the examples/ directory for many examples of how to +Have a look in the testsuite/ directory for many examples of how to hunk ./AltData/Dynamic.hs 1 -{-# OPTIONS -fglasgow-exts -cpp #-} ------------------------------------------------------------------------------ +{-# OPTIONS -fglasgow-exts #-} +-- hunk ./AltData/Typeable.hs 1 -{-# OPTIONS -cpp -fglasgow-exts -fno-implicit-prelude #-} +{-# OPTIONS -fglasgow-exts #-} hunk ./System/Eval/Haskell.hs 56 -import Foreign.C -import Foreign +-- import Foreign.C +-- import Foreign hunk ./System/Eval/Haskell.hs 179 - m_v <- load obj [pwd] loadpath symbol + m_v <- load obj [pwd] loadpath symbol :: IO (LoadStatus Dynamic) hunk ./System/Eval/Haskell.hs 181 - LoadFailure _ -> return "" - LoadSuccess _ (v::Dynamic) -> return $ (init . tail) $ show v + LoadFailure _ -> return "" + LoadSuccess _ v -> return $ (init . tail) $ show v hunk ./System/Eval/Utils.hs 1 -{-# OPTIONS -fglasgow-exts -fffi -cpp #-} hunk ./System/MkTemp.hs 1 -{-# OPTIONS -cpp -fffi -fglasgow-exts #-} +{-# OPTIONS -fglasgow-exts #-} hunk ./System/Plugins/Load.hs 1 -{-# OPTIONS -#include "Linker.h" #-} hunk ./System/Plugins/PackageAPI.hs 1 -{-# OPTIONS -cpp #-} hunk ./System/Plugins/ParsePkgConfCabal.hs 1 -{-# OPTIONS -fglasgow-exts -cpp #-} +{-# OPTIONS -fglasgow-exts #-} hunk ./System/Plugins/ParsePkgConfLite.hs 1 -{-# OPTIONS -fglasgow-exts -cpp #-} +{-# OPTIONS -fglasgow-exts #-} hunk ./System/Plugins/Process.hs 1 -{-# OPTIONS -cpp #-} hunk ./System/Plugins/Utils.hs 1 -{-# OPTIONS -cpp #-} hunk ./README 50 + $ mv plugins.cabal.hsx plugins.cabal hunk ./config.mk.in 7 - -PREFIX = @PREFIX@ -LIBDIR = $(PREFIX)/lib/$(PACKAGE)-$(VERSION) -BINDIR = $(PREFIX)/bin -MANDIR = $(PREFIX)/man - hunk ./config.mk.in 9 - -# A few aliases -INSTALL = @INSTALL@ -INSTALL_PROGRAM = ${INSTALL} -s -m 755 -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_DATA_DIR= ${INSTALL} -d -m 755 hunk ./config.mk.in 2 - -VERSION = 0.9.10 -PACKAGE = plugins - hunk ./configure 2711 - ac_config_files="$ac_config_files config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" + ac_config_files="$ac_config_files config.mk testsuite/makewith/io/TestIO.conf testsuite/makewith/unsafeio/Unsafe.conf" hunk ./configure 3239 - "examples/makewith/io/TestIO.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/io/TestIO.conf" ;; - "examples/makewith/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/unsafeio/Unsafe.conf" ;; + "testsuite/makewith/io/TestIO.conf" ) CONFIG_FILES="$CONFIG_FILES testsuite/makewith/io/TestIO.conf" ;; + "testsuite/makewith/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES testsuite/makewith/unsafeio/Unsafe.conf" ;; hunk ./install-sh 1 -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# 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="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - 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 [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -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 [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# 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. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 rmfile ./install-sh addfile ./install.sh adddir ./src move ./AltData ./src/AltData move ./Language ./src/Language move ./System ./src/System hunk ./configure 274 -ac_unique_file="System/Plugins.hs" +ac_unique_file="src/System/Plugins.hs" hunk ./configure.ac 11 -AC_INIT(System/Plugins.hs) +AC_INIT(src/System/Plugins.hs) hunk ./plugins.cabal 33 - Language/Hi/hschooks.c + src/Language/Hi/hschooks.c hunk ./plugins.cabal 38 +Hs-source-dirs: src hunk ./plugins.cabal.hsx 33 - Language/Hi/hschooks.c + src/Language/Hi/hschooks.c hunk ./plugins.cabal.hsx 38 - +Hs-source-dirs: src hunk ./src/Language/Hi/Parser.hs 51 -#include "../../config.h" +#include "../../../config.h" hunk ./src/System/Plugins/Consts.hs 22 -#include "../../config.h" +#include "../../../config.h" hunk ./src/System/Plugins/Env.hs 48 -#include "../../config.h" +#include "../../../config.h" hunk ./src/System/Plugins/Load.hs 52 -#include "../../config.h" +#include "../../../config.h" hunk ./src/System/Plugins/PackageAPI.hs 39 -#include "../../config.h" +#include "../../../config.h" hunk ./src/System/Plugins/Parser.hs 27 -#include "../../config.h" +#include "../../../config.h" hunk ./src/System/Plugins/Utils.hs 59 -#include "../../config.h" +#include "../../../config.h" hunk ./docs/hs-plugins.tex 763 -compile. \code{Just v} gives you \code{v}, the result of evaluating -your code. It is interesting to note that \code{eval} has the type of -an interpreter. The \code{Typeable} constraint is used to type check -the evaluated code when it is loaded, using \code{dynload}. -As usual, \code{eval\_} is a version of \code{eval} that lets you pass -extra flags to ghc and to the dynamic loader. +compile, or did not typecheck at its splice point. \code{Just v} gives +you \code{v}, the result of evaluating your code. It is interesting to +note that \code{eval} has the type of an interpreter. The +\code{Typeable} constraint is used to type check the evaluated code when +it is loaded, using \code{dynload}. As usual, \code{eval\_} is a +version of \code{eval} that lets you pass extra flags to ghc and to the +dynamic loader. hunk ./src/System/Eval/Haskell.hs 21 --- compile and run haskell strings at runtime. +-- | Evaluate Haskell at runtime, using runtime compilation and dynamic +-- loading. Arguments are compiled to native code, and dynamically +-- loaded, returning a Haskell value representing the compiled argument. +-- The underlying implementation treats 'String' arguments as the source +-- for plugins to be compiled at runtime. hunk ./src/System/Eval/Haskell.hs 63 +-- | 'eval' provides a typesafe (to a limit) form of runtime evaluation +-- for Haskell -- a limited form of /runtime metaprogramming/. The +-- 'String' argument to 'eval' is a Haskell source fragment to evaluate +-- at rutime. @imps@ are a list of module names to use in the context of +-- the compiled value. +-- +-- The value returned by 'eval' is constrained to be 'Typeable' -- +-- meaning we can perform a /limited/ runtime typecheck, using the +-- 'dynload' function. One consequence of this is that the code must +-- evaluate to a monomorphic value (which will be wrapped in a +-- 'Dynamic'). hunk ./src/System/Eval/Haskell.hs 75 --- ok. the idea is: the have either installed the library, in which case --- is is registered, and the path to altdata is known to ghc, so just --- saying "-package altdata" will work. if not, we search in the build --- dir just in case. this should work for inplace work. +-- If the evaluated code typechecks under the 'Typeable' constraints, +-- 'Just v' is returned. 'Nothing' indicates typechecking failed. +-- Typechecking may fail at two places: when compiling the argument, or +-- when typechecking the splice point. 'eval' resembles a +-- metaprogramming 'run' operator for /closed/ source fragments. hunk ./src/System/Eval/Haskell.hs 81 --- TODO could have a few extra package.conf search paths in here, --- including PREFIX. +-- To evaluate polymorphic values you need to wrap them in data +-- structures using rank-N types. hunk ./src/System/Eval/Haskell.hs 84 - --- --------------------------------------------------------------------- --- return a compiled value, and type check it first +-- Examples: hunk ./src/System/Eval/Haskell.hs 86 --- TODO make this faster. +-- > do i <- eval "1 + 6 :: Int" [] :: IO (Maybe Int) +-- > when (isJust i) $ putStrLn (show (fromJust i)) hunk ./src/System/Eval/Haskell.hs 90 -eval src mods = do +eval src imps = do hunk ./src/System/Eval/Haskell.hs 93 - tmpf <- mkUniqueWith dynwrap src mods + tmpf <- mkUniqueWith dynwrap src imps hunk ./src/System/Eval/Haskell.hs 104 --- --------------------------------------------------------------------- --- Version of eval with all the buttons available. +-- +-- | 'eval_' is a variety of 'eval' with all the internal hooks +-- available. You are able to set any extra arguments to the compiler +-- (for example, optimisation flags) or dynamic loader, as well as +-- having any errors returned in an 'Either' type. +-- hunk ./src/System/Eval/Haskell.hs 132 --- --------------------------------------------------------------------- --- unsafe because it doesn't use Dynamic types --- useful for not having to provide type constraints to values, or when --- you want to easily deal with polymorphic values. +-- | Sometimes when constructing string fragments to evaluate, the +-- programmer is able to provide some other constraint on the evaluated +-- string, such that the evaluated expression will be typesafe, without +-- requiring a 'Typeable' constraint. In such cases, the monomorphic +-- restriction is annoying. 'unsafeEval' removes any splice-point +-- typecheck, with an accompanying obligation on the programmer to +-- ensure that the fragment evaluated will be typesafe at the point it +-- is spliced. +-- +-- An example of how to do this would be to wrap the fragment in a call +-- to 'show'. The augmented fragment would then be checked when compiled +-- to return a 'String', and the programmer can rely on this, without +-- requiring a splice-point typecheck, and thus no 'Typeable' +-- restriction. +-- +-- Note that if you get the proof wrong, your program will likely +-- segfault. +-- +-- Example: +-- +-- > do s <- unsafeEval "map toUpper \"haskell\"" ["Data.Char"] +-- > when (isJust s) $ putStrLn (fromJust s) hunk ./src/System/Eval/Haskell.hs 169 --- --- like unsafeEval, except you can supply extra args to make and load, --- and the error messages are returned too. hunk ./src/System/Eval/Haskell.hs 170 --- Need to be able to specify a search path to look in. +-- | 'unsafeEval_' is a form of 'unsafeEval' with all internal hooks +-- exposed. This is useful for application wishing to return error +-- messages to users, to specify particular libraries to link against +-- and so on. hunk ./src/System/Eval/Haskell.hs 196 --- Convenience function for use with eval (and friends). Returns a --- string of Haskell code with the Data.Map passed as values. +-- | 'mkHsValues' is a helper function for converting 'Data.Map's +-- of names and values into Haskell code. It relies on the assumption of +-- names and values into Haskell code. It relies on the assumption that +-- the passed values' Show instances produce valid Haskell literals +-- (this is true for all Prelude types). hunk ./src/System/Eval/Haskell.hs 208 --- return a compiled value's type, by using Dynamic to get a +-- | Return a compiled value's type, by using Dynamic to get a hunk ./plugins.cabal 38 -Hs-source-dirs: src +hs-source-dir: src hunk ./plugins.cabal.hsx 38 -Hs-source-dirs: src +hs-source-dir: src hunk ./src/System/Plugins/Make.hs 20 +-- | An interface to a Haskell compiler, providing the facilities of a +-- compilation manager. + hunk ./src/System/Plugins/Make.hs 25 + -- * The @MakeStatus@ type + MakeStatus(..), + + -- * The @MakeCode@ type + MakeCode(..), + + -- * Compiling Haskell modules hunk ./src/System/Plugins/Make.hs 35 - MakeStatus(..), - MakeCode(..), hunk ./src/System/Plugins/Make.hs 36 + -- * Handling reecompilation hunk ./src/System/Plugins/Make.hs 42 + -- * Merging together Haskell source files + MergeStatus(..), + MergeCode, + Args, + Errors, hunk ./src/System/Plugins/Make.hs 50 - MergeStatus(..), - MergeCode, hunk ./src/System/Plugins/Make.hs 51 + -- * Cleaning up temporary files hunk ./src/System/Plugins/Make.hs 55 + -- * Low-level compilation primitives hunk ./src/System/Plugins/Make.hs 84 - ------------------------------------------------------------------------- hunk ./src/System/Plugins/Make.hs 85 --- A better compiler status. +-- | The @MakeStatus@ type represents success or failure of compilation. +-- Compilation can fail for the usual reasons: syntax errors, type +-- errors and the like. The @MakeFailure@ constructor returns any error +-- messages produced by the compiler. @MakeSuccess@ returns a @MakeCode@ +-- value, and the path to the object file produced. hunk ./src/System/Plugins/Make.hs 92 - = MakeSuccess MakeCode FilePath - | MakeFailure Errors + = MakeSuccess MakeCode FilePath -- ^ compilation was successful + | MakeFailure Errors -- ^ compilation failed hunk ./src/System/Plugins/Make.hs 96 -data MakeCode = ReComp | NotReq +-- | The @MakeCode@ type is used when compilation is successful, to +-- distinguish two cases: +-- * The source file needed recompiling, and this was done +-- * The source file was already up to date, recompilation was skipped +data MakeCode + = ReComp -- ^ recompilation was performed + | NotReq -- ^ recompilation was not required hunk ./src/System/Plugins/Make.hs 105 ------------------------------------------------------------------------- hunk ./src/System/Plugins/Make.hs 106 --- An equivalent status for the preprocessor (merge) +-- | An equivalent status for the preprocessor phase hunk ./src/System/Plugins/Make.hs 109 - = MergeSuccess MergeCode Args FilePath - | MergeFailure Errors + = MergeSuccess MergeCode Args FilePath -- ^ the merge was successful + | MergeFailure Errors -- ^ failure, and any errors returned hunk ./src/System/Plugins/Make.hs 113 +-- +-- | Merging may be avoided if the source files are older than an +-- existing merged result. The @MergeCode@ type indicates whether +-- merging was performed, or whether it was unneccessary. +-- hunk ./src/System/Plugins/Make.hs 120 +-- | A list of @String@ arguments hunk ./src/System/Plugins/Make.hs 122 + +-- | Convience synonym hunk ./src/System/Plugins/Make.hs 126 +-- touch. + +-- --------------------------------------------------------------------- +-- | One-shot unconditional compilation of a single Haskell module. +-- @make@ behaves like 'ghc -c'. Extra arguments to 'ghc' may be passed +-- in the 'args' parameter, they will be appended to the argument list. +-- @make@ always recompiles its target, whether or not it is out of +-- date. +-- +-- A side-effect of calling 'make' is to have GHC produce a @.hi@ file +-- containing a list of package and objects that the source depends on. +-- Subsequent calls to 'load' will use this interface file to load +-- module and library dependencies prior to loading the object itself. hunk ./src/System/Plugins/Make.hs 140 --- |Returns @True@ if the module or any of its dependencies have older object files than source files. --- Defaults to @True@ if some files couldn't be located. +make :: FilePath -> [Arg] -> IO MakeStatus +make src args = rawMake src ("-c":args) True + +-- | 'makeAll' recursively compiles any dependencies it can find using +-- GHC's @--make@ flag. Dependencies will be recompiled only if they are +-- visible to 'ghc' -- this may require include paths in the 'args' +-- parameter. 'makeAll' takes the top-level file as the first argument. +-- +makeAll :: FilePath -> [Arg] -> IO MakeStatus +makeAll src args = + rawMake src ( "--make":"-no-hs-main":"-no-link":"-v0":args ) False + +-- | merge two files; then make them. will leave a .o and .hi file in tmpDir. +-- +makeWith :: FilePath -- ^ a src file + -> FilePath -- ^ a syntax stub file + -> [Arg] -- ^ any required args + -> IO MakeStatus -- ^ path to an object file + +makeWith src stub args = do + status <- merge src stub + case status of + MergeFailure errs -> return $ MakeFailure ("merge failed:\n":errs) + MergeSuccess _ args' tmpf -> do + status' <- rawMake tmpf ("-c": args' ++ args) True + return status' + +------------------------------------------------------------------------ +-- +-- | @hasChanged@ returns @True@ if the module or any of its +-- dependencies have older object files than source files. Defaults to +-- @True@ if some files couldn't be located. hunk ./src/System/Plugins/Make.hs 192 --- |Same as 'makeAll' but with better recompilation checks since module dependencies are known. +-- | Same as 'makeAll' but with better recompilation checks since module +-- dependencies are known. hunk ./src/System/Plugins/Make.hs 210 --- touch. - --- --------------------------------------------------------------------- --- | Standard make. Compile a single module, unconditionally. --- Behaves like ghc -c --- -make :: FilePath -> [Arg] -> IO MakeStatus -make src args = rawMake src ("-c":args) True - --- | Recursive make. Compile a module, and its dependencies if we can --- find them. Takes the top-level file as the first argument. --- Behaves like ghc --make --- -makeAll :: FilePath -> [Arg] -> IO MakeStatus -makeAll src args = - rawMake src ( "--make":"-no-hs-main":"-no-link":"-v0":args ) False - --- | merge two files; then make them. will leave a .o and .hi file in tmpDir. --- -makeWith :: FilePath -- ^ a src file - -> FilePath -- ^ a syntax stub file - -> [Arg] -- ^ any required args - -> IO MakeStatus -- ^ path to an object file - -makeWith src stub args = do - status <- merge src stub - case status of - MergeFailure errs -> return $ MakeFailure ("merge failed:\n":errs) - MergeSuccess _ args' tmpf -> do - status' <- rawMake tmpf ("-c": args' ++ args) True - return status' - hunk ./src/System/Plugins/Make.hs 145 --- visible to 'ghc' -- this may require include paths in the 'args' --- parameter. 'makeAll' takes the top-level file as the first argument. +-- visible to 'ghc' -- this may require passing appropriate include path +-- flags in the 'args' parameter. 'makeAll' takes the top-level file as +-- the first argument. hunk ./src/System/Plugins/Make.hs 153 --- | merge two files; then make them. will leave a .o and .hi file in tmpDir. +-- | This is a variety of 'make' that first calls 'merge' to +-- combine the plugin source with a syntax stub. The result is then +-- compiled. This is provided for EDSL authors who wish to add extra +-- syntax to a user\'s source. It is important to note that the +-- module and types from the second file argument are used to override +-- any of those that appear in the first argument. For example, consider +-- the following source files: +-- +-- > module A where +-- > a :: Integer +-- > a = 1 +-- +-- and +-- +-- > module B where +-- > a :: Int +-- +-- Calling @makeWith "A" "B" []@ will merge the module name and types +-- from module B into module A, generating a third file: +-- +-- > {-# LINE 1 "A.hs" #-} +-- > module MxYz123 where +-- > {-# LINE 3 "B.hs" #-} +-- > a :: Int +-- > {-# LINE 4 "A.hs" #-} +-- > a = 1 hunk ./src/System/Plugins/Make.hs 218 --- | Same as 'makeAll' but with better recompilation checks since module --- dependencies are known. +-- | 'recompileAll' is like 'makeAll', but rather than relying on +-- @ghc --make@, we explicitly check a module\'s dependencies using our +-- internal map of module dependencies. Performance is thus better, and +-- the result is more accurate. hunk ./src/System/Plugins/Make.hs 282 --- compile a .hs file to a .o file --- +-- | Lower-level than 'make'. Compile a .hs file to a .o file hunk ./src/System/Plugins/Make.hs 287 -build :: FilePath -- path to .hs source - -> FilePath -- path to object file - -> [String] -- any extra cmd line flags +build :: FilePath -- ^ path to .hs source + -> FilePath -- ^ path to object file + -> [String] -- ^ any extra cmd line flags hunk ./src/System/Plugins/Make.hs 320 +-- The merging operation is extremely useful for providing extra default +-- syntax. An EDSL user then need not worry about declaring module +-- names, or having required imports. In this way, the stub file can +-- also be used to provide syntax declarations that would be +-- inconvenient to require of the plugin author. +-- +-- 'merge' will include any import and export declarations written in +-- the stub, as well as any module name, so that plugin author\'s need +-- not worry about this compulsory syntax. Additionally, if a plugin +-- requires some non-standard library, which must be provided as a +-- @-package@ flag to GHC, they may specify this using the non-standard +-- @GLOBALOPTIONS@ pragma. Options specified in the source this way +-- will be added to the command line. This is useful for users who wish +-- to use GHC flags that cannot be specified using the conventional +-- @OPTIONS@ pragma. The merging operation uses the parser hs-plugins +-- was configured with, either 'Language.Haskell' or the HSX parser, to +-- parse Haskell source files. +-- hunk ./src/System/Plugins/Make.hs 348 --- | Merge to source files and store them in the specified output file, --- instead of a temp file as merge does. --- +-- | 'mergeTo' behaves like 'merge', but we can specify the file in +-- which to place output. hunk ./src/System/Plugins/Make.hs 353 +-- | 'mergeToDir' behaves like 'merge', but lets you specify a target +-- directory. hunk ./src/System/Plugins/Make.hs 420 --- .hi and .o components. Silently ignore any missing components. *Does --- not remove .hs files*. To do that use makeCleaner. This would be +-- .hi and .o components. Silently ignore any missing components. /Does +-- not remove .hs files/. To do that use 'makeCleaner'. This would be hunk ./src/System/Plugins/Load.hs 21 +-- | An interface to the GHC runtime's dynamic linker, providing runtime +-- loading and linking of Haskell object files, commonly known as +-- /plugins/. + hunk ./src/System/Plugins/Load.hs 27 --- high level interface - load , load_ + -- * The @LoadStatus@ type + LoadStatus(..) + + -- * High-level interface + , load + , load_ hunk ./src/System/Plugins/Load.hs 34 - , pdynload , pdynload_ + , pdynload + , pdynload_ hunk ./src/System/Plugins/Load.hs 41 - , LoadStatus(..) - --- low level interface + -- * Low-level interface hunk ./src/System/Plugins/Load.hs 88 --- --------------------------------------------------------------------- --- return status of all *load functions: +-- +-- | The @LoadStatus@ type encodes the return status of functions that +-- perform dynamic loading in a type isomorphic to 'Either'. Failure +-- returns a list of error strings, success returns a reference to a +-- loaded module, and the Haskell value corresponding to the symbol that +-- was indexed. hunk ./src/System/Plugins/Load.hs 99 --- --------------------------------------------------------------------- --- | load an object file into the address space, returning the closure --- associated with the symbol requested, after removing its dynamism. hunk ./src/System/Plugins/Load.hs 100 --- Recursively loads the specified modules, and all the modules they --- depend on. +-- | 'load' is the basic interface to the dynamic loader. A call to +-- 'load' imports a single object file into the caller's address space, +-- returning the value associated with the symbol requested. Libraries +-- and modules that the requested module depends upon are loaded and +-- linked in turn. +-- +-- The first argument is the path to the object file to load, the second +-- argument is a list of directories to search for dependent modules. +-- The third argument is a list of paths to user-defined, but +-- unregistered, /package.conf/ files. The 'Symbol' argument is the +-- symbol name of the value you with to retrieve. +-- +-- The value returned must be given an explicit type signature, or +-- provided with appropriate type constraints such that Haskell compiler +-- can determine the expected type returned by 'load', as the return +-- type is notionally polymorphic. +-- +-- Example: +-- +-- > do mv <- load "Plugin.o" ["api"] [] "resource" +-- > case mv of +-- > LoadFailure msg -> print msg +-- > LoadSuccess _ v -> return v hunk ./src/System/Plugins/Load.hs 45 + , loadFunction_ -- retrieve a function from an object hunk ./src/System/Plugins/Load.hs 406 + hunk ./src/System/Plugins/Load.hs 410 - hunk ./src/System/Plugins/Load.hs 411 - = do let m = mi_module i - symbol = symbolise m + = loadFunction_ (mi_module i) valsym + +loadFunction_ :: String + -> String + -> IO (Maybe a) +loadFunction_ m valsym + = do let symbol = prefixUnderscore++m++"_"++(encode valsym)++"_closure" hunk ./src/System/Plugins/Load.hs 426 - where - symbolise m = prefixUnderscore++m++"_"++(encode valsym)++"_closure" hunk ./src/System/Plugins/Env.hs 21 + env, hunk ./src/Language/Hi/Binary.hs 475 +#if WORD_SIZE_IN_BITS == 32 hunk ./src/Language/Hi/Binary.hs 477 +#elif WORD_SIZE_IN_BITS == 64 +binaryInterfaceMagic = 0x1face64 :: Word32 +#endif hunk ./src/System/Plugins/Env.hs 280 - in ls ++ [foldr (\p fm' -> addToFM fm' (packageName p) p) fm ps'] + in foldr (\p fm' -> addToFM fm' (packageName p) p) fm ps' : ls hunk ./Setup.hs 2 -main = defaultMainWithHooks defaultUserHooks +import Distribution.Setup ( ConfigFlags (..) ) +import System.Directory ( findExecutable ) + +main = defaultMainWithHooks (defaultUserHooks { postConf = defaultPostConf }) + where defaultPostConf args flags lbi + = do args' <- fmap (args++) (configToArgs flags) + (postConf defaultUserHooks) args' flags lbi + +configToArgs :: ConfigFlags -> IO [String] +configToArgs (ConfigFlags { configHcPath = Just hcPath }) + = do exec <- findExecutable hcPath + case exec of + Just realPath -> return ["--with-ghc="++realPath] + Nothing -> return ["--with-ghc="++hcPath] +configToArgs _ = return [] hunk ./Setup.hs 6 - where defaultPostConf args flags lbi + where defaultPostConf args flags lbi xxx hunk ./Setup.hs 8 - (postConf defaultUserHooks) args' flags lbi + (postConf defaultUserHooks) args' flags lbi xxx move ./Setup.hs ./Setup.lhs hunk ./Setup.lhs 1 -import Distribution.Simple -import Distribution.Setup ( ConfigFlags (..) ) -import System.Directory ( findExecutable ) - -main = defaultMainWithHooks (defaultUserHooks { postConf = defaultPostConf }) - where defaultPostConf args flags lbi xxx - = do args' <- fmap (args++) (configToArgs flags) - (postConf defaultUserHooks) args' flags lbi xxx - -configToArgs :: ConfigFlags -> IO [String] -configToArgs (ConfigFlags { configHcPath = Just hcPath }) - = do exec <- findExecutable hcPath - case exec of - Just realPath -> return ["--with-ghc="++realPath] - Nothing -> return ["--with-ghc="++hcPath] -configToArgs _ = return [] +#!/usr/bin/env runhaskell +> module Main where +> import Distribution.Simple +> import Distribution.Setup ( ConfigFlags (..) ) +> import System.Directory ( findExecutable ) +> +> main :: IO () +> main = defaultMainWithHooks (defaultUserHooks { postConf = defaultPostConf }) +> where defaultPostConf args flags lbi {- xx -} +> = do args' <- fmap (args++) (configToArgs flags) +> (postConf defaultUserHooks) args' flags lbi {- xx -} +> +> configToArgs :: ConfigFlags -> IO [String] +> configToArgs (ConfigFlags { configHcPath = Just hcPath }) +> = do exec <- findExecutable hcPath +> case exec of +> Just realPath -> return ["--with-ghc="++realPath] +> Nothing -> return ["--with-ghc="++hcPath] +> configToArgs _ = return [] hunk ./plugins.cabal 37 -ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures +ghc-options: -Wall -O -fasm -funbox-strict-fields -fno-warn-missing-signatures hunk ./README 28 - $ runhaskell Setup.hs configure --prefix=/usr/local - $ runhaskell Setup.hs build - $ runhaskell Setup.hs install + $ chmod +x Setup.lhs configure + $ ./Setup.hs configure --prefix=/usr/local + $ ./Setup.hs build + $ ./Setup.hs install hunk ./README 52 - $ runhaskell Setup.hs configure --enable-hsx + $ ./Setup.lhs configure --enable-hsx hunk ./README 29 - $ ./Setup.hs configure --prefix=/usr/local - $ ./Setup.hs build - $ ./Setup.hs install + $ ./Setup.lhs configure --prefix=/usr/local + $ ./Setup.lhs build + $ ./Setup.lhs install hunk ./TODO 3 + ++ version numbers in package loads are annyoing hunk ./src/System/Plugins/Load.hs 550 - putStr (' ':show dlls) + putStr (' ':show libs) >> hFlush stdout + putStr (' ':show dlls) >> hFlush stdout hunk ./Setup.lhs 4 -> import Distribution.Setup ( ConfigFlags (..) ) -> import System.Directory ( findExecutable ) -> hunk ./Setup.lhs 5 -> main = defaultMainWithHooks (defaultUserHooks { postConf = defaultPostConf }) -> where defaultPostConf args flags lbi {- xx -} -> = do args' <- fmap (args++) (configToArgs flags) -> (postConf defaultUserHooks) args' flags lbi {- xx -} -> -> configToArgs :: ConfigFlags -> IO [String] -> configToArgs (ConfigFlags { configHcPath = Just hcPath }) -> = do exec <- findExecutable hcPath -> case exec of -> Just realPath -> return ["--with-ghc="++realPath] -> Nothing -> return ["--with-ghc="++hcPath] -> configToArgs _ = return [] +> main = defaultMainWithHooks defaultUserHooks addfile ./scripts/Setup-with-ghc.lhs hunk ./scripts/Setup-with-ghc.lhs 1 +#!/usr/bin/env runhaskell +> module Main where +> import Distribution.Simple +> import Distribution.Setup ( ConfigFlags (..) ) +> import System.Directory ( findExecutable ) +> +> main :: IO () +> main = defaultMainWithHooks (defaultUserHooks { postConf = defaultPostConf }) +> where defaultPostConf args flags lbi {- xx -} +> = do args' <- fmap (args++) (configToArgs flags) +> (postConf defaultUserHooks) args' flags lbi {- xx -} +> +> -- need to pass with-ghc arg onto ./configure for non-standard ghcs +> configToArgs :: ConfigFlags -> IO [String] +> configToArgs (ConfigFlags { configHcPath = Just hcPath }) +> = do exec <- findExecutable hcPath +> case exec of +> Just realPath -> return ["--with-ghc="++realPath] +> Nothing -> return ["--with-ghc="++hcPath] +> configToArgs _ = return [] hunk ./TODO 1 -For 0.1 +For 1.0 hunk ./VERSION 1 -hs-plugins 0.9.10 rmfile ./VERSION hunk ./plugins.cabal 2 -version: 0.9.10 +version: 1.0 hunk ./plugins.cabal.hsx 2 -version: 0.9.10 +version: 1.0 hunk ./testsuite/iface/null/expected.605 3 -package dependencies: base-1.0, plugins-0.9.10 +package dependencies: base-1.0, plugins-1.0 hunk ./testsuite/plugs/runplugs/Main.hs 12 +import Data.Char (chr) hunk ./testsuite/plugs/runplugs/Main.hs 14 -import Control.Monad (when) +import Control.Monad hunk ./testsuite/plugs/runplugs/Main.hs 16 +import System.Random hunk ./testsuite/plugs/runplugs/Main.hs 24 +import qualified Control.Exception (catch) + hunk ./testsuite/plugs/runplugs/Main.hs 32 -qualifieds = ["qualified Data.Map as M", "qualified Data.Set as S"] +qualifieds = ["qualified Data.Map as M" + ,"qualified Data.Set as S" + ,"qualified Data.IntSet as I"] hunk ./testsuite/plugs/runplugs/Main.hs 38 - "Graph", "Int", "Ix", "List", + "Graph", "Int", "Ix", "List", hunk ./testsuite/plugs/runplugs/Main.hs 45 - setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit) - s <- getContents - when (not . null $ s) $ do - s <- unsafeEval ("(take 2048 (show ("++s++")))") context - when (isJust s) (putStrLn (fromJust s)) - exitWith ExitSuccess + setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit) + s <- getLine + when (not . null $ s) $ do + x <- sequence (take 3 (repeat $ getStdRandom (randomR (97,122)) >>= return . chr)) + s <- unsafeEval ("let { "++x++ + " = \n# 1 \"\"\n"++s++ + "\n} in take 2048 (show "++x++ + ")") context + when (isJust s) $ Control.Exception.catch + (putStrLn $ fromJust s) + (\e -> putStrLn $ "Exception: " ++ show e ) + exitWith ExitSuccess hunk ./configure 1551 - { echo "$as_me:$LINENO: WARNING: You'll need tex if you wish to build the documentation" >&5 -echo "$as_me: WARNING: You'll need tex if you wish to build the documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: tex is needed to build some of the documentation" >&5 +echo "$as_me: WARNING: tex is needed to build some of the documentation" >&2;} hunk ./configure 1590 - { echo "$as_me:$LINENO: WARNING: You'll need tex2page if you wish to build the - documentation: http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&5 -echo "$as_me: WARNING: You'll need tex2page if you wish to build the - documentation: http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&2;} + { echo "$as_me:$LINENO: WARNING: tex2page is needed to build some of the documentation + http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&5 +echo "$as_me: WARNING: tex2page is needed to build some of the documentation + http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&2;} hunk ./configure.ac 127 - AC_MSG_WARN(You'll need tex if you wish to build the documentation) + AC_MSG_WARN(tex is needed to build some of the documentation) hunk ./configure.ac 131 - AC_MSG_WARN(You'll need tex2page if you wish to build the - documentation: http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html) + AC_MSG_WARN(tex2page is needed to build some of the documentation + http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html) hunk ./src/System/Plugins/Load.hs 261 - is = map (\s -> "-i"++s) incs -- api + is = map ("-i"++) incs -- api hunk ./src/System/Plugins/Load.hs 267 - -- removeFile tmpf - removeFile tmpf1 + mapM_ removeFile [tmpf,tmpf1] hunk ./src/System/Plugins/Make.hs 295 + -- does this work in the presence of hier plugins? + -- won't handle hier names properly. hunk ./src/System/Plugins/Make.hs 304 - hunk ./src/System/Plugins/Make.hs 358 - out <- mkUniqueIn dir - rawMerge src stb out True + out <- mkUniqueIn dir + rawMerge src stb out True hunk ./testsuite/iface/null/expected.604 3 -package dependencies: base-1.0, plugins-0.9.10 +package dependencies: base-1.0, plugins-1.0 hunk ./testsuite/pdynload/bayley1/Load.hs 6 +-- +-- load doesn't seem to behave nicely when using dirname on hier names +-- +-- make, and maybe other places, use dirname to work out various names +-- from paths, which is invalid when hier names are used.. +-- + hunk ./testsuite/pdynload/bayley1/Load.hs 20 - s <- make "../Sub/Plugin2.hs" ["-i../api"] + s <- make "../Sub/Plugin2.hs" ["-i../api","-hidir.."] -- ! hunk ./testsuite/pdynload/bayley1/Load.hs 34 + -- will reqeust 'Plugin2', but module is actually 'Sub.Plugin2' hunk ./testsuite/pdynload/bayley1/Load.hs 36 - fc <- pdynload o2 ["..","../api"] [] "API.PluginAPI" "action" + fc <- pdynload (o2) ["..","../api"] [] "API.PluginAPI" "action" hunk ./README 17 -It provides an eval() function, for generating new, well-typed, -compiled code from a Haskell source string. +It provides an `eval' function, for generating new, well-typed, compiled +code from a Haskell source string. hunk ./README 71 -* The documentation relies on latex, dvips, tex2page: +* The documentation relies on haddock, latex, dvips, tex2page: hunk ./Makefile 30 - runhaskell Setup.hs clean 2> /dev/null || true + runhaskell Setup.lhs clean 2> /dev/null || true hunk ./docs/hs-plugins.tex 47 -\urlh{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.10.tar.gz} - {version 0.9.10}} +\urlh{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-1.0.tar.gz} + {version 1.0}} hunk ./docs/hs-plugins.tex 55 -combination of runtime compilation and dynamic loading provides a set -of \code{eval} functions-- a form of runtime metaprogramming. Values +combination of runtime compilation and dynamic loading provides a set of +\code{eval} functions-- a form of runtime metaprogramming. Values hunk ./docs/hs-plugins.tex 58 -applications, and bindings exist to use Haskell plugins from at least C +applications, and bindings exist to use Haskell dynamically in C, Perl hunk ./docs/hs-plugins.tex 75 -\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-0.9.10.tar.gz} +\url{ftp://ftp.cse.unsw.edu.au/pub/users/dons/hs-plugins/hs-plugins-1.0.tar.gz} hunk ./docs/hs-plugins.tex 110 + \item Jan 2006, v1.0 + \begin{itemize} + \item Cabalised build system + \item Behave better on 64 bit platforms + \item Haddock documentation of the API. + \item A couple of bug fixes + \end{itemize} + hunk ./docs/hs-plugins.tex 120 - \item Support for GHC 6.4, with help from Sean - Seefried for the package.conf parser. - \item Ported to Windows of various flavours thanks to Vivian McPhail and Shelarcy - \item Removed posix and unix dependencies - \item Now uses HSX parser, thanks to Niklas Broberg - \item Extended load interface, thanks to Lemmih - \item Source now in a darcs repository - \item Supports building with GNU make -jN - \item Simplified module hierarchy, moved under System.* namespace - \item pdynload clarifications, thanks to Alistair Bayley - \item Miscellaneous bug fixes + \item Support for GHC 6.4, with help from Sean + Seefried for the package.conf parser. + \item Ported to Windows of various flavours thanks to Vivian McPhail and Shelarcy + \item Removed posix and unix dependencies + \item Now uses HSX parser, thanks to Niklas Broberg + \item Extended load interface, thanks to Lemmih + \item Source now in a darcs repository + \item Supports building with GNU make -jN + \item Simplified module hierarchy, moved under System.* namespace + \item pdynload clarifications, thanks to Alistair Bayley + \item Miscellaneous bug fixes hunk ./docs/hs-plugins.tex 298 -manager. When passed a string of Haskell code, it compiles the string to -object code, loads the result, and returns a Haskell value representing -the compiled string to the caller. It can be considered a Haskell -interpreter, implemented as a library. +manager. When passed a string containing a Haskell expression, it +compiles the string to object code, loads the result, and returns a +Haskell value representing the compiled string to the caller. It can be +considered a Haskell interpreter, implemented as a library, and can be +used to embed Haskell evaluation facilities in an application. hunk ./docs/hs-plugins.tex 336 - = LoadSuccess Module a - | LoadFailure Errors + = LoadSuccess Module a + | LoadFailure Errors hunk ./docs/hs-plugins.tex 364 -expected type returned by \code{load}, as the return type is notionally -polymorphic. +expected type returned by \code{load}. hunk ./docs/hs-plugins.tex 394 -\code{pdynload} is on average 7\% slower than an unchecked load. hunk ./docs/hs-plugins.tex 419 -mechanism, and is not restricted in its expressiveness (at the cost of greater load -times): +mechanism, and is not restricted in its expressiveness (at the cost of +greater load times): hunk ./docs/hs-plugins.tex 564 - unloadPackage "yi" + unloadPackage "yi-0.1" hunk ./docs/hs-plugins.tex 905 -\subsection{Foreign Eval} - -A preliminary binding to \code{eval} has been implemented to allow C -(and Objective C) programs access to the evaluator. Foreign bindings -to the compilation manager and dynamic loader are yet to be -implemented, but shouldn't be too hard. An foreign binding to a -Haskell module that wraps up calls to \code{make} and \code{load} -would be fairly trivial. - -At the moment we have an ad-hoc binding to \code{eval}, so that C -programmers who know the type of value that will be returned by -Haskell can call the appropriate hook into the evaluator. If they get -the type wrong, a nullPtr will be returned (so calling Haskell is -still typesafe). The foreign bindings to \code{eval} all return -\code{NULL} if an error occurred, otherwise a pointer to the value is -returned. - -\begin{quote} -\scm{ -foreign export ccall hs_eval_b :: CString -> IO (Ptr CInt) - -foreign export ccall hs_eval_c :: CString -> IO (Ptr CChar) - -foreign export ccall hs_eval_i :: CString -> IO (Ptr CInt) - -foreign export ccall hs_eval_s :: CString -> IO CString -} -\end{quote} - -An example C program for compiling and evaluating Haskell code at -runtime follows. This program calculates a fibonacci number, returning -it as a \code{CString} to the C program: -% -\begin{quote} -\begin{verbatim} -#include "EvalHaskell.h" -#include - -int main(int argc, char *argv[]) -{ - char *p; - hs_init(&argc, &argv); - p = hs_eval_s("show $ let fibs = 1:1:zipWith (+) fibs (tail fibs) in fibs !! 20"); - if (p != NULL) - printf("%s\n",p); - else - printf("error in code\n"); - hs_exit(); - return 0; -} -\end{verbatim} -\end{quote} - -\subsection{Notes} - -Be careful if you're calling eval from a forked thread. This can -introduce races between the thread and the forked process used by eval -to compile its code. +% \subsection{Foreign Eval} +% +% A preliminary binding to \code{eval} has been implemented to allow C +% (and Objective C) programs access to the evaluator. Foreign bindings +% to the compilation manager and dynamic loader are yet to be +% implemented, but shouldn't be too hard. An foreign binding to a +% Haskell module that wraps up calls to \code{make} and \code{load} +% would be fairly trivial. +% +% At the moment we have an ad-hoc binding to \code{eval}, so that C +% programmers who know the type of value that will be returned by +% Haskell can call the appropriate hook into the evaluator. If they get +% the type wrong, a nullPtr will be returned (so calling Haskell is +% still typesafe). The foreign bindings to \code{eval} all return +% \code{NULL} if an error occurred, otherwise a pointer to the value is +% returned. +% +% \begin{quote} +% \scm{ +% foreign export ccall hs_eval_b :: CString -> IO (Ptr CInt) +% +% foreign export ccall hs_eval_c :: CString -> IO (Ptr CChar) +% +% foreign export ccall hs_eval_i :: CString -> IO (Ptr CInt) +% +% foreign export ccall hs_eval_s :: CString -> IO CString +% } +% \end{quote} +% +% An example C program for compiling and evaluating Haskell code at +% runtime follows. This program calculates a fibonacci number, returning +% it as a \code{CString} to the C program: +% % +% \begin{quote} +% \begin{verbatim} +% #include "EvalHaskell.h" +% #include +% +% int main(int argc, char *argv[]) +% { +% char *p; +% hs_init(&argc, &argv); +% p = hs_eval_s("show $ let fibs = 1:1:zipWith (+) fibs (tail fibs) in fibs !! 20"); +% if (p != NULL) +% printf("%s\n",p); +% else +% printf("error in code\n"); +% hs_exit(); +% return 0; +% } +% \end{verbatim} +% \end{quote} +% hunk ./docs/hs-plugins.tex 1662 -Copyright 2004, Don Stewart - \url{http://www.cse.unsw.edu.au/~dons} +Copyright 2003-5, Don Stewart - \url{http://www.cse.unsw.edu.au/~dons} hunk ./docs/hs-plugins.1 1 -.TH HS-PLUGINS 1 2005-07-06 "hs-plugins version 0.9.10" "User Manual" +.TH HS-PLUGINS 1 2005-12-27 "hs-plugins version 1.0" "User Manual" hunk ./docs/hs-plugins.1 15 -requires GHC 6.2.2 or later. +requires GHC 6.4 or later. hunk ./docs/hs-plugins.1 25 -Copyright \(co 2004-2005 Don Stewart +Copyright \(co 2003-2005 Don Stewart hunk ./TODO 3 + ++ hs-plugins doesn't know to look for packages in the user packages, +only in the global packages hunk ./src/System/Eval/Haskell.hs 238 - "resource = let { v = \n" ++ - "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn v" + "resource = let { yhjulwwiefzojcbxybbruweejw = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn yhjulwwiefzojcbxybbruweejw" hunk ./src/System/Eval/Haskell.hs 248 - "resource = let { v = \n" ++ - "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in v" + "resource = let { yhjulwwiefzojcbxybbruweejw = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in yhjulwwiefzojcbxybbruweejw" + +-- what is this big variable name? +-- its a random value, so that it won't clash if the accidently mistype +-- an unbound 'x' or 'v' in their code.. it won't reveal the internal +-- structure of the wrapper, which is annoying in irc use by lambdabot hunk ./src/System/Plugins/Make.hs 69 -import System.IO (hFlush, stdout, openFile, IOMode(..),hClose, hPutStr) +import System.IO (hFlush, stdout, openFile, IOMode(..),hClose, hPutStr, hGetContents) hunk ./src/System/Plugins/Make.hs 71 -import System.IO (openFile, IOMode(..),hClose,hPutStr) +import System.IO (openFile, IOMode(..),hClose,hPutStr, hGetContents) hunk ./src/System/Plugins/Make.hs 394 - src_str <- readFile src - stb_str <- readFile stb + src_str <- readFile' src + stb_str <- readFile' stb hunk ./src/System/Plugins/Make.hs 444 +readFile' f = do + h <- openFile f ReadMode + s <- hGetContents h + length s `seq` return () + hClose h + return s + hunk ./TODO 4 ++ broken on mac. +symbols with suspiciously many _ chars + ++ Add verbose versions of the load functions, to avoid -DDEBUG + ++ mention that you need .o archives, not .a ones. Use Cabal, ghc-pkg -u + or ld -r --whole-archive + hunk ./src/System/Eval/Haskell.hs 56 +import Data.Char hunk ./src/System/Eval/Haskell.hs 60 +import System.Random +import System.IO.Unsafe hunk ./src/System/Eval/Haskell.hs 164 - MakeSuccess _ obj -> do + MakeSuccess _ obj -> do hunk ./src/System/Eval/Haskell.hs 241 - "resource = let { yhjulwwiefzojcbxybbruweejw = \n" ++ - "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn yhjulwwiefzojcbxybbruweejw" + "resource = let { "++x++" = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in toDyn "++x + where + x = ident () + +ident () = unsafePerformIO $ + sequence (take 3 (repeat $ getStdRandom (randomR (97,122)) >>= return . chr)) hunk ./src/System/Eval/Haskell.hs 256 - "resource = let { yhjulwwiefzojcbxybbruweejw = \n" ++ - "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in yhjulwwiefzojcbxybbruweejw" + "resource = let { "++x++" = \n" ++ + "{-# LINE 1 \"\" #-}\n" ++ expr ++ ";} in "++x + where + x = ident () hunk ./configure 1342 -powerpc-apple-darwin*) +*-apple-darwin*) hunk ./configure.ac 38 -powerpc-apple-darwin*) +*-apple-darwin*) hunk ./configure 912 - cd $ac_popdir + cd "$ac_popdir" hunk ./configure 2164 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2222 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2338 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2392 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2437 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2481 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 2590 - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' hunk ./configure 3508 - 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 hunk ./configure 3546 + + 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 hunk ./src/System/Plugins/Env.hs 361 +#if defined(MACOSX) +mkDynPkgName root = mkSOName (root ++ "_dyn") +#else +mkDynPkgName root = mkSOName root +#endif + +data HSLib = Static FilePath | Dynamic FilePath + hunk ./src/System/Plugins/Env.hs 397 - libs <- mapM (findHSlib libdirs) (hslibs ++ cbits) + -- If we're loading dynamic libs we need the cbits to appear before the + -- real packages. + libs <- mapM (findHSlib libdirs) (cbits ++ hslibs) hunk ./src/System/Plugins/Env.hs 414 - return (deppkgs, (filterRight libs,map (either id id) libs') ) + let slibs = [ lib | Right (Static lib) <- libs ] + dlibs = [ lib | Right (Dynamic lib) <- libs ] + return (deppkgs, (slibs,map (either id id) libs' ++ dlibs) ) hunk ./src/System/Plugins/Env.hs 437 - -- Problem: sysPkgSuffix is ".o", but extra libraries could be - -- ".so" -- what to do? - -- - findHSlib :: [FilePath] -> String -> IO (Either String FilePath) - findHSlib [] lib = return (Left lib) - findHSlib (dir:dirs) lib = do - let l = dir lib ++ sysPkgSuffix + findHSlib' :: [FilePath] -> String -> IO (Maybe FilePath) + findHSlib' [] _ = return Nothing + findHSlib' (dir:dirs) lib = do + let l = dir lib hunk ./src/System/Plugins/Env.hs 442 - if b then return $ Right l -- found it! - else findHSlib dirs lib + if b then return $ Just l -- found it! + else findHSlib' dirs lib + + findHSslib dirs lib = findHSlib' dirs $ lib ++ sysPkgSuffix + findHSdlib dirs lib = findHSlib' dirs $ mkDynPkgName lib + + -- Problem: sysPkgSuffix is ".o", but extra libraries could be + -- ".so" + -- Solution: first look for static library, if we don't find it + -- look for a dynamic version. + findHSlib :: [FilePath] -> String -> IO (Either String HSLib) + findHSlib dirs lib = do + static <- findHSslib dirs lib + case static of + Just file -> return $ Right $ Static file + Nothing -> do + dynamic <- findHSdlib dirs lib + case dynamic of + Just file -> return $ Right $ Dynamic file + Nothing -> return $ Left lib hunk ./src/System/Eval/Haskell.hs 1 --- +-- hunk ./src/System/Eval/Haskell.hs 3 --- +-- hunk ./src/System/Eval/Haskell.hs 8 --- +-- hunk ./src/System/Eval/Haskell.hs 13 --- +-- hunk ./src/System/Eval/Haskell.hs 18 --- +-- hunk ./src/System/Eval/Haskell.hs 28 -module System.Eval.Haskell ( +module System.Eval.Haskell ( hunk ./src/System/Eval/Haskell.hs 43 - module System.Eval.Utils, + module System.Eval.Utils, hunk ./src/System/Eval/Haskell.hs 71 --- +-- hunk ./src/System/Eval/Haskell.hs 99 - MakeSuccess _ obj -> do + MakeSuccess _ obj -> do hunk ./src/System/Eval/Haskell.hs 121 -eval_ src mods args ldflags incs = do +eval_ src mods args ldflags incs = do hunk ./src/System/Eval/Haskell.hs 127 - MakeSuccess _ obj -> do + MakeSuccess _ obj -> do hunk ./src/System/Eval/Haskell.hs 152 --- +-- hunk ./src/System/Eval/Haskell.hs 185 -unsafeEval_ src mods args ldflags incs = do +unsafeEval_ src mods args ldflags incs = do hunk ./src/System/Eval/Haskell.hs 190 - MakeSuccess _ obj -> do + MakeSuccess _ obj -> do hunk ./src/System/Eval/Haskell.hs 207 - where convertToHs :: (Show a) => String -> a -> String - convertToHs name value = name ++ " = " ++ show value ++ "\n" + where convertToHs :: (Show a) => String -> a -> String + convertToHs name value = name ++ " = " ++ show value ++ "\n" hunk ./src/System/Eval/Haskell.hs 221 - MakeSuccess _ obj -> do + MakeSuccess _ obj -> do hunk ./src/System/Eval/Haskell.hs 223 - case m_v of + case m_v of hunk ./src/System/Eval/Haskell.hs 238 - "module "++nm++ "( resource ) where\n" ++ + "module "++nm++ "( resource ) where\n" ++ hunk ./src/System/Eval/Haskell.hs 254 - "module "++nm++ "( resource ) where\n" ++ + "module "++nm++ "( resource ) where\n" ++ hunk ./src/System/Eval/Haskell.hs 277 - + hunk ./src/System/Eval/Haskell.hs 291 - case m_v of Nothing -> return nullPtr + case m_v of Nothing -> return nullPtr hunk ./src/System/Eval/Haskell.hs 296 - case m_v of Nothing -> return nullPtr + case m_v of Nothing -> return nullPtr hunk ./src/System/Eval/Haskell.hs 302 - case m_v of Nothing -> return nullPtr + case m_v of Nothing -> return nullPtr hunk ./src/System/Eval/Haskell.hs 307 - case m_v of Nothing -> return nullPtr + case m_v of Nothing -> return nullPtr hunk ./src/System/Eval/Haskell.hs 309 - + hunk ./src/System/Plugins/Load.hs 678 -foreign import ccall unsafe "lookupSymbol" +foreign import ccall threadsafe "lookupSymbol" hunk ./src/System/Plugins/LoadTypes.hs 40 -data Module = Module { path :: !FilePath - , mname :: !String - , kind :: !ObjType +data Module = Module { path :: !FilePath + , mname :: !String + , kind :: !ObjType hunk ./src/System/Plugins/LoadTypes.hs 46 + hunk ./plugins.cabal 8 - AltData.Dynamic, - AltData.Typeable, hunk ./src/System/Eval/Haskell.hs 51 -import AltData.Dynamic ( Dynamic ) -import AltData.Typeable ( Typeable ) +import Data.Dynamic ( Dynamic ) +import Data.Typeable ( Typeable ) hunk ./src/System/Plugins/Load.hs 70 -import AltData.Dynamic ( fromDynamic, Dynamic ) -import AltData.Typeable ( Typeable ) +import Data.Dynamic ( fromDynamic, Dynamic ) +import Data.Typeable ( Typeable ) hunk ./src/AltData/Dynamic.hs 1 -{-# OPTIONS -fglasgow-exts #-} --- --- | --- Module : Data.Dynamic --- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file libraries/base/LICENSE) --- --- Maintainer : libraries@haskell.org --- Stability : experimental --- Portability : portable --- --- The Dynamic interface provides basic support for dynamic types. --- --- Operations for injecting values of arbitrary type into --- a dynamically typed value, Dynamic, are provided, together --- with operations for converting dynamic values into a concrete --- (monomorphic) type. --- ------------------------------------------------------------------------------ - -module AltData.Dynamic ( - - -- Module Data.Typeable re-exported for convenience - module AltData.Typeable, - - -- * The @Dynamic@ type - Dynamic, -- abstract, instance of: Show, Typeable - - -- * Converting to and from @Dynamic@ - toDyn, -- :: Typeable a => a -> Dynamic - fromDyn, -- :: Typeable a => Dynamic -> a -> a - fromDynamic, -- :: Typeable a => Dynamic -> Maybe a - -#if __GLASGOW_HASKELL__ >= 603 - -- * Applying functions of dynamic type - dynApply, - dynApp, - dynTypeRep - -#endif - ) where - -import AltData.Typeable -import Data.Maybe - -import System.IO.Unsafe (unsafePerformIO) - -import GHC.Base -import GHC.Show -#if __GLASGOW_HASKELL__ >= 603 -import GHC.Err -#endif - -unsafeCoerce :: a -> b -unsafeCoerce = unsafeCoerce# - -------------------------------------------------------------- --- --- The type Dynamic --- -------------------------------------------------------------- - -{-| - A value of type 'Dynamic' is an object encapsulated together with its type. - - A 'Dynamic' may only represent a monomorphic value; an attempt to - create a value of type 'Dynamic' from a polymorphically-typed - expression will result in an ambiguity error (see 'toDyn'). - - 'Show'ing a value of type 'Dynamic' returns a pretty-printed representation - of the object\'s type; useful for debugging. --} -data Dynamic = Dynamic TypeRep Obj - -instance Typeable Dynamic where -#if __GLASGOW_HASKELL__ >= 603 - typeOf _ = mkTyConApp (mkTyCon "AltData.Dynamic") [] -#else - typeOf _ = mkAppTy (mkTyCon "AltData.Dynamic") [] -#endif - -instance Show Dynamic where - -- the instance just prints the type representation. - showsPrec _ (Dynamic t _) = - showString "<<" . - showsPrec 0 t . - showString ">>" - -type Obj = forall a . a - -- Dummy type to hold the dynamically typed value. - -- - -- In GHC's new eval/apply execution model this type must - -- be polymorphic. It can't be a constructor, because then - -- GHC will use the constructor convention when evaluating it, - -- and this will go wrong if the object is really a function. On - -- the other hand, if we use a polymorphic type, GHC will use - -- a fallback convention for evaluating it that works for all types. - -- (using a function type here would also work). - --- | Converts an arbitrary value into an object of type 'Dynamic'. --- --- The type of the object must be an instance of 'Typeable', which --- ensures that only monomorphically-typed objects may be converted to --- 'Dynamic'. To convert a polymorphic object into 'Dynamic', give it --- a monomorphic type signature. For example: --- --- > toDyn (id :: Int -> Int) --- -toDyn :: Typeable a => a -> Dynamic -toDyn v = Dynamic (typeOf v) (unsafeCoerce v) - --- | Converts a 'Dynamic' object back into an ordinary Haskell value of --- the correct type. See also 'fromDynamic'. -fromDyn :: Typeable a - => Dynamic -- ^ the dynamically-typed object - -> a -- ^ a default value - -> a -- ^ returns: the value of the first argument, if - -- it has the correct type, otherwise the value of - -- the second argument. -fromDyn (Dynamic t v) def - | typeOf def == t = unsafeCoerce v - | otherwise = def - --- | Converts a 'Dynamic' object back into an ordinary Haskell value of --- the correct type. See also 'fromDyn'. -fromDynamic - :: Typeable a - => Dynamic -- ^ the dynamically-typed object - -> Maybe a -- ^ returns: @'Just' a@, if the dynamically-typed - -- object has the correct type (and @a@ is its value), - -- or 'Nothing' otherwise. -fromDynamic (Dynamic t v) = - case unsafeCoerce v of - r | t == typeOf r -> Just r - | otherwise -> unsafePerformIO (putStrLn $ - "Couldn't match `" ++show(typeOf r) ++ - "' against `" ++show t ++"'"++ - "\n\tExpected type: " ++show(typeOf r) ++ - "\n\tInferred type: " ++show t - ) `seq` Nothing - -#if __GLASGOW_HASKELL__ >= 603 - --- (f::(a->b)) `dynApply` (x::a) = (f a)::b -dynApply :: Dynamic -> Dynamic -> Maybe Dynamic -dynApply (Dynamic t1 f) (Dynamic t2 x) = - case funResultTy t1 t2 of - Just t3 -> Just (Dynamic t3 ((unsafeCoerce f) x)) - Nothing -> Nothing - - -dynApp :: Dynamic -> Dynamic -> Dynamic -dynApp f x = case dynApply f x of - Just r -> r - Nothing -> error ("Type error in dynamic application.\n" ++ - "Can't apply function " ++ show f ++ - " to argument " ++ show x) - -dynTypeRep :: Dynamic -> TypeRep -dynTypeRep (Dynamic tr _) = tr - -#endif rmfile ./src/AltData/Dynamic.hs hunk ./src/AltData/Typeable.hs 1 -{-# OPTIONS -fglasgow-exts #-} --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- Based on: --- --- | --- Module : Data.Typeable --- Copyright : (c) The University of Glasgow, CWI 2001--2004 --- License : BSD-style (see the file libraries/base/LICENSE) --- --- Maintainer : libraries@haskell.org --- Stability : experimental --- Portability : portable --- --- The Typeable class reifies types to some extent by associating type --- representations to types. These type representations can be compared, --- and one can in turn define a type-safe cast operation. To this end, --- an unsafe cast is guarded by a test for type (representation) --- equivalence. The module Data.Dynamic uses Typeable for an --- implementation of dynamics. The module Data.Generics uses Typeable --- and type-safe cast (but not dynamics) to support the \"Scrap your --- boilerplate\" style of generic programming. --- - -module AltData.Typeable - -#if __GLASGOW_HASKELL__ >= 603 - ( - - -- * The Typeable class - Typeable( typeOf ), -- :: a -> TypeRep - - -- * Type-safe cast - cast, -- :: (Typeable a, Typeable b) => a -> Maybe b - gcast, -- a generalisation of cast - - -- * Type representations - TypeRep, -- abstract, instance of: Eq, Show, Typeable - TyCon, -- abstract, instance of: Eq, Show, Typeable - - -- * Construction of type representations - mkTyCon, -- :: String -> TyCon - mkTyConApp, -- :: TyCon -> [TypeRep] -> TypeRep - mkAppTy, -- :: TypeRep -> TypeRep -> TypeRep - mkFunTy, -- :: TypeRep -> TypeRep -> TypeRep - - -- * Observation of type representations - splitTyConApp, -- :: TypeRep -> (TyCon, [TypeRep]) - funResultTy, -- :: TypeRep -> TypeRep -> Maybe TypeRep - typeRepTyCon, -- :: TypeRep -> TyCon - typeRepArgs, -- :: TypeRep -> [TypeRep] - tyConString, -- :: TyCon -> String - - -- * The other Typeable classes - -- | /Note:/ The general instances are provided for GHC only. - Typeable1( typeOf1 ), -- :: t a -> TypeRep - Typeable2( typeOf2 ), -- :: t a b -> TypeRep - Typeable3( typeOf3 ), -- :: t a b c -> TypeRep - Typeable4( typeOf4 ), -- :: t a b c d -> TypeRep - Typeable5( typeOf5 ), -- :: t a b c d e -> TypeRep - Typeable6( typeOf6 ), -- :: t a b c d e f -> TypeRep - Typeable7( typeOf7 ), -- :: t a b c d e f g -> TypeRep - gcast1, -- :: ... => c (t a) -> Maybe (c (t' a)) - gcast2, -- :: ... => c (t a b) -> Maybe (c (t' a b)) - - -- * Default instances - -- | /Note:/ These are not needed by GHC, for which these instances - -- are generated by general instance declarations. - typeOfDefault, -- :: (Typeable1 t, Typeable a) => t a -> TypeRep - typeOf1Default, -- :: (Typeable2 t, Typeable a) => t a b -> TypeRep - typeOf2Default, -- :: (Typeable3 t, Typeable a) => t a b c -> TypeRep - typeOf3Default, -- :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep - typeOf4Default, -- :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep - typeOf5Default, -- :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep - typeOf6Default -- :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep - - ) where - -import qualified Data.HashTable as HT -import Data.Maybe -import Data.Either -import Data.Int -import Data.Word -import Data.List( foldl ) - -import GHC.Base -import GHC.Show -import GHC.Err -import GHC.Num -import GHC.Float -import GHC.Real( rem, Ratio ) -import GHC.IOBase -import GHC.Ptr -- So we can give Typeable instance for Ptr -import GHC.Stable -- So we can give Typeable instance for StablePtr - -unsafeCoerce :: a -> b -unsafeCoerce = unsafeCoerce# - -#include "Typeable.h" - -------------------------------------------------------------- --- --- Type representations --- -------------------------------------------------------------- - --- | A concrete representation of a (monomorphic) type. 'TypeRep' --- supports reasonably efficient equality. --- --- equality of keys doesn't work for dynamically loaded code, so we --- revert back to canonical type names. --- --- could use packed strings here. --- -data TypeRep = TypeRep !Key TyCon [TypeRep] - --- Compare keys for equality -instance Eq TypeRep where - (TypeRep _ t1 a1) == (TypeRep _ t2 a2) = t1 == t2 && a1 == a2 - --- | An abstract representation of a type constructor. 'TyCon' objects can --- be built using 'mkTyCon'. -data TyCon = TyCon !Key String - -instance Eq TyCon where - (TyCon _ s1) == (TyCon _ s2) = s1 == s2 - - -- - -- let fTy = mkTyCon "Foo" in show (mkTyConApp (mkTyCon ",,") - -- [fTy,fTy,fTy]) - -- - -- returns "(Foo,Foo,Foo)" - -- - -- The TypeRep Show instance promises to print tuple types - -- correctly. Tuple type constructors are specified by a - -- sequence of commas, e.g., (mkTyCon ",,,,") returns - -- the 5-tuple tycon. - ------------------ Construction -------------------- - --- | Applies a type constructor to a sequence of types -mkTyConApp :: TyCon -> [TypeRep] -> TypeRep -mkTyConApp tc@(TyCon tc_k _) args - = TypeRep (appKeys tc_k arg_ks) tc args - where - arg_ks = [k | TypeRep k _ _ <- args] - --- | A special case of 'mkTyConApp', which applies the function --- type constructor to a pair of types. -mkFunTy :: TypeRep -> TypeRep -> TypeRep -mkFunTy f a = mkTyConApp funTc [f,a] - --- | Splits a type constructor application -splitTyConApp :: TypeRep -> (TyCon,[TypeRep]) -splitTyConApp (TypeRep _ tc trs) = (tc,trs) - --- | Applies a type to a function type. Returns: @'Just' u@ if the --- first argument represents a function of type @t -> u@ and the --- second argument represents a function of type @t@. Otherwise, --- returns 'Nothing'. -funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep -funResultTy trFun trArg - = case splitTyConApp trFun of - (tc, [t1,t2]) | tc == funTc && t1 == trArg -> Just t2 - _ -> Nothing - --- | Adds a TypeRep argument to a TypeRep. -mkAppTy :: TypeRep -> TypeRep -> TypeRep -mkAppTy (TypeRep tr_k tc trs) arg_tr - = let (TypeRep arg_k _ _) = arg_tr - in TypeRep (appKey tr_k arg_k) tc (trs++[arg_tr]) - --- If we enforce the restriction that there is only one --- @TyCon@ for a type & it is shared among all its uses, --- we can map them onto Ints very simply. The benefit is, --- of course, that @TyCon@s can then be compared efficiently. - --- Provided the implementor of other @Typeable@ instances --- takes care of making all the @TyCon@s CAFs (toplevel constants), --- this will work. - --- If this constraint does turn out to be a sore thumb, changing --- the Eq instance for TyCons is trivial. - --- | Builds a 'TyCon' object representing a type constructor. An --- implementation of "Data.Typeable" should ensure that the following holds: --- --- > mkTyCon "a" == mkTyCon "a" --- - -mkTyCon :: String -- ^ the name of the type constructor (should be unique - -- in the program, so it might be wise to use the - -- fully qualified name). - -> TyCon -- ^ A unique 'TyCon' object -mkTyCon str = TyCon (mkTyConKey str) str - ------------------ Observation --------------------- - --- | Observe the type constructor of a type representation -typeRepTyCon :: TypeRep -> TyCon -typeRepTyCon (TypeRep _ tc _) = tc - --- | Observe the argument types of a type representation -typeRepArgs :: TypeRep -> [TypeRep] -typeRepArgs (TypeRep _ _ args) = args - --- | Observe string encoding of a type representation -tyConString :: TyCon -> String -tyConString (TyCon _ str) = str - ------------------ Showing TypeReps -------------------- - -instance Show TypeRep where - showsPrec p (TypeRep _ tycon tys) = - case tys of - [] -> showsPrec p tycon - [x] | tycon == listTc -> showChar '[' . shows x . showChar ']' - [a,r] | tycon == funTc -> showParen (p > 8) $ - showsPrec 9 a . - showString " -> " . - showsPrec 8 r - xs | isTupleTyCon tycon -> showTuple tycon xs - | otherwise -> - showParen (p > 9) $ - showsPrec p tycon . - showChar ' ' . - showArgs tys - -instance Show TyCon where - showsPrec _ (TyCon _ s) = showString s - -isTupleTyCon :: TyCon -> Bool -isTupleTyCon (TyCon _ (',':_)) = True -isTupleTyCon _ = False - --- Some (Show.TypeRep) helpers: - -showArgs :: Show a => [a] -> ShowS -showArgs [] = id -showArgs [a] = showsPrec 10 a -showArgs (a:as) = showsPrec 10 a . showString " " . showArgs as - -showTuple :: TyCon -> [TypeRep] -> ShowS -showTuple (TyCon _ str) args = showChar '(' . go str args - where - go [] [a] = showsPrec 10 a . showChar ')' - go _ [] = showChar ')' -- a failure condition, really. - go (',':xs) (a:as) = showsPrec 10 a . showChar ',' . go xs as - go _ _ = showChar ')' - -------------------------------------------------------------- --- --- The Typeable class and friends --- -------------------------------------------------------------- - --- | The class 'Typeable' allows a concrete representation of a type to --- be calculated. -class Typeable a where - typeOf :: a -> TypeRep - -- ^ Takes a value of type @a@ and returns a concrete representation - -- of that type. The /value/ of the argument should be ignored by - -- any instance of 'Typeable', so that it is safe to pass 'undefined' as - -- the argument. - --- | Variant for unary type constructors -class Typeable1 t where - typeOf1 :: t a -> TypeRep - --- | For defining a 'Typeable' instance from any 'Typeable1' instance. -typeOfDefault :: (Typeable1 t, Typeable a) => t a -> TypeRep -typeOfDefault x = typeOf1 x `mkAppTy` typeOf (argType x) - where - argType :: t a -> a - argType = undefined - --- | Variant for binary type constructors -class Typeable2 t where - typeOf2 :: t a b -> TypeRep - --- | For defining a 'Typeable1' instance from any 'Typeable2' instance. -typeOf1Default :: (Typeable2 t, Typeable a) => t a b -> TypeRep -typeOf1Default x = typeOf2 x `mkAppTy` typeOf (argType x) - where - argType :: t a b -> a - argType = undefined - --- | Variant for 3-ary type constructors -class Typeable3 t where - typeOf3 :: t a b c -> TypeRep - --- | For defining a 'Typeable2' instance from any 'Typeable3' instance. -typeOf2Default :: (Typeable3 t, Typeable a) => t a b c -> TypeRep -typeOf2Default x = typeOf3 x `mkAppTy` typeOf (argType x) - where - argType :: t a b c -> a - argType = undefined - --- | Variant for 4-ary type constructors -class Typeable4 t where - typeOf4 :: t a b c d -> TypeRep - --- | For defining a 'Typeable3' instance from any 'Typeable4' instance. -typeOf3Default :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep -typeOf3Default x = typeOf4 x `mkAppTy` typeOf (argType x) - where - argType :: t a b c d -> a - argType = undefined - --- | Variant for 5-ary type constructors -class Typeable5 t where - typeOf5 :: t a b c d e -> TypeRep - --- | For defining a 'Typeable4' instance from any 'Typeable5' instance. -typeOf4Default :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep -typeOf4Default x = typeOf5 x `mkAppTy` typeOf (argType x) - where - argType :: t a b c d e -> a - argType = undefined - --- | Variant for 6-ary type constructors -class Typeable6 t where - typeOf6 :: t a b c d e f -> TypeRep - --- | For defining a 'Typeable5' instance from any 'Typeable6' instance. -typeOf5Default :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep -typeOf5Default x = typeOf6 x `mkAppTy` typeOf (argType x) - where - argType :: t a b c d e f -> a - argType = undefined - --- | Variant for 7-ary type constructors -class Typeable7 t where - typeOf7 :: t a b c d e f g -> TypeRep - --- | For defining a 'Typeable6' instance from any 'Typeable7' instance. -typeOf6Default :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep -typeOf6Default x = typeOf7 x `mkAppTy` typeOf (argType x) - where - argType :: t a b c d e f g -> a - argType = undefined - --- Given a @Typeable@/n/ instance for an /n/-ary type constructor, --- define the instances for partial applications. --- Programmers using non-GHC implementations must do this manually --- for each type constructor. --- (The INSTANCE_TYPEABLE/n/ macros in Typeable.h include this.) - --- | One Typeable instance for all Typeable1 instances -instance (Typeable1 s, Typeable a) - => Typeable (s a) where - typeOf = typeOfDefault - --- | One Typeable1 instance for all Typeable2 instances -instance (Typeable2 s, Typeable a) - => Typeable1 (s a) where - typeOf1 = typeOf1Default - --- | One Typeable2 instance for all Typeable3 instances -instance (Typeable3 s, Typeable a) - => Typeable2 (s a) where - typeOf2 = typeOf2Default - --- | One Typeable3 instance for all Typeable4 instances -instance (Typeable4 s, Typeable a) - => Typeable3 (s a) where - typeOf3 = typeOf3Default - --- | One Typeable4 instance for all Typeable5 instances -instance (Typeable5 s, Typeable a) - => Typeable4 (s a) where - typeOf4 = typeOf4Default - --- | One Typeable5 instance for all Typeable6 instances -instance (Typeable6 s, Typeable a) - => Typeable5 (s a) where - typeOf5 = typeOf5Default - --- | One Typeable6 instance for all Typeable7 instances -instance (Typeable7 s, Typeable a) - => Typeable6 (s a) where - typeOf6 = typeOf6Default - -------------------------------------------------------------- --- --- Type-safe cast --- -------------------------------------------------------------- - --- | The type-safe cast operation -cast :: (Typeable a, Typeable b) => a -> Maybe b -cast x = r - where - r = if typeOf x == typeOf (fromJust r) - then Just $ unsafeCoerce x - else Nothing - --- | A flexible variation parameterised in a type constructor -gcast :: (Typeable a, Typeable b) => c a -> Maybe (c b) -gcast x = r - where - r = if typeOf (getArg x) == typeOf (getArg (fromJust r)) - then Just $ unsafeCoerce x - else Nothing - getArg :: c x -> x - getArg = undefined - --- | Cast for * -> * -gcast1 :: (Typeable1 t, Typeable1 t') => c (t a) -> Maybe (c (t' a)) -gcast1 x = r - where - r = if typeOf1 (getArg x) == typeOf1 (getArg (fromJust r)) - then Just $ unsafeCoerce x - else Nothing - getArg :: c x -> x - getArg = undefined - --- | Cast for * -> * -> * -gcast2 :: (Typeable2 t, Typeable2 t') => c (t a b) -> Maybe (c (t' a b)) -gcast2 x = r - where - r = if typeOf2 (getArg x) == typeOf2 (getArg (fromJust r)) - then Just $ unsafeCoerce x - else Nothing - getArg :: c x -> x - getArg = undefined - -------------------------------------------------------------- --- --- Instances of the Typeable classes for Prelude types --- -------------------------------------------------------------- - -INSTANCE_TYPEABLE1([],listTc,"[]") -INSTANCE_TYPEABLE1(Maybe,maybeTc,"Maybe") -INSTANCE_TYPEABLE1(Ratio,ratioTc,"Ratio") -INSTANCE_TYPEABLE2(Either,eitherTc,"Either") -INSTANCE_TYPEABLE2((->),funTc,"->") -INSTANCE_TYPEABLE1(IO,ioTc,"IO") -INSTANCE_TYPEABLE0((),unitTc,"()") - -INSTANCE_TYPEABLE2((,),pairTc,",") -INSTANCE_TYPEABLE3((,,),tup3Tc,",,") - -tup4Tc :: TyCon -tup4Tc = mkTyCon ",,," - -instance Typeable4 (,,,) where - typeOf4 _ = mkTyConApp tup4Tc [] - -tup5Tc :: TyCon -tup5Tc = mkTyCon ",,,," - -instance Typeable5 (,,,,) where - typeOf5 _ = mkTyConApp tup5Tc [] - -tup6Tc :: TyCon -tup6Tc = mkTyCon ",,,,," - -instance Typeable6 (,,,,,) where - typeOf6 _ = mkTyConApp tup6Tc [] - -tup7Tc :: TyCon -tup7Tc = mkTyCon ",,,,," - -instance Typeable7 (,,,,,,) where - typeOf7 _ = mkTyConApp tup7Tc [] - -INSTANCE_TYPEABLE1(Ptr,ptrTc,"Foreign.Ptr.Ptr") -INSTANCE_TYPEABLE1(StablePtr,stableptrTc,"Foreign.StablePtr.StablePtr") -INSTANCE_TYPEABLE1(IORef,iorefTc,"Data.IORef.IORef") - -------------------------------------------------------- --- --- Generate Typeable instances for standard datatypes --- -------------------------------------------------------- - -INSTANCE_TYPEABLE0(Bool,boolTc,"Bool") -INSTANCE_TYPEABLE0(Char,charTc,"Char") -INSTANCE_TYPEABLE0(Float,floatTc,"Float") -INSTANCE_TYPEABLE0(Double,doubleTc,"Double") -INSTANCE_TYPEABLE0(Int,intTc,"Int") -INSTANCE_TYPEABLE0(Integer,integerTc,"Integer") -INSTANCE_TYPEABLE0(Ordering,orderingTc,"Ordering") -INSTANCE_TYPEABLE0(Handle,handleTc,"Handle") - -INSTANCE_TYPEABLE0(Int8,int8Tc,"Int8") -INSTANCE_TYPEABLE0(Int16,int16Tc,"Int16") -INSTANCE_TYPEABLE0(Int32,int32Tc,"Int32") -INSTANCE_TYPEABLE0(Int64,int64Tc,"Int64") - -INSTANCE_TYPEABLE0(Word8,word8Tc,"Word8" ) -INSTANCE_TYPEABLE0(Word16,word16Tc,"Word16") -INSTANCE_TYPEABLE0(Word32,word32Tc,"Word32") -INSTANCE_TYPEABLE0(Word64,word64Tc,"Word64") - -INSTANCE_TYPEABLE0(TyCon,tyconTc,"TyCon") -INSTANCE_TYPEABLE0(TypeRep,typeRepTc,"TypeRep") - -INSTANCE_TYPEABLE0(Word,wordTc,"Word" ) - -#else /* GHC < 6.3 */ - - ( - -- * The Typeable class - Typeable( typeOf ), -- :: a -> TypeRep - - -- * Type-safe cast - cast, -- :: (Typeable a, Typeable b) => a -> Maybe b - castss, -- a cast for kind "* -> *" - castarr, -- another convenient variation - - -- * Type representations - TypeRep, -- abstract, instance of: Eq, Show, Typeable - TyCon, -- abstract, instance of: Eq, Show, Typeable - - -- * Construction of type representations - mkTyCon, -- :: String -> TyCon - mkAppTy, -- :: TyCon -> [TypeRep] -> TypeRep - mkFunTy, -- :: TypeRep -> TypeRep -> TypeRep - applyTy, -- :: TypeRep -> TypeRep -> Maybe TypeRep - - -- * Observation of type representations - typerepTyCon, -- :: TypeRep -> TyCon - typerepArgs, -- :: TypeRep -> [TypeRep] - tyconString -- :: TyCon -> String - - - ) where - -import qualified Data.HashTable as HT -import Data.Maybe -import Data.Either -import Data.Int -import Data.Word -import Data.List( foldl ) - -import GHC.Base -import GHC.Show -import GHC.Err -import GHC.Num -import GHC.Float -import GHC.Real( rem, Ratio ) -import GHC.IOBase -import GHC.Ptr -- So we can give Typeable instance for Ptr -import GHC.Stable -- So we can give Typeable instance for StablePtr - -unsafeCoerce :: a -> b -unsafeCoerce = unsafeCoerce# - -#include "Typeable.h" - - -------------------------------------------------------------- --- --- Type representations --- -------------------------------------------------------------- - - --- | A concrete representation of a (monomorphic) type. 'TypeRep' --- supports reasonably efficient equality. -data TypeRep = TypeRep !Key TyCon [TypeRep] - --- Compare keys for equality -instance Eq TypeRep where - (TypeRep _ t1 a1) == (TypeRep _ t2 a2) = t1 == t2 && a1 == a2 - --- | An abstract representation of a type constructor. 'TyCon' objects can --- be built using 'mkTyCon'. -data TyCon = TyCon !Key String - -instance Eq TyCon where - (TyCon _ s1) == (TyCon _ s2) = s1 == s2 - - -- - -- let fTy = mkTyCon "Foo" in show (mkAppTy (mkTyCon ",,") - -- [fTy,fTy,fTy]) - -- - -- returns "(Foo,Foo,Foo)" - -- - -- The TypeRep Show instance promises to print tuple types - -- correctly. Tuple type constructors are specified by a - -- sequence of commas, e.g., (mkTyCon ",,,,") returns - -- the 5-tuple tycon. - ------------------ Construction -------------------- - --- | Applies a type constructor to a sequence of types -mkAppTy :: TyCon -> [TypeRep] -> TypeRep -mkAppTy tc@(TyCon tc_k _) args - = TypeRep (appKeys tc_k arg_ks) tc args - where - arg_ks = [k | TypeRep k _ _ <- args] - -funTc :: TyCon -funTc = mkTyCon "->" - --- | A special case of 'mkAppTy', which applies the function --- type constructor to a pair of types. -mkFunTy :: TypeRep -> TypeRep -> TypeRep -mkFunTy f a = mkAppTy funTc [f,a] - --- | Applies a type to a function type. Returns: @'Just' u@ if the --- first argument represents a function of type @t -> u@ and the --- second argument represents a function of type @t@. Otherwise, --- returns 'Nothing'. -applyTy :: TypeRep -> TypeRep -> Maybe TypeRep -applyTy (TypeRep _ tc [t1,t2]) t3 - | tc == funTc && t1 == t3 = Just t2 -applyTy _ _ = Nothing - --- If we enforce the restriction that there is only one --- @TyCon@ for a type & it is shared among all its uses, --- we can map them onto Ints very simply. The benefit is, --- of course, that @TyCon@s can then be compared efficiently. - --- Provided the implementor of other @Typeable@ instances --- takes care of making all the @TyCon@s CAFs (toplevel constants), --- this will work. - --- If this constraint does turn out to be a sore thumb, changing --- the Eq instance for TyCons is trivial. - --- | Builds a 'TyCon' object representing a type constructor. An --- implementation of "Data.Typeable" should ensure that the following holds: --- --- > mkTyCon "a" == mkTyCon "a" --- - -mkTyCon :: String -- ^ the name of the type constructor (should be unique - -- in the program, so it might be wise to use the - -- fully qualified name). - -> TyCon -- ^ A unique 'TyCon' object -mkTyCon str = TyCon (mkTyConKey str) str - - - ------------------ Observation --------------------- - - --- | Observe the type constructor of a type representation -typerepTyCon :: TypeRep -> TyCon -typerepTyCon (TypeRep _ tc _) = tc - - --- | Observe the argument types of a type representation -typerepArgs :: TypeRep -> [TypeRep] -typerepArgs (TypeRep _ _ args) = args - - --- | Observe string encoding of a type representation -tyconString :: TyCon -> String -tyconString (TyCon _ str) = str - - ------------------ Showing TypeReps -------------------- - -instance Show TypeRep where - showsPrec p (TypeRep _ tycon tys) = - case tys of - [] -> showsPrec p tycon - [x] | tycon == listTc -> showChar '[' . shows x . showChar ']' - [a,r] | tycon == funTc -> showParen (p > 8) $ - showsPrec 9 a . showString " -> " . showsPrec 8 r - xs | isTupleTyCon tycon -> showTuple tycon xs - | otherwise -> - showParen (p > 9) $ - showsPrec p tycon . - showChar ' ' . - showArgs tys - -instance Show TyCon where - showsPrec _ (TyCon _ s) = showString s - -isTupleTyCon :: TyCon -> Bool -isTupleTyCon (TyCon _ (',':_)) = True -isTupleTyCon _ = False - --- Some (Show.TypeRep) helpers: - -showArgs :: Show a => [a] -> ShowS -showArgs [] = id -showArgs [a] = showsPrec 10 a -showArgs (a:as) = showsPrec 10 a . showString " " . showArgs as - -showTuple :: TyCon -> [TypeRep] -> ShowS -showTuple (TyCon _ str) args = showChar '(' . go str args - where - go [] [a] = showsPrec 10 a . showChar ')' - go _ [] = showChar ')' -- a failure condition, really. - go (',':xs) (a:as) = showsPrec 10 a . showChar ',' . go xs as - go _ _ = showChar ')' - - -------------------------------------------------------------- --- --- The Typeable class --- -------------------------------------------------------------- - --- | The class 'Typeable' allows a concrete representation of a type to --- be calculated. -class Typeable a where - typeOf :: a -> TypeRep - -- ^ Takes a value of type @a@ and returns a concrete representation - -- of that type. The /value/ of the argument should be ignored by - -- any instance of 'Typeable', so that it is safe to pass 'undefined' as - -- the argument. - - -------------------------------------------------------------- --- --- Type-safe cast --- -------------------------------------------------------------- - --- | The type-safe cast operation -cast :: (Typeable a, Typeable b) => a -> Maybe b -cast x = r - where - r = if typeOf x == typeOf (fromJust r) - then Just $ unsafeCoerce x - else Nothing - - --- | A convenient variation for kind "* -> *" -castss :: (Typeable a, Typeable b) => t a -> Maybe (t b) -castss x = r - where - r = if typeOf (get x) == typeOf (get (fromJust r)) - then Just $ unsafeCoerce x - else Nothing - get :: t c -> c - get = undefined - - --- | Another variation -castarr :: (Typeable a, Typeable b, Typeable c, Typeable d) - => (a -> t b) -> Maybe (c -> t d) -castarr x = r - where - r = if typeOf (get x) == typeOf (get (fromJust r)) - then Just $ unsafeCoerce x - else Nothing - get :: (e -> t f) -> (e, f) - get = undefined - -{- - -The variations castss and castarr are arguably not really needed. -Let's discuss castss in some detail. To get rid of castss, we can -require "Typeable (t a)" and "Typeable (t b)" rather than just -"Typeable a" and "Typeable b". In that case, the ordinary cast would -work. Eventually, all kinds of library instances should become -Typeable. (There is another potential use of variations as those given -above. It allows quantification on type constructors. - --} - - -------------------------------------------------------------- --- --- Instances of the Typeable class for Prelude types --- -------------------------------------------------------------- - -listTc :: TyCon -listTc = mkTyCon "[]" - -instance Typeable a => Typeable [a] where - typeOf ls = mkAppTy listTc [typeOf ((undefined :: [a] -> a) ls)] - -- In GHC we can say - -- typeOf (undefined :: a) - -- using scoped type variables, but we use the - -- more verbose form here, for compatibility with Hugs - -unitTc :: TyCon -unitTc = mkTyCon "()" - -instance Typeable () where - typeOf _ = mkAppTy unitTc [] - -tup2Tc :: TyCon -tup2Tc = mkTyCon "," - -instance (Typeable a, Typeable b) => Typeable (a,b) where - typeOf tu = mkAppTy tup2Tc [typeOf ((undefined :: (a,b) -> a) tu), - typeOf ((undefined :: (a,b) -> b) tu)] - -tup3Tc :: TyCon -tup3Tc = mkTyCon ",," - -instance ( Typeable a , Typeable b , Typeable c) => Typeable (a,b,c) where - typeOf tu = mkAppTy tup3Tc [typeOf ((undefined :: (a,b,c) -> a) tu), - typeOf ((undefined :: (a,b,c) -> b) tu), - typeOf ((undefined :: (a,b,c) -> c) tu)] - -tup4Tc :: TyCon -tup4Tc = mkTyCon ",,," - -instance ( Typeable a - , Typeable b - , Typeable c - , Typeable d) => Typeable (a,b,c,d) where - typeOf tu = mkAppTy tup4Tc [typeOf ((undefined :: (a,b,c,d) -> a) tu), - typeOf ((undefined :: (a,b,c,d) -> b) tu), - typeOf ((undefined :: (a,b,c,d) -> c) tu), - typeOf ((undefined :: (a,b,c,d) -> d) tu)] -tup5Tc :: TyCon -tup5Tc = mkTyCon ",,,," - -instance ( Typeable a - , Typeable b - , Typeable c - , Typeable d - , Typeable e) => Typeable (a,b,c,d,e) where - typeOf tu = mkAppTy tup5Tc [typeOf ((undefined :: (a,b,c,d,e) -> a) tu), - typeOf ((undefined :: (a,b,c,d,e) -> b) tu), - typeOf ((undefined :: (a,b,c,d,e) -> c) tu), - typeOf ((undefined :: (a,b,c,d,e) -> d) tu), - typeOf ((undefined :: (a,b,c,d,e) -> e) tu)] - -instance (Typeable a, Typeable b) => Typeable (a -> b) where - typeOf f = mkFunTy (typeOf ((undefined :: (a -> b) -> a) f)) - (typeOf ((undefined :: (a -> b) -> b) f)) - - - -------------------------------------------------------- --- --- Generate Typeable instances for standard datatypes --- -------------------------------------------------------- - -INSTANCE_TYPEABLE0(Bool,boolTc,"Bool") -INSTANCE_TYPEABLE0(Char,charTc,"Char") -INSTANCE_TYPEABLE0(Float,floatTc,"Float") -INSTANCE_TYPEABLE0(Double,doubleTc,"Double") -INSTANCE_TYPEABLE0(Int,intTc,"Int") -INSTANCE_TYPEABLE0(Integer,integerTc,"Integer") -INSTANCE_TYPEABLE1(Ratio,ratioTc,"Ratio") -INSTANCE_TYPEABLE2(Either,eitherTc,"Either") -INSTANCE_TYPEABLE1(IO,ioTc,"IO") -INSTANCE_TYPEABLE1(Maybe,maybeTc,"Maybe") -INSTANCE_TYPEABLE0(Ordering,orderingTc,"Ordering") -INSTANCE_TYPEABLE0(Handle,handleTc,"Handle") -INSTANCE_TYPEABLE1(Ptr,ptrTc,"Ptr") -INSTANCE_TYPEABLE1(StablePtr,stablePtrTc,"StablePtr") - -INSTANCE_TYPEABLE0(Int8,int8Tc,"Int8") -INSTANCE_TYPEABLE0(Int16,int16Tc,"Int16") -INSTANCE_TYPEABLE0(Int32,int32Tc,"Int32") -INSTANCE_TYPEABLE0(Int64,int64Tc,"Int64") - -INSTANCE_TYPEABLE0(Word8,word8Tc,"Word8" ) -INSTANCE_TYPEABLE0(Word16,word16Tc,"Word16") -INSTANCE_TYPEABLE0(Word32,word32Tc,"Word32") -INSTANCE_TYPEABLE0(Word64,word64Tc,"Word64") - -INSTANCE_TYPEABLE0(TyCon,tyconTc,"TyCon") -INSTANCE_TYPEABLE0(TypeRep,typeRepTc,"TypeRep") - -INSTANCE_TYPEABLE1(IORef,ioRefTc,"IORef") - -#endif /* GHC < 6.3 */ - - ---------------------------------------------- --- --- Internals --- ---------------------------------------------- - -newtype Key = Key Int deriving( Eq ) - -data KeyPr = KeyPr !Key !Key deriving( Eq ) - -hashKP :: KeyPr -> Int32 -hashKP (KeyPr (Key k1) (Key k2)) = (HT.hashInt k1 + HT.hashInt k2) `rem` HT.prime - -data Cache = Cache { next_key :: !(IORef Key), - tc_tbl :: !(HT.HashTable String Key), - ap_tbl :: !(HT.HashTable KeyPr Key) } - -{-# NOINLINE cache #-} -cache :: Cache -cache = unsafePerformIO $ do - empty_tc_tbl <- HT.new (==) HT.hashString - empty_ap_tbl <- HT.new (==) hashKP - key_loc <- newIORef (Key 1) - return (Cache { next_key = key_loc, - tc_tbl = empty_tc_tbl, - ap_tbl = empty_ap_tbl }) - -newKey :: IORef Key -> IO Key -newKey _ = do i <- genSym; return (Key i) - - --- In GHC we use the RTS's genSym function to get a new unique, --- because in GHCi we might have two copies of the Data.Typeable --- library running (one in the compiler and one in the running --- program), and we need to make sure they don't share any keys. --- --- This is really a hack. A better solution would be to centralise the --- whole mutable state used by this module, i.e. both hashtables. But --- the current solution solves the immediate problem, which is that --- dynamics generated in one world with one type were erroneously --- being recognised by the other world as having a different type. --- --- dons: SimonM says we need to unify the hashes by storing them in a --- variable in the rts. --- -foreign import ccall unsafe "genSymZh" - genSym :: IO Int - -mkTyConKey :: String -> Key -mkTyConKey str - = unsafePerformIO $ do - let Cache {next_key = kloc, tc_tbl = tbl} = cache - mb_k <- HT.lookup tbl str - case mb_k of - Just k -> return k - Nothing -> do { k <- newKey kloc ; - HT.insert tbl str k ; - return k } - -appKey :: Key -> Key -> Key -appKey k1 k2 - = unsafePerformIO $ do - let Cache {next_key = kloc, ap_tbl = tbl} = cache - mb_k <- HT.lookup tbl kpr - case mb_k of - Just k -> return k - Nothing -> do { k <- newKey kloc ; - HT.insert tbl kpr k ; - return k } - where - kpr = KeyPr k1 k2 - -appKeys :: Key -> [Key] -> Key -appKeys k ks = foldl appKey k ks rmfile ./src/AltData/Typeable.hs rmdir ./src/AltData hunk ./src/System/Eval/Haskell.hs 240 - "import AltData.Dynamic\n" ++ + "import Data.Dynamic\n" ++ hunk ./src/Language/Hi/Parser.hs 73 + pkg_name <- get bh :: IO FastString hunk ./src/Language/Hi/Parser.hs 76 - let pkg_name = mkFastString "unknown" -- >=604 has no package field hunk ./testsuite/build.mk 6 -BIN= prog/a.out +BIN= prog/Main hunk ./testsuite/build.mk 11 -REALBIN= ./a.out +REALBIN= ./Main hunk ./testsuite/build.mk 35 - rm -rf */*.{hi,o,old} */a.out + rm -rf */*.{hi,o,old} */Main hunk ./testsuite/eval/eval3/Main.hs 14 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/eval/eval3/Main.hs 22 - ["AltData.Dynamic"] + ["Data.Dynamic"] hunk ./testsuite/eval.mk 4 -BIN=a.out +BIN=Main hunk ./testsuite/foreign.mk 10 -BIN=./a.out +BIN=./Main hunk ./testsuite/iface/null/expected 1 -interface "Main" Main +interface "main" Main hunk ./testsuite/iface/null/expected 3 -package dependencies: base, haskell98, hi -import A -import B +package dependencies: base, plugins-1.0 + hunk ./testsuite/load/io/TestIO.hs 11 + +import Distribution.Package +import Language.Haskell.Parser +import Network.HxWeb hunk ./testsuite/makewith/io/prog/expected 6 -a.out: failed +Main: failed hunk ./testsuite/makewith/unsafeio/prog/expected 6 -a.out: failed +Main: failed hunk ./src/System/Plugins/Env.hs 43 + addStaticPkg, + isStaticPkg, hunk ./src/System/Plugins/Env.hs 76 -#if __GLASGOW_HASKELL__ < 604 -import Data.FiniteMap +import Distribution.Package +import Text.ParserCombinators.ReadP hunk ./src/System/Plugins/Env.hs 79 -#else hunk ./src/System/Plugins/Env.hs 80 - +import qualified Data.Set as S hunk ./src/System/Plugins/Env.hs 98 -#endif - hunk ./src/System/Plugins/Env.hs 134 +type StaticPkgEnv = S.Set PackageName + hunk ./src/System/Plugins/Env.hs 146 + IORef StaticPkgEnv, hunk ./src/System/Plugins/Env.hs 160 - ref4 <- newIORef emptyFM -- merged files - return (mvar, ref1, ref2, ref3, ref4) + ref4 <- newIORef (S.fromList ["base","Cabal","haskell-src"]) + ref5 <- newIORef emptyFM -- merged files + return (mvar, ref1, ref2, ref3, ref4, ref5) hunk ./src/System/Plugins/Env.hs 174 +withStaticPkgEnv :: Env -> (StaticPkgEnv -> IO a) -> IO a hunk ./src/System/Plugins/Env.hs 177 -withModEnv (mvar,ref,_,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) -withDepEnv (mvar,_,ref,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) -withPkgEnvs (mvar,_,_,ref,_) f = withMVar mvar (\_ -> readIORef ref >>= f) -withMerged (mvar,_,_,_,ref) f = withMVar mvar (\_ -> readIORef ref >>= f) +withModEnv (mvar,ref,_,_,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withDepEnv (mvar,_,ref,_,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withPkgEnvs (mvar,_,_,ref,_,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withStaticPkgEnv (mvar,_,_,_,ref,_) f = withMVar mvar (\_ -> readIORef ref >>= f) +withMerged (mvar,_,_,_,_,ref) f = withMVar mvar (\_ -> readIORef ref >>= f) hunk ./src/System/Plugins/Env.hs 191 +modifyStaticPkgEnv :: Env -> (StaticPkgEnv -> IO StaticPkgEnv) -> IO () hunk ./src/System/Plugins/Env.hs 194 -modifyModEnv (mvar,ref,_,_,_) f = lockAndWrite mvar ref f -modifyDepEnv (mvar,_,ref,_,_) f = lockAndWrite mvar ref f -modifyPkgEnv (mvar,_,_,ref,_) f = lockAndWrite mvar ref f -modifyMerged (mvar,_,_,_,ref) f = lockAndWrite mvar ref f +modifyModEnv (mvar,ref,_,_,_,_) f = lockAndWrite mvar ref f +modifyDepEnv (mvar,_,ref,_,_,_) f = lockAndWrite mvar ref f +modifyPkgEnv (mvar,_,_,ref,_,_) f = lockAndWrite mvar ref f +modifyStaticPkgEnv (mvar,_,_,_,ref,_) f = lockAndWrite mvar ref f +modifyMerged (mvar,_,_,_,_,ref) f = lockAndWrite mvar ref f hunk ./src/System/Plugins/Env.hs 321 +-- ----------------------------------------------------------- +-- Static package management stuff. A static package is linked with the base +-- application and we should therefore not link with any of the DLLs it requires. + +addStaticPkg :: PackageName -> IO () +addStaticPkg pkg = modifyStaticPkgEnv env $ \set -> return $ S.insert pkg set + +isStaticPkg :: PackageName -> IO Bool +isStaticPkg pkg + = case readP_to_S parsePackageName pkg of + ((pkgName,_):_) -> withStaticPkgEnv env $ \set -> return $ S.member pkgName set + [] -> return False hunk ./src/System/Plugins/Env.hs 355 - case t of ([],(f,g)) -> return (f,g) + static <- isStaticPkg p + case t of ([],(f,g)) -> return (f,if static then [] else g) hunk ./src/System/Plugins/Env.hs 359 - return $ (nub $ (concat f') ++ f,nub $ (concat g') ++ g) + return $ (nub $ (concat f') ++ f + ,if static then [] else nub $ (concat g') ++ g) hunk ./src/System/Plugins/Env.hs 406 - extras = filter (not . flip elem (cbits++["m","gmp"])) extras' + extras = filter (flip notElem cbits) extras' hunk ./src/System/Plugins/Env.hs 160 - ref4 <- newIORef (S.fromList ["base","Cabal","haskell-src"]) + ref4 <- newIORef (S.fromList ["base","Cabal-1.1.6","haskell-src-1.0"]) -- FIXME hunk ./src/System/Plugins/Env.hs 287 - in foldr (\p fm' -> addToFM fm' (packageName p) p) fm ps' : ls + in foldr (\p fm' -> if packageName_ p == "base" + then addToFM fm' (packageName_ p) p + else addToFM fm' (packageName p) p) fm ps' : ls hunk ./src/System/Plugins/Load.hs 416 - = do let symbol = prefixUnderscore++m++"_"++(encode valsym)++"_closure" + = do let symbol = prefixUnderscore++encode m++"_"++(encode valsym)++"_closure" hunk ./src/System/Plugins/Env.hs 287 - in foldr (\p fm' -> if packageName_ p == "base" + in foldr (\p fm' -> if packageName_ p == "base" -- ghc doesn't supply a version with 'base' + -- for some reason. hunk ./src/System/Plugins/Env.hs 289 - then addToFM fm' (packageName_ p) p + then addToFM (addToFM fm' (packageName_ p) p) (packageName p) p hunk ./configure.ac 66 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0` +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` hunk ./configure.ac 103 - GHC_LIB_PATH=`$GHC --print-libdir` + GHC_LIB_PATH=`$GHC --print-libdir | tr -d '\r'` hunk ./plugins.cabal.hsx 8 - AltData.Dynamic, - AltData.Typeable, hunk ./src/System/Eval/Haskell.hs 231 --- --- note that the wrapper uses our altdata library for dynamic typing. --- hence it needs to see the path to the altdata package. grr. is it --- installed or not? what path does it have? --- hunk ./src/System/Plugins/Load.hs 46 + , loadPackageFunction hunk ./src/System/Plugins/Load.hs 416 -loadFunction_ m valsym - = do let symbol = prefixUnderscore++encode m++"_"++(encode valsym)++"_closure" +loadFunction_ = loadFunction__ Nothing + +loadFunction__ :: Maybe String + -> String + -> String + -> IO (Maybe a) +loadFunction__ pkg m valsym + = do let symbol = prefixUnderscore++(maybe "" (\p -> encode p++"_") pkg) + ++encode m++"_"++(encode valsym)++"_closure" hunk ./src/System/Plugins/Load.hs 435 +-- | Loads a function from a package module, given the package name, +-- module name and symbol name. +loadPackageFunction :: String -- ^ Package name, including version number. + -> String -- ^ Module name + -> String -- ^ Symbol to lookup in the module + -> IO (Maybe a) +loadPackageFunction pkgName moduleName functionName = + do loadPackage pkgName + resolveObjs (unloadPackage pkgName) + loadFunction__ (Just pkgName) moduleName functionName hunk ./plugins.cabal 8 - Language.Hi.Binary, - Language.Hi.FastMutInt, - Language.Hi.FastString, - Language.Hi.Parser, - Language.Hi.PrimPacked, - Language.Hi.Syntax, hunk ./plugins.cabal 24 -c-sources: - src/Language/Hi/hschooks.c hunk ./plugins.cabal 26 -Build-Depends: base, Cabal, haskell-src +Build-Depends: base, Cabal, haskell-src, containers, array, directory, random, process, ghc hunk ./plugins.cabal 28 -hs-source-dir: src +hs-source-dirs: src hunk ./plugins.cabal.hsx 1 -name: plugins -version: 1.0 -license: LGPL -License-file: LICENSE -author: Don Stewart -maintainer: dons@cse.unsw.edu.au -exposed-modules: - Language.Hi.Binary, - Language.Hi.FastMutInt, - Language.Hi.FastString, - Language.Hi.Parser, - Language.Hi.PrimPacked, - Language.Hi.Syntax, - System.Eval, - System.Eval.Haskell, - System.Eval.Utils, - System.MkTemp, - System.Plugins, - System.Plugins.Consts, - System.Plugins.Env, - System.Plugins.Load, - System.Plugins.LoadTypes, - System.Plugins.Make, - System.Plugins.Package, - System.Plugins.PackageAPI, - System.Plugins.ParsePkgConfCabal, - System.Plugins.Parser, - System.Plugins.Process, - System.Plugins.Utils -c-sources: - src/Language/Hi/hschooks.c -includes: Linker.h -extensions: CPP, ForeignFunctionInterface -Build-Depends: base, Cabal, haskell-src-exts -ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures -hs-source-dir: src rmfile ./plugins.cabal.hsx hunk ./src/Language/Hi/Binary.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} -{-# OPTIONS -fno-warn-unused-imports -fno-warn-name-shadowing #-} -{-# OPTIONS -fno-warn-unused-matches -fno-warn-unused-binds #-} --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA - --- Based on $fptools/ghc/compiler/utils/Binary.hs: --- (c) The University of Glasgow 2002 --- --- Binary I/O library, with special tweaks for GHC --- --- Based on the nhc98 Binary library, which is copyright --- (c) Malcolm Wallace and Colin Runciman, University of York, 1998. --- Under the terms of the license for that software, we must tell you --- where you can obtain the original version of the Binary library, namely --- http://www.cs.york.ac.uk/fp/nhc98/ --- --- We never have to write stuff, so I've scrubbed all the put* code. --- - -module Language.Hi.Binary ( - {-type-} Bin, - {-class-} Binary(..), - {-type-} BinHandle, - - openBinIO, openBinIO_, - openBinMem, --- closeBin, - - seekBin, - tellBin, - castBin, - - readBinMem, - - isEOFBin, - - -- for writing instances: - getByte, - - -- lazy Bin I/O - lazyGet, - - -- GHC only: - ByteArray(..), - getByteArray, - - getBinFileWithDict, -- :: Binary a => FilePath -> IO a - - ) where - --- The *host* architecture version: -#include "MachDeps.h" - --- import Hi.Utils -- ? - -import Language.Hi.FastMutInt -import Language.Hi.FastString - -#if __GLASGOW_HASKELL__ < 604 -import Data.FiniteMap -#else -import qualified Data.Map as M -#endif - -import Data.Unique - -import Data.Array.IO -import Data.Array -import Data.Bits -import Data.Int -import Data.Word -import Data.IORef -import Data.Char ( ord, chr ) -import Data.Array.Base ( unsafeRead, unsafeWrite ) -import Control.Monad ( when ) -import System.IO -import System.IO.Unsafe ( unsafeInterleaveIO ) -import System.IO.Error ( mkIOError, eofErrorType ) -import GHC.Real ( Ratio(..) ) -import GHC.Exts -import GHC.IOBase ( IO(..) ) -import GHC.Word ( Word8(..) ) -#if __GLASGOW_HASKELL__ < 601 -import GHC.Handle ( openFileEx, IOModeEx(..) ) -#endif - -#if __GLASGOW_HASKELL__ < 601 -openBinaryFile f mode = openFileEx f (BinaryMode mode) -#endif - -type BinArray = IOUArray Int Word8 - ---------------------------------------------------------------- --- BinHandle ---------------------------------------------------------------- - -data BinHandle - = BinMem { -- binary data stored in an unboxed array - bh_usr :: UserData, -- sigh, need parameterized modules :-) - off_r :: !FastMutInt, -- the current offset - sz_r :: !FastMutInt, -- size of the array (cached) - arr_r :: !(IORef BinArray) -- the array (bounds: (0,size-1)) - } - -- XXX: should really store a "high water mark" for dumping out - -- the binary data to a file. - - | BinIO { -- binary data stored in a file - bh_usr :: UserData, - off_r :: !FastMutInt, -- the current offset (cached) - hdl :: !Handle -- the file handle (must be seekable) - } - -- cache the file ptr in BinIO; using hTell is too expensive - -- to call repeatedly. If anyone else is modifying this Handle - -- at the same time, we'll be screwed. - -getUserData :: BinHandle -> UserData -getUserData bh = bh_usr bh - -setUserData :: BinHandle -> UserData -> BinHandle -setUserData bh us = bh { bh_usr = us } - - ---------------------------------------------------------------- --- Bin ---------------------------------------------------------------- - -newtype Bin a = BinPtr Int - deriving (Eq, Ord, Show, Bounded) - -castBin :: Bin a -> Bin b -castBin (BinPtr i) = BinPtr i - ---------------------------------------------------------------- --- class Binary ---------------------------------------------------------------- - -class Binary a where - get :: BinHandle -> IO a - -getAt :: Binary a => BinHandle -> Bin a -> IO a -getAt bh p = do seekBin bh p; get bh - -openBinIO_ :: Handle -> IO BinHandle -openBinIO_ h = openBinIO h - -openBinIO :: Handle -> IO BinHandle -openBinIO h = do - r <- newFastMutInt - writeFastMutInt r 0 - return (BinIO noUserData r h) - -openBinMem :: Int -> IO BinHandle -openBinMem size - | size <= 0 = error "Hi.Binary.openBinMem: size must be >= 0" - | otherwise = do - arr <- newArray_ (0,size-1) - arr_r <- newIORef arr - ix_r <- newFastMutInt - writeFastMutInt ix_r 0 - sz_r <- newFastMutInt - writeFastMutInt sz_r size - return (BinMem noUserData ix_r sz_r arr_r) - -tellBin :: BinHandle -> IO (Bin a) -tellBin (BinIO _ r _) = do ix <- readFastMutInt r; return (BinPtr ix) -tellBin (BinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) - -seekBin :: BinHandle -> Bin a -> IO () -seekBin (BinIO _ ix_r h) (BinPtr p) = do - writeFastMutInt ix_r p - hSeek h AbsoluteSeek (fromIntegral p) -seekBin h@(BinMem _ ix_r sz_r a) (BinPtr p) = do - sz <- readFastMutInt sz_r - if (p >= sz) - then do expandBin h p; writeFastMutInt ix_r p - else writeFastMutInt ix_r p - -isEOFBin :: BinHandle -> IO Bool -isEOFBin (BinMem _ ix_r sz_r a) = do - ix <- readFastMutInt ix_r - sz <- readFastMutInt sz_r - return (ix >= sz) -isEOFBin (BinIO _ ix_r h) = hIsEOF h - -readBinMem :: FilePath -> IO BinHandle --- Return a BinHandle with a totally undefined State -readBinMem filename = do - h <- openBinaryFile filename ReadMode - filesize' <- hFileSize h - let filesize = fromIntegral filesize' - arr <- newArray_ (0,filesize-1) - count <- hGetArray h arr filesize - when (count /= filesize) - (error ("Hi.Binary.readBinMem: only read " ++ show count ++ " bytes")) - hClose h - arr_r <- newIORef arr - ix_r <- newFastMutInt - writeFastMutInt ix_r 0 - sz_r <- newFastMutInt - writeFastMutInt sz_r filesize - return (BinMem noUserData ix_r sz_r arr_r) - --- expand the size of the array to include a specified offset -expandBin :: BinHandle -> Int -> IO () -expandBin (BinMem _ ix_r sz_r arr_r) off = do - sz <- readFastMutInt sz_r - let sz' = head (dropWhile (<= off) (iterate (* 2) sz)) - arr <- readIORef arr_r - arr' <- newArray_ (0,sz'-1) - sequence_ [ unsafeRead arr i >>= unsafeWrite arr' i - | i <- [ 0 .. sz-1 ] ] - writeFastMutInt sz_r sz' - writeIORef arr_r arr' -#ifdef DEBUG - hPutStrLn stderr ("Binary: expanding to size: " ++ show sz') -#endif - return () -expandBin (BinIO _ _ _) _ = return () - -- no need to expand a file, we'll assume they expand by themselves. - --- ----------------------------------------------------------------------------- --- Low-level reading/writing of bytes - -getWord8 :: BinHandle -> IO Word8 -getWord8 (BinMem _ ix_r sz_r arr_r) = do - ix <- readFastMutInt ix_r - sz <- readFastMutInt sz_r - when (ix >= sz) $ -#if __GLASGOW_HASKELL__ <= 408 - throw (mkIOError eofErrorType "Hi.Binary.getWord8" Nothing Nothing) -#else - ioError (mkIOError eofErrorType "Hi.Binary.getWord8" Nothing Nothing) -#endif - arr <- readIORef arr_r - w <- unsafeRead arr ix - writeFastMutInt ix_r (ix+1) - return w -getWord8 (BinIO _ ix_r h) = do - ix <- readFastMutInt ix_r - c <- hGetChar h - writeFastMutInt ix_r (ix+1) - return $! (fromIntegral (ord c)) -- XXX not really correct - -getByte :: BinHandle -> IO Word8 -getByte = getWord8 - --- ----------------------------------------------------------------------------- --- Primitve Word writes - -instance Binary Word8 where - get = getWord8 - -instance Binary Word16 where - get h = do - w1 <- getWord8 h - w2 <- getWord8 h - return $! ((fromIntegral w1 `shiftL` 8) .|. fromIntegral w2) - -instance Binary Word32 where - get h = do - w1 <- getWord8 h - w2 <- getWord8 h - w3 <- getWord8 h - w4 <- getWord8 h - return $! ((fromIntegral w1 `shiftL` 24) .|. - (fromIntegral w2 `shiftL` 16) .|. - (fromIntegral w3 `shiftL` 8) .|. - (fromIntegral w4)) - -instance Binary Word64 where - get h = do - w1 <- getWord8 h - w2 <- getWord8 h - w3 <- getWord8 h - w4 <- getWord8 h - w5 <- getWord8 h - w6 <- getWord8 h - w7 <- getWord8 h - w8 <- getWord8 h - return $! ((fromIntegral w1 `shiftL` 56) .|. - (fromIntegral w2 `shiftL` 48) .|. - (fromIntegral w3 `shiftL` 40) .|. - (fromIntegral w4 `shiftL` 32) .|. - (fromIntegral w5 `shiftL` 24) .|. - (fromIntegral w6 `shiftL` 16) .|. - (fromIntegral w7 `shiftL` 8) .|. - (fromIntegral w8)) - --- ----------------------------------------------------------------------------- --- Primitve Int writes - -instance Binary Int8 where - get h = do w <- get h; return $! (fromIntegral (w::Word8)) - -instance Binary Int16 where - get h = do w <- get h; return $! (fromIntegral (w::Word16)) - -instance Binary Int32 where - get h = do w <- get h; return $! (fromIntegral (w::Word32)) - -instance Binary Int64 where - get h = do w <- get h; return $! (fromIntegral (w::Word64)) - --- ----------------------------------------------------------------------------- --- Instances for standard types - -instance Binary () where - get _ = return () - -instance Binary Bool where - get bh = do x <- getWord8 bh; return $! (toEnum (fromIntegral x)) - -instance Binary Char where - get bh = do x <- get bh; return $! (chr (fromIntegral (x :: Word32))) - -instance Binary Int where -#if SIZEOF_HSINT == 4 - get bh = do - x <- get bh - return $! (fromIntegral (x :: Int32)) -#elif SIZEOF_HSINT == 8 - get bh = do - x <- get bh - return $! (fromIntegral (x :: Int64)) -#else -#error "unsupported sizeof(HsInt)" -#endif - -instance Binary a => Binary [a] where -#if __GLASGOW_HASKELL__ < 605 - get bh = do h <- getWord8 bh - case h of - 0 -> return [] - _ -> do x <- get bh - xs <- get bh - return (x:xs) -#else - get bh = do - b <- getByte bh - len <- if b == 0xff - then get bh - else return (fromIntegral b :: Word32) - let loop 0 = return [] - loop n = do a <- get bh; as <- loop (n-1); return (a:as) - loop len -#endif - -instance (Binary a, Binary b) => Binary (a,b) where - get bh = do a <- get bh - b <- get bh - return (a,b) - -instance (Binary a, Binary b, Binary c) => Binary (a,b,c) where - get bh = do a <- get bh - b <- get bh - c <- get bh - return (a,b,c) - -instance (Binary a, Binary b, Binary c, Binary d) => Binary (a,b,c,d) where - get bh = do a <- get bh - b <- get bh - c <- get bh - d <- get bh - return (a,b,c,d) - -instance Binary a => Binary (Maybe a) where - get bh = do h <- getWord8 bh - case h of - 0 -> return Nothing - _ -> do x <- get bh; return (Just x) - -instance (Binary a, Binary b) => Binary (Either a b) where - get bh = do h <- getWord8 bh - case h of - 0 -> do a <- get bh ; return (Left a) - _ -> do b <- get bh ; return (Right b) - -#ifdef __GLASGOW_HASKELL__ -instance Binary Integer where - get bh = do - b <- getByte bh - case b of - 0 -> do (I# i#) <- get bh - return (S# i#) - _ -> do (I# s#) <- get bh - sz <- get bh - (BA a#) <- getByteArray bh sz - return (J# s# a#) - -getByteArray :: BinHandle -> Int -> IO ByteArray -getByteArray bh (I# sz) = do - (MBA arr) <- newByteArray sz - let loop n - | n ==# sz = return () - | otherwise = do - w <- getByte bh - writeByteArray arr n w - loop (n +# 1#) - loop 0# - freezeByteArray arr - - -data ByteArray = BA ByteArray# -data MBA = MBA (MutableByteArray# RealWorld) - -newByteArray :: Int# -> IO MBA -newByteArray sz = IO $ \s -> - case newByteArray# sz s of { (# s, arr #) -> - (# s, MBA arr #) } - -freezeByteArray :: MutableByteArray# RealWorld -> IO ByteArray -freezeByteArray arr = IO $ \s -> - case unsafeFreezeByteArray# arr s of { (# s, arr #) -> - (# s, BA arr #) } - -#if __GLASGOW_HASKELL__ < 503 -writeByteArray arr i w8 = IO $ \s -> - case word8ToWord w8 of { W# w# -> - case writeCharArray# arr i (chr# (word2Int# w#)) s of { s -> - (# s , () #) }} -#else -writeByteArray arr i (W8# w) = IO $ \s -> - case writeWord8Array# arr i w s of { s -> - (# s, () #) } -#endif - -#if __GLASGOW_HASKELL__ < 503 -indexByteArray a# n# = fromIntegral (I# (ord# (indexCharArray# a# n#))) -#else -indexByteArray a# n# = W8# (indexWord8Array# a# n#) -#endif - -instance (Integral a, Binary a) => Binary (Ratio a) where - get bh = do a <- get bh; b <- get bh; return (a :% b) -#endif - -instance Binary (Bin a) where - get bh = do i <- get bh; return (BinPtr i) - --- ----------------------------------------------------------------------------- --- Lazy reading/writing - -lazyGet :: Binary a => BinHandle -> IO a -lazyGet bh = do - p <- get bh -- a BinPtr - p_a <- tellBin bh - a <- unsafeInterleaveIO (getAt bh p_a) - seekBin bh p -- skip over the object for now - return a - --- -------------------------------------------------------------- --- Main wrappers: getBinFileWithDict, putBinFileWithDict --- --- This layer is built on top of the stuff above, --- and should not know anything about BinHandles --- -------------------------------------------------------------- - -initBinMemSize = (1024*1024) :: Int -#if WORD_SIZE_IN_BITS == 32 -binaryInterfaceMagic = 0x1face :: Word32 -#elif WORD_SIZE_IN_BITS == 64 -binaryInterfaceMagic = 0x1face64 :: Word32 -#endif - -getBinFileWithDict :: Binary a => FilePath -> IO a -getBinFileWithDict file_path = do - bh <- Language.Hi.Binary.readBinMem file_path - - -- Read the magic number to check that this really is a GHC .hi file - -- (This magic number does not change when we change - -- GHC interface file format) - magic <- get bh - - when (magic /= binaryInterfaceMagic) $ - error "magic number mismatch: old/corrupt interface file?" - - -- Read the dictionary - -- The next word in the file is a pointer to where the dictionary is - -- (probably at the end of the file) - dict_p <- Language.Hi.Binary.get bh -- Get the dictionary ptr - data_p <- tellBin bh -- Remember where we are now - seekBin bh dict_p - dict <- getDictionary bh - - seekBin bh data_p -- Back to where we were before - - -- Initialise the user-data field of bh - let bh' = setUserData bh (initReadState dict) - - -- At last, get the thing - get bh' - --- ----------------------------------------------------------------------------- --- UserData --- ----------------------------------------------------------------------------- - -data UserData = - UserData { -- This field is used only when reading - ud_dict :: Dictionary, - - -- The next two fields are only used when writing - ud_next :: IORef Int, -- The next index to use -#if __GLASGOW_HASKELL__ < 604 - ud_map :: IORef (FiniteMap Unique (Int,FastString)) -#else - ud_map :: IORef (M.Map Unique (Int,FastString)) -#endif - } - -noUserData = error "Hi.Binary.UserData: no user data" - -initReadState :: Dictionary -> UserData -initReadState dict = UserData{ ud_dict = dict, - ud_next = undef "next", - ud_map = undef "map" } - -newWriteState :: IO UserData -newWriteState = do - j_r <- newIORef 0 -#if __GLASGOW_HASKELL__ < 604 - out_r <- newIORef emptyFM -#else - out_r <- newIORef M.empty -#endif - return (UserData { ud_dict = error "dict", - ud_next = j_r, - ud_map = out_r }) - - -undef s = error ("Hi.Binary.UserData: no " ++ s) - ---------------------------------------------------------- --- The Dictionary ---------------------------------------------------------- - -type Dictionary = Array Int FastString -- The dictionary - -- Should be 0-indexed - -getDictionary :: BinHandle -> IO Dictionary -getDictionary bh = do - sz <- get bh - elems <- sequence (take sz (repeat (getFS bh))) - return (listArray (0,sz-1) elems) - -#if __GLASGOW_HASKELL__ < 604 -constructDictionary :: Int -> FiniteMap Unique (Int,FastString) -> Dictionary -constructDictionary j fm = array (0,j-1) (eltsFM fm) -#else -constructDictionary :: Int -> M.Map Unique (Int,FastString) -> Dictionary -constructDictionary j fm = array (0,j-1) (M.elems fm) -#endif - ---------------------------------------------------------- --- Reading and writing FastStrings ---------------------------------------------------------- - -getFS bh = do - (I# l) <- get bh - (BA ba) <- getByteArray bh (I# l) - return $! (mkFastSubStringBA# ba 0# l) - -instance Binary FastString where - get bh = do j <- get bh -- Int - return $! (ud_dict (getUserData bh) ! j) - rmfile ./src/Language/Hi/Binary.hs hunk ./src/Language/Hi/FastMutInt.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} -{-# OPTIONS -fno-warn-name-shadowing #-} --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- --- Based on code from $fptools/ghc/compiler/utils/FastMutInt.lhs --- --- (c) Copyright 2002, The University Court of the University of Glasgow. - --- --- Unboxed mutable Ints --- - -module Language.Hi.FastMutInt ( - FastMutInt, - newFastMutInt, - readFastMutInt, - writeFastMutInt, - incFastMutInt, - incFastMutIntBy - ) where - -#include "MachDeps.h" - -#if __GLASGOW_HASKELL__ < 503 -import GlaExts -import PrelIOBase -#else -import GHC.Base -import GHC.IOBase -#endif - -#if __GLASGOW_HASKELL__ < 411 -newByteArray# = newCharArray# -#endif - -data FastMutInt = FastMutInt (MutableByteArray# RealWorld) - -newFastMutInt :: IO FastMutInt -newFastMutInt = IO $ \s -> - case newByteArray# size s of { (# s, arr #) -> - (# s, FastMutInt arr #) } - where I# size = SIZEOF_HSINT - -readFastMutInt :: FastMutInt -> IO Int -readFastMutInt (FastMutInt arr) = IO $ \s -> - case readIntArray# arr 0# s of { (# s, i #) -> - (# s, I# i #) } - -writeFastMutInt :: FastMutInt -> Int -> IO () -writeFastMutInt (FastMutInt arr) (I# i) = IO $ \s -> - case writeIntArray# arr 0# i s of { s -> - (# s, () #) } - -incFastMutInt :: FastMutInt -> IO Int -- Returns original value -incFastMutInt (FastMutInt arr) = IO $ \s -> - case readIntArray# arr 0# s of { (# s, i #) -> - case writeIntArray# arr 0# (i +# 1#) s of { s -> - (# s, I# i #) } } - -incFastMutIntBy :: FastMutInt -> Int -> IO Int -- Returns original value -incFastMutIntBy (FastMutInt arr) (I# n) = IO $ \s -> - case readIntArray# arr 0# s of { (# s, i #) -> - case writeIntArray# arr 0# (i +# n) s of { s -> - (# s, I# i #) } } - rmfile ./src/Language/Hi/FastMutInt.hs hunk ./src/Language/Hi/FastString.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} -{-# OPTIONS -fno-warn-name-shadowing -fno-warn-unused-matches #-} - -{-# OPTIONS -#include "hschooks.h" #-} - --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- --- Based on $fptools/ghc/compiler/utils/FastString.lhs --- --- (c) The GRASP/AQUA Project, Glasgow University, 1997-1998 --- --- Fast strings --- --- Compact representations of character strings with --- unique identifiers (hash-cons'ish). --- - -module Language.Hi.FastString - ( - FastString(..), -- not abstract, for now. - - mkFastString, -- :: String -> FastString - mkFastStringNarrow, -- :: String -> FastString - mkFastSubString, -- :: Addr -> Int -> Int -> FastString - - mkFastString#, -- :: Addr# -> FastString - mkFastSubStringBA#, -- :: ByteArray# -> Int# -> Int# -> FastString - - mkFastStringInt, -- :: [Int] -> FastString - - uniqueOfFS, -- :: FastString -> Int# - lengthFS, -- :: FastString -> Int - nullFastString, -- :: FastString -> Bool - - unpackFS, -- :: FastString -> String - unpackIntFS, -- :: FastString -> [Int] - appendFS, -- :: FastString -> FastString -> FastString - headFS, -- :: FastString -> Char - headIntFS, -- :: FastString -> Int - tailFS, -- :: FastString -> FastString - concatFS, -- :: [FastString] -> FastString - consFS, -- :: Char -> FastString -> FastString - indexFS, -- :: FastString -> Int -> Char - nilFS, -- :: FastString - - hPutFS, -- :: Handle -> FastString -> IO () - - LitString, - mkLitString# -- :: Addr# -> LitString - ) where - -import Language.Hi.PrimPacked - -import System.IO -import Data.Char ( chr, ord ) - -import GHC.Exts -import GHC.IOBase -import GHC.Arr ( STArray(..), newSTArray ) -import GHC.Handle - -import Foreign.C - --- import System.IO.Unsafe ( unsafePerformIO ) --- import Control.Monad.ST ( stToIO ) --- import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) - - -#define hASH_TBL_SIZE 993 - -{- -@FastString@s are packed representations of strings -with a unique id for fast comparisons. The unique id -is assigned when creating the @FastString@, using -a hash table to map from the character string representation -to the unique ID. --} - -data FastString - = FastString -- packed repr. on the heap. - Int# -- unique id - -- 0 => string literal, comparison - -- will - Int# -- length - ByteArray# -- stuff - - | UnicodeStr -- if contains characters outside '\1'..'\xFF' - Int# -- unique id - [Int] -- character numbers - -instance Eq FastString where - -- shortcut for real FastStrings - (FastString u1 _ _) == (FastString u2 _ _) = u1 ==# u2 - a == b = case cmpFS a b of { LT -> False; EQ -> True; GT -> False } - - (FastString u1 _ _) /= (FastString u2 _ _) = u1 /=# u2 - a /= b = case cmpFS a b of { LT -> True; EQ -> False; GT -> True } - -instance Ord FastString where - -- Compares lexicographically, not by unique - a <= b = case cmpFS a b of { LT -> True; EQ -> True; GT -> False } - a < b = case cmpFS a b of { LT -> True; EQ -> False; GT -> False } - a >= b = case cmpFS a b of { LT -> False; EQ -> True; GT -> True } - a > b = case cmpFS a b of { LT -> False; EQ -> False; GT -> True } - max x y | x >= y = x - | otherwise = y - min x y | x <= y = x - | otherwise = y - compare a b = cmpFS a b - -lengthFS :: FastString -> Int -lengthFS (FastString _ l# _) = I# l# -lengthFS (UnicodeStr _ s) = length s - -nullFastString :: FastString -> Bool -nullFastString (FastString _ l# _) = l# ==# 0# -nullFastString (UnicodeStr _ []) = True -nullFastString (UnicodeStr _ (_:_)) = False - -unpackFS :: FastString -> String -unpackFS (FastString _ l# ba#) = unpackNBytesBA (BA ba#) (I# l#) -unpackFS (UnicodeStr _ s) = map chr s - -unpackIntFS :: FastString -> [Int] -unpackIntFS (UnicodeStr _ s) = s -unpackIntFS fs = map ord (unpackFS fs) - -appendFS :: FastString -> FastString -> FastString -appendFS fs1 fs2 = mkFastStringInt (unpackIntFS fs1 ++ unpackIntFS fs2) - -concatFS :: [FastString] -> FastString -concatFS ls = mkFastStringInt (concat (map unpackIntFS ls)) -- ToDo: do better - -headFS :: FastString -> Char -headFS (FastString _ l# ba#) = - if l# ># 0# then C# (indexCharArray# ba# 0#) else error ("headFS: empty FS") -headFS (UnicodeStr _ (c:_)) = chr c -headFS (UnicodeStr _ []) = error ("headFS: empty FS") - -headIntFS :: FastString -> Int -headIntFS (UnicodeStr _ (c:_)) = c -headIntFS fs = ord (headFS fs) - -indexFS :: FastString -> Int -> Char -indexFS f i@(I# i#) = - case f of - FastString _ l# ba# - | l# ># 0# && l# ># i# -> C# (indexCharArray# ba# i#) - | otherwise -> error (msg (I# l#)) - UnicodeStr _ s -> chr (s!!i) - where - msg l = "indexFS: out of range: " ++ show (l,i) - -tailFS :: FastString -> FastString -tailFS (FastString _ l# ba#) = mkFastSubStringBA# ba# 1# (l# -# 1#) -tailFS fs = mkFastStringInt (tail (unpackIntFS fs)) - -consFS :: Char -> FastString -> FastString -consFS c fs = mkFastStringInt (ord c : unpackIntFS fs) - -uniqueOfFS :: FastString -> Int# -uniqueOfFS (FastString u# _ _) = u# -uniqueOfFS (UnicodeStr u# _) = u# - -nilFS = mkFastString "" - -{- -GHC-related stuff: - -Internally, the compiler will maintain a fast string symbol -table, providing sharing and fast comparison. Creation of -new @FastString@s then covertly does a lookup, re-using the -@FastString@ if there was a hit. - -Caution: mkFastStringUnicode assumes that if the string is in the -table, it sits under the UnicodeStr constructor. Other mkFastString -variants analogously assume the FastString constructor. --} - -data FastStringTable = - FastStringTable - Int# - (MutableArray# RealWorld [FastString]) - -type FastStringTableVar = IORef FastStringTable - -string_table :: FastStringTableVar -string_table = - unsafePerformIO ( - stToIO (newSTArray (0::Int,hASH_TBL_SIZE) []) - >>= \ (STArray _ _ arr#) -> - newIORef (FastStringTable 0# arr#)) - -lookupTbl :: FastStringTable -> Int# -> IO [FastString] -lookupTbl (FastStringTable _ arr#) i# = - IO ( \ s# -> - readArray# arr# i# s#) - -updTbl :: FastStringTableVar -> FastStringTable -> Int# -> [FastString] -> IO () -updTbl fs_table_var (FastStringTable uid# arr#) i# ls = - IO (\ s# -> case writeArray# arr# i# ls s# of { s2# -> - (# s2#, () #) }) >> - writeIORef fs_table_var (FastStringTable (uid# +# 1#) arr#) - -mkFastString# :: Addr# -> FastString -mkFastString# a# = - case strLength (Ptr a#) of { (I# len#) -> mkFastStringLen# a# len# } - -mkFastStringLen# :: Addr# -> Int# -> FastString -mkFastStringLen# a# len# = - unsafePerformIO ( - readIORef string_table >>= \ ft@(FastStringTable uid# tbl#) -> - let - h = hashStr a# len# - in --- _trace ("hashed: "++show (I# h)) $ - lookupTbl ft h >>= \ lookup_result -> - case lookup_result of - [] -> - -- no match, add it to table by copying out the - -- the string into a ByteArray - -- _trace "empty bucket" $ - case copyPrefixStr a# (I# len#) of - BA barr# -> - let f_str = FastString uid# len# barr# in - updTbl string_table ft h [f_str] >> - ({- _trace ("new: " ++ show f_str) $ -} return f_str) - ls -> - -- non-empty `bucket', scan the list looking - -- entry with same length and compare byte by byte. - -- _trace ("non-empty bucket"++show ls) $ - case bucket_match ls len# a# of - Nothing -> - case copyPrefixStr a# (I# len#) of - BA barr# -> - let f_str = FastString uid# len# barr# in - updTbl string_table ft h (f_str:ls) >> - ( {- _trace ("new: " ++ show f_str) $ -} return f_str) - Just v -> {- _trace ("re-use: "++show v) $ -} return v) - where - bucket_match [] _ _ = Nothing - bucket_match (v@(FastString _ l# ba#):ls) len# a# = - if len# ==# l# && eqStrPrefix a# ba# l# then - Just v - else - bucket_match ls len# a# - bucket_match (UnicodeStr _ _ : ls) len# a# = - bucket_match ls len# a# - -mkFastSubStringBA# :: ByteArray# -> Int# -> Int# -> FastString -mkFastSubStringBA# barr# start# len# = - unsafePerformIO ( - readIORef string_table >>= \ ft@(FastStringTable uid# tbl#) -> - let - h = hashSubStrBA barr# start# len# - in --- _trace ("hashed(b): "++show (I# h)) $ - lookupTbl ft h >>= \ lookup_result -> - case lookup_result of - [] -> - -- no match, add it to table by copying out the - -- the string into a ByteArray - -- _trace "empty bucket(b)" $ - case copySubStrBA (BA barr#) (I# start#) (I# len#) of - BA ba# -> - let f_str = FastString uid# len# ba# in - updTbl string_table ft h [f_str] >> - -- _trace ("new(b): " ++ show f_str) $ - return f_str - ls -> - -- non-empty `bucket', scan the list looking - -- entry with same length and compare byte by byte. - -- _trace ("non-empty bucket(b)"++show ls) $ - case bucket_match ls start# len# barr# of - Nothing -> - case copySubStrBA (BA barr#) (I# start#) (I# len#) of - BA ba# -> - let f_str = FastString uid# len# ba# in - updTbl string_table ft h (f_str:ls) >> - -- _trace ("new(b): " ++ show f_str) $ - return f_str - Just v -> - -- _trace ("re-use(b): "++show v) $ - return v - ) - where - bucket_match [] _ _ _ = Nothing - bucket_match (v:ls) start# len# ba# = - case v of - FastString _ l# barr# -> - if len# ==# l# && eqStrPrefixBA barr# ba# start# len# then - Just v - else - bucket_match ls start# len# ba# - UnicodeStr _ _ -> bucket_match ls start# len# ba# - -mkFastStringUnicode :: [Int] -> FastString -mkFastStringUnicode s = - unsafePerformIO ( - readIORef string_table >>= \ ft@(FastStringTable uid# tbl#) -> - let - h = hashUnicode s - in --- _trace ("hashed(b): "++show (I# h)) $ - lookupTbl ft h >>= \ lookup_result -> - case lookup_result of - [] -> - -- no match, add it to table by copying out the - -- the string into a [Int] - let f_str = UnicodeStr uid# s in - updTbl string_table ft h [f_str] >> - -- _trace ("new(b): " ++ show f_str) $ - return f_str - ls -> - -- non-empty `bucket', scan the list looking - -- entry with same length and compare byte by byte. - -- _trace ("non-empty bucket(b)"++show ls) $ - case bucket_match ls of - Nothing -> - let f_str = UnicodeStr uid# s in - updTbl string_table ft h (f_str:ls) >> - -- _trace ("new(b): " ++ show f_str) $ - return f_str - Just v -> - -- _trace ("re-use(b): "++show v) $ - return v - ) - where - bucket_match [] = Nothing - bucket_match (v@(UnicodeStr _ s'):ls) = - if s' == s then Just v else bucket_match ls - bucket_match (FastString _ _ _ : ls) = bucket_match ls - -mkFastStringNarrow :: String -> FastString -mkFastStringNarrow str = - case packString str of { (I# len#, BA frozen#) -> - mkFastSubStringBA# frozen# 0# len# - } - {- 0-indexed array, len# == index to one beyond end of string, - i.e., (0,1) => empty string. -} - -mkFastString :: String -> FastString -mkFastString str = if all good str - then mkFastStringNarrow str - else mkFastStringUnicode (map ord str) - where - good c = c >= '\1' && c <= '\xFF' - -mkFastStringInt :: [Int] -> FastString -mkFastStringInt str = if all good str - then mkFastStringNarrow (map chr str) - else mkFastStringUnicode str - where - good c = c >= 1 && c <= 0xFF - -mkFastSubString :: Addr# -> Int -> Int -> FastString -mkFastSubString a# (I# start#) (I# len#) = - mkFastStringLen# (a# `plusAddr#` start#) len# - -hashStr :: Addr# -> Int# -> Int# - -- use the Addr to produce a hash value between 0 & m (inclusive) -hashStr a# len# = - case len# of - 0# -> 0# - 1# -> ((ord# c0 *# 631#) +# len#) `remInt#` hASH_TBL_SIZE# - 2# -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# len#) `remInt#` hASH_TBL_SIZE# - _ -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# (ord# c2 *# 43#) +# len#) `remInt#` hASH_TBL_SIZE# - where - c0 = indexCharOffAddr# a# 0# - c1 = indexCharOffAddr# a# (len# `quotInt#` 2# -# 1#) - c2 = indexCharOffAddr# a# (len# -# 1#) -{- - c1 = indexCharOffAddr# a# 1# - c2 = indexCharOffAddr# a# 2# --} - -hashSubStrBA :: ByteArray# -> Int# -> Int# -> Int# - -- use the byte array to produce a hash value between 0 & m (inclusive) -hashSubStrBA ba# start# len# = - case len# of - 0# -> 0# - 1# -> ((ord# c0 *# 631#) +# len#) `remInt#` hASH_TBL_SIZE# - 2# -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# len#) `remInt#` hASH_TBL_SIZE# - _ -> ((ord# c0 *# 631#) +# (ord# c1 *# 217#) +# (ord# c2 *# 43#) +# len#) `remInt#` hASH_TBL_SIZE# - where - c0 = indexCharArray# ba# (start# +# 0#) - c1 = indexCharArray# ba# (start# +# (len# `quotInt#` 2# -# 1#)) - c2 = indexCharArray# ba# (start# +# (len# -# 1#)) - --- c1 = indexCharArray# ba# 1# --- c2 = indexCharArray# ba# 2# - -hashUnicode :: [Int] -> Int# - -- use the Addr to produce a hash value between 0 & m (inclusive) -hashUnicode [] = 0# -hashUnicode [I# c0] = ((c0 *# 631#) +# 1#) `remInt#` hASH_TBL_SIZE# -hashUnicode [I# c0, I# c1] = ((c0 *# 631#) +# (c1 *# 217#) +# 2#) `remInt#` hASH_TBL_SIZE# -hashUnicode s = ((c0 *# 631#) +# (c1 *# 217#) +# (c2 *# 43#) +# len#) `remInt#` hASH_TBL_SIZE# - where - I# len# = length s - I# c0 = s !! 0 - I# c1 = s !! (I# (len# `quotInt#` 2# -# 1#)) - I# c2 = s !! (I# (len# -# 1#)) - -cmpFS :: FastString -> FastString -> Ordering -cmpFS (UnicodeStr u1# s1) (UnicodeStr u2# s2) = if u1# ==# u2# then EQ - else compare s1 s2 -cmpFS (UnicodeStr _ s1) s2 = compare s1 (unpackIntFS s2) -cmpFS s1 (UnicodeStr _ s2) = compare (unpackIntFS s1) s2 -cmpFS (FastString u1# l1# b1#) (FastString u2# l2# b2#) = - if u1# ==# u2# then EQ else - let l# = if l1# <=# l2# then l1# else l2# in - unsafePerformIO ( - memcmp b1# b2# l# >>= \ (I# res) -> - return ( - if res <# 0# then LT - else if res ==# 0# then - if l1# ==# l2# then EQ - else if l1# <# l2# then LT else GT - else GT - )) - -foreign import ccall unsafe "memcmp" - memcmp :: ByteArray# -> ByteArray# -> Int# -> IO Int - --- ----------------------------------------------------------------------------- --- Outputting 'FastString's - -#if __GLASGOW_HASKELL__ >= 504 - --- this is our own version of hPutBuf for FastStrings, because in --- 5.04+ we don't have mutable byte arrays and therefore hPutBufBA. --- The closest is hPutArray in Data.Array.IO, but that does some extra --- range checks that we want to avoid here. - -foreign import ccall unsafe "__hscore_memcpy_dst_off" - memcpy_baoff_ba :: RawBuffer -> Int -> RawBuffer -> CSize -> IO (Ptr ()) - -hPutFS handle (FastString _ l# ba#) - | l# ==# 0# = return () - | otherwise - = do wantWritableHandle "hPutFS" handle $ - \ handle_@Handle__{ haFD=fd, haBuffer=ref, haIsStream=stream } -> do - - old_buf@Buffer{ bufBuf=old_raw, bufRPtr=r, bufWPtr=w, bufSize=size } - <- readIORef ref - - let count = I# l# - raw = unsafeCoerce# ba# :: MutableByteArray# RealWorld - - -- enough room in handle buffer? - if (size - w > count) - -- There's enough room in the buffer: - -- just copy the data in and update bufWPtr. - then do memcpy_baoff_ba old_raw w raw (fromIntegral count) - writeIORef ref old_buf{ bufWPtr = w + count } - return () - - -- else, we have to flush - else do flushed_buf <- flushWriteBuffer fd stream old_buf - writeIORef ref flushed_buf - let this_buf = - Buffer{ bufBuf=raw, bufState=WriteBuffer, - bufRPtr=0, bufWPtr=count, bufSize=count } - flushWriteBuffer fd stream this_buf - return () - -#else - -hPutFS :: Handle -> FastString -> IO () -hPutFS handle (FastString _ l# ba#) - | l# ==# 0# = return () - | otherwise = do mba <- stToIO $ unsafeThawByteArray (ByteArray (bot::Int) bot ba#) - hPutBufBAFull handle mba (I# l#) - where - bot = error "hPutFS.ba" - -#endif - --- ONLY here for debugging the NCG (so -ddump-stix works for string --- literals); no idea if this is really necessary. JRS, 010131 -hPutFS handle (UnicodeStr _ is) - = hPutStr handle ("(UnicodeStr " ++ show is ++ ")") - --- ----------------------------------------------------------------------------- --- LitStrings, here for convenience only. - -type LitString = Ptr () --- ToDo: make it a Ptr when we don't have to support 4.08 any more - -mkLitString# :: Addr# -> LitString -mkLitString# a# = Ptr a# rmfile ./src/Language/Hi/FastString.hs hunk ./src/Language/Hi/Parser.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} -{-# OPTIONS -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-name-shadowing #-} --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- --- Based on $fptools/ghc/compiler/iface/BinIface.hs --- --- (c) The University of Glasgow 2002 --- --- Binary interface file support. --- - --- --- This provides the "Binary" instances for the Iface type such that we --- can parse binary representations of that type. i.e. from .hi files --- --- The main problem we have is that all the stuff we don't care about, --- we just want to read in to a string. So this has to be hand-hacked --- somewhat. --- --- The "Binary" class for hs-plugins only includes a get method. We --- don't do any writing. Saves us having to properly reconstruct the --- abstract syntax, which would pull in *way* too much of GHC. --- - - - -module Language.Hi.Parser ( readIface, module Language.Hi.Syntax ) where - -import Language.Hi.Syntax -import Language.Hi.Binary -import Language.Hi.FastString - -#include "../../../config.h" - --- --------------------------------------------------------------------------- --- how to get there from here - -readIface :: FilePath -> IO Iface -readIface hi_path = getBinFileWithDict hi_path - --- --------------------------------------------------------------------- --- All the Binary instances --- --- Reading a binary interface into ParsedIface --- --- We pull the trick of only reading up to the point we need --- - -instance Binary Iface where - get bh = do - version <- get bh :: IO String - build_tag <- get bh :: IO String -- 'way' flag - -#if __GLASGOW_HASKELL__ >= 604 - pkg_name <- get bh :: IO FastString - mod_name <- get bh :: IO FastString - _is_boot <- get bh :: IO Bool -#elif CABAL == 1 && __GLASGOW_HASKELL__ == 603 - mod_name <- get bh :: IO FastString - let pkg_name = mkFastString "unknown" -#else /* <= 622 */ - mod_name <- get bh :: IO FastString - pkg_name <- get bh :: IO FastString -#endif - mod_vers <- get bh :: IO Version - orphan <- get bh :: IO Bool - deps <- get bh :: IO Dependencies - - get bh :: IO (Bin Int) -- fake a lazyGet for [Usage] - usages <- get bh :: IO [Usage] - - exports <- get bh :: IO [IfaceExport] - --- (exp_vers :: Version) <- get bh --- (fixities :: [(OccName,Fixity)]) <- get bh --- (deprecs :: [IfaceDeprec]) <- get bh - --- (decls :: [(Version,IfaceDecl)])<- get bh - --- (insts :: [IfaceInst]) <- get bh --- (rules :: [IfaceRule]) <- get bh --- (rule_vers :: Version) <- get bh - - return $ Iface { - mi_package = unpackFS pkg_name, - mi_module = unpackFS mod_name, - mi_deps = deps , - mi_usages = usages, - mi_exports = exports {-,-} - --- mi_mod_vers = mod_vers, --- mi_boot = False, -- .hi files are never .hi-boot files! --- mi_orphan = orphan, --- mi_usages = usages, --- mi_exports = exports, --- mi_exp_vers = exp_vers, --- mi_fixities = fixities, --- mi_deprecs = deprecs, --- mi_decls = decls, --- mi_insts = insts, --- mi_rules = rules, --- mi_rule_vers = rule_vers - } - ------------------------------------------------------------------------- --- --- Types from: Iface.hs, HscTypes --- - --- fake a lazyGet -instance Binary Dependencies where - get bh = do get bh :: IO (Bin Int) -- really a BinPtr Int - ms <- get bh :: IO [(FastString,Bool)] - ps <- get bh :: IO [FastString] - _ <- get bh :: IO [FastString] -- !!orphans - return Deps { dep_mods = map unpackFS $! map fst ms, - dep_pkgs = map unpackFS ps {-,-} - } - ------------------------------------------------------------------------- --- Usages ------------------------------------------------------------------------- - -instance Binary OccName where - get bh = do aa <- get bh :: IO NameSpace - ab <- get bh :: IO FastString - return $ OccName aa (unpackFS ab) - -instance Binary NameSpace where - get bh = do h <- getByte bh - case h of - 0 -> return VarName - 1 -> return DataName - 2 -> return TvName - _ -> return TcClsName - -instance Binary Usage where - get bh = do (nm :: FastString) <- get bh - (mod :: Version) <- get bh - (exps :: Maybe Version) <- get bh - (ents :: [(OccName,Version)]) <- get bh - (rules :: Version) <- get bh - return $ Usage {usg_name = (unpackFS nm), - usg_mod = mod, - usg_exports = exps, - usg_entities = ents, - usg_rules = rules } - ------------------------------------------------------------------------- --- Exports - -instance (Binary name) => Binary (GenAvailInfo name) where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: name) <- get bh - return $ Avail aa - _ -> do (ab :: name) <- get bh - (ac :: [name]) <- get bh - return $ AvailTC ab ac - -{- -instance Binary a => Binary (Deprecs a) where - get bh = do - h <- getByte bh - case h of - 0 -> return Deprecs - 1 -> do (aa :: FastString) <- get bh - return Deprecs - _ -> do (ab :: a) <- get bh - return Deprecs --} - -------------------------------------------------------------------------- --- Types from: BasicTypes -------------------------------------------------------------------------- - -{- -instance Binary Activation where - get bh = do - h <- getByte bh - case h of - 0 -> return Activation - 1 -> return Activation - 2 -> do (aa :: Int) <- get bh ; return Activation - _ -> do (ab :: Int) <- get bh ; return Activation - -instance Binary StrictnessMark where - get bh = do - h <- getByte bh - case h of - 0 -> return StrictnessMark - 1 -> return StrictnessMark - _ -> return StrictnessMark - -instance Binary Boxity where - get bh = do - h <- getByte bh - case h of - 0 -> return Boxity - _ -> return Boxity - -instance Binary TupCon where - get bh = do - (ab :: Boxity) <- get bh - (ac :: Arity) <- get bh - return TupCon - -instance Binary RecFlag where - get bh = do - h <- getByte bh - case h of - 0 -> return RecFlag - _ -> return RecFlag - -instance Binary DefMeth where - get bh = do - h <- getByte bh - case h of - 0 -> return DefMeth - 1 -> return DefMeth - _ -> return DefMeth - -instance Binary FixityDirection where - get bh = do - h <- getByte bh - case h of - 0 -> return FixityDirection - 1 -> return FixityDirection - _ -> return FixityDirection - -instance Binary Fixity where - get bh = do - (aa :: Int) <- get bh - (ab :: FixityDirection) <- get bh - return Fixity - -instance (Binary name) => Binary (IPName name) where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: name) <- get bh ; return IPName - _ -> do (ab :: name) <- get bh ; return IPName - -------------------------------------------------------------------------- --- Types from: basicTypes/NewDemand -------------------------------------------------------------------------- - -instance Binary DmdType where - -- Ignore DmdEnv when spitting out the DmdType - get bh = do (ds :: [Demand]) <- get bh - (dr :: DmdResult) <- get bh - return DmdType - -instance Binary Demand where - get bh = do - h <- getByte bh - case h of - 0 -> return Demand - 1 -> return Demand - 2 -> do (aa :: Demand) <- get bh ; return Demand - 3 -> do (ab :: Demands) <- get bh ; return Demand - 4 -> do (ac :: Demands) <- get bh ; return Demand - 5 -> do (ad :: Demand) <- get bh ; return Demand - _ -> return Demand - -instance Binary Demands where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: Demand) <- get bh - return Demands - _ -> do (ab :: [Demand]) <- get bh - return Demands - -instance Binary DmdResult where - get bh = do - h <- getByte bh - case h of - 0 -> return DmdResult - 1 -> return DmdResult - _ -> return DmdResult - -instance Binary StrictSig where - get bh = do (aa :: DmdType) <- get bh ; return StrictSig --} - -------------------------------------------------------------------------- --- Types from: CostCentre, from profiling/CostCentre.lhs -------------------------------------------------------------------------- - -{- -instance Binary IsCafCC where - get bh = do - h <- getByte bh - case h of - 0 -> return IsCafCC - _ -> return IsCafCC - -instance Binary IsDupdCC where - get bh = do - h <- getByte bh - case h of - 0 -> return IsDupdCC - _ -> return IsDupdCC - -instance Binary CostCentre where - get bh = do - h <- getByte bh - case h of - 0 -> do return CostCentre - 1 -> do (aa :: CcName) <- get bh - (ab :: ModuleName) <- get bh - (ac :: IsDupdCC) <- get bh - (ad :: IsCafCC) <- get bh - return CostCentre - _ -> do (ae :: ModuleName) <- get bh - return CostCentre --} - -------------------------------------------------------------------------- --- IfaceTypes and friends, from IfaceType.lhs -------------------------------------------------------------------------- - -{- -instance Binary IfaceExtName where - get bh = do - h <- getByte bh - case h of - 0 -> do (mod :: ModuleName) <- get bh - (occ :: OccName) <- get bh - return IfaceExtName - 1 -> do (mod :: ModuleName) <- get bh - (occ :: OccName) <- get bh - (vers :: Version) <- get bh - return IfaceExtName - _ -> do (occ :: OccName) <- get bh - return IfaceExtName - -instance Binary IfaceBndr where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: IfaceIdBndr) <- get bh ; return IfaceBndr - _ -> do (ab :: IfaceTvBndr) <- get bh ; return IfaceBndr - -instance Binary Kind where - get bh = do - h <- getByte bh - case h of - 0 -> return Kind - 1 -> return Kind - 2 -> return Kind - 3 -> return Kind - 4 -> return Kind - _ -> do (k1 :: Kind) <- get bh - (k2 :: Kind) <- get bh - return Kind - -instance Binary IfaceType where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: IfaceTvBndr) <- get bh - (ab :: IfaceType) <- get bh - return IfaceType - 1 -> do (ad :: OccName) <- get bh - return IfaceType - 2 -> do (ae :: IfaceType) <- get bh - (af :: IfaceType) <- get bh - return IfaceType - 3 -> do (ag :: IfaceType) <- get bh - (ah :: IfaceType) <- get bh - return IfaceType - 5 -> do (ap :: IfacePredType) <- get bh - return IfaceType - - -- Now the special cases for TyConApp - 6 -> return IfaceType - 7 -> return IfaceType - 8 -> return IfaceType - 9 -> do (ty :: IfaceType) <- get bh - return IfaceType - 10 -> return IfaceType - 11 -> do (t1 :: IfaceType) <- get bh - (t2 :: IfaceType) <- get bh - return IfaceType - 12 -> do (tc :: IfaceExtName) <- get bh - (tys :: [IfaceType]) <- get bh - return IfaceType - _ -> do (tc :: IfaceTyCon) <- get bh - (tys :: [IfaceType]) <- get bh - return IfaceType - -instance Binary IfaceTyCon where - get bh = do - h <- getByte bh - case h of - 1 -> return IfaceTyCon - 2 -> return IfaceTyCon - _ -> do (bx :: Boxity) <- get bh - (ar :: Arity) <- get bh - return IfaceTyCon - -instance Binary IfacePredType where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: IfaceExtName) <- get bh - (ab :: [IfaceType]) <- get bh - return IfacePredType - _ -> do (ac :: (IPName OccName)) <- get bh - (ad :: IfaceType) <- get bh - return IfacePredType - -instance Binary IfaceExpr where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: OccName) <- get bh - return IfaceExpr - 1 -> do (ab :: IfaceType) <- get bh - return IfaceExpr - 2 -> do (ac :: Boxity) <- get bh - (ad :: [IfaceExpr]) <- get bh - return IfaceExpr - 3 -> do (ae :: IfaceBndr) <- get bh - (af :: IfaceExpr) <- get bh - return IfaceExpr - 4 -> do (ag :: IfaceExpr) <- get bh - (ah :: IfaceExpr) <- get bh - return IfaceExpr - 5 -> do (ai :: IfaceExpr) <- get bh - (aj :: OccName) <- get bh - (ak :: [IfaceAlt]) <- get bh - return IfaceExpr - 6 -> do (al :: IfaceBinding) <- get bh - (am :: IfaceExpr) <- get bh - return IfaceExpr - 7 -> do (an :: IfaceNote) <- get bh - (ao :: IfaceExpr) <- get bh - return IfaceExpr - 8 -> do (ap :: Literal) <- get bh - return IfaceExpr - 9 -> do (as :: ForeignCall) <- get bh - (at :: IfaceType) <- get bh - return IfaceExpr - _ -> do (aa :: IfaceExtName) <- get bh - return IfaceExpr - -instance Binary IfaceConAlt where - get bh = do - h <- getByte bh - case h of - 0 -> return IfaceConAlt - 1 -> do (aa :: OccName) <- get bh - return IfaceConAlt - 2 -> do (ab :: Boxity) <- get bh - return IfaceConAlt - _ -> do (ac :: Literal) <- get bh - return IfaceConAlt - -instance Binary IfaceBinding where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: IfaceIdBndr) <- get bh - (ab :: IfaceExpr) <- get bh - return IfaceBinding - _ -> do (ac :: [(IfaceIdBndr,IfaceExpr)]) <- get bh - return IfaceBinding - -instance Binary IfaceIdInfo where - get bh = do - h <- getByte bh - case h of - 0 -> return IfaceIdInfo - _ -> do (info :: [IfaceInfoItem]) <- lazyGet bh - return IfaceIdInfo - -instance Binary IfaceInfoItem where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: Arity) <- get bh - return IfaceInfoItem - 1 -> do (ab :: StrictSig) <- get bh - return IfaceInfoItem - 2 -> do (ac :: Activation) <- get bh - (ad :: IfaceExpr) <- get bh - return IfaceInfoItem - 3 -> return IfaceInfoItem - _ -> do (ae :: IfaceExtName) <- get bh - (af :: Arity) <- get bh - return IfaceInfoItem - -instance Binary IfaceNote where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: CostCentre) <- get bh - return IfaceNote - 1 -> do (ab :: IfaceType ) <- get bh - return IfaceNote - 2 -> return IfaceNote - 3 -> return IfaceNote - _ -> do (ac :: String) <- get bh - return IfaceNote - -instance Binary IfaceDecl where - get bh = do - h <- getByte bh - case h of - 0 -> do - (name :: OccName) <- get bh - (ty :: IfaceType) <- get bh - (idinfo :: IfaceIdInfo) <- get bh - return IfaceDecl - 1 -> error "Binary.get(TyClDecl): ForeignType" - 2 -> do - (a1 :: IfaceContext) <- get bh - (a2 :: OccName) <- get bh - (a3 :: [IfaceTvBndr]) <- get bh - (a4 :: IfaceConDecls) <- get bh - (a5 :: RecFlag) <- get bh - (a6 :: ArgVrcs) <- get bh - (a7 :: Bool) <- get bh - return IfaceDecl - 3 -> do - (aq :: OccName) <- get bh - (ar :: [IfaceTvBndr]) <- get bh - (as :: ArgVrcs) <- get bh - (at :: IfaceType) <- get bh - return IfaceDecl - _ -> do - (a1 :: IfaceContext) <- get bh - (a2 :: OccName) <- get bh - (a3 :: [IfaceTvBndr]) <- get bh - (a4 :: [FunDep OccName])<- get bh - (a5 :: [IfaceClassOp]) <- get bh - (a6 :: RecFlag) <- get bh - (a7 :: ArgVrcs) <- get bh - return IfaceDecl - -instance Binary IfaceInst where - get bh = do - (ty :: IfaceType) <- get bh - (dfun :: OccName) <- get bh - return IfaceInst - -instance Binary IfaceConDecls where - get bh = do - h <- getByte bh - case h of - 0 -> return IfaceConDecls - 1 -> do (aa :: [IfaceConDecl]) <- get bh - return IfaceConDecls - _ -> do (aa :: IfaceConDecl) <- get bh - return IfaceConDecls - -instance Binary IfaceConDecl where - get bh = do - (a1 :: OccName) <- get bh - (a2 :: [IfaceTvBndr]) <- get bh - (a3 :: IfaceContext) <- get bh - (a4 :: [IfaceType]) <- get bh - (a5 :: [StrictnessMark])<- get bh - (a6 :: [OccName]) <- get bh - return IfaceConDecl - -instance Binary IfaceClassOp where - get bh = do - (n :: OccName) <- get bh - (def :: DefMeth) <- get bh - (ty :: IfaceType) <- get bh - return IfaceClassOp - -instance Binary IfaceRule where - get bh = do - (a1 :: RuleName) <- get bh - (a2 :: Activation) <- get bh - (a3 :: [IfaceBndr]) <- get bh - (a4 :: IfaceExtName) <- get bh - (a5 :: [IfaceExpr]) <- get bh - (a6 :: IfaceExpr) <- get bh - return IfaceRule - --} - ------------------------------------------------------------------------- --- from Literal ------------------------------------------------------------------------- - -{- -instance Binary Literal where - get bh = do - h <- getByte bh - case h of - 0 -> do - (aa :: Char) <- get bh - return Literal - 1 -> do - (ab :: FastString) <- get bh - return Literal - 2 -> do return Literal - 3 -> do - (ad :: Integer) <- get bh - return Literal - 4 -> do - (ae :: Integer) <- get bh - return Literal - 5 -> do - (af :: Integer) <- get bh - return Literal - 6 -> do - (ag :: Integer) <- get bh - return Literal - 7 -> do - (ah :: Rational) <- get bh - return Literal - 8 -> do - (ai :: Rational) <- get bh - return Literal - 9 -> do - (aj :: FastString) <- get bh - (mb :: Maybe Int) <- get bh - return Literal - _ -> return Literal -- ? - --} - ------------------------------------------------------------------------- --- prelude/ForeignCall.lhs ------------------------------------------------------------------------- - -{- -instance Binary ForeignCall where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: CCallSpec) <- get bh - return ForeignCall - _ -> do (ab :: DNCallSpec) <- get bh - return ForeignCall - -instance Binary Safety where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: Bool) <- get bh - return Safety - _ -> return Safety - -instance Binary CExportSpec where - get bh = do - (aa :: CLabelString) <- get bh - (ab :: CCallConv) <- get bh - return CExportSpec - -instance Binary CCallSpec where - get bh = do - (aa :: CCallTarget) <- get bh - (ab :: CCallConv) <- get bh - (ac :: Safety) <- get bh - return CCallSpec - -instance Binary CCallTarget where - get bh = do - h <- getByte bh - case h of - 0 -> do (aa :: CLabelString) <- get bh - return CCallTarget - _ -> return CCallTarget - -instance Binary CCallConv where - get bh = do - h <- getByte bh - case h of - 0 -> return CCallConv - _ -> return CCallConv - -instance Binary DNCallSpec where - get bh = do - (isStatic :: Bool) <- get bh - (kind :: DNKind) <- get bh - (ass :: String) <- get bh - (nm :: String) <- get bh - return DNCallSpec - -instance Binary DNKind where - get bh = do - h <- getByte bh - case h of - _ -> return DNKind - -instance Binary DNType where - get bh = do - h <- getByte bh - case h of - _ -> return DNType - --} rmfile ./src/Language/Hi/Parser.hs hunk ./src/Language/Hi/PrimPacked.hs 1 -{-# OPTIONS -cpp -fglasgow-exts #-} -{-# OPTIONS -fno-warn-name-shadowing -fno-warn-unused-matches #-} - -{-# OPTIONS -#include "hschooks.h" #-} - --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- --- Based on $fptools/ghc/compiler/utils/PrimPacked.lhs --- --- (c) The GRASP/AQUA Project, Glasgow University, 1997-1998 --- --- --- Basic ops on packed representations --- --- Some basic operations for working on packed representations of series --- of bytes (character strings). Used by the interface lexer input --- subsystem, mostly. - -{-# OPTIONS -optc-DNON_POSIX_SOURCE #-} - -module Language.Hi.PrimPacked ( - Ptr(..), nullPtr, plusAddr#, - BA(..), - packString, -- :: String -> (Int, BA) - unpackNBytesBA, -- :: BA -> Int -> [Char] - strLength, -- :: Ptr CChar -> Int - copyPrefixStr, -- :: Addr# -> Int -> BA - copySubStrBA, -- :: BA -> Int -> Int -> BA - eqStrPrefix, -- :: Addr# -> ByteArray# -> Int# -> Bool - eqStrPrefixBA, -- :: ByteArray# -> ByteArray# -> Int# -> Int# -> Bool - ) where - -import Foreign -import GHC.Exts -import GHC.ST - --- Wrapper types for bytearrays - -data BA = BA ByteArray# -data MBA s = MBA (MutableByteArray# s) - -packString :: String -> (Int, BA) -packString str = (l, arr) - where - l@(I# length#) = length str - - arr = runST (do - ch_array <- new_ps_array length# - -- fill in packed string from "str" - fill_in ch_array 0# str - -- freeze the puppy: - freeze_ps_array ch_array length# - ) - - fill_in :: MBA s -> Int# -> [Char] -> ST s () - fill_in arr_in# idx [] = - return () - fill_in arr_in# idx (C# c : cs) = - write_ps_array arr_in# idx c >> - fill_in arr_in# (idx +# 1#) cs - --- Unpacking a string - -unpackNBytesBA :: BA -> Int -> [Char] -unpackNBytesBA (BA bytes) (I# len) - = unpack 0# - where - unpack nh - | nh >=# len = [] - | otherwise = C# ch : unpack (nh +# 1#) - where - ch = indexCharArray# bytes nh - --- Copying a char string prefix into a byte array. - -copyPrefixStr :: Addr# -> Int -> BA -copyPrefixStr a# len@(I# length#) = copy' length# - where - copy' length# = runST (do - {- allocate an array that will hold the string - -} - ch_array <- new_ps_array length# - {- Revert back to Haskell-only solution for the moment. - _ccall_ memcpy ch_array (A# a) len >>= \ () -> - write_ps_array ch_array length# (chr# 0#) >> - -} - -- fill in packed string from "addr" - fill_in ch_array 0# - -- freeze the puppy: - freeze_ps_array ch_array length# - ) - - fill_in :: MBA s -> Int# -> ST s () - fill_in arr_in# idx - | idx ==# length# - = return () - | otherwise - = case (indexCharOffAddr# a# idx) of { ch -> - write_ps_array arr_in# idx ch >> - fill_in arr_in# (idx +# 1#) } - --- Copying out a substring, assume a 0-indexed string: --- (and positive lengths, thank you). - -copySubStrBA :: BA -> Int -> Int -> BA -copySubStrBA (BA barr#) (I# start#) len@(I# length#) = ba - where - ba = runST (do - -- allocate an array that will hold the string - ch_array <- new_ps_array length# - -- fill in packed string from "addr" - fill_in ch_array 0# - -- freeze the puppy: - freeze_ps_array ch_array length# - ) - - fill_in :: MBA s -> Int# -> ST s () - fill_in arr_in# idx - | idx ==# length# - = return () - | otherwise - = case (indexCharArray# barr# (start# +# idx)) of { ch -> - write_ps_array arr_in# idx ch >> - fill_in arr_in# (idx +# 1#) } - --- (Very :-) ``Specialised'' versions of some CharArray things... --- [Copied from PackBase; no real reason -- UGH] - -new_ps_array :: Int# -> ST s (MBA s) -write_ps_array :: MBA s -> Int# -> Char# -> ST s () -freeze_ps_array :: MBA s -> Int# -> ST s BA - -#if __GLASGOW_HASKELL__ < 411 -#define NEW_BYTE_ARRAY newCharArray# -#else -#define NEW_BYTE_ARRAY newByteArray# -#endif - -new_ps_array size = ST $ \ s -> - case (NEW_BYTE_ARRAY size s) of { (# s2#, barr# #) -> - (# s2#, MBA barr# #) } - -write_ps_array (MBA barr#) n ch = ST $ \ s# -> - case writeCharArray# barr# n ch s# of { s2# -> - (# s2#, () #) } - --- same as unsafeFreezeByteArray -freeze_ps_array (MBA arr#) len# = ST $ \ s# -> - case unsafeFreezeByteArray# arr# s# of { (# s2#, frozen# #) -> - (# s2#, BA frozen# #) } - --- Compare two equal-length strings for equality: - -eqStrPrefix :: Addr# -> ByteArray# -> Int# -> Bool -eqStrPrefix a# barr# len# = - unsafePerformIO $ do - x <- memcmp_ba a# barr# (I# len#) - return (x == 0) - -eqStrPrefixBA :: ByteArray# -> ByteArray# -> Int# -> Int# -> Bool -eqStrPrefixBA b1# b2# start# len# = - unsafePerformIO $ do - x <- memcmp_baoff_ba b2# (I# start#) b1# (I# len#) - return (x == 0) - ------------------------------------------------------------------------- --- in hschooks --- - -foreign import ccall unsafe "plugin_strlen" - strLength :: Ptr () -> Int - -foreign import ccall unsafe "plugin_memcmp" - memcmp_ba :: Addr# -> ByteArray# -> Int -> IO Int - -foreign import ccall unsafe "plugin_memcmp_off" - memcmp_baoff_ba :: ByteArray# -> Int -> ByteArray# -> Int -> IO Int - rmfile ./src/Language/Hi/PrimPacked.hs hunk ./src/Language/Hi/Syntax.hs 1 --- --- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- --- Based on code from $fptools/ghc/compiler/main/HscTypes.lhs --- (c) The University of Glasgow 2002 --- - -module Language.Hi.Syntax where - -import Language.Hi.FastString - -import Data.List ( intersperse ) - --- --------------------------------------------------------------------- --- An Iface, the representation of an .hi file. --- --- The abstract syntax that we don't need is blanked with a default --- type, however we must be careful in BinIface to still parse the --- correct number of bytes for each data type. This involves leaving the --- code alone, other than to add the types of the sub-constructors of --- the types we have blanked out (because they can't be inferred --- anymore). --- - -data Iface = Iface { - mi_package :: String, -- what package is this? - mi_module :: String, -- what module is this? - mi_deps :: Dependencies, - mi_usages :: [Usage], - mi_exports :: [IfaceExport] {-,-} - --- mi_decls :: [(Version,IfaceDecl)] {-,-} - --- mi_mod_vers :: !Version, --- mi_orphan :: !Bool, --- mi_boot :: !Bool, --- mi_exp_vers :: !Version, --- mi_fixities :: [(OccName,Fixity)], --- mi_deprecs :: [IfaceDeprec], --- mi_insts :: [IfaceInst], --- mi_rules :: [IfaceRule], --- mi_rule_vers :: !Version, - } - -emptyIface = Iface { - mi_package = undefined, - mi_module = undefined, - mi_deps = noDependencies, - mi_usages = undefined, - mi_exports = undefined - } - --- --------------------------------------------------------------------- --- pretty-print an interface --- -showIface :: Iface -> String -showIface (Iface { mi_package = p, mi_module = m, - mi_deps = deps, mi_usages = us }) = - "interface \"" ++ p ++ "\" " ++ m ++ - "\n" ++ pprDeps deps ++ - "\n" ++ (concat $ intersperse "\n" (map pprUsage us)) - -- "\n" ++ (concat $ intersperse "\n" (map pprExport es)) - -pprDeps :: Dependencies -> String -pprDeps (Deps { dep_mods = mods, dep_pkgs = pkgs }) - = "module dependencies: " ++ (concat $ intersperse ", " mods) ++ - "\npackage dependencies: " ++ (concat $ intersperse ", " pkgs) - -pprUsage :: Usage -> String -pprUsage usage = hsep ["import", usg_name usage] - -pprExport :: IfaceExport -> String -pprExport (fsmod, items) - = hsep [ "export", unpackFS fsmod, hsep (map pp_avail items) ] - where - pp_avail :: GenAvailInfo OccName -> String - pp_avail (Avail nm) = ppr_occ nm - pp_avail (AvailTC _ []) = empty - pp_avail (AvailTC n (n':ns)) - | n==n' = (ppr_occ n) ++ pp_export ns - | otherwise = (ppr_occ n) ++ "|" ++ pp_export (n':ns) - - pp_export [] = empty - pp_export names = "{" ++ (hsep (map ppr_occ names)) ++ "}" - - ppr_occ (OccName _ s) = s - --- --- TODO bring in the Pretty library --- -hsep = \ss -> concat (intersperse " " ss) -empty = "" - --- --------------------------------------------------------------------- --- --- Dependency info about modules and packages below this one --- in the import hierarchy. See TcRnTypes.ImportAvails for details. --- --- Invariant: the dependencies of a module M never includes M --- Invariant: the lists are unordered, with no duplicates --- --- The fields are: --- Home-package module dependencies --- External package dependencies --- Orphan modules (whether home or external pkg) - -data Dependencies = Deps { - dep_mods :: [ModuleName], - dep_pkgs :: [PackageName] {-,-} - } deriving (Show) - -noDependencies :: Dependencies -noDependencies = Deps [] [] - --- --- Type aliases need to have a real type so the parser can work out how --- to parse them. You have to find what these are by reading GHC. --- -type ModuleName = String {- was FastString -} -- Module -type PackageName = String {- was FastString -} -- Packages -type Version = Int -- BasicTypes -type EncodedFS = FastString -- FastString -type IfaceExport = (EncodedFS, [GenAvailInfo OccName]) -- HscTypes - -data GenAvailInfo name - = Avail name -- An ordinary identifier - | AvailTC name -- The name of the type or class - [name] -- The available pieces of type/class. - -- NB: If the type or class is itself - -- to be in scope, it must be in this list. - -- Thus, typically: AvailTC Eq [Eq, ==, /=] - deriving Show - -data OccName = OccName NameSpace String {- was EncodedFS -} - deriving Show - -instance Eq OccName where - (OccName sp1 s1) == (OccName sp2 s2) = s1 == s2 && sp1 == sp2 - -data NameSpace = VarName -- variables, and "source" data constructors - | DataName -- "real" data constructors - | TvName -- tyvars - | TcClsName -- type constructors and classes - deriving (Eq, Show) - -data Usage - = Usage { usg_name :: ModuleName, -- Name of the module - usg_mod :: Version, -- Module version - usg_exports :: Maybe Version, -- Export-list version, if we depend on it - usg_entities :: [(OccName,Version)],-- Sorted by occurrence name - usg_rules :: Version -- Orphan-rules version (for non-orphan - -- modules this will always be initialVersion) - } deriving Show - ------------------------------------------------------------------------- --- TODO parsing type and decl information out of the .hi file --- complex data structure... --- - -{- -data IfaceExtName - = ExtPkg ModuleName OccName -- From an external package; no version # - -- Also used for wired-in things regardless - -- of whether they are home-pkg or not - - | HomePkg ModuleName OccName Version -- From another module in home package; - -- has version # - - | LocalTop OccName -- Top-level from the same module as - -- the enclosing IfaceDecl - - | LocalTopSub -- Same as LocalTop, but for a class method or constr - OccName -- Class-meth/constr name - OccName -- Parent class/datatype name - -- LocalTopSub is written into iface files as LocalTop; the parent - -- info is only used when computing version information in MkIface - -data IfaceTyCon -- Abbreviations for common tycons with known names - = IfaceTc IfaceExtName -- The common case - | IfaceIntTc | IfaceBoolTc | IfaceCharTc - | IfaceListTc | IfacePArrTc - | IfaceTupTc Boxity Arity - -type Arity = Int -- BasicTypes - -data Boxity - = Boxed - | Unboxed - -type IfaceContext = [IfacePredType] - -data IfacePredType -- NewTypes are handled as ordinary TyConApps - = IfaceClassP IfaceExtName [IfaceType] - | IfaceIParam (IPName OccName) IfaceType - -data IPName name - = Dupable name -- ?x: you can freely duplicate this implicit parameter - | Linear name -- %x: you must use the splitting function to duplicate it - deriving( Eq, Ord ) -- Ord is used in the IP name cache finite map - -- (used in HscTypes.OrigIParamCache) - -data IfaceType - = IfaceTyVar OccName -- Type variable only, not tycon - | IfaceAppTy IfaceType IfaceType - | IfaceForAllTy IfaceTvBndr IfaceType - | IfacePredTy IfacePredType - | IfaceTyConApp IfaceTyCon [IfaceType] -- Not necessarily saturated - -- Includes newtypes, synonyms, tuples - | IfaceFunTy IfaceType IfaceType - -data IfaceBndr -- Local (non-top-level) binders - = IfaceIdBndr IfaceIdBndr - | IfaceTvBndr IfaceTvBndr - -type IfaceIdBndr = (OccName, IfaceType) -- OccName, because always local -type IfaceTvBndr = (OccName, IfaceKind) -type IfaceKind = Kind -- Re-use the Kind type, but no KindVars in it - -data IfaceIdInfo - = NoInfo -- When writing interface file without -O - | HasInfo [IfaceInfoItem] -- Has info, and here it is - -data IfaceInfoItem - = HsArity Arity - | HsStrictness StrictSig - | HsUnfold Activation IfaceExpr - | HsNoCafRefs - | HsWorker IfaceExtName Arity -- Worker, if any see IdInfo.WorkerInfo - -- for why we want arity here. - -- NB: we need IfaceExtName (not just OccName) because the worker - -- can simplify to a function in another module. --- NB: Specialisations and rules come in separately and are --- only later attached to the Id. Partial reason: some are orphans. - -newtype StrictSig = StrictSig DmdType - -data IfaceDecl - = IfaceId { ifName :: OccName, - ifType :: IfaceType, - ifIdInfo :: IfaceIdInfo } - - | IfaceData { ifCtxt :: IfaceContext, -- Context - ifName :: OccName, -- Type constructor - ifTyVars :: [IfaceTvBndr], -- Type variables - ifCons :: IfaceConDecls, -- Includes new/data info - ifRec :: RecFlag, -- Recursive or not? - ifVrcs :: ArgVrcs, - ifGeneric :: Bool -- True <=> generic converter functions available - } -- We need this for imported data decls, since the - -- imported modules may have been compiled with - -- different flags to the current compilation unit - - | IfaceSyn { ifName :: OccName, -- Type constructor - ifTyVars :: [IfaceTvBndr], -- Type variables - ifVrcs :: ArgVrcs, - ifSynRhs :: IfaceType -- synonym expansion - } - - | IfaceClass { ifCtxt :: IfaceContext, -- Context... - ifName :: OccName, -- Name of the class - ifTyVars :: [IfaceTvBndr], -- Type variables - ifFDs :: [FunDep OccName], -- Functional dependencies - ifSigs :: [IfaceClassOp], -- Method signatures - ifRec :: RecFlag, -- Is newtype/datatype associated with the class recursive? - ifVrcs :: ArgVrcs -- ... and what are its argument variances ... - } - - | IfaceForeign { ifName :: OccName, -- Needs expanding when we move beyond .NET - ifExtName :: Maybe FastString } --} - ------------------------------------------------------------------------- --- --- all this stuff may be enabled if we ever want other information out --- - -{- -type ArgVrcs = [(Bool,Bool)] -- TyCon -type CLabelString = FastString -- CStrings -type CcName = EncodedFS -- CostCentre -type DeprecTxt = FastString -- BasicTypes -type FunDep a = ([a],[a]) -- Class -type IfaceAlt = (IfaceConAlt,[OccName],IfaceExpr) -- IfaceSyn -type IfaceContext = [IfacePredType] -- IfaceType -type IfaceDeprec = Deprecs [(OccName,DeprecTxt)] -- HscTypes -type IfaceIdBndr = (OccName, IfaceType) -- IfaceType -type IfaceKind = Kind -- IfaceType -type IfaceTvBndr = (OccName, IfaceKind) -- IfaceType -type RuleName = FastString -- CoreSyn - --- --- Empty definitions for the various types we need, but whose results we --- don't care about. --- --- 'data' types that have a parsing method associated with them --- This list corresponds to each instance in BinIface --- --- Try to keep this list ordered by the order they appear in BinIface --- -data Deprecs a = Deprecs -data Activation = Activation -data StrictnessMark = StrictnessMark -data Boxity = Boxity -data TupCon = TupCon -data RecFlag = RecFlag -data DefMeth = DefMeth -data FixityDirection = FixityDirection -data Fixity = Fixity -data DmdType = DmdType -data Demand = Demand -data Demands = Demands -data DmdResult = DmdResult -data StrictSig = StrictSig -data IsCafCC = IsCafCC -data IsDupdCC = IsDupdCC -data CostCentre = CostCentre -data IfaceExtName = IfaceExtName -data IfaceBndr = IfaceBndr -data Kind = Kind -data IfaceTyCon = IfaceTyCon -data IfacePredType = IfacePredType -data IfaceExpr = IfaceExpr -data IfaceConAlt = IfaceConAlt -data IfaceBinding = IfaceBinding -data IfaceIdInfo = IfaceIdInfo -data IfaceNoteItem = IfaceNoteItem -data IfaceInfoItem = IfaceInfoItem -data IfaceNote = IfaceNote -data IfaceInst = IfaceInst -data IfaceConDecls = IfaceConDecls -data IfaceConDecl = IfaceConDecl -data IfaceClassOp = IfaceClassOp -data IfaceRule = IfaceRule -data Literal = Literal -data ForeignCall = ForeignCall -data Safety = Safety -data CExportSpec = CExportSpec -data CCallSpec = CCallSpec -data CCallTarget = CCallTarget -data CCallConv = CCallConv -data DNCallSpec = DNCallSpec -data DNKind = DNKind -data DNType = DNType - --} rmfile ./src/Language/Hi/Syntax.hs hunk ./src/Language/Hi/hschooks.c 1 -/* -These routines customise the error messages -for various bits of the RTS. They are linked -in instead of the defaults. -*/ - -#include - -/* For GHC 4.08, we are relying on the fact that RtsFlags has - * compatibile layout with the current version, because we're - * #including the current version of RtsFlags.h below. 4.08 didn't - * ship with its own RtsFlags.h, unfortunately. For later GHC - * versions, we #include the correct RtsFlags.h. - */ - -#include "Rts.h" -#include "RtsFlags.h" - -#include "HsFFI.h" - -HsInt -plugin_strlen( HsAddr a ) -{ - return (strlen((char *)a)); -} - -HsInt -plugin_memcmp( HsAddr a1, HsAddr a2, HsInt len ) -{ - return (memcmp((char *)a1, a2, len)); -} - -HsInt -plugin_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len ) -{ - return (memcmp((char *)a1 + i, a2, len)); -} - rmfile ./src/Language/Hi/hschooks.c hunk ./src/Language/Hi/hschooks.h 1 -/* ----------------------------------------------------------------------------- - * $ Id: hschooks.h,v 1.1.1.1 2004/05/24 09:35:39 dons Exp $ - * - * Hooks into the RTS from the compiler. - * - * -------------------------------------------------------------------------- */ - -#include "HsFFI.h" - -// Out-of-line string functions, see PrimPacked.lhs -HsInt plugin_strlen( HsAddr a ); -HsInt plugin_memcmp( HsAddr a1, HsAddr a2, HsInt len ); -HsInt plugin_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len ); rmfile ./src/Language/Hi/hschooks.h rmdir ./src/Language/Hi rmdir ./src/Language hunk ./src/System/Plugins/Load.hs 69 -import Language.Hi.Parser +-- import Language.Hi.Parser +import BinIface +import HscTypes +import Module (moduleName, moduleNameString) +import PackageConfig (packageIdString) +import HscMain (newHscEnv) +import PrelInfo ( wiredInThings, basicKnownKeyNames ) +import Name ( Name, NamedThing(..) ) +import TcRnMonad (initTcRnIf) hunk ./src/System/Plugins/Load.hs 96 +ifaceModuleName = moduleNameString . moduleName . mi_module + +readBinIface' :: FilePath -> IO ModIface +readBinIface' hi_path = do + -- kludgy as hell + e <- newHscEnv undefined + initTcRnIf 'r' e undefined undefined (readBinIface hi_path) + +knownKeyNames :: [Name] -- Put here to avoid loops involving DsMeta, + -- where templateHaskellNames are defined +knownKeyNames = map getName wiredInThings + ++ basicKnownKeyNames + + hunk ./src/System/Plugins/Load.hs 163 - putStr (' ':(decode $ mi_module hif)) >> hFlush stdout + putStr (' ':(decode $ ifaceModuleName hif)) >> hFlush stdout hunk ./src/System/Plugins/Load.hs 166 - m' <- loadObject obj (Object (mi_module hif)) + m' <- loadObject obj . Object . ifaceModuleName $ hif hunk ./src/System/Plugins/Load.hs 391 - m_ <- loadObject p (Object $ mi_module hi) -- load object at path p + m_ <- loadObject p . Object . ifaceModuleName $ hi -- load object at path p hunk ./src/System/Plugins/Load.hs 433 - = loadFunction_ (mi_module i) valsym + = loadFunction_ (ifaceModuleName i) valsym hunk ./src/System/Plugins/Load.hs 512 - where emptyMod q = Module q (mkModid q) Vanilla emptyIface ky + where emptyMod q = Module q (mkModid q) Vanilla undefined ky hunk ./src/System/Plugins/Load.hs 524 - else do hiface <- readIface hifile - loadObject obj (Object (mi_module hiface)) + else do hiface <- readBinIface' hifile + loadObject obj (Object (ifaceModuleName hiface)) hunk ./src/System/Plugins/Load.hs 567 - then return (Module str (mkModid str) Shared emptyIface (Package (mkModid str))) + then return (Module str (mkModid str) Shared undefined (Package (mkModid str))) hunk ./src/System/Plugins/Load.hs 652 -loadDepends :: FilePath -> [FilePath] -> IO (Iface,[Module]) +loadDepends :: FilePath -> [FilePath] -> IO (ModIface,[Module]) hunk ./src/System/Plugins/Load.hs 661 - return (emptyIface,[]) -- could be considered fatal + return (undefined,[]) -- could be considered fatal hunk ./src/System/Plugins/Load.hs 663 - else do hiface <- readIface hifile + else do hiface <- readBinIface' hifile hunk ./src/System/Plugins/Load.hs 667 - ds' <- filterM loaded (dep_mods ds) + ds' <- filterM loaded . map (moduleNameString . fst) . dep_mods $ ds hunk ./src/System/Plugins/Load.hs 687 - ps' <- filterM loaded (nub ps) + ps' <- filterM loaded . map packageIdString . nub $ ps hunk ./src/System/Plugins/Load.hs 712 - hi <- readIface (m ++ hiSuf) - return $ dep_mods (mi_deps hi) + hi <- readBinIface' (m ++ hiSuf) + return . map (moduleNameString . fst) . dep_mods . mi_deps $ hi hunk ./src/System/Plugins/LoadTypes.hs 31 -import Language.Hi.Parser +-- import Language.Hi.Parser + +import HscTypes hunk ./src/System/Plugins/LoadTypes.hs 45 - , iface :: Iface -- cache the iface + , iface :: ModIface -- cache the iface hunk ./testsuite/eval/eval_/Main.hs 5 - ["Maybe"] + ["Data.Maybe"] hunk ./src/System/Plugins/Load.hs 75 -import PrelInfo ( wiredInThings, basicKnownKeyNames ) -import Name ( Name, NamedThing(..) ) hunk ./src/System/Plugins/Load.hs 102 -knownKeyNames :: [Name] -- Put here to avoid loops involving DsMeta, - -- where templateHaskellNames are defined -knownKeyNames = map getName wiredInThings - ++ basicKnownKeyNames - - hunk ./src/System/Plugins/Load.hs 455 -loadPackageFunction pkgName moduleName functionName = +loadPackageFunction pkgName modName functionName = hunk ./src/System/Plugins/Load.hs 458 - loadFunction__ (Just pkgName) moduleName functionName + loadFunction__ (Just pkgName) modName functionName hunk ./configure.ac 125 -AC_CHECK_PROG(TEX,tex,tex) -if test -z "$TEX" ; then - AC_MSG_WARN(tex is needed to build some of the documentation) -fi -AC_CHECK_PROG(TEX2PAGE,tex2page,tex2page) -if test -z "$TEX2PAGE" ; then - AC_MSG_WARN(tex2page is needed to build some of the documentation - http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html) -fi +#AC_CHECK_PROG(TEX,tex,tex) +#if test -z "$TEX" ; then +# AC_MSG_WARN(tex is needed to build some of the documentation) +#fi +#AC_CHECK_PROG(TEX2PAGE,tex2page,tex2page) +#if test -z "$TEX2PAGE" ; then +# AC_MSG_WARN(tex2page is needed to build some of the documentation +# http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html) +#fi hunk ./plugins.cabal 1 -name: plugins -version: 1.0 -license: LGPL -License-file: LICENSE -author: Don Stewart -maintainer: dons@cse.unsw.edu.au -exposed-modules: - System.Eval, - System.Eval.Haskell, - System.Eval.Utils, - System.MkTemp, - System.Plugins, - System.Plugins.Consts, - System.Plugins.Env, - System.Plugins.Load, - System.Plugins.LoadTypes, - System.Plugins.Make, - System.Plugins.Package, - System.Plugins.PackageAPI, - System.Plugins.ParsePkgConfCabal, - System.Plugins.Parser, - System.Plugins.Process, - System.Plugins.Utils -includes: Linker.h -extensions: CPP, ForeignFunctionInterface -Build-Depends: base, Cabal, haskell-src, containers, array, directory, random, process, ghc -ghc-options: -Wall -O -fasm -funbox-strict-fields -fno-warn-missing-signatures -hs-source-dirs: src +name: plugins +version: 1.1 +homepage: http://code.haskell.org/~dons/code/hs-plugins +synopsis: Dynamic linking for Haskell and C objects +description: Dynamic linking and runtime evaluation of Haskell, + and C, including dependency chasing and package resolution. + Described in the paper: + /Plugging Haskell In/, + . +category: System +license: BSD3 +License-file: LICENSE +author: Don Stewart +maintainer: Don Stewart +cabal-version: >= 1.2 + +library + exposed-modules: + System.Eval, + System.Eval.Haskell, + System.Eval.Utils, + System.MkTemp, + System.Plugins, + System.Plugins.Consts, + System.Plugins.Env, + System.Plugins.Load, + System.Plugins.LoadTypes, + System.Plugins.Make, + System.Plugins.Package, + System.Plugins.PackageAPI, + System.Plugins.ParsePkgConfCabal, + System.Plugins.Parser, + System.Plugins.Process, + System.Plugins.Utils + includes: Linker.h + extensions: CPP, ForeignFunctionInterface + ghc-options: -Wall -O -fasm -funbox-strict-fields -fno-warn-missing-signatures + hs-source-dirs: src + build-depends: base >= 3.0, + Cabal == 1.2.3.0, + haskell-src, + containers, + array, + directory, + random, + process, + ghc >= 6.8 + hunk ./configure 275 -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 build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL HASKELL_SRC TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' +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 build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL HASKELL_SRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' hunk ./configure 912 - cd "$ac_popdir" + cd $ac_popdir hunk ./configure 1385 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0` +TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` hunk ./configure 1475 - GHC_LIB_PATH=`$GHC --print-libdir` + GHC_LIB_PATH=`$GHC --print-libdir | tr -d '\r'` hunk ./configure 1515 -# Extract the first word of "tex", so it can be a program name with args. -set dummy tex; 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_TEX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$TEX"; then - ac_cv_prog_TEX="$TEX" # 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_TEX="tex" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -TEX=$ac_cv_prog_TEX -if test -n "$TEX"; then - echo "$as_me:$LINENO: result: $TEX" >&5 -echo "${ECHO_T}$TEX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$TEX" ; then - { echo "$as_me:$LINENO: WARNING: tex is needed to build some of the documentation" >&5 -echo "$as_me: WARNING: tex is needed to build some of the documentation" >&2;} -fi -# Extract the first word of "tex2page", so it can be a program name with args. -set dummy tex2page; 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_TEX2PAGE+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$TEX2PAGE"; then - ac_cv_prog_TEX2PAGE="$TEX2PAGE" # 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_TEX2PAGE="tex2page" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -TEX2PAGE=$ac_cv_prog_TEX2PAGE -if test -n "$TEX2PAGE"; then - echo "$as_me:$LINENO: result: $TEX2PAGE" >&5 -echo "${ECHO_T}$TEX2PAGE" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$TEX2PAGE" ; then - { echo "$as_me:$LINENO: WARNING: tex2page is needed to build some of the documentation - http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&5 -echo "$as_me: WARNING: tex2page is needed to build some of the documentation - http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html" >&2;} -fi +#AC_CHECK_PROG(TEX,tex,tex) +#if test -z "$TEX" ; then +# AC_MSG_WARN(tex is needed to build some of the documentation) +#fi +#AC_CHECK_PROG(TEX2PAGE,tex2page,tex2page) +#if test -z "$TEX2PAGE" ; then +# AC_MSG_WARN(tex2page is needed to build some of the documentation +# http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html) +#fi hunk ./configure 2093 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2152 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2269 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2324 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2370 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2415 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 2525 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' hunk ./configure 3264 -s,@TEX@,$TEX,;t t -s,@TEX2PAGE@,$TEX2PAGE,;t t hunk ./configure 3442 + 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 hunk ./configure 3485 - - 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 hunk ./plugins.cabal 40 - Cabal == 1.2.3.0, + Cabal >= 1.2.3, hunk ./plugins.cabal 37 - ghc-options: -Wall -O -fasm -funbox-strict-fields -fno-warn-missing-signatures + ghc-options: -Wall -funbox-strict-fields -fno-warn-missing-signatures hunk ./plugins.cabal 7 + . hunk ./plugins.cabal 10 - . hunk ./plugins.cabal 16 +build-type: Configure +extra-source-files: config.guess config.h.in config.mk.in config.sub configure + configure.ac install.sh Makefile hunk ./plugins.cabal 17 -extra-source-files: config.guess config.h.in config.mk.in config.sub configure - configure.ac install.sh Makefile +extra-source-files: config.guess, config.h.in, config.mk.in, config.sub, + configure, configure.ac, install.sh, Makefile, + testsuite/makewith/io/TestIO.conf.in, + testsuite/makewith/unsafeio/Unsafe.conf.in hunk ./plugins.cabal 2 -version: 1.1 +version: 1.2 hunk ./src/System/Plugins/Env.hs 64 -import Data.List ( isPrefixOf, nub ) +import Data.List ( isPrefixOf, isInfixOf, nub ) hunk ./src/System/Plugins/Env.hs 67 +import System.IO ( hGetContents ) hunk ./src/System/Plugins/Env.hs 69 +import System.Process ( waitForProcess, runInteractiveCommand ) hunk ./src/System/Plugins/Env.hs 72 -import System.Environment ( getEnv ) hunk ./src/System/Plugins/Env.hs 301 + hunk ./src/System/Plugins/Env.hs 303 - pkgs <- readPackageConf $ ghcLibraryPath sysPkgConf - return $ union [] pkgs + pkg_confs <- get_ghc_configs + packages <- mapM readPackageConf pkg_confs + return $ foldl union [] packages hunk ./src/System/Plugins/Env.hs 520 + +------------------------------------------------------------------------- +-- +-- 'run_cmd' executes command and returns it's standard output +-- as 'String' + +run_cmd :: String -> IO String +run_cmd cmd = do (_hI, hO, _hE, hProcess) <- runInteractiveCommand cmd + output <- hGetContents hO + _exitCode <- waitForProcess hProcess + return output +-- +-- 'get_ghc_configs' returns list of strings of packages.conf files in system + +get_ghc_configs :: IO [String] +get_ghc_configs = do ghc_out <- run_cmd "ghc-pkg list" + let configs = map (reverse.strip_trash.reverse) $ + filter (isInfixOf sysPkgConf) $ lines ghc_out + return configs + -- | strip ":\r?" from string head + where strip_trash [] = [] + strip_trash xs@(x:xs') | x `elem` ":\r" = strip_trash xs' + | otherwise = xs hunk ./src/System/Plugins/Load.hs 664 - if c == '.' then '/' else c) $ decode s)) ds' + if c == '.' then '/' else c) $ s)) ds' hunk ./src/System/Plugins/Load.hs 694 - mapM_ (\(m,_) -> putStr (" "++(decode m)) >> hFlush stdout) mods'' + mapM_ (\(m,_) -> putStr (" "++ m) >> hFlush stdout) mods'' hunk ./plugins.cabal 2 -version: 1.2 +version: 1.3 hunk ./plugins.cabal 13 -author: Don Stewart +author: Don Stewart 2004-2008 hunk ./plugins.cabal 44 - build-depends: base >= 3.0, - Cabal >= 1.2.3, + build-depends: base >= 3 && < 4, + Cabal >= 1.4, hunk ./src/System/Plugins/Env.hs 77 -import Distribution.Package +import Distribution.Package hiding (packageName) hunk ./src/System/Plugins/PackageAPI.hs 43 -import Distribution.Package +import Distribution.Package hiding (depends, packageName) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 9 -import Distribution.Package +import Distribution.Package hiding (depends) hunk ./src/System/Plugins/ParsePkgConfCabal.y_in 39 -import Distribution.Package +import Distribution.Package hiding (depends) hunk ./plugins.cabal 2 -version: 1.3 +version: 1.3.1 hunk ./plugins.cabal 45 - Cabal >= 1.4, + Cabal >= 1.4 && < 1.5, hunk ./plugins.cabal 44 - build-depends: base >= 3 && < 4, - Cabal >= 1.4 && < 1.5, + build-depends: base >= 4, + Cabal >= 1.6, hunk ./plugins.cabal 52 - ghc >= 6.8 + ghc >= 6.10, + ghc-prim hunk ./src/System/MkTemp.hs 51 -import GHC.IOBase ( IOException(IOError), - Exception(IOException), - IOErrorType(AlreadyExists) ) +import GHC.IOBase (IOException(..), IOErrorType(AlreadyExists) ) hunk ./src/System/MkTemp.hs 186 -alreadyExists :: Exception -> Maybe Exception -alreadyExists e@(IOException ioe) - | isAlreadyExistsError ioe = Just e +alreadyExists :: IOError -> Maybe IOError +alreadyExists ioe + | isAlreadyExistsError ioe = Just ioe hunk ./src/System/MkTemp.hs 190 -alreadyExists _ = Nothing hunk ./src/System/MkTemp.hs 191 -isInUse :: Exception -> Maybe () +isInUse :: IOError -> Maybe () hunk ./src/System/MkTemp.hs 193 -isInUse (IOException ioe) +isInUse ioe hunk ./src/System/MkTemp.hs 196 -isInUse _ = Nothing hunk ./src/System/MkTemp.hs 197 -isInUse (IOException ioe) +isInUse ioe hunk ./src/System/Plugins/Env.hs 55 -#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 -import System.Plugins.ParsePkgConfCabal( parsePkgConf ) -#else -import System.Plugins.ParsePkgConfLite ( parsePkgConf ) -#endif hunk ./src/System/Plugins/Env.hs 72 -import Distribution.Package hiding (packageName) -import Text.ParserCombinators.ReadP +import Distribution.InstalledPackageInfo +-- import Distribution.Package hiding (packageName, PackageName(..)) +import Distribution.Simple.Compiler +import Distribution.Simple.GHC +import Distribution.Simple.PackageIndex +import Distribution.Simple.Program +import Distribution.Text +import Distribution.Verbosity hunk ./src/System/Plugins/Env.hs 151 + hunk ./src/System/Plugins/Env.hs 290 - in foldr (\p fm' -> if packageName_ p == "base" -- ghc doesn't supply a version with 'base' - -- for some reason. - then addToFM (addToFM fm' (packageName_ p) p) (packageName p) p + in foldr (\p fm' -> if (display $ package p) == "base" -- ghc doesn't supply a version with 'base' + -- for some reason. + then addToFM (addToFM fm' (display $ package p) p) (packageName p) p hunk ./src/System/Plugins/Env.hs 314 - s <- readFile f - let p = parsePkgConf s - return $! map expand_libdir p +-- s <- readFile f +-- let p = map parseInstalledPackageInfo $ splitPkgs s +-- return $ flip map p $ \p' -> case p' of +-- ParseFailed e -> error $ show e +-- ParseOk _ c -> expand_libdir c + pc <- configureAllKnownPrograms silent defaultProgramConfiguration + pkgIndex <- getInstalledPackages silent (SpecificPackageDB f) pc + return $ allPackages pkgIndex hunk ./src/System/Plugins/Env.hs 334 + splitPkgs :: String -> [String] + splitPkgs = map unlines . splitWith ("---" ==) . lines + where + splitWith :: (a -> Bool) -> [a] -> [[a]] + splitWith p xs = ys : case zs of + [] -> [] + _:ws -> splitWith p ws + where (ys,zs) = break p xs + hunk ./src/System/Plugins/Env.hs 351 -isStaticPkg pkg - = case readP_to_S parsePackageName pkg of - ((pkgName,_):_) -> withStaticPkgEnv env $ \set -> return $ S.member pkgName set - [] -> return False +isStaticPkg pkg = withStaticPkgEnv env $ \set -> return $ S.member pkg set hunk ./src/System/Plugins/Env.hs 421 - Just package -> do - let hslibs = hsLibraries package - extras' = extraLibraries package + Just pkg -> do + let hslibs = hsLibraries pkg + extras' = extraLibraries pkg hunk ./src/System/Plugins/Env.hs 426 - ldopts = ldOptions package - deppkgs = packageDeps package + ldopts = ldOptions pkg + deppkgs = packageDeps pkg hunk ./src/System/Plugins/Env.hs 433 - libdirs = fix_topdir (libraryDirs package) ++ ldOptsPaths + libdirs = fix_topdir (libraryDirs pkg) ++ ldOptsPaths hunk ./src/System/Plugins/Env.hs 435 - libdirs = libraryDirs package ++ ldOptsPaths + libdirs = libraryDirs pkg ++ ldOptsPaths hunk ./src/System/Plugins/Env.hs 470 - filterRight :: [Either left right] -> [right] - filterRight [] = [] - filterRight (Right x:xs) = x:filterRight xs - filterRight (Left _:xs) = filterRight xs + --filterRight :: [Either left right] -> [right] + --filterRight [] = [] + --filterRight (Right x:xs) = x:filterRight xs + --filterRight (Left _:xs) = filterRight xs hunk ./src/System/Plugins/Load.hs 72 -import Module (moduleName, moduleNameString) -import PackageConfig (packageIdString) +import Module (moduleName, moduleNameString, packageIdString) hunk ./src/System/Plugins/Load.hs 99 - initTcRnIf 'r' e undefined undefined (readBinIface hi_path) + initTcRnIf 'r' e undefined undefined (readBinIface IgnoreHiWay QuietBinIFaceReading hi_path) hunk ./src/System/Plugins/Make.hs 78 -import GHC.IOBase ( Exception(IOException) ) hunk ./src/System/Plugins/Make.hs 150 - rawMake src ( "--make":"-no-hs-main":"-no-link":"-v0":args ) False + rawMake src ( "--make":"-no-hs-main":"-c":"-v0":args ) False hunk ./src/System/Plugins/Make.hs 297 - let ghc_opts = [ "-Onot" ] + let ghc_opts = [ "-O0" ] hunk ./src/System/Plugins/Make.hs 438 - doesntExist (IOException ioe) + doesntExist ioe hunk ./src/System/Plugins/Make.hs 441 - doesntExist _ = Nothing hunk ./src/System/Plugins/PackageAPI.hs 43 -import Distribution.Package hiding (depends, packageName) +import Distribution.Package hiding (depends, packageName, PackageName(..)) +import Distribution.Text hunk ./src/System/Plugins/PackageAPI.hs 61 -packageName = showPackageId . package +packageName = display . package hunk ./src/System/Plugins/PackageAPI.hs 63 -packageDeps = (map showPackageId) . depends +packageDeps = (map display) . depends hunk ./plugins.cabal 2 -version: 1.3.1 +version: 1.4.0 hunk ./plugins.cabal 15 -cabal-version: >= 1.2 +cabal-version: >= 1.6 hunk ./plugins.cabal 36 - System.Plugins.ParsePkgConfCabal, hunk ./src/System/Plugins/Env.hs 55 -import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix ) +import System.Plugins.Consts ( sysPkgConf, sysPkgSuffix ) hunk ./src/System/Plugins/Env.hs 59 -import Data.List ( isPrefixOf, isInfixOf, nub ) +import Data.List ( isInfixOf, nub ) hunk ./src/System/Plugins/Env.hs 314 --- s <- readFile f --- let p = map parseInstalledPackageInfo $ splitPkgs s --- return $ flip map p $ \p' -> case p' of --- ParseFailed e -> error $ show e --- ParseOk _ c -> expand_libdir c hunk ./src/System/Plugins/Env.hs 318 - where - expand_libdir :: PackageConfig -> PackageConfig - expand_libdir pk = - let pk' = updImportDirs (\idirs -> map expand idirs) pk - pk'' = updLibraryDirs (\ldirs -> map expand ldirs) pk' - in pk'' - - expand :: FilePath -> FilePath - expand s | "$libdir" `isPrefixOf` s = ghcLibraryPath ++ drop 7 s - expand s = s - - splitPkgs :: String -> [String] - splitPkgs = map unlines . splitWith ("---" ==) . lines - where - splitWith :: (a -> Bool) -> [a] -> [[a]] - splitWith p xs = ys : case zs of - [] -> [] - _:ws -> splitWith p ws - where (ys,zs) = break p xs - hunk ./src/System/Plugins/Process.hs 17 -import qualified Control.Exception +import qualified Control.OldException as E hunk ./src/System/Plugins/Process.hs 41 - Control.Exception.handle (\e -> return ([],show e,error (show e))) $ do + E.handle (\e -> return ([],show e, error (show e))) $ do hunk ./src/System/Plugins/Process.hs 58 - forkIO (Control.Exception.evaluate (length output) >> return ()) - forkIO (Control.Exception.evaluate (length errput) >> return ()) + forkIO (E.evaluate (length output) >> return ()) + forkIO (E.evaluate (length errput) >> return ()) hunk ./src/System/Plugins/Process.hs 82 - Control.Exception.handle (\e -> return ([], show e, error $ show e )) $ do + E.handle (\e -> return ([], show e, error $ show e )) $ do hunk ./plugins.cabal 2 -version: 1.4.0 +version: 1.4.1 hunk ./plugins.cabal 13 -author: Don Stewart 2004-2008 +author: Don Stewart 2004-2009 hunk ./plugins.cabal 39 - includes: Linker.h + hunk ./src/System/MkTemp.hs 43 +import System.FilePath ( splitFileName, () ) hunk ./src/System/MkTemp.hs 94 - (p,t) = break (== 'X') r - in (p,t,s) + (d,f) = splitFileName r + (p,t) = break (== 'X') f + in (d p,t,s) hunk ./Setup.lhs 5 -> main = defaultMainWithHooks defaultUserHooks +> main = defaultMainWithHooks autoconfUserHooks hunk ./plugins.cabal 2 -version: 1.4.1 +version: 1.5.1 hunk ./plugins.cabal 17 +Tested-with: GHC >= 6.12.1 hunk ./plugins.cabal 50 + filepath, hunk ./src/System/Eval/Haskell.hs 54 -import Data.Either +import Data.Either ( ) hunk ./src/System/Eval/Haskell.hs 58 -import System.IO +import System.IO ( ) hunk ./src/System/Eval/Haskell.hs 125 - status <- make tmpf $ ["-Onot"] ++ cmdline ++ args + status <- make tmpf $ ["-O0"] ++ cmdline ++ args hunk ./src/System/Eval/Utils.hs 74 - let make_line = ["-Onot","-fglasgow-exts","-package","plugins"] + let make_line = ["-O0","-fglasgow-exts","-package","plugins"] hunk ./src/System/MkTemp.hs 39 -import Data.List +import Data.List ( ) hunk ./src/System/MkTemp.hs 47 -import System.IO.Error ( isAlreadyExistsError ) +import System.IO.Error ( mkIOError, alreadyExistsErrorType, + isAlreadyExistsError ) hunk ./src/System/MkTemp.hs 53 -import GHC.IOBase (IOException(..), IOErrorType(AlreadyExists) ) - hunk ./src/System/MkTemp.hs 218 - err = IOError Nothing AlreadyExists "open0600" "already exists" Nothing + err = mkIOError alreadyExistsErrorType "op0600" Nothing (Just f) hunk ./src/System/Plugins/Env.hs 55 -import System.Plugins.Consts ( sysPkgConf, sysPkgSuffix ) +import System.Plugins.Consts ( sysPkgSuffix ) + +import Control.Monad ( liftM ) hunk ./src/System/Plugins/Env.hs 61 -import Data.List ( isInfixOf, nub ) +import Data.List ( nub ) hunk ./src/System/Plugins/Env.hs 64 -import System.IO ( hGetContents ) hunk ./src/System/Plugins/Env.hs 65 -import System.Process ( waitForProcess, runInteractiveCommand ) hunk ./src/System/Plugins/Env.hs 94 +addWithFM :: (Ord key) + => (elt -> elt -> elt) -> FiniteMap key elt -> key -> elt -> FiniteMap key elt +addWithFM = \comb m k e -> M.insertWith comb k e m + hunk ./src/System/Plugins/Env.hs 167 - ref4 <- newIORef (S.fromList ["base","Cabal-1.1.6","haskell-src-1.0"]) -- FIXME + ref4 <- newIORef (S.fromList ["base","Cabal","haskell-src", "containers", + "arrays", "directory", "random", "process", + "ghc", "ghc-prim"]) hunk ./src/System/Plugins/Env.hs 291 --- | add a new FM for the package.conf to the list of existing ones +-- | add a new FM for the package.conf to the list of existing ones; if a package occurs multiple +-- times, pick the one with the higher version number as the default (e.g., important for base in +-- GHC 6.12) hunk ./src/System/Plugins/Env.hs 298 - in foldr (\p fm' -> if (display $ package p) == "base" -- ghc doesn't supply a version with 'base' - -- for some reason. - then addToFM (addToFM fm' (display $ package p) p) (packageName p) p - else addToFM fm' (packageName p) p) fm ps' : ls + in foldr addOnePkg fm ps' : ls + where + -- we add each package with and without it's version number + addOnePkg p fm' = addToPkgEnvs (addToPkgEnvs fm' (display $ sourcePackageId p) p) + (packageName p) p + + -- if no version number specified, pick the higher version + addToPkgEnvs = addWithFM higherVersion hunk ./src/System/Plugins/Env.hs 307 + higherVersion pkgconf1 pkgconf2 + | installedPackageId pkgconf1 >= installedPackageId pkgconf2 = pkgconf1 + | otherwise = pkgconf2 + hunk ./src/System/Plugins/Env.hs 319 - hunk ./src/System/Plugins/Env.hs 320 - pkg_confs <- get_ghc_configs - packages <- mapM readPackageConf pkg_confs - return $ foldl union [] packages + pc <- configureAllKnownPrograms silent defaultProgramConfiguration + pkgIndex <- getInstalledPackages silent [GlobalPackageDB, UserPackageDB] pc + return $ [] `union` allPackages pkgIndex hunk ./src/System/Plugins/Env.hs 330 - pkgIndex <- getInstalledPackages silent (SpecificPackageDB f) pc + pkgIndex <- getInstalledPackages silent [GlobalPackageDB, UserPackageDB, SpecificPackageDB f] pc hunk ./src/System/Plugins/Env.hs 363 - t <- lookupPkg' p + (ps, (f, g)) <- lookupPkg' p hunk ./src/System/Plugins/Env.hs 365 - case t of ([],(f,g)) -> return (f,if static then [] else g) - (ps,(f,g)) -> do gss <- mapM lookupPkg ps - let (f',g') = unzip gss - return $ (nub $ (concat f') ++ f - ,if static then [] else nub $ (concat g') ++ g) + (f', g') <- liftM unzip $ mapM lookupPkg ps + return $ (nub $ (concat f') ++ f, if static then [] else nub $ (concat g') ++ g) hunk ./src/System/Plugins/Env.hs 521 -------------------------------------------------------------------------- --- --- 'run_cmd' executes command and returns it's standard output --- as 'String' - -run_cmd :: String -> IO String -run_cmd cmd = do (_hI, hO, _hE, hProcess) <- runInteractiveCommand cmd - output <- hGetContents hO - _exitCode <- waitForProcess hProcess - return output --- --- 'get_ghc_configs' returns list of strings of packages.conf files in system - -get_ghc_configs :: IO [String] -get_ghc_configs = do ghc_out <- run_cmd "ghc-pkg list" - let configs = map (reverse.strip_trash.reverse) $ - filter (isInfixOf sysPkgConf) $ lines ghc_out - return configs - -- | strip ":\r?" from string head - where strip_trash [] = [] - strip_trash xs@(x:xs') | x `elem` ":\r" = strip_trash xs' - | otherwise = xs hunk ./src/System/Plugins/Load.hs 84 +import GHC ( defaultCallbacks ) hunk ./src/System/Plugins/Load.hs 99 - e <- newHscEnv undefined + e <- newHscEnv defaultCallbacks undefined hunk ./src/System/Plugins/Load.hs 442 - ptr@(~(Ptr addr)) <- withCString symbol c_lookupSymbol + ptr@(Ptr addr) <- withCString symbol c_lookupSymbol hunk ./src/System/Plugins/Load.hs 710 -foreign import ccall threadsafe "lookupSymbol" +foreign import ccall safe "lookupSymbol" hunk ./src/System/Plugins/PackageAPI.hs 61 -packageName = display . package -packageName_ = pkgName . package +packageName = display . pkgName . sourcePackageId +packageName_ = pkgName . sourcePackageId hunk ./src/System/Plugins/Parser.hs 31 -import Data.Either +import Data.Either ( ) hunk ./src/System/Plugins/Process.hs 17 -import qualified Control.OldException as E +import qualified Control.Exception as E hunk ./src/System/Plugins/Process.hs 41 - E.handle (\e -> return ([],show e, error (show e))) $ do + E.handle (\e -> return ([],show (e::E.IOException), error (show e))) $ do hunk ./src/System/Plugins/Process.hs 58 - forkIO (E.evaluate (length output) >> return ()) - forkIO (E.evaluate (length errput) >> return ()) + _ <- forkIO (E.evaluate (length output) >> return ()) + _ <- forkIO (E.evaluate (length errput) >> return ()) hunk ./src/System/Plugins/Process.hs 82 - E.handle (\e -> return ([], show e, error $ show e )) $ do + E.handle (\e -> return ([], show (e::IOException), error $ show e )) $ do hunk ./testsuite/build.mk 16 -GHCFLAGS= -Onot -cpp -fglasgow-exts +GHCFLAGS= -O0 -cpp -fglasgow-exts hunk ./testsuite/dynload/io/TestIO.hs 10 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/io/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/poly/Plugin.hs 4 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/poly/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/should_fail/Plugin.hs 5 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/should_fail/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/should_fail_1/Plugin.hs 8 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/should_fail_1/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/should_fail_2/Plugin.in 12 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/should_fail_2/Plugin.stub 6 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/should_fail_2/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/should_fail_3/Plugin.in 12 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/should_fail_3/Plugin.stub 6 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/should_fail_3/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/dynload/simple/Plugin.hs 5 -import AltData.Dynamic +import Data.Dynamic hunk ./testsuite/dynload/simple/api/API.hs 5 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/eval/eval_fn1/Poly.hs 4 -import AltData.Typeable +import Data.Typeable hunk ./testsuite/hier/hier1/prog/Main.hs 12 - -rec = Flags.FlagRec { Flags.f1 = 4, Flags.f2 = 10 } +record = Flags.FlagRec { Flags.f1 = 4, Flags.f2 = 10 } hunk ./testsuite/hier/hier1/prog/Main.hs 20 - print (func rec) + print (func record) hunk ./testsuite/misc/mkstemps/Main.hs 39 - else putStrLn $ "mkstemp: created "++(show $ length $ catMaybes ts)++" files" + else putStrLn $ "mkstemp: created "++(show $ length $ catMaybes ts)++" files" hunk ./testsuite/misc/mkstemps/Main.hs 50 - else putStrLn $ "mkstemps: created "++(show $ length $ catMaybes ts)++" files" + else putStrLn $ "mkstemps: created "++(show $ length $ catMaybes ts)++" files" hunk ./testsuite/misc/mkstemps/Main.hs 58 - then putStrLn $ "mkdtemp: couldn't create all expected directories" - else putStrLn $ "mkdtemp: created "++(show $ length $ catMaybes ts)++" directories" + then putStrLn $ "mkdtemp: couldn't create all expected directories" + else putStrLn $ "mkdtemp: created "++(show $ length $ catMaybes ts)++" directories" hunk ./testsuite/misc/mkstemps/expected 3 -mkstemp: created 10000 files -mkstemps: created 2000 files -mkdtemp: created 2000 directories +mkstemp: created 10000 files +mkstemps: created 2000 files +mkdtemp: created 2000 directories hunk ./testsuite/objc/expression_parser/PluginEvalAux.hs 18 - status <- make srcFile ["-Onot"] + status <- make srcFile ["-O0"] hunk ./testsuite/pdynload/poly/Plugin.hs 3 +import Data.Typeable +import Data.Generics.Aliases hunk ./testsuite/pdynload/poly/Plugin.hs 10 - field = id listify + field = id listify :: Typeable r => (r -> Bool) -> GenericQ [r] hunk ./testsuite/plugs/runplugs/Makefile 1 -GHCFLAGS= -Onot $(GHC_EXTRA_OPTS) +GHCFLAGS= -O0 $(GHC_EXTRA_OPTS) hunk ./plugins.cabal 44 - build-depends: base >= 4, + build-depends: base >= 4 && < 5, hunk ./plugins.cabal 2 -version: 1.5.1 +version: 1.5.1.1 hunk ./plugins.cabal 13 -author: Don Stewart 2004-2009 +author: Don Stewart 2004..2010 hunk ./plugins.cabal 41 - extensions: CPP, ForeignFunctionInterface + extensions: CPP, + ForeignFunctionInterface hunk ./src/System/MkTemp.hs 1 -{-# OPTIONS -fglasgow-exts #-} --- --- glaexts for I# ops +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} hunk ./src/System/Plugins/Consts.hs 1 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/Env.hs 1 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/Load.hs 1 -{-# OPTIONS -fglasgow-exts #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE ForeignFunctionInterface #-} hunk ./src/System/Plugins/Load.hs 398 --- --------------------------------------------------------------------- --- This is a stripped-down version of André Pang's runtime_loader, +-- +-- This is a stripped-down version of Andre Pang's runtime_loader, hunk ./src/System/Plugins/Load.hs 412 ------------------------------------------------------------------------- + hunk ./src/System/Plugins/Make.hs 1 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/Make.hs 3 --- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons +-- Copyright (C) 2004..2010 Don Stewart - http://www.cse.unsw.edu.au/~dons hunk ./src/System/Plugins/PackageAPI.hs 1 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/ParsePkgConfCabal.hs 2 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/Parser.hs 1 -{-# OPTIONS -fglasgow-exts #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE PatternGuards #-} hunk ./src/System/Plugins/Process.hs 1 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/Utils.hs 1 +{-# LANGUAGE CPP #-} hunk ./src/System/Plugins/ParsePkgConfCabal.hs 1 -{-# OPTIONS -fglasgow-exts #-} -{-# LANGUAGE CPP #-} -{-# OPTIONS -w #-} - -module System.Plugins.ParsePkgConfCabal ( - parsePkgConf, parseOnePkgConf - ) where - -import Distribution.InstalledPackageInfo -import Distribution.Package hiding (depends) -import Distribution.Version - -import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) -import Data.List ( break ) -import Data.Array -#if __GLASGOW_HASKELL__ >= 503 -import GHC.Exts -#else -import GlaExts -#endif - --- parser produced by Happy Version 1.15 - -newtype HappyAbsSyn = HappyAbsSyn (() -> ()) -happyIn5 :: ([ PackageConfig ]) -> (HappyAbsSyn ) -happyIn5 x = unsafeCoerce# x -{-# INLINE happyIn5 #-} -happyOut5 :: (HappyAbsSyn ) -> ([ PackageConfig ]) -happyOut5 x = unsafeCoerce# x -{-# INLINE happyOut5 #-} -happyIn6 :: ([ PackageConfig ]) -> (HappyAbsSyn ) -happyIn6 x = unsafeCoerce# x -{-# INLINE happyIn6 #-} -happyOut6 :: (HappyAbsSyn ) -> ([ PackageConfig ]) -happyOut6 x = unsafeCoerce# x -{-# INLINE happyOut6 #-} -happyIn7 :: (PackageConfig) -> (HappyAbsSyn ) -happyIn7 x = unsafeCoerce# x -{-# INLINE happyIn7 #-} -happyOut7 :: (HappyAbsSyn ) -> (PackageConfig) -happyOut7 x = unsafeCoerce# x -{-# INLINE happyOut7 #-} -happyIn8 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) -happyIn8 x = unsafeCoerce# x -{-# INLINE happyIn8 #-} -happyOut8 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) -happyOut8 x = unsafeCoerce# x -{-# INLINE happyOut8 #-} -happyIn9 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) -happyIn9 x = unsafeCoerce# x -{-# INLINE happyIn9 #-} -happyOut9 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) -happyOut9 x = unsafeCoerce# x -{-# INLINE happyOut9 #-} -happyIn10 :: (PackageIdentifier) -> (HappyAbsSyn ) -happyIn10 x = unsafeCoerce# x -{-# INLINE happyIn10 #-} -happyOut10 :: (HappyAbsSyn ) -> (PackageIdentifier) -happyOut10 x = unsafeCoerce# x -{-# INLINE happyOut10 #-} -happyIn11 :: (Version) -> (HappyAbsSyn ) -happyIn11 x = unsafeCoerce# x -{-# INLINE happyIn11 #-} -happyOut11 :: (HappyAbsSyn ) -> (Version) -happyOut11 x = unsafeCoerce# x -{-# INLINE happyOut11 #-} -happyIn12 :: ([PackageIdentifier]) -> (HappyAbsSyn ) -happyIn12 x = unsafeCoerce# x -{-# INLINE happyIn12 #-} -happyOut12 :: (HappyAbsSyn ) -> ([PackageIdentifier]) -happyOut12 x = unsafeCoerce# x -{-# INLINE happyOut12 #-} -happyIn13 :: ([PackageIdentifier]) -> (HappyAbsSyn ) -happyIn13 x = unsafeCoerce# x -{-# INLINE happyIn13 #-} -happyOut13 :: (HappyAbsSyn ) -> ([PackageIdentifier]) -happyOut13 x = unsafeCoerce# x -{-# INLINE happyOut13 #-} -happyIn14 :: ([Int]) -> (HappyAbsSyn ) -happyIn14 x = unsafeCoerce# x -{-# INLINE happyIn14 #-} -happyOut14 :: (HappyAbsSyn ) -> ([Int]) -happyOut14 x = unsafeCoerce# x -{-# INLINE happyOut14 #-} -happyIn15 :: ([Int]) -> (HappyAbsSyn ) -happyIn15 x = unsafeCoerce# x -{-# INLINE happyIn15 #-} -happyOut15 :: (HappyAbsSyn ) -> ([Int]) -happyOut15 x = unsafeCoerce# x -{-# INLINE happyOut15 #-} -happyIn16 :: ([String]) -> (HappyAbsSyn ) -happyIn16 x = unsafeCoerce# x -{-# INLINE happyIn16 #-} -happyOut16 :: (HappyAbsSyn ) -> ([String]) -happyOut16 x = unsafeCoerce# x -{-# INLINE happyOut16 #-} -happyIn17 :: ([String]) -> (HappyAbsSyn ) -happyIn17 x = unsafeCoerce# x -{-# INLINE happyIn17 #-} -happyOut17 :: (HappyAbsSyn ) -> ([String]) -happyOut17 x = unsafeCoerce# x -{-# INLINE happyOut17 #-} -happyInTok :: Token -> (HappyAbsSyn ) -happyInTok x = unsafeCoerce# x -{-# INLINE happyInTok #-} -happyOutTok :: (HappyAbsSyn ) -> Token -happyOutTok x = unsafeCoerce# x -{-# INLINE happyOutTok #-} - -happyActOffsets :: HappyAddr -happyActOffsets = HappyA# "\x50\x00\x4a\x00\x4c\x00\x49\x00\x46\x00\x4b\x00\x45\x00\x0a\x00\x1e\x00\x00\x00\x00\x00\x44\x00\x16\x00\x00\x00\x43\x00\x00\x00\x42\x00\x00\x00\x03\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x01\x00\x00\x00\x40\x00\x00\x00\x3e\x00\x3d\x00\x1c\x00\x00\x00\x3f\x00\x00\x00\x00\x00\x3b\x00\x00\x00\x3a\x00\x39\x00\x35\x00\x00\x00\x00\x00\x38\x00\x31\x00\x34\x00\x33\x00\x37\x00\x36\x00\x28\x00\x00\x00\x30\x00\x32\x00\x2f\x00\x09\x00\x2d\x00\x00\x00\x2e\x00\x26\x00\x2c\x00\x22\x00\x00\x00\x00\x00\x2b\x00\x29\x00\x0d\x00\x00\x00\x00\x00"# - -happyGotoOffsets :: HappyAddr -happyGotoOffsets = HappyA# "\x2a\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\xfe\xff\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x04\x00\x00\x00\xfb\xff\x00\x00\x00\x00"# - -happyDefActions :: HappyAddr -happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xfd\xff\x00\x00\x00\x00\xf8\xff\x00\x00\xfc\xff\x00\x00\xfa\xff\x00\x00\xf9\xff\x00\x00\xf7\xff\xf6\xff\xf1\xff\xf2\xff\x00\x00\xf4\xff\xf5\xff\x00\x00\xf3\xff\xed\xff\x00\x00\x00\x00\xe7\xff\x00\x00\xe5\xff\xe6\xff\x00\x00\xee\xff\x00\x00\x00\x00\x00\x00\xec\xff\xe4\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xeb\xff\xe9\xff\x00\x00\x00\x00\x00\x00\xea\xff\xe8\xff\x00\x00\x00\x00\x00\x00\xef\xff"# - -happyCheck :: HappyAddr -happyCheck = HappyA# "\xff\xff\x05\x00\x01\x00\x05\x00\x08\x00\x07\x00\x03\x00\x0c\x00\x0c\x00\x0b\x00\x09\x00\x08\x00\x09\x00\x04\x00\x04\x00\x0b\x00\x04\x00\x04\x00\x08\x00\x0a\x00\x08\x00\x09\x00\x09\x00\x05\x00\x02\x00\x0a\x00\x08\x00\x05\x00\x03\x00\x04\x00\x01\x00\x02\x00\x04\x00\x05\x00\x04\x00\x05\x00\x0a\x00\x04\x00\x06\x00\x02\x00\x09\x00\x02\x00\x00\x00\x02\x00\x0a\x00\x07\x00\x03\x00\x07\x00\xff\xff\x04\x00\x06\x00\x05\x00\x05\x00\x03\x00\x06\x00\x01\x00\x07\x00\x02\x00\x06\x00\x08\x00\xff\xff\x05\x00\x09\x00\x06\x00\x01\x00\x04\x00\x08\x00\x05\x00\x09\x00\xff\xff\xff\xff\x07\x00\x07\x00\x06\x00\x08\x00\x07\x00\x01\x00\x04\x00\xff\xff\x03\x00\x0b\x00\x0b\x00\x08\x00\x03\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# - -happyTable :: HappyAddr -happyTable = HappyA# "\x00\x00\x1e\x00\x1d\x00\x16\x00\x1f\x00\x17\x00\x1a\x00\x20\x00\x20\x00\x18\x00\x1e\x00\x1b\x00\x1c\x00\x3a\x00\x0b\x00\x41\x00\x22\x00\x22\x00\x06\x00\x3b\x00\x23\x00\x24\x00\x24\x00\x1e\x00\x14\x00\x3f\x00\x2a\x00\x15\x00\x0c\x00\x0d\x00\x08\x00\x09\x00\x25\x00\x26\x00\x10\x00\x11\x00\x38\x00\x15\x00\x30\x00\x11\x00\x36\x00\x04\x00\x06\x00\x44\x00\x3b\x00\x3d\x00\x43\x00\x35\x00\x00\x00\x3f\x00\x41\x00\x3e\x00\x3c\x00\x38\x00\x36\x00\x33\x00\x2f\x00\x34\x00\x30\x00\x32\x00\x00\x00\x2e\x00\x2d\x00\x2a\x00\x1d\x00\x27\x00\x23\x00\x28\x00\x2c\x00\x00\x00\x00\x00\x29\x00\x0f\x00\x13\x00\x06\x00\x0f\x00\x0c\x00\x0b\x00\x00\x00\x04\x00\xff\xff\xff\xff\x06\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# - -happyReduceArr = array (2, 27) [ - (2 , happyReduce_2), - (3 , happyReduce_3), - (4 , happyReduce_4), - (5 , happyReduce_5), - (6 , happyReduce_6), - (7 , happyReduce_7), - (8 , happyReduce_8), - (9 , happyReduce_9), - (10 , happyReduce_10), - (11 , happyReduce_11), - (12 , happyReduce_12), - (13 , happyReduce_13), - (14 , happyReduce_14), - (15 , happyReduce_15), - (16 , happyReduce_16), - (17 , happyReduce_17), - (18 , happyReduce_18), - (19 , happyReduce_19), - (20 , happyReduce_20), - (21 , happyReduce_21), - (22 , happyReduce_22), - (23 , happyReduce_23), - (24 , happyReduce_24), - (25 , happyReduce_25), - (26 , happyReduce_26), - (27 , happyReduce_27) - ] - -happy_n_terms = 12 :: Int -happy_n_nonterms = 13 :: Int - -happyReduce_2 = happySpecReduce_2 0# happyReduction_2 -happyReduction_2 happy_x_2 - happy_x_1 - = happyIn5 - ([] - ) - -happyReduce_3 = happySpecReduce_3 0# happyReduction_3 -happyReduction_3 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut6 happy_x_2 of { happy_var_2 -> - happyIn5 - (reverse happy_var_2 - )} - -happyReduce_4 = happySpecReduce_1 1# happyReduction_4 -happyReduction_4 happy_x_1 - = case happyOut7 happy_x_1 of { happy_var_1 -> - happyIn6 - ([ happy_var_1 ] - )} - -happyReduce_5 = happySpecReduce_3 1# happyReduction_5 -happyReduction_5 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut6 happy_x_1 of { happy_var_1 -> - case happyOut7 happy_x_3 of { happy_var_3 -> - happyIn6 - (happy_var_3 : happy_var_1 - )}} - -happyReduce_6 = happyReduce 4# 2# happyReduction_6 -happyReduction_6 (happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut8 happy_x_3 of { happy_var_3 -> - happyIn7 - (happy_var_3 defaultPackageConfig - ) `HappyStk` happyRest} - -happyReduce_7 = happySpecReduce_1 3# happyReduction_7 -happyReduction_7 happy_x_1 - = case happyOut9 happy_x_1 of { happy_var_1 -> - happyIn8 - (\p -> happy_var_1 p - )} - -happyReduce_8 = happySpecReduce_3 3# happyReduction_8 -happyReduction_8 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut8 happy_x_1 of { happy_var_1 -> - case happyOut9 happy_x_3 of { happy_var_3 -> - happyIn8 - (\p -> happy_var_1 (happy_var_3 p) - )}} - -happyReduce_9 = happySpecReduce_3 4# happyReduction_9 -happyReduction_9 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut10 happy_x_3 of { happy_var_3 -> - happyIn9 - (\p -> case happy_var_1 of - "package" -> p {package = happy_var_3} - _ -> error "unknown key in config file" - )}} - -happyReduce_10 = happySpecReduce_3 4# happyReduction_10 -happyReduction_10 happy_x_3 - happy_x_2 - happy_x_1 - = happyIn9 - (id - ) - -happyReduce_11 = happySpecReduce_3 4# happyReduction_11 -happyReduction_11 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOutTok happy_x_3 of { (ITconid happy_var_3) -> - happyIn9 - (case happy_var_1 of { - "exposed" -> - case happy_var_3 of { - "True" -> (\p -> p {exposed=True}); - "False" -> (\p -> p {exposed=False}); - _ -> error "exposed must be either True or False" }; - "license" -> id; -- not interested - _ -> error "unknown constructor" } - )}} - -happyReduce_12 = happyReduce 4# 4# happyReduction_12 -happyReduction_12 (happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = happyIn9 - (id - ) `HappyStk` happyRest - -happyReduce_13 = happySpecReduce_3 4# happyReduction_13 -happyReduction_13 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut16 happy_x_3 of { happy_var_3 -> - happyIn9 - (\p -> case happy_var_1 of - "exposedModules" -> p{exposedModules = happy_var_3} - "hiddenModules" -> p{hiddenModules = happy_var_3} - "importDirs" -> p{importDirs = happy_var_3} - "libraryDirs" -> p{libraryDirs = happy_var_3} - "hsLibraries" -> p{hsLibraries = happy_var_3} - "extraLibraries" -> p{extraLibraries = happy_var_3} - "includeDirs" -> p{includeDirs = happy_var_3} - "includes" -> p{includes = happy_var_3} - "hugsOptions" -> p{hugsOptions = happy_var_3} - "ccOptions" -> p{ccOptions = happy_var_3} - "ldOptions" -> p{ldOptions = happy_var_3} - "frameworkDirs" -> p{frameworkDirs = happy_var_3} - "frameworks" -> p{frameworks = happy_var_3} - "haddockInterfaces" -> p{haddockInterfaces = happy_var_3} - "haddockHTMLs" -> p{haddockHTMLs = happy_var_3} - "depends" -> p{depends = []} - -- empty list only, non-empty handled below - other -> p - )}} - -happyReduce_14 = happySpecReduce_3 4# happyReduction_14 -happyReduction_14 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut12 happy_x_3 of { happy_var_3 -> - happyIn9 - (case happy_var_1 of - "depends" -> (\p -> p{depends = happy_var_3}) - _other -> error "unknown key in config file" - )}} - -happyReduce_15 = happyReduce 10# 5# happyReduction_15 -happyReduction_15 (happy_x_10 `HappyStk` - happy_x_9 `HappyStk` - happy_x_8 `HappyStk` - happy_x_7 `HappyStk` - happy_x_6 `HappyStk` - happy_x_5 `HappyStk` - happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOutTok happy_x_5 of { (ITstring happy_var_5) -> - case happyOut11 happy_x_9 of { happy_var_9 -> - happyIn10 - (PackageIdentifier{ pkgName = happy_var_5, - pkgVersion = happy_var_9 } - ) `HappyStk` happyRest}} - -happyReduce_16 = happyReduce 10# 6# happyReduction_16 -happyReduction_16 (happy_x_10 `HappyStk` - happy_x_9 `HappyStk` - happy_x_8 `HappyStk` - happy_x_7 `HappyStk` - happy_x_6 `HappyStk` - happy_x_5 `HappyStk` - happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut14 happy_x_5 of { happy_var_5 -> - case happyOut16 happy_x_9 of { happy_var_9 -> - happyIn11 - (Version{ versionBranch=happy_var_5, versionTags=happy_var_9 } - ) `HappyStk` happyRest}} - -happyReduce_17 = happySpecReduce_3 7# happyReduction_17 -happyReduction_17 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut13 happy_x_2 of { happy_var_2 -> - happyIn12 - (happy_var_2 - )} - -happyReduce_18 = happySpecReduce_1 8# happyReduction_18 -happyReduction_18 happy_x_1 - = case happyOut10 happy_x_1 of { happy_var_1 -> - happyIn13 - ([ happy_var_1 ] - )} - -happyReduce_19 = happySpecReduce_3 8# happyReduction_19 -happyReduction_19 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut10 happy_x_1 of { happy_var_1 -> - case happyOut13 happy_x_3 of { happy_var_3 -> - happyIn13 - (happy_var_1 : happy_var_3 - )}} - -happyReduce_20 = happySpecReduce_2 9# happyReduction_20 -happyReduction_20 happy_x_2 - happy_x_1 - = happyIn14 - ([] - ) - -happyReduce_21 = happySpecReduce_3 9# happyReduction_21 -happyReduction_21 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut15 happy_x_2 of { happy_var_2 -> - happyIn14 - (happy_var_2 - )} - -happyReduce_22 = happySpecReduce_1 10# happyReduction_22 -happyReduction_22 happy_x_1 - = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> - happyIn15 - ([ fromIntegral happy_var_1 ] - )} - -happyReduce_23 = happySpecReduce_3 10# happyReduction_23 -happyReduction_23 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITinteger happy_var_1) -> - case happyOut15 happy_x_3 of { happy_var_3 -> - happyIn15 - (fromIntegral happy_var_1 : happy_var_3 - )}} - -happyReduce_24 = happySpecReduce_2 11# happyReduction_24 -happyReduction_24 happy_x_2 - happy_x_1 - = happyIn16 - ([] - ) - -happyReduce_25 = happySpecReduce_3 11# happyReduction_25 -happyReduction_25 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut17 happy_x_2 of { happy_var_2 -> - happyIn16 - (reverse happy_var_2 - )} - -happyReduce_26 = happySpecReduce_1 12# happyReduction_26 -happyReduction_26 happy_x_1 - = case happyOutTok happy_x_1 of { (ITstring happy_var_1) -> - happyIn17 - ([ happy_var_1 ] - )} - -happyReduce_27 = happySpecReduce_3 12# happyReduction_27 -happyReduction_27 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut17 happy_x_1 of { happy_var_1 -> - case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> - happyIn17 - (happy_var_3 : happy_var_1 - )}} - -happyNewToken action sts stk [] = - happyDoAction 11# (error "reading EOF!") action sts stk [] - -happyNewToken action sts stk (tk:tks) = - let cont i = happyDoAction i tk action sts stk tks in - case tk of { - ITocurly -> cont 1#; - ITccurly -> cont 2#; - ITobrack -> cont 3#; - ITcbrack -> cont 4#; - ITcomma -> cont 5#; - ITequal -> cont 6#; - ITvarid happy_dollar_dollar -> cont 7#; - ITconid happy_dollar_dollar -> cont 8#; - ITstring happy_dollar_dollar -> cont 9#; - ITinteger happy_dollar_dollar -> cont 10#; - _ -> happyError' (tk:tks) - } - -happyError_ tk tks = happyError' (tk:tks) - -newtype HappyIdentity a = HappyIdentity a -happyIdentity = HappyIdentity -happyRunIdentity (HappyIdentity a) = a - -instance Monad HappyIdentity where - return = HappyIdentity - (HappyIdentity p) >>= q = q p - -happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b -happyThen = (>>=) -happyReturn :: () => a -> HappyIdentity a -happyReturn = (return) -happyThen1 m k tks = (>>=) m (\a -> k a tks) -happyReturn1 :: () => a -> b -> HappyIdentity a -happyReturn1 = \a tks -> (return) a -happyError' :: () => [Token] -> HappyIdentity a -happyError' = HappyIdentity . happyError - -parse tks = happyRunIdentity happySomeParser where - happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) - -parseOne tks = happyRunIdentity happySomeParser where - happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) - -happySeq = happyDoSeq - -type PackageConfig = InstalledPackageInfo - -defaultPackageConfig = emptyInstalledPackageInfo - -data Token - = ITocurly - | ITccurly - | ITobrack - | ITcbrack - | ITcomma - | ITequal - | ITvarid String - | ITconid String - | ITstring String - | ITinteger Int - -lexer :: String -> [Token] - -lexer [] = [] -lexer ('{':cs) = ITocurly : lexer cs -lexer ('}':cs) = ITccurly : lexer cs -lexer ('[':cs) = ITobrack : lexer cs -lexer (']':cs) = ITcbrack : lexer cs -lexer (',':cs) = ITcomma : lexer cs -lexer ('=':cs) = ITequal : lexer cs -lexer ('"':cs) = lexString cs "" -lexer (c:cs) - | isSpace c = lexer cs - | isAlpha c = lexID (c:cs) - | isDigit c = lexInt (c:cs) -lexer _ = error ( "Unexpected token") - -lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest - where - (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs - -lexInt cs = let (intStr, rest) = span isDigit cs - in ITinteger (read intStr) : lexer rest - - -lexString ('"':cs) s = ITstring (reverse s) : lexer cs -lexString ('\\':c:cs) s = lexString cs (c:s) -lexString (c:cs) s = lexString cs (c:s) - -happyError _ = error "Couldn't parse package configuration." - -parsePkgConf :: String -> [PackageConfig] -parsePkgConf = parse . lexer - -parseOnePkgConf :: String -> PackageConfig -parseOnePkgConf = parseOne . lexer -{-# LINE 1 "GenericTemplate.hs" #-} -{-# LINE 1 "" #-} -{-# LINE 1 "" #-} -{-# LINE 1 "GenericTemplate.hs" #-} --- $Id$ - - -{-# LINE 28 "GenericTemplate.hs" #-} - - -data Happy_IntList = HappyCons Int# Happy_IntList - - - - - - -{-# LINE 49 "GenericTemplate.hs" #-} - - -{-# LINE 59 "GenericTemplate.hs" #-} - - - - - - - - - - -infixr 9 `HappyStk` -data HappyStk a = HappyStk a (HappyStk a) - ------------------------------------------------------------------------------ --- starting the parse - -happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll - ------------------------------------------------------------------------------ --- Accepting the parse - --- If the current token is 0#, it means we've just accepted a partial --- parse (a %partial parser). We must ignore the saved token on the top of --- the stack in this case. -happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = - happyReturn1 ans -happyAccept j tk st sts (HappyStk ans _) = - (happyTcHack j (happyTcHack st)) (happyReturn1 ans) - ------------------------------------------------------------------------------ --- Arrays only: do the next action - - - -happyDoAction i tk st - = {- nothing -} - - - case action of - 0# -> {- nothing -} - happyFail i tk st - -1# -> {- nothing -} - happyAccept i tk st - n | (n <# (0# :: Int#)) -> {- nothing -} - - (happyReduceArr ! rule) i tk st - where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) - n -> {- nothing -} - - - happyShift new_state i tk st - where new_state = (n -# (1# :: Int#)) - where off = indexShortOffAddr happyActOffsets st - off_i = (off +# i) - check = if (off_i >=# (0# :: Int#)) - then (indexShortOffAddr happyCheck off_i ==# i) - else False - action | check = indexShortOffAddr happyTable off_i - | otherwise = indexShortOffAddr happyDefActions st - - - - - - - - - - - -indexShortOffAddr (HappyA# arr) off = -#if __GLASGOW_HASKELL__ > 500 - narrow16Int# i -#elif __GLASGOW_HASKELL__ == 500 - intToInt16# i -#else - (i `iShiftL#` 16#) `iShiftRA#` 16# -#endif - where -#if __GLASGOW_HASKELL__ >= 503 - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) -#else - i = word2Int# ((high `shiftL#` 8#) `or#` low) -#endif - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# - - - - - -data HappyAddr = HappyA# Addr# - - - - ------------------------------------------------------------------------------ --- HappyState data type (not arrays) - -{-# LINE 170 "GenericTemplate.hs" #-} - ------------------------------------------------------------------------------ --- Shifting a token - -happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = - let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in --- trace "shifting the error token" $ - happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) - -happyShift new_state i tk st sts stk = - happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) - --- happyReduce is specialised for the common cases. - -happySpecReduce_0 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_0 nt fn j tk st@((action)) sts stk - = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) - -happySpecReduce_1 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') - = let r = fn v1 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_2 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') - = let r = fn v1 v2 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_3 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') - = let r = fn v1 v2 v3 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happyReduce k i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyReduce k nt fn j tk st sts stk - = case happyDrop (k -# (1# :: Int#)) sts of - sts1@((HappyCons (st1@(action)) (_))) -> - let r = fn stk in -- it doesn't hurt to always seq here... - happyDoSeq r (happyGoto nt j tk st1 sts1 r) - -happyMonadReduce k nt fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyMonadReduce k nt fn j tk st sts stk = - happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) - where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) - drop_stk = happyDropStk k stk - -happyDrop 0# l = l -happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t - -happyDropStk 0# l = l -happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs - ------------------------------------------------------------------------------ --- Moving to a new state after a reduction - - -happyGoto nt j tk st = - {- nothing -} - happyDoAction j tk new_state - where off = indexShortOffAddr happyGotoOffsets st - off_i = (off +# nt) - new_state = indexShortOffAddr happyTable off_i - - - - ------------------------------------------------------------------------------ --- Error recovery (0# is the error token) - --- parse error if we are in recovery and we fail again -happyFail 0# tk old_st _ stk = --- trace "failing" $ - happyError_ tk - -{- We don't need state discarding for our restricted implementation of - "error". In fact, it can cause some bogus parses, so I've disabled it - for now --SDM - --- discard a state -happyFail 0# tk old_st (HappyCons ((action)) (sts)) - (saved_tok `HappyStk` _ `HappyStk` stk) = --- trace ("discarding state, depth " ++ show (length stk)) $ - happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) --} - --- Enter error recovery: generate an error token, --- save the old token and carry on. -happyFail i tk (action) sts stk = --- trace "entering error recovery" $ - happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) - --- Internal happy errors: - -notHappyAtAll = error "Internal Happy error\n" - ------------------------------------------------------------------------------ --- Hack to get the typechecker to accept our action functions - - -happyTcHack :: Int# -> a -> a -happyTcHack x y = y -{-# INLINE happyTcHack #-} - - ------------------------------------------------------------------------------ --- Seq-ing. If the --strict flag is given, then Happy emits --- happySeq = happyDoSeq --- otherwise it emits --- happySeq = happyDontSeq - -happyDoSeq, happyDontSeq :: a -> b -> b -happyDoSeq a b = a `seq` b -happyDontSeq a b = b - ------------------------------------------------------------------------------ --- Don't inline any functions from the template. GHC has a nasty habit --- of deciding to inline happyGoto everywhere, which increases the size of --- the generated parser quite a bit. - - -{-# NOINLINE happyDoAction #-} -{-# NOINLINE happyTable #-} -{-# NOINLINE happyCheck #-} -{-# NOINLINE happyActOffsets #-} -{-# NOINLINE happyGotoOffsets #-} -{-# NOINLINE happyDefActions #-} - -{-# NOINLINE happyShift #-} -{-# NOINLINE happySpecReduce_0 #-} -{-# NOINLINE happySpecReduce_1 #-} -{-# NOINLINE happySpecReduce_2 #-} -{-# NOINLINE happySpecReduce_3 #-} -{-# NOINLINE happyReduce #-} -{-# NOINLINE happyMonadReduce #-} -{-# NOINLINE happyGoto #-} -{-# NOINLINE happyFail #-} - --- end of Happy Template. rmfile ./src/System/Plugins/ParsePkgConfCabal.hs hunk ./src/System/Plugins/ParsePkgConfCabal.y_in 1 --- --- Copyright (C) 2005 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- --- Taken (apart from the most minor of alterations) from --- ghc/utils/ghc-pkg/ParsePkgConfLite.hs from GHC 6.2.2 source tree --- and then modified to mimic the behaviour of the parser within --- ghc/compiler/main/ParsePkgConf.y in GHC 6.4, without importing --- heavy-weight infrastructure from the GHC source tree such as module --- FastString, Lexer, etc. --- --- (c) Copyright 2002, The University Court of the University of Glasgow. --- - -{ -{-# OPTIONS -w #-} - -module System.Plugins.ParsePkgConfCabal ( - parsePkgConf, parseOnePkgConf - ) where - -import Distribution.InstalledPackageInfo -import Distribution.Package hiding (depends) -import Distribution.Version - -import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) -import Data.List ( break ) - -} - -%token - '{' { ITocurly } - '}' { ITccurly } - '[' { ITobrack } - ']' { ITcbrack } - ',' { ITcomma } - '=' { ITequal } - VARID { ITvarid $$ } - CONID { ITconid $$ } - STRING { ITstring $$ } - INT { ITinteger $$ } - -%name parse pkgconf -%name parseOne pkg -%tokentype { Token } -%% - -pkgconf :: { [ PackageConfig ] } - : '[' ']' { [] } - | '[' pkgs ']' { reverse $2 } - -pkgs :: { [ PackageConfig ] } - : pkg { [ $1 ] } - | pkgs ',' pkg { $3 : $1 } - -pkg :: { PackageConfig } - : CONID '{' fields '}' { $3 defaultPackageConfig } - -fields :: { PackageConfig -> PackageConfig } - : field { \p -> $1 p } - | fields ',' field { \p -> $1 ($3 p) } - -field :: { PackageConfig -> PackageConfig } - : VARID '=' pkgid - {\p -> case $1 of - "package" -> p {package = $3} - _ -> error "unknown key in config file" } - - | VARID '=' STRING { id } - -- we aren't interested in the string fields, they're all - -- boring (copyright, maintainer etc.) - - | VARID '=' CONID - { case $1 of { - "exposed" -> - case $3 of { - "True" -> (\p -> p {exposed=True}); - "False" -> (\p -> p {exposed=False}); - _ -> error "exposed must be either True or False" }; - "license" -> id; -- not interested - _ -> error "unknown constructor" } - } - - | VARID '=' CONID STRING { id } - -- another case of license - - | VARID '=' strlist - {\p -> case $1 of - "exposedModules" -> p{exposedModules = $3} - "hiddenModules" -> p{hiddenModules = $3} - "importDirs" -> p{importDirs = $3} - "libraryDirs" -> p{libraryDirs = $3} - "hsLibraries" -> p{hsLibraries = $3} - "extraLibraries" -> p{extraLibraries = $3} - "includeDirs" -> p{includeDirs = $3} - "includes" -> p{includes = $3} - "hugsOptions" -> p{hugsOptions = $3} - "ccOptions" -> p{ccOptions = $3} - "ldOptions" -> p{ldOptions = $3} - "frameworkDirs" -> p{frameworkDirs = $3} - "frameworks" -> p{frameworks = $3} - "haddockInterfaces" -> p{haddockInterfaces = $3} - "haddockHTMLs" -> p{haddockHTMLs = $3} - "depends" -> p{depends = []} - -- empty list only, non-empty handled below - other -> p - } - | VARID '=' pkgidlist - { case $1 of - "depends" -> (\p -> p{depends = $3}) - _other -> error "unknown key in config file" - } - - -pkgid :: { PackageIdentifier } - : CONID '{' VARID '=' STRING ',' VARID '=' version '}' - { PackageIdentifier{ pkgName = $5, - pkgVersion = $9 } } - -version :: { Version } - : CONID '{' VARID '=' intlist ',' VARID '=' strlist '}' - { Version{ versionBranch=$5, versionTags=$9 } } - -pkgidlist :: { [PackageIdentifier] } - : '[' pkgids ']' { $2 } - -- empty list case is covered by strlist, to avoid conflicts - -pkgids :: { [PackageIdentifier] } - : pkgid { [ $1 ] } - | pkgid ',' pkgids { $1 : $3 } - -intlist :: { [Int] } - : '[' ']' { [] } - | '[' ints ']' { $2 } - -ints :: { [Int] } - : INT { [ fromIntegral $1 ] } - | INT ',' ints { fromIntegral $1 : $3 } - -strlist :: { [String] } - : '[' ']' { [] } - | '[' strs ']' { reverse $2 } - -strs :: { [String] } - : STRING { [ $1 ] } - | strs ',' STRING { $3 : $1 } - -{ - -type PackageConfig = InstalledPackageInfo - -defaultPackageConfig = emptyInstalledPackageInfo - -data Token - = ITocurly - | ITccurly - | ITobrack - | ITcbrack - | ITcomma - | ITequal - | ITvarid String - | ITconid String - | ITstring String - | ITinteger Int - -lexer :: String -> [Token] - -lexer [] = [] -lexer ('{':cs) = ITocurly : lexer cs -lexer ('}':cs) = ITccurly : lexer cs -lexer ('[':cs) = ITobrack : lexer cs -lexer (']':cs) = ITcbrack : lexer cs -lexer (',':cs) = ITcomma : lexer cs -lexer ('=':cs) = ITequal : lexer cs -lexer ('"':cs) = lexString cs "" -lexer (c:cs) - | isSpace c = lexer cs - | isAlpha c = lexID (c:cs) - | isDigit c = lexInt (c:cs) -lexer _ = error ( "Unexpected token") - -lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest - where - (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs - -lexInt cs = let (intStr, rest) = span isDigit cs - in ITinteger (read intStr) : lexer rest - - -lexString ('"':cs) s = ITstring (reverse s) : lexer cs -lexString ('\\':c:cs) s = lexString cs (c:s) -lexString (c:cs) s = lexString cs (c:s) - -happyError _ = error "Couldn't parse package configuration." - -parsePkgConf :: String -> [PackageConfig] -parsePkgConf = parse . lexer - -parseOnePkgConf :: String -> PackageConfig -parseOnePkgConf = parseOne . lexer - -} rmfile ./src/System/Plugins/ParsePkgConfCabal.y_in hunk ./src/System/Plugins/ParsePkgConfLite.hs 1 -{-# OPTIONS -fglasgow-exts #-} -{-# OPTIONS -w #-} - -module System.Plugins.ParsePkgConfLite ( - parsePkgConf, parseOnePkgConf - ) where - -import System.Plugins.Package ( PackageConfig(..), defaultPackageConfig ) - -import Char ( isSpace, isAlpha, isAlphaNum, isUpper ) -import List ( break ) -import Array -#if __GLASGOW_HASKELL__ >= 503 -import GHC.Exts -#else -import GlaExts -#endif - --- parser produced by Happy Version 1.15 - -newtype HappyAbsSyn = HappyAbsSyn (() -> ()) -happyIn5 :: ([ PackageConfig ]) -> (HappyAbsSyn ) -happyIn5 x = unsafeCoerce# x -{-# INLINE happyIn5 #-} -happyOut5 :: (HappyAbsSyn ) -> ([ PackageConfig ]) -happyOut5 x = unsafeCoerce# x -{-# INLINE happyOut5 #-} -happyIn6 :: ([ PackageConfig ]) -> (HappyAbsSyn ) -happyIn6 x = unsafeCoerce# x -{-# INLINE happyIn6 #-} -happyOut6 :: (HappyAbsSyn ) -> ([ PackageConfig ]) -happyOut6 x = unsafeCoerce# x -{-# INLINE happyOut6 #-} -happyIn7 :: (PackageConfig) -> (HappyAbsSyn ) -happyIn7 x = unsafeCoerce# x -{-# INLINE happyIn7 #-} -happyOut7 :: (HappyAbsSyn ) -> (PackageConfig) -happyOut7 x = unsafeCoerce# x -{-# INLINE happyOut7 #-} -happyIn8 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) -happyIn8 x = unsafeCoerce# x -{-# INLINE happyIn8 #-} -happyOut8 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) -happyOut8 x = unsafeCoerce# x -{-# INLINE happyOut8 #-} -happyIn9 :: (PackageConfig -> PackageConfig) -> (HappyAbsSyn ) -happyIn9 x = unsafeCoerce# x -{-# INLINE happyIn9 #-} -happyOut9 :: (HappyAbsSyn ) -> (PackageConfig -> PackageConfig) -happyOut9 x = unsafeCoerce# x -{-# INLINE happyOut9 #-} -happyIn10 :: ([String]) -> (HappyAbsSyn ) -happyIn10 x = unsafeCoerce# x -{-# INLINE happyIn10 #-} -happyOut10 :: (HappyAbsSyn ) -> ([String]) -happyOut10 x = unsafeCoerce# x -{-# INLINE happyOut10 #-} -happyIn11 :: ([String]) -> (HappyAbsSyn ) -happyIn11 x = unsafeCoerce# x -{-# INLINE happyIn11 #-} -happyOut11 :: (HappyAbsSyn ) -> ([String]) -happyOut11 x = unsafeCoerce# x -{-# INLINE happyOut11 #-} -happyIn12 :: (Bool) -> (HappyAbsSyn ) -happyIn12 x = unsafeCoerce# x -{-# INLINE happyIn12 #-} -happyOut12 :: (HappyAbsSyn ) -> (Bool) -happyOut12 x = unsafeCoerce# x -{-# INLINE happyOut12 #-} -happyInTok :: Token -> (HappyAbsSyn ) -happyInTok x = unsafeCoerce# x -{-# INLINE happyInTok #-} -happyOutTok :: (HappyAbsSyn ) -> Token -happyOutTok x = unsafeCoerce# x -{-# INLINE happyOutTok #-} - -happyActOffsets :: HappyAddr -happyActOffsets = HappyA# "\x1f\x00\x1e\x00\x1d\x00\x1b\x00\x1a\x00\x1c\x00\x19\x00\x01\x00\x0e\x00\x00\x00\x00\x00\x17\x00\x08\x00\x00\x00\x16\x00\x00\x00\x13\x00\x00\x00\xfe\xff\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00"# - -happyGotoOffsets :: HappyAddr -happyGotoOffsets = HappyA# "\x18\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\xfd\xff\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# - -happyDefActions :: HappyAddr -happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xfd\xff\x00\x00\x00\x00\xf8\xff\x00\x00\xfc\xff\x00\x00\xfa\xff\x00\x00\xf9\xff\x00\x00\xf7\xff\xf4\xff\xf5\xff\x00\x00\xef\xff\xf6\xff\x00\x00\xf3\xff\xf1\xff\xf2\xff\x00\x00\xf0\xff"# - -happyCheck :: HappyAddr -happyCheck = HappyA# "\xff\xff\x03\x00\x05\x00\x04\x00\x07\x00\x04\x00\x08\x00\x09\x00\x09\x00\x08\x00\x02\x00\x01\x00\x02\x00\x05\x00\x03\x00\x04\x00\x04\x00\x05\x00\x04\x00\x05\x00\x04\x00\x06\x00\x02\x00\x02\x00\x00\x00\x07\x00\x09\x00\x08\x00\x06\x00\x01\x00\x07\x00\x04\x00\x03\x00\xff\xff\x03\x00\x0a\x00\x0a\x00\xff\xff\x08\x00\xff\xff\xff\xff\xff\xff"# - -happyTable :: HappyAddr -happyTable = HappyA# "\x00\x00\x19\x00\x16\x00\x1d\x00\x17\x00\x0b\x00\x1a\x00\x1b\x00\x1e\x00\x06\x00\x14\x00\x08\x00\x09\x00\x15\x00\x0c\x00\x0d\x00\x1f\x00\x20\x00\x10\x00\x11\x00\x15\x00\x1b\x00\x11\x00\x04\x00\x06\x00\x0f\x00\x21\x00\x06\x00\x13\x00\x0c\x00\x0f\x00\x0b\x00\x04\x00\x00\x00\x08\x00\xff\xff\xff\xff\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00"# - -happyReduceArr = array (2, 16) [ - (2 , happyReduce_2), - (3 , happyReduce_3), - (4 , happyReduce_4), - (5 , happyReduce_5), - (6 , happyReduce_6), - (7 , happyReduce_7), - (8 , happyReduce_8), - (9 , happyReduce_9), - (10 , happyReduce_10), - (11 , happyReduce_11), - (12 , happyReduce_12), - (13 , happyReduce_13), - (14 , happyReduce_14), - (15 , happyReduce_15), - (16 , happyReduce_16) - ] - -happy_n_terms = 11 :: Int -happy_n_nonterms = 8 :: Int - -happyReduce_2 = happySpecReduce_2 0# happyReduction_2 -happyReduction_2 happy_x_2 - happy_x_1 - = happyIn5 - ([] - ) - -happyReduce_3 = happySpecReduce_3 0# happyReduction_3 -happyReduction_3 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut6 happy_x_2 of { happy_var_2 -> - happyIn5 - (reverse happy_var_2 - )} - -happyReduce_4 = happySpecReduce_1 1# happyReduction_4 -happyReduction_4 happy_x_1 - = case happyOut7 happy_x_1 of { happy_var_1 -> - happyIn6 - ([ happy_var_1 ] - )} - -happyReduce_5 = happySpecReduce_3 1# happyReduction_5 -happyReduction_5 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut6 happy_x_1 of { happy_var_1 -> - case happyOut7 happy_x_3 of { happy_var_3 -> - happyIn6 - (happy_var_3 : happy_var_1 - )}} - -happyReduce_6 = happyReduce 4# 2# happyReduction_6 -happyReduction_6 (happy_x_4 `HappyStk` - happy_x_3 `HappyStk` - happy_x_2 `HappyStk` - happy_x_1 `HappyStk` - happyRest) - = case happyOut8 happy_x_3 of { happy_var_3 -> - happyIn7 - (happy_var_3 defaultPackageConfig - ) `HappyStk` happyRest} - -happyReduce_7 = happySpecReduce_1 3# happyReduction_7 -happyReduction_7 happy_x_1 - = case happyOut9 happy_x_1 of { happy_var_1 -> - happyIn8 - (\p -> happy_var_1 p - )} - -happyReduce_8 = happySpecReduce_3 3# happyReduction_8 -happyReduction_8 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut8 happy_x_1 of { happy_var_1 -> - case happyOut9 happy_x_3 of { happy_var_3 -> - happyIn8 - (\p -> happy_var_1 (happy_var_3 p) - )}} - -happyReduce_9 = happySpecReduce_3 4# happyReduction_9 -happyReduction_9 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> - happyIn9 - (\p -> case happy_var_1 of - "name" -> p{name = happy_var_3} - _ -> error "unknown key in config file" - )}} - -happyReduce_10 = happySpecReduce_3 4# happyReduction_10 -happyReduction_10 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut12 happy_x_3 of { happy_var_3 -> - happyIn9 - (\p -> case happy_var_1 of { - "auto" -> p{auto = happy_var_3}; - _ -> p } - )}} - -happyReduce_11 = happySpecReduce_3 4# happyReduction_11 -happyReduction_11 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOutTok happy_x_1 of { (ITvarid happy_var_1) -> - case happyOut10 happy_x_3 of { happy_var_3 -> - happyIn9 - (\p -> case happy_var_1 of - "import_dirs" -> p{import_dirs = happy_var_3} - "library_dirs" -> p{library_dirs = happy_var_3} - "hs_libraries" -> p{hs_libraries = happy_var_3} - "extra_libraries" -> p{extra_libraries = happy_var_3} - "include_dirs" -> p{include_dirs = happy_var_3} - "c_includes" -> p{c_includes = happy_var_3} - "package_deps" -> p{package_deps = happy_var_3} - "extra_ghc_opts" -> p{extra_ghc_opts = happy_var_3} - "extra_cc_opts" -> p{extra_cc_opts = happy_var_3} - "extra_ld_opts" -> p{extra_ld_opts = happy_var_3} - "framework_dirs" -> p{framework_dirs = happy_var_3} - "extra_frameworks"-> p{extra_frameworks= happy_var_3} - _other -> p - )}} - -happyReduce_12 = happySpecReduce_2 5# happyReduction_12 -happyReduction_12 happy_x_2 - happy_x_1 - = happyIn10 - ([] - ) - -happyReduce_13 = happySpecReduce_3 5# happyReduction_13 -happyReduction_13 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut11 happy_x_2 of { happy_var_2 -> - happyIn10 - (reverse happy_var_2 - )} - -happyReduce_14 = happySpecReduce_1 6# happyReduction_14 -happyReduction_14 happy_x_1 - = case happyOutTok happy_x_1 of { (ITstring happy_var_1) -> - happyIn11 - ([ happy_var_1 ] - )} - -happyReduce_15 = happySpecReduce_3 6# happyReduction_15 -happyReduction_15 happy_x_3 - happy_x_2 - happy_x_1 - = case happyOut11 happy_x_1 of { happy_var_1 -> - case happyOutTok happy_x_3 of { (ITstring happy_var_3) -> - happyIn11 - (happy_var_3 : happy_var_1 - )}} - -happyReduce_16 = happySpecReduce_1 7# happyReduction_16 -happyReduction_16 happy_x_1 - = case happyOutTok happy_x_1 of { (ITconid happy_var_1) -> - happyIn12 - ( case happy_var_1 of { - "True" -> True; - "False" -> False; - _ -> error ("unknown constructor in config file: " ++ happy_var_1) } - )} - -happyNewToken action sts stk [] = - happyDoAction 10# (error "reading EOF!") action sts stk [] - -happyNewToken action sts stk (tk:tks) = - let cont i = happyDoAction i tk action sts stk tks in - case tk of { - ITocurly -> cont 1#; - ITccurly -> cont 2#; - ITobrack -> cont 3#; - ITcbrack -> cont 4#; - ITcomma -> cont 5#; - ITequal -> cont 6#; - ITvarid happy_dollar_dollar -> cont 7#; - ITconid happy_dollar_dollar -> cont 8#; - ITstring happy_dollar_dollar -> cont 9#; - _ -> happyError' (tk:tks) - } - -happyError_ tk tks = happyError' (tk:tks) - -newtype HappyIdentity a = HappyIdentity a -happyIdentity = HappyIdentity -happyRunIdentity (HappyIdentity a) = a - -instance Monad HappyIdentity where - return = HappyIdentity - (HappyIdentity p) >>= q = q p - -happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b -happyThen = (>>=) -happyReturn :: () => a -> HappyIdentity a -happyReturn = (return) -happyThen1 m k tks = (>>=) m (\a -> k a tks) -happyReturn1 :: () => a -> b -> HappyIdentity a -happyReturn1 = \a tks -> (return) a -happyError' :: () => [Token] -> HappyIdentity a -happyError' = HappyIdentity . happyError - -parse tks = happyRunIdentity happySomeParser where - happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut5 x)) - -parseOne tks = happyRunIdentity happySomeParser where - happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut7 x)) - -happySeq = happyDontSeq - -data Token - = ITocurly - | ITccurly - | ITobrack - | ITcbrack - | ITcomma - | ITequal - | ITvarid String - | ITconid String - | ITstring String - -lexer :: String -> [Token] - -lexer [] = [] -lexer ('{':cs) = ITocurly : lexer cs -lexer ('}':cs) = ITccurly : lexer cs -lexer ('[':cs) = ITobrack : lexer cs -lexer (']':cs) = ITcbrack : lexer cs -lexer (',':cs) = ITcomma : lexer cs -lexer ('=':cs) = ITequal : lexer cs -lexer ('"':cs) = lexString cs "" -lexer (c:cs) - | isSpace c = lexer cs - | isAlpha c = lexID (c:cs) where -lexer _ = error "Unexpected token" - -lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest - where - (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs - -lexString ('"':cs) s = ITstring (reverse s) : lexer cs -lexString ('\\':c:cs) s = lexString cs (c:s) -lexString (c:cs) s = lexString cs (c:s) - -happyError _ = error "Couldn't parse package configuration." - -parsePkgConf :: String -> [PackageConfig] -parsePkgConf = parse . lexer - -parseOnePkgConf :: String -> PackageConfig -parseOnePkgConf = parseOne . lexer -{-# LINE 1 "GenericTemplate.hs" #-} -{-# LINE 1 "" #-} -{-# LINE 1 "" #-} -{-# LINE 1 "GenericTemplate.hs" #-} --- $Id$ - - -{-# LINE 28 "GenericTemplate.hs" #-} - - -data Happy_IntList = HappyCons Int# Happy_IntList - - - - - - -{-# LINE 49 "GenericTemplate.hs" #-} - - -{-# LINE 59 "GenericTemplate.hs" #-} - - - - - - - - - - -infixr 9 `HappyStk` -data HappyStk a = HappyStk a (HappyStk a) - ------------------------------------------------------------------------------ --- starting the parse - -happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll - ------------------------------------------------------------------------------ --- Accepting the parse - --- If the current token is 0#, it means we've just accepted a partial --- parse (a %partial parser). We must ignore the saved token on the top of --- the stack in this case. -happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = - happyReturn1 ans -happyAccept j tk st sts (HappyStk ans _) = - (happyTcHack j (happyTcHack st)) (happyReturn1 ans) - ------------------------------------------------------------------------------ --- Arrays only: do the next action - - - -happyDoAction i tk st - = {- nothing -} - - - case action of - 0# -> {- nothing -} - happyFail i tk st - -1# -> {- nothing -} - happyAccept i tk st - n | (n <# (0# :: Int#)) -> {- nothing -} - - (happyReduceArr ! rule) i tk st - where rule = (I# ((negateInt# ((n +# (1# :: Int#)))))) - n -> {- nothing -} - - - happyShift new_state i tk st - where new_state = (n -# (1# :: Int#)) - where off = indexShortOffAddr happyActOffsets st - off_i = (off +# i) - check = if (off_i >=# (0# :: Int#)) - then (indexShortOffAddr happyCheck off_i ==# i) - else False - action | check = indexShortOffAddr happyTable off_i - | otherwise = indexShortOffAddr happyDefActions st - - - - - - - - - - - -indexShortOffAddr (HappyA# arr) off = -#if __GLASGOW_HASKELL__ > 500 - narrow16Int# i -#elif __GLASGOW_HASKELL__ == 500 - intToInt16# i -#else - (i `iShiftL#` 16#) `iShiftRA#` 16# -#endif - where -#if __GLASGOW_HASKELL__ >= 503 - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) -#else - i = word2Int# ((high `shiftL#` 8#) `or#` low) -#endif - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# - - - - - -data HappyAddr = HappyA# Addr# - - - - ------------------------------------------------------------------------------ --- HappyState data type (not arrays) - -{-# LINE 170 "GenericTemplate.hs" #-} - ------------------------------------------------------------------------------ --- Shifting a token - -happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = - let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in --- trace "shifting the error token" $ - happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) - -happyShift new_state i tk st sts stk = - happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) - --- happyReduce is specialised for the common cases. - -happySpecReduce_0 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_0 nt fn j tk st@((action)) sts stk - = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) - -happySpecReduce_1 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') - = let r = fn v1 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_2 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') - = let r = fn v1 v2 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happySpecReduce_3 i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') - = let r = fn v1 v2 v3 in - happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) - -happyReduce k i fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyReduce k nt fn j tk st sts stk - = case happyDrop (k -# (1# :: Int#)) sts of - sts1@((HappyCons (st1@(action)) (_))) -> - let r = fn stk in -- it doesn't hurt to always seq here... - happyDoSeq r (happyGoto nt j tk st1 sts1 r) - -happyMonadReduce k nt fn 0# tk st sts stk - = happyFail 0# tk st sts stk -happyMonadReduce k nt fn j tk st sts stk = - happyThen1 (fn stk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) - where sts1@((HappyCons (st1@(action)) (_))) = happyDrop k (HappyCons (st) (sts)) - drop_stk = happyDropStk k stk - -happyDrop 0# l = l -happyDrop n (HappyCons (_) (t)) = happyDrop (n -# (1# :: Int#)) t - -happyDropStk 0# l = l -happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs - ------------------------------------------------------------------------------ --- Moving to a new state after a reduction - - -happyGoto nt j tk st = - {- nothing -} - happyDoAction j tk new_state - where off = indexShortOffAddr happyGotoOffsets st - off_i = (off +# nt) - new_state = indexShortOffAddr happyTable off_i - - - - ------------------------------------------------------------------------------ --- Error recovery (0# is the error token) - --- parse error if we are in recovery and we fail again -happyFail 0# tk old_st _ stk = --- trace "failing" $ - happyError_ tk - -{- We don't need state discarding for our restricted implementation of - "error". In fact, it can cause some bogus parses, so I've disabled it - for now --SDM - --- discard a state -happyFail 0# tk old_st (HappyCons ((action)) (sts)) - (saved_tok `HappyStk` _ `HappyStk` stk) = --- trace ("discarding state, depth " ++ show (length stk)) $ - happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk)) --} - --- Enter error recovery: generate an error token, --- save the old token and carry on. -happyFail i tk (action) sts stk = --- trace "entering error recovery" $ - happyDoAction 0# tk action sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk) - --- Internal happy errors: - -notHappyAtAll = error "Internal Happy error\n" - ------------------------------------------------------------------------------ --- Hack to get the typechecker to accept our action functions - - -happyTcHack :: Int# -> a -> a -happyTcHack x y = y -{-# INLINE happyTcHack #-} - - ------------------------------------------------------------------------------ --- Seq-ing. If the --strict flag is given, then Happy emits --- happySeq = happyDoSeq --- otherwise it emits --- happySeq = happyDontSeq - -happyDoSeq, happyDontSeq :: a -> b -> b -happyDoSeq a b = a `seq` b -happyDontSeq a b = b - ------------------------------------------------------------------------------ --- Don't inline any functions from the template. GHC has a nasty habit --- of deciding to inline happyGoto everywhere, which increases the size of --- the generated parser quite a bit. - - -{-# NOINLINE happyDoAction #-} -{-# NOINLINE happyTable #-} -{-# NOINLINE happyCheck #-} -{-# NOINLINE happyActOffsets #-} -{-# NOINLINE happyGotoOffsets #-} -{-# NOINLINE happyDefActions #-} - -{-# NOINLINE happyShift #-} -{-# NOINLINE happySpecReduce_0 #-} -{-# NOINLINE happySpecReduce_1 #-} -{-# NOINLINE happySpecReduce_2 #-} -{-# NOINLINE happySpecReduce_3 #-} -{-# NOINLINE happyReduce #-} -{-# NOINLINE happyMonadReduce #-} -{-# NOINLINE happyGoto #-} -{-# NOINLINE happyFail #-} - --- end of Happy Template. rmfile ./src/System/Plugins/ParsePkgConfLite.hs hunk ./src/System/Plugins/ParsePkgConfLite.y 1 --- --- Copyright (C) 2004 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- --- Taken (apart from the most minor of alterations) from --- ghc/utils/ghc-pkg/ParsePkgConfLite.hs: --- --- (c) Copyright 2002, The University Court of the University of Glasgow. --- - -{ - -{-# OPTIONS -w #-} - -module System.Plugins.ParsePkgConfLite ( - parsePkgConf, parseOnePkgConf - ) where - -import System.Plugins.Package ( PackageConfig(..), defaultPackageConfig ) - -import Char ( isSpace, isAlpha, isAlphaNum, isUpper ) -import List ( break ) - -} - -%token - '{' { ITocurly } - '}' { ITccurly } - '[' { ITobrack } - ']' { ITcbrack } - ',' { ITcomma } - '=' { ITequal } - VARID { ITvarid $$ } - CONID { ITconid $$ } - STRING { ITstring $$ } - -%name parse pkgconf -%name parseOne pkg -%tokentype { Token } -%% - -pkgconf :: { [ PackageConfig ] } - : '[' ']' { [] } - | '[' pkgs ']' { reverse $2 } - -pkgs :: { [ PackageConfig ] } - : pkg { [ $1 ] } - | pkgs ',' pkg { $3 : $1 } - -pkg :: { PackageConfig } - : CONID '{' fields '}' { $3 defaultPackageConfig } - -fields :: { PackageConfig -> PackageConfig } - : field { \p -> $1 p } - | fields ',' field { \p -> $1 ($3 p) } - -field :: { PackageConfig -> PackageConfig } - : VARID '=' STRING - {\p -> case $1 of - "name" -> p{name = $3} - _ -> error "unknown key in config file" } - - | VARID '=' bool - {\p -> case $1 of { - "auto" -> p{auto = $3}; - _ -> p } } - - | VARID '=' strlist - {\p -> case $1 of - "import_dirs" -> p{import_dirs = $3} - "library_dirs" -> p{library_dirs = $3} - "hs_libraries" -> p{hs_libraries = $3} - "extra_libraries" -> p{extra_libraries = $3} - "include_dirs" -> p{include_dirs = $3} - "c_includes" -> p{c_includes = $3} - "package_deps" -> p{package_deps = $3} - "extra_ghc_opts" -> p{extra_ghc_opts = $3} - "extra_cc_opts" -> p{extra_cc_opts = $3} - "extra_ld_opts" -> p{extra_ld_opts = $3} - "framework_dirs" -> p{framework_dirs = $3} - "extra_frameworks"-> p{extra_frameworks= $3} - _other -> p - } - -strlist :: { [String] } - : '[' ']' { [] } - | '[' strs ']' { reverse $2 } - -strs :: { [String] } - : STRING { [ $1 ] } - | strs ',' STRING { $3 : $1 } - -bool :: { Bool } - : CONID {% case $1 of { - "True" -> True; - "False" -> False; - _ -> error ("unknown constructor in config file: " ++ $1) } } - -{ - -data Token - = ITocurly - | ITccurly - | ITobrack - | ITcbrack - | ITcomma - | ITequal - | ITvarid String - | ITconid String - | ITstring String - -lexer :: String -> [Token] - -lexer [] = [] -lexer ('{':cs) = ITocurly : lexer cs -lexer ('}':cs) = ITccurly : lexer cs -lexer ('[':cs) = ITobrack : lexer cs -lexer (']':cs) = ITcbrack : lexer cs -lexer (',':cs) = ITcomma : lexer cs -lexer ('=':cs) = ITequal : lexer cs -lexer ('"':cs) = lexString cs "" -lexer (c:cs) - | isSpace c = lexer cs - | isAlpha c = lexID (c:cs) where -lexer _ = error "Unexpected token" - -lexID cs = (if isUpper (head cs) then ITconid else ITvarid) id : lexer rest - where - (id,rest) = break (\c -> c /= '_' && not (isAlphaNum c)) cs - -lexString ('"':cs) s = ITstring (reverse s) : lexer cs -lexString ('\\':c:cs) s = lexString cs (c:s) -lexString (c:cs) s = lexString cs (c:s) - -happyError _ = error "Couldn't parse package configuration." - -parsePkgConf :: String -> [PackageConfig] -parsePkgConf = parse . lexer - -parseOnePkgConf :: String -> PackageConfig -parseOnePkgConf = parseOne . lexer - -} rmfile ./src/System/Plugins/ParsePkgConfLite.y hunk ./plugins.cabal 2 -version: 1.5.1.1 +version: 1.5.1.2 hunk ./plugins.cabal 35 - System.Plugins.Package, - System.Plugins.PackageAPI, hunk ./src/System/Plugins/Env.hs 55 -import System.Plugins.PackageAPI {- everything -} hunk ./src/System/Plugins/Env.hs 72 +import Distribution.Package hiding (depends, packageName, PackageName(..)) +import Distribution.Text + hunk ./src/System/Plugins/Env.hs 81 -import Distribution.Text hunk ./src/System/Plugins/Env.hs 523 + +------------------------------------------------------------------------ + +-- +-- We export an abstract interface to package conf`s because we have +-- to handle either traditional or Cabal style package conf`s. +-- + + + +packageName :: PackageConfig -> PackageName +packageDeps :: PackageConfig -> [PackageName] +-- updImportDirs :: ([FilePath] -> [FilePath]) -> PackageConfig -> PackageConfig +-- updLibraryDirs :: ([FilePath] -> [FilePath]) -> PackageConfig -> PackageConfig + + +type PackageName = String + +type PackageConfig = InstalledPackageInfo + +packageName = display . pkgName . sourcePackageId +-- packageName_ = pkgName . sourcePackageId +packageDeps = (map display) . depends + +{- +updImportDirs f pk@(InstalledPackageInfo { importDirs = idirs }) = + pk { importDirs = f idirs } +updLibraryDirs f pk@(InstalledPackageInfo { libraryDirs = ldirs }) = + pk { libraryDirs = f ldirs } +-} hunk ./src/System/Plugins/Package.hs 1 --- --- Copyright (C) 2004 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA - --- --- Read information from a package.conf --- - -module System.Plugins.Package {-everything-} where - -type PackageName = String - --- --- Take directly from ghc/utils/ghc-pkg/Package.hs --- - -data PackageConfig = Package { - name :: PackageName, - auto :: Bool, - import_dirs :: [FilePath], - source_dirs :: [FilePath], - library_dirs :: [FilePath], - hs_libraries :: [String], - extra_libraries :: [String], - include_dirs :: [FilePath], - c_includes :: [String], - package_deps :: [String], - extra_ghc_opts :: [String], - extra_cc_opts :: [String], - extra_ld_opts :: [String], - framework_dirs :: [FilePath], -- ignored everywhere but on Darwin/MacOS X - extra_frameworks:: [String] -- ignored everywhere but on Darwin/MacOS X - } deriving Show - - -defaultPackageConfig = Package { - name = error "defaultPackage", - auto = False, - import_dirs = [], - source_dirs = [], - library_dirs = [], - hs_libraries = [], - extra_libraries = [], - include_dirs = [], - c_includes = [], - package_deps = [], - extra_ghc_opts = [], - extra_cc_opts = [], - extra_ld_opts = [], - framework_dirs = [], - extra_frameworks= [] - } - rmfile ./src/System/Plugins/Package.hs hunk ./src/System/Plugins/PackageAPI.hs 1 -{-# LANGUAGE CPP #-} --- --- Copyright (C) 2005 Sean Seefried - http://www.cse.unsw.edu.au/~sseefried --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA - --- --- We export an abstract interface to package conf`s because we have --- to handle either traditional or Cabal style package conf`s. --- - -module System.Plugins.PackageAPI ( - PackageName - , PackageConfig - , packageName - , packageName_ - , importDirs - , hsLibraries - , libraryDirs - , extraLibraries - , ldOptions - , packageDeps - , updImportDirs - , updLibraryDirs - ) where - -#include "../../../config.h" - -#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 -import Distribution.InstalledPackageInfo -import Distribution.Package hiding (depends, packageName, PackageName(..)) -import Distribution.Text -#else -import System.Plugins.Package -#endif - -packageName :: PackageConfig -> PackageName -packageDeps :: PackageConfig -> [PackageName] -updImportDirs :: ([FilePath] -> [FilePath]) -> PackageConfig -> PackageConfig -updLibraryDirs :: ([FilePath] -> [FilePath]) -> PackageConfig -> PackageConfig - --- We use different package.conf parsers when running on 6.2.x or 6.4 -#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 - -type PackageName = String - -type PackageConfig = InstalledPackageInfo - -packageName = display . pkgName . sourcePackageId -packageName_ = pkgName . sourcePackageId -packageDeps = (map display) . depends - -updImportDirs f pk@(InstalledPackageInfo { importDirs = idirs }) = - pk { importDirs = f idirs } -updLibraryDirs f pk@(InstalledPackageInfo { libraryDirs = ldirs }) = - pk { libraryDirs = f ldirs } -#else - -packageName = name -packageName_ = name -packageDeps = package_deps - -updImportDirs f pk@(Package {import_dirs = idirs}) - = pk {import_dirs = f idirs} - -updLibraryDirs f pk@(Package {library_dirs = ldirs}) - = pk {library_dirs = f ldirs} - -importDirs :: PackageConfig -> [FilePath] -importDirs = import_dirs - -hsLibraries :: PackageConfig -> [String] -hsLibraries = hs_libraries - -libraryDirs :: PackageConfig -> [FilePath] -libraryDirs = library_dirs - -extraLibraries :: PackageConfig -> [String] -extraLibraries = extra_libraries - -ldOptions :: PackageConfig -> [String] -ldOptions = extra_ld_opts - -#endif rmfile ./src/System/Plugins/PackageAPI.hs hunk ./plugins.cabal 8 - Described in the paper: - /Plugging Haskell In/, + Described in the papers: + + * /Plugging Haskell In/, + * /Dynamic Applications from the Ground Up/, + * /Dynamic Extension of Typed Functional Languages/. + hunk ./plugins.cabal 32 - System.MkTemp, hunk ./src/System/MkTemp.hs 1 -{-# LANGUAGE CPP #-} -{-# LANGUAGE MagicHash #-} --- --- Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. --- --- This library 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 --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 --- USA --- - --- --- A Haskell reimplementation of the C mktemp/mkstemp/mkstemps library --- based on the algorithms in: --- > $ OpenBSD: mktemp.c,v 1.17 2003/06/02 20:18:37 millert Exp $ --- which are available under the BSD license. --- - -module System.MkTemp ( - - mktemp, -- :: FilePath -> IO Maybe FilePath - mkstemp, -- :: FilePath -> IO Maybe (FilePath, Handle) - mkstemps, -- :: FilePath -> Int -> IO Maybe (FilePath,Handle) - mkdtemp, -- :: FilePath -> IO Maybe FilePath - - ) where - -import Data.List ( ) -import Data.Char ( chr, ord, isDigit ) -import Control.Monad ( liftM ) -import Control.Exception ( handleJust ) -import System.FilePath ( splitFileName, () ) -import System.Directory ( doesDirectoryExist, doesFileExist, createDirectory ) -import System.IO -#ifndef __MINGW32__ -import System.IO.Error ( mkIOError, alreadyExistsErrorType, - isAlreadyExistsError ) -#else -import System.IO.Error ( isAlreadyExistsError, isAlreadyInUseError, isPermissionError ) -#endif - -#ifndef __MINGW32__ -import qualified System.Posix.Internals ( c_getpid ) -#endif - -#ifdef HAVE_ARC4RANDOM -import GHC.Base hiding ( ord, chr ) -import GHC.Int -#else -import System.Random ( getStdRandom, Random(randomR) ) -#endif - ------------------------------------------------------------------------- - -mkstemps :: FilePath -> Int -> IO (Maybe (FilePath,Handle)) -mkstemp :: FilePath -> IO (Maybe (FilePath,Handle)) -mktemp :: FilePath -> IO (Maybe FilePath) -mkdtemp :: FilePath -> IO (Maybe FilePath) - -mkstemps path slen = gettemp path True False slen - -mkstemp path = gettemp path True False 0 - -mktemp path = do v <- gettemp path False False 0 - return $ case v of Just (path',_) -> Just path'; _ -> Nothing - -mkdtemp path = do v <- gettemp path False True 0 - return $ case v of Just (path',_) -> Just path'; _ -> Nothing - ------------------------------------------------------------------------- - -gettemp :: FilePath -> Bool -> Bool -> Int -> IO (Maybe (FilePath, Handle)) - -gettemp [] _ _ _ = return Nothing -gettemp _ True True _ = return Nothing - -gettemp path doopen domkdir slen = do - -- - -- firstly, break up the path and extract the template - -- - let (pref,tmpl,suff) = let (r,s) = splitAt (length path - slen) path - (d,f) = splitFileName r - (p,t) = break (== 'X') f - in (d p,t,s) - -- - -- an error if there is only a suffix, it seems - -- - if null pref && null tmpl then return Nothing else do { - -- - -- replace end of template with process id, and rest with randomness - -- - ;pid <- liftM show $ getProcessID - ;let (rest, xs) = merge tmpl pid - ;as <- randomise rest - ;let tmpl' = as ++ xs - path' = pref ++ tmpl' ++ suff - -- - -- just check if we can get at the directory we might need - -- - ;dir_ok <- if doopen || domkdir - then let d = reverse $ dropWhile (/= '/') $ reverse path' - in doesDirectoryExist d - else return True - - ;if not dir_ok then return Nothing else do { - -- - -- We need a function for looking for appropriate temp files - -- - ;let fn p - | doopen = handleJust isInUse (\_ -> return Nothing) $ - do h <- open0600 p ; return $ Just h - | domkdir = handleJust alreadyExists (\_ -> return Nothing) $ - do mkdir0700 p ; return $ Just undefined - | otherwise = do b <- doesFileExist p - return $ if b then Nothing else Just undefined - - -- - -- now, try to create the tmp file, permute if we can't - -- once we've tried all permutations, give up - -- - ;let tryIt p t i = - do v <- fn p - case v of Just h -> return $ Just (p,h) -- it worked - Nothing -> let (i',t') = tweak i t - in if null t' - then return Nothing -- no more - else tryIt (pref++t'++suff) t' i' - ;tryIt path' tmpl' 0 - - }} - --- --- Replace X's with pid digits. Complete rewrite --- -merge :: String -> String -> (String,String) -merge t [] = (t ,[]) -merge [] _ = ([] ,[]) -merge (_:ts) (p:ps) = (ts',p:ps') - where (ts',ps') = merge ts ps - --- --- And replace remaining X's with random chars --- randomR is pretty slow, oh well. --- -randomise :: String -> IO String -randomise [] = return [] -randomise ('X':xs) = do p <- getRandom () - let c = chr $! if p < 26 - then p + (ord 'A') - else (p - 26) + (ord 'a') - xs' <- randomise xs - return (c : xs') -randomise s = return s - --- --- "tricky little algorithm for backward compatibility" --- could do with a Haskellish rewrite --- -tweak :: Int -> String -> (Int,String) -tweak i s - | i > length s - 1 = (i,[]) -- no more - | s !! i == 'Z' = if i == length s - 1 - then (i,[]) -- no more - else let s' = splice (i+1) 'a' - in tweak (i+1) s' -- loop - | otherwise = let c = s !! i in case () of {_ - | isDigit c -> (i, splice i 'a' ) - | c == 'z' -> (i, splice i 'A' ) - | otherwise -> let c' = chr $ (ord c) + 1 in (i,splice i c') - } - where - splice j c = let (a,b) = splitAt j s in a ++ [c] ++ tail b - --- --------------------------------------------------------------------- - -alreadyExists :: IOError -> Maybe IOError -alreadyExists ioe - | isAlreadyExistsError ioe = Just ioe - | otherwise = Nothing - -isInUse :: IOError -> Maybe () -#ifndef __MINGW32__ -isInUse ioe - | isAlreadyExistsError ioe = Just () - | otherwise = Nothing -#else -isInUse ioe - | isAlreadyInUseError ioe = Just () - | isPermissionError ioe = Just () - | isAlreadyExistsError ioe = Just () -- we throw this - | otherwise = Nothing -isInUse _ = Nothing -#endif - --- --------------------------------------------------------------------- --- Create a file mode 0600 if possible --- --- N.B. race condition between testing existence and opening --- But we can live with that to avoid a posix dependency, right? --- -open0600 :: FilePath -> IO Handle -open0600 f = do - b <- doesFileExist f - if b then ioError err -- race - else openFile f ReadWriteMode - where - err = mkIOError alreadyExistsErrorType "op0600" Nothing (Just f) - -{- --- open(path, O_CREAT|O_EXCL|O_RDWR, 0600) --- -open0600 f = do - openFd f ReadWrite (Just o600) excl >>= fdToHandle - where - o600 = ownerReadMode `unionFileModes` ownerWriteMode - excl = defaultFileFlags { exclusive = True } --} - --- --- create a directory mode 0700 if possible --- -mkdir0700 :: FilePath -> IO () -mkdir0700 dir = createDirectory dir -{- - System.Posix.Directory.createDirectory dir ownerModes --} - --- | getProcessId, stolen from GHC /main\/SysTools.lhs/ --- -#ifdef __MINGW32__ --- relies on Int == Int32 on Windows -foreign import ccall unsafe "_getpid" getProcessID' :: IO Int -getProcessID :: IO Int -getProcessID = liftM abs getProcessID' -#else -getProcessID :: IO Int -#ifdef CYGWIN -getProcessID = System.Posix.Internals.c_getpid >>= return . abs . fromIntegral -#else -getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral -#endif -#endif - --- --------------------------------------------------------------------- --- | Use a variety of random functions, if you like. --- -getRandom :: () -> IO Int - -#ifndef HAVE_ARC4RANDOM -getRandom _ = getStdRandom (randomR (0,51)) -#else --- --- OpenBSD: "The arc4random() function provides a high quality 32-bit --- pseudo-random number very quickly. arc4random() seeds itself on a --- regular basis from the kernel strong random number subsystem --- described in random(4)." Also, it is a bit faster than getStdRandom --- -getRandom _ = do - (I32# i) <- c_arc4random - return (I# (word2Int# ((int2Word# i `and#` int2Word# 0xffff#) - `remWord#` int2Word# 52#))) - -foreign import ccall unsafe "stdlib.h arc4random" c_arc4random :: IO Int32 -#endif rmfile ./src/System/MkTemp.hs hunk ./src/System/Plugins/Utils.hs 64 -import qualified System.MkTemp ( mkstemps ) +-- import qualified System.MkTemp ( mkstemps ) hunk ./src/System/Plugins/Utils.hs 97 -mkstemps :: String -> Int -> IO (String,Handle) -mkstemps path slen = do - m_v <- System.MkTemp.mkstemps path slen - case m_v of Nothing -> error "mkstemps : couldn't create temp file" - Just v' -> return v' +-- mkstemps :: String -> Int -> IO (String,Handle) +-- mkstemps path slen = do +-- m_v <- System.MkTemp.mkstemps path slen +-- case m_v of Nothing -> error "mkstemps : couldn't create temp file" +-- Just v' -> return v' hunk ./src/System/Plugins/Utils.hs 127 - (tmpf,hdl) <- mkstemps (tmpd++"/MXXXXXXXXX.hs") 3 + -- XXX (tmpf,hdl) <- mkstemps (tmpd++"/MXXXXXXXXX.hs") 3 + + (tmpf, hdl) <- openTempFile tmpd "MXXXXX.hs" hunk ./plugins.cabal 2 -version: 1.5.1.2 +version: 1.5.1.3 hunk ./src/System/Plugins/Env.hs 61 -import Data.List ( nub ) +import Data.List ( (\\), nub, ) +import qualified Data.List as List hunk ./src/System/Plugins/Env.hs 303 - -- we add each package with and without it's version number - addOnePkg p fm' = addToPkgEnvs (addToPkgEnvs fm' (display $ sourcePackageId p) p) + -- we add each package with and without it's version number and with the full installedPackageId + addOnePkg p fm' = addToPkgEnvs (addToPkgEnvs (addToPkgEnvs fm' (display $ sourcePackageId p) p) (display $ installedPackageId p) p) hunk ./src/System/Plugins/Env.hs 365 -lookupPkg p = do +lookupPkg pn = go [] pn + where + go :: [PackageName] -> PackageName -> IO ([FilePath],[FilePath]) + go seen p = do hunk ./src/System/Plugins/Env.hs 371 - (f', g') <- liftM unzip $ mapM lookupPkg ps + (f', g') <- liftM unzip $ mapM (go (nub $ seen ++ ps)) (ps \\ seen) hunk ./plugins.cabal 2 -version: 1.5.1.3 +version: 1.5.1.4 hunk ./plugins.cabal 11 + hunk ./plugins.cabal 13 + hunk ./src/System/Plugins/Env.hs 62 -import qualified Data.List as List hunk ./src/System/Plugins/Load.hs 87 +#if !MIN_VERSION_ghc(7,2,0) hunk ./src/System/Plugins/Load.hs 89 +#endif hunk ./src/System/Plugins/Load.hs 104 +#if MIN_VERSION_ghc(7,2,0) + e <- newHscEnv undefined +#else hunk ./src/System/Plugins/Load.hs 108 +#endif hunk ./src/System/Plugins/Load.hs 688 +#if MIN_VERSION_ghc(7,2,0) + ps' <- filterM loaded . map packageIdString . nub $ map fst ps +#else hunk ./src/System/Plugins/Load.hs 692 +#endif hunk ./src/System/Plugins/Load.hs 91 +#if !MIN_VERSION_ghc(7,4,1) hunk ./src/System/Plugins/Load.hs 93 +#else +import GHC.Exts ( addrToAny# ) +#endif + hunk ./src/System/Plugins/Load.hs 459 +#if !MIN_VERSION_ghc(7,4,1) hunk ./src/System/Plugins/Load.hs 461 +#else + else case addrToAny# addr of +#endif hunk ./plugins.cabal 60 + if impl(ghc >= 7.2) + build-depends: ghc-paths + + hunk ./src/System/Plugins/Load.hs 89 +#else +import DynFlags (defaultDynFlags, initDynFlags) +import GHC.Paths (libdir) +import SysTools (initSysTools) hunk ./src/System/Plugins/Load.hs 114 - e <- newHscEnv undefined + mySettings <- initSysTools (Just libdir) -- how should we really set the top dir? + dflags <- initDynFlags (defaultDynFlags mySettings) + e <- newHscEnv dflags hunk ./configure 3 -# Generated by GNU Autoconf 2.59. +# Generated by GNU Autoconf 2.67. +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# hunk ./configure 11 -# Copyright (C) 2003 Free Software Foundation, Inc. hunk ./configure 13 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## hunk ./configure 17 -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : hunk ./configure 22 - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which hunk ./configure 25 -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac hunk ./configure 34 -DUALCASE=1; export DUALCASE # for MKS sh hunk ./configure 35 -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' hunk ./configure 53 - as_unset=false + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } hunk ./configure 84 -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 +IFS=$as_save_IFS + + ;; +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 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done hunk ./configure 128 -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 +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH hunk ./configure 186 - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." hunk ./configure 230 - $as_unset $as_var + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." hunk ./configure 235 -done + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append hunk ./configure 340 -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then hunk ./configure 381 -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then hunk ./configure 387 +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi hunk ./configure 393 -# Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || hunk ./configure 396 - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` hunk ./configure 412 - -# PATH needs CR, and LINENO needs CR and PATH. hunk ./configure 419 -# 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 hunk ./configure 420 - # 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 | + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | hunk ./configure 430 + s/[$]LINENO.*/&-/ + t lineno + b + :lineno hunk ./configure 435 - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ hunk ./configure 438 - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// hunk ./configure 440 - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } hunk ./configure 445 - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" hunk ./configure 451 - -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= ;; +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; hunk ./configure 464 -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file hunk ./configure 468 - as_expr=false + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null hunk ./configure 471 - -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 +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then hunk ./configure 474 + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' hunk ./configure 485 -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln hunk ./configure 488 -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null hunk ./configure 492 - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' hunk ./configure 498 -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x hunk ./configure 528 -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - +test -n "$DJDIR" || exec 7<&0 &1 hunk ./configure 532 -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, hunk ./configure 536 -exec 6>&1 - hunk ./configure 540 +ac_clean_files= hunk ./configure 542 +LIBOBJS= hunk ./configure 547 -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} hunk ./configure 554 +PACKAGE_URL= hunk ./configure 557 -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 build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL HASKELL_SRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' +ac_subst_vars='LTLIBOBJS +LIBOBJS +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +HASKELL_SRC +GLASGOW_HASKELL +GHC +TOP +PREFIX +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' hunk ./configure 617 +ac_user_opts=' +enable_option_checking +with_ghc +enable_debug +enable_hsx +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS' + hunk ./configure 636 +ac_unrecognized_opts= +ac_unrecognized_sep= hunk ./configure 660 +# (The list follows the same order as the GNU Coding Standards.) hunk ./configure 664 -datadir='${prefix}/share' +datarootdir='${prefix}/share' +datadir='${datarootdir}' hunk ./configure 669 -libdir='${exec_prefix}/lib' hunk ./configure 671 -infodir='${prefix}/info' -mandir='${prefix}/man' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' hunk ./configure 682 +ac_dashdash= hunk ./configure 687 - eval "$ac_prev=\$ac_option" + eval $ac_prev=\$ac_option hunk ./configure 692 - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac hunk ./configure 700 - case $ac_option in + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; hunk ./configure 724 - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + -datadir | --datadir | --datadi | --datad) hunk ./configure 726 - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) + -datadir=* | --datadir=* | --datadi=* | --datad=*) hunk ./configure 729 + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + hunk ./configure 737 - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` hunk ./configure 739 - 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" ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; hunk ./configure 763 - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` hunk ./configure 765 - 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 ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; hunk ./configure 776 - eval "enable_$ac_feature='$ac_optarg'" ;; + eval enable_$ac_useropt=\$ac_optarg ;; hunk ./configure 803 + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + hunk ./configure 833 + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + hunk ./configure 839 - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) + | --localstate | --localstat | --localsta | --localst | --locals) hunk ./configure 842 - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) hunk ./configure 907 + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + hunk ./configure 967 - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` hunk ./configure 969 - 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 ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; hunk ./configure 980 - eval "with_$ac_package='$ac_optarg'" ;; + eval with_$ac_useropt=\$ac_optarg ;; hunk ./configure 983 - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` hunk ./configure 985 - 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" ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; hunk ./configure 1016 - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" hunk ./configure 1023 - 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'" + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg hunk ./configure 1032 - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 hunk ./configure 1034 - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 hunk ./configure 1043 - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "missing argument to $ac_option" hunk ./configure 1046 -# 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; }; };; +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; hunk ./configure 1052 -done +fi hunk ./configure 1054 -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir hunk ./configure 1060 - eval ac_val=$`echo $ac_var` + eval ac_val=\$$ac_var + # Remove trailing slashes. hunk ./configure 1063 - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; hunk ./configure 1067 + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" hunk ./configure 1086 - 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 + $as_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 hunk ./configure 1099 +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + hunk ./configure 1110 - # 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'` + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` hunk ./configure 1135 - if test ! -r $srcdir/$ac_unique_file; then + if test ! -r "$srcdir/$ac_unique_file"; then hunk ./configure 1141 -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 +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. hunk ./configure 1153 -(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 +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done hunk ./configure 1187 - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages hunk ./configure 1193 -_ACEOF - - cat <<_ACEOF hunk ./configure 1195 - [$ac_default_prefix] + [$ac_default_prefix] hunk ./configure 1197 - [PREFIX] + [PREFIX] hunk ./configure 1207 - --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] + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --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] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] hunk ./configure 1240 + --disable-option-checking ignore unrecognized --enable/--with options hunk ./configure 1256 - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory hunk ./configure 1263 +Report bugs to the package provider. hunk ./configure 1265 +ac_status=$? hunk ./configure 1270 - ac_popdir=`pwd` hunk ./configure 1271 - test -d $ac_dir || continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue hunk ./configure 1276 -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 "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix hunk ./configure 1293 - .) # No --srcdir option. We are building in place. + .) # We are building in place. hunk ./configure 1295 - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. hunk ./configure 1299 - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; hunk ./configure 1306 +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix hunk ./configure 1308 -# 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 + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested 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 hunk ./configure 1317 - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd $ac_popdir + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } hunk ./configure 1323 -test -n "$ac_init_help" && exit 0 +test -n "$ac_init_help" && exit $ac_status hunk ./configure 1326 +configure +generated by GNU Autoconf 2.67 hunk ./configure 1329 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. hunk ./configure 1333 - exit 0 + exit hunk ./configure 1335 -exec 5>config.log -cat >&5 <<_ACEOF + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* 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_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_func +cat >config.log <<_ACEOF hunk ./configure 1495 -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was hunk ./configure 1500 +exec 5>>config.log hunk ./configure 1519 -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` hunk ./configure 1531 - echo "PATH: $as_dir" -done + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS hunk ./configure 1555 -ac_sep= hunk ./configure 1565 - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; hunk ./configure 1569 - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; hunk ./configure 1571 - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" hunk ./configure 1587 - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " + as_fn_append ac_configure_args " '$ac_arg'" hunk ./configure 1592 -$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; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} hunk ./configure 1598 -# 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. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. hunk ./configure 1605 - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## hunk ./configure 1607 -## ---------------- ## -_ASBOX +## ---------------- ##" hunk ./configure 1610 -{ +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done hunk ./configure 1627 - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) hunk ./configure 1630 - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( hunk ./configure 1634 - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" hunk ./configure 1636 - esac; -} + esac | + sort +) hunk ./configure 1641 - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## hunk ./configure 1643 -## ----------------- ## -_ASBOX +## ----------------- ##" hunk ./configure 1647 - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" hunk ./configure 1656 - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" hunk ./configure 1662 - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" hunk ./configure 1672 - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## hunk ./configure 1674 -## ----------- ## -_ASBOX +## ----------- ##" hunk ./configure 1676 - sed "/^$/d" confdefs.h | sort + cat confdefs.h hunk ./configure 1680 - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" hunk ./configure 1683 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && hunk ./configure 1686 - ' 0 +' 0 hunk ./configure 1688 - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal hunk ./configure 1693 -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h hunk ./configure 1703 - hunk ./configure 1707 - hunk ./configure 1711 - hunk ./configure 1715 - hunk ./configure 1719 +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + hunk ./configure 1725 -# 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 +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site hunk ./configure 1742 -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;} +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} hunk ./configure 1749 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5 ; } hunk ./configure 1758 - # 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;} + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} hunk ./configure 1764 - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; hunk ./configure 1769 - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} hunk ./configure 1777 -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do +for ac_var in $ac_precious_vars; do hunk ./configure 1780 - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value hunk ./configure 1784 - { 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;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} hunk ./configure 1788 - { 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;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} hunk ./configure 1794 - { 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=: + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} hunk ./configure 1815 - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; hunk ./configure 1820 - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; hunk ./configure 1825 - { 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; }; } + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 hunk ./configure 1831 +## -------------------- ## +## Main body of script. ## +## -------------------- ## hunk ./configure 1843 - - - - - - - - - - - - - - - - - hunk ./configure 1844 - ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers config.h" hunk ./configure 1852 -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then hunk ./configure 1857 - elif test -f $ac_dir/install.sh; then + elif test -f "$ac_dir/install.sh"; then hunk ./configure 1861 - elif test -f $ac_dir/shtool; then + elif test -f "$ac_dir/shtool"; then hunk ./configure 1868 - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 hunk ./configure 1870 -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. + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + hunk ./configure 1881 -$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; }; } +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 hunk ./configure 1884 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 1889 - 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; }; } + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 hunk ./configure 1898 -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; +esac hunk ./configure 1905 -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/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac hunk ./configure 1953 -cat >>confdefs.h <<\_ACEOF -#define __MINGW32__ 1 -_ACEOF +$as_echo "#define __MINGW32__ 1" >>confdefs.h hunk ./configure 1961 -cat >>confdefs.h <<\_ACEOF -#define CYGWIN 1 -_ACEOF +$as_echo "#define CYGWIN 1" >>confdefs.h hunk ./configure 1974 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` +TOP=`echo "System.Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` hunk ./configure 1987 -# Check whether --with-ghc or --without-ghc was given. -if test "${with_ghc+set}" = set; then - withval="$with_ghc" - GHC="$withval" +# Check whether --with-ghc was given. +if test "${with_ghc+set}" = set; then : + withval=$with_ghc; GHC="$withval" hunk ./configure 1991 - { { echo "$as_me:$LINENO: error: $GHC not found. You need GHC to build this project" >&5 -echo "$as_me: error: $GHC not found. You need GHC to build this project" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "$GHC not found. You need GHC to build this project" "$LINENO" 5 hunk ./configure 1997 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_GHC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_GHC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2010 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2013 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2017 -done + done +IFS=$as_save_IFS hunk ./configure 2024 - echo "$as_me:$LINENO: result: $GHC" >&5 -echo "${ECHO_T}$GHC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GHC" >&5 +$as_echo "$GHC" >&6; } hunk ./configure 2027 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2031 + hunk ./configure 2033 - { { echo "$as_me:$LINENO: error: You need GHC to build this project" >&5 -echo "$as_me: error: You need GHC to build this project" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You need GHC to build this project" "$LINENO" 5 hunk ./configure 2037 -fi; +fi + hunk ./configure 2048 - echo "$as_me:$LINENO: checking for value of __GLASGOW_HASKELL__" >&5 -echo $ECHO_N "checking for value of __GLASGOW_HASKELL__... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for value of __GLASGOW_HASKELL__" >&5 +$as_echo_n "checking for value of __GLASGOW_HASKELL__... " >&6; } hunk ./configure 2053 - echo "$as_me:$LINENO: result: $GLASGOW_HASKELL" >&5 -echo "${ECHO_T}$GLASGOW_HASKELL" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GLASGOW_HASKELL" >&5 +$as_echo "$GLASGOW_HASKELL" >&6; } hunk ./configure 2060 - echo "$as_me:$LINENO: checking for ghc library directory" >&5 -echo $ECHO_N "checking for ghc library directory... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ghc library directory" >&5 +$as_echo_n "checking for ghc library directory... " >&6; } hunk ./configure 2063 - echo "$as_me:$LINENO: result: $GHC_LIB_PATH" >&5 -echo "${ECHO_T}$GHC_LIB_PATH" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GHC_LIB_PATH" >&5 +$as_echo "$GHC_LIB_PATH" >&6; } hunk ./configure 2073 -# Check whether --enable-debug or --disable-debug was given. -if test "${enable_debug+set}" = set; then - enableval="$enable_debug" - +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; hunk ./configure 2083 -fi; +fi + hunk ./configure 2087 -# Check whether --enable-hsx or --disable-hsx was given. -if test "${enable_hsx+set}" = set; then - enableval="$enable_hsx" - HASKELL_SRC=haskell-src-exts ; +# Check whether --enable-hsx was given. +if test "${enable_hsx+set}" = set; then : + enableval=$enable_hsx; HASKELL_SRC=haskell-src-exts ; hunk ./configure 2097 -fi; +fi + hunk ./configure 2120 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2133 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2136 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2140 -done + done +IFS=$as_save_IFS hunk ./configure 2147 - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } hunk ./configure 2150 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2154 + hunk ./configure 2160 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2173 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2176 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2180 -done + done +IFS=$as_save_IFS hunk ./configure 2187 - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } hunk ./configure 2190 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2194 - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi hunk ./configure 2210 - 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. + 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. hunk ./configure 2213 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2226 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2229 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2233 -done + done +IFS=$as_save_IFS hunk ./configure 2240 - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } hunk ./configure 2243 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2247 -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 hunk ./configure 2248 + fi hunk ./configure 2253 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2267 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2274 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2278 -done + done +IFS=$as_save_IFS hunk ./configure 2297 - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } hunk ./configure 2300 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2304 + hunk ./configure 2308 - for ac_prog in cl + for ac_prog in cl.exe hunk ./configure 2312 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2325 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2328 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2332 -done + done +IFS=$as_save_IFS hunk ./configure 2339 - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } hunk ./configure 2342 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2346 + hunk ./configure 2352 - for ac_prog in cl + for ac_prog in cl.exe hunk ./configure 2356 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2369 - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then hunk ./configure 2372 - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 hunk ./configure 2376 -done + done +IFS=$as_save_IFS hunk ./configure 2383 - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } hunk ./configure 2386 - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } hunk ./configure 2390 + hunk ./configure 2394 - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi hunk ./configure 2410 -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; }; } +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5 ; } hunk ./configure 2416 -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 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err hunk ./configure 2429 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done hunk ./configure 2440 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext hunk ./configure 2452 -ac_clean_files="$ac_clean_files a.out a.exe b.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" hunk ./configure 2456 -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. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" hunk ./configure 2463 -# 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 +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' hunk ./configure 2493 - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) hunk ./configure 2500 - 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 + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. hunk ./configure 2514 +test "$ac_cv_exeext" = no && ac_cv_exeext= + hunk ./configure 2517 - echo "$as_me: failed program was:" >&5 + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 hunk ./configure 2525 -{ { 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; }; } +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } hunk ./configure 2533 - +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } hunk ./configure 2538 -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 hunk ./configure 2539 -# 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 +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out hunk ./configure 2541 -# 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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 hunk ./configure 2552 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : hunk ./configure 2561 - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; hunk ./configure 2563 - export ac_cv_exeext hunk ./configure 2568 - { { 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; }; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5 ; } hunk ./configure 2573 - -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 conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } hunk ./configure 2580 -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. */ +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} hunk ./configure 2593 -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5 ; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext hunk ./configure 2656 -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 hunk ./configure 2665 - 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 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; hunk ./configure 2670 - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; hunk ./configure 2676 - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 hunk ./configure 2679 -{ { 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; }; } +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } hunk ./configure 2684 - hunk ./configure 2686 -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } hunk ./configure 2690 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2695 - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext hunk ./configure 2709 -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 ac_fn_c_try_compile "$LINENO"; then : hunk ./configure 2712 - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no + ac_compiler_gnu=no hunk ./configure 2714 -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext hunk ./configure 2718 -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` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi hunk ./configure 2727 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2732 - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext hunk ./configure 2747 -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 ac_fn_c_try_compile "$LINENO"; then : hunk ./configure 2750 - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ hunk ./configure 2754 -ac_cv_prog_cc_g=no +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext hunk ./configure 2785 -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag hunk ./configure 2788 -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } hunk ./configure 2805 -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 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2810 - ac_cv_prog_cc_stdc=no + ac_cv_prog_cc_c89=no hunk ./configure 2812 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext hunk ./configure 2840 - as 'x'. The following induces an error, until -std1 is added to get + as 'x'. The following induces an error, until -std is added to get hunk ./configure 2843 - that's true only with -std1. */ + that's true only with -std. */ hunk ./configure 2846 +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + hunk ./configure 2865 -# 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__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" hunk ./configure 2869 - 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 - + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg hunk ./configure 2872 -rm -f conftest.err conftest.$ac_objext +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break hunk ./configure 2875 -rm -f conftest.$ac_ext conftest.$ac_objext +rm -f conftest.$ac_ext hunk ./configure 2879 - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; hunk ./configure 2888 - 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" ;; + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; hunk ./configure 2892 - -# 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 +if test "x$ac_cv_prog_cc_c89" != xno; then : hunk ./configure 2895 -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 hunk ./configure 2896 -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext hunk ./configure 2903 - hunk ./configure 2904 -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+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 $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* 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 $ac_func (); -/* 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_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - 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 - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then +do : + ac_fn_c_check_func "$LINENO" "arc4random" "ac_cv_func_arc4random" +if test "x$ac_cv_func_arc4random" = x""yes; then : hunk ./configure 2908 -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define HAVE_ARC4RANDOM 1 hunk ./configure 2928 -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } hunk ./configure 2932 -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +if test "${ac_cv_path_install+set}" = set; then : + $as_echo_n "(cached) " >&6 hunk ./configure 2940 - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ hunk ./configure 2944 - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ hunk ./configure 2952 - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then hunk ./configure 2962 - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi hunk ./configure 2980 -done hunk ./configure 2981 + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir hunk ./configure 2990 - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will hunk ./configure 2993 - # removed, or if the path is relative. + # removed, or if the value is a relative name. hunk ./configure 2997 -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } hunk ./configure 3010 - ac_config_files="$ac_config_files config.mk testsuite/makewith/io/TestIO.conf testsuite/makewith/unsafeio/Unsafe.conf" +ac_config_files="$ac_config_files config.mk testsuite/makewith/io/TestIO.conf testsuite/makewith/unsafeio/Unsafe.conf" hunk ./configure 3030 -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. hunk ./configure 3033 -{ +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + hunk ./configure 3051 - 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 \). + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. hunk ./configure 3058 - ;; + ;; #( hunk ./configure 3061 - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" hunk ./configure 3063 - esac; -} | + esac | + sort +) | hunk ./configure 3067 + /^ac_cv_env_/b end hunk ./configure 3069 - : clear + :clear hunk ./configure 3072 - /^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" + 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" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} hunk ./configure 3081 - echo "not updating unwritable cache $cache_file" + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} hunk ./configure 3091 -# 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 - hunk ./configure 3095 +U= hunk ./configure 3098 - 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' + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' hunk ./configure 3112 +ac_write_fail=0 hunk ./configure 3115 -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 hunk ./configure 3128 -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF hunk ./configure 3129 -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## hunk ./configure 3137 -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : hunk ./configure 3142 - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which hunk ./configure 3145 -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac hunk ./configure 3154 -DUALCASE=1; export DUALCASE # for MKS sh hunk ./configure 3155 -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' hunk ./configure 3173 - as_unset=false + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' hunk ./configure 3194 +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi hunk ./configure 3203 -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 +IFS=$as_save_IFS + + ;; +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 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done hunk ./configure 3248 -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 +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 hunk ./configure 3269 -done + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit hunk ./configure 3292 -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then hunk ./configure 3343 -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then hunk ./configure 3349 +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi hunk ./configure 3355 -# Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || hunk ./configure 3358 - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` hunk ./configure 3374 -# PATH needs CR, and LINENO needs CR and PATH. hunk ./configure 3381 -# 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= ;; +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; hunk ./configure 3394 -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file hunk ./configure 3398 - as_expr=false + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null hunk ./configure 3401 - -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 +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then hunk ./configure 3404 + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' hunk ./configure 3415 -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln hunk ./configure 3418 -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ hunk ./configure 3428 + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p hunk ./configure 3470 - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' hunk ./configure 3476 -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x hunk ./configure 3506 -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - hunk ./configure 3507 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 hunk ./configure 3513 -# Open the log real soon, to keep \$[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to hunk ./configure 3516 -# 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 - +# values after options handling. +ac_log=" hunk ./configure 3519 -generated by GNU Autoconf 2.59. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was hunk ./configure 3527 -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + hunk ./configure 3532 -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac hunk ./configure 3536 -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac hunk ./configure 3540 -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi hunk ./configure 3541 -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" hunk ./configure 3546 -cat >>$CONFIG_STATUS <<\_ACEOF +_ACEOF hunk ./configure 3548 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 hunk ./configure 3550 -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. hunk ./configure 3554 -Usage: $0 [OPTIONS] [FILE]... +Usage: $0 [OPTION]... [TAG]... hunk ./configure 3557 - -V, --version print version number, then exit - -q, --quiet do not print progress messages + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages hunk ./configure 3563 - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE hunk ./configure 3574 -Report bugs to ." -_ACEOF +Report bugs to the package provider." hunk ./configure 3576 -cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" hunk ./configure 3581 -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.67, + with options \\"\$ac_cs_config\\" hunk ./configure 3584 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. hunk ./configure 3587 -srcdir=$srcdir -INSTALL="$INSTALL" + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk hunk ./configure 3594 -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. +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. hunk ./configure 3600 - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` hunk ./configure 3605 - -*) + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) hunk ./configure 3615 - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; hunk ./configure 3619 -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF hunk ./configure 3621 - --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 ) + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) hunk ./configure 3629 - CONFIG_FILES="$CONFIG_FILES $ac_optarg" + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" hunk ./configure 3637 - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" hunk ./configure 3642 + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; hunk ./configure 3653 - -*) { { 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; }; } ;; + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; hunk ./configure 3656 - *) ac_config_targets="$ac_config_targets $1" ;; + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; hunk ./configure 3671 -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 hunk ./configure 3673 - 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 + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" hunk ./configure 3682 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 hunk ./configure 3692 +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF hunk ./configure 3696 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 hunk ./configure 3698 - - -cat >>$CONFIG_STATUS <<\_ACEOF +# Handling of arguments. hunk ./configure 3701 - case "$ac_config_target" in - # Handling of arguments. - "config.mk" ) CONFIG_FILES="$CONFIG_FILES config.mk" ;; - "testsuite/makewith/io/TestIO.conf" ) CONFIG_FILES="$CONFIG_FILES testsuite/makewith/io/TestIO.conf" ;; - "testsuite/makewith/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES testsuite/makewith/unsafeio/Unsafe.conf" ;; - "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.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; }; };; + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "config.mk") CONFIG_FILES="$CONFIG_FILES config.mk" ;; + "testsuite/makewith/io/TestIO.conf") CONFIG_FILES="$CONFIG_FILES testsuite/makewith/io/TestIO.conf" ;; + "testsuite/makewith/unsafeio/Unsafe.conf") CONFIG_FILES="$CONFIG_FILES testsuite/makewith/unsafeio/Unsafe.conf" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; hunk ./configure 3711 + hunk ./configure 3722 -# simply because there is no reason to put it here, and in addition, +# simply because there is no reason against having it here, and in addition, hunk ./configure 3724 -# Create a temporary directory, and hook for its removal unless debugging. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. hunk ./configure 3729 - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 hunk ./configure 3735 - hunk ./configure 3738 - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && hunk ./configure 3742 - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + hunk ./configure 3771 - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 hunk ./configure 3782 + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && hunk ./configure 3796 +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" hunk ./configure 3846 -cat >>$CONFIG_STATUS <<_ACEOF +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } hunk ./configure 3864 -# -# CONFIG_FILES section. -# + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries 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[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi hunk ./configure 3901 -# 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,@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,@PREFIX@,$PREFIX,;t t -s,@TOP@,$TOP,;t t -s,@GHC@,$GHC,;t t -s,@GLASGOW_HASKELL@,$GLASGOW_HASKELL,;t t -s,@HASKELL_SRC@,$HASKELL_SRC,;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,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" hunk ./configure 3904 +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { hunk ./configure 3912 - 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 +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " hunk ./configure 3928 -fi # test -n "$CONFIG_FILES" +done hunk ./configure 3930 +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #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. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK hunk ./configure 4008 -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 ;; +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; hunk ./configure 4020 + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift hunk ./configure 4034 - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # 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. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || hunk ./configure 4086 - 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; }; }; } - + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p hunk ./configure 4108 -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 "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix hunk ./configure 4125 - .) # No --srcdir option. We are building in place. + .) # We are building in place. hunk ./configure 4127 - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. hunk ./configure 4131 - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; hunk ./configure 4138 +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix hunk ./configure 4140 -# 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 hunk ./configure 4141 + case $ac_mode in + :F) + # + # CONFIG_FILE + # hunk ./configure 4149 - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; hunk ./configure 4151 +_ACEOF hunk ./configure 4153 - 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; } +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac hunk ./configure 4183 -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub hunk ./configure 4191 -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 hunk ./configure 4194 -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 -s,@INSTALL@,$ac_INSTALL,;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 +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;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&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 hunk ./configure 4210 -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} hunk ./configure 4218 -# -# 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". + rm -f "$tmp/stdin" hunk ./configure 4220 - - | *:- | *:-:* ) # 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 + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # hunk ./configure 4230 - 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;} + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} hunk ./configure 4239 - 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 + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 hunk ./configure 4244 - cat $tmp/config.h - rm -f $tmp/config.h + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 hunk ./configure 4248 -done -_ACEOF + ;; + + + esac hunk ./configure 4253 -cat >>$CONFIG_STATUS <<\_ACEOF +done # for ac_tag hunk ./configure 4255 -{ (exit 0); exit 0; } + +as_fn_exit 0 hunk ./configure 4258 -chmod +x $CONFIG_STATUS hunk ./configure 4260 +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + hunk ./configure 4282 - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} hunk ./configure.ac 66 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` +TOP=`echo "System.Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` hunk ./src/System/Plugins/Utils.hs 1 -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP, ScopedTypeVariables #-} hunk ./src/System/Plugins/Utils.hs 66 +import Control.Exception (IOException, catch) hunk ./src/System/Plugins/Utils.hs 69 +import Prelude hiding (catch) hunk ./src/System/Plugins/Utils.hs 124 -mkTemp = do tmpd <- catch (getEnv "TMPDIR") (\_ -> return tmpDir) +mkTemp = do tmpd <- catch (getEnv "TMPDIR") (\ (_ :: IOException) -> return tmpDir)