From d068332b8864cc1f39f23b471281d9e91f2743f4 Mon Sep 17 00:00:00 2001 From: CattySteve Date: Wed, 26 Mar 2025 09:29:24 +0800 Subject: [PATCH] feat: initial commit Code is from cxx.uclibc.org, modified by catty to implement c++17 features --- .gitignore | 41 + BugFinders | 111 + ChangeLog | 319 ++ DOCUMENTATION | 37 + INSTALL | 36 + Makefile | 7 + Makefile.end | 44 + Makefile.in | 129 + README | 32 + Rules.mak | 596 ++++ TODO | 26 + bin/Makefile | 6 + bin/Makefile.in | 57 + extra/Configs/Config.default | 2 + extra/Configs/Config.in | 380 +++ extra/Configs/Config.in.arch | 54 + extra/Makefile | 28 + extra/Makefile.in | 3 + extra/config/.gitignore | 19 + extra/config/Kconfig-language.txt | 282 ++ extra/config/Makefile | 128 + extra/config/checklist.c | 363 +++ extra/config/colors.h | 161 + extra/config/conf.c | 566 ++++ extra/config/confdata.c | 435 +++ extra/config/dialog.h | 196 ++ extra/config/expr.c | 1083 +++++++ extra/config/expr.h | 194 ++ extra/config/inputbox.c | 240 ++ extra/config/lex.zconf.c_shipped | 3688 +++++++++++++++++++++ extra/config/lkc.h | 113 + extra/config/lkc_proto.h | 39 + extra/config/mconf.c | 703 ++++ extra/config/menu.c | 396 +++ extra/config/menubox.c | 436 +++ extra/config/msgbox.c | 85 + extra/config/symbol.c | 763 +++++ extra/config/textbox.c | 556 ++++ extra/config/util.c | 375 +++ extra/config/yesno.c | 118 + extra/config/zconf.l | 366 +++ extra/config/zconf.tab.c_shipped | 2127 ++++++++++++ extra/config/zconf.tab.h_shipped | 125 + extra/config/zconf.y | 687 ++++ extra/libstrip/libstrip | 72 + extra/locale/LOCALES | 258 ++ extra/locale/Makefile | 95 + extra/locale/README | 71 + extra/locale/charmaps/ARMSCII-8.pairs | 254 ++ extra/locale/charmaps/ASCII.pairs | 128 + extra/locale/charmaps/CP1251.pairs | 255 ++ extra/locale/charmaps/CP1255.pairs | 233 ++ extra/locale/charmaps/GEORGIAN-PS.pairs | 256 ++ extra/locale/charmaps/ISO-8859-1.pairs | 256 ++ extra/locale/charmaps/ISO-8859-10.pairs | 256 ++ extra/locale/charmaps/ISO-8859-13.pairs | 256 ++ extra/locale/charmaps/ISO-8859-14.pairs | 256 ++ extra/locale/charmaps/ISO-8859-15.pairs | 256 ++ extra/locale/charmaps/ISO-8859-16.pairs | 256 ++ extra/locale/charmaps/ISO-8859-2.pairs | 256 ++ extra/locale/charmaps/ISO-8859-3.pairs | 249 ++ extra/locale/charmaps/ISO-8859-4.pairs | 256 ++ extra/locale/charmaps/ISO-8859-5.pairs | 256 ++ extra/locale/charmaps/ISO-8859-6.pairs | 211 ++ extra/locale/charmaps/ISO-8859-7.pairs | 250 ++ extra/locale/charmaps/ISO-8859-8.pairs | 220 ++ extra/locale/charmaps/ISO-8859-9.pairs | 256 ++ extra/locale/charmaps/KOI8-R.pairs | 256 ++ extra/locale/charmaps/KOI8-T.pairs | 237 ++ extra/locale/charmaps/KOI8-U.pairs | 256 ++ extra/locale/charmaps/TIS-620.pairs | 215 ++ extra/locale/collation/af_ZA | 1 + extra/locale/collation/am_ET | 26 + extra/locale/collation/ar_AE | 4 + extra/locale/collation/ar_BH | 4 + extra/locale/collation/ar_DZ | 4 + extra/locale/collation/ar_EG | 4 + extra/locale/collation/ar_IN | 3 + extra/locale/collation/ar_IQ | 4 + extra/locale/collation/ar_JO | 4 + extra/locale/collation/ar_KW | 4 + extra/locale/collation/ar_LB | 4 + extra/locale/collation/ar_LY | 4 + extra/locale/collation/ar_MA | 4 + extra/locale/collation/ar_OM | 4 + extra/locale/collation/ar_QA | 4 + extra/locale/collation/ar_SA | 220 ++ extra/locale/collation/ar_SD | 4 + extra/locale/collation/ar_SY | 4 + extra/locale/collation/ar_TN | 4 + extra/locale/collation/ar_YE | 4 + extra/locale/collation/az_AZ | 137 + extra/locale/collation/be_BY | 15 + extra/locale/collation/bg_BG | 106 + extra/locale/collation/bn_BD | 2 + extra/locale/collation/bn_IN | 4 + extra/locale/collation/br_FR | 40 + extra/locale/collation/bs_BA | 91 + extra/locale/collation/comm | 1872 +++++++++++ extra/locale/collation/cy_GB | 136 + extra/locale/collation/de_AT | 2 + extra/locale/collation/de_BE | 1 + extra/locale/collation/de_CH | 1 + extra/locale/collation/de_DE | 4 + extra/locale/collation/de_LU | 1 + extra/locale/collation/el_GR | 1 + extra/locale/collation/en_AU | 1 + extra/locale/collation/en_BW | 1 + extra/locale/collation/en_CA | 2061 ++++++++++++ extra/locale/collation/en_DK | 1 + extra/locale/collation/en_GB | 2 + extra/locale/collation/en_HK | 1 + extra/locale/collation/en_IE | 1 + extra/locale/collation/en_IN | 4 + extra/locale/collation/en_NZ | 1 + extra/locale/collation/en_PH | 4 + extra/locale/collation/en_SG | 4 + extra/locale/collation/en_US | 4 + extra/locale/collation/en_ZA | 1 + extra/locale/collation/en_ZW | 1 + extra/locale/collation/eo_EO | 49 + extra/locale/collation/eu_ES | 1 + extra/locale/collation/fa_IR | 185 ++ extra/locale/collation/fo_FO | 1 + extra/locale/collation/fr_BE | 1 + extra/locale/collation/fr_CA | 1 + extra/locale/collation/fr_CH | 1 + extra/locale/collation/fr_FR | 2 + extra/locale/collation/fr_LU | 1 + extra/locale/collation/ga_IE | 1 + extra/locale/collation/gd_GB | 1 + extra/locale/collation/gl_ES | 1 + extra/locale/collation/gv_GB | 1 + extra/locale/collation/he_IL | 1 + extra/locale/collation/hi_IN | 4 + extra/locale/collation/hu_HU | 357 ++ extra/locale/collation/hy_AM | 91 + extra/locale/collation/id_ID | 1 + extra/locale/collation/iso14651_t1 | 1495 +++++++++ extra/locale/collation/it_CH | 1 + extra/locale/collation/it_IT | 1 + extra/locale/collation/iw_IL | 1 + extra/locale/collation/ka_GE | 1 + extra/locale/collation/kl_GL | 1 + extra/locale/collation/kw_GB | 1 + extra/locale/collation/mi_NZ | 44 + extra/locale/collation/mk_MK | 1 + extra/locale/collation/mr_IN | 4 + extra/locale/collation/ms_MY | 4 + extra/locale/collation/mt_MT | 80 + extra/locale/collation/nl_BE | 1 + extra/locale/collation/nl_NL | 1 + extra/locale/collation/nn_NO | 4 + extra/locale/collation/oc_FR | 1 + extra/locale/collation/pt_BR | 1 + extra/locale/collation/pt_PT | 1 + extra/locale/collation/ro_RO | 54 + extra/locale/collation/ru_RU | 15 + extra/locale/collation/ru_UA | 15 + extra/locale/collation/se_NO | 149 + extra/locale/collation/sk_SK | 1 + extra/locale/collation/sq_AL | 4 + extra/locale/collation/sr_YU | 90 + extra/locale/collation/sv_FI | 1 + extra/locale/collation/sv_SE | 51 + extra/locale/collation/ta_IN | 4 + extra/locale/collation/te_IN | 4 + extra/locale/collation/tg_TJ | 63 + extra/locale/collation/th_TH | 746 +++++ extra/locale/collation/ti_ER | 1 + extra/locale/collation/ti_ET | 1 + extra/locale/collation/tl_PH | 30 + extra/locale/collation/tt_RU | 162 + extra/locale/collation/uk_UA | 15 + extra/locale/collation/ur_PK | 1 + extra/locale/collation/uz_UZ | 28 + extra/locale/collation/vi_VN | 4 + extra/locale/collation/wa_BE | 1 + extra/locale/collation/yi_US | 43 + extra/locale/gen_collate.c | 3940 +++++++++++++++++++++++ extra/locale/gen_ldc.c | 295 ++ extra/locale/gen_locale.c | 1319 ++++++++ extra/locale/gen_mmap.c | 237 ++ extra/locale/gen_wc8bit.c | 710 ++++ extra/locale/gen_wctype.c | 870 +++++ extra/locale/lmmtolso.c | 72 + extra/locale/locale_mmap.h | 93 + extra/locale/tst_nl_langinfo.c | 298 ++ include/Makefile | 5 + include/Makefile.in | 7 + include/algorithm | 1695 ++++++++++ include/array | 191 ++ include/associative_base | 639 ++++ include/basic_definitions | 89 + include/bitset | 423 +++ include/cassert | 19 + include/cctype | 37 + include/cerrno | 19 + include/cfloat | 30 + include/char_traits | 198 ++ include/cinttypes | 42 + include/climits | 28 + include/clocale | 30 + include/cmath | 234 ++ include/complex | 327 ++ include/csetjmp | 44 + include/csignal | 61 + include/cstdarg | 60 + include/cstddef | 58 + include/cstdint | 111 + include/cstdio | 80 + include/cstdlib | 71 + include/cstring | 77 + include/ctime | 81 + include/cwchar | 86 + include/cwctype | 106 + include/deque | 884 +++++ include/exception | 120 + include/fstream | 677 ++++ include/func_exception | 41 + include/functional | 439 +++ include/iomanip | 170 + include/ios | 503 +++ include/iosfwd | 114 + include/iostream | 101 + include/istream | 631 ++++ include/istream_helpers | 428 +++ include/iterator | 229 ++ include/iterator_base | 305 ++ include/limits | 663 ++++ include/list | 926 ++++++ include/locale | 83 + include/map | 264 ++ include/memory | 196 ++ include/new | 70 + include/numeric | 161 + include/ostream | 522 +++ include/ostream_helpers | 490 +++ include/queue | 126 + include/set | 406 +++ include/sstream | 384 +++ include/stack | 84 + include/stdexcept | 117 + include/streambuf | 329 ++ include/string | 1043 ++++++ include/string_iostream | 146 + include/support | 165 + include/type_traits | 92 + include/typeinfo | 156 + include/unwind-cxx.h | 247 ++ include/utility | 88 + include/valarray | 1042 ++++++ include/vector | 517 +++ scripts/find_libgcc_eh.sh | 9 + scripts/find_libsupc.sh | 9 + src/Makefile | 6 + src/Makefile.in | 58 + src/abi/abi.cpp | 39 + src/abi/libgcc_eh/Makefile | 4 + src/abi/libgcc_eh/Makefile.in | 24 + src/abi/libsupc/Makefile | 4 + src/abi/libsupc/Makefile.in | 24 + src/algorithm.cpp | 30 + src/array.cpp | 0 src/associative_base.cpp | 26 + src/bitset.cpp | 26 + src/char_traits.cpp | 69 + src/complex.cpp | 28 + src/del_op.cpp | 26 + src/del_opnt.cpp | 28 + src/del_ops.cpp | 27 + src/del_opv.cpp | 26 + src/del_opvnt.cpp | 28 + src/del_opvs.cpp | 27 + src/deque.cpp | 42 + src/eh_alloc.cpp | 65 + src/eh_globals.cpp | 42 + src/exception.cpp | 52 + src/fstream.cpp | 174 + src/func_exception.cpp | 87 + src/iomanip.cpp | 29 + src/ios.cpp | 189 ++ src/iostream.cpp | 38 + src/istream.cpp | 75 + src/iterator.cpp | 28 + src/limits.cpp | 25 + src/list.cpp | 29 + src/locale.cpp | 29 + src/map.cpp | 33 + src/new_handler.cpp | 31 + src/new_op.cpp | 36 + src/new_opnt.cpp | 28 + src/new_opv.cpp | 35 + src/new_opvnt.cpp | 28 + src/numeric.cpp | 27 + src/ostream.cpp | 65 + src/queue.cpp | 27 + src/set.cpp | 33 + src/sstream.cpp | 59 + src/stack.cpp | 27 + src/stdexcept.cpp | 63 + src/streambuf.cpp | 49 + src/string.cpp | 112 + src/support.cpp | 53 + src/typeinfo.cpp | 34 + src/utility.cpp | 30 + src/valarray.cpp | 29 + src/vector.cpp | 83 + tests/.gitignore | 42 + tests/Makefile | 7 + tests/Makefile.in | 47 + tests/algotest.cpp | 631 ++++ tests/bitsettest.cpp | 80 + tests/chartraitstest.cpp | 177 + tests/combotest.cpp | 63 + tests/dequetest.cpp | 267 ++ tests/excepttest.cpp | 52 + tests/fstreamtest.cpp | 150 + tests/functionaltest.cpp | 408 +++ tests/ioexceptiontest.cpp | 42 + tests/iotest.cpp | 150 + tests/listtest.cpp | 527 +++ tests/maptest.cpp | 351 ++ tests/memorytest.cpp | 60 + tests/mmaptest.cpp | 230 ++ tests/newdeltest.cpp | 94 + tests/numerictest.cpp | 60 + tests/settest.cpp | 342 ++ tests/sstreamtest.cpp | 204 ++ tests/stacktest.cpp | 71 + tests/streambuftest.cpp | 18 + tests/streamitertest.cpp | 21 + tests/stringtest.cpp | 553 ++++ tests/testframework.cpp | 40 + tests/testframework.h | 62 + tests/testoutput/Makefile.in | 7 + tests/testoutput/algotest.good | 6 + tests/testoutput/bitsettest.good | 14 + tests/testoutput/chartraitstest.good | 23 + tests/testoutput/combotest.good | 6 + tests/testoutput/dequetest.good | 94 + tests/testoutput/excepttest.good | 9 + tests/testoutput/fstreamtest.good | 290 ++ tests/testoutput/fstreamtest.input | Bin 0 -> 272 bytes tests/testoutput/functionaltest.good | 50 + tests/testoutput/ioexceptiontest.good | 6 + tests/testoutput/iotest.good | 40 + tests/testoutput/iotest.input | 2 + tests/testoutput/listtest.good | 128 + tests/testoutput/maptest.good | 70 + tests/testoutput/memorytest.good | 10 + tests/testoutput/mmaptest.good | 20 + tests/testoutput/newdeltest.good | 29 + tests/testoutput/runtests.sh | 54 + tests/testoutput/settest.good | 61 + tests/testoutput/sstreamtest.good | 67 + tests/testoutput/stacktest.good | 6 + tests/testoutput/streambuftest.good | 22 + tests/testoutput/streambuftest.input | 1 + tests/testoutput/stringtest.good | 15 + tests/testoutput/stringtest.input | 2 + tests/testoutput/utilitytest.good | 5 + tests/testoutput/valarraytest.good | 72 + tests/testoutput/vectortest.good | 115 + tests/testoutput/wchartest.good | 5 + tests/testoutput/wchartest.input | 2 + tests/utilitytest.cpp | 241 ++ tests/valarraytest.cpp | 186 ++ tests/vectortest.cpp | 244 ++ tests/wchartest.cpp | 24 + 370 files changed, 65488 insertions(+) create mode 100644 .gitignore create mode 100644 BugFinders create mode 100644 ChangeLog create mode 100644 DOCUMENTATION create mode 100644 INSTALL create mode 100644 Makefile create mode 100644 Makefile.end create mode 100644 Makefile.in create mode 100644 README create mode 100644 Rules.mak create mode 100644 TODO create mode 100644 bin/Makefile create mode 100644 bin/Makefile.in create mode 100644 extra/Configs/Config.default create mode 100644 extra/Configs/Config.in create mode 100644 extra/Configs/Config.in.arch create mode 100644 extra/Makefile create mode 100644 extra/Makefile.in create mode 100644 extra/config/.gitignore create mode 100644 extra/config/Kconfig-language.txt create mode 100644 extra/config/Makefile create mode 100644 extra/config/checklist.c create mode 100644 extra/config/colors.h create mode 100644 extra/config/conf.c create mode 100644 extra/config/confdata.c create mode 100644 extra/config/dialog.h create mode 100644 extra/config/expr.c create mode 100644 extra/config/expr.h create mode 100644 extra/config/inputbox.c create mode 100644 extra/config/lex.zconf.c_shipped create mode 100644 extra/config/lkc.h create mode 100644 extra/config/lkc_proto.h create mode 100644 extra/config/mconf.c create mode 100644 extra/config/menu.c create mode 100644 extra/config/menubox.c create mode 100644 extra/config/msgbox.c create mode 100644 extra/config/symbol.c create mode 100644 extra/config/textbox.c create mode 100644 extra/config/util.c create mode 100644 extra/config/yesno.c create mode 100644 extra/config/zconf.l create mode 100644 extra/config/zconf.tab.c_shipped create mode 100644 extra/config/zconf.tab.h_shipped create mode 100644 extra/config/zconf.y create mode 100755 extra/libstrip/libstrip create mode 100644 extra/locale/LOCALES create mode 100644 extra/locale/Makefile create mode 100644 extra/locale/README create mode 100644 extra/locale/charmaps/ARMSCII-8.pairs create mode 100644 extra/locale/charmaps/ASCII.pairs create mode 100644 extra/locale/charmaps/CP1251.pairs create mode 100644 extra/locale/charmaps/CP1255.pairs create mode 100644 extra/locale/charmaps/GEORGIAN-PS.pairs create mode 100644 extra/locale/charmaps/ISO-8859-1.pairs create mode 100644 extra/locale/charmaps/ISO-8859-10.pairs create mode 100644 extra/locale/charmaps/ISO-8859-13.pairs create mode 100644 extra/locale/charmaps/ISO-8859-14.pairs create mode 100644 extra/locale/charmaps/ISO-8859-15.pairs create mode 100644 extra/locale/charmaps/ISO-8859-16.pairs create mode 100644 extra/locale/charmaps/ISO-8859-2.pairs create mode 100644 extra/locale/charmaps/ISO-8859-3.pairs create mode 100644 extra/locale/charmaps/ISO-8859-4.pairs create mode 100644 extra/locale/charmaps/ISO-8859-5.pairs create mode 100644 extra/locale/charmaps/ISO-8859-6.pairs create mode 100644 extra/locale/charmaps/ISO-8859-7.pairs create mode 100644 extra/locale/charmaps/ISO-8859-8.pairs create mode 100644 extra/locale/charmaps/ISO-8859-9.pairs create mode 100644 extra/locale/charmaps/KOI8-R.pairs create mode 100644 extra/locale/charmaps/KOI8-T.pairs create mode 100644 extra/locale/charmaps/KOI8-U.pairs create mode 100644 extra/locale/charmaps/TIS-620.pairs create mode 100644 extra/locale/collation/af_ZA create mode 100644 extra/locale/collation/am_ET create mode 100644 extra/locale/collation/ar_AE create mode 100644 extra/locale/collation/ar_BH create mode 100644 extra/locale/collation/ar_DZ create mode 100644 extra/locale/collation/ar_EG create mode 100644 extra/locale/collation/ar_IN create mode 100644 extra/locale/collation/ar_IQ create mode 100644 extra/locale/collation/ar_JO create mode 100644 extra/locale/collation/ar_KW create mode 100644 extra/locale/collation/ar_LB create mode 100644 extra/locale/collation/ar_LY create mode 100644 extra/locale/collation/ar_MA create mode 100644 extra/locale/collation/ar_OM create mode 100644 extra/locale/collation/ar_QA create mode 100644 extra/locale/collation/ar_SA create mode 100644 extra/locale/collation/ar_SD create mode 100644 extra/locale/collation/ar_SY create mode 100644 extra/locale/collation/ar_TN create mode 100644 extra/locale/collation/ar_YE create mode 100644 extra/locale/collation/az_AZ create mode 100644 extra/locale/collation/be_BY create mode 100644 extra/locale/collation/bg_BG create mode 100644 extra/locale/collation/bn_BD create mode 100644 extra/locale/collation/bn_IN create mode 100644 extra/locale/collation/br_FR create mode 100644 extra/locale/collation/bs_BA create mode 100644 extra/locale/collation/comm create mode 100644 extra/locale/collation/cy_GB create mode 100644 extra/locale/collation/de_AT create mode 100644 extra/locale/collation/de_BE create mode 100644 extra/locale/collation/de_CH create mode 100644 extra/locale/collation/de_DE create mode 100644 extra/locale/collation/de_LU create mode 100644 extra/locale/collation/el_GR create mode 100644 extra/locale/collation/en_AU create mode 100644 extra/locale/collation/en_BW create mode 100644 extra/locale/collation/en_CA create mode 100644 extra/locale/collation/en_DK create mode 100644 extra/locale/collation/en_GB create mode 100644 extra/locale/collation/en_HK create mode 100644 extra/locale/collation/en_IE create mode 100644 extra/locale/collation/en_IN create mode 100644 extra/locale/collation/en_NZ create mode 100644 extra/locale/collation/en_PH create mode 100644 extra/locale/collation/en_SG create mode 100644 extra/locale/collation/en_US create mode 100644 extra/locale/collation/en_ZA create mode 100644 extra/locale/collation/en_ZW create mode 100644 extra/locale/collation/eo_EO create mode 100644 extra/locale/collation/eu_ES create mode 100644 extra/locale/collation/fa_IR create mode 100644 extra/locale/collation/fo_FO create mode 100644 extra/locale/collation/fr_BE create mode 100644 extra/locale/collation/fr_CA create mode 100644 extra/locale/collation/fr_CH create mode 100644 extra/locale/collation/fr_FR create mode 100644 extra/locale/collation/fr_LU create mode 100644 extra/locale/collation/ga_IE create mode 100644 extra/locale/collation/gd_GB create mode 100644 extra/locale/collation/gl_ES create mode 100644 extra/locale/collation/gv_GB create mode 100644 extra/locale/collation/he_IL create mode 100644 extra/locale/collation/hi_IN create mode 100644 extra/locale/collation/hu_HU create mode 100644 extra/locale/collation/hy_AM create mode 100644 extra/locale/collation/id_ID create mode 100644 extra/locale/collation/iso14651_t1 create mode 100644 extra/locale/collation/it_CH create mode 100644 extra/locale/collation/it_IT create mode 100644 extra/locale/collation/iw_IL create mode 100644 extra/locale/collation/ka_GE create mode 100644 extra/locale/collation/kl_GL create mode 100644 extra/locale/collation/kw_GB create mode 100644 extra/locale/collation/mi_NZ create mode 100644 extra/locale/collation/mk_MK create mode 100644 extra/locale/collation/mr_IN create mode 100644 extra/locale/collation/ms_MY create mode 100644 extra/locale/collation/mt_MT create mode 100644 extra/locale/collation/nl_BE create mode 100644 extra/locale/collation/nl_NL create mode 100644 extra/locale/collation/nn_NO create mode 100644 extra/locale/collation/oc_FR create mode 100644 extra/locale/collation/pt_BR create mode 100644 extra/locale/collation/pt_PT create mode 100644 extra/locale/collation/ro_RO create mode 100644 extra/locale/collation/ru_RU create mode 100644 extra/locale/collation/ru_UA create mode 100644 extra/locale/collation/se_NO create mode 100644 extra/locale/collation/sk_SK create mode 100644 extra/locale/collation/sq_AL create mode 100644 extra/locale/collation/sr_YU create mode 100644 extra/locale/collation/sv_FI create mode 100644 extra/locale/collation/sv_SE create mode 100644 extra/locale/collation/ta_IN create mode 100644 extra/locale/collation/te_IN create mode 100644 extra/locale/collation/tg_TJ create mode 100644 extra/locale/collation/th_TH create mode 100644 extra/locale/collation/ti_ER create mode 100644 extra/locale/collation/ti_ET create mode 100644 extra/locale/collation/tl_PH create mode 100644 extra/locale/collation/tt_RU create mode 100644 extra/locale/collation/uk_UA create mode 100644 extra/locale/collation/ur_PK create mode 100644 extra/locale/collation/uz_UZ create mode 100644 extra/locale/collation/vi_VN create mode 100644 extra/locale/collation/wa_BE create mode 100644 extra/locale/collation/yi_US create mode 100644 extra/locale/gen_collate.c create mode 100644 extra/locale/gen_ldc.c create mode 100644 extra/locale/gen_locale.c create mode 100644 extra/locale/gen_mmap.c create mode 100644 extra/locale/gen_wc8bit.c create mode 100644 extra/locale/gen_wctype.c create mode 100644 extra/locale/lmmtolso.c create mode 100644 extra/locale/locale_mmap.h create mode 100644 extra/locale/tst_nl_langinfo.c create mode 100644 include/Makefile create mode 100644 include/Makefile.in create mode 100644 include/algorithm create mode 100644 include/array create mode 100644 include/associative_base create mode 100644 include/basic_definitions create mode 100644 include/bitset create mode 100644 include/cassert create mode 100644 include/cctype create mode 100644 include/cerrno create mode 100644 include/cfloat create mode 100644 include/char_traits create mode 100644 include/cinttypes create mode 100644 include/climits create mode 100644 include/clocale create mode 100644 include/cmath create mode 100644 include/complex create mode 100644 include/csetjmp create mode 100644 include/csignal create mode 100644 include/cstdarg create mode 100644 include/cstddef create mode 100644 include/cstdint create mode 100644 include/cstdio create mode 100644 include/cstdlib create mode 100644 include/cstring create mode 100644 include/ctime create mode 100644 include/cwchar create mode 100644 include/cwctype create mode 100644 include/deque create mode 100644 include/exception create mode 100644 include/fstream create mode 100644 include/func_exception create mode 100644 include/functional create mode 100644 include/iomanip create mode 100644 include/ios create mode 100644 include/iosfwd create mode 100644 include/iostream create mode 100644 include/istream create mode 100644 include/istream_helpers create mode 100644 include/iterator create mode 100644 include/iterator_base create mode 100644 include/limits create mode 100644 include/list create mode 100644 include/locale create mode 100644 include/map create mode 100644 include/memory create mode 100644 include/new create mode 100644 include/numeric create mode 100644 include/ostream create mode 100644 include/ostream_helpers create mode 100644 include/queue create mode 100644 include/set create mode 100644 include/sstream create mode 100644 include/stack create mode 100644 include/stdexcept create mode 100644 include/streambuf create mode 100644 include/string create mode 100644 include/string_iostream create mode 100644 include/support create mode 100644 include/type_traits create mode 100644 include/typeinfo create mode 100644 include/unwind-cxx.h create mode 100644 include/utility create mode 100644 include/valarray create mode 100644 include/vector create mode 100755 scripts/find_libgcc_eh.sh create mode 100755 scripts/find_libsupc.sh create mode 100644 src/Makefile create mode 100644 src/Makefile.in create mode 100644 src/abi/abi.cpp create mode 100644 src/abi/libgcc_eh/Makefile create mode 100644 src/abi/libgcc_eh/Makefile.in create mode 100644 src/abi/libsupc/Makefile create mode 100644 src/abi/libsupc/Makefile.in create mode 100644 src/algorithm.cpp create mode 100644 src/array.cpp create mode 100644 src/associative_base.cpp create mode 100644 src/bitset.cpp create mode 100644 src/char_traits.cpp create mode 100644 src/complex.cpp create mode 100644 src/del_op.cpp create mode 100644 src/del_opnt.cpp create mode 100644 src/del_ops.cpp create mode 100644 src/del_opv.cpp create mode 100644 src/del_opvnt.cpp create mode 100644 src/del_opvs.cpp create mode 100644 src/deque.cpp create mode 100644 src/eh_alloc.cpp create mode 100644 src/eh_globals.cpp create mode 100644 src/exception.cpp create mode 100644 src/fstream.cpp create mode 100644 src/func_exception.cpp create mode 100644 src/iomanip.cpp create mode 100644 src/ios.cpp create mode 100644 src/iostream.cpp create mode 100644 src/istream.cpp create mode 100644 src/iterator.cpp create mode 100644 src/limits.cpp create mode 100644 src/list.cpp create mode 100644 src/locale.cpp create mode 100644 src/map.cpp create mode 100644 src/new_handler.cpp create mode 100644 src/new_op.cpp create mode 100644 src/new_opnt.cpp create mode 100644 src/new_opv.cpp create mode 100644 src/new_opvnt.cpp create mode 100644 src/numeric.cpp create mode 100644 src/ostream.cpp create mode 100644 src/queue.cpp create mode 100644 src/set.cpp create mode 100644 src/sstream.cpp create mode 100644 src/stack.cpp create mode 100644 src/stdexcept.cpp create mode 100644 src/streambuf.cpp create mode 100644 src/string.cpp create mode 100644 src/support.cpp create mode 100644 src/typeinfo.cpp create mode 100644 src/utility.cpp create mode 100644 src/valarray.cpp create mode 100644 src/vector.cpp create mode 100644 tests/.gitignore create mode 100644 tests/Makefile create mode 100644 tests/Makefile.in create mode 100644 tests/algotest.cpp create mode 100644 tests/bitsettest.cpp create mode 100644 tests/chartraitstest.cpp create mode 100644 tests/combotest.cpp create mode 100644 tests/dequetest.cpp create mode 100644 tests/excepttest.cpp create mode 100644 tests/fstreamtest.cpp create mode 100644 tests/functionaltest.cpp create mode 100644 tests/ioexceptiontest.cpp create mode 100644 tests/iotest.cpp create mode 100644 tests/listtest.cpp create mode 100644 tests/maptest.cpp create mode 100644 tests/memorytest.cpp create mode 100644 tests/mmaptest.cpp create mode 100644 tests/newdeltest.cpp create mode 100644 tests/numerictest.cpp create mode 100644 tests/settest.cpp create mode 100644 tests/sstreamtest.cpp create mode 100644 tests/stacktest.cpp create mode 100644 tests/streambuftest.cpp create mode 100644 tests/streamitertest.cpp create mode 100644 tests/stringtest.cpp create mode 100644 tests/testframework.cpp create mode 100644 tests/testframework.h create mode 100644 tests/testoutput/Makefile.in create mode 100644 tests/testoutput/algotest.good create mode 100644 tests/testoutput/bitsettest.good create mode 100644 tests/testoutput/chartraitstest.good create mode 100644 tests/testoutput/combotest.good create mode 100644 tests/testoutput/dequetest.good create mode 100644 tests/testoutput/excepttest.good create mode 100644 tests/testoutput/fstreamtest.good create mode 100644 tests/testoutput/fstreamtest.input create mode 100644 tests/testoutput/functionaltest.good create mode 100644 tests/testoutput/ioexceptiontest.good create mode 100644 tests/testoutput/iotest.good create mode 100644 tests/testoutput/iotest.input create mode 100644 tests/testoutput/listtest.good create mode 100644 tests/testoutput/maptest.good create mode 100644 tests/testoutput/memorytest.good create mode 100644 tests/testoutput/mmaptest.good create mode 100644 tests/testoutput/newdeltest.good create mode 100755 tests/testoutput/runtests.sh create mode 100644 tests/testoutput/settest.good create mode 100644 tests/testoutput/sstreamtest.good create mode 100644 tests/testoutput/stacktest.good create mode 100644 tests/testoutput/streambuftest.good create mode 100644 tests/testoutput/streambuftest.input create mode 100644 tests/testoutput/stringtest.good create mode 100644 tests/testoutput/stringtest.input create mode 100644 tests/testoutput/utilitytest.good create mode 100644 tests/testoutput/valarraytest.good create mode 100644 tests/testoutput/vectortest.good create mode 100644 tests/testoutput/wchartest.good create mode 100644 tests/testoutput/wchartest.input create mode 100644 tests/utilitytest.cpp create mode 100644 tests/valarraytest.cpp create mode 100644 tests/vectortest.cpp create mode 100644 tests/wchartest.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1624581 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# +# Never ignore these +# +!.gitignore + +# +# Generated files +# +*.a +*.i +*.o +*.depend +.config* +.*.dep +/*.log +cscope.* +bin/g++-uc +bin/env_check +libuClibc++*.so +libuClibc++*.so.0 +include/system_configuration.h +include/bits/ + +# +# Debugging files +# +.gdb_history +.gdbinit +core + +# +# Backups / patches +# +*~ +*.orig +*.rej +/*.patch +/*.diff + +# Playground +playground diff --git a/BugFinders b/BugFinders new file mode 100644 index 0000000..a4d3094 --- /dev/null +++ b/BugFinders @@ -0,0 +1,111 @@ +//This file lists everybody who has sent me bug problems/fixes starting Jan 24, 2005 +//The list will be in order of total number of points, with the most at the top +//Anybody who sends me a bug listing with some sample code gets 1 point +//If that sample code is a minimal test case, it becomes 2 points +//If a patch or usable instructions for correction are included, it is 3 points +//Note that I am the final arbiter on how many points a bug report is worth +//I reserve the right to alter any and all bug points at a whim without any recourse +//Functionality that isn't part of the standard isn't included +//Stuff that hasn't been implemented yet doesn't count +//Saying "this piece of software doesn't work" doesn't count +//I reserve the right to modify the rules at any point without notice +//I suggest killing all the lawyers +//Using the bug tracking system at bugs.uclibc.org gets you a bonus point + + +tommi: 39 Points +2007-05-29: 1+1: Found problem with string.compare(), provided solution / BTS +2007-04-27: 1 : Found missing formatflags initialization in ios_base::init / BTS +2007-04-27: 1+1: Found problem with fstreambuf reading closed file descriptor / BTS +2007-03-07: 1+1: Found that ostream was improperly flushing on destruction +2006-09-04: 1+1: Wanted implementation of locale::name, used BTS and provided patch +2006-09-04: 1+1: Found problem with default flags for ios plus provided patch +2005-07-20: 1+2: Compared code sizes and sent patch to minimize code size / BTS +2005-07-20: 1+1: Found problem in streambuf::xsputn / BTS +2005-07-13: 1+1: Fixed setting of error flags in certain istream code. / BTS +2005-07-12: 1+2: Fixed implemenation of certain exceptions / BTS +2005-07-12: 1+2: Provided implemenation of istreambuf_iterator::equal() / BTS +2005-07-12: 1+1: Set eofbit as appropriate. Provided partial solution/BTS +2005-07-11: 1+1: Found problem in uflow(). Provided fix/BTS +2005-07-09: 1+1: Found probelm with exception declarations. Provided Fix/BTS +2005-07-08: 1+1: Found inefficiency in sterambuf code. Provided fix/BTS +2005-07-08: 1+1: Found problem in ostream code with infinite loop. Provided fix/BTS +2005-07-08: 1+1: Found problem in ostream code calling flush(). Provided partial fix/BTS +2005-07-04: 1+2: Found need for basic_ios(). Used BTS and provided test case. +2005-07-04: 1+1: Found string::compare ambiguity. Used BTS. + +asierllano: 18 Points +2006-02-08: 1+2: Provided reworking of some map internals to better meet spec and to be smaller +2006-02-08: 1+2: Found problem in functional and provided fix +2006-02-08: 1+2: Reported compilation problems with no C99 math support and provided fix +2006-02-08: 0+1: Found gcc4 bug already fixed - provided better fix. +2005-07-02: 1+1: Minor fix to list::swap. Now swaps number of elements. Used BTS & patch +2005-07-02: 1+2: Found invalid functionality in lower_bound and upper_bound for map +2005-07-02: 1+2: Found missing const on some data types. Used BTS & provided patch + +scott: 7 Points +2005-02-01: 1+2: Found problem with wchar needing ifdefs. Used bug system and provided partial solution +2005-01-20: 1+1: Found problem in string internal typedefs. Used bug system +2005-01-18: 1+1: Found duplicate declaration of size_t. Used bug system + +Peter Schueller: 5 Points +2006-12-14: 1 : Provided a fix for an unused variable warning. Used BTS. +2006-12-14: 1+1: Provided implementation of deque::swap. Used BTS. +2006-10-06: 1+1: Found map = instead of equals error. Use BTS, provided solution. + +dcas: 5 Points +2006-03-07: 0+1: Found lack of string resize specifier and provided fix in BTS +2006-03-07: 0+2: Found missing string::find_last_not_of - prop. fix in BTS +2006-03-07: 0+2: Found missing std::ws and submitted proposed fix in BTS + +Vijay: 4 Points +2007-04-03: 2: Found problem with set and map iterators - provided test case. +2007-04-01: 2: Found problem with set construct-from-iterators. Provided test case. +2007-03-10: 2: Found lack of ios::exception support + +Ciaran: 4 Points +2005-12-21: 1+1: Found that a const iterator doesn't handle operator* +2005-12-20: 1+1: Found that iterator and const_iterator weren't compatible + +thritter: 3 Points +2005-02-11: 1+2: Found problem in cstdlib needing ifdefs for wchar. Used BTS & provided solution + +Faye2040: 3 Points +2006-02-10: 1 : Noted that long_double support should depend upon float support +2006-02-09: 1+1: Found problem with functional binder. Used BTS. + +Peter Nixon: 3 Points +2008-06-18: 2 : Found that limits asn't definied and provided implementation. +2008-06-18: 1 : Found that ios_base::width was not being honored and provided partial fix. + +Olivier Hochreutiner: 2 Points +2009-04-03: 1+1: Found a problem with map::operator[] and provided test case. + +Christian Taedcke: 2 Points +2007-04-11: 1+1: Found a problem with find dereferencing end(). Provided fix. + +Thomas Volpini: 2 Points +2006-08-11: Found memory leak in vector. Provided test case and fix. + +Gavin Lambert: 2 Points +2006-06-30: 1+1: Found memory leak and provided a proposed fix. + +Natanael Copa: 2 Points +2006-06-22: 1+1: Found ios_base::app error. Provided minimal test case. + +Ted Schroeder: 2 Points +2005-05-20: 1+1: Found error in functional. Provided fix. + +Thomas Giesel: 2 Points +2005-03-02: 2 : Found problems in getline code with minimal test case. + +Vladimir Dronnikov: 1 Point +2009-04-01: 1: Found a problem with map and mmap now exporting swap correctly. + +Manjuantha Srinivasan: 1 Point +2006-11-28: 1 : Found that the iostream library did not flush contents on destruction. + +Anthony Lee: 1 Point +2005-01-24: 1 : Found problem in functional which had const missing causing havok + + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..16c42ff --- /dev/null +++ b/ChangeLog @@ -0,0 +1,319 @@ +0.2.5 +- wrapper: Fix handling arguments with spaces +- stream: Add support for 64-bit integers +- buildsys: allow to pass in LDFLAGS +- __base_associative: fix erase(iter,iter), e.g. multimap +- list: fix splice to empty list from other.begin() +- add refcounted exceptions +- tests: Allow to run tests via a simulator +- algorithm: Fix decl of stable_sort +- string: assign(): fix two bugs +- C++14 sized allocation +- buildsys: Revamp. Fix spurious rebuilds, check CXXFLAGS with CXX +- iostream: fix string getline to set noskipws +- istream: add missing operator >> implementation +- buildsys: rename .config WARNINGS to UCLIBCXX_WARNINGS +- unwind: Fix for __ARM_EABI_UNWINDER__ + +0.2.4 +- valarray: Fix operator=(const valarray&) DR 630 +- valarray: Adjust constness of operator[](size_t) +- valarray: Properly implement class member valarray operator!() +- valarray: Fix operator|= (const T&) to or, not not +- valarray: Fix both shift() and cshift() for any overrun and +- offsets +- valarray: Fix slice_array& operator=(const slice_array&) to return properly +- valarray: Adjust class gslice default constructor DR 543 +- valarray: Fix valarray operator>(const T&, const valarray&) +- valarray: Return the result of all algo +- valarray: Fix copy'n paster error in atan2() inner fn call +- valarray: Fix pow (const T& const valarray&) +- istream: fix readin +- fix compilation with >= gcc-4.7 +- ios: Fix typo in operator!= +- tests: Fix typo in chartraitstest +- bitset: reset(), flip(): Fix off-by-one error +- tests: Show diff when V=1 was given +- buildsys: several fixes (ccache, Makefile deps, portability) + +0.2.3 +- eh: Add alloc/free for dependent exception +- cstring: Provide inlines only if __CORRECT_ISO_CPP_STRING_H_PROTO is not defined +- Several compile fixes for recent gcc versions +- Have string use some of the base class insert functions to be more complete +- Change map::operator[] to not create unnecessary temp objects. +- Ensure that map and mmap swap functions are properly exported +- Add support for ostream adjustwidth support +- Add support for bool limits support +- Misc fstream fixes +- Add support for comparison between deque iteractors and deque const_iterators + +0.2.2 +- Fixed default flags for ios +- Implemented locale::name() for compatability reasons +- Found embarassing = instead of == in code. Fixed. +- Made algotest active. +- Ifdef out GCC specific pragmas and attribute foo to be more portable. Thanks to asierllano. +- Stop initializing variables in destructor. +- Have destruction of ostream objects cause the buffers to be flushed. +- Implement deque::swap +- Remove variable name to avoid unused variable declaration warning. +- Add #pragma GCC visibility push/pop in header files at the request of Peter S. Mazinger +- Convert string test suite to use new test framework. +- Don't have ostream do flushing - leave that to subclasses. +- Now support ios::exception properly +- istream::get(char *s, streamsize n) is now more standards-compliant. +- Added new base to be used for associative containers (map, set, multimap, multiset). +- Fixed iterator returned by list::erase when erasing first element in list. +- Map and multimap classes have been rewritten with the new associative base. Now passes test suite! +- Set and multiset classes have been rewritten with the new associative base. +- Set and Map now should insert from iterators correctly. +- Fix fstreambuf to not segfault on reading from a closed file descripter. +- Have ios_Base::init reset the stream flags as per the spec. +- Fixed string.compare() to do math on the correct variables. +- Added location for complex tests, plus a preliminary test attempting to reproduce suspected issue. + +0.2.1 +- Now export std::calloc & std::realloc +- Implement std::ws +- Implement istream>> (*pf)(istream) +- Implement istream>> (*pf)(ios_base) +- Implement string::find_last_not_of +- Convert some string functions to use traits::eq in spec compliance +- String now accepts resize filler character +- String::assign(iterator first, iterator last) now implemented +- Clean up double-semicolons +- Add parent class scoping as appropriate +- Make ios::Init() exported again +- Replace cwchar and cstdio with my own versions, getting rid of GNU badness +- Add eh_alloc to source - replacing more objects from the GNU implementation +- Add configurable use of TLS as appropriate (migrating this way - no support deprecated) +- Make ostream formating more accurately reflect specification (curtesy Gavin Lambert) +- Make streams respect the ios_base::app flag. Added test case to check for this in fstream +- Elliminate unuse architecture config code (Thanks to Mike Frysinger) +- Added preliminary implementation of +- Fixed memory error in list::remove implementation +- Fix memory leak in vector + + +0.2.0 +- Now can compare set iterators and const_iterators +- Now can compare map iterators and const_iterators +- Now can get a const value from operator* on set/map iterator +- Added fixed to std::map / std::multimap +- Clean up test suite +- Map test now tests for some additional error conditions +- Map iterators still invalidated improperly +- Fix to functional binder using wrong type +- Long double support now depends on float support + +0.1.12 +- Add missing const declarators to some data types (thanks to asierllano) +- Fix list::swap to alter the nubmer of elements +- Fix map and mmap code find functions +- Add const operator== and operator!= to multiple containers +- Removied 3-argument string::compare and substituted 5-arguement compare with defaults +- Re-instituted basic_ios() constructor. istream/ostream now manually call protected init() +- Fixed implementation of uflow() (Thanks tommi) +- badbit now set if data not written in ostream code +- fix implementation of traits::copy +- Call flush far less often +- Now with multimap::operator== (thanks to tommi) +- Implementation of istreambuf_iterator::equal() (Thanks to tommi) +- Fix certain exception implementations +- Istream now sets error bits correctly (thanks to tommi) +- Change implementation of streambuf::xsputn +- Fix of binder2nd operator implementation +- Elliminated unneccessary pointers in ostream and istream - use pointers in base class instead +- Added tests of utilities +- Now handle calls to new() requesting 0 bytes without throwing exception +- Changed behaviour of sstream to more closely match standard, GNU libstdc++ and the rest of iostream +- Fix implementation for man_fun to use mem_fun1_t as appropriate +- Fix const on mem_fun1_t +- Remove const from auto_ptr::release() +- Add const to map::const_iterator operator->() +- Add const to set::const_iterator operator->() +- Provide for default argument to vector::resize() +- Implemented std::ends +- Implemented [multi]set comparison operators +- Fixed deque operator== +- Deque const_iterator now works properly +- Fix auto_ptr() copy constructor to not be const +- Better fix for deque const_iterator +- Undef min/max in algorithm to get rid of macro versions +- Yet Another Implementation of deque::iterator +- Implemented swap(string, string) +- Change algorithms swap to use copy constructor instead of default constructor +- Added a little more from gslice_array +- Created comparison operatators for list +- Added binary operators to valarray +- Added trig operators to valarray +- Fixed typos in valarray (thanks to psm) +- Broke spec slightly in slice_array to allow copying to make borken apps/compilers work +- More fixes to auto_ptr const correctness +- Fix deque constness in deque const_iterator typenames +- Fix stringstream buffer xsputn implementation + + +0.1.11 +- Expanding basic_string automatically expands vector, even if not + explicitly expanding vector for other data types. No cost and may save space. +- Explicitly share istream code for tokenizing stream +- Fix of bind2nd in function (Thanks to Ted Schroeder) +- Properly implement fstream::sync() - now works +- Added std::streamoff +- Added operators for fpos in ios +- Fix resize() call in string wrapping non-existant resize() call +- Fix operator >= in string +- Performance speedup in vector/string (now *use* preallocated buffer space) +- Showbase is no longer on by default +- i|ostream now call the constructor for basic_ios properly +- Fixes to how snextc() works. Code now fixed +- seekoff() and thus tellg now returns ftell to give useful information +- General iostream cleanups +- Additions to io and other tests +- Added test for streambuf +- Made changes to iostream - now reads first and last character! +- Update istream::read to list amount of data last read successfully +- Add configuration option to avoid expanding pesky [con|de]structors +- Implemented std::auto_ptr - don't know how I missed that one +- Now able to have all support libraries imported (libgcc_eh) +- wchar output now works properly - note that performance sucks necessarily +- Fix to string::erase() so it now actually erases + + +0.1.10 +- Implemented clog and changed cerr to meet spec (unbuffered) +- Implemented wcout, wcin, wcerr and wclog +- Added functions to support conversion of wchar to appropriate types +- Cleanup of #includes in header files to reduce bloat and compilation time +- Added ostream support for wchar +- Fixed missing const declaration in functional causing problems with algorithms +Peter S. Mazinger: Added -z defs to $(CC) -shared +- Fixed wchar enhancements if wchar is not enabled +- Cleaned up tests system to be much easier to add additional tests +- Fixed problems in getline() code +- Major performance increase on fstream input code (4.5X, approximately) +- Move libgcc_eh and libsupc++ code into separate directories +- More code expansion into the library to make executibles much smaller +- Remove unneeded typedefs to clean up the code and make it easier to understand +- nearly complete - only need to implement pow() +- Fixed problem with failing to handle end-of-file notification +- Removed certain enhancements until I can figure out why they are spewing warnings + + + +0.1.9 +Peter S. Mazinger: wchar cleanups across the board +- Make sure that operator= changes the number of elements in the vector. +- Fix to string::pop_back function scope +- reverse_iterator copying fixed +- Have max string length test aginst proper variable (oops) +- Change sstream to use append instead of push_back all of the time +- Make string::append start reading at the correct location +- Convert sstream to allow seeking on write stream without truncation +- Convert sstream xsputn to use either append or replace +- Elliminate duplicate size_t definition - now use C library version +- Make sure string assign(size_type n, Ch c) clears the string before resizing +- Fix string insert functions to move the correct amount of data +- Reimplemented cstring, cassert, cerrno, cstdlib + + +0.1.8 +- Fixed problem in which returned this instead of *this for operator= +- Fixed an problem using . instead of -> Oops. +- Added string find, rfind, find_first_of and find_last_of functions +- Moved operator+(string, string) into library binary. +- Added header. Forgot that little thing. Oops. +- Fixed insert for vector. Technique shamelessly stolen from glibc++ +- fix problem in list which incorrectly handles pointers +- Create native std::string::find(Ch) instead of calling through string constructor. +- Fix of istream getline (only sets failbit if extracted 0 chars, not copied 0 chars) +- Fix string::find so we can scan the last character in the string. +- Fix map iterator overloading class definion +- Fix map iterator returning value not reference +- Change tests to check changes +- Change ios::operator() to return 1 instead of this +- Fix [i|o]stream to check open() return value +- Change fstream open functions to use the proper bitwise operators +- Change allocator functionality so that it works according to spec. +- Conversion of STL to use allocator::construct/destroy +- Make test suite nicer. + + +0.1.7 - 2004-12-23 +- Significant changes to the library +- Converted a lot of forced instanteation from double definitions to ifdef tricks +- Merged some of the helper functions into the main files +- Split off i/ostream string code from core string header +- Lots of little bugfixes done involving function definitions, etc. +- Fixed a spec error in list code - erase now returns a pointer after deleted elements, not before +- Fixed a spec error in streambuf - now call pbackfail instead of returning error. +- Added more code to valarray - now supports slice_array - untested +- Modified test suite (by popular demand). Now the process can be automated +- Added targets make tests and make test. tests builds tests and test runs them + + +0.1.6 - 2004-11-30 +- Fixed problem with straembuf where a value was being returned instead of a pointer +- Fixed a problem where a buffer was not flushed on close of an fstraem +- Added basic test for fstream +- Started working on better way to expand symbols in library + +0.1.5 - 2004-09-26 +- Added code for all algorithms +- Fixed map/set code to prevent infinite loops. Oops. +- Fixed list code to prevent most memory leaks. 1 still remains, but unknown location +- stlport v 1.00 test suite now compiles, links and runs. Some issues remain +- Fix deque constructor using the wrong end_pointer value +- Added erase capability to vector +- Changed multimap::find to point to first matching element instead of any matching element +- Added more tests to test suite based upon problems from stlport test suite +- Altered istream_iterator template so that it handles begining of stream conditions properly +- Fixed make_heap and sort_heap functions to sort in the correct order +- Fixed a few pedantic errors in std::string as it relates to the vector base +- All (known) stlport issues have been resolved. Compiles and runs properly. + + +0.1.4 - 2004-09-10 +- Fixed minor previous errors +- Added heap functions. Just treat as a descending sorted list +- Added more code to +- Added <, <=, >, >= comparisons to deque iterators (don't know why I missed them in the first place) +- Making Makefiles a little bit better. + +0.1.3 - 2004-09-06 +- Compiles with gcc 3.4, thus it is far more "correct" than previously +- Started adding code for valarray + + +0.1.2 - 2004-09-05 +- Completed all core code for set, multiset, map and multimap. Rewrote to use inheritance to cut code duplication +- Added more algorithms +- Now compiles the stlport 1.0 testsuite (some minor changes to not test extensions needed) +- Does not yet link stlport testsuite - missing implementations of a number of functions +- Added sort algorithm - using a bubble sort for now. +- sort_stable will likely remain bubble sort for some time (It is both stable and in-place) +- sort will likely be converted to a heap sort eventually (It is in-place, but non-stable) +- List sort is a bubble sort. Might change later (insertion sort?), but it is difficult to work with list limitations +- Split iterator code into two sections to cut down on dependency hell +- Compiles ncurses c++ library and test application + + +0.1.1 - 2004-09-01 + +- Removed semicolons on the closing of namespaces. My compiler doesn't warn, so I may have missed one or two +- Fixed a problem with the istream code which caused it to fail to read in the first character of input. +- Changed compiler flags to not generate some warnings on >=GCC 3.4 +- Changed build process to prevent misconfiguration under certain circumstances +- Added stringstream and all of it's incarnations +- Added +- Added - code is considered 'under development' - not finished + + +0.1.0 - 2004-08-28 +- Nearly done all algorithms +- Added some SGI extensions +- Completed numerics libraries +- Only multimap has yet to be started of containers +- Lots of bug fixes +- Coompiles all of the stlport C++ STL tests up to mmap1.cpp (no multimap) diff --git a/DOCUMENTATION b/DOCUMENTATION new file mode 100644 index 0000000..f643629 --- /dev/null +++ b/DOCUMENTATION @@ -0,0 +1,37 @@ +Source Files + +All of the forward declarations and templates are defined in header files in +the include/ directory. + +All of the .cpp files in the src/ directory are supposed to produce binary output +at compile time to be linked into the library. There is one such file per header +file located in include. These .cpp files may not actually contain any code or +instanteated objects and instead simply be place holders. + +Source categories. + +Source code can be broken down into 4 separate categories: + +- uClibc++ support code + - new and delete operators + +- GNU libstdc++ support code + - Code taken to be compatible with compiler ABI requirements + - Difficult to replace + +- IOStream code + - This code is used by almost anything. It is extremely + convoluted internally and has been rewritten on more than one + occasion because it is very difficult to understand + +- STL Containers and Algorithms + - These are hardest to keep small because of code expansion. + - Fairly self-contained in their own right + + +Deviations from spec +- Map and set iterators are currently invalidated if you erase or insert an + element into the map/set + +- Locales are not supported. This is intentional. + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..fcd35c7 --- /dev/null +++ b/INSTALL @@ -0,0 +1,36 @@ +For those just beginning with the uClibc++ library, the steps to +begin are fairly easy. + +1) Find the location of the GNU libsupc++.a file on your computer. + It will likely be in a location like: + /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libsupc++.a + Make a note of this file path + +2) Run 'make menuconfig' which will bring up a nifty ncurses-based + configuration dialog system. This is similar to the Linux kernel + configuration system, and was ripped directly from uClibc. + +3) Configure to fit your system. Defaults will be good enough for + now. + +4) Under 'Library Installation Options', put the path to libsupc++.a + in the appropriate location. + +5) Save your configuration + +6) Compile by typing 'make' + +7) Install the library by typing 'make install' + +8) If you want to use this library as a part of your working system + and you did not install the library to a directory in the library + search path, you can either add the installation directory to + the /etc/ld.so.conf file, or (preferred) make a symlink from + the libuClibc++.so symlink into a directory in your search path, + such as /usr/lib + +9) Compile applications using the wrapper script provided in the bin + directory of the install path. If you run into problems, please + let me know. + +10) Enjoy! diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f0c3346 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +top_srcdir=./ +top_builddir=$(if $(O),$(O),.)/ +export top_builddir +all: +include $(top_srcdir)Rules.mak +include Makefile.in +include $(top_srcdir)Makefile.end diff --git a/Makefile.end b/Makefile.end new file mode 100644 index 0000000..87fc87e --- /dev/null +++ b/Makefile.end @@ -0,0 +1,44 @@ +# Rules.mak +# vi: ft=make : + +# Copyright Garrett Kajmowicz, 2004-2006 +# Copyright (C) 2000 by Lineo, inc. +# Copyright (C) 2000-2002 Erik Andersen +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library 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 Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library 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 + +# This file and most of the menuconfiguration system have been taken wholesale from +# the uClibc package availalble at www.uclibc.org + +ifeq ($(HAVE_DOT_CONFIG),y) +# dependency tracking +files.dep := $(libcxx-a-y) $(libcxx-so-y) $(libcxx-nonshared-y) \ + $(libgcc_eh-y) $(libsupc-y) +.depends.dep := \ + $(patsubst %.s,%.s.dep,$(filter %.s,$(files.dep))) \ + $(patsubst %.o,%.o.dep,$(filter %.o,$(files.dep))) +# Oh, and prepend a dot to the basename so i don't have to change my habit of +# calling 'size thefile.o*' +.depends.dep := $(foreach f,$(.depends.dep),$(dir $(f)).$(notdir $(f))) +.depends.dep := $(wildcard $(.depends.dep)) $(manual.depends.dep) + +ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) +ifneq ($(strip $(.depends.dep)),) +.NOEXPORT: +-include $(.depends.dep) +endif # filter +endif # any .dep file + +endif # ifeq ($(HAVE_DOT_CONFIG),y) diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..d49a68d --- /dev/null +++ b/Makefile.in @@ -0,0 +1,129 @@ +ifeq ($(HAVE_DOT_CONFIG),y) +all: lib +else +all: defconfig +endif + +include $(top_srcdir)bin/Makefile.in +include $(top_srcdir)include/Makefile.in +include $(top_srcdir)src/Makefile.in +include $(top_srcdir)extra/Makefile.in + +$(headers-y) $(libcxx-a-y) $(libcxx-so-y): include/system_configuration.h + +DISTCLEAN_tests: + $(Q)$(MAKE) -C tests distclean + +tests: lib + $(Q)$(MAKE) -C tests all + +check test: tests + $(Q)$(MAKE) -C tests test + +release: + $(RM) ../uClibc++-$(VERSION).tar + git archive --format=tar --prefix=uClibc++-$(VERSION)/ HEAD \ + > ../uClibc++-$(VERSION).tar + cat ../uClibc++-$(VERSION).tar | bzip2 -c9 > ../uClibc++-$(VERSION).tar.bz2 + cat ../uClibc++-$(VERSION).tar | xz -e -c8 > ../uClibc++-$(VERSION).tar.xz + du -b $(addprefix ../uClibc++-$(VERSION).tar.,bz2 xz) + +install: install-bin install-include install-lib + +clean: CLEAN_bin CLEAN_src + #$(MAKE) -C $(top_builddir)extra/locale clean + +realclean: clean DISTCLEAN_extra DISTCLEAN_include DISTCLEAN_src DISTCLEAN_tests +distclean: realclean DISTCLEAN_.config +DISTCLEAN_.config: + $(do_rm) $(addprefix $(top_builddir),.config .config.cmd .config.old) + +#Menu configuration system + +extra/config/conf: + $(Q)$(MAKE) -C extra/config conf + +extra/config/mconf: + $(Q)$(MAKE) -C extra/config ncurses mconf + +menuconfig: extra/config/mconf + $(Q)$< extra/Configs/Config.in + +config: extra/config/conf + $(Q)$< extra/Configs/Config.in + +oldconfig: extra/config/conf + $(Q)$< -o extra/Configs/Config.in + +silentoldconfig: extra/config/conf + $(Q)$< -s extra/Configs/Config.in + +randconfig: extra/config/conf + $(Q)$< -r extra/Configs/Config.in + +allyesconfig: extra/config/conf + $(Q)$< -y extra/Configs/Config.in + +allnoconfig: extra/config/conf + $(Q)$< -n extra/Configs/Config.in + +defconfig: extra/config/conf + $(Q)$< -d extra/Configs/Config.in + +include/system_configuration.h: .config | extra/config/conf + $(Q)extra/config/conf -o extra/Configs/Config.in + + +ifeq ($(HAVE_DOT_CONFIG),) +.config: defconfig +endif + +help: + @echo 'Cleaning:' + @echo ' clean - delete temporary object files' + @echo ' realclean - delete temporary object files, including dependencies' + @echo ' distclean - delete all non-source files (including .config)' + @echo + @echo 'Build:' + @echo ' all - libraries' + @echo + @echo 'Configuration:' + @echo ' allnoconfig - disable all symbols in .config' + @echo ' allyesconfig - enable all symbols in .config (see defconfig)' + @echo ' config - text based configurator (of last resort)' + @echo ' defconfig - set .config to arch-specific defaults' + @echo ' menuconfig - interactive curses-based configurator' + @echo ' oldconfig - resolve any unresolved symbols in .config' + @echo ' silentoldconfig - resolve any unresolved symbols in .config, silently' + @echo ' randconfig - generate a random .config' + @$(if $(arch-defconfigs), \ + @echo ''; \ + echo 'Architecture specific configs ($(ARCH))'; \ + $(foreach c, $(arch-defconfigs), \ + printf " %-21s - Build for %s\\n" $(c) $(subst _defconfig,,$(c));) \ + ) + @echo + @echo 'Installation:' + @echo ' install - install both the runtime and the headers' + @echo + @echo 'Development:' + @echo ' check - run testsuite' + @echo ' tests - compile testsuite binaries' + @echo ' release - create a distribution tarball' + @echo + @echo 'Environment variables:' + @echo ' V="" - Quiet build (default)' + @echo ' V=1 - Brief build (show defines, ld flags)' + @echo ' V=2 - Very verbose build' + @echo ' CROSS_COMPILE= - Override CROSS_COMPILER_PREFIX from .config' + @echo ' SHELL= - Shell to use for make' + @echo ' HOSTCC= - C Compiler for compiling host binaries' + @echo ' HOSTCXX= - C++ Compiler for compiling host binaries' + @echo ' HOSTCFLAGS= - extra CFLAGS for compiling host binaries' + @echo ' HOSTCXXFLAGS= - extra CXXFLAGS for compiling host binaries' + @echo ' HOSTLDFLAGS= - extra LDFLAGS for linking host binaries' + @echo + @echo ' DESTDIR= - Prepended prefix to installation paths' + @echo ' CPU_CFLAGS - extra C- and CXX- FLAGS for compiling uClibc++' + @echo ' LDFLAGS - extra LDFLAGS for linking uClibc++ itself' + @echo ' BUILD_EXTRA_LIBRARIES - extra LDFLAGS for linking uClibc++ itself' diff --git a/README b/README new file mode 100644 index 0000000..43e760e --- /dev/null +++ b/README @@ -0,0 +1,32 @@ +A few notes: + +- Most of the uClibc++ development is done against relatively recent versions of + GCC. Currently that means something in the 4.2 series. The 3 series was great, + but has a large number of known issues. + +- If you are looking to statically compile an application, you must compile it + without the use of either rtti or exceptions. The library should be compiled + likewise. Since the application will be statically compiled, you may run a + dynamic library with exception support. + +- As of version 0.1.11 uClibc+ throws LOTS of warnings when compiling about inline + functions used but never defined. There warnings are known errors in GCC + versions 3.3.3 3.4.0 4.0.0 4.1.0 [Bug #21627]. Either ignore these warnings or + upgrade your compiler. Note that these warnings will exist when compiling software + as well as the library itself. + +- uClibc++ is not capable of bootstrapping itself. The library depends upon some + of the gcc support files and libstdc++ for exception support. Linking in libsupc++ + moves all of the required code into the library so that the GNU library is no + longer required AFTER COMPILATION. Thus you can build uClibc++ on a development + system against libstdc++, but when deployed you will not need any of the GNU library + files. + +- The debugging option now has an impact on produced code. For now it simply zeros out + pointers used internally which should never be used, or which are considered to be + invalidated anyways. This will help track down bugs easier (this change was in result + of a memory-related error). + +- The files in the tests/testoutput directory ending in good are used as reference for + the test suite - this allows a byte-for-byte comparison of the output of the streams + library, and so on. diff --git a/Rules.mak b/Rules.mak new file mode 100644 index 0000000..468e490 --- /dev/null +++ b/Rules.mak @@ -0,0 +1,596 @@ +# Rules.mak +# vi: ft=make : + +# Copyright Garrett Kajmowicz, 2004-2006 +# Copyright (C) 2000 by Lineo, inc. +# Copyright (C) 2000-2002 Erik Andersen +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library 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 Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library 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 + +# This file and most of the menuconfiguration system have been taken wholesale from +# the uClibc package availalble at www.uclibc.org + +.SUFFIXES: +.SUFFIXES: .cpp .c .S .o .so .a .s .i +PHONY := FORCE +.PHONY: $(PHONY) all clean realclean distclean install +FORCE: + +ifdef CROSS +# CROSS is still supported for backward compatibily only +$(warning CROSS is deprecated, please use CROSS_COMPILE instead) +ifneq ($(CROSS_COMPILE),) +$(warning CROSS_COMPILE has precedence over CROSS, ignoring the latter) +endif +endif +CROSS_COMPILE ?= $(CROSS) +CC= $(CROSS_COMPILE)gcc +CXX= $(CROSS_COMPILE)g++ +AR= $(CROSS_COMPILE)ar +LD= $(CROSS_COMPILE)ld +NM= $(CROSS_COMPILE)nm +RANLIB= $(CROSS_COMPILE)ranlib +STRIPTOOL= $(CROSS_COMPILE)strip + +INSTALL = install +LN = ln +RM = rm -f +TAR = tar +SED = sed +AWK = awk + +ARFLAGS:= cr + +# Select the compiler needed to build binaries for your development system +HOSTCC=gcc +HOSTCFLAGS=-O2 -Wall +HOSTCXX=g++ +HOSTCXXFLAGS=-O2 -Wall + +#-------------------------------------------------------- +# Nothing beyond this point should ever be touched by mere mortals. +# Unless you hang out with the gods, you should probably leave all +# this stuff alone. + +MAJOR_VERSION:=0 +MINOR_VERSION:=2 +SUBLEVEL:=5 +VERSION:=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL) +ABI_VERSION:=$(MAJOR_VERSION) +export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION ABI_VERSION + +LNAME:=uClibc++ +LIBNAME:=libuClibc++ +SHARED_FULLNAME:=$(LIBNAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so +SHARED_MAJORNAME:=$(LIBNAME).so.$(ABI_VERSION) + +# Make sure DESTDIR and PREFIX can be used to install +ifdef PREFIX +# PREFIX is a uClibcism while DESTDIR is a common GNUism +$(warning PREFIX is deprecated, please use DESTDIR instead) +ifneq ($(DESTDIR),) +$(warning DESTDIR has precedence over PREFIX, ignoring the latter) +endif +endif +DESTDIR ?= $(PREFIX) + +clean_targets := clean realclean distclean CLEAN_% DISTCLEAN_% +noconfig_targets := conf mconf \ + menuconfig config oldconfig silentoldconfig randconfig \ + defconfig allyesconfig allnoconfig $(clean_targets) \ + release tags TAGS help + +# Pull in the user's uClibc++ configuration +ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) +# Prevent make from searching +-include $(abspath $(top_builddir).config) +endif + +comma:=, +space:= # + +# A nifty macro to make testing gcc features easier +check_gcc=$(shell \ + if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi) +check_gxx=$(shell \ + if $(CXX) $(1) -S -o /dev/null -xc++ /dev/null > /dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi) +check_as=$(shell \ + if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \ + then echo "-Wa,$(1)"; fi) +check_ld=$(shell \ + if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \ + then echo "$(1)"; fi) + +# Use variable indirection here so that we can have variable +# names with fun chars in them like equal signs +define check-tool-var +ifeq ($(filter $(clean_targets) CLEAN_%,$(MAKECMDGOALS)),) +_v = $(2)_$(3) +ifndef $$(_v) +$$(_v) := $$(call $(1),$(subst %, ,$(3))) +export $$(_v) +endif +endif +endef + +# Usage: check-gcc-var, +# Check the C compiler to see if it supports . +# Export the variable CFLAG_ if it does. +define check-gcc-var +$(call check-tool-var,check_gcc,CFLAG,$(1)) +endef +# Check the C++ compiler to see if it supports . +# Export the variable CXXFLAG_ if it does. +define check-gxx-var +$(call check-tool-var,check_gxx,CXXFLAG,$(1)) +endef +# Usage: check-as-var, +# Check the assembler to see if it supports . Export the +# variable ASFLAG_ if it does (for invoking the assembler), +# as well CFLAG_-Wa (for invoking the compiler driver). +define check-as-var +$(call check-tool-var,check_as,ASFLAG,$(1)) +_v = CFLAG_-Wa$(1) +export $$(_v) = $$(if $$(ASFLAG_$(1)),-Wa$$(comma)$$(ASFLAG_$(1))) +endef +# Usage: check-ld-var, +# Check the linker to see if it supports . Export the +# variable LDFLAG_ if it does (for invoking the linker), +# as well CFLAG_-Wl (for invoking the compiler driver). +define check-ld-var +$(call check-tool-var,check_ld,LDFLAG,$(1)) +_v = CFLAG_-Wl$(1) +export $$(_v) = $$(if $$(LDFLAG_$(1)),-Wl$$(comma)$$(LDFLAG_$(1))) +endef +# Usage: cache-output-var,, +# Execute and cache the output in . +define cache-output-var +ifndef $(1) +$(1) := $$(shell $(2)) +export $(1) +endif +endef + +$(eval $(call cache-output-var,GCC_VER,$(CC) -dumpversion)) +GCC_VER := $(subst ., ,$(GCC_VER)) +GCC_MAJOR_VER ?= $(word 1,$(GCC_VER)) +#GCC_MINOR_VER ?= $(word 2,$(GCC_VER)) + +# strip quotes +qstrip = $(strip $(subst ",,$(1))) +#")) + +BUILD_EXTRA_LIBRARIES:=$(call qstrip,$(BUILD_EXTRA_LIBRARIES)) + +# Make certain these contain a final "/", but no "//"s. +UCLIBCXX_RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(call qstrip,$(UCLIBCXX_RUNTIME_PREFIX))))) +UCLIBCXX_RUNTIME_LIBDIR:=$(strip $(subst //,/, $(subst //,/, $(subst ,/, $(call qstrip,$(UCLIBCXX_RUNTIME_PREFIX)$(UCLIBCXX_RUNTIME_LIB_SUBDIR)))))) +UCLIBCXX_RUNTIME_BINDIR:=$(strip $(subst //,/, $(subst //,/, $(subst ,/, $(call qstrip,$(UCLIBCXX_RUNTIME_PREFIX)$(UCLIBCXX_RUNTIME_BIN_SUBDIR)))))) +UCLIBCXX_RUNTIME_INCLUDEDIR:=$(strip $(subst //,/, $(subst //,/, $(subst ,/, $(call qstrip,$(UCLIBCXX_RUNTIME_PREFIX)$(UCLIBCXX_RUNTIME_INCLUDE_SUBDIR)))))) +export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_RUNTIME_LIBDIR UCLIBCXX_RUNTIME_BINDIR UCLIBCXX_RUNTIME_INCLUDEDIR + +WRAPPER = $(top_builddir)bin/g++-uc +OPTIMIZATION:= +PICFLAG:=-fPIC + +# use '-Os' optimization if available, else use -O2, allow Config to override +$(eval $(call check-gcc-var,-Os)) +ifneq ($(CFLAG_-Os),) +OPTIMIZATION += $(CFLAG_-Os) +else +$(eval $(call check-gcc-var,-O2)) +OPTIMIZATION += $(CFLAG_-O2) +endif + +$(eval $(call check-gxx-var,-fvisibility-inlines-hidden)) +$(eval $(call check-gxx-var,-std=gnu++14)) +$(eval $(call check-gxx-var,-Wno-sized-deallocation)) +$(eval $(call check-gxx-var,-Wno-tautological-compare)) + +# Add a bunch of extra pedantic annoyingly strict checks +XWARNINGS=$(call qstrip,$(UCLIBCXX_WARNINGS)) -Wno-trigraphs -pedantic +CPU_CFLAGS=$(call qstrip,$(CPU_CFLAGS-y)) + +# Some nice CFLAGS to work with +GEN_CFLAGS:=-fno-builtin +CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS) + +LDFLAGS-$(LIBNAME).so:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs + +STRIP_FLAGS-src := -x -R .note -R .comment +STRIP_FLAGS-src/abi := -x -R .note -R .comment +ifeq ($(DODEBUG),y) + CFLAGS += -O0 -g3 + STRIPTOOL:= true -Since_we_are_debugging +else + CFLAGS += $(OPTIMIZATION) +endif + +ifneq ($(BUILD_ONLY_STATIC_LIB),y) + CFLAGS += $(PICFLAG) +endif + +EH_CXXFLAGS:= +ifneq ($(UCLIBCXX_EXCEPTION_SUPPORT),y) + EH_CXXFLAGS += -fno-exceptions -fno-rtti +endif + +GEN_CXXFLAGS:=-nostdinc++ +GEN_CXXFLAGS+=$(if $(CXXFLAG_-fvisibility-inlines-hidden),-DGCC_HASCLASSVISIBILITY) +CXXFLAGS:=$(CFLAGS) +CFLAGS += -ansi + +LIBGCC:=$(shell $(CC) -print-libgcc-file-name) +LIBGCC_DIR:=$(dir $(LIBGCC)) + +# Let users override these +ifndef LIBGCC_EH +$(eval $(call cache-output-var,FILE_LIBGCC_EH,$(CXX) -print-file-name=libgcc_eh.a)) +LIBGCC_EH:=$(strip $(if $(IMPORT_LIBGCC_EH),$(FILE_LIBGCC_EH))) +endif +ifndef LIBSUP +$(eval $(call cache-output-var,FILE_LIBSUP,$(CXX) -print-file-name=libsupc++.a)) +LIBSUP:=$(strip $(if $(IMPORT_LIBSUP),$(FILE_LIBSUP))) +endif + +list-archive-members = $(if $(1),$(shell $(AR) t $(1))) +variablify = $(strip $(subst /,_,$(subst :,_,$(subst ;,_,$(subst |,_,$(subst >,_,$(subst <,_,$(1)))))))) + +GEN_LIBS:= -lc +ifneq ($(LIBGCC_DIR),$(UCLIBCXX_RUNTIME_LIBDIR)) +GEN_LIBS += -L$(LIBGCC_DIR) +endif +ifneq ($(IMPORT_LIBSUP),y) + GEN_LIBS += -lsupc++ +endif + +LIBS := $(GEN_LIBS) +STATIC_LIBS := $(GEN_LIBS) + +$(eval $(call cache-output-var,LDASNEEDED,$(LD) --help 2>/dev/null | grep -q -- --as-needed && echo y)) +link.asneeded = $(if $1,$(if $(LDASNEEDED),-Wl$(comma)--as-needed $(1) -Wl$(comma)--no-as-needed,$(1))) + +#ifneq ($(GCC_MAJOR_VER),3) +#LIBS-ASNEEDED-$(LIBNAME).so = -lgcc_s +#endif +ifneq ($(IMPORT_LIBGCC_EH),y) + STATIC_LIBS += -lgcc_eh + LIBS-ASNEEDED-$(LIBNAME).so+= -lgcc_eh +endif + +# We do not need built-in implicit rules +MAKEFLAGS += -r + +ifneq ($(findstring s,$(MAKEFLAGS)),) +export MAKE_IS_SILENT := y +SECHO := -@false +DISP := sil +Q := @ +else +export MAKE_IS_SILENT := n +SECHO := @echo +ifneq ($(V)$(VERBOSE),) +ifeq ($(V),1) +DISP := bri# brief, like pur but with defines +Q := @ +else +SHELL_SET_X := set -x +DISP := ver +Q := +endif +else +DISP := pur +Q := @ +endif +endif + +show_objs = $(subst $(top_builddir),,$(subst ../,,$@)) +define show_defs + $(filter -D%,$(call unwrapper,$(1))) +endef +define show_ldflags + $(subst $(comma), ,$(subst -Wl$(comma),,$(filter -Wl%,$(1)))) +endef + +pur_disp_compile.cxx = echo " "CXX $(show_objs) +pur_disp_compile.c = echo " "CC $(show_objs) +pur_disp_compile.ixx = echo " "CPP $(show_objs) +pur_disp_compile.i = echo " "CPP $(show_objs) +pur_disp_compile.sxx = echo " "CXX-S $(show_objs) +pur_disp_compile.s = echo " "CC-S $(show_objs) +pur_disp_compile.u = echo " "CC $(show_objs) +pur_disp_compile.S = echo " "AS $(show_objs) +pur_disp_compile.uxx = echo " "CXX $(show_objs) +pur_disp_compile.oxx = echo " "CXX-o $(show_objs) +pur_disp_hcompile.u = echo " "HOSTCC $(show_objs) +pur_disp_hcompile.o = echo " "HOSTCC-o $(show_objs) +pur_disp_hcompile.uxx= echo " "HOSTCXX $(show_objs) +pur_disp_hcompile.oxx= echo " "HOSTCXX-o $(show_objs) +pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@ +pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS-$(@D)) $@ +pur_disp_ar = echo " "AR $(ARFLAGS) $@ +pur_disp_ranlib = echo " "RANLIB $(RANLIBFLAGS) $@ +pur_disp_ld = echo " "LD $(call dirify,$(1)) +pur_disp_ln = echo " "LN $(show_objs) +pur_disp_mkdir = echo " "MKDIR $(show_objs) +pur_disp_gen = echo " "GEN $(show_objs) +pur_disp_install = echo " "INSTALL $(1) +pur_disp_unifdef = echo " "UNIFDEF $(show_objs) +pur_disp_rm = echo " "CLEAN $(subst CLEAN_,,$(subst DISTCLEAN_,,$@)) + +sil_disp_compile.cxx = true +sil_disp_compile.c = true +sil_disp_compile.ixx = true +sil_disp_compile.i = true +sil_disp_compile.sxx = true +sil_disp_compile.s = true +sil_disp_compile.u = true +sil_disp_compile.S = true +sil_disp_compile.uxx = true +sil_disp_compile.oxx = true +sil_disp_hcompile.u = true +sil_disp_hcompile.o = true +sil_disp_hcompile.uxx= true +sil_disp_hcompile.oxx= true +sil_disp_strip = true +sil_disp_t_strip = true +sil_disp_ar = true +sil_disp_ranlib = true +sil_disp_ld = true +sil_disp_ln = true +sil_disp_mkdir = true +sil_disp_gen = true +sil_disp_install = true +sil_disp_unifdef = true +sil_disp_rm = true + +bri_disp_compile.cxx = $(pur_disp_compile.cxx) $(call show_defs,$(cmd_compile.cxx)) +bri_disp_compile.c = $(pur_disp_compile.c) $(call show_defs,$(cmd_compile.c)) +bri_disp_compile.ixx = $(pur_disp_compile.ixx) $(call show_defs,$(cmd_compile.ixx)) +bri_disp_compile.i = $(pur_disp_compile.i) $(call show_defs,$(cmd_compile.i)) +bri_disp_compile.sxx = $(pur_disp_compile.sxx) $(call show_defs,$(cmd_compile.sxx)) +bri_disp_compile.s = $(pur_disp_compile.s) $(call show_defs,$(cmd_compile.s)) +bri_disp_compile.u = $(pur_disp_compile.u) $(call show_defs,$(cmd_compile.u)) +bri_disp_compile.S = $(pur_disp_compile.S) $(call show_defs,$(cmd_compile.S)) +bri_disp_compile.uxx = $(pur_disp_compile.uxx) $(call show_defs,$(cmd_compile.uxx)) +bri_disp_compile.oxx = $(pur_disp_compile.oxx) $(call show_defs,$(cmd_compile.oxx)) +bri_disp_hcompile.u = $(pur_disp_hcompile.u) $(call show_defs,$(cmd_hcompile.u)) +bri_disp_hcompile.o = $(pur_disp_hcompile.o) $(call show_defs,$(cmd_hcompile.o)) +bri_disp_hcompile.uxx=$(pur_disp_hcompile.uxx) $(call show_defs,$(cmd_hcompile.uxx)) +bri_disp_hcompile.oxx=$(pur_disp_hcompile.oxx) $(call show_defs,$(cmd_hcompile.oxx)) +bri_disp_strip = $(pur_disp_strip) +bri_disp_t_strip = $(pur_disp_t_strip) +bri_disp_ar = $(pur_disp_ar) +bri_disp_ranlib = $(pur_disp_ranlib) +bri_disp_ld = $(pur_disp_ld) $(call show_ldflags,$(cmd_ld)) +bri_disp_ln = $(pur_disp_ln) +bri_disp_mkdir = $(pur_disp_mkdir) +bri_disp_gen = $(pur_disp_gen) +bri_disp_install = $(pur_disp_install) +bri_disp_unifdef = $(pur_disp_unifdef) +bri_disp_rm = $(pur_disp_rm) + +esc=$(subst ','\'',$(1)) +# ') +ver_disp_compile.cxx = echo '$(call esc,$(cmd_compile.cxx))' +ver_disp_compile.c = echo '$(call esc,$(cmd_compile.c))' +ver_disp_compile.ixx = echo '$(call esc,$(cmd_compile.ixx))' +ver_disp_compile.i = echo '$(call esc,$(cmd_compile.i))' +ver_disp_compile.sxx = echo '$(call esc,$(cmd_compile.sxx))' +ver_disp_compile.s = echo '$(call esc,$(cmd_compile.s))' +ver_disp_compile.u = echo '$(call esc,$(cmd_compile.u))' +ver_disp_compile.S = echo '$(call esc,$(cmd_compile.S))' +ver_disp_compile.uxx = echo '$(call esc,$(cmd_compile.uxx))' +ver_disp_compile.oxx = echo '$(call esc,$(cmd_compile.oxx))' +ver_disp_hcompile.u = echo '$(call esc,$(cmd_hcompile.u))' +ver_disp_hcompile.o = echo '$(call esc,$(cmd_hcompile.o))' +ver_disp_hcompile.uxx= echo '$(call esc,$(cmd_hcompile.uxx))' +ver_disp_hcompile.oxx= echo '$(call esc,$(cmd_hcompile.oxx))' +ver_disp_strip = echo '$(call esc,$(cmd_strip))' +ver_disp_t_strip = echo '$(call esc,$(cmd_t_strip))' +ver_disp_ar = echo '$(call esc,$(cmd_ar))' +ver_disp_ranlib = echo '$(call esc,$(cmd_ranlib))' +ver_disp_ld = +ver_disp_ln = +ver_disp_mkdir = +ver_disp_gen = +ver_disp_install = +ver_disp_unifdef = echo '$(call esc,$(cmd_unifdef))' +ver_disp_rm = + +disp_compile.cxx = $($(DISP)_disp_compile.cxx) +disp_compile.c = $($(DISP)_disp_compile.c) +disp_compile.ixx = $($(DISP)_disp_compile.ixx) +disp_compile.i = $($(DISP)_disp_compile.i) +disp_compile.s = $($(DISP)_disp_compile.s) +disp_compile.sxx = $($(DISP)_disp_compile.sxx) +disp_compile.u = $($(DISP)_disp_compile.u) +disp_compile.S = $($(DISP)_disp_compile.S) +disp_compile.uxx = $($(DISP)_disp_compile.uxx) +disp_compile.oxx = $($(DISP)_disp_compile.oxx) +disp_hcompile.u = $($(DISP)_disp_hcompile.u) +disp_hcompile.o = $($(DISP)_disp_hcompile.o) +disp_hcompile.uxx= $($(DISP)_disp_hcompile.uxx) +disp_hcompile.oxx= $($(DISP)_disp_hcompile.oxx) +disp_strip = $($(DISP)_disp_strip) +disp_t_strip = $($(DISP)_disp_t_strip) +disp_ar = $($(DISP)_disp_ar) +disp_ranlib = $($(DISP)_disp_ranlib) +disp_ld = $($(DISP)_disp_ld) +disp_ln = $($(DISP)_disp_ln) +disp_mkdir = $($(DISP)_disp_mkdir) +disp_gen = $($(DISP)_disp_gen) +disp_install = $($(DISP)_disp_install) +disp_unifdef = $($(DISP)_disp_unifdef) +disp_rm = $($(DISP)_disp_rm) + +any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) + +# strip the top_builddir off everything to make the *string* idempotent for -C +dirify = $(subst $(top_builddir),,$(patsubst -L$(top_builddir)%,-L%,$(patsubst -I$(top_builddir)%,-I%,$(1)))) +unwrapper = $(call dirify,$(subst $(call dirify,$(WRAPPER)),$(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS),$(subst WRAPPER_INCLUDEDIR=,,$(subst WRAPPER_LIBDIR=,,$(1))))) +# True if not identical. Neither order nor whitespace nor identical flags +# matter. +compare_flags = \ + $(strip $(filter-out $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(1))))), \ + $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(@)))))) \ + $(filter-out $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(@))))), \ + $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(1))))))) + +# Rebuild if any prerequisite, the used CC or flags changed. +# Previously used flags are stored in the corresponding .%.dep files +maybe_exec = \ + $(if $(strip $(compare_flags) $(any-prereq)), \ + @set -e; \ + $(disp_$(1)); \ + $(cmd_$(1)); \ + echo 'cmd_$(call variablify,$(call dirify,$(@))) := $(call dirify,$(cmd_$(call variablify,$(call dirify,$(1)))))' >> $(dir $@).$(notdir $@).dep) + +CFLAGS_gen.dep = -MT $@ -MD -MP -MF $(dir $@).$(notdir $@).dep + +cmd_compile.c = $(CC) \ + $(CFLAGS-$(suffix $@)) \ + $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $( $@.new + @echo '' >> $@.new + @if cmp -s $@ $@.new ; then \ + $(RM) $@.new ; \ + else \ + mv $@.new $@ ; \ + $(RM) $(WRAPPER) ; \ + fi + +define do_wrapper + @$(disp_gen) + $(Q)echo '#!/bin/sh' > $@.tmp + $(Q)echo '' >> $@.tmp + $(Q)echo 'WRAPPER_INCLUDEDIR="$${WRAPPER_INCLUDEDIR:=-I$(UCLIBCXX_RUNTIME_INCLUDEDIR)}"' >> $@.tmp + $(Q)echo 'WRAPPER_LIBDIR="$${WRAPPER_LIBDIR:=-L$(UCLIBCXX_RUNTIME_LIBDIR)}"' >> $@.tmp + $(Q)echo '' >> $@.tmp + $(Q)echo 'WRAPPER_OPTIONS=""' >> $@.tmp + $(Q)echo 'WRAPPER_LIBS="$(strip $(LIBS))"' >> $@.tmp + $(Q)echo '' >> $@.tmp + $(Q)echo 'WRAPPER_INCLIB="Y"' >> $@.tmp + $(Q)echo 'for arg' >> $@.tmp + $(Q)echo 'do' >> $@.tmp + $(Q)echo ' case "$$arg" in' >> $@.tmp + $(Q)echo ' -c|-E|-S) WRAPPER_INCLIB="N" ;;' >> $@.tmp + $(Q)echo ' -static) [ "$$WRAPPER_LIBS" != "$(strip $(STATIC_LIBS))" ] && WRAPPER_LIBS="$(strip $(STATIC_LIBS))" ;;' >> $@.tmp + $(Q)echo ' esac' >> $@.tmp + $(Q)echo 'done' >> $@.tmp + $(Q)echo 'if [ "$$WRAPPER_INCLIB" = "Y" ]' >> $@.tmp + $(Q)echo 'then' >> $@.tmp + $(Q)echo ' WRAPPER_OPTIONS="$$WRAPPER_OPTIONS -nodefaultlibs $$WRAPPER_LIBDIR -l$(LNAME) $$WRAPPER_LIBS"' >> $@.tmp + $(Q)echo 'fi' >> $@.tmp + $(Q)echo '' >> $@.tmp + $(Q)echo '[ -n "$$V" ] && [ $$V -gt 1 ] && echo $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR "$$@" $$WRAPPER_OPTIONS' >> $@.tmp + $(Q)echo 'exec $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR "$$@" $$WRAPPER_OPTIONS' >> $@.tmp + $(Q)echo '' >> $@.tmp + $(Q)chmod 0755 $@.tmp + $(Q)mv $@.tmp $@ +endef + +$(WRAPPER) $(BIN_DIR)env_check: $(BIN_DIR)Makefile.in +$(WRAPPER): $(BIN_DIR)env_check + $(if $(strip $(call compare_flags,$<) $(any-prereq)),$(do_wrapper)) + diff --git a/extra/Configs/Config.default b/extra/Configs/Config.default new file mode 100644 index 0000000..a93596d --- /dev/null +++ b/extra/Configs/Config.default @@ -0,0 +1,2 @@ +# This file is empty to let people select their own +# build options however they like.... diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in new file mode 100644 index 0000000..afc358a --- /dev/null +++ b/extra/Configs/Config.in @@ -0,0 +1,380 @@ +# +# For a description of the syntax of this configuration file, +# see extra/config/Kconfig-language.txt +# +mainmenu "uClibc++ C++ Library Configuration" + +menu "Target Features and Options" + +source "extra/Configs/Config.in.arch" + +endmenu + +menu "String and I/O Stream Support" + +config UCLIBCXX_HAS_WCHAR + bool "Wide Character Support (Not Currently Supported)" + default n + help + Answer Y to enable wide character support. This will make + uClibc++ much larger. It also requires support from the underlying + C library. Note that this code is currently unmaintained and may + not work. + + Most people will answer N. + +config UCLIBCXX_IOSTREAM_BUFSIZE + int "I/O stream buffer size" + default 32 + help + Please select a value for BUFSIZE. This will be used by the + iostream subsystem as the default buffer size for a file, and + affects cin, cout, fstream, etc. This is independent of the + buffering provided by the underlying C library. This must be a + multiple of 2. + + NOTE: Setting this to '0' will disable buffering completely. + This may break applications which extend the I/O stream + subsystem, but those are few and far between. Disabling will + result in both smaller and very likely faster code. + + THIS DOESN'T WORK YET - FIXME + + +config UCLIBCXX_HAS_LFS + bool "Large File Support" + default y + depends on !CONFIG_CRIS + help + If you wish to build uClibc++ with support for accessing large + files (i.e. files greater then 2 GiB) then answer Y. Do not enable + this if you are using an older Linux kernel (2.0.x) that lacks + large file support. Enabling this option will increase the size + of uClibc++. + + THIS DOESN'T WORK YET - FIXME + + +config UCLIBCXX_SUPPORT_CDIR + bool "Enable support for standard streams like cin and cout" + default y + help + Answer Y to enable the framework for cin, cout, cerr and clog as well + as their wide character versions wcin, wcout, wcerr and wclog. Note + that each of those can be manually altered at a later point. + Disabling this option will result in space savings as well as + performance improvements as some startup code can be eliminated. + This is a widely used feature. Most people will answer Y. + +config UCLIBCXX_SUPPORT_CIN + bool "Enable cin" + default y + depends on UCLIBCXX_SUPPORT_CDIR + help + Answer y to have support for std::cin. This is a commonly used + feature, so you will probably want to say yes here. + +config UCLIBCXX_SUPPORT_COUT + bool "Enable cout" + default y + depends on UCLIBCXX_SUPPORT_CDIR + help + Answer y to have support for std::cout. This is a commonly used + feature, so you will probably want to say yes here. + +config UCLIBCXX_SUPPORT_CERR + bool "Enable cerr" + default y + depends on UCLIBCXX_SUPPORT_CDIR + help + Answer y to have support for std::cerr. This is a commonly used + feature, so you will probably want to say yes here. + +config UCLIBCXX_SUPPORT_CLOG + bool "Enable clog" + default n + depends on UCLIBCXX_SUPPORT_CDIR + help + Answer y to have support for std::clog. This stream is the same as + std::cerr except that it is buffered, where cerr is not. + +config UCLIBCXX_SUPPORT_WCIN + bool "Enable wcin" + default y + depends on UCLIBCXX_SUPPORT_CDIR + depends on UCLIBCXX_HAS_WCHAR + help + Answer y to have support for std::wcin. This is the wide-character + version of cin. You will probably want to say yes here. + +config UCLIBCXX_SUPPORT_WCOUT + bool "Enable wcout" + default y + depends on UCLIBCXX_SUPPORT_CDIR + depends on UCLIBCXX_HAS_WCHAR + help + Answer y to have support for std::wcout. This is the wide-character + version of cout. You will probably want to say yes here. + +config UCLIBCXX_SUPPORT_WCERR + bool "Enable wcerr" + default y + depends on UCLIBCXX_SUPPORT_CDIR + depends on UCLIBCXX_HAS_WCHAR + help + Answer y to have support for std::wcerr. This is the wide-character + version of cerr. You will probably want to say yes here. + +config UCLIBCXX_SUPPORT_WCLOG + bool "Enable wclog" + default n + depends on UCLIBCXX_SUPPORT_CDIR + depends on UCLIBCXX_HAS_WCHAR + help + Answer y to have support for std::wclog. This is the wide-character + version of clog. + +endmenu + + +menu "STL and Code Expansion" + +config UCLIBCXX_STL_BUFFER_SIZE + int "STL buffer size" + default 32 + help + Much of the STL code relies on allocating memory for a number + of objects. For objects like vectors which must reallocate + all of their memory when resizing, aquiring a few extra + objects-worth can provide a dramatic performance improvement. + + This specifies the number of spare objects allocated. + NOTE: This number must be at least 4. Default: 32 + +config UCLIBCXX_CODE_EXPANSION + bool "Template code expansion" + default y + help + Most of the code in the C++ standard library is in the form of + templates which are compiled and linked into each executable + on demand. Answering 'Y' here will allow you to select a + number of templates to pre-expand for certain data types so + that the code is stored in the library instead of the + executable. + + Almost everybody will want to answer Y + +config UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS + bool "Expand constructors and destructors" + default y + depends on UCLIBCXX_CODE_EXPANSION + help + Some compilers will produce warnings or errors if some + techniques are used for code expansion (notably old versions + of gcc). Say yes to minimize the size of compiled + applications. Say no to avoid these errors and warnings. + You should say Y. + +config UCLIBCXX_EXPAND_STRING_CHAR + bool "Expand std::basic_string for " + default y + depends on UCLIBCXX_CODE_EXPANSION + help + If you use std::string at all, you will want to answer Y here. + The largest portions of the code for basic_string will be + expanded and placed into the library, shrinking executables. + You should only say N if you don't use strings at all. + +config UCLIBCXX_EXPAND_VECTOR_BASIC + bool "Expand std::vector for basic data types" + default y + depends on UCLIBCXX_CODE_EXPANSION + help + std::basic string inherits from vector, so saying Y here is + always a good idea. This will expand std::vector for all + primitive data types, shrinking executables. + +config UCLIBCXX_EXPAND_IOS_CHAR + bool "Expand ios core code for char" + default y + depends on UCLIBCXX_CODE_EXPANSION + help + Much of the STL code uses core ios classes. These classes, + though small, are used frequently and will use a lot of space + in your executibles. Expanding this code will save space. + + +config UCLIBCXX_EXPAND_STREAMBUF_CHAR + bool "Expand std::streambuf for char" + default y + depends on UCLIBCXX_CODE_EXPANSION + help + std::streambuf is used extensively throughout the C++ library. + Expanding this code will shrink the size of your executables. + +config UCLIBCXX_EXPAND_ISTREAM_CHAR + bool "Expand std::istream for " + default y + depends on UCLIBCXX_CODE_EXPANSION + help + If you use istream or it's derivatives, including fstream + and iostream with characters, you will want to say yes here + to expand the code and place it into the library. + +config UCLIBCXX_EXPAND_OSTREAM_CHAR + bool "Expand std::ostream for " + default y + depends on UCLIBCXX_CODE_EXPANSION + help + If you use any ostream derivative, including fstream and + iostream with characters, you will want to say yes here to + expand the code and place it into the library. + +config UCLIBCXX_EXPAND_FSTREAM_CHAR + bool "Expand std::fstream for " + default y + depends on UCLIBCXX_CODE_EXPANSION + help + If you use any fstream derivative, you will want to say + yes here to expand the code and place it into the library. + +config UCLIBCXX_EXPAND_SSTREAM_CHAR + bool "Expand std::sstream for " + default y + depends on UCLIBCXX_CODE_EXPANSION + help + If you use any stringstream derivative, you will want to say + yes here to expand the code and place it into the library. + +endmenu + + + + +menu "Library Installation Options" + +config UCLIBCXX_RUNTIME_PREFIX + string "uClibc++ runtime prefix directory" + default "/usr/uClibc++" + help + UCLIBCXX_RUNTIME_PREFIX is the directory into which the uClibc++ + runtime libraries will be installed. + + For a typical target system this should be set to "/usr", so + that 'make install' will install libuClibc++.so into + /usr/lib. + +config UCLIBCXX_RUNTIME_INCLUDE_SUBDIR + string "uClibc++ header file subdirectory" + default "/include" + help + UCLIBCXX_RUNTIME_INCLUDE_SUBDIR is the subdirectory of + UCLIBCXX_RUNTIME_PREFIX in which the header files for the library + are installed. If you set the prefix to /usr, set this to /include + to install the headers into /include + +config UCLIBCXX_RUNTIME_LIB_SUBDIR + string "uClibc++ library subdirectory" + default "/lib" + help + UCLIBCXX_RUNTIME_LIB_SUBDIR is the subdirectory of + UCLIBCXX_RUNTIME_PREFIX in which the library binaries are installed. + If you set the prefix to /usr, set this to /lib to install the + headers into /lib + +config UCLIBCXX_RUNTIME_BIN_SUBDIR + string "uClibc++ application file subdirectory" + default "/bin" + help + UCLIBCXX_RUNTIME_BIN_SUBDIR is the subdirectory of + UCLIBCXX_RUNTIME_PREFIX in which the binary applicatons for the + library are installed - right now this is just the g++ wrapper. If + you set the prefix to /usr, set this to /bin to install the + applications headers into /bin + + + +config UCLIBCXX_EXCEPTION_SUPPORT + bool "Exception and RTTI support" + default y + help + This option enables exception support in the library. + Exception support is part of the C++ standard, and as such + should almost always be enabled. This increases the size of + the library. + + RTTI support is used for exceptions as well as operators such + as dynamic_cast<>() and others. + Using this increases the size of the library. + + Most people will answer Y. + +config IMPORT_LIBSUP + bool "Import libsupc++.a" + depends on UCLIBCXX_EXCEPTION_SUPPORT + default y + help + libsupc++.a is a file which comes with the g++ compiler and + provides all of the language support features required for C++ + programs to run, such as exception support, rtti support, as well + as support for the C++ ABI. This is largely compiler dependent. + + Since the library is statically compiled, this code would normally + need to be compiled into each executable. However, it can also be + imported into this library and shared. uClibc++ imports this code. + + There is no point in importing this if you disable exception and + rtti support above. + + You should say yes. + +config IMPORT_LIBGCC_EH + bool "Import libgcc_eh.a" + depends on UCLIBCXX_EXCEPTION_SUPPORT + default y + help + libgcc_eh.a is a file which comes with the g++ compiler and + provides unwind support for static apps (the dynamically linked + apps use libgcc_s.so instead). + This code is largely compiler dependent. + + Currently for gcc-4.0.0 it is imported only into libuClibc++.a, the + shared library will depend on libgcc_s.so. + +config BUILD_STATIC_LIB + bool "Build static library" + default y + help + By default, libuClibc++ is built only as a shared library. Choosing + 'y' here will also build a static library which can be used to build + statically linked executables. + + There is little reason to say 'no' here. + + You should say yes. + +config BUILD_ONLY_STATIC_LIB + bool "Build only static library" + depends on BUILD_STATIC_LIB + default n + help + By default, libuClibc++ is built as a shared library. Choosing + 'y' here will disable building the shared library. You should + only choose 'y' here if you are on a system which does not + support shared libraries. + + You should say no. + +config DODEBUG + bool "Build uClibc++ with debugging symbols" + default n + help + Say Y here if you wish to compile uClibc++ with debugging symbols. + This will allow you to use a debugger to examine uClibc++ internals + while applications are running. This increases the size of the + library considerably and should only be used when doing development. + If you are doing development and want to debug uClibc++, answer Y. + + Otherwise, answer N. + +endmenu diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch new file mode 100644 index 0000000..1cd1318 --- /dev/null +++ b/extra/Configs/Config.in.arch @@ -0,0 +1,54 @@ +# +# For a description of the syntax of this configuration file, +# see extra/config/Kconfig-language.txt +# + +config UCLIBCXX_HAS_FLOATS + bool "Enable floating point number support" + default y + help + This option allows you to entirely omit all floating point number + support from uClibc++. This will cause floating point functions like + strtod() to be omitted from uClibc++. Other floating point functions, + such as printf() and scanf() will still be included in the library, + but will not contain support for floating point numbers. + Answering N to this option can reduce the size of uClibc++. + + Most people will answer Y. + + THIS DOESN'T DO ANYTHING YET - FIXME + +config UCLIBCXX_HAS_LONG_DOUBLE + bool "Math operations with long double" + depends on UCLIBCXX_HAS_FLOATS + default y + help + Answer Y to enable math support for long double types. + It requires support from the underlying C library. + +config UCLIBCXX_HAS_TLS + bool "Toolchain supports Thread-Local Storage" + default y + help + Answer Y if your toolchain supports Thread-Local Storage. This should + work with GCC versions 3.4 and greater, depending on platform. + + Answering no will use non thread-safe exception handling. + +config UCLIBCXX_WARNINGS + string "Compiler Warnings" + default "-Wall" + help + Set this to the set of gcc warnings you wish to see while compiling. + +config BUILD_EXTRA_LIBRARIES + string "Extra Library Link Flags" + default "" + help + Set this to link against extra libraries when building the library. + This is useful if you need to link in POSIX threads or TLS support. + +config HAVE_DOT_CONFIG + bool + default y + diff --git a/extra/Makefile b/extra/Makefile new file mode 100644 index 0000000..90f9311 --- /dev/null +++ b/extra/Makefile @@ -0,0 +1,28 @@ +# Makefile for uClibc +# +# Copyright (C) 2000 by Lineo, inc. +# Copyright (C) 2000,2001 Erik Andersen +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library 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 Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library 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 +# +# Derived in part from the Linux-8086 C library, the GNU C Library, and several +# other sundry sources. Files within this library are copyright by their +# respective copyright holders. + +top_srcdir=../ +top_builddir=../ +all: +include $(top_srcdir)Rules.mak +include Makefile.in diff --git a/extra/Makefile.in b/extra/Makefile.in new file mode 100644 index 0000000..4d05d52 --- /dev/null +++ b/extra/Makefile.in @@ -0,0 +1,3 @@ +EXTRA_DIR := $(top_srcdir)extra/ +DISTCLEAN_extra: $(PHONY) + $(Q)$(MAKE) -C $(EXTRA_DIR)config CLEAN_extra/config diff --git a/extra/config/.gitignore b/extra/config/.gitignore new file mode 100644 index 0000000..b49584c --- /dev/null +++ b/extra/config/.gitignore @@ -0,0 +1,19 @@ +# +# Generated files +# +config* +lex.*.c +*.tab.c +*.tab.h +zconf.hash.c +*.moc +lkc_defs.h + +# +# configuration programs +# +conf +mconf +qconf +gconf +kxgettext diff --git a/extra/config/Kconfig-language.txt b/extra/config/Kconfig-language.txt new file mode 100644 index 0000000..371dc92 --- /dev/null +++ b/extra/config/Kconfig-language.txt @@ -0,0 +1,282 @@ +Introduction +------------ + +The configuration database is collection of configuration options +organized in a tree structure: + + +- Code maturity level options + | +- Prompt for development and/or incomplete code/drivers + +- General setup + | +- Networking support + | +- System V IPC + | +- BSD Process Accounting + | +- Sysctl support + +- Loadable module support + | +- Enable loadable module support + | +- Set version information on all module symbols + | +- Kernel module loader + +- ... + +Every entry has its own dependencies. These dependencies are used +to determine the visibility of an entry. Any child entry is only +visible if its parent entry is also visible. + +Menu entries +------------ + +Most entries define a config option, all other entries help to organize +them. A single configuration option is defined like this: + +config MODVERSIONS + bool "Set version information on all module symbols" + depends MODULES + help + Usually, modules have to be recompiled whenever you switch to a new + kernel. ... + +Every line starts with a key word and can be followed by multiple +arguments. "config" starts a new config entry. The following lines +define attributes for this config option. Attributes can be the type of +the config option, input prompt, dependencies, help text and default +values. A config option can be defined multiple times with the same +name, but every definition can have only a single input prompt and the +type must not conflict. + +Menu attributes +--------------- + +A menu entry can have a number of attributes. Not all of them are +applicable everywhere (see syntax). + +- type definition: "bool"/"tristate"/"string"/"hex"/"integer" + Every config option must have a type. There are only two basic types: + tristate and string, the other types are based on these two. The type + definition optionally accepts an input prompt, so these two examples + are equivalent: + + bool "Networking support" + and + bool + prompt "Networking support" + +- input prompt: "prompt" ["if" ] + Every menu entry can have at most one prompt, which is used to display + to the user. Optionally dependencies only for this prompt can be added + with "if". + +- default value: "default" ["if" ] + A config option can have any number of default values. If multiple + default values are visible, only the first defined one is active. + Default values are not limited to the menu entry, where they are + defined, this means the default can be defined somewhere else or be + overridden by an earlier definition. + The default value is only assigned to the config symbol if no other + value was set by the user (via the input prompt above). If an input + prompt is visible the default value is presented to the user and can + be overridden by him. + Optionally dependencies only for this default value can be added with + "if". + +- dependencies: "depends on"/"requires" + This defines a dependency for this menu entry. If multiple + dependencies are defined they are connected with '&&'. Dependencies + are applied to all other options within this menu entry (which also + accept an "if" expression), so these two examples are equivalent: + + bool "foo" if BAR + default y if BAR + and + depends on BAR + bool "foo" + default y + +- reverse dependencies: "select" ["if" ] + While normal dependencies reduce the upper limit of a symbol (see + below), reverse dependencies can be used to force a lower limit of + another symbol. The value of the current menu symbol is used as the + minimal value can be set to. If is selected multiple + times, the limit is set to the largest selection. + Reverse dependencies can only be used with boolean or tristate + symbols. + +- numerical ranges: "range" ["if" ] + This allows to limit the range of possible input values for integer + and hex symbols. The user can only input a value which is larger than + or equal to the first symbol and smaller than or equal to the second + symbol. + +- help text: "help" or "---help---" + This defines a help text. The end of the help text is determined by + the indentation level, this means it ends at the first line which has + a smaller indentation than the first line of the help text. + "---help---" and "help" do not differ in behaviour, "---help---" is + used to help visually seperate configuration logic from help within + the file as an aid to developers. + + +Menu dependencies +----------------- + +Dependencies define the visibility of a menu entry and can also reduce +the input range of tristate symbols. The tristate logic used in the +expressions uses one more state than normal boolean logic to express the +module state. Dependency expressions have the following syntax: + + ::= (1) + '=' (2) + '!=' (3) + '(' ')' (4) + '!' (5) + '&&' (6) + '||' (7) + +Expressions are listed in decreasing order of precedence. + +(1) Convert the symbol into an expression. Boolean and tristate symbols + are simply converted into the respective expression values. All + other symbol types result in 'n'. +(2) If the values of both symbols are equal, it returns 'y', + otherwise 'n'. +(3) If the values of both symbols are equal, it returns 'n', + otherwise 'y'. +(4) Returns the value of the expression. Used to override precedence. +(5) Returns the result of (2-/expr/). +(6) Returns the result of max(/expr/, /expr/). +(7) Returns the result of min(/expr/, /expr/). + +An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 +respectively for calculations). A menu entry becomes visible when it's +expression evaluates to 'm' or 'y'. + +There are two types of symbols: constant and nonconstant symbols. +Nonconstant symbols are the most common ones and are defined with the +'config' statement. Nonconstant symbols consist entirely of alphanumeric +characters or underscores. +Constant symbols are only part of expressions. Constant symbols are +always surrounded by single or double quotes. Within the quote any +other character is allowed and the quotes can be escaped using '\'. + +Menu structure +-------------- + +The position of a menu entry in the tree is determined in two ways. First +it can be specified explicitly: + +menu "Network device support" + depends NET + +config NETDEVICES + ... + +endmenu + +All entries within the "menu" ... "endmenu" block become a submenu of +"Network device support". All subentries inherit the dependencies from +the menu entry, e.g. this means the dependency "NET" is added to the +dependency list of the config option NETDEVICES. + +The other way to generate the menu structure is done by analyzing the +dependencies. If a menu entry somehow depends on the previous entry, it +can be made a submenu of it. First, the previous (parent) symbol must +be part of the dependency list and then one of these two conditions +must be true: +- the child entry must become invisible, if the parent is set to 'n' +- the child entry must only be visible, if the parent is visible + +config MODULES + bool "Enable loadable module support" + +config MODVERSIONS + bool "Set version information on all module symbols" + depends MODULES + +comment "module support disabled" + depends !MODULES + +MODVERSIONS directly depends on MODULES, this means it's only visible if +MODULES is different from 'n'. The comment on the other hand is always +visible when MODULES is visible (the (empty) dependency of MODULES is +also part of the comment dependencies). + + +Kconfig syntax +-------------- + +The configuration file describes a series of menu entries, where every +line starts with a keyword (except help texts). The following keywords +end a menu entry: +- config +- menuconfig +- choice/endchoice +- comment +- menu/endmenu +- if/endif +- source +The first five also start the definition of a menu entry. + +config: + + "config" + + +This defines a config symbol and accepts any of above +attributes as options. + +menuconfig: + "menuconfig" + + +This is similiar to the simple config entry above, but it also gives a +hint to front ends, that all suboptions should be displayed as a +separate list of options. + +choices: + + "choice" + + + "endchoice" + +This defines a choice group and accepts any of above attributes as +options. A choice can only be of type bool or tristate, while a boolean +choice only allows a single config entry to be selected, a tristate +choice also allows any number of config entries to be set to 'm'. This +can be used if multiple drivers for a single hardware exists and only a +single driver can be compiled/loaded into the kernel, but all drivers +can be compiled as modules. +A choice accepts another option "optional", which allows to set the +choice to 'n' and no entry needs to be selected. + +comment: + + "comment" + + +This defines a comment which is displayed to the user during the +configuration process and is also echoed to the output files. The only +possible options are dependencies. + +menu: + + "menu" + + + "endmenu" + +This defines a menu block, see "Menu structure" above for more +information. The only possible options are dependencies. + +if: + + "if" + + "endif" + +This defines an if block. The dependency expression is appended +to all enclosed menu entries. + +source: + + "source" + +This reads the specified configuration file. This file is always parsed. diff --git a/extra/config/Makefile b/extra/config/Makefile new file mode 100644 index 0000000..b9112a7 --- /dev/null +++ b/extra/config/Makefile @@ -0,0 +1,128 @@ +# Makefile for uClibc +# +# Copyright (C) 2002 Erik Andersen +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library 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 Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library 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 + +top_srcdir=../../ +include $(top_srcdir)Rules.mak + +all: ncurses conf mconf + +LIBS = -lncurses +ifeq (/usr/include/ncursesw/ncurses.h, $(wildcard /usr/include/ncursesw/ncurses.h)) + HOSTNCURSES += -I/usr/include/ncursesw -DCURSES_LOC="" + LIBS = -lncursesw +else +ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) + HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) + HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h)) + HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h)) + HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) + HOSTNCURSES += -DCURSES_LOC="" +else + HOSTNCURSES += -DCURSES_LOC="" +endif +endif +endif +endif +endif +endif + +CONF_SRC =conf.c +MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c +SHARED_SRC=zconf.tab.c +SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h +CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC)) +MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC)) +SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC)) + +conf: $(CONF_OBJS) $(SHARED_OBJS) + $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ + +mconf: $(MCONF_OBJS) $(SHARED_OBJS) + $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS) + +$(CONF_OBJS): %.o : %.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@ + +$(MCONF_OBJS): %.o : %.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@ + +lkc_defs.h: lkc_proto.h + @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' + +### +# The following requires flex/bison +# By default we use the _shipped versions, uncomment the +# following line if you are modifying the flex/bison src. +#LKC_GENPARSER := 1 + +ifdef LKC_GENPARSER + +%.tab.c %.tab.h: %.y + bison -t -d -v -b $* -p $(notdir $*) $< + +lex.%.c: %.l + flex -P$(notdir $*) -o$@ $< +else + +lex.zconf.o: lex.zconf.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@ + +lex.zconf.c: lex.zconf.c_shipped + cp lex.zconf.c_shipped lex.zconf.c + +zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@ + +zconf.tab.c: zconf.tab.c_shipped + cp zconf.tab.c_shipped zconf.tab.c + +zconf.tab.h: zconf.tab.h_shipped + cp zconf.tab.h_shipped zconf.tab.h +endif + +.PHONY: ncurses + +ncurses: + @echo "int main() {return 0;}" > lxtemp.c + @if $(HOSTCC) lxtemp.c $(LIBS) ; then \ + $(RM) lxtemp.c a.out; \ + else \ + $(RM) lxtemp.c; \ + echo -e "\007" ;\ + echo ">> Unable to find the Ncurses libraries." ;\ + echo ">>" ;\ + echo ">> You must have Ncurses installed in order" ;\ + echo ">> to use 'make menuconfig'" ;\ + echo ">>" ;\ + echo ">> Maybe you want to try 'make config', which" ;\ + echo ">> doesn't depend on the Ncurses libraries." ;\ + echo ;\ + exit 1 ;\ + fi + +CLEAN_extra/config: + $(do_rm) *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \ + conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h diff --git a/extra/config/checklist.c b/extra/config/checklist.c new file mode 100644 index 0000000..c4a9289 --- /dev/null +++ b/extra/config/checklist.c @@ -0,0 +1,363 @@ +/* + * checklist.c -- implements the checklist box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension + * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static int list_width, check_x, item_x, checkflag; + +/* + * Print list item + */ +static void +print_item (WINDOW * win, const char *item, int status, + int choice, int selected) +{ + int i; + + /* Clear 'residue' of last item */ + wattrset (win, menubox_attr); + wmove (win, choice, 0); + for (i = 0; i < list_width; i++) + waddch (win, ' '); + + wmove (win, choice, check_x); + wattrset (win, selected ? check_selected_attr : check_attr); + if (checkflag == FLAG_CHECK) + wprintw (win, "[%c]", status ? 'X' : ' '); + else + wprintw (win, "(%c)", status ? 'X' : ' '); + + wattrset (win, selected ? tag_selected_attr : tag_attr); + mvwaddch(win, choice, item_x, item[0]); + wattrset (win, selected ? item_selected_attr : item_attr); + waddstr (win, (char *)item+1); + if (selected) { + wmove (win, choice, check_x+1); + wrefresh (win); + } +} + +/* + * Print the scroll indicators. + */ +static void +print_arrows (WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) +{ + wmove(win, y, x); + + if (scroll > 0) { + wattrset (win, uarrow_attr); + waddch (win, ACS_UARROW); + waddstr (win, "(-)"); + } + else { + wattrset (win, menubox_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset (win, darrow_attr); + waddch (win, ACS_DARROW); + waddstr (win, "(+)"); + } + else { + wattrset (win, menubox_border_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } +} + +/* + * Display the termination buttons + */ +static void +print_buttons( WINDOW *dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button (dialog, "Select", y, x, selected == 0); + print_button (dialog, " Help ", y, x + 14, selected == 1); + + wmove(dialog, y, x+1 + 14*selected); + wrefresh (dialog); +} + +/* + * Display a dialog box with a list of options that can be turned on or off + * The `flag' parameter is used to select between radiolist and checklist. + */ +int +dialog_checklist (const char *title, const char *prompt, int height, int width, + int list_height, int item_no, struct dialog_list_item ** items, + int flag) + +{ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; + WINDOW *dialog, *list; + + checkflag = flag; + + /* Allocate space for storing item on/off status */ + if ((status = malloc (sizeof (int) * item_no)) == NULL) { + endwin (); + fprintf (stderr, + "\nCan't allocate memory in dialog_checklist().\n"); + exit (-1); + } + + /* Initializes status */ + for (i = 0; i < item_no; i++) { + status[i] = items[i]->selected; + if (!choice && status[i]) + choice = i; + } + + max_choice = MIN (list_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1); + + keypad (list, TRUE); + + /* draw a box around the list items */ + draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, + menubox_border_attr, menubox_attr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + for (i = 0; i < item_no; i++) + check_x = MAX (check_x, + strlen (items[i]->name) + 4); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + print_item (list, items[scroll + i]->name, + status[i+scroll], i, i == choice); + } + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh (list); + wnoutrefresh (dialog); + doupdate (); + + while (key != ESC) { + key = wgetch (dialog); + + for (i = 0; i < max_choice; i++) + if (toupper(key) == toupper(items[scroll + i]->name[0])) + break; + + + if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-' ) { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + print_item (list, items[scroll]->name, + status[scroll], 0, FALSE); + scrollok (list, TRUE); + wscrl (list, -1); + scrollok (list, FALSE); + } + scroll--; + print_item (list, items[scroll]->name, + status[scroll], 0, TRUE); + wnoutrefresh (list); + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + wrefresh (dialog); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_no - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + print_item (list, items[scroll + max_choice - 1]->name, + status[scroll + max_choice - 1], + max_choice - 1, FALSE); + scrollok (list, TRUE); + scroll (list); + scrollok (list, FALSE); + } + scroll++; + print_item (list, items[scroll + max_choice - 1]->name, + status[scroll + max_choice - 1], + max_choice - 1, TRUE); + wnoutrefresh (list); + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + wrefresh (dialog); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + print_item (list, items[scroll + choice]->name, + status[scroll + choice], choice, FALSE); + /* Highlight new item */ + choice = i; + print_item (list, items[scroll + choice]->name, + status[scroll + choice], choice, TRUE); + wnoutrefresh (list); + wrefresh (dialog); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + delwin (dialog); + free (status); + return 1; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh (dialog); + break; + case 'S': + case 's': + case ' ': + case '\n': + if (!button) { + if (flag == FLAG_CHECK) { + status[scroll + choice] = !status[scroll + choice]; + wmove (list, choice, check_x); + wattrset (list, check_selected_attr); + wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); + } else { + if (!status[scroll + choice]) { + for (i = 0; i < item_no; i++) + status[i] = 0; + status[scroll + choice] = 1; + for (i = 0; i < max_choice; i++) + print_item (list, items[scroll + i]->name, + status[scroll + i], i, i == choice); + } + } + wnoutrefresh (list); + wrefresh (dialog); + + for (i = 0; i < item_no; i++) { + items[i]->selected = status[i]; + } + } + delwin (dialog); + free (status); + return button; + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + + /* Now, update everything... */ + doupdate (); + } + + + delwin (dialog); + free (status); + return -1; /* ESC pressed */ +} diff --git a/extra/config/colors.h b/extra/config/colors.h new file mode 100644 index 0000000..d34dd37 --- /dev/null +++ b/extra/config/colors.h @@ -0,0 +1,161 @@ +/* + * colors.h -- color attribute definitions + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * Default color definitions + * + * *_FG = foreground + * *_BG = background + * *_HL = highlight? + */ +#define SCREEN_FG COLOR_CYAN +#define SCREEN_BG COLOR_BLUE +#define SCREEN_HL TRUE + +#define SHADOW_FG COLOR_BLACK +#define SHADOW_BG COLOR_BLACK +#define SHADOW_HL TRUE + +#define DIALOG_FG COLOR_BLACK +#define DIALOG_BG COLOR_WHITE +#define DIALOG_HL FALSE + +#define TITLE_FG COLOR_YELLOW +#define TITLE_BG COLOR_WHITE +#define TITLE_HL TRUE + +#define BORDER_FG COLOR_WHITE +#define BORDER_BG COLOR_WHITE +#define BORDER_HL TRUE + +#define BUTTON_ACTIVE_FG COLOR_WHITE +#define BUTTON_ACTIVE_BG COLOR_BLUE +#define BUTTON_ACTIVE_HL TRUE + +#define BUTTON_INACTIVE_FG COLOR_BLACK +#define BUTTON_INACTIVE_BG COLOR_WHITE +#define BUTTON_INACTIVE_HL FALSE + +#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE +#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE +#define BUTTON_KEY_ACTIVE_HL TRUE + +#define BUTTON_KEY_INACTIVE_FG COLOR_RED +#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE +#define BUTTON_KEY_INACTIVE_HL FALSE + +#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW +#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE +#define BUTTON_LABEL_ACTIVE_HL TRUE + +#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK +#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE +#define BUTTON_LABEL_INACTIVE_HL TRUE + +#define INPUTBOX_FG COLOR_BLACK +#define INPUTBOX_BG COLOR_WHITE +#define INPUTBOX_HL FALSE + +#define INPUTBOX_BORDER_FG COLOR_BLACK +#define INPUTBOX_BORDER_BG COLOR_WHITE +#define INPUTBOX_BORDER_HL FALSE + +#define SEARCHBOX_FG COLOR_BLACK +#define SEARCHBOX_BG COLOR_WHITE +#define SEARCHBOX_HL FALSE + +#define SEARCHBOX_TITLE_FG COLOR_YELLOW +#define SEARCHBOX_TITLE_BG COLOR_WHITE +#define SEARCHBOX_TITLE_HL TRUE + +#define SEARCHBOX_BORDER_FG COLOR_WHITE +#define SEARCHBOX_BORDER_BG COLOR_WHITE +#define SEARCHBOX_BORDER_HL TRUE + +#define POSITION_INDICATOR_FG COLOR_YELLOW +#define POSITION_INDICATOR_BG COLOR_WHITE +#define POSITION_INDICATOR_HL TRUE + +#define MENUBOX_FG COLOR_BLACK +#define MENUBOX_BG COLOR_WHITE +#define MENUBOX_HL FALSE + +#define MENUBOX_BORDER_FG COLOR_WHITE +#define MENUBOX_BORDER_BG COLOR_WHITE +#define MENUBOX_BORDER_HL TRUE + +#define ITEM_FG COLOR_BLACK +#define ITEM_BG COLOR_WHITE +#define ITEM_HL FALSE + +#define ITEM_SELECTED_FG COLOR_WHITE +#define ITEM_SELECTED_BG COLOR_BLUE +#define ITEM_SELECTED_HL TRUE + +#define TAG_FG COLOR_YELLOW +#define TAG_BG COLOR_WHITE +#define TAG_HL TRUE + +#define TAG_SELECTED_FG COLOR_YELLOW +#define TAG_SELECTED_BG COLOR_BLUE +#define TAG_SELECTED_HL TRUE + +#define TAG_KEY_FG COLOR_YELLOW +#define TAG_KEY_BG COLOR_WHITE +#define TAG_KEY_HL TRUE + +#define TAG_KEY_SELECTED_FG COLOR_YELLOW +#define TAG_KEY_SELECTED_BG COLOR_BLUE +#define TAG_KEY_SELECTED_HL TRUE + +#define CHECK_FG COLOR_BLACK +#define CHECK_BG COLOR_WHITE +#define CHECK_HL FALSE + +#define CHECK_SELECTED_FG COLOR_WHITE +#define CHECK_SELECTED_BG COLOR_BLUE +#define CHECK_SELECTED_HL TRUE + +#define UARROW_FG COLOR_GREEN +#define UARROW_BG COLOR_WHITE +#define UARROW_HL TRUE + +#define DARROW_FG COLOR_GREEN +#define DARROW_BG COLOR_WHITE +#define DARROW_HL TRUE + +/* End of default color definitions */ + +#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) +#define COLOR_NAME_LEN 10 +#define COLOR_COUNT 8 + +/* + * Global variables + */ + +typedef struct { + char name[COLOR_NAME_LEN]; + int value; +} color_names_st; + +extern color_names_st color_names[]; +extern int color_table[][3]; diff --git a/extra/config/conf.c b/extra/config/conf.c new file mode 100644 index 0000000..20ea2c9 --- /dev/null +++ b/extra/config/conf.c @@ -0,0 +1,566 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +static void conf(struct menu *menu); +static void check_conf(struct menu *menu); + +enum { + ask_all, + ask_new, + ask_silent, + set_default, + set_yes, + set_mod, + set_no, + set_random +} input_mode = ask_all; + +static int indent = 1; +static int valid_stdin = 1; +static int conf_cnt; +static char line[128]; +static struct menu *rootEntry; + +static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; + +static void strip(char *str) +{ + char *p = str; + int l; + + while ((isspace(*p))) + p++; + l = strlen(p); + if (p != str) + memmove(str, p, l + 1); + if (!l) + return; + p = str + l - 1; + while ((isspace(*p))) + *p-- = 0; +} + +static void check_stdin(void) +{ + if (!valid_stdin && input_mode == ask_silent) { + printf("aborted!\n\n"); + printf("Console input/output is redirected. "); + printf("Run 'make oldconfig' to update configuration.\n\n"); + exit(1); + } +} + +static void conf_askvalue(struct symbol *sym, const char *def) +{ + enum symbol_type type = sym_get_type(sym); + tristate val; + + if (!sym_has_value(sym)) + printf("(NEW) "); + + line[0] = '\n'; + line[1] = 0; + + if (!sym_is_changable(sym)) { + printf("%s\n", def); + line[0] = '\n'; + line[1] = 0; + return; + } + + switch (input_mode) { + case ask_new: + case ask_silent: + if (sym_has_value(sym)) { + printf("%s\n", def); + return; + } + check_stdin(); + case ask_all: + fflush(stdout); + fgets(line, 128, stdin); + return; + case set_default: + printf("%s\n", def); + return; + default: + break; + } + + switch (type) { + case S_INT: + case S_HEX: + case S_STRING: + printf("%s\n", def); + return; + default: + ; + } + switch (input_mode) { + case set_yes: + if (sym_tristate_within_range(sym, yes)) { + line[0] = 'y'; + line[1] = '\n'; + line[2] = 0; + break; + } + case set_mod: + if (type == S_TRISTATE) { + if (sym_tristate_within_range(sym, mod)) { + line[0] = 'm'; + line[1] = '\n'; + line[2] = 0; + break; + } + } else { + if (sym_tristate_within_range(sym, yes)) { + line[0] = 'y'; + line[1] = '\n'; + line[2] = 0; + break; + } + } + case set_no: + if (sym_tristate_within_range(sym, no)) { + line[0] = 'n'; + line[1] = '\n'; + line[2] = 0; + break; + } + case set_random: + do { + val = (tristate)(random() % 3); + } while (!sym_tristate_within_range(sym, val)); + switch (val) { + case no: line[0] = 'n'; break; + case mod: line[0] = 'm'; break; + case yes: line[0] = 'y'; break; + } + line[1] = '\n'; + line[2] = 0; + break; + default: + break; + } + printf("%s", line); +} + +int conf_string(struct menu *menu) +{ + struct symbol *sym = menu->sym; + const char *def, *help; + + while (1) { + printf("%*s%s ", indent - 1, "", menu->prompt->text); + printf("(%s) ", sym->name); + def = sym_get_string_value(sym); + if (sym_get_string_value(sym)) + printf("[%s] ", def); + conf_askvalue(sym, def); + switch (line[0]) { + case '\n': + break; + case '?': + /* print help */ + if (line[1] == 0) { + help = nohelp_text; + if (menu->sym->help) + help = menu->sym->help; + printf("\n%s\n", menu->sym->help); + def = NULL; + break; + } + default: + line[strlen(line)-1] = 0; + def = line; + } + if (def && sym_set_string_value(sym, def)) + return 0; + } +} + +static int conf_sym(struct menu *menu) +{ + struct symbol *sym = menu->sym; + int type; + tristate oldval, newval; + const char *help; + + while (1) { + printf("%*s%s ", indent - 1, "", menu->prompt->text); + if (sym->name) + printf("(%s) ", sym->name); + type = sym_get_type(sym); + putchar('['); + oldval = sym_get_tristate_value(sym); + switch (oldval) { + case no: + putchar('N'); + break; + case mod: + putchar('M'); + break; + case yes: + putchar('Y'); + break; + } + if (oldval != no && sym_tristate_within_range(sym, no)) + printf("/n"); + if (oldval != mod && sym_tristate_within_range(sym, mod)) + printf("/m"); + if (oldval != yes && sym_tristate_within_range(sym, yes)) + printf("/y"); + if (sym->help) + printf("/?"); + printf("] "); + conf_askvalue(sym, sym_get_string_value(sym)); + strip(line); + + switch (line[0]) { + case 'n': + case 'N': + newval = no; + if (!line[1] || !strcmp(&line[1], "o")) + break; + continue; + case 'm': + case 'M': + newval = mod; + if (!line[1]) + break; + continue; + case 'y': + case 'Y': + newval = yes; + if (!line[1] || !strcmp(&line[1], "es")) + break; + continue; + case 0: + newval = oldval; + break; + case '?': + goto help; + default: + continue; + } + if (sym_set_tristate_value(sym, newval)) + return 0; +help: + help = nohelp_text; + if (sym->help) + help = sym->help; + printf("\n%s\n", help); + } +} + +static int conf_choice(struct menu *menu) +{ + struct symbol *sym, *def_sym; + struct menu *child; + int type; + bool is_new; + + sym = menu->sym; + type = sym_get_type(sym); + is_new = !sym_has_value(sym); + if (sym_is_changable(sym)) { + conf_sym(menu); + sym_calc_value(sym); + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: + return 0; + case yes: + break; + } + } else { + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: + printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + return 0; + case yes: + break; + } + } + + while (1) { + int cnt, def; + + printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + def_sym = sym_get_choice_value(sym); + cnt = def = 0; + line[0] = '0'; + line[1] = 0; + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + if (!child->sym) { + printf("%*c %s\n", indent, '*', menu_get_prompt(child)); + continue; + } + cnt++; + if (child->sym == def_sym) { + def = cnt; + printf("%*c", indent, '>'); + } else + printf("%*c", indent, ' '); + printf(" %d. %s", cnt, menu_get_prompt(child)); + if (child->sym->name) + printf(" (%s)", child->sym->name); + if (!sym_has_value(child->sym)) + printf(" (NEW)"); + printf("\n"); + } + printf("%*schoice", indent - 1, ""); + if (cnt == 1) { + printf("[1]: 1\n"); + goto conf_childs; + } + printf("[1-%d", cnt); + if (sym->help) + printf("?"); + printf("]: "); + switch (input_mode) { + case ask_new: + case ask_silent: + if (!is_new) { + cnt = def; + printf("%d\n", cnt); + break; + } + check_stdin(); + case ask_all: + fflush(stdout); + fgets(line, 128, stdin); + strip(line); + if (line[0] == '?') { + printf("\n%s\n", menu->sym->help ? + menu->sym->help : nohelp_text); + continue; + } + if (!line[0]) + cnt = def; + else if (isdigit(line[0])) + cnt = atoi(line); + else + continue; + break; + case set_random: + def = (random() % cnt) + 1; + case set_default: + case set_yes: + case set_mod: + case set_no: + cnt = def; + printf("%d\n", cnt); + break; + } + + conf_childs: + for (child = menu->list; child; child = child->next) { + if (!child->sym || !menu_is_visible(child)) + continue; + if (!--cnt) + break; + } + if (!child) + continue; + if (line[strlen(line) - 1] == '?') { + printf("\n%s\n", child->sym->help ? + child->sym->help : nohelp_text); + continue; + } + sym_set_choice_value(sym, child->sym); + if (child->list) { + indent += 2; + conf(child->list); + indent -= 2; + } + return 1; + } +} + +static void conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + prop = menu->prompt; + if (prop) { + const char *prompt; + + switch (prop->type) { + case P_MENU: + if (input_mode == ask_silent && rootEntry != menu) { + check_conf(menu); + return; + } + case P_COMMENT: + prompt = menu_get_prompt(menu); + if (prompt) + printf("%*c\n%*c %s\n%*c\n", + indent, '*', + indent, '*', prompt, + indent, '*'); + default: + ; + } + } + + if (!sym) + goto conf_childs; + + if (sym_is_choice(sym)) { + conf_choice(menu); + if (sym->curr.tri != mod) + return; + goto conf_childs; + } + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + conf_string(menu); + break; + default: + conf_sym(menu); + break; + } + +conf_childs: + if (sym) + indent += 2; + for (child = menu->list; child; child = child->next) + conf(child); + if (sym) + indent -= 2; +} + +static void check_conf(struct menu *menu) +{ + struct symbol *sym; + struct menu *child; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + if (sym) { + if (sym_is_changable(sym) && !sym_has_value(sym)) { + if (!conf_cnt++) + printf("*\n* Restart config...\n*\n"); + rootEntry = menu_get_parent_menu(menu); + conf(rootEntry); + } + if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod) + return; + } + + for (child = menu->list; child; child = child->next) + check_conf(child); +} + +int main(int ac, char **av) +{ + const char *name; + struct stat tmpstat; + + if (ac > 1 && av[1][0] == '-') { + switch (av[1][1]) { + case 'o': + input_mode = ask_new; + break; + case 's': + input_mode = ask_silent; + valid_stdin = isatty(0) && isatty(1) && isatty(2); + break; + case 'd': + input_mode = set_default; + break; + case 'n': + input_mode = set_no; + break; + case 'm': + input_mode = set_mod; + break; + case 'y': + input_mode = set_yes; + break; + case 'r': + input_mode = set_random; + srandom(time(NULL)); + break; + case 'h': + case '?': + printf("%s [-o|-s] config\n", av[0]); + exit(0); + } + name = av[2]; + } else + name = av[1]; + conf_parse(name); + //zconfdump(stdout); + switch (input_mode) { + case set_default: + name = conf_get_default_confname(); + if (conf_read(name)) { + printf("***\n" + "*** Can't find default configuration \"%s\"!\n" + "***\n", name); + exit(1); + } + break; + case ask_silent: + if (stat(".config", &tmpstat)) { + printf("***\n" + "*** You have not yet configured uClibc!\n" + "***\n" + "*** Please run some configurator (e.g. \"make config\" or\n" + "*** \"make oldconfig\" or \"make menuconfig\").\n" + "***\n"); + exit(1); + } + case ask_all: + case ask_new: + conf_read(NULL); + break; + default: + break; + } + + if (input_mode != ask_silent) { + rootEntry = &rootmenu; + conf(&rootmenu); + if (input_mode == ask_all) { + input_mode = ask_silent; + valid_stdin = 1; + } + } + do { + conf_cnt = 0; + check_conf(&rootmenu); + } while (conf_cnt); + conf_write(NULL); + return 0; +} diff --git a/extra/config/confdata.c b/extra/config/confdata.c new file mode 100644 index 0000000..e3f279c --- /dev/null +++ b/extra/config/confdata.c @@ -0,0 +1,435 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +const char conf_def_filename[] = ".config"; + +const char conf_defname[] = "extra/Configs/Config.default"; + +const char *conf_confnames[] = { + ".config", + conf_defname, + NULL, +}; + +static char *conf_expand_value(const char *in) +{ + struct symbol *sym; + const char *src; + static char res_value[SYMBOL_MAXLENGTH]; + char *dst, name[SYMBOL_MAXLENGTH]; + + res_value[0] = 0; + dst = name; + while ((src = strchr(in, '$'))) { + strncat(res_value, in, src - in); + src++; + dst = name; + while (isalnum(*src) || *src == '_') + *dst++ = *src++; + *dst = 0; + sym = sym_lookup(name, 0); + sym_calc_value(sym); + strcat(res_value, sym_get_string_value(sym)); + in = src; + } + strcat(res_value, in); + + return res_value; +} + +char *conf_get_default_confname(void) +{ + struct stat buf; + static char fullname[4096+1]; + char *env, *name; + + name = conf_expand_value(conf_defname); + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + if (!stat(fullname, &buf)) + return fullname; + } + return name; +} + +int conf_read(const char *name) +{ + FILE *in = NULL; + char line[1024]; + char *p, *p2; + int lineno = 0; + struct symbol *sym; + struct property *prop; + struct expr *e; + int i; + + if (name) { + in = zconf_fopen(name); + } else { + const char **names = conf_confnames; + while ((name = *names++)) { + name = conf_expand_value(name); + in = zconf_fopen(name); + if (in) { + printf("#\n" + "# using defaults found in %s\n" + "#\n", name); + break; + } + } + } + + if (!in) + return 1; + + for_all_symbols(i, sym) { + sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; + sym->flags &= ~SYMBOL_VALID; + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + if (sym->user.val) + free(sym->user.val); + default: + sym->user.val = NULL; + sym->user.tri = no; + } + } + + while (fgets(line, sizeof(line), in)) { + lineno++; + sym = NULL; + switch (line[0]) { + case '#': + if (line[1]!=' ') + continue; + p = strchr(line + 2, ' '); + if (!p) + continue; + *p++ = 0; + if (strncmp(p, "is not set", 10)) + continue; + sym = sym_find(line + 2); + if (!sym) { + fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2); + break; + } + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + sym->user.tri = no; + sym->flags &= ~SYMBOL_NEW; + break; + default: + ; + } + break; + + case 'A' ... 'Z': + p = strchr(line, '='); + if (!p) + continue; + *p++ = 0; + p2 = strchr(p, '\n'); + if (p2) + *p2 = 0; + sym = sym_find(line); + if (!sym) { + fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); + break; + } + switch (sym->type) { + case S_TRISTATE: + if (p[0] == 'm') { + sym->user.tri = mod; + sym->flags &= ~SYMBOL_NEW; + break; + } + case S_BOOLEAN: + if (p[0] == 'y') { + sym->user.tri = yes; + sym->flags &= ~SYMBOL_NEW; + break; + } + if (p[0] == 'n') { + sym->user.tri = no; + sym->flags &= ~SYMBOL_NEW; + break; + } + break; + case S_STRING: + if (*p++ != '"') + break; + for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { + if (*p2 == '"') { + *p2 = 0; + break; + } + memmove(p2, p2 + 1, strlen(p2)); + } + if (!p2) { + fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); + exit(1); + } + case S_INT: + case S_HEX: + if (sym_string_valid(sym, p)) { + sym->user.val = strdup(p); + sym->flags &= ~SYMBOL_NEW; + } else { + fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); + exit(1); + } + break; + default: + ; + } + break; + case '\n': + break; + default: + continue; + } + if (sym && sym_is_choice_value(sym)) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + switch (sym->user.tri) { + case no: + break; + case mod: + if (cs->user.tri == yes) + /* warn? */; + break; + case yes: + if (cs->user.tri != no) + /* warn? */; + cs->user.val = sym; + break; + } + cs->user.tri = E_OR(cs->user.tri, sym->user.tri); + cs->flags &= ~SYMBOL_NEW; + } + } + fclose(in); + + for_all_symbols(i, sym) { + sym_calc_value(sym); + if (sym_has_value(sym) && !sym_is_choice_value(sym)) { + if (sym->visible == no) + sym->flags |= SYMBOL_NEW; + switch (sym->type) { + case S_STRING: + case S_INT: + case S_HEX: + if (!sym_string_within_range(sym, sym->user.val)) + sym->flags |= SYMBOL_NEW; + default: + break; + } + } + if (!sym_is_choice(sym)) + continue; + prop = sym_get_choice_prop(sym); + for (e = prop->expr; e; e = e->left.expr) + if (e->right.sym->visible != no) + sym->flags |= e->right.sym->flags & SYMBOL_NEW; + } + + sym_change_count = 1; + + return 0; +} + +int conf_write(const char *name) +{ + FILE *out, *out_h; + struct symbol *sym; + struct menu *menu; + const char *basename; + char dirname[128], tmpname[128], newname[128]; + int type, l; + const char *str; + + dirname[0] = 0; + if (name && name[0]) { + char *slash = strrchr(name, '/'); + if (slash) { + int size = slash - name + 1; + memcpy(dirname, name, size); + dirname[size] = 0; + if (slash[1]) + basename = slash + 1; + else + basename = conf_def_filename; + } else + basename = name; + } else + basename = conf_def_filename; + + sprintf(newname, "%s.tmpconfig.%d", dirname, getpid()); + out = fopen(newname, "w"); + if (!out) + return 1; + out_h = NULL; + if (!name) { + out_h = fopen(".tmpconfig.h", "w"); + if (!out_h) + return 1; + } + fprintf(out, "#\n" + "# Automatically generated make config: don't edit\n" + "#\n"); + if (out_h) + fprintf(out_h, "/*\n" + " * Automatically generated C config: don't edit\n" + " */\n" + "/*\n" + " * Version Number\n" + " */\n" + "#define __UCLIBCXX_MAJOR__ %s\n" + "#define __UCLIBCXX_MINOR__ %s\n" + "#define __UCLIBCXX_SUBLEVEL__ %s\n", + getenv("MAJOR_VERSION"), + getenv("MINOR_VERSION"), + getenv("SUBLEVEL")); + + if (!sym_change_count) + sym_clear_all_valid(); + + menu = rootmenu.list; + while (menu) { + sym = menu->sym; + if (!sym) { + if (!menu_is_visible(menu)) + goto next; + str = menu_get_prompt(menu); + fprintf(out, "\n" + "#\n" + "# %s\n" + "#\n", str); + if (out_h) + fprintf(out_h, "\n" + "/*\n" + " * %s\n" + " */\n", str); + } else if (!(sym->flags & SYMBOL_CHOICE)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE)) + goto next; + sym->flags &= ~SYMBOL_WRITE; + type = sym->type; + if (type == S_TRISTATE) { + sym_calc_value(modules_sym); + if (modules_sym->curr.tri == no) + type = S_BOOLEAN; + } + switch (type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (sym_get_tristate_value(sym)) { + case no: + fprintf(out, "# %s is not set\n", sym->name); + if (out_h) + fprintf(out_h, "#undef __%s__\n", sym->name); + break; + case mod: + fprintf(out, "%s=m\n", sym->name); + if (out_h) + fprintf(out_h, "#define %s_MODULE 1\n", sym->name); + break; + case yes: + fprintf(out, "%s=y\n", sym->name); + if (out_h) + fprintf(out_h, "#define __%s__ 1\n", sym->name); + break; + } + break; + case S_STRING: + // fix me + str = sym_get_string_value(sym); + fprintf(out, "%s=\"", sym->name); + if (out_h) + fprintf(out_h, "#define __%s__ \"", sym->name); + do { + l = strcspn(str, "\"\\"); + if (l) { + fwrite(str, l, 1, out); + if (out_h) + fwrite(str, l, 1, out_h); + } + str += l; + while (*str == '\\' || *str == '"') { + fprintf(out, "\\%c", *str); + if (out_h) + fprintf(out_h, "\\%c", *str); + str++; + } + } while (*str); + fputs("\"\n", out); + if (out_h) + fputs("\"\n", out_h); + break; + case S_HEX: + str = sym_get_string_value(sym); + if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { + fprintf(out, "%s=%s\n", sym->name, str); + if (out_h) + fprintf(out_h, "#define __%s__ 0x%s\n", sym->name, str); + break; + } + case S_INT: + str = sym_get_string_value(sym); + fprintf(out, "%s=%s\n", sym->name, str); + if (out_h) + fprintf(out_h, "#define __%s__ %s\n", sym->name, str); + break; + } + } + + next: + if (menu->list) { + menu = menu->list; + continue; + } + if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->next) { + menu = menu->next; + break; + } + } + } + fclose(out); + if (out_h) { + fclose(out_h); + rename(".tmpconfig.h", "include/system_configuration.h"); + file_write_dep(NULL); + } + if (!name || basename != conf_def_filename) { + if (!name) + name = conf_def_filename; + sprintf(tmpname, "%s.old", name); + rename(name, tmpname); + } + sprintf(tmpname, "%s%s", dirname, basename); + if (rename(newname, tmpname)) + return 1; + + sym_change_count = 0; + + return 0; +} diff --git a/extra/config/dialog.h b/extra/config/dialog.h new file mode 100644 index 0000000..8116cee --- /dev/null +++ b/extra/config/dialog.h @@ -0,0 +1,196 @@ + +/* + * dialog.h -- common declarations for all dialog modules + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef CURSES_LOC +#include CURSES_LOC + +/* + * Colors in ncurses 1.9.9e do not work properly since foreground and + * background colors are OR'd rather than separately masked. This version + * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible + * with standard curses. The simplest fix (to make this work with standard + * curses) uses the wbkgdset() function, not used in the original hack. + * Turn it off if we're building with 1.9.9e, since it just confuses things. + */ +#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) +#define OLD_NCURSES 1 +#undef wbkgdset +#define wbkgdset(w,p) /*nothing*/ +#else +#define OLD_NCURSES 0 +#endif + +#define TR(params) _tracef params + +#define ESC 27 +#define TAB 9 +#define MAX_LEN 2048 +#define BUF_SIZE (10*1024) +#define MIN(x,y) (x < y ? x : y) +#define MAX(x,y) (x > y ? x : y) + + +#ifndef ACS_ULCORNER +#define ACS_ULCORNER '+' +#endif +#ifndef ACS_LLCORNER +#define ACS_LLCORNER '+' +#endif +#ifndef ACS_URCORNER +#define ACS_URCORNER '+' +#endif +#ifndef ACS_LRCORNER +#define ACS_LRCORNER '+' +#endif +#ifndef ACS_HLINE +#define ACS_HLINE '-' +#endif +#ifndef ACS_VLINE +#define ACS_VLINE '|' +#endif +#ifndef ACS_LTEE +#define ACS_LTEE '+' +#endif +#ifndef ACS_RTEE +#define ACS_RTEE '+' +#endif +#ifndef ACS_UARROW +#define ACS_UARROW '^' +#endif +#ifndef ACS_DARROW +#define ACS_DARROW 'v' +#endif + +/* + * Attribute names + */ +#define screen_attr attributes[0] +#define shadow_attr attributes[1] +#define dialog_attr attributes[2] +#define title_attr attributes[3] +#define border_attr attributes[4] +#define button_active_attr attributes[5] +#define button_inactive_attr attributes[6] +#define button_key_active_attr attributes[7] +#define button_key_inactive_attr attributes[8] +#define button_label_active_attr attributes[9] +#define button_label_inactive_attr attributes[10] +#define inputbox_attr attributes[11] +#define inputbox_border_attr attributes[12] +#define searchbox_attr attributes[13] +#define searchbox_title_attr attributes[14] +#define searchbox_border_attr attributes[15] +#define position_indicator_attr attributes[16] +#define menubox_attr attributes[17] +#define menubox_border_attr attributes[18] +#define item_attr attributes[19] +#define item_selected_attr attributes[20] +#define tag_attr attributes[21] +#define tag_selected_attr attributes[22] +#define tag_key_attr attributes[23] +#define tag_key_selected_attr attributes[24] +#define check_attr attributes[25] +#define check_selected_attr attributes[26] +#define uarrow_attr attributes[27] +#define darrow_attr attributes[28] + +/* number of attributes */ +#define ATTRIBUTE_COUNT 29 + +/* + * Global variables + */ +extern bool use_colors; + +extern chtype attributes[]; +#endif + +extern char *backtitle; + +struct dialog_list_item { + char *name; + int namelen; + char *tag; + int selected; /* Set to 1 by dialog_*() function. */ +}; + +/* + * Function prototypes + */ + +void init_dialog (void); +void end_dialog (void); +void dialog_clear (void); +#ifdef CURSES_LOC +void attr_clear (WINDOW * win, int height, int width, chtype attr); +void color_setup (void); +void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); +void print_button (WINDOW * win, const char *label, int y, int x, int selected); +void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow (WINDOW * win, int y, int x, int height, int width); +#endif + +int first_alpha (const char *string, const char *exempt); +int dialog_yesno (const char *title, const char *prompt, int height, int width); +int dialog_msgbox (const char *title, const char *prompt, int height, + int width, int pause); +int dialog_textbox (const char *title, const char *file, int height, int width); +int dialog_menu (const char *title, const char *prompt, int height, int width, + int menu_height, const char *choice, int item_no, + struct dialog_list_item ** items); +int dialog_checklist (const char *title, const char *prompt, int height, + int width, int list_height, int item_no, + struct dialog_list_item ** items, int flag); +extern unsigned char dialog_input_result[]; +int dialog_inputbox (const char *title, const char *prompt, int height, + int width, const char *init); + +struct dialog_list_item *first_sel_item(int item_no, + struct dialog_list_item ** items); + +/* + * This is the base for fictitious keys, which activate + * the buttons. + * + * Mouse-generated keys are the following: + * -- the first 32 are used as numbers, in addition to '0'-'9' + * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') + * -- uppercase chars are used to invoke the button (M_EVENT + 'O') + */ +#ifdef CURSES_LOC +#define M_EVENT (KEY_MAX+1) +#endif + + +/* + * The `flag' parameter in checklist is used to select between + * radiolist and checklist + */ +#define FLAG_CHECK 1 +#define FLAG_RADIO 0 diff --git a/extra/config/expr.c b/extra/config/expr.c new file mode 100644 index 0000000..3f15ae8 --- /dev/null +++ b/extra/config/expr.c @@ -0,0 +1,1083 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +struct expr *expr_alloc_symbol(struct symbol *sym) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = E_SYMBOL; + e->left.sym = sym; + return e; +} + +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.expr = ce; + return e; +} + +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.expr = e1; + e->right.expr = e2; + return e; +} + +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.sym = s1; + e->right.sym = s2; + return e; +} + +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_AND, e1, e2) : e1; +} + +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; +} + +struct expr *expr_copy(struct expr *org) +{ + struct expr *e; + + if (!org) + return NULL; + + e = malloc(sizeof(*org)); + memcpy(e, org, sizeof(*org)); + switch (org->type) { + case E_SYMBOL: + e->left = org->left; + break; + case E_NOT: + e->left.expr = expr_copy(org->left.expr); + break; + case E_EQUAL: + case E_UNEQUAL: + e->left.sym = org->left.sym; + e->right.sym = org->right.sym; + break; + case E_AND: + case E_OR: + case E_CHOICE: + e->left.expr = expr_copy(org->left.expr); + e->right.expr = expr_copy(org->right.expr); + break; + default: + printf("can't copy type %d\n", e->type); + free(e); + e = NULL; + break; + } + + return e; +} + +void expr_free(struct expr *e) +{ + if (!e) + return; + + switch (e->type) { + case E_SYMBOL: + break; + case E_NOT: + expr_free(e->left.expr); + return; + case E_EQUAL: + case E_UNEQUAL: + break; + case E_OR: + case E_AND: + expr_free(e->left.expr); + expr_free(e->right.expr); + break; + default: + printf("how to free type %d?\n", e->type); + break; + } + free(e); +} + +static int trans_count; + +#define e1 (*ep1) +#define e2 (*ep2) + +static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ + if (e1->type == type) { + __expr_eliminate_eq(type, &e1->left.expr, &e2); + __expr_eliminate_eq(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + __expr_eliminate_eq(type, &e1, &e2->left.expr); + __expr_eliminate_eq(type, &e1, &e2->right.expr); + return; + } + if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO))) + return; + if (!expr_eq(e1, e2)) + return; + trans_count++; + expr_free(e1); expr_free(e2); + switch (type) { + case E_OR: + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + break; + case E_AND: + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + break; + default: + ; + } +} + +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) +{ + if (!e1 || !e2) + return; + switch (e1->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e1->type, ep1, ep2); + default: + ; + } + if (e1->type != e2->type) switch (e2->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e2->type, ep1, ep2); + default: + ; + } + e1 = expr_eliminate_yn(e1); + e2 = expr_eliminate_yn(e2); +} + +#undef e1 +#undef e2 + +int expr_eq(struct expr *e1, struct expr *e2) +{ + int res, old_count; + + if (e1->type != e2->type) + return 0; + switch (e1->type) { + case E_EQUAL: + case E_UNEQUAL: + return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; + case E_SYMBOL: + return e1->left.sym == e2->left.sym; + case E_NOT: + return expr_eq(e1->left.expr, e2->left.expr); + case E_AND: + case E_OR: + e1 = expr_copy(e1); + e2 = expr_copy(e2); + old_count = trans_count; + expr_eliminate_eq(&e1, &e2); + res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym); + expr_free(e1); + expr_free(e2); + trans_count = old_count; + return res; + case E_CHOICE: + case E_RANGE: + case E_NONE: + /* panic */; + } + + print_expr(0, e1, 0); + printf(" = "); + print_expr(0, e2, 0); + printf(" ?\n"); + + return 0; +} + +struct expr *expr_eliminate_yn(struct expr *e) +{ + struct expr *tmp; + + if (e) switch (e->type) { + case E_AND: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } + } + break; + case E_OR: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + break; + default: + ; + } + return e; +} + +/* + * bool FOO!=n => FOO + */ +struct expr *expr_trans_bool(struct expr *e) +{ + if (!e) + return NULL; + switch (e->type) { + case E_AND: + case E_OR: + case E_NOT: + e->left.expr = expr_trans_bool(e->left.expr); + e->right.expr = expr_trans_bool(e->right.expr); + break; + case E_UNEQUAL: + // FOO!=n -> FOO + if (e->left.sym->type == S_TRISTATE) { + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + } + } + break; + default: + ; + } + return e; +} + +/* + * e1 || e2 -> ? + */ +struct expr *expr_join_or(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='m') -> (a!='n') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='n') -> (a!='m') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { + // (a='m') || (a='n') -> (a!='y') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes); + } + } + if (sym1->type == S_BOOLEAN && sym1 == sym2) { + if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || + (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) + return expr_alloc_symbol(&symbol_yes); + } + + printf("optimize "); + print_expr(0, e1, 0); + printf(" || "); + print_expr(0, e2, 0); + printf(" ?\n"); + return NULL; +} + +struct expr *expr_join_and(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) + // (a) && (a='y') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) + // (a) && (a!='n') -> (a) + return expr_alloc_symbol(sym1); + + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e1->right.sym; + if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e2->right.sym; + if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='m') -> (a='n') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_no); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) + // (a!='m') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || + (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) + return NULL; + } + printf("optimize "); + print_expr(0, e1, 0); + printf(" && "); + print_expr(0, e2, 0); + printf(" ?\n"); + return NULL; +} + +static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp; + + if (e1->type == type) { + expr_eliminate_dups1(type, &e1->left.expr, &e2); + expr_eliminate_dups1(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups1(type, &e1, &e2->left.expr); + expr_eliminate_dups1(type, &e1, &e2->right.expr); + return; + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e1->type, &e1, &e1); + default: + ; + } + + switch (type) { + case E_OR: + tmp = expr_join_or(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_no); + e2 = tmp; + trans_count++; + } + break; + case E_AND: + tmp = expr_join_and(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_yes); + e2 = tmp; + trans_count++; + } + break; + default: + ; + } +#undef e1 +#undef e2 +} + +static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp, *tmp1, *tmp2; + + if (e1->type == type) { + expr_eliminate_dups2(type, &e1->left.expr, &e2); + expr_eliminate_dups2(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups2(type, &e1, &e2->left.expr); + expr_eliminate_dups2(type, &e1, &e2->right.expr); + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: + expr_eliminate_dups2(e1->type, &e1, &e1); + // (FOO || BAR) && (!FOO && !BAR) -> n + tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); + tmp2 = expr_copy(e2); + tmp = expr_extract_eq_and(&tmp1, &tmp2); + if (expr_is_yes(tmp1)) { + expr_free(e1); + e1 = expr_alloc_symbol(&symbol_no); + trans_count++; + } + expr_free(tmp2); + expr_free(tmp1); + expr_free(tmp); + break; + case E_AND: + expr_eliminate_dups2(e1->type, &e1, &e1); + // (FOO && BAR) || (!FOO || !BAR) -> y + tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); + tmp2 = expr_copy(e2); + tmp = expr_extract_eq_or(&tmp1, &tmp2); + if (expr_is_no(tmp1)) { + expr_free(e1); + e1 = expr_alloc_symbol(&symbol_yes); + trans_count++; + } + expr_free(tmp2); + expr_free(tmp1); + expr_free(tmp); + break; + default: + ; + } +#undef e1 +#undef e2 +} + +struct expr *expr_eliminate_dups(struct expr *e) +{ + int oldcount; + if (!e) + return e; + + oldcount = trans_count; + while (1) { + trans_count = 0; + switch (e->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e->type, &e, &e); + expr_eliminate_dups2(e->type, &e, &e); + default: + ; + } + if (!trans_count) + break; + e = expr_eliminate_yn(e); + } + trans_count = oldcount; + return e; +} + +struct expr *expr_transform(struct expr *e) +{ + struct expr *tmp; + + if (!e) + return NULL; + switch (e->type) { + case E_EQUAL: + case E_UNEQUAL: + case E_SYMBOL: + case E_CHOICE: + break; + default: + e->left.expr = expr_transform(e->left.expr); + e->right.expr = expr_transform(e->right.expr); + } + + switch (e->type) { + case E_EQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + break; + case E_UNEQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + break; + case E_NOT: + switch (e->left.expr->type) { + case E_NOT: + // !!a -> a + tmp = e->left.expr->left.expr; + free(e->left.expr); + free(e); + e = tmp; + e = expr_transform(e); + break; + case E_EQUAL: + case E_UNEQUAL: + // !a='x' -> a!='x' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; + break; + case E_OR: + // !(a || b) -> !a && !b + tmp = e->left.expr; + e->type = E_AND; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_AND: + // !(a && b) -> !a || !b + tmp = e->left.expr; + e->type = E_OR; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_SYMBOL: + if (e->left.expr->left.sym == &symbol_yes) { + // !'y' -> 'n' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + break; + } + if (e->left.expr->left.sym == &symbol_mod) { + // !'m' -> 'm' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_mod; + break; + } + if (e->left.expr->left.sym == &symbol_no) { + // !'n' -> 'y' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + break; + } + break; + default: + ; + } + break; + default: + ; + } + return e; +} + +int expr_contains_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return 0; + + switch (dep->type) { + case E_AND: + case E_OR: + return expr_contains_symbol(dep->left.expr, sym) || + expr_contains_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + case E_UNEQUAL: + return dep->left.sym == sym || + dep->right.sym == sym; + case E_NOT: + return expr_contains_symbol(dep->left.expr, sym); + default: + ; + } + return 0; +} + +bool expr_depends_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return false; + + switch (dep->type) { + case E_AND: + return expr_depends_symbol(dep->left.expr, sym) || + expr_depends_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) + return true; + } + break; + case E_UNEQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_no) + return true; + } + break; + default: + ; + } + return false; +} + +struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) +{ + struct expr *tmp = NULL; + expr_extract_eq(E_AND, &tmp, ep1, ep2); + if (tmp) { + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); + } + return tmp; +} + +struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) +{ + struct expr *tmp = NULL; + expr_extract_eq(E_OR, &tmp, ep1, ep2); + if (tmp) { + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); + } + return tmp; +} + +void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + if (e1->type == type) { + expr_extract_eq(type, ep, &e1->left.expr, &e2); + expr_extract_eq(type, ep, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_extract_eq(type, ep, ep1, &e2->left.expr); + expr_extract_eq(type, ep, ep1, &e2->right.expr); + return; + } + if (expr_eq(e1, e2)) { + *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1; + expr_free(e2); + if (type == E_AND) { + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + } else if (type == E_OR) { + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + } + } +#undef e1 +#undef e2 +} + +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) +{ + struct expr *e1, *e2; + + if (!e) { + e = expr_alloc_symbol(sym); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + } + switch (e->type) { + case E_AND: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_AND, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_OR, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_OR: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_OR, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_AND, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_NOT: + return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); + case E_UNEQUAL: + case E_EQUAL: + if (type == E_EQUAL) { + if (sym == &symbol_yes) + return expr_copy(e); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_no); + if (sym == &symbol_no) + return expr_alloc_one(E_NOT, expr_copy(e)); + } else { + if (sym == &symbol_yes) + return expr_alloc_one(E_NOT, expr_copy(e)); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_yes); + if (sym == &symbol_no) + return expr_copy(e); + } + break; + case E_SYMBOL: + return expr_alloc_comp(type, e->left.sym, sym); + case E_CHOICE: + case E_RANGE: + case E_NONE: + /* panic */; + } + return NULL; +} + +tristate expr_calc_value(struct expr *e) +{ + tristate val1, val2; + const char *str1, *str2; + + if (!e) + return yes; + + switch (e->type) { + case E_SYMBOL: + sym_calc_value(e->left.sym); + return e->left.sym->curr.tri; + case E_AND: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return E_AND(val1, val2); + case E_OR: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return E_OR(val1, val2); + case E_NOT: + val1 = expr_calc_value(e->left.expr); + return E_NOT(val1); + case E_EQUAL: + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + return !strcmp(str1, str2) ? yes : no; + case E_UNEQUAL: + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + return !strcmp(str1, str2) ? no : yes; + default: + printf("expr_calc_value: %d?\n", e->type); + return no; + } +} + +int expr_compare_type(enum expr_type t1, enum expr_type t2) +{ +#if 0 + return 1; +#else + if (t1 == t2) + return 0; + switch (t1) { + case E_EQUAL: + case E_UNEQUAL: + if (t2 == E_NOT) + return 1; + case E_NOT: + if (t2 == E_AND) + return 1; + case E_AND: + if (t2 == E_OR) + return 1; + case E_OR: + if (t2 == E_CHOICE) + return 1; + case E_CHOICE: + if (t2 == 0) + return 1; + default: + return -1; + } + printf("[%dgt%d?]", t1, t2); + return 0; +#endif +} + +void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken) +{ + if (!e) { + fn(data, "y"); + return; + } + + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, "("); + switch (e->type) { + case E_SYMBOL: + if (e->left.sym->name) + fn(data, e->left.sym->name); + else + fn(data, ""); + break; + case E_NOT: + fn(data, "!"); + expr_print(e->left.expr, fn, data, E_NOT); + break; + case E_EQUAL: + fn(data, e->left.sym->name); + fn(data, "="); + fn(data, e->right.sym->name); + break; + case E_UNEQUAL: + fn(data, e->left.sym->name); + fn(data, "!="); + fn(data, e->right.sym->name); + break; + case E_OR: + expr_print(e->left.expr, fn, data, E_OR); + fn(data, " || "); + expr_print(e->right.expr, fn, data, E_OR); + break; + case E_AND: + expr_print(e->left.expr, fn, data, E_AND); + fn(data, " && "); + expr_print(e->right.expr, fn, data, E_AND); + break; + case E_CHOICE: + fn(data, e->right.sym->name); + if (e->left.expr) { + fn(data, " ^ "); + expr_print(e->left.expr, fn, data, E_CHOICE); + } + break; + case E_RANGE: + fn(data, "["); + fn(data, e->left.sym->name); + fn(data, " "); + fn(data, e->right.sym->name); + fn(data, "]"); + break; + default: + { + char buf[32]; + sprintf(buf, "", e->type); + fn(data, buf); + break; + } + } + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, ")"); +} + +static void expr_print_file_helper(void *data, const char *str) +{ + fwrite(str, strlen(str), 1, data); +} + +void expr_fprint(struct expr *e, FILE *out) +{ + expr_print(e, expr_print_file_helper, out, E_NONE); +} + +void print_expr(int mask, struct expr *e, int prevtoken) +{ + if (!(cdebug & mask)) + return; + expr_fprint(e, stdout); +} + diff --git a/extra/config/expr.h b/extra/config/expr.h new file mode 100644 index 0000000..cc616f1 --- /dev/null +++ b/extra/config/expr.h @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef EXPR_H +#define EXPR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifndef __cplusplus +#include +#endif + +struct file { + struct file *next; + struct file *parent; + char *name; + int lineno; + int flags; +}; + +#define FILE_BUSY 0x0001 +#define FILE_SCANNED 0x0002 +#define FILE_PRINTED 0x0004 + +typedef enum tristate { + no, mod, yes +} tristate; + +enum expr_type { + E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE +}; + +union expr_data { + struct expr *expr; + struct symbol *sym; +}; + +struct expr { + enum expr_type type; + union expr_data left, right; +}; + +#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) +#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) +#define E_NOT(dep) (2-(dep)) + +struct expr_value { + struct expr *expr; + tristate tri; +}; + +struct symbol_value { + void *val; + tristate tri; +}; + +enum symbol_type { + S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER +}; + +struct symbol { + struct symbol *next; + char *name; + char *help; + enum symbol_type type; + struct symbol_value curr, user; + tristate visible; + int flags; + struct property *prop; + struct expr *dep, *dep2; + struct expr_value rev_dep; +}; + +#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) + +#define SYMBOL_YES 0x0001 +#define SYMBOL_MOD 0x0002 +#define SYMBOL_NO 0x0004 +#define SYMBOL_CONST 0x0007 +#define SYMBOL_CHECK 0x0008 +#define SYMBOL_CHOICE 0x0010 +#define SYMBOL_CHOICEVAL 0x0020 +#define SYMBOL_PRINTED 0x0040 +#define SYMBOL_VALID 0x0080 +#define SYMBOL_OPTIONAL 0x0100 +#define SYMBOL_WRITE 0x0200 +#define SYMBOL_CHANGED 0x0400 +#define SYMBOL_NEW 0x0800 +#define SYMBOL_AUTO 0x1000 +#define SYMBOL_CHECKED 0x2000 +#define SYMBOL_CHECK_DONE 0x4000 +#define SYMBOL_WARNED 0x8000 + +#define SYMBOL_MAXLENGTH 256 +#define SYMBOL_HASHSIZE 257 +#define SYMBOL_HASHMASK 0xff + +enum prop_type { + P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE +}; + +struct property { + struct property *next; + struct symbol *sym; + enum prop_type type; + const char *text; + struct expr_value visible; + struct expr *expr; + struct menu *menu; + struct file *file; + int lineno; +}; + +#define for_all_properties(sym, st, tok) \ + for (st = sym->prop; st; st = st->next) \ + if (st->type == (tok)) +#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) +#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) +#define for_all_prompts(sym, st) \ + for (st = sym->prop; st; st = st->next) \ + if (st->text) + +struct menu { + struct menu *next; + struct menu *parent; + struct menu *list; + struct symbol *sym; + struct property *prompt; + struct expr *dep; + unsigned int flags; + //char *help; + struct file *file; + int lineno; + void *data; +}; + +#define MENU_CHANGED 0x0001 +#define MENU_ROOT 0x0002 + +#ifndef SWIG + +extern struct file *file_list; +extern struct file *current_file; +struct file *lookup_file(const char *name); + +extern struct symbol symbol_yes, symbol_no, symbol_mod; +extern struct symbol *modules_sym; +extern int cdebug; +struct expr *expr_alloc_symbol(struct symbol *sym); +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); +struct expr *expr_copy(struct expr *org); +void expr_free(struct expr *e); +int expr_eq(struct expr *e1, struct expr *e2); +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); +tristate expr_calc_value(struct expr *e); +struct expr *expr_eliminate_yn(struct expr *e); +struct expr *expr_trans_bool(struct expr *e); +struct expr *expr_eliminate_dups(struct expr *e); +struct expr *expr_transform(struct expr *e); +int expr_contains_symbol(struct expr *dep, struct symbol *sym); +bool expr_depends_symbol(struct expr *dep, struct symbol *sym); +struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); +struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); +void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); + +void expr_fprint(struct expr *e, FILE *out); +void print_expr(int mask, struct expr *e, int prevtoken); + +static inline int expr_is_yes(struct expr *e) +{ + return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); +} + +static inline int expr_is_no(struct expr *e) +{ + return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); +} +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EXPR_H */ diff --git a/extra/config/inputbox.c b/extra/config/inputbox.c new file mode 100644 index 0000000..fa7bebc --- /dev/null +++ b/extra/config/inputbox.c @@ -0,0 +1,240 @@ +/* + * inputbox.c -- implements the input box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +unsigned char dialog_input_result[MAX_LEN + 1]; + +/* + * Print the termination buttons + */ +static void +print_buttons(WINDOW *dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button (dialog, " Ok ", y, x, selected==0); + print_button (dialog, " Help ", y, x + 14, selected==1); + + wmove(dialog, y, x+1+14*selected); + wrefresh(dialog); +} + +/* + * Display a dialog box for inputing a string + */ +int +dialog_inputbox (const char *title, const char *prompt, int height, int width, + const char *init) +{ + int i, x, y, box_y, box_x, box_width; + int input_x = 0, scroll = 0, key = 0, button = -1; + unsigned char *instr = dialog_input_result; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx (dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, + border_attr, dialog_attr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove (dialog, box_y, box_x); + wattrset (dialog, inputbox_attr); + + if (!init) + instr[0] = '\0'; + else + strcpy (instr, init); + + input_x = strlen (instr); + + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch (dialog, instr[scroll + i]); + } else + waddstr (dialog, instr); + + wmove (dialog, box_y, box_x + input_x); + + wrefresh (dialog); + + while (key != ESC) { + key = wgetch (dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + continue; + case KEY_RIGHT: + continue; + case KEY_BACKSPACE: + case 127: + if (input_x || scroll) { + wattrset (dialog, inputbox_attr); + if (!input_x) { + scroll = scroll < box_width - 1 ? + 0 : scroll - (box_width - 1); + wmove (dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch (dialog, instr[scroll + input_x + i] ? + instr[scroll + input_x + i] : ' '); + input_x = strlen (instr) - scroll; + } else + input_x--; + instr[scroll + input_x] = '\0'; + mvwaddch (dialog, box_y, input_x + box_x, ' '); + wmove (dialog, box_y, input_x + box_x); + wrefresh (dialog); + } + continue; + default: + if (key < 0x100 && isprint (key)) { + if (scroll + input_x < MAX_LEN) { + wattrset (dialog, inputbox_attr); + instr[scroll + input_x] = key; + instr[scroll + input_x + 1] = '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove (dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch (dialog, instr[scroll + i]); + } else { + wmove (dialog, box_y, input_x++ + box_x); + waddch (dialog, key); + } + wrefresh (dialog); + } else + flash (); /* Alarm user about overflow */ + continue; + } + } + } + switch (key) { + case 'O': + case 'o': + delwin (dialog); + return 0; + case 'H': + case 'h': + delwin (dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove (dialog, box_y, box_x + input_x); + wrefresh (dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove (dialog, box_y, box_x + input_x); + wrefresh (dialog); + break; + } + break; + case ' ': + case '\n': + delwin (dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + } + + delwin (dialog); + return -1; /* ESC pressed */ +} diff --git a/extra/config/lex.zconf.c_shipped b/extra/config/lex.zconf.c_shipped new file mode 100644 index 0000000..22dda11 --- /dev/null +++ b/extra/config/lex.zconf.c_shipped @@ -0,0 +1,3688 @@ + +#line 3 "lex.zconf.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 31 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE zconfrestart(zconfin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int zconfleng; + +extern FILE *zconfin, *zconfout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via zconfrestart()), so that the user can continue scanning by + * just pointing zconfin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when zconftext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int zconfleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow zconfwrap()'s to do buffer switches + * instead of setting up a fresh zconfin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void zconfrestart (FILE *input_file ); +void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); +void zconf_delete_buffer (YY_BUFFER_STATE b ); +void zconf_flush_buffer (YY_BUFFER_STATE b ); +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); +void zconfpop_buffer_state (void ); + +static void zconfensure_buffer_stack (void ); +static void zconf_load_buffer_state (void ); +static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); + +void *zconfalloc (yy_size_t ); +void *zconfrealloc (void *,yy_size_t ); +void zconffree (void * ); + +#define yy_new_buffer zconf_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define zconfwrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; + +typedef int yy_state_type; + +extern int zconflineno; + +int zconflineno = 1; + +extern char *zconftext; +#define yytext_ptr zconftext +static yyconst flex_int16_t yy_nxt[][38] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, + 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, + 27, 18, 28, 29, 30, 18, 18, 16 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, + 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, + 27, 18, 28, 29, 30, 18, 18, 16 + + }, + + { + 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31 + }, + + { + 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31 + }, + + { + 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, + 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, + + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34 + }, + + { + 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, + 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34 + }, + + { + 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, + 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 52 + + }, + + { + 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, + 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 52 + }, + + { + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11 + }, + + { + 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12 + }, + + { + 11, -13, 53, 54, -13, -13, 55, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13 + }, + + { + 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14 + + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16 + }, + + { + 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17 + }, + + { + 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, 58, -18, -18, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -18 + }, + + { + 11, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, 58, -19, -19, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 59, + 58, 58, 58, 58, 58, 58, 58, -19 + + }, + + { + 11, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, 58, -20, -20, 58, 58, 58, 58, + 58, 58, 58, 58, 60, 58, 58, 58, 58, 61, + 58, 58, 58, 58, 58, 58, 58, -20 + }, + + { + 11, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, 58, -21, -21, 58, 58, 58, 58, + 58, 62, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -21 + }, + + { + 11, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, 58, -22, -22, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 63, 58, + 58, 58, 58, 58, 58, 58, 58, -22 + }, + + { + 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, 58, -23, -23, 58, 58, 58, 58, + 58, 64, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -23 + }, + + { + 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, 58, -24, -24, 58, 58, 58, 58, + 58, 58, 65, 58, 58, 58, 58, 58, 66, 58, + 58, 58, 58, 58, 58, 58, 58, -24 + + }, + + { + 11, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, 58, -25, -25, 58, 67, 58, 58, + 58, 68, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -25 + }, + + { + 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, 58, -26, -26, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 69, 58, 58, 58, 58, 58, 58, -26 + }, + + { + 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -27, -27, -27, 58, -27, -27, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 70, 58, 58, 58, 58, -27 + }, + + { + 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, 58, -28, -28, 58, 71, 58, 58, + 58, 72, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -28 + }, + + { + 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, 58, -29, -29, 58, 58, 58, 58, + 58, 73, 58, 58, 58, 58, 58, 58, 58, 74, + 58, 58, 58, 58, 75, 58, 58, -29 + + }, + + { + 11, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, 58, -30, -30, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 76, 58, 58, 58, 58, -30 + }, + + { + 11, 77, 77, -31, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77 + }, + + { + 11, -32, 78, 79, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32 + }, + + { + 11, 80, -33, -33, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80 + }, + + { + 11, 81, 81, 82, 81, -34, 81, 81, -34, 81, + 81, 81, 81, 81, 81, -34, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81 + + }, + + { + 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35 + }, + + { + 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36 + }, + + { + 11, 83, 83, 84, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83 + }, + + { + 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38 + }, + + { + 11, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39 + + }, + + { + 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, 85, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40 + }, + + { + 11, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41 + }, + + { + 11, 86, 86, -42, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86 + }, + + { + 11, -43, -43, -43, -43, -43, -43, 87, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43 + }, + + { + 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44 + + }, + + { + 11, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45 + }, + + { + 11, -46, -46, -46, -46, -46, -46, -46, -46, -46, + -46, 88, 89, 89, -46, -46, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -46 + }, + + { + 11, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, 89, 89, 89, -47, -47, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -47 + }, + + { + 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48 + }, + + { + 11, -49, -49, 90, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49 + + }, + + { + 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, 89, 89, 89, -50, -50, 89, 89, 89, 89, + 89, 89, 91, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -50 + }, + + { + 11, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, 89, 89, 89, -51, -51, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 92, 89, + 89, 89, 89, 89, 89, 89, 89, -51 + }, + + { + 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, 93 + }, + + { + 11, -53, 53, 54, -53, -53, 55, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53 + }, + + { + 11, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54 + + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57 + }, + + { + 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, 58, -58, -58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -58 + }, + + { + 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, 58, -59, -59, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, + 58, 58, 58, 58, 58, 58, 58, -59 + + }, + + { + 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, 58, -60, -60, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 95, + 58, 58, 58, 58, 58, 58, 58, -60 + }, + + { + 11, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, 58, -61, -61, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 96, 97, 58, + 58, 58, 58, 58, 58, 58, 58, -61 + }, + + { + 11, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, 58, -62, -62, 58, 58, 58, 58, + + 58, 58, 98, 58, 58, 58, 58, 58, 58, 58, + 99, 58, 58, 58, 58, 58, 58, -62 + }, + + { + 11, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, 58, -63, -63, 58, 100, 58, 58, + 101, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -63 + }, + + { + 11, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, 58, -64, -64, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 102, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 103, -64 + + }, + + { + 11, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, 58, -65, -65, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -65 + }, + + { + 11, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, 58, -66, -66, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 104, 58, 58, -66 + }, + + { + 11, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, 58, -67, -67, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 105, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -67 + }, + + { + 11, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, 58, -68, -68, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 106, 58, + 58, 58, 58, 58, 58, 58, 58, -68 + }, + + { + 11, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, 58, -69, -69, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 107, 58, 58, -69 + + }, + + { + 11, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, 58, -70, -70, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 108, + 58, 58, 58, 58, 58, 58, 58, -70 + }, + + { + 11, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, 58, -71, -71, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 109, 58, + 58, 58, 58, 58, 58, 58, 58, -71 + }, + + { + 11, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, 58, -72, -72, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 110, 58, 58, 58, 58, 58, -72 + }, + + { + 11, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, 58, -73, -73, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 111, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -73 + }, + + { + 11, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, 58, -74, -74, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 112, 58, -74 + + }, + + { + 11, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, 58, -75, -75, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 113, 58, 58, 58, 58, -75 + }, + + { + 11, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, 58, -76, -76, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 114, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -76 + }, + + { + 11, 77, 77, -77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77 + }, + + { + 11, -78, 78, 79, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78 + }, + + { + 11, 80, -79, -79, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80 + + }, + + { + 11, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80 + }, + + { + 11, 81, 81, 82, 81, -81, 81, 81, -81, 81, + 81, 81, 81, 81, 81, -81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81 + }, + + { + 11, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82 + }, + + { + 11, -83, -83, 84, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83 + }, + + { + 11, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84 + + }, + + { + 11, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85 + }, + + { + 11, 86, 86, -86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86 + }, + + { + 11, -87, -87, -87, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, + + -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, -87 + }, + + { + 11, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, 115, 89, 89, -88, -88, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -88 + }, + + { + 11, -89, -89, -89, -89, -89, -89, -89, -89, -89, + -89, 89, 89, 89, -89, -89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -89 + + }, + + { + 11, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90 + }, + + { + 11, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, 89, 89, 89, -91, -91, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -91 + }, + + { + 11, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, 89, 89, 89, -92, -92, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -92 + }, + + { + 11, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93 + }, + + { + 11, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, 58, -94, -94, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 116, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -94 + + }, + + { + 11, -95, -95, -95, -95, -95, -95, -95, -95, -95, + -95, -95, -95, 58, -95, -95, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 117, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -95 + }, + + { + 11, -96, -96, -96, -96, -96, -96, -96, -96, -96, + -96, -96, -96, 58, -96, -96, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 118, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -96 + }, + + { + 11, -97, -97, -97, -97, -97, -97, -97, -97, -97, + -97, -97, -97, 58, -97, -97, 58, 58, 58, 58, + + 58, 58, 119, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -97 + }, + + { + 11, -98, -98, -98, -98, -98, -98, -98, -98, -98, + -98, -98, -98, 58, -98, -98, 120, 121, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -98 + }, + + { + 11, -99, -99, -99, -99, -99, -99, -99, -99, -99, + -99, -99, -99, 58, -99, -99, 58, 58, 58, 58, + 58, 122, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -99 + + }, + + { + 11, -100, -100, -100, -100, -100, -100, -100, -100, -100, + -100, -100, -100, 58, -100, -100, 58, 58, 123, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -100 + }, + + { + 11, -101, -101, -101, -101, -101, -101, -101, -101, -101, + -101, -101, -101, 58, -101, -101, 58, 58, 58, 124, + 58, 58, 58, 58, 58, 125, 58, 126, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -101 + }, + + { + 11, -102, -102, -102, -102, -102, -102, -102, -102, -102, + -102, -102, -102, 58, -102, -102, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 127, 58, 58, 58, 58, 58, 58, -102 + }, + + { + 11, -103, -103, -103, -103, -103, -103, -103, -103, -103, + -103, -103, -103, 58, -103, -103, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -103 + }, + + { + 11, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, 58, -104, -104, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -104 + + }, + + { + 11, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, 58, -105, -105, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 128, 58, + 58, 58, 58, 58, 58, 58, 58, -105 + }, + + { + 11, -106, -106, -106, -106, -106, -106, -106, -106, -106, + -106, -106, -106, 58, -106, -106, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 129, 58, -106 + }, + + { + 11, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, 58, -107, -107, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 130, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -107 + }, + + { + 11, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, 58, -108, -108, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 131, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -108 + }, + + { + 11, -109, -109, -109, -109, -109, -109, -109, -109, -109, + -109, -109, -109, 58, -109, -109, 58, 58, 58, 58, + 58, 58, 58, 132, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -109 + + }, + + { + 11, -110, -110, -110, -110, -110, -110, -110, -110, -110, + -110, -110, -110, 58, -110, -110, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 133, 58, -110 + }, + + { + 11, -111, -111, -111, -111, -111, -111, -111, -111, -111, + -111, -111, -111, 58, -111, -111, 58, 58, 58, 58, + 58, 134, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -111 + }, + + { + 11, -112, -112, -112, -112, -112, -112, -112, -112, -112, + -112, -112, -112, 58, -112, -112, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 135, 58, 58, 58, 58, -112 + }, + + { + 11, -113, -113, -113, -113, -113, -113, -113, -113, -113, + -113, -113, -113, 58, -113, -113, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -113 + }, + + { + 11, -114, -114, -114, -114, -114, -114, -114, -114, -114, + -114, -114, -114, 58, -114, -114, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 137, 58, 58, 58, -114 + + }, + + { + 11, -115, -115, -115, -115, -115, -115, -115, -115, -115, + -115, 89, 89, 89, -115, -115, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -115 + }, + + { + 11, -116, -116, -116, -116, -116, -116, -116, -116, -116, + -116, -116, -116, 58, -116, -116, 58, 58, 58, 58, + 58, 138, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -116 + }, + + { + 11, -117, -117, -117, -117, -117, -117, -117, -117, -117, + -117, -117, -117, 58, -117, -117, 58, 58, 58, 139, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -117 + }, + + { + 11, -118, -118, -118, -118, -118, -118, -118, -118, -118, + -118, -118, -118, 58, -118, -118, 58, 58, 58, 58, + 58, 140, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -118 + }, + + { + 11, -119, -119, -119, -119, -119, -119, -119, -119, -119, + -119, -119, -119, 58, -119, -119, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 141, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -119 + + }, + + { + 11, -120, -120, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, 58, -120, -120, 58, 58, 142, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 143, 58, 58, -120 + }, + + { + 11, -121, -121, -121, -121, -121, -121, -121, -121, -121, + -121, -121, -121, 58, -121, -121, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 144, 58, -121 + }, + + { + 11, -122, -122, -122, -122, -122, -122, -122, -122, -122, + -122, -122, -122, 58, -122, -122, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 145, 58, + 58, 58, 58, 58, 58, 58, 58, -122 + }, + + { + 11, -123, -123, -123, -123, -123, -123, -123, -123, -123, + -123, -123, -123, 58, -123, -123, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 146, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -123 + }, + + { + 11, -124, -124, -124, -124, -124, -124, -124, -124, -124, + -124, -124, -124, 58, -124, -124, 58, 58, 58, 58, + 58, 58, 58, 58, 147, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -124 + + }, + + { + 11, -125, -125, -125, -125, -125, -125, -125, -125, -125, + -125, -125, -125, 58, -125, -125, 58, 58, 58, 58, + 58, 58, 148, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -125 + }, + + { + 11, -126, -126, -126, -126, -126, -126, -126, -126, -126, + -126, -126, -126, 58, -126, -126, 58, 58, 58, 58, + 58, 149, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -126 + }, + + { + 11, -127, -127, -127, -127, -127, -127, -127, -127, -127, + -127, -127, -127, 58, -127, -127, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -127 + }, + + { + 11, -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, 58, -128, -128, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 150, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -128 + }, + + { + 11, -129, -129, -129, -129, -129, -129, -129, -129, -129, + -129, -129, -129, 58, -129, -129, 58, 58, 58, 151, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -129 + + }, + + { + 11, -130, -130, -130, -130, -130, -130, -130, -130, -130, + -130, -130, -130, 58, -130, -130, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 152, + 58, 58, 58, 58, 58, 58, 58, -130 + }, + + { + 11, -131, -131, -131, -131, -131, -131, -131, -131, -131, + -131, -131, -131, 58, -131, -131, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 153, 58, 58, 58, 58, 58, 58, -131 + }, + + { + 11, -132, -132, -132, -132, -132, -132, -132, -132, -132, + -132, -132, -132, 58, -132, -132, 58, 58, 58, 58, + + 58, 154, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -132 + }, + + { + 11, -133, -133, -133, -133, -133, -133, -133, -133, -133, + -133, -133, -133, 58, -133, -133, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 155, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -133 + }, + + { + 11, -134, -134, -134, -134, -134, -134, -134, -134, -134, + -134, -134, -134, 58, -134, -134, 58, 58, 58, 156, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -134 + + }, + + { + 11, -135, -135, -135, -135, -135, -135, -135, -135, -135, + -135, -135, -135, 58, -135, -135, 58, 58, 58, 157, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -135 + }, + + { + 11, -136, -136, -136, -136, -136, -136, -136, -136, -136, + -136, -136, -136, 58, -136, -136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 158, 58, + 58, 58, 58, 58, 58, 58, 58, -136 + }, + + { + 11, -137, -137, -137, -137, -137, -137, -137, -137, -137, + -137, -137, -137, 58, -137, -137, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 159, 58, 58, -137 + }, + + { + 11, -138, -138, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, 58, -138, -138, 58, 160, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -138 + }, + + { + 11, -139, -139, -139, -139, -139, -139, -139, -139, -139, + -139, -139, -139, 58, -139, -139, 58, 58, 58, 58, + 58, 161, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -139 + + }, + + { + 11, -140, -140, -140, -140, -140, -140, -140, -140, -140, + -140, -140, -140, 58, -140, -140, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 162, 58, + 58, 58, 58, 58, 58, 58, 58, -140 + }, + + { + 11, -141, -141, -141, -141, -141, -141, -141, -141, -141, + -141, -141, -141, 58, -141, -141, 58, 58, 58, 58, + 58, 58, 58, 163, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -141 + }, + + { + 11, -142, -142, -142, -142, -142, -142, -142, -142, -142, + -142, -142, -142, 58, -142, -142, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 164, + 58, 58, 58, 58, 58, 58, 58, -142 + }, + + { + 11, -143, -143, -143, -143, -143, -143, -143, -143, -143, + -143, -143, -143, 58, -143, -143, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 165, 58, 58, 58, 58, -143 + }, + + { + 11, -144, -144, -144, -144, -144, -144, -144, -144, -144, + -144, -144, -144, 58, -144, -144, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 166, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -144 + + }, + + { + 11, -145, -145, -145, -145, -145, -145, -145, -145, -145, + -145, -145, -145, 58, -145, -145, 58, 58, 58, 58, + 167, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -145 + }, + + { + 11, -146, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, 58, -146, -146, 58, 58, 58, 58, + 58, 168, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -146 + }, + + { + 11, -147, -147, -147, -147, -147, -147, -147, -147, -147, + -147, -147, -147, 58, -147, -147, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 169, + 58, 58, 58, 58, 58, 58, 58, -147 + }, + + { + 11, -148, -148, -148, -148, -148, -148, -148, -148, -148, + -148, -148, -148, 58, -148, -148, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -148 + }, + + { + 11, -149, -149, -149, -149, -149, -149, -149, -149, -149, + -149, -149, -149, 58, -149, -149, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 170, 58, + 58, 58, 58, 58, 58, 58, 58, -149 + + }, + + { + 11, -150, -150, -150, -150, -150, -150, -150, -150, -150, + -150, -150, -150, 58, -150, -150, 58, 58, 58, 58, + 58, 171, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -150 + }, + + { + 11, -151, -151, -151, -151, -151, -151, -151, -151, -151, + -151, -151, -151, 58, -151, -151, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 172, + 58, 58, 58, 58, 58, 58, 58, -151 + }, + + { + 11, -152, -152, -152, -152, -152, -152, -152, -152, -152, + -152, -152, -152, 58, -152, -152, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 173, 58, + 58, 58, 58, 58, 58, 58, 58, -152 + }, + + { + 11, -153, -153, -153, -153, -153, -153, -153, -153, -153, + -153, -153, -153, 58, -153, -153, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 174, 58, 58, -153 + }, + + { + 11, -154, -154, -154, -154, -154, -154, -154, -154, -154, + -154, -154, -154, 58, -154, -154, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -154 + + }, + + { + 11, -155, -155, -155, -155, -155, -155, -155, -155, -155, + -155, -155, -155, 58, -155, -155, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 175, 58, 58, 58, 58, -155 + }, + + { + 11, -156, -156, -156, -156, -156, -156, -156, -156, -156, + -156, -156, -156, 58, -156, -156, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 176, 58, 58, -156 + }, + + { + 11, -157, -157, -157, -157, -157, -157, -157, -157, -157, + -157, -157, -157, 58, -157, -157, 58, 58, 58, 58, + + 58, 177, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -157 + }, + + { + 11, -158, -158, -158, -158, -158, -158, -158, -158, -158, + -158, -158, -158, 58, -158, -158, 58, 58, 58, 58, + 58, 58, 58, 178, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -158 + }, + + { + 11, -159, -159, -159, -159, -159, -159, -159, -159, -159, + -159, -159, -159, 58, -159, -159, 58, 179, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -159 + + }, + + { + 11, -160, -160, -160, -160, -160, -160, -160, -160, -160, + -160, -160, -160, 58, -160, -160, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 180, 58, + 58, 58, 58, 58, 58, 58, 58, -160 + }, + + { + 11, -161, -161, -161, -161, -161, -161, -161, -161, -161, + -161, -161, -161, 58, -161, -161, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -161 + }, + + { + 11, -162, -162, -162, -162, -162, -162, -162, -162, -162, + -162, -162, -162, 58, -162, -162, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 181, 58, 58, -162 + }, + + { + 11, -163, -163, -163, -163, -163, -163, -163, -163, -163, + -163, -163, -163, 58, -163, -163, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -163 + }, + + { + 11, -164, -164, -164, -164, -164, -164, -164, -164, -164, + -164, -164, -164, 58, -164, -164, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 182, + 58, 58, 58, 58, 58, 58, 58, -164 + + }, + + { + 11, -165, -165, -165, -165, -165, -165, -165, -165, -165, + -165, -165, -165, 58, -165, -165, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 183, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -165 + }, + + { + 11, -166, -166, -166, -166, -166, -166, -166, -166, -166, + -166, -166, -166, 58, -166, -166, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 184, 58, 58, -166 + }, + + { + 11, -167, -167, -167, -167, -167, -167, -167, -167, -167, + -167, -167, -167, 58, -167, -167, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 185, 58, 58, 58, -167 + }, + + { + 11, -168, -168, -168, -168, -168, -168, -168, -168, -168, + -168, -168, -168, 58, -168, -168, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -168 + }, + + { + 11, -169, -169, -169, -169, -169, -169, -169, -169, -169, + -169, -169, -169, 58, -169, -169, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 186, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -169 + + }, + + { + 11, -170, -170, -170, -170, -170, -170, -170, -170, -170, + -170, -170, -170, 58, -170, -170, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 187, 58, -170 + }, + + { + 11, -171, -171, -171, -171, -171, -171, -171, -171, -171, + -171, -171, -171, 58, -171, -171, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 188, 58, + 58, 58, 58, 58, 58, 58, 58, -171 + }, + + { + 11, -172, -172, -172, -172, -172, -172, -172, -172, -172, + -172, -172, -172, 58, -172, -172, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 189, 58, + 58, 58, 58, 58, 58, 58, 58, -172 + }, + + { + 11, -173, -173, -173, -173, -173, -173, -173, -173, -173, + -173, -173, -173, 58, -173, -173, 58, 190, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -173 + }, + + { + 11, -174, -174, -174, -174, -174, -174, -174, -174, -174, + -174, -174, -174, 58, -174, -174, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -174 + + }, + + { + 11, -175, -175, -175, -175, -175, -175, -175, -175, -175, + -175, -175, -175, 58, -175, -175, 58, 58, 58, 58, + 58, 191, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -175 + }, + + { + 11, -176, -176, -176, -176, -176, -176, -176, -176, -176, + -176, -176, -176, 58, -176, -176, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -176 + }, + + { + 11, -177, -177, -177, -177, -177, -177, -177, -177, -177, + -177, -177, -177, 58, -177, -177, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -177 + }, + + { + 11, -178, -178, -178, -178, -178, -178, -178, -178, -178, + -178, -178, -178, 58, -178, -178, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -178 + }, + + { + 11, -179, -179, -179, -179, -179, -179, -179, -179, -179, + -179, -179, -179, 58, -179, -179, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 192, 58, 58, -179 + + }, + + { + 11, -180, -180, -180, -180, -180, -180, -180, -180, -180, + -180, -180, -180, 58, -180, -180, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -180 + }, + + { + 11, -181, -181, -181, -181, -181, -181, -181, -181, -181, + -181, -181, -181, 58, -181, -181, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -181 + }, + + { + 11, -182, -182, -182, -182, -182, -182, -182, -182, -182, + -182, -182, -182, 58, -182, -182, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 193, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -182 + }, + + { + 11, -183, -183, -183, -183, -183, -183, -183, -183, -183, + -183, -183, -183, 58, -183, -183, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 194, 58, 58, 58, -183 + }, + + { + 11, -184, -184, -184, -184, -184, -184, -184, -184, -184, + -184, -184, -184, 58, -184, -184, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -184 + + }, + + { + 11, -185, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, 58, -185, -185, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -185 + }, + + { + 11, -186, -186, -186, -186, -186, -186, -186, -186, -186, + -186, -186, -186, 58, -186, -186, 58, 58, 58, 195, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -186 + }, + + { + 11, -187, -187, -187, -187, -187, -187, -187, -187, -187, + -187, -187, -187, 58, -187, -187, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -187 + }, + + { + 11, -188, -188, -188, -188, -188, -188, -188, -188, -188, + -188, -188, -188, 58, -188, -188, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 196, 58, -188 + }, + + { + 11, -189, -189, -189, -189, -189, -189, -189, -189, -189, + -189, -189, -189, 58, -189, -189, 58, 58, 58, 58, + 58, 58, 197, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -189 + + }, + + { + 11, -190, -190, -190, -190, -190, -190, -190, -190, -190, + -190, -190, -190, 58, -190, -190, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 198, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -190 + }, + + { + 11, -191, -191, -191, -191, -191, -191, -191, -191, -191, + -191, -191, -191, 58, -191, -191, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 199, 58, 58, 58, -191 + }, + + { + 11, -192, -192, -192, -192, -192, -192, -192, -192, -192, + -192, -192, -192, 58, -192, -192, 58, 58, 58, 58, + + 58, 200, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -192 + }, + + { + 11, -193, -193, -193, -193, -193, -193, -193, -193, -193, + -193, -193, -193, 58, -193, -193, 58, 58, 58, 58, + 58, 201, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -193 + }, + + { + 11, -194, -194, -194, -194, -194, -194, -194, -194, -194, + -194, -194, -194, 58, -194, -194, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 202, 58, 58, -194 + + }, + + { + 11, -195, -195, -195, -195, -195, -195, -195, -195, -195, + -195, -195, -195, 58, -195, -195, 58, 58, 58, 58, + 58, 203, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -195 + }, + + { + 11, -196, -196, -196, -196, -196, -196, -196, -196, -196, + -196, -196, -196, 58, -196, -196, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -196 + }, + + { + 11, -197, -197, -197, -197, -197, -197, -197, -197, -197, + -197, -197, -197, 58, -197, -197, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 204, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -197 + }, + + { + 11, -198, -198, -198, -198, -198, -198, -198, -198, -198, + -198, -198, -198, 58, -198, -198, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -198 + }, + + { + 11, -199, -199, -199, -199, -199, -199, -199, -199, -199, + -199, -199, -199, 58, -199, -199, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -199 + + }, + + { + 11, -200, -200, -200, -200, -200, -200, -200, -200, -200, + -200, -200, -200, 58, -200, -200, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -200 + }, + + { + 11, -201, -201, -201, -201, -201, -201, -201, -201, -201, + -201, -201, -201, 58, -201, -201, 58, 205, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -201 + }, + + { + 11, -202, -202, -202, -202, -202, -202, -202, -202, -202, + -202, -202, -202, 58, -202, -202, 58, 206, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -202 + }, + + { + 11, -203, -203, -203, -203, -203, -203, -203, -203, -203, + -203, -203, -203, 58, -203, -203, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -203 + }, + + { + 11, -204, -204, -204, -204, -204, -204, -204, -204, -204, + -204, -204, -204, 58, -204, -204, 58, 58, 58, 58, + 58, 58, 58, 207, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -204 + + }, + + { + 11, -205, -205, -205, -205, -205, -205, -205, -205, -205, + -205, -205, -205, 58, -205, -205, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 208, 58, + 58, 58, 58, 58, 58, 58, 58, -205 + }, + + { + 11, -206, -206, -206, -206, -206, -206, -206, -206, -206, + -206, -206, -206, 58, -206, -206, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 209, 58, 58, -206 + }, + + { + 11, -207, -207, -207, -207, -207, -207, -207, -207, -207, + -207, -207, -207, 58, -207, -207, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -207 + }, + + { + 11, -208, -208, -208, -208, -208, -208, -208, -208, -208, + -208, -208, -208, 58, -208, -208, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -208 + }, + + { + 11, -209, -209, -209, -209, -209, -209, -209, -209, -209, + -209, -209, -209, 58, -209, -209, 58, 58, 58, 58, + 58, 210, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -209 + + }, + + { + 11, -210, -210, -210, -210, -210, -210, -210, -210, -210, + -210, -210, -210, 58, -210, -210, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -210 + }, + + } ; + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up zconftext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + zconfleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[211] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 65, 5, 4, 3, 2, 36, 37, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 63, 60, 62, 55, 59, 58, 57, 53, 48, 42, + 47, 51, 53, 40, 41, 50, 50, 43, 53, 50, + 50, 53, 4, 3, 2, 2, 1, 35, 35, 35, + 35, 35, 35, 35, 16, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 63, 60, 62, 61, + 55, 54, 57, 56, 44, 51, 38, 50, 50, 52, + 45, 46, 39, 35, 35, 35, 35, 35, 35, 35, + + 35, 35, 30, 29, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 49, 25, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 15, 35, 7, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 17, 35, 35, + 35, 35, 35, 34, 35, 35, 35, 35, 35, 35, + 10, 35, 13, 35, 35, 35, 35, 33, 35, 35, + 35, 35, 35, 22, 35, 32, 9, 31, 35, 26, + 12, 35, 35, 21, 18, 35, 8, 35, 35, 35, + 35, 35, 27, 35, 35, 6, 35, 20, 19, 23, + + 35, 35, 11, 35, 35, 35, 14, 28, 35, 24 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, + 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 1, 15, 1, 1, 16, 1, 17, 18, 19, 20, + + 21, 22, 23, 24, 25, 13, 13, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 13, 13, 36, + 13, 13, 1, 37, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +extern int zconf_flex_debug; +int zconf_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *zconftext; + +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define START_STRSIZE 16 + +char *text; +static char *text_ptr; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static struct buffer *zconf_endfile(void); + +void new_string(void) +{ + text = malloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_ptr = text; + text_size = 0; + *text_ptr = 0; +} + +void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + text = realloc(text, new_size); + text_asize = new_size; + text_ptr = text + text_size; + } + memcpy(text_ptr, str, size); + text_ptr += size; + text_size += size; + *text_ptr = 0; +} + +void alloc_string(const char *str, int size) +{ + text = malloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +#define INITIAL 0 +#define COMMAND 1 +#define HELP 2 +#define STRING 3 +#define PARAM 4 + +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int zconfwrap (void ); +#else +extern int zconfwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + errno=0; \ + while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(zconfin); \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int zconflex (void); + +#define YY_DECL int zconflex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after zconftext and zconfleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + int str = 0; + int ts, i; + + if ( (yy_init) ) + { + (yy_init) = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! zconfin ) + zconfin = stdin; + + if ( ! zconfout ) + zconfout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of zconftext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) + ++yy_cp; + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 2: +YY_RULE_SETUP + + YY_BREAK +case 3: +/* rule 3 can match eol */ +YY_RULE_SETUP +current_file->lineno++; return T_EOL; + YY_BREAK +case 4: +YY_RULE_SETUP +{ + BEGIN(COMMAND); +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ + unput(zconftext[0]); + BEGIN(COMMAND); +} + YY_BREAK + +case 6: +YY_RULE_SETUP +BEGIN(PARAM); return T_MAINMENU; + YY_BREAK +case 7: +YY_RULE_SETUP +BEGIN(PARAM); return T_MENU; + YY_BREAK +case 8: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDMENU; + YY_BREAK +case 9: +YY_RULE_SETUP +BEGIN(PARAM); return T_SOURCE; + YY_BREAK +case 10: +YY_RULE_SETUP +BEGIN(PARAM); return T_CHOICE; + YY_BREAK +case 11: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDCHOICE; + YY_BREAK +case 12: +YY_RULE_SETUP +BEGIN(PARAM); return T_COMMENT; + YY_BREAK +case 13: +YY_RULE_SETUP +BEGIN(PARAM); return T_CONFIG; + YY_BREAK +case 14: +YY_RULE_SETUP +BEGIN(PARAM); return T_MENUCONFIG; + YY_BREAK +case 15: +YY_RULE_SETUP +BEGIN(PARAM); return T_HELP; + YY_BREAK +case 16: +YY_RULE_SETUP +BEGIN(PARAM); return T_IF; + YY_BREAK +case 17: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDIF; + YY_BREAK +case 18: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEPENDS; + YY_BREAK +case 19: +YY_RULE_SETUP +BEGIN(PARAM); return T_REQUIRES; + YY_BREAK +case 20: +YY_RULE_SETUP +BEGIN(PARAM); return T_OPTIONAL; + YY_BREAK +case 21: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEFAULT; + YY_BREAK +case 22: +YY_RULE_SETUP +BEGIN(PARAM); return T_PROMPT; + YY_BREAK +case 23: +YY_RULE_SETUP +BEGIN(PARAM); return T_TRISTATE; + YY_BREAK +case 24: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_TRISTATE; + YY_BREAK +case 25: +YY_RULE_SETUP +BEGIN(PARAM); return T_BOOLEAN; + YY_BREAK +case 26: +YY_RULE_SETUP +BEGIN(PARAM); return T_BOOLEAN; + YY_BREAK +case 27: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_BOOLEAN; + YY_BREAK +case 28: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_BOOLEAN; + YY_BREAK +case 29: +YY_RULE_SETUP +BEGIN(PARAM); return T_INT; + YY_BREAK +case 30: +YY_RULE_SETUP +BEGIN(PARAM); return T_HEX; + YY_BREAK +case 31: +YY_RULE_SETUP +BEGIN(PARAM); return T_STRING; + YY_BREAK +case 32: +YY_RULE_SETUP +BEGIN(PARAM); return T_SELECT; + YY_BREAK +case 33: +YY_RULE_SETUP +BEGIN(PARAM); return T_SELECT; + YY_BREAK +case 34: +YY_RULE_SETUP +BEGIN(PARAM); return T_RANGE; + YY_BREAK +case 35: +YY_RULE_SETUP +{ + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 36: +YY_RULE_SETUP + + YY_BREAK +case 37: +/* rule 37 can match eol */ +YY_RULE_SETUP +current_file->lineno++; BEGIN(INITIAL); + YY_BREAK + +case 38: +YY_RULE_SETUP +return T_AND; + YY_BREAK +case 39: +YY_RULE_SETUP +return T_OR; + YY_BREAK +case 40: +YY_RULE_SETUP +return T_OPEN_PAREN; + YY_BREAK +case 41: +YY_RULE_SETUP +return T_CLOSE_PAREN; + YY_BREAK +case 42: +YY_RULE_SETUP +return T_NOT; + YY_BREAK +case 43: +YY_RULE_SETUP +return T_EQUAL; + YY_BREAK +case 44: +YY_RULE_SETUP +return T_UNEQUAL; + YY_BREAK +case 45: +YY_RULE_SETUP +return T_IF; + YY_BREAK +case 46: +YY_RULE_SETUP +return T_ON; + YY_BREAK +case 47: +YY_RULE_SETUP +{ + str = zconftext[0]; + new_string(); + BEGIN(STRING); + } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +BEGIN(INITIAL); current_file->lineno++; return T_EOL; + YY_BREAK +case 49: +YY_RULE_SETUP +/* ignore */ + YY_BREAK +case 50: +YY_RULE_SETUP +{ + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 51: +YY_RULE_SETUP +/* comment */ + YY_BREAK +case 52: +/* rule 52 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 53: +YY_RULE_SETUP + + YY_BREAK +case YY_STATE_EOF(PARAM): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 54: +/* rule 54 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 55: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + } + YY_BREAK +case 56: +/* rule 56 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 57: +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + } + YY_BREAK +case 58: +YY_RULE_SETUP +{ + if (str == zconftext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(zconftext, 1); + } + YY_BREAK +case 59: +/* rule 59 can match eol */ +YY_RULE_SETUP +{ + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + YY_BREAK +case YY_STATE_EOF(STRING): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 60: +YY_RULE_SETUP +{ + ts = 0; + for (i = 0; i < zconfleng; i++) { + if (zconftext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + YY_BREAK +case 61: +/* rule 61 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK +case 62: +/* rule 62 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + append_string("\n", 1); + } + YY_BREAK +case 63: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + if (!first_ts) + first_ts = last_ts; + } + YY_BREAK +case YY_STATE_EOF(HELP): +{ + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMAND): +{ + if (current_buf) { + zconf_endfile(); + return T_EOF; + } + fclose(zconfin); + yyterminate(); +} + YY_BREAK +case 64: +YY_RULE_SETUP +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed zconfin at a new source and called + * zconflex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( zconfwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * zconftext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of zconflex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + zconfrestart(zconfin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + + yy_current_state = yy_nxt[yy_current_state][1]; + yy_is_jam = (yy_current_state <= 0); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up zconftext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + zconfrestart(zconfin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( zconfwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve zconftext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void zconfrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); + zconf_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * zconfpop_buffer_state(); + * zconfpush_buffer_state(new_buffer); + */ + zconfensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + zconf_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (zconfwrap()) processing, but the only time this flag + * is looked at is after zconfwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void zconf_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + zconf_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with zconf_create_buffer() + * + */ + void zconf_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + zconffree((void *) b->yy_ch_buf ); + + zconffree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a zconfrestart() or at EOF. + */ + static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + zconf_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then zconf_init_buffer was _probably_ + * called from zconfrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void zconf_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + zconf_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + zconfensure_buffer_stack(); + + /* This block is copied from zconf_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from zconf_switch_to_buffer. */ + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void zconfpop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void zconfensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + zconf_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to zconflex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * zconf_scan_bytes() instead. + */ +YY_BUFFER_STATE zconf_scan_string (yyconst char * str ) +{ + + return zconf_scan_bytes(str,strlen(str) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) zconfalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = zconf_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + zconftext[zconfleng] = (yy_hold_char); \ + (yy_c_buf_p) = zconftext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + zconfleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int zconfget_lineno (void) +{ + + return zconflineno; +} + +/** Get the input stream. + * + */ +FILE *zconfget_in (void) +{ + return zconfin; +} + +/** Get the output stream. + * + */ +FILE *zconfget_out (void) +{ + return zconfout; +} + +/** Get the length of the current token. + * + */ +int zconfget_leng (void) +{ + return zconfleng; +} + +/** Get the current token. + * + */ + +char *zconfget_text (void) +{ + return zconftext; +} + +/** Set the current line number. + * @param line_number + * + */ +void zconfset_lineno (int line_number ) +{ + + zconflineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see zconf_switch_to_buffer + */ +void zconfset_in (FILE * in_str ) +{ + zconfin = in_str ; +} + +void zconfset_out (FILE * out_str ) +{ + zconfout = out_str ; +} + +int zconfget_debug (void) +{ + return zconf_flex_debug; +} + +void zconfset_debug (int bdebug ) +{ + zconf_flex_debug = bdebug ; +} + +/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ +int zconflex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + zconfpop_buffer_state(); + } + + /* Destroy the stack itself. */ + zconffree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *zconfalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *zconfrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void zconffree (void * ptr ) +{ + free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef yytext_ptr +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = malloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; + current_file->flags = FILE_BUSY; +} + +void zconf_nextfile(const char *name) +{ + struct file *file = file_lookup(name); + struct buffer *buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", name); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", name); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +static struct buffer *zconf_endfile(void) +{ + struct buffer *parent; + + current_file->flags |= FILE_SCANNED; + current_file->flags &= ~FILE_BUSY; + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(zconfin); + zconf_delete_buffer(YY_CURRENT_BUFFER); + zconf_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; + + return parent; +} + +int zconf_lineno(void) +{ + if (current_buf) + return current_file->lineno - 1; + else + return 0; +} + +char *zconf_curname(void) +{ + if (current_buf) + return current_file->name; + else + return ""; +} + diff --git a/extra/config/lkc.h b/extra/config/lkc.h new file mode 100644 index 0000000..dd040f7 --- /dev/null +++ b/extra/config/lkc.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef LKC_H +#define LKC_H + +#include "expr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LKC_DIRECT_LINK +#define P(name,type,arg) extern type name arg +#else +#include "lkc_defs.h" +#define P(name,type,arg) extern type (*name ## _p) arg +#endif +#include "lkc_proto.h" +#undef P + +#define SRCTREE "srctree" + +int zconfparse(void); +void zconfdump(FILE *out); + +extern int zconfdebug; +void zconf_starthelp(void); +FILE *zconf_fopen(const char *name); +void zconf_initscan(const char *name); +void zconf_nextfile(const char *name); +int zconf_lineno(void); +char *zconf_curname(void); + +/* confdata.c */ +extern const char conf_def_filename[]; +extern char conf_filename[]; + +char *conf_get_default_confname(void); + +/* kconfig_load.c */ +void kconfig_load(void); + +/* menu.c */ +void menu_init(void); +void menu_add_menu(void); +void menu_end_menu(void); +void menu_add_entry(struct symbol *sym); +void menu_end_entry(void); +void menu_add_dep(struct expr *dep); +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); +void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); +void menu_finalize(struct menu *parent); +void menu_set_type(int type); +struct file *file_lookup(const char *name); +int file_write_dep(const char *name); + +extern struct menu *current_entry; +extern struct menu *current_menu; + +/* symbol.c */ +void sym_init(void); +void sym_clear_all_valid(void); +void sym_set_changed(struct symbol *sym); +struct symbol *sym_check_deps(struct symbol *sym); +struct property *prop_alloc(enum prop_type type, struct symbol *sym); +struct symbol *prop_get_symbol(struct property *prop); + +static inline tristate sym_get_tristate_value(struct symbol *sym) +{ + return sym->curr.tri; +} + + +static inline struct symbol *sym_get_choice_value(struct symbol *sym) +{ + return (struct symbol *)sym->curr.val; +} + +static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) +{ + return sym_set_tristate_value(chval, yes); +} + +static inline bool sym_is_choice(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICE ? true : false; +} + +static inline bool sym_is_choice_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICEVAL ? true : false; +} + +static inline bool sym_is_optional(struct symbol *sym) +{ + return sym->flags & SYMBOL_OPTIONAL ? true : false; +} + +static inline bool sym_has_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_NEW ? false : true; +} + +#ifdef __cplusplus +} +#endif + +#endif /* LKC_H */ diff --git a/extra/config/lkc_proto.h b/extra/config/lkc_proto.h new file mode 100644 index 0000000..97c7917 --- /dev/null +++ b/extra/config/lkc_proto.h @@ -0,0 +1,39 @@ + +/* confdata.c */ +P(conf_parse,void,(const char *name)); +P(conf_read,int,(const char *name)); +P(conf_write,int,(const char *name)); + +/* menu.c */ +P(rootmenu,struct menu,); + +P(menu_is_visible,bool,(struct menu *menu)); +P(menu_get_prompt,const char *,(struct menu *menu)); +P(menu_get_root_menu,struct menu *,(struct menu *menu)); +P(menu_get_parent_menu,struct menu *,(struct menu *menu)); + +/* symbol.c */ +P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); +P(sym_change_count,int,); + +P(sym_lookup,struct symbol *,(const char *name, int isconst)); +P(sym_find,struct symbol *,(const char *name)); +P(sym_type_name,const char *,(enum symbol_type type)); +P(sym_calc_value,void,(struct symbol *sym)); +P(sym_get_type,enum symbol_type,(struct symbol *sym)); +P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); +P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); +P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); +P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); +P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); +P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); +P(sym_is_changable,bool,(struct symbol *sym)); +P(sym_get_choice_prop,struct property *,(struct symbol *sym)); +P(sym_get_default_prop,struct property *,(struct symbol *sym)); +P(sym_get_string_value,const char *,(struct symbol *sym)); + +P(prop_get_type_name,const char *,(enum prop_type type)); + +/* expr.c */ +P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); +P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)); diff --git a/extra/config/mconf.c b/extra/config/mconf.c new file mode 100644 index 0000000..d3bebcb --- /dev/null +++ b/extra/config/mconf.c @@ -0,0 +1,703 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + * + * Introduced single menu mode (show all sub-menus in one large tree). + * 2002-11-06 Petr Baudis + * + * Directly use liblxdialog library routines. + * 2002-11-14 Petr Baudis + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dialog.h" + +#define LKC_DIRECT_LINK +#include "lkc.h" + +static char menu_backtitle[128]; +static const char menu_instructions[] = + "Arrow keys navigate the menu. " + " selects submenus --->. " + "Highlighted letters are hotkeys. " + "Pressing selectes a feature, while will exclude a feature. " + "Press to exit, for Help. " + "Legend: [*] feature is selected [ ] feature is excluded", +radiolist_instructions[] = + "Use the arrow keys to navigate this window or " + "press the hotkey of the item you wish to select " + "followed by the . " + "Press for additional information about this option.", +inputbox_instructions_int[] = + "Please enter a decimal value. " + "Fractions will not be accepted. " + "Use the key to move from the input field to the buttons below it.", +inputbox_instructions_hex[] = + "Please enter a hexadecimal value. " + "Use the key to move from the input field to the buttons below it.", +inputbox_instructions_string[] = + "Please enter a string value. " + "Use the key to move from the input field to the buttons below it.", +setmod_text[] = + "This feature depends on another which has been configured as a module.\n" + "As a result, this feature will be built as a module.", +nohelp_text[] = + "There is no help available for this option.\n", +load_config_text[] = + "Enter the name of the configuration file you wish to load. " + "Accept the name shown to restore the configuration you " + "last retrieved. Leave blank to abort.", +load_config_help[] = + "\n" + "For various reasons, one may wish to keep several different uClibc\n" + "configurations available on a single machine.\n" + "\n" + "If you have saved a previous configuration in a file other than the\n" + "uClibc's default, entering the name of the file here will allow you\n" + "to modify that configuration.\n" + "\n" + "If you are uncertain, then you have probably never used alternate\n" + "configuration files. You should therefor leave this blank to abort.\n", +save_config_text[] = + "Enter a filename to which this configuration should be saved " + "as an alternate. Leave blank to abort.", +save_config_help[] = + "\n" + "For various reasons, one may wish to keep different uClibc\n" + "configurations available on a single machine.\n" + "\n" + "Entering a file name here will allow you to later retrieve, modify\n" + "and use the current configuration as an alternate to whatever\n" + "configuration options you have selected at that time.\n" + "\n" + "If you are uncertain what all this means then you should probably\n" + "leave this blank.\n", +top_menu_help[] = + "\n" + "Use the Up/Down arrow keys (cursor keys) to highlight the item\n" + "you wish to change or submenu wish to select and press .\n" + "Submenus are designated by \"--->\".\n" + "\n" + "Shortcut: Press the option's highlighted letter (hotkey).\n" + "\n" + "You may also use the and keys to scroll\n" + "unseen options into view.\n" +; + +static char filename[PATH_MAX+1] = ".config"; +static int indent = 0; +static struct termios ios_org; +static int rows, cols; +static int child_count; +static int single_menu_mode; + +static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */ +static int item_no; + +static void conf(struct menu *menu); +static void conf_choice(struct menu *menu); +static void conf_string(struct menu *menu); +static void conf_load(void); +static void conf_save(void); +static void show_textbox(const char *title, const char *text, int r, int c); +static void show_helptext(const char *title, const char *text); +static void show_help(struct menu *menu); +static void show_readme(void); + +static void init_wsize(void) +{ + struct winsize ws; + char *env; + + if (ioctl(1, TIOCGWINSZ, &ws) == -1) { + rows = 24; + cols = 80; + } else { + rows = ws.ws_row; + cols = ws.ws_col; + if (!rows) { + env = getenv("LINES"); + if (env) + rows = atoi(env); + if (!rows) + rows = 24; + } + if (!cols) { + env = getenv("COLUMNS"); + if (env) + cols = atoi(env); + if (!cols) + cols = 80; + } + } + + if (rows < 19 || cols < 80) { + fprintf(stderr, "Your display is too small to run Menuconfig!\n"); + fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); + exit(1); + } + + rows -= 4; + cols -= 5; +} + +static void cinit(void) +{ + item_no = 0; +} + +static void cmake(void) +{ + items[item_no] = malloc(sizeof(struct dialog_list_item)); + memset(items[item_no], 0, sizeof(struct dialog_list_item)); + items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0; + items[item_no]->name = malloc(512); items[item_no]->name[0] = 0; + items[item_no]->namelen = 0; + item_no++; +} + +static int cprint_name(const char *fmt, ...) +{ + va_list ap; + int res; + + if (!item_no) + cmake(); + va_start(ap, fmt); + res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen, + 512 - items[item_no - 1]->namelen, fmt, ap); + if (res > 0) + items[item_no - 1]->namelen += res; + va_end(ap); + + return res; +} + +static int cprint_tag(const char *fmt, ...) +{ + va_list ap; + int res; + + if (!item_no) + cmake(); + va_start(ap, fmt); + res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap); + va_end(ap); + + return res; +} + +static void cdone(void) +{ + int i; + + for (i = 0; i < item_no; i++) { + free(items[i]->tag); + free(items[i]->name); + free(items[i]); + } + + item_no = 0; +} + +static void build_conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + int type, tmp, doint = 2; + tristate val; + char ch; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + prop = menu->prompt; + if (!sym) { + if (prop && menu != current_menu) { + const char *prompt = menu_get_prompt(menu); + switch (prop->type) { + case P_MENU: + child_count++; + cmake(); + cprint_tag("m%p", menu); + + if (single_menu_mode) { + cprint_name("%s%*c%s", + menu->data ? "-->" : "++>", + indent + 1, ' ', prompt); + } else { + cprint_name(" %*c%s --->", indent + 1, ' ', prompt); + } + + if (single_menu_mode && menu->data) + goto conf_childs; + return; + default: + if (prompt) { + child_count++; + cmake(); + cprint_tag(":%p", menu); + cprint_name("---%*c%s", indent + 1, ' ', prompt); + } + } + } else + doint = 0; + goto conf_childs; + } + + cmake(); + type = sym_get_type(sym); + if (sym_is_choice(sym)) { + struct symbol *def_sym = sym_get_choice_value(sym); + struct menu *def_menu = NULL; + + child_count++; + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child) && child->sym == def_sym) + def_menu = child; + } + + val = sym_get_tristate_value(sym); + if (sym_is_changable(sym)) { + cprint_tag("t%p", menu); + switch (type) { + case S_BOOLEAN: + cprint_name("[%c]", val == no ? ' ' : '*'); + break; + case S_TRISTATE: + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + cprint_name("<%c>", ch); + break; + } + } else { + cprint_tag("%c%p", def_menu ? 't' : ':', menu); + cprint_name(" "); + } + + cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + if (val == yes) { + if (def_menu) { + cprint_name(" (%s)", menu_get_prompt(def_menu)); + cprint_name(" --->"); + if (def_menu->list) { + indent += 2; + build_conf(def_menu); + indent -= 2; + } + } + return; + } + } else { + child_count++; + val = sym_get_tristate_value(sym); + if (sym_is_choice_value(sym) && val == yes) { + cprint_tag(":%p", menu); + cprint_name(" "); + } else { + switch (type) { + case S_BOOLEAN: + cprint_tag("t%p", menu); + if (sym_is_changable(sym)) + cprint_name("[%c]", val == no ? ' ' : '*'); + else + cprint_name("---"); + break; + case S_TRISTATE: + cprint_tag("t%p", menu); + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + if (sym_is_changable(sym)) + cprint_name("<%c>", ch); + else + cprint_name("---"); + break; + default: + cprint_tag("s%p", menu); + tmp = cprint_name("(%s)", sym_get_string_value(sym)); + tmp = indent - tmp + 4; + if (tmp < 0) + tmp = 0; + cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : " (NEW)"); + goto conf_childs; + } + } + cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : " (NEW)"); + if (menu->prompt->type == P_MENU) { + cprint_name(" --->"); + return; + } + } + +conf_childs: + indent += doint; + for (child = menu->list; child; child = child->next) + build_conf(child); + indent -= doint; +} + +static void conf(struct menu *menu) +{ + struct dialog_list_item *active_item = NULL; + struct menu *submenu; + const char *prompt = menu_get_prompt(menu); + struct symbol *sym; + char active_entry[40]; + int stat, type; + + unlink("lxdialog.scrltmp"); + active_entry[0] = 0; + while (1) { + indent = 0; + child_count = 0; + current_menu = menu; + cdone(); cinit(); + build_conf(menu); + if (!child_count) + break; + if (menu == &rootmenu) { + cmake(); cprint_tag(":"); cprint_name("--- "); + cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); + cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); + } + dialog_clear(); + stat = dialog_menu(prompt ? prompt : "Main Menu", + menu_instructions, rows, cols, rows - 10, + active_entry, item_no, items); + if (stat < 0) + return; + + if (stat == 1 || stat == 255) + break; + + active_item = first_sel_item(item_no, items); + if (!active_item) + continue; + active_item->selected = 0; + strncpy(active_entry, active_item->tag, sizeof(active_entry)); + active_entry[sizeof(active_entry)-1] = 0; + type = active_entry[0]; + if (!type) + continue; + + sym = NULL; + submenu = NULL; + if (sscanf(active_entry + 1, "%p", &submenu) == 1) + sym = submenu->sym; + + switch (stat) { + case 0: + switch (type) { + case 'm': + if (single_menu_mode) + submenu->data = (void *) (long) !submenu->data; + else + conf(submenu); + break; + case 't': + if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) + conf_choice(submenu); + else if (submenu->prompt->type == P_MENU) + conf(submenu); + break; + case 's': + conf_string(submenu); + break; + case 'L': + conf_load(); + break; + case 'S': + conf_save(); + break; + } + break; + case 2: + if (sym) + show_help(submenu); + else + show_readme(); + break; + case 3: + if (type == 't') { + if (sym_set_tristate_value(sym, yes)) + break; + if (sym_set_tristate_value(sym, mod)) + show_textbox(NULL, setmod_text, 6, 74); + } + break; + case 4: + if (type == 't') + sym_set_tristate_value(sym, no); + break; + case 5: + if (type == 't') + sym_set_tristate_value(sym, mod); + break; + case 6: + if (type == 't') + sym_toggle_tristate_value(sym); + else if (type == 'm') + conf(submenu); + break; + } + } +} + +static void show_textbox(const char *title, const char *text, int r, int c) +{ + int fd; + + fd = creat(".help.tmp", 0777); + write(fd, text, strlen(text)); + close(fd); + while (dialog_textbox(title, ".help.tmp", r, c) < 0) + ; + unlink(".help.tmp"); +} + +static void show_helptext(const char *title, const char *text) +{ + show_textbox(title, text, rows, cols); +} + +static void show_help(struct menu *menu) +{ + const char *help; + char *helptext; + struct symbol *sym = menu->sym; + + help = sym->help; + if (!help) + help = nohelp_text; + if (sym->name) { + helptext = malloc(strlen(sym->name) + strlen(help) + 16); + sprintf(helptext, "%s:\n\n%s", sym->name, help); + show_helptext(menu_get_prompt(menu), helptext); + free(helptext); + } else + show_helptext(menu_get_prompt(menu), help); +} + +static void show_readme(void) +{ + show_helptext("Help", top_menu_help); +} + +static void conf_choice(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + struct menu *child; + struct symbol *active; + + while (1) { + current_menu = menu; + active = sym_get_choice_value(menu->sym); + cdone(); cinit(); + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + cmake(); + cprint_tag("%p", child); + cprint_name("%s", menu_get_prompt(child)); + items[item_no - 1]->selected = (child->sym == active); + } + + switch (dialog_checklist(prompt ? prompt : "Main Menu", + radiolist_instructions, 15, 70, 6, + item_no, items, FLAG_RADIO)) { + case 0: + if (sscanf(first_sel_item(item_no, items)->tag, "%p", &menu) != 1) + break; + sym_set_tristate_value(menu->sym, yes); + return; + case 1: + show_help(menu); + break; + case 255: + return; + } + } +} + +static void conf_string(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + + while (1) { + char *heading; + + switch (sym_get_type(menu->sym)) { + case S_INT: + heading = (char *) inputbox_instructions_int; + break; + case S_HEX: + heading = (char *) inputbox_instructions_hex; + break; + case S_STRING: + heading = (char *) inputbox_instructions_string; + break; + default: + heading = "Internal mconf error!"; + /* panic? */; + } + + switch (dialog_inputbox(prompt ? prompt : "Main Menu", + heading, 10, 75, + sym_get_string_value(menu->sym))) { + case 0: + if (sym_set_string_value(menu->sym, dialog_input_result)) + return; + show_textbox(NULL, "You have made an invalid entry.", 5, 43); + break; + case 1: + show_help(menu); + break; + case 255: + return; + } + } +} + +static void conf_load(void) +{ + while (1) { + switch (dialog_inputbox(NULL, load_config_text, 11, 55, + filename)) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_read(dialog_input_result)) + return; + show_textbox(NULL, "File does not exist!", 5, 38); + break; + case 1: + show_helptext("Load Alternate Configuration", load_config_help); + break; + case 255: + return; + } + } +} + +static void conf_save(void) +{ + while (1) { + switch (dialog_inputbox(NULL, save_config_text, 11, 55, + filename)) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_write(dialog_input_result)) + return; + show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); + break; + case 1: + show_helptext("Save Alternate Configuration", save_config_help); + break; + case 255: + return; + } + } +} + +static void conf_cleanup(void) +{ + tcsetattr(1, TCSAFLUSH, &ios_org); + unlink(".help.tmp"); +} + +static void winch_handler(int sig) +{ + struct winsize ws; + + if (ioctl(1, TIOCGWINSZ, &ws) == -1) { + rows = 24; + cols = 80; + } else { + rows = ws.ws_row; + cols = ws.ws_col; + } + + if (rows < 19 || cols < 80) { + end_dialog(); + fprintf(stderr, "Your display is too small to run Menuconfig!\n"); + fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); + exit(1); + } + + rows -= 4; + cols -= 5; + +} + +int main(int ac, char **av) +{ + int stat; + char *mode; + struct symbol *sym; + + conf_parse(av[1]); + conf_read(NULL); + + sym = sym_lookup("VERSION", 0); + sym_calc_value(sym); + snprintf(menu_backtitle, 128, "uClibc v%s Configuration", + sym_get_string_value(sym)); + + mode = getenv("MENUCONFIG_MODE"); + if (mode) { + if (!strcasecmp(mode, "single_menu")) + single_menu_mode = 1; + } + + tcgetattr(1, &ios_org); + atexit(conf_cleanup); + init_wsize(); + init_dialog(); + signal(SIGWINCH, winch_handler); + conf(&rootmenu); + end_dialog(); + + /* Restart dialog to act more like when lxdialog was still separate */ + init_dialog(); + do { + stat = dialog_yesno(NULL, + "Do you wish to save your new uClibc configuration?", 5, 60); + } while (stat < 0); + end_dialog(); + + if (stat == 0) { + conf_write(NULL); + printf("\n\n" + "*** End of uClibc configuration.\n" + "*** Check the top-level Makefile for additional configuration options.\n\n"); + } else + printf("\n\nYour uClibc configuration changes were NOT saved.\n\n"); + + return 0; +} diff --git a/extra/config/menu.c b/extra/config/menu.c new file mode 100644 index 0000000..07d4cb2 --- /dev/null +++ b/extra/config/menu.c @@ -0,0 +1,396 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +struct menu rootmenu; +struct menu *current_menu, *current_entry; +static struct menu **last_entry_ptr; + +struct file *file_list; +struct file *current_file; + +void menu_init(void) +{ + current_entry = current_menu = &rootmenu; + last_entry_ptr = &rootmenu.list; +} + +void menu_add_entry(struct symbol *sym) +{ + struct menu *menu; + + menu = malloc(sizeof(*menu)); + memset(menu, 0, sizeof(*menu)); + menu->sym = sym; + menu->parent = current_menu; + menu->file = current_file; + menu->lineno = zconf_lineno(); + + *last_entry_ptr = menu; + last_entry_ptr = &menu->next; + current_entry = menu; +} + +void menu_end_entry(void) +{ +} + +void menu_add_menu(void) +{ + current_menu = current_entry; + last_entry_ptr = ¤t_entry->list; +} + +void menu_end_menu(void) +{ + last_entry_ptr = ¤t_menu->next; + current_menu = current_menu->parent; +} + +struct expr *menu_check_dep(struct expr *e) +{ + if (!e) + return e; + + switch (e->type) { + case E_NOT: + e->left.expr = menu_check_dep(e->left.expr); + break; + case E_OR: + case E_AND: + e->left.expr = menu_check_dep(e->left.expr); + e->right.expr = menu_check_dep(e->right.expr); + break; + case E_SYMBOL: + /* change 'm' into 'm' && MODULES */ + if (e->left.sym == &symbol_mod) + return expr_alloc_and(e, expr_alloc_symbol(modules_sym)); + break; + default: + break; + } + return e; +} + +void menu_add_dep(struct expr *dep) +{ + current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); +} + +void menu_set_type(int type) +{ + struct symbol *sym = current_entry->sym; + + if (sym->type == type) + return; + if (sym->type == S_UNKNOWN) { + sym->type = type; + return; + } + fprintf(stderr, "%s:%d:warning: type of '%s' redefined from '%s' to '%s'\n", + current_entry->file->name, current_entry->lineno, + sym->name ? sym->name : "", sym_type_name(sym->type), sym_type_name(type)); +} + +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) +{ + struct property *prop = prop_alloc(type, current_entry->sym); + + prop->menu = current_entry; + prop->text = prompt; + prop->expr = expr; + prop->visible.expr = menu_check_dep(dep); + + if (prompt) { + if (current_entry->prompt) + fprintf(stderr, "%s:%d: prompt redefined\n", + current_entry->file->name, current_entry->lineno); + current_entry->prompt = prop; + } + + return prop; +} + +void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) +{ + menu_add_prop(type, prompt, NULL, dep); +} + +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) +{ + menu_add_prop(type, NULL, expr, dep); +} + +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) +{ + menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); +} + +void menu_finalize(struct menu *parent) +{ + struct menu *menu, *last_menu; + struct symbol *sym; + struct property *prop; + struct expr *parentdep, *basedep, *dep, *dep2, **ep; + + sym = parent->sym; + if (parent->list) { + if (sym && sym_is_choice(sym)) { + /* find the first choice value and find out choice type */ + for (menu = parent->list; menu; menu = menu->next) { + if (menu->sym) { + current_entry = parent; + menu_set_type(menu->sym->type); + current_entry = menu; + menu_set_type(sym->type); + break; + } + } + parentdep = expr_alloc_symbol(sym); + } else if (parent->prompt) + parentdep = parent->prompt->visible.expr; + else + parentdep = parent->dep; + + for (menu = parent->list; menu; menu = menu->next) { + basedep = expr_transform(menu->dep); + basedep = expr_alloc_and(expr_copy(parentdep), basedep); + basedep = expr_eliminate_dups(basedep); + menu->dep = basedep; + if (menu->sym) + prop = menu->sym->prop; + else + prop = menu->prompt; + for (; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + dep = expr_transform(prop->visible.expr); + dep = expr_alloc_and(expr_copy(basedep), dep); + dep = expr_eliminate_dups(dep); + if (menu->sym && menu->sym->type != S_TRISTATE) + dep = expr_trans_bool(dep); + prop->visible.expr = dep; + if (prop->type == P_SELECT) { + struct symbol *es = prop_get_symbol(prop); + es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, + expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); + } + } + } + for (menu = parent->list; menu; menu = menu->next) + menu_finalize(menu); + } else if (sym) { + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; + basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); + basedep = expr_eliminate_dups(expr_transform(basedep)); + last_menu = NULL; + for (menu = parent->next; menu; menu = menu->next) { + dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; + if (!expr_contains_symbol(dep, sym)) + break; + if (expr_depends_symbol(dep, sym)) + goto next; + dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); + dep = expr_eliminate_dups(expr_transform(dep)); + dep2 = expr_copy(basedep); + expr_eliminate_eq(&dep, &dep2); + expr_free(dep); + if (!expr_is_yes(dep2)) { + expr_free(dep2); + break; + } + expr_free(dep2); + next: + menu_finalize(menu); + menu->parent = parent; + last_menu = menu; + } + if (last_menu) { + parent->list = parent->next; + parent->next = last_menu->next; + last_menu->next = NULL; + } + } + for (menu = parent->list; menu; menu = menu->next) { + if (sym && sym_is_choice(sym) && menu->sym) { + menu->sym->flags |= SYMBOL_CHOICEVAL; + if (!menu->prompt) + fprintf(stderr, "%s:%d:warning: choice value must have a prompt\n", + menu->file->name, menu->lineno); + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_PROMPT && prop->menu != menu) { + fprintf(stderr, "%s:%d:warning: choice values currently only support a single prompt\n", + prop->file->name, prop->lineno); + + } + if (prop->type == P_DEFAULT) + fprintf(stderr, "%s:%d:warning: defaults for choice values not supported\n", + prop->file->name, prop->lineno); + } + current_entry = menu; + menu_set_type(sym->type); + menu_add_symbol(P_CHOICE, sym, NULL); + prop = sym_get_choice_prop(sym); + for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr) + ; + *ep = expr_alloc_one(E_CHOICE, NULL); + (*ep)->right.sym = menu->sym; + } + if (menu->list && (!menu->prompt || !menu->prompt->text)) { + for (last_menu = menu->list; ; last_menu = last_menu->next) { + last_menu->parent = parent; + if (!last_menu->next) + break; + } + last_menu->next = menu->next; + menu->next = menu->list; + menu->list = NULL; + } + } + + if (sym && !(sym->flags & SYMBOL_WARNED)) { + struct symbol *sym2; + if (sym->type == S_UNKNOWN) + fprintf(stderr, "%s:%d:warning: config symbol defined without type\n", + parent->file->name, parent->lineno); + + if (sym_is_choice(sym) && !parent->prompt) + fprintf(stderr, "%s:%d:warning: choice must have a prompt\n", + parent->file->name, parent->lineno); + + for (prop = sym->prop; prop; prop = prop->next) { + switch (prop->type) { + case P_DEFAULT: + if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && + prop->expr->type != E_SYMBOL) + fprintf(stderr, "%s:%d:warning: default must be a single symbol\n", + prop->file->name, prop->lineno); + break; + case P_SELECT: + sym2 = prop_get_symbol(prop); + if ((sym->type != S_BOOLEAN) || (sym2->type != S_BOOLEAN)) + fprintf(stderr, "%s:%d:warning: enable is only allowed with booleans\n", + prop->file->name, prop->lineno); + break; + case P_RANGE: + if (sym->type != S_INT && sym->type != S_HEX) + fprintf(stderr, "%s:%d:warning: range is only allowed for int or hex symbols\n", + prop->file->name, prop->lineno); + if (!sym_string_valid(sym, prop->expr->left.sym->name) || + !sym_string_valid(sym, prop->expr->right.sym->name)) + fprintf(stderr, "%s:%d:warning: range is invalid\n", + prop->file->name, prop->lineno); + break; + default: + ; + } + } + sym->flags |= SYMBOL_WARNED; + } + + if (sym && !sym_is_optional(sym) && parent->prompt) { + sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, + expr_alloc_and(parent->prompt->visible.expr, + expr_alloc_symbol(&symbol_mod))); + } +} + +bool menu_is_visible(struct menu *menu) +{ + struct menu *child; + struct symbol *sym; + tristate visible; + + if (!menu->prompt) + return false; + sym = menu->sym; + if (sym) { + sym_calc_value(sym); + visible = menu->prompt->visible.tri; + } else + visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); + + if (visible != no) + return true; + if (!sym || sym_get_tristate_value(menu->sym) == no) + return false; + + for (child = menu->list; child; child = child->next) + if (menu_is_visible(child)) + return true; + return false; +} + +const char *menu_get_prompt(struct menu *menu) +{ + if (menu->prompt) + return menu->prompt->text; + else if (menu->sym) + return menu->sym->name; + return NULL; +} + +struct menu *menu_get_root_menu(struct menu *menu) +{ + return &rootmenu; +} + +struct menu *menu_get_parent_menu(struct menu *menu) +{ + enum prop_type type; + + for (; menu != &rootmenu; menu = menu->parent) { + type = menu->prompt ? menu->prompt->type : 0; + if (type == P_MENU) + break; + } + return menu; +} + +struct file *file_lookup(const char *name) +{ + struct file *file; + + for (file = file_list; file; file = file->next) { + if (!strcmp(name, file->name)) + return file; + } + + file = malloc(sizeof(*file)); + memset(file, 0, sizeof(*file)); + file->name = strdup(name); + file->next = file_list; + file_list = file; + return file; +} + +int file_write_dep(const char *name) +{ + struct file *file; + FILE *out; + + if (!name) + name = ".config.cmd"; + out = fopen(".config.tmp", "w"); + if (!out) + return 1; + fprintf(out, "deps_config := \\\n"); + for (file = file_list; file; file = file->next) { + if (file->next) + fprintf(out, "\t%s \\\n", file->name); + else + fprintf(out, "\t%s\n", file->name); + } + fprintf(out, "\n.config include/system_configuration.h: $(deps_config)\n\n$(deps_config):\n"); + fclose(out); + rename(".config.tmp", name); + return 0; +} + diff --git a/extra/config/menubox.c b/extra/config/menubox.c new file mode 100644 index 0000000..18e0216 --- /dev/null +++ b/extra/config/menubox.c @@ -0,0 +1,436 @@ +/* + * menubox.c -- implements the menu box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Changes by Clifford Wolf (god@clifford.at) + * + * [ 1998-06-13 ] + * + * *) A bugfix for the Page-Down problem + * + * *) Formerly when I used Page Down and Page Up, the cursor would be set + * to the first position in the menu box. Now lxdialog is a bit + * smarter and works more like other menu systems (just have a look at + * it). + * + * *) Formerly if I selected something my scrolling would be broken because + * lxdialog is re-invoked by the Menuconfig shell script, can't + * remember the last scrolling position, and just sets it so that the + * cursor is at the bottom of the box. Now it writes the temporary file + * lxdialog.scrltmp which contains this information. The file is + * deleted by lxdialog if the user leaves a submenu or enters a new + * one, but it would be nice if Menuconfig could make another "rm -f" + * just to be sure. Just try it out - you will recognise a difference! + * + * [ 1998-06-14 ] + * + * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files + * and menus change their size on the fly. + * + * *) If for some reason the last scrolling position is not saved by + * lxdialog, it sets the scrolling so that the selected item is in the + * middle of the menu box, not at the bottom. + * + * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) + * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. + * This fixes a bug in Menuconfig where using ' ' to descend into menus + * would leave mis-synchronized lxdialog.scrltmp files lying around, + * fscanf would read in 'scroll', and eventually that value would get used. + */ + +#include "dialog.h" + +static int menu_width, item_x; + +/* + * Print menu item + */ +static void +print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey) +{ + int j; + char menu_item[menu_width+1]; + + strncpy(menu_item, item, menu_width); + menu_item[menu_width] = 0; + j = first_alpha(menu_item, "YyNnMm"); + + /* Clear 'residue' of last item */ + wattrset (win, menubox_attr); + wmove (win, choice, 0); +#if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch (win, ' '); + } +#else + wclrtoeol(win); +#endif + wattrset (win, selected ? item_selected_attr : item_attr); + mvwaddstr (win, choice, item_x, menu_item); + if (hotkey) { + wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); + mvwaddch(win, choice, item_x+j, menu_item[j]); + } + if (selected) { + wmove (win, choice, item_x+1); + wrefresh (win); + } +} + +/* + * Print the scroll indicators. + */ +static void +print_arrows (WINDOW * win, int item_no, int scroll, + int y, int x, int height) +{ + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset (win, uarrow_attr); + waddch (win, ACS_UARROW); + waddstr (win, "(-)"); + } + else { + wattrset (win, menubox_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset (win, darrow_attr); + waddch (win, ACS_DARROW); + waddstr (win, "(+)"); + } + else { + wattrset (win, menubox_border_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); +} + +/* + * Display the termination buttons. + */ +static void +print_buttons (WINDOW *win, int height, int width, int selected) +{ + int x = width / 2 - 16; + int y = height - 2; + + print_button (win, "Select", y, x, selected == 0); + print_button (win, " Exit ", y, x + 12, selected == 1); + print_button (win, " Help ", y, x + 24, selected == 2); + + wmove(win, y, x+1+12*selected); + wrefresh (win); +} + +/* + * Display a menu for choosing among a number of options + */ +int +dialog_menu (const char *title, const char *prompt, int height, int width, + int menu_height, const char *current, int item_no, + struct dialog_list_item ** items) +{ + int i, j, x, y, box_x, box_y; + int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice; + WINDOW *dialog, *menu; + FILE *f; + + max_choice = MIN (menu_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + wbkgdset (dialog, dialog_attr & A_COLOR); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin (dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad (menu, TRUE); + + /* draw a box around the menu items */ + draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2, + menubox_border_attr, menubox_attr); + + /* + * Find length of longest item in order to center menu. + * Set 'choice' to default item. + */ + item_x = 0; + for (i = 0; i < item_no; i++) { + item_x = MAX (item_x, MIN(menu_width, strlen (items[i]->name) + 2)); + if (strcmp(current, items[i]->tag) == 0) choice = i; + } + + item_x = (menu_width - item_x) / 2; + + /* get the scroll info from the temp file */ + if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) { + if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) && + (scroll+max_choice > choice) && (scroll >= 0) && + (scroll+max_choice <= item_no) ) { + first_item = scroll; + choice = choice - scroll; + fclose(f); + } else { + scroll=0; + remove("lxdialog.scrltmp"); + fclose(f); + f=NULL; + } + } + if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { + if (choice >= item_no-max_choice/2) + scroll = first_item = item_no-max_choice; + else + scroll = first_item = choice - max_choice/2; + choice = choice - scroll; + } + + /* Print the menu */ + for (i=0; i < max_choice; i++) { + print_item (menu, items[first_item + i]->name, i, i == choice, + (items[first_item + i]->tag[0] != ':')); + } + + wnoutrefresh (menu); + + print_arrows(dialog, item_no, scroll, + box_y, box_x+item_x+1, menu_height); + + print_buttons (dialog, height, width, 0); + wmove (menu, choice, item_x+1); + wrefresh (menu); + + while (key != ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) key = tolower(key); + + if (strchr("ynm", key)) + i = max_choice; + else { + for (i = choice+1; i < max_choice; i++) { + j = first_alpha(items[scroll + i]->name, "YyNnMm>"); + if (key == tolower(items[scroll + i]->name[j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + j = first_alpha(items[scroll + i]->name, "YyNnMm>"); + if (key == tolower(items[scroll + i]->name[j])) + break; + } + } + + if (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE) { + + print_item (menu, items[scroll + choice]->name, choice, FALSE, + (items[scroll + choice]->tag[0] != ':')); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + scrollok (menu, TRUE); + wscrl (menu, -1); + scrollok (menu, FALSE); + + scroll--; + + print_item (menu, items[scroll]->name, 0, FALSE, + (items[scroll]->tag[0] != ':')); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + + print_item (menu, items[scroll + choice]->name, choice, FALSE, + (items[scroll + choice]->tag[0] != ':')); + + if ((choice > max_choice-3) && + (scroll + max_choice < item_no) + ) { + /* Scroll menu up */ + scrollok (menu, TRUE); + scroll (menu); + scrollok (menu, FALSE); + + scroll++; + + print_item (menu, items[scroll + max_choice - 1]->name, + max_choice-1, FALSE, + (items[scroll + max_choice - 1]->tag[0] != ':')); + } else + choice = MIN(choice+1, max_choice-1); + + } else if (key == KEY_PPAGE) { + scrollok (menu, TRUE); + for (i=0; (i < max_choice); i++) { + if (scroll > 0) { + wscrl (menu, -1); + scroll--; + print_item (menu, items[scroll]->name, 0, FALSE, + (items[scroll]->tag[0] != ':')); + } else { + if (choice > 0) + choice--; + } + } + scrollok (menu, FALSE); + + } else if (key == KEY_NPAGE) { + for (i=0; (i < max_choice); i++) { + if (scroll+max_choice < item_no) { + scrollok (menu, TRUE); + scroll(menu); + scrollok (menu, FALSE); + scroll++; + print_item (menu, items[scroll + max_choice - 1]->name, + max_choice-1, FALSE, + (items[scroll + max_choice - 1]->tag[0] != ':')); + } else { + if (choice+1 < max_choice) + choice++; + } + } + + } else + choice = i; + + print_item (menu, items[scroll + choice]->name, choice, TRUE, + (items[scroll + choice]->tag[0] != ':')); + + print_arrows(dialog, item_no, scroll, + box_y, box_x+item_x+1, menu_height); + + wnoutrefresh (dialog); + wrefresh (menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 2 : (button > 2 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh (menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + /* save scroll info */ + if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { + fprintf(f,"%d\n",scroll); + fclose(f); + } + delwin (dialog); + items[scroll + choice]->selected = 1; + switch (key) { + case 's': return 3; + case 'y': return 3; + case 'n': return 4; + case 'm': return 5; + case ' ': return 6; + } + return 0; + case 'h': + case '?': + button = 2; + case '\n': + delwin (dialog); + items[scroll + choice]->selected = 1; + + remove("lxdialog.scrltmp"); + return button; + case 'e': + case 'x': + key = ESC; + case ESC: + break; + } + } + + delwin (dialog); + remove("lxdialog.scrltmp"); + return -1; /* ESC pressed */ +} diff --git a/extra/config/msgbox.c b/extra/config/msgbox.c new file mode 100644 index 0000000..93692e1 --- /dev/null +++ b/extra/config/msgbox.c @@ -0,0 +1,85 @@ +/* + * msgbox.c -- implements the message box and info box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display a message box. Program will pause and display an "OK" button + * if the parameter 'pause' is non-zero. + */ +int +dialog_msgbox (const char *title, const char *prompt, int height, int width, + int pause) +{ + int i, x, y, key = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 2); + + if (pause) { + wattrset (dialog, border_attr); + mvwaddch (dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + print_button (dialog, " Ok ", + height - 2, width / 2 - 4, TRUE); + + wrefresh (dialog); + while (key != ESC && key != '\n' && key != ' ' && + key != 'O' && key != 'o' && key != 'X' && key != 'x') + key = wgetch (dialog); + } else { + key = '\n'; + wrefresh (dialog); + } + + delwin (dialog); + return key == ESC ? -1 : 0; +} diff --git a/extra/config/symbol.c b/extra/config/symbol.c new file mode 100644 index 0000000..3bd4d87 --- /dev/null +++ b/extra/config/symbol.c @@ -0,0 +1,763 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +struct symbol symbol_yes = { + name: "y", + curr: { "y", yes }, + flags: SYMBOL_YES|SYMBOL_VALID, +}, symbol_mod = { + name: "m", + curr: { "m", mod }, + flags: SYMBOL_MOD|SYMBOL_VALID, +}, symbol_no = { + name: "n", + curr: { "n", no }, + flags: SYMBOL_NO|SYMBOL_VALID, +}, symbol_empty = { + name: "", + curr: { "", no }, + flags: SYMBOL_VALID, +}; + +int sym_change_count; +struct symbol *modules_sym; + +void sym_add_default(struct symbol *sym, const char *def) +{ + struct property *prop = prop_alloc(P_DEFAULT, sym); + + prop->expr = expr_alloc_symbol(sym_lookup(def, 1)); +} + +void sym_init(void) +{ + struct symbol *sym; + char *p; + static bool inited = false; + + if (inited) + return; + inited = true; + + sym = sym_lookup("VERSION", 0); + sym->type = S_STRING; + sym->flags |= SYMBOL_AUTO; + p = getenv("VERSION"); + if (p) + sym_add_default(sym, p); +} + +enum symbol_type sym_get_type(struct symbol *sym) +{ + enum symbol_type type = sym->type; + + if (type == S_TRISTATE) { + if (sym_is_choice_value(sym) && sym->visible == yes) + type = S_BOOLEAN; + else { + sym_calc_value(modules_sym); + if (modules_sym->curr.tri == no) + type = S_BOOLEAN; + } + } + return type; +} + +const char *sym_type_name(enum symbol_type type) +{ + switch (type) { + case S_BOOLEAN: + return "boolean"; + case S_TRISTATE: + return "tristate"; + case S_INT: + return "integer"; + case S_HEX: + return "hex"; + case S_STRING: + return "string"; + case S_UNKNOWN: + return "unknown"; + case S_OTHER: + break; + } + return "???"; +} + +struct property *sym_get_choice_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_choices(sym, prop) + return prop; + return NULL; +} + +struct property *sym_get_default_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +struct property *sym_get_range_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_properties(sym, prop, P_RANGE) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +static void sym_calc_visibility(struct symbol *sym) +{ + struct property *prop; + tristate tri; + + /* any prompt visible? */ + tri = no; + for_all_prompts(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + tri = E_OR(tri, prop->visible.tri); + } + if (sym->visible != tri) { + sym->visible = tri; + sym_set_changed(sym); + } + if (sym_is_choice_value(sym)) + return; + tri = no; + if (sym->rev_dep.expr) + tri = expr_calc_value(sym->rev_dep.expr); + if (sym->rev_dep.tri != tri) { + sym->rev_dep.tri = tri; + sym_set_changed(sym); + } +} + +static struct symbol *sym_calc_choice(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + + /* is the user choice visible? */ + def_sym = sym->user.val; + if (def_sym) { + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + return def_sym; + } + + /* any of the defaults visible? */ + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri == no) + continue; + def_sym = prop_get_symbol(prop); + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + return def_sym; + } + + /* just get the first visible value */ + prop = sym_get_choice_prop(sym); + for (e = prop->expr; e; e = e->left.expr) { + def_sym = e->right.sym; + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + return def_sym; + } + + /* no choice? reset tristate value */ + sym->curr.tri = no; + return NULL; +} + +void sym_calc_value(struct symbol *sym) +{ + struct symbol_value newval, oldval; + struct property *prop; + struct expr *e; + + if (!sym) + return; + + if (sym->flags & SYMBOL_VALID) + return; + sym->flags |= SYMBOL_VALID; + + oldval = sym->curr; + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + newval = symbol_empty.curr; + break; + case S_BOOLEAN: + case S_TRISTATE: + newval = symbol_no.curr; + break; + default: + sym->curr.val = sym->name; + sym->curr.tri = no; + return; + } + if (!sym_is_choice_value(sym)) + sym->flags &= ~SYMBOL_WRITE; + + sym_calc_visibility(sym); + + /* set default if recursively called */ + sym->curr = newval; + + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_is_choice_value(sym) && sym->visible == yes) { + prop = sym_get_choice_prop(sym); + newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; + } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) { + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) + newval.tri = sym->user.tri; + else if (!sym_is_choice(sym)) { + prop = sym_get_default_prop(sym); + if (prop) + newval.tri = expr_calc_value(prop->expr); + } + newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri); + } else if (!sym_is_choice(sym)) { + prop = sym_get_default_prop(sym); + if (prop) { + sym->flags |= SYMBOL_WRITE; + newval.tri = expr_calc_value(prop->expr); + } + } + if (sym_get_type(sym) == S_BOOLEAN) { + if (newval.tri == mod) + newval.tri = yes; + if (sym->visible == mod) + sym->visible = yes; + if (sym->rev_dep.tri == mod) + sym->rev_dep.tri = yes; + } + break; + case S_STRING: + case S_HEX: + case S_INT: + if (sym->visible != no) { + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) { + newval.val = sym->user.val; + break; + } + } + prop = sym_get_default_prop(sym); + if (prop) { + struct symbol *ds = prop_get_symbol(prop); + if (ds) { + sym->flags |= SYMBOL_WRITE; + sym_calc_value(ds); + newval.val = ds->curr.val; + } + } + break; + default: + ; + } + + sym->curr = newval; + if (sym_is_choice(sym) && newval.tri == yes) + sym->curr.val = sym_calc_choice(sym); + + if (memcmp(&oldval, &sym->curr, sizeof(oldval))) + sym_set_changed(sym); + + if (sym_is_choice(sym)) { + int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); + prop = sym_get_choice_prop(sym); + for (e = prop->expr; e; e = e->left.expr) { + e->right.sym->flags |= flags; + if (flags & SYMBOL_CHANGED) + sym_set_changed(e->right.sym); + } + } +} + +void sym_clear_all_valid(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_VALID; + sym_change_count++; +} + +void sym_set_changed(struct symbol *sym) +{ + struct property *prop; + + sym->flags |= SYMBOL_CHANGED; + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu) + prop->menu->flags |= MENU_CHANGED; + } +} + +void sym_set_all_changed(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym_set_changed(sym); +} + +bool sym_tristate_within_range(struct symbol *sym, tristate val) +{ + int type = sym_get_type(sym); + + if (sym->visible == no) + return false; + + if (type != S_BOOLEAN && type != S_TRISTATE) + return false; + + if (type == S_BOOLEAN && val == mod) + return false; + if (sym->visible <= sym->rev_dep.tri) + return false; + if (sym_is_choice_value(sym) && sym->visible == yes) + return val == yes; + return val >= sym->rev_dep.tri && val <= sym->visible; +} + +bool sym_set_tristate_value(struct symbol *sym, tristate val) +{ + tristate oldval = sym_get_tristate_value(sym); + + if (oldval != val && !sym_tristate_within_range(sym, val)) + return false; + + if (sym->flags & SYMBOL_NEW) { + sym->flags &= ~SYMBOL_NEW; + sym_set_changed(sym); + } + if (sym_is_choice_value(sym) && val == yes) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + + cs->user.val = sym; + cs->flags &= ~SYMBOL_NEW; + } + + sym->user.tri = val; + if (oldval != val) { + sym_clear_all_valid(); + if (sym == modules_sym) + sym_set_all_changed(); + } + + return true; +} + +tristate sym_toggle_tristate_value(struct symbol *sym) +{ + tristate oldval, newval; + + oldval = newval = sym_get_tristate_value(sym); + do { + switch (newval) { + case no: + newval = mod; + break; + case mod: + newval = yes; + break; + case yes: + newval = no; + break; + } + if (sym_set_tristate_value(sym, newval)) + break; + } while (oldval != newval); + return newval; +} + +bool sym_string_valid(struct symbol *sym, const char *str) +{ + char ch; + + switch (sym->type) { + case S_STRING: + return true; + case S_INT: + ch = *str++; + if (ch == '-') + ch = *str++; + if (!isdigit(ch)) + return false; + if (ch == '0' && *str != 0) + return false; + while ((ch = *str++)) { + if (!isdigit(ch)) + return false; + } + return true; + case S_HEX: + if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + str += 2; + ch = *str++; + do { + if (!isxdigit(ch)) + return false; + } while ((ch = *str++)); + return true; + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + case 'm': case 'M': + case 'n': case 'N': + return true; + } + return false; + default: + return false; + } +} + +bool sym_string_within_range(struct symbol *sym, const char *str) +{ + struct property *prop; + int val; + + switch (sym->type) { + case S_STRING: + return sym_string_valid(sym, str); + case S_INT: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtol(str, NULL, 10); + return val >= strtol(prop->expr->left.sym->name, NULL, 10) && + val <= strtol(prop->expr->right.sym->name, NULL, 10); + case S_HEX: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtol(str, NULL, 16); + return val >= strtol(prop->expr->left.sym->name, NULL, 16) && + val <= strtol(prop->expr->right.sym->name, NULL, 16); + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + return sym_tristate_within_range(sym, yes); + case 'm': case 'M': + return sym_tristate_within_range(sym, mod); + case 'n': case 'N': + return sym_tristate_within_range(sym, no); + } + return false; + default: + return false; + } +} + +bool sym_set_string_value(struct symbol *sym, const char *newval) +{ + const char *oldval; + char *val; + int size; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (newval[0]) { + case 'y': case 'Y': + return sym_set_tristate_value(sym, yes); + case 'm': case 'M': + return sym_set_tristate_value(sym, mod); + case 'n': case 'N': + return sym_set_tristate_value(sym, no); + } + return false; + default: + ; + } + + if (!sym_string_within_range(sym, newval)) + return false; + + if (sym->flags & SYMBOL_NEW) { + sym->flags &= ~SYMBOL_NEW; + sym_set_changed(sym); + } + + oldval = sym->user.val; + size = strlen(newval) + 1; + if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { + size += 2; + sym->user.val = val = malloc(size); + *val++ = '0'; + *val++ = 'x'; + } else if (!oldval || strcmp(oldval, newval)) + sym->user.val = val = malloc(size); + else + return true; + + strcpy(val, newval); + free((void *)oldval); + sym_clear_all_valid(); + + return true; +} + +const char *sym_get_string_value(struct symbol *sym) +{ + tristate val; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + val = sym_get_tristate_value(sym); + switch (val) { + case no: + return "n"; + case mod: + return "m"; + case yes: + return "y"; + } + break; + default: + ; + } + return (const char *)sym->curr.val; +} + +bool sym_is_changable(struct symbol *sym) +{ + return sym->visible > sym->rev_dep.tri; +} + +struct symbol *sym_lookup(const char *name, int isconst) +{ + struct symbol *symbol; + const char *ptr; + char *new_name; + int hash = 0; + + if (name) { + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + for (ptr = name; *ptr; ptr++) + hash += *ptr; + hash &= 0xff; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (!strcmp(symbol->name, name)) { + if ((isconst && symbol->flags & SYMBOL_CONST) || + (!isconst && !(symbol->flags & SYMBOL_CONST))) + return symbol; + } + } + new_name = strdup(name); + } else { + new_name = NULL; + hash = 256; + } + + symbol = malloc(sizeof(*symbol)); + memset(symbol, 0, sizeof(*symbol)); + symbol->name = new_name; + symbol->type = S_UNKNOWN; + symbol->flags = SYMBOL_NEW; + if (isconst) + symbol->flags |= SYMBOL_CONST; + + symbol->next = symbol_hash[hash]; + symbol_hash[hash] = symbol; + + return symbol; +} + +struct symbol *sym_find(const char *name) +{ + struct symbol *symbol = NULL; + const char *ptr; + int hash = 0; + + if (!name) + return NULL; + + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + for (ptr = name; *ptr; ptr++) + hash += *ptr; + hash &= 0xff; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (!strcmp(symbol->name, name) && + !(symbol->flags & SYMBOL_CONST)) + break; + } + + return symbol; +} + +struct symbol *sym_check_deps(struct symbol *sym); + +static struct symbol *sym_check_expr_deps(struct expr *e) +{ + struct symbol *sym; + + if (!e) + return NULL; + switch (e->type) { + case E_OR: + case E_AND: + sym = sym_check_expr_deps(e->left.expr); + if (sym) + return sym; + return sym_check_expr_deps(e->right.expr); + case E_NOT: + return sym_check_expr_deps(e->left.expr); + case E_EQUAL: + case E_UNEQUAL: + sym = sym_check_deps(e->left.sym); + if (sym) + return sym; + return sym_check_deps(e->right.sym); + case E_SYMBOL: + return sym_check_deps(e->left.sym); + default: + break; + } + printf("Oops! How to check %d?\n", e->type); + return NULL; +} + +struct symbol *sym_check_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + + if (sym->flags & SYMBOL_CHECK_DONE) + return NULL; + if (sym->flags & SYMBOL_CHECK) { + printf("Warning! Found recursive dependency: %s", sym->name); + return sym; + } + + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_expr_deps(sym->rev_dep.expr); + if (sym2) + goto out; + + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->type == P_CHOICE) + continue; + sym2 = sym_check_expr_deps(prop->visible.expr); + if (sym2) + goto out; + if (prop->type != P_DEFAULT || sym_is_choice(sym)) + continue; + sym2 = sym_check_expr_deps(prop->expr); + if (sym2) + goto out; + } +out: + if (sym2) + printf(" %s", sym->name); + sym->flags &= ~SYMBOL_CHECK; + return sym2; +} + +struct property *prop_alloc(enum prop_type type, struct symbol *sym) +{ + struct property *prop; + struct property **propp; + + prop = malloc(sizeof(*prop)); + memset(prop, 0, sizeof(*prop)); + prop->type = type; + prop->sym = sym; + prop->file = current_file; + prop->lineno = zconf_lineno(); + + /* append property to the prop list of symbol */ + if (sym) { + for (propp = &sym->prop; *propp; propp = &(*propp)->next) + ; + *propp = prop; + } + + return prop; +} + +struct symbol *prop_get_symbol(struct property *prop) +{ + if (prop->expr && (prop->expr->type == E_SYMBOL || + prop->expr->type == E_CHOICE)) + return prop->expr->left.sym; + return NULL; +} + +const char *prop_get_type_name(enum prop_type type) +{ + switch (type) { + case P_PROMPT: + return "prompt"; + case P_COMMENT: + return "comment"; + case P_MENU: + return "menu"; + case P_DEFAULT: + return "default"; + case P_CHOICE: + return "choice"; + case P_SELECT: + return "select"; + case P_RANGE: + return "range"; + case P_UNKNOWN: + break; + } + return "unknown"; +} diff --git a/extra/config/textbox.c b/extra/config/textbox.c new file mode 100644 index 0000000..8fe9077 --- /dev/null +++ b/extra/config/textbox.c @@ -0,0 +1,556 @@ +/* + * textbox.c -- implements the text box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void back_lines (int n); +static void print_page (WINDOW * win, int height, int width); +static void print_line (WINDOW * win, int row, int width); +static char *get_line (void); +static void print_position (WINDOW * win, int height, int width); + +static int hscroll = 0, fd, file_size, bytes_read; +static int begin_reached = 1, end_reached = 0, page_length; +static char *buf, *page; + +/* + * Display text from a file in a dialog box. + */ +int +dialog_textbox (const char *title, const char *file, int height, int width) +{ + int i, x, y, cur_x, cur_y, fpos, key = 0; + int passed_end; + char search_term[MAX_LEN + 1]; + WINDOW *dialog, *text; + + search_term[0] = '\0'; /* no search term entered yet */ + + /* Open input file for reading */ + if ((fd = open (file, O_RDONLY)) == -1) { + endwin (); + fprintf (stderr, + "\nCan't open input file in dialog_textbox().\n"); + exit (-1); + } + /* Get file size. Actually, 'file_size' is the real file size - 1, + since it's only the last byte offset from the beginning */ + if ((file_size = lseek (fd, 0, SEEK_END)) == -1) { + endwin (); + fprintf (stderr, "\nError getting file size in dialog_textbox().\n"); + exit (-1); + } + /* Restore file pointer to beginning of file after getting file size */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + /* Allocate space for read buffer */ + if ((buf = malloc (BUF_SIZE + 1)) == NULL) { + endwin (); + fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n"); + exit (-1); + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in dialog_textbox().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; /* mark end of valid data */ + page = buf; /* page is pointer to start of page to be displayed */ + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + /* Create window for text region, used for scrolling text */ + text = subwin (dialog, height - 4, width - 2, y + 1, x + 1); + wattrset (text, dialog_attr); + wbkgdset (text, dialog_attr & A_COLOR); + + keypad (text, TRUE); + + /* register the new window, along with its borders */ + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + wbkgdset (dialog, dialog_attr & A_COLOR); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE); + wnoutrefresh (dialog); + getyx (dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear (text, height - 4, width - 2, dialog_attr); + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + + while ((key != ESC) && (key != '\n')) { + key = wgetch (dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + delwin (dialog); + free (buf); + close (fd); + return 0; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + /* First page not in buffer? */ + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + if (fpos > bytes_read) { /* Yes, we have to read it in */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "dialog_textbox().\n"); + exit (-1); + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, + "\nError reading file in dialog_textbox().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } + page = buf; + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* Last page not in buffer? */ + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + if (fpos < file_size) { /* Yes, we have to read it in */ + if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, + "\nError reading file in dialog_textbox().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } + page = buf + bytes_read; + back_lines (height - 4); + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (!begin_reached) { + back_lines (page_length + 1); + + /* We don't call print_page() here but use scrolling to ensure + faster screen update. However, 'end_reached' and + 'page_length' should still be updated, and 'page' should + point to start of next page. This is done by calling + get_line() in the following 'for' loop. */ + scrollok (text, TRUE); + wscrl (text, -1); /* Scroll text region down one line */ + scrollok (text, FALSE); + page_length = 0; + passed_end = 0; + for (i = 0; i < height - 4; i++) { + if (!i) { + /* print first line of page */ + print_line (text, 0, width - 2); + wnoutrefresh (text); + } else + /* Called to update 'end_reached' and 'page' */ + get_line (); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + } + break; + case 'B': /* Previous page */ + case 'b': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines (page_length + height - 4); + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (!end_reached) { + begin_reached = 0; + scrollok (text, TRUE); + scroll (text); /* Scroll text region up one line */ + scrollok (text, FALSE); + print_line (text, height - 5, width - 2); + wnoutrefresh (text); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + } + break; + case KEY_NPAGE: /* Next page */ + case ' ': + if (end_reached) + break; + + begin_reached = 0; + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines (page_length); + print_page (text, height - 4, width - 2); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines (page_length); + print_page (text, height - 4, width - 2); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case ESC: + break; + } + } + + delwin (dialog); + free (buf); + close (fd); + return 1; /* ESC pressed */ +} + +/* + * Go back 'n' lines in text file. Called by dialog_textbox(). + * 'page' will be updated to point to the desired line in 'buf'. + */ +static void +back_lines (int n) +{ + int i, fpos; + + begin_reached = 0; + /* We have to distinguish between end_reached and !end_reached + since at end of file, the line is not ended by a '\n'. + The code inside 'if' basically does a '--page' to move one + character backward so as to skip '\n' of the previous line */ + if (!end_reached) { + /* Either beginning of buffer or beginning of file reached? */ + if (page == buf) { + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "back_lines().\n"); + exit (-1); + } + if (fpos > bytes_read) { /* Not beginning of file yet */ + /* We've reached beginning of buffer, but not beginning of + file yet, so read previous part of file into buffer. + Note that we only move backward for BUF_SIZE/2 bytes, + but not BUF_SIZE bytes to avoid re-reading again in + print_page() later */ + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "back_lines().\n"); + exit (-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) + == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer " + "in back_lines().\n"); + exit (-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in back_lines().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } + } + if (*(--page) != '\n') { /* '--page' here */ + /* Something's wrong... */ + endwin (); + fprintf (stderr, "\nInternal error in back_lines().\n"); + exit (-1); + } + } + /* Go back 'n' lines */ + for (i = 0; i < n; i++) + do { + if (page == buf) { + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in back_lines().\n"); + exit (-1); + } + if (fpos > bytes_read) { + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer " + "in back_lines().\n"); + exit (-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), + SEEK_CUR) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer" + " in back_lines().\n"); + exit (-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in " + "back_lines().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } + } + } while (*(--page) != '\n'); + page++; +} + +/* + * Print a new page of text. Called by dialog_textbox(). + */ +static void +print_page (WINDOW * win, int height, int width) +{ + int i, passed_end = 0; + + page_length = 0; + for (i = 0; i < height; i++) { + print_line (win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh (win); +} + +/* + * Print a new line of text. Called by dialog_textbox() and print_page(). + */ +static void +print_line (WINDOW * win, int row, int width) +{ + int y, x; + char *line; + + line = get_line (); + line += MIN (strlen (line), hscroll); /* Scroll horizontally */ + wmove (win, row, 0); /* move cursor to correct line */ + waddch (win, ' '); + waddnstr (win, line, MIN (strlen (line), width - 2)); + + getyx (win, y, x); + /* Clear 'residue' of previous line */ +#if OLD_NCURSES + { + int i; + for (i = 0; i < width - x; i++) + waddch (win, ' '); + } +#else + wclrtoeol(win); +#endif +} + +/* + * Return current line of text. Called by dialog_textbox() and print_line(). + * 'page' should point to start of current line before calling, and will be + * updated to point to start of next line. + */ +static char * +get_line (void) +{ + int i = 0, fpos; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + /* Either end of file or end of buffer reached */ + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "get_line().\n"); + exit (-1); + } + if (fpos < file_size) { /* Not end of file yet */ + /* We've reached end of buffer, but not end of file yet, + so read next part of file into buffer */ + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in get_line().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + page = buf; + } else { + if (!end_reached) + end_reached = 1; + break; + } + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; + } + } + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move pass '\n' */ + + return line; +} + +/* + * Print current position + */ +static void +print_position (WINDOW * win, int height, int width) +{ + int fpos, percent; + + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in print_position().\n"); + exit (-1); + } + wattrset (win, position_indicator_attr); + wbkgdset (win, position_indicator_attr & A_COLOR); + percent = !file_size ? + 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; + wmove (win, height - 3, width - 9); + wprintw (win, "(%3d%%)", percent); +} diff --git a/extra/config/util.c b/extra/config/util.c new file mode 100644 index 0000000..d20730b --- /dev/null +++ b/extra/config/util.c @@ -0,0 +1,375 @@ +/* + * util.c + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + + +/* use colors by default? */ +bool use_colors = 1; + +char *backtitle = NULL; + +const char *dialog_result; + +/* + * Attribute values, default is for mono display + */ +chtype attributes[] = +{ + A_NORMAL, /* screen_attr */ + A_NORMAL, /* shadow_attr */ + A_NORMAL, /* dialog_attr */ + A_BOLD, /* title_attr */ + A_NORMAL, /* border_attr */ + A_REVERSE, /* button_active_attr */ + A_DIM, /* button_inactive_attr */ + A_REVERSE, /* button_key_active_attr */ + A_BOLD, /* button_key_inactive_attr */ + A_REVERSE, /* button_label_active_attr */ + A_NORMAL, /* button_label_inactive_attr */ + A_NORMAL, /* inputbox_attr */ + A_NORMAL, /* inputbox_border_attr */ + A_NORMAL, /* searchbox_attr */ + A_BOLD, /* searchbox_title_attr */ + A_NORMAL, /* searchbox_border_attr */ + A_BOLD, /* position_indicator_attr */ + A_NORMAL, /* menubox_attr */ + A_NORMAL, /* menubox_border_attr */ + A_NORMAL, /* item_attr */ + A_REVERSE, /* item_selected_attr */ + A_BOLD, /* tag_attr */ + A_REVERSE, /* tag_selected_attr */ + A_BOLD, /* tag_key_attr */ + A_REVERSE, /* tag_key_selected_attr */ + A_BOLD, /* check_attr */ + A_REVERSE, /* check_selected_attr */ + A_BOLD, /* uarrow_attr */ + A_BOLD /* darrow_attr */ +}; + + +#include "colors.h" + +/* + * Table of color values + */ +int color_table[][3] = +{ + {SCREEN_FG, SCREEN_BG, SCREEN_HL}, + {SHADOW_FG, SHADOW_BG, SHADOW_HL}, + {DIALOG_FG, DIALOG_BG, DIALOG_HL}, + {TITLE_FG, TITLE_BG, TITLE_HL}, + {BORDER_FG, BORDER_BG, BORDER_HL}, + {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, + {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, + {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, + {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, + {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, + {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, + BUTTON_LABEL_INACTIVE_HL}, + {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, + {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, + {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, + {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, + {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, + {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, + {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, + {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, + {ITEM_FG, ITEM_BG, ITEM_HL}, + {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, + {TAG_FG, TAG_BG, TAG_HL}, + {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, + {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, + {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, + {CHECK_FG, CHECK_BG, CHECK_HL}, + {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, + {UARROW_FG, UARROW_BG, UARROW_HL}, + {DARROW_FG, DARROW_BG, DARROW_HL}, +}; /* color_table */ + +/* + * Set window to attribute 'attr' + */ +void +attr_clear (WINDOW * win, int height, int width, chtype attr) +{ + int i, j; + + wattrset (win, attr); + for (i = 0; i < height; i++) { + wmove (win, i, 0); + for (j = 0; j < width; j++) + waddch (win, ' '); + } + touchwin (win); +} + +void dialog_clear (void) +{ + attr_clear (stdscr, LINES, COLS, screen_attr); + /* Display background title if it exists ... - SLH */ + if (backtitle != NULL) { + int i; + + wattrset (stdscr, screen_attr); + mvwaddstr (stdscr, 0, 1, (char *)backtitle); + wmove (stdscr, 1, 1); + for (i = 1; i < COLS - 1; i++) + waddch (stdscr, ACS_HLINE); + } + wnoutrefresh (stdscr); +} + +/* + * Do some initialization for dialog + */ +void +init_dialog (void) +{ + initscr (); /* Init curses */ + keypad (stdscr, TRUE); + cbreak (); + noecho (); + + + if (use_colors) /* Set up colors */ + color_setup (); + + + dialog_clear (); +} + +/* + * Setup for color display + */ +void +color_setup (void) +{ + int i; + + if (has_colors ()) { /* Terminal supports color? */ + start_color (); + + /* Initialize color pairs */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + init_pair (i + 1, color_table[i][0], color_table[i][1]); + + /* Setup color attributes */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + attributes[i] = C_ATTR (color_table[i][2], i + 1); + } +} + +/* + * End using dialog functions. + */ +void +end_dialog (void) +{ + endwin (); +} + + +/* + * Print a string of text in a window, automatically wrap around to the + * next line if the string is too long to fit on one line. Newline + * characters '\n' are replaced by spaces. We start on a new line + * if there is no room for at least 4 nonblanks following a double-space. + */ +void +print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) +{ + int newl, cur_x, cur_y; + int i, prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + + strcpy (tempstr, prompt); + + prompt_len = strlen(tempstr); + + /* + * Remove newlines + */ + for(i=0; i room || + (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room + && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { + cur_y++; + cur_x = x; + } + wmove (win, cur_y, cur_x); + waddstr (win, word); + getyx (win, cur_y, cur_x); + cur_x++; + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' '); + newl = 1; + } else + newl = 0; + word = sp; + } + } +} + +/* + * Print a button + */ +void +print_button (WINDOW * win, const char *label, int y, int x, int selected) +{ + int i, temp; + + wmove (win, y, x); + wattrset (win, selected ? button_active_attr : button_inactive_attr); + waddstr (win, "<"); + temp = strspn (label, " "); + label += temp; + wattrset (win, selected ? button_label_active_attr + : button_label_inactive_attr); + for (i = 0; i < temp; i++) + waddch (win, ' '); + wattrset (win, selected ? button_key_active_attr + : button_key_inactive_attr); + waddch (win, label[0]); + wattrset (win, selected ? button_label_active_attr + : button_label_inactive_attr); + waddstr (win, (char *)label + 1); + wattrset (win, selected ? button_active_attr : button_inactive_attr); + waddstr (win, ">"); + wmove (win, y, x + temp + 1); +} + +/* + * Draw a rectangular box with line drawing characters + */ +void +draw_box (WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) +{ + int i, j; + + wattrset (win, 0); + for (i = 0; i < height; i++) { + wmove (win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch (win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch (win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch (win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch (win, box | ACS_LRCORNER); + else if (!i) + waddch (win, border | ACS_HLINE); + else if (i == height - 1) + waddch (win, box | ACS_HLINE); + else if (!j) + waddch (win, border | ACS_VLINE); + else if (j == width - 1) + waddch (win, box | ACS_VLINE); + else + waddch (win, box | ' '); + } +} + +/* + * Draw shadows along the right and bottom edge to give a more 3D look + * to the boxes + */ +void +draw_shadow (WINDOW * win, int y, int x, int height, int width) +{ + int i; + + if (has_colors ()) { /* Whether terminal supports color? */ + wattrset (win, shadow_attr); + wmove (win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch (win, winch (win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove (win, i, x + width); + waddch (win, winch (win) & A_CHARTEXT); + waddch (win, winch (win) & A_CHARTEXT); + } + wnoutrefresh (win); + } +} + +/* + * Return the position of the first alphabetic character in a string. + */ +int +first_alpha(const char *string, const char *exempt) +{ + int i, in_paren=0, c; + + for (i = 0; i < strlen(string); i++) { + c = tolower(string[i]); + + if (strchr("<[(", c)) ++in_paren; + if (strchr(">])", c)) --in_paren; + + if ((! in_paren) && isalpha(c) && + strchr(exempt, c) == 0) + return i; + } + + return 0; +} + +/* + * Get the first selected item in the dialog_list_item list. + */ +struct dialog_list_item * +first_sel_item(int item_no, struct dialog_list_item ** items) +{ + int i; + + for (i = 0; i < item_no; i++) { + if (items[i]->selected) + return items[i]; + } + + return NULL; +} diff --git a/extra/config/yesno.c b/extra/config/yesno.c new file mode 100644 index 0000000..11fcc25 --- /dev/null +++ b/extra/config/yesno.c @@ -0,0 +1,118 @@ +/* + * yesno.c -- implements the yes/no box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display termination buttons + */ +static void +print_buttons(WINDOW *dialog, int height, int width, int selected) +{ + int x = width / 2 - 10; + int y = height - 2; + + print_button (dialog, " Yes ", y, x, selected == 0); + print_button (dialog, " No ", y, x + 13, selected == 1); + + wmove(dialog, y, x+1 + 13*selected ); + wrefresh (dialog); +} + +/* + * Display a dialog box with two buttons - Yes and No + */ +int +dialog_yesno (const char *title, const char *prompt, int height, int width) +{ + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != ESC) { + key = wgetch (dialog); + switch (key) { + case 'Y': + case 'y': + delwin (dialog); + return 0; + case 'N': + case 'n': + delwin (dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh (dialog); + break; + case ' ': + case '\n': + delwin (dialog); + return button; + case ESC: + break; + } + } + + delwin (dialog); + return -1; /* ESC pressed */ +} diff --git a/extra/config/zconf.l b/extra/config/zconf.l new file mode 100644 index 0000000..55517b2 --- /dev/null +++ b/extra/config/zconf.l @@ -0,0 +1,366 @@ +%option backup nostdinit noyywrap never-interactive full ecs +%option 8bit backup nodefault perf-report perf-report +%x COMMAND HELP STRING PARAM +%{ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define START_STRSIZE 16 + +char *text; +static char *text_ptr; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static struct buffer *zconf_endfile(void); + +void new_string(void) +{ + text = malloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_ptr = text; + text_size = 0; + *text_ptr = 0; +} + +void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + text = realloc(text, new_size); + text_asize = new_size; + text_ptr = text + text_size; + } + memcpy(text_ptr, str, size); + text_ptr += size; + text_size += size; + *text_ptr = 0; +} + +void alloc_string(const char *str, int size) +{ + text = malloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} +%} + +ws [ \n\t] +n [A-Za-z0-9_] + +%% + int str = 0; + int ts, i; + +[ \t]*#.*\n current_file->lineno++; +[ \t]*#.* + +[ \t]*\n current_file->lineno++; return T_EOL; + +[ \t]+ { + BEGIN(COMMAND); +} + +. { + unput(yytext[0]); + BEGIN(COMMAND); +} + + +{ + "mainmenu" BEGIN(PARAM); return T_MAINMENU; + "menu" BEGIN(PARAM); return T_MENU; + "endmenu" BEGIN(PARAM); return T_ENDMENU; + "source" BEGIN(PARAM); return T_SOURCE; + "choice" BEGIN(PARAM); return T_CHOICE; + "endchoice" BEGIN(PARAM); return T_ENDCHOICE; + "comment" BEGIN(PARAM); return T_COMMENT; + "config" BEGIN(PARAM); return T_CONFIG; + "menuconfig" BEGIN(PARAM); return T_MENUCONFIG; + "help" BEGIN(PARAM); return T_HELP; + "if" BEGIN(PARAM); return T_IF; + "endif" BEGIN(PARAM); return T_ENDIF; + "depends" BEGIN(PARAM); return T_DEPENDS; + "requires" BEGIN(PARAM); return T_REQUIRES; + "optional" BEGIN(PARAM); return T_OPTIONAL; + "default" BEGIN(PARAM); return T_DEFAULT; + "prompt" BEGIN(PARAM); return T_PROMPT; + "tristate" BEGIN(PARAM); return T_TRISTATE; + "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE; + "bool" BEGIN(PARAM); return T_BOOLEAN; + "boolean" BEGIN(PARAM); return T_BOOLEAN; + "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN; + "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN; + "int" BEGIN(PARAM); return T_INT; + "hex" BEGIN(PARAM); return T_HEX; + "string" BEGIN(PARAM); return T_STRING; + "select" BEGIN(PARAM); return T_SELECT; + "enable" BEGIN(PARAM); return T_SELECT; + "range" BEGIN(PARAM); return T_RANGE; + {n}+ { + alloc_string(yytext, yyleng); + zconflval.string = text; + return T_WORD; + } + . + \n current_file->lineno++; BEGIN(INITIAL); +} + +{ + "&&" return T_AND; + "||" return T_OR; + "(" return T_OPEN_PAREN; + ")" return T_CLOSE_PAREN; + "!" return T_NOT; + "=" return T_EQUAL; + "!=" return T_UNEQUAL; + "if" return T_IF; + "on" return T_ON; + \"|\' { + str = yytext[0]; + new_string(); + BEGIN(STRING); + } + \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; + --- /* ignore */ + ({n}|[-/.])+ { + alloc_string(yytext, yyleng); + zconflval.string = text; + return T_WORD; + } + #.* /* comment */ + \\\n current_file->lineno++; + . + <> { + BEGIN(INITIAL); + } +} + +{ + [^'"\\\n]+/\n { + append_string(yytext, yyleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + [^'"\\\n]+ { + append_string(yytext, yyleng); + } + \\.?/\n { + append_string(yytext + 1, yyleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + \\.? { + append_string(yytext + 1, yyleng - 1); + } + \'|\" { + if (str == yytext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(yytext, 1); + } + \n { + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + <> { + BEGIN(INITIAL); + } +} + +{ + [ \t]+ { + ts = 0; + for (i = 0; i < yyleng; i++) { + if (yytext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + [ \t]*\n/[^ \t\n] { + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + [ \t]*\n { + current_file->lineno++; + append_string("\n", 1); + } + [^ \t\n].* { + append_string(yytext, yyleng); + if (!first_ts) + first_ts = last_ts; + } + <> { + zconf_endhelp(); + return T_HELPTEXT; + } +} + +<> { + if (current_buf) { + zconf_endfile(); + return T_EOF; + } + fclose(yyin); + yyterminate(); +} + +%% +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + yyin = zconf_fopen(name); + if (!yyin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = malloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; + current_file->flags = FILE_BUSY; +} + +void zconf_nextfile(const char *name) +{ + struct file *file = file_lookup(name); + struct buffer *buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + yyin = zconf_fopen(name); + if (!yyin) { + printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + exit(1); + } + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", name); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", name); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +static struct buffer *zconf_endfile(void) +{ + struct buffer *parent; + + current_file->flags |= FILE_SCANNED; + current_file->flags &= ~FILE_BUSY; + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(yyin); + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; + + return parent; +} + +int zconf_lineno(void) +{ + if (current_buf) + return current_file->lineno - 1; + else + return 0; +} + +char *zconf_curname(void) +{ + if (current_buf) + return current_file->name; + else + return ""; +} diff --git a/extra/config/zconf.tab.c_shipped b/extra/config/zconf.tab.c_shipped new file mode 100644 index 0000000..dae711d --- /dev/null +++ b/extra/config/zconf.tab.c_shipped @@ -0,0 +1,2127 @@ +/* A Bison parser, made by GNU Bison 1.875a. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* If NAME_PREFIX is specified substitute the variables and functions + names. */ +#define yyparse zconfparse +#define yylex zconflex +#define yyerror zconferror +#define yylval zconflval +#define yychar zconfchar +#define yydebug zconfdebug +#define yynerrs zconfnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_MAINMENU = 258, + T_MENU = 259, + T_ENDMENU = 260, + T_SOURCE = 261, + T_CHOICE = 262, + T_ENDCHOICE = 263, + T_COMMENT = 264, + T_CONFIG = 265, + T_MENUCONFIG = 266, + T_HELP = 267, + T_HELPTEXT = 268, + T_IF = 269, + T_ENDIF = 270, + T_DEPENDS = 271, + T_REQUIRES = 272, + T_OPTIONAL = 273, + T_PROMPT = 274, + T_DEFAULT = 275, + T_TRISTATE = 276, + T_DEF_TRISTATE = 277, + T_BOOLEAN = 278, + T_DEF_BOOLEAN = 279, + T_STRING = 280, + T_INT = 281, + T_HEX = 282, + T_WORD = 283, + T_WORD_QUOTE = 284, + T_UNEQUAL = 285, + T_EOF = 286, + T_EOL = 287, + T_CLOSE_PAREN = 288, + T_OPEN_PAREN = 289, + T_ON = 290, + T_SELECT = 291, + T_RANGE = 292, + T_OR = 293, + T_AND = 294, + T_EQUAL = 295, + T_NOT = 296 + }; +#endif +#define T_MAINMENU 258 +#define T_MENU 259 +#define T_ENDMENU 260 +#define T_SOURCE 261 +#define T_CHOICE 262 +#define T_ENDCHOICE 263 +#define T_COMMENT 264 +#define T_CONFIG 265 +#define T_MENUCONFIG 266 +#define T_HELP 267 +#define T_HELPTEXT 268 +#define T_IF 269 +#define T_ENDIF 270 +#define T_DEPENDS 271 +#define T_REQUIRES 272 +#define T_OPTIONAL 273 +#define T_PROMPT 274 +#define T_DEFAULT 275 +#define T_TRISTATE 276 +#define T_DEF_TRISTATE 277 +#define T_BOOLEAN 278 +#define T_DEF_BOOLEAN 279 +#define T_STRING 280 +#define T_INT 281 +#define T_HEX 282 +#define T_WORD 283 +#define T_WORD_QUOTE 284 +#define T_UNEQUAL 285 +#define T_EOF 286 +#define T_EOL 287 +#define T_CLOSE_PAREN 288 +#define T_OPEN_PAREN 289 +#define T_ON 290 +#define T_SELECT 291 +#define T_RANGE 292 +#define T_OR 293 +#define T_AND 294 +#define T_EQUAL 295 +#define T_NOT 296 + + + + +/* Copy the first part of user declarations. */ + + +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(int token, int starttoken, int endtoken); + +struct symbol *symbol_hash[257]; + +#define YYERROR_VERBOSE + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) + +typedef union YYSTYPE { + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} YYSTYPE; +/* Line 191 of yacc.c. */ + +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +#define LKC_DIRECT_LINK +#include "lkc.h" + + +/* Line 214 of yacc.c. */ + + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 201 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 41 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 104 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 182 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 296 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, + 21, 23, 26, 28, 30, 32, 34, 36, 38, 42, + 45, 49, 52, 53, 56, 59, 62, 65, 69, 74, + 78, 83, 87, 91, 95, 100, 105, 110, 116, 119, + 122, 124, 128, 131, 132, 135, 138, 141, 144, 149, + 153, 157, 160, 165, 166, 169, 173, 175, 179, 182, + 183, 186, 189, 192, 196, 199, 201, 205, 208, 209, + 212, 215, 218, 222, 226, 228, 232, 235, 238, 241, + 242, 245, 248, 253, 257, 261, 262, 265, 267, 269, + 272, 275, 278, 280, 282, 283, 286, 288, 292, 296, + 300, 303, 307, 311, 313 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 43, 0, -1, -1, 43, 44, -1, 45, -1, 55, + -1, 66, -1, 3, 77, 79, -1, 5, -1, 15, + -1, 8, -1, 1, 79, -1, 61, -1, 71, -1, + 47, -1, 49, -1, 69, -1, 79, -1, 10, 28, + 32, -1, 46, 50, -1, 11, 28, 32, -1, 48, + 50, -1, -1, 50, 51, -1, 50, 75, -1, 50, + 73, -1, 50, 32, -1, 21, 76, 32, -1, 22, + 81, 80, 32, -1, 23, 76, 32, -1, 24, 81, + 80, 32, -1, 26, 76, 32, -1, 27, 76, 32, + -1, 25, 76, 32, -1, 19, 77, 80, 32, -1, + 20, 81, 80, 32, -1, 36, 28, 80, 32, -1, + 37, 82, 82, 80, 32, -1, 7, 32, -1, 52, + 56, -1, 78, -1, 53, 58, 54, -1, 53, 58, + -1, -1, 56, 57, -1, 56, 75, -1, 56, 73, + -1, 56, 32, -1, 19, 77, 80, 32, -1, 21, + 76, 32, -1, 23, 76, 32, -1, 18, 32, -1, + 20, 28, 80, 32, -1, -1, 58, 45, -1, 14, + 81, 32, -1, 78, -1, 59, 62, 60, -1, 59, + 62, -1, -1, 62, 45, -1, 62, 66, -1, 62, + 55, -1, 4, 77, 32, -1, 63, 74, -1, 78, + -1, 64, 67, 65, -1, 64, 67, -1, -1, 67, + 45, -1, 67, 66, -1, 67, 55, -1, 67, 1, + 32, -1, 6, 77, 32, -1, 68, -1, 9, 77, + 32, -1, 70, 74, -1, 12, 32, -1, 72, 13, + -1, -1, 74, 75, -1, 74, 32, -1, 16, 35, + 81, 32, -1, 16, 81, 32, -1, 17, 81, 32, + -1, -1, 77, 80, -1, 28, -1, 29, -1, 5, + 79, -1, 8, 79, -1, 15, 79, -1, 32, -1, + 31, -1, -1, 14, 81, -1, 82, -1, 82, 40, + 82, -1, 82, 30, 82, -1, 34, 81, 33, -1, + 41, 81, -1, 81, 38, 81, -1, 81, 39, 81, + -1, 28, -1, 29, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 94, 94, 95, 98, 99, 100, 101, 102, 103, + 104, 105, 109, 110, 111, 112, 113, 114, 120, 128, + 134, 142, 152, 154, 155, 156, 157, 160, 166, 173, + 179, 186, 192, 198, 204, 210, 216, 222, 230, 239, + 245, 254, 255, 261, 263, 264, 265, 266, 269, 275, + 281, 287, 293, 299, 301, 306, 315, 324, 325, 331, + 333, 334, 335, 340, 347, 353, 362, 363, 369, 371, + 372, 373, 374, 377, 383, 390, 397, 404, 410, 417, + 418, 419, 422, 427, 432, 440, 442, 447, 448, 451, + 452, 453, 457, 457, 459, 460, 463, 464, 465, 466, + 467, 468, 469, 472, 473 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", + "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", + "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", + "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", + "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT", + "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL", + "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR", + "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block", + "common_block", "config_entry_start", "config_stmt", + "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", + "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", + "choice_option_list", "choice_option", "choice_block", "if", "if_end", + "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", + "menu_block", "source", "source_stmt", "comment", "comment_stmt", + "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", + "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, + 44, 44, 45, 45, 45, 45, 45, 45, 46, 47, + 48, 49, 50, 50, 50, 50, 50, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, + 54, 55, 55, 56, 56, 56, 56, 56, 57, 57, + 57, 57, 57, 58, 58, 59, 60, 61, 61, 62, + 62, 62, 62, 63, 64, 65, 66, 66, 67, 67, + 67, 67, 67, 68, 69, 70, 71, 72, 73, 74, + 74, 74, 75, 75, 75, 76, 76, 77, 77, 78, + 78, 78, 79, 79, 80, 80, 81, 81, 81, 81, + 81, 81, 81, 82, 82 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, + 3, 2, 0, 2, 2, 2, 2, 3, 4, 3, + 4, 3, 3, 3, 4, 4, 4, 5, 2, 2, + 1, 3, 2, 0, 2, 2, 2, 2, 4, 3, + 3, 2, 4, 0, 2, 3, 1, 3, 2, 0, + 2, 2, 2, 3, 2, 1, 3, 2, 0, 2, + 2, 2, 3, 3, 1, 3, 2, 2, 2, 0, + 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, + 2, 2, 1, 1, 0, 2, 1, 3, 3, 3, + 2, 3, 3, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 2, 0, 1, 0, 0, 0, 8, 0, 0, 10, + 0, 0, 0, 0, 9, 93, 92, 3, 4, 22, + 14, 22, 15, 43, 53, 5, 59, 12, 79, 68, + 6, 74, 16, 79, 13, 17, 11, 87, 88, 0, + 0, 0, 38, 0, 0, 0, 103, 104, 0, 0, + 0, 96, 19, 21, 39, 42, 58, 64, 0, 76, + 7, 63, 73, 75, 18, 20, 0, 100, 55, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, + 85, 0, 85, 85, 85, 26, 0, 0, 23, 0, + 25, 24, 0, 0, 0, 85, 85, 47, 44, 46, + 45, 0, 0, 0, 54, 41, 40, 60, 62, 57, + 61, 56, 81, 80, 0, 69, 71, 66, 70, 65, + 99, 101, 102, 98, 97, 77, 0, 0, 0, 94, + 94, 0, 94, 94, 0, 94, 0, 0, 0, 94, + 0, 78, 51, 94, 94, 0, 0, 89, 90, 91, + 72, 0, 83, 84, 0, 0, 0, 27, 86, 0, + 29, 0, 33, 31, 32, 0, 94, 0, 0, 49, + 50, 82, 95, 34, 35, 28, 30, 36, 0, 48, + 52, 37 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short yydefgoto[] = +{ + -1, 1, 17, 18, 19, 20, 21, 22, 52, 88, + 23, 24, 105, 25, 54, 98, 55, 26, 109, 27, + 56, 28, 29, 117, 30, 58, 31, 32, 33, 34, + 89, 90, 57, 91, 131, 132, 106, 35, 155, 50, + 51 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -99 +static const short yypact[] = +{ + -99, 48, -99, 38, 46, 46, -99, 46, -29, -99, + 46, -17, -3, -11, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, -99, -99, -99, -99, -99, 38, + 12, 15, -99, 18, 51, 62, -99, -99, -11, -11, + 4, -24, 138, 138, 160, 121, 110, -4, 81, -4, + -99, -99, -99, -99, -99, -99, -19, -99, -99, -11, + -11, 70, 70, 73, 32, -11, 46, -11, 46, -11, + 46, -11, 46, 46, 46, -99, 36, 70, -99, 95, + -99, -99, 96, 46, 106, 46, 46, -99, -99, -99, + -99, 38, 38, 38, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, 112, -99, -99, -99, -99, -99, + -99, 117, -99, -99, -99, -99, -11, 33, 65, 131, + 1, 119, 131, 1, 136, 1, 153, 154, 155, 131, + 70, -99, -99, 131, 131, 156, 157, -99, -99, -99, + -99, 101, -99, -99, -11, 158, 159, -99, -99, 161, + -99, 162, -99, -99, -99, 163, 131, 164, 165, -99, + -99, -99, 99, -99, -99, -99, -99, -99, 166, -99, + -99, -99 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short yypgoto[] = +{ + -99, -99, -99, 111, -99, -99, -99, -99, 178, -99, + -99, -99, -99, 91, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, 115, -99, -99, -99, -99, -99, + -99, 146, 168, 89, 27, 0, 126, -1, -98, -48, + -63 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -68 +static const short yytable[] = +{ + 66, 67, 36, 42, 39, 40, 71, 41, 123, 124, + 43, 44, 74, 75, 120, 154, 72, 46, 47, 69, + 70, 121, 122, 48, 140, 45, 127, 128, 112, 130, + 49, 133, 156, 135, 158, 159, 68, 161, 60, 69, + 70, 165, 69, 70, 61, 167, 168, 62, 2, 3, + 63, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 46, 47, 13, 14, 139, 152, 48, 126, 178, 15, + 16, 69, 70, 49, 37, 38, 129, 166, 151, 15, + 16, -67, 114, 64, -67, 5, 101, 7, 8, 102, + 10, 11, 12, 143, 65, 13, 103, 153, 46, 47, + 147, 148, 149, 69, 70, 125, 172, 134, 141, 136, + 137, 138, 15, 16, 5, 101, 7, 8, 102, 10, + 11, 12, 145, 146, 13, 103, 101, 7, 142, 102, + 10, 11, 12, 171, 144, 13, 103, 69, 70, 69, + 70, 15, 16, 100, 150, 154, 113, 108, 113, 116, + 73, 157, 15, 16, 74, 75, 70, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 104, 107, 160, 115, + 85, 110, 73, 118, 86, 87, 74, 75, 92, 93, + 94, 95, 111, 96, 119, 162, 163, 164, 169, 170, + 173, 174, 97, 175, 176, 177, 179, 180, 181, 53, + 99, 59 +}; + +static const unsigned char yycheck[] = +{ + 48, 49, 3, 32, 4, 5, 30, 7, 71, 72, + 10, 28, 16, 17, 33, 14, 40, 28, 29, 38, + 39, 69, 70, 34, 87, 28, 74, 75, 32, 77, + 41, 79, 130, 81, 132, 133, 32, 135, 39, 38, + 39, 139, 38, 39, 32, 143, 144, 32, 0, 1, + 32, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 28, 29, 14, 15, 28, 32, 34, 35, 166, 31, + 32, 38, 39, 41, 28, 29, 76, 140, 126, 31, + 32, 0, 1, 32, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 93, 32, 14, 15, 32, 28, 29, + 101, 102, 103, 38, 39, 32, 154, 80, 13, 82, + 83, 84, 31, 32, 4, 5, 6, 7, 8, 9, + 10, 11, 95, 96, 14, 15, 5, 6, 32, 8, + 9, 10, 11, 32, 28, 14, 15, 38, 39, 38, + 39, 31, 32, 54, 32, 14, 57, 56, 59, 58, + 12, 32, 31, 32, 16, 17, 39, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 55, 56, 32, 58, + 32, 56, 12, 58, 36, 37, 16, 17, 18, 19, + 20, 21, 56, 23, 58, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 21, + 54, 33 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 43, 0, 1, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 14, 15, 31, 32, 44, 45, 46, + 47, 48, 49, 52, 53, 55, 59, 61, 63, 64, + 66, 68, 69, 70, 71, 79, 79, 28, 29, 77, + 77, 77, 32, 77, 28, 28, 28, 29, 34, 41, + 81, 82, 50, 50, 56, 58, 62, 74, 67, 74, + 79, 32, 32, 32, 32, 32, 81, 81, 32, 38, + 39, 30, 40, 12, 16, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 32, 36, 37, 51, 72, + 73, 75, 18, 19, 20, 21, 23, 32, 57, 73, + 75, 5, 8, 15, 45, 54, 78, 45, 55, 60, + 66, 78, 32, 75, 1, 45, 55, 65, 66, 78, + 33, 81, 81, 82, 82, 32, 35, 81, 81, 77, + 81, 76, 77, 81, 76, 81, 76, 76, 76, 28, + 82, 13, 32, 77, 28, 76, 76, 79, 79, 79, + 32, 81, 32, 32, 14, 80, 80, 32, 80, 80, + 32, 80, 32, 32, 32, 80, 82, 80, 80, 32, + 32, 32, 81, 32, 32, 32, 32, 32, 80, 32, + 32, 32 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.first_line = Rhs[1].first_line; \ + Current.first_column = Rhs[1].first_column; \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (cinluded). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylineno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylineno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 8: + + { zconfprint("unexpected 'endmenu' statement"); ;} + break; + + case 9: + + { zconfprint("unexpected 'endif' statement"); ;} + break; + + case 10: + + { zconfprint("unexpected 'endchoice' statement"); ;} + break; + + case 11: + + { zconfprint("syntax error"); yyerrok; ;} + break; + + case 18: + + { + struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 19: + + { + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 20: + + { + struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 21: + + { + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 27: + + { + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 28: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 29: + + { + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 30: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 31: + + { + menu_set_type(S_INT); + printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 32: + + { + menu_set_type(S_HEX); + printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 33: + + { + menu_set_type(S_STRING); + printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 34: + + { + menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 35: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 36: + + { + menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 37: + + { + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 38: + + { + struct symbol *sym = sym_lookup(NULL, 0); + sym->flags |= SYMBOL_CHOICE; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 39: + + { + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 40: + + { + if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 42: + + { + printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 48: + + { + menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 49: + + { + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 50: + + { + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 51: + + { + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 52: + + { + menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 55: + + { + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep(yyvsp[-1].expr); + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 56: + + { + if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 58: + + { + printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 63: + + { + menu_add_entry(NULL); + menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 64: + + { + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 65: + + { + if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 67: + + { + printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 72: + + { zconfprint("invalid menu option"); yyerrok; ;} + break; + + case 73: + + { + yyval.string = yyvsp[-1].string; + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 74: + + { + zconf_nextfile(yyvsp[0].string); +;} + break; + + case 75: + + { + menu_add_entry(NULL); + menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 76: + + { + menu_end_entry(); +;} + break; + + case 77: + + { + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +;} + break; + + case 78: + + { + current_entry->sym->help = yyvsp[0].string; +;} + break; + + case 82: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 83: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 84: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 86: + + { + menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); +;} + break; + + case 89: + + { yyval.token = T_ENDMENU; ;} + break; + + case 90: + + { yyval.token = T_ENDCHOICE; ;} + break; + + case 91: + + { yyval.token = T_ENDIF; ;} + break; + + case 94: + + { yyval.expr = NULL; ;} + break; + + case 95: + + { yyval.expr = yyvsp[0].expr; ;} + break; + + case 96: + + { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;} + break; + + case 97: + + { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} + break; + + case 98: + + { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} + break; + + case 99: + + { yyval.expr = yyvsp[-1].expr; ;} + break; + + case 100: + + { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;} + break; + + case 101: + + { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;} + break; + + case 102: + + { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;} + break; + + case 103: + + { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;} + break; + + case 104: + + { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;} + break; + + + } + +/* Line 999 of yacc.c. */ + + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("syntax error, unexpected ") + 1; + yysize += yystrlen (yytname[yytype]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* Return failure if at end of input. */ + if (yychar == YYEOF) + { + /* Pop the error token. */ + YYPOPSTACK; + /* Pop the rest of the stack. */ + while (yyss < yyssp) + { + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + YYPOPSTACK; + } + YYABORT; + } + + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*----------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action. | +`----------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + yyvsp--; + yystate = *--yyssp; + + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + + + + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + menu_init(); + modules_sym = sym_lookup("MODULES", 0); + rootmenu.prompt = menu_add_prop(P_MENU, "uClibc++ Configuration", NULL, NULL); + + //zconfdebug = 1; + zconfparse(); + if (zconfnerrs) + exit(1); + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) + printf("\n"); + else + sym->flags |= SYMBOL_CHECK_DONE; + } + + sym_change_count = 1; +} + +const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + } + return ""; +} + +static bool zconf_endtoken(int token, int starttoken, int endtoken) +{ + if (token != endtoken) { + zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfprint("location of the '%s'", zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "choice\n"); + else + fprintf(out, "config %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (sym->help) { + int len = strlen(sym->help); + while (sym->help[--len] == '\n') + sym->help[len] = 0; + fprintf(out, " help\n%s\n", sym->help); + } + fputc('\n', out); +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + fputs("\n", out); + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "lex.zconf.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" + + diff --git a/extra/config/zconf.tab.h_shipped b/extra/config/zconf.tab.h_shipped new file mode 100644 index 0000000..3b191ef --- /dev/null +++ b/extra/config/zconf.tab.h_shipped @@ -0,0 +1,125 @@ +/* A Bison parser, made from zconf.y, by GNU bison 1.75. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +#ifndef BISON_ZCONF_TAB_H +# define BISON_ZCONF_TAB_H + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_MAINMENU = 258, + T_MENU = 259, + T_ENDMENU = 260, + T_SOURCE = 261, + T_CHOICE = 262, + T_ENDCHOICE = 263, + T_COMMENT = 264, + T_CONFIG = 265, + T_HELP = 266, + T_HELPTEXT = 267, + T_IF = 268, + T_ENDIF = 269, + T_DEPENDS = 270, + T_REQUIRES = 271, + T_OPTIONAL = 272, + T_PROMPT = 273, + T_DEFAULT = 274, + T_TRISTATE = 275, + T_BOOLEAN = 276, + T_INT = 277, + T_HEX = 278, + T_WORD = 279, + T_STRING = 280, + T_UNEQUAL = 281, + T_EOF = 282, + T_EOL = 283, + T_CLOSE_PAREN = 284, + T_OPEN_PAREN = 285, + T_ON = 286, + T_OR = 287, + T_AND = 288, + T_EQUAL = 289, + T_NOT = 290 + }; +#endif +#define T_MAINMENU 258 +#define T_MENU 259 +#define T_ENDMENU 260 +#define T_SOURCE 261 +#define T_CHOICE 262 +#define T_ENDCHOICE 263 +#define T_COMMENT 264 +#define T_CONFIG 265 +#define T_HELP 266 +#define T_HELPTEXT 267 +#define T_IF 268 +#define T_ENDIF 269 +#define T_DEPENDS 270 +#define T_REQUIRES 271 +#define T_OPTIONAL 272 +#define T_PROMPT 273 +#define T_DEFAULT 274 +#define T_TRISTATE 275 +#define T_BOOLEAN 276 +#define T_INT 277 +#define T_HEX 278 +#define T_WORD 279 +#define T_STRING 280 +#define T_UNEQUAL 281 +#define T_EOF 282 +#define T_EOL 283 +#define T_CLOSE_PAREN 284 +#define T_OPEN_PAREN 285 +#define T_ON 286 +#define T_OR 287 +#define T_AND 288 +#define T_EQUAL 289 +#define T_NOT 290 + + + + +#ifndef YYSTYPE +#line 33 "zconf.y" +typedef union { + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} yystype; +/* Line 1281 of /usr/share/bison/yacc.c. */ +#line 118 "zconf.tab.h" +# define YYSTYPE yystype +#endif + +extern YYSTYPE zconflval; + + +#endif /* not BISON_ZCONF_TAB_H */ + diff --git a/extra/config/zconf.y b/extra/config/zconf.y new file mode 100644 index 0000000..acfca80 --- /dev/null +++ b/extra/config/zconf.y @@ -0,0 +1,687 @@ +%{ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(int token, int starttoken, int endtoken); + +struct symbol *symbol_hash[257]; + +#define YYERROR_VERBOSE +%} +%expect 40 + +%union +{ + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} + +%token T_MAINMENU +%token T_MENU +%token T_ENDMENU +%token T_SOURCE +%token T_CHOICE +%token T_ENDCHOICE +%token T_COMMENT +%token T_CONFIG +%token T_MENUCONFIG +%token T_HELP +%token T_HELPTEXT +%token T_IF +%token T_ENDIF +%token T_DEPENDS +%token T_REQUIRES +%token T_OPTIONAL +%token T_PROMPT +%token T_DEFAULT +%token T_TRISTATE +%token T_DEF_TRISTATE +%token T_BOOLEAN +%token T_DEF_BOOLEAN +%token T_STRING +%token T_INT +%token T_HEX +%token T_WORD +%token T_WORD_QUOTE +%token T_UNEQUAL +%token T_EOF +%token T_EOL +%token T_CLOSE_PAREN +%token T_OPEN_PAREN +%token T_ON +%token T_SELECT +%token T_RANGE + +%left T_OR +%left T_AND +%left T_EQUAL T_UNEQUAL +%nonassoc T_NOT + +%type prompt +%type source +%type symbol +%type expr +%type if_expr +%type end + +%{ +#define LKC_DIRECT_LINK +#include "lkc.h" +%} +%% +input: /* empty */ + | input block +; + +block: common_block + | choice_stmt + | menu_stmt + | T_MAINMENU prompt nl_or_eof + | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); } + | T_ENDIF { zconfprint("unexpected 'endif' statement"); } + | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); } + | error nl_or_eof { zconfprint("syntax error"); yyerrok; } +; + +common_block: + if_stmt + | comment_stmt + | config_stmt + | menuconfig_stmt + | source_stmt + | nl_or_eof +; + + +/* config/menuconfig entry */ + +config_entry_start: T_CONFIG T_WORD T_EOL +{ + struct symbol *sym = sym_lookup($2, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +config_stmt: config_entry_start config_option_list +{ + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +}; + +menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL +{ + struct symbol *sym = sym_lookup($2, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +menuconfig_stmt: menuconfig_entry_start config_option_list +{ + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +}; + +config_option_list: + /* empty */ + | config_option_list config_option + | config_option_list depends + | config_option_list help + | config_option_list T_EOL +; + +config_option: T_TRISTATE prompt_stmt_opt T_EOL +{ + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEF_TRISTATE expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_BOOLEAN prompt_stmt_opt T_EOL +{ + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEF_BOOLEAN expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_INT prompt_stmt_opt T_EOL +{ + menu_set_type(S_INT); + printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_HEX prompt_stmt_opt T_EOL +{ + menu_set_type(S_HEX); + printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_STRING prompt_stmt_opt T_EOL +{ + menu_set_type(S_STRING); + printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_PROMPT prompt if_expr T_EOL +{ + menu_add_prompt(P_PROMPT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEFAULT expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_SELECT T_WORD if_expr T_EOL +{ + menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_RANGE symbol symbol if_expr T_EOL +{ + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +}; + +/* choice entry */ + +choice: T_CHOICE T_EOL +{ + struct symbol *sym = sym_lookup(NULL, 0); + sym->flags |= SYMBOL_CHOICE; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +}; + +choice_entry: choice choice_option_list +{ + menu_end_entry(); + menu_add_menu(); +}; + +choice_end: end +{ + if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +}; + +choice_stmt: + choice_entry choice_block choice_end + | choice_entry choice_block +{ + printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +}; + +choice_option_list: + /* empty */ + | choice_option_list choice_option + | choice_option_list depends + | choice_option_list help + | choice_option_list T_EOL +; + +choice_option: T_PROMPT prompt if_expr T_EOL +{ + menu_add_prompt(P_PROMPT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_TRISTATE prompt_stmt_opt T_EOL +{ + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_BOOLEAN prompt_stmt_opt T_EOL +{ + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_OPTIONAL T_EOL +{ + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_DEFAULT T_WORD if_expr T_EOL +{ + menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +}; + +choice_block: + /* empty */ + | choice_block common_block +; + +/* if entry */ + +if: T_IF expr T_EOL +{ + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep($2); + menu_end_entry(); + menu_add_menu(); +}; + +if_end: end +{ + if (zconf_endtoken($1, T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +}; + +if_stmt: + if if_block if_end + | if if_block +{ + printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +}; + +if_block: + /* empty */ + | if_block common_block + | if_block menu_stmt + | if_block choice_stmt +; + +/* menu entry */ + +menu: T_MENU prompt T_EOL +{ + menu_add_entry(NULL); + menu_add_prop(P_MENU, $2, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +}; + +menu_entry: menu depends_list +{ + menu_end_entry(); + menu_add_menu(); +}; + +menu_end: end +{ + if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +}; + +menu_stmt: + menu_entry menu_block menu_end + | menu_entry menu_block +{ + printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +}; + +menu_block: + /* empty */ + | menu_block common_block + | menu_block menu_stmt + | menu_block choice_stmt + | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; } +; + +source: T_SOURCE prompt T_EOL +{ + $$ = $2; + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +source_stmt: source +{ + zconf_nextfile($1); +}; + +/* comment entry */ + +comment: T_COMMENT prompt T_EOL +{ + menu_add_entry(NULL); + menu_add_prop(P_COMMENT, $2, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +}; + +comment_stmt: comment depends_list +{ + menu_end_entry(); +}; + +/* help option */ + +help_start: T_HELP T_EOL +{ + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +}; + +help: help_start T_HELPTEXT +{ + current_entry->sym->help = $2; +}; + +/* depends option */ + +depends_list: /* empty */ + | depends_list depends + | depends_list T_EOL +; + +depends: T_DEPENDS T_ON expr T_EOL +{ + menu_add_dep($3); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +} + | T_DEPENDS expr T_EOL +{ + menu_add_dep($2); + printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); +} + | T_REQUIRES expr T_EOL +{ + menu_add_dep($2); + printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); +}; + +/* prompt statement */ + +prompt_stmt_opt: + /* empty */ + | prompt if_expr +{ + menu_add_prop(P_PROMPT, $1, NULL, $2); +}; + +prompt: T_WORD + | T_WORD_QUOTE +; + +end: T_ENDMENU nl_or_eof { $$ = T_ENDMENU; } + | T_ENDCHOICE nl_or_eof { $$ = T_ENDCHOICE; } + | T_ENDIF nl_or_eof { $$ = T_ENDIF; } +; + +nl_or_eof: + T_EOL | T_EOF; + +if_expr: /* empty */ { $$ = NULL; } + | T_IF expr { $$ = $2; } +; + +expr: symbol { $$ = expr_alloc_symbol($1); } + | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } + | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } + | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } + | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } + | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } + | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } +; + +symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } + | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); } +; + +%% + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + menu_init(); + modules_sym = sym_lookup("MODULES", 0); + rootmenu.prompt = menu_add_prop(P_MENU, "uClibc++ Configuration", NULL, NULL); + + //zconfdebug = 1; + zconfparse(); + if (zconfnerrs) + exit(1); + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) + printf("\n"); + else + sym->flags |= SYMBOL_CHECK_DONE; + } + + sym_change_count = 1; +} + +const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + } + return ""; +} + +static bool zconf_endtoken(int token, int starttoken, int endtoken) +{ + if (token != endtoken) { + zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfprint("location of the '%s'", zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "choice\n"); + else + fprintf(out, "config %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (sym->help) { + int len = strlen(sym->help); + while (sym->help[--len] == '\n') + sym->help[len] = 0; + fprintf(out, " help\n%s\n", sym->help); + } + fputc('\n', out); +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + fputs("\n", out); + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "lex.zconf.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" diff --git a/extra/libstrip/libstrip b/extra/libstrip/libstrip new file mode 100755 index 0000000..69a1043 --- /dev/null +++ b/extra/libstrip/libstrip @@ -0,0 +1,72 @@ +#!/usr/bin/perl -w +# vi: set ts=4: + +# Libstrip - A utility to optimize libraries for specific executables +# Copyright (C) 2001 David A. Schleef +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This is a surprisingly simple script that gets a list of +# unresolved symbols in a list of executables specified on the +# command line, and then relinks the uClibc shared object file +# with only the those symbols and their dependencies. This +# results in a shared object that is optimized for the executables +# listed, and thus may not work with other executables. +# +# Example: optimizing uClibc for BusyBox +# Compile uClibc and BusyBox as normal. Then, in this +# directory, run: +# libstrip path/to/busybox +# After the script completes, there should be a new +# libuClibc-0.9.5.so in the current directory, which +# is optimized for busybox. +# +# How it works: +# The uClibc Makefiles create libuClibc.so by first creating +# the ar archive libc.a with all the object files, then links +# the final libuClibc.so by using 'ld --shared --whole-archive'. +# We take advantage of the linker command line option --undefined, +# which pulls in a symbol and all its dependencies, and so relink +# the library using --undefined for each symbol in place of +# --whole-archive. The linker script is used only to avoid +# having very long command lines. + +$topdir="../.."; + +# This is the name of the default ldscript for shared libs. The +# file name will be different for other architectures. +$ldscript="/usr/lib/ldscripts/elf_i386.xs"; + +my @syms; +my @allsyms; +my $s; + +while($exec = shift @ARGV){ + #print "$exec\n"; + @syms=`nm --dynamic $exec`; + for $s (@syms){ + chomp $s; + if($s =~ m/^.{8} [BUV] (.+)/){ + my $x = $1; + if(!grep { m/^$x$/; } @allsyms){ + unshift @allsyms, $x; + } + } + } +} + +open(LDSCRIPT, ">ldscript"); +print LDSCRIPT "INCLUDE $ldscript\n"; +for $s (@allsyms) { + print LDSCRIPT "EXTERN($s)\n"; +} + + +`gcc -s -nostdlib -Wl,-warn-common -shared \\ + -o libuClibc-0.9.5.so \\ + -Wl,-soname,libc.so.0 -Wl,--script=ldscript \\ + $topdir/libc/libc.a \\ + $topdir/libc/tmp/libgcc-need.a` + diff --git a/extra/locale/LOCALES b/extra/locale/LOCALES new file mode 100644 index 0000000..16b9c3e --- /dev/null +++ b/extra/locale/LOCALES @@ -0,0 +1,258 @@ +# First some @modifier mappings. Internally, the modifier is signaled by +# replacing '_' in the locale name with a unique identifying character. +# For example, internally we map "ca_ES@euro" to "caeES". This allows for +# smaller code and easier processing of locale names. + +@euro e +@cyrillic c + +#--------------------------------------------------------------------------- +# Next, set to {y}es to enable and {n}o to disable the UTF-8 and the 8-bit +# codeset locales. Of course, you must have built the c8tables.h and +# the wctables.h files appropriately. + + +UTF-8 yes +8-BIT yes + +#--------------------------------------------------------------------------- +# Now the locales + +af_ZA ISO-8859-1 +af_ZA.UTF-8 UTF-8 +am_ET UTF-8 +ar_AE ISO-8859-6 +ar_AE.UTF-8 UTF-8 +ar_BH ISO-8859-6 +ar_BH.UTF-8 UTF-8 +ar_DZ ISO-8859-6 +ar_DZ.UTF-8 UTF-8 +ar_EG ISO-8859-6 +ar_EG.UTF-8 UTF-8 +ar_IN UTF-8 +ar_IQ ISO-8859-6 +ar_IQ.UTF-8 UTF-8 +ar_JO ISO-8859-6 +ar_JO.UTF-8 UTF-8 +ar_KW ISO-8859-6 +ar_KW.UTF-8 UTF-8 +ar_LB ISO-8859-6 +ar_LB.UTF-8 UTF-8 +ar_LY ISO-8859-6 +ar_LY.UTF-8 UTF-8 +ar_MA ISO-8859-6 +ar_MA.UTF-8 UTF-8 +ar_OM ISO-8859-6 +ar_OM.UTF-8 UTF-8 +ar_QA ISO-8859-6 +ar_QA.UTF-8 UTF-8 +ar_SA ISO-8859-6 +ar_SA.UTF-8 UTF-8 +ar_SD ISO-8859-6 +ar_SD.UTF-8 UTF-8 +ar_SY ISO-8859-6 +ar_SY.UTF-8 UTF-8 +ar_TN ISO-8859-6 +ar_TN.UTF-8 UTF-8 +ar_YE ISO-8859-6 +ar_YE.UTF-8 UTF-8 +# az_AZ ISO-8859-9E +az_AZ ISO-8859-9 +az_AZ.UTF-8 UTF-8 +be_BY CP1251 +be_BY.UTF-8 UTF-8 +bg_BG CP1251 +bg_BG.UTF-8 UTF-8 +bn_BD UTF-8 +bn_IN UTF-8 +br_FR ISO-8859-1 +br_FR.UTF-8 UTF-8 +bs_BA ISO-8859-2 +bs_BA.UTF-8 UTF-8 +cy_GB ISO-8859-14 +cy_GB.UTF-8 UTF-8 +de_AT ISO-8859-1 +de_AT.UTF-8 UTF-8 +de_AT.UTF-8@euro UTF-8 +de_AT@euro ISO-8859-15 +de_BE ISO-8859-1 +de_BE.UTF-8 UTF-8 +de_BE.UTF-8@euro UTF-8 +de_BE@euro ISO-8859-15 +de_CH ISO-8859-1 +de_CH.UTF-8 UTF-8 +de_DE ISO-8859-1 +de_DE.UTF-8 UTF-8 +de_DE.UTF-8@euro UTF-8 +de_DE@euro ISO-8859-15 +de_LU ISO-8859-1 +de_LU.UTF-8 UTF-8 +de_LU.UTF-8@euro UTF-8 +de_LU@euro ISO-8859-15 +el_GR ISO-8859-7 +el_GR.UTF-8 UTF-8 +en_AU ISO-8859-1 +en_AU.UTF-8 UTF-8 +en_BW ISO-8859-1 +en_BW.UTF-8 UTF-8 +en_CA ISO-8859-1 +en_CA.UTF-8 UTF-8 +en_DK ISO-8859-1 +en_DK.UTF-8 UTF-8 +en_GB ISO-8859-1 +en_GB.UTF-8 UTF-8 +en_HK ISO-8859-1 +en_HK.UTF-8 UTF-8 +en_IE ISO-8859-1 +en_IE.UTF-8 UTF-8 +en_IE.UTF-8@euro UTF-8 +en_IE@euro ISO-8859-15 +en_IN UTF-8 +en_NZ ISO-8859-1 +en_NZ.UTF-8 UTF-8 +en_PH ISO-8859-1 +en_PH.UTF-8 UTF-8 +en_SG ISO-8859-1 +en_SG.UTF-8 UTF-8 +en_US ISO-8859-1 +en_US.UTF-8 UTF-8 +en_ZA ISO-8859-1 +en_ZA.UTF-8 UTF-8 +en_ZW ISO-8859-1 +en_ZW.UTF-8 UTF-8 +eo_EO.UTF-8 UTF-8 +eu_ES ISO-8859-1 +eu_ES.UTF-8 UTF-8 +eu_ES.UTF-8@euro UTF-8 +eu_ES@euro ISO-8859-15 +fa_IR UTF-8 +fa_IR.UTF-8 UTF-8 +fo_FO ISO-8859-1 +fo_FO.UTF-8 UTF-8 +fr_BE ISO-8859-1 +fr_BE.UTF-8 UTF-8 +fr_BE.UTF-8@euro UTF-8 +fr_BE@euro ISO-8859-15 +fr_CA ISO-8859-1 +fr_CA.UTF-8 UTF-8 +fr_CH ISO-8859-1 +fr_CH.UTF-8 UTF-8 +fr_FR ISO-8859-1 +fr_FR.UTF-8 UTF-8 +fr_FR.UTF-8@euro UTF-8 +fr_FR@euro ISO-8859-15 +fr_LU ISO-8859-1 +fr_LU.UTF-8 UTF-8 +fr_LU.UTF-8@euro UTF-8 +fr_LU@euro ISO-8859-15 +ga_IE ISO-8859-1 +ga_IE.UTF-8 UTF-8 +ga_IE.UTF-8@euro UTF-8 +ga_IE@euro ISO-8859-15 +gd_GB ISO-8859-15 +gd_GB.UTF-8 UTF-8 +gl_ES ISO-8859-1 +gl_ES.UTF-8 UTF-8 +gl_ES.UTF-8@euro UTF-8 +gl_ES@euro ISO-8859-15 +gv_GB ISO-8859-1 +gv_GB.UTF-8 UTF-8 +he_IL ISO-8859-8 +he_IL.UTF-8 UTF-8 +hi_IN UTF-8 +hi_IN.UTF-8 UTF-8 +hu_HU ISO-8859-2 +hu_HU.UTF-8 UTF-8 +hy_AM ARMSCII-8 +hy_AM.UTF-8 UTF-8 +id_ID ISO-8859-1 +id_ID.UTF-8 UTF-8 +it_CH ISO-8859-1 +it_CH.UTF-8 UTF-8 +it_IT ISO-8859-1 +it_IT.UTF-8 UTF-8 +it_IT.UTF-8@euro UTF-8 +it_IT@euro ISO-8859-15 +iw_IL ISO-8859-8 +iw_IL.UTF-8 UTF-8 +ka_GE GEORGIAN-PS +ka_GE.UTF-8 UTF-8 +kl_GL ISO-8859-1 +kl_GL.UTF-8 UTF-8 +ko_KR.UTF-8 UTF-8 +kw_GB ISO-8859-1 +kw_GB.UTF-8 UTF-8 +mi_NZ ISO-8859-13 +mi_NZ.UTF-8 UTF-8 +mk_MK ISO-8859-5 +mk_MK.UTF-8 UTF-8 +mr_IN UTF-8 +mr_IN.UTF-8 UTF-8 +ms_MY ISO-8859-1 +ms_MY.UTF-8 UTF-8 +mt_MT ISO-8859-3 +mt_MT.UTF-8 UTF-8 +nl_BE ISO-8859-1 +nl_BE.UTF-8 UTF-8 +nl_BE.UTF-8@euro UTF-8 +nl_BE@euro ISO-8859-15 +nl_NL ISO-8859-1 +nl_NL.UTF-8 UTF-8 +nl_NL.UTF-8@euro UTF-8 +nl_NL@euro ISO-8859-15 +nn_NO ISO-8859-1 +nn_NO.UTF-8 UTF-8 +oc_FR ISO-8859-1 +oc_FR.UTF-8 UTF-8 +pt_BR ISO-8859-1 +pt_BR.UTF-8 UTF-8 +pt_PT ISO-8859-1 +pt_PT.UTF-8 UTF-8 +pt_PT.UTF-8@euro UTF-8 +pt_PT@euro ISO-8859-15 +ro_RO ISO-8859-2 +ro_RO.UTF-8 UTF-8 +ru_RU ISO-8859-5 +ru_RU.KOI8-R KOI8-R +ru_RU.UTF-8 UTF-8 +ru_UA KOI8-U +ru_UA.UTF-8 UTF-8 +se_NO UTF-8 +sk_SK ISO-8859-2 +sk_SK.UTF-8 UTF-8 +sq_AL ISO-8859-1 +sq_AL.UTF-8 UTF-8 +sr_YU ISO-8859-2 +sr_YU.UTF-8 UTF-8 +sr_YU.UTF-8@cyrillic UTF-8 +sr_YU@cyrillic ISO-8859-5 +sv_FI ISO-8859-1 +sv_FI.UTF-8 UTF-8 +sv_FI.UTF-8@euro UTF-8 +sv_FI@euro ISO-8859-15 +sv_SE ISO-8859-1 +sv_SE.UTF-8 UTF-8 +ta_IN UTF-8 +te_IN UTF-8 +tg_TJ KOI8-T +tg_TJ.UTF-8 UTF-8 +th_TH TIS-620 +th_TH.UTF-8 UTF-8 +ti_ER UTF-8 +ti_ET UTF-8 +tl_PH ISO-8859-1 +tl_PH.UTF-8 UTF-8 +# tt_RU TATAR-CYR +tt_RU.UTF-8 UTF-8 +uk_UA KOI8-U +uk_UA.UTF-8 UTF-8 +ur_PK UTF-8 +uz_UZ ISO-8859-1 +uz_UZ.UTF-8 UTF-8 +vi_VN UTF-8 +vi_VN.UTF-8 UTF-8 +wa_BE ISO-8859-1 +wa_BE.UTF-8 UTF-8 +wa_BE@euro ISO-8859-15 +yi_US CP1255 +yi_US.UTF-8 UTF-8 diff --git a/extra/locale/Makefile b/extra/locale/Makefile new file mode 100644 index 0000000..1118524 --- /dev/null +++ b/extra/locale/Makefile @@ -0,0 +1,95 @@ + +top_srcdir = ../../ +EXTRA_LOCALE_DIR:=${shell cd $(top_srcdir)/extra/locale && pwd} +include $(top_srcdir)Rules.mak + +CFLAGS_wc8bit=-DCTYPE_PACKED=1 +CFLAGS_mmap= +ifeq ($(strip $(UCLIBC_HAS_WCHAR)),y) + CFLAGS_wc8bit += -DDO_WIDE_CHAR=1 + CFLAGS_mmap += -D__WCHAR_ENABLED=1 +endif + +all: links-target + +codesets.txt: + @if [ ! -f codesets.txt ] ; then \ + set -e; \ + echo " "; \ + echo "You do not have a codesets.txt file. Please create this "; \ + echo "file in the extra/locale directory by running something like: "; \ + echo -e " find $(EXTRA_LOCALE_DIR)/charmaps -name \"*.pairs\" > \\"; \ + echo -e " $(EXTRA_LOCALE_DIR)/codesets.txt"; \ + echo "and then edit that file to disable/enable the codesets you wish to support. "; \ + echo " "; \ + false; \ + fi; + +gen_wc8bit: gen_wc8bit.c + $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $(CFLAGS_wc8bit) -D__UCLIBC_GEN_LOCALE $^ -o $@ + +c8tables.h: gen_wc8bit codesets.txt + ./gen_wc8bit `cat codesets.txt` + +gen_wctype: gen_wctype.c + $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) -D__UCLIBC_GEN_LOCALE $^ -o $@ + +# Warning! Beware tr_TR toupper/tolower exceptions! +wctables.h: gen_wctype + ./gen_wctype en_US + +gen_locale: gen_locale.c c8tables.h + $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) gen_locale.c -o $@ + +locale_tables.h: gen_locale locales.txt + ./gen_locale locales.txt + +lt_defines.h: locale_tables.h locale_collate.h + grep "^#define" locale_tables.h > lt_defines.h + grep "^#define __lc" locale_collate.h >> lt_defines.h + +gen_collate: gen_collate.c + $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) gen_collate.c -o $@ + +locale_collate.h: gen_collate locale_tables.h + grep COL_IDX_ locale_tables.h | sed -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | xargs ./gen_collate + +locales.txt: + @if [ ! -f locales.txt ] ; then \ + set -e; \ + echo " "; \ + echo "You do not have a locales.txt file in the extra/locale "; \ + echo "directory, Please copy the LOCALES file to locales.txt by "; \ + echo "running something like: "; \ + echo " cp $(EXTRA_LOCALE_DIR)/LOCALES \\ "; \ + echo " $(EXTRA_LOCALE_DIR)/locales.txt "; \ + echo "then edit locales.txt to disable/enable the locales you wish "; \ + echo "to support. "; \ + echo " "; \ + false; \ + fi; + +gen_ldc: gen_ldc.c c8tables.h wctables.h locale_tables.h locale_collate.h + $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $(CFLAGS_mmap) gen_ldc.c -o $@ + +locale_data.c: gen_ldc + ./gen_ldc + +uClibc_locale_data.h: c8tables.h wctables.h lt_defines.h locale_mmap.h + grep -v "define __LC" lt_defines.h > uClibc_locale_data.h + cat c8tables.h wctables.h locale_mmap.h >> uClibc_locale_data.h + +links-target: locale_data.c uClibc_locale_data.h + cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h + +pregen: + cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h + +clean: + $(RM) *.[oa] *~ core + $(RM) gen_wc8bit gen_wctype gen_locale gen_ldc gen_collate + $(RM) c8tables.h wctables.h locale_tables.h lt_defines.h locale_collate.h + $(RM) gen_mmap locale.mmap lmmtolso + $(RM) locale_data.c uClibc_locale_data.h + +.PHONY: pregen links-target diff --git a/extra/locale/README b/extra/locale/README new file mode 100644 index 0000000..244b925 --- /dev/null +++ b/extra/locale/README @@ -0,0 +1,71 @@ +Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! +Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! + +The programs in this directory are strictly cut-and-paste hack jobs to +extract the data I needed from glibc's locale database. I'm ashamed to +even let them into the light of day, and I consider them complete garbage. + +However, they are currently necessary to build the data needed for the +locale support I've implemented, so I'm forced to include them here. + +NOTE: While its possible to use this stuff for native != target arch, +you'll have to either write a converter to account for endianess and +struct padding issues, or run the mmap file generator on your target +arch. But all these programs will be rewritten at some point. + +All that being said, LC_CTYPE support has been added and supports the +ctype.h and wctype.h function. Also, LC_TIME, LC_MONETARY, LC_NUMERIC, +and LC_MESSAGES are supported wrt SUSv3. localeconv() works in both +real and stub locale modes. nl_langinfo() currently only works with +real locales enabled. That will be fixed though. wc->mb unsupported +char replacement and basic translit support is on the way as well. +Finally, some basic 8-bit codeset LC_COLLATE support should be in place +in the next week or two (similar to what was in the previous locale +implementation). + +Also, as one can probably guess, I'm working towards having the locale +data accessed via a shared mmap. That will allow non-mmu platforms +to use this without the current bloat. + +Currently, the output of size for my locale_data.o file is + text data bss dec hex filename + 59072 4 0 59076 e6c4 extra/locale/locale_data.o +which is for the C locale (automatic of course) + all codesets in +charmaps/ and all 268 locales in LOCALES. I estimate that the +translit support for those 8-bit codesets will add another 7-10k. + +One difference of note is that the special case upper/lower mappings +in the turkish locale are currently not implemented. That will be +fixed. + +Manuel + +Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! +Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! Warning!!! + + +1) In the toplevel dir, 'make headers'. + +2) Create a codesets.txt file in this dir listing the codesets you want + to support. The easiest way to do this is to edit the output of + 'find ./charmaps -name "*.pairs" > codesets.txt'. + NOTE: UTF-8 support is always included if you build with wide chars enabled. + NOTE: The files in charmaps/ were created from glibc's charmap files + with the awk script at the end of this file. You can add others + but only single byte codesets are supported. + +3) Create a locales.txt file to select the locales you want to support. + You can copy and edit the LOCALES file for example. Other locales could + added provided you've included the appropriate codesets in step 2. + NOTE: You have to have the approprite locales available for glibc! + +4) Run make here. + +5) Continue building uClibc from the toplevel dir. + + + + +Script used to generate the charmaps/*.pairs files: + +cat $1 | awk 'BEGIN { i = 0 } ; { if ($1 == "CHARMAP") i=1 ; else if ($1 == "END") i=0 ; else if (i==1) { sub("/","0",$2) ; sub("","",$1) ; print "{", $2, ",", $1, "}," } }' diff --git a/extra/locale/charmaps/ARMSCII-8.pairs b/extra/locale/charmaps/ARMSCII-8.pairs new file mode 100644 index 0000000..6a0f441 --- /dev/null +++ b/extra/locale/charmaps/ARMSCII-8.pairs @@ -0,0 +1,254 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa2 , 0x0587 }, +{ 0xa3 , 0x0589 }, +{ 0xa4 , 0x0029 }, +{ 0xa5 , 0x0028 }, +{ 0xa6 , 0x00BB }, +{ 0xa7 , 0x00AB }, +{ 0xa8 , 0x2014 }, +{ 0xa9 , 0x002E }, +{ 0xaa , 0x055D }, +{ 0xab , 0x002C }, +{ 0xac , 0x002D }, +{ 0xad , 0x058A }, +{ 0xae , 0x2026 }, +{ 0xaf , 0x055C }, +{ 0xb0 , 0x055B }, +{ 0xb1 , 0x055E }, +{ 0xb2 , 0x0531 }, +{ 0xb3 , 0x0561 }, +{ 0xb4 , 0x0532 }, +{ 0xb5 , 0x0562 }, +{ 0xb6 , 0x0533 }, +{ 0xb7 , 0x0563 }, +{ 0xb8 , 0x0534 }, +{ 0xb9 , 0x0564 }, +{ 0xba , 0x0535 }, +{ 0xbb , 0x0565 }, +{ 0xbc , 0x0536 }, +{ 0xbd , 0x0566 }, +{ 0xbe , 0x0537 }, +{ 0xbf , 0x0567 }, +{ 0xc0 , 0x0538 }, +{ 0xc1 , 0x0568 }, +{ 0xc2 , 0x0539 }, +{ 0xc3 , 0x0569 }, +{ 0xc4 , 0x053A }, +{ 0xc5 , 0x056A }, +{ 0xc6 , 0x053B }, +{ 0xc7 , 0x056B }, +{ 0xc8 , 0x053C }, +{ 0xc9 , 0x056C }, +{ 0xca , 0x053D }, +{ 0xcb , 0x056D }, +{ 0xcc , 0x053E }, +{ 0xcd , 0x056E }, +{ 0xce , 0x053F }, +{ 0xcf , 0x056F }, +{ 0xd0 , 0x0540 }, +{ 0xd1 , 0x0570 }, +{ 0xd2 , 0x0541 }, +{ 0xd3 , 0x0571 }, +{ 0xd4 , 0x0542 }, +{ 0xd5 , 0x0572 }, +{ 0xd6 , 0x0543 }, +{ 0xd7 , 0x0573 }, +{ 0xd8 , 0x0544 }, +{ 0xd9 , 0x0574 }, +{ 0xda , 0x0545 }, +{ 0xdb , 0x0575 }, +{ 0xdc , 0x0546 }, +{ 0xdd , 0x0576 }, +{ 0xde , 0x0547 }, +{ 0xdf , 0x0577 }, +{ 0xe0 , 0x0548 }, +{ 0xe1 , 0x0578 }, +{ 0xe2 , 0x0549 }, +{ 0xe3 , 0x0579 }, +{ 0xe4 , 0x054A }, +{ 0xe5 , 0x057A }, +{ 0xe6 , 0x054B }, +{ 0xe7 , 0x057B }, +{ 0xe8 , 0x054C }, +{ 0xe9 , 0x057C }, +{ 0xea , 0x054D }, +{ 0xeb , 0x057D }, +{ 0xec , 0x054E }, +{ 0xed , 0x057E }, +{ 0xee , 0x054F }, +{ 0xef , 0x057F }, +{ 0xf0 , 0x0550 }, +{ 0xf1 , 0x0580 }, +{ 0xf2 , 0x0551 }, +{ 0xf3 , 0x0581 }, +{ 0xf4 , 0x0552 }, +{ 0xf5 , 0x0582 }, +{ 0xf6 , 0x0553 }, +{ 0xf7 , 0x0583 }, +{ 0xf8 , 0x0554 }, +{ 0xf9 , 0x0584 }, +{ 0xfa , 0x0555 }, +{ 0xfb , 0x0585 }, +{ 0xfc , 0x0556 }, +{ 0xfd , 0x0586 }, +{ 0xfe , 0x055A }, diff --git a/extra/locale/charmaps/ASCII.pairs b/extra/locale/charmaps/ASCII.pairs new file mode 100644 index 0000000..038314d --- /dev/null +++ b/extra/locale/charmaps/ASCII.pairs @@ -0,0 +1,128 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, diff --git a/extra/locale/charmaps/CP1251.pairs b/extra/locale/charmaps/CP1251.pairs new file mode 100644 index 0000000..a5a80d6 --- /dev/null +++ b/extra/locale/charmaps/CP1251.pairs @@ -0,0 +1,255 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0402 }, +{ 0x81 , 0x0403 }, +{ 0x82 , 0x201A }, +{ 0x83 , 0x0453 }, +{ 0x84 , 0x201E }, +{ 0x85 , 0x2026 }, +{ 0x86 , 0x2020 }, +{ 0x87 , 0x2021 }, +{ 0x88 , 0x20AC }, +{ 0x89 , 0x2030 }, +{ 0x8a , 0x0409 }, +{ 0x8b , 0x2039 }, +{ 0x8c , 0x040A }, +{ 0x8d , 0x040C }, +{ 0x8e , 0x040B }, +{ 0x8f , 0x040F }, +{ 0x90 , 0x0452 }, +{ 0x91 , 0x2018 }, +{ 0x92 , 0x2019 }, +{ 0x93 , 0x201C }, +{ 0x94 , 0x201D }, +{ 0x95 , 0x2022 }, +{ 0x96 , 0x2013 }, +{ 0x97 , 0x2014 }, +{ 0x99 , 0x2122 }, +{ 0x9a , 0x0459 }, +{ 0x9b , 0x203A }, +{ 0x9c , 0x045A }, +{ 0x9d , 0x045C }, +{ 0x9e , 0x045B }, +{ 0x9f , 0x045F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x040E }, +{ 0xa2 , 0x045E }, +{ 0xa3 , 0x0408 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x0490 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x0401 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x0404 }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x0407 }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x0406 }, +{ 0xb3 , 0x0456 }, +{ 0xb4 , 0x0491 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x0451 }, +{ 0xb9 , 0x2116 }, +{ 0xba , 0x0454 }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x0458 }, +{ 0xbd , 0x0405 }, +{ 0xbe , 0x0455 }, +{ 0xbf , 0x0457 }, +{ 0xc0 , 0x0410 }, +{ 0xc1 , 0x0411 }, +{ 0xc2 , 0x0412 }, +{ 0xc3 , 0x0413 }, +{ 0xc4 , 0x0414 }, +{ 0xc5 , 0x0415 }, +{ 0xc6 , 0x0416 }, +{ 0xc7 , 0x0417 }, +{ 0xc8 , 0x0418 }, +{ 0xc9 , 0x0419 }, +{ 0xca , 0x041A }, +{ 0xcb , 0x041B }, +{ 0xcc , 0x041C }, +{ 0xcd , 0x041D }, +{ 0xce , 0x041E }, +{ 0xcf , 0x041F }, +{ 0xd0 , 0x0420 }, +{ 0xd1 , 0x0421 }, +{ 0xd2 , 0x0422 }, +{ 0xd3 , 0x0423 }, +{ 0xd4 , 0x0424 }, +{ 0xd5 , 0x0425 }, +{ 0xd6 , 0x0426 }, +{ 0xd7 , 0x0427 }, +{ 0xd8 , 0x0428 }, +{ 0xd9 , 0x0429 }, +{ 0xda , 0x042A }, +{ 0xdb , 0x042B }, +{ 0xdc , 0x042C }, +{ 0xdd , 0x042D }, +{ 0xde , 0x042E }, +{ 0xdf , 0x042F }, +{ 0xe0 , 0x0430 }, +{ 0xe1 , 0x0431 }, +{ 0xe2 , 0x0432 }, +{ 0xe3 , 0x0433 }, +{ 0xe4 , 0x0434 }, +{ 0xe5 , 0x0435 }, +{ 0xe6 , 0x0436 }, +{ 0xe7 , 0x0437 }, +{ 0xe8 , 0x0438 }, +{ 0xe9 , 0x0439 }, +{ 0xea , 0x043A }, +{ 0xeb , 0x043B }, +{ 0xec , 0x043C }, +{ 0xed , 0x043D }, +{ 0xee , 0x043E }, +{ 0xef , 0x043F }, +{ 0xf0 , 0x0440 }, +{ 0xf1 , 0x0441 }, +{ 0xf2 , 0x0442 }, +{ 0xf3 , 0x0443 }, +{ 0xf4 , 0x0444 }, +{ 0xf5 , 0x0445 }, +{ 0xf6 , 0x0446 }, +{ 0xf7 , 0x0447 }, +{ 0xf8 , 0x0448 }, +{ 0xf9 , 0x0449 }, +{ 0xfa , 0x044A }, +{ 0xfb , 0x044B }, +{ 0xfc , 0x044C }, +{ 0xfd , 0x044D }, +{ 0xfe , 0x044E }, +{ 0xff , 0x044F }, diff --git a/extra/locale/charmaps/CP1255.pairs b/extra/locale/charmaps/CP1255.pairs new file mode 100644 index 0000000..123bb5a --- /dev/null +++ b/extra/locale/charmaps/CP1255.pairs @@ -0,0 +1,233 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x20AC }, +{ 0x82 , 0x201A }, +{ 0x83 , 0x0192 }, +{ 0x84 , 0x201E }, +{ 0x85 , 0x2026 }, +{ 0x86 , 0x2020 }, +{ 0x87 , 0x2021 }, +{ 0x88 , 0x02C6 }, +{ 0x89 , 0x2030 }, +{ 0x8b , 0x2039 }, +{ 0x91 , 0x2018 }, +{ 0x92 , 0x2019 }, +{ 0x93 , 0x201C }, +{ 0x94 , 0x201D }, +{ 0x95 , 0x2022 }, +{ 0x96 , 0x2013 }, +{ 0x97 , 0x2014 }, +{ 0x98 , 0x02DC }, +{ 0x99 , 0x2122 }, +{ 0x9b , 0x203A }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x00A1 }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x20AA }, +{ 0xa5 , 0x00A5 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x00D7 }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x00F7 }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x00BC }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x00BE }, +{ 0xbf , 0x00BF }, +{ 0xc0 , 0x05B0 }, +{ 0xc1 , 0x05B1 }, +{ 0xc2 , 0x05B2 }, +{ 0xc3 , 0x05B3 }, +{ 0xc4 , 0x05B4 }, +{ 0xc5 , 0x05B5 }, +{ 0xc6 , 0x05B6 }, +{ 0xc7 , 0x05B7 }, +{ 0xc8 , 0x05B8 }, +{ 0xc9 , 0x05B9 }, +{ 0xcb , 0x05BB }, +{ 0xcc , 0x05BC }, +{ 0xcd , 0x05BD }, +{ 0xce , 0x05BE }, +{ 0xcf , 0x05BF }, +{ 0xd0 , 0x05C0 }, +{ 0xd1 , 0x05C1 }, +{ 0xd2 , 0x05C2 }, +{ 0xd3 , 0x05C3 }, +{ 0xd4 , 0x05F0 }, +{ 0xd5 , 0x05F1 }, +{ 0xd6 , 0x05F2 }, +{ 0xd7 , 0x05F3 }, +{ 0xd8 , 0x05F4 }, +{ 0xe0 , 0x05D0 }, +{ 0xe1 , 0x05D1 }, +{ 0xe2 , 0x05D2 }, +{ 0xe3 , 0x05D3 }, +{ 0xe4 , 0x05D4 }, +{ 0xe5 , 0x05D5 }, +{ 0xe6 , 0x05D6 }, +{ 0xe7 , 0x05D7 }, +{ 0xe8 , 0x05D8 }, +{ 0xe9 , 0x05D9 }, +{ 0xea , 0x05DA }, +{ 0xeb , 0x05DB }, +{ 0xec , 0x05DC }, +{ 0xed , 0x05DD }, +{ 0xee , 0x05DE }, +{ 0xef , 0x05DF }, +{ 0xf0 , 0x05E0 }, +{ 0xf1 , 0x05E1 }, +{ 0xf2 , 0x05E2 }, +{ 0xf3 , 0x05E3 }, +{ 0xf4 , 0x05E4 }, +{ 0xf5 , 0x05E5 }, +{ 0xf6 , 0x05E6 }, +{ 0xf7 , 0x05E7 }, +{ 0xf8 , 0x05E8 }, +{ 0xf9 , 0x05E9 }, +{ 0xfa , 0x05EA }, +{ 0xfd , 0x200E }, +{ 0xfe , 0x200F }, diff --git a/extra/locale/charmaps/GEORGIAN-PS.pairs b/extra/locale/charmaps/GEORGIAN-PS.pairs new file mode 100644 index 0000000..815b2e6 --- /dev/null +++ b/extra/locale/charmaps/GEORGIAN-PS.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x201A }, +{ 0x83 , 0x0192 }, +{ 0x84 , 0x201E }, +{ 0x85 , 0x2026 }, +{ 0x86 , 0x2020 }, +{ 0x87 , 0x2021 }, +{ 0x88 , 0x02C6 }, +{ 0x89 , 0x2030 }, +{ 0x8a , 0x0160 }, +{ 0x8b , 0x2039 }, +{ 0x8c , 0x0152 }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x2018 }, +{ 0x92 , 0x2019 }, +{ 0x93 , 0x201C }, +{ 0x94 , 0x201D }, +{ 0x95 , 0x2022 }, +{ 0x96 , 0x2013 }, +{ 0x97 , 0x2014 }, +{ 0x98 , 0x02DC }, +{ 0x99 , 0x2122 }, +{ 0x9a , 0x0161 }, +{ 0x9b , 0x203A }, +{ 0x9c , 0x0153 }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x0178 }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x00A1 }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x00A5 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x00AA }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x00BA }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x00BC }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x00BE }, +{ 0xbf , 0x00BF }, +{ 0xc0 , 0x10D0 }, +{ 0xc1 , 0x10D1 }, +{ 0xc2 , 0x10D2 }, +{ 0xc3 , 0x10D3 }, +{ 0xc4 , 0x10D4 }, +{ 0xc5 , 0x10D5 }, +{ 0xc6 , 0x10D6 }, +{ 0xc7 , 0x10F1 }, +{ 0xc8 , 0x10D7 }, +{ 0xc9 , 0x10D8 }, +{ 0xca , 0x10D9 }, +{ 0xcb , 0x10DA }, +{ 0xcc , 0x10DB }, +{ 0xcd , 0x10DC }, +{ 0xce , 0x10F2 }, +{ 0xcf , 0x10DD }, +{ 0xd0 , 0x10DE }, +{ 0xd1 , 0x10DF }, +{ 0xd2 , 0x10E0 }, +{ 0xd3 , 0x10E1 }, +{ 0xd4 , 0x10E2 }, +{ 0xd5 , 0x10F3 }, +{ 0xd6 , 0x10E3 }, +{ 0xd7 , 0x10E4 }, +{ 0xd8 , 0x10E5 }, +{ 0xd9 , 0x10E6 }, +{ 0xda , 0x10E7 }, +{ 0xdb , 0x10E8 }, +{ 0xdc , 0x10E9 }, +{ 0xdd , 0x10EA }, +{ 0xde , 0x10EB }, +{ 0xdf , 0x10EC }, +{ 0xe0 , 0x10ED }, +{ 0xe1 , 0x10EE }, +{ 0xe2 , 0x10F4 }, +{ 0xe3 , 0x10EF }, +{ 0xe4 , 0x10F0 }, +{ 0xe5 , 0x10F5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x00F0 }, +{ 0xf1 , 0x00F1 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x00FD }, +{ 0xfe , 0x00FE }, +{ 0xff , 0x00FF }, diff --git a/extra/locale/charmaps/ISO-8859-1.pairs b/extra/locale/charmaps/ISO-8859-1.pairs new file mode 100644 index 0000000..97812a0 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-1.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x00A1 }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x00A5 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x00AA }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x00BA }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x00BC }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x00BE }, +{ 0xbf , 0x00BF }, +{ 0xc0 , 0x00C0 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x00C3 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x00C8 }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x00CA }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x00CC }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd0 , 0x00D0 }, +{ 0xd1 , 0x00D1 }, +{ 0xd2 , 0x00D2 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x00D8 }, +{ 0xd9 , 0x00D9 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x00DD }, +{ 0xde , 0x00DE }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x00E0 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x00E3 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x00F0 }, +{ 0xf1 , 0x00F1 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x00FD }, +{ 0xfe , 0x00FE }, +{ 0xff , 0x00FF }, diff --git a/extra/locale/charmaps/ISO-8859-10.pairs b/extra/locale/charmaps/ISO-8859-10.pairs new file mode 100644 index 0000000..a39892f --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-10.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x0104 }, +{ 0xa2 , 0x0112 }, +{ 0xa3 , 0x0122 }, +{ 0xa4 , 0x012A }, +{ 0xa5 , 0x0128 }, +{ 0xa6 , 0x0136 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x013B }, +{ 0xa9 , 0x0110 }, +{ 0xaa , 0x0160 }, +{ 0xab , 0x0166 }, +{ 0xac , 0x017D }, +{ 0xad , 0x00AD }, +{ 0xae , 0x016A }, +{ 0xaf , 0x014A }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x0105 }, +{ 0xb2 , 0x0113 }, +{ 0xb3 , 0x0123 }, +{ 0xb4 , 0x012B }, +{ 0xb5 , 0x0129 }, +{ 0xb6 , 0x0137 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x013C }, +{ 0xb9 , 0x0111 }, +{ 0xba , 0x0161 }, +{ 0xbb , 0x0167 }, +{ 0xbc , 0x017E }, +{ 0xbd , 0x2015 }, +{ 0xbe , 0x016B }, +{ 0xbf , 0x014B }, +{ 0xc0 , 0x0100 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x00C3 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x012E }, +{ 0xc8 , 0x010C }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x0118 }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x0116 }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd0 , 0x00D0 }, +{ 0xd1 , 0x0145 }, +{ 0xd2 , 0x014C }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x0168 }, +{ 0xd8 , 0x00D8 }, +{ 0xd9 , 0x0172 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x00DD }, +{ 0xde , 0x00DE }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x0101 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x00E3 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x012F }, +{ 0xe8 , 0x010D }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x0119 }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x0117 }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x00F0 }, +{ 0xf1 , 0x0146 }, +{ 0xf2 , 0x014D }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x0169 }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x0173 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x00FD }, +{ 0xfe , 0x00FE }, +{ 0xff , 0x0138 }, diff --git a/extra/locale/charmaps/ISO-8859-13.pairs b/extra/locale/charmaps/ISO-8859-13.pairs new file mode 100644 index 0000000..ff95fb4 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-13.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x201D }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x201E }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00D8 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x0156 }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00C6 }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x201C }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00F8 }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x0157 }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x00BC }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x00BE }, +{ 0xbf , 0x00E6 }, +{ 0xc0 , 0x0104 }, +{ 0xc1 , 0x012E }, +{ 0xc2 , 0x0100 }, +{ 0xc3 , 0x0106 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x0118 }, +{ 0xc7 , 0x0112 }, +{ 0xc8 , 0x010C }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x0179 }, +{ 0xcb , 0x0116 }, +{ 0xcc , 0x0122 }, +{ 0xcd , 0x0136 }, +{ 0xce , 0x012A }, +{ 0xcf , 0x013B }, +{ 0xd0 , 0x0160 }, +{ 0xd1 , 0x0143 }, +{ 0xd2 , 0x0145 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x014C }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x0172 }, +{ 0xd9 , 0x0141 }, +{ 0xda , 0x015A }, +{ 0xdb , 0x016A }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x017B }, +{ 0xde , 0x017D }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x0105 }, +{ 0xe1 , 0x012F }, +{ 0xe2 , 0x0101 }, +{ 0xe3 , 0x0107 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x0119 }, +{ 0xe7 , 0x0113 }, +{ 0xe8 , 0x010D }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x017A }, +{ 0xeb , 0x0117 }, +{ 0xec , 0x0123 }, +{ 0xed , 0x0137 }, +{ 0xee , 0x012B }, +{ 0xef , 0x013C }, +{ 0xf0 , 0x0161 }, +{ 0xf1 , 0x0144 }, +{ 0xf2 , 0x0146 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x014D }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x0173 }, +{ 0xf9 , 0x0142 }, +{ 0xfa , 0x015B }, +{ 0xfb , 0x016B }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x017C }, +{ 0xfe , 0x017E }, +{ 0xff , 0x2019 }, diff --git a/extra/locale/charmaps/ISO-8859-14.pairs b/extra/locale/charmaps/ISO-8859-14.pairs new file mode 100644 index 0000000..8a8f06e --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-14.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x1E02 }, +{ 0xa2 , 0x1E03 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x010A }, +{ 0xa5 , 0x010B }, +{ 0xa6 , 0x1E0A }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x1E80 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x1E82 }, +{ 0xab , 0x1E0B }, +{ 0xac , 0x1EF2 }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x0178 }, +{ 0xb0 , 0x1E1E }, +{ 0xb1 , 0x1E1F }, +{ 0xb2 , 0x0120 }, +{ 0xb3 , 0x0121 }, +{ 0xb4 , 0x1E40 }, +{ 0xb5 , 0x1E41 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x1E56 }, +{ 0xb8 , 0x1E81 }, +{ 0xb9 , 0x1E57 }, +{ 0xba , 0x1E83 }, +{ 0xbb , 0x1E60 }, +{ 0xbc , 0x1EF3 }, +{ 0xbd , 0x1E84 }, +{ 0xbe , 0x1E85 }, +{ 0xbf , 0x1E61 }, +{ 0xc0 , 0x00C0 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x00C3 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x00C8 }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x00CA }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x00CC }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd0 , 0x0174 }, +{ 0xd1 , 0x00D1 }, +{ 0xd2 , 0x00D2 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x1E6A }, +{ 0xd8 , 0x00D8 }, +{ 0xd9 , 0x00D9 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x00DD }, +{ 0xde , 0x0176 }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x00E0 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x00E3 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x0175 }, +{ 0xf1 , 0x00F1 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x1E6B }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x00FD }, +{ 0xfe , 0x0177 }, +{ 0xff , 0x00FF }, diff --git a/extra/locale/charmaps/ISO-8859-15.pairs b/extra/locale/charmaps/ISO-8859-15.pairs new file mode 100644 index 0000000..ca50e22 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-15.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x00A1 }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x20AC }, +{ 0xa5 , 0x00A5 }, +{ 0xa6 , 0x0160 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x0161 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x00AA }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x017D }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x017E }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x00BA }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x0152 }, +{ 0xbd , 0x0153 }, +{ 0xbe , 0x0178 }, +{ 0xbf , 0x00BF }, +{ 0xc0 , 0x00C0 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x00C3 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x00C8 }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x00CA }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x00CC }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd0 , 0x00D0 }, +{ 0xd1 , 0x00D1 }, +{ 0xd2 , 0x00D2 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x00D8 }, +{ 0xd9 , 0x00D9 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x00DD }, +{ 0xde , 0x00DE }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x00E0 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x00E3 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x00F0 }, +{ 0xf1 , 0x00F1 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x00FD }, +{ 0xfe , 0x00FE }, +{ 0xff , 0x00FF }, diff --git a/extra/locale/charmaps/ISO-8859-16.pairs b/extra/locale/charmaps/ISO-8859-16.pairs new file mode 100644 index 0000000..6b74963 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-16.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x0104 }, +{ 0xa2 , 0x0105 }, +{ 0xa3 , 0x0141 }, +{ 0xa4 , 0x20AC }, +{ 0xa5 , 0x00AB }, +{ 0xa6 , 0x0160 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x0161 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x0218 }, +{ 0xab , 0x201E }, +{ 0xac , 0x0179 }, +{ 0xad , 0x00AD }, +{ 0xae , 0x017A }, +{ 0xaf , 0x017B }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x010C }, +{ 0xb3 , 0x0142 }, +{ 0xb4 , 0x017D }, +{ 0xb5 , 0x201D }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x017E }, +{ 0xb9 , 0x010D }, +{ 0xba , 0x0219 }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x0152 }, +{ 0xbd , 0x0153 }, +{ 0xbe , 0x0178 }, +{ 0xbf , 0x017C }, +{ 0xc0 , 0x00C0 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x0102 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x0106 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x00C8 }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x00CA }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x00CC }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd0 , 0x0110 }, +{ 0xd1 , 0x0143 }, +{ 0xd2 , 0x00D2 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x0150 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x015A }, +{ 0xd8 , 0x0170 }, +{ 0xd9 , 0x00D9 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x0118 }, +{ 0xde , 0x021A }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x00E0 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x0103 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x0107 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x0111 }, +{ 0xf1 , 0x0144 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x0151 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x015B }, +{ 0xf8 , 0x0171 }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x0119 }, +{ 0xfe , 0x021B }, +{ 0xff , 0x00FF }, diff --git a/extra/locale/charmaps/ISO-8859-2.pairs b/extra/locale/charmaps/ISO-8859-2.pairs new file mode 100644 index 0000000..4e92f94 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-2.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x0104 }, +{ 0xa2 , 0x02D8 }, +{ 0xa3 , 0x0141 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x013D }, +{ 0xa6 , 0x015A }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x0160 }, +{ 0xaa , 0x015E }, +{ 0xab , 0x0164 }, +{ 0xac , 0x0179 }, +{ 0xad , 0x00AD }, +{ 0xae , 0x017D }, +{ 0xaf , 0x017B }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x0105 }, +{ 0xb2 , 0x02DB }, +{ 0xb3 , 0x0142 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x013E }, +{ 0xb6 , 0x015B }, +{ 0xb7 , 0x02C7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x0161 }, +{ 0xba , 0x015F }, +{ 0xbb , 0x0165 }, +{ 0xbc , 0x017A }, +{ 0xbd , 0x02DD }, +{ 0xbe , 0x017E }, +{ 0xbf , 0x017C }, +{ 0xc0 , 0x0154 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x0102 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x0139 }, +{ 0xc6 , 0x0106 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x010C }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x0118 }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x011A }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x010E }, +{ 0xd0 , 0x0110 }, +{ 0xd1 , 0x0143 }, +{ 0xd2 , 0x0147 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x0150 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x0158 }, +{ 0xd9 , 0x016E }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x0170 }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x00DD }, +{ 0xde , 0x0162 }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x0155 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x0103 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x013A }, +{ 0xe6 , 0x0107 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x010D }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x0119 }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x011B }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x010F }, +{ 0xf0 , 0x0111 }, +{ 0xf1 , 0x0144 }, +{ 0xf2 , 0x0148 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x0151 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x0159 }, +{ 0xf9 , 0x016F }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x0171 }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x00FD }, +{ 0xfe , 0x0163 }, +{ 0xff , 0x02D9 }, diff --git a/extra/locale/charmaps/ISO-8859-3.pairs b/extra/locale/charmaps/ISO-8859-3.pairs new file mode 100644 index 0000000..3a8814c --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-3.pairs @@ -0,0 +1,249 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x0126 }, +{ 0xa2 , 0x02D8 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x00A4 }, +{ 0xa6 , 0x0124 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x0130 }, +{ 0xaa , 0x015E }, +{ 0xab , 0x011E }, +{ 0xac , 0x0134 }, +{ 0xad , 0x00AD }, +{ 0xaf , 0x017B }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x0127 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x0125 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x0131 }, +{ 0xba , 0x015F }, +{ 0xbb , 0x011F }, +{ 0xbc , 0x0135 }, +{ 0xbd , 0x00BD }, +{ 0xbf , 0x017C }, +{ 0xc0 , 0x00C0 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x010A }, +{ 0xc6 , 0x0108 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x00C8 }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x00CA }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x00CC }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd1 , 0x00D1 }, +{ 0xd2 , 0x00D2 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x0120 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x011C }, +{ 0xd9 , 0x00D9 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x016C }, +{ 0xde , 0x015C }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x00E0 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x010B }, +{ 0xe6 , 0x0109 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf1 , 0x00F1 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x0121 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x011D }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x016D }, +{ 0xfe , 0x015D }, +{ 0xff , 0x02D9 }, diff --git a/extra/locale/charmaps/ISO-8859-4.pairs b/extra/locale/charmaps/ISO-8859-4.pairs new file mode 100644 index 0000000..dda865c --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-4.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x0104 }, +{ 0xa2 , 0x0138 }, +{ 0xa3 , 0x0156 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x0128 }, +{ 0xa6 , 0x013B }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x0160 }, +{ 0xaa , 0x0112 }, +{ 0xab , 0x0122 }, +{ 0xac , 0x0166 }, +{ 0xad , 0x00AD }, +{ 0xae , 0x017D }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x0105 }, +{ 0xb2 , 0x02DB }, +{ 0xb3 , 0x0157 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x0129 }, +{ 0xb6 , 0x013C }, +{ 0xb7 , 0x02C7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x0161 }, +{ 0xba , 0x0113 }, +{ 0xbb , 0x0123 }, +{ 0xbc , 0x0167 }, +{ 0xbd , 0x014A }, +{ 0xbe , 0x017E }, +{ 0xbf , 0x014B }, +{ 0xc0 , 0x0100 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x00C3 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x012E }, +{ 0xc8 , 0x010C }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x0118 }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x0116 }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x012A }, +{ 0xd0 , 0x0110 }, +{ 0xd1 , 0x0145 }, +{ 0xd2 , 0x014C }, +{ 0xd3 , 0x0136 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x00D8 }, +{ 0xd9 , 0x0172 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x0168 }, +{ 0xde , 0x016A }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x0101 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x00E3 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x012F }, +{ 0xe8 , 0x010D }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x0119 }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x0117 }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x012B }, +{ 0xf0 , 0x0111 }, +{ 0xf1 , 0x0146 }, +{ 0xf2 , 0x014D }, +{ 0xf3 , 0x0137 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x0173 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x0169 }, +{ 0xfe , 0x016B }, +{ 0xff , 0x02D9 }, diff --git a/extra/locale/charmaps/ISO-8859-5.pairs b/extra/locale/charmaps/ISO-8859-5.pairs new file mode 100644 index 0000000..08ebcae --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-5.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x0401 }, +{ 0xa2 , 0x0402 }, +{ 0xa3 , 0x0403 }, +{ 0xa4 , 0x0404 }, +{ 0xa5 , 0x0405 }, +{ 0xa6 , 0x0406 }, +{ 0xa7 , 0x0407 }, +{ 0xa8 , 0x0408 }, +{ 0xa9 , 0x0409 }, +{ 0xaa , 0x040A }, +{ 0xab , 0x040B }, +{ 0xac , 0x040C }, +{ 0xad , 0x00AD }, +{ 0xae , 0x040E }, +{ 0xaf , 0x040F }, +{ 0xb0 , 0x0410 }, +{ 0xb1 , 0x0411 }, +{ 0xb2 , 0x0412 }, +{ 0xb3 , 0x0413 }, +{ 0xb4 , 0x0414 }, +{ 0xb5 , 0x0415 }, +{ 0xb6 , 0x0416 }, +{ 0xb7 , 0x0417 }, +{ 0xb8 , 0x0418 }, +{ 0xb9 , 0x0419 }, +{ 0xba , 0x041A }, +{ 0xbb , 0x041B }, +{ 0xbc , 0x041C }, +{ 0xbd , 0x041D }, +{ 0xbe , 0x041E }, +{ 0xbf , 0x041F }, +{ 0xc0 , 0x0420 }, +{ 0xc1 , 0x0421 }, +{ 0xc2 , 0x0422 }, +{ 0xc3 , 0x0423 }, +{ 0xc4 , 0x0424 }, +{ 0xc5 , 0x0425 }, +{ 0xc6 , 0x0426 }, +{ 0xc7 , 0x0427 }, +{ 0xc8 , 0x0428 }, +{ 0xc9 , 0x0429 }, +{ 0xca , 0x042A }, +{ 0xcb , 0x042B }, +{ 0xcc , 0x042C }, +{ 0xcd , 0x042D }, +{ 0xce , 0x042E }, +{ 0xcf , 0x042F }, +{ 0xd0 , 0x0430 }, +{ 0xd1 , 0x0431 }, +{ 0xd2 , 0x0432 }, +{ 0xd3 , 0x0433 }, +{ 0xd4 , 0x0434 }, +{ 0xd5 , 0x0435 }, +{ 0xd6 , 0x0436 }, +{ 0xd7 , 0x0437 }, +{ 0xd8 , 0x0438 }, +{ 0xd9 , 0x0439 }, +{ 0xda , 0x043A }, +{ 0xdb , 0x043B }, +{ 0xdc , 0x043C }, +{ 0xdd , 0x043D }, +{ 0xde , 0x043E }, +{ 0xdf , 0x043F }, +{ 0xe0 , 0x0440 }, +{ 0xe1 , 0x0441 }, +{ 0xe2 , 0x0442 }, +{ 0xe3 , 0x0443 }, +{ 0xe4 , 0x0444 }, +{ 0xe5 , 0x0445 }, +{ 0xe6 , 0x0446 }, +{ 0xe7 , 0x0447 }, +{ 0xe8 , 0x0448 }, +{ 0xe9 , 0x0449 }, +{ 0xea , 0x044A }, +{ 0xeb , 0x044B }, +{ 0xec , 0x044C }, +{ 0xed , 0x044D }, +{ 0xee , 0x044E }, +{ 0xef , 0x044F }, +{ 0xf0 , 0x2116 }, +{ 0xf1 , 0x0451 }, +{ 0xf2 , 0x0452 }, +{ 0xf3 , 0x0453 }, +{ 0xf4 , 0x0454 }, +{ 0xf5 , 0x0455 }, +{ 0xf6 , 0x0456 }, +{ 0xf7 , 0x0457 }, +{ 0xf8 , 0x0458 }, +{ 0xf9 , 0x0459 }, +{ 0xfa , 0x045A }, +{ 0xfb , 0x045B }, +{ 0xfc , 0x045C }, +{ 0xfd , 0x00A7 }, +{ 0xfe , 0x045E }, +{ 0xff , 0x045F }, diff --git a/extra/locale/charmaps/ISO-8859-6.pairs b/extra/locale/charmaps/ISO-8859-6.pairs new file mode 100644 index 0000000..ccba9f9 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-6.pairs @@ -0,0 +1,211 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa4 , 0x00A4 }, +{ 0xac , 0x060C }, +{ 0xad , 0x00AD }, +{ 0xbb , 0x061B }, +{ 0xbf , 0x061F }, +{ 0xc1 , 0x0621 }, +{ 0xc2 , 0x0622 }, +{ 0xc3 , 0x0623 }, +{ 0xc4 , 0x0624 }, +{ 0xc5 , 0x0625 }, +{ 0xc6 , 0x0626 }, +{ 0xc7 , 0x0627 }, +{ 0xc8 , 0x0628 }, +{ 0xc9 , 0x0629 }, +{ 0xca , 0x062A }, +{ 0xcb , 0x062B }, +{ 0xcc , 0x062C }, +{ 0xcd , 0x062D }, +{ 0xce , 0x062E }, +{ 0xcf , 0x062F }, +{ 0xd0 , 0x0630 }, +{ 0xd1 , 0x0631 }, +{ 0xd2 , 0x0632 }, +{ 0xd3 , 0x0633 }, +{ 0xd4 , 0x0634 }, +{ 0xd5 , 0x0635 }, +{ 0xd6 , 0x0636 }, +{ 0xd7 , 0x0637 }, +{ 0xd8 , 0x0638 }, +{ 0xd9 , 0x0639 }, +{ 0xda , 0x063A }, +{ 0xe0 , 0x0640 }, +{ 0xe1 , 0x0641 }, +{ 0xe2 , 0x0642 }, +{ 0xe3 , 0x0643 }, +{ 0xe4 , 0x0644 }, +{ 0xe5 , 0x0645 }, +{ 0xe6 , 0x0646 }, +{ 0xe7 , 0x0647 }, +{ 0xe8 , 0x0648 }, +{ 0xe9 , 0x0649 }, +{ 0xea , 0x064A }, +{ 0xeb , 0x064B }, +{ 0xec , 0x064C }, +{ 0xed , 0x064D }, +{ 0xee , 0x064E }, +{ 0xef , 0x064F }, +{ 0xf0 , 0x0650 }, +{ 0xf1 , 0x0651 }, +{ 0xf2 , 0x0652 }, diff --git a/extra/locale/charmaps/ISO-8859-7.pairs b/extra/locale/charmaps/ISO-8859-7.pairs new file mode 100644 index 0000000..36b8ba2 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-7.pairs @@ -0,0 +1,250 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x2018 }, +{ 0xa2 , 0x2019 }, +{ 0xa3 , 0x00A3 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x00A9 }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xaf , 0x2015 }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x0384 }, +{ 0xb5 , 0x0385 }, +{ 0xb6 , 0x0386 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x0388 }, +{ 0xb9 , 0x0389 }, +{ 0xba , 0x038A }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x038C }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x038E }, +{ 0xbf , 0x038F }, +{ 0xc0 , 0x0390 }, +{ 0xc1 , 0x0391 }, +{ 0xc2 , 0x0392 }, +{ 0xc3 , 0x0393 }, +{ 0xc4 , 0x0394 }, +{ 0xc5 , 0x0395 }, +{ 0xc6 , 0x0396 }, +{ 0xc7 , 0x0397 }, +{ 0xc8 , 0x0398 }, +{ 0xc9 , 0x0399 }, +{ 0xca , 0x039A }, +{ 0xcb , 0x039B }, +{ 0xcc , 0x039C }, +{ 0xcd , 0x039D }, +{ 0xce , 0x039E }, +{ 0xcf , 0x039F }, +{ 0xd0 , 0x03A0 }, +{ 0xd1 , 0x03A1 }, +{ 0xd3 , 0x03A3 }, +{ 0xd4 , 0x03A4 }, +{ 0xd5 , 0x03A5 }, +{ 0xd6 , 0x03A6 }, +{ 0xd7 , 0x03A7 }, +{ 0xd8 , 0x03A8 }, +{ 0xd9 , 0x03A9 }, +{ 0xda , 0x03AA }, +{ 0xdb , 0x03AB }, +{ 0xdc , 0x03AC }, +{ 0xdd , 0x03AD }, +{ 0xde , 0x03AE }, +{ 0xdf , 0x03AF }, +{ 0xe0 , 0x03B0 }, +{ 0xe1 , 0x03B1 }, +{ 0xe2 , 0x03B2 }, +{ 0xe3 , 0x03B3 }, +{ 0xe4 , 0x03B4 }, +{ 0xe5 , 0x03B5 }, +{ 0xe6 , 0x03B6 }, +{ 0xe7 , 0x03B7 }, +{ 0xe8 , 0x03B8 }, +{ 0xe9 , 0x03B9 }, +{ 0xea , 0x03BA }, +{ 0xeb , 0x03BB }, +{ 0xec , 0x03BC }, +{ 0xed , 0x03BD }, +{ 0xee , 0x03BE }, +{ 0xef , 0x03BF }, +{ 0xf0 , 0x03C0 }, +{ 0xf1 , 0x03C1 }, +{ 0xf2 , 0x03C2 }, +{ 0xf3 , 0x03C3 }, +{ 0xf4 , 0x03C4 }, +{ 0xf5 , 0x03C5 }, +{ 0xf6 , 0x03C6 }, +{ 0xf7 , 0x03C7 }, +{ 0xf8 , 0x03C8 }, +{ 0xf9 , 0x03C9 }, +{ 0xfa , 0x03CA }, +{ 0xfb , 0x03CB }, +{ 0xfc , 0x03CC }, +{ 0xfd , 0x03CD }, +{ 0xfe , 0x03CE }, diff --git a/extra/locale/charmaps/ISO-8859-8.pairs b/extra/locale/charmaps/ISO-8859-8.pairs new file mode 100644 index 0000000..8d32dd8 --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-8.pairs @@ -0,0 +1,220 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x00A5 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x00D7 }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x00F7 }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x00BC }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x00BE }, +{ 0xdf , 0x2017 }, +{ 0xe0 , 0x05D0 }, +{ 0xe1 , 0x05D1 }, +{ 0xe2 , 0x05D2 }, +{ 0xe3 , 0x05D3 }, +{ 0xe4 , 0x05D4 }, +{ 0xe5 , 0x05D5 }, +{ 0xe6 , 0x05D6 }, +{ 0xe7 , 0x05D7 }, +{ 0xe8 , 0x05D8 }, +{ 0xe9 , 0x05D9 }, +{ 0xea , 0x05DA }, +{ 0xeb , 0x05DB }, +{ 0xec , 0x05DC }, +{ 0xed , 0x05DD }, +{ 0xee , 0x05DE }, +{ 0xef , 0x05DF }, +{ 0xf0 , 0x05E0 }, +{ 0xf1 , 0x05E1 }, +{ 0xf2 , 0x05E2 }, +{ 0xf3 , 0x05E3 }, +{ 0xf4 , 0x05E4 }, +{ 0xf5 , 0x05E5 }, +{ 0xf6 , 0x05E6 }, +{ 0xf7 , 0x05E7 }, +{ 0xf8 , 0x05E8 }, +{ 0xf9 , 0x05E9 }, +{ 0xfa , 0x05EA }, +{ 0xfd , 0x200E }, +{ 0xfe , 0x200F }, diff --git a/extra/locale/charmaps/ISO-8859-9.pairs b/extra/locale/charmaps/ISO-8859-9.pairs new file mode 100644 index 0000000..a5748cd --- /dev/null +++ b/extra/locale/charmaps/ISO-8859-9.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x0080 }, +{ 0x81 , 0x0081 }, +{ 0x82 , 0x0082 }, +{ 0x83 , 0x0083 }, +{ 0x84 , 0x0084 }, +{ 0x85 , 0x0085 }, +{ 0x86 , 0x0086 }, +{ 0x87 , 0x0087 }, +{ 0x88 , 0x0088 }, +{ 0x89 , 0x0089 }, +{ 0x8a , 0x008A }, +{ 0x8b , 0x008B }, +{ 0x8c , 0x008C }, +{ 0x8d , 0x008D }, +{ 0x8e , 0x008E }, +{ 0x8f , 0x008F }, +{ 0x90 , 0x0090 }, +{ 0x91 , 0x0091 }, +{ 0x92 , 0x0092 }, +{ 0x93 , 0x0093 }, +{ 0x94 , 0x0094 }, +{ 0x95 , 0x0095 }, +{ 0x96 , 0x0096 }, +{ 0x97 , 0x0097 }, +{ 0x98 , 0x0098 }, +{ 0x99 , 0x0099 }, +{ 0x9a , 0x009A }, +{ 0x9b , 0x009B }, +{ 0x9c , 0x009C }, +{ 0x9d , 0x009D }, +{ 0x9e , 0x009E }, +{ 0x9f , 0x009F }, +{ 0xa0 , 0x00A0 }, +{ 0xa1 , 0x00A1 }, +{ 0xa2 , 0x00A2 }, +{ 0xa3 , 0x00A3 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x00A5 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xa8 , 0x00A8 }, +{ 0xa9 , 0x00A9 }, +{ 0xaa , 0x00AA }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xaf , 0x00AF }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x00B3 }, +{ 0xb4 , 0x00B4 }, +{ 0xb5 , 0x00B5 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb8 , 0x00B8 }, +{ 0xb9 , 0x00B9 }, +{ 0xba , 0x00BA }, +{ 0xbb , 0x00BB }, +{ 0xbc , 0x00BC }, +{ 0xbd , 0x00BD }, +{ 0xbe , 0x00BE }, +{ 0xbf , 0x00BF }, +{ 0xc0 , 0x00C0 }, +{ 0xc1 , 0x00C1 }, +{ 0xc2 , 0x00C2 }, +{ 0xc3 , 0x00C3 }, +{ 0xc4 , 0x00C4 }, +{ 0xc5 , 0x00C5 }, +{ 0xc6 , 0x00C6 }, +{ 0xc7 , 0x00C7 }, +{ 0xc8 , 0x00C8 }, +{ 0xc9 , 0x00C9 }, +{ 0xca , 0x00CA }, +{ 0xcb , 0x00CB }, +{ 0xcc , 0x00CC }, +{ 0xcd , 0x00CD }, +{ 0xce , 0x00CE }, +{ 0xcf , 0x00CF }, +{ 0xd0 , 0x011E }, +{ 0xd1 , 0x00D1 }, +{ 0xd2 , 0x00D2 }, +{ 0xd3 , 0x00D3 }, +{ 0xd4 , 0x00D4 }, +{ 0xd5 , 0x00D5 }, +{ 0xd6 , 0x00D6 }, +{ 0xd7 , 0x00D7 }, +{ 0xd8 , 0x00D8 }, +{ 0xd9 , 0x00D9 }, +{ 0xda , 0x00DA }, +{ 0xdb , 0x00DB }, +{ 0xdc , 0x00DC }, +{ 0xdd , 0x0130 }, +{ 0xde , 0x015E }, +{ 0xdf , 0x00DF }, +{ 0xe0 , 0x00E0 }, +{ 0xe1 , 0x00E1 }, +{ 0xe2 , 0x00E2 }, +{ 0xe3 , 0x00E3 }, +{ 0xe4 , 0x00E4 }, +{ 0xe5 , 0x00E5 }, +{ 0xe6 , 0x00E6 }, +{ 0xe7 , 0x00E7 }, +{ 0xe8 , 0x00E8 }, +{ 0xe9 , 0x00E9 }, +{ 0xea , 0x00EA }, +{ 0xeb , 0x00EB }, +{ 0xec , 0x00EC }, +{ 0xed , 0x00ED }, +{ 0xee , 0x00EE }, +{ 0xef , 0x00EF }, +{ 0xf0 , 0x011F }, +{ 0xf1 , 0x00F1 }, +{ 0xf2 , 0x00F2 }, +{ 0xf3 , 0x00F3 }, +{ 0xf4 , 0x00F4 }, +{ 0xf5 , 0x00F5 }, +{ 0xf6 , 0x00F6 }, +{ 0xf7 , 0x00F7 }, +{ 0xf8 , 0x00F8 }, +{ 0xf9 , 0x00F9 }, +{ 0xfa , 0x00FA }, +{ 0xfb , 0x00FB }, +{ 0xfc , 0x00FC }, +{ 0xfd , 0x0131 }, +{ 0xfe , 0x015F }, +{ 0xff , 0x00FF }, diff --git a/extra/locale/charmaps/KOI8-R.pairs b/extra/locale/charmaps/KOI8-R.pairs new file mode 100644 index 0000000..f34053d --- /dev/null +++ b/extra/locale/charmaps/KOI8-R.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x2500 }, +{ 0x81 , 0x2502 }, +{ 0x82 , 0x250C }, +{ 0x83 , 0x2510 }, +{ 0x84 , 0x2514 }, +{ 0x85 , 0x2518 }, +{ 0x86 , 0x251C }, +{ 0x87 , 0x2524 }, +{ 0x88 , 0x252C }, +{ 0x89 , 0x2534 }, +{ 0x8a , 0x253C }, +{ 0x8b , 0x2580 }, +{ 0x8c , 0x2584 }, +{ 0x8d , 0x2588 }, +{ 0x8e , 0x258C }, +{ 0x8f , 0x2590 }, +{ 0x90 , 0x2591 }, +{ 0x91 , 0x2592 }, +{ 0x92 , 0x2593 }, +{ 0x93 , 0x2320 }, +{ 0x94 , 0x25A0 }, +{ 0x95 , 0x2219 }, +{ 0x96 , 0x221A }, +{ 0x97 , 0x2248 }, +{ 0x98 , 0x2264 }, +{ 0x99 , 0x2265 }, +{ 0x9a , 0x00A0 }, +{ 0x9b , 0x2321 }, +{ 0x9c , 0x00B0 }, +{ 0x9d , 0x00B2 }, +{ 0x9e , 0x00B7 }, +{ 0x9f , 0x00F7 }, +{ 0xa0 , 0x2550 }, +{ 0xa1 , 0x2551 }, +{ 0xa2 , 0x2552 }, +{ 0xa3 , 0x0451 }, +{ 0xa4 , 0x2553 }, +{ 0xa5 , 0x2554 }, +{ 0xa6 , 0x2555 }, +{ 0xa7 , 0x2556 }, +{ 0xa8 , 0x2557 }, +{ 0xa9 , 0x2558 }, +{ 0xaa , 0x2559 }, +{ 0xab , 0x255A }, +{ 0xac , 0x255B }, +{ 0xad , 0x255C }, +{ 0xae , 0x255D }, +{ 0xaf , 0x255E }, +{ 0xb0 , 0x255F }, +{ 0xb1 , 0x2560 }, +{ 0xb2 , 0x2561 }, +{ 0xb3 , 0x0401 }, +{ 0xb4 , 0x2562 }, +{ 0xb5 , 0x2563 }, +{ 0xb6 , 0x2564 }, +{ 0xb7 , 0x2565 }, +{ 0xb8 , 0x2566 }, +{ 0xb9 , 0x2567 }, +{ 0xba , 0x2568 }, +{ 0xbb , 0x2569 }, +{ 0xbc , 0x256A }, +{ 0xbd , 0x256B }, +{ 0xbe , 0x256C }, +{ 0xbf , 0x00A9 }, +{ 0xc0 , 0x044E }, +{ 0xc1 , 0x0430 }, +{ 0xc2 , 0x0431 }, +{ 0xc3 , 0x0446 }, +{ 0xc4 , 0x0434 }, +{ 0xc5 , 0x0435 }, +{ 0xc6 , 0x0444 }, +{ 0xc7 , 0x0433 }, +{ 0xc8 , 0x0445 }, +{ 0xc9 , 0x0438 }, +{ 0xca , 0x0439 }, +{ 0xcb , 0x043A }, +{ 0xcc , 0x043B }, +{ 0xcd , 0x043C }, +{ 0xce , 0x043D }, +{ 0xcf , 0x043E }, +{ 0xd0 , 0x043F }, +{ 0xd1 , 0x044F }, +{ 0xd2 , 0x0440 }, +{ 0xd3 , 0x0441 }, +{ 0xd4 , 0x0442 }, +{ 0xd5 , 0x0443 }, +{ 0xd6 , 0x0436 }, +{ 0xd7 , 0x0432 }, +{ 0xd8 , 0x044C }, +{ 0xd9 , 0x044B }, +{ 0xda , 0x0437 }, +{ 0xdb , 0x0448 }, +{ 0xdc , 0x044D }, +{ 0xdd , 0x0449 }, +{ 0xde , 0x0447 }, +{ 0xdf , 0x044A }, +{ 0xe0 , 0x042E }, +{ 0xe1 , 0x0410 }, +{ 0xe2 , 0x0411 }, +{ 0xe3 , 0x0426 }, +{ 0xe4 , 0x0414 }, +{ 0xe5 , 0x0415 }, +{ 0xe6 , 0x0424 }, +{ 0xe7 , 0x0413 }, +{ 0xe8 , 0x0425 }, +{ 0xe9 , 0x0418 }, +{ 0xea , 0x0419 }, +{ 0xeb , 0x041A }, +{ 0xec , 0x041B }, +{ 0xed , 0x041C }, +{ 0xee , 0x041D }, +{ 0xef , 0x041E }, +{ 0xf0 , 0x041F }, +{ 0xf1 , 0x042F }, +{ 0xf2 , 0x0420 }, +{ 0xf3 , 0x0421 }, +{ 0xf4 , 0x0422 }, +{ 0xf5 , 0x0423 }, +{ 0xf6 , 0x0416 }, +{ 0xf7 , 0x0412 }, +{ 0xf8 , 0x042C }, +{ 0xf9 , 0x042B }, +{ 0xfa , 0x0417 }, +{ 0xfb , 0x0428 }, +{ 0xfc , 0x042D }, +{ 0xfd , 0x0429 }, +{ 0xfe , 0x0427 }, +{ 0xff , 0x042A }, diff --git a/extra/locale/charmaps/KOI8-T.pairs b/extra/locale/charmaps/KOI8-T.pairs new file mode 100644 index 0000000..aeba582 --- /dev/null +++ b/extra/locale/charmaps/KOI8-T.pairs @@ -0,0 +1,237 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x049B }, +{ 0x81 , 0x0493 }, +{ 0x82 , 0x201A }, +{ 0x83 , 0x0492 }, +{ 0x84 , 0x201E }, +{ 0x85 , 0x2026 }, +{ 0x86 , 0x2020 }, +{ 0x87 , 0x2021 }, +{ 0x89 , 0x2030 }, +{ 0x8a , 0x04B3 }, +{ 0x8b , 0x2039 }, +{ 0x8c , 0x04B2 }, +{ 0x8d , 0x04B7 }, +{ 0x8e , 0x04B6 }, +{ 0x90 , 0x049A }, +{ 0x91 , 0x2018 }, +{ 0x92 , 0x2019 }, +{ 0x93 , 0x201C }, +{ 0x94 , 0x201D }, +{ 0x95 , 0x2022 }, +{ 0x96 , 0x2013 }, +{ 0x97 , 0x2014 }, +{ 0x99 , 0x2122 }, +{ 0x9b , 0x203A }, +{ 0xa1 , 0x04EF }, +{ 0xa2 , 0x04EE }, +{ 0xa3 , 0x0451 }, +{ 0xa4 , 0x00A4 }, +{ 0xa5 , 0x04E3 }, +{ 0xa6 , 0x00A6 }, +{ 0xa7 , 0x00A7 }, +{ 0xab , 0x00AB }, +{ 0xac , 0x00AC }, +{ 0xad , 0x00AD }, +{ 0xae , 0x00AE }, +{ 0xb0 , 0x00B0 }, +{ 0xb1 , 0x00B1 }, +{ 0xb2 , 0x00B2 }, +{ 0xb3 , 0x0401 }, +{ 0xb5 , 0x04E2 }, +{ 0xb6 , 0x00B6 }, +{ 0xb7 , 0x00B7 }, +{ 0xb9 , 0x2116 }, +{ 0xbb , 0x00BB }, +{ 0xbf , 0x00A9 }, +{ 0xc0 , 0x044E }, +{ 0xc1 , 0x0430 }, +{ 0xc2 , 0x0431 }, +{ 0xc3 , 0x0446 }, +{ 0xc4 , 0x0434 }, +{ 0xc5 , 0x0435 }, +{ 0xc6 , 0x0444 }, +{ 0xc7 , 0x0433 }, +{ 0xc8 , 0x0445 }, +{ 0xc9 , 0x0438 }, +{ 0xca , 0x0439 }, +{ 0xcb , 0x043A }, +{ 0xcc , 0x043B }, +{ 0xcd , 0x043C }, +{ 0xce , 0x043D }, +{ 0xcf , 0x043E }, +{ 0xd0 , 0x043F }, +{ 0xd1 , 0x044F }, +{ 0xd2 , 0x0440 }, +{ 0xd3 , 0x0441 }, +{ 0xd4 , 0x0442 }, +{ 0xd5 , 0x0443 }, +{ 0xd6 , 0x0436 }, +{ 0xd7 , 0x0432 }, +{ 0xd8 , 0x044C }, +{ 0xd9 , 0x044B }, +{ 0xda , 0x0437 }, +{ 0xdb , 0x0448 }, +{ 0xdc , 0x044D }, +{ 0xdd , 0x0449 }, +{ 0xde , 0x0447 }, +{ 0xdf , 0x044A }, +{ 0xe0 , 0x042E }, +{ 0xe1 , 0x0410 }, +{ 0xe2 , 0x0411 }, +{ 0xe3 , 0x0426 }, +{ 0xe4 , 0x0414 }, +{ 0xe5 , 0x0415 }, +{ 0xe6 , 0x0424 }, +{ 0xe7 , 0x0413 }, +{ 0xe8 , 0x0425 }, +{ 0xe9 , 0x0418 }, +{ 0xea , 0x0419 }, +{ 0xeb , 0x041A }, +{ 0xec , 0x041B }, +{ 0xed , 0x041C }, +{ 0xee , 0x041D }, +{ 0xef , 0x041E }, +{ 0xf0 , 0x041F }, +{ 0xf1 , 0x042F }, +{ 0xf2 , 0x0420 }, +{ 0xf3 , 0x0421 }, +{ 0xf4 , 0x0422 }, +{ 0xf5 , 0x0423 }, +{ 0xf6 , 0x0416 }, +{ 0xf7 , 0x0412 }, +{ 0xf8 , 0x042C }, +{ 0xf9 , 0x042B }, +{ 0xfa , 0x0417 }, +{ 0xfb , 0x0428 }, +{ 0xfc , 0x042D }, +{ 0xfd , 0x0429 }, +{ 0xfe , 0x0427 }, +{ 0xff , 0x042A }, diff --git a/extra/locale/charmaps/KOI8-U.pairs b/extra/locale/charmaps/KOI8-U.pairs new file mode 100644 index 0000000..ff05ed2 --- /dev/null +++ b/extra/locale/charmaps/KOI8-U.pairs @@ -0,0 +1,256 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0x80 , 0x2500 }, +{ 0x81 , 0x2502 }, +{ 0x82 , 0x250C }, +{ 0x83 , 0x2510 }, +{ 0x84 , 0x2514 }, +{ 0x85 , 0x2518 }, +{ 0x86 , 0x251C }, +{ 0x87 , 0x2524 }, +{ 0x88 , 0x252C }, +{ 0x89 , 0x2534 }, +{ 0x8a , 0x253C }, +{ 0x8b , 0x2580 }, +{ 0x8c , 0x2584 }, +{ 0x8d , 0x2588 }, +{ 0x8e , 0x258C }, +{ 0x8f , 0x2590 }, +{ 0x90 , 0x2591 }, +{ 0x91 , 0x2592 }, +{ 0x92 , 0x2593 }, +{ 0x93 , 0x2320 }, +{ 0x94 , 0x25A0 }, +{ 0x95 , 0x2219 }, +{ 0x96 , 0x221A }, +{ 0x97 , 0x2248 }, +{ 0x98 , 0x2264 }, +{ 0x99 , 0x2265 }, +{ 0x9a , 0x00A0 }, +{ 0x9b , 0x2321 }, +{ 0x9c , 0x00B0 }, +{ 0x9d , 0x00B2 }, +{ 0x9e , 0x00B7 }, +{ 0x9f , 0x00F7 }, +{ 0xa0 , 0x2550 }, +{ 0xa1 , 0x2551 }, +{ 0xa2 , 0x2552 }, +{ 0xa3 , 0x0451 }, +{ 0xa4 , 0x0454 }, +{ 0xa5 , 0x2554 }, +{ 0xa6 , 0x0456 }, +{ 0xa7 , 0x0457 }, +{ 0xa8 , 0x2557 }, +{ 0xa9 , 0x2558 }, +{ 0xaa , 0x2559 }, +{ 0xab , 0x255A }, +{ 0xac , 0x255B }, +{ 0xad , 0x0491 }, +{ 0xae , 0x255D }, +{ 0xaf , 0x255E }, +{ 0xb0 , 0x255F }, +{ 0xb1 , 0x2560 }, +{ 0xb2 , 0x2561 }, +{ 0xb3 , 0x0401 }, +{ 0xb4 , 0x0404 }, +{ 0xb5 , 0x2563 }, +{ 0xb6 , 0x0406 }, +{ 0xb7 , 0x0407 }, +{ 0xb8 , 0x2566 }, +{ 0xb9 , 0x2567 }, +{ 0xba , 0x2568 }, +{ 0xbb , 0x2569 }, +{ 0xbc , 0x256A }, +{ 0xbd , 0x0490 }, +{ 0xbe , 0x256C }, +{ 0xbf , 0x00A9 }, +{ 0xc0 , 0x044E }, +{ 0xc1 , 0x0430 }, +{ 0xc2 , 0x0431 }, +{ 0xc3 , 0x0446 }, +{ 0xc4 , 0x0434 }, +{ 0xc5 , 0x0435 }, +{ 0xc6 , 0x0444 }, +{ 0xc7 , 0x0433 }, +{ 0xc8 , 0x0445 }, +{ 0xc9 , 0x0438 }, +{ 0xca , 0x0439 }, +{ 0xcb , 0x043A }, +{ 0xcc , 0x043B }, +{ 0xcd , 0x043C }, +{ 0xce , 0x043D }, +{ 0xcf , 0x043E }, +{ 0xd0 , 0x043F }, +{ 0xd1 , 0x044F }, +{ 0xd2 , 0x0440 }, +{ 0xd3 , 0x0441 }, +{ 0xd4 , 0x0442 }, +{ 0xd5 , 0x0443 }, +{ 0xd6 , 0x0436 }, +{ 0xd7 , 0x0432 }, +{ 0xd8 , 0x044C }, +{ 0xd9 , 0x044B }, +{ 0xda , 0x0437 }, +{ 0xdb , 0x0448 }, +{ 0xdc , 0x044D }, +{ 0xdd , 0x0449 }, +{ 0xde , 0x0447 }, +{ 0xdf , 0x044A }, +{ 0xe0 , 0x042E }, +{ 0xe1 , 0x0410 }, +{ 0xe2 , 0x0411 }, +{ 0xe3 , 0x0426 }, +{ 0xe4 , 0x0414 }, +{ 0xe5 , 0x0415 }, +{ 0xe6 , 0x0424 }, +{ 0xe7 , 0x0413 }, +{ 0xe8 , 0x0425 }, +{ 0xe9 , 0x0418 }, +{ 0xea , 0x0419 }, +{ 0xeb , 0x041A }, +{ 0xec , 0x041B }, +{ 0xed , 0x041C }, +{ 0xee , 0x041D }, +{ 0xef , 0x041E }, +{ 0xf0 , 0x041F }, +{ 0xf1 , 0x042F }, +{ 0xf2 , 0x0420 }, +{ 0xf3 , 0x0421 }, +{ 0xf4 , 0x0422 }, +{ 0xf5 , 0x0423 }, +{ 0xf6 , 0x0416 }, +{ 0xf7 , 0x0412 }, +{ 0xf8 , 0x042C }, +{ 0xf9 , 0x042B }, +{ 0xfa , 0x0417 }, +{ 0xfb , 0x0428 }, +{ 0xfc , 0x042D }, +{ 0xfd , 0x0429 }, +{ 0xfe , 0x0427 }, +{ 0xff , 0x042A }, diff --git a/extra/locale/charmaps/TIS-620.pairs b/extra/locale/charmaps/TIS-620.pairs new file mode 100644 index 0000000..618a3be --- /dev/null +++ b/extra/locale/charmaps/TIS-620.pairs @@ -0,0 +1,215 @@ +{ 0x00 , 0x0000 }, +{ 0x01 , 0x0001 }, +{ 0x02 , 0x0002 }, +{ 0x03 , 0x0003 }, +{ 0x04 , 0x0004 }, +{ 0x05 , 0x0005 }, +{ 0x06 , 0x0006 }, +{ 0x07 , 0x0007 }, +{ 0x08 , 0x0008 }, +{ 0x09 , 0x0009 }, +{ 0x0a , 0x000A }, +{ 0x0b , 0x000B }, +{ 0x0c , 0x000C }, +{ 0x0d , 0x000D }, +{ 0x0e , 0x000E }, +{ 0x0f , 0x000F }, +{ 0x10 , 0x0010 }, +{ 0x11 , 0x0011 }, +{ 0x12 , 0x0012 }, +{ 0x13 , 0x0013 }, +{ 0x14 , 0x0014 }, +{ 0x15 , 0x0015 }, +{ 0x16 , 0x0016 }, +{ 0x17 , 0x0017 }, +{ 0x18 , 0x0018 }, +{ 0x19 , 0x0019 }, +{ 0x1a , 0x001A }, +{ 0x1b , 0x001B }, +{ 0x1c , 0x001C }, +{ 0x1d , 0x001D }, +{ 0x1e , 0x001E }, +{ 0x1f , 0x001F }, +{ 0x20 , 0x0020 }, +{ 0x21 , 0x0021 }, +{ 0x22 , 0x0022 }, +{ 0x23 , 0x0023 }, +{ 0x24 , 0x0024 }, +{ 0x25 , 0x0025 }, +{ 0x26 , 0x0026 }, +{ 0x27 , 0x0027 }, +{ 0x28 , 0x0028 }, +{ 0x29 , 0x0029 }, +{ 0x2a , 0x002A }, +{ 0x2b , 0x002B }, +{ 0x2c , 0x002C }, +{ 0x2d , 0x002D }, +{ 0x2e , 0x002E }, +{ 0x2f , 0x002F }, +{ 0x30 , 0x0030 }, +{ 0x31 , 0x0031 }, +{ 0x32 , 0x0032 }, +{ 0x33 , 0x0033 }, +{ 0x34 , 0x0034 }, +{ 0x35 , 0x0035 }, +{ 0x36 , 0x0036 }, +{ 0x37 , 0x0037 }, +{ 0x38 , 0x0038 }, +{ 0x39 , 0x0039 }, +{ 0x3a , 0x003A }, +{ 0x3b , 0x003B }, +{ 0x3c , 0x003C }, +{ 0x3d , 0x003D }, +{ 0x3e , 0x003E }, +{ 0x3f , 0x003F }, +{ 0x40 , 0x0040 }, +{ 0x41 , 0x0041 }, +{ 0x42 , 0x0042 }, +{ 0x43 , 0x0043 }, +{ 0x44 , 0x0044 }, +{ 0x45 , 0x0045 }, +{ 0x46 , 0x0046 }, +{ 0x47 , 0x0047 }, +{ 0x48 , 0x0048 }, +{ 0x49 , 0x0049 }, +{ 0x4a , 0x004A }, +{ 0x4b , 0x004B }, +{ 0x4c , 0x004C }, +{ 0x4d , 0x004D }, +{ 0x4e , 0x004E }, +{ 0x4f , 0x004F }, +{ 0x50 , 0x0050 }, +{ 0x51 , 0x0051 }, +{ 0x52 , 0x0052 }, +{ 0x53 , 0x0053 }, +{ 0x54 , 0x0054 }, +{ 0x55 , 0x0055 }, +{ 0x56 , 0x0056 }, +{ 0x57 , 0x0057 }, +{ 0x58 , 0x0058 }, +{ 0x59 , 0x0059 }, +{ 0x5a , 0x005A }, +{ 0x5b , 0x005B }, +{ 0x5c , 0x005C }, +{ 0x5d , 0x005D }, +{ 0x5e , 0x005E }, +{ 0x5f , 0x005F }, +{ 0x60 , 0x0060 }, +{ 0x61 , 0x0061 }, +{ 0x62 , 0x0062 }, +{ 0x63 , 0x0063 }, +{ 0x64 , 0x0064 }, +{ 0x65 , 0x0065 }, +{ 0x66 , 0x0066 }, +{ 0x67 , 0x0067 }, +{ 0x68 , 0x0068 }, +{ 0x69 , 0x0069 }, +{ 0x6a , 0x006A }, +{ 0x6b , 0x006B }, +{ 0x6c , 0x006C }, +{ 0x6d , 0x006D }, +{ 0x6e , 0x006E }, +{ 0x6f , 0x006F }, +{ 0x70 , 0x0070 }, +{ 0x71 , 0x0071 }, +{ 0x72 , 0x0072 }, +{ 0x73 , 0x0073 }, +{ 0x74 , 0x0074 }, +{ 0x75 , 0x0075 }, +{ 0x76 , 0x0076 }, +{ 0x77 , 0x0077 }, +{ 0x78 , 0x0078 }, +{ 0x79 , 0x0079 }, +{ 0x7a , 0x007A }, +{ 0x7b , 0x007B }, +{ 0x7c , 0x007C }, +{ 0x7d , 0x007D }, +{ 0x7e , 0x007E }, +{ 0x7f , 0x007F }, +{ 0xa1 , 0x0E01 }, +{ 0xa2 , 0x0E02 }, +{ 0xa3 , 0x0E03 }, +{ 0xa4 , 0x0E04 }, +{ 0xa5 , 0x0E05 }, +{ 0xa6 , 0x0E06 }, +{ 0xa7 , 0x0E07 }, +{ 0xa8 , 0x0E08 }, +{ 0xa9 , 0x0E09 }, +{ 0xaa , 0x0E0A }, +{ 0xab , 0x0E0B }, +{ 0xac , 0x0E0C }, +{ 0xad , 0x0E0D }, +{ 0xae , 0x0E0E }, +{ 0xaf , 0x0E0F }, +{ 0xb0 , 0x0E10 }, +{ 0xb1 , 0x0E11 }, +{ 0xb2 , 0x0E12 }, +{ 0xb3 , 0x0E13 }, +{ 0xb4 , 0x0E14 }, +{ 0xb5 , 0x0E15 }, +{ 0xb6 , 0x0E16 }, +{ 0xb7 , 0x0E17 }, +{ 0xb8 , 0x0E18 }, +{ 0xb9 , 0x0E19 }, +{ 0xba , 0x0E1A }, +{ 0xbb , 0x0E1B }, +{ 0xbc , 0x0E1C }, +{ 0xbd , 0x0E1D }, +{ 0xbe , 0x0E1E }, +{ 0xbf , 0x0E1F }, +{ 0xc0 , 0x0E20 }, +{ 0xc1 , 0x0E21 }, +{ 0xc2 , 0x0E22 }, +{ 0xc3 , 0x0E23 }, +{ 0xc4 , 0x0E24 }, +{ 0xc5 , 0x0E25 }, +{ 0xc6 , 0x0E26 }, +{ 0xc7 , 0x0E27 }, +{ 0xc8 , 0x0E28 }, +{ 0xc9 , 0x0E29 }, +{ 0xca , 0x0E2A }, +{ 0xcb , 0x0E2B }, +{ 0xcc , 0x0E2C }, +{ 0xcd , 0x0E2D }, +{ 0xce , 0x0E2E }, +{ 0xcf , 0x0E2F }, +{ 0xd0 , 0x0E30 }, +{ 0xd1 , 0x0E31 }, +{ 0xd2 , 0x0E32 }, +{ 0xd3 , 0x0E33 }, +{ 0xd4 , 0x0E34 }, +{ 0xd5 , 0x0E35 }, +{ 0xd6 , 0x0E36 }, +{ 0xd7 , 0x0E37 }, +{ 0xd8 , 0x0E38 }, +{ 0xd9 , 0x0E39 }, +{ 0xda , 0x0E3A }, +{ 0xdf , 0x0E3F }, +{ 0xe0 , 0x0E40 }, +{ 0xe1 , 0x0E41 }, +{ 0xe2 , 0x0E42 }, +{ 0xe3 , 0x0E43 }, +{ 0xe4 , 0x0E44 }, +{ 0xe5 , 0x0E45 }, +{ 0xe6 , 0x0E46 }, +{ 0xe7 , 0x0E47 }, +{ 0xe8 , 0x0E48 }, +{ 0xe9 , 0x0E49 }, +{ 0xea , 0x0E4A }, +{ 0xeb , 0x0E4B }, +{ 0xec , 0x0E4C }, +{ 0xed , 0x0E4D }, +{ 0xee , 0x0E4E }, +{ 0xef , 0x0E4F }, +{ 0xf0 , 0x0E50 }, +{ 0xf1 , 0x0E51 }, +{ 0xf2 , 0x0E52 }, +{ 0xf3 , 0x0E53 }, +{ 0xf4 , 0x0E54 }, +{ 0xf5 , 0x0E55 }, +{ 0xf6 , 0x0E56 }, +{ 0xf7 , 0x0E57 }, +{ 0xf8 , 0x0E58 }, +{ 0xf9 , 0x0E59 }, +{ 0xfa , 0x0E5A }, +{ 0xfb , 0x0E5B }, diff --git a/extra/locale/collation/af_ZA b/extra/locale/collation/af_ZA new file mode 100644 index 0000000..d66184e --- /dev/null +++ b/extra/locale/collation/af_ZA @@ -0,0 +1 @@ +copy "en_DK" diff --git a/extra/locale/collation/am_ET b/extra/locale/collation/am_ET new file mode 100644 index 0000000..94a9181 --- /dev/null +++ b/extra/locale/collation/am_ET @@ -0,0 +1,26 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + +% Correct Unicode Addressing +script +order_start ;forward +# qW qWi + + +# QW QWi + + +# hW hWi + + +# kW kWi + + +# KW KWi + + +# gW gWi + + +order_end diff --git a/extra/locale/collation/ar_AE b/extra/locale/collation/ar_AE new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_AE @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_BH b/extra/locale/collation/ar_BH new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_BH @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_DZ b/extra/locale/collation/ar_DZ new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_DZ @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_EG b/extra/locale/collation/ar_EG new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_EG @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_IN b/extra/locale/collation/ar_IN new file mode 100644 index 0000000..d05f74d --- /dev/null +++ b/extra/locale/collation/ar_IN @@ -0,0 +1,3 @@ +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_IQ b/extra/locale/collation/ar_IQ new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_IQ @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_JO b/extra/locale/collation/ar_JO new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_JO @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_KW b/extra/locale/collation/ar_KW new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_KW @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_LB b/extra/locale/collation/ar_LB new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_LB @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_LY b/extra/locale/collation/ar_LY new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_LY @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_MA b/extra/locale/collation/ar_MA new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_MA @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_OM b/extra/locale/collation/ar_OM new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_OM @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_QA b/extra/locale/collation/ar_QA new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_QA @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_SA b/extra/locale/collation/ar_SA new file mode 100644 index 0000000..a01c4ec --- /dev/null +++ b/extra/locale/collation/ar_SA @@ -0,0 +1,220 @@ + + +order_start forward; forward + + + + + + + + + + + + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IGNORE + IGNORE + IGNORE + IGNORE + IGNORE + IGNORE + IGNORE + IGNORE + IGNORE + +% UCLIBC -- add an explicit UNDEFINED entry +UNDEFINED +order_end + + diff --git a/extra/locale/collation/ar_SD b/extra/locale/collation/ar_SD new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_SD @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_SY b/extra/locale/collation/ar_SY new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_SY @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_TN b/extra/locale/collation/ar_TN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_TN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ar_YE b/extra/locale/collation/ar_YE new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ar_YE @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/az_AZ b/extra/locale/collation/az_AZ new file mode 100644 index 0000000..daaeacc --- /dev/null +++ b/extra/locale/collation/az_AZ @@ -0,0 +1,137 @@ +% The new (1991) latin azeri alphabet is: +% , , , , , , , , , , , , +% (dotless i), (i with dot), , , , , , , , +% ,

, , , , , , , , , +% +% cyrillic alphabet: +% , , , , , , , , , , , +% , , , , , , , , , , , +% , , , , , , , , + +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + + + + + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/be_BY b/extra/locale/collation/be_BY new file mode 100644 index 0000000..342a761 --- /dev/null +++ b/extra/locale/collation/be_BY @@ -0,0 +1,15 @@ +copy "iso14651_t1" + +% iso14651_t1 is missing Ukrainian ghe +collating-symbol + +reorder-after + + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-end diff --git a/extra/locale/collation/bg_BG b/extra/locale/collation/bg_BG new file mode 100644 index 0000000..ddf84dc --- /dev/null +++ b/extra/locale/collation/bg_BG @@ -0,0 +1,106 @@ + +% We have made the following changes to the basic collation scheme in +% the file iso14651_t1: +% 1. The Cyrillic script is first in the order. +% 2. The non-Bulgarian Cyrillic letters are sorted according to +% their transliteration with Bulgarian Cyrillic letters. + +copy "iso14651_t1" +reorder-after <9> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +reorder-after + ;;;IGNORE % Mac. gje +reorder-after + "";"";"";IGNORE % CYR-DJE + "";"";"";IGNORE % CYR-DCHE + "";"";"";IGNORE % CYR-DZE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE +reorder-after + "";"";"";IGNORE % CYR-LJE +reorder-after + "";"";"";IGNORE % CYR-NJE +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE % Mac. gje +reorder-after + "";"";"";IGNORE % CYR-DJE + "";"";"";IGNORE % CYR-DCHE + "";"";"";IGNORE % CYR-DZE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE +reorder-after + "";"";"";IGNORE % CYR-LJE +reorder-after + "";"";"";IGNORE % CYR-NJE +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE +reorder-end diff --git a/extra/locale/collation/bn_BD b/extra/locale/collation/bn_BD new file mode 100644 index 0000000..9a3ff3b --- /dev/null +++ b/extra/locale/collation/bn_BD @@ -0,0 +1,2 @@ +% TODO: Bengali sorting should be added +copy "iso14651_t1" diff --git a/extra/locale/collation/bn_IN b/extra/locale/collation/bn_IN new file mode 100644 index 0000000..0caba14 --- /dev/null +++ b/extra/locale/collation/bn_IN @@ -0,0 +1,4 @@ +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + +% diff --git a/extra/locale/collation/br_FR b/extra/locale/collation/br_FR new file mode 100644 index 0000000..0887c81 --- /dev/null +++ b/extra/locale/collation/br_FR @@ -0,0 +1,40 @@ +copy "iso14651_t1" + +%% a b c ch c'h d e f g h i j k l m n o p q r s t u v w x y z +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol + +reorder-after + + +reorder-after + + +reorder-after + + + +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/bs_BA b/extra/locale/collation/bs_BA new file mode 100644 index 0000000..24be941 --- /dev/null +++ b/extra/locale/collation/bs_BA @@ -0,0 +1,91 @@ +copy "iso14651_t1" + +% a b c c' c< d dz< d// e f g h i j k l lj m n nj o p +% q r s s< t u v w x y z z< + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-symbol + +reorder-after + +reorder-after + + +reorder-after + + + + + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +%reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/comm b/extra/locale/collation/comm new file mode 100644 index 0000000..356df60 --- /dev/null +++ b/extra/locale/collation/comm @@ -0,0 +1,1872 @@ + +% Base collation scheme: 1994-03-22 + +% Ordering algorithm: +% 1. Spaces and hyphen (but not soft +% hyphen) before punctuation +% characters, punctuation characters +% before numbers, +% numbers before letters. +% 2. Letters with diacritical marks are +% members of equivalence classes +% 3. A distinction is made with regards +% to case as noted below. +% 4. Special characters are ignored +% when comparing letters, but then +% they are considered +% 5. The alphabets are sorted in order +% of first appearance in ISO 10646: +% Latin, Greek, Cyrillic, etc. +% +% According to Greek specifications, +% the steps 2. and 3. above are reversed +% for the Greek script + +% collating symbols + +% The collating symbol naming is +% mostly taken from ISO 10646-1, +% for example the case and accent +% names are from this standard. + +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +% and +% are for cases like Danish +% and Spanish being treated +% as one letter. + +% The ...... collating +% symbols have defined weights as +% the last character in a group of +% Latin letters. They are used +% to specify deltas by locales using +% a locale as the default ordering +% and by "replace-after" statements +% specifying the changed placement +% in an ordering of a character. + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +% letter;accent;case;specials + +order_start forward;backward;forward;position + +% or letters first: + + + +% Accents: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ;;;IGNORE + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; +<"=> IGNORE;IGNORE;IGNORE;<"=> + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; +UNDEFINED IGNORE;IGNORE;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + +% Arabic collating + + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +% katakana/hiragana sorting +% base is katakana, as this is present in most charsets +% normal before voiced before semi-voiced +% small vocals before normal vocals +% katakana before hiragana + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + +order_end + diff --git a/extra/locale/collation/cy_GB b/extra/locale/collation/cy_GB new file mode 100644 index 0000000..6cda676 --- /dev/null +++ b/extra/locale/collation/cy_GB @@ -0,0 +1,136 @@ +copy "iso14651_t1" + +% Welsh sorting order is: +% a b c ch d dd e f ff g ng h i l ll m n o p ph r rh s t th u w y + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol + +reorder-after + +reorder-after + + +reorder-after + + + +reorder-after + + + +reorder-after + +reorder-after

+collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +# +# / +# +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +# +# +# +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +# +# GREC +# +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +# +# CYRIL +# +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +# Ordre des symboles internes / Order of internal symbols +# +# SYMB. N +# + + +# forme de base (bas de casse, arabe intrinsque, +# hbreu intrinsque, etc. +# basic form (lower case, intrinsic Arabic +# intrinsic Hebrew and so on) +# +# / +# +# + # voir + # isol. +# 3 + # final +# 4 + # initial +# 5 + # medial/mdian +# 6 +# + # 7 + # 8 + # 9 + # 10 + # 11 + +#alternate lower case/ +# 12 +# +#minuscules spciales aprs majuscules +# / +# + # accent madda #13 + # accent hamza #14 + # accent hamza/waw #14 1 + # accent hamza under / hamza souscrit #14 2 + # accent under yeh / accent souscrit du ya' #14 3 + # accent hamza/yeh barree #14 4 +# + # 15 +# + # 16 + # 17 + # 18 + # 19 + # 20 + # 21 + # 22 + # 23 + # 24 + # 25 + # 26 + # 27 + # 28 + # 29 + # 30 + # 31 +# +# GREC +# + # accent aigu/tonos/acute accent + # trma/dialytica/diaeresis + # dialytika tonos +# +<0> # 48 +<1> # 49 +<2> # 50 +<3> # 51 +<4> # 52 +<5> # 53 +<6> # 54 +<7> # 55 +<8> # 56 +<9> # 57 +# + # 97 + # 98 + # 99 + # 100 + # 101 + # 102 + # 103 + # 104 + # 105 + # 106 + # 107 + # 108 + # 109 + # 110 + # 111 +

# 112 + # 113 + # 114 + # 115 + # 116 + # 117 + # 118 + # 119 + # 120 + # 121 + # 122 +# 122b +# +# / +# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# +# +# + + + + + + + + + + + + + + + + + + + + + + + + + + + +# +#GREC +# + + + + + + + + + + + + + + + + + + + + + + + + +# +#CYRIL +# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +order_start ;forward;backward;forward;forward,position +# +# Tout caractre non prcisment dfini sera considr comme caractre spcial +# et considr uniquement au dernier niveau. +# +# Any character not precisely specified will be considered as a special +# character and considered only at the last level. +# ...... IGNORE;IGNORE;IGNORE;...... +# +# SYMB. N GLY +# + IGNORE;IGNORE;IGNORE; # 32 + IGNORE;IGNORE;IGNORE; # 33 _ + IGNORE;IGNORE;IGNORE; # 34 <"_> + IGNORE;IGNORE;IGNORE; # 35 - (MACRON) + IGNORE;IGNORE;IGNORE; # 36 + IGNORE;IGNORE;IGNORE; # 37 - + IGNORE;IGNORE;IGNORE; # 38 , + IGNORE;IGNORE;IGNORE; # 39 ; + IGNORE;IGNORE;IGNORE; # 40 : + IGNORE;IGNORE;IGNORE; # 41 ! + IGNORE;IGNORE;IGNORE; # 42 + IGNORE;IGNORE;IGNORE; # 43 ? + IGNORE;IGNORE;IGNORE; # 44 + IGNORE;IGNORE;IGNORE; # 45 / + IGNORE;IGNORE;IGNORE; # 46 <"/> + IGNORE;IGNORE;IGNORE; # 47 . + IGNORE;IGNORE;IGNORE; # 58 + IGNORE;IGNORE;IGNORE; # 59 + IGNORE;IGNORE;IGNORE; # 60 <";> + IGNORE;IGNORE;IGNORE; # 61 ' + IGNORE;IGNORE;IGNORE; # 62 <'6> + IGNORE;IGNORE;IGNORE; # 63 <'9> + IGNORE;IGNORE;IGNORE; # 64 " + IGNORE;IGNORE;IGNORE; # 65 <"6> + IGNORE;IGNORE;IGNORE; # 66 <"9> + IGNORE;IGNORE;IGNORE; # 67 + IGNORE;IGNORE;IGNORE; # 68 + IGNORE;IGNORE;IGNORE; # 69 ( + IGNORE;IGNORE;IGNORE; # 70 <(S> + IGNORE;IGNORE;IGNORE; # 71 ) + IGNORE;IGNORE;IGNORE; # 72 <)S> + IGNORE;IGNORE;IGNORE; # 73 [ + IGNORE;IGNORE;IGNORE; # 74 ] + IGNORE;IGNORE;IGNORE; # 75 { + IGNORE;IGNORE;IGNORE; # 76 } + IGNORE;IGNORE;IGNORE; # 77 + IGNORE;IGNORE;IGNORE; # 78 + IGNORE;IGNORE;IGNORE; # 79 + IGNORE;IGNORE;IGNORE; # 80 + IGNORE;IGNORE;IGNORE; # 81 + IGNORE;IGNORE;IGNORE; # 82 @ + IGNORE;IGNORE;IGNORE; # 83 + IGNORE;IGNORE;IGNORE; # 84 + IGNORE;IGNORE;IGNORE; # 85 $ + IGNORE;IGNORE;IGNORE; # 86 + IGNORE;IGNORE;IGNORE; # 87 + IGNORE;IGNORE;IGNORE; # ecu + IGNORE;IGNORE;IGNORE; # colon + IGNORE;IGNORE;IGNORE; # cruzeiro + IGNORE;IGNORE;IGNORE; # french franc + IGNORE;IGNORE;IGNORE; # lira + IGNORE;IGNORE;IGNORE; # mill + IGNORE;IGNORE;IGNORE; # naira + IGNORE;IGNORE;IGNORE; # peseta + IGNORE;IGNORE;IGNORE; # rupee + IGNORE;IGNORE;IGNORE; # won + IGNORE;IGNORE;IGNORE; # new sheqel + IGNORE;IGNORE;IGNORE; # dong + IGNORE;IGNORE;IGNORE; # euro + IGNORE;IGNORE;IGNORE; # kip + IGNORE;IGNORE;IGNORE; # tugrik + IGNORE;IGNORE;IGNORE; # drachma + IGNORE;IGNORE;IGNORE; # 88 * + IGNORE;IGNORE;IGNORE; # 89 + IGNORE;IGNORE;IGNORE; # 90 & + IGNORE;IGNORE;IGNORE; # 91 # + IGNORE;IGNORE;IGNORE; # 92 % + IGNORE;IGNORE;IGNORE; # 93 <-S> + IGNORE;IGNORE;IGNORE; # 94 + + IGNORE;IGNORE;IGNORE; # 95 <+S> + IGNORE;IGNORE;IGNORE; # 96 + IGNORE;IGNORE;IGNORE;<0> # 123 + IGNORE;IGNORE;IGNORE;<1> # 124 ` + IGNORE;IGNORE;IGNORE;<2> # 125 <"(> + IGNORE;IGNORE;IGNORE;<3> # 126 ^ + IGNORE;IGNORE;IGNORE;<4> # 127 <"<> + IGNORE;IGNORE;IGNORE;<5> # 128 <"0> + IGNORE;IGNORE;IGNORE;<6> # 129 + IGNORE;IGNORE;IGNORE;<7> # 130 <""> + IGNORE;IGNORE;IGNORE;<8> # 131 ~ + IGNORE;IGNORE;IGNORE;<9> # 132 <".> + IGNORE;IGNORE;IGNORE; # 133 + IGNORE;IGNORE;IGNORE; # 134 + IGNORE;IGNORE;IGNORE; # 135 + IGNORE;IGNORE;IGNORE; # 136 < + IGNORE;IGNORE;IGNORE; # 137 <=<> + IGNORE;IGNORE;IGNORE; # 138 = + IGNORE;IGNORE;IGNORE; # 139 => + IGNORE;IGNORE;IGNORE; # 140 > + IGNORE;IGNORE;IGNORE; # 141 + IGNORE;IGNORE;IGNORE; # 142 | + IGNORE;IGNORE;IGNORE; # 143 | + IGNORE;IGNORE;IGNORE; # 144 + IGNORE;IGNORE;IGNORE; # 145 m + IGNORE;IGNORE;IGNORE; # 146 + IGNORE;IGNORE;IGNORE; # 147 + IGNORE;IGNORE;IGNORE;

# 148 <_V/>> + IGNORE;IGNORE;IGNORE; # 149 <_V-> + IGNORE;IGNORE;IGNORE; # 150 <_V + IGNORE;IGNORE;IGNORE; # 151 <_!/>> + IGNORE;IGNORE;IGNORE; # 152 <_!-> + IGNORE;IGNORE;IGNORE; # 153 <_!<> + IGNORE;IGNORE;IGNORE; # 154 <_A/>> + IGNORE;IGNORE;IGNORE; # 155 <_-A> + IGNORE;IGNORE;IGNORE; # 156 <_A<> + IGNORE;IGNORE;IGNORE; # 157 <_!> + IGNORE;IGNORE;IGNORE; # 158 <_-> # + IGNORE;IGNORE;IGNORE; # 159 <_=> + IGNORE;IGNORE;IGNORE; # 160 <<-> + IGNORE;IGNORE;IGNORE; # 161 <-/>> + IGNORE;IGNORE;IGNORE; # 162 <"7> + IGNORE;IGNORE;IGNORE; # 163 <-!> + IGNORE;IGNORE;IGNORE; # 164 <-v> + IGNORE;IGNORE;IGNORE; # 165 <_d!> + IGNORE;IGNORE;IGNORE; # 166 <_/>//> + IGNORE;IGNORE;IGNORE; # 167 <_<\> + IGNORE;IGNORE;IGNORE; # 168 <_./>//> + IGNORE;IGNORE;IGNORE; # 169 <_.<\> # # / # + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # + IGNORE;IGNORE;IGNORE; # # # # + IGNORE;IGNORE;IGNORE; #point_sheva + IGNORE;IGNORE;IGNORE; #point_hataf_segol + IGNORE;IGNORE;IGNORE; #point_hataf_patah + IGNORE;IGNORE;IGNORE; #point_hataf_qamats + IGNORE;IGNORE;IGNORE; #point_hiriq + IGNORE;IGNORE;IGNORE; #point_tsere + IGNORE;IGNORE;IGNORE; #point_segol + IGNORE;IGNORE;IGNORE; #point_patah + IGNORE;IGNORE;IGNORE; #point_qamats + IGNORE;IGNORE;IGNORE; #point_holam + IGNORE;IGNORE;IGNORE; #point_qubuts + IGNORE;IGNORE;IGNORE; #point_dagesh + IGNORE;IGNORE;IGNORE; #point_meteg + IGNORE;IGNORE;IGNORE; #maqaf + IGNORE;IGNORE;IGNORE; #point_rafe + IGNORE;IGNORE;IGNORE; #paseq + IGNORE;IGNORE;IGNORE; #point_shin_dot + IGNORE;IGNORE;IGNORE; #point_sin_dot + IGNORE;IGNORE;IGNORE; #sof pasuq + +# The comment at the beginning of this section mentions characters which +# are not otherwise covered. But this description cannot express this. +# Therefore we add here a few entries which are used in older implementations +# to be compatible. --drepper + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + +order_start ;forward;backward;forward;forward,position +# + ;;;IGNORE # 170 +# + <0>;;;IGNORE # 171 0 + <1>;;;IGNORE # 172 1 + <2>;;;IGNORE # 173 2 + <3>;;;IGNORE # 174 3 + <4>;;;IGNORE # 175 4 + <5>;;;IGNORE # 176 5 + <6>;;;IGNORE # 177 6 + <7>;;;IGNORE # 178 7 + <8>;;;IGNORE # 179 8 + <9>;;;IGNORE # 180 9 +# + <0>;;;IGNORE # 181 <18> + <0>;;;IGNORE # 182 + <0>;;;IGNORE # 183 <38> + <0>;;;IGNORE # 184 <58> + <0>;;;IGNORE # 185 <78> + <0>;;;IGNORE # 186 + <0>;;;IGNORE # 187 + <0>;;;IGNORE # 188 <0S> + <1>;;;IGNORE # 189 + <2>;;;IGNORE # 190 + <3>;;;IGNORE # 191 + <4>;;;IGNORE # 192 <4S> + <5>;;;IGNORE # 193 <5S> + <6>;;;IGNORE # 194 <6S> + <7>;;;IGNORE # 195 <7S> + <8>;;;IGNORE # 196 <8S> + <9>;;;IGNORE # 197 <9S> +# + ;;;IGNORE # 198 a + ;;;IGNORE # 199 + ;;;IGNORE # 200 + ;;;IGNORE # 201 + ;;;IGNORE # 202 + ;;;IGNORE # 203 + ;;;IGNORE # 204 + ;;;IGNORE # 205 + ;;;IGNORE # 206 + ;;;IGNORE # 207 + ;;;IGNORE # 208 + "";"";"";IGNORE # 209 + ;;;IGNORE # 210 b + ;;;IGNORE # 211 c + ;;;IGNORE # 212 + ;;;IGNORE # 213 + ;;;IGNORE # 214 > + ;;;IGNORE # 215 + ;;;IGNORE # 216 + ;;;IGNORE # 217 d + ;;;IGNORE # 218 + ;;;IGNORE # 219 + ;;;IGNORE # 220 + ;;;IGNORE # 221 e + ;;;IGNORE # 222 + ;;;IGNORE # 223 + ;;;IGNORE # 224 + ;;;IGNORE # 225 + ;;;IGNORE # 226 + ;;;IGNORE # 227 + ;;;IGNORE # 228 + ;;;IGNORE # 229 + ;;;IGNORE # 230 f + ;;;IGNORE # 231 g + ;;;IGNORE # 232 + ;;;IGNORE # 233 > + ;;;IGNORE # 234 + ;;;IGNORE # 235 + ;;;IGNORE # 236 h + ;;;IGNORE # 237 > + ;;;IGNORE # 238 + ;;;IGNORE # 239 i + ;;;IGNORE # 240 + ;;;IGNORE # 241 + ;;;IGNORE # 242 + ;;;IGNORE # 243 + ;;;IGNORE # 244 + ;;;IGNORE # 245 + ;;;IGNORE # 246 + ;;;IGNORE # 247 + "";"";"";IGNORE # 248 + ;;;IGNORE # 249 j + ;;;IGNORE # 250 > + ;;;IGNORE # 251 k + ;;;IGNORE # 252 + ;;;IGNORE # 253 + ;;;IGNORE # 254 l + ;;;IGNORE # 255 + ;;;IGNORE # 256 + ;;;IGNORE # 257 + ;;;IGNORE # 258 + ;;;IGNORE # 259 + ;;;IGNORE # 260 m + ;;;IGNORE # 261 n + ;;;IGNORE # 262 + ;;;IGNORE # 263 <'n> + ;;;IGNORE # 264 + ;;;IGNORE # 265 + ;;;IGNORE # 266 + "";"";"";IGNORE # 267 + ;;;IGNORE # 268 o + ;;;IGNORE # 269 + ;;;IGNORE # 270 + ;;;IGNORE # 271 + ;;;IGNORE # 272 + ;;;IGNORE # 273 + ;;;IGNORE # 274 + ;;;IGNORE # 275 + ;;;IGNORE # 276 + ;;;IGNORE # 277 + "";"";"";IGNORE # 278 +

;;;IGNORE # 279 p + ;;;IGNORE # 280 q + ;;;IGNORE # 281 r + ;;;IGNORE # 282 + ;;;IGNORE # 283 + ;;;IGNORE # 284 + ;;;IGNORE # 285 s + ;;;IGNORE # 286 + ;;;IGNORE # 287 > + ;;;IGNORE # 288 + ;;;IGNORE # 289 + "";"";"";IGNORE # 290 + ;;;IGNORE # 291 t + ;;;IGNORE # 292 + ;;;IGNORE # 293 + ;;;IGNORE # 294 + ;;;IGNORE # 296 u + ;;;IGNORE # 297 + ;;;IGNORE # 298 + ;;;IGNORE # 299 + ;;;IGNORE # 300 + ;;;IGNORE # 301 + ;;;IGNORE # 302 + ;;;IGNORE # 303 + ;;;IGNORE # 304 + ;;;IGNORE # 305 + ;;;IGNORE # 306 + ;;;IGNORE # 307 v + ;;;IGNORE # 308 w + ;;;IGNORE # 309 > + ;;;IGNORE # 310 x + ;;;IGNORE # 311 y + ;;;IGNORE # 312 + ;;;IGNORE # 313 _ + ;;;IGNORE # 314 > + ;;;IGNORE # 315 z + ;;;IGNORE # 316 + ;;;IGNORE # 317 + ;;;IGNORE # 318 + ;;;IGNORE # 318b # + ;;;IGNORE # 319 A + ;;;IGNORE # 320 + ;;;IGNORE # 321 + ;;;IGNORE # 322 + ;;;IGNORE # 323 + ;;;IGNORE # 324 + ;;;IGNORE # 325 + ;;;IGNORE # 326 + ;;;IGNORE # 327 + ;;;IGNORE # 328 + "";"";"";IGNORE # 329 + ;;;IGNORE # 330 B + ;;;IGNORE # 331 C + ;;;IGNORE # 332 + ;;;IGNORE # 333 + ;;;IGNORE # 334 > + ;;;IGNORE # 335 > + ;;;IGNORE # 336 + ;;;IGNORE # 337 D + ;;;IGNORE # 338 + ;;;IGNORE # 339 + ;;;IGNORE # 340 + ;;;IGNORE # 341 E + ;;;IGNORE # 342 + ;;;IGNORE # 343 + ;;;IGNORE # 344 + ;;;IGNORE # 345 + ;;;IGNORE # 346 + ;;;IGNORE # 347 + ;;;IGNORE # 348 + ;;;IGNORE # 349 + ;;;IGNORE # 350 F + ;;;IGNORE # 351 G + ;;;IGNORE # 352 + ;;;IGNORE # 353 > + ;;;IGNORE # 354 + ;;;IGNORE # 355 + ;;;IGNORE # 356 H + ;;;IGNORE # 357 > + ;;;IGNORE # 358 + ;;;IGNORE # 359 I + ;;;IGNORE # 360 + ;;;IGNORE # 361 + ;;;IGNORE # 362 + ;;;IGNORE # 363 + ;;;IGNORE # 364 + ;;;IGNORE # 365 + ;;;IGNORE # 366 + ;;;IGNORE # 367 + "";"";"";IGNORE # 368 + ;;;IGNORE # 369 J + ;;;IGNORE # 370 > + ;;;IGNORE # 371 K + ;;;IGNORE # 372 + ;;;IGNORE # 373 L + ;;;IGNORE # 374 + ;;;IGNORE # 375 + ;;;IGNORE # 376 + ;;;IGNORE # 377 + ;;;IGNORE # 378 + ;;;IGNORE # 379 M + ;;;IGNORE # 380 N + ;;;IGNORE # 381 + ;;;IGNORE # 382 + ;;;IGNORE # 383 + ;;;IGNORE # 384 + "";"";"";IGNORE # 385 + ;;;IGNORE # 386 O + ;;;IGNORE # 387 + ;;;IGNORE # 388 + ;;;IGNORE # 389 + ;;;IGNORE # 390 + ;;;IGNORE # 391 + ;;;IGNORE # 392 + ;;;IGNORE # 393 + ;;;IGNORE # 394 + "";"";"";IGNORE # 395 +

;;;IGNORE # 396 P + ;;;IGNORE # 397 Q + ;;;IGNORE # 398 R + ;;;IGNORE # 399 + ;;;IGNORE # 400 + ;;;IGNORE # 401 + ;;;IGNORE # 402 S + ;;;IGNORE # 403 + ;;;IGNORE # 404 > + ;;;IGNORE # 405 + ;;;IGNORE # 406 + ;;;IGNORE # 407 T + ;;;IGNORE # 408 + ;;;IGNORE # 409 + ;;;IGNORE # 410 + ;;;IGNORE # 412 U + ;;;IGNORE # 413 + ;;;IGNORE # 414 + ;;;IGNORE # 415 + ;;;IGNORE # 416 + ;;;IGNORE # 417 + ;;;IGNORE # 418 + ;;;IGNORE # 419 + ;;;IGNORE # 420 + ;;;IGNORE # 421 + ;;;IGNORE # 422 + ;;;IGNORE # 423 V + ;;;IGNORE # 424 W + ;;;IGNORE # 425 > + ;;;IGNORE # 426 X + ;;;IGNORE # 427 Y + ;;;IGNORE # 428 + ;;;IGNORE # 429 > + ;;;IGNORE # 430 + ;;;IGNORE # 431 Z + ;;;IGNORE # 432 + ;;;IGNORE # 433 + ;;;IGNORE # 434 + ;;;IGNORE # 411 + +order_start ;forward;forward;forward;forward,position + <0>;;;IGNORE + <0>;;;IGNORE + <1>;;;IGNORE + <1>;;;IGNORE + <2>;;;IGNORE + <2>;;;IGNORE + <3>;;;IGNORE + <3>;;;IGNORE + <4>;;;IGNORE + <4>;;;IGNORE + <5>;;;IGNORE + <5>;;;IGNORE + <6>;;;IGNORE + <6>;;;IGNORE + <7>;;;IGNORE + <7>;;;IGNORE + <8>;;;IGNORE + <8>;;;IGNORE + <9>;;;IGNORE + <9>;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +order_start ;backward;backward;backward;forward,position + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +order_start ;forward;forward;forward;forward,position + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + +order_start ;forward;backward;forward;forward,position + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # digamma copte + ;;;IGNORE + ;;;IGNORE # GANGIA COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # HORI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # koppa copte + ;;;IGNORE # KHEI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # STIGMA ARCH. + ;;;IGNORE # SHIMA COPTE + ;;;IGNORE + ;;;IGNORE # DEI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # FEI COPTE + ;;;IGNORE + ;;;IGNORE # sampi copte + ;;;IGNORE + ;;;IGNORE # SHEI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # gangia copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # hori copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # yot + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # khei copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # shima copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # dei copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # fei copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # shei copte + ;;;IGNORE + ;;;IGNORE + +order_start ;forward;forward;forward;forward,position + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +order_start ;forward;forward;forward;forward,position +UCLIBC_RANGE ..;IGNORE;IGNORE;IGNORE +# ;IGNORE;IGNORE;IGNORE +#.. ..;IGNORE;IGNORE;IGNORE +# ;IGNORE;IGNORE;IGNORE +# +order_end +# diff --git a/extra/locale/collation/it_CH b/extra/locale/collation/it_CH new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/it_CH @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/it_IT b/extra/locale/collation/it_IT new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/it_IT @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/iw_IL b/extra/locale/collation/iw_IL new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/iw_IL @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/ka_GE b/extra/locale/collation/ka_GE new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/ka_GE @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/kl_GL b/extra/locale/collation/kl_GL new file mode 100644 index 0000000..b7628e7 --- /dev/null +++ b/extra/locale/collation/kl_GL @@ -0,0 +1 @@ +copy "da_DK" diff --git a/extra/locale/collation/kw_GB b/extra/locale/collation/kw_GB new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/kw_GB @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/mi_NZ b/extra/locale/collation/mi_NZ new file mode 100644 index 0000000..c36305d --- /dev/null +++ b/extra/locale/collation/mi_NZ @@ -0,0 +1,44 @@ +copy "iso14651_t1" + +%% a b c d e f g h i j k l m n ng o p q r s t u v w wh x y z + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol + +reorder-after + +reorder-after + + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/mk_MK b/extra/locale/collation/mk_MK new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/mk_MK @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/mr_IN b/extra/locale/collation/mr_IN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/mr_IN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/ms_MY b/extra/locale/collation/ms_MY new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ms_MY @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/mt_MT b/extra/locale/collation/mt_MT new file mode 100644 index 0000000..bd028da --- /dev/null +++ b/extra/locale/collation/mt_MT @@ -0,0 +1,80 @@ + +% a b c c. d e f g. g gh/ h h/ i ie j k l m n o p q r s t u v w x y z. z + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol + +reorder-after + +reorder-after + + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/nl_BE b/extra/locale/collation/nl_BE new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/nl_BE @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/nl_NL b/extra/locale/collation/nl_NL new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/nl_NL @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/nn_NO b/extra/locale/collation/nn_NO new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/nn_NO @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/oc_FR b/extra/locale/collation/oc_FR new file mode 100644 index 0000000..d66184e --- /dev/null +++ b/extra/locale/collation/oc_FR @@ -0,0 +1 @@ +copy "en_DK" diff --git a/extra/locale/collation/pt_BR b/extra/locale/collation/pt_BR new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/pt_BR @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/pt_PT b/extra/locale/collation/pt_PT new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/pt_PT @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/ro_RO b/extra/locale/collation/ro_RO new file mode 100644 index 0000000..862db75 --- /dev/null +++ b/extra/locale/collation/ro_RO @@ -0,0 +1,54 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + +% a a> a( b c d e f g h i i> j k l m n o p q r s s, t t, u v w x y z + +collating-symbol > +collating-symbol +collating-symbol > +collating-symbol +collating-symbol + +reorder-after + + + +reorder-after +> + +reorder-after +> +reorder-after + +reorder-after + + +reorder-after + >;;;IGNORE + ;;;IGNORE +reorder-after + >;;;IGNORE + ;;;IGNORE + +reorder-after + >;;;IGNORE +reorder-after + >;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/ru_RU b/extra/locale/collation/ru_RU new file mode 100644 index 0000000..342a761 --- /dev/null +++ b/extra/locale/collation/ru_RU @@ -0,0 +1,15 @@ +copy "iso14651_t1" + +% iso14651_t1 is missing Ukrainian ghe +collating-symbol + +reorder-after + + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-end diff --git a/extra/locale/collation/ru_UA b/extra/locale/collation/ru_UA new file mode 100644 index 0000000..342a761 --- /dev/null +++ b/extra/locale/collation/ru_UA @@ -0,0 +1,15 @@ +copy "iso14651_t1" + +% iso14651_t1 is missing Ukrainian ghe +collating-symbol + +reorder-after + + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-end diff --git a/extra/locale/collation/se_NO b/extra/locale/collation/se_NO new file mode 100644 index 0000000..9718edc --- /dev/null +++ b/extra/locale/collation/se_NO @@ -0,0 +1,149 @@ +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +% +reorder-after + + +reorder-after + + + + + + +reorder-after + + + + + +reorder-after + + + +reorder-after + + +reorder-after + + + +reorder-after + + +reorder-after + + + +reorder-after + + + + + + +reorder-after + ;;;IGNORE % 201 + ;;;IGNORE % 200 + ;;;IGNORE % 202 + ;;;IGNORE % 203 + +reorder-after + ;;;IGNORE % 321 + ;;;IGNORE % 320 + ;;;IGNORE % 322 + ;;;IGNORE % 323 + +reorder-after + ;;;IGNORE % 212 + ;;;IGNORE % 215 + +reorder-after + ;;;IGNORE % 332 + ;;;IGNORE % 335 + +reorder-after + ;;;IGNORE % ezh + ;;;IGNORE % ezh caron + +reorder-after + ;;;IGNORE % EZH + ;;;IGNORE % EZH caron + +reorder-after + ;;;IGNORE % 218 + ;;;IGNORE % 220 + +reorder-after + ;;;IGNORE % 338 + ;;;IGNORE % 340 + +reorder-after + ;;;IGNORE % f WITH HOOK + +reorder-after + ;;;IGNORE % gcaron + ;;;IGNORE % gstroke + +reorder-after + ;;;IGNORE % Gcaron + ;;;IGNORE % Gstroke + +reorder-after + ;;;IGNORE % kcaron +reorder-after + ;;;IGNORE % Kcaron + +reorder-after + ;"";"";IGNORE % + ;;;IGNORE % 288 + ;;;IGNORE % 405 + + +reorder-after + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % +reorder-after + ;;;IGNORE % + ;;;IGNORE % + +reorder-after + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % +reorder-after + ;;;IGNORE % + ;;;IGNORE % + +% / is treated like y/Y but is sorted after the latter +reorder-after + ;;;IGNORE % +reorder-after + ;;;IGNORE % +reorder-end + diff --git a/extra/locale/collation/sk_SK b/extra/locale/collation/sk_SK new file mode 100644 index 0000000..245653c --- /dev/null +++ b/extra/locale/collation/sk_SK @@ -0,0 +1 @@ +copy "cs_CZ" diff --git a/extra/locale/collation/sq_AL b/extra/locale/collation/sq_AL new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/sq_AL @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/sr_YU b/extra/locale/collation/sr_YU new file mode 100644 index 0000000..1dcd15c --- /dev/null +++ b/extra/locale/collation/sr_YU @@ -0,0 +1,90 @@ +copy "iso14651_t1" + +% a b c c' c< d dz< d// e f g h i j k l lj m n nj o p +% q r s s< t u v w x y z z< + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-symbol + +reorder-after + +reorder-after + + +reorder-after + + + + + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end diff --git a/extra/locale/collation/sv_FI b/extra/locale/collation/sv_FI new file mode 100644 index 0000000..ab50386 --- /dev/null +++ b/extra/locale/collation/sv_FI @@ -0,0 +1 @@ +copy "fi_FI" diff --git a/extra/locale/collation/sv_SE b/extra/locale/collation/sv_SE new file mode 100644 index 0000000..2d299a4 --- /dev/null +++ b/extra/locale/collation/sv_SE @@ -0,0 +1,51 @@ +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +% is sorted after and etc. +reorder-after + + +reorder-after + + + + + +% The letter w is normally not present in the Swedish alphabet. It +% exists in some names in Swedish and foreign words, but is accounted +% for as a variant of 'v'. Words and names with 'w' are in Swedish +% ordered alphabetically among the words and names with 'v'. If two +% words or names are only to be distinguished by 'v' or % 'w', 'v' is +% placed before 'w'. +reorder-after + ;;; % W +reorder-after + ;;; % w + +reorder-after + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % +reorder-after + ;;;IGNORE % + ;;;IGNORE % + +reorder-after + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % +reorder-after + ;;;IGNORE % + ;;;IGNORE % + +% / is treated like y/Y but is sorted after the latter +reorder-after + ;;;IGNORE % +reorder-after + ;;;IGNORE % +reorder-end + diff --git a/extra/locale/collation/ta_IN b/extra/locale/collation/ta_IN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/ta_IN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/te_IN b/extra/locale/collation/te_IN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/te_IN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/tg_TJ b/extra/locale/collation/tg_TJ new file mode 100644 index 0000000..e2f01ae --- /dev/null +++ b/extra/locale/collation/tg_TJ @@ -0,0 +1,63 @@ + +% Tadjik cyrillic alphabet is: +% , , , , (cyr ghe with stroke), , , +% , , , , (cyr i with macron), , , +% (cyr k with descender), , , , , , , +% , , , (cyr u with macron), , , +% (cyr ha with descender), , (cyr che with descender), +% , (cyr hard sign), , , + +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/th_TH b/extra/locale/collation/th_TH new file mode 100644 index 0000000..6e3230f --- /dev/null +++ b/extra/locale/collation/th_TH @@ -0,0 +1,746 @@ + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +order_start forward;forward;forward;forward + +% definitions of extra collating symbols + + + + + + +UNDEFINED IGNORE;IGNORE;IGNORE;IGNORE + +% punctuation marks, ordered after ISO/IEC 14651 + IGNORE;IGNORE;;IGNORE % SPACE + IGNORE;IGNORE;;IGNORE % LOW LINE + IGNORE;IGNORE;;IGNORE % HYPHEN-MINUS + IGNORE;IGNORE;;IGNORE % COMMA + IGNORE;IGNORE;;IGNORE % SEMICOLON + IGNORE;IGNORE;;IGNORE % COLON + IGNORE;IGNORE;;IGNORE % EXCLAMATION MARK + IGNORE;IGNORE;;IGNORE % QUESTION MARK + IGNORE;IGNORE;;IGNORE % SOLIDUS + IGNORE;IGNORE;;IGNORE % FULL STOP + IGNORE;IGNORE;;IGNORE % THAI CHARACTER PAIYANNOI + IGNORE;IGNORE;;IGNORE % THAI CHARACTER MAIYAMOK + IGNORE;IGNORE;;IGNORE % GRAVE ACCENT + IGNORE;IGNORE;;IGNORE % CIRCUMFLEX + IGNORE;IGNORE;;IGNORE % TILDE + IGNORE;IGNORE;;IGNORE % APOSTROPHE + IGNORE;IGNORE;;IGNORE % QUOTATION MARK + IGNORE;IGNORE;;IGNORE % LEFT PAREN. + IGNORE;IGNORE;;IGNORE % LT BRACKET + IGNORE;IGNORE;;IGNORE % LEFT CURLY BRACKET + IGNORE;IGNORE;;IGNORE % RIGHT CURLY BRACKET + IGNORE;IGNORE;;IGNORE % RT BRACKET + IGNORE;IGNORE;;IGNORE % RIGHT PAREN. + IGNORE;IGNORE;;IGNORE % COMMERCIAL AT + IGNORE;IGNORE;;IGNORE % THAI CHARACTER SYMBOL BAHT + IGNORE;IGNORE;;IGNORE % DOLLAR SIGN + IGNORE;IGNORE;;IGNORE % THAI CHARACTER FONGMAN + IGNORE;IGNORE;;IGNORE % THAI CHARACTER ANGKHANKHU + IGNORE;IGNORE;;IGNORE % THAI CHARACTER KHOMUT + IGNORE;IGNORE;;IGNORE % ASTERISK + IGNORE;IGNORE;;IGNORE % BACK SOLIDUS + IGNORE;IGNORE;;IGNORE % AMPERSAND + IGNORE;IGNORE;;IGNORE % NUMBER SIGN + IGNORE;IGNORE;;IGNORE % PERCENT + IGNORE;IGNORE;;IGNORE % PLUS + IGNORE;IGNORE;;IGNORE % LESS THAN + IGNORE;IGNORE;;IGNORE % EQUAL + IGNORE;IGNORE;;IGNORE % GREATER THAN + IGNORE;IGNORE;;IGNORE % VERTICAL LINE + +% Thai tone marks and diacritics + IGNORE;;; % THAI CHARACTER YAMAKKAN + IGNORE;;; % THAI CHARACTER PINTHU + IGNORE;;; % THAI CHARACTER THANTHAKHAT + IGNORE;;; % THAI CHARACTER MAITAIKHU + IGNORE;;; % THAI CHARACTER MAI EK + IGNORE;;; % THAI CHARACTER MAI THO + IGNORE;;; % THAI CHARACTER MAI TRI + IGNORE;;; % THAI CHARACTER MAI CHATTAWA + +% Arabic and Thai decimal digits + ;;; % DIGIT ZERO + ;;; % THAI DIGIT ZERO + ;;; % DIGIT ONE + ;;; % THAI DIGIT ONE + ;;; % DIGIT TWO + ;;; % THAI DIGIT TWO + ;;; % DIGIT THREE + ;;; % THAI DIGIT THREE + ;;; % DIGIT FOUR + ;;; % THAI DIGIT FOUR + ;;; % DIGIT FIVE + ;;; % THAI DIGIT FIVE + ;;; % DIGIT SIX + ;;; % THAI DIGIT SIX + ;;; % DIGIT SEVEN + ;;; % THAI DIGIT SEVEN + ;;; % DIGIT EIGHT + ;;; % THAI DIGIT EIGHT + ;;; % DIGIT NINE + ;;; % THAI DIGIT NINE + +% Latin alphabet + ;;; % A + ;;; % a + ;;; % B + ;;; % b + ;;; % C + ;;; % c + ;;; % D + ;;; % d + ;;; % E + ;;; % e + ;;; % F + ;;; % f + ;;; % G + ;;; % g + ;;; % H + ;;; % h + ;;; % I + ;;; % i + ;;; % J + ;;; % j + ;;; % K + ;;; % k + ;;; % L + ;;; % l + ;;; % M + ;;; % m + ;;; % N + ;;; % n + ;;; % O + ;;; % o + ;;; % P + ;;; % p + ;;; % Q + ;;; % q + ;;; % R + ;;; % r + ;;; % S + ;;; % s + ;;; % T + ;;; % t + ;;; % U + ;;; % u + ;;; % V + ;;; % v + ;;; % W + ;;; % w + ;;; % X + ;;; % x + ;;; % Y + ;;; % y + ;;; % Z + ;;; % z + +% +% Thai consonants, with leading vowels rearrangement +% + ;;; % THAI CHARACTER KO KAI + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER KHO KHAI + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER KHO KHUAT + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER KHO KHWAI + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER KHO KHON + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER KHO RAKHANG + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER NGO NGU + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER CHO CHAN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER CHO CHING + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER CHO CHANG + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER SO SO + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER CHO CHOE + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER YO YING + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER DO CHADA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER TO PATAK + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER THO THAN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER THO NANGMONTHO + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER THO PHUTHAO + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER NO NEN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER DO DEK + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER TO TAO + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER THO THUNG + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER THO THAHAN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER THO THONG + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER NO NU + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER BO BAIMAI + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER PO PLA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER PHO PHUNG + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER FO FA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER PHO PHAN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER FO FAN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER PHO SAMPHAO + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER MO MA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER YO YAK + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER RO RUA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER RU + + ;;; % THAI CHARACTER LO LING + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER LU + + ;;; % THAI CHARACTER WO WAEN + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER SO SALA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER SO RUSI + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER SO SUA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER HO HIP + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER LO CHULA + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER O ANG + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER HO NOKHUK + "";;; + "";;; + "";;; + "";;; + "";;; + + ;;; % THAI CHARACTER NIKHAHIT + +% order of Thai vowels + ;;; % THAI CHARACTER SARA A + ;;; % THAI CHARACTER MAI HAN-AKAT + ;;; % THAI CHARACTER SARA AA + ;;; % THAI CHARACTER LAKKHANGYAO + ;;; % THAI CHARACTER SARA AM + ;;; % THAI CHARACTER SARA I + ;;; % THAI CHARACTER SARA II + ;;; % THAI CHARACTER SARA UE + ;;; % THAI CHARACTER SARA UEE + ;;; % THAI CHARACTER SARA U + ;;; % THAI CHARACTER SARA UU + ;;; % THAI CHARACTER SARA E + ;;; % THAI CHARACTER SARA AE + ;;; % THAI CHARACTER SARA O + ;;; % THAI CHARACTER SARA AI MAIMUAN + ;;; % THAI CHARACTER SARA AI MAIMALAI + +order_end + diff --git a/extra/locale/collation/ti_ER b/extra/locale/collation/ti_ER new file mode 100644 index 0000000..61b292b --- /dev/null +++ b/extra/locale/collation/ti_ER @@ -0,0 +1 @@ +copy "am_ET" diff --git a/extra/locale/collation/ti_ET b/extra/locale/collation/ti_ET new file mode 100644 index 0000000..61b292b --- /dev/null +++ b/extra/locale/collation/ti_ET @@ -0,0 +1 @@ +copy "am_ET" diff --git a/extra/locale/collation/tl_PH b/extra/locale/collation/tl_PH new file mode 100644 index 0000000..420168c --- /dev/null +++ b/extra/locale/collation/tl_PH @@ -0,0 +1,30 @@ +copy "iso14651_t1" + +%% a b c d e f g h i j k l m n ng o p q r s t u v w x y z + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol + +reorder-after + +reorder-after + + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/tt_RU b/extra/locale/collation/tt_RU new file mode 100644 index 0000000..1ca9685 --- /dev/null +++ b/extra/locale/collation/tt_RU @@ -0,0 +1,162 @@ + +% The new (2000) latin tatar alphabet is: +% a, sw, b, c, c,, d, e, f, g, g(, h, i (dotless i), +% i. (i with dot), j, k, q, l, m, n, ng, o, o--, p, r, s, s,, +% t, u, u:, v, w, x, y, z +% ,,,,,,,,,,, +% , , ,,,,,,, +% ,,,,,,,,,,???, ,, +% +% However, a commonly used alphabet in internet uses , and +% for respectively , and + +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + + + + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +% FIXME: check order of cyrillic letters (I copied from cyr Azeri) +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end + + diff --git a/extra/locale/collation/uk_UA b/extra/locale/collation/uk_UA new file mode 100644 index 0000000..342a761 --- /dev/null +++ b/extra/locale/collation/uk_UA @@ -0,0 +1,15 @@ +copy "iso14651_t1" + +% iso14651_t1 is missing Ukrainian ghe +collating-symbol + +reorder-after + + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-end diff --git a/extra/locale/collation/ur_PK b/extra/locale/collation/ur_PK new file mode 100644 index 0000000..d66184e --- /dev/null +++ b/extra/locale/collation/ur_PK @@ -0,0 +1 @@ +copy "en_DK" diff --git a/extra/locale/collation/uz_UZ b/extra/locale/collation/uz_UZ new file mode 100644 index 0000000..afdc7d4 --- /dev/null +++ b/extra/locale/collation/uz_UZ @@ -0,0 +1,28 @@ +copy "iso14651_t1" + +%% a b c d e f g g' h i j k l m n o o' p q r s t u v x y z +collating-symbol +collating-element from "" +collating-element from "" +collating-symbol +collating-element from "" +collating-element from "" + +reorder-after + + +reorder-after + + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE +reorder-after + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/vi_VN b/extra/locale/collation/vi_VN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/vi_VN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/wa_BE b/extra/locale/collation/wa_BE new file mode 100644 index 0000000..be8221c --- /dev/null +++ b/extra/locale/collation/wa_BE @@ -0,0 +1 @@ +copy "fr_BE" diff --git a/extra/locale/collation/yi_US b/extra/locale/collation/yi_US new file mode 100644 index 0000000..91de1b9 --- /dev/null +++ b/extra/locale/collation/yi_US @@ -0,0 +1,43 @@ +copy "iso14651_t1" + +collating-symbol +collating-element from "" +collating-symbol +collating-element from "" +collating-symbol +collating-element from "" +collating-symbol +collating-element from "" +collating-symbol +collating-element from "" +collating-symbol +collating-element from "" + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + + + +reorder-after + ;;;IGNORE +reorder-after + "";"";IGNORE;IGNORE + "";"";IGNORE;IGNORE +reorder-after + "";"";IGNORE;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c new file mode 100644 index 0000000..0a41a62 --- /dev/null +++ b/extra/locale/gen_collate.c @@ -0,0 +1,3940 @@ +/* TODO: + * + * add UNDEFINED at end if not specified + * convert POSITION -> FORWARD,POSITION + * + * + * deal with lowercase in + * + * what about reorders that keep the same rule? + * + * remove "unused" collation elements? (probably doesn't save much) + * + * add_rule function ... returns index into rule table after possibly adding custom-indexed rule + * but don't forget about multichar weights... replace with strings of indexes + * + */ + + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + char *name; /* */ + + int num_weights; /* */ + + int ii_shift; /* */ + int ti_shift; /* */ + int ii_len; /* */ + int ti_len; /* */ + int max_weight; /* */ + int num_col_base; /* */ + int max_col_index; /* */ + int undefined_idx; /* */ + int range_low; /* */ + int range_count; /* high - low */ + int range_base_weight; /* */ + int num_starters; /* */ + + int range_rule_offset; /* */ + int wcs2colidt_offset; /* */ + int index2weight_offset; /* */ + int index2ruleidx_offset; /* */ + int multistart_offset; /* */ + +} base_locale_t; + +#define BASE_LOCALE_LEN 20 +static base_locale_t base_locale_array[BASE_LOCALE_LEN]; +static size_t base_locale_len; + +typedef struct { + char *name; /* */ + + int base_idx; /* */ + + int undefined_idx; /* */ + + int overrides_offset; /* */ + int multistart_offset; /* */ +} der_locale_t; + +#define DER_LOCALE_LEN 300 +static der_locale_t der_locale_array[DER_LOCALE_LEN]; +static size_t der_locale_len; + + +#define OVERRIDE_LEN 50000 +static uint16_t override_buffer[OVERRIDE_LEN]; +static size_t override_len; + +#define MULTISTART_LEN 10000 +static uint16_t multistart_buffer[MULTISTART_LEN]; +static size_t multistart_len; + +#define WCS2COLIDT_LEN 200000 +static uint16_t wcs2colidt_buffer[WCS2COLIDT_LEN]; +static size_t wcs2colidt_len; + +#define INDEX2WEIGHT_LEN 200000 +static uint16_t index2weight_buffer[INDEX2WEIGHT_LEN]; +static size_t index2weight_len; + +static uint16_t index2ruleidx_buffer[INDEX2WEIGHT_LEN]; +static size_t index2ruleidx_len; + +#define WEIGHTSTR_LEN 10000 +static uint16_t weightstr_buffer[WEIGHTSTR_LEN]; +static size_t weightstr_len; + +#define RULETABLE_LEN (1L<<16) +static uint16_t ruletable_buffer[RULETABLE_LEN]; +static size_t ruletable_len; + + +#define RANGE (0x10000UL) + +typedef uint16_t tbl_item; + +static uint16_t u16_buf[10000]; +static int u16_buf_len; +static int u16_starter; + +typedef struct { + uint16_t ii_len; + uint16_t ti_len; + uint16_t ut_len; + + unsigned char ii_shift; + unsigned char ti_shift; + + tbl_item *ii; + tbl_item *ti; + tbl_item *ut; +} table_data; + + +static size_t newopt(tbl_item *ut, size_t usize, int shift, table_data *tbl); + + +#define MAX_COLLATION_WEIGHTS 4 + +#define MAX_FNO 1 +#define MAX_FILES (MAX_FNO + 1) + +static FILE *fstack[MAX_FILES]; +static char *fname[MAX_FILES]; +static int lineno[MAX_FILES]; +static int fno = -1; + +static tbl_item wcs2index[RANGE]; + +static char linebuf[1024]; +static char *pos; +static char *pos_e = NULL; +static char end_of_token = 0; /* slot to save */ + +#define IN_ORDER 0x01 +#define IN_REORDER 0x02 +#define IN_REORDER_SECTIONS 0x04 +static int order_state; +static int cur_num_weights; /* number of weights in current use */ +static char cur_rule[MAX_COLLATION_WEIGHTS]; + +static int anonsection = 0; + +typedef struct ll_item_struct ll_item_t; + +struct ll_item_struct { + ll_item_t *next; + ll_item_t *prev; + void *data; + int data_type; + int idx; +}; + +static ll_item_t *reorder_section_ptr = NULL; +static int superset; +static int superset_order_start_cnt; /* only support one order for now */ +static int superset_in_sync; +static ll_item_t *comm_cur_ptr; +static ll_item_t *comm_prev_ptr; + +enum { + R_FORWARD = 0x01, + R_POSITION = 0x02, + R_BACKWARD = 0x04 /* must be largest in value */ +}; + +typedef struct { + size_t num_weights; + char rule[MAX_COLLATION_WEIGHTS]; + const char *colitem[MAX_COLLATION_WEIGHTS]; +} weight_t; + +static void *root_weight = NULL; +size_t unique_weights = 0; + +typedef struct { + const char *symbol; + weight_t *weight; +} weighted_item_t; + +typedef struct { + const char *symbol1; + const char *symbol2; + int length; + weight_t *weight; +} range_item_t; + +typedef struct { + const char *name; + ll_item_t *itm_list; /* weighted_item_t list .. circular!!! */ + size_t num_items; + size_t num_rules; + char rules[MAX_COLLATION_WEIGHTS]; +} section_t; + +static section_t *cur_section = NULL; + +typedef struct { + const char *symbol; + ll_item_t *node; +} wi_index_t; + +typedef struct col_locale_struct col_locale_t; + +struct col_locale_struct { + char *name; + void *root_colitem; /* all base and derived, or just derived */ + void *root_element; + void *root_scripts; + void *root_wi_index; + void *root_wi_index_reordered; + ll_item_t *section_list; + col_locale_t *base_locale; /* null if this is a base */ + void *root_derived_wi; + ll_item_t *derived_list; + void *root_starter_char; + void *root_starter_all; + ll_item_t *undefined_idx; +}; + +typedef struct { + const char *symbol; + int idx; +} col_index_t; + +static void *root_col_locale = NULL; + +typedef struct { + const char *keyword; + void (*handler)(void); +} keyword_table_t; + +typedef struct { + const char *string; + const char *element; /* NULL if collating symbol */ +} colitem_t; + +static col_locale_t *cur_base = NULL; +static col_locale_t *cur_derived = NULL; +static col_locale_t *cur_col = NULL; + +static void *root_sym = NULL; +static size_t num_sym = 0; +static size_t mem_sym = 0; + +static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2))); +static void *xmalloc(size_t n); +static char *xsymdup(const char *s); /* only allocate once... store in a tree */ +static void pushfile(char *filename); +static void popfile(void); +static void processfile(void); +static int iscommentchar(int); +static void eatwhitespace(void); +static int next_line(void); +static char *next_token(void); +static void do_unrecognized(void); +static col_locale_t *new_col_locale(char *name); +static ll_item_t *new_ll_item(int data_type, void *data); +static weight_t *register_weight(weight_t *w); +static size_t ll_len(ll_item_t *l); +static size_t ll_count(ll_item_t *l, int mask); +static void add_wi_index(ll_item_t *l); +static size_t tnumnodes(const void *root); +static ll_item_t *find_wi_index(const char *sym, col_locale_t *cl); +static void mark_reordered(const char *sym); +static ll_item_t *find_wi_index_reordered(const char *sym); +static ll_item_t *next_comm_ptr(void); +static ll_item_t *init_comm_ptr(void); +static ll_item_t *find_ll_last(ll_item_t *p); +static void dump_weights(const char *name); +static void finalize_base(void); +static int is_ucode(const char *s); +static int sym_cmp(const void *n1, const void *n2); +static void do_starter_lists(col_locale_t *cl); +static void dump_base_locale(int n); +static void dump_der_locale(int n); +static void dump_collate(FILE *fp); + +enum { + DT_SECTION = 0x01, + DT_WEIGHTED = 0x02, + DT_REORDER = 0x04, /* a section to support reorder_after */ + DT_COL_LOCALE = 0x08, + DT_RANGE = 0x10, +}; + +static section_t *new_section(const char *name) +{ + section_t *p; + char buf[128]; + + p = xmalloc(sizeof(section_t)); + if (!name) { /* anonymous section */ + name = buf; + snprintf(buf, sizeof(buf), "anon%05d", anonsection); + ++anonsection; + } else if (*name != '<') { /* reorder */ + name = buf; + snprintf(buf, sizeof(buf), "%s %05d", cur_col->name, anonsection); + ++anonsection; + } +#warning devel code +/* fprintf(stderr, "section %s\n", name); */ + p->name = xsymdup(name); + p->itm_list = NULL; + p->num_items = 0; + p->num_rules = 0; + memset(p->rules, 0, MAX_COLLATION_WEIGHTS); +/* cur_num_weights = p->num_rules = 0; */ +/* memset(p->rules, 0, MAX_COLLATION_WEIGHTS); */ +/* memset(cur_rule, R_FORWARD, 4); */ + +#warning devel code + if (*p->name == 'a') { + cur_num_weights = p->num_rules = 4; + memset(p->rules, R_FORWARD, 4); + memset(cur_rule, R_FORWARD, 4); + p->rules[3] |= R_POSITION; + cur_rule[3] |= R_POSITION; + } +/* fprintf(stderr, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */ + + return p; +} + + + +static void do_order_start(void); +static void do_order_end(void); +static void do_reorder_after(void); +static void do_reorder_end(void); +static void do_reorder_sections_after(void); +static void do_reorder_sections_end(void); +static void do_copy(void); +static void do_colsym(void); +static void do_colele(void); +static void do_script(void); +static void do_range(void); + +static col_locale_t *new_col_locale(char *name); +static int colitem_cmp(const void *n1, const void *n2); +static int colelement_cmp(const void *n1, const void *n2); +static void del_colitem(colitem_t *p); +static colitem_t *new_colitem(char *item, char *def); +static void add_colitem(char *item, char *def); +static void add_script(const char *s); +static unsigned int add_rule(weighted_item_t *wi); +static unsigned int add_range_rule(range_item_t *ri); + +static const keyword_table_t keyword_table[] = { + { "collating-symbol", do_colsym }, + { "collating-element", do_colele }, + { "script", do_script }, + { "copy", do_copy }, + { "order_start", do_order_start }, + { "order_end", do_order_end }, + { "order-end", do_order_end }, + { "reorder-after", do_reorder_after }, + { "reorder-end", do_reorder_end }, + { "reorder-sections-after", do_reorder_sections_after }, + { "reorder-sections-end", do_reorder_sections_end }, + { "UCLIBC_RANGE", do_range }, + { NULL, do_unrecognized } +}; + + +static void do_unrecognized(void) +{ +#if 1 + error_msg("warning: unrecognized: %s", pos); +#else +/* fprintf(stderr, "warning: unrecognized initial keyword \"%s\"\n", pos); */ + fprintf(stderr, "warning: unrecognized: %s", pos); + if (end_of_token) { + fprintf(stderr, "%c%s", end_of_token, pos_e+1); + } + fprintf(stderr, "\n"); +#endif +} + +/* typedef struct { */ +/* const char *symbol1; */ +/* const char *symbol2; */ +/* int length; */ +/* weight_t *weight; */ +/* } range_item_t; */ + +static void do_range(void) +{ + range_item_t *ri; + weight_t w; + int i; + char *s; + char *s1; + char *s2; + const char **ci; + ll_item_t *lli; + + assert(!superset); + assert(order_state == IN_ORDER); + + s1 = next_token(); + if (!s1) { + error_msg("missing start of range"); + } + if (!is_ucode(s1)) { + error_msg("start of range is not a ucode: %s", s1); + } + s1 = xsymdup(s1); + + s2 = next_token(); + if (!s2) { + error_msg("missing end of range"); + } + if (!is_ucode(s2)) { + error_msg("end of range is not a ucode: %s", s2); + } + s2 = xsymdup(s2); + + ri = (range_item_t *) xmalloc(sizeof(range_item_t)); + ri->symbol1 = s1; + ri->symbol2 = s2; + ri->length = strtoul(s2+2, NULL, 16) - strtoul(s1+2, NULL, 16); + if (ri->length <= 0) { + error_msg("illegal range length %d", ri->length); + } + + s = next_token(); + w.num_weights = cur_num_weights; + + for (i=0 ; i < cur_num_weights ; i++) { + w.rule[i] = cur_rule[i]; + } + ci = w.colitem + (i-1); + /* now i == cur_num_weights */ + +#define STR_DITTO "." + + while (s && *s && i) { + --i; + if (*s == ';') { + ci[-i] = xsymdup(STR_DITTO); + if (*++s) { + continue; + } + } + if (*s) { + ci[-i] = xsymdup(s); + } + s = next_token(); + if (s) { + if (*s == ';') { + ++s; + } else if (i) { + error_msg("missing seperator"); + } + } + } + if (s) { + error_msg("too many weights: %d %d |%s| %d", cur_num_weights, i, s, (int)*s); + } + + while (i) { /* missing weights are not an error */ + --i; + ci[-i] = xsymdup(STR_DITTO); + } + + ri->weight = register_weight(&w); + +/* if ((i = is_ucode(t)) != 0) { */ +/* assert(!t[i]); */ +/* add_colitem(t, NULL); */ +/* } */ + + lli = new_ll_item(DT_RANGE, ri); + if (!cur_section->itm_list) { +/* printf("creating new item list: %s\n", wi->symbol); */ + cur_section->itm_list = lli; + lli->prev = lli->next = lli; + ++cur_section->num_items; + } else { + insque(lli, cur_section->itm_list->prev); +/* printf("adding item to list: %d - %s\n", ll_len(cur_section->itm_list), wi->symbol); */ + ++cur_section->num_items; + } +/* add_wi_index(lli); */ + + +} + +static weighted_item_t *add_weight(char *t) +{ + weighted_item_t *wi; + weight_t w; + int i; + char *s; + const char **ci; + + t = xsymdup(t); + + s = next_token(); + w.num_weights = cur_num_weights; + + for (i=0 ; i < cur_num_weights ; i++) { + w.rule[i] = cur_rule[i]; + } + ci = w.colitem + (i-1); + /* now i == cur_num_weights */ + + while (s && *s && i) { + --i; + if (*s == ';') { + ci[-i] = xsymdup(STR_DITTO); + if (*++s) { + continue; + } + } + if (*s) { + if (!strcmp(s,t)) { + s = STR_DITTO; + } + ci[-i] = xsymdup(s); + } + s = next_token(); + if (s) { + if (*s == ';') { + ++s; + } else if (i) { + error_msg("missing seperator"); + } + } + } + if (s) { + error_msg("too many weights: %d %d |%s| %d", cur_num_weights, i, s, (int)*s); + } + + while (i) { /* missing weights are not an error */ + --i; + ci[-i] = xsymdup(STR_DITTO); + } + + wi = xmalloc(sizeof(weighted_item_t)); + wi->symbol = t; + wi->weight = register_weight(&w); + + if ((i = is_ucode(t)) != 0) { + assert(!t[i]); + add_colitem(t, NULL); + } + + return wi; +} + +static void add_superset_weight(char *t) +{ + ll_item_t *lli; + weighted_item_t *wi; + + if (!comm_cur_ptr + || (strcmp(t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol) != 0) + ) { /* now out of sync */ + if (superset_in_sync) { /* need a new section */ + superset_in_sync = 0; + + cur_section = new_section("R"); + cur_num_weights = cur_section->num_rules + = ((section_t *)(cur_base->section_list->data))->num_rules; + memcpy(cur_rule, + ((section_t *)(cur_base->section_list->data))->rules, + MAX_COLLATION_WEIGHTS); + memcpy(cur_section->rules, + ((section_t *)(cur_base->section_list->data))->rules, + MAX_COLLATION_WEIGHTS); + + insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list)); + assert(comm_prev_ptr); + lli = new_ll_item(DT_REORDER, cur_section); + lli->prev = lli->next = lli; + insque(lli, comm_prev_ptr); +/* fprintf(stderr, " subsection -----------------------\n"); */ + } + +/* fprintf(stderr, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */ + wi = add_weight(t); + lli = new_ll_item(DT_WEIGHTED, wi); + mark_reordered(wi->symbol); + /* printf("reorder: %s\n", t); */ + if (!cur_section->itm_list) { + cur_section->itm_list = lli; + lli->prev = lli->next = lli; + ++cur_section->num_items; + } else { + insque(lli, cur_section->itm_list->prev); + ++cur_section->num_items; + } + add_wi_index(lli); + + } else { /* in sync */ + superset_in_sync = 1; + next_comm_ptr(); + } +} + +static void do_weight(char *t) +{ + weighted_item_t *wi; + ll_item_t *lli; + + if (superset) { + add_superset_weight(t); + return; + } + + switch(order_state) { + case 0: +/* fprintf(stdout, "no-order weight: %s\n", t); */ +/* break; */ + case IN_ORDER: + /* in a section */ +/* fprintf(stdout, "weight: %s\n", t); */ + wi = add_weight(t); + lli = new_ll_item(DT_WEIGHTED, wi); + if (!cur_section->itm_list) { +/* fprintf(stdout, "creating new item list: %s %s %p\n", wi->symbol, cur_section->name, lli); */ + cur_section->itm_list = lli; + lli->prev = lli->next = lli; + ++cur_section->num_items; + } else { + insque(lli, cur_section->itm_list->prev); +/* fprintf(stdout, "adding item to list: %d - %s %p\n", ll_len(cur_section->itm_list), wi->symbol, lli); */ + ++cur_section->num_items; + } + add_wi_index(lli); + break; + case IN_REORDER: + /* std rule - but in a block with an insert-after pt */ + wi = add_weight(t); + lli = new_ll_item(DT_WEIGHTED, wi); + mark_reordered(wi->symbol); +/* fprintf(stdout, "reorder: %s %s %p\n", t, cur_section->name, lli); */ + if (!cur_section->itm_list) { + cur_section->itm_list = lli; + lli->prev = lli->next = lli; + ++cur_section->num_items; + } else { + insque(lli, cur_section->itm_list->prev); + ++cur_section->num_items; + } + add_wi_index(lli); + break; + case IN_REORDER_SECTIONS: + t = xsymdup(t); + if (next_token() != NULL) { + error_msg("trailing text in reorder section item: %s", pos); + } + lli = cur_col->section_list; + do { + if (lli->data_type & DT_SECTION) { + if (!strcmp(((section_t *)(lli->data))->name, t)) { + lli->data_type = DT_REORDER; + lli = new_ll_item(DT_REORDER, (section_t *)(lli->data)); + insque(lli, reorder_section_ptr); + reorder_section_ptr = lli; + return; + } + } + lli = lli->next; + } while (lli); + error_msg("reorder_sections_after for non-base item currently not supported: %s", t); +/* fprintf(stdout, "reorder_secitons: %s\n", t); */ + break; + default: + error_msg("invalid order_state %d", order_state); + } +} + +static int col_locale_cmp(const void *n1, const void *n2) +{ + return strcmp(((const col_locale_t *) n1)->name, ((const col_locale_t *) n2)->name); +} + +static void processfile(void) +{ + char *t; + const keyword_table_t *k; + + order_state = 0; +#warning devel code +/* cur_num_weights = 0; */ +/* cur_num_weights = 4; */ +/* memset(cur_rule, R_FORWARD, 4); */ + + if (cur_col != cur_base) { + cur_col->base_locale = cur_base; + cur_col->undefined_idx = cur_base->undefined_idx; + if (!cur_base->derived_list) { + cur_base->derived_list = new_ll_item(DT_COL_LOCALE, cur_col); + } else { + insque(new_ll_item(DT_COL_LOCALE, cur_col), find_ll_last(cur_base->derived_list)); + } + } + + if (tfind(cur_col, &root_col_locale, col_locale_cmp)) { + error_msg("attempt to read locale: %s", cur_col->name); + } + if (!tsearch(cur_col, &root_col_locale, col_locale_cmp)) { + error_msg("OUT OF MEMORY!"); + } + + if (superset) { + superset_order_start_cnt = 0; + superset_in_sync = 0; + init_comm_ptr(); + } + + while (next_line()) { +/* printf("%5d:", lineno[fno]); */ +/* while ((t = next_token()) != NULL) { */ +/* printf(" |%s|", t); */ +/* printf("\n"); */ +/* } */ + t = next_token(); + assert(t); + assert(t == pos); + if ((*t == '<') || (!strcmp(t, "UNDEFINED"))) { + do_weight(t); + } else { + for (k = keyword_table ; k->keyword ; k++) { + if (!strcmp(k->keyword, t)) { + break; + } + } + k->handler(); + } + } + + if (cur_base == cur_col) { + fprintf(stderr, "Base: %15s", cur_col->name); + } else { +#if 1 + if (!cur_col->undefined_idx) { +#if 0 + if (superset) { + if (superset_order_start_cnt == 1) { + --superset_order_start_cnt; /* ugh.. hack this */ + } + } +#endif + /* This is an awful hack to get around the problem of unspecified UNDEFINED + * definitions in the supported locales derived from iso14651_t1. */ + if (!strcmp(cur_base->name, "iso14651_t1")) { + fprintf(stderr, "Warning: adding UNDEFINED entry for %s\n", cur_col->name); + strcpy(linebuf, "script \n"); + pos_e = NULL; + pos = linebuf; + t = next_token(); + assert(t); + assert(t == pos); + do_script(); + strcpy(linebuf, "order_start ;forward;backward;forward;forward,position\n"); + pos_e = NULL; + pos = linebuf; + t = next_token(); + assert(t); + assert(t == pos); + do_order_start(); + strcpy(linebuf, "UNDEFINED IGNORE;IGNORE;IGNORE\n"); + pos_e = NULL; + pos = linebuf; + t = next_token(); + assert(t); + assert(t == pos); + do_weight(t); + strcpy(linebuf, "order_end\n"); + pos_e = NULL; + pos = linebuf; + t = next_token(); + assert(t); + assert(t == pos); + do_order_end(); + } else { + error_msg("no definition of UNDEFINED for %s", cur_col->name); + } + } +#endif + + fprintf(stderr, " Der: %15s", cur_col->name); + } + { + ll_item_t *p = cur_col->section_list; + + fprintf(stderr, "%6u weights", tnumnodes(cur_col->root_wi_index)); + if (cur_base) { + fprintf(stderr, " %6u der %6u reor %6u starter - %u new stubs", + tnumnodes(cur_base->root_derived_wi), + tnumnodes(cur_base->root_wi_index_reordered), + tnumnodes(cur_base->root_starter_char), + ll_count(cur_col->section_list, DT_REORDER)); + } + fprintf(stderr, "\n"); + +#if 0 + while (p) { + assert(((section_t *)(p->data))->num_items == + ll_len(((section_t *)(p->data))->itm_list)); + + + if (!p->next && + ((*((section_t *)(p->data))->name == 'a') + && (((section_t *)(p->data))->num_items == 0)) + ) { + break; + } + + if (!(p->data_type & DT_REORDER)) { + if ((*((section_t *)(p->data))->name != 'a') + || (((section_t *)(p->data))->num_items > 0) + ) { + fprintf(stderr, +/* "\t%-15s %zu\n", */ + "\t%-15s %6u\n", + ((section_t *)(p->data))->name, + ((section_t *)(p->data))->num_items); + } + } + p = p->next; + } +#endif + } + + +} + +static void print_colnode(const void *ptr, VISIT order, int level) +{ + const colitem_t *p = *(const colitem_t **) ptr; + + if (order == postorder || order == leaf) { + printf("collating item = \"%s\"", p->string); + if (p->element) { + printf(" is %s", p->element); + } + printf("\n"); + } +} + +static void print_weight_node(const void *ptr, VISIT order, int level) +{ + const weight_t *p = *(const weight_t **) ptr; + int i; + + if (order == postorder || order == leaf) { + printf("weight: (%d) ", p->num_weights); + for (i = 0 ; i < p->num_weights ; i++) { + if (p->rule[i] & R_FORWARD) { + printf("F"); + } + if (p->rule[i] & R_BACKWARD) { + printf("B"); + } + if (p->rule[i] & R_POSITION) { + printf("P"); + } + printf(","); + } + for (i = 0 ; i < p->num_weights ; i++) { + printf(" %s", p->colitem[i]); + } + printf("\n"); + } +} + + +typedef struct { + const char *der_name; + int base_locale; +} deps_t; + +enum { + BASE_iso14651_t1, + BASE_comm, + BASE_cs_CZ, + BASE_ar_SA, + BASE_th_TH, + BASE_ja_JP, + BASE_ko_KR, + BASE_MAX +}; + +static const char *base_name[] = { + "iso14651_t1", + "comm", + "cs_CZ", + "ar_SA", + "th_TH", + "ja_JP", + "ko_KR" +}; + + + +static ll_item_t *locale_list[BASE_MAX]; + +static void init_locale_list(void) +{ + int i; + + for (i=0 ; i < BASE_MAX ; i++) { + locale_list[i] = (ll_item_t *) xmalloc(sizeof(ll_item_t)); + locale_list[i]->prev = locale_list[i]->next = locale_list[i]; + locale_list[i]->data = (void *) base_name[i]; + } +} + + +deps_t deps[] = { + { "af_ZA", BASE_iso14651_t1 }, + { "am_ET", BASE_iso14651_t1 }, + { "ar_AE", BASE_iso14651_t1 }, + { "ar_BH", BASE_iso14651_t1 }, + { "ar_DZ", BASE_iso14651_t1 }, + { "ar_EG", BASE_iso14651_t1 }, + { "ar_IN", BASE_iso14651_t1 }, + { "ar_IQ", BASE_iso14651_t1 }, + { "ar_JO", BASE_iso14651_t1 }, + { "ar_KW", BASE_iso14651_t1 }, + { "ar_LB", BASE_iso14651_t1 }, + { "ar_LY", BASE_iso14651_t1 }, + { "ar_MA", BASE_iso14651_t1 }, + { "ar_OM", BASE_iso14651_t1 }, + { "ar_QA", BASE_iso14651_t1 }, + { "ar_SA", BASE_ar_SA }, + { "ar_SD", BASE_iso14651_t1 }, + { "ar_SY", BASE_iso14651_t1 }, + { "ar_TN", BASE_iso14651_t1 }, + { "ar_YE", BASE_iso14651_t1 }, + { "az_AZ", BASE_iso14651_t1 }, + { "be_BY", BASE_iso14651_t1 }, + { "bg_BG", BASE_iso14651_t1 }, + { "bn_BD", BASE_iso14651_t1 }, + { "bn_IN", BASE_iso14651_t1 }, + { "br_FR", BASE_iso14651_t1 }, + { "bs_BA", BASE_iso14651_t1 }, + { "ca_ES", BASE_comm }, + { "cs_CZ", BASE_cs_CZ }, + { "cy_GB", BASE_iso14651_t1 }, + { "da_DK", BASE_comm }, + { "de_AT", BASE_iso14651_t1 }, + { "de_BE", BASE_iso14651_t1 }, + { "de_CH", BASE_iso14651_t1 }, + { "de_DE", BASE_iso14651_t1 }, + { "de_LU", BASE_iso14651_t1 }, + { "el_GR", BASE_iso14651_t1 }, + { "en_AU", BASE_iso14651_t1 }, + { "en_BW", BASE_iso14651_t1 }, + { "en_CA", BASE_comm }, + { "en_DK", BASE_iso14651_t1 }, + { "en_GB", BASE_iso14651_t1 }, + { "en_HK", BASE_iso14651_t1 }, + { "en_IE", BASE_iso14651_t1 }, + { "en_IN", BASE_iso14651_t1 }, + { "en_NZ", BASE_iso14651_t1 }, + { "en_PH", BASE_iso14651_t1 }, + { "en_SG", BASE_iso14651_t1 }, + { "en_US", BASE_iso14651_t1 }, + { "en_ZA", BASE_iso14651_t1 }, + { "en_ZW", BASE_iso14651_t1 }, + { "eo_EO", BASE_iso14651_t1 }, + { "es_AR", BASE_comm }, + { "es_BO", BASE_comm }, + { "es_CL", BASE_comm }, + { "es_CO", BASE_comm }, + { "es_CR", BASE_comm }, + { "es_DO", BASE_comm }, + { "es_EC", BASE_comm }, + { "es_ES", BASE_comm }, + { "es_GT", BASE_comm }, + { "es_HN", BASE_comm }, + { "es_MX", BASE_comm }, + { "es_NI", BASE_comm }, + { "es_PA", BASE_comm }, + { "es_PE", BASE_comm }, + { "es_PR", BASE_comm }, + { "es_PY", BASE_comm }, + { "es_SV", BASE_comm }, + { "es_US", BASE_comm }, + { "es_UY", BASE_comm }, + { "es_VE", BASE_comm }, + { "et_EE", BASE_comm }, + { "eu_ES", BASE_iso14651_t1 }, + { "fa_IR", BASE_iso14651_t1 }, + { "fi_FI", BASE_comm }, + { "fo_FO", BASE_comm }, + { "fr_BE", BASE_iso14651_t1 }, + { "fr_CA", BASE_comm }, + { "fr_CH", BASE_iso14651_t1 }, + { "fr_FR", BASE_iso14651_t1 }, + { "fr_LU", BASE_iso14651_t1 }, + { "ga_IE", BASE_iso14651_t1 }, + { "gd_GB", BASE_iso14651_t1 }, + { "gl_ES", BASE_comm }, + { "gv_GB", BASE_iso14651_t1 }, + { "he_IL", BASE_iso14651_t1 }, + { "hi_IN", BASE_iso14651_t1 }, + { "hr_HR", BASE_comm }, + { "hu_HU", BASE_iso14651_t1 }, + { "hy_AM", BASE_iso14651_t1 }, + { "id_ID", BASE_iso14651_t1 }, + { "is_IS", BASE_comm }, + { "it_CH", BASE_iso14651_t1 }, + { "it_IT", BASE_iso14651_t1 }, + { "iw_IL", BASE_iso14651_t1 }, + { "ja_JP", BASE_ja_JP }, + { "ka_GE", BASE_iso14651_t1 }, + { "kl_GL", BASE_comm }, + { "ko_KR", BASE_ko_KR }, + { "kw_GB", BASE_iso14651_t1 }, + { "lt_LT", BASE_comm }, + { "lv_LV", BASE_comm }, + { "mi_NZ", BASE_iso14651_t1 }, + { "mk_MK", BASE_iso14651_t1 }, + { "mr_IN", BASE_iso14651_t1 }, + { "ms_MY", BASE_iso14651_t1 }, + { "mt_MT", BASE_iso14651_t1 }, + { "nl_BE", BASE_iso14651_t1 }, + { "nl_NL", BASE_iso14651_t1 }, + { "nn_NO", BASE_iso14651_t1 }, + { "no_NO", BASE_comm }, + { "oc_FR", BASE_iso14651_t1 }, + { "pl_PL", BASE_comm }, + { "pt_BR", BASE_iso14651_t1 }, + { "pt_PT", BASE_iso14651_t1 }, + { "ro_RO", BASE_iso14651_t1 }, + { "ru_RU", BASE_iso14651_t1 }, + { "ru_UA", BASE_iso14651_t1 }, + { "se_NO", BASE_iso14651_t1 }, + { "sk_SK", BASE_cs_CZ }, + { "sl_SI", BASE_comm }, + { "sq_AL", BASE_iso14651_t1 }, + { "sr_YU", BASE_iso14651_t1 }, + { "sv_FI", BASE_comm }, + { "sv_SE", BASE_iso14651_t1 }, + { "ta_IN", BASE_iso14651_t1 }, + { "te_IN", BASE_iso14651_t1 }, + { "tg_TJ", BASE_iso14651_t1 }, + { "th_TH", BASE_th_TH }, + { "ti_ER", BASE_iso14651_t1 }, + { "ti_ET", BASE_iso14651_t1 }, + { "tl_PH", BASE_iso14651_t1 }, + { "tr_TR", BASE_comm }, + { "tt_RU", BASE_iso14651_t1 }, + { "uk_UA", BASE_iso14651_t1 }, + { "ur_PK", BASE_iso14651_t1 }, + { "uz_UZ", BASE_iso14651_t1 }, + { "vi_VN", BASE_iso14651_t1 }, + { "wa_BE", BASE_iso14651_t1 }, + { "yi_US", BASE_iso14651_t1 }, + { "zh_CN", BASE_iso14651_t1 }, + { "zh_HK", BASE_iso14651_t1 }, + { "zh_SG", BASE_iso14651_t1 }, + { "zh_TW", BASE_iso14651_t1 }, +}; + + +static int der_count[BASE_MAX]; +static const char *new_args[500]; +static int new_arg_count; + +static int dep_cmp(const void *s1, const void *s2) +{ + return strcmp( (const char *) s1, ((const deps_t *) s2)->der_name); +} + +static int old_main(int argc, char **argv); + +int main(int argc, char **argv) +{ + const deps_t *p; + ll_item_t *lli; + int i; + int total; + + if (argc < 2) { + return EXIT_FAILURE; + } + + init_locale_list(); + + while (--argc) { + p = (const deps_t *) bsearch(*++argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp); + if (!p) { + if (!strcmp("C", *argv)) { + printf("ignoring C locale\n"); + continue; + } else { + printf("%s not found\n", *argv); + return EXIT_FAILURE; + } + } + + i = p->base_locale; + ++der_count[i]; + + if (!strcmp(base_name[i], *argv)) { + /* same name as base, so skip after count incremented */ + continue; + } + + /* add it to the list. the main body will catch duplicates */ + lli = (ll_item_t *) xmalloc(sizeof(ll_item_t)); + lli->prev = lli->next = NULL; + lli->data = (void *) *argv; + insque(lli, locale_list[i]); + } + + total = 0; + for (i=0 ; i < BASE_MAX ; i++) { +/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */ + total += der_count[i]; + } +/* printf("total = %d\n", total); */ + + new_args[new_arg_count++] = "dummyprogramname"; + for (i=0 ; i < BASE_MAX ; i++) { + if (!der_count[i]) { + continue; + } + new_args[new_arg_count++] = (i == BASE_comm) ? "-c" : "-b"; + lli = locale_list[i]; + do { + new_args[new_arg_count++] = (const char *) (lli->data); + lli = lli->next; + } while (lli != locale_list[i]); + new_args[new_arg_count++] = "-f"; + } + +/* for (i=0 ; i < new_arg_count ; i++) { */ +/* printf("%3d: %s\n", i, new_args[i]); */ +/* } */ + + return old_main(new_arg_count, (char **) new_args); +} + + +/* usage... prog -b basefile derived {derived} -s single {single} */ + +static int old_main(int argc, char **argv) +{ + int next_is_base = 0; + int next_is_subset = 0; + + superset = 0; + + while (--argc) { + ++argv; + if (**argv == '-') { + if ((*argv)[1] == 'd') { + dump_weights((*argv) + 2); + } else if ((*argv)[1] == 'f') { /* dump all weight rules */ + finalize_base(); + } else if ((*argv)[1] == 'R') { /* dump all weight rules */ + twalk(root_weight, print_weight_node); + } else if (((*argv)[1] == 'c') && !(*argv)[2]) { /* new common subset */ + cur_base = cur_derived = NULL; + next_is_subset = 1; + next_is_base = 1; + superset = 0; + } else if (((*argv)[1] == 'b') && !(*argv)[2]) { /* new base locale */ + cur_base = cur_derived = NULL; + next_is_subset = 0; + next_is_base = 1; + superset = 0; + } else if (((*argv)[1] == 's') && !(*argv)[2]) { /* single locales follow */ + cur_base = cur_derived = NULL; + next_is_subset = 0; + next_is_base = 2; + superset = 0; + } else { + error_msg("unrecognized option %s", *argv); + } + continue; + } + /* new file */ + new_col_locale(*argv); /* automaticly sets cur_col */ + if (next_is_base) { + cur_base = cur_col; + } else { + cur_derived = cur_col; + } + pushfile(*argv); +/* fprintf(stderr, "processing file %s\n", *argv); */ + processfile(); /* this does a popfile */ + +/* twalk(cur_col->root_colitem, print_colnode); */ + + if (next_is_base == 1) { + next_is_base = 0; + } + if (next_is_subset) { + next_is_subset = 0; + superset = 1; + } + } + + fprintf(stderr, "success!\n"); + fprintf(stderr, +/* "num_sym=%zu mem_sym=%zu unique_weights=%zu\n", */ + "num_sym=%u mem_sym=%u unique_weights=%u\n", + num_sym, mem_sym, unique_weights); +/* twalk(root_weight, print_weight_node); */ + + fprintf(stderr, "num base locales = %d num derived locales = %d\n", + base_locale_len, der_locale_len); + + fprintf(stderr, + "override_len = %d multistart_len = %d weightstr_len = %d\n" + "wcs2colidt_len = %d index2weight_len = %d index2ruleidx_len = %d\n" + "ruletable_len = %d\n" + "total size is %d bytes or %d kB\n", + override_len, multistart_len, weightstr_len, + wcs2colidt_len, index2weight_len, index2ruleidx_len, + ruletable_len, +#warning mult by 2 for rule indecies + (override_len + multistart_len + weightstr_len + + wcs2colidt_len + index2weight_len + index2ruleidx_len + ruletable_len) * 2, + (override_len + multistart_len + weightstr_len + + wcs2colidt_len + index2weight_len + index2ruleidx_len + ruletable_len + 511) / 512); + +#if 0 + { + int i; + + for (i=0 ; i < base_locale_len ; i++) { + dump_base_locale(i); + } + for (i=0 ; i < der_locale_len ; i++) { + dump_der_locale(i); + } + } +#endif + + { + FILE *fp = fopen("locale_collate.h", "w"); + + if (!fp) { + error_msg("couldn't open output file!"); + } + dump_collate(fp); + if (ferror(fp) || fclose(fp)) { + error_msg("write error or close error for output file!\n"); + } + } + + return EXIT_SUCCESS; +} + +static void error_msg(const char *fmt, ...) +{ + va_list arg; + + fprintf(stderr, "Error: "); + if (fno >= 0) { + fprintf(stderr, "file %s (%d): ", fname[fno], lineno[fno]); + } + va_start(arg, fmt); + vfprintf(stderr, fmt, arg); + va_end(arg); + fprintf(stderr, "\n"); + + exit(EXIT_FAILURE); +} + +static void pushfile(char *filename) +{ + static char fbuf[PATH_MAX]; + + snprintf(fbuf, PATH_MAX, "collation/%s", filename); + + if (fno >= MAX_FNO) { + error_msg("file stack size exceeded"); + } + + if (!(fstack[++fno] = fopen(fbuf, "r"))) { + --fno; /* oops */ + error_msg("cannot open file %s", fbuf); + } + + fname[fno] = xsymdup(filename); + lineno[fno] = 0; +} + +static void popfile(void) +{ + if (fno < 0) { + error_msg("pop on empty file stack"); + } + +/* free(fname[fno]); */ + fclose(fstack[fno]); + --fno; +} + +static void eatwhitespace(void) +{ + while (isspace(*pos)) { + ++pos; + } +} + +static int iscommentchar(int c) +{ + return ((c == '#') || (c == '%')); +} + +static int next_line(void) +{ + size_t n; + char *s = linebuf; + + assert(fno >= 0); + + pos_e = NULL; + do { + if (fgets(s, sizeof(linebuf), fstack[fno]) != NULL) { + ++lineno[fno]; + n = strlen(linebuf); + if ((n == sizeof(linebuf) - 1) && (linebuf[n-1] != '\n')) { + /* Either line is too long or last line is very long with + * no trailing newline. But we'll always treat it as an + * errro. */ + error_msg("line too long?"); + } + + --n; + /* Be careful... last line doesn't need a newline. */ + if (linebuf[n] == '\n') { + linebuf[n--] = 0; /* trim trailing newline */ + } + + pos = linebuf; + eatwhitespace(); + if (*pos && !iscommentchar(*pos)) { /* not empty or comment line */ + return 1; /* got a line */ + } + } else { /* eof */ + popfile(); + } + } while (fno >= 0); + + return 0; +} + +static char *next_token(void) +{ + char *p; + +#if 0 + if (pos_e == NULL) { + return NULL + pos = pos_e; + *pos = end_of_token; + end_of_token = 0; + } +#else + if (pos_e != NULL) { + pos = pos_e; + *pos = end_of_token; + end_of_token = 0; + } +#endif + eatwhitespace(); + p = pos; + + if (!*p || iscommentchar(*p)) { /* end of line or start of comment */ + pos = pos_e = NULL; + *p = 0; /* treat comment as end of line */ +/* fprintf(stdout, "returning NUL token |%s|\n", pos); */ + return NULL; +#if 1 + } else if (*p == '<') { /* collating symbol, element, or value */ + while (*++p) { + if ((*p == '/') && p[1]) { + ++p; + continue; + } + if (*p == '>') { + pos_e = ++p; + end_of_token = *p; + *p = 0; +/* fprintf(stdout, "returning col token |%s|\n", pos); */ + return pos; + } + } + } else if (*p == '"') { /* collating element value? */ + while (*++p) { + if (*p == '"') { /* found the end of the quoted string */ + pos_e = ++p; + end_of_token = *p; + *p = 0; +/* fprintf(stdout, "returning quote token |%s|\n", pos); */ + return pos; + } + } +#endif + } else { /* some kind of keyword */ + while (*++p) { + if (isspace(*p) || (*p == ';')) { + break; + } + } + pos_e = p; + end_of_token = *p; + *p = 0; +/* fprintf(stdout, "returning key token |%s|\n", pos); */ + return pos; + } + + error_msg("illegal token |%s|", pos); +} + +static void *xmalloc(size_t n) +{ + void *p; + + if (!(p = malloc(n))) { + error_msg("OUT OF MEMORY"); + } + return p; +} + +static void do_copy(void) +{ + char *s; + char *e; + + if ((s = next_token()) != NULL) { + e = strchr(s + 1, '"'); + if ((*s == '"') && e && (*e == '"') && !e[1]) { + if (next_token() != NULL) { + error_msg("illegal trailing text: %s", pos); + } + *e = 0; + ++s; + if (cur_base && !strcmp(cur_base->name,s)) { +/* fprintf(stderr, "skipping copy of base file %s\n", s); */ +#warning need to update last in order and position or check + return; + } +/* fprintf(stderr, "full copy of %s\n", s); */ + pushfile(s); + return; + } + } + error_msg("illegal or missing arg for copy: %s", s); +} + +static void do_colsym(void) +{ + char *s; + char *e; + + if ((s = next_token()) != NULL) { + e = strrchr(s,'>'); + if ((*s == '<') && e && (*e == '>') && !e[1]) { + if (next_token() != NULL) { + error_msg("illegal trailing text: %s", pos); + } + e[1] = 0; /* cleanup in case next_token stored something */ + add_colitem(s,NULL); + return; + } + } + error_msg("illegal or missing arg for collating-symbol: %s", s); +} + +static void do_colele(void) +{ + char *s; + char *e; + char *s1; + char *e1; + int n; + + if ((s = next_token()) != NULL) { + e = strrchr(s,'>'); + if ((*s == '<') && e && (*e == '>') && !e[1]) { + if (((s1 = next_token()) == NULL) + || (strcmp(s1,"from") != 0) + || ((s1 = next_token()) == NULL) + || (*s1 != '\"') + ) { + error_msg("illegal format for collating-element spec"); + } + e1 = strchr(s1 + 1, '"'); + if ((*s1 != '"') || !e1 || (*e1 != '"') || (e1[1] != 0)) { + error_msg("illegal definition for collating-element: %s", s1); + } + if (next_token() != NULL) { + error_msg("illegal trailing text: %s", pos); + } + e[1] = 0; /* cleanup in case next_token stored something */ + e1[1] = 0; + add_colitem(s,s1); + ++s1; + if (!(n = is_ucode(s1))) { + error_msg("starting char must be a code: %s", s1); + } + assert(s1[n] == '<'); + s1[n] = 0; + s = xsymdup(s1); + if (!(tsearch(s, &cur_base->root_starter_char, sym_cmp))) { + error_msg("OUT OF MEMORY"); + } + + return; + } + } + error_msg("illegal or missing arg for collating-element: %s", s); +} + +static ll_item_t *find_section_list_item(const char *name, col_locale_t *loc) +{ + ll_item_t *p; + + if (!loc) { + return NULL; + } + + p = loc->section_list; + + while (p) { +#warning devel code +/* if (!((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER))) { */ +/* fprintf(stderr, "fsli = %d\n", p->data_type); */ +/* } */ + assert((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER)); + if (!strcmp(name, ((section_t *)(p->data))->name)) { + break; + } + p = p->next; + } + return p; +} + +static ll_item_t *find_ll_last(ll_item_t *p) +{ + assert(p); + + while (p->next) { + p = p->next; + } + return p; +} + +static void do_script(void) +{ + char *s; + char *e; + + if ((s = next_token()) != NULL) { + e = strrchr(s,'>'); + if ((*s == '<') && e && (*e == '>') && !e[1]) { + if (next_token() != NULL) { + error_msg("illegal trailing text: %s", pos); + } + e[1] = 0; /* cleanup in case next_token stored something */ + add_script(s); + return; + } + } + error_msg("illegal or missing arg for script: %s", s); +} + +static col_locale_t *new_col_locale(char *name) +{ + ll_item_t *lli; + ll_item_t *lli2; + + cur_col = (col_locale_t *) xmalloc(sizeof(col_locale_t)); + cur_col->name = name; + cur_col->root_colitem = NULL; + cur_col->root_element = NULL; + cur_col->root_scripts = NULL; + cur_col->base_locale = NULL; + if (!superset) { + /* start with an anonymous section */ + cur_section = new_section(NULL); + cur_col->section_list = new_ll_item(DT_SECTION, cur_section); + } else { + /* start with a reorder section */ + cur_section = new_section("R"); + cur_num_weights = cur_section->num_rules + = ((section_t *)(cur_base->section_list->data))->num_rules; + memcpy(cur_rule, + ((section_t *)(cur_base->section_list->data))->rules, + MAX_COLLATION_WEIGHTS); + memcpy(cur_section->rules, + ((section_t *)(cur_base->section_list->data))->rules, + MAX_COLLATION_WEIGHTS); + cur_col->section_list = new_ll_item(DT_REORDER, cur_section); + assert(cur_base->section_list->next == NULL); /* currently only one section allowed */ + lli = ((section_t *)(cur_base->section_list->data))->itm_list; + assert(lli); + lli2 = new_ll_item(DT_REORDER, cur_section); + lli2->prev = lli2->next = lli2; + insque(lli2, lli->prev); + ((section_t *)(cur_base->section_list->data))->itm_list = lli2; + } +/* cur_col->section_list = NULL; */ +/* add_script(((section_t *)(cur_col->section_list->data))->name); */ + cur_col->root_wi_index = NULL; + cur_col->root_wi_index_reordered = NULL; + cur_col->root_derived_wi = NULL; + cur_col->derived_list = NULL; + cur_col->root_starter_char = NULL; + cur_col->root_starter_all = NULL; + cur_col->undefined_idx = NULL; + return cur_col; +} + +static int colitem_cmp(const void *n1, const void *n2) +{ + return strcmp(((colitem_t *)n1)->string, ((colitem_t *)n2)->string); +} + +static int colelement_cmp(const void *n1, const void *n2) +{ + int r; + + r = strcmp(((colitem_t *)n1)->string, ((colitem_t *)n2)->string); + if (!r) { + if (((colitem_t *)n1)->element && ((colitem_t *)n2)->element) { + r = strcmp(((colitem_t *)n1)->element, ((colitem_t *)n2)->element); + } else if (((colitem_t *)n1)->element == ((colitem_t *)n2)->element) { + r = 0; /* both null */ + } else { + r = (((colitem_t *)n1)->element == NULL) ? -1 : 1; + } + } + return r; +} + +static void del_colitem(colitem_t *p) +{ +/* free((void *) p->element); */ +/* free((void *) p->string); */ + free(p); +} + +static colitem_t *new_colitem(char *item, char *def) +{ + colitem_t *p; + + p = xmalloc(sizeof(colitem_t)); + p->string = xsymdup(item); + p->element = (!def) ? def : xsymdup(def); + + return p; +} + +static void add_colitem(char *item, char *def) +{ + colitem_t *p; + +#if 0 + printf("adding collation item %s", item); + if (def) { + printf(" with definition %s", def); + } + printf("\n"); +#endif + + p = new_colitem(item, def); + +#warning devel code + if (superset) { + if (tfind(p, &cur_base->root_colitem, colitem_cmp)) { +/* fprintf(stderr, "skipping superset duplicate collating item \"%s\"\n", p->string); */ + del_colitem(p); + return; +/* } else { */ +/* fprintf(stderr, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */ + } + } + + if (cur_col == cur_derived) { + if (!tfind(p, &cur_base->root_colitem, colitem_cmp)) { + /* not in current but could be in base */ + if (!tsearch(p, &cur_base->root_colitem, colitem_cmp)) { + error_msg("OUT OF MEMORY!"); + } + } else if (!tfind(p, &cur_base->root_colitem, colelement_cmp)) { + error_msg("collating element/symbol mismatch: item=%s def=%s", item, def); + } + } + + + if (!tfind(p, &cur_col->root_colitem, colitem_cmp)) { + /* not in current but could be in base */ + if (!tsearch(p, &cur_col->root_colitem, colitem_cmp)) { + error_msg("OUT OF MEMORY!"); + } + } else if (!tfind(p, &cur_col->root_colitem, colelement_cmp)) { + error_msg("collating element/symbol mismatch"); + } else { /* already there */ + fprintf(stderr, "duplicate collating item \"%s\"\n", p->string); + del_colitem(p); + } +} + +/* add a script (section) to the current locale */ +static void add_script(const char *s) +{ + ll_item_t *l; + + /* make sure it isn't in base if working with derived */ + if (cur_base != cur_col) { + if (find_section_list_item(s, cur_base)) { + error_msg("attempt to add script %s for derived when already in base", s); + } + } + + if (find_section_list_item(s, cur_col)) { + error_msg("attempt to readd script %s", s); + } + + l = find_ll_last(cur_col->section_list); + insque(new_ll_item(DT_SECTION, new_section(s)), l); +} + +static const char str_forward[] = "forward"; +static const char str_backward[] = "backward"; +static const char str_position[] = "position"; + +static void do_order_start(void) +{ + const char *s; + char *e; + ll_item_t *l; + section_t *sect; + int rule; + + if (order_state & ~IN_ORDER) { + error_msg("order_start following reorder{_sections}_after"); + } + order_state |= IN_ORDER; + + if (superset) { + if (++superset_order_start_cnt > 1) { + error_msg("currently only a common order_start is supported in superset"); + } + return; + } + + if (!(s = next_token())) { + s = str_forward; /* if no args */ + } + + if (*s == '<') { /* section (script) */ + e = strrchr(s,'>'); + if ((*s == '<') && e && (*e == '>') && !e[1]) { + e[1] = 0; /* cleanup in case next_token stored something */ + + if (!(l = find_section_list_item(s, cur_col))) { + error_msg("ref of undefined sections: %s", s); + } + sect = (section_t *)(l->data); + if (sect->num_rules) { + error_msg("sections already defined: %s", s); + } + } else { + error_msg("illegal section ref: %s", s); + } + + if (!(s = next_token())) { + s = str_forward; /* if no args */ + } else if (*s != ';') { + error_msg("missing seperator!"); + } + } else { /* need an anonymous section */ + if ((*cur_section->name != '<') && (cur_section->num_items == 0)) { /* already in an empty anonymous section */ + sect = cur_section; +/* fprintf(stdout, "using empty anon section %s\n", sect->name); */ + } else { + sect = new_section(NULL); + l = find_ll_last(cur_col->section_list); + insque(new_ll_item(DT_SECTION, sect), l); +/* fprintf(stdout, "adding order section after section %s\n", ((section_t *)(l->data))->name); */ +/* fprintf(stdout, " last section is %s\n", ((section_t *)(l->next->data))->name); */ + } + sect->num_rules = 0; /* setting this below so nix default */ + } + cur_section = sect; +/* fprintf(stdout, "cur_section now %s\n", cur_section->name); */ + +#warning need to add section to weight list? + + /* now do rules */ + do { + rule = 0; + if (*s == ';') { + ++s; + } + while (*s) { + if (!strncmp(str_forward, s, 7)) { + rule |= R_FORWARD; + s += 7; + } else if (!strncmp(str_backward, s, 8)) { + rule |= R_BACKWARD; + s += 8; + } else if (!strncmp(str_position, s, 8)) { + rule |= R_POSITION; + s += 8; + } + + if (*s == ',') { + ++s; + continue; + } + + if (!*s || (*s == ';')) { + if (sect->num_rules >= MAX_COLLATION_WEIGHTS) { + error_msg("more than %d weight rules!", MAX_COLLATION_WEIGHTS); + } + if (!rule) { + error_msg("missing weight rule!"); + } + if ((rule & (R_FORWARD|R_BACKWARD|R_POSITION)) > R_BACKWARD) { + error_msg("backward paired with forward and/or position!"); + } + + sect->rules[sect->num_rules++] = rule; + rule = 0; + continue; + } + + error_msg("illegal weight rule: %s", s); + } + } while ((s = next_token()) != NULL); + + cur_section = sect; + +/* fprintf(stderr, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */ + cur_num_weights = sect->num_rules; + memcpy(cur_rule, sect->rules, MAX_COLLATION_WEIGHTS); +} + +static void do_order_end(void) +{ + if (!(order_state & IN_ORDER)) { + error_msg("order_end with no matching order_start"); + } + order_state &= ~IN_ORDER; + + cur_section = new_section(NULL); +} + +static void do_reorder_after(void) +{ + char *t; + ll_item_t *lli; + const weight_t *w; + int save_cur_num_weights; + char save_cur_rule[MAX_COLLATION_WEIGHTS]; + + + if (order_state & ~IN_REORDER) { + error_msg("reorder_after following order_start or reorder_sections_after"); + } + order_state |= IN_REORDER; + + if (superset) { + error_msg("currently reorder_after is not supported in supersets"); + } + +#warning have to use rule for current section!!! + + if (!(t = next_token())) { + error_msg("missing arg for reorder_after"); + } + + t = xsymdup(t); + + if (next_token() != NULL) { + error_msg("trailing text reorder_after: %s", pos); + } + + if (cur_col == cur_base) { + error_msg("sorry.. reorder_after in base locale is not currently supported"); + } + + if (!(lli = find_wi_index(t, cur_base))) { + error_msg("reorder_after for non-base item currently not supported: %s", t); + } + + w = ((weighted_item_t *)(lli->data))->weight; + + + save_cur_num_weights = cur_num_weights; + memcpy(save_cur_rule, cur_rule, MAX_COLLATION_WEIGHTS); + + cur_section = new_section("R"); + insque(new_ll_item(DT_REORDER, cur_section), lli); + +#if 0 + + { + ll_item_t *l1; + ll_item_t *l2; + ll_item_t *l3; + l1 = new_ll_item(DT_REORDER, cur_section); + l2 = find_ll_last(cur_col->section_list); + insque(l1, l2); + l3 = find_ll_last(cur_col->section_list); + + fprintf(stderr, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name); + } +#else + insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list)); +#endif + + cur_num_weights = cur_section->num_rules = save_cur_num_weights; + memcpy(cur_rule, save_cur_rule, MAX_COLLATION_WEIGHTS); + memcpy(cur_section->rules, save_cur_rule, MAX_COLLATION_WEIGHTS); + + +#warning devel code +/* fprintf(stderr, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */ + +#warning hack to get around hu_HU reorder-after problem +/* if (!w->num_weights) { */ + +/* } else { */ +/* cur_num_weights = w->num_weights; */ +/* memcpy(cur_rule, w->rule, MAX_COLLATION_WEIGHTS); */ +/* } */ + +/* fprintf(stderr, "reorder_after succeeded for %s\n", t); */ +} + +static void do_reorder_end(void) +{ + if (!(order_state & IN_REORDER)) { + error_msg("reorder_end with no matching reorder_after"); + } + order_state &= ~IN_REORDER; +} + +static void do_reorder_sections_after(void) +{ + const char *t; + ll_item_t *lli; + + if (order_state & ~IN_REORDER_SECTIONS) { + error_msg("reorder_sections_after following order_start or reorder_after"); + } + order_state |= IN_REORDER_SECTIONS; + + if (superset) { + error_msg("currently reorder_sections_after is not supported in supersets"); + } + + if (!(t = next_token())) { + error_msg("missing arg for reorder_sections_after"); + } + + t = xsymdup(t); + + if (next_token() != NULL) { + error_msg("trailing text reorder_sections_after: %s", pos); + } + + if (cur_col == cur_base) { + error_msg("sorry.. reorder_sections_after in base locale is not currently supported"); + } + + lli = cur_base->section_list; + do { +/* fprintf(stderr, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */ + if (lli->data_type & DT_SECTION) { +/* fprintf(stderr, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */ + if (!strcmp(((section_t *)(lli->data))->name, t)) { + reorder_section_ptr = lli; + return; + } + } + lli = lli->next; + } while (lli); + + error_msg("reorder_sections_after for non-base item currently not supported: %s", t); +} + +static void do_reorder_sections_end(void) +{ + if (!(order_state & IN_REORDER_SECTIONS)) { + error_msg("reorder_sections_end with no matching reorder_sections_after"); + } + order_state &= ~IN_REORDER_SECTIONS; + + reorder_section_ptr = NULL; +} + +static ll_item_t *new_ll_item(int data_type, void *data) +{ + ll_item_t *p; + + p = xmalloc(sizeof(ll_item_t)); + p->next = p->prev = NULL; + p->data_type = data_type; + p->data = data; + p->idx = INT_MIN; + + return p; +} + +static int sym_cmp(const void *n1, const void *n2) +{ +/* fprintf(stderr, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */ + return strcmp((const char *) n1, (const char *) n2); +} + +static char *xsymdup(const char *s) +{ + void *p; + + if (!(p = tfind(s, &root_sym, sym_cmp))) { /* not a currently known symbol */ + if (!(s = strdup(s)) || !(p = tsearch(s, &root_sym, sym_cmp))) { + error_msg("OUT OF MEMORY!"); + } + ++num_sym; + mem_sym += strlen(s) + 1; +/* fprintf(stderr, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */ +/* } else { */ +/* fprintf(stderr, "xsymdup: found |%s| %p\n", *(char **)p, p); */ + } + return *(char **) p; +} + +static int weight_cmp(const void *n1, const void *n2) +{ + const weight_t *w1 = (const weight_t *) n1; + const weight_t *w2 = (const weight_t *) n2; + int i, r; + + if (w1->num_weights != w2->num_weights) { + return w1->num_weights - w2->num_weights; + } + + for (i=0 ; i < w1->num_weights ; i++) { + if (w1->rule[i] != w2->rule[i]) { + return w1->rule[i] - w2->rule[i]; + } + if ((r = strcmp(w1->colitem[i], w2->colitem[i])) != 0) { + return r; + } + } + return 0; +} + +static weight_t *register_weight(weight_t *w) +{ + void *p; + + if (!(p = tfind(w, &root_weight, weight_cmp))) { /* new weight */ + p = xmalloc(sizeof(weight_t)); + memcpy(p, w, sizeof(weight_t)); + if (!(p = tsearch(p, &root_weight, weight_cmp))) { + error_msg("OUT OF MEMORY!"); + } + ++unique_weights; +/* } else { */ +/* fprintf(stderr, "rw: found\n"); */ + } + return *(weight_t **)p; +} + +static size_t ll_len(ll_item_t *l) +{ + size_t n = 0; + ll_item_t *p = l; + + while (p) { + ++n; + p = p->next; + if (p == l) { /* work for circular too */ + break; + } + } + return n; +} + +static size_t ll_count(ll_item_t *l, int mask) +{ + size_t n = 0; + ll_item_t *p = l; + + while (p) { + if (p->data_type & mask) { + ++n; + } + p = p->next; + if (p == l) { /* work for circular too */ + break; + } + } + return n; +} + + +static int wi_index_cmp(const void *n1, const void *n2) +{ + const char *s1 = ((weighted_item_t *)(((ll_item_t *) n1)->data))->symbol; + const char *s2 = ((weighted_item_t *)(((ll_item_t *) n2)->data))->symbol; + + return strcmp(s1, s2); +} + +static void add_wi_index(ll_item_t *l) +{ + assert(l->data_type == DT_WEIGHTED); + + if (!strcmp(((weighted_item_t *)(l->data))->symbol, "UNDEFINED")) { + cur_col->undefined_idx = l; + } + + if (!tfind(l, &cur_col->root_wi_index, wi_index_cmp)) { /* new wi_index */ + if (!tsearch(l, &cur_col->root_wi_index, wi_index_cmp)) { + error_msg("OUT OF MEMORY!"); + } + } + + if (cur_base != cur_col) { + if (!tfind(l, &cur_base->root_wi_index, wi_index_cmp)) {/* not a base val */ +/* printf("derived: %s\n", ((weighted_item_t *)(l->data))->symbol); */ + if (!tfind(l, &cur_base->root_derived_wi, wi_index_cmp)) { /* new derived */ + if (!tsearch(l, &cur_base->root_derived_wi, wi_index_cmp)) { + error_msg("OUT OF MEMORY!"); + } + } + } + } +} + +static int final_index; + + +static int is_ucode(const char *s) +{ + if ((s[0] == '<') + && (s[1] == 'U') + && isxdigit(s[2]) + && isxdigit(s[3]) + && isxdigit(s[4]) + && isxdigit(s[5]) + && (s[6] == '>') + ) { + return 7; + } else { + return 0; + } +} + +static void add_final_col_index(const char *s) +{ + ENTRY e; + + e.key = (char *) s; + e.data = (void *)(final_index); + if (!hsearch(e, FIND)) { /* not in the table */ + if (!hsearch(e, ENTER)) { + error_msg("OUT OF MEMORY! (hsearch)"); + } +#if 0 + { + int n; + void *v; + colitem_t ci; + colitem_t *p; + const char *t; + + if (!strcmp(s, "UNDEFINED")) { + printf("%6d: %s\n", final_index, s); + } else { + assert(*s == '<'); + if ((n = is_ucode(s)) != 0) { + assert(!s[n]); + printf("%6d: %s\n", final_index, s); + } else { + ci.string = (char *) s; + ci.element = NULL; /* don't care */ + v = tfind(&ci, &cur_base->root_colitem, colitem_cmp); + if (!v) { + fprintf(stderr, "%s NOT DEFINED!!!\n", s); + } else { + p = *((colitem_t **) v); + if (p->element != NULL) { + t = p->element; + assert(*t == '"'); + ++t; + n = is_ucode(t); + assert(n); + printf("%6d: %.*s | ", final_index, n, t); + do { + t += n; + assert(*t); + if (*t == '"') { + assert(!t[1]); + break; + } + n = is_ucode(t); + assert(n); + printf("%.*s", n, t); + } while (1); + printf(" collating-element %s\n", s); + } else { + printf("%6d: %s (collating-symbol)\n", final_index, s); + } + } + } + } + } +#endif + ++final_index; + } + +} + +static int final_index_val0(const char *s) +{ + ENTRY *p; + ENTRY e; + e.key = (char *) s; + + if (!(p = hsearch(e, FIND))) { /* not in the table */ + return 0; + } + + return (int)(p->data); +} + +static int final_index_val(const char *s) +{ + ENTRY *p; + ENTRY e; + e.key = (char *) s; + + if (!(p = hsearch(e, FIND))) { /* not in the table */ + error_msg("can't find final index: %s", s); + } + + return (int)(p->data); +} + +static size_t num_tree_nodes; + +static void count_nodes(const void *ptr, VISIT order, int level) +{ + if ((order == postorder) || (order == leaf)) { + ++num_tree_nodes; + } +} + +static size_t tnumnodes(const void *root) +{ + num_tree_nodes = 0; + + twalk(root, count_nodes); + + return num_tree_nodes; + +} + +static ll_item_t *find_wi_index(const char *sym, col_locale_t *cl) +{ + weighted_item_t w; + ll_item_t l; + void *p; + + w.symbol = sym; + l.data = &w; + l.data_type = DT_WEIGHTED; + + p = tfind(&l, &cl->root_wi_index, wi_index_cmp); + + if (p) { + p = *(ll_item_t **)p; + } + + return (ll_item_t *) p; +} + +static void mark_reordered(const char *sym) +{ + ll_item_t *lli; + + lli = find_wi_index(sym, cur_base); + + if (lli) { + if (!tsearch(lli, &cur_base->root_wi_index_reordered, wi_index_cmp)) { + error_msg("OUT OF MEMORY!"); + } + } +} + +static ll_item_t *find_wi_index_reordered(const char *sym) +{ + weighted_item_t w; + ll_item_t l; + void *p; + + w.symbol = sym; + l.data = &w; + l.data_type = DT_WEIGHTED; + + p = tfind(&l, &cur_base->root_wi_index_reordered, wi_index_cmp); + + if (p) { + p = *(ll_item_t **)p; + } + + return (ll_item_t *) p; +} + +static ll_item_t *init_comm_ptr(void) +{ + assert(cur_base); + assert(cur_base->section_list); + /* at the moment, only support one section in comm */ + assert(cur_base->section_list->next == NULL); + + comm_cur_ptr = ((section_t *)(cur_base->section_list->data))->itm_list; + + while (comm_cur_ptr && (comm_cur_ptr->data_type & DT_REORDER)) { + comm_cur_ptr = comm_cur_ptr->next; + } + +#warning devel code +/* { */ +/* ll_item_t *p = comm_cur_ptr; */ +/* fprintf(stderr, "init_comm_ptr\n"); */ + +/* while (p != comm_cur_ptr) { */ +/* if (p->data_type & DT_WEIGHTED) { */ +/* fprintf(stderr, "%s", ((weighted_item_t *)p)->symbol); */ +/* } */ +/* p = p->next; */ +/* } */ +/* } */ + + assert(comm_cur_ptr); + +/* fprintf(stderr, "init_comm_ptr -- %s %p %p %p %d\n", */ +/* ((weighted_item_t *)(comm_cur_ptr->data))->symbol, */ +/* comm_cur_ptr, comm_cur_ptr->prev, comm_cur_ptr->next, */ +/* ll_len(comm_cur_ptr)); */ + + comm_prev_ptr = NULL; + return comm_cur_ptr; +} + +static ll_item_t *next_comm_ptr(void) +{ + /* at the moment, only support one section in comm */ + assert(cur_base->section_list->next == NULL); + + comm_prev_ptr = comm_cur_ptr; + + while (comm_cur_ptr && ((comm_cur_ptr = comm_cur_ptr->next) != NULL)) { + if (!(comm_cur_ptr->data_type & DT_REORDER)) { + break; + } + } + + return comm_cur_ptr; +} + +static int dump_count; + +#if 0 +static void dump_section(section_t *s, int mask, col_locale_t *der) +{ + ll_item_t *lli; + ll_item_t *lli0; + weighted_item_t *w; + weight_t *p; + int i; + + lli0 = lli = s->itm_list; + + if (!lli0) { + return; + } + + do { + if (!(lli->data_type & mask)) { + lli = lli->next; + continue; + } + if (lli->data_type & DT_WEIGHTED) { + ++dump_count; + w = (weighted_item_t *)(lli->data); + p = w->weight; + printf("%6d: %s (%d) ", dump_count, w->symbol, p->num_weights); + for (i = 0 ; i < p->num_weights ; i++) { + if (p->rule[i] & R_FORWARD) { + printf("F"); + } + if (p->rule[i] & R_BACKWARD) { + printf("B"); + } + if (p->rule[i] & R_POSITION) { + printf("P"); + } + printf(","); + } + for (i = 0 ; i < p->num_weights ; i++) { + printf(" %s", p->colitem[i]); + } + printf("\n"); + } else if (lli->data_type & (DT_SECTION|DT_REORDER)) { + + if (lli->data_type == DT_REORDER) { + assert(der); + if (strncmp(((section_t *)(lli->data))->name, der->name, strlen(der->name))) { + lli = lli->next; + continue; + } + } + + if (lli->data_type & DT_SECTION) { + printf("SECTION -----------------\n"); + } else { + printf("REORDER -----------------\n"); + } + + dump_section((section_t *)(lli->data), mask, der); + printf("DONE --------------------\n"); + } + lli = lli->next; + } while (lli != lli0); +} +#else +static int in_reorder_section = 0; + +static void dump_section(section_t *s, int mask, col_locale_t *der) +{ + ll_item_t *lli; + ll_item_t *lli0; + weighted_item_t *w; + weight_t *p; + int i; + + lli0 = lli = s->itm_list; + + if (!lli0) { + return; + } + + do { + if (!(lli->data_type & mask)) { + lli = lli->next; + continue; + } + if (lli->data_type & DT_WEIGHTED) { + ++dump_count; + w = (weighted_item_t *)(lli->data); + p = w->weight; +#if 1 + if (in_reorder_section) { + printf(" %p", w); + } +#else + printf("%6d: %s (%d) ", dump_count, w->symbol, p->num_weights); + for (i = 0 ; i < p->num_weights ; i++) { + if (p->rule[i] & R_FORWARD) { + printf("F"); + } + if (p->rule[i] & R_BACKWARD) { + printf("B"); + } + if (p->rule[i] & R_POSITION) { + printf("P"); + } + printf(","); + } + for (i = 0 ; i < p->num_weights ; i++) { + printf(" %s", p->colitem[i]); + } + printf("\n"); +#endif + } else if (lli->data_type & (DT_SECTION|DT_REORDER)) { + + if (lli->data_type == DT_REORDER) { + assert(der); + if (strncmp(((section_t *)(lli->data))->name, der->name, strlen(der->name))) { + lli = lli->next; + continue; + } + } + + if (lli->data_type & DT_SECTION) { +/* printf("SECTION -----------------\n"); */ + assert(0); + } else { +/* printf("REORDER -----------------\n"); */ + in_reorder_section = 1; + } + + dump_section((section_t *)(lli->data), mask, der); +/* printf("DONE --------------------\n"); */ + printf("\n"); + in_reorder_section = 0; + } + lli = lli->next; + } while (lli != lli0); +} +#endif + +static void dump_weights(const char *name) +{ + ll_item_t *lli; + col_locale_t *base; + col_locale_t *der; + col_locale_t cl; + void *p; + + assert(name); + + if (!*name) { /* use last */ + base = cur_base; + der = cur_derived; + } else { + cl.name = (char *) name; + if (!(p = tfind(&cl, &root_col_locale, col_locale_cmp))) { + error_msg("unknown locale: %s", name); + } + base = *((col_locale_t **) p); + der = NULL; + if (base->base_locale) { /* oops... really derived */ + der = base; + base = der->base_locale; + } + } + + dump_count = 0; + + if (base) { +/* printf("BASE - %s\n", base->name); */ + for (lli = base->section_list ; lli ; lli = lli->next) { +/* printf("SECTION %s\n", ((section_t *)(lli->data))->name); */ + dump_section((section_t *)(lli->data), ~0, der); + } + } + + assert(der != base); + + if (der) { +/* printf("DERIVED - %s\n", der->name); */ + for (lli = der->section_list ; lli ; lli = lli->next) { + if (lli->data_type == DT_SECTION) { + dump_section((section_t *)(lli->data), DT_WEIGHTED, der); + } + } + } +/* printf("DONE\n"); */ +} + +static void print_starter_node(const void *ptr, VISIT order, int level) +{ + if (order == postorder || order == leaf) { + fprintf(stderr, " %s\n", *(const char **) ptr); + } +} + +static void finalize_base(void) +{ + ll_item_t *s; + ll_item_t *h; + ll_item_t *lli; + ll_item_t *h2; + ll_item_t *l2; + ll_item_t *cli; + ll_item_t *rli = NULL; + weighted_item_t *w; + weight_t *p; + int i, n, mr, r, mi; + col_locale_t *cl; + void *mm; + + int num_invariant = 0; + int num_varying = 0; + int max_weight; + int index2weight_len_inc = 1; + + assert(cur_base); + assert(base_locale_len+1 < BASE_LOCALE_LEN); + + base_locale_array[base_locale_len].name = cur_base->name; + base_locale_array[base_locale_len].num_weights = 1; + base_locale_array[base_locale_len].index2weight_offset = index2weight_len; + base_locale_array[base_locale_len].index2ruleidx_offset = index2ruleidx_len; + if (!strcmp(cur_base->name,"ja_JP") || !strcmp(cur_base->name,"ko_KR")) { +#warning fix the index2weight check!! + index2weight_len_inc = 0; + } +/* printf("%s -- index2weight_len = %d\n", cur_base->name, index2weight_len); */ + + if (!hcreate(30000)) { + error_msg("OUT OF MEMORY!"); + } + + /* first pass ... set the fixed indexes */ + final_index = i = 1; + mr = 0; + for (s = cur_base->section_list ; s ; s = s->next) { +#if 1 + if (s->data_type & DT_REORDER) { /* a reordered section */ + fprintf(stderr, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name); + lli = ((section_t *)(s->data))->itm_list; + r = 0; + if (lli) { +/* r = ll_len( ((section_t *)(lli->data))->itm_list ); */ + r = ll_len(lli) + 1; + } + if (r > mr) { + mr = r; + } + fprintf(stderr, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r); + continue; + } +#endif + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { + continue; + } + do { + if (lli->data_type & DT_RANGE) { + i += mr; + mr = 0; +#warning check ko_kR and 9 +/* ++i; */ + lli->idx = i; + assert(!rli); + rli = lli; + fprintf(stderr, "range pre = %d after = ", i); + i += ((range_item_t *)(lli->data))->length + 1; +#warning check ko_kR and 9 +/* ++i; */ + fprintf(stderr, "%d\n", i); + if (!index2weight_len_inc) { /* ko_KR hack */ + final_index += ((range_item_t *)(lli->data))->length + 1; + } +/* add_final_col_index("RANGE"); */ + } else if (lli->data_type & DT_WEIGHTED) { + i += mr; + mr = 0; + w = (weighted_item_t *)(lli->data); + if (find_wi_index_reordered(w->symbol)) { /* reordered symbol so skip on first pass */ + ++num_varying; + ++i; + continue; + } + ++num_invariant; + index2weight_buffer[index2weight_len] = lli->idx = i++; + index2weight_len += index2weight_len_inc; + add_final_col_index(w->symbol); + + } else { + assert(lli->data_type & DT_REORDER); + r = ll_len( ((section_t *)(lli->data))->itm_list ); +#warning check ko_kR and 9 + if (r > mr) { + mr = r; + } +/* r = 0; */ + } + } while ((lli = lli->next) != h); + } + + /* second pass ... set the reordered indexes */ + mi = i + mr; + mr = i = 0; + for (s = cur_base->section_list ; s ; s = s->next) { + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { + continue; + } + do { + if (lli->data_type & DT_RANGE) { + i += mr; + mr = 0; + i = lli->idx + ((range_item_t *)(lli->data))->length + 1; +#warning check + } else if ((lli->data_type & DT_WEIGHTED) && !(s->data_type & DT_REORDER)) { + i += mr; + mr = 0; + w = (weighted_item_t *)(lli->data); + if (find_wi_index_reordered(w->symbol) /* reordered symbol skipped on first pass */ +#if 0 + || (s->data_type & DT_REORDER) /* or in a reordered section */ +#endif + ) { + assert(!(s->data_type & DT_REORDER)); + index2weight_buffer[index2weight_len] = lli->idx = ++i; + index2weight_len += index2weight_len_inc; + add_final_col_index(w->symbol); + +/* fprintf(stdout, "%11s: r %6d %6d %s\n", */ +/* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ + + continue; + } + i = lli->idx; + +/* fprintf(stdout, "%11s: w %6d %6d %s\n", */ +/* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ + + } else { +/* fprintf(stderr, "section: %s %d %d\n", ((section_t *)(s->data))->name, */ +/* s->data_type, lli->data_type); */ +/* assert(!(s->data_type & DT_REORDER)); */ +/* assert(lli->data_type & DT_REORDER); */ +#if 1 + if (s->data_type & DT_REORDER) { + h2 = l2 = lli; + if (!h2) { + continue; + } + } else { + assert(s->data_type & DT_SECTION); + h2 = l2 = ((section_t *)(lli->data))->itm_list; + if (!h2) { + continue; + } + } + + +#else + h2 = l2 = ((section_t *)(lli->data))->itm_list; + if (!h2) { + continue; + } +#endif + r = 0; + do { + assert(l2->data_type & DT_WEIGHTED); + ++r; + l2->idx = i + r; + +/* fprintf(stdout, "%s: R %6d %s\n", */ +/* ((section_t *)(lli->data))->name, l2->idx, ((weighted_item_t *)(l2->data))->symbol); */ + + } while ((l2 = l2->next) != h2); + if (r > mr) { + mr = r; + } + } + } while ((lli = lli->next) != h); + } + + /* finally, walk through all derived locales and set non-reordered section items */ + mr = mi; + for (cli = cur_base->derived_list ; cli ; cli = cli->next) { + cl = (col_locale_t *)(cli->data); +/* fprintf(stderr, "pass3: %d %s\n", cli->data_type, cl->name); */ + +/* fprintf(stdout, "pass3: %d %s\n", cli->data_type, cl->name); */ + + assert(cli->data_type == DT_COL_LOCALE); + + i = mi; + for (s = cl->section_list ; s ; s = s->next) { +/* if (s->data_type & DT_REORDER) { */ +/* continue; */ +/* } */ + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { + continue; + } + do { + assert(!(lli->data_type & DT_RANGE)); + if (lli->data_type & DT_WEIGHTED) { +/* fprintf(stderr, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */ + add_final_col_index(((weighted_item_t *)(lli->data))->symbol); + if (s->data_type & DT_REORDER) { + continue; + } + assert(lli->idx == INT_MIN); + lli->idx = ++i; + +/* fprintf(stdout, "%11s: S %6d %6d %s\n", */ +/* cl->name, lli->idx, */ +/* final_index_val(((weighted_item_t *)(lli->data))->symbol), */ +/* ((weighted_item_t *)(lli->data))->symbol); */ + + } else { + assert(0); + assert(lli->data_type & DT_SECTION); + + h2 = l2 = ((section_t *)(lli->data))->itm_list; + if (!h2) { + continue; + } + do { + assert(l2->data_type & DT_WEIGHTED); + assert(l2->idx == INT_MIN); + l2->idx = ++i; + add_final_col_index(((weighted_item_t *)(l2->data))->symbol); + } while ((l2 = l2->next) != h2); + } + } while ((lli = lli->next) != h); + } + if (i > mr) { + mr = i; + } + } + max_weight = mr; + + assert(num_varying == tnumnodes(cur_base->root_wi_index_reordered)); + + /* we can now initialize the wcs2index array */ + { + ENTRY *p; + ENTRY e; + char buf[8]; + static const char xd[] = "0123456789ABCDEF"; + int starter_index = final_index; + int wcs2index_count = 0; + + strcpy(buf, ""); + memset(wcs2index, 0, sizeof(wcs2index)); + e.key = (char *) buf; + for (i=1 ; i <= 0xffff ; i++) { + buf[5] = xd[ i & 0xf ]; + buf[4] = xd[ (i >> 4) & 0xf ]; + buf[3] = xd[ (i >> 8) & 0xf ]; + buf[2] = xd[ (i >> 12) & 0xf ]; + + if ((p = hsearch(e, FIND)) != NULL) { + ++wcs2index_count; + if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { + wcs2index[i] = ++starter_index; +/* fprintf(stderr, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */ + } else { + wcs2index[i] = (int)(p->data); +/* fprintf(stderr, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */ + } + } else { + if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { + error_msg("marked starter but not in hash: %s", buf); + } + } + } + + + /* ---------------------------------------------------------------------- */ + { + int i, n; + table_data table; + size_t t, smallest; + + n = 0; + smallest = SIZE_MAX; + table.ii = NULL; + for (i=0 ; i < 14 ; i++) { + if ((RANGE >> i) < 4) { + break; + } + t = newopt(wcs2index, RANGE, i, &table); + if (smallest >= t) { + n = i; + smallest = t; + /* } else { */ + /* break; */ + } + } + + +/* printf("smallest = %u for range %#x (%u)\n", smallest, RANGE, RANGE); */ + assert(smallest != SIZE_MAX); + if (smallest + wcs2colidt_len >= WCS2COLIDT_LEN) { + error_msg("WCS2COLIDT_LEN too small"); + } + base_locale_array[base_locale_len].wcs2colidt_offset = wcs2colidt_len; + table.ii = wcs2colidt_buffer + wcs2colidt_len; + t = smallest; + smallest = SIZE_MAX; + smallest = newopt(wcs2index, RANGE, n, &table); + assert(t == smallest); + wcs2colidt_len += smallest; +/* fprintf(stderr, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */ + +#if 0 + { + unsigned int sc, n, i0, i1; + unsigned int u = 0xe40; + table_data *tbl = &table; + +#define __LOCALE_DATA_WCctype_TI_MASK ((1 << tbl->ti_shift)-1) +#define __LOCALE_DATA_WCctype_TI_SHIFT (tbl->ti_shift) +#define __LOCALE_DATA_WCctype_TI_LEN (tbl->ti_len) +#define __LOCALE_DATA_WCctype_II_MASK ((1 << tbl->ii_shift)-1) +#define __LOCALE_DATA_WCctype_II_SHIFT (tbl->ii_shift) +#define __LOCALE_DATA_WCctype_II_LEN (tbl->ii_len) + + sc = u & __LOCALE_DATA_WCctype_TI_MASK; + u >>= __LOCALE_DATA_WCctype_TI_SHIFT; + n = u & __LOCALE_DATA_WCctype_II_MASK; + u >>= __LOCALE_DATA_WCctype_II_SHIFT; + + i0 = tbl->ii[u]; + fprintf(stderr, "i0 = %d\n", i0); + i0 <<= __LOCALE_DATA_WCctype_II_SHIFT; + i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n]; + /* i1 = tbl->ti[i0 + n]; */ + fprintf(stderr, "i1 = %d\n", i1); + i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT; + /* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */ + fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc); + fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]); + /* return tbl->ut[i1 + sc]; */ + + + } +#endif + base_locale_array[base_locale_len].ii_shift = table.ii_shift; + base_locale_array[base_locale_len].ti_shift = table.ti_shift; + base_locale_array[base_locale_len].ii_len = table.ii_len; + base_locale_array[base_locale_len].ti_len = table.ti_len; + } + /* ---------------------------------------------------------------------- */ + + base_locale_array[base_locale_len].num_col_base = num_invariant + num_varying; + base_locale_array[base_locale_len].max_col_index = final_index; + base_locale_array[base_locale_len].max_weight = max_weight; + + fprintf(stderr, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n", + cur_base->name, num_invariant, num_varying, + tnumnodes(cur_base->root_derived_wi), final_index, max_weight, + wcs2index_count); + + } + +#if 1 + /* ok, now we need to dump out the base and derived tables... */ + /* don't forget to break up collating elements!!! */ + +/* fprintf(stdout, "**************************************************\n"); */ + /* first pass ... set the invariants */ + for (s = cur_base->section_list ; s ; s = s->next) { +#if 1 + if (s->data_type & DT_REORDER) { + fprintf(stderr, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name); + continue; + } +#endif + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { + continue; + } + do { + if (lli->data_type & DT_WEIGHTED) { + w = (weighted_item_t *)(lli->data); + if (find_wi_index_reordered(w->symbol)) { /* reordered symbol so skip on first pass */ + continue; + } + if (index2weight_len_inc) { + index2ruleidx_buffer[index2ruleidx_len++] = + add_rule((weighted_item_t *)(lli->data)); + } +/* fprintf(stdout, "%11s: w %6d %6d %s\n", */ +/* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ + } + } while ((lli = lli->next) != h); + } + + /* second pass ... set varying */ + for (s = cur_base->section_list ; s ; s = s->next) { +#if 1 + if (s->data_type & DT_REORDER) { + fprintf(stderr, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name); + continue; + } +#endif + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { + continue; + } + do { + if (lli->data_type & DT_WEIGHTED) { + w = (weighted_item_t *)(lli->data); + if (find_wi_index_reordered(w->symbol)) { /* reordered symbol so skip on first pass */ + if (index2weight_len_inc) { + index2ruleidx_buffer[index2ruleidx_len++] = + add_rule((weighted_item_t *)(lli->data)); + } +/* fprintf(stdout, "%11s: r %6d %6d %s\n", */ +/* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ + continue; + } + } + } while ((lli = lli->next) != h); + } + + do_starter_lists(cur_base); + + +/* fprintf(stderr,"updated final_index = %d\n", final_index); */ + + if (rli) { + base_locale_array[base_locale_len].range_low + = strtoul(((range_item_t *)(rli->data))->symbol1 + 2, NULL, 16); + base_locale_array[base_locale_len].range_count + = ((range_item_t *)(rli->data))->length; + base_locale_array[base_locale_len].range_base_weight = rli->idx; + base_locale_array[base_locale_len].range_rule_offset = add_range_rule((range_item_t *)(rli->data)); +/* fprintf(stdout, "%11s: %6d %6d %s %s (%d)\n", */ +/* "RANGE", rli->idx, -1, */ +/* ((range_item_t *)(rli->data))->symbol1, */ +/* ((range_item_t *)(rli->data))->symbol2, */ +/* ((range_item_t *)(rli->data))->length); */ + } + +/* fprintf(stdout,"\nDerived\n\n"); */ + + /* first, if base name is of the form ll_CC, add a derived locale for it */ + if ((strlen(cur_base->name) == 5) + && islower(cur_base->name[0]) + && islower(cur_base->name[1]) + && (cur_base->name[2] == '_') + && isupper(cur_base->name[3]) + && isupper(cur_base->name[4]) + ) { + + fprintf(stderr, "adding special derived for %s\n", cur_base->name); +/* fprintf(stderr,"updated final_index = %d\n", final_index); */ + + + assert(der_locale_len+1 < DER_LOCALE_LEN); + + der_locale_array[der_locale_len].name = cur_base->name; + der_locale_array[der_locale_len].base_idx = base_locale_len; + + u16_buf[0] = 1; + u16_buf[1] = 0; + u16_buf_len = 2; + + mm = NULL; + if ((u16_buf_len > override_len) || + !(mm = memmem(override_buffer, override_len*sizeof(override_buffer[0]), + u16_buf, u16_buf_len*sizeof(u16_buf[0]))) + ) { + assert(override_len + u16_buf_len < OVERRIDE_LEN); + memcpy(override_buffer + override_len, u16_buf, u16_buf_len*sizeof(u16_buf[0])); + der_locale_array[der_locale_len].overrides_offset = override_len; + override_len += u16_buf_len; +/* printf("%s: override_len = %d u16_buf_len = %d\n", cl->name, override_len, u16_buf_len); */ + } else if (!(u16_buf_len > override_len)) { + assert(mm); + der_locale_array[der_locale_len].overrides_offset = ((uint16_t *)(mm)) - override_buffer; +/* printf("%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ + } + der_locale_array[der_locale_len].multistart_offset + = base_locale_array[base_locale_len].multistart_offset; + der_locale_array[der_locale_len].undefined_idx = final_index_val0("UNDEFINED"); + + if (!der_locale_array[der_locale_len].undefined_idx) { + error_msg("no UNDEFINED definition for %s", cur_base->name); + } + + ++der_locale_len; + } else { + fprintf(stderr, "NOT adding special derived for %s\n", cur_base->name); + } + + /* now all the derived... */ + for (cli = cur_base->derived_list ; cli ; cli = cli->next) { + cl = (col_locale_t *)(cli->data); + assert(cli->data_type == DT_COL_LOCALE); + + assert(der_locale_len+1 < DER_LOCALE_LEN); + + der_locale_array[der_locale_len].name = cl->name; + der_locale_array[der_locale_len].base_idx = base_locale_len; + + u16_buf_len = 0; + + for (i = 0 ; i < 2 ; i++) { + if (i) { +/* fprintf(stdout, " section --- (singles)\n"); */ + u16_buf[u16_buf_len++] = 1; /* single */ + } + /* we do this in two passes... first all sequences, then all single reorders */ + for (s = cl->section_list ; s ; s = s->next) { +/* fprintf(stderr, "doing section %s\n", ((section_t *)(s->data))->name); */ + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { +/* fprintf(stdout, "EMPTY ITEM LIST IN SECTION %s\n", ((section_t *)(s->data))->name ); */ + continue; + } + assert(u16_buf_len +4 < sizeof(u16_buf)/sizeof(u16_buf[0])); + if ((!i && (ll_len(h) > 1) ) || (ll_len(h) == i)) { + if (!i) { +/* fprintf(stdout, " section ----------------- %d %d\n", i, ll_len(h)); */ + u16_buf[u16_buf_len++] = ll_len(h); /* multi */ + assert(lli->data_type & DT_WEIGHTED); +#if 0 + u16_buf[u16_buf_len++] = final_index_val(((weighted_item_t *)(lli->data))->symbol); /* start index */ +#endif + u16_buf[u16_buf_len++] = lli->idx; /* start weight */ + } + do { + assert(lli->data_type & DT_WEIGHTED); + if (lli->data_type & DT_WEIGHTED) { +/* fprintf(stdout, "%11s: S %6d %6d %s\n", */ +/* cl->name, lli->idx, */ +/* final_index_val(((weighted_item_t *)(lli->data))->symbol), */ +/* ((weighted_item_t *)(lli->data))->symbol); */ +#if 0 + if (i) { + assert(u16_buf_len +4 < sizeof(u16_buf)/sizeof(u16_buf[0])); + u16_buf[u16_buf_len++] = final_index_val(((weighted_item_t *)(lli->data))->symbol); + assert(u16_buf[u16_buf_len-1]); + u16_buf[u16_buf_len++] = lli->idx; /* weight */ + } +#else + assert(u16_buf_len +4 < sizeof(u16_buf)/sizeof(u16_buf[0])); + u16_buf[u16_buf_len++] = final_index_val(((weighted_item_t *)(lli->data))->symbol); + assert(u16_buf[u16_buf_len-1]); + if (i) { + u16_buf[u16_buf_len++] = lli->idx; /* weight */ + } +#endif + u16_buf[u16_buf_len++] = add_rule((weighted_item_t *)(lli->data)); + + } + } while ((lli = lli->next) != h); + } + } + } + u16_buf[u16_buf_len++] = 0; + + mm = NULL; + if ((u16_buf_len > override_len) || + !(mm = memmem(override_buffer, override_len*sizeof(override_buffer[0]), + u16_buf, u16_buf_len*sizeof(u16_buf[0]))) + ) { + assert(override_len + u16_buf_len < OVERRIDE_LEN); + memcpy(override_buffer + override_len, u16_buf, u16_buf_len*sizeof(u16_buf[0])); + der_locale_array[der_locale_len].overrides_offset = override_len; + override_len += u16_buf_len; +/* printf("%s: override_len = %d u16_buf_len = %d\n", cl->name, override_len, u16_buf_len); */ + } else if (!(u16_buf_len > override_len)) { + assert(mm); + der_locale_array[der_locale_len].overrides_offset = ((uint16_t *)(mm)) - override_buffer; +/* printf("%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ + } + + do_starter_lists(cl); + + der_locale_array[der_locale_len].undefined_idx = final_index_val0("UNDEFINED"); +#if 0 + assert(der_locale_array[der_locale_len].undefined_idx); + if (!der_locale_array[der_locale_len].undefined_idx) { + der_locale_array[der_locale_len].undefined_idx = base_locale_array[base_locale_len].undefined_idx; + } +#endif + + if (!der_locale_array[der_locale_len].undefined_idx) { + error_msg("no UNDEFINED definition for %s", cl->name); + } + + ++der_locale_len; + } + +#endif + +#warning handle UNDEFINED idx specially? what if in only some of derived? +/* base_locale_array[base_locale_len].undefined_idx = final_index_val0("UNDEFINED"); */ + base_locale_array[base_locale_len].undefined_idx = 0; + + + hdestroy(); + + ++base_locale_len; + +/* if (tnumnodes(cur_base->root_starter_char)) { */ +/* fprintf(stderr, "starter nodes\n"); */ +/* twalk(cur_base->root_starter_char, print_starter_node); */ +/* } */ +} + +static int starter_all_cmp(const void *n1, const void *n2) +{ + const char *s1 = ((weighted_item_t *) n1)->symbol; + const char *s2 = ((weighted_item_t *) n2)->symbol; + colitem_t x; + colitem_t *p; + int n; + + /* sort by 1st char ... then inverse for string */ + + x.element = NULL; + if (!is_ucode(s1)) { + x.string = s1; + p = tfind(&x, &cur_base->root_colitem, colitem_cmp); + s1 = (*((colitem_t **) p))->element + 1; + } + if (!is_ucode(s2)) { + x.string = s2; + p = tfind(&x, &cur_base->root_colitem, colitem_cmp); + s2 = (*((colitem_t **) p))->element + 1; + } + + /* < */ + /* 01234567 */ + + assert(is_ucode(s1)); + assert(is_ucode(s2)); + + n = strncmp(s1+2, s2+2, 4); + if (n) { + return n; + } + + s1 += 7; + s2 += 7; + + return strcmp(s2, s1); +} + +static void print_starter_all_node(const void *ptr, VISIT order, int level) +{ + const weighted_item_t *w = *(const weighted_item_t **) ptr; + colitem_t *ci; + void *p; + int n; + colitem_t x; + + if (order == postorder || order == leaf) { +#if 0 + if ((n = is_ucode(w->symbol)) != 0) { + printf(" %s\n", w->symbol); + } else { + x.string = w->symbol; + x.element = NULL; + p = tfind(&x, &cur_base->root_colitem, colitem_cmp); + assert(p); + ci = *((colitem_t **) p); + printf("%s = %s\n", ci->element, w->symbol); + } +#else + printf("%s|", w->symbol); +/* if ((n = is_ucode(w->symbol)) != 0) { */ +/* printf("\n"); */ +/* } */ +#endif + } +} + +static void process_starter_node(const void *ptr, VISIT order, int level) +{ + const weighted_item_t *w = *(const weighted_item_t **) ptr; + colitem_t *ci; + void *p; + int n; + colitem_t x; + const char *s; + char buf[32]; + + /* store index of collation item followed by (unprefixed) nul-terminated string */ + if (order == postorder || order == leaf) { + if ((n = is_ucode(w->symbol)) != 0) { + u16_buf[u16_buf_len++] = final_index_val(w->symbol); + assert(u16_buf[u16_buf_len-1]); + u16_buf[u16_buf_len++] = 0; + if (++u16_starter < base_locale_array[base_locale_len].num_starters) { + u16_buf[u16_starter] = u16_buf_len; + } +/* fprintf(stderr, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */ + } else { + x.string = w->symbol; + x.element = NULL; + p = tfind(&x, &cur_base->root_colitem, colitem_cmp); + assert(p); + ci = *((colitem_t **) p); + s = ci->element; + u16_buf[u16_buf_len++] = final_index_val(w->symbol); + assert(u16_buf[u16_buf_len-1]); + assert(*s == '"'); + n = is_ucode(++s); +/* fprintf(stderr, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */ + assert(n); + s += n; + while (*s != '"') { + n = is_ucode(s); + assert(n); + strncpy(buf, s, n+1); + buf[n] = 0; +/* fprintf(stderr, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */ + u16_buf[u16_buf_len++] = final_index_val(buf); + assert(u16_buf[u16_buf_len-1]); + s += n; + } + u16_buf[u16_buf_len++] = 0; + } + } +} + +static void **p_cl_root_starter_all; + +static void complete_starter_node(const void *ptr, VISIT order, int level) +{ + weighted_item_t w; + weighted_item_t *p; + + if (order == postorder || order == leaf) { + w.symbol = *(const char **) ptr; + w.weight = NULL; + if (!tfind(&w, p_cl_root_starter_all, starter_all_cmp)) { + p = xmalloc(sizeof(weighted_item_t)); + p->symbol = w.symbol; + p->weight = NULL; +/* fprintf(stderr, "complete_starter_node: %s\n", *(const char **) ptr); */ + if (!tsearch(p, p_cl_root_starter_all, starter_all_cmp)) { + error_msg("OUT OF MEMORY"); + } + } + } +} + +static void do_starter_lists(col_locale_t *cl) +{ + ll_item_t *s; + ll_item_t *h; + ll_item_t *lli; + col_locale_t *c; + colitem_t *ci; + weighted_item_t *w; + void *p; + char buf[32]; + int n; + colitem_t x; + void *mm; + + c = cl; + if (c != cur_base) { + c = cur_base; + } + +/* printf("STARTERS %s --------------------\n", cl->name); */ + LOOP: + for (s = c->section_list ; s ; s = s->next) { + h = lli = ((section_t *)(s->data))->itm_list; + if (!lli) { + continue; + } + do { + if (lli->data_type & DT_WEIGHTED) { + w = (weighted_item_t *)(lli->data); + ci = NULL; + if ((n = is_ucode(w->symbol)) != 0) { + strcpy(buf, w->symbol); + } else { +/* fprintf(stdout, "looking for |%s|\n", w->symbol); */ + x.string = w->symbol; + x.element = NULL; + p = tfind(&x, &cur_base->root_colitem, colitem_cmp); + if (!p) { +/* fprintf(stderr, "Whoa... processing starters for %s and couldn't find %s\n", */ +/* cl->name, w->symbol); */ + continue; + } + ci = *((colitem_t **) p); + if (!ci->element) { /* just a collating symbol */ + continue; + } + assert(ci->element[0] == '"'); + n = is_ucode(ci->element + 1); + assert(n); + strncpy(buf, ci->element + 1, n); + } + if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { +/* fprintf(stdout, "adding from %s: %s", c->name, w->symbol); */ +/* if (ci) { */ +/* fprintf(stdout, " = %s", ci->element); */ +/* } */ +/* fprintf(stdout, "\n"); */ + + if (!tsearch(w, &cl->root_starter_all, starter_all_cmp)) { + error_msg("OUT OF MEMORY"); + } + } + } + } while ((lli = lli->next) != h); + } + + if (c != cl) { + c = cl; + goto LOOP; + } + + p_cl_root_starter_all = &cl->root_starter_all; + twalk(cur_base->root_starter_char, complete_starter_node); + + if (cl == cur_base) { + base_locale_array[base_locale_len].num_starters = tnumnodes(cur_base->root_starter_char); + } + +#if 0 + printf("\nNow walking tree...\n\n"); + twalk(cl->root_starter_all, print_starter_all_node); + printf("\n\n"); + +#endif + u16_starter = 0; + u16_buf[0] = u16_buf_len = base_locale_array[base_locale_len].num_starters; + twalk(cl->root_starter_all, process_starter_node); +/* fprintf(stderr, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */ + assert(u16_starter == base_locale_array[base_locale_len].num_starters); + +#if 0 + { int i; + for (i=0 ; i < u16_buf_len ; i++) { + fprintf(stderr, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]); + }} +#endif + + mm = NULL; + if (u16_buf_len) { +/* assert(base_locale_array[base_locale_len].num_starters); */ + if ((u16_buf_len > multistart_len) || + !(mm = memmem(multistart_buffer, multistart_len*sizeof(multistart_buffer[0]), + u16_buf, u16_buf_len*sizeof(u16_buf[0]))) + ) { + assert(multistart_len + u16_buf_len < MULTISTART_LEN); + memcpy(multistart_buffer + multistart_len, u16_buf, u16_buf_len*sizeof(u16_buf[0])); + if (cl == cur_base) { + base_locale_array[base_locale_len].multistart_offset = multistart_len; + } else { + der_locale_array[der_locale_len].multistart_offset = multistart_len; + } + multistart_len += u16_buf_len; +/* fprintf(stderr, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */ + } else if (!(u16_buf_len > multistart_len)) { + assert(mm); + if (cl == cur_base) { + base_locale_array[base_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer; + } else { + der_locale_array[der_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer; + } +/* fprintf(stderr, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ + } + } else { + assert(!base_locale_array[base_locale_len].num_starters); + } + +/* printf("u16_buf_len = %d\n", u16_buf_len); */ + +/* printf("STARTERS %s DONE ---------------\n", cl->name); */ +} + + +/* For sorting the blocks of unsigned chars. */ +static size_t nu_val; + +int nu_memcmp(const void *a, const void *b) +{ + return memcmp(*(unsigned char**)a, *(unsigned char**)b, nu_val * sizeof(tbl_item)); +} + + +size_t newopt(tbl_item *ut, size_t usize, int shift, table_data *tbl) +{ + static int recurse = 0; + tbl_item *ti[RANGE]; /* table index */ + size_t numblocks; + size_t blocksize; + size_t uniq; + size_t i, j; + size_t smallest, t; + tbl_item *ii_save; + int uniqblock[1 << (8*sizeof(tbl_item) - 1)]; + tbl_item uit[RANGE]; + int shift2; + + if (shift > 15) { + return SIZE_MAX; + } + + ii_save = NULL; + blocksize = 1 << shift; + numblocks = usize >> shift; + + /* init table index */ + for (i=j=0 ; i < numblocks ; i++) { + ti[i] = ut + j; + j += blocksize; + } + + /* sort */ + nu_val = blocksize; + qsort(ti, numblocks, sizeof(unsigned char *), nu_memcmp); + + uniq = 1; + uit[(ti[0]-ut)/blocksize] = 0; + for (i=1 ; i < numblocks ; i++) { + if (memcmp(ti[i-1], ti[i], blocksize*sizeof(tbl_item)) < 0) { + if (++uniq > (1 << (8*sizeof(tbl_item) - 1))) { + break; + } + uniqblock[uniq - 1] = i; + } +#if 1 + else if (memcmp(ti[i-1], ti[i], blocksize*sizeof(tbl_item)) > 0) { + printf("bad sort %i!\n", i); + abort(); + } +#endif + uit[(ti[i]-ut)/blocksize] = uniq - 1; + } + + smallest = SIZE_MAX; + shift2 = -1; + if (uniq <= (1 << (8*sizeof(tbl_item) - 1))) { + smallest = numblocks + uniq * blocksize; + if (!recurse) { + ++recurse; + for (j=1 ; j < 14 ; j++) { + if ((numblocks >> j) < 2) break; + if (tbl) { + ii_save = tbl->ii; + tbl->ii = NULL; + } + if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) { + t += uniq * blocksize; + } + if (tbl) { + tbl->ii = ii_save; + } + if (smallest >= t) { + shift2 = j; + smallest = t; +/* if (!tbl->ii) { */ +/* printf("ishift %u tshift %u size %u\n", */ +/* shift2, shift, t); */ +/* } */ +/* } else { */ +/* break; */ + } + } + --recurse; + } + } else { + return SIZE_MAX; + } + + if (tbl->ii) { + if (recurse) { + tbl->ii_shift = shift; + tbl->ii_len = numblocks; + memcpy(tbl->ii, uit, numblocks*sizeof(tbl_item)); + tbl->ti = tbl->ii + tbl->ii_len; + tbl->ti_len = uniq * blocksize; + for (i=0 ; i < uniq ; i++) { + memcpy(tbl->ti + i * blocksize, ti[uniqblock[i]], blocksize*sizeof(tbl_item)); + } + } else { + ++recurse; +/* printf("setting ishift %u tshift %u\n", shift2, shift); */ + newopt(uit, numblocks, shift2, tbl); + --recurse; + tbl->ti_shift = shift; + tbl->ut_len = uniq * blocksize; + tbl->ut = tbl->ti + tbl->ti_len; + for (i=0 ; i < uniq ; i++) { + memcpy(tbl->ut + i * blocksize, ti[uniqblock[i]], blocksize*sizeof(tbl_item)); + } + } + } + return smallest; +} + +static const int rule2val[8] = { + -1, + (1 << 14), /* forward */ + (2 << 14), /* position */ + (3 << 14), /* forward,position */ + 0, /* backward */ + -1, + -1, + -1, +}; + + +static int final_index_val_x(const char *s, const char *sym) +{ + int r; + + if (!(r = final_index_val0(s))) { + if (!strcmp(s, "IGNORE")) { + r = 0; + } else if (!strcmp(s, "..") || !strcmp(sym, "RANGE")) { + if (*sym == '.') { + final_index_val(sym); /* make sure it's known */ + } + r = 0x3fff; + } else if (!strcmp(s, ".")) { + r = 0x3ffe; + } else { + error_msg("can't find final index: %s", s); + } + } + return r; +} + +/* store rule2val in 2 high bits and collation index in lower. + * for sort strings, store (offset from base) + max colindex as index. + */ +static unsigned int add_rule(weighted_item_t *wi) +{ + weight_t *w = wi->weight; + int i, j, r, n; + uint16_t rbuf[MAX_COLLATION_WEIGHTS]; + uint16_t ws_buf[32]; + void *mm; + char buf[32]; + const char *s; + const char *e; + + for (i=0 ; i < MAX_COLLATION_WEIGHTS ; i++) { + rbuf[i] = rule2val[R_FORWARD]; /* set a default to forward-ignore */ + } + + if (base_locale_array[base_locale_len].num_weights < w->num_weights) { + base_locale_array[base_locale_len].num_weights = w->num_weights; + } + + for (i=0 ; i < w->num_weights ; i++) { + assert(rule2val[(int)(w->rule[i])] >= 0); + assert(w->colitem[i] && *w->colitem[i]); + if (*w->colitem[i] == '"') { /* string... */ + s = w->colitem[i] + 1; + assert(*s == '<'); + n = 0; + do { + e = s; + do { + if (*e == '/') { + e += 2; + continue; + } + } while (*e++ != '>'); + assert(((size_t)(e-s) < sizeof(buf))); + memcpy(buf, s, (size_t)(e-s)); + buf[(size_t)(e-s)] = 0; + + r = final_index_val_x(buf, wi->symbol); + assert(n + 1 < sizeof(ws_buf)/sizeof(ws_buf[0])); + ws_buf[n++] = r | rule2val[(int)(w->rule[i])]; + + s = e; + } while (*s != '"'); + ws_buf[n++] = 0; /* terminator */ + + mm = memmem(weightstr_buffer, weightstr_len*sizeof(weightstr_buffer[0]), + ws_buf, n*sizeof(ws_buf[0])); + + if (!mm) { + assert(weightstr_len + n < WEIGHTSTR_LEN); + memcpy(weightstr_buffer + weightstr_len, ws_buf, n*sizeof(ws_buf[0])); + mm = weightstr_buffer + weightstr_len; + weightstr_len += n; + } + r = (((uint16_t *)(mm)) - weightstr_buffer) + + base_locale_array[base_locale_len].max_col_index + 2; + assert(r < (1 << 14)); + rbuf[i] = r | rule2val[(int)(w->rule[i])]; + } else { /* item */ + r = final_index_val_x(w->colitem[i], wi->symbol); + rbuf[i] = r | rule2val[(int)(w->rule[i])]; + } + } + + for (i=0 ; i < ruletable_len ; i += MAX_COLLATION_WEIGHTS) { + if (!memcmp(ruletable_buffer + i, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0]))) { + return i/MAX_COLLATION_WEIGHTS; + } + } + + memcpy(ruletable_buffer + ruletable_len, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0])); + ruletable_len += MAX_COLLATION_WEIGHTS; + + return (ruletable_len / MAX_COLLATION_WEIGHTS)-1; +} + +static unsigned int add_range_rule(range_item_t *ri) +{ + weight_t *w = ri->weight; + int i, j, r, n; + uint16_t rbuf[MAX_COLLATION_WEIGHTS]; + uint16_t ws_buf[32]; + void *mm; + char buf[32]; + const char *s; + const char *e; + + for (i=0 ; i < MAX_COLLATION_WEIGHTS ; i++) { + rbuf[i] = rule2val[R_FORWARD]; /* set a default to forward-ignore */ + } + + if (base_locale_array[base_locale_len].num_weights < w->num_weights) { + base_locale_array[base_locale_len].num_weights = w->num_weights; + } + + for (i=0 ; i < w->num_weights ; i++) { + assert(rule2val[(int)(w->rule[i])] >= 0); + assert(w->colitem[i] && *w->colitem[i]); + if (*w->colitem[i] == '"') { /* string... */ + s = w->colitem[i] + 1; + assert(*s == '<'); + n = 0; + do { + e = s; + do { + if (*e == '/') { + e += 2; + continue; + } + } while (*e++ != '>'); + assert(((size_t)(e-s) < sizeof(buf))); + memcpy(buf, s, (size_t)(e-s)); + buf[(size_t)(e-s)] = 0; + + r = final_index_val_x(buf, "RANGE"); + assert(n + 1 < sizeof(ws_buf)/sizeof(ws_buf[0])); + ws_buf[n++] = r | rule2val[(int)(w->rule[i])]; + + s = e; + } while (*s != '"'); + ws_buf[n++] = 0; /* terminator */ + + mm = memmem(weightstr_buffer, weightstr_len*sizeof(weightstr_buffer[0]), + ws_buf, n*sizeof(ws_buf[0])); + + if (!mm) { + assert(weightstr_len + n < WEIGHTSTR_LEN); + memcpy(weightstr_buffer + weightstr_len, ws_buf, n*sizeof(ws_buf[0])); + mm = weightstr_buffer + weightstr_len; + weightstr_len += n; + } + r = (((uint16_t *)(mm)) - weightstr_buffer) + + base_locale_array[base_locale_len].max_col_index + 2; + assert(r < (1 << 14)); + rbuf[i] = r | rule2val[(int)(w->rule[i])]; + } else { /* item */ + r = final_index_val_x(w->colitem[i], "RANGE"); + rbuf[i] = r | rule2val[(int)(w->rule[i])]; + } + } + + for (i=0 ; i < ruletable_len ; i += MAX_COLLATION_WEIGHTS) { + if (!memcmp(ruletable_buffer + i, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0]))) { + return i/MAX_COLLATION_WEIGHTS; + } + } + + memcpy(ruletable_buffer + ruletable_len, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0])); + ruletable_len += MAX_COLLATION_WEIGHTS; + + return (ruletable_len / MAX_COLLATION_WEIGHTS)-1; +} + +#define DUMPn(X) fprintf(stderr, "%10d-%-.20s", base_locale_array[n]. X, #X); + +static void dump_base_locale(int n) +{ + assert(n < base_locale_len); + + fprintf(stderr, "Base Locale: %s\n", base_locale_array[n].name); + + DUMPn(num_weights); + + DUMPn(ii_shift); + DUMPn(ti_shift); + DUMPn(ii_len); + DUMPn(ti_len); + DUMPn(max_weight); + fprintf(stderr, "\n"); + DUMPn(num_col_base); + DUMPn(max_col_index); + DUMPn(undefined_idx); + DUMPn(range_low); + DUMPn(range_count); + fprintf(stderr, "\n"); + DUMPn(range_base_weight); + DUMPn(num_starters); + + fprintf(stderr, "\n"); + DUMPn(range_rule_offset); + DUMPn(wcs2colidt_offset); + DUMPn(index2weight_offset); + fprintf(stderr, "\n"); + DUMPn(index2ruleidx_offset); + DUMPn(multistart_offset); + fprintf(stderr, "\n"); +} + +#undef DUMPn +#define DUMPn(X) fprintf(stderr, "%10d-%s", der_locale_array[n]. X, #X); + +static void dump_der_locale(int n) +{ + assert(n < der_locale_len); + + fprintf(stderr, "Derived Locale: %s (%.12s)", + der_locale_array[n].name, + base_locale_array[der_locale_array[n].base_idx].name); + + + DUMPn(base_idx); + + DUMPn(undefined_idx); + + DUMPn(overrides_offset); + DUMPn(multistart_offset); + + fprintf(stderr, "\n"); +} + + +static unsigned long collate_pos; + +static void dump_u16_array(FILE *fp, uint16_t *u, int len, const char *name) +{ + int i; + + fprintf(fp, "\t/* %8lu %s */\n", collate_pos, name); + for (i=0 ; i < len ; i++) { + if (!(i & 7)) { + fprintf(fp, "\n\t"); + } + fprintf(fp," %#06x,", (unsigned int)(u[i])); + } + fprintf(fp,"\n"); + collate_pos += len; +} + +#define OUT_U16C(X,N) fprintf(fp,"\t%10d, /* %8lu %s */\n", X, collate_pos++, N); + +static void dump_collate(FILE *fp) +{ + int n; + + fprintf(fp, "const uint16_t __locale_collate_tbl[] = {\n"); + + OUT_U16C(base_locale_len, "numbef of base locales"); + OUT_U16C(der_locale_len, "number of derived locales"); + OUT_U16C(MAX_COLLATION_WEIGHTS, "max collation weights"); + OUT_U16C(index2weight_len, "number of index2{weight|ruleidx} elements"); + OUT_U16C(weightstr_len, "number of weightstr elements"); + OUT_U16C(multistart_len, "number of multistart elements"); + OUT_U16C(override_len, "number of override elements"); + OUT_U16C(ruletable_len, "number of ruletable elements"); + +#undef DUMPn +#define DUMPn(X) fprintf(fp, "\t%10d, /* %8lu %s */\n", base_locale_array[n]. X, collate_pos++, #X); + for (n=0 ; n < base_locale_len ; n++) { + unsigned wcs2colidt_offset_low = base_locale_array[n].wcs2colidt_offset & 0xffffU; + unsigned wcs2colidt_offset_hi = base_locale_array[n].wcs2colidt_offset >> 16; + fprintf(fp, "\t/* Base Locale %2d: %s */\n", n, base_locale_array[n].name); + DUMPn(num_weights); + DUMPn(num_starters); + DUMPn(ii_shift); + DUMPn(ti_shift); + DUMPn(ii_len); + DUMPn(ti_len); + DUMPn(max_weight); + DUMPn(num_col_base); + DUMPn(max_col_index); + DUMPn(undefined_idx); + DUMPn(range_low); + DUMPn(range_count); + DUMPn(range_base_weight); + DUMPn(range_rule_offset); + DUMPn(index2weight_offset); + DUMPn(index2ruleidx_offset); + DUMPn(multistart_offset); +#undef DUMPn +#define DUMPn(X) fprintf(fp, "\t%10d, /* %8lu %s */\n", X, collate_pos++, #X); + DUMPn(wcs2colidt_offset_low); + DUMPn(wcs2colidt_offset_hi); + } +#undef DUMPn + + + fprintf(fp, "#define COL_IDX_C %5d\n", 0); +#define DUMPn(X) fprintf(fp, "\t%10d, /* %8lu %s */\n", der_locale_array[n]. X, collate_pos++, #X); + for (n=0 ; n < der_locale_len ; n++) { + fprintf(fp, "#define COL_IDX_%s %5d\n", der_locale_array[n].name, n+1); + fprintf(fp, "\t/* Derived Locale %4d: %s (%.12s) */\n", + n, der_locale_array[n].name, + base_locale_array[der_locale_array[n].base_idx].name); + DUMPn(base_idx); + DUMPn(undefined_idx); + DUMPn(overrides_offset); + DUMPn(multistart_offset); + } +#undef DUMPn + + fprintf(fp, "\n"); + + dump_u16_array(fp, index2weight_buffer, index2weight_len, "index2weight"); + dump_u16_array(fp, index2ruleidx_buffer, index2ruleidx_len, "index2ruleidx"); + dump_u16_array(fp, multistart_buffer, multistart_len, "multistart"); + dump_u16_array(fp, override_buffer, override_len, "override"); + dump_u16_array(fp, ruletable_buffer, ruletable_len, "ruletable"); + dump_u16_array(fp, weightstr_buffer, weightstr_len, "weightstr"); + dump_u16_array(fp, wcs2colidt_buffer, wcs2colidt_len, "wcs2colidt"); + + + fprintf(fp,"}; /* %8lu */\n", collate_pos); + + fprintf(fp,"#define __lc_collate_data_LEN %d\n\n", collate_pos); +} diff --git a/extra/locale/gen_ldc.c b/extra/locale/gen_ldc.c new file mode 100644 index 0000000..3ffc90e --- /dev/null +++ b/extra/locale/gen_ldc.c @@ -0,0 +1,295 @@ +#include +#include +#include +#include +#include +#include + +#ifndef __WCHAR_ENABLED +#warning WHOA!!! __WCHAR_ENABLED is not defined! defining it now... +#define __WCHAR_ENABLED +#endif + +#define WANT_DATA +#include "c8tables.h" +#ifndef __CTYPE_HAS_8_BIT_LOCALES +#warning __CTYPE_HAS_8_BIT_LOCALES is not defined... +/* #define __CTYPE_HAS_8_BIT_LOCALES */ +#endif + +/* #define __LOCALE_DATA_Cctype_TBL_LEN 328 */ +/* #define __LOCALE_DATA_Cuplow_TBL_LEN 400 */ +/* #define __LOCALE_DATA_Cc2wc_TBL_LEN 1448 */ +/* #define __LOCALE_DATA_Cwc2c_TBL_LEN 3744 */ + +#define WANT_WCctype_data +#define WANT_WCuplow_data +#define WANT_WCuplow_diff_data +/* #define WANT_WCcomb_data */ +/* #define WANT_WCwidth_data */ +#include "wctables.h" +#undef WANT_WCctype_data +#undef WANT_WCuplow_data +#undef WANT_WCuplow_diff_data +/* #undef WANT_WCcomb_data */ +/* #undef WANT_WCwidth_data */ + + #define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN) + #define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN) + #define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs) +/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */ + +#include "locale_collate.h" +#include "locale_tables.h" + +#include "locale_mmap.h" + +/* #undef __PASTE2 */ +/* #define __PASTE2(A,B) A ## B */ +/* #undef __PASTE3 */ +/* #define __PASTE3(A,B,C) A ## B ## C */ + + +/* #define __LOCALE_DATA_MAGIC_SIZE 64 */ + +/* #define COMMON_MMAP(X) \ */ +/* unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; */ + +/* #define COMMON_MMIDX(X) \ */ +/* unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \ */ +/* uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \ */ +/* uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \ */ + +/* ---------------------------------------------------------------------- */ + +#define COMMON_OFFSETS(X) \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_rows)), \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_offsets)), \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_idx)), \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)) \ + + +static const size_t common_tbl_offsets[__LOCALE_DATA_CATEGORIES*4] = { + COMMON_OFFSETS(ctype), + COMMON_OFFSETS(numeric), + COMMON_OFFSETS(monetary), + COMMON_OFFSETS(time), + 0, 0, 0, 0, /* collate */ + COMMON_OFFSETS(messages), +}; + + +void out_uc(FILE *f, const unsigned char *p, size_t n, char *comment) +{ + size_t i; + + fprintf(f, "{\t/* %s */", comment); + for (i = 0 ; i < n ; i++) { + if (!(i & 7)) { + fprintf(f, "\n\t"); + } + if (p[i]) { + fprintf(f, "%#04x, ", p[i]); + } else { + fprintf(f, "%#4x, ", p[i]); + } + } + fprintf(f, "\n},\n"); +} + +void out_u16(FILE *f, const uint16_t *p, size_t n, char *comment) +{ + size_t i; + + fprintf(f, "{\t/* %s */", comment); + for (i = 0 ; i < n ; i++) { + if (!(i & 7)) { + fprintf(f, "\n\t"); + } + if (p[i]) { + fprintf(f, "%#06x, ", p[i]); + } else { + fprintf(f, "%#6x, ", p[i]); + } + } + fprintf(f, "\n},\n"); +} + +void out_i16(FILE *f, const int16_t *p, size_t n, char *comment) +{ + size_t i; + + fprintf(f, "{\t/* %s */", comment); + for (i = 0 ; i < n ; i++) { + if (!(i & 7)) { + fprintf(f, "\n\t"); + } + fprintf(f, "%6d, ", p[i]); + } + fprintf(f, "\n},\n"); +} + +void out_size_t(FILE *f, const size_t *p, size_t n, char *comment) +{ + size_t i; + + fprintf(f, "{\t/* %s */", comment); + for (i = 0 ; i < n ; i++) { + if (!(i & 3)) { + fprintf(f, "\n\t"); + } + if (p[i]) { + fprintf(f, "%#010zx, ", p[i]); + } else { + fprintf(f, "%#10zx, ", p[i]); + } + } + fprintf(f, "\n},\n"); +} + + +int main(void) +{ + FILE *lso; /* static object */ + int i; +#ifdef __LOCALE_DATA_MAGIC_SIZE + unsigned char magic[__LOCALE_DATA_MAGIC_SIZE]; + + memset(magic, 0, __LOCALE_DATA_MAGIC_SIZE); +#endif /* __LOCALE_DATA_MAGIC_SIZE */ + + if (!(lso = fopen("locale_data.c", "w"))) { + printf("can't open locale_data.c!\n"); + return EXIT_FAILURE; + } + + fprintf(lso, + "#include \n" + "#include \n" +/* "#define __CTYPE_HAS_8_BIT_LOCALES\n" */ + "#ifndef __WCHAR_ENABLED\n" + "#error __WCHAR_ENABLED not defined\n" + "#endif\n" + "#include \"c8tables.h\"\n" + "#include \"wctables.h\"\n" + "#include \"lt_defines.h\"\n" + "#include \"locale_mmap.h\"\n\n" + "static const __locale_mmap_t locale_mmap = {\n\n" + ); +#ifdef __LOCALE_DATA_MAGIC_SIZE + out_uc(lso, magic, __LOCALE_DATA_MAGIC_SIZE, "magic"); +#endif /* __LOCALE_DATA_MAGIC_SIZE */ +#ifdef __CTYPE_HAS_8_BIT_LOCALES + out_uc(lso, __LOCALE_DATA_Cctype_data, __LOCALE_DATA_Cctype_TBL_LEN, "tbl8ctype"); + out_uc(lso, __LOCALE_DATA_Cuplow_data, __LOCALE_DATA_Cuplow_TBL_LEN, "tbl8uplow"); +#ifdef __WCHAR_ENABLED + out_u16(lso, __LOCALE_DATA_Cc2wc_data, __LOCALE_DATA_Cc2wc_TBL_LEN, "tbl8c2wc"); + out_uc(lso, __LOCALE_DATA_Cwc2c_data, __LOCALE_DATA_Cwc2c_TBL_LEN, "tbl8wc2c"); + /* translit */ +#endif /* __WCHAR_ENABLED */ +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ +#ifdef __WCHAR_ENABLED + out_uc(lso, __LOCALE_DATA_WCctype_data, __LOCALE_DATA_WCctype_TBL_LEN, "tblwctype"); + out_uc(lso, __LOCALE_DATA_WCuplow_data, __LOCALE_DATA_WCuplow_TBL_LEN, "tblwuplow"); + out_i16(lso, __LOCALE_DATA_WCuplow_diff_data, __LOCALE_DATA_WCuplow_diff_TBL_LEN, "tblwuplow_diff"); +/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */ + /* width?? */ +#endif /* __WCHAR_ENABLED */ + out_uc(lso, __lc_ctype_data, __lc_ctype_data_LEN, "lc_ctype_data"); + out_uc(lso, __lc_numeric_data, __lc_numeric_data_LEN, "lc_numeric_data"); + out_uc(lso, __lc_monetary_data, __lc_monetary_data_LEN, "lc_monetary_data"); + out_uc(lso, __lc_time_data, __lc_time_data_LEN, "lc_time_data"); + /* TODO -- collate*/ + out_uc(lso, __lc_messages_data, __lc_messages_data_LEN, "lc_messages_data"); + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + fprintf(lso, "{ /* codeset_8_bit array */\n"); + for (i = 0 ; i < __LOCALE_DATA_NUM_CODESETS ; i++) { + fprintf(lso, "{ /* codeset_8_bit[%d] */\n", i); + out_uc(lso, codeset_8_bit[i].idx8ctype, __LOCALE_DATA_Cctype_IDX_LEN, "idx8ctype"); + out_uc(lso, codeset_8_bit[i].idx8uplow, __LOCALE_DATA_Cuplow_IDX_LEN, "idx8uplow"); + out_uc(lso, codeset_8_bit[i].idx8c2wc, __LOCALE_DATA_Cc2wc_IDX_LEN, "idx8c2wc"); + out_uc(lso, codeset_8_bit[i].idx8wc2c, __LOCALE_DATA_Cwc2c_II_LEN, "idx8wc2c"); + fprintf(lso, "},\n"); + } + fprintf(lso, "},\n"); +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + + out_uc(lso, __lc_ctype_rows, __lc_ctype_rows_LEN, "lc_ctype_rows"); + out_u16(lso, __lc_ctype_item_offsets, __lc_ctype_item_offsets_LEN, "lc_ctype_item_offsets"); + out_u16(lso, __lc_ctype_item_idx, __lc_ctype_item_idx_LEN, "lc_ctype_item_idx"); + + out_uc(lso, __lc_numeric_rows, __lc_numeric_rows_LEN, "lc_numeric_rows"); + out_u16(lso, __lc_numeric_item_offsets, __lc_numeric_item_offsets_LEN, "lc_numeric_item_offsets"); + out_u16(lso, __lc_numeric_item_idx, __lc_numeric_item_idx_LEN, "lc_numeric_item_idx"); + + out_uc(lso, __lc_monetary_rows, __lc_monetary_rows_LEN, "lc_monetary_rows"); + out_u16(lso, __lc_monetary_item_offsets, __lc_monetary_item_offsets_LEN, "lc_monetary_item_offsets"); + out_u16(lso, __lc_monetary_item_idx, __lc_monetary_item_idx_LEN, "lc_monetary_item_idx"); + + out_uc(lso, __lc_time_rows, __lc_time_rows_LEN, "lc_time_rows"); + out_u16(lso, __lc_time_item_offsets, __lc_time_item_offsets_LEN, "lc_time_item_offsets"); + out_u16(lso, __lc_time_item_idx, __lc_time_item_idx_LEN, "lc_time_item_idx"); + + out_uc(lso, __lc_messages_rows, __lc_messages_rows_LEN, "lc_messages_rows"); + out_u16(lso, __lc_messages_item_offsets, __lc_messages_item_offsets_LEN, "lc_messages_item_offsets"); + out_u16(lso, __lc_messages_item_idx, __lc_messages_item_idx_LEN, "lc_messages_item_idx"); + + /* collate should be last*/ + assert(sizeof(__locale_collate_tbl)/sizeof(__locale_collate_tbl[0]) == __lc_collate_data_LEN) ; + out_u16(lso, __locale_collate_tbl, __lc_collate_data_LEN, "collate_data"); + + + { + unsigned char co_buf[__LOCALE_DATA_CATEGORIES] = { + __lc_ctype_item_offsets_LEN, + __lc_numeric_item_offsets_LEN, + __lc_monetary_item_offsets_LEN, + __lc_time_item_offsets_LEN, + 0, + __lc_messages_item_offsets_LEN + }; + out_uc(lso, co_buf, __LOCALE_DATA_CATEGORIES, "lc_common_item_offsets_LEN"); + } + + out_size_t(lso, common_tbl_offsets, __LOCALE_DATA_CATEGORIES * 4, "lc_common_tbl_offsets"); + /* offsets from start of locale_mmap_t */ + /* rows, item_offsets, item_idx, data */ + +#ifdef __LOCALE_DATA_NUM_LOCALES + out_uc(lso, __locales, __LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES, "locales"); + out_uc(lso, __locale_names5, 5 * __LOCALE_DATA_NUM_LOCALE_NAMES, "locale_names5"); +#ifdef __LOCALE_DATA_AT_MODIFIERS_LENGTH + out_uc(lso, __locale_at_modifiers, __LOCALE_DATA_AT_MODIFIERS_LENGTH, "locale_at_modifiers"); +#else +#error __LOCALE_DATA_AT_MODIFIERS_LENGTH not defined! +#endif /* __LOCALE_DATA_AT_MODIFIERS_LENGTH */ +#endif /* __LOCALE_DATA_NUM_LOCALES */ + + out_uc(lso, lc_names, __lc_names_LEN, "lc_names"); +#ifdef __CTYPE_HAS_8_BIT_LOCALES + out_uc(lso, (const unsigned char*) __LOCALE_DATA_CODESET_LIST, sizeof(__LOCALE_DATA_CODESET_LIST), "codeset_list"); +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + + fprintf(lso, + "\n};\n\n" + "const __locale_mmap_t *__locale_mmap = &locale_mmap;\n\n" + ); + + if (ferror(lso) || fclose(lso)) { + printf("error writing!\n"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +/* ---------------------------------------------------------------------- */ + +/* TODO: + * collate data (8-bit weighted single char only) + * @ mappings! + * codeset list? yes, since we'll want to be able to inspect them... + * that means putting some header stuff in magic + * fix ctype LEN defines in gen_c8tables + */ diff --git a/extra/locale/gen_locale.c b/extra/locale/gen_locale.c new file mode 100644 index 0000000..388f543 --- /dev/null +++ b/extra/locale/gen_locale.c @@ -0,0 +1,1319 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "c8tables.h" + + +#define __LOCALE_DATA_CATEGORIES 6 + +/* must agree with ordering of gen_mmap! */ +static const unsigned char *lc_names[] = { + "LC_CTYPE", + "LC_NUMERIC", + "LC_MONETARY", + "LC_TIME", + "LC_COLLATE", + "LC_MESSAGES", +#if __LOCALE_DATA_CATEGORIES == 12 + "LC_PAPER", + "LC_NAME", + "LC_ADDRESS", + "LC_TELEPHONE", + "LC_MEASUREMENT", + "LC_IDENTIFICATION", +#elif __LOCALE_DATA_CATEGORIES != 6 +#error unsupported __LOCALE_DATA_CATEGORIES value! +#endif +}; + + + +typedef struct { + char *glibc_name; + char name[5]; + char dot_cs; /* 0 if no codeset specified */ + char cs; + unsigned char idx_name; + unsigned char lc_time_row; + unsigned char lc_numeric_row; + unsigned char lc_monetary_row; + unsigned char lc_messages_row; + unsigned char lc_ctype_row; +#if __LOCALE_DATA_CATEGORIES != 6 +#error unsupported __LOCALE_DATA_CATEGORIES value +#endif +} locale_entry; + +static void read_at_mappings(void); +static void read_enable_disable(void); +static void read_locale_list(void); + +static int find_codeset_num(const char *cs); +static int find_at_string_num(const char *as); +static int le_cmp(const void *, const void *); +static void dump_table8(const char *name, const char *tbl, int len); +static void dump_table8c(const char *name, const char *tbl, int len); +static void dump_table16(const char *name, const int *tbl, int len); + +static void do_lc_time(void); +static void do_lc_numeric(void); +static void do_lc_monetary(void); + +static void do_lc_messages(void); +static void do_lc_ctype(void); + + +static FILE *fp; +static FILE *ofp; +static char line_buf[80]; +static char at_mappings[256]; +static char at_mapto[256]; +static char at_strings[1024]; +static char *at_strings_end; +static locale_entry locales[700]; +static char glibc_locale_names[60000]; + +static int num_locales; + +static int default_utf8; +static int default_8bit; + +static int total_size; +static int null_count; + +static void do_locale_names(void) +{ + /* "C" locale name is handled specially by the setlocale code. */ + int uniq = 0; + int i; + + if (num_locales <= 1) { +/* printf("error - only C locale?\n"); */ +/* exit(EXIT_FAILURE); */ + fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + __LOCALE_DATA_CATEGORIES)); + fprintf(ofp, "static const unsigned char __locale_names5[5];\n"); + } else { + if (default_utf8) { + fprintf(ofp, "#define __CTYPE_HAS_UTF_8_LOCALES\t\t\t1\n"); + } + fprintf(ofp, "#define __LOCALE_DATA_CATEGORIES\t\t\t%d\n", __LOCALE_DATA_CATEGORIES); + fprintf(ofp, "#define __LOCALE_DATA_WIDTH_LOCALES\t\t\t%d\n", 3+__LOCALE_DATA_CATEGORIES); + fprintf(ofp, "#define __LOCALE_DATA_NUM_LOCALES\t\t\t%d\n", num_locales); + fprintf(ofp, "static const unsigned char __locales[%d] = {\n", + (num_locales) * (3 + __LOCALE_DATA_CATEGORIES)); + for (i=0 ; i < num_locales ; i++) { + if (memcmp(locales[i].name, locales[i-1].name, 5) != 0) { + locales[i].idx_name = uniq; + ++uniq; + } else { + locales[i].idx_name = uniq - 1; + } + fprintf(ofp, "\t%#4x, ", (int)((unsigned char) locales[i].idx_name)); + fprintf(ofp, "\t%#4x, ", (int)((unsigned char) locales[i].dot_cs)); + fprintf(ofp, "\t%#4x, ", (int)((unsigned char) locales[i].cs)); + /* lc_ctype would store translit flags and turkish up/low flag. */ + fprintf(ofp, "%#4x, ", (int)((unsigned char) locales[i].lc_ctype_row)); + fprintf(ofp, "%#4x, ", (int)((unsigned char) locales[i].lc_numeric_row)); + fprintf(ofp, "%#4x, ", (int)((unsigned char) locales[i].lc_monetary_row)); + fprintf(ofp, "%#4x, ", (int)((unsigned char) locales[i].lc_time_row)); +#if 1 + /* lc_collate */ + if (strlen(locales[i].glibc_name) >= 5) { + fprintf(ofp, "COL_IDX_%.2s_%.2s, ", locales[i].glibc_name, locales[i].glibc_name+3); + } else if (!strcmp(locales[i].glibc_name, "C")) { + fprintf(ofp, "COL_IDX_C , "); + } else { + printf("don't know how to handle COL_IDX_ for %s\n", locales[i].glibc_name); + exit(EXIT_FAILURE); + } +#else + fprintf(ofp, "%#4x, ", 0); /* place holder for lc_collate */ +#endif + fprintf(ofp, "%#4x, ", (int)((unsigned char) locales[i].lc_messages_row)); + fprintf(ofp, "\t/* %s */\n", locales[i].glibc_name); + } + fprintf(ofp, "};\n\n"); + + fprintf(ofp, "#define __LOCALE_DATA_NUM_LOCALE_NAMES\t\t%d\n", uniq ); + fprintf(ofp, "static const unsigned char __locale_names5[%d] = \n\t", uniq * 5); + uniq = 0; + for (i=1 ; i < num_locales ; i++) { + if (memcmp(locales[i].name, locales[i-1].name, 5) != 0) { + fprintf(ofp, "\"%5.5s\" ", locales[i].name); + ++uniq; + if ((uniq % 8) == 0) { + fprintf(ofp, "\n\t"); + } + } + } + fprintf(ofp,";\n\n"); + + if (at_strings_end > at_strings) { + int i, j; + char *p; + i = 0; + p = at_strings; + while (*p) { + ++i; + p += 1 + (unsigned char) *p; + } + /* len, char, string\0 */ + fprintf(ofp, "#define __LOCALE_DATA_AT_MODIFIERS_LENGTH\t\t%d\n", + i + (at_strings_end - at_strings)); + fprintf(ofp, "static const unsigned char __locale_at_modifiers[%d] = {", + i + (at_strings_end - at_strings)); + i = 0; + p = at_strings; + while (*p) { + fprintf(ofp, "\n\t%4d, '%c',", + (unsigned char) *p, /* len of string\0 */ + at_mapto[i]); + for (j=1 ; j < ((unsigned char) *p) ; j++) { + fprintf(ofp, " '%c',", p[j]); + } + fprintf(ofp, " 0,"); + ++i; + p += 1 + (unsigned char) *p; + } + fprintf(ofp, "\n};\n\n"); + } + + { + int pos[__LOCALE_DATA_CATEGORIES]; + pos[0] = __LOCALE_DATA_CATEGORIES; + for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) { + fprintf(ofp, "#define __%s\t\t%d\n", lc_names[i], i); + if (i + 1 < __LOCALE_DATA_CATEGORIES) { + pos[i+1] = 1 + strlen(lc_names[i]) + pos[i]; + } + } + if (pos[__LOCALE_DATA_CATEGORIES-1] > 255) { + printf("error - lc_names is too big (%d)\n", pos[__LOCALE_DATA_CATEGORIES-1]); + exit(EXIT_FAILURE); + } + fprintf(ofp, "#define __LC_ALL\t\t%d\n\n", i); + + fprintf(ofp, "#define __lc_names_LEN\t\t%d\n", + pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1); + total_size += pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1; + + fprintf(ofp, "static unsigned const char lc_names[%d] =\n", + pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1); + fprintf(ofp, "\t\""); + for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) { + fprintf(ofp, "\\x%02x", (unsigned char) pos[i]); + } + fprintf(ofp, "\""); + for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) { + fprintf(ofp, "\n\t\"%s\\0\"", lc_names[i]); + } + fprintf(ofp, ";\n\n"); + } + + printf("locale data = %d name data = %d for %d uniq\n", + num_locales * (3 + __LOCALE_DATA_CATEGORIES), uniq * 5, uniq); + + total_size += num_locales * (3 + __LOCALE_DATA_CATEGORIES) + uniq * 5; + } + +} + +static void read_at_mappings(void) +{ + char *p; + char *m; + int mc = 0; + + do { + if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) { + if (!fgets(line_buf, sizeof(line_buf), fp)) { + if (ferror(fp)) { + printf("error reading file\n"); + exit(EXIT_FAILURE); + } + return; /* EOF */ + } + if ((*line_buf == '#') && (line_buf[1] == '-')) { + break; + } + continue; + } + if (*p == '@') { + if (p[1] == 0) { + printf("error: missing @modifier name\n"); + exit(EXIT_FAILURE); + } + m = p; /* save the modifier name */ + if (!(p = strtok(NULL, " \t\n")) || p[1] || (((unsigned char) *p) > 0x7f)) { + printf("error: missing or illegal @modifier mapping char\n"); + exit(EXIT_FAILURE); + } + if (at_mappings[(int)((unsigned char) *p)]) { + printf("error: reused @modifier mapping char\n"); + exit(EXIT_FAILURE); + } + at_mappings[(int)((unsigned char) *p)] = 1; + at_mapto[mc] = *p; + ++mc; + *at_strings_end = (char)( (unsigned char) (strlen(m)) ); + strcpy(++at_strings_end, m+1); + at_strings_end += (unsigned char) at_strings_end[-1]; + + printf("@mapping: \"%s\" to '%c'\n", m, *p); + + if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) { + printf("ignoring trailing text: %s...\n", p); + } + *line_buf = 0; + continue; + } + break; + } while (1); + +#if 0 + { + p = at_strings; + + if (!*p) { + printf("no @ strings\n"); + return; + } + + do { + printf("%s\n", p+1); + p += 1 + (unsigned char) *p; + } while (*p); + } +#endif +} + +static void read_enable_disable(void) +{ + char *p; + + do { + if (!(p = strtok(line_buf, " =\t\n")) || (*p == '#')) { + if (!fgets(line_buf, sizeof(line_buf), fp)) { + if (ferror(fp)) { + printf("error reading file\n"); + exit(EXIT_FAILURE); + } + return; /* EOF */ + } + if ((*line_buf == '#') && (line_buf[1] == '-')) { + break; + } + continue; + } + if (!strcmp(p, "UTF-8")) { + if (!(p = strtok(NULL, " =\t\n")) + || ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) { + printf("error: missing or illegal UTF-8 setting\n"); + exit(EXIT_FAILURE); + } + default_utf8 = (toupper(*p) == 'Y'); + printf("UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2)); + } else if (!strcmp(p, "8-BIT")) { + if (!(p = strtok(NULL, " =\t\n")) + || ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) { + printf("error: missing or illegal 8-BIT setting\n"); + exit(EXIT_FAILURE); + } + default_8bit = (toupper(*p) == 'Y'); + printf("8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2)); + } else { + break; + } + + if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) { + printf("ignoring trailing text: %s...\n", p); + } + *line_buf = 0; + continue; + + } while (1); +} + +#ifdef __LOCALE_DATA_CODESET_LIST + +static int find_codeset_num(const char *cs) +{ + int r = 2; + char *s = __LOCALE_DATA_CODESET_LIST; + + /* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */ + + if (strcmp(cs, "UTF-8") != 0) { + ++r; + while (*s && strcmp(__LOCALE_DATA_CODESET_LIST+ ((unsigned char) *s), cs)) { +/* printf("tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */ + ++r; + ++s; + } + if (!*s) { + printf("error: unsupported codeset %s\n", cs); + exit(EXIT_FAILURE); + } + } + return r; +} + +#else + +static int find_codeset_num(const char *cs) +{ + int r = 2; + + /* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */ + + if (strcmp(cs, "UTF-8") != 0) { + printf("error: unsupported codeset %s\n", cs); + exit(EXIT_FAILURE); + } + return r; +} + +#endif + +static int find_at_string_num(const char *as) +{ + int i = 0; + char *p = at_strings; + + while (*p) { + if (!strcmp(p+1, as)) { + return i; + } + ++i; + p += 1 + (unsigned char) *p; + } + + printf("error: unmapped @string %s\n", as); + exit(EXIT_FAILURE); +} + +static void read_locale_list(void) +{ + char *p; + char *s; + char *ln; /* locale name */ + char *ls; /* locale name ll_CC */ + char *as; /* at string */ + char *ds; /* dot string */ + char *cs; /* codeset */ + int i; + + typedef struct { + char *glibc_name; + char name[5]; + char dot_cs; /* 0 if no codeset specified */ + char cs; + } locale_entry; + + /* First the C locale. */ + locales[0].glibc_name = locales[0].name; + strncpy(locales[0].name,"C",5); + locales[0].dot_cs = 0; + locales[0].cs = 1; /* 7-bit encoding */ + ++num_locales; + + do { + if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) { + if (!fgets(line_buf, sizeof(line_buf), fp)) { + if (ferror(fp)) { + printf("error reading file\n"); + exit(EXIT_FAILURE); + } + return; /* EOF */ + } + if ((*line_buf == '#') && (line_buf[1] == '-')) { + break; + } + continue; + } + + s = glibc_locale_names; + for (i=0 ; i < num_locales ; i++) { + if (!strcmp(s+1, p)) { + break; + } + s += 1 + ((unsigned char) *s); + } + if (i < num_locales) { + printf("ignoring dulplicate locale name: %s", p); + *line_buf = 0; + continue; + } + + /* New locale, but don't increment num until codeset verified! */ + *s = (char)((unsigned char) (strlen(p) + 1)); + strcpy(s+1, p); + locales[num_locales].glibc_name = s+1; + ln = p; /* save locale name */ + + if (!(p = strtok(NULL, " \t\n"))) { + printf("error: missing codeset for locale %s\n", ln); + exit(EXIT_FAILURE); + } + cs = p; + i = find_codeset_num(p); + if ((i == 2) && !default_utf8) { + printf("ignoring UTF-8 locale %s\n", ln); + *line_buf = 0; + continue; + } else if ((i > 2) && !default_8bit) { + printf("ignoring 8-bit codeset locale %s\n", ln); + *line_buf = 0; + continue; + } + locales[num_locales].cs = (char)((unsigned char) i); + + if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) { + printf("ignoring trailing text: %s...\n", p); + } + + /* Now go back to locale string for .codeset and @modifier */ + as = strtok(ln, "@"); + if (as) { + as = strtok(NULL, "@"); + } + ds = strtok(ln, "."); + if (ds) { + ds = strtok(NULL, "."); + } + ls = ln; + + if ((strlen(ls) != 5) || (ls[2] != '_')) { + printf("error: illegal locale name %s\n", ls); + exit(EXIT_FAILURE); + } + + i = 0; /* value for unspecified codeset */ + if (ds) { + i = find_codeset_num(ds); + if ((i == 2) && !default_utf8) { + printf("ignoring UTF-8 locale %s\n", ln); + *line_buf = 0; + continue; + } else if ((i > 2) && !default_8bit) { + printf("ignoring 8-bit codeset locale %s\n", ln); + *line_buf = 0; + continue; + } + } + locales[num_locales].dot_cs = (char)((unsigned char) i); + + if (as) { + i = find_at_string_num(as); + ls[2] = at_mapto[i]; + } + memcpy(locales[num_locales].name, ls, 5); +/* printf("locale: %5.5s %2d %2d %s\n", */ +/* locales[num_locales].name, */ +/* locales[num_locales].cs, */ +/* locales[num_locales].dot_cs, */ +/* locales[num_locales].glibc_name */ +/* ); */ + ++num_locales; + *line_buf = 0; + } while (1); +} + +static int le_cmp(const void *a, const void *b) +{ + const locale_entry *p; + const locale_entry *q; + int r; + + p = (const locale_entry *) a; + q = (const locale_entry *) b; + + if (!(r = p->name[0] - q->name[0]) + && !(r = p->name[1] - q->name[1]) + && !(r = p->name[3] - q->name[3]) + && !(r = p->name[4] - q->name[4]) + && !(r = p->name[2] - q->name[2]) + && !(r = -(p->cs - q->cs)) + ) { + r = -(p->dot_cs - q->dot_cs); + /* Reverse the ordering of the codesets so UTF-8 comes last. + * Work-around (hopefully) for glibc bug affecting at least + * the euro currency symbol. */ + } + + return r; +} + +int main(int argc, char **argv) +{ + if ((argc != 2) || (!(fp = fopen(*++argv, "r")))) { + printf("error: missing filename or file!\n"); + return EXIT_FAILURE; + } + + at_strings_end = at_strings; + + read_at_mappings(); + read_enable_disable(); + read_locale_list(); + + fclose(fp); + + /* handle C locale specially */ + qsort(locales+1, num_locales-1, sizeof(locale_entry), le_cmp); + +#if 0 + for (i=0 ; i < num_locales ; i++) { + printf("locale: %5.5s %2d %2d %s\n", + locales[i].name, + locales[i].cs, + locales[i].dot_cs, + locales[i].glibc_name + ); + } +#endif + + if (!(ofp = fopen("locale_tables.h", "w"))) { + printf("error: can not open locale_tables.h for writing!\n"); + return EXIT_FAILURE; + } + + do_lc_time(); + do_lc_numeric(); + do_lc_monetary(); + do_lc_messages(); + do_lc_ctype(); + + do_locale_names(); + + fclose(ofp); + + printf("total data size = %d\n", total_size); + printf("null count = %d\n", null_count); + + return EXIT_SUCCESS; +} + +static char *idx[10000]; +static char buf[100000]; +static char *last; +static int uniq; + +static int addblock(const char *s, size_t n) /* l includes nul terminator */ +{ + int j; + + if (!s) { + ++null_count; + return 0; + } + + for (j=0 ; (j < uniq) && (idx[j] + n < last) ; j++) { + if (!memcmp(s, idx[j], n)) { + return idx[j] - buf; + } + } + if (uniq >= sizeof(idx)) { + printf("too many uniq strings!\n"); + exit(EXIT_FAILURE); + } + if (last + n >= buf + sizeof(buf)) { + printf("need to increase size of buf!\n"); + exit(EXIT_FAILURE); + } + + idx[uniq] = last; + ++uniq; + memcpy(last, s, n); + last += n; + return idx[uniq - 1] - buf; +} + +static int addstring(const char *s) +{ + int j; + size_t l; + + if (!s) { + ++null_count; + return 0; + } + + for (j=0 ; j < uniq ; j++) { + if (!strcmp(s, idx[j])) { + return idx[j] - buf; + } + } + if (uniq >= sizeof(idx)) { + printf("too many uniq strings!\n"); + exit(EXIT_FAILURE); + } + l = strlen(s) + 1; + if (last + l >= buf + sizeof(buf)) { + printf("need to increase size of buf!\n"); + exit(EXIT_FAILURE); + } + + idx[uniq] = last; + ++uniq; + strcpy(last, s); + last += l; + return idx[uniq - 1] - buf; +} + +#define DO_LC_COMMON(CATEGORY) \ + printf("buf-size=%d uniq=%d rows=%d\n", \ + (int)(last - buf), uniq, lc_##CATEGORY##_uniq); \ + printf("total = %d + %d * %d + %d = %d\n", \ + num_locales, lc_##CATEGORY##_uniq, NUM_NL_##CATEGORY, (int)(last - buf), \ + i = num_locales + lc_##CATEGORY##_uniq*NUM_NL_##CATEGORY + (int)(last - buf)); \ + total_size += i; \ + dump_table8c("__lc_" #CATEGORY "_data", buf, (int)(last - buf)); \ + for (i=0 ; i < lc_##CATEGORY##_uniq ; i++) { \ + m = locales[i].lc_##CATEGORY##_row; \ + for (k=0 ; k < NUM_NL_##CATEGORY ; k++) { \ + buf[NUM_NL_##CATEGORY*i + k] = (char)((unsigned char) lc_##CATEGORY##_uniq_X[i][k]); \ + } \ + } \ + dump_table8("__lc_" #CATEGORY "_rows", buf, lc_##CATEGORY##_uniq * NUM_NL_##CATEGORY); \ + buf16[0] =0; \ + for (i=0 ; i < NUM_NL_##CATEGORY - 1 ; i++) { \ + buf16[i+1] = buf16[i] + lc_##CATEGORY##_count[i]; \ + } \ + dump_table16("__lc_" #CATEGORY "_item_offsets", buf16, NUM_NL_##CATEGORY); \ + m = 0; \ + for (k=0 ; k < NUM_NL_##CATEGORY ; k++) { \ + for (i=0 ; i < lc_##CATEGORY##_count[k] ; i++) { \ + buf16[m] = lc_##CATEGORY##_item[k][i]; \ + ++m; \ + } \ + } \ + dump_table16("__lc_" #CATEGORY "_item_idx", buf16, m); + + +#define DL_LC_LOOPTAIL(CATEGORY) \ + if (k > NUM_NL_##CATEGORY) { \ + printf("error -- lc_" #CATEGORY " nl_item count > %d!\n", NUM_NL_##CATEGORY); \ + exit(EXIT_FAILURE); \ + } \ + { \ + int r; \ + for (r=0 ; r < lc_##CATEGORY##_uniq ; r++) { \ + if (!memcmp(lc_##CATEGORY##_uniq_X[lc_##CATEGORY##_uniq], \ + lc_##CATEGORY##_uniq_X[r], NUM_NL_##CATEGORY)) { \ + break; \ + } \ + } \ + if (r == lc_##CATEGORY##_uniq) { /* new locale row */ \ + ++lc_##CATEGORY##_uniq; \ + if (lc_##CATEGORY##_uniq > 255) { \ + printf("too many unique lc_" #CATEGORY " rows!\n"); \ + exit(EXIT_FAILURE); \ + } \ + } \ + locales[i].lc_##CATEGORY##_row = r; \ + } + + + +static int buf16[100*256]; + +static void dump_table8(const char *name, const char *tbl, int len) +{ + int i; + + fprintf(ofp, "#define %s_LEN\t\t%d\n", name, len); + fprintf(ofp, "static const unsigned char %s[%d] = {", name, len); + for (i=0 ; i < len ; i++) { + if ((i % 12) == 0) { + fprintf(ofp, "\n\t"); + } + fprintf(ofp, "%#4x, ", (int)((unsigned char) tbl[i])); + } + fprintf(ofp, "\n};\n\n"); +} + +#define __C_isdigit(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((c) - '0')) < 10) \ + : (((unsigned int)((c) - '0')) < 10)) +#define __C_isalpha(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)(((c) | 0x20) - 'a')) < 26) \ + : (((unsigned int)(((c) | 0x20) - 'a')) < 26)) +#define __C_isalnum(c) (__C_isalpha(c) || __C_isdigit(c)) + +static void dump_table8c(const char *name, const char *tbl, int len) +{ + int i; + + fprintf(ofp, "#define %s_LEN\t\t%d\n", name, len); + fprintf(ofp, "static const unsigned char %s[%d] = {", name, len); + for (i=0 ; i < len ; i++) { + if ((i % 12) == 0) { + fprintf(ofp, "\n\t"); + } + if (__C_isalnum(tbl[i]) || (tbl[i] == ' ')) { + fprintf(ofp, " '%c', ", (int)((unsigned char) tbl[i])); + } else { + fprintf(ofp, "%#4x, ", (int)((unsigned char) tbl[i])); + } + } + fprintf(ofp, "\n};\n\n"); +} + +static void dump_table16(const char *name, const int *tbl, int len) +{ + int i; + + fprintf(ofp, "#define %s_LEN\t\t%d\n", name, len); + fprintf(ofp, "static const uint16_t %s[%d] = {", name, len); + for (i=0 ; i < len ; i++) { + if ((i % 8) == 0) { + fprintf(ofp, "\n\t"); + } + if (tbl[i] != (uint16_t) tbl[i]) { + printf("error - falls outside uint16 range!\n"); + exit(EXIT_FAILURE); + } + fprintf(ofp, "%#6x, ", tbl[i]); + } + fprintf(ofp, "\n};\n\n"); +} + + +#define NUM_NL_time 50 + +static int lc_time_item[NUM_NL_time][256]; +static int lc_time_count[NUM_NL_time]; +static unsigned char lc_time_uniq_X[700][NUM_NL_time]; +static int lc_time_uniq; + +#define DO_NL_S(X) lc_time_S(X, k++) + +static void lc_time_S(int X, int k) +{ + size_t len; + int j, m; + const char *s = nl_langinfo(X); + const char *p; + static const char nulbuf[] = ""; + + if (X == ALT_DIGITS) { + len = 1; + if (!s) { + s = nulbuf; + } + if (*s) { + p = s; + for (j = 0 ; j < 100 ; j++) { + while (*p) { + ++p; + } + ++p; + } + len = p - s; + } + j = addblock(s, len); +/* if (len > 1) fprintf(stderr, "alt_digit: called addblock with len %zd\n", len); */ + } else if (X == ERA) { + if (!s) { + s = nulbuf; + } + p = s; + while (*p) { + while (*p) { + ++p; + } + ++p; + } + ++p; + j = addblock(s, p - s); +/* if (p-s > 1) fprintf(stderr, "era: called addblock with len %d\n", p-s); */ + } else { + j = addstring(s); + } + for (m=0 ; m < lc_time_count[k] ; m++) { + if (lc_time_item[k][m] == j) { + break; + } + } + if (m == lc_time_count[k]) { /* new for this nl_item */ + if (m > 255) { + printf("too many nl_item %d entries in lc_time\n", k); + exit(EXIT_FAILURE); + } + lc_time_item[k][m] = j; + ++lc_time_count[k]; + } + lc_time_uniq_X[lc_time_uniq][k] = m; +} + +static void do_lc_time(void) +{ + int i, k, m; + + last = buf+1; + uniq = 1; + *buf = 0; + *idx = buf; + + for (i=0 ; i < num_locales ; i++) { + k = 0; + + if (!setlocale(LC_ALL, locales[i].glibc_name)) { + printf("setlocale(LC_ALL,%s) failed!\n", + locales[i].glibc_name); + } + + DO_NL_S(ABDAY_1); + DO_NL_S(ABDAY_2); + DO_NL_S(ABDAY_3); + DO_NL_S(ABDAY_4); + DO_NL_S(ABDAY_5); + DO_NL_S(ABDAY_6); + DO_NL_S(ABDAY_7); + + DO_NL_S(DAY_1); + DO_NL_S(DAY_2); + DO_NL_S(DAY_3); + DO_NL_S(DAY_4); + DO_NL_S(DAY_5); + DO_NL_S(DAY_6); + DO_NL_S(DAY_7); + + DO_NL_S(ABMON_1); + DO_NL_S(ABMON_2); + DO_NL_S(ABMON_3); + DO_NL_S(ABMON_4); + DO_NL_S(ABMON_5); + DO_NL_S(ABMON_6); + DO_NL_S(ABMON_7); + DO_NL_S(ABMON_8); + DO_NL_S(ABMON_9); + DO_NL_S(ABMON_10); + DO_NL_S(ABMON_11); + DO_NL_S(ABMON_12); + + DO_NL_S(MON_1); + DO_NL_S(MON_2); + DO_NL_S(MON_3); + DO_NL_S(MON_4); + DO_NL_S(MON_5); + DO_NL_S(MON_6); + DO_NL_S(MON_7); + DO_NL_S(MON_8); + DO_NL_S(MON_9); + DO_NL_S(MON_10); + DO_NL_S(MON_11); + DO_NL_S(MON_12); + + DO_NL_S(AM_STR); + DO_NL_S(PM_STR); + + DO_NL_S(D_T_FMT); + DO_NL_S(D_FMT); + DO_NL_S(T_FMT); + DO_NL_S(T_FMT_AMPM); + DO_NL_S(ERA); + + DO_NL_S(ERA_YEAR); /* non SuSv3 */ + DO_NL_S(ERA_D_FMT); + DO_NL_S(ALT_DIGITS); + DO_NL_S(ERA_D_T_FMT); + DO_NL_S(ERA_T_FMT); + + DL_LC_LOOPTAIL(time) + } + + DO_LC_COMMON(time) +} + +#undef DO_NL_S + +#define NUM_NL_numeric 3 + +static int lc_numeric_item[NUM_NL_numeric][256]; +static int lc_numeric_count[NUM_NL_numeric]; +static unsigned char lc_numeric_uniq_X[700][NUM_NL_numeric]; +static int lc_numeric_uniq; + +#define DO_NL_S(X) lc_numeric_S(X, k++) + +static void lc_numeric_S(int X, int k) +{ + int j, m; + char buf[256]; + char *e; + char *s; + char c; + + s = nl_langinfo(X); + if (X == GROUPING) { + if (s) { + if ((*s == CHAR_MAX) || (*s == -1)) { /* stupid glibc... :-( */ + s = ""; + } + e = s; + c = 0; + while (*e) { /* find end of string */ + if (*e == CHAR_MAX) { + c = CHAR_MAX; + ++e; + break; + } + ++e; + } + if ((e - s) > sizeof(buf)) { + printf("grouping specifier too long\n"); + exit(EXIT_FAILURE); + } + strncpy(buf, s, (e-s)); + e = buf + (e-s); + *e = 0; /* Make sure we're null-terminated. */ + + if (c != CHAR_MAX) { /* remove duplicate repeats */ + while (e > buf) { + --e; + if (*e != e[-1]) { + break; + } + } + *++e = 0; + } + s = buf; + } + } + j = addstring(s); + for (m=0 ; m < lc_numeric_count[k] ; m++) { + if (lc_numeric_item[k][m] == j) { + break; + } + } + if (m == lc_numeric_count[k]) { /* new for this nl_item */ + if (m > 255) { + printf("too many nl_item %d entries in lc_numeric\n", k); + exit(EXIT_FAILURE); + } + lc_numeric_item[k][m] = j; + ++lc_numeric_count[k]; + } +/* printf("\\x%02x", m); */ + lc_numeric_uniq_X[lc_numeric_uniq][k] = m; +} + +static void do_lc_numeric(void) +{ + int i, k, m; + + last = buf+1; + uniq = 1; + *buf = 0; + *idx = buf; + + for (i=0 ; i < num_locales ; i++) { + k = 0; + + if (!setlocale(LC_ALL, locales[i].glibc_name)) { + printf("setlocale(LC_ALL,%s) failed!\n", + locales[i].glibc_name); + } + + DO_NL_S(RADIXCHAR); /* DECIMAL_POINT */ + DO_NL_S(THOUSEP); /* THOUSANDS_SEP */ + DO_NL_S(GROUPING); + + DL_LC_LOOPTAIL(numeric) + } + + DO_LC_COMMON(numeric) +} + +#undef DO_NL_S + +#define NUM_NL_monetary (7+14+1) + +static int lc_monetary_item[NUM_NL_monetary][256]; +static int lc_monetary_count[NUM_NL_monetary]; +static unsigned char lc_monetary_uniq_X[700][NUM_NL_monetary]; +static int lc_monetary_uniq; + +#define DO_NL_S(X) lc_monetary_S(X, k++) + +/* #define DO_NL_C(X) printf("%#02x", (int)(unsigned char)(*nl_langinfo(X))); */ +#define DO_NL_C(X) lc_monetary_C(X, k++) + +static void lc_monetary_C(int X, int k) +{ + int j, m; + char c_buf[2]; + +#warning fix the char entries for monetary... target signedness of char may be different! + + c_buf[1] = 0; + c_buf[0] = *nl_langinfo(X); + j = addstring(c_buf); + for (m=0 ; m < lc_monetary_count[k] ; m++) { + if (lc_monetary_item[k][m] == j) { + break; + } + } + if (m == lc_monetary_count[k]) { /* new for this nl_item */ + if (m > 255) { + printf("too many nl_item %d entries in lc_monetary\n", k); + exit(EXIT_FAILURE); + } + lc_monetary_item[k][m] = j; + ++lc_monetary_count[k]; + } +/* printf("\\x%02x", m); */ + lc_monetary_uniq_X[lc_monetary_uniq][k] = m; +} + + +static void lc_monetary_S(int X, int k) +{ + int j, m; + char buf[256]; + char *e; + char *s; + char c; + + s = nl_langinfo(X); + if (X == MON_GROUPING) { + if (s) { + if ((*s == CHAR_MAX) || (*s == -1)) { /* stupid glibc... :-( */ + s = ""; + } + e = s; + c = 0; + while (*e) { /* find end of string */ + if (*e == CHAR_MAX) { + c = CHAR_MAX; + ++e; + break; + } + ++e; + } + if ((e - s) > sizeof(buf)) { + printf("mon_grouping specifier too long\n"); + exit(EXIT_FAILURE); + } + strncpy(buf, s, (e-s)); + e = buf + (e-s); + *e = 0; /* Make sure we're null-terminated. */ + + if (c != CHAR_MAX) { /* remove duplicate repeats */ + while (e > buf) { + --e; + if (*e != e[-1]) { + break; + } + } + *++e = 0; + } + s = buf; + } + } + j = addstring(s); + for (m=0 ; m < lc_monetary_count[k] ; m++) { + if (lc_monetary_item[k][m] == j) { + break; + } + } + if (m == lc_monetary_count[k]) { /* new for this nl_item */ + if (m > 255) { + printf("too many nl_item %d entries in lc_monetary\n", k); + exit(EXIT_FAILURE); + } + lc_monetary_item[k][m] = j; + ++lc_monetary_count[k]; + } +/* printf("\\x%02x", m); */ + lc_monetary_uniq_X[lc_monetary_uniq][k] = m; +} + +static void do_lc_monetary(void) +{ + int i, k, m; + + last = buf+1; + uniq = 1; + *buf = 0; + *idx = buf; + + for (i=0 ; i < num_locales ; i++) { + k = 0; + + if (!setlocale(LC_ALL, locales[i].glibc_name)) { + printf("setlocale(LC_ALL,%s) failed!\n", + locales[i].glibc_name); + } + + + /* non SUSv3 */ + DO_NL_S(INT_CURR_SYMBOL); + DO_NL_S(CURRENCY_SYMBOL); + DO_NL_S(MON_DECIMAL_POINT); + DO_NL_S(MON_THOUSANDS_SEP); + DO_NL_S(MON_GROUPING); + DO_NL_S(POSITIVE_SIGN); + DO_NL_S(NEGATIVE_SIGN); + DO_NL_C(INT_FRAC_DIGITS); + DO_NL_C(FRAC_DIGITS); + DO_NL_C(P_CS_PRECEDES); + DO_NL_C(P_SEP_BY_SPACE); + DO_NL_C(N_CS_PRECEDES); + DO_NL_C(N_SEP_BY_SPACE); + DO_NL_C(P_SIGN_POSN); + DO_NL_C(N_SIGN_POSN); + DO_NL_C(INT_P_CS_PRECEDES); + DO_NL_C(INT_P_SEP_BY_SPACE); + DO_NL_C(INT_N_CS_PRECEDES); + DO_NL_C(INT_N_SEP_BY_SPACE); + DO_NL_C(INT_P_SIGN_POSN); + DO_NL_C(INT_N_SIGN_POSN); + + DO_NL_S(CRNCYSTR); /* CURRENCY_SYMBOL */ + + DL_LC_LOOPTAIL(monetary) + } + + DO_LC_COMMON(monetary) +} + + +#undef DO_NL_S + +#define NUM_NL_messages 4 + +static int lc_messages_item[NUM_NL_messages][256]; +static int lc_messages_count[NUM_NL_messages]; +static unsigned char lc_messages_uniq_X[700][NUM_NL_messages]; +static int lc_messages_uniq; + +#define DO_NL_S(X) lc_messages_S(X, k++) + +static void lc_messages_S(int X, int k) +{ + int j, m; + j = addstring(nl_langinfo(X)); + for (m=0 ; m < lc_messages_count[k] ; m++) { + if (lc_messages_item[k][m] == j) { + break; + } + } + if (m == lc_messages_count[k]) { /* new for this nl_item */ + if (m > 255) { + printf("too many nl_item %d entries in lc_messages\n", k); + exit(EXIT_FAILURE); + } + lc_messages_item[k][m] = j; + ++lc_messages_count[k]; + } +/* printf("\\x%02x", m); */ + lc_messages_uniq_X[lc_messages_uniq][k] = m; +} + +static void do_lc_messages(void) +{ + int i, k, m; + + last = buf+1; + uniq = 1; + *buf = 0; + *idx = buf; + + for (i=0 ; i < num_locales ; i++) { + k = 0; + + if (!setlocale(LC_ALL, locales[i].glibc_name)) { + printf("setlocale(LC_ALL,%s) failed!\n", + locales[i].glibc_name); + } + + DO_NL_S(YESEXPR); + DO_NL_S(NOEXPR); + DO_NL_S(YESSTR); + DO_NL_S(NOSTR); + + DL_LC_LOOPTAIL(messages) + } + + DO_LC_COMMON(messages) +} + +#undef DO_NL_S + +#define NUM_NL_ctype 10 + +static int lc_ctype_item[NUM_NL_ctype][256]; +static int lc_ctype_count[NUM_NL_ctype]; +static unsigned char lc_ctype_uniq_X[700][NUM_NL_ctype]; +static int lc_ctype_uniq; + +#define DO_NL_S(X) lc_ctype_S(X, k++) + +static void lc_ctype_S(int X, int k) +{ + int j, m; + j = addstring(nl_langinfo(X)); + for (m=0 ; m < lc_ctype_count[k] ; m++) { + if (lc_ctype_item[k][m] == j) { + break; + } + } + if (m == lc_ctype_count[k]) { /* new for this nl_item */ + if (m > 255) { + printf("too many nl_item %d entries in lc_ctype\n", k); + exit(EXIT_FAILURE); + } + lc_ctype_item[k][m] = j; + ++lc_ctype_count[k]; + } +/* printf("\\x%02x", m); */ + lc_ctype_uniq_X[lc_ctype_uniq][k] = m; +} + +static void do_lc_ctype(void) +{ + int i, k, m; + + last = buf+1; + uniq = 1; + *buf = 0; + *idx = buf; + + for (i=0 ; i < num_locales ; i++) { + k = 0; + + if (!setlocale(LC_ALL, locales[i].glibc_name)) { + printf("setlocale(LC_ALL,%s) failed!\n", + locales[i].glibc_name); + } + + DO_NL_S(_NL_CTYPE_OUTDIGIT0_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT1_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT2_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT3_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT4_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT5_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT6_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT7_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT8_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT9_MB); + + DL_LC_LOOPTAIL(ctype) + } + + DO_LC_COMMON(ctype) +} diff --git a/extra/locale/gen_mmap.c b/extra/locale/gen_mmap.c new file mode 100644 index 0000000..f9bce02 --- /dev/null +++ b/extra/locale/gen_mmap.c @@ -0,0 +1,237 @@ +#include +#include +#include +#include +#include +#include + +#define WANT_DATA +#include "c8tables.h" + +/* #define Cctype_TBL_LEN 328 */ +/* #define Cuplow_TBL_LEN 400 */ +/* #define Cc2wc_TBL_LEN 1448 */ +/* #define Cwc2c_TBL_LEN 3744 */ + +#define WANT_WCctype_data +#define WANT_WCuplow_data +#define WANT_WCuplow_diff_data +/* #define WANT_WCcomb_data */ +/* #define WANT_WCwidth_data */ +#include "wctables.h" +#undef WANT_WCctype_data +#undef WANT_WCuplow_data +#undef WANT_WCuplow_diff_data +/* #undef WANT_WCcomb_data */ +/* #undef WANT_WCwidth_data */ + +/* #define WCctype_TBL_LEN (WCctype_II_LEN + WCctype_TI_LEN + WCctype_UT_LEN) */ +/* #define WCuplow_TBL_LEN (WCuplow_II_LEN + WCuplow_TI_LEN + WCuplow_UT_LEN) */ +/* #define WCuplow_diff_TBL_LEN (2 * WCuplow_diffs) */ +/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */ + +#include "locale_tables.h" + +#include "locale_mmap.h" + +/* #undef __PASTE2 */ +/* #define __PASTE2(A,B) A ## B */ +/* #undef __PASTE3 */ +/* #define __PASTE3(A,B,C) A ## B ## C */ + + +/* #define MAGIC_SIZE 64 */ + +/* #define COMMON_MMAP(X) \ */ +/* unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; */ + +/* #define COMMON_MMIDX(X) \ */ +/* unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \ */ +/* uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \ */ +/* uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \ */ + +#define WRITE_COMMON_MMAP(X) \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(__lc_,X,_data_LEN) ; i++) { \ + putc(__PASTE3(__lc_,X,_data)[i], fp); \ + } + +#define WRITE_COMMON_MMIDX(X) \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_rows)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(__lc_,X,_rows_LEN) ; i++) { \ + putc(__PASTE3(__lc_,X,_rows)[i], fp); \ + } \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_offsets)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(__lc_,X,_item_offsets_LEN) ; i++) { \ + putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_offsets)[i]))[0], fp); \ + putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_offsets)[i]))[1], fp); \ + } \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_idx)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(__lc_,X,_item_idx_LEN) ; i++) { \ + putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_idx)[i]))[0], fp); \ + putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_idx)[i]))[1], fp); \ + } + +#define WRITE_WC_DATA(X) \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tblw,X)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(WC,X,_TBL_LEN) ; i++) { \ + putc(__PASTE3(WC,X,_data)[i], fp); \ + } + +#define WRITE_WC_I16_DATA(X) \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tblw,X)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(WC,X,_TBL_LEN) ; i++) { \ + putc( ((unsigned char *) &(__PASTE3(WC,X,_data)[i]))[0], fp); \ + putc( ((unsigned char *) &(__PASTE3(WC,X,_data)[i]))[1], fp); \ + } + +#define WRITE_C_DATA(X) \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tbl8,X)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(C,X,_TBL_LEN) ; i++) { \ + putc(__PASTE3(C,X,_data)[i], fp); \ + } + +#define WRITE_C_U16_DATA(X) \ + fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tbl8,X)), SEEK_SET); \ + for (i=0 ; i < __PASTE3(C,X,_TBL_LEN) ; i++) { \ + putc( ((unsigned char *) &(__PASTE3(C,X,_data)[i]))[0], fp); \ + putc( ((unsigned char *) &(__PASTE3(C,X,_data)[i]))[1], fp); \ + } + +/**********************************************************************/ + +#define COMMON_OFFSETS(X) \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_rows)), \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_offsets)), \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_idx)), \ + offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)) \ + + +static const size_t common_tbl_offsets[CATEGORIES*4] = { + 0, 0, 0, 0, /* ctype */ + COMMON_OFFSETS(numeric), + COMMON_OFFSETS(monetary), + COMMON_OFFSETS(time), + 0, 0, 0, 0, /* collate */ + COMMON_OFFSETS(messages), +}; + + + + + +int main(void) +{ + FILE *fp; + size_t i; + unsigned char *p; + + if (!(fp = fopen("locale.mmap", "w"))) { + printf("error - can't open locale.mmap for writing!"); + return EXIT_FAILURE; + } + + for (i=0 ; i < sizeof(__locale_mmap_t) ; i++) { + putc(0, fp); /* Zero out the file. */ + } + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + WRITE_C_DATA(ctype); + WRITE_C_DATA(uplow); +#ifdef __WCHAR_ENABLED + WRITE_C_U16_DATA(c2wc); + WRITE_C_DATA(wc2c); + /* translit */ +#endif /* __WCHAR_ENABLED */ +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + +#ifdef __WCHAR_ENABLED + WRITE_WC_DATA(ctype); + WRITE_WC_DATA(uplow); + WRITE_WC_I16_DATA(uplow_diff); +/* WRITE_WC_DATA(comb); */ + /* width?? */ +#endif /* __WCHAR_ENABLED */ + + WRITE_COMMON_MMAP(numeric); + WRITE_COMMON_MMAP(monetary); + WRITE_COMMON_MMAP(time); + /* TODO -- collate*/ + WRITE_COMMON_MMAP(messages); + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + fseek(fp, (long) offsetof(__locale_mmap_t, codeset_8_bit), SEEK_SET); \ + p = (unsigned char *) codeset_8_bit; + for (i=0 ; i < sizeof(codeset_8_bit) ; i++) { + putc(p[i], fp); + } +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + + WRITE_COMMON_MMIDX(numeric); + WRITE_COMMON_MMIDX(monetary); + WRITE_COMMON_MMIDX(time); + /* TODO -- collate*/ + WRITE_COMMON_MMIDX(messages); + + fseek(fp, (long) offsetof(__locale_mmap_t, lc_common_item_offsets_LEN), SEEK_SET); + putc(1, fp); /* ctype -- (codeset) handled specially */ + putc(__lc_numeric_item_offsets_LEN, fp); + putc(__lc_monetary_item_offsets_LEN, fp); + putc(__lc_time_item_offsets_LEN, fp); + putc(0, fp); /* collate */ + putc(__lc_messages_item_offsets_LEN, fp); + + fseek(fp, (long) offsetof(__locale_mmap_t, lc_common_tbl_offsets), SEEK_SET); + for (i=0 ; i < sizeof(common_tbl_offsets) ; i++) { + putc(((unsigned char *)common_tbl_offsets)[i], fp); + } + +#ifdef NUM_LOCALES + fseek(fp, (long) offsetof(__locale_mmap_t, locales), SEEK_SET); + for (i=0 ; i < (NUM_LOCALES * WIDTH_LOCALES) ; i++) { + putc(__locales[i], fp); + } + + fseek(fp, (long) offsetof(__locale_mmap_t, locale_names5), SEEK_SET); + for (i=0 ; i < 5 * NUM_LOCALE_NAMES ; i++) { + putc(__locale_names5[i], fp); + } + +#ifdef LOCALE_AT_MODIFIERS_LENGTH + fseek(fp, (long) offsetof(__locale_mmap_t, locale_at_modifiers), SEEK_SET); + for (i=0 ; i < LOCALE_AT_MODIFIERS_LENGTH ; i++) { + putc(__locale_at_modifiers[i], fp); + } +#endif /* LOCALE_AT_MODIFIERS_LENGTH */ +#endif /* NUM_LOCALES */ + + fseek(fp, (long) offsetof(__locale_mmap_t, lc_names), SEEK_SET); + for (i=0 ; i < lc_names_LEN ; i++) { + putc(lc_names[i], fp); + } + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + fseek(fp, (long) offsetof(__locale_mmap_t, codeset_list), SEEK_SET); + for (i=0 ; i < sizeof(CODESET_LIST) ; i++) { + putc((unsigned char)(CODESET_LIST[i]), fp); + } +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + + + if (ferror(fp) || (fclose(fp) == EOF)) { + printf("error - stream in error state or fclose failed!"); + return EXIT_FAILURE; + } + + printf("sizeof(__locale_mmap_t) = %zd\n", sizeof(__locale_mmap_t)); + + return EXIT_SUCCESS; +} + +/* TODO: + * collate data (8-bit weighted single char only) + * @ mappings! + * codeset list? yes, since we'll want to be able to inspect them... + * that means putting some header stuff in magic + * fix ctype LEN defines in gen_c8tables + */ diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c new file mode 100644 index 0000000..8a6d47a --- /dev/null +++ b/extra/locale/gen_wc8bit.c @@ -0,0 +1,710 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#ifndef _CTYPE_H +#define _CTYPE_H +#endif +#ifndef _WCTYPE_H +#define _WCTYPE_H +#endif +#include "../../libc/sysdeps/linux/common/bits/uClibc_ctype.h" + + +/* #define CTYPE_PACKED */ +#define UPLOW_IDX_SHIFT 3 +/* best if 2 unpacked or 3 packed */ +#define CTYPE_IDX_SHIFT 3 +/* 3 or 4 are very similar */ +#define C2WC_IDX_SHIFT 3 + +#define CTYPE_IDX_LEN (128 >> (CTYPE_IDX_SHIFT)) +#define UPLOW_IDX_LEN (128 >> (UPLOW_IDX_SHIFT)) +#define C2WC_IDX_LEN (128 >> (C2WC_IDX_SHIFT)) + +/* #ifdef CTYPE_PACKED */ +/* #define CTYPE_ROW_LEN (1 << ((CTYPE_IDX_SHIFT)-1)) */ +/* #else */ +#define CTYPE_ROW_LEN (1 << (CTYPE_IDX_SHIFT)) +/* #endif */ +#define UPLOW_ROW_LEN (1 << (UPLOW_IDX_SHIFT)) +#define C2WC_ROW_LEN (1 << (C2WC_IDX_SHIFT)) + + + +#define MAX_WCHAR (0x2600-1) + +static unsigned char ctype_tbl[256 * CTYPE_ROW_LEN]; +static unsigned char uplow_tbl[256 * UPLOW_ROW_LEN]; +#ifdef DO_WIDE_CHAR +static unsigned short c2wc_tbl[256 * C2WC_ROW_LEN]; +#endif +static unsigned char tt[MAX_WCHAR+1]; +static unsigned char ti[MAX_WCHAR+1]; +static unsigned char xi[MAX_WCHAR+1]; + +static int n_ctype_rows; +static int n_uplow_rows; +#ifdef DO_WIDE_CHAR +static int n_c2wc_rows; +#endif +static int tt_num; +static int ti_num; + +#define RANGE MAX_WCHAR + +#define TT_SHIFT 4 +#define TI_SHIFT 4 + +#define II_LEN ((MAX_WCHAR+1) >> (TT_SHIFT+TI_SHIFT)) + +typedef struct { + unsigned long c2w[256]; + unsigned char w2c[MAX_WCHAR]; + unsigned char ii[II_LEN]; + unsigned char ctype_idx[CTYPE_IDX_LEN]; + unsigned char uplow_idx[UPLOW_IDX_LEN]; + unsigned char c2wc_idx[C2WC_IDX_LEN]; +} charset_data; + +int main(int argc, char **argv) +{ + FILE *fp; + FILE *out; + charset_data csd[30]; + unsigned long max_wchar; + unsigned char *p; + int numsets; + int i; + int j; + char buf[80]; + unsigned char row[256]; +#ifdef DO_WIDE_CHAR + unsigned short wrow[256]; +#endif + char codeset_list[500]; + char codeset_index[30]; + int codeset_list_end = 0; + int total_size = 0; + + if (!setlocale(LC_CTYPE, "en_US.UTF-8")) { + printf("setlocale(LC_CTYPE,\"en_US.UTF-8\") failed!\n"); + return EXIT_FAILURE; + } + + if (!(out = fopen("c8tables.h","w"))) { + printf("error: couldn't open file \"c8tables.h\"\n"); + return EXIT_FAILURE; + } + +#if 0 + if (argc == 1) { + /* User requested 8-bit codesets, but didn't list any... */ + /* Allow to build, just so this feature can be left on in config. */ + fprintf(out, "#ifdef __CTYPE_HAS_8_BIT_LOCALES\n"); + fprintf(out, "#warning ignoring 8 bit codesets request" + " as no codesets specified.\n"); + fprintf(out, "#endif\n"); + fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n"); + + fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n"); + fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n"); + fclose(out); + return EXIT_SUCCESS; + } + +/* fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t1\n\n"); */ + fprintf(out, "#ifdef __CTYPE_HAS_8_BIT_LOCALES\n\n"); +#endif + + if (argc == 1) { + fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n"); + + fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n"); + fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n"); + } else { + fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n"); + } + + fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN); +#ifdef CTYPE_PACKED + fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1); + fprintf(out, "#define __LOCALE_DATA_Cctype_PACKED\t\t1\n"); +#else + fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN); + fprintf(out, "#undef __LOCALE_DATA_Cctype_PACKED\n"); +#endif + + fprintf(out, "\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN); + fprintf(out, "#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN); + +#ifdef DO_WIDE_CHAR + fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN); + fprintf(out, "#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN); +#endif + + fprintf(out, "\ntypedef struct {\n"); + fprintf(out, "\tunsigned char idx8ctype[%d];\n", CTYPE_IDX_LEN); + fprintf(out, "\tunsigned char idx8uplow[%d];\n", UPLOW_IDX_LEN); +#ifdef DO_WIDE_CHAR + fprintf(out, "\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN); + fprintf(out, "\tunsigned char idx8wc2c[%d];\n", II_LEN); +#endif + fprintf(out, "} __codeset_8_bit_t;\n\n"); + + fprintf(out, "#ifdef WANT_DATA\n\n"); + fprintf(out, "static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1); + + max_wchar = 0x7f; + numsets = 0; + codeset_index[0] = 0; + while (--argc) { + if (!(fp = fopen(*++argv,"r"))) { + printf("error: couldn't open file \"%s\"\n", *argv); + return EXIT_FAILURE; + } + printf("processing %s... ", *argv); + + { + char *s0; + char *s1; + int n; + + s0 = strrchr(*argv, '/'); + if (!s0) { + s0 = *argv; + } else { + ++s0; + } + s1 = strchr(s0, '.'); + if (!s1) { + n = strlen(s0); + } else { + n = s1 - s0; + } + +/* if ((numsets == 0) && strncmp("ASCII", s0, n)) { */ +/* printf("error - first codeset isn't ASCII!\n"); */ +/* return EXIT_FAILURE; */ +/* } */ + + if (numsets >= sizeof(codeset_index)) { + printf("error - too many codesets!\n"); + return EXIT_FAILURE; + } + + if (codeset_list_end + n + 1 + numsets + 1 + 1 >= 256) { + printf("error - codeset list to big!\n"); + return EXIT_FAILURE; + } + + codeset_index[numsets+1] = codeset_index[numsets] + n+1; + strncpy(codeset_list + codeset_list_end, s0, n); + codeset_list_end += (n+1); + codeset_list[codeset_list_end - 1] = 0; + + fprintf(out, "\t{ /* %.*s */", n, s0); + } + + memset(&csd[numsets],sizeof(charset_data),0); + memset(xi, sizeof(xi), 0); + { + unsigned long c, wc; + int lines; + lines = 0; + while (fgets(buf,sizeof(buf),fp)) { + if ((2 != sscanf(buf, "{ %lx , %lx", &c, &wc)) + || (c >= 256) || (wc > MAX_WCHAR)) { + printf("error: scanf failure! \"%s\"\n", buf); + return EXIT_FAILURE; + } + + /* don't put in w2c... dynamicly build tt instead. */ + + if (c <= 0x7f) { /* check the 7bit entries but don't store */ + if (c != wc) { + printf("error: c != wc in %s\n", buf); + return EXIT_FAILURE; + } + csd[numsets].c2w[c] = wc; + csd[numsets].w2c[wc] = 0; /* ignore */ + if (wc > max_wchar) { + max_wchar = wc; + } + } else { + csd[numsets].c2w[c] = wc; + csd[numsets].w2c[wc] = c; + if (wc > max_wchar) { + max_wchar = wc; + } + } + ++lines; + } + printf("%d lines ", lines); + + for (i = 0 ; i <= MAX_WCHAR ; i += (1 << TT_SHIFT)) { + p = &csd[numsets].w2c[i]; + for (j = 0 ; j < tt_num ; j++) { + if (!memcmp(p, &tt[j << TT_SHIFT], (1 << TT_SHIFT))) { + break; + } + } + if (j == tt_num) { /* new entry */ + memcpy(&tt[j << TT_SHIFT], p, (1 << TT_SHIFT)); + ++tt_num; + } + xi[i >> TT_SHIFT] = j; + } + + for (i = 0 ; i <= (MAX_WCHAR >> TT_SHIFT) ; i += (1 << TI_SHIFT)) { + p = &xi[i]; + for (j = 0 ; j < ti_num ; j++) { + if (!memcmp(p, &ti[j << TI_SHIFT], (1 << TI_SHIFT))) { + break; + } + } + if (j == ti_num) { /* new entry */ + memcpy(&ti[j << TI_SHIFT], p, (1 << TI_SHIFT)); + ++ti_num; + } + csd[numsets].ii[i >> TI_SHIFT] = j; +/* printf("%d ", i >> TI_SHIFT); */ + } + +#if 1 + fprintf(out, "\n\t\t/* idx8ctype data */\n\t\t{"); + for (i = 128 ; i < 256 ; i++) { + wchar_t c; + unsigned int d; + +/* if (!(i & 0x7)) { */ +/* fprintf(out, "\n"); */ +/* } */ + + c = csd[numsets].c2w[i]; + + if (c == 0) { /* non-existant char in codeset */ + d = __CTYPE_unclassified; + } else if (iswdigit(c)) { + d = __CTYPE_digit; + } else if (iswalpha(c)) { + d = __CTYPE_alpha_nonupper_nonlower; + if (iswlower(c)) { + d = __CTYPE_alpha_lower; + if (iswupper(c)) { + d = __CTYPE_alpha_upper_lower; + } + } else if (iswupper(c)) { + d = __CTYPE_alpha_upper; + } + } else if (iswpunct(c)) { + d = __CTYPE_punct; + } else if (iswgraph(c)) { + d = __CTYPE_graph; + } else if (iswprint(c)) { + d = __CTYPE_print_space_nonblank; + if (iswblank(c)) { + d = __CTYPE_print_space_blank; + } + } else if (iswspace(c) && !iswcntrl(c)) { + d = __CTYPE_space_nonblank_noncntrl; + if (iswblank(c)) { + d = __CTYPE_space_blank_noncntrl; + } + } else if (iswcntrl(c)) { + d = __CTYPE_cntrl_nonspace; + if (iswspace(c)) { + d = __CTYPE_cntrl_space_nonblank; + if (iswblank(c)) { + d = __CTYPE_cntrl_space_blank; + } + } + } else { + d = __CTYPE_unclassified; + } + +#if 1 + row[i & (CTYPE_ROW_LEN-1)] = d; + if ((i & (CTYPE_ROW_LEN-1)) == (CTYPE_ROW_LEN-1)) { + p = ctype_tbl; + for (j=0 ; j < n_ctype_rows ; j++) { + if (!memcmp(p, row, CTYPE_ROW_LEN)) { + break; + } + p += CTYPE_ROW_LEN; + } + if (j == n_ctype_rows) { /* new entry */ + if (++n_ctype_rows > 256) { + printf("error -- to many ctype rows!\n"); + return EXIT_FAILURE; + } + memcpy(p, row, CTYPE_ROW_LEN); + } + csd[numsets].ctype_idx[i >> CTYPE_IDX_SHIFT] = j; + if (!((i >> CTYPE_IDX_SHIFT) & 0x7) + && (i != (127 + CTYPE_ROW_LEN)) + ) { + fprintf(out, "\n\t\t "); + } + fprintf(out, " %#4x,", j); + } +#else + fprintf(out, " %#4x,", d); +#endif + } +#endif + fprintf(out, " }"); + +#if 1 + fprintf(out, ",\n\t\t/* idx8uplow data */\n\t\t{"); + for (i = 128 ; i < 256 ; i++) { + wchar_t c, u, l; +/* if (!(i & 0x7)) { */ +/* fprintf(out, "\n"); */ +/* } */ + c = csd[numsets].c2w[i]; + if ((c != 0) || 1) { + u = towupper(c); + l = towlower(c); + + if (u >= 0x80) u = csd[numsets].w2c[u]; + if (l >= 0x80) l = csd[numsets].w2c[l]; + + if (u == 0) u = i; /* upper is missing, so ignore */ + if (l == 0) l = i; /* lower is missing, so ignore */ + +#if 1 + /* store as unsigned char and let overflow handle it. */ +/* if ((((u-i) < CHAR_MIN) || ((u-i) > CHAR_MAX)) */ +/* || (((i-l) < CHAR_MIN) || ((i-l) > CHAR_MAX)) */ +/* ) { */ +/* printf("error - uplow diff out of range! %d %ld %ld\n", */ +/* i, u, l); */ +/* return EXIT_FAILURE; */ +/* } */ + + row[i & (UPLOW_ROW_LEN-1)] = ((l==i) ? (u-i) : (i-l)); + if ((i & (UPLOW_ROW_LEN-1)) == (UPLOW_ROW_LEN-1)) { + p = uplow_tbl; + for (j=0 ; j < n_uplow_rows ; j++) { + if (!memcmp(p, row, UPLOW_ROW_LEN)) { + break; + } + p += UPLOW_ROW_LEN; + } + if (j == n_uplow_rows) { /* new entry */ + if (++n_uplow_rows > 256) { + printf("error -- to many uplow rows!\n"); + return EXIT_FAILURE; + } + memcpy(p, row, UPLOW_ROW_LEN); + } + csd[numsets].uplow_idx[i >> UPLOW_IDX_SHIFT] = j; + if (!((i >> UPLOW_IDX_SHIFT) & 0x7) + && (i != (127 + UPLOW_ROW_LEN)) + ) { + fprintf(out, "\n\t\t "); + } + fprintf(out, " %#4x,", j); + } + +#elif 0 + if (!(i & 0x7) && i) { + fprintf(out, "\n"); + } + fprintf(out, " %4ld,", (l==i) ? (u-i) : (i-l)); +/* fprintf(out, " %4ld,", (l==i) ? u : l); */ +#else + if ((u != i) || (l != i)) { +#if 0 + fprintf(out, " %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, \n", + (unsigned long) i, + (unsigned long) c, + (unsigned long) l, + (unsigned long) towlower(c), + (unsigned long) u, + (unsigned long) towupper(c)); + +#else + fprintf(out, " %#08lx, %8ld, %d, %8ld, %d, %#08lx\n", + (unsigned long) i, + (long) (l - i), + iswupper(c), + (long) (i - u), + iswlower(c), + (unsigned long) c); +#endif + } +#endif + } + } + fprintf(out, " }"); +#endif + +#ifndef DO_WIDE_CHAR + fprintf(out,"\n"); +#else /* DO_WIDE_CHAR */ + +#if 1 + fprintf(out, ",\n\t\t/* idx8c2wc data */\n\t\t{"); + for (i = 128 ; i < 256 ; i++) { +#if 1 + wrow[i & (C2WC_ROW_LEN-1)] = csd[numsets].c2w[i]; + if ((i & (C2WC_ROW_LEN-1)) == (C2WC_ROW_LEN-1)) { + p = (char *) c2wc_tbl; + for (j=0 ; j < n_c2wc_rows ; j++) { + if (!memcmp(p, (char *) wrow, 2*C2WC_ROW_LEN)) { + break; + } + p += 2*C2WC_ROW_LEN; + } + if (j == n_c2wc_rows) { /* new entry */ + if (++n_c2wc_rows > 256) { + printf("error -- to many c2wc rows!\n"); + return EXIT_FAILURE; + } + memcpy(p, (char *) wrow, 2*C2WC_ROW_LEN); + } + csd[numsets].c2wc_idx[i >> C2WC_IDX_SHIFT] = j; + if (!((i >> C2WC_IDX_SHIFT) & 0x7) + && (i != (127 + C2WC_ROW_LEN)) + ) { + fprintf(out, "\n\t\t "); + } + fprintf(out, " %#4x,", j); + } +#else + if (!(i & 0x7) && i) { + fprintf(out, "\n"); + } + fprintf(out, " %#6lx,", csd[numsets].c2w[i]); +#endif + } + fprintf(out, " },\n"); +#endif + +#if 1 +/* fprintf(out, "\nII_LEN = %d\n", II_LEN); */ + fprintf(out, "\t\t/* idx8wc2c data */\n\t\t{"); + for (i = 0 ; i < II_LEN ; i++) { + if (!(i & 0x7) && i) { + fprintf(out, "\n\t\t "); + } + fprintf(out, " %#4x,", csd[numsets].ii[i]); + } + fprintf(out, " }\n"); +#endif + +#endif /* DO_WIDE_CHAR */ + fprintf(out, "\t},\n"); + + } + ++numsets; + printf("done\n"); + } + fprintf(out, "};\n"); + fprintf(out, "\n#endif /* WANT_DATA */\n"); + +#ifdef DO_WIDE_CHAR + fprintf(out, "\n"); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT); + fprintf(out, "\n"); + + fprintf(out, "\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n", + (ti_num << TI_SHIFT) + (tt_num << TT_SHIFT)); + + fprintf(out, "#ifdef WANT_DATA\n\n"); + fprintf(out, "static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n", + (ti_num << TI_SHIFT) + (tt_num << TT_SHIFT)); + fprintf(out, "\t/* ti_table */\n\t"); + for (i=0 ; i < ti_num << TI_SHIFT ; i++) { + if (!(i & 7) && i) { + fprintf(out, "\n\t"); + } + fprintf(out, " %#4x,", ti[i]); + } + fprintf(out, "\n"); + fprintf(out, "\t/* tt_table */\n\t"); + for (i=0 ; i < tt_num << TT_SHIFT ; i++) { + if (!(i & 7) && i) { + fprintf(out, "\n\t"); + } + fprintf(out, " %#4x,", tt[i]); + } + fprintf(out, "\n};\n"); + + fprintf(out, "\n#endif /* WANT_DATA */\n"); +#endif /* DO_WIDE_CHAR */ + + fprintf(out, "\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n", + n_uplow_rows * UPLOW_ROW_LEN); + fprintf(out, "\n#ifdef WANT_DATA\n\n"); + + fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n", + n_uplow_rows * UPLOW_ROW_LEN); + p = uplow_tbl; + for (j=0 ; j < n_uplow_rows ; j++) { + fprintf(out, "\t"); + for (i=0 ; i < UPLOW_ROW_LEN ; i++) { + fprintf(out, " %#4x,", (unsigned int)((unsigned char) p[i])); + } + fprintf(out, "\n"); + p += UPLOW_ROW_LEN; + } + fprintf(out, "};\n"); + + fprintf(out, "\n#endif /* WANT_DATA */\n"); + fprintf(out, "\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n", +#ifdef CTYPE_PACKED + n_ctype_rows * CTYPE_ROW_LEN / 2 +#else + n_ctype_rows * CTYPE_ROW_LEN +#endif + ); + fprintf(out, "\n#ifdef WANT_DATA\n\n"); + + + fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n", +#ifdef CTYPE_PACKED + n_ctype_rows * CTYPE_ROW_LEN / 2 +#else + n_ctype_rows * CTYPE_ROW_LEN +#endif + ); + p = ctype_tbl; + for (j=0 ; j < n_ctype_rows ; j++) { + fprintf(out, "\t"); + for (i=0 ; i < CTYPE_ROW_LEN ; i++) { +#ifdef CTYPE_PACKED + fprintf(out, " %#4x,", (unsigned int)(p[i] + (p[i+1] << 4))); + ++i; +#else + fprintf(out, " %#4x,", (unsigned int)p[i]); +#endif + } + fprintf(out, "\n"); + p += CTYPE_ROW_LEN; + } + fprintf(out, "};\n"); + + fprintf(out, "\n#endif /* WANT_DATA */\n"); + +#ifdef DO_WIDE_CHAR + + fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n", + n_c2wc_rows * C2WC_ROW_LEN); + fprintf(out, "\n#ifdef WANT_DATA\n\n"); + + fprintf(out, "\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n", + n_c2wc_rows * C2WC_ROW_LEN); + p = (char *) c2wc_tbl; + for (j=0 ; j < n_c2wc_rows ; j++) { + fprintf(out, "\t"); + for (i=0 ; i < C2WC_ROW_LEN ; i++) { + fprintf(out, " %#6x,", (unsigned int)(((unsigned short *)p)[i])); + } + fprintf(out, "\n"); + p += 2*C2WC_ROW_LEN; + } + fprintf(out, "};\n"); + fprintf(out, "\n#endif /* WANT_DATA */\n"); +#endif /* DO_WIDE_CHAR */ + fprintf(out, "\n\n"); + + fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets); + fprintf(out, "#define __LOCALE_DATA_CODESET_LIST \\\n\t\""); + for (i=0 ; i < numsets ; i++) { + fprintf(out, "\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]); + if (((i & 7) == 7) && (i + 1 < numsets)) { + fprintf(out, "\" \\\n\t\""); + } + } + fprintf(out, "\" \\\n\t\"\\0\""); + for (i=0 ; i < numsets ; i++) { + fprintf(out, " \\\n\t\"%s\\0\"", + codeset_list + ((unsigned char)codeset_index[i])); + } + + fprintf(out, "\n\n"); + for (i=0 ; i < numsets ; i++) { + char buf[30]; + char *z; + strcpy(buf, codeset_list + ((unsigned char)codeset_index[i])); + for (z=buf ; *z ; z++) { + if (*z == '-') { + *z = '_'; + } + } + fprintf(out, "#define __CTYPE_HAS_CODESET_%s\n", buf); + } +#ifdef DO_WIDE_CHAR + fprintf(out, "#define __CTYPE_HAS_CODESET_UTF_8\n"); +#endif /* DO_WIDE_CHAR */ + +#if 0 + fprintf(out, "\n#endif /* __CTYPE_HAS_8_BIT_LOCALES */\n\n"); +#endif + + fclose(out); + + total_size = 0; +#ifdef DO_WIDE_CHAR + printf("tt_num = %d ti_num = %d\n", tt_num, ti_num); + printf("max_wchar = %#lx\n", max_wchar); + + printf("size is %d * %d + %d * %d + %d * %d = %d\n", + tt_num, 1 << TT_SHIFT, ti_num, 1 << TI_SHIFT, + ((MAX_WCHAR >> (TT_SHIFT + TI_SHIFT)) + 1), numsets, + j = tt_num * (1 << TT_SHIFT) + ti_num * (1 << TI_SHIFT) + + ((MAX_WCHAR >> (TT_SHIFT + TI_SHIFT)) + 1) * numsets); + total_size += j; +#endif /* DO_WIDE_CHAR */ + +#ifdef CTYPE_PACKED + i = 2; +#else + i = 1; +#endif + + printf("ctype - CTYPE_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n", + CTYPE_IDX_SHIFT, numsets, CTYPE_IDX_LEN, n_ctype_rows, CTYPE_ROW_LEN / i, + j = numsets * CTYPE_IDX_LEN + n_ctype_rows * CTYPE_ROW_LEN / i); + total_size += j; + + printf("uplow - UPLOW_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n", + UPLOW_IDX_SHIFT, numsets, UPLOW_IDX_LEN, n_uplow_rows, UPLOW_ROW_LEN, + j = numsets * UPLOW_IDX_LEN + n_uplow_rows * UPLOW_ROW_LEN); + total_size += j; + +#ifdef DO_WIDE_CHAR + + printf("c2wc - C2WC_IDX_SHIFT = %d -- %d * %d + 2 * %d * %d = %d\n", + C2WC_IDX_SHIFT, numsets, C2WC_IDX_LEN, n_c2wc_rows, C2WC_ROW_LEN, + j = numsets * C2WC_IDX_LEN + 2 * n_c2wc_rows * C2WC_ROW_LEN); + total_size += j; + +#endif /* DO_WIDE_CHAR */ + + printf("total size = %d\n", total_size); + +/* for (i=0 ; i < numsets ; i++) { */ +/* printf("codeset_index[i] = %d codeset_list[ci[i]] = \"%s\"\n", */ +/* (unsigned char) codeset_index[i], */ +/* codeset_list + ((unsigned char)codeset_index[i])); */ +/* } */ + + return EXIT_SUCCESS; +} diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c new file mode 100644 index 0000000..6a90b92 --- /dev/null +++ b/extra/locale/gen_wctype.c @@ -0,0 +1,870 @@ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _CTYPE_H +#define _CTYPE_H +#endif +#ifndef _WCTYPE_H +#define _WCTYPE_H +#endif +#include "../../libc/sysdeps/linux/common/bits/uClibc_ctype.h" + +/* 0x9 : space blank */ +/* 0xa : space */ +/* 0xb : space */ +/* 0xc : space */ +/* 0xd : space */ +/* 0x20 : space blank */ +/* 0x1680 : space blank */ +/* 0x2000 : space blank */ +/* 0x2001 : space blank */ +/* 0x2002 : space blank */ +/* 0x2003 : space blank */ +/* 0x2004 : space blank */ +/* 0x2005 : space blank */ +/* 0x2006 : space blank */ +/* 0x2008 : space blank */ +/* 0x2009 : space blank */ +/* 0x200a : space blank */ +/* 0x200b : space blank */ +/* 0x2028 : space */ +/* 0x2029 : space */ +/* 0x3000 : space blank */ + +/* typecount[ 0] = 88670 C_alpha_nonupper_nonlower */ +/* typecount[ 1] = 742 C_alpha_lower */ +/* typecount[ 2] = 4 C_alpha_upper_lower */ +/* typecount[ 3] = 731 C_alpha_upper */ +/* typecount[ 4] = 10 C_digit */ +/* typecount[ 5] = 10270 C_punct */ +/* typecount[ 6] = 0 C_graph */ +/* typecount[ 7] = 0 C_print_space_nonblank */ +/* typecount[ 8] = 14 C_print_space_blank */ +/* typecount[ 9] = 0 C_space_nonblank_noncntrl */ +/* typecount[10] = 0 C_space_blank_noncntrl */ +/* typecount[11] = 6 C_cntrl_space_nonblank */ +/* typecount[12] = 1 C_cntrl_space_blank */ +/* typecount[13] = 60 C_cntrl_nonspace */ +/* typecount[14] = 96100 C_unclassified */ +/* typecount[15] = 0 empty_slot */ + + + +/* Set to #if 0 to restrict wchars to 16 bits. */ +#if 1 +#define RANGE 0x2ffffUL +#elif 0 +#define RANGE 0x1ffffUL +#else +#define RANGE 0xffffUL /* Restrict for 16-bit wchar_t... */ +#endif + +#if 0 +/* Classification codes. */ + +static const char *typename[] = { + "C_unclassified", + "C_alpha_nonupper_nonlower", + "C_alpha_lower", + "C_alpha_upper_lower", + "C_alpha_upper", + "C_digit", + "C_punct", + "C_graph", + "C_print_space_nonblank", + "C_print_space_blank", + "C_space_nonblank_noncntrl", + "C_space_blank_noncntrl", + "C_cntrl_space_nonblank", + "C_cntrl_space_blank", + "C_cntrl_nonspace", + "empty_slot" +}; +#endif + +#if 0 +/* Taking advantage of the C99 mutual-exclusion guarantees for the various + * (w)ctype classes, including the descriptions of printing and control + * (w)chars, we can place each in one of the following mutually-exlusive + * subsets. Since there are less than 16, we can store the data for + * each (w)chars in a nibble. In contrast, glibc uses an unsigned int + * per (w)char, with one bit flag for each is* type. While this allows + * a simple '&' operation to determine the type vs. a range test and a + * little special handling for the "blank" and "xdigit" types in my + * approach, it also uses 8 times the space for the tables on the typical + * 32-bit archs we supported.*/ +enum { + __CTYPE_unclassified = 0, + __CTYPE_alpha_nonupper_nonlower, + __CTYPE_alpha_lower, + __CTYPE_alpha_upper_lower, + __CTYPE_alpha_upper, + __CTYPE_digit, + __CTYPE_punct, + __CTYPE_graph, + __CTYPE_print_space_nonblank, + __CTYPE_print_space_blank, + __CTYPE_space_nonblank_noncntrl, + __CTYPE_space_blank_noncntrl, + __CTYPE_cntrl_space_nonblank, + __CTYPE_cntrl_space_blank, + __CTYPE_cntrl_nonspace, +}; +#endif + +#define __CTYPE_isxdigit(D,X) \ + (__CTYPE_isdigit(D) || (((unsigned int)(((X)|0x20) - 'a')) <= 5)) + +#define mywalnum(x) __CTYPE_isalnum(d) +#define mywalpha(x) __CTYPE_isalpha(d) +#define mywblank(x) __CTYPE_isblank(d) +#define mywcntrl(x) __CTYPE_iscntrl(d) +#define mywdigit(x) __CTYPE_isdigit(d) +#define mywgraph(x) __CTYPE_isgraph(d) +#define mywlower(x) __CTYPE_islower(d) +#define mywprint(x) __CTYPE_isprint(d) +#define mywpunct(x) __CTYPE_ispunct(d) +#define mywspace(x) __CTYPE_isspace(d) +#define mywupper(x) __CTYPE_isupper(d) +#define mywxdigit(x) __CTYPE_isxdigit(d,x) + +typedef struct { + short l; + short u; +} uldiff_entry; + +typedef struct { + uint16_t ii_len; + uint16_t ti_len; + uint16_t ut_len; + + unsigned char ii_shift; + unsigned char ti_shift; + + unsigned char *ii; + unsigned char *ti; + unsigned char *ut; +} table_data; + + +void output_table(FILE *fp, const char *name, table_data *tbl) +{ + size_t i; + + fprintf(fp, "#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len); + fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len); + fprintf(fp, "#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len); + + fprintf(fp, "#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift); + fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift); + + fprintf(fp, "\n#ifdef WANT_WC%s_data\n", name); + + i = tbl->ii_len + tbl->ti_len + tbl->ut_len; + fprintf(fp, "\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i); + for (i=0 ; i < tbl->ii_len ; i++) { + if (i % 12 == 0) { + fprintf(fp, "\n"); + } + fprintf(fp, " %#04x,", tbl->ii[i]); + } + for (i=0 ; i < tbl->ti_len ; i++) { + if (i % 12 == 0) { + fprintf(fp, "\n"); + } + fprintf(fp, " %#04x,", tbl->ti[i]); + } + for (i=0 ; i < tbl->ut_len ; i++) { + if (i % 12 == 0) { + fprintf(fp, "\n"); + } + fprintf(fp, " %#04x,", tbl->ut[i]); + } + fprintf(fp, "\n};\n\n"); + + fprintf(fp, "#endif /* WANT_WC%s_data */\n\n", name); +} + +static void dump_table_data(table_data *tbl) +{ + printf("ii_shift = %d ti_shift = %d\n" + "ii_len = %d ti_len = %d ut_len = %d\n" + "total = %d\n", + tbl->ii_shift, tbl->ti_shift, + tbl->ii_len, tbl->ti_len, tbl->ut_len, + (int) tbl->ii_len + (int) tbl->ti_len + (int) tbl->ut_len); +} + +/* For sorting the blocks of unsigned chars. */ +static size_t nu_val; + +int nu_memcmp(const void *a, const void *b) +{ + return memcmp(*(unsigned char**)a, *(unsigned char**)b, nu_val); +} + +static size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl); + +#define MAXTO 255 /* Restrict to minimal unsigned char max. */ + +int main(int argc, char **argv) +{ + long int u, l, tt; + size_t smallest, t; + unsigned int c; + unsigned int d; + int i, n; + int ul_count = 0; + uldiff_entry uldiff[MAXTO]; + table_data cttable; + table_data ultable; + table_data combtable; + table_data widthtable; + long int last_comb = 0; + + unsigned char wct[(RANGE/2)+1]; /* wctype table (nibble per wchar) */ + unsigned char ult[RANGE+1]; /* upper/lower table */ + unsigned char combt[(RANGE/4)+1]; /* combining */ + unsigned char widtht[(RANGE/4)+1]; /* width */ + wctrans_t totitle; + wctype_t is_comb, is_comb3; + + long int typecount[16]; + const char *typename[16]; + static const char empty_slot[] = "empty_slot"; + int built = 0; + +#define INIT_TYPENAME(X) typename[__CTYPE_##X] = "C_" #X + + for (i=0 ; i < 16 ; i++) { + typename[i] = empty_slot; + } + + INIT_TYPENAME(unclassified); + INIT_TYPENAME(alpha_nonupper_nonlower); + INIT_TYPENAME(alpha_lower); + INIT_TYPENAME(alpha_upper_lower); + INIT_TYPENAME(alpha_upper); + INIT_TYPENAME(digit); + INIT_TYPENAME(punct); + INIT_TYPENAME(graph); + INIT_TYPENAME(print_space_nonblank); + INIT_TYPENAME(print_space_blank); + INIT_TYPENAME(space_nonblank_noncntrl); + INIT_TYPENAME(space_blank_noncntrl); + INIT_TYPENAME(cntrl_space_nonblank); + INIT_TYPENAME(cntrl_space_blank); + INIT_TYPENAME(cntrl_nonspace); + + setvbuf(stdout, NULL, _IONBF, 0); + + while (--argc) { + if (!setlocale(LC_CTYPE, *++argv)) { + printf("setlocale(LC_CTYPE,%s) failed!\n", *argv); + continue; + } + + if (!(totitle = wctrans("totitle"))) { + printf("no totitle transformation.\n"); + } + if (!(is_comb = wctype("combining"))) { + printf("no combining wctype.\n"); + } + if (!(is_comb3 = wctype("combining_level3"))) { + printf("no combining_level3 wctype.\n"); + } + + if (!built) { + built = 1; + ul_count = 1; + uldiff[0].u = uldiff[0].l = 0; + + memset(wct, 0, sizeof(wct)); + memset(combt, 0, sizeof(combt)); + memset(widtht, 0, sizeof(widtht)); + + for (i = 0 ; i < 16 ; i++) { + typecount[i] = 0; + } + + for (c=0 ; c <= RANGE ; c++) { + if (iswdigit(c)) { + d = __CTYPE_digit; + } else if (iswalpha(c)) { + d = __CTYPE_alpha_nonupper_nonlower; + if (iswlower(c)) { + d = __CTYPE_alpha_lower; + if (iswupper(c)) { + d = __CTYPE_alpha_upper_lower; + } + } else if (iswupper(c)) { + d = __CTYPE_alpha_upper; + } + } else if (iswpunct(c)) { + d = __CTYPE_punct; + } else if (iswgraph(c)) { + d = __CTYPE_graph; + } else if (iswprint(c)) { + d = __CTYPE_print_space_nonblank; + if (iswblank(c)) { + d = __CTYPE_print_space_blank; + } + } else if (iswspace(c) && !iswcntrl(c)) { + d = __CTYPE_space_nonblank_noncntrl; + if (iswblank(c)) { + d = __CTYPE_space_blank_noncntrl; + } + } else if (iswcntrl(c)) { + d = __CTYPE_cntrl_nonspace; + if (iswspace(c)) { + d = __CTYPE_cntrl_space_nonblank; + if (iswblank(c)) { + d = __CTYPE_cntrl_space_blank; + } + } + } else { + d = __CTYPE_unclassified; + } + + ++typecount[d]; + +#if 0 + if (iswspace(c)) { + if (iswblank(c)) { + printf("%#8x : space blank\n", c); + } else { + printf("%#8x : space\n", c); + } + } +#endif + +#if 0 + if (c < 256) { + unsigned int glibc; + + glibc = 0; + if (isalnum(c)) ++glibc; glibc <<= 1; + if (isalpha(c)) ++glibc; glibc <<= 1; + if (isblank(c)) ++glibc; glibc <<= 1; + if (iscntrl(c)) ++glibc; glibc <<= 1; + if (isdigit(c)) ++glibc; glibc <<= 1; + if (isgraph(c)) ++glibc; glibc <<= 1; + if (islower(c)) ++glibc; glibc <<= 1; + if (isprint(c)) ++glibc; glibc <<= 1; + if (ispunct(c)) ++glibc; glibc <<= 1; + if (isspace(c)) ++glibc; glibc <<= 1; + if (isupper(c)) ++glibc; glibc <<= 1; + if (isxdigit(c)) ++glibc; + printf("%#8x : ctype %#4x\n", c, glibc); + } +#endif + +#if 1 + /* Paranoid checking... */ + { + unsigned int glibc; + unsigned int mine; + + glibc = 0; + if (iswalnum(c)) ++glibc; glibc <<= 1; + if (iswalpha(c)) ++glibc; glibc <<= 1; + if (iswblank(c)) ++glibc; glibc <<= 1; + if (iswcntrl(c)) ++glibc; glibc <<= 1; + if (iswdigit(c)) ++glibc; glibc <<= 1; + if (iswgraph(c)) ++glibc; glibc <<= 1; + if (iswlower(c)) ++glibc; glibc <<= 1; + if (iswprint(c)) ++glibc; glibc <<= 1; + if (iswpunct(c)) ++glibc; glibc <<= 1; + if (iswspace(c)) ++glibc; glibc <<= 1; + if (iswupper(c)) ++glibc; glibc <<= 1; + if (iswxdigit(c)) ++glibc; + + mine = 0; + if (mywalnum(c)) ++mine; mine <<= 1; + if (mywalpha(c)) ++mine; mine <<= 1; + if (mywblank(c)) ++mine; mine <<= 1; + if (mywcntrl(c)) ++mine; mine <<= 1; + if (mywdigit(c)) ++mine; mine <<= 1; + if (mywgraph(c)) ++mine; mine <<= 1; + if (mywlower(c)) ++mine; mine <<= 1; + if (mywprint(c)) ++mine; mine <<= 1; + if (mywpunct(c)) ++mine; mine <<= 1; + if (mywspace(c)) ++mine; mine <<= 1; + if (mywupper(c)) ++mine; mine <<= 1; + if (mywxdigit(c)) ++mine; + + if (glibc != mine) { + printf("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d); + return EXIT_FAILURE; + } + +#if 0 + if (iswctype(c,is_comb) || iswctype(c,is_comb3)) { +/* if (!iswpunct(c)) { */ + printf("%#8x : %d %d %#4x\n", + c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc); +/* } */ + } +#endif +#if 0 + if (iswctype(c,is_comb) || iswctype(c,is_comb3)) { + if (!last_comb) { + printf("%#8x - ", c); + last_comb = c; + } else if (last_comb + 1 < c) { + printf("%#8x\n%#8x - ", last_comb, c); + last_comb = c; + } else { + last_comb = c; + } + } +#endif + } +#endif + + combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3)) + << ((c & 3) << 1)); +/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */ + +/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */ + + if (c & 1) { /* Use the high nibble for odd numbered wchars. */ + d <<= 4; + } + wct[c/2] |= d; + + l = towlower(c) - c; + u = towupper(c) - c; + ult[c] = 0; + if (l || u) { + if ((l != (short)l) || (u != (short)u)) { + printf("range assumption error! %x %ld %ld\n", c, l, u); + return EXIT_FAILURE; + } + for (i=0 ; i < ul_count ; i++) { + if ((l == uldiff[i].l) && (u == uldiff[i].u)) { + goto found; + } + } + uldiff[ul_count].l = l; + uldiff[ul_count].u = u; + ++ul_count; + if (ul_count > MAXTO) { + printf("too many touppers/tolowers!\n"); + return EXIT_FAILURE; + } + found: + ult[c] = i; + } + } + + for (i = 0 ; i < 16 ; i++) { + printf("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]); + } + + printf("optimizing is* table..\n"); + n = -1; + smallest = SIZE_MAX; + cttable.ii = NULL; + for (i=0 ; i < 14 ; i++) { + t = newopt(wct, (RANGE/2)+1, i, &cttable); + if (smallest >= t) { + n = i; + smallest = t; +/* } else { */ +/* break; */ + } + } + printf("smallest = %zu\n", smallest); + if (!(cttable.ii = malloc(smallest))) { + printf("couldn't allocate space!\n"); + return EXIT_FAILURE; + } + smallest = SIZE_MAX; + newopt(wct, (RANGE/2)+1, n, &cttable); + ++cttable.ti_shift; /* correct for nibble mode */ + + + + printf("optimizing u/l-to table..\n"); + smallest = SIZE_MAX; + ultable.ii = NULL; + for (i=0 ; i < 14 ; i++) { + t = newopt(ult, RANGE+1, i, &ultable); + if (smallest >= t) { + n = i; + smallest = t; +/* } else { */ +/* break; */ + } + } + printf("%zu (smallest) + %zu (u/l diffs) = %zu\n", + smallest, 4 * ul_count, smallest + 4 * ul_count); + printf("smallest = %zu\n", smallest); + if (!(ultable.ii = malloc(smallest))) { + printf("couldn't allocate space!\n"); + return EXIT_FAILURE; + } + smallest = SIZE_MAX; + newopt(ult, RANGE+1, n, &ultable); + + +#if 0 + printf("optimizing comb table..\n"); + smallest = SIZE_MAX; + combtable.ii = NULL; + for (i=0 ; i < 14 ; i++) { + t = newopt(combt, sizeof(combt), i, &combtable); + if (smallest >= t) { + n = i; + smallest = t; +/* } else { */ +/* break; */ + } + } + printf("smallest = %zu\n", smallest); + if (!(combtable.ii = malloc(smallest))) { + printf("couldn't allocate space!\n"); + return EXIT_FAILURE; + } + smallest = SIZE_MAX; + newopt(combt, sizeof(combt), n, &combtable); + combtable.ti_shift += 4; /* correct for 4 entries per */ +#endif + + +#if 0 + printf("optimizing width table..\n"); + smallest = SIZE_MAX; + widthtable.ii = NULL; + for (i=0 ; i < 14 ; i++) { + t = newopt(widtht, sizeof(widtht), i, &widthtable); + if (smallest >= t) { + n = i; + smallest = t; +/* } else { */ +/* break; */ + } + } + printf("smallest = %zu\n", smallest); + if (!(widthtable.ii = malloc(smallest))) { + printf("couldn't allocate space!\n"); + return EXIT_FAILURE; + } + smallest = SIZE_MAX; + newopt(widtht, sizeof(widtht), n, &widthtable); + widthtable.ti_shift += 4; /* correct for 4 entries per */ +#endif + +#if 0 + printf("optimizing comb3 table..\n"); + smallest = SIZE_MAX; + comb3table.ii = NULL; + for (i=0 ; i < 14 ; i++) { + t = newopt(comb3t, sizeof(comb3t), i, &comb3table); + if (smallest >= t) { + n = i; + smallest = t; +/* } else { */ +/* break; */ + } + } + printf("smallest = %zu\n", smallest); + if (!(comb3table.ii = malloc(smallest))) { + printf("couldn't allocate space!\n"); + return EXIT_FAILURE; + } + smallest = SIZE_MAX; + newopt(comb3t, sizeof(comb3t), n, &comb3table); + comb3table.ti_shift += 8; /* correct for 4 entries per */ +#endif + + dump_table_data(&cttable); + dump_table_data(&ultable); + dump_table_data(&combtable); + } + + printf("verifying for %s...\n", *argv); +#if RANGE == 0xffffU + for (c=0 ; c <= 0xffffUL ; c++) +#else + for (c=0 ; c <= 0x10ffffUL ; c++) +#endif + { + unsigned int glibc; + unsigned int mine; + unsigned int upper, lower; + +#if 0 +#if RANGE < 0x10000UL + if (c == 0x10000UL) { + c = 0x30000UL; /* skip 1st and 2nd sup planes */ + } +#elif RANGE < 0x20000UL + if (c == 0x20000UL) { + c = 0x30000UL; /* skip 2nd sup planes */ + } +#endif +#endif + + glibc = 0; + if (iswalnum(c)) ++glibc; glibc <<= 1; + if (iswalpha(c)) ++glibc; glibc <<= 1; + if (iswblank(c)) ++glibc; glibc <<= 1; + if (iswcntrl(c)) ++glibc; glibc <<= 1; + if (iswdigit(c)) ++glibc; glibc <<= 1; + if (iswgraph(c)) ++glibc; glibc <<= 1; + if (iswlower(c)) ++glibc; glibc <<= 1; + if (iswprint(c)) ++glibc; glibc <<= 1; + if (iswpunct(c)) ++glibc; glibc <<= 1; + if (iswspace(c)) ++glibc; glibc <<= 1; + if (iswupper(c)) ++glibc; glibc <<= 1; + if (iswxdigit(c)) ++glibc; + + { + unsigned int u; + int n, sc; + int i0, i1; + + u = c; + if (u <= RANGE) { + sc = u & ((1 << cttable.ti_shift) - 1); + u >>= cttable.ti_shift; + n = u & ((1 << cttable.ii_shift) - 1); + u >>= cttable.ii_shift; + + i0 = cttable.ii[u]; + i0 <<= cttable.ii_shift; + i1 = cttable.ti[i0 + n]; + i1 <<= (cttable.ti_shift-1); + d = cttable.ut[i1 + (sc >> 1)]; + + if (sc & 1) { + d >>= 4; + } + d &= 0x0f; + } else if ((((unsigned int)(c - 0xe0020UL)) <= 0x5f) || (c == 0xe0001UL)){ + d = __CTYPE_punct; + } else if (((unsigned int)(c - 0xf0000UL)) < 0x20000UL) { + if ((c & 0xffffU) <= 0xfffdU) { + d = __CTYPE_punct; + } else { + d = __CTYPE_unclassified; + } + } else { + d = __CTYPE_unclassified; + } + + mine = 0; + if (mywalnum(c)) ++mine; mine <<= 1; + if (mywalpha(c)) ++mine; mine <<= 1; + if (mywblank(c)) ++mine; mine <<= 1; + if (mywcntrl(c)) ++mine; mine <<= 1; + if (mywdigit(c)) ++mine; mine <<= 1; + if (mywgraph(c)) ++mine; mine <<= 1; + if (mywlower(c)) ++mine; mine <<= 1; + if (mywprint(c)) ++mine; mine <<= 1; + if (mywpunct(c)) ++mine; mine <<= 1; + if (mywspace(c)) ++mine; mine <<= 1; + if (mywupper(c)) ++mine; mine <<= 1; + if (mywxdigit(c)) ++mine; + + if (glibc != mine) { + printf("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d); + if (c < 0x30000UL) { + printf("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1); + } + } + upper = lower = u = c; + if (u <= RANGE) { + sc = u & ((1 << ultable.ti_shift) - 1); + u >>= ultable.ti_shift; + n = u & ((1 << ultable.ii_shift) - 1); + u >>= ultable.ii_shift; + + i0 = ultable.ii[u]; + i0 <<= ultable.ii_shift; + i1 = ultable.ti[i0 + n]; + i1 <<= (ultable.ti_shift); + i1 += sc; + i0 = ultable.ut[i1]; + upper = c + uldiff[i0].u; + lower = c + uldiff[i0].l; + } + + if (towupper(c) != upper) { + printf("%#8x : towupper glibc %#4x != %#4x mine\n", + c, towupper(c), upper); + } + + if (towlower(c) != lower) { + printf("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n", + c, towlower(c), lower, i0); + } + + if (totitle && ((tt = towctrans(c, totitle)) != upper)) { + printf("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n", + c, tt, upper, i0); + } + } + + + if ((c & 0xfff) == 0xfff) printf("."); + } + printf("done\n"); + } + + if (1) { + FILE *fp; + + if (!(fp = fopen("wctables.h", "w"))) { + printf("couldn't open wctables.h!\n"); + return EXIT_FAILURE; + } + + fprintf(fp, "#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n", + (unsigned long) RANGE); + output_table(fp, "ctype", &cttable); + output_table(fp, "uplow", &ultable); + + +#warning fix the upper bound on the upper/lower tables... save 200 bytes or so + fprintf(fp, "#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count); + fprintf(fp, "\n#ifdef WANT_WCuplow_diff_data\n\n"); + fprintf(fp, "\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {", + 2 * (size_t) ul_count); + for (i=0 ; i < ul_count ; i++) { + if (i % 4 == 0) { + fprintf(fp, "\n"); + } + fprintf(fp, " %6d, %6d,", uldiff[i].u, uldiff[i].l); + } + fprintf(fp, "\n};\n\n"); + fprintf(fp, "#endif /* WANT_WCuplow_diff_data */\n\n"); + + +/* output_table(fp, "comb", &combtable); */ +/* output_table(fp, "width", &widthtable); */ + + fclose(fp); + } + + return EXIT_SUCCESS; +} + +size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl) +{ + static int recurse = 0; + unsigned char *ti[RANGE+1]; /* table index */ + size_t numblocks; + size_t blocksize; + size_t uniq; + size_t i, j; + size_t smallest, t; + unsigned char *ii_save; + int uniqblock[256]; + unsigned char uit[RANGE+1]; + int shift2; + + ii_save = NULL; + blocksize = 1 << shift; + numblocks = usize >> shift; + + /* init table index */ + for (i=j=0 ; i < numblocks ; i++) { + ti[i] = ut + j; + j += blocksize; + } + + /* sort */ + nu_val = blocksize; + qsort(ti, numblocks, sizeof(unsigned char *), nu_memcmp); + + uniq = 1; + uit[(ti[0]-ut)/blocksize] = 0; + for (i=1 ; i < numblocks ; i++) { + if (memcmp(ti[i-1], ti[i], blocksize) < 0) { + if (++uniq > 255) { + break; + } + uniqblock[uniq - 1] = i; + } +#if 1 + else if (memcmp(ti[i-1], ti[i], blocksize) > 0) { + printf("bad sort %i!\n", i); + abort(); + } +#endif + uit[(ti[i]-ut)/blocksize] = uniq - 1; + } + + smallest = SIZE_MAX; + shift2 = -1; + if (uniq <= 255) { + smallest = numblocks + uniq * blocksize; + if (!recurse) { + ++recurse; + for (j=1 ; j < 14 ; j++) { + if ((numblocks >> j) < 2) break; + if (tbl) { + ii_save = tbl->ii; + tbl->ii = NULL; + } + if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) { + t += uniq * blocksize; + } + if (tbl) { + tbl->ii = ii_save; + } + if (smallest >= t) { + shift2 = j; + smallest = t; + if (!tbl->ii) { + printf("ishift %zu tshift %zu size %zu\n", + shift2, shift, t); + } +/* } else { */ +/* break; */ + } + } + --recurse; + } + } else { + return SIZE_MAX; + } + + if (tbl->ii) { + if (recurse) { + tbl->ii_shift = shift; + tbl->ii_len = numblocks; + memcpy(tbl->ii, uit, numblocks); + tbl->ti = tbl->ii + tbl->ii_len; + tbl->ti_len = uniq * blocksize; + for (i=0 ; i < uniq ; i++) { + memcpy(tbl->ti + i * blocksize, ti[uniqblock[i]], blocksize); + } + } else { + ++recurse; + printf("setting ishift %zu tshift %zu\n", + shift2, shift); + newopt(uit, numblocks, shift2, tbl); + --recurse; + tbl->ti_shift = shift; + tbl->ut_len = uniq * blocksize; + tbl->ut = tbl->ti + tbl->ti_len; + for (i=0 ; i < uniq ; i++) { + memcpy(tbl->ut + i * blocksize, ti[uniqblock[i]], blocksize); + } + } + } + return smallest; +} diff --git a/extra/locale/lmmtolso.c b/extra/locale/lmmtolso.c new file mode 100644 index 0000000..a1876a7 --- /dev/null +++ b/extra/locale/lmmtolso.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include + +int main(void) +{ + FILE *lmm; /* mmap-able file */ + FILE *lso; /* static object */ + struct stat fd_stat; + int c; + size_t i; + + if (!(lmm = fopen("locale.mmap", "r"))) { + printf("can't open locale.mmap!\n"); + return EXIT_FAILURE; + } + + if (fstat(fileno(lmm), &fd_stat)) { + printf("can't stat locale.mmap!\n"); + fclose(lmm); + return EXIT_FAILURE; + } + + if (!(lso = fopen("locale_data.c", "w"))) { + printf("can't open locale_data.c!\n"); + fclose(lmm); + return EXIT_FAILURE; + } + + fprintf(lso, + "#include \n" + "#include \n" + "#include \"lt_defines.h\"\n" + "#include \"locale_mmap.h\"\n\n" + "typedef union {\n" + "\tunsigned char buf[%zu];\n" + "\t__locale_mmap_t lmm;\n" + "} locale_union_t;\n\n" + "static const locale_union_t locale_union = { {", + (size_t) fd_stat.st_size + ); + + i = 0; + while ((c = getc(lmm)) != EOF) { + if (!(i & 0x7)) { + fprintf(lso, "\n\t"); + } + fprintf(lso, "%#04x, ", c); + ++i; + } + fprintf(lso, + "\n} };\n\n" + "const __locale_mmap_t *__locale_mmap = &locale_union.lmm;\n\n" + ); + + if (ferror(lmm)) { + printf("error reading!\n"); + return EXIT_FAILURE; + } + + if (ferror(lso) || fclose(lso)) { + printf("error writing!\n"); + return EXIT_FAILURE; + } + + fclose(lmm); + + return EXIT_SUCCESS; +} diff --git a/extra/locale/locale_mmap.h b/extra/locale/locale_mmap.h new file mode 100644 index 0000000..1b74823 --- /dev/null +++ b/extra/locale/locale_mmap.h @@ -0,0 +1,93 @@ +/* #define __LOCALE_DATA_MAGIC_SIZE 64 */ +#ifndef __WCHAR_ENABLED +#if 0 +#warning WHOA!!! __WCHAR_ENABLED is not defined! defining it now... +#endif +#define __WCHAR_ENABLED +#endif + +/* TODO - fix */ +#ifdef __WCHAR_ENABLED +#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN) +#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN) +#define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs) +/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */ +#endif + +#undef __PASTE2 +#define __PASTE2(A,B) A ## B +#undef __PASTE3 +#define __PASTE3(A,B,C) A ## B ## C + +#define __LOCALE_DATA_COMMON_MMAP(X) \ + unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; + +#define __LOCALE_DATA_COMMON_MMIDX(X) \ + unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \ + uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \ + uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \ + + +typedef struct { +#ifdef __LOCALE_DATA_MAGIC_SIZE + unsigned char magic[__LOCALE_DATA_MAGIC_SIZE]; +#endif /* __LOCALE_DATA_MAGIC_SIZE */ + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + const unsigned char tbl8ctype[__LOCALE_DATA_Cctype_TBL_LEN]; + const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN]; +#ifdef __WCHAR_ENABLED + const uint16_t tbl8c2wc[__LOCALE_DATA_Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */ + const unsigned char tbl8wc2c[__LOCALE_DATA_Cwc2c_TBL_LEN]; + /* translit */ +#endif /* __WCHAR_ENABLED */ +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ +#ifdef __WCHAR_ENABLED + const unsigned char tblwctype[__LOCALE_DATA_WCctype_TBL_LEN]; + const unsigned char tblwuplow[__LOCALE_DATA_WCuplow_TBL_LEN]; + const int16_t tblwuplow_diff[__LOCALE_DATA_WCuplow_diff_TBL_LEN]; +/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */ + /* width?? */ +#endif /* __WCHAR_ENABLED */ + + __LOCALE_DATA_COMMON_MMAP(ctype); + __LOCALE_DATA_COMMON_MMAP(numeric); + __LOCALE_DATA_COMMON_MMAP(monetary); + __LOCALE_DATA_COMMON_MMAP(time); + /* collate is different */ + __LOCALE_DATA_COMMON_MMAP(messages); + + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + const __codeset_8_bit_t codeset_8_bit[__LOCALE_DATA_NUM_CODESETS]; +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + + __LOCALE_DATA_COMMON_MMIDX(ctype); + __LOCALE_DATA_COMMON_MMIDX(numeric); + __LOCALE_DATA_COMMON_MMIDX(monetary); + __LOCALE_DATA_COMMON_MMIDX(time); + /* collate is different */ + __LOCALE_DATA_COMMON_MMIDX(messages); + + const uint16_t collate_data[__lc_collate_data_LEN]; + + unsigned char lc_common_item_offsets_LEN[__LOCALE_DATA_CATEGORIES]; + size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4]; + /* offsets from start of locale_mmap_t */ + /* rows, item_offsets, item_idx, data */ + +#ifdef __LOCALE_DATA_NUM_LOCALES + unsigned char locales[__LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES]; + unsigned char locale_names5[5*__LOCALE_DATA_NUM_LOCALE_NAMES]; + unsigned char locale_at_modifiers[__LOCALE_DATA_AT_MODIFIERS_LENGTH]; +#endif /* __LOCALE_DATA_NUM_LOCALES */ + + unsigned char lc_names[__lc_names_LEN]; +#ifdef __CTYPE_HAS_8_BIT_LOCALES + unsigned char codeset_list[sizeof(__LOCALE_DATA_CODESET_LIST)]; /* TODO - fix */ +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ + + +} __locale_mmap_t; + +extern const __locale_mmap_t *__locale_mmap; diff --git a/extra/locale/tst_nl_langinfo.c b/extra/locale/tst_nl_langinfo.c new file mode 100644 index 0000000..373f934 --- /dev/null +++ b/extra/locale/tst_nl_langinfo.c @@ -0,0 +1,298 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include + +#if !defined(__UCLIBC__) && 0 +#define DO_EXTRA +#endif + +int main(int argc, char **argv) +{ + char *l; + const unsigned char *x; +/* const unsigned char *y; */ + const unsigned char *p; + + if (argc > 2) { + printf("invalid args\n"); + return EXIT_FAILURE; + } + if (argc == 1) { + l = ""; + } else { + l = *++argv; + } + + if (!(x = setlocale(LC_ALL,l))) { + printf("couldn't set locale %s\n", l); + return EXIT_FAILURE; + } + +/* printf("\nsetlocale returned:\n "); */ +/* do { */ +/* printf("\\x%02x", *x); */ +/* } while (*x++); */ +/* printf("\n"); */ + +#ifndef __BCC__ +#define STR(X) #X +#else +#define STR(X) __STR(X) +#endif +#define __PASTE2(A,B) A.B + +#define DO_NL_I(X) \ + printf( STR(X) " = %d\n", (int) nl_langinfo(X) ); +#define DO_NL_S(X) \ + printf( STR(X) " = \"%s\"\n", nl_langinfo(X) ); +#define DO_NL_C(X) \ + printf( STR(X) " = \"\\x%02x\"\n", *((unsigned char *) nl_langinfo(X)) ); + + printf("ctype\n"); + + DO_NL_S(CODESET); +#ifdef DO_EXTRA + DO_NL_I(_NL_CTYPE_INDIGITS_MB_LEN); + DO_NL_S(_NL_CTYPE_INDIGITS0_MB); + DO_NL_S(_NL_CTYPE_INDIGITS1_MB); + DO_NL_S(_NL_CTYPE_INDIGITS2_MB); + DO_NL_S(_NL_CTYPE_INDIGITS3_MB); + DO_NL_S(_NL_CTYPE_INDIGITS4_MB); + DO_NL_S(_NL_CTYPE_INDIGITS5_MB); + DO_NL_S(_NL_CTYPE_INDIGITS6_MB); + DO_NL_S(_NL_CTYPE_INDIGITS7_MB); + DO_NL_S(_NL_CTYPE_INDIGITS8_MB); + DO_NL_S(_NL_CTYPE_INDIGITS9_MB); +#endif + DO_NL_S(_NL_CTYPE_OUTDIGIT0_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT1_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT2_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT3_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT4_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT5_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT6_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT7_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT8_MB); + DO_NL_S(_NL_CTYPE_OUTDIGIT9_MB); + + + printf("numeric\n"); + + DO_NL_S(RADIXCHAR); /* DECIMAL_POINT */ + DO_NL_S(THOUSEP); /* THOUSANDS_SEP */ +/* DO_NL_S(GROUPING); */ + + printf("GROUPING = \""); + for (p = (unsigned char *) nl_langinfo(GROUPING) ; *p ; p++) { + printf("\\x%02x", *p); + } + printf("\"\n\n"); + + printf("monetary\n"); + + DO_NL_S(INT_CURR_SYMBOL); + DO_NL_S(CURRENCY_SYMBOL); + DO_NL_S(MON_DECIMAL_POINT); + DO_NL_S(MON_THOUSANDS_SEP); +/* DO_NL_S(MON_GROUPING); */ + + printf("MON_GROUPING = \""); + for (p = (unsigned char *) nl_langinfo(MON_GROUPING) ; *p ; p++) { + printf("\\x%02x", *p); + } + printf("\"\n\n"); + + DO_NL_S(POSITIVE_SIGN); + DO_NL_S(NEGATIVE_SIGN); + DO_NL_C(INT_FRAC_DIGITS); + DO_NL_C(FRAC_DIGITS); + DO_NL_C(P_CS_PRECEDES); + DO_NL_C(P_SEP_BY_SPACE); + DO_NL_C(N_CS_PRECEDES); + DO_NL_C(N_SEP_BY_SPACE); + DO_NL_C(P_SIGN_POSN); + DO_NL_C(N_SIGN_POSN); + DO_NL_C(INT_P_CS_PRECEDES); + DO_NL_C(INT_P_SEP_BY_SPACE); + DO_NL_C(INT_N_CS_PRECEDES); + DO_NL_C(INT_N_SEP_BY_SPACE); + DO_NL_C(INT_P_SIGN_POSN); + DO_NL_C(INT_N_SIGN_POSN); + + DO_NL_S(CRNCYSTR); /* CURRENCY_SYMBOL */ + + + printf("time\n"); + + DO_NL_S(ABDAY_1); + DO_NL_S(ABDAY_2); + DO_NL_S(ABDAY_3); + DO_NL_S(ABDAY_4); + DO_NL_S(ABDAY_5); + DO_NL_S(ABDAY_6); + DO_NL_S(ABDAY_7); + + DO_NL_S(DAY_1); + DO_NL_S(DAY_2); + DO_NL_S(DAY_3); + DO_NL_S(DAY_4); + DO_NL_S(DAY_5); + DO_NL_S(DAY_6); + DO_NL_S(DAY_7); + + DO_NL_S(ABMON_1); + DO_NL_S(ABMON_2); + DO_NL_S(ABMON_3); + DO_NL_S(ABMON_4); + DO_NL_S(ABMON_5); + DO_NL_S(ABMON_6); + DO_NL_S(ABMON_7); + DO_NL_S(ABMON_8); + DO_NL_S(ABMON_9); + DO_NL_S(ABMON_10); + DO_NL_S(ABMON_11); + DO_NL_S(ABMON_12); + + DO_NL_S(MON_1); + DO_NL_S(MON_2); + DO_NL_S(MON_3); + DO_NL_S(MON_4); + DO_NL_S(MON_5); + DO_NL_S(MON_6); + DO_NL_S(MON_7); + DO_NL_S(MON_8); + DO_NL_S(MON_9); + DO_NL_S(MON_10); + DO_NL_S(MON_11); + DO_NL_S(MON_12); + + DO_NL_S(AM_STR); + DO_NL_S(PM_STR); + + DO_NL_S(D_T_FMT); + DO_NL_S(D_FMT); + DO_NL_S(T_FMT); + DO_NL_S(T_FMT_AMPM); +/* DO_NL_S(ERA); */ + { + const char *p = nl_langinfo(ERA); + if (!p || !*p) { + printf("ERA = (none)\n"); + } else { + int i; + printf("ERA:\n"); + for (i=0 ; i < 100 ; i++) { + printf(" %3d: \"%s\"\n", i, p); + while (*p) ++p; + ++p; + if (!*p) break; + } + } + } + + DO_NL_S(ERA_YEAR); /* non SuSv3 */ + DO_NL_S(ERA_D_FMT); +/* DO_NL_S(ALT_DIGITS); */ + { + const char *p = nl_langinfo(ALT_DIGITS); + if (!p || !*p) { + printf("ALT_DIGITS = (none)\n"); + } else { + int i; + printf("ALT_DIGITS:\n"); + for (i=0 ; i < 100 ; i++) { + printf(" %3d: \"%s\"\n", i, p); + while (*p) ++p; + ++p; + } + } + } + DO_NL_S(ERA_D_T_FMT); + DO_NL_S(ERA_T_FMT); + +#ifdef DO_EXTRA + DO_NL_C(_NL_TIME_WEEK_NDAYS); + DO_NL_I(_NL_TIME_WEEK_1STDAY); /* grr... this won't work with 16bit ptrs */ + DO_NL_C(_NL_TIME_WEEK_1STWEEK); + DO_NL_C(_NL_TIME_FIRST_WEEKDAY); + DO_NL_C(_NL_TIME_FIRST_WORKDAY); + DO_NL_C(_NL_TIME_CAL_DIRECTION); + DO_NL_S(_NL_TIME_TIMEZONE); + DO_NL_S(_DATE_FMT); +#endif + + printf("messages\n"); + + DO_NL_S(YESEXPR); + DO_NL_S(NOEXPR); + DO_NL_S(YESSTR); + DO_NL_S(NOSTR); + +#ifdef DO_EXTRA + + printf("paper\n"); + + DO_NL_I(_NL_PAPER_HEIGHT); + DO_NL_I(_NL_PAPER_WIDTH); + + printf("name\n"); + + DO_NL_S(_NL_NAME_NAME_FMT); + DO_NL_S(_NL_NAME_NAME_GEN); + DO_NL_S(_NL_NAME_NAME_MR); + DO_NL_S(_NL_NAME_NAME_MRS); + DO_NL_S(_NL_NAME_NAME_MISS); + DO_NL_S(_NL_NAME_NAME_MS); + + printf("address\n"); + + DO_NL_S(_NL_ADDRESS_POSTAL_FMT); + DO_NL_S(_NL_ADDRESS_COUNTRY_NAME); + DO_NL_S(_NL_ADDRESS_COUNTRY_POST); + DO_NL_S(_NL_ADDRESS_COUNTRY_AB2); + DO_NL_S(_NL_ADDRESS_COUNTRY_AB3); + DO_NL_S(_NL_ADDRESS_COUNTRY_CAR); + DO_NL_I(_NL_ADDRESS_COUNTRY_NUM); + DO_NL_S(_NL_ADDRESS_COUNTRY_ISBN); + DO_NL_S(_NL_ADDRESS_LANG_NAME); + DO_NL_S(_NL_ADDRESS_LANG_AB); + DO_NL_S(_NL_ADDRESS_LANG_TERM); + DO_NL_S(_NL_ADDRESS_LANG_LIB); + + printf("telephone\n"); + + DO_NL_S(_NL_TELEPHONE_TEL_INT_FMT); + DO_NL_S(_NL_TELEPHONE_TEL_DOM_FMT); + DO_NL_S(_NL_TELEPHONE_INT_SELECT); + DO_NL_S(_NL_TELEPHONE_INT_PREFIX); + + printf("measurement\n"); + + DO_NL_C(_NL_MEASUREMENT_MEASUREMENT); /* 1 is metric, 2 is US */ + + printf("identification\n"); + + DO_NL_S(_NL_IDENTIFICATION_TITLE); + DO_NL_S(_NL_IDENTIFICATION_SOURCE); + DO_NL_S(_NL_IDENTIFICATION_ADDRESS); + DO_NL_S(_NL_IDENTIFICATION_CONTACT); + DO_NL_S(_NL_IDENTIFICATION_EMAIL); + DO_NL_S(_NL_IDENTIFICATION_TEL); + DO_NL_S(_NL_IDENTIFICATION_FAX); + DO_NL_S(_NL_IDENTIFICATION_LANGUAGE); + DO_NL_S(_NL_IDENTIFICATION_TERRITORY); + DO_NL_S(_NL_IDENTIFICATION_AUDIENCE); + DO_NL_S(_NL_IDENTIFICATION_APPLICATION); + DO_NL_S(_NL_IDENTIFICATION_ABBREVIATION); + DO_NL_S(_NL_IDENTIFICATION_REVISION); + DO_NL_S(_NL_IDENTIFICATION_DATE); + DO_NL_S(_NL_IDENTIFICATION_CATEGORY); + +#endif + + return EXIT_SUCCESS; +} diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000..6590b44 --- /dev/null +++ b/include/Makefile @@ -0,0 +1,5 @@ +top_srcdir=../ +top_builddir=../ +include $(top_srcdir)Rules.mak +include Makefile.in +include $(top_srcdir)Makefile.end diff --git a/include/Makefile.in b/include/Makefile.in new file mode 100644 index 0000000..0b55cf9 --- /dev/null +++ b/include/Makefile.in @@ -0,0 +1,7 @@ +DISTCLEAN_include: + $(do_rm) $(top_builddir)include/system_configuration.h + +headers-y = $(filter-out .svn bits CVS Makefile Makefile.in,$(notdir $(wildcard $(top_srcdir)include/*))) +install-include: | $(DESTDIR)$(UCLIBCXX_RUNTIME_INCLUDEDIR) + @$(call disp_install, include/) + $(Q)$(INSTALL) -m 0644 $(addprefix $(top_srcdir)include/, $(headers-y)) $(DESTDIR)$(UCLIBCXX_RUNTIME_INCLUDEDIR) diff --git a/include/algorithm b/include/algorithm new file mode 100644 index 0000000..af04f97 --- /dev/null +++ b/include/algorithm @@ -0,0 +1,1695 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + 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 +#include +#include +#include + +#ifndef __STD_HEADER_ALGORITHM +#define __STD_HEADER_ALGORITHM 1 + +//Elliminate any previously defined macro +#undef min +#undef max + +#pragma GCC visibility push(default) + +namespace std{ + + // subclause _lib.alg.nonmodifying_, non-modifying sequence operations: + template _UCXXEXPORT + Function for_each(InputIterator first, InputIterator last, Function f) + { + while(first !=last){ + f(*first); + ++first; + } + return f; + } + + + template _UCXXEXPORT + InputIterator find(InputIterator first, InputIterator last, const T& value) + { + while(first !=last && *first != value){ + ++first; + } + return first; + } + + template _UCXXEXPORT + InputIterator find_if(InputIterator first, InputIterator last, Predicate pred) + { + while(first !=last && !pred(*first)){ + ++first; + } + return first; + } + + template _UCXXEXPORT ForwardIterator1 + find_end(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) + { + ForwardIterator1 retval = last1; + while(first1 !=last1){ + ForwardIterator1 temp1(first1); + ForwardIterator2 temp2(first2); + while(temp2!=last2 && temp1!= last1){ + if(*temp1 != *temp2){ + break; //Exit while loop + } + ++temp1; + ++temp2; + if(temp2 == last2){ //Have successfully checked the whole sequence + retval = first1; + } + } + } + return retval; + } + + template _UCXXEXPORT + ForwardIterator1 + find_end(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred) + { + ForwardIterator1 retval = last1; + while(first1 !=last1){ + ForwardIterator1 temp1(first1); + ForwardIterator2 temp2(first2); + while(temp2!=last2 && temp1!= last1){ + if( ! pred(*temp1, *temp2)){ + break; //Exit while loop + } + ++temp1; + ++temp2; + if(temp2 == last2){ //Have successfully checked the whole sequence + retval = first1; + } + } + } + return retval; + } + + template _UCXXEXPORT + ForwardIterator1 + find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) + { + while(first1 != last1){ + ForwardIterator2 temp2(first2); + while(temp2 != last2 ){ + if(*temp2 == first1){ + return first1; + } + ++temp2; + } + + } + return last1; + } + + template _UCXXEXPORT + ForwardIterator1 + find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred) + { + while(first1 != last1){ + ForwardIterator2 temp2(first2); + while(temp2 != last2 ){ + if(*temp2 == first1){ + return first1; + } + ++temp2; + } + + } + return last1; + } + + template _UCXXEXPORT ForwardIterator + adjacent_find(ForwardIterator first, ForwardIterator last) + { + ForwardIterator temp; + while(first != last){ + temp = first; + ++temp; + if(*temp == *first){ + return first; + } + ++first; + } + return first; + } + + template _UCXXEXPORT + ForwardIterator + adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) + { + ForwardIterator temp; + while(first != last){ + temp = first; + ++temp; + if( pred(*temp, *first)){ + return first; + } + ++first; + } + return first; + } + + template _UCXXEXPORT + typename iterator_traits::difference_type + count(InputIterator first, InputIterator last, const T& value) + { + typename iterator_traits::difference_type i = 0; + while(first!=last){ + if(*first == value){ + ++i; + } + ++first; + } + return i; + } + + template _UCXXEXPORT + typename iterator_traits::difference_type + count_if(InputIterator first, InputIterator last, Predicate pred) + { + typename iterator_traits::difference_type i = 0; + while(first!=last){ + if( pred(*first) ){ + ++i; + } + ++first; + } + return i; + } + + template _UCXXEXPORT + pair + mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) + { + while(first1 != last1){ + if(*first1 != *first2){ + break; + } + ++first1; + ++first2; + } + + pair retval; + retval.first = first1; + retval.second = first2; + return retval; + } + + template _UCXXEXPORT + pair + mismatch(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, BinaryPredicate pred) + { + while(first1 != last1){ + if( !pred(*first1, *first2) ){ + break; + } + ++first1; + ++first2; + } + + pair retval; + retval.first = first1; + retval.second = first2; + return retval; + } + + template _UCXXEXPORT + bool + equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) + { + while(first1 !=last1){ + if(*first1 != *first2){ + return false; + } + ++first1; + ++first2; + } + return true; + } + + template _UCXXEXPORT + bool + equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, BinaryPredicate pred) + { + while(first1 !=last1){ + if( !pred(*first1, *first2) ){ + return false; + } + ++first1; + ++first2; + } + return true; + } + + template _UCXXEXPORT + ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) + { + equal_to::value_type> c; + return search(first1, last1, first2, last2, c); + } + + + template _UCXXEXPORT + ForwardIterator1 + search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred) + { + while(first1 != last1){ + ForwardIterator1 temp1(first1); + ForwardIterator2 temp2(first2); + while(temp2 != last2 && temp1 != last1){ + if( !pred(*temp2, *temp1) ){ + break; + } + ++temp1; + ++temp2; + if(temp2 == last2){ + return first1; + } + } + ++first1; + } + return last1; + } + + + template _UCXXEXPORT + ForwardIterator + search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value) + { + while( first != last ){ + if(*first == value){ + ForwardIterator temp(first); + Size i = 1; + ++first; //Avoid doing the same comparison over again + while(i < count && *temp == value){ + ++first; + ++i; + } + if(i == count){ + return first; + } + } + ++first; + } + return first; + } + + + template _UCXXEXPORT + ForwardIterator + search_n(ForwardIterator first, ForwardIterator last, + Size count, const T& value, BinaryPredicate pred) + { + while( first != last ){ + if( pred(*first, value) ){ + ForwardIterator temp(first); + Size i = 1; + ++first; //Avoid doing the same comparison over again + while(i < count && pred(*temp, value) ){ + ++first; + ++i; + } + if(i == count){ + return first; + } + } + ++first; + } + return first; + + } + + // subclause _lib.alg.modifying.operations_, modifying sequence operations: + + template _UCXXEXPORT + OutputIterator + copy(InputIterator first, InputIterator last, OutputIterator result) + { + while(first != last){ + *result = *first; + ++first; + ++result; + } + return result; + } + + template _UCXXEXPORT + BidirectionalIterator2 + copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, + BidirectionalIterator2 result) + { + while(first !=last ){ + --result; + --last; + *result = *last; + } + return result; + } + + template _UCXXEXPORT void swap(T& a, T& b){ + T temp(a); + a = b; + b = temp; + } + + template _UCXXEXPORT + ForwardIterator2 + swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) + { + while(first1 != last1){ + iter_swap(first1, first2); + ++first1; + ++first2; + } + return first2; + } + + + template _UCXXEXPORT + void + iter_swap(ForwardIterator1 a, ForwardIterator2 b) + { + typename iterator_traits::value_type temp(*a); + *a = *b; + *b = temp; + } + + + template _UCXXEXPORT + OutputIterator + transform(InputIterator first, InputIterator last, + OutputIterator result, UnaryOperation op) + { + while(first != last){ + *result = op(*first); + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + OutputIterator transform(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, OutputIterator result, + BinaryOperation binary_op) + { + while(first1 != last1){ + *result = binary_op(*first1, *first2); + ++first1; + ++first2; + ++result; + } + return result; + } + + + template _UCXXEXPORT + void + replace(ForwardIterator first, ForwardIterator last, + const T& old_value, const T& new_value) + { + while(first != last){ + if(*first == old_value){ + *first = new_value; + } + ++first; + } + } + + template _UCXXEXPORT + void + replace_if(ForwardIterator first, ForwardIterator last, + Predicate pred, const T& new_value) + { + while(first != last){ + if( pred(*first) ){ + *first = new_value; + } + ++first; + } + } + + + template _UCXXEXPORT + OutputIterator + replace_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& old_value, const T& new_value) + { + while(first != last){ + if(*first == old_value){ + *result = new_value; + }else{ + *result = *first; + } + ++first; + ++result; + } + return result; + } + + template _UCXXEXPORT + OutputIterator + replace_copy_if(Iterator first, Iterator last, + OutputIterator result, Predicate pred, const T& new_value) + { + while(first != last){ + if( pred(*first) ){ + *result = new_value; + }else{ + *result = *first; + } + ++first; + ++result; + } + return result; + } + + template _UCXXEXPORT + void + fill(ForwardIterator first, ForwardIterator last, const T& value) + { + while(first != last){ + *first = value; + ++first; + } + } + + template _UCXXEXPORT + void + fill_n(OutputIterator first, Size n, const T& value) + { + while(n != 0){ + *first = value; + --n; + ++first; + } + } + + template _UCXXEXPORT + void + generate(ForwardIterator first, ForwardIterator last, Generator gen) + { + while(first != last){ + *first = gen(); + ++first; + } + } + + template _UCXXEXPORT + void + generate_n(OutputIterator first, Size n, Generator gen) + { + while(n !=0){ + *first = gen(); + --n; + ++first; + } + } + + template _UCXXEXPORT + ForwardIterator + remove(ForwardIterator first, ForwardIterator last, const T& value) + { + ForwardIterator temp(first); + while(temp !=last){ + if(*temp == value){ + + }else{ + *first = *temp; + ++first; + } + ++temp; + } + return first; + } + + template _UCXXEXPORT + ForwardIterator + remove_if(ForwardIterator first, ForwardIterator last, Predicate pred) + { + ForwardIterator temp(first); + while(temp !=last){ + if( pred(*temp) ){ + + }else{ + *first = *temp; + ++first; + } + ++temp; + } + return first; + } + + + template _UCXXEXPORT + OutputIterator + remove_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& value) + { + while(first !=last){ + if(*first != value){ + *result = *first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + OutputIterator + remove_copy_if(InputIterator first, InputIterator last, + OutputIterator result, Predicate pred) + { + while(first !=last){ + if( !pred(*first) ){ + *result = *first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + ForwardIterator + unique(ForwardIterator first, ForwardIterator last) + { + ForwardIterator new_val(first); + ForwardIterator old_val(first); + + while(new_val !=last){ + if(*new_val == *old_val && new_val != old_val){ + + }else{ + *first = *new_val; + old_val = new_val; + ++first; + } + ++new_val; + } + return first; + } + + template _UCXXEXPORT + ForwardIterator + unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) + { + ForwardIterator new_val(first); + ForwardIterator old_val(first); + + while(new_val !=last){ + if( pred(*new_val, *old_val) && new_val != old_val){ + + }else{ + *first = *new_val; + old_val = new_val; + ++first; + } + ++new_val; + } + return first; + } + + template _UCXXEXPORT + OutputIterator + unique_copy(InputIterator first, InputIterator last, OutputIterator result) + { + InputIterator temp(first); + while(first !=last ){ + if(*first == *temp && first != temp){ + + }else{ + *result = *first; + temp = first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + OutputIterator + unique_copy(InputIterator first, InputIterator last, + OutputIterator result, BinaryPredicate pred) + { + InputIterator temp(first); + while(first !=last ){ + if( pred(*first, *temp) && first != temp){ + + }else{ + *result = *first; + temp = first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + void + reverse(BidirectionalIterator first, BidirectionalIterator last) + { + --last; //Don't work with one past the end element + while(first < last){ + iter_swap(first, last); + ++first; + --last; + } + } + + template _UCXXEXPORT + OutputIterator + reverse_copy(BidirectionalIterator first, BidirectionalIterator last, + OutputIterator result) + { + while(last > first){ + --last; + *result = *last; + ++result; + } + return result; + } + + template _UCXXEXPORT + void + rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) + { + if ((first == middle) || (last == middle)){ + return; + } + + ForwardIterator first2 = middle; + + do { + swap(*first, *first2); + first++; + first2++; + if(first == middle){ + middle = first2; + } + } while(first2 != last); + + first2 = middle; + + while (first2 != last) { + swap(*first, *first2); + first++; + first2++; + if (first == middle){ + middle = first2; + }else if (first2 == last){ + first2 = middle; + } + } + } + + template _UCXXEXPORT + OutputIterator + rotate_copy(ForwardIterator first, ForwardIterator middle, + ForwardIterator last, OutputIterator result) + { + ForwardIterator temp(middle); + while(temp !=last){ + *result = *temp; + ++temp; + ++result; + } + while(first != middle){ + *result = *first; + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + void + random_shuffle(RandomAccessIterator first, RandomAccessIterator last) + { + --last; + while(first != last){ + iter_swap(first, (first + (rand() % (last - first) ) ) ); + ++first; + } + } + + template _UCXXEXPORT + void + random_shuffle(RandomAccessIterator first, RandomAccessIterator last, + RandomNumberGenerator& rand) + { + --last; + while(first != last){ + iter_swap(first, (first + (rand(last - first) ) ) ); + ++first; + } + } + + // _lib.alg.partitions_, partitions: + template _UCXXEXPORT BidirectionalIterator + partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred) + { + return stable_partition(first, last, pred); + } + + template _UCXXEXPORT BidirectionalIterator + stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred) + { + //first now points to the first non-desired element + while( first != last && pred(*first) ){ + ++first; + } + + BidirectionalIterator tempb; + BidirectionalIterator tempe = first; + + while( tempe != last ){ + //Find the next desired element + while( !pred(*tempe) ){ + ++tempe; + + //See if we should exit + if(tempe == last){ + return first; + } + } + + //Rotate the element back to the begining + tempb = tempe; + while(tempb != first){ + iter_swap(tempb, tempb-1 ); + --tempb; + } + //First now has a desired element + ++first; + } + + return first; + } + + template _UCXXEXPORT + void sort(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + sort(first, last, c ); + } + + template _UCXXEXPORT + void stable_sort(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + stable_sort(first, last, c); + } + + template _UCXXEXPORT + void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + //FIXME - bubble sort + RandomAccessIterator temp; + --last; + while(last - first > 0){ + temp = last; + while(temp != first){ + if( comp( *temp, *(temp-1) ) ){ + iter_swap( temp-1, temp); + } + --temp; + } + ++first; + } + } + + template _UCXXEXPORT + void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + stable_sort(first, last, comp); + } + + template _UCXXEXPORT + void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last) + { + less::value_type> c; + partial_sort(first, middle, last, c); + } + template _UCXXEXPORT + void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, + RandomAccessIterator last, Compare comp) + { + //Fixme - partial bubble sort + RandomAccessIterator temp; + --last; + while(first < middle){ + temp = last; + while(temp != first){ + if( comp(*temp, *(temp -1 ) ) ) { + iter_swap( temp-1, temp); + } + --temp; + } + ++first; + } + } + template _UCXXEXPORT + RandomAccessIterator + partial_sort_copy(InputIterator first, InputIterator last, + RandomAccessIterator result_first, RandomAccessIterator result_last) + { + less::value_type> c; + return partial_sort_copy(first, last, result_first, result_last, c); + } + template _UCXXEXPORT + RandomAccessIterator + partial_sort_copy(InputIterator first, InputIterator last, + RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp) + { + size_t output_size = last-first; + size_t temp_size = result_last - result_first; + if(temp_size < output_size){ + output_size = temp_size; + } + + RandomAccessIterator middle = result_first + output_size; + RandomAccessIterator temp = result_first; + + while(temp != middle){ + *temp = *first; + ++temp; + ++first; + } + sort(result_first, middle, comp); + + while( first != last){ + if( comp( *first, *(middle-1) ) ){ + *(middle-1) = *first; + sort(result_first, middle, comp); + } + ++first; + } + + return middle; + } + template _UCXXEXPORT + void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last) + { + less::value_type> c; + nth_element(first, nth, last, c); + } + template _UCXXEXPORT + void nth_element(RandomAccessIterator first, RandomAccessIterator nth, + RandomAccessIterator last, Compare comp) + { + partial_sort(first, nth, last, comp); + } + + template _UCXXEXPORT + ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, + const T& value) + { + less::value_type> c; + return lower_bound(first, last, value, c); + } + + template _UCXXEXPORT + ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) + { + if(first == last){ + return last; + } + //If below or equal to the first element + if( comp(*first, value) == false){ + return first; + } + ForwardIterator middle; + + //If greater than the top element + middle = first; + advance(middle, distance(first, last) - 1); + if( comp(*middle, value) ){ + return last; + } + + //Now begin the actual search for the begining + while( distance(first, last) > 1 ){ + //Find middle + middle = first; + advance(middle, (distance(first, last)/2) ); + if( !comp(*middle, value) ){ + last = middle; + }else{ + first = middle; + } + } + + if( !comp(*first, value) ){ + return first; + } + return last; + } + + template _UCXXEXPORT + ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, + const T& value) + { + less::value_type> c; + return upper_bound(first, last, value, c); + } + + + template _UCXXEXPORT + ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) + { + if(first == last){ + return last; + } + //If below the first element + if( comp(value, *first) == true){ + return first; + } + + ForwardIterator middle; + + //If greater than the top element + middle = first; + advance(middle, distance(first, last) - 1); + if( comp(*middle, value) ){ + return last; + } + + //Now begin the actual search for the end + while( distance(first, last) > 1 ){ + //Find middle + middle = first; + advance(middle, (distance(first, last)/2) ); + if( comp(value, *middle) ){ + last = middle; + }else{ + first = middle; + } + } + + if( comp(value, *first) ){ + return first; + } + return last; + } + + + template _UCXXEXPORT + pair + equal_range(ForwardIterator first, ForwardIterator last, const T& value) + { + less::value_type> c; + return equal_range(first, last, value, c); + } + + template _UCXXEXPORT + pair + equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) + { + pair retval; + retval.first = lower_bound(first, last, value, comp); + //Reuse retval.first in order to (possibly) save a few comparisons + retval.second = upper_bound(retval.first, last, value, comp); + return retval; + + } + + template _UCXXEXPORT + bool binary_search(ForwardIterator first, ForwardIterator last, + const T& value) + { + less::value_type> c; + return binary_search(first, last, value, c); + } + + template _UCXXEXPORT + bool binary_search(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) + { + if( distance(first, last) == 0){ + return false; + } + + ForwardIterator middle; + + while( distance(first, last) > 1 ){ + //Set middle between first and last + middle = first; + advance(middle, distance(first, last)/2 ); + + if( comp(*middle, value ) == true){ + first = middle; + }else{ + last = middle; + } + } + + if( !comp(*first, value) && !comp(value, *first) ){ + return true; + } + if( !comp(*last, value) && !comp(value, *last) ){ + return true; + } + + return false; + } + + // _lib.alg.merge_, merge: + template _UCXXEXPORT + OutputIterator + merge(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return merge(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator + merge(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + //If in this order so first1 elements which are equal come first + if( comp(*first2, *first1) ){ + *result = *first2; + ++first2; + }else{ + *result = *first1; + ++first1; + } + ++result; + } + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++first1; + ++result; + } + while(first2 != last2){ + *result = *first2; + ++first2; + ++result; + } + return result; + } + template _UCXXEXPORT + void inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, BidirectionalIterator last) + { + less::value_type> c; + inplace_merge(first, middle, last, c); + } + template _UCXXEXPORT + void inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, BidirectionalIterator last, Compare comp) + { + //FIXME - using a bubble exchange method + while(first != middle && middle !=last){ + if( comp(*middle, *first) ){ + BidirectionalIterator temp(middle); + while( temp != first){ + iter_swap(temp, temp-1); + --temp; + } + ++middle; + } + ++first; + } + } + + // _lib.alg.set.operations_, set operations: + template _UCXXEXPORT + bool includes(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) + { + less::value_type> c; + return includes(first1, last1, first2, last2, c ); + } + + template _UCXXEXPORT + bool includes(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, Compare comp) + { + while(first2 != last2){ + //Advance the large set until no longer smaller than the element we are looking for + while( comp(*first1, *first2) ){ + ++first1; + //If we are at the end of the list, we don't have the desired element + if(first1 == last1){ + return false; + } + } + //If we are past the element we want, it isn't here + if( comp(*first2, *first1) ){ + return false; + } + ++first2; //Move to next element + } + return true; + } + + template _UCXXEXPORT + OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_union(first1, last1, first2, last2, result, c); + } + + template _UCXXEXPORT + OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first2, *first1) ){ + *result = *first2; + + //Elliminate duplicates + InputIterator2 temp = first2; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + }else{ + *result = *first1; + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + ++result; + } + + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + } + + while(first2 != last2){ + *result = *first2; + ++result; + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + return result; + } + + template _UCXXEXPORT + OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_intersection(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first2, *first1) ){ + ++first2; + }else if( comp(*first1, *first2) ) { + ++first1; + }else{ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + ++first2; + } + } + return result; + } + template _UCXXEXPORT + OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_difference(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first1, *first2) ){ + *result = *first1; + ++result; + + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + }else if( comp(*first2, *first1) ){ + + //Elliminate duplicates + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + + }else{ //They are identical - skip + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + } + + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + } + + return result; + } + template _UCXXEXPORT + OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_symmetric_difference(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first1, *first2) ){ + *result = *first1; + ++result; + + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + }else if( comp(*first2, *first1) ){ + *result = *first2; + ++result; + + //Elliminate duplicates + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + + }else{ //They are identical - skip + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + } + + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + } + + while(first2 != last2){ + *result = *first2; + ++result; + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + + return result; + } + + // _lib.alg.heap.operations_, heap operations: + + template _UCXXEXPORT + void push_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + push_heap(first, last, c); + } + + template _UCXXEXPORT + void push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + // *(last - 1) is the last element + RandomAccessIterator begin, middle, end; + begin = first; + end = last - 2; + if(last - first < 2){ //Empty heap + return; + } + if ( comp(*(last-1), *end) ){ //Belongs past the end - already in place + return; + } + while(end - begin > 1){ + middle = begin + ((end - begin)/2); + if( comp(*middle, *(last-1) ) ){ + end = middle; + }else{ + begin = middle; + } + } + + if( comp(*begin, *(last-1)) ){ + middle = begin; + }else{ + middle = end; + } + + //Now all we do is swap the elements up to the begining + --last; + + while(last > middle){ + iter_swap(last, last-1); + --last; + } + } + + template _UCXXEXPORT + void pop_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + pop_heap(first, last, c); + } + template _UCXXEXPORT + void pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare) + { + --last; + while(first < last){ + iter_swap( first, first+1); + ++first; + } + } + + template _UCXXEXPORT + void make_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + make_heap(first, last, c); + } + template _UCXXEXPORT + void make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + sort( reverse_iterator(last), reverse_iterator(first), comp); + } + template _UCXXEXPORT + void sort_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + sort_heap(first, last, c); + } + template _UCXXEXPORT + void sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + sort( first, last, comp); + } + + + // _lib.alg.min.max_, minimum and maximum: + template _UCXXEXPORT + const T& min(const T& a, const T& b) + { + if(b < a){ + return b; + } + return a; + } + + template _UCXXEXPORT + const T& min(const T& a, const T& b, Compare comp) + { + if( comp(b, a) == true){ + return b; + } + return a; + } + + template _UCXXEXPORT + const T& max(const T& a, const T& b) + { + if( a < b){ + return b; + } + return a; + } + + template _UCXXEXPORT + const T& max(const T& a, const T& b, Compare comp) + { + if( comp(a, b) ){ + return b; + } + return a; + } + + template _UCXXEXPORT + ForwardIterator min_element(ForwardIterator first, ForwardIterator last) + { + less::value_type> c; + return min_element(first, last, c); + } + + template _UCXXEXPORT + ForwardIterator min_element(ForwardIterator first, ForwardIterator last, Compare comp) + { + ForwardIterator retval = first; + ++first; + while(first != last){ + if( comp( *first, *retval) ){ + retval = first; + } + ++first; + } + return retval; + } + + template _UCXXEXPORT + ForwardIterator max_element(ForwardIterator first, ForwardIterator last) + { + less::value_type> c; + return max_element(first, last, c); + } + + template _UCXXEXPORT + ForwardIterator max_element(ForwardIterator first, ForwardIterator last, Compare comp) + { + ForwardIterator retval = first; + ++first; + while(first != last){ + if( comp( *retval, *first ) ){ + retval = first; + } + ++first; + } + return retval; + } + + template _UCXXEXPORT + bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) + { + less::value_type> c; + return lexicographical_compare(first1, last1, first2, last2, c); + } + + template _UCXXEXPORT + bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, Compare comp) + { + while(first1 != last1 && first2 != last2){ + if( comp(*first1, *first2) ){ + return true; + } + if( comp(*first2, *first1) ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + // _lib.alg.permutation.generators_, permutations + template _UCXXEXPORT + bool next_permutation(BidirectionalIterator first, BidirectionalIterator last) + { + less::value_type> c; + return next_permutation(first, last, c); + } + + template _UCXXEXPORT + bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp) + { + if(first == last){ + return false; // No data + } + BidirectionalIterator i = last; + --i; + if(i == first){ + return false; //Only one element + } + BidirectionalIterator ii = i; + --ii; + //If the last two items are in order, swap them and call it done + if( comp(*ii, *i) ){ + iter_swap(ii, i); + return true; + } + + + //This part of the algorithm copied from G++ header files ver. 3.4.2 + i = last; + --i; + for(;;){ + ii = i; + --i; + if ( comp(*i, *ii) ){ + BidirectionalIterator j = last; + --j; + while ( !comp(*i, *j)){ + --j; + } + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first){ + reverse(first, last); + return false; + } + } + + + } + + template _UCXXEXPORT + bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last) + { + less::value_type> c; + return prev_permutation(first, last, c); + } + + template _UCXXEXPORT + bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp) + { + if(first == last){ + return false; // No data + } + BidirectionalIterator i = last; + --i; + if(i == first){ + return false; //Only one element + } + BidirectionalIterator ii = i; + --ii; + //If the last two items are in reverse order, swap them and call it done + if( comp(*i, *ii) ){ + iter_swap(ii, i); + return true; + } + + //Copied from GNU GCC header files version 3.4.2 + i = last; + --i; + + for(;;){ + ii = i; + --i; + if ( comp(*ii, *i)){ + BidirectionalIterator j = last; + --j; + while ( !comp(*j, *i)){ + --j; + } + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first){ + reverse(first, last); + return false; + } + } + + } + +} + +#pragma GCC visibility pop + +#endif + + + diff --git a/include/array b/include/array new file mode 100644 index 0000000..7f6811f --- /dev/null +++ b/include/array @@ -0,0 +1,191 @@ +/* Copyright (C) 2025 Catty Steve + + This file is part of the uClibc++ Library. + 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 + + TODO: Currently untested +*/ +#include +#include +#include "basic_definitions" +#include + +namespace std { + template + struct array{ + // types + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // support for zero-sized arrays currently not implemented + T elements[N]={0,}; + + void fill(const value_type & value) { + std::fill(begin(), end(), value); + } + + void swap(array& other) { + std::swap_ranges(begin(), end(), other.begin()); + } + + UCLIBCXX_CONSTEXPR iterator begin() { + return iterator(data()); + } + + UCLIBCXX_CONSTEXPR const_iterator begin() const { + return const_iterator(data()); + } + + UCLIBCXX_CONSTEXPR iterator end() { + return iterator(data() + N); + } + + UCLIBCXX_CONSTEXPR const_iterator end() const { + return const_iterator(data() + N); + } + + UCLIBCXX_CONSTEXPR const_iterator cbegin() const { + return const_iterator(data()); + } + + UCLIBCXX_CONSTEXPR const_iterator cend() const { + return const_iterator(data() + N); + } + + UCLIBCXX_CONSTEXPR reverse_iterator rbegin() { + return reverse_iterator(end()); + } + + UCLIBCXX_CONSTEXPR const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + + UCLIBCXX_CONSTEXPR reverse_iterator rend() { + return reverse_iterator(begin()); + } + + UCLIBCXX_CONSTEXPR const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + UCLIBCXX_CONSTEXPR const_reverse_iterator crbegin() const { + return const_reverse_iterator(end()); + } + + UCLIBCXX_CONSTEXPR const_reverse_iterator crend() const { + return const_reverse_iterator(begin()); + } + + UCLIBCXX_CONSTEXPR size_type size() const { + return N; + } + + UCLIBCXX_CONSTEXPR size_type max_size() const { + return N; + } + + UCLIBCXX_CONSTEXPR bool empty() const { + return N == 0; + } + + UCLIBCXX_CONSTEXPR reference operator[](size_type i) { + return elements[i]; + } + + UCLIBCXX_CONSTEXPR const_reference operator[](size_type i) const { + return elements[i]; + } + + UCLIBCXX_CONSTEXPR reference at(size_type i) { + // if (i >= N) throw std::out_of_range("array::at"); + assert(i < N); // alternative without throwing exception + return elements[i]; + } + + UCLIBCXX_CONSTEXPR const_reference at(size_type i) const { + //if (i >= N) throw std::out_of_range("array::at"); + assert(i < N); // alternative without throwing exception + return elements[i]; + } + + UCLIBCXX_CONSTEXPR const_reference front() const { + return elements[(size_type)0]; + } + + UCLIBCXX_CONSTEXPR const_reference back() const { + return elements[N - 1]; + } + + reference front() { + return elements[(size_type)0]; + } + + reference back() { + return elements[N - 1]; + } + + pointer data() { + return static_cast(elements); + } + + const_pointer data() const { + return static_cast(elements); + } + }; + template + bool operator == (const array &lhs, const array &rhs) { + return std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } + + template + bool operator != (const array &lhs, const array &rhs) { + return !(lhs == rhs); + } + + template + bool operator < (const array &lhs, const array &rhs) { + return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + } + + template + bool operator > (const array &lhs, const array &rhs) { + return rhs < lhs; + } + + template + bool operator <= (const array &lhs, const array &rhs) { + return !(rhs < lhs); + } + + template + bool operator >= (const array &lhs, const array &rhs) { + return !(lhs < rhs); + } + + template + void swap(array &lhs, array &rhs) { + lhs.swap(rhs); + } + +} diff --git a/include/associative_base b/include/associative_base new file mode 100644 index 0000000..be8b27f --- /dev/null +++ b/include/associative_base @@ -0,0 +1,639 @@ +/* Copyright (C) 2007 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include + + +#ifndef __STD_HEADER_ASSOCIATIVE_BASE +#define __STD_HEADER_ASSOCIATIVE_BASE + +#pragma GCC visibility push(default) + +namespace std{ + + +/* + * The basic premise here is that most of the code used by map, multimap, set and + * multiset is really common. There are a number of interface additions, and + * considerations about how to address multiple entries with the same key. + * The goal is that the tree/storage code should be here, and managing + * single or multiple counts will be left to subclasses. + * Yes, inheritence for the purpose of code sharing is usually a bad idea. + * However, since our goal is to reduce the total amount of code written + * and the overall binary size, this seems to be the best approach possible. + */ + +template, class Allocator = allocator > class __base_associative; +template class _associative_iter; +template class _associative_citer; + +template, class Allocator = allocator > class __single_associative; +template, class Allocator = allocator > class __multi_associative; + +template class _UCXXEXPORT __base_associative{ + +protected: + +public: + typedef Key key_type; + typedef ValueType value_type; + typedef Compare key_compare; + typedef Allocator allocator_type; + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef __base_associative associative_type; + + typedef _associative_iter iterator; + typedef _associative_citer const_iterator; + typedef typename std::reverse_iterator reverse_iterator; + typedef typename std::reverse_iterator const_reverse_iterator; + + + explicit __base_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) + : c(comp), value_to_key(v_to_k) { } +protected: + __base_associative(const associative_type& x) + : c(x.c), backing(x.backing), value_to_key(x.value_to_key) { } + +public: + ~__base_associative(){ + } + + bool empty() const{ + return backing.empty(); + } + size_type size() const{ + return backing.size(); + } + size_type max_size() const{ + return backing.max_size(); + } + + iterator begin(){ + return iterator(backing.begin()); + } + + const_iterator begin() const{ + return const_iterator(backing.begin()); + } + + iterator end() { + return iterator(backing.end()); + } + + const_iterator end() const{ + return const_iterator(backing.end()); + } + + reverse_iterator rbegin(){ + return reverse_iterator(end()); + } + + const_reverse_iterator rbegin() const{ + return const_reverse_iterator(end()); + } + + reverse_iterator rend(){ + return reverse_iterator(begin()); + } + + const_reverse_iterator rend() const{ + return const_reverse_iterator(begin()); + } + + + iterator lower_bound(const key_type &x); + const_iterator lower_bound(const key_type &x) const; + iterator upper_bound(const key_type &x); + const_iterator upper_bound(const key_type &x) const; + + pair equal_range(const key_type& x){ + pair retval; + retval.first = lower_bound(x); + retval.second = retval.first; + while(retval.second != end() && !c(x, value_to_key(*retval.second))){ + ++retval.second; + } + return retval; + } + pair equal_range(const key_type& x) const{ + pair retval; + retval.first = lower_bound(x); + retval.second = retval.first; + while(retval.second != end() && !c(x, value_to_key(*retval.second))){ + ++retval.second; + } + return retval; + } + + iterator find(const key_type& x){ + iterator retval = lower_bound(x); + if(retval == end()){ + return retval; + } + if(c(x, value_to_key(*retval))){ + return end(); + } + return retval; + } + const_iterator find(const key_type& x) const{ + const_iterator retval = lower_bound(x); + if(retval == end()){ + return retval; + } + if(c(x, value_to_key(*retval))){ + return end(); + } + return retval; + } + size_type count(const key_type& x) const{ + size_type retval(0); + const_iterator first = lower_bound(x); + while(first != end() && !c(x, value_to_key(*first))){ + ++retval; + ++first; + } + return retval; + } + + void clear(){ + backing.clear(); + } + + void erase(iterator pos){ + backing.erase(pos.base_iterator()); + } + size_type erase(const key_type& x){ + size_type count(0); + iterator start = lower_bound(x); + iterator end = upper_bound(x); + while(start != end){ + start = backing.erase(start.base_iterator()); + ++count; + } + return count; + } + void erase(iterator first, iterator last){ + while(first != last){ + first = backing.erase(first.base_iterator()); + } + } + + key_compare key_comp() const{ + return c; + } + + __base_associative &operator=(const __base_associative & x){ + c = x.c; + backing = x.backing; + value_to_key = x.value_to_key; + return *this; + } + bool operator==(const __base_associative & x){ + return x.backing == backing; + } + bool operator!=(const __base_associative & x){ + return !(x.backing == backing); + } + +protected: + void swap(__base_associative & x); + + Compare c; + std::list backing; + + const key_type (*value_to_key)(const value_type); + +}; + + +/* + * Tree iterators for the base associative class + */ + +template class _associative_citer + : public std::iterator< + bidirectional_iterator_tag, + ValueType, + typename Allocator::difference_type, + ValueType*, + ValueType& + > +{ +protected: + typedef std::list listtype; + + typename listtype::const_iterator base_iter; + friend class _associative_iter; +public: + _associative_citer() { } + _associative_citer(const _associative_citer & m) + : base_iter(m.base_iter) { } + _associative_citer(const typename listtype::const_iterator & m) + : base_iter(m) { } + ~_associative_citer() { } + ValueType operator*() const{ + return *base_iter; + } + const ValueType * operator->() const{ + return &(*base_iter); + } + _associative_citer & operator=(const _associative_citer & m){ + base_iter = m.base_iter; + return *this; + } + bool operator==(const _associative_citer & m) const{ + return m.base_iter == base_iter; + } + bool operator!=(const _associative_citer & m) const{ + return m.base_iter != base_iter; + } + _associative_citer & operator++(){ + ++base_iter; + return *this; + } + _associative_citer operator++(int){ + //The following approach ensures that we only need to + //provide code for ++ in one place (above) + _associative_citer temp(base_iter); + ++base_iter; + return temp; + } + _associative_citer & operator--(){ + --base_iter; + return *this; + } + _associative_citer operator--(int){ + //The following approach ensures that we only need to + //provide code for -- in one place (above) + _associative_citer temp(base_iter); + --base_iter; + return temp; + } + + //This is an implementation-defined function designed to make internals work correctly + typename listtype::const_iterator base_iterator(){ + return base_iter; + } +}; + + +template class _associative_iter + : public std::iterator< + bidirectional_iterator_tag, + ValueType, + typename Allocator::difference_type, + ValueType*, + ValueType& + > +{ +protected: + typedef std::list listtype; + + typename listtype::iterator base_iter; + typedef _associative_citer __associative_citer; + +public: + _associative_iter() { } + _associative_iter(const _associative_iter & m) + : base_iter(m.base_iter) { } + _associative_iter(const typename listtype::iterator & m) + : base_iter(m) { } + ~_associative_iter() { } + const ValueType & operator*() const{ + return *base_iter; + } + ValueType & operator*(){ + return *base_iter; + } + ValueType * operator->(){ + return &(*base_iter); + } + const ValueType * operator->() const{ + return &(*base_iter); + } + _associative_iter & operator=(const _associative_iter & m){ + base_iter = m.base_iter; + return *this; + } + bool operator==(const _associative_iter & m) const{ + return m.base_iter == base_iter; + } + bool operator==(const __associative_citer & m) const{ + return m.base_iter == base_iter; + } + bool operator!=(const _associative_iter & m) const{ + return m.base_iter != base_iter; + } + bool operator!=(const __associative_citer & m) const{ + return m.base_iter != base_iter; + } + _associative_iter & operator++(){ + ++base_iter; + return *this; + } + _associative_iter operator++(int){ + //The following approach ensures that we only need to + //provide code for ++ in one place (above) + _associative_iter temp(base_iter); + ++base_iter; + return temp; + } + _associative_iter & operator--(){ + --base_iter; + return *this; + } + _associative_iter operator--(int){ + //The following approach ensures that we only need to + //provide code for -- in one place (above) + _associative_iter temp(base_iter); + --base_iter; + return temp; + } + operator __associative_citer() const{ + return __associative_citer(base_iter); + } + typename listtype::iterator base_iterator(){ + return base_iter; + } + const typename listtype::iterator base_iterator() const{ + return base_iter; + } + +}; + + + // The lower_bound code is really crappy linear search. However, it is a dead + // simple implementation (easy to audit). It can also be easily replaced. + + + template + typename __base_associative::iterator + __base_associative::lower_bound(const key_type &x) + { + iterator retval = begin(); + while(retval != end() && c(value_to_key(*retval), x)){ + ++retval; + } + return retval; + } + + template + typename __base_associative::const_iterator + __base_associative::lower_bound(const key_type &x) const + { + const_iterator retval = begin(); + while(retval != end() && c(value_to_key(*retval), x)){ + ++retval; + } + return retval; + } + + // Upper bound search is linear from the point of lower_bound. This is likely the best solution + // in all but the most pathological of cases. + + template + typename __base_associative::iterator + __base_associative::upper_bound(const key_type &x) + { + iterator retval = lower_bound(x); + while(retval != end() && !c(x, value_to_key(*retval))){ + ++retval; + } + return retval; + } + + template + typename __base_associative::const_iterator + __base_associative::upper_bound(const key_type &x) const + { + const_iterator retval = begin(); + while(retval != end() && !c(x, value_to_key(*retval))){ + ++retval; + } + return retval; + } + + + template + void __base_associative::swap(__base_associative& m) + { + Compare n = c; + c = m.c; + m.c = n; + + m.backing.swap(backing); + } + + +template class _UCXXEXPORT __single_associative : + public __base_associative +{ +protected: + typedef __base_associative base; + using base::backing; + + using base::c; + +public: + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + using base::operator=; + using base::operator==; + using base::operator!=; + + explicit __single_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) + : base(comp, A, v_to_k) { } + + template __single_associative( + InputIterator first, + InputIterator last, + const Compare& comp, + const Allocator& A, + const key_type (*v_to_k)(const value_type) + ) : base(comp, A, v_to_k) { + insert(first, last); + } + + pair insert(const value_type& x){ + pair retval; + iterator location = lower_bound(this->value_to_key(x)); + retval.second = true; + //Empty list or need to insert at end + if(end() == location){ + backing.push_back(x); + retval.first = --(end()); + return retval; + } + //Something in the list + if(c(this->value_to_key(x), this->value_to_key(*location))){ + location = backing.insert(location.base_iterator(), x); + retval.first = location; + }else{ + retval.second = false; + retval.first = location; + } + return retval; + } + + iterator insert(iterator position, const value_type& x){ + // FIXME - this is cheating and probably should be more efficient since we are + // now log(n) to find for inserts + return insert(x).first; + } + + template void insert(InputIterator first, InputIterator last){ + while(first != last){ + insert(*first); + ++first; + } + } + +}; + + +template class _UCXXEXPORT __multi_associative : + public __base_associative +{ +protected: + typedef __base_associative base; + using base::backing; + + using base::c; + +public: + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + using base::operator=; + using base::operator==; + + + explicit __multi_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) + : base(comp, A, v_to_k) { } + + template __multi_associative( + InputIterator first, + InputIterator last, + const Compare& comp, + const Allocator& A, + const key_type (*v_to_k)(const value_type) + ) : base(comp, A, v_to_k) { + insert(first, last); + } + + iterator insert(const value_type& x){ + iterator location = lower_bound(this->value_to_key(x)); + + if(location == begin()){ + backing.push_front(x); + location = begin(); + }else{ + location = backing.insert(location.base_iterator(), x); + } + return location; + } + + iterator insert(iterator position, const value_type& x){ + // FIXME - this is cheating and probably should be more efficient since we are + // now log(n) to find for inserts + return insert(x); + } + + template void insert(InputIterator first, InputIterator last){ + while(first != last){ + insert(*first); + ++first; + } + } +}; + + + + +} + +#pragma GCC visibility pop + +#endif //__STD_HEADER_ASSOCIATIVE_BASE + diff --git a/include/basic_definitions b/include/basic_definitions new file mode 100644 index 0000000..25ef232 --- /dev/null +++ b/include/basic_definitions @@ -0,0 +1,89 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + 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 +*/ + +#ifndef __BASIC_DEFINITIONS +#define __BASIC_DEFINITIONS 1 + +#include + +#pragma GCC visibility push(default) + +//The following is used to support GCC symbol visibility patch + +#ifdef GCC_HASCLASSVISIBILITY + #define _UCXXEXPORT __attribute__ ((visibility("default"))) + #define _UCXXLOCAL __attribute__ ((visibility("hidden"))) +#else + #define _UCXXEXPORT + #define _UCXXLOCAL + +#endif + +#ifdef __GCC__ +#define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) +#else +#define __UCLIBCXX_NORETURN +#endif + +#ifdef __GCC__ +# ifndef _UCXX_NOTHROW +# ifndef __cplusplus +# define _UCXX_NOTHROW __attribute__((__nothrow__)) +# endif +# endif +#endif +#ifdef __cplusplus +# if __cplusplus >= 201103L +# define _UCXX_NOEXCEPT noexcept +# define _UCXX_USE_NOEXCEPT noexcept +# define _UCXX_THROW(_EXCEPTION) +# else +# define _UCXX_NOEXCEPT +# define _UCXX_USE_NOEXCEPT throw() +# define _UCXX_THROW(_EXCEPTION) throw(_EXCEPTION) +# endif +# ifndef _UCXX_NOTHROW +# define _UCXX_NOTHROW _UCXX_USE_NOEXCEPT +# endif +#endif + +#ifdef __UCLIBCXX_HAS_TLS__ + #define __UCLIBCXX_TLS __thread +#else + #define __UCLIBCXX_TLS +#endif + + + +//Testing purposes +#define __STRING_MAX_UNITS 65535 + +namespace std{ + typedef signed long int streamsize; +} + +#pragma GCC visibility pop + +# ifdef __DODEBUG__ + #define UCLIBCXX_DEBUG 1 +# else + #define UCLIBCXX_DEBUG 0 +# endif + +// Catty Steve modify begin +# define UCLIBCXX_CONSTEXPR constexpr +#endif diff --git a/include/bitset b/include/bitset new file mode 100644 index 0000000..50d5404 --- /dev/null +++ b/include/bitset @@ -0,0 +1,423 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include +#include + +#ifndef __STD_BITSET_HEADER +#define __STD_BITSET_HEADER 1 + +#pragma GCC visibility push(default) + +namespace std{ + template class bitset; + + + template bitset operator&(const bitset&, const bitset&); + template bitset operator|(const bitset&, const bitset&); + template bitset operator^(const bitset&, const bitset&); + template basic_istream& + operator>>(basic_istream& is, bitset& x); + + template basic_ostream& + operator<<(basic_ostream& os, const bitset& x); + + //Actual Code + + + template class _UCXXEXPORT bitset { + private: + //Number of characters allocated to hold the bits + static const size_t WORD_SIZE = CHAR_BIT; //Use int maybe? + static const size_t num_bytes = (N + WORD_SIZE - 1) / WORD_SIZE; + + //From the bit number, figure out which byte we are working with + size_t byte_num(size_t bit_num) const{ + if(WORD_SIZE == 8){ + return (bit_num >> 3); + } + if(WORD_SIZE == 16){ + return (bit_num >> 4); + } + if(WORD_SIZE == 32){ + return (bit_num >> 5); + } + if(WORD_SIZE == 64){ + return (bit_num >> 6); + } + return bit_num / WORD_SIZE; + } + //From the bit number, figure out which bit inside the byte we need + size_t bit_num(const size_t bit_num) const{ + return bit_num % WORD_SIZE; + } + + + //Point to the actual data + char data[num_bytes]; + public: + + class _UCXXEXPORT reference { + friend class bitset; + reference() : bit_num(0), parent(0) { } + size_t bit_num; + bitset * parent; + public: + ~reference() { } + reference& operator=(bool x){ // for b[i] = x; + parent->set(bit_num, x); + return *this; + } + reference& operator=(const reference& x){ // for b[i] = b[j]; + parent->set(bit_num, x); + return *this; + } + bool operator~() const{ // flips the bit + return !parent->test(bit_num); + } + operator bool() const{ // for x = b[i]; + return parent->test(bit_num); + } + reference& flip(){ // for b[i].flip(); + parent->flip(bit_num); + return *this; + } + }; + + bitset(){ + reset(); + } + bitset(unsigned long val){ + reset(); + size_t count = sizeof(val) * CHAR_BIT; + if(count > N){ + count = N; + } + for(size_t i = 0; i < count; ++i){ + set(i, ((val >> i) & 1)); + } + } + + bitset(const bitset & val){ + for(size_t i = 0; i < num_bytes; ++i){ + data[i] = val.data[i]; + } + } + + template _UCXXEXPORT + explicit bitset( + const basic_string& str, + typename basic_string::size_type pos = 0, + typename basic_string::size_type n = + basic_string::npos + + ){ + reset(); + if(n > str.length()){ + n = str.length(); + } + size_t width = n; + if (width + pos > str.length()){ + width = str.length() - pos; + } + + for(size_t i = 0; i < width; ++i){ + switch(str[pos + width - i - 1]){ + case '0': + break; + case '1': + set(i); + break; + default: + __throw_invalid_argument(); + } + } + } + + bitset& operator&=(const bitset& rhs){ + for(size_t i =0; i < num_bytes; ++i){ + data[i] &= rhs.data[i]; + } + return *this; + } + + bitset& operator|=(const bitset& rhs){ + for(size_t i =0; i < num_bytes; ++i){ + data[i] |= rhs.data[i]; + } + return *this; + } + bitset& operator^=(const bitset& rhs){ + for(size_t i=0; i < num_bytes; ++i){ + data[i] ^= rhs.data[i]; + } + return *this; + } + + bitset& operator<<=(size_t pos){ + for(size_t i = N-1; i >=pos; --i){ + set(i, test(i - pos)); + } + for(size_t i = 0; i < pos; ++i){ + reset(i); + } + return *this; + } + + bitset& operator>>=(size_t pos){ + for(size_t i = 0; i < (N - pos); ++i){ + set(i, test(i + pos)); + } + for(size_t i = pos; i > 0; --i){ + reset(N - i); + } + return *this; + } + + bitset& set(){ + size_t i; + for(i = 0; i < N ; ++i){ + data[byte_num(i)] |= (1<& set(size_t pos, int val = true){ + if(val == true){ + data[byte_num(pos)] |= (1<& reset(){ + for(size_t i = 0; i < num_bytes; ++i){ + data[i] = 0; + } + return *this; + } + bitset& reset(size_t pos){ + data[byte_num(pos)] &= ~(1< operator~() const{ + bitset retval(*this); + retval.flip(); + return retval; + } + + bitset& flip(){ + for(size_t i = 0; i < num_bytes; ++i){ + data[i] = ~data[i]; + } + return *this; + } + bitset& flip(size_t pos){ + char temp = data[byte_num(pos)] & (1 << bit_num(pos)); + if(temp == 0){ //Bit was 0 + data[byte_num(pos)] |= (1 << bit_num(pos)); + }else{ //Bit was 1 + data[byte_num(pos)] &= ~(1< sizeof(unsigned long) * CHAR_BIT){ + __throw_overflow_error(); + } + unsigned long retval = 0; + size_t count = N; + for(size_t i = count; i > 0; --i){ + if(test(i)){ + retval +=1; + } + retval<<=1; + } + if(test(0)){ + retval +=1; + } + return retval; + } + + template + basic_string to_string() const + { + basic_string retval; + retval.reserve(N); + for(size_t i = N ; i > 0; --i){ + if(test(i-1) == true){ + retval.append("1"); + }else{ + retval.append("0"); + } + } + return retval; + } + + + size_t count() const{ + size_t retval = 0; + for(size_t i =0; i < N; ++i){ + if(test(i)){ + ++retval; + } + } + return retval; + } + size_t size() const{ + return N; + } + + bitset& operator=(const bitset & rhs){ + if(&rhs == this){ + return *this; + } + for(size_t i = 0; i <= byte_num(N); ++i){ + data[i] = rhs.data[i]; + } + return *this; + } + + + bool operator==(const bitset& rhs) const{ + for(size_t i =0; i< N; ++i){ + if(test(i) != rhs.test(i)){ + return false; + } + } + return true; + } + + bool operator!=(const bitset& rhs) const{ + for(size_t i =0; i< N; ++i){ + if(test(i) != rhs.test(i)){ + return true; + } + } + return false; + } + + bool test(size_t pos) const{ + return (data[byte_num(pos)] & (1< operator<<(size_t pos) const{ + bitset retval(*this); + retval<<=pos; + return retval; + } + bitset operator>>(size_t pos) const{ + bitset retval(*this); + retval>>=pos; + return retval; + } + }; + + //Non-member functions + + + template _UCXXEXPORT bitset operator&(const bitset& lhs, const bitset& rhs){ + bitset retval(lhs); + retval &= rhs; + return retval; + } + + template _UCXXEXPORT bitset operator|(const bitset& lhs, const bitset& rhs){ + bitset retval(lhs); + retval |= rhs; + return retval; + } + + template _UCXXEXPORT bitset operator^(const bitset& lhs, const bitset& rhs){ + bitset retval(lhs); + retval ^= rhs; + return retval; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, bitset& x) + { + string s; + charT c; + for(size_t i = 0; i < N; ++i){ + is.get(c); + if(!is.good()){ + break; + } + if(c != '1' && c !='0'){ + is.putback(c); + break; + } + s+=c; + } + bitset temp(s); + x = temp; + + return is; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const bitset& x) + { + for(size_t i = N ; i > 0; --i){ + if(x.test(i-1) == true){ + os << "1"; + }else{ + os << "0"; + } + } + return os; + } + + + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/cassert b/include/cassert new file mode 100644 index 0000000..dc590dd --- /dev/null +++ b/include/cassert @@ -0,0 +1,19 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 diff --git a/include/cctype b/include/cctype new file mode 100644 index 0000000..ef12b1f --- /dev/null +++ b/include/cctype @@ -0,0 +1,37 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 + +namespace std{ + + using ::isalnum; + using ::isalpha; + using ::iscntrl; + using ::isdigit; + using ::isgraph; + using ::islower; + using ::isprint; + using ::ispunct; + using ::isspace; + using ::isupper; + using ::isxdigit; + using ::tolower; + using ::toupper; + +} diff --git a/include/cerrno b/include/cerrno new file mode 100644 index 0000000..b779c5c --- /dev/null +++ b/include/cerrno @@ -0,0 +1,19 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 diff --git a/include/cfloat b/include/cfloat new file mode 100644 index 0000000..d2ab703 --- /dev/null +++ b/include/cfloat @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef __STD_HEADER_CFLOAT +#define __STD_HEADER_CFLOAT 1 + + +#include + + +#endif + diff --git a/include/char_traits b/include/char_traits new file mode 100644 index 0000000..36eae36 --- /dev/null +++ b/include/char_traits @@ -0,0 +1,198 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 +#include +#include +#include + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif + +#ifndef __HEADER_CHAR_TRAITS +#define __HEADER_CHAR_TRAITS 1 + +namespace std{ + /* Inlining all wrapped function calls to shrink the amount of code generated*/ + //Typedefs to use for stuff + typedef signed int char_traits_off_type; + + //Generic char_traits + template struct _UCXXEXPORT char_traits { }; + + //Specialize for char + template<> struct _UCXXEXPORT char_traits { + typedef char char_type; + typedef short int int_type; + typedef char_traits_off_type off_type; + typedef char_traits_off_type pos_type; + typedef char state_type; + + inline static void assign(char_type & c, const char_type & d) { c = d; } + + static bool eq(const char_type& c1, const char_type& c2); + + static char_type to_char_type(const int_type & i); + + inline static int_type to_int_type(const char_type & c){ + return (short int)(unsigned char)c; + } + + inline static bool eq_int_type(const int_type & a, const int_type & b){ + if(a==b){ + return true; + } + return false; + } + + + inline static bool lt(const char_type& c1, const char_type& c2){ + if(strncmp(&c1, &c2, 1) < 0){ + return true; + } + return false; + } + + inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ + return (char*) memmove(s1, s2, n); + } + + inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ + for(unsigned long int i=0; i< n; ++i){ + assign(s1[i], s2[i]); + } + return s1 + n; + } + + inline static char_type* assign(char_type* s, size_t n, char_type a){ + return (char *)memset(s, a, n); + } + + inline static int compare(const char_type* s1, const char_type* s2, size_t n){ + return strncmp(s1, s2, n); + } + + inline static size_t length(const char_type* s){ + return strlen(s); + } + + static const char_type* find(const char_type* s, int n, const char_type& a); + + inline static char_type eos() { return 0; } + inline static int_type eof() { return -1; } + inline static int_type not_eof(const int_type & i) { + if(i == -1){ + return 0; + } else { + return i; + } + } + static state_type get_state(pos_type p){ + p = p; + state_type a; + return a; + } + }; + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template<> struct _UCXXEXPORT char_traits { + typedef wchar_t char_type; + typedef wint_t int_type; + typedef char_traits_off_type off_type; + typedef char_traits_off_type pos_type; + typedef mbstate_t state_type; + + static void assign(char_type & c, const char_type & d){ c=d; } + + static char_type to_char_type(const int_type & i){ + return i; + } + + static int_type to_int_type(const char_type & c){ + return c; + } + + inline static bool eq_int_type(const int_type & a, const int_type & b){ + if(a==b){ + return true; + } + return false; + } + + inline static bool eq(const char_type& c1, const char_type& c2){ + if(wcsncmp(&c1, &c2, 1) == 0){ + return true; + } + return false; + } + + inline static bool lt(const char_type& c1, const char_type& c2){ + if(wcsncmp(&c1, &c2, 1) < 0){ + return true; + } + return false; + } + + inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ + return (char_type*) memmove(s1, s2, n * sizeof(char_type)); + } + + inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ + for(unsigned long int i=0; i< n; ++i){ + assign(s1[i], s2[i]); + } + return s1 + n; + } + + inline static char_type* assign(char_type* s, size_t n, char_type a){ + return (char_type *)memset(s, a, n); /*FIXME*/ + } + + inline static int compare(const char_type* s1, const char_type* s2, size_t n){ + return wcsncmp(s1, s2, n); + } + + inline static size_t length(const char_type* s){ + return wcslen(s); + } + + static const char_type* find(const char_type* s, int n, const char_type& a); + + inline static char_type eos() { return 0; } + inline static int_type eof() { return WEOF; } + inline static int_type not_eof(const int_type & i) { + if(i == WEOF){ + return (int_type)0; + } else { + return i; + } + } + static state_type get_state(pos_type){ + state_type a; + return a; + } + }; +#endif + +} + +#endif + diff --git a/include/cinttypes b/include/cinttypes new file mode 100644 index 0000000..5a2d8df --- /dev/null +++ b/include/cinttypes @@ -0,0 +1,42 @@ +/* Copyright (C) 2025 Catty Steve + + This file is part of the uClibc++ Library. + 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 + + TODO: Currently untested +*/ +#include +#include + +namespace std{ + // types + using ::imaxdiv_t; + + // functions + using ::imaxabs; + using ::imaxdiv; + + // GCC does not support extended integer types + // intmax_t abs(intmax_t) + // imaxdiv_t div(intmax_t, intmax_t) + + using ::strtoimax; + using ::strtoumax; + + + // Untested + using ::wcstoimax; + using ::wcstoumax; +} diff --git a/include/climits b/include/climits new file mode 100644 index 0000000..7d39780 --- /dev/null +++ b/include/climits @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#ifndef __STD_HEADER_CLIMITS +#define __STD_HEADER_CLIMITS 1 + + +#include + + +#endif + diff --git a/include/clocale b/include/clocale new file mode 100644 index 0000000..4f3cd69 --- /dev/null +++ b/include/clocale @@ -0,0 +1,30 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 +*/ + +#ifndef __STD_HEADER_CLOCALE +#define __STD_HEADER_CLOCALE 1 + +#include + +namespace std { + using ::lconv; + using ::setlocale; + using ::localeconv; +} + +#endif // __STD_HEADER_CLOCALE diff --git a/include/cmath b/include/cmath new file mode 100644 index 0000000..5409e64 --- /dev/null +++ b/include/cmath @@ -0,0 +1,234 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef __STD_HEADER_CMATH +#define __STD_HEADER_CMATH 1 + +#undef abs +#undef acos +#undef asin +#undef atan +#undef atan2 +#undef ceil +#undef cos +#undef cosh +#undef exp +#undef fabs +#undef floor +#undef fmod +#undef frexp +#undef ldexp +#undef log +#undef log10 +#undef modf +#undef pow +#undef sin +#undef sinh +#undef sqrt +#undef tan +#undef tanh + +namespace std { + + using ::acos; + using ::asin; + using ::atan; + using ::atan2; + using ::ceil; + using ::cos; + using ::cosh; + using ::exp; + using ::fabs; + using ::floor; + using ::fmod; + using ::frexp; + using ::ldexp; + using ::log; + using ::log10; + using ::modf; + using ::pow; + using ::sin; + using ::sinh; + using ::sqrt; + using ::tan; + using ::tanh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline float abs (float x){ + return fabsf(x); + } + inline float acos (float x){ + return acosf(x); + } + inline float asin (float x){ + return asinf(x); + } + inline float atan (float x){ + return atanf(x); + } + inline float atan2(float y, float x){ + return atan2f(y, x); + } + inline float ceil (float x){ + return ceilf(x); + } + inline float cos (float x){ + return cosf(x); + } + inline float cosh (float x){ + return coshf(x); + } + inline float exp (float x){ + return expf(x); + } + inline float fabs (float x){ + return fabsf(x); + } + inline float floor(float x){ + return floorf(x); + } + inline float fmod (float x, float y){ + return fmodf(x, y); + } + inline float frexp(float x, int* exp){ + return frexpf(x, exp); + } + inline float ldexp(float x, int exp){ + return ldexpf(x, exp); + } + inline float log (float x){ + return logf(x); + } + inline float log10(float x){ + return log10f(x); + } + inline float modf (float x, float* inptr){ + return modff(x, inptr); + } + inline float pow (float x, float y){ + return powf(x, y); + } +#if 1 // DR 550 removed this + inline float pow (float x, int y){ + return pow((double)x, (double)y); + } +#endif + inline float sin (float x){ + return sinf(x); + } + inline float sinh (float x){ + return sinhf(x); + } + inline float sqrt (float x){ + return sqrtf(x); + } + inline float tan (float x){ + return tanf(x); + } + inline float tanh (float x){ + return tanhf(x); + } + inline double abs(double x){ + return fabs(x); + } + inline double pow(double x, int y){ + return pow((double)x, (double)y); + } + +# ifdef __UCLIBCXX_HAS_LONG_DOUBLE__ + inline long double abs (long double x){ + return fabsl(x); + } + inline long double acos (long double x){ + return acosl(x); + } + inline long double asin (long double x){ + return asinl(x); + } + inline long double atan (long double x){ + return atanl(x); + } + inline long double atan2(long double y, long double x){ + return atan2l(y, x); + } + inline long double ceil (long double x){ + return ceill(x); + } + inline long double cos (long double x){ + return cosl(x); + } + inline long double cosh (long double x){ + return coshl(x); + } + inline long double exp (long double x){ + return expl(x); + } + inline long double fabs (long double x){ + return fabsl(x); + } + inline long double floor(long double x){ + return floorl(x); + } + inline long double frexp(long double x, int* exp){ + return frexpl(x, exp); + } + inline long double fmod (long double x, long double y){ + return fmodl(x, y); + } + inline long double ldexp(long double x, int y){ + return ldexpl(x, y); + } + inline long double log (long double x){ + return logl(x); + } + inline long double log10(long double x){ + return log10l(x); + } + inline long double modf (long double x, long double* iptr){ + return modfl(x, iptr); + } + inline long double pow (long double x, long double y){ + return powl(x, y); + } + inline long double pow (long double x, int y){ + return powl(x, (long double)y ); + } + inline long double sin (long double x){ + return sinl(x); + } + inline long double sinh (long double x){ + return sinhl(x); + } + inline long double sqrt (long double x){ + return sqrtl(x); + } + inline long double tan (long double x){ + return tanl(x); + } + inline long double tanh (long double x){ + return tanhl(x); + } +# endif // __UCLIBCXX_HAS_LONG_DOUBLE__ +#endif // __CORRECT_ISO_CPP_MATH_H_PROTO +} + +#endif //__STD_HEADER_CMATH + diff --git a/include/complex b/include/complex new file mode 100644 index 0000000..2c3c82b --- /dev/null +++ b/include/complex @@ -0,0 +1,327 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include + +#ifndef __STD_HEADER_COMPLEX +#define __STD_HEADER_COMPLEX 1 + + +namespace std { +// class complex; +// class complex; +// class complex; + + template class _UCXXEXPORT complex{ + public: + typedef T value_type; + + complex(const T& re = T(), const T& im = T()) : r(re), i(im) { } + complex(const complex& c): r(c.r), i(c.i){ } + template complex(const complex& c): r(c.r), i(c.i){ } + + inline T real() const{ + return r; + } + inline T imag() const{ + return i; + } + + complex& operator= (const T& v){ + r = v; + i = 0; + return *this; + } + complex& operator+=(const T& v){ + r +=v; + return *this; + } + complex& operator-=(const T& v){ + r -=v; + return *this; + } + complex& operator*=(const T& v){ + r*=v; + i*=v; + return *this; + } + complex& operator/=(const T& v){ + r/=v; + i/=v; + return *this; + } + complex& operator=(const complex& v){ + if(&v != this){ + r = v.r; + i = v.i; + } + return *this; + } + template complex& operator= (const complex& v){ + r = v.r; + i = v.i; + return *this; + } + template complex& operator+=(const complex& v){ + r+=v.r; + i+=v.i; + return *this; + } + template complex& operator-=(const complex& v){ + r-=v.r; + i-=v.i; + return *this; + } + template complex& operator*=(const complex& v){ + T tempr = r*v.r - i*v.i; + T tempi = r*v.i + i*v.r; + r = tempr; + i = tempi; + return *this; + } + template complex& operator/=(const complex& v){ + T tempr = (r*v.r + i*v.i) / (v.r*v.r + v.i*v.i); + T tempi = (i*v.r - r*v.i) / (v.r*v.r + v.i*v.i); + r = tempr; + i = tempi; + return *this; + } + private: + T r; + T i; + }; + + template _UCXXEXPORT complex operator+(const complex& ls, const complex& rs){ + complex retval(ls); + retval += rs; + return retval; + } + template _UCXXEXPORT complex operator+(const complex& ls, const T& rs){ + complex retval(ls); + ls += rs; + return retval; + } + template _UCXXEXPORT inline complex operator+(const T& ls, const complex& rs){ + return rs + ls; + } + template _UCXXEXPORT complex operator-(const complex& ls, const complex& rs){ + complex retval(ls); + retval -= rs; + return retval; + } + template _UCXXEXPORT complex operator-(const complex& ls, const T& rs){ + complex retval(ls); + retval -= rs; + return retval; + } + template _UCXXEXPORT complex operator-(const T& ls, const complex& rs){ + complex retval(ls); + retval -= rs; + return retval; + } + template _UCXXEXPORT complex operator*(const complex& ls, const complex& rs){ + complex retval(ls); + retval *= rs; + return retval; + } + template _UCXXEXPORT complex operator*(const complex& ls, const T& rs){ + complex retval(ls); + retval *= rs; + return retval; + } + template _UCXXEXPORT complex operator*(const T& ls, const complex& rs){ + complex retval(ls); + retval *=rs; + return retval; + } + template _UCXXEXPORT complex operator/(const complex& ls, const complex& rs){ + complex retval(ls); + retval/=rs; + return retval; + } + template _UCXXEXPORT complex operator/(const complex& ls, const T& rs){ + complex retval(ls); + retval/=rs; + return retval; + } + template _UCXXEXPORT complex operator/(const T& ls, const complex& rs){ + complex retval(ls); + retval/=rs; + return retval; + } + template _UCXXEXPORT complex operator+(const complex& v){ + return v; + } + template _UCXXEXPORT complex operator-(const complex& v){ + return complex (-v.real(), -v.imag()); + } + template _UCXXEXPORT bool operator==(const complex& ls, const complex& rs){ + if( ls.real() == rs.real() && ls.imag() == rs.image()){ + return true; + } + return false; + } + template _UCXXEXPORT bool operator==(const complex& ls, const T& rs){ + if(ls.real() == rs && ls.imag() == T()){ + return true; + } + return false; + } + template _UCXXEXPORT bool operator==(const T& ls, const complex& rs){ + if(ls == rs.real() && rs.imag() == T()){ + return true; + } + return false; + } + template _UCXXEXPORT bool operator!=(const complex& ls, const complex& rs){ + if(ls == rs){ + return false; + } + return true; + } + template _UCXXEXPORT bool operator!=(const complex& ls, const T& rs){ + if(ls == rs){ + return false; + } + return true; + } + template _UCXXEXPORT bool operator!=(const T& ls, const complex& rs){ + if(ls == rs){ + return false; + } + return true; + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, complex& v) + { + T tempr; + T tempi; + is >> tempr; + is.get(); + is >> tempi; + v = complex(tempr, tempi); + return is; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const complex&v) + { + os << v.real() << ", " << v.imag(); + return os; + } + + template _UCXXEXPORT T real(const complex& v){ + return v.real(); + } + + template _UCXXEXPORT T imag(const complex& v){ + return v.imag(); + } + + template _UCXXEXPORT T norm(const complex& v){ + return (v.real() * v.real() + v.imag() * v.imag()); + } + + template _UCXXEXPORT complex conj(const complex& v){ + return complex(v.real(), -v.imag()); + } + +#ifdef __UCLIBCXX_SUPPORT_MATH__ //Can we link with libm? + + template _UCXXEXPORT T abs(const complex& v){ + return sqrt(v.real() * v.real() + v.imag() * v.imag()); + } + + template _UCXXEXPORT T arg(const complex& v){ + return atan2(v.imag(), v.real()); + } + + template _UCXXEXPORT complex polar(const T& rho, const T& theta){ + return complex(rho * cos(theta), rho * sin(theta)); + } + + template _UCXXEXPORT complex cos (const complex& v){ + return complex(cos(v.real()) * cosh(v.imag()), -sin(v.real()) * sinh(v.imag())); + } + + template _UCXXEXPORT complex cosh (const complex& v){ + return complex(cosh(v.real()) * cos(v.imag()), sinh(v.real()) * sin(v.imag())); + } + + template _UCXXEXPORT complex exp (const complex& v){ + return polar(exp(v.real()), v.imag()); + } + + template _UCXXEXPORT complex log (const complex& v){ + return complex(log(abs(v)), arg(v)); + } + + template _UCXXEXPORT complex log10(const complex& v){ + return (log(v) / log(T(10.0))); + } + + template _UCXXEXPORT complex pow(const complex& v, int p){ + T rho = pow(abs(v), p); + T theta = arg(v); + return complex(rho * cos(p * theta), rho * sin(p * theta) ); + } + + template _UCXXEXPORT complex pow(const complex& v, const T& p){ + return polar( pow(abs(v),p), arg(v)*p ); + } + + template _UCXXEXPORT complex pow(const complex& v, const complex& p){ + if(v == T()){ + //We are using "0" as the value + return T(); + } + return exp(p * log(v)); + } + + template _UCXXEXPORT complex pow(const T& v, const complex& p){ + if(v == T()){ + return T(); + } + return polar(pow(v,p.real()), y.imag() * log(x) ); + } + + template _UCXXEXPORT complex sin (const complex& v){ + return complex(sin(v.real()) * cosh(v.imag()), cosh(v.real()) * sin(v.imag())); + } + + template _UCXXEXPORT complex sinh (const complex& v){ + return complext(sinh(v.real()) * cos(v.imag()), cosh(v.real()) * sin(v.imag()) ); + } + + template _UCXXEXPORT complex sqrt (const complex&); + template _UCXXEXPORT complex tan (const complex& v){ + return sin(v) / cos(v); + } + + template _UCXXEXPORT complex tanh (const complex& v){ + return sinh(v) / cosh(v); + } + +#endif + +} + +#endif + diff --git a/include/csetjmp b/include/csetjmp new file mode 100644 index 0000000..a11f932 --- /dev/null +++ b/include/csetjmp @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef __STD_HEADER_CSETJMP +#define __STD_HEADER_CSETJMP 1 + + +//From GCC Header files +#undef longjmp + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef setjmp +#define setjmp(env) setjmp (env) +#endif + +//Mine again + + +namespace std{ + using ::longjmp; + using ::jmp_buf; +} + + +#endif + diff --git a/include/csignal b/include/csignal new file mode 100644 index 0000000..1017161 --- /dev/null +++ b/include/csignal @@ -0,0 +1,61 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 20.4.6 C library +// + +/** @file csignal + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c signal.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CSIGNAL +#define _CPP_CSIGNAL 1 + +#pragma GCC system_header + +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef raise + +namespace std +{ + using ::sig_atomic_t; + using ::signal; + using ::raise; +} + +#endif diff --git a/include/cstdarg b/include/cstdarg new file mode 100644 index 0000000..9383ade --- /dev/null +++ b/include/cstdarg @@ -0,0 +1,60 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 20.4.6 C library +// + +/** @file cstdarg + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c stdarg.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CSTDARG +#define _CPP_CSTDARG 1 + +#pragma GCC system_header + +#include + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef va_end +#define va_end(ap) va_end (ap) +#endif + +namespace std +{ + using ::va_list; +} + +#endif diff --git a/include/cstddef b/include/cstddef new file mode 100644 index 0000000..d44834b --- /dev/null +++ b/include/cstddef @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 18.1 Types +// + +/** @file cstddef + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c stddef.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CSTDDEF +#define _CPP_CSTDDEF 1 + +#ifdef __GCC__ +#pragma GCC system_header +#endif + +#include + +namespace std +{ + using ::ptrdiff_t; + using ::size_t; +} + +#endif diff --git a/include/cstdint b/include/cstdint new file mode 100644 index 0000000..e93cb56 --- /dev/null +++ b/include/cstdint @@ -0,0 +1,111 @@ +/* Copyright (C) 2025 Catty Steve + + This file is part of the uClibc++ Library. + 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 + + TODO: Currently untested +*/ +#include + +namespace std{ + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::int_fast8_t; + using ::int_fast16_t; + using ::int_fast32_t; + using ::int_fast64_t; + + using ::int_least8_t; + using ::int_least16_t; + using ::int_least32_t; + using ::int_least64_t; + + using ::intmax_t; + using ::intptr_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; + + using ::uint_fast8_t; + using ::uint_fast16_t; + using ::uint_fast32_t; + using ::uint_fast64_t; + + using ::uint_least8_t; + using ::uint_least16_t; + using ::uint_least32_t; + using ::uint_least64_t; + + using ::uintmax_t; + using ::uintptr_t; + + using intmax_t = __INTMAX_TYPE__; + using uintmax_t = __UINTMAX_TYPE__; + + #ifdef __INT8_TYPE__ + using int8_t = __INT8_TYPE__; + #endif + #ifdef __INT16_TYPE__ + using int16_t = __INT16_TYPE__; + #endif + #ifdef __INT32_TYPE__ + using int32_t = __INT32_TYPE__; + #endif + #ifdef __INT64_TYPE__ + using int64_t = __INT64_TYPE__; + #endif + + using int_least8_t = __INT_LEAST8_TYPE__; + using int_least16_t = __INT_LEAST16_TYPE__; + using int_least32_t = __INT_LEAST32_TYPE__; + using int_least64_t = __INT_LEAST64_TYPE__; + using int_fast8_t = __INT_FAST8_TYPE__; + using int_fast16_t = __INT_FAST16_TYPE__; + using int_fast32_t = __INT_FAST32_TYPE__; + using int_fast64_t = __INT_FAST64_TYPE__; + + #ifdef __INTPTR_TYPE__ + using intptr_t = __INTPTR_TYPE__; + #endif + + #ifdef __UINT8_TYPE__ + using uint8_t = __UINT8_TYPE__; + #endif + #ifdef __UINT16_TYPE__ + using uint16_t = __UINT16_TYPE__; + #endif + #ifdef __UINT32_TYPE__ + using uint32_t = __UINT32_TYPE__; + #endif + #ifdef __UINT64_TYPE__ + using uint64_t = __UINT64_TYPE__; + #endif + using uint_least8_t = __UINT_LEAST8_TYPE__; + using uint_least16_t = __UINT_LEAST16_TYPE__; + using uint_least32_t = __UINT_LEAST32_TYPE__; + using uint_least64_t = __UINT_LEAST64_TYPE__; + using uint_fast8_t = __UINT_FAST8_TYPE__; + using uint_fast16_t = __UINT_FAST16_TYPE__; + using uint_fast32_t = __UINT_FAST32_TYPE__; + using uint_fast64_t = __UINT_FAST64_TYPE__; + #ifdef __UINTPTR_TYPE__ + using uintptr_t = __UINTPTR_TYPE__; + #endif +} diff --git a/include/cstdio b/include/cstdio new file mode 100644 index 0000000..8699385 --- /dev/null +++ b/include/cstdio @@ -0,0 +1,80 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 version 2.1 + + 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 +#include + +#ifndef __HEADER_CSTDIO +#define __HEADER_CSTDIO 1 + + +namespace std{ + using ::FILE; + using ::fpos_t; + + using ::clearerr; + using ::fclose; + using ::feof; + using ::ferror; + using ::fflush; + using ::fgetc; + using ::fgetpos; + using ::fgets; + using ::fopen; + using ::fprintf; + using ::fputc; + using ::fputs; + using ::fread; + using ::freopen; + using ::fscanf; + using ::fseek; + using ::fsetpos; + using ::ftell; + using ::fwrite; + using ::getc; + using ::getchar; +#if __cplusplus <= 201103L + // LWG 2249 + using ::gets; +#endif + using ::perror; + using ::printf; + using ::putc; + using ::putchar; + using ::puts; + using ::remove; + using ::rename; + using ::rewind; + using ::scanf; + using ::setbuf; + using ::setvbuf; + using ::sprintf; + using ::sscanf; + using ::tmpfile; +#if _GLIBCXX_USE_TMPNAM + using ::tmpnam; +#endif + using ::ungetc; + using ::vfprintf; + using ::vprintf; + using ::vsprintf; +} + + + +#endif + diff --git a/include/cstdlib b/include/cstdlib new file mode 100644 index 0000000..b85ed36 --- /dev/null +++ b/include/cstdlib @@ -0,0 +1,71 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 +#include + +#ifndef __HEADER_CSTDLIB +#define __HEADER_CSTDLIB 1 + + +namespace std{ + using ::abort; + using ::abs; + using ::atexit; + using ::atol; + using ::atof; + using ::atoi; + using ::bsearch; + using ::calloc; + using ::div; + using ::exit; + using ::free; + using ::getenv; + using ::labs; + using ::ldiv; + using ::malloc; + using ::qsort; + using ::rand; + using ::realloc; + using ::srand; + using ::strtod; + using ::strtol; + using ::strtoul; + using ::system; +#ifdef __UCLIBCXX_HAS_WCHAR__ + using ::mblen; + using ::mbstowcs; + using ::mbtowc; + using ::wctomb; + using ::wcstombs; +#endif + + inline long abs(long i){ + return labs(i); + } + + inline ldiv_t div(long i, long j){ + return ldiv(i, j); + } + +} + + + +#endif + diff --git a/include/cstring b/include/cstring new file mode 100644 index 0000000..de8589b --- /dev/null +++ b/include/cstring @@ -0,0 +1,77 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 +#include + +#ifndef __HEADER_CSTRING +#define __HEADER_CSTRING 1 + + +namespace std{ + + using ::memchr; + using ::memcmp; + using ::memcpy; + using ::memmove; + using ::memset; + using ::strcat; + using ::strchr; + using ::strcmp; + using ::strcoll; + using ::strcpy; + using ::strcspn; + using ::strerror; + using ::strlen; + using ::strncat; + using ::strncmp; + using ::strncpy; + using ::strpbrk; + using ::strrchr; + using ::strspn; + using ::strstr; + using ::strtok; + using ::strxfrm; + +#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO + //Extra definitions required in c++ spec + + inline void* memchr(void* s, int c, size_t n){ + return memchr(const_cast(s), c, n); + } + + inline char* strchr(char* s, int c){ + return strchr(const_cast(s), c); + } + + inline char* strpbrk(char* s1, const char* s2){ + return strpbrk(const_cast(s1), s2); + } + + inline char* strrchr(char* s, int c){ + return strrchr(const_cast(s), c); + } + + inline char* strstr(char* s1, const char* s2){ + return strstr(const_cast(s1), s2); + } +#endif +} + +#endif + diff --git a/include/ctime b/include/ctime new file mode 100644 index 0000000..1b4c09b --- /dev/null +++ b/include/ctime @@ -0,0 +1,81 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 20.5 Date and time +// + +/** @file ctime + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c time.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CTIME +#define _CPP_CTIME 1 + +#pragma GCC system_header + +#include + +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef clock +#undef difftime +#undef mktime +#undef time +#undef asctime +#undef ctime +#undef gmtime +#undef localtime +#undef strftime + +namespace std +{ + using ::clock_t; + using ::time_t; + using ::tm; + + using ::clock; + using ::difftime; + using ::mktime; + using ::time; + using ::asctime; + using ::ctime; + using ::gmtime; + using ::localtime; + using ::strftime; +} + +#endif diff --git a/include/cwchar b/include/cwchar new file mode 100644 index 0000000..03fae09 --- /dev/null +++ b/include/cwchar @@ -0,0 +1,86 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 version 2.1 + + 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 +#include + +#ifndef __HEADER_CWCHAR +#define __HEADER_CWCHAR 1 + + +namespace std{ + using ::mbstate_t; + using ::wint_t; + + using ::btowc; + using ::fgetwc; + using ::fgetws; + using ::fputwc; + using ::fputws; + using ::fwide; + using ::fwprintf; + using ::fwscanf; + using ::getwc; + using ::getwchar; + using ::mbrlen; + using ::mbrtowc; + using ::mbsinit; + using ::mbsrtowcs; + using ::putwc; + using ::putwchar; + using ::swprintf; + using ::swscanf; + using ::ungetwc; + using ::vfwprintf; + using ::vswprintf; + using ::vwprintf; + using ::wcrtomb; + using ::wcscat; + using ::wcschr; + using ::wcscmp; + using ::wcscoll; + using ::wcscpy; + using ::wcscspn; + using ::wcsftime; + using ::wcslen; + using ::wcsncat; + using ::wcsncmp; + using ::wcsncpy; + using ::wcspbrk; + using ::wcsrchr; + using ::wcsrtombs; + using ::wcsspn; + using ::wcsstr; + using ::wcstod; + using ::wcstok; + using ::wcstol; + using ::wcstoul; + using ::wcsxfrm; + using ::wctob; + using ::wmemchr; + using ::wmemcmp; + using ::wmemcpy; + using ::wmemmove; + using ::wmemset; + using ::wprintf; + using ::wscanf; +} + + + +#endif + diff --git a/include/cwctype b/include/cwctype new file mode 100644 index 0000000..5e4b605 --- /dev/null +++ b/include/cwctype @@ -0,0 +1,106 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: +// + +/** @file cwctype + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c wctype.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CWCTYPE +#define _CPP_CWCTYPE 1 + +#pragma GCC system_header + +//#include + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#endif + +// Get rid of those macros defined in in lieu of real functions. +#undef iswalnum +#undef iswalpha +#undef iswblank +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef iswctype +#undef towlower +#undef towupper +#undef towctrans +#undef wctrans +#undef wctype + +#if __UCLIBCXX_HAS_WCHAR__ +namespace std +{ + using ::wint_t; // cwchar + + using ::wctype_t; + using ::wctrans_t; + + using ::iswalnum; + using ::iswalpha; + using ::iswblank; + using ::iswcntrl; + using ::iswdigit; + using ::iswgraph; + using ::iswlower; + using ::iswprint; + using ::iswprint; + using ::iswpunct; + using ::iswspace; + using ::iswupper; + using ::iswxdigit; + using ::iswctype; + using ::towlower; + using ::towupper; + using ::towctrans; + using ::wctrans; + using ::wctype; +} +#endif //__ULIBCXX_HAS_WCHAR__ + +#endif diff --git a/include/deque b/include/deque new file mode 100644 index 0000000..ff07ab5 --- /dev/null +++ b/include/deque @@ -0,0 +1,884 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + 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 +#include +#include + +#pragma GCC visibility push(default) + +#ifndef __STD_HEADER_DEQUE +#define __STD_HEADER_DEQUE + + +namespace std{ + template > class deque; + template bool operator==(const deque& x, const deque& y); + template bool operator< (const deque& x, const deque& y); + template bool operator!=(const deque& x, const deque& y); + template bool operator> (const deque& x, const deque& y); + template bool operator>=(const deque& x, const deque& y); + template bool operator<=(const deque& x, const deque& y); + template void swap(deque& x, deque& y); + + template class _UCXXEXPORT deque { + public: + friend bool operator==<>(const deque& x, const deque& y); + friend class deque_iter; + friend class deque_citer; + class deque_iter; + class deque_citer; + + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef deque_iter iterator; + typedef deque_citer const_iterator; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef T value_type; + typedef Allocator allocator_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + explicit deque(const Allocator& al = Allocator()); + explicit deque(size_type n, const T& value = T(), const Allocator& al = Allocator()); + template deque(InputIterator first, InputIterator last, const Allocator& = Allocator()); + deque(const deque& x); + ~deque(); + + deque& operator=(const deque& x); + template void assign(InputIterator first, InputIterator last); + template void assign(Size n, const U& u = U()); + allocator_type get_allocator() const; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + + size_type size() const; + size_type max_size() const; + void resize(size_type sz, T c = T()); + bool empty() const; + + reference operator[](size_type n); + const_reference operator[](size_type n) const; + reference at(size_type n); + const_reference at(size_type n) const; + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + void push_front(const T& x); + void push_back(const T& x); + iterator insert(iterator position, const T& x = T()); + void insert(iterator position, size_type n, const T& x); + template void insert (iterator position, InputIterator first, InputIterator last); + void pop_front(); + void pop_back(); + + iterator erase(iterator position); + iterator erase(iterator first, iterator last); + void swap(deque&); + void clear(); + + protected: + void reserve(size_type n); + inline size_type array_element(size_type deque_element) const{ + if(deque_element < (data_size - first_element)){ + return first_element + deque_element; + } + return deque_element - (data_size - first_element); + } + inline size_type first_subtract(size_type sub_size) const{ + if(sub_size > first_element){ + return (data_size - first_element) - sub_size; + } + return first_element - sub_size; + } + + T * data; + size_type data_size; //Physical size of array + size_type elements; //Elements in array + size_type first_element; //Element number of array 0..n + size_type last_element; //Element number of array 0..n + Allocator a; + + }; + + + template class _UCXXEXPORT deque::deque_iter + : public std::iterator< + random_access_iterator_tag, + T, + typename Allocator::difference_type, + typename Allocator::pointer, + typename Allocator::reference + > + { + friend class deque; + protected: + deque * container; + typename Allocator::size_type element; + + public: + deque_iter() : container(0), element(0) { } + deque_iter(const deque_iter & d) : container (d.container), element(d.element) { } + deque_iter(deque * c, typename Allocator::size_type e) + : container(c), element(e) + { + return; + } + ~deque_iter() { } + deque_iter & operator=(const deque_iter & d){ + container = d.container; + element = d.element; + return *this; + } + T & operator*(){ + return container->data[container->array_element(element)]; + } + T * operator->(){ + return container->data + container->array_element(element); + } + const T & operator*() const{ + return container->data[container->array_element(element)]; + } + const T * operator->() const{ + return container->data + container->array_element(element); + } + bool operator==(const deque_iter & d) const{ + if(container == d.container && element == d.element){ + return true; + } + return false; + } + bool operator==(const deque_citer & d) const{ + if(container == d.container && element == d.element){ + return true; + } + return false; + } + bool operator!=(const deque_iter & d) const{ + if(container != d.container || element != d.element){ + return true; + } + return false; + } + bool operator!=(const deque_citer & d) const{ + if(container != d.container || element != d.element){ + return true; + } + return false; + } + bool operator<(const deque_iter & d) const{ + if(element < d.element){ + return true; + } + return false; + } + bool operator<(const deque_citer & d) const{ + if(element < d.element){ + return true; + } + return false; + } + bool operator<=(const deque_iter & d) const{ + if(element <= d.element){ + return true; + } + return false; + } + bool operator<=(const deque_citer & d) const{ + if(element <= d.element){ + return true; + } + return false; + } + bool operator>(const deque_iter & d) const{ + if(element > d.element){ + return true; + } + return false; + } + bool operator>(const deque_citer & d) const{ + if(element > d.element){ + return true; + } + return false; + } + bool operator>=(const deque_iter & d) const{ + if(element >= d.element){ + return true; + } + return false; + } + bool operator>=(const deque_citer & d) const{ + if(element >= d.element){ + return true; + } + return false; + } + deque_iter & operator++(){ + ++element; + return *this; + } + deque_iter operator++(int){ + deque_iter temp(container, element); + ++element; + return temp; + } + deque_iter operator+(typename Allocator::size_type n){ + deque_iter temp(container, element + n); + return temp; + } + deque_iter & operator+=(typename Allocator::size_type n){ + element += n; + return *this; + } + deque_iter & operator--(){ + --element; + return *this; + } + deque_iter operator--(int){ + deque_iter temp(container, element); + --element; + return temp; + } + deque_iter operator-(typename Allocator::size_type n){ + deque_iter temp(container, element - n); + return temp; + } + deque_iter & operator-=(typename Allocator::size_type n){ + element -= n; + return *this; + } + typename Allocator::size_type operator-(const deque_iter & d){ + return element - d.element; + } + + }; + + template class _UCXXEXPORT deque::deque_citer + : public std::iterator< + random_access_iterator_tag, + T, + typename Allocator::difference_type, + typename Allocator::const_pointer, + typename Allocator::const_reference + > + { + friend class deque; + protected: + const deque * container; + typename Allocator::size_type element; + + public: + deque_citer() : container(0), element(0) { } + deque_citer(const deque_citer & d) : container (d.container), element(d.element) { } + deque_citer(const deque_iter & d) : container (d.container), element(d.element) { } + deque_citer(const deque * c, typename Allocator::size_type e) + : container(c), element(e) + { + return; + } + ~deque_citer() { } + deque_citer & operator=(const deque_iter & d){ + container = d.container; + element = d.element; + return *this; + } + const T & operator*() const{ + return container->data[container->array_element(element)]; + } + const T * operator->() const{ + return container->data + container->array_element(element); + } + bool operator==(const deque_citer & d) const{ + if(container == d.container && element == d.element){ + return true; + } + return false; + } + bool operator==(const deque_iter & d) const{ + if(container == d.container && element == d.element){ + return true; + } + return false; + } + bool operator!=(const deque_citer & d) const{ + if(container != d.container || element != d.element){ + return true; + } + return false; + } + bool operator!=(const deque_iter & d) const{ + if(container != d.container || element != d.element){ + return true; + } + return false; + } + bool operator<(const deque_citer & d) const{ + if(element < d.element){ + return true; + } + return false; + } + bool operator<(const deque_iter & d) const{ + if(element < d.element){ + return true; + } + return false; + } + bool operator<=(const deque_citer & d) const{ + if(element <= d.element){ + return true; + } + return false; + } + bool operator<=(const deque_iter & d) const{ + if(element <= d.element){ + return true; + } + return false; + } + bool operator>(const deque_citer & d) const{ + if(element > d.element){ + return true; + } + return false; + } + bool operator>(const deque_iter & d) const{ + if(element > d.element){ + return true; + } + return false; + } + bool operator>=(const deque_citer & d){ + if(element >= d.element){ + return true; + } + return false; + } + bool operator>=(const deque_iter & d){ + if(element >= d.element){ + return true; + } + return false; + } + deque_citer & operator++(){ + ++element; + return *this; + } + deque_citer operator++(int){ + deque_citer temp(container, element); + ++element; + return temp; + } + deque_citer operator+(typename Allocator::size_type n){ + deque_citer temp(container, element + n); + return temp; + } + deque_citer & operator+=(typename Allocator::size_type n){ + element += n; + return *this; + } + deque_citer & operator--(){ + --element; + return *this; + } + deque_citer operator--(int){ + deque_citer temp(container, element); + --element; + return temp; + } + deque_citer operator-(typename Allocator::size_type n){ + deque_citer temp(container, element - n); + return temp; + } + deque_citer & operator-=(typename Allocator::size_type n){ + element -= n; + return *this; + } + typename Allocator::size_type operator-(const deque_citer & d){ + return element - d.element; + } + + }; + + template deque::deque(const Allocator& al) + : data(0), + data_size(0), elements(0), first_element(0), last_element(0), a(al) + { + data_size = __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = data_size /2; + last_element = first_element; + } + + + template deque::deque( + size_type n, const T& value, const Allocator& al) + : data(0), + elements(n), first_element(0), last_element(0), a(al) + { + data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = (data_size - elements) / 2; + last_element = first_element; + + for(n=first_element ; n < last_element; ++n ){ + a.construct(data+n, value); + } + } + + + template template + deque::deque(InputIterator first, InputIterator last, const Allocator& al) + : data(0), + data_size(0), elements(0), first_element(0), last_element(0), a(al) + { + data_size = __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = data_size / 4; //Note sure how big, but let's add a little space... + last_element = first_element; + while(first != last){ + push_back(*first); + ++first; + } + } + + + template deque::deque(const deque& x) + : data(0), + elements(0), first_element(0), last_element(0), a(x.a) + { + data_size = x.elements + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = (data_size - x.elements) / 2; + last_element = first_element; + for(size_type i=0; i < x.elements; ++i){ + push_back(x[i]); + } + } + + + template deque::~deque(){ + clear(); + a.deallocate(data, data_size); + } + + template deque& deque:: + operator=(const deque& x) + { + if(&x == this){ + return *this; + } + resize(x.elements); + for(size_t i = 0; i < elements; ++i){ + data[array_element(i)] = x[i]; + } + return *this; + } + + + template template void + deque::assign(InputIterator first, InputIterator last) + { + clear(); + while(first !=last){ + push_back(*first); + ++first; + } + } + + + template template void + deque::assign(Size n, const U& u) + { + if(&u == this){ + return; + } + clear(); + for(size_type i = 0; i < n; ++i){ + push_back(u); + } + } + + + template typename deque::allocator_type + deque::get_allocator() const + { + return a; + } + + template typename + deque::iterator deque::begin() + { + return deque_iter(this, 0); + } + + + template typename deque::const_iterator + deque::begin() const + { + return deque_citer(this, 0); + } + + template typename + deque::iterator deque::end() + { + return deque_iter(this, elements); + } + + template typename + deque::const_iterator deque::end() const + { + return deque_citer(this, elements); + } + + template typename + deque::reverse_iterator deque::rbegin() + { + return reverse_iterator(end()); + } + + template typename + deque::const_reverse_iterator deque::rbegin() const + { + return const_reverse_iterator(end()); + } + + template typename + deque::reverse_iterator deque::rend() + { + return reverse_iterator(begin()); + } + + template typename + deque::const_reverse_iterator deque::rend() const + { + return const_reverse_iterator(begin()); + } + + template typename + deque::size_type deque::size() const + { + return elements; + } + + template typename + deque::size_type deque::max_size() const + { + return ((size_type)(-1)) / sizeof(T); + } + + template void deque::resize(size_type sz, T c){ + reserve(sz); + while(sz > size()){ + push_back(c); + } + while(sz < size()){ + pop_back(); + } + } + + template bool deque::empty() const{ + return (elements == 0); + } + + template typename + deque::reference deque::operator[](size_type n) + { + return data[array_element(n)]; + } + + template typename + deque::const_reference deque::operator[](size_type n) const + { + return data[array_element(n)]; + } + + template typename + deque::reference deque::at(size_type n) + { + if(n > elements){ + __throw_out_of_range("Out of deque range"); + } + return data[array_element(n)]; + } + + template typename + deque::const_reference deque::at(size_type n) const + { + if(n > elements){ + __throw_out_of_range("Out of deque range"); + } + return data[array_element(n)]; + } + + template typename + deque::reference deque::front() + { + return data[first_element]; + } + + template typename + deque::const_reference deque::front() const + { + return data[first_element]; + } + + template typename + deque::reference deque::back() + { + return data[array_element(elements-1)]; + } + + template typename + deque::const_reference deque::back() const + { + return data[array_element(elements-1)]; + } + + template void deque::push_front(const T& x){ + reserve(elements + 1); + first_element = first_subtract(1); + a.construct(data + first_element, x); + ++elements; + } + + template void deque::push_back(const T& x){ + reserve(elements + 1); + a.construct(data + last_element, x); + ++elements; + last_element = array_element(elements); + } + + template typename + deque::iterator deque::insert(iterator position, const T& x) + { + reserve(elements+1); + if(position.element > (elements/2)){ + //Push all elements back 1 + push_back(x); + for(size_type i = elements-1; i > position.element; --i){ + at(i) = at(i-1); + } + }else{ + //Push all elements forward 1 + push_front(x); + for(size_type i = 0; i < position.element; ++i){ + at(i) = at(i+1); + } + } + at(position.element) = x; + return deque_iter(this, position.element); + } + + template void deque:: + insert(typename deque::iterator position, size_type n, const T& x) + { + reserve(elements + n); + for(size_t i =0; i < n; ++i){ + position = insert(position, x); + } + } + + template template + void deque::insert (iterator position, InputIterator first, InputIterator last) + { + while(first != last){ + position = insert(position, *first); + ++first; + } + } + + template void deque::pop_front(){ + if(elements == 0){ + __throw_out_of_range("deque pop_front"); + } + a.destroy(data + first_element); + first_element = array_element(1); + --elements; + } + + template void deque::pop_back(){ + last_element = array_element(elements - 1); + a.destroy(data + last_element); + --elements; + } + + template typename + deque::iterator deque::erase(typename deque::iterator position) + { + if(position.element > (elements /2)){ + for(size_type i = position.element; i < elements - 1; ++i){ + at(i) = at(i+1); + } + pop_back(); + }else{ + for(size_type i = position.element; i > 0; --i){ + at(i) = at(i-1); + } + pop_front(); + } + return deque_iter(this, position.element); + } + + template typename deque::iterator + deque:: + erase(typename deque::iterator first, typename deque::iterator last) + { + //Shift backwards + size_type num_move = last.element - first.element; + if( first.element > (elements - last.element) ){ + for(size_type i = last.element; i < elements ; ++i){ + at(i-num_move) = at(i); + } + for(size_type i = 0; i < num_move ; ++i){ + pop_back(); + } + }else{ + for(size_type i = 0; i < first.element ; ++i){ + at(last.element - i - 1) = at(first.element - i - 1); + } + for(size_type i = 0; i < num_move ; ++i){ + pop_front(); + } + } + return deque_iter(this, first.element); + } + + template void deque::swap(deque& x) + { + T * temp_data; + typename deque::size_type temp_size; + + //Swap data pointers + temp_data = x.data; + x.data = data; + data = temp_data; + + //Swap array sizes + temp_size = x.data_size; + x.data_size = data_size; + data_size = temp_size; + + //Swap num array elements + temp_size = x.elements; + x.elements = elements; + elements = temp_size; + + //Swap first_pointer + temp_size = x.first_element; + x.first_element = first_element; + first_element = temp_size; + + //Swap last_pointer + temp_size = x.last_element; + x.last_element = last_element; + last_element = temp_size; + } + + template void deque::clear() + { + while(elements > 0 ){ + pop_back(); + } + } + + + template void deque::reserve(typename deque::size_type n) + { + if(data_size >= n){ + return; + } + + size_type size_temp; + size_type first_temp; + T * data_temp; + size_temp = n + __UCLIBCXX_STL_BUFFER_SIZE__; //Reserve extra 'cause we can + data_temp = a.allocate(size_temp); + + first_temp = (size_temp - elements) / 2; + for(size_type i = 0; i < elements; ++i){ + a.construct(data_temp + first_temp + i, data[array_element(i)]); + a.destroy(data + array_element(i)); + } + + //Now shuffle pointers + a.deallocate(data, data_size); + data = data_temp; + data_size = size_temp; + first_element = first_temp; + last_element = first_element + elements; + } + + + template _UCXXEXPORT + bool + operator==(const deque& x, const deque& y) + { + if(x.elements != y.elements){ + return false; + } + for(typename deque::size_type i = 0; i < x.elements; ++i){ + if(x[i] < y[i] || y[i] < x[i]){ + return false; + } + } + return true; + } + + template bool operator< (const deque& x, const deque& y); + template _UCXXEXPORT + bool + operator!=(const deque& x, const deque& y) + { + if(x == y){ + return false; + } + return true; + } + template bool operator> (const deque& x, const deque& y); + template bool operator>=(const deque& x, const deque& y); + template bool operator<=(const deque& x, const deque& y); + template _UCXXEXPORT void swap(deque& x, deque& y){ + x.swap(y); + } + + + +} + +#pragma GCC visibility pop + +#endif + + + + diff --git a/include/exception b/include/exception new file mode 100644 index 0000000..0cccc9c --- /dev/null +++ b/include/exception @@ -0,0 +1,120 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002 +// Free Software Foundation +// +// This file is part of GNU CC. +// +// GNU CC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// GNU CC 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 GNU CC; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file exception + * This header defines several types and functions relating to the + * handling of exceptions in a C++ program. + */ + +#ifndef __EXCEPTION__ +#define __EXCEPTION__ + +#include + +extern "C++" { + +namespace std +{ + /** + * @brief Base class for all library exceptions. + * + * This is the base class for all exceptions thrown by the standard + * library, and by certain language expressions. You are free to derive + * your own %exception classes, or use a different hierarchy, or to + * throw non-class data (e.g., fundamental types). + */ + class exception + { + public: + exception() _UCXX_NOTHROW { } + virtual ~exception() _UCXX_NOTHROW; + /** Returns a C-style character string describing the general cause + * of the current error. */ + virtual const char* what() const _UCXX_NOTHROW; + }; + + /** If an %exception is thrown which is not listed in a function's + * %exception specification, one of these may be thrown. */ + class bad_exception : public exception + { + public: + bad_exception() _UCXX_USE_NOEXCEPT { } + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_exception() _UCXX_USE_NOEXCEPT; + }; + + /// If you write a replacement %terminate handler, it must be of this type. + typedef void (*terminate_handler) (); + /// If you write a replacement %unexpected handler, it must be of this type. + typedef void (*unexpected_handler) (); + + /// Takes a new handler function as an argument, returns the old function. + terminate_handler set_terminate(terminate_handler) _UCXX_USE_NOEXCEPT; + /** The runtime will call this function if %exception handling must be + * abandoned for any reason. */ + void terminate() __UCLIBCXX_NORETURN; + + /// Takes a new handler function as an argument, returns the old function. + unexpected_handler set_unexpected(unexpected_handler) _UCXX_USE_NOEXCEPT; + /** The runtime will call this function if an %exception is thrown which + * violates the function's %exception specification. */ + void unexpected() __UCLIBCXX_NORETURN; + + /** [18.6.4]/1: "Returns true after completing evaluation of a + * throw-expression until either completing initialization of the + * exception-declaration in the matching handler or entering @c unexpected() + * due to the throw; or after entering @c terminate() for any reason + * other than an explicit call to @c terminate(). [Note: This includes + * stack unwinding [15.2]. end note]" + * + * 2: "When @c uncaught_exception() is true, throwing an %exception can + * result in a call of @c terminate() (15.5.1)." + */ + bool uncaught_exception() _UCXX_USE_NOEXCEPT; +} // namespace std + +namespace __gnu_cxx +{ + /** A replacement for the standard terminate_handler which prints more + information about the terminating exception (if any) on stderr. Call + @code + std::set_terminate (__gnu_cxx::__verbose_terminate_handler) + @endcode + to use. For more info, see + http://gcc.gnu.org/onlinedocs/libstdc++/19_diagnostics/howto.html#4 + */ + void __verbose_terminate_handler (); +} // namespace __gnu_cxx + +} // extern "C++" + +#endif diff --git a/include/fstream b/include/fstream new file mode 100644 index 0000000..fddfa35 --- /dev/null +++ b/include/fstream @@ -0,0 +1,677 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 +*/ + +#ifndef __STD_HEADER_FSTREAM +#define __STD_HEADER_FSTREAM 1 + + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif //__UCLIBCXX_HAS_WCHAR__ + +#pragma GCC visibility push(default) + +namespace std{ + + template class basic_filebuf; + + typedef basic_filebuf filebuf; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_filebuf wfilebuf; +#endif + + + template class _UCXXEXPORT basic_filebuf + : public basic_streambuf + { +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + friend ios_base::Init::Init(); //Needed for cout/cin stuff +#endif + public: + // Types (inherited from basic_streambuf: + typedef typename basic_streambuf::char_type char_type; + typedef typename basic_streambuf::int_type int_type; + typedef typename basic_streambuf::pos_type pos_type; + typedef typename basic_streambuf::off_type off_type; + typedef traits traits_type; + + //Constructors/destructor: + + _UCXXEXPORT basic_filebuf() + : basic_streambuf(), fp(0), pbuffer(0), + gbuffer(0), append(false) + { + pbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; + gbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; + + this->setp(pbuffer, pbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); + //Position get buffer so that there is no data available + this->setg(gbuffer, gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__, + gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); + } + + + _UCXXEXPORT virtual ~basic_filebuf(){ + sync(); + close(); + delete [] pbuffer; + delete [] gbuffer; + pbuffer = 0; + gbuffer = 0; + } + + + //Members: + + _UCXXEXPORT bool is_open() const{ + if(fp == 0){ + return false; + } + return true; + } + + _UCXXEXPORT basic_filebuf* open(const char* s, ios_base::openmode mode){ + bool move_end = (mode & ios_base::ate) != 0; + if(is_open() !=false){ //Must call close() first + return 0; + } + basic_streambuf::openedFor = mode; + mode = mode & ~ios_base::ate; + + if(mode == ios_base::out || mode == (ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w" ); + }else if((mode & ios_base::app) && ! (mode & ios_base::trunc)){ + if(mode & ios_base::binary){ + if(mode & ios_base::in){ + fp = fopen(s, "a+b"); + }else{ + fp = fopen(s, "ab"); + } + }else{ + if(mode & ios_base::in){ + fp = fopen(s, "a+"); + }else{ + fp = fopen(s, "a"); + } + } + }else if(mode == ios_base::in){ + fp = fopen(s, "r"); + }else if(mode == (ios_base::in | ios_base::out)){ + fp = fopen(s, "r+"); + }else if(mode == (ios_base::in | ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w+"); + }else if(mode == (ios_base::binary | ios_base::out)){ + fp = fopen(s, "wb"); + }else if(mode == (ios_base::in | ios_base::binary)){ + fp = fopen(s, "rb"); + }else if(mode == (ios_base::in | ios_base::binary | ios_base::out)){ + fp = fopen(s, "r+b"); + }else if(mode==(ios_base::binary | ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w+b"); + }else if(mode == (ios_base::in | ios_base::binary | ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w+b"); + } + + if(fp == 0){ + return 0; + } + if(ferror(fp)){ + fclose(fp); + fp=0; + return 0; + } + int retval = 0; + + //Check to make sure the stream is good + if(move_end == true){ + retval = fseek(fp, 0, SEEK_END); + }else{ + retval = fseek(fp, 0, SEEK_SET); + } + if(retval!=0){ //Seek error + fclose(fp); + fp=0; + return 0; + } + + basic_streambuf::mgnext = basic_streambuf::mgend; + + return this; + } + _UCXXEXPORT basic_filebuf* close(){ + if(fp != 0 && fp != stdin && fp != stdout && fp !=stderr ){ + overflow(); + sync(); + int retval = fclose(fp); + if(retval !=0){ //Error of some sort + return 0; + } + fp=0; + } + return this; + } + protected: + _UCXXEXPORT basic_filebuf(const basic_filebuf &){ } + _UCXXEXPORT basic_filebuf & operator=(const basic_filebuf &){ return *this; } + + //Overridden virtual functions: + + virtual _UCXXEXPORT int showmanyc(){ + return basic_streambuf::egptr() - basic_streambuf::gptr(); + } + virtual _UCXXEXPORT int_type underflow(){ + /* Some variables used internally: + Buffer pointers: + charT * mgbeg; + charT * mgnext; + charT * mgend; + + eback() returns mgbeg + gptr() returns mgnext + egptr() returns mgend + + gbump(int n) mgnext+=n + + */ + + if(!is_open()){ + return traits::eof(); + } + + if(basic_streambuf::eback() == 0){ + //No buffer, so... + charT c; + int retval; + retval = fread(&c, sizeof(charT), 1, fp); + + if(retval == 0 || feof(fp) || ferror(fp) ){ + return traits::eof(); + } + return traits::to_int_type(c); + } + + if(basic_streambuf::eback() == basic_streambuf::gptr()){ //Buffer is full + return traits::to_int_type(*basic_streambuf::gptr()); + } + //Shift entire buffer back to the begining + size_t offset = basic_streambuf::gptr() - basic_streambuf::eback(); + size_t amountData = basic_streambuf::egptr() - basic_streambuf::gptr(); + + for(charT * i = basic_streambuf::gptr(); i < basic_streambuf::egptr(); ++i){ + *(i-offset) = *i; + } + + size_t retval = 0; + //Save operating flags from file descriptor + int fcntl_flags = fcntl(fileno(fp), F_GETFL); + retval = 0; + + //Set to non_blocking mode + fcntl(fileno(fp), F_SETFL, fcntl_flags | O_NONBLOCK); + + //Fill rest of buffer + retval = fread(basic_streambuf::egptr() - + basic_streambuf::gptr() + basic_streambuf::eback(), + sizeof(charT), + offset, + fp + ); + + //Clear problems where we didn't read in enough characters + if(EAGAIN == errno){ + clearerr(fp); + } + + //Restore file descriptor clase + fcntl(fileno(fp), F_SETFL, fcntl_flags); + + //Now we are going to make sure that we read in at least one character. The hard way. + if(retval == 0){ + fcntl_flags = fcntl(fileno(fp), F_GETFL); + //Set to blocking mode + fcntl(fileno(fp), F_SETFL, fcntl_flags & ~O_NONBLOCK); + + retval = fread(basic_streambuf::egptr() - + basic_streambuf::gptr() + basic_streambuf::eback(), + sizeof(charT), + 1, + fp + ); + + //Restore file descriptor clase + fcntl(fileno(fp), F_SETFL, fcntl_flags); + + } + + if(retval !=offset){ //Slide buffer forward again + for(size_t i = 0; i < amountData + retval; ++i){ + *(basic_streambuf::egptr() - i - 1) = + *(basic_streambuf::eback() + amountData + retval - i - 1); + } + } + + basic_streambuf::mgnext -= retval; + + if( (retval <= 0 && feof(fp)) || ferror(fp) ){ + return traits::eof(); + } + + return traits::to_int_type(*basic_streambuf::gptr()); + } + virtual _UCXXEXPORT int_type uflow(){ + bool dobump = (basic_streambuf::gptr() != 0); + int_type retval = underflow(); + if(dobump){ + basic_streambuf::gbump(1); + } + return retval; + } + virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ + if(is_open() == false || + basic_streambuf::gptr() == basic_streambuf::eback()) + { + return traits::eof(); + } + if(traits::eq_int_type(c,traits::eof()) == false){ + if(traits::eq(traits::to_char_type(c), basic_streambuf::gptr()[-1]) == true){ + basic_streambuf::gbump(-1); + }else{ + basic_streambuf::gbump(-1); + basic_streambuf::gptr()[0] = c; + } + return c; + }else{ + basic_streambuf::gbump(-1); + return traits::not_eof(c); + } + } + + virtual _UCXXEXPORT int_type overflow(int_type c = traits::eof()){ + if(is_open() == false){ + //Can't do much + return traits::eof(); + } + if(basic_streambuf::pbase() == 0){ //Unbuffered - elliminate dupe code below + if(fputc(c, fp) == EOF){ + return traits::eof(); + } + return c; + } + if(basic_streambuf::pbase() == 0 && traits::eq_int_type(c,traits::eof()) ){ + //Nothing to flush + return traits::not_eof(c); + } + size_t r = basic_streambuf::pptr() - basic_streambuf::pbase(); + + if( r == 0 && traits::eq_int_type(c,traits::eof()) ){ + return traits::not_eof(c); + }else if (r == 0 ){ + if(fputc(c, fp) == EOF){ + return traits::eof(); + } + return c; + } + + size_t totalChars = r; + + char_type *buffer = 0; + if(traits::eq_int_type(c,traits::eof())){ + buffer = new char_type[r]; + }else{ + buffer = new char_type[r+1]; + buffer[r] = c; + totalChars++; + } + + traits::copy(buffer, basic_streambuf::pbase(), r); +// memcpy(buffer, basic_streambuf::pbase(), r); + + size_t retval = fwrite(buffer, sizeof(charT), totalChars, fp); + if(retval !=totalChars){ + if(retval == 0){ + delete [] buffer; + return traits::eof(); + } + basic_streambuf::pbump(-retval); + fprintf(stderr, "***** Did not write the full buffer out. Should be: %d, actually: %d\n", + totalChars, retval); + }else{ + basic_streambuf::pbump(-r); + } + + delete [] buffer; + return traits::not_eof(c); + } + + virtual _UCXXEXPORT basic_streambuf* setbuf(char_type* s, streamsize n){ + if(s == 0 && n == 0){ //Unbuffered + if(pbuffer !=0){ + delete [] pbuffer; + pbuffer = 0; + } + if(gbuffer !=0){ + delete [] gbuffer; + gbuffer = 0; + } + }else if(basic_streambuf::gptr() !=0 && + basic_streambuf::gptr()==basic_streambuf::egptr()) + { + delete [] pbuffer; + pbuffer = s; + } + return this; + } + virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, + ios_base::openmode = ios_base::in | ios_base::out) + { + if(is_open() == false){ + return -1; + } + int whence = SEEK_SET; // if(way == basic_ios::beg) + off_type position = off; + + if(way == basic_ios::cur){ + whence = SEEK_CUR; + position -= (basic_streambuf::egptr() - basic_streambuf::gptr()); + }else if(way == basic_ios::end){ + whence = SEEK_END; + } + + sync(); + + int retval = fseek( + fp, + sizeof(charT)*(position), + whence + ); + + //Invalidate read buffer + basic_streambuf::gbump( + basic_streambuf::egptr() - basic_streambuf::gptr() + ); + + if(-1 != retval){ + retval = ftell(fp); + } + + return retval; + } + virtual _UCXXEXPORT pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in | ios_base::out){ + if(is_open() == false){ + return -1; + } + sync(); + + int retval = fseek(fp,sizeof(charT)* sp, SEEK_SET); + + //Invalidate read buffer + basic_streambuf::gbump(basic_streambuf::egptr() - basic_streambuf::gptr()); + if(retval > -1){ + return sp; + } + return -1; + } + virtual _UCXXEXPORT int sync(){ + if(pbuffer !=0){ + if(overflow() == traits::eof()){ + return -1; + } + } + if(0 != fp && 0 != fflush(fp)){ + return -1; + } + return 0; + } + virtual _UCXXEXPORT void imbue(const locale&){ + return; + } + + + virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ + if(is_open() == false){ + return 0; + } + //Check to see if buffered + + //Check to see if we can buffer the data + streamsize buffer_avail = basic_streambuf::epptr() - basic_streambuf::pptr(); + + if(n > buffer_avail){ //Flush buffer and write directly + overflow(); //Flush the buffer + return fwrite(s, sizeof(charT), n, fp); + } + + //Add to buffer to be written later + + traits::copy(basic_streambuf::pptr(), s, n); + basic_streambuf::pbump(n); + + return n; + } + + FILE * fp; + char_type * pbuffer; + char_type * gbuffer; + bool append; + }; + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::overflow(int_type c); + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::underflow(); + +#endif //__UCLIBCXX_HAS_WCHAR__ + + + +#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_FSTREAM__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT filebuf::basic_filebuf(); + template <> _UCXXEXPORT filebuf::~basic_filebuf(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT filebuf::int_type filebuf::pbackfail(filebuf::int_type c); + template <> _UCXXEXPORT filebuf * filebuf::open(const char* s, ios_base::openmode mode); + template <> _UCXXEXPORT filebuf * filebuf::close(); + template <> _UCXXEXPORT filebuf::int_type filebuf::overflow(filebuf::int_type c); + template <> _UCXXEXPORT filebuf::int_type filebuf::underflow (); + + template <> _UCXXEXPORT basic_streambuf > * filebuf::setbuf(char * s, streamsize n); + template <> _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n); + +#endif +#endif + + + template class _UCXXEXPORT basic_ifstream + : public basic_istream + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + _UCXXEXPORT basic_ifstream(): basic_ios(&sb), basic_istream(&sb){ + //Passing the address of sb + } + explicit _UCXXEXPORT basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in) + : basic_ios(&sb), basic_istream(&sb) + { + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + + virtual _UCXXEXPORT ~basic_ifstream(){ + + } + + _UCXXEXPORT basic_filebuf* rdbuf() const{ + return (basic_filebuf*)&sb; + } + _UCXXEXPORT bool is_open() const{ + return sb.is_open(); + } + _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::in){ + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + _UCXXEXPORT void close(){ + sb.close(); + } + private: + basic_filebuf sb; + }; + + + template class _UCXXEXPORT basic_ofstream + : public basic_ostream + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + _UCXXEXPORT basic_ofstream() : basic_ios(&sb), basic_ostream(&sb){ + + } + + virtual _UCXXEXPORT ~basic_ofstream(); + + explicit _UCXXEXPORT basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out | ios_base::trunc) : + basic_ios(&sb), basic_ostream(&sb) + { + if(sb.open(s, mode | ios_base::out ) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + + _UCXXEXPORT basic_filebuf* rdbuf() const{ + return (basic_filebuf*)&sb; + } + + _UCXXEXPORT bool is_open() const{ + return sb.is_open(); + } + _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::out | ios_base::trunc){ + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + _UCXXEXPORT void close(){ + sb.close(); + } + private: + basic_filebuf sb; + }; + + template _UCXXEXPORT basic_ofstream::~basic_ofstream(){ + basic_ostream::flush(); + } + + + template class _UCXXEXPORT basic_fstream + : public basic_iostream + { + public: + typedef charT char_type; + typedef typename traits::int_type ins_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + _UCXXEXPORT basic_fstream(): basic_ios(&sb), basic_iostream(&sb){ } + + explicit _UCXXEXPORT basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out): + basic_ios(&sb), basic_iostream(&sb) + { + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + + _UCXXEXPORT basic_filebuf* rdbuf() const{ + return (basic_filebuf*)&sb; + } + _UCXXEXPORT bool is_open() const{ + return sb.is_open(); + } + _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out){ + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + _UCXXEXPORT void close(){ + sb.close(); + } + private: + basic_filebuf sb; + }; + + + +#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_FSTREAM__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_ofstream >::basic_ofstream(); + template <> _UCXXEXPORT basic_ofstream >::basic_ofstream(const char* s, ios_base::openmode mode); + template <> _UCXXEXPORT basic_ofstream >::~basic_ofstream(); + + template <> _UCXXEXPORT basic_ifstream >::basic_ifstream(); + template <> _UCXXEXPORT basic_ifstream >::basic_ifstream(const char* s, ios_base::openmode mode); + template <> _UCXXEXPORT basic_ifstream >::~basic_ifstream(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + +#endif +#endif + + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/func_exception b/include/func_exception new file mode 100644 index 0000000..1b7bdd8 --- /dev/null +++ b/include/func_exception @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include + + +#ifndef HEADER_IMPLEMENTATION_FUNC_EXCEPTION +#define HEADER_IMPLEMENTATION_FUNC_EXCEPTION + +#pragma GCC visibility push(default) + +namespace std{ + + _UCXXEXPORT void __throw_bad_alloc(); + _UCXXEXPORT void __throw_out_of_range(const char * message = 0); + _UCXXEXPORT void __throw_overflow_error(const char * message = 0); + _UCXXEXPORT void __throw_length_error(const char * message = 0); + _UCXXEXPORT void __throw_invalid_argument(const char * message = 0); +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/functional b/include/functional new file mode 100644 index 0000000..ae9ed4b --- /dev/null +++ b/include/functional @@ -0,0 +1,439 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + 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 +*/ + + +#ifndef __STD_HEADER_FUNCTIONAL +#define __STD_HEADER_FUNCTIONAL 1 + +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template struct unary_function; + template struct binary_function; + + template struct plus; + template struct minus; + template struct multiplies; + template struct divides; + template struct modulus; + template struct negate; + + template struct equal_to; + template struct not_equal_to; + template struct greater; + template struct less; + template struct greater_equal; + template struct less_equal; + + template struct logical_and; + template struct logical_or; + template struct logical_not; + + template struct unary_negate; + template unary_negate not1(const Predicate&); + template struct binary_negate; + template binary_negate not2(const Predicate&); + + + template class binder1st; + template binder1st bind1st(const Operation&, const T&); + template class binder2nd; + template binder2nd bind2nd(const Operation&, const T&); + + template class pointer_to_unary_function; + template pointer_to_unary_function ptr_fun(Result (*)(Arg)); + template class pointer_to_binary_function; + template + pointer_to_binary_function ptr_fun(Result (*)(Arg1,Arg2)); + + template class mem_fun_t; + template class mem_fun1_t; + template class const_mem_fun_t; + template class const_mem_fun1_t; + template mem_fun_t mem_fun(S (T::*f)()); + template mem_fun1_t mem_fun(S (T::*f)(A)); + template class mem_fun_ref_t; + template class mem_fun1_ref_t; + template mem_fun_ref_t mem_fun_ref(S (T::*f)()); + template mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)); + + //Implementation + + template struct _UCXXEXPORT unary_function{ + typedef Arg argument_type; + typedef Result result_type; + }; + + + template struct _UCXXEXPORT binary_function{ + typedef Arg1 first_argument_type; + typedef Arg2 second_argument_type; + typedef Result result_type; + }; + + template struct _UCXXEXPORT plus : binary_function{ + T operator()(const T& x, const T& y) const{ + return x + y; + } + }; + + template struct _UCXXEXPORT minus : binary_function{ + T operator()(const T& x, const T& y) const{ + return x - y; + } + }; + + template struct _UCXXEXPORT multiplies : binary_function{ + T operator()(const T& x, const T& y) const{ + return x * y; + } + }; + + template struct _UCXXEXPORT divides : binary_function{ + T operator()(const T& x, const T& y) const{ + return x / y; + } + }; + + template struct _UCXXEXPORT modulus : binary_function{ + T operator()(const T& x, const T& y) const{ + return x % y; + } + }; + + template struct _UCXXEXPORT negate : unary_function{ + T operator()(const T& x) const{ + return -x; + } + }; + + template struct _UCXXEXPORT equal_to : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x == y); + } + }; + + template struct _UCXXEXPORT not_equal_to : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x != y); + } + }; + + template struct _UCXXEXPORT greater : binary_function{ + bool operator()(const T& x, const T& y) const _UCXX_NOTHROW { + return (x > y); + } + }; + + template struct _UCXXEXPORT less : binary_function{ + bool operator()(const T& x, const T& y) const _UCXX_NOTHROW { + return (x < y); + } + }; + + template struct _UCXXEXPORT greater_equal : binary_function{ + bool operator()(const T& x, const T& y) const _UCXX_NOTHROW { + return (x >= y); + } + }; + + template struct _UCXXEXPORT less_equal : binary_function{ + bool operator()(const T& x, const T& y) const _UCXX_NOTHROW { + return (x <= y); + } + }; + + template struct _UCXXEXPORT logical_and : binary_function { + bool operator()(const T& x, const T& y) const{ + return (x && y); + } + }; + + template struct _UCXXEXPORT logical_or : binary_function { + bool operator()(const T& x, const T& y) const{ + return (x || y); + } + }; + + template struct _UCXXEXPORT logical_not : unary_function { + bool operator()(const T& x) const{ + return !x; + } + }; + + template class _UCXXEXPORT unary_negate + : public unary_function + { + public: + explicit unary_negate(const Predicate& pred) : p(pred) { } + bool operator()(const typename Predicate::argument_type& x) const{ + return !p(x); + } + private: + Predicate p; + }; + + + template _UCXXEXPORT unary_negate not1(const Predicate& pred){ + return unary_negate(pred); + } + + + template class _UCXXEXPORT binary_negate : public + binary_function + { + public: + explicit binary_negate(const Predicate& pred) : p(pred) { } + bool operator()(const typename Predicate::first_argument_type& x, + const typename Predicate::second_argument_type& y) const + { + return !p(x, y); + } + private: + Predicate p; + }; + + + template _UCXXEXPORT binary_negate not2(const Predicate& pred){ + return binary_negate(pred); + } + + + template class _UCXXEXPORT binder1st + : public unary_function + { + protected: + Operation op; + typename Operation::first_argument_type value; + public: + binder1st(const Operation& x, const typename Operation::first_argument_type& y) : op(x), value(y){ } + typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const{ + return op(value,x); + } + }; + + + template _UCXXEXPORT binder1st bind1st(const Operation& op, const T& x){ + return binder1st(op, typename Operation::first_argument_type(x)); + } + + + template class _UCXXEXPORT binder2nd + : public unary_function + { + protected: + Operation op; + typename Operation::second_argument_type value; + public: + binder2nd(const Operation& x, const typename Operation::second_argument_type& y) : op(x), value(y) { } + typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const{ + return op(x,value); + } + }; + + + template _UCXXEXPORT + binder2nd bind2nd(const Operation& op, const T& x) + { + return binder2nd(op, typename Operation::second_argument_type(x)); + } + + + template class _UCXXEXPORT + pointer_to_unary_function : public unary_function + { + protected: + Result (*func)(Arg); + public: + explicit pointer_to_unary_function(Result (*f)(Arg)) : func(f) { } + Result operator()(Arg x) const{ + return func(x); + } + }; + + + template _UCXXEXPORT pointer_to_unary_function ptr_fun(Result (*f)(Arg)){ + return pointer_to_unary_function(f); + } + + + template class _UCXXEXPORT + pointer_to_binary_function : public binary_function + { + protected: + Result (*func)(Arg1, Arg2); + public: + explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : func(f) { } + Result operator()(Arg1 x, Arg2 y) const{ + return func(x, y); + } + }; + + template _UCXXEXPORT + pointer_to_binary_function ptr_fun(Result (*f)(Arg1, Arg2)) + { + return pointer_to_binary_function(f); + } + + + template class _UCXXEXPORT mem_fun_t + : public unary_function + { + public: + explicit mem_fun_t(S (T::*p)()) : m(p) { } + S operator()(T* p) const { return (p->*m)(); } + private: + S (T::*m)(); + }; + + + template class _UCXXEXPORT mem_fun1_t + : public binary_function + { + public: + explicit mem_fun1_t(S (T::*p)(A)) : m(p) { } + S operator()(T* p, A x) const { return (p->*m)(x); } + private: + S (T::*m)(A); + }; + + + template class _UCXXEXPORT const_mem_fun_t + : public unary_function + { + public: + explicit const_mem_fun_t(S (T::*p)() const) : m(p) { } + S operator()(const T* p) const { return (p->*m)(); } + private: + S (T::*m)() const; + }; + + + template class _UCXXEXPORT const_mem_fun1_t + : public binary_function + { + public: + explicit const_mem_fun1_t(S (T::*p)(A) const) : m(p) { } + S operator()(const T* p, A x) const { return (p->*m)(x); } + private: + S (T::*m)(A) const; + }; + + + template _UCXXEXPORT mem_fun_t mem_fun(S (T::*f)()){ + return mem_fun_t(f); + } + + template _UCXXEXPORT const_mem_fun_t mem_fun(S (T::*f)() const){ + return const_mem_fun_t(f); + } + + template _UCXXEXPORT mem_fun1_t mem_fun(S (T::*f)(A)){ + return mem_fun1_t(f); + } + + template _UCXXEXPORT const_mem_fun1_t mem_fun(S (T::*f)(A) const){ + return const_mem_fun1_t(f); + } + + template class _UCXXEXPORT mem_fun_ref_t + : public unary_function + { + public: + explicit mem_fun_ref_t(S (T::*p)()) : mf(p) { } + S operator()(T& p) { return (p.*mf)(); } + private: + S (T::*mf)(); + }; + + template class _UCXXEXPORT mem_fun1_ref_t + : public binary_function + { + public: + explicit mem_fun1_ref_t(S (T::*p)(A)) : mf(p) { } + S operator()(T& p, A x) { return (p.*mf)(x); } + private: + S (T::*mf)(A); + }; + + template _UCXXEXPORT mem_fun_ref_t mem_fun_ref(S (T::*f)()){ + return mem_fun_ref_t(f); + } + + template _UCXXEXPORT mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)){ + return mem_fun1_ref_t(f); + } + + +} + + +//These are SGI extensions which are checked for by some conformance checks. They +// are *NOT* part of the C++ standard, however + +template class _UCXXEXPORT unary_compose : + public std::unary_function +{ +protected: + Op1 mf1; + Op2 mf2; +public: + unary_compose(const Op1& x, const Op2& y) : mf1(x), mf2(y) { } + typename Op1::result_type operator()(const typename Op2::argument_type& x) const { + return mf1(mf2(x)); + } +}; + +template _UCXXEXPORT +inline unary_compose +compose1(const Op1& fn1, const Op2& fn2){ + return unary_compose(fn1, fn2); +} + +template class _UCXXEXPORT binary_compose : + public std::unary_function +{ +protected: + Op1 mf1; + Op2 mf2; + Op3 mf3; +public: + binary_compose(const Op1 & x, const Op2 & y, const Op3 & z) + : mf1(x), mf2(y), mf3(z){ } + typename Op1::result_type operator()(const typename Op2::argument_type & x) const { + return mf1(mf2(x), mf3(x)); + } +}; + +template inline _UCXXEXPORT binary_compose +compose2(const Op1 & fn1, const Op2 & fn2, const Op3 & fn3){ + return binary_compose(fn1, fn2, fn3); +} + +#pragma GCC visibility pop + +#endif + + + diff --git a/include/iomanip b/include/iomanip new file mode 100644 index 0000000..14a8260 --- /dev/null +++ b/include/iomanip @@ -0,0 +1,170 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include + +#ifndef __STD_IOMANIP +#define __STD_IOMANIP 1 + +#pragma GCC visibility push(default) + +namespace std{ + +// These are the helper classes which we are going to be using to +// hold the required data + +class _UCXXEXPORT __resetiosflags{ +public: + ios_base::fmtflags m; + _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ } +}; + +class _UCXXEXPORT __setiosflags{ +public: + ios_base::fmtflags m; + _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ } +}; + +class _UCXXEXPORT __setbase{ +public: + int base; + _UCXXEXPORT __setbase(int b) : base(b){ } +}; + +class _UCXXEXPORT __setfill{ +public: + int character; + _UCXXEXPORT __setfill(int c): character(c){ } +}; + +class _UCXXEXPORT __setprecision{ +public: + int digits; + _UCXXEXPORT __setprecision(int n): digits(n) { } +}; + +class _UCXXEXPORT __setw{ +public: + int width; + _UCXXEXPORT __setw(int n): width(n) { } +}; + + +//Actual manipulator functions + +inline __resetiosflags resetiosflags(ios_base::fmtflags mask){ + return __resetiosflags(mask); +} + +inline __setiosflags setiosflags(ios_base::fmtflags mask){ + return __setiosflags(mask); +} + +inline __setbase setbase(int b){ + return __setbase(b); +} + +inline __setfill setfill(int c){ + return __setfill(c); +} + +inline __setprecision setprecision(int n){ + return __setprecision(n); +} + +inline __setw setw(int n){ + return __setw(n); +} + + +//How to handle interaction with [i|o]stream classes + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __resetiosflags s) +{ + os.setf(ios_base::fmtflags(0),s.m); + return os; +} + +template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, const __resetiosflags s) +{ + is.setf(ios_base::fmtflags(0),s.m); + return is; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setiosflags s) +{ + os.setf(s.m); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setbase s) +{ + ios_base::fmtflags f(0); + switch(s.base){ + case 8: + f = ios_base::oct; + break; + case 10: + f = ios_base::dec; + break; + case 16: + f = ios_base::hex; + break; + default: + break; + + } + os.setf(f, ios_base::basefield); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setfill s) +{ + os.fill(s.character); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setprecision s) +{ + os.precision(s.digits); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setw s) +{ + os.width(s.width); + return os; +} + + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/ios b/include/ios new file mode 100644 index 0000000..ac6566a --- /dev/null +++ b/include/ios @@ -0,0 +1,503 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include + +#ifndef __HEADER_STD_IOS +#define __HEADER_STD_IOS 1 + +#pragma GCC visibility push(default) + +namespace std{ + typedef signed long int streamoff; + + template class fpos; + + class _UCXXEXPORT ios_base { + public: + class failure; +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + class failure : public exception { + public: + explicit failure(const std::string&) { } + explicit failure() { } + virtual const char* what() const _UCXX_USE_NOEXCEPT { + return "std::ios_base failure exception"; + } + }; +#endif +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + class _UCXXLOCAL Init{ + public: + _UCXXEXPORT Init(); + _UCXXEXPORT ~Init(); + private: + static int init_cnt; + }; +#endif + + public: + + typedef unsigned short int fmtflags; + + static const fmtflags skipws = 0x0001; + + static const fmtflags left = 0x0002; + static const fmtflags right = 0x0004; + static const fmtflags internal = 0x0008; + + static const fmtflags boolalpha = 0x0010; + + static const fmtflags dec = 0x0020; + static const fmtflags oct = 0x0040; + static const fmtflags hex = 0x0080; + + static const fmtflags scientific = 0x0100; + static const fmtflags fixed = 0x0200; + + static const fmtflags showbase = 0x0400; + static const fmtflags showpoint = 0x0800; + static const fmtflags showpos = 0x1000; + static const fmtflags uppercase = 0x2000; + + static const fmtflags adjustfield = left | right | internal; + static const fmtflags basefield = dec | oct | hex; + static const fmtflags floatfield = fixed | scientific; + + static const fmtflags unitbuf = 0x4000; + + typedef unsigned char iostate; + static const iostate goodbit = 0x00; + static const iostate badbit = 0x01; + static const iostate eofbit = 0x02; + static const iostate failbit = 0x04; + + typedef unsigned char openmode; + static const openmode app = 0x01; + static const openmode ate = 0x02; + static const openmode binary = 0x04; + static const openmode in = 0x08; + static const openmode out = 0x10; + static const openmode trunc = 0x20; + + typedef unsigned char seekdir; + static const seekdir beg = 0x01; + static const seekdir cur = 0x02; + static const seekdir end = 0x04; + + _UCXXEXPORT fmtflags flags() const{ + return mformat; + } + _UCXXEXPORT fmtflags flags(fmtflags fmtfl); + + fmtflags setf(fmtflags fmtfl); + fmtflags setf(fmtflags fmtfl, fmtflags mask ); + + _UCXXEXPORT void unsetf(fmtflags mask){ + mformat&= ~mask; + } + + _UCXXEXPORT streamsize precision() const{ + return mprecision; + } + + _UCXXEXPORT streamsize precision(streamsize prec); + + _UCXXEXPORT streamsize width() const{ + return mwidth; + } + + _UCXXEXPORT streamsize width(streamsize wide); + + _UCXXEXPORT locale imbue(const locale& loc); + + _UCXXEXPORT locale getloc() const{ + return mLocale; + } + +// FIXME - These need to be implemented +// static int xalloc(); +// long& iword(int index); +// void*& pword(int index); + + enum event { erase_event, imbue_event, copyfmt_event }; + + typedef void (*event_callback)(event, ios_base&, int index); +// void register_callback(event_call_back fn, int index); + + virtual _UCXXEXPORT ~ios_base() { + /* would run erase_event callbacks here */ + } + + //We are going to wrap stdio so we don't need implementation of the following: + inline static bool sync_with_stdio(bool = true) { return true; } + + protected: + _UCXXEXPORT ios_base() : mLocale(), mformat(dec | skipws ), mstate(goodbit), + mmode(), mdir(), mprecision(6), mwidth(0) +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + ,mInit() +#endif + { + + } + locale mLocale; + fmtflags mformat; + iostate mstate; + openmode mmode; + seekdir mdir; + streamsize mprecision; + streamsize mwidth; +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + Init mInit; +#endif + }; + + + //ios_base manipulators + + + inline ios_base& boolalpha (ios_base& str){ + str.setf(ios_base::boolalpha); + return str; + } + inline ios_base& noboolalpha(ios_base& str){ + str.unsetf(ios_base::boolalpha); + return str; + } + inline ios_base& showbase (ios_base& str){ + str.setf(ios_base::showbase); + return str; + } + inline ios_base& noshowbase (ios_base& str){ + str.unsetf(ios_base::showbase); + return str; + } + inline ios_base& showpoint (ios_base& str){ + str.setf(ios_base::showpoint); + return str; + } + inline ios_base& noshowpoint(ios_base& str){ + str.unsetf(ios_base::showpoint); + return str; + } + inline ios_base& showpos (ios_base& str){ + str.setf(ios_base::showpos); + return str; + } + inline ios_base& noshowpos (ios_base& str){ + str.unsetf(ios_base::showpos); + return str; + } + inline ios_base& skipws (ios_base& str){ + str.setf(ios_base::skipws); + return str; + } + inline ios_base& noskipws (ios_base& str){ + str.unsetf(ios_base::skipws); + return str; + } + inline ios_base& uppercase (ios_base& str){ + str.setf(ios_base::uppercase); + return str; + } + inline ios_base& nouppercase(ios_base& str){ + str.unsetf(ios_base::uppercase); + return str; + } + + inline ios_base& unitbuf (ios_base& str){ + str.setf(ios_base::unitbuf); + return str; + } + inline ios_base& nounitbuf (ios_base& str){ + str.unsetf(ios_base::unitbuf); + return str; + } + inline ios_base& internal (ios_base& str){ + str.setf(ios_base::internal, ios_base::adjustfield); + return str; + } + inline ios_base& left (ios_base& str){ + str.setf(ios_base::left, ios_base::adjustfield); + return str; + } + inline ios_base& right (ios_base& str){ + str.setf(ios_base::right, ios_base::adjustfield); + return str; + } + + inline ios_base& dec (ios_base& str){ + str.setf(ios_base::dec, ios_base::basefield); + return str; + } + inline ios_base& hex (ios_base& str){ + str.setf(ios_base::hex, ios_base::basefield); + return str; + } + inline ios_base& oct (ios_base& str){ + str.setf(ios_base::oct, ios_base::basefield); + return str; + } + + inline ios_base& fixed (ios_base& str){ + str.setf(ios_base::fixed, ios_base::floatfield); + return str; + } + inline ios_base& scientific (ios_base& str){ + str.setf(ios_base::scientific, ios_base::floatfield); + return str; + } + + + //basic_ios class definition + + + template class _UCXXEXPORT basic_ios + : public ios_base + { + public: + // Types: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + _UCXXEXPORT operator void*() const{ + if(fail() ){ + return 0; + } + return (void *)(1); //Must return a non-NULL pointer (though it can be *any* pointer) + } + + _UCXXEXPORT bool operator!() const{ + return fail(); + } + _UCXXEXPORT iostate rdstate() const{ + return mstate; + } + _UCXXEXPORT void clear(iostate state = goodbit){ + if(rdbuf()!=0){ + mstate = state; + }else{ + mstate = state|ios_base::badbit; + } + } + _UCXXEXPORT void setstate(iostate state) { + clear(rdstate() | state); +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + if(rdstate() & throw_mask){ + throw failure(); + } +#endif + } + + _UCXXEXPORT bool good() const{ + return (rdstate() == 0); + } + _UCXXEXPORT bool eof() const{ + if(rdstate() & eofbit){ + return true; + } + return false; + } + _UCXXEXPORT bool fail() const{ + if( mstate & (failbit | badbit) ){ + return true; + } + return false; + } + + _UCXXEXPORT bool bad() const{ + if(mstate & badbit){ + return true; + } + return false; + } + + _UCXXEXPORT iostate exceptions() const{ + return throw_mask; + } + _UCXXEXPORT void exceptions(iostate except){ + throw_mask = except; + } + + explicit _UCXXEXPORT basic_ios(basic_streambuf* sb) + : fill_char(' '), mtied(0), mstreambuf(0), throw_mask(0) { + init(sb); + } + + basic_ios() : mtied(0), mstreambuf(0){ } + + virtual _UCXXEXPORT ~basic_ios(){ + } + + _UCXXEXPORT basic_ostream* tie() const{ + return mtied; + } + _UCXXEXPORT basic_ostream* tie(basic_ostream* tiestr){ + basic_ostream* retval= mtied; + mtied = tiestr; + return retval; + } + _UCXXEXPORT basic_streambuf* rdbuf() const{ + return mstreambuf; + } + _UCXXEXPORT basic_streambuf* rdbuf(basic_streambuf* sb){ + basic_streambuf* retval = mstreambuf; + mstreambuf = sb; + return retval; + } + _UCXXEXPORT basic_ios& copyfmt(const basic_ios& rhs); + _UCXXEXPORT char_type fill() const{ + return fill_char; + } + _UCXXEXPORT char_type fill(char_type ch){ + char_type temp = fill_char; + fill_char = ch; + return temp; + } + + _UCXXEXPORT locale imbue(const locale& loc){ + return ios_base::imbue(loc); + } + _UCXXEXPORT char narrow(char_type c, char dfault) const; + _UCXXEXPORT char_type widen(char c) const; + + protected: + char_type fill_char; + basic_ostream* mtied; + basic_streambuf* mstreambuf; + iostate throw_mask; + _UCXXEXPORT basic_ios(const basic_ios &){ } + _UCXXEXPORT basic_ios & operator=(const basic_ios &){ return *this; } + _UCXXEXPORT void init(basic_streambuf* sb){ + ios_base::mformat = skipws|dec; + mstreambuf = sb; + mstate = goodbit; + throw_mask = goodbit; + } + }; + +#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ +#ifndef __UCLIBCXX_COMPILE_IOS__ + + template <> _UCXXEXPORT void basic_ios >::clear(iostate state); + template <> _UCXXEXPORT void basic_ios >::setstate(iostate state); + +#endif +#endif + + + template + inline char basic_ios::narrow(char_type c, char dfault) const + { + return dfault; + } + + template <> + inline char basic_ios >::narrow(char_type c, char) const + { + return c; + } + +#ifdef __UCLIBCXX_HAS_WCHAR__ + + template <> + inline char basic_ios >::narrow(char_type c, char dfault) const + { + char retval = wctob (c); + if(retval == EOF){ + retval = dfault; + } + return retval; + } + +#endif //__UCLIBCXX_HAS_WCHAR__ + + template + inline typename basic_ios::char_type + basic_ios::widen(char c) const + { + return c; + } + + template <> + inline basic_ios >::char_type + basic_ios >::widen(char c) const + { + return c; + } + +#ifdef __UCLIBCXX_HAS_WCHAR__ + + template <> + inline basic_ios >::char_type + basic_ios >::widen(char c) const + { + return btowc(c); + } + +#endif //__UCLIBCXX_HAS_WCHAR__ + + + template class _UCXXEXPORT fpos{ + public: + _UCXXEXPORT fpos(stateT s){ + st = s; + } + _UCXXEXPORT stateT state() const{ + return st; + } + _UCXXEXPORT void state(stateT s){ + st = s; + } + _UCXXEXPORT bool operator==(const fpos &rhs){ + return st == rhs.st; + } + _UCXXEXPORT bool operator!=(const fpos &rhs){ + return st != rhs.st; + } + _UCXXEXPORT fpos & operator+(const streamoff & o){ + st += o; + return *this; + } + _UCXXEXPORT fpos & operator-(const streamoff & o){ + st -= o; + return *this; + } + _UCXXEXPORT streamoff operator-(const fpos & rhs){ + return st - rhs.st; + } + + private: + stateT st; + }; + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/iosfwd b/include/iosfwd new file mode 100644 index 0000000..2c14725 --- /dev/null +++ b/include/iosfwd @@ -0,0 +1,114 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + + +#ifndef __HEADER_STD_IOSFWD +#define __HEADER_STD_IOSFWD 1 + +#pragma GCC visibility push(default) + +namespace std { + class ios_base; + template<> class char_traits; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template<> class char_traits; +#endif + + template > class basic_ios; + + template > class basic_streambuf; + template > class basic_istream; + template > class basic_ostream; + template > class basic_iostream; + + template , + class Allocator = allocator > class basic_stringbuf; + + template , + class Allocator = allocator > class basic_istringstream; + + template , + class Allocator = allocator > class basic_ostringstream; + + template , + class Allocator = allocator > class basic_stringstream; + + template > class basic_filebuf; + + template > class basic_ifstream; + + template > class basic_ofstream; + + template > class basic_fstream; + + template > class basic_istreambuf_iterator; + + template > class basic_ostreambuf_iterator; + + typedef basic_ios ios; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_ios wios; +#endif + + typedef basic_streambuf streambuf; + typedef basic_istream istream; + typedef basic_ostream ostream; + typedef basic_iostream iostream; + + typedef basic_stringbuf stringbuf; + typedef basic_istringstream istringstream; + typedef basic_ostringstream ostringstream; + typedef basic_stringstream stringstream; + + typedef basic_filebuf filebuf; + typedef basic_ifstream ifstream; + typedef basic_ofstream ofstream; + typedef basic_fstream fstream; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_streambuf wstreambuf; + typedef basic_istream wistream; + typedef basic_ostream wostream; + typedef basic_iostream wiostream; + + typedef basic_stringbuf wstringbuf; + typedef basic_istringstream wistringstream; + typedef basic_ostringstream wostringstream; + typedef basic_stringstream wstringstream; + + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_ofstream wofstream; + typedef basic_fstream wfstream; +#endif + + template class fpos; + typedef fpos::state_type> streampos; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef fpos::state_type> wstreampos; +#endif +} + +#pragma GCC visibility pop + +#endif diff --git a/include/iostream b/include/iostream new file mode 100644 index 0000000..f93987f --- /dev/null +++ b/include/iostream @@ -0,0 +1,101 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef __HEADER_STD_IOSTREAM +#define __HEADER_STD_IOSTREAM 1 + +#include +#include +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +namespace std{ +#ifdef __UCLIBCXX_SUPPORT_CIN__ + extern istream cin; +#endif +#ifdef __UCLIBCXX_SUPPORT_COUT__ + extern ostream cout; +#endif +#ifdef __UCLIBCXX_SUPPORT_CERR__ + extern ostream cerr; +#endif +#ifdef __UCLIBCXX_SUPPORT_CLOG__ + extern ostream clog; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + extern wistream wcin; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + extern wostream wcout; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + extern wostream wcerr; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + extern wostream wclog; +#endif + + + template class _UCXXEXPORT basic_iostream : + public basic_istream, public basic_ostream + { + public: + // constructor/destructor + explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); + virtual _UCXXEXPORT ~basic_iostream(); //Below + }; + + template _UCXXEXPORT + basic_iostream:: basic_iostream(basic_streambuf* sb) + : basic_ios(sb), basic_istream(sb), basic_ostream(sb) + { + return; + } + + + template _UCXXEXPORT basic_iostream::~basic_iostream(){ + return; + } + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_IOSTREAM__ + + template <> _UCXXEXPORT basic_iostream >:: + basic_iostream(basic_streambuf >* sb); + template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); + +#endif +#endif +#endif + + + +} + +#pragma GCC visibility pop + +#endif diff --git a/include/istream b/include/istream new file mode 100644 index 0000000..72a8834 --- /dev/null +++ b/include/istream @@ -0,0 +1,631 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc C++ Library. This library is free + software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) + any later version. + + This 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this library; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. +*/ + +#include +#include +#include +#include +#include + +#ifndef __STD_HEADER_ISTREAM +#define __STD_HEADER_ISTREAM 1 + +#pragma GCC visibility push(default) + +namespace std{ + + typedef basic_istream istream; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_istream wistream; +#endif + + template basic_istream& ws(basic_istream& is); + + template class _UCXXEXPORT basic_istream : + virtual public basic_ios + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef basic_streambuf streambuf_type; + typedef traits traits_type; + + explicit basic_istream(basic_streambuf* sb) + : basic_ios(sb), count_last_ufmt_input(0) + { + basic_ios::init(sb); + } + virtual ~basic_istream() { } + + class sentry; + + basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); + basic_istream& operator>>(basic_ios& (*pf)(basic_ios&)); + basic_istream& operator>>(ios_base& (*pf)(ios_base&)); + basic_istream& operator>>(bool& n); + basic_istream& operator>>(short& n); + basic_istream& operator>>(unsigned short& n); + basic_istream& operator>>(int& n); + basic_istream& operator>>(unsigned int& n); + basic_istream& operator>>(long& n); + basic_istream& operator>>(unsigned long& n); + basic_istream& operator>>(void*& p); + basic_istream& operator>>(basic_streambuf* sb); + +#ifndef __STRICT_ANSI__ + basic_istream& operator>>(long long& n); + basic_istream& operator>>(unsigned long long& n); +#endif + +#ifdef __UCLIBCXX_HAS_FLOATS__ + basic_istream& operator>>(float& f); + basic_istream& operator>>(double& f); + basic_istream& operator>>(long double& f); +#endif + + _UCXXEXPORT streamsize gcount() const{ + return count_last_ufmt_input; + } + + _UCXXEXPORT int_type get(); //below + _UCXXEXPORT basic_istream& get(char_type& c); //Below + + _UCXXEXPORT basic_istream& get(char_type* s, streamsize n){ + return get(s, n, basic_ios::widen('\n')); + } + + _UCXXEXPORT basic_istream& get(char_type* s, streamsize n, char_type delim){ + sentry(*this, true); + streamsize i = 0; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + basic_ios::mstreambuf->sbumpc(); + if(c == traits::eof() ){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + }else{ + basic_ios::setstate(ios_base::eofbit); + } + break; + } + if(c == delim){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + } + basic_ios::mstreambuf->sputbackc(c); + break; + } + s[i] = c; + } + s[i] = traits::eos(); + count_last_ufmt_input = i; + return *this; + } + + _UCXXEXPORT basic_istream& get(basic_streambuf& sb){ + return get(sb, basic_ios::widen('\n')); + } + + _UCXXEXPORT basic_istream& get(basic_streambuf& sb, char_type delim){ + sentry(*this, true); + streamsize i = 0; + int_type c; + while(1){ //We will exit internally based upon error conditions + c = basic_ios::mstreambuf->sgetc(); + if(c == traits::eof()){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + }else{ + basic_ios::setstate(ios_base::eofbit); + } + count_last_ufmt_input = i; + return *this; + } + if(c == delim){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + } + count_last_ufmt_input = i; + return *this; + } + if(sb.sputc(c) != c){ //Error doing output + count_last_ufmt_input = i; + return *this; + } + ++i; + basic_ios::mstreambuf->sbumpc(); + } + } + + _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n){ + return getline(s, n, basic_ios::widen('\n')); + } + + _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n, char_type delim){ + sentry(*this, true); + streamsize i = 0; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + if(c == traits::eof() ){ + if( basic_ios::eof() ){ + basic_ios::setstate(ios_base::failbit); + }else{ + basic_ios::setstate(ios_base::eofbit); + } + count_last_ufmt_input = i; + s[i] = traits::eos(); + return *this; + } + if(basic_ios::mstreambuf->sbumpc()==traits::eof() ){ + basic_ios::setstate(ios_base::eofbit); + } + if(c == delim){ + count_last_ufmt_input = i+1; + s[i] = traits::eos(); + return *this; + } + s[i] = c; + } + s[n-1] = traits::eos(); + return *this; + } + + _UCXXEXPORT basic_istream& ignore (streamsize n = 1, int_type delim = traits::eof()){ + sentry(*this, true); + streamsize i; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + if(c == traits::eof()){ + basic_ios::setstate(ios_base::eofbit); + return *this; + } + basic_ios::mstreambuf->sbumpc(); + if(c == delim){ + return *this; + } + } + return *this; + } + + _UCXXEXPORT int_type peek(){ + if(basic_ios::good() == false){ + return traits::eof(); + }else{ + int_type c = basic_ios::mstreambuf->sgetc(); + if(c == traits::eof()){ + basic_ios::setstate(ios_base::eofbit); + } + return basic_ios::mstreambuf->sgetc(); + } + } + + _UCXXEXPORT basic_istream& read (char_type* s, streamsize n){ + sentry(*this, true); + streamsize i; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + + if(c == traits::eof()){ + basic_ios::setstate(ios_base::failbit); + basic_ios::setstate(ios_base::eofbit); + count_last_ufmt_input = i; + return *this; + } + basic_ios::mstreambuf->sbumpc(); + s[i] = c; + } + count_last_ufmt_input = n; + return *this; + } + + _UCXXEXPORT streamsize readsome(char_type* s, streamsize n){ + sentry(*this, true); + if(!basic_ios::good()){ + count_last_ufmt_input = 0; + basic_ios::setstate(ios_base::failbit); + return 0; + } + + if( basic_ios::mstreambuf->in_avail() == -1){ + count_last_ufmt_input=0; + basic_ios::setstate(ios_base::eofbit); + return 0; + } + + if(n > basic_ios::mstreambuf->in_avail() ){ + n = basic_ios::mstreambuf->in_avail(); + } + + streamsize i; + int_type c; + + for(i=0;i::mstreambuf->sgetc(); + basic_ios::mstreambuf->sbumpc(); + s[i] = c; + } + count_last_ufmt_input = n; + return n; + } + + _UCXXEXPORT basic_istream& putback(char_type c){ + sentry(*this, true); + if(!basic_ios::good()){ + basic_ios::setstate(ios_base::failbit); + return *this; + } + if(basic_ios::mstreambuf == 0){ + basic_ios::setstate(ios_base::badbit); + return *this; + } + if(basic_ios::mstreambuf->sputbackc(c) == traits::eof()){ + basic_ios::setstate(ios_base::badbit); + return *this; + } + return *this; + } + + _UCXXEXPORT basic_istream& unget(){ + sentry(*this, true); + if(!basic_ios::good()){ + basic_ios::setstate(ios_base::failbit); + return *this; + } + if(basic_ios::mstreambuf == 0){ + basic_ios::setstate(ios_base::failbit); + return *this; + } + if(basic_ios::mstreambuf->sungetc() == traits::eof()){ + basic_ios::setstate(ios_base::failbit); + } + return *this; + } + + _UCXXEXPORT int sync(){ + sentry(*this, true); + if(basic_ios::mstreambuf == 0){ + return -1; + } + if(basic_ios::mstreambuf->pubsync() == -1){ + basic_ios::setstate(ios_base::badbit); + return traits::eof(); + } + return 0; + } + + _UCXXEXPORT pos_type tellg(){ + if(basic_ios::fail() !=false){ + return pos_type(-1); + } + return basic_ios::mstreambuf->pubseekoff(0, ios_base::cur, ios_base::in); + } + + _UCXXEXPORT basic_istream& seekg(pos_type pos){ + if(basic_ios::fail() !=true){ + basic_ios::mstreambuf->pubseekpos(pos); + } + return *this; + } + + _UCXXEXPORT basic_istream& seekg(off_type off, ios_base::seekdir dir){ + if(basic_ios::fail() !=true){ + basic_ios::mstreambuf->pubseekoff(off, dir); + } + return *this; + } + + protected: + _UCXXEXPORT basic_istream(const basic_istream &): basic_ios() { } + _UCXXEXPORT basic_istream & operator=(const basic_istream &){ return *this; } + streamsize count_last_ufmt_input; + + }; + + template + class _UCXXEXPORT basic_istream::sentry + { + bool ok; + public: + explicit _UCXXEXPORT sentry(basic_istream& os, bool noskipws = false) + : ok(false){ + if(os.good() !=0){ //Prepare for output + } + + //Flush any tied buffer + if(os.tie() != 0){ + os.tie()->flush(); + } + if(!noskipws){ + __skipws(os); + } + + ok = true; + } + _UCXXEXPORT ~sentry() { } + _UCXXEXPORT operator bool() { + return ok; + } + }; + + //Template implementations of basic_istream functions which may be partially specialized + //For code reduction + + template + _UCXXEXPORT typename basic_istream::int_type basic_istream::get(){ + sentry(*this, true); + int_type retval = basic_ios::mstreambuf->sgetc(); + if(retval == traits::eof()){ + count_last_ufmt_input = 0; + basic_ios::setstate(ios_base::eofbit); + }else{ + count_last_ufmt_input = 1; + basic_ios::mstreambuf->sbumpc(); + } + return retval; + } + + template + _UCXXEXPORT basic_istream& basic_istream::get(char_type& c){ + sentry(*this, true); + int_type retval = basic_ios::mstreambuf->sgetc(); + if(retval == traits::eof()){ + count_last_ufmt_input = 0; + basic_ios::setstate(ios_base::eofbit); + basic_ios::setstate(ios_base::failbit); + }else{ + count_last_ufmt_input = 1; + c = traits::to_char_type(retval); + basic_ios::mstreambuf->sbumpc(); + } + return *this; + } + + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(bool& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(short& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(unsigned short& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& basic_istream::operator>>(int& n){ + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& basic_istream::operator>>(unsigned int& n){ + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& basic_istream::operator>>(long int& n){ + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(unsigned long int& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + +#ifndef __STRICT_ANSI__ + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(long long& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(unsigned long long& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } +#endif +#ifdef __UCLIBCXX_HAS_FLOATS__ + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(float& f) + { + sentry(*this); + __istream_readin::readin(*this, f); + return *this; + } + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(double& f) + { + sentry(*this); + __istream_readin::readin(*this, f); + return *this; + } + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(long double& f) + { + sentry(*this); + __istream_readin::readin(*this, f); + return *this; + } +#endif + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(void *& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, charT& c) + { + typename basic_istream::sentry s(is); + is.get(c); + return is; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, unsigned char& c) + { + typename basic_istream::sentry s(is); + char b; + is.get(b); + c = b; + return is; + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, signed char& c) + { + typename basic_istream::sentry s(is); + is.get(c); + return is; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, charT* c) + { + typename basic_istream::sentry s(is); + int n = is.width(); + if(n == 0){ + n = __STRING_MAX_UNITS; + } + is.get(c, n); + return is; + + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, unsigned char* c) + { + typename basic_istream::sentry s(is); + int n = is.width(); + if(n == 0){ + n = __STRING_MAX_UNITS; + } + is.get(c, n); + return is; + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, signed char* c) + { + typename basic_istream::sentry s(is); + int n = is.width(); + if(n == 0){ + n = __STRING_MAX_UNITS; + } + is.get(c, n); + return is; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(basic_istream& (*pf)(basic_istream&)) + { + sentry(*this); + pf(*this); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(basic_ios& (*pf)(basic_ios&)) + { + sentry(*this); + pf(*this); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(ios_base& (*pf)(ios_base&)) + { + sentry(*this); + pf(*this); + return *this; + } + + template _UCXXEXPORT basic_istream& + ws(basic_istream& is) + { + __skipws(is); + return is; + } + + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_ISTREAM__ + + + template <> _UCXXEXPORT istream & basic_istream >::get(char & c); + template <> _UCXXEXPORT istream::int_type basic_istream >::get(); + + template <> _UCXXEXPORT istream & istream::operator>>(bool &n); + template <> _UCXXEXPORT istream & istream::operator>>(short &n); + template <> _UCXXEXPORT istream & istream::operator>>(unsigned short &n); + template <> _UCXXEXPORT istream & istream::operator>>(int &n); + template <> _UCXXEXPORT istream & istream::operator>>(unsigned int &n); + template <> _UCXXEXPORT istream & istream::operator>>(long unsigned &n); + template <> _UCXXEXPORT istream & istream::operator>>(long int &n); + template <> _UCXXEXPORT istream & istream::operator>>(void *& p); + +#ifdef __UCLIBCXX_HAS_FLOATS__ + template <> _UCXXEXPORT istream & istream::operator>>(float &f); + template <> _UCXXEXPORT istream & istream::operator>>(double &f); + template <> _UCXXEXPORT istream & istream::operator>>(long double &f); +#endif + + template <> _UCXXEXPORT istream & operator>>(istream & is, char & c); + + template <> _UCXXEXPORT void __skipws(basic_istream >& is); + +#endif +#endif + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/istream_helpers b/include/istream_helpers new file mode 100644 index 0000000..d87e0c7 --- /dev/null +++ b/include/istream_helpers @@ -0,0 +1,428 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include + +#include + +#ifndef __STD_HEADER_ISTREAM_HELPERS +#define __STD_HEADER_ISTREAM_HELPERS 1 + +#pragma GCC visibility push(default) + +namespace std{ + + + /* We are making the following template class for serveral reasons. Firstly, + * we want to keep the main istream code neat and tidy. Secondly, we want it + * to be easy to do partial specialization of the istream code so that it can + * be expanded and put into the library. This will allow us to make application + * code smaller at the expense of increased library size. This is a fair + * trade-off when there are multiple applications being compiled. Also, this + * feature will be used optionally via configuration options. It will also + * allow us to keep the code bases in sync, dramatically simplifying the + * maintenance required. We specialized for char because wchar and others + * require different scanf functions + */ + + template _UCXXEXPORT + basic_string _readToken(basic_istream& stream) + { + basic_string temp; + typename traits::int_type c; + while(true){ + c = stream.rdbuf()->sgetc(); + if(c != traits::eof() && isspace(c) == false){ + stream.rdbuf()->sbumpc(); + temp.append(1, traits::to_char_type(c)); + }else{ + break; + } + } + if (temp.size() == 0) + stream.setstate(ios_base::eofbit|ios_base::failbit); + + return temp; + } + + template _UCXXEXPORT + basic_string _readTokenDecimal(basic_istream& stream) + { + basic_string temp; + typename traits::int_type c; + while(true){ + c = stream.rdbuf()->sgetc(); + if(c != traits::eof() && isspace(c) == false && ( + isdigit(c) || + c == '.' || + c == ',' || + ((c == '-' || c == '+') && temp.size() == 0) ) + ){ + stream.rdbuf()->sbumpc(); + temp.append(1, traits::to_char_type(c)); + }else{ + break; + } + } + if (temp.size() == 0) + stream.setstate(ios_base::eofbit|ios_base::failbit); + + return temp; + } + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + + template <> _UCXXEXPORT string _readToken >(istream & stream); + +#endif + + + template class _UCXXEXPORT __istream_readin{ + public: + static void readin(basic_istream& stream, dataType & var); + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, bool & var) + { + /* 22.4.2.1.2.4 */ + basic_string temp; + temp = _readToken( stream); + if (stream.flags() & ios_base::boolalpha) { + if (temp == "true") // truename() + var = true; + else { + var = false; + if (temp != "false") // falsename() + stream.setstate(ios_base::failbit); + } + } else { + long int i = 0; + int ret; + if (stream.flags() & ios_base::dec) { + ret = sscanf(temp.c_str(), "%ld", &i ); + } else { + if (stream.flags() & ios_base::oct) { + ret = sscanf(temp.c_str(), "%lo", (unsigned long int *)(&i)); + } else if (stream.flags() & ios_base::hex) { + if (stream.flags() & ios_base::uppercase) { + ret = sscanf(temp.c_str(), "%lX", (unsigned long int *)(&i)); + } else { + ret = sscanf(temp.c_str(), "%lx", (unsigned long int *)(&i)); + } + } else { + ret = sscanf(temp.c_str(), "%li", &i); + } + } + if (ret != 1 || i >> 1) + stream.setstate(ios_base::failbit); + var = ret == 1 && bool(i); + } + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, short & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%hd", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%hi", &var); + } + } + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned short & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%hu", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%ho", &var); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%hX", &var ); + }else{ + sscanf(temp.c_str(), "%hx", &var); + } + }else{ + sscanf(temp.c_str(), "%hi", (signed short int*)(&var) ); + } + } + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%d", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%i", &var); + } + } + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%u", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%i", (int *)(&var) ); + } + } + + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, long int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%ld", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%li", (long int *)(&var) ); + } + } + + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned long int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%lu", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%lo", &var ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%lX", &var ); + }else{ + sscanf(temp.c_str(), "%lx", &var); + } + }else{ + sscanf(temp.c_str(), "%li", (long int *)(&var) ); + } + } + } + }; + + +#ifndef __STRICT_ANSI__ + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, long long & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%lld", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%llo", (unsigned long long *)&var ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + scanf(temp.c_str(), "%llX", (unsigned long long *)&var ); + }else{ + sscanf(temp.c_str(), "%llx", (unsigned long long *)&var); + } + }else{ + sscanf(temp.c_str(), "%lli", (&var) ); + } + } + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned long long & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%llu", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%llo", &var ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + scanf(temp.c_str(), "%llX", &var ); + }else{ + sscanf(temp.c_str(), "%llx", &var); + } + }else{ + sscanf(temp.c_str(), "%lli", (long long *)(&var) ); + } + } + } + }; +#endif + +#ifdef __UCLIBCXX_HAS_FLOATS__ + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, float & var) + { + basic_string temp; + temp = _readTokenDecimal( stream); + + sscanf(temp.c_str(), "%g", &var); + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, double & var) + { + basic_string temp; + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%lg", &var); + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, long double & var) + { + basic_string temp; + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%Lg", &var); + } + }; + +#endif // ifdef __UCLIBCXX_HAS_FLOATS__ + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, void* & var) + { + basic_string temp; + temp = _readToken( stream); + sscanf(temp.c_str(), "%p", &var); + } + }; + + + template void __skipws(basic_istream& is){ + const typename basic_istream::int_type eof = traits::eof(); + typename basic_istream::int_type c; + //While the next character normally read doesn't equal eof + //and that character is a space, advance to the next read position + //Thus itterating through all whitespace until we get to the meaty stuff + while ( + !traits::eq_int_type((c = is.rdbuf()->sgetc()), eof) + && isspace(c) + ) { + is.rdbuf()->sbumpc(); + } + if(traits::eq_int_type(c, eof)){ + is.setstate(ios_base::eofbit); + } + } +} + +#pragma GCC visibility pop + +#endif + + + diff --git a/include/iterator b/include/iterator new file mode 100644 index 0000000..d65f467 --- /dev/null +++ b/include/iterator @@ -0,0 +1,229 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include + + + +#ifndef __STD_HEADER_ITERATOR +#define __STD_HEADER_ITERATOR 1 + +#pragma GCC visibility push(default) + +namespace std{ + + // subclause _lib.stream.iterators_, stream iterators: + template , class Distance = ptrdiff_t> class istream_iterator; + template bool + operator==(const istream_iterator& x, const istream_iterator& y); + template bool + operator!=(const istream_iterator& x, const istream_iterator& y); + template > class ostream_iterator; + template > class istreambuf_iterator; + template bool + operator==(const istreambuf_iterator& a, const istreambuf_iterator& b); + template bool + operator!=(const istreambuf_iterator& a, const istreambuf_iterator& b); + template > class ostreambuf_iterator; + + + template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator + : public iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_istream istream_type; + istream_iterator() : in_stream(0), value(0) {} + istream_iterator(istream_type& s) : in_stream(&s), value() { + *in_stream >> value; + } + istream_iterator(const istream_iterator& x) + : in_stream(x.in_stream), value(x.value) + { } + ~istream_iterator() { } + const T& operator*() const{ + return value; + } + const T* operator->() const{ + return &value; + } + istream_iterator& operator++() { + *in_stream >> value; + return *this; + } + istream_iterator operator++(int){ + istream_iterator tmp = *this; + *in_stream >> value; + return (tmp); + } + bool m_equal(const istream_iterator& x) const{ + return (in_stream == x.in_stream); + } + private: + basic_istream* in_stream; + T value; + }; + + template _UCXXEXPORT + bool operator==(const istream_iterator& x, + const istream_iterator& y) + { + return x.m_equal(y); + } + + template _UCXXEXPORT + bool operator!=(const istream_iterator& x, + const istream_iterator& y) + { + return !(x == y); + } + + template class _UCXXEXPORT ostream_iterator + : public iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_ostream ostream_type; + + ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { } + ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { } + ostream_iterator(const ostream_iterator& x) : out_stream(x.out_stream), delim(x.delim) { } + ~ostream_iterator() { } + ostream_iterator& operator=(const T& value){ + *out_stream << value; + if(delim != 0){ + *out_stream << delim; + } + return (*this); + } + ostream_iterator& operator*(){ return *this; } + ostream_iterator& operator++() { return *this; } + ostream_iterator operator++(int) { return *this; } + private: + basic_ostream* out_stream; + const char* delim; + }; + + template class _UCXXEXPORT istreambuf_iterator : + public iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef typename traits::int_type int_type; + typedef basic_streambuf streambuf_type; + typedef basic_istream istream_type; + + class _UCXXEXPORT proxy{ + charT val; + basic_streambuf * buf; + + proxy(charT v, basic_streambuf * b) : val(v), buf(b) { } + public: + charT operator*() { return val; } + }; + + istreambuf_iterator() _UCXX_USE_NOEXCEPT : sbuf(0) { } + istreambuf_iterator(istream_type& s) _UCXX_USE_NOEXCEPT : sbuf(s.rdbuf()) { } + istreambuf_iterator(streambuf_type* s) _UCXX_USE_NOEXCEPT : sbuf(s) { } + istreambuf_iterator(const proxy& p) _UCXX_USE_NOEXCEPT : sbuf(&p.buf) { } + + charT operator*() const{ + return sbuf->sgetc(); + } + istreambuf_iterator& operator++(){ + sbuf->sbumpc(); + return *this; + } + istreambuf_iterator operator++(int){ + istreambuf_iterator tmp = *this; + sbuf->sbumpc(); + return(tmp); + } + + bool equal(const istreambuf_iterator& b) const{ + return sbuf == b.sbuf || is_eof() && b.is_eof(); + } + private: + streambuf_type* sbuf; + inline bool is_eof() const{ + return sbuf == 0 || sbuf->sgetc() == traits_type::eof(); + } + }; + + template _UCXXEXPORT bool + operator==(const istreambuf_iterator& a, + const istreambuf_iterator& b) + { + return a.equal(b); + } + + template bool _UCXXEXPORT + operator!=(const istreambuf_iterator& a, + const istreambuf_iterator& b) + { + return !a.equal(b); + } + + template class _UCXXEXPORT ostreambuf_iterator + : iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_streambuf streambuf_type; + typedef basic_ostream ostream_type; + public: + ostreambuf_iterator(ostream_type& s) _UCXX_USE_NOEXCEPT : sbuf(s.rdbuf()), f(false) { } + ostreambuf_iterator(streambuf_type* s) _UCXX_USE_NOEXCEPT : sbuf(s), f(false) { } + ostreambuf_iterator& operator=(charT c){ + if(failed() == false){ + if(sbuf->sputc(c) == traits::eof()){ + f = true; + } + } + return *this; + } + ostreambuf_iterator& operator*(){ + return *this; + } + ostreambuf_iterator& operator++() { return *this; } + ostreambuf_iterator operator++(int) { return *this; } + bool failed() const _UCXX_USE_NOEXCEPT{ + return f; + } + + private: + streambuf_type* sbuf; + bool f; + }; + +} + +#pragma GCC visibility pop + +#endif + + diff --git a/include/iterator_base b/include/iterator_base new file mode 100644 index 0000000..1cae589 --- /dev/null +++ b/include/iterator_base @@ -0,0 +1,305 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef __STD_HEADER_ITERATOR_BASE +#define __STD_HEADER_ITERATOR_BASE 1 + +#pragma GCC visibility push(default) + +namespace std{ + template struct iterator_traits; + template struct iterator_traits; + + template struct iterator; + + struct _UCXXEXPORT input_iterator_tag {}; + struct _UCXXEXPORT output_iterator_tag {}; + struct _UCXXEXPORT forward_iterator_tag: public input_iterator_tag {}; + struct _UCXXEXPORT bidirectional_iterator_tag: public forward_iterator_tag {}; + struct _UCXXEXPORT random_access_iterator_tag: public bidirectional_iterator_tag {}; + + template _UCXXEXPORT void advance(InputIterator& i, Distance n){ + while(n > 0){ + --n; + ++i; + } + } + + template _UCXXEXPORT typename iterator_traits::difference_type + distance(InputIterator first, InputIterator last) + { + typename iterator_traits::difference_type d = 0; + while(first++ !=last){ + d++; + } + return d; + } + + // subclause _lib.predef.iterators_, predefined iterators: + template class reverse_iterator; + template bool operator==(const reverse_iterator& x, const reverse_iterator& y); + template bool operator<(const reverse_iterator& x, const reverse_iterator& y); + template bool operator!=(const reverse_iterator& x, const reverse_iterator& y); + template bool operator>(const reverse_iterator& x, const reverse_iterator& y); + template bool operator>=(const reverse_iterator& x, const reverse_iterator& y); + template bool operator<=(const reverse_iterator& x, const reverse_iterator& y); + template typename reverse_iterator::difference_type + operator-( const reverse_iterator& x, const reverse_iterator& y); + template reverse_iterator + operator+( typename reverse_iterator::difference_type n, const reverse_iterator& x); + template class back_insert_iterator; + template back_insert_iterator back_inserter(Container& x); + template class front_insert_iterator; + template front_insert_iterator front_inserter(Container& x); + template class insert_iterator; + template + insert_iterator inserter(Container& x, Iterator i); + + //Actual Template definitions + + template struct _UCXXEXPORT iterator_traits { + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + typedef typename Iterator::iterator_category iterator_category; + }; + + //Pointer specialization - required by standard + template struct _UCXXEXPORT iterator_traits { + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef random_access_iterator_tag iterator_category; + }; + + //Specialization recomended by standard +/* template struct _UCXXEXPORT iterator_traits { + typedef long difference_type; + typedef T value_type; + typedef T __far* pointer; + typedef T __far& reference; + typedef random_access_iterator_tag iterator_category; + };*/ + +/* template _UCXXEXPORT void + reverse(BidirectionalIterator first, BidirectionalIterator last) + { + typename iterator_traits::difference_type n = distance(first, last); + --n; + while(n > 0){ + typename iterator_traits::value_type tmp = *first; + *first++ = * --last; + *last = tmp; + n -= 2; + } + };*/ + + + template + struct _UCXXEXPORT iterator + { + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; + typedef Category iterator_category; + }; + + + template class _UCXXEXPORT reverse_iterator + : public iterator::iterator_category, + typename iterator_traits::value_type, typename iterator_traits::difference_type, + typename iterator_traits::pointer, typename iterator_traits::reference> + { + protected: + Iterator current; + friend bool operator== (const reverse_iterator& x, const reverse_iterator& y); + friend bool operator< (const reverse_iterator& x, const reverse_iterator& y); + + public: + typedef Iterator iterator_type; + + reverse_iterator() : current(){}; + explicit reverse_iterator(Iterator x) : current(x) { } + template reverse_iterator(const reverse_iterator &x) : current(x.base()){} + + Iterator base() const { return current; } // explicit + + typename iterator_traits::reference operator*() const { Iterator tmp = current; return *--tmp; } + typename iterator_traits::pointer operator->() const { return &(operator*()); } + typename iterator_traits::reference operator[](typename iterator_traits::difference_type n) const{ + return current[-n-1]; + } + + reverse_iterator& operator++(){ --current; return *this; } + reverse_iterator operator++(int) {reverse_iterator tmp = *this; --current; return tmp; } + reverse_iterator& operator--() { ++ current; return *this; } + reverse_iterator operator--(int) {reverse_iterator tmp = *this; ++current; return tmp; } + + reverse_iterator operator+ (typename iterator_traits::difference_type n) const{ + reverse_iterator retval( *this ); + retval+=n; + return retval; + } + reverse_iterator& operator+=(typename iterator_traits::difference_type n){ + current -= n; + return *this; + } + reverse_iterator operator- (typename iterator_traits::difference_type n) const{ + reverse_iterator retval( *this ); + retval-=n; + return retval; + } + reverse_iterator& operator-=(typename iterator_traits::difference_type n){ + current += n; + return *this; + } + }; + + + template _UCXXEXPORT bool + operator==(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() == y.base(); + } + template _UCXXEXPORT bool + operator<(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() < y.base(); + } + template _UCXXEXPORT bool + operator!=(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() != y.base(); + } + template _UCXXEXPORT bool + operator>(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() > y.base(); + } + template _UCXXEXPORT bool + operator>=(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() >= y.base(); + } + template _UCXXEXPORT bool + operator<=(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() <= y.base(); + } + template _UCXXEXPORT typename reverse_iterator::difference_type + operator-( const reverse_iterator& x, const reverse_iterator& y) + { + return y.base() - x.base(); + } + template _UCXXEXPORT reverse_iterator + operator+(typename reverse_iterator::difference_type n, const reverse_iterator& x) + { + return reverse_iterator (x.base() - n); + } + + template class _UCXXEXPORT back_insert_iterator : + public iterator + { + protected: + Container& container; + public: + typedef Container container_type; + explicit back_insert_iterator(Container& x):container(x) {}; + back_insert_iterator& operator=(const typename Container::value_type& value){ + container.push_back(value); + return *this; + } + back_insert_iterator& operator*(){ + return *this; + } + back_insert_iterator& operator++(){ + return *this; + } + back_insert_iterator operator++(int){ + return *this; + } + }; + + template _UCXXEXPORT back_insert_iterator + back_inserter(Container& x) + { + return back_insert_iterator(x); + } + + template class _UCXXEXPORT front_insert_iterator + : public iterator + { + protected: + Container& container; + public: + typedef Container container_type; + explicit front_insert_iterator(Container& x): container(x) {} + front_insert_iterator& operator=(const typename Container::value_type& value){ + container.push_front(value); + return *this; + } + + front_insert_iterator& operator*() { return *this; } + front_insert_iterator& operator++() { return *this; } + front_insert_iterator operator++(int) { return *this; } + }; + + template _UCXXEXPORT front_insert_iterator + front_inserter(Container& x) + { + return front_insert_iterator(x); + } + + template class _UCXXEXPORT insert_iterator + : public iterator + { + protected: + Container& container; + typename Container::iterator iter; + public: + typedef Container container_type; + insert_iterator(Container& x, typename Container::iterator i) : container(x), iter(i) {} + insert_iterator& operator=(const typename Container::value_type& value){ + iter = container.insert(iter, value); + ++iter; + return *this; + } + insert_iterator& operator*() { return *this; } + insert_iterator& operator++() { return *this; } + insert_iterator operator++(int) { return *this; } + }; + + template _UCXXEXPORT insert_iterator + inserter(Container& x, Iterator i) + { + return insert_iterator(x,typename Container::iterator(i)); + } + +} + +#pragma GCC visibility pop + +#endif + + diff --git a/include/limits b/include/limits new file mode 100644 index 0000000..e275eb5 --- /dev/null +++ b/include/limits @@ -0,0 +1,663 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + +#ifndef __STD_HEADER_LIMITS +#define __STD_HEADER_LIMITS 1 + +#warning limits header is nowhere complete or accurate + +#pragma GCC visibility push(default) + +namespace std{ + +enum float_round_style{ + round_indeterminate =-1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, + round_toward_neg_infinity = 3 +}; + +template struct __bits_to_base_10{ + static const int size = -1; +}; +template <> struct __bits_to_base_10<7>{ + static const int size = 2; +}; +template <> struct __bits_to_base_10<8>{ + static const int size = 2; +}; +template <> struct __bits_to_base_10<9>{ + static const int size = 2; +}; +template <> struct __bits_to_base_10<10>{ + static const int size = 3; +}; +template <> struct __bits_to_base_10<15>{ + static const int size = 4; +}; +template <> struct __bits_to_base_10<16>{ + static const int size = 4; +}; +template <> struct __bits_to_base_10<17>{ + static const int size = 5; +}; +template <> struct __bits_to_base_10<18>{ + static const int size = 5; +}; +template <> struct __bits_to_base_10<31>{ + static const int size = 9; +}; +template <> struct __bits_to_base_10<32>{ + static const int size = 9; +}; +template <> struct __bits_to_base_10<35>{ + static const int size = 10; +}; +template <> struct __bits_to_base_10<36>{ + static const int size = 10; +}; +template <> struct __bits_to_base_10<63>{ + static const int size = 18; +}; +template <> struct __bits_to_base_10<64>{ + static const int size = 19; +}; +template <> struct __bits_to_base_10<71>{ + static const int size = 21; +}; +template <> struct __bits_to_base_10<72>{ + static const int size = 21; +}; +template <> struct __bits_to_base_10<79>{ + static const int size = 23; +}; +template <> struct __bits_to_base_10<80>{ + static const int size = 24; +}; +template <> struct __bits_to_base_10<127>{ + static const int size = 38; +}; +template <> struct __bits_to_base_10<128>{ + static const int size = 38; +}; + + + + + + +template class numeric_limits { +public: + // General -- meaningful for all specializations. + + static const bool is_specialized = false; + static T min(); + static T max(); + static const int radix; + static const int digits; + static const int digits10; + static const bool is_signed; + static const bool is_integer; + static const bool is_exact; + static const bool traps; + static const bool is_modulo; + static const bool is_bounded; + + // Floating point specific. + + static T epsilon(); + static T round_error(); + static const int min_exponent10; + static const int max_exponent10; + static const int min_exponent; + + static const int max_exponent; + static const bool has_infinity; + static const bool has_quiet_NaN; + static const bool has_signaling_NaN; + static const bool is_iec559; + static const bool has_denorm; + static const bool tinyness_before; + static const float_round_style round_style; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef bool T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return false; + } + static T max(){ + return true; + } + static const int radix = 2; + static const int digits = 1; + static const int digits10 = 0; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = false; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned char T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return UCHAR_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT; + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed char T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return SCHAR_MIN; + } + static T max(){ + return SCHAR_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT - 1; + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef char T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return CHAR_MIN; + } + static T max(){ + return CHAR_MAX; + } + static const int radix = 2; + static const int digits = (CHAR_MIN != 0) ? CHAR_BIT - 1 : CHAR_BIT; + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = (CHAR_MIN != 0); + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned short T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return USHRT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed short T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return SHRT_MIN; + } + static T max(){ + return SHRT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return UINT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return INT_MIN; + } + static T max(){ + return INT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned long int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return ULONG_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed long int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return LONG_MIN; + } + static T max(){ + return LONG_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef double numeric_type; + + static const bool is_specialized = true; + static numeric_type min () { return __DBL_MIN__; } + static numeric_type max () { return __DBL_MAX__; } + static const int radix = __FLT_RADIX__; + static const int digits = __DBL_MANT_DIG__; + static const int digits10 = __DBL_DIG__; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const bool traps = false; // this is a guess + static const bool is_modulo = false; + static const bool is_bounded = true; + + // Floating point specific. + + static numeric_type epsilon () { return __DBL_EPSILON__; } + static numeric_type round_error () { return 0.5; } + static const int min_exponent10 = -1; //How do I properly get this? + static const int max_exponent10 = -1; //How do I properly get this? + static const int min_exponent = -1; //How do I properly get this? + static const int max_exponent = -1; //How do I properly get this? + static const bool has_infinity = false; //I don't know, so until I can find out, I'm saying no + static const bool has_quiet_NaN = false; //I don't know, so until I can find out, I'm saying no + static const bool has_signaling_NaN = false; //I don't know, so until I can find out, I'm saying no + static const bool has_denorm = false; //I don't know, so until I can find out, I'm saying no + + static const bool is_iec559 = false; //I don't know, so until I can find out, I'm saying no + static const bool tinyness_before = false; // more questions + static const float_round_style round_style = round_to_nearest; // more questions + static numeric_type denorm_min () { return -1; } //How do I properly get this? + static numeric_type infinity () { return -1; } //How do I properly get this? + static numeric_type quiet_NaN () { return -1; } //How do I properly get this? + static numeric_type signaling_NaN () { return -1; } //How do I properly get this? +}; + + + + + +} + +#pragma GCC visibility pop + +#endif diff --git a/include/list b/include/list new file mode 100644 index 0000000..1ef00fb --- /dev/null +++ b/include/list @@ -0,0 +1,926 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef __STD_HEADER_LIST +#define __STD_HEADER_LIST 1 + +#pragma GCC visibility push(default) + +namespace std{ + + template > class _UCXXEXPORT list { + public: + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef T value_type; + typedef Allocator allocator_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + + protected: + class node; + class iter_list; + + node * list_start; + node * list_end; + size_type elements; + Allocator a; + + public: + + typedef iter_list iterator; + typedef iter_list const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + explicit list(const Allocator& = Allocator()); + explicit list(size_type n, const T& value = T(), const Allocator& = Allocator()); + template list(InputIterator first, InputIterator last, + const Allocator& al= Allocator()); + list(const list& x); + ~list(); + + list& operator=(const list& x){ + if(&x == this){ + return *this; + } + clear(); + iterator i = x.begin(); + while(i != x.end()){ + push_back(*i); + ++i; + } + return *this; + } + + template void assign(InputIterator first, InputIterator last); + template void assign(Size n, const U& u = U()); + allocator_type get_allocator() const; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + + bool empty() const; + size_type size() const; + size_type max_size() const; + void resize(size_type sz, T c = T()); + + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + void push_front(const T& x); + void pop_front(); + void push_back(const T& x); + void pop_back(); + iterator insert(iterator position, const T& x = T()); + void insert(iterator position, size_type n, const T& x); + template void insert(iterator position, InputIterator first, InputIterator last); + iterator erase(iterator position); + iterator erase(iterator position, iterator last); + void swap(list&); + void clear(); + + void splice(iterator position, list& x); + void splice(iterator position, list& x, iterator i); + void splice(iterator position, list& x, iterator first, iterator last); + void remove(const T& value); + template void remove_if(Predicate pred); + void unique(); + template void unique(BinaryPredicate binary_pred); + void merge(list& x); + template void merge(list& x, Compare comp); + void sort(); + template void sort(Compare comp); + void reverse(); + protected: + void swap_nodes(node * x, node * y); + }; + + + //Implementations of List + + //List node + template class _UCXXEXPORT list::node{ + public: + node * previous; + node * next; + T * val; + + node(): previous(0), next(0), val(0){ } + node(const T & t ): previous(0), next(0), val(0) { + val = new T(t); + //FIXME use allocator somehow but only call constructor once + } + node(const T & t, node * p, node * n): previous(p), next(n), val(0) { + val = new T(t); + } + ~node(){ } + }; + + //List iterator + template class _UCXXEXPORT list::iter_list + : public std::iterator< + bidirectional_iterator_tag, + T, + typename Allocator::difference_type, + typename Allocator::pointer, + typename Allocator::reference + > + { + private: + node * current; + public: + iter_list():current(0) { } + iter_list( typename list::node * n): current(n) { } + iter_list(const list::iter_list & l): current(l.current) { } + ~iter_list(){ } + + iter_list & operator=(const list::iter_list & right ){ + current = right.current; + return *this; + } + + T & operator*(){ + return *(current->val); + } + T * operator->(){ + return current->val; + } + const T & operator*() const{ + return *current->val; + } + const T * operator->() const{ + return current->val; + } + + bool operator==(const list::iter_list & right) const { + return (current == right.current); + } + + bool operator!=(const list::iter_list & right) const { + return (current != right.current); + } + + iter_list & operator++(){ + current = current->next; + return *this; + } + + iter_list operator++(int){ + iter_list temp(current); + current = current->next; + return temp; + } + iter_list & operator--(){ + current = current->previous; + return *this; + } + + iter_list operator--(int){ + iter_list temp(current); + current = current->previous; + return temp; + } + node * link_struct(){ + return current; + } + iter_list & operator+=(unsigned int n){ + for(unsigned int i = 0; i < n; ++i){ + current = current->next; + } + return *this; + } + iter_list & operator-=(unsigned int n){ + for(unsigned int i = 0; i < n; ++i){ + current = current->previous; + } + return *this; + } + }; + + + template list::list(const Allocator& al) + :list_start(0), list_end(0), elements(0), a(al) + { + //End node + list_start = new node(); + list_end = list_start; + return; + } + + template list::list + (typename Allocator::size_type n, const T& value, const Allocator& al) + :list_start(0), list_end(0), elements(0), a(al) + { + //End node + list_start = new node(); + list_end = list_start; + + for(typename Allocator::size_type i = 0; i < n ; ++i){ + push_back(value); + } + } + + template template + list::list + (InputIterator first, InputIterator last, const Allocator& al) + : list_start(0), list_end(0), elements(0), a(al) + { + list_start = new node(); + list_end = list_start; + while(first != last){ + push_back(*first); + ++first; + } + } + + template list::list(const list& x) + : list_start(0), list_end(0), elements(0), a(x.a) + { + list_start = new node(); + list_end = list_start; + + iterator i = x.begin(); + while(i != x.end()){ + push_back( *i); + ++i; + } + } + + template list::~list(){ + while(elements > 0){ + pop_front(); + } + delete list_start->val; +#if UCLIBCXX_DEBUG + list_start->val = 0; +#endif + delete list_start; +#if UCLIBCXX_DEBUG + list_start = 0; + list_end = 0; +#endif + } + + + template void list::swap_nodes(node * x, node * y){ + T * v = x->val; + x->val = y->val; + y->val = v; + } + + template typename list::iterator + list::begin() + { + return iterator(list_start); + } + + + template typename list::const_iterator + list::begin() const + { + return const_iterator(list_start); + } + + + template typename list::iterator + list::end() + { + return iterator(list_end); + } + + template typename list::const_iterator + list::end() const + { + return const_iterator(list_end); + } + + template typename list::reverse_iterator + list::rbegin() + { + return reverse_iterator(end()); + } + + template typename list::const_reverse_iterator + list::rbegin() const + { + return const_reverse_iterator(end()); + } + + template typename list::reverse_iterator + list::rend() + { + return reverse_iterator(begin()); + } + + template typename list::const_reverse_iterator + list::rend() const + { + return const_reverse_iterator(begin()); + } + + template bool list::empty() const{ + return (elements == 0); + } + template typename list::size_type list::size() const{ + return elements; + } + template typename list::size_type list::max_size() const{ + return ((size_type)(-1)) / (sizeof(T) + sizeof(node)); + } + template void list::resize(typename Allocator::size_type sz, T c){ +// if(sz > elements){ + for(typename Allocator::size_type i = elements; i < sz; ++i){ + push_back(c); + } +// } +// if(sz < elements){ + for(typename Allocator::size_type i = elements; i > sz; --i){ + pop_back(); + } +// } + } + + template typename list::reference list::front(){ + return *(list_start->val); + } + template typename list::const_reference list::front() const{ + return *(list_start->val); + } + template typename list::reference list::back(){ + return *(list_end->previous->val); + } + template typename list::const_reference list::back() const{ + return *(list_end->previous->val); + } + + + template void list::push_front(const T& x){ + node * temp = new node(x); + list_start->previous = temp; + temp->previous = 0; + temp->next = list_start; + list_start = temp; + ++elements; + } + + template void list::pop_front(){ + if(elements > 0){ + list_start = list_start->next; + delete list_start->previous->val; +#if UCLIBCXX_DEBUG + list_start->previous->val = 0; + list_start->previous->next = 0; + list_start->previous->previous = 0; +#endif + delete list_start->previous; + list_start->previous = 0; + --elements; + } + } + + template void list::push_back(const T& x){ + if(elements == 0){ + //The list is completely empty + list_start = new node(x); + list_end->previous = list_start; + list_start->previous = 0; + list_start->next = list_end; + elements = 1; + }else{ + node * temp = new node(x); + temp->previous = list_end->previous; + temp->next = list_end; + list_end->previous->next = temp; + list_end->previous = temp; + ++elements; + } + } + + template void list::pop_back(){ + if(elements > 0){ + node * temp = list_end->previous; + if(temp == list_start){ + list_end->previous = 0; + list_start = list_end; + }else{ + temp->previous->next = temp->next; + list_end->previous = temp->previous; + } + delete temp->val; +#if UCLIBCXX_DEBUG + temp->val = 0; + temp->next = 0; + temp->previous = 0; +#endif + delete temp; +#if UCLIBCXX_DEBUG + temp = 0; +#endif + --elements; + } + } + + + template typename list::iterator + list::insert(iterator position, const T& x) + { + node * temp = new node(x); + + temp->previous = position.link_struct()->previous; + temp->next = position.link_struct(); + + if(temp->previous == 0){ + list_start = temp; + }else{ + position.link_struct()->previous->next = temp; + } + + position.link_struct()->previous = temp; + + ++elements; + --position; + return position; + } + + template void list::insert(iterator position, size_type n, const T& x){ + for(typename list::size_type i = 0; i < n; ++i){ + position = insert(position, x); + } + } + + template template void + list::insert(iterator position, InputIterator first, InputIterator last) + { + while(first !=last){ + insert(position, *first); + ++first; + } + } + template typename list::iterator + list::erase(iterator position) + { + if(position != end() ){ + node * temp = position.link_struct(); + if(temp == list_start){ + ++position; + temp->next->previous = 0; + list_start = temp->next; + }else{ + --position; + temp->next->previous = temp->previous; + temp->previous->next = temp->next; + ++position; + } + delete temp->val; +#if UCLIBCXX_DEBUG + temp->next = 0; + temp->previous = 0; + temp->val = 0; +#endif + delete temp; +#if UCLIBCXX_DEBUG + temp = 0; +#endif + --elements; + } + return position; + } + template typename list::iterator + list::erase(iterator position, iterator last) + { + iterator temp = position; + while(position !=last){ + position = erase(position); + } + return position; + } + template void list::swap(list& l){ + node * temp; + size_type tempel; + + temp = list_start; + list_start = l.list_start; + l.list_start = temp; + + temp = list_end; + list_end = l.list_end; + l.list_end = temp; + + tempel = elements; + elements = l.elements; + l.elements = tempel; + } + template void list::clear(){ + while(elements > 0){ + pop_front(); + } + } + + template + void list::splice(iterator position, list& x) + { + + //Can't add non-existant elements + if(x.elements == 0){ + return; + } + + elements += x.elements; + x.elements = 0; + + + //Chaining to the begining + if(position == begin()){ + x.list_end->previous->next = list_start; + list_start->previous = x.list_end->previous; + + list_start = x.list_start; + + x.list_start = x.list_end; + x.list_end->previous = 0; + + return; + } + + //Link everything we need + x.list_start->previous = position.link_struct()->previous; + position.link_struct()->previous->next = x.list_start; + + position.link_struct()->previous = x.list_end->previous; + x.list_end->previous->next = position.link_struct(); + + //Clean up the other list + + x.list_start = x.list_end; + x.list_end->previous=0; + + } + + template + void list::splice(iterator position, list& x, iterator i) + { + //Invalid conditions + if( x.elements == 0 || i == position || position.link_struct() == i.link_struct()->next ){ + return; + } + + //Do we need to adjust the begining pointer? + if(i == x.begin()){ + x.list_start = x.list_start->next; + x.list_start->previous = 0; + } + + + //Insert at begining special case + if(position == begin()){ + if (i.link_struct()->previous != 0) + i.link_struct()->previous->next = i.link_struct()->next; + i.link_struct()->next->previous = i.link_struct()->previous; + + i.link_struct()->previous = 0; + i.link_struct()->next = position.link_struct(); + position.link_struct()->previous = i.link_struct(); + + list_start = i.link_struct(); + + --x.elements; + ++elements; + return; + } + + if( i.link_struct()->previous != 0){ + i.link_struct()->previous->next = i.link_struct()->next; + i.link_struct()->next->previous = i.link_struct()->previous; + }else{ + i.link_struct()->next->previous = 0; + x.list_start = i.link_struct()->next; + } + + i.link_struct()->previous = position.link_struct()->previous; + position.link_struct()->previous->next = i.link_struct(); + + i.link_struct()->next = position.link_struct(); + position.link_struct()->previous = i.link_struct(); + + --x.elements; + ++elements; + } + + template + void list::splice(iterator position, list& x, + iterator first, iterator last) + { + if(x.elements == 0){ + return; + } + + iterator temp; + while(first != last){ + temp = first; + ++first; + splice(position, x, temp); + } + } + + + template void list::remove(const T& value){ + iterator temp = begin(); + while( temp != end() ){ + if(*temp == value){ + temp = erase(temp); + }else{ + ++temp; + } + } + } + + + template template void list::remove_if(Predicate pred){ + iterator temp = begin(); + while( temp != end() ){ + if( pred(*temp) ){ + temp = erase(temp); + }else{ + ++temp; + } + } + } + + + template void list::unique(){ + equal_to::value_type> p; + unique(p); + } + + template template + void list::unique(BinaryPredicate binary_pred) + { + iterator temp1 = begin(); + iterator temp2; + ++temp1; + while( temp1 != end() ){ + temp2 = temp1; + --temp2; + if( binary_pred(*temp1, *temp2) ){ + erase(temp1); + temp1 = temp2; + } + ++temp1; + } + } + + template void list::merge(list& x){ + less::iterator>::value_type> c; + merge(x, c); + } + + template template + void list::merge(list& x, Compare comp) + { + iterator source = x.begin(); + iterator temp; + iterator dest = begin(); + + while(source != x.end()){ + while( dest != end() && comp (*dest, *source) ){ + ++dest; + } + ++elements; + --x.elements; + + temp = source; + ++temp; + + if(dest == begin()){ + dest.link_struct()->previous = source.link_struct(); + source.link_struct()->next = dest.link_struct(); + source.link_struct()->previous = 0; + list_start = source.link_struct(); + }else{ + source.link_struct()->previous = dest.link_struct()->previous; + dest.link_struct()->previous->next = source.link_struct(); + source.link_struct()->next = dest.link_struct(); + dest.link_struct()->previous = source.link_struct(); + } + source = temp; + } + + //Fix up x; + x.list_start = x.list_end; + x.list_start->previous = 0; + } + + template void list::sort(){ + less::iterator>::value_type> c; + sort(c); + } + + template template + void list::sort(Compare comp) + { + typename list::iterator i, j, k; + + //FIXME - bubble sort + + if(elements == 0){ + return; + } + + i = end(); + --i; + while(i != begin()){ + j = begin(); + k = j; + ++k; + while(j != i){ + if( comp(*k, *j) ){ + swap_nodes(k.link_struct(), j.link_struct()); + } + ++j; + ++k; + } + --i; + } + } + + + template void list::reverse(){ + if(elements == 0){ + return; + } + + node * current; + node * following; + node * temp; + + //Need to move the list_end element to the begining + + temp = list_end; + list_end = temp->previous; + list_end->next = 0; + + list_start->previous = temp; + temp->previous = 0; + temp->next = list_start; + list_start = temp; + + current = list_start; + + while( current != list_end ){ + following = current->next; + + //Swap the values pointed to/at with the current node + temp = current->next; + current->next = current->previous; + current->previous = temp; + + current = following; + } + + //Swap pointers on the end node + temp = list_end->next; + list_end->next = list_end->previous; + list_end->previous = temp; + + + //Swap the fixed pointers + temp = list_start; + list_start = list_end; + list_end = temp; + + } + + template + bool operator==(const list& x, const list& y){ + if(x.size() != y.size()){ + return false; + } + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + + while(i != x.end()){ + if( *i != *j){ + return false; + } + ++i; + ++j; + } + return true; + } + + template + bool operator< (const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i < *j){ + return true; + } + if(*j < *i){ + return false; + } + ++i; + ++j; + } + return (i == x.end() && j != y.end()); + } + + template + bool operator!=(const list& x, const list& y){ + return !(x == y); + } + + template + bool operator> (const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i > *j){ + return true; + } + if( *j > *i){ + return false; + } + ++i; + ++j; + } + return (i != x.end() && j == y.end()); + } + + template + bool operator>=(const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i >= *j){ + return true; + } + if(*j >= *i){ + return false; + } + ++i; + ++j; + } + return (i != x.end() && j == y.end()); + } + + template + bool operator<=(const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i <= *j){ + return true; + } + if(*j <= *i){ + return false; + } + ++i; + ++j; + } + return (i == x.end()); + } + + template + void swap(list& x, list& y){ + x.swap(y); + } + +} + +#pragma GCC visibility pop + +#endif + + diff --git a/include/locale b/include/locale new file mode 100644 index 0000000..ed4dfa3 --- /dev/null +++ b/include/locale @@ -0,0 +1,83 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef __HEADER_STD_LOCALE +#define __HEADER_STD_LOCALE 1 + +#pragma GCC visibility push(default) + +namespace std{ + class _UCXXEXPORT locale { + public: + // types: + class facet; + class id; + typedef unsigned char category; + + static const category + none = 0, + collate = 0x01, ctype = 0x02, + monetary = 0x04, numeric = 0x08, + time = 0x10, messages = 0x20, + all = collate | ctype | monetary | numeric | time | messages; + + // construct/copy/destroy: + locale() _UCXX_USE_NOEXCEPT{ + return; + } + locale(const locale& other) _UCXX_USE_NOEXCEPT{ + (void)other; + return; + } + locale(const char *) _UCXX_USE_NOEXCEPT{ + return; + } + ~locale() _UCXX_USE_NOEXCEPT{ + return; + } + + const locale& operator=(const locale&) _UCXX_USE_NOEXCEPT{ + return *this; + } + std::string name() const { return "C"; } + }; + + class _UCXXEXPORT locale::facet { + friend class locale; + explicit facet(size_t = 0){ + return; + } + virtual ~facet(){ + return; + } + }; + + class _UCXXEXPORT locale::id { + id(){ } + }; + +} + +#pragma GCC visibility pop + +#endif diff --git a/include/map b/include/map new file mode 100644 index 0000000..038191a --- /dev/null +++ b/include/map @@ -0,0 +1,264 @@ +/* Copyright (C) 2004-2007 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include + + +#ifndef __STD_HEADER_MAP +#define __STD_HEADER_MAP + +#pragma GCC visibility push(default) + +namespace std{ + + +template, class Allocator = allocator > class map; +template, class Allocator = allocator > class multimap; + + + //Compare the keys of the two items +/* template class _UCXXEXPORT + __base_map::value_compare : public binary_function< + typename map::value_type, + typename map::value_type, + bool> + { + friend class __base_map; + protected: + Compare comp; + value_compare(Compare c) : comp(c) { } + ~value_compare() { } + public: + bool operator()(const value_type& x, const value_type& y) const { + return comp(x.first, y.first); + } + }; +*/ + +// value_compare value_comp() const; + + + +/* This is the implementation for the map container. As noted above, it deviates + * from ISO spec by deriving from a base class in order to reduce code redundancy. + * More code could be reduced by convirting to virtual functions (thus allowing + * much of the erase and insert code to be duplicated), but that would deviate from + * the specifications too much to be worth the risk. + */ + + + +//Implementation of map + + +template class _UCXXEXPORT map + : public __single_associative, Compare, Allocator> +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it + +public: + + typedef __single_associative, Compare, Allocator> base; + typedef T mapped_type; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + static const key_type v_t_k(const value_type v){ + return v.first; + } + +// using base::value_compare; + + explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template map(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + map(const map& x) : base(x) { } + ~map() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + using base::swap; + + reference operator[](const key_type& k){ + iterator i = lower_bound(k); + if (i == end() || base::c(k, i->first)) { + i = insert(make_pair(k, T())).first; + } + return i->second; + } + +protected: + using base::backing; +}; + + +//Implementation of multimap + + +template class _UCXXEXPORT multimap + : public __multi_associative, Compare, Allocator> + +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __multi_associative, Compare, Allocator> base; + typedef T mapped_type; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + static const key_type v_t_k(const value_type v){ + return v.first; + } + + explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template multimap(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + + multimap(const multimap& x) : base(x) { } + ~multimap() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + using base::swap; + +protected: + + using base::c; + +}; + + +/* Non-member functions. These are at the end because they are not associated with any + particular class. These will be implemented as I figure out exactly what all of + them are supposed to do, and I have time. + */ + + template _UCXXEXPORT bool operator< + (const map& x, const map& y); + template _UCXXEXPORT bool operator!= + (const map& x, const map& y); + template _UCXXEXPORT bool operator> + (const map& x, const map& y); + template _UCXXEXPORT bool operator>= + (const map& x, const map& y); + template _UCXXEXPORT bool operator<= + (const map& x, const map& y); + template _UCXXEXPORT void swap + (map& x, map& y); + + + template _UCXXEXPORT bool operator== + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator< + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator!= + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator> + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator>= + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator<= + (const multimap& x, const multimap& y); + template _UCXXEXPORT void swap + (multimap& x, multimap& y); + +} + +#pragma GCC visibility pop + +#endif + + diff --git a/include/memory b/include/memory new file mode 100644 index 0000000..9ce6559 --- /dev/null +++ b/include/memory @@ -0,0 +1,196 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include +#include + +#ifndef HEADER_STD_MEMORY +#define HEADER_STD_MEMORY 1 + +#pragma GCC visibility push(default) + +namespace std{ + +template class allocator; + // Specialize for void: + +template <> class _UCXXEXPORT allocator { +public: + typedef void* pointer; + typedef const void* const_pointer; + typedef void value_type; + template struct rebind { typedef allocator other; }; +}; + +template class _UCXXEXPORT allocator{ +public: + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + typedef T* pointer; + typedef const T* const_pointer; + + typedef T& reference; + typedef const T& const_reference; + + pointer address(reference r) const { return &r; } + const_pointer address(const_reference r) const { return &r; } + + allocator() _UCXX_USE_NOEXCEPT{} + template allocator(const allocator& ) _UCXX_USE_NOEXCEPT; + ~allocator() _UCXX_USE_NOEXCEPT{} + + //Space for n Ts + pointer allocate(size_type n, typename allocator::const_pointer = 0){ + return (T*)(::operator new( n * sizeof(T) )); + } + void deallocate(pointer p, size_type){ + ::operator delete(p); + } + + //Use placement new to engage the constructor + void construct(pointer p, const T& val) { new((void*)p) T(val); } + void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor + + size_type max_size() const _UCXX_USE_NOEXCEPT; + template struct rebind { typedef allocator other; }; + +}; + +template class _UCXXEXPORT raw_storage_iterator + : public iterator +{ + Out p; + +public: + explicit raw_storage_iterator(Out pp) : p (pp) { } + raw_storage_iterator & operator*() { return *this; } + raw_storage_iterator & operator=(const T& val) { + T* pp = &*p; + new(pp) T(val); + return *this; + } + + raw_storage_iterator & operator++() { ++p; return *this; } + raw_storage_iterator operator++(int) { + raw_storage_iterator t = *this; + ++p; + return t; + } +}; + +template _UCXXEXPORT pair get_temporary_buffer(ptrdiff_t n){ + pair retval; + retval.first = static_cast(malloc(n * sizeof(T))); + if(retval.first == 0){ + retval.second = 0; + }else{ + retval.second = n; + } + return retval; +} + +template _UCXXEXPORT void return_temporary_buffer(T* p){ + free(p); +} + + +template class _UCXXEXPORT auto_ptr{ + +private: + T * object; + template struct auto_ptr_ref{ + Y * p; + }; + +public: + + typedef T element_type; + + explicit auto_ptr(T* p =0) _UCXX_USE_NOEXCEPT : object(p){ } + auto_ptr(auto_ptr& p) _UCXX_USE_NOEXCEPT : object(p.release()){ } + auto_ptr(auto_ptr_ref r) _UCXX_USE_NOEXCEPT : object(r.p){ + r.p = 0; + } + template auto_ptr(auto_ptr& p) _UCXX_USE_NOEXCEPT : object(p.release()){ } + auto_ptr& operator=(auto_ptr& p) _UCXX_USE_NOEXCEPT{ + if(&p == this){ + return *this; + } + delete object; + object = p.release(); + return *this; + } + template auto_ptr& operator=(auto_ptr& p) _UCXX_USE_NOEXCEPT{ + if(&p == this){ + return *this; + } + delete object; + object = p.release(); + return *this; + } + ~auto_ptr(){ + delete object; + } + + T& operator*() const _UCXX_USE_NOEXCEPT{ + return *object; + } + T* operator->() const _UCXX_USE_NOEXCEPT{ + return object; + } + T* get() const _UCXX_USE_NOEXCEPT{ + return object; + } + T* release() _UCXX_USE_NOEXCEPT{ + T * temp(object); + object = 0; + return temp; + } + void reset(T * p=0) _UCXX_USE_NOEXCEPT{ + if(p != object){ + delete object; + object = p; + } + } + template operator auto_ptr_ref() _UCXX_USE_NOEXCEPT{ + auto_ptr_ref retval; + retval.p = object; + object = 0; + return retval; + } + template operator auto_ptr() _UCXX_USE_NOEXCEPT{ + auto_ptr retval(object); + object = 0; + return retval; + } + +}; + +} //namespace std + +#pragma GCC visibility pop + +#endif + diff --git a/include/new b/include/new new file mode 100644 index 0000000..6214b11 --- /dev/null +++ b/include/new @@ -0,0 +1,70 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef __STD_NEW_OPERATOR +#define __STD_NEW_OPERATOR 1 + +#pragma GCC visibility push(default) + +namespace std{ + class _UCXXEXPORT bad_alloc : public exception {}; + + struct _UCXXEXPORT nothrow_t {}; + extern const nothrow_t nothrow; + + typedef void (*new_handler)(); + _UCXXEXPORT new_handler set_new_handler(new_handler new_p) _UCXX_USE_NOEXCEPT; +} + + +_UCXXEXPORT void* operator new(std::size_t numBytes) _UCXX_THROW(std::bad_alloc); +_UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT; +#if __cpp_sized_deallocation +_UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT; +#endif + +_UCXXEXPORT void* operator new[](std::size_t numBytes) _UCXX_THROW(std::bad_alloc); +_UCXXEXPORT void operator delete[](void * ptr) _UCXX_USE_NOEXCEPT; +#if __cpp_sized_deallocation +_UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT; +#endif + +#ifndef NO_NOTHROW +_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; +_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; + +_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; +_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; +#endif + + /* Placement operators */ +inline void* operator new(std::size_t, void* ptr) _UCXX_USE_NOEXCEPT {return ptr; } +inline void operator delete(void* , void *) _UCXX_USE_NOEXCEPT { } + +inline void* operator new[](std::size_t, void *p) _UCXX_USE_NOEXCEPT { return p; } +inline void operator delete[](void* , void *) _UCXX_USE_NOEXCEPT {} + +#pragma GCC visibility pop + +#endif + diff --git a/include/numeric b/include/numeric new file mode 100644 index 0000000..25d1b27 --- /dev/null +++ b/include/numeric @@ -0,0 +1,161 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include + +#ifndef __STD_NUMERIC_HEADER +#define __STD_NUMERIC_HEADER 1 + +#pragma GCC visibility push(default) + +namespace std{ + template _UCXXEXPORT + T accumulate(InputIterator first, InputIterator last, T init) + { + while(first != last){ + init = init + *first; + ++first; + } + return init; + } + + template _UCXXEXPORT + T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) + { + while(first != last){ + init = binary_op(init, *first); + ++first; + } + return init; + } + + + template _UCXXEXPORT + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init) + { + while(first1 != last1){ + init = init + *first1 * *first2; + ++first1; + ++first2; + } + return init; + } + + template _UCXXEXPORT + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 binary_op1, + BinaryOperation2 binary_op2) + { + while(first1 != last1){ + init = binary_op1(init, binary_op2(*first1, *first2)); + ++first1; + ++first2; + } + return init; + } + + template _UCXXEXPORT + OutputIterator partial_sum(InputIterator first, InputIterator last, + OutputIterator result) + { + OutputIterator temp(result); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = *first + *temp; + temp = result; + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + OutputIterator partial_sum(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op) + { + OutputIterator temp(result); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = binary_op(*first, *temp); + temp = result; + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + OutputIterator + adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result) + { + OutputIterator temp(first); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = *first - *temp; + temp = first; + ++first; + ++result; + } + + return result; + } + + + template _UCXXEXPORT + OutputIterator + adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op) + { + OutputIterator temp(first); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = binary_op(*first, *temp); + temp = first; + ++first; + ++result; + } + + return result; + } + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/ostream b/include/ostream new file mode 100644 index 0000000..289514c --- /dev/null +++ b/include/ostream @@ -0,0 +1,522 @@ +/* Copyright (C) 2004-2008 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef STD_HEADER_OSTREAM +#define STD_HEADER_OSTREAM 1 + +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +namespace std { + template class basic_ostream; + typedef basic_ostream ostream; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_ostream wostream; +#endif + + template basic_ostream& endl(basic_ostream& os); + template basic_ostream& ends(basic_ostream& os); + template basic_ostream& flush(basic_ostream& os); + + template class _UCXXEXPORT basic_ostream + : virtual public basic_ios + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + + _UCXXEXPORT basic_ostream(basic_streambuf* sb) + : basic_ios(sb) + { + basic_ios::init(sb); + } + virtual _UCXXEXPORT ~basic_ostream(); + + class sentry; + + _UCXXEXPORT basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&)){ + return pf(*this); + } + _UCXXEXPORT basic_ostream& operator<<(basic_ios& (*pf)(basic_ios&)){ + pf(*this); + return *this; + } + _UCXXEXPORT basic_ostream& operator<<(ios_base& (*pf)(ios_base&)){ + pf(*this); + return *this; + } + basic_ostream& operator<<(bool n); + basic_ostream& operator<<(short n); + basic_ostream& operator<<(unsigned short n); + basic_ostream& operator<<(int n); + basic_ostream& operator<<(unsigned int n); + basic_ostream& operator<<(long n); + basic_ostream& operator<<(unsigned long n); + basic_ostream& operator<<(float f); + basic_ostream& operator<<(double f); + basic_ostream& operator<<(long double f); + basic_ostream& operator<<(void* p); + basic_ostream& operator<<(basic_streambuf* sb); +#ifndef __STRICT_ANSI__ + basic_ostream& operator<<(long long n); + basic_ostream& operator<<(unsigned long long n); +#endif + + _UCXXEXPORT basic_ostream& put(char_type c){ + if(basic_ostream::traits_type::eq_int_type( + basic_ios::mstreambuf->sputc(c), + basic_ostream::traits_type::eof())) + { + basic_ios::setstate(ios_base::eofbit); + } + return *this; + } + _UCXXEXPORT basic_ostream& write(const char_type* s, streamsize n){ + if(basic_ostream::traits_type::eq_int_type( + basic_ios::mstreambuf->sputn(s, n), + basic_ostream::traits_type::eof()) + ){ + basic_ios::setstate(ios_base::eofbit); + } + return *this; + } + _UCXXEXPORT basic_ostream& flush(){ + if(basic_ios::mstreambuf->pubsync() == -1){ + basic_ios::setstate(ios_base::badbit); + } + return *this; + } + _UCXXEXPORT pos_type tellp(){ + if(basic_ios::fail() != false){ + return pos_type(-1); + } + return basic_ios::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + } + _UCXXEXPORT basic_ostream& seekp(pos_type pos){ + if( basic_ios::fail() != true ){ + basic_ios::rdbuf()->pubseekpos(pos); + } + return *this; + } + _UCXXEXPORT basic_ostream& seekp(off_type off, ios_base::seekdir dir){ + if( basic_ios::fail() != true){ + basic_ios::rdbuf()->pubseekoff(off, dir); + } + return *this; + } + + _UCXXEXPORT void printout(const char_type* s, streamsize n){ + streamsize extra = ios::width() - n; + if ((ios::flags()&ios::adjustfield) == ios::right){ + while (extra > 0) { + --extra; + put(ios::fill()); + } + } + write(s, n); + if ((ios::flags()&ios::adjustfield) == ios::left) { + while (extra > 0) { + --extra; + put(ios::fill()); + } + } + // Width value only applies for the next output operation. Reset to zero. + ios::width(0); + } + + protected: + basic_ostream(const basic_ostream &){ } + basic_ostream & operator=(const basic_ostream &){ return *this; } + }; + + //Implementations of template functions. To allow for partial specialization + + template _UCXXEXPORT basic_ostream::~basic_ostream(){ } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(bool n){ + sentry s(*this); + if( basic_ios::flags() & ios_base::boolalpha){ + if(n){ + printout("true", 4); + }else{ + printout("false", 5); + } + }else{ + if(n){ + printout("1", 1); + }else{ + printout("0", 1); + } + } + if(basic_ios::flags() & ios_base::unitbuf){ + flush(); + } + return *this; + } + + template _UCXXEXPORT basic_ostream& + basic_ostream::operator<<(unsigned short n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(short n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(int n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(unsigned int n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& + basic_ostream::operator<<(unsigned long n) + { + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + +#ifndef __STRICT_ANSI__ + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long long n) + { + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(unsigned long long n) + { + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } +#endif + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(float f){ + sentry s(*this); + __ostream_printout::printout(*this, f); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(double f){ + sentry s(*this); + __ostream_printout::printout(*this, f); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long double f){ + sentry s(*this); + __ostream_printout::printout(*this, f); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(void* p){ + sentry s(*this); + char buffer[20]; + printout(buffer, snprintf(buffer, 20, "%p", p) ); + if(basic_ios::flags() & ios_base::unitbuf){ + flush(); + } + return *this; + } + + template _UCXXEXPORT basic_ostream& + basic_ostream::operator<<(basic_streambuf* sb) + { + sentry s(*this); + if(sb == 0){ + basic_ios::setstate(ios_base::badbit); + return *this; + } + + typename traits::int_type c; + + while(basic_ios::good() && (c = sb->sbumpc()) != traits::eof() ){ + put(c); + } + + if(basic_ios::flags() & ios_base::unitbuf){ + flush(); + } + return *this; + } + + /*Template Specializations*/ + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_OSTREAM__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT ostream::~basic_ostream(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT ostream & ostream::flush(); + + template <> _UCXXEXPORT ostream & ostream::operator<<(bool n); + template <> _UCXXEXPORT ostream & ostream::operator<<(short int n); + template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n); + template <> _UCXXEXPORT ostream & ostream::operator<<(int n); + template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned int n); + template <> _UCXXEXPORT ostream & ostream::operator<<(long n); + template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned long n); + template <> _UCXXEXPORT ostream & ostream::operator<<(float f); + template <> _UCXXEXPORT ostream & ostream::operator<<(double f); + template <> _UCXXEXPORT ostream & ostream::operator<<(long double f); + template <> _UCXXEXPORT ostream & ostream::operator<<(void* p); + template <> _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf >* sb); +#endif +#endif + + template + class _UCXXEXPORT basic_ostream::sentry + { + bool ok; + public: + explicit _UCXXEXPORT sentry(basic_ostream& os): ok(true){ + if(os.good() !=0){ //Prepare for output + } + + //Flush any tied buffer + if(os.tie() !=0 ){ + os.tie()->flush(); + } + } + _UCXXEXPORT ~sentry() { } + _UCXXEXPORT operator bool() { + return ok; + } + }; + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_OSTREAM__ +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os); + template <> _UCXXEXPORT ostream::sentry::~sentry(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ +#endif +#endif + + + //Non - class functions + + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, charT c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + // signed and unsigned + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, signed char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, unsigned char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const charT* c) + { + typename basic_ostream::sentry s(out); + out.printout(c, traits::length(c) ); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const char* c) + { + typename basic_ostream::sentry s(out); + out.printout(c, char_traits::length(c) ); + return out; + } + + // partial specializations + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const char* c) + { + typename basic_ostream::sentry s(out); + out.printout(c, traits::length(c)); + return out; + } + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const char* c) + { + typename basic_ostream::sentry s(out); + size_t numChars = char_traits::length(c); + wchar_t * temp = new wchar_t[numChars]; + + for(size_t i=0; i < numChars; ++i){ + temp[i] = out.widen(c[i]); + } + + out.printout(temp, numChars); + return out; + } +#endif + + // signed and unsigned + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const signed char* c) + { + typename basic_ostream::sentry s(out); + out.printout(reinterpret_cast(c), traits::length( reinterpret_cast(c))); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const unsigned char* c) + { + typename basic_ostream::sentry s(out); + out.printout(reinterpret_cast(c), traits::length( reinterpret_cast(c))); + return out; + } + + template _UCXXEXPORT basic_ostream& + endl(basic_ostream& os) + { + typename basic_ostream::sentry s(os); + os.put('\n'); + os.flush(); + return os; + } + + template _UCXXEXPORT basic_ostream& + ends(basic_ostream& os) + { + typename basic_ostream::sentry s(os); + os.put(traits::eos()); + return os; + } + + template _UCXXEXPORT basic_ostream& flush(basic_ostream& os){ + typename basic_ostream::sentry s(os); + os.flush(); + return os; + } + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_OSTREAM__ + template <> _UCXXEXPORT ostream & endl(ostream & os); + template <> _UCXXEXPORT ostream & flush(ostream & os); + template <> _UCXXEXPORT ostream & operator<<(ostream & out, char c); + template <> _UCXXEXPORT ostream & operator<<(ostream & out, const char* c); + template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c); + template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned const char* c); + +#endif +#endif + + +#ifndef __STRICT_ANSI__ + +//Support for output of long long data types + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, signed long long int i) +{ + typename basic_ostream::sentry s(os); + __ostream_printout::printout(os, i); + return os; +} + + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, unsigned long long int i) +{ + typename basic_ostream::sentry s(os); + __ostream_printout::printout(os, i); + return os; +} + + +#endif //__STRICT_ANSI__ + + + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/ostream_helpers b/include/ostream_helpers new file mode 100644 index 0000000..fa50407 --- /dev/null +++ b/include/ostream_helpers @@ -0,0 +1,490 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include + +#ifndef __STD_HEADER_OSTREAM_HELPERS +#define __STD_HEADER_OSTREAM_HELPERS 1 + +#pragma GCC visibility push(default) + +namespace std{ + + /* We are making the following template class for serveral reasons. Firstly, + * we want to keep the main ostream code neat and tidy. Secondly, we want it + * to be easy to do partial specialization of the ostream code so that it can + * be expanded and put into the library. This will allow us to make application + * code smaller at the expense of increased library size. This is a fair + * trade-off when there are multiple applications being compiled. Also, this + * feature will be used optionally via configuration options. It will also + * allow us to keep the code bases in sync, dramatically simplifying the + * maintenance required. We specialized for char because wchar and others + * require different scanf functions + */ + + + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const dataType n); + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long int n) + { + char buffer[20]; + const char * c_ld = "%ld"; + const char * c_lo = "%lo"; + const char * c_lX = "%lX"; + const char * c_lx = "%lx"; + const char * c_hashlo = "%#lo"; + const char * c_hashlX = "%#lX"; + const char * c_hashlx = "%#lx"; + + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = c_ld; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = c_hashlo; + }else{ + formatString = c_lo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = c_hashlX; + }else{ + formatString = c_hashlx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = c_lX; + }else{ + formatString = c_lx; + } + } + } + + stream.printout(buffer, snprintf(buffer, 20, formatString, n) ); + + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long int n) + { + char buffer[20]; + const char * c_lo = "%lo"; + const char * c_lu = "%lu"; + const char * c_lX = "%lX"; + const char * c_lx = "%lx"; + const char * c_hashlo = "%#lo"; + const char * c_hashlX = "%#lX"; + const char * c_hashlx = "%#lx"; + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = c_lu; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = c_hashlo; + }else{ + formatString = c_lo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = c_hashlX; + }else{ + formatString = c_hashlx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = c_lX; + }else{ + formatString = c_lx; + } + } + } + + stream.printout(buffer, snprintf(buffer, 20, formatString, n)); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + +#ifndef __STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long long int n) + { + char buffer[28]; + const char * lld = "%lld"; + const char * llo = "%llo"; + const char * llX = "%llX"; + const char * llx = "%llx"; + const char * hashllo = "%#llo"; + const char * hashllX = "%#llX"; + const char * hashllx = "%#llx"; + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = lld; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = hashllo; + }else{ + formatString = llo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = hashllX; + }else{ + formatString = hashllx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = llX; + }else{ + formatString = llx; + } + } + } + + stream.printout(buffer, snprintf(buffer, 27, formatString, n) ); + + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long long int n) + { + char buffer[28]; + const char * llo = "%llo"; + const char * llu = "%llu"; + const char * llX = "%llX"; + const char * llx = "%llx"; + const char * hashllo = "%#llo"; + const char * hashllX = "%#llX"; + const char * hashllx = "%#llx"; + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = llu; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = hashllo; + }else{ + formatString = llo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = hashllX; + }else{ + formatString = hashllx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = llX; + }else{ + formatString = llx; + } + } + } + + stream.printout(buffer, snprintf(buffer, 27, formatString, n) ); + + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + +#endif //__STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const double f) + { + char buffer[32]; + int length; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + length = snprintf(buffer, 32, "%*.*E", static_cast(stream.width()),static_cast(stream.precision()), f); + }else{ + length = snprintf(buffer, 32, "%*.*e", static_cast(stream.width()),static_cast(stream.precision()), f); + } + } else if(stream.flags() & ios_base::fixed){ + length = snprintf(buffer, 32, "%*.*f",static_cast(stream.width()),static_cast(stream.precision()), f); + } else { + length = snprintf(buffer, 32, "%*.*g",static_cast(stream.width()),static_cast(stream.precision()), f); + } + stream.printout(buffer, length); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const long double f) + { + char buffer[32]; + int length; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + length = snprintf(buffer, 32, "%*.*LE", static_cast(stream.width()), static_cast(stream.precision()), f); + }else{ + length = snprintf(buffer, 32, "%*.*Le", static_cast(stream.width()), static_cast(stream.precision()), f); + } + } else if(stream.flags() & ios_base::fixed){ + length = snprintf(buffer, 32, "%*.*Lf", static_cast(stream.width()), static_cast(stream.precision()), f); + } else { + length = snprintf(buffer, 32, "%*.*Lg", static_cast(stream.width()), static_cast(stream.precision()), f); + } + stream.printout(buffer, length); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + + } + }; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long int n) + { + wchar_t buffer[20]; + if( stream.flags() & ios_base::dec){ + stream.printout(buffer, swprintf(buffer, 20, L"%ld", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.printout(buffer, swprintf(buffer, 20, L"%#lo", n)); + }else{ + stream.printout(buffer, swprintf(buffer, 20, L"%lo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 20, L"%#lX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 20, L"%#lx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 20, L"%lX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 20, L"%lx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long int n) + { + wchar_t buffer[20]; + if( stream.flags() & ios_base::dec){ + stream.printout(buffer, swprintf(buffer, 20, L"%lu", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.printout(buffer, swprintf(buffer, 20, L"%#lo", n)); + }else{ + stream.printout(buffer, swprintf(buffer, 20, L"%lo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 20, L"%#lX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 20, L"%#lx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 20, L"%lX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 20, L"%lx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + +#ifndef __STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long long int n) + { + wchar_t buffer[28]; + if( stream.flags() & ios_base::dec){ + stream.printout(buffer, swprintf(buffer, 27, L"%lld", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.printout(buffer, swprintf(buffer, 27, L"%#llo", n)); + }else{ + stream.printout(buffer, swprintf(buffer, 27, L"%llo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 27, L"%#llX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 27, L"%#llx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 27, L"%llX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 27, L"%llx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long long int n) + { + wchar_t buffer[28]; + if( stream.flags() & ios_base::dec){ + stream.printout(buffer, swprintf(buffer, 27, L"%llu", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.printout(buffer, swprintf(buffer, 27, L"%#llo", n)); + }else{ + stream.printout(buffer, swprintf(buffer, 27, L"%llo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 27, L"%#llX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 27, L"%#llx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.printout(buffer, swprintf(buffer, 27, L"%llX", n) ); + }else{ + stream.printout(buffer, swprintf(buffer, 27, L"%llx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + +#endif //__STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const double f) + { + wchar_t buffer[32]; + wchar_t format_string[32]; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + swprintf(format_string, 32, L"%%%u.%uE", static_cast(stream.width()), static_cast(stream.precision())); + }else{ + swprintf(format_string, 32, L"%%%u.%ue", static_cast(stream.width()), static_cast(stream.precision())); + } + } else if(stream.flags() & ios_base::fixed){ + swprintf(format_string, 32, L"%%%u.%uf", static_cast(stream.width()), static_cast(stream.precision())); + } else { + swprintf(format_string, 32, L"%%%u.%ug", static_cast(stream.width()), static_cast(stream.precision())); + } + stream.printout(buffer, swprintf(buffer, 32, format_string, f) ); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const long double f) + { + wchar_t buffer[32]; + wchar_t format_string[32]; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + swprintf(format_string, 32, L"%%%u.%uLE", static_cast(stream.width()), static_cast(stream.precision())); + }else{ + swprintf(format_string, 32, L"%%%u.%uLe", static_cast(stream.width()), static_cast(stream.precision())); + } + } else if(stream.flags() & ios_base::fixed){ + swprintf(format_string, 32, L"%%%u.%uLf", static_cast(stream.width()), static_cast(stream.precision())); + } else { + swprintf(format_string, 32, L"%%%u.%uLg", static_cast(stream.width()), static_cast(stream.precision())); + } + stream.printout(buffer, swprintf(buffer, 32, format_string, f) ); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + +#endif //__UCLIBCXX_HAS_WCHAR__ + +} + +#pragma GCC visibility pop + +#endif + + + diff --git a/include/queue b/include/queue new file mode 100644 index 0000000..b817b1d --- /dev/null +++ b/include/queue @@ -0,0 +1,126 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + 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 +#include +#include +#include + +#ifndef __HEADER_STD_QUEUE +#define __HEADER_STD_QUEUE 1 + +#pragma GCC visibility push(default) + +namespace std{ + + template > class _UCXXEXPORT queue{ + protected: + Container c; + public: + typedef typename Container::value_type value_type; + typedef typename Container::size_type size_type; + typedef Container container_type; + + explicit queue(const Container& a = Container()) : c(a) { } + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& front() { return c.front(); } + const value_type& front() const { return c.front(); } + value_type& back() { return c.back(); } + const value_type& back() const { return c.back(); } + void push(const value_type& x) { c.push_back(x); } + void pop() { c.pop_front(); } + }; + + + template _UCXXEXPORT bool + operator==(const queue& x, const queue& y) + { + return (x.c == y.c); + } + template _UCXXEXPORT bool + operator< (const queue& x, const queue& y) + { + return (x.c < y.c); + } + template _UCXXEXPORT bool + operator!=(const queue& x, const queue& y) + { + return (x.c != y.c); + } + template _UCXXEXPORT bool + operator> (const queue& x, const queue& y) + { + return (x.c > y.c); + } + template _UCXXEXPORT bool + operator>=(const queue& x, const queue& y) + { + return (x.c >= y.c); + } + template _UCXXEXPORT bool + operator<=(const queue& x, const queue& y) + { + return (x.c <= y.c); + } + + + template , + class Compare = less + > class _UCXXEXPORT priority_queue { + protected: + Container c; + Compare comp; + public: + typedef typename Container::value_type value_type; + typedef typename Container::size_type size_type; + typedef Container container_type; + + explicit priority_queue(const Compare& x = Compare(), const Container& a = Container()) + : c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; } + template priority_queue(InputIterator first, + InputIterator last, + const Compare& x = Compare(), + const Container& y= Container()) + : c(y), comp(c) + { + c.insert(c.end(), first, last); + make_heap(c.begin(), c.end(), comp); + } + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + const value_type& top() const { return c.front(); } + void push(const value_type& x){ + c.push_back(x); + push_heap(c.begin(), c.end(), comp); + } + void pop(){ + pop_heap(c.begin(), c.end(), comp); + c.pop_back(); + } + }; + +} + +#pragma GCC visibility pop + +#endif + + diff --git a/include/set b/include/set new file mode 100644 index 0000000..f376e47 --- /dev/null +++ b/include/set @@ -0,0 +1,406 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include +#include + +#ifndef __STD_HEADER_SET +#define __STD_HEADER_SET + +#pragma GCC visibility push(default) + +namespace std{ + + +template, class Allocator = allocator > class set; +template, class Allocator = allocator > class multiset; + + +/* This is the implementation for the set container. As noted above, it deviates + * from ISO spec by deriving from a base class in order to reduce code redundancy. + * More code could be reduced by convirting to virtual functions (thus allowing + * much of the erase and insert code to be duplicated), but that would deviate from + * the specifications too much to be worth the risk. + */ + + +//Implementation of set + + +template class _UCXXEXPORT set + : public __single_associative +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __single_associative base; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + +// using base::value_compare; + + static const key_type v_t_k(const value_type v){ + return v; + } + + explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template set(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + set(const set& x) : base(x) { } + ~set() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + +protected: + +}; + + +//Implementation of multiset + + +template class _UCXXEXPORT multiset + : public __multi_associative +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __multi_associative base; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + static const key_type v_t_k(const value_type v){ + return v; + } + + explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template multiset(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + + multiset(const multiset& x) : base(x) { } + ~multiset() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + +protected: + +}; + + +/* Non-member functions. These are at the end because they are not associated with any + particular class. These will be implemented as I figure out exactly what all of + them are supposed to do, and I have time. + */ + + template _UCXXEXPORT bool operator< + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + template _UCXXEXPORT bool operator> + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1 && first2 == last2; + } + + template _UCXXEXPORT bool operator>= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1; + } + + template _UCXXEXPORT bool operator<= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first2!=last2; + } + template _UCXXEXPORT void swap + (set& x, set& y) + { + x.swap(y); + } + + + template _UCXXEXPORT bool operator== + (const multiset& x, const multiset& y) + { + if(x.data == y.data){ + return true; + } + return false; + } + + template _UCXXEXPORT bool operator< + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + template _UCXXEXPORT bool operator!= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 != *first2 ){ + return true; + } + ++first1; + ++first2; + } + return first1!=last1 || first2 != last2; + } + + template _UCXXEXPORT bool operator> + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1 && first2 == last2; + } + + template _UCXXEXPORT bool operator>= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1; + } + + template _UCXXEXPORT bool operator<= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first2!=last2; + } + + template _UCXXEXPORT void swap + (multiset& x, multiset& y) + { + x.swap(y); + } + + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/sstream b/include/sstream new file mode 100644 index 0000000..2969853 --- /dev/null +++ b/include/sstream @@ -0,0 +1,384 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef HEADER_STD_SSTREAM +#define HEADER_STD_SSTREAM 1 + +#include +#include +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template + class _UCXXEXPORT basic_stringbuf : public basic_streambuf + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef typename Allocator::size_type size_type; + + explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out) + : data(), ielement(0), oelement(0) + { + basic_streambuf::openedFor = which; + } + + explicit _UCXXEXPORT basic_stringbuf(const basic_string& str, + ios_base::openmode which = ios_base::in | ios_base::out) + : data(str), ielement(0), oelement(0) + { + if(which & ios_base::ate){ + oelement = data.length(); + } + basic_streambuf::openedFor = which; + } + + virtual _UCXXEXPORT ~basic_stringbuf() { } + + _UCXXEXPORT basic_string str() const{ + return data; + } + + _UCXXEXPORT void str(const basic_string& s){ + data = s; + ielement = 0; + if(basic_streambuf::openedFor & ios_base::ate){ + oelement = data.length(); + }else{ + oelement = 0; + } + } + + protected: + virtual _UCXXEXPORT int sync(){ + return 0; + } + virtual _UCXXEXPORT int_type underflow(){ + if(ielement >= data.length()){ + return traits::eof(); + } + return traits::to_int_type(data[ielement]); + } + + virtual _UCXXEXPORT int_type uflow(){ + int_type retval = underflow(); + if(retval != traits::eof()){ + ++ielement; + } + return retval; + } + + virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ + //Error possibilities + if(ielement == 0){ + return traits::eof(); + } + if(ielement > data.length()){ + ielement = data.length(); + return traits::eof(); + } + //eof passed in + if(traits::eq_int_type(c,traits::eof())==true){ + --ielement; + return traits::not_eof(c); + } + if(traits::eq(traits::to_char_type(c),data[ielement-1]) == true){ + --ielement; + return c; + } + if(basic_streambuf::openedFor & ios_base::out){ + --ielement; + data[ielement] = c; + return c; + } + return traits::eof(); + } + + virtual _UCXXEXPORT int showmanyc(){ + return data.length() - ielement; + } + virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n){ + streamsize i = 0; + while(ielement < data.length() && i < n ){ + c[i] = data[ielement]; + ++i; + ++ielement; + } + return i; + } + + virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof()){ + //Nothing to do + if(traits::eq_int_type(c,traits::eof())){ + return traits::not_eof(c); + } + + //Actually add character, if possible + if(basic_streambuf::openedFor & ios_base::out){ + if(oelement >= data.length()){ + data.push_back(c); + }else{ + data[oelement] = c; + } + ++oelement; + return c; + } + //Not possible + return traits::eof(); + } + + virtual _UCXXEXPORT basic_streambuf* setbuf(charT*, streamsize){ + //This function does nothing + return this; + } + + virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ + data.replace(oelement, n, s, n); + oelement += n; + return n; + } + + virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, + ios_base::openmode which = ios_base::in | ios_base::out) + { + //Test for invalid option + if( (which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur)){ + return -1; + } + + //Calculate new location + size_type newpos = 0; + + if(way == ios_base::beg){ + newpos = off; + }else if(way == ios_base::cur){ + if(which & ios_base::out){ + newpos = data.length() + off; + } + if(which & ios_base::in){ + newpos = ielement + off; + } + + }else{ + newpos = data.length() + off; + } + + //Test for error conditions + if(newpos > data.length()){ + return -1; + } + + //Shuffle pointers + + if(which & ios_base::in){ + ielement = newpos; + } + if(which & ios_base::out){ + data.resize(newpos); + if(ielement > data.length()){ + ielement = data.length(); + } + } + + return newpos; + } + + virtual _UCXXEXPORT pos_type seekpos(pos_type sp, + ios_base::openmode which = ios_base::in | ios_base::out) + { + return seekoff(sp, ios_base::beg, which); + } + + basic_string data; + size_type ielement; + size_type oelement; + }; + + + template class _UCXXEXPORT basic_istringstream + : public basic_istream + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + + explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in) + : basic_ios(&sb), basic_istream(&sb), sb(m) + { + } + explicit _UCXXEXPORT basic_istringstream( const basic_string& str, + ios_base::openmode which = ios_base::in) + : basic_ios(&sb), basic_istream(&sb), sb(str, which) + { + } + virtual _UCXXEXPORT ~basic_istringstream() { } + _UCXXEXPORT basic_stringbuf* rdbuf() const{ + return &sb; + } + _UCXXEXPORT basic_string str() const{ + return sb.str(); + } + _UCXXEXPORT void str(const basic_string& s){ + sb.str(s); + basic_istream::clear(); + } + private: + basic_stringbuf sb; + }; + + + template class _UCXXEXPORT basic_ostringstream + : public basic_ostream + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out) + : basic_ios(&sb), basic_ostream(&sb), sb(m) + { + } + explicit _UCXXEXPORT basic_ostringstream(const basic_string& str, + ios_base::openmode which = ios_base::out) + : basic_ios(&sb), basic_ostream(&sb), sb(str, which) + { + } + virtual _UCXXEXPORT ~basic_ostringstream() { } + + _UCXXEXPORT basic_stringbuf* rdbuf() const{ + return &sb; + } + _UCXXEXPORT basic_string str() const{ + return sb.str(); + } + _UCXXEXPORT void str(const basic_string& s){ + sb.str(s); + basic_ostream::clear(); + } + private: + basic_stringbuf sb; + }; + + + template class _UCXXEXPORT basic_stringstream + : public basic_iostream + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in) + : basic_ios(&sb), basic_iostream(&sb), sb(which) + { + } + + explicit _UCXXEXPORT basic_stringstream(const basic_string& str, + ios_base::openmode which = ios_base::out|ios_base::in) + : basic_ios(&sb), basic_iostream(&sb), sb(str, which) + { + } + virtual _UCXXEXPORT ~basic_stringstream(){ } + + _UCXXEXPORT basic_stringbuf* rdbuf(){ + return &sb; + } + _UCXXEXPORT basic_string str() const{ + return sb.str(); + } + _UCXXEXPORT void str(const basic_string& s){ + sb.str(s); + basic_iostream::clear(); + } + private: + basic_stringbuf sb; + }; + +#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_SSTREAM__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_stringbuf, allocator >:: + basic_stringbuf(ios_base::openmode which); + template <> _UCXXEXPORT basic_stringbuf, allocator >::~basic_stringbuf(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_string, allocator > + basic_stringbuf, allocator >::str() const; + + template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type + basic_stringbuf, allocator >:: + pbackfail(basic_stringbuf, allocator >::int_type c); + + template <> _UCXXEXPORT basic_stringbuf, allocator >::pos_type + basic_stringbuf, allocator >:: + seekoff (basic_stringbuf, allocator >::off_type off, + ios_base::seekdir way, + ios_base::openmode which + ); + + template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type + basic_stringbuf, allocator >:: + overflow (basic_stringbuf, allocator >::int_type c); + + template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type + basic_stringbuf, allocator >::underflow (); + + template <> _UCXXEXPORT streamsize basic_stringbuf, allocator >:: + xsputn(const char* s, streamsize n); + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_stringstream, allocator >:: + basic_stringstream(ios_base::openmode which); + template <> _UCXXEXPORT basic_stringstream, allocator >::~basic_stringstream(); + template <> _UCXXEXPORT basic_istringstream, allocator >::~basic_istringstream(); + template <> _UCXXEXPORT basic_ostringstream, allocator >::~basic_ostringstream(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + +#endif +#endif + +#pragma GCC visibility pop + +} + + +#endif diff --git a/include/stack b/include/stack new file mode 100644 index 0000000..d4861b3 --- /dev/null +++ b/include/stack @@ -0,0 +1,84 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + 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 +#include + +#ifndef __HEADER_STD_STACK +#define __HEADER_STD_STACK 1 + +#pragma GCC visibility push(default) + +namespace std{ + + template > class _UCXXEXPORT stack{ + protected: + Container c; + + public: + typedef typename Container::value_type value_type; + typedef typename Container::size_type size_type; + typedef Container container_type; + + explicit stack(const Container& a = Container()) : c(a) { }; + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& top() { return c.back(); } + const value_type& top() const { return c.back(); } + void push(const value_type& x) { c.push_back(x); } + void pop() { c.pop_back(); } + + bool operator==(const stack &x) const{ + return x.c == c; + } + + }; + + + template _UCXXEXPORT bool + operator< (const stack& x, const stack& y) + { + return (x.c < y.c); + } + template _UCXXEXPORT bool + operator!=(const stack& x, const stack& y) + { + return (x.c != y.c); + } + template _UCXXEXPORT bool + operator> (const stack& x, const stack& y) + { + return (x.c > y.c); + } + template _UCXXEXPORT bool + operator>=(const stack& x, const stack& y) + { + return (x.c >= y.c); + } + template _UCXXEXPORT bool + operator<=(const stack& x, const stack& y) + { + return (x.c <= y.c); + } + +} + +#pragma GCC visibility pop + +#endif + + diff --git a/include/stdexcept b/include/stdexcept new file mode 100644 index 0000000..76c3870 --- /dev/null +++ b/include/stdexcept @@ -0,0 +1,117 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef HEADER_STD_EXCEPTIONS +#define HEADER_STD_EXCEPTIONS 1 + +//Don't include support if not needed +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +#pragma GCC visibility push(default) + +namespace std{ + +//typedef basic_string string; + +class _UCXXEXPORT logic_error : public exception { +protected: + string mstring; +public: + logic_error() _UCXX_USE_NOEXCEPT; + logic_error(const string& what_arg); + + virtual ~logic_error() _UCXX_USE_NOEXCEPT {} + virtual const char * what() const _UCXX_USE_NOEXCEPT; + +}; + +class _UCXXEXPORT domain_error : public logic_error { +public: + domain_error() : logic_error() {} + domain_error(const string& what_arg) : logic_error(what_arg) {} + virtual ~domain_error() _UCXX_USE_NOEXCEPT {} +}; + +class _UCXXEXPORT invalid_argument : public logic_error { +public: + invalid_argument() : logic_error(){} + invalid_argument(const string& what_arg) : logic_error(what_arg){} + virtual ~invalid_argument() _UCXX_USE_NOEXCEPT {} +}; + +class _UCXXEXPORT length_error : public logic_error { +public: + length_error() : logic_error(){} + length_error(const string& what_arg) : logic_error(what_arg){} + virtual ~length_error() _UCXX_USE_NOEXCEPT {} +}; + +class _UCXXEXPORT out_of_range : public logic_error{ +public: + out_of_range(); + out_of_range(const string & what_arg); + virtual ~out_of_range() _UCXX_USE_NOEXCEPT {} + +}; + +class _UCXXEXPORT runtime_error : public exception{ +protected: + string mstring; +public: + runtime_error(); + runtime_error(const string& what_arg); + + virtual ~runtime_error() _UCXX_USE_NOEXCEPT {} + virtual const char * what() const _UCXX_USE_NOEXCEPT; +}; + +class _UCXXEXPORT range_error : public runtime_error{ +public: + range_error() : runtime_error(){} + range_error(const string& what_arg) : runtime_error(what_arg) {} + virtual ~range_error() _UCXX_USE_NOEXCEPT{ } +}; + + +class _UCXXEXPORT overflow_error : public runtime_error{ +public: + overflow_error() : runtime_error(){} + overflow_error(const string& what_arg) : runtime_error(what_arg) {} + virtual ~overflow_error() _UCXX_USE_NOEXCEPT{} +}; + +class _UCXXEXPORT underflow_error : public runtime_error{ +public: + underflow_error() : runtime_error(){} + underflow_error(const string& what_arg) : runtime_error(what_arg) {} + virtual ~underflow_error() _UCXX_USE_NOEXCEPT{} +}; + + + +} + +#pragma GCC visibility pop + +#endif +#endif diff --git a/include/streambuf b/include/streambuf new file mode 100644 index 0000000..0daa388 --- /dev/null +++ b/include/streambuf @@ -0,0 +1,329 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include + +#ifndef HEADER_STD_STREAMBUF +#define HEADER_STD_STREAMBUF 1 + +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template class _UCXXEXPORT basic_streambuf{ + public: +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + friend ios_base::Init::Init(); +#endif + // Types: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + virtual ~basic_streambuf(); + + locale pubimbue(const locale &loc); + + locale getloc() const{ + return myLocale; + } + + basic_streambuf* pubsetbuf(char_type* s, streamsize n){ + return setbuf(s,n); + } + pos_type pubseekoff(off_type off, + typename ios_base::seekdir way, + ios_base::openmode which = ios_base::in | + ios_base::out + ) + { + return seekoff(off,way,which); + } + pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out){ + return seekpos(sp,which); + } + int pubsync(){ + return sync(); + } + + streamsize in_avail(); + + int_type snextc(); + + int_type sbumpc(); + + int_type sgetc(); + + streamsize sgetn(char_type* s, streamsize n){ + return xsgetn(s,n); + } + + int_type sputbackc(char_type c); + + int_type sungetc(); + + int_type sputc(char_type c); + + streamsize sputn(const char_type* s, streamsize n){ + if(openedFor & ios_base::app){ + seekoff(0, ios_base::end, ios_base::out); + } + return xsputn(s, n); + } + + protected: + locale myLocale; + //Pointers for the "get" buffers + charT * mgbeg; + charT * mgnext; + charT * mgend; + + //Pointers for the "put" buffers + charT * mpbeg; + charT * mpnext; + charT * mpend; + + //In the event of null buffers Lets us know what the buffer is opened for + ios_base::openmode openedFor; + + basic_streambuf(); + + basic_streambuf(const basic_streambuf > &) + : myLocale(), + mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), + openedFor(0) + { } + basic_streambuf > & operator=(const basic_streambuf > &){ + return *this; + } + + char_type* eback() const{ + return mgbeg; + } + char_type* gptr() const{ + return mgnext; + } + char_type* egptr() const{ + return mgend; + } + void gbump(int n){ + mgnext+=n; + } + void setg(char_type* gbeg, char_type* gnext, char_type* gend){ + mgbeg = gbeg; + mgnext = gnext; + mgend = gend; + } + + char_type* pbase() const{ + return mpbeg; + } + char_type* pptr() const{ + return mpnext; + } + char_type* epptr() const{ + return mpend; + } + void pbump(int n){ + mpnext+=n; + } + void setp(char_type* pbeg, char_type* pend){ + mpbeg = pbeg; + mpnext = pbeg; + mpend = pend; + } + + virtual void imbue(const locale &loc){ + myLocale = loc; + } + + //Virtual functions which we will not implement + + virtual basic_streambuf* setbuf(char_type* , streamsize){ + return 0; + } + virtual pos_type seekoff(off_type , ios_base::seekdir, + ios_base::openmode = ios_base::in | ios_base::out) + { + return 0; + } + virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out){ + return 0; + } + virtual int sync(){ + return 0; + } + + virtual int showmanyc(){ + return 0; + } + virtual streamsize xsgetn(char_type* , streamsize ){ + return 0; + } + virtual int_type underflow(){ + return traits_type::eof(); + } + virtual int_type uflow(){ + int_type ret = underflow(); + if (!traits_type::eq_int_type(ret, traits_type::eof())) + gbump(1); + return ret; + } + + virtual int_type pbackfail(int_type c = traits::eof()){ + return c; + } + virtual streamsize xsputn(const char_type* c, streamsize n){ + //This function is designed to be replaced by subclasses + for(streamsize i = 0; i< n; ++i){ + if(sputc(c[i]) == traits::eof()){ + return i; + } + } + return n; + } + virtual int_type overflow (int_type c = traits::eof()){ + return c; + } + }; + + typedef basic_streambuf streambuf; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_streambuf wstreambuf; +#endif + + +//Definitions put below to allow for easy expansion of code + + template basic_streambuf::~basic_streambuf(){ } + + template locale basic_streambuf::pubimbue(const locale &loc){ + locale temp = myLocale; + myLocale = loc; + return temp; + } + + template streamsize basic_streambuf::in_avail(){ + if(mgend !=0 && mgnext !=0){ + return mgend - mgnext; + } + return showmanyc(); + } + + template typename basic_streambuf::int_type basic_streambuf::sbumpc(){ + if(mgbeg == 0 || mgnext == mgend){ + return uflow(); + } + int_type retval = T::to_int_type(*gptr()); + gbump(1); + return retval; + } + + template typename basic_streambuf::int_type basic_streambuf::snextc(){ + if(sbumpc() == T::eof() ){ + return T::eof() ; + } + return sgetc(); + } + + template typename basic_streambuf::int_type basic_streambuf::sgetc(){ + if(mgbeg == 0 || mgnext == mgend){ + return underflow(); + } + return T::to_int_type(*gptr()); + } + + template typename basic_streambuf::int_type basic_streambuf::sputbackc(char_type c){ + if(mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1] )){ + return pbackfail(T::to_int_type(c)); + } + gbump(-1); + return T::to_int_type(*gptr()); + } + + template typename basic_streambuf::int_type basic_streambuf::sungetc(){ + if(mgbeg == 0 || mgnext == mgbeg){ + return ios_base::failbit; + } + gbump(-1); + return T::to_int_type(*gptr()); + } + + template typename basic_streambuf::int_type basic_streambuf::sputc(char_type c){ + if(openedFor & ios_base::app){ + seekoff(0, ios_base::end, ios_base::out); + } + if(mpnext < mpend){ + *mpnext = c; + ++mpnext; + }else{ + return overflow( T::to_int_type(c) ); + } + return T::to_int_type(c); + } + + template basic_streambuf::basic_streambuf() + : myLocale(), + mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), + openedFor(0) + { } + + + + + + +#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STREAMBUF__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT streambuf::basic_streambuf(); + template <> _UCXXEXPORT streambuf::~basic_streambuf(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT locale streambuf::pubimbue(const locale &loc); + template <> _UCXXEXPORT streamsize streambuf::in_avail(); + template <> _UCXXEXPORT streambuf::int_type streambuf::sbumpc(); + template <> _UCXXEXPORT streambuf::int_type streambuf::snextc(); + template <> _UCXXEXPORT streambuf::int_type streambuf::sgetc(); + template <> _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c); + template <> _UCXXEXPORT streambuf::int_type streambuf::sungetc(); + template <> _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c); + +#endif +#endif + + + + + +} + +#pragma GCC visibility pop + +#endif diff --git a/include/string b/include/string new file mode 100644 index 0000000..a790715 --- /dev/null +++ b/include/string @@ -0,0 +1,1043 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include +#include + + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif + +#ifndef __HEADER_STD_STRING +#define __HEADER_STD_STRING 1 + +#pragma GCC visibility push(default) + +namespace std{ + + //Basic basic_string + + template, class A = allocator > class basic_string; + + typedef basic_string string; + #ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_string wstring; + #endif + + + +//template, class A = allocator > class _UCXXEXPORT basic_string +template class basic_string + : public std::vector +{ +public: + typedef Tr traits_type; + typedef typename Tr::char_type value_type; + typedef A allocator_type; + typedef typename A::size_type size_type; + typedef typename A::difference_type difference_type; + + typedef typename A::reference reference; + typedef typename A::const_reference const_reference; + typedef typename A::pointer pointer; + typedef typename A::const_pointer const_pointer; + + typedef typename vector::iterator iterator; + typedef typename vector::const_iterator const_iterator; + + typedef typename vector::reverse_iterator reverse_iterator; + typedef typename vector::const_reverse_iterator const_reverse_iterator; + + static const size_type npos = (size_type)-1; + + explicit _UCXXEXPORT basic_string(const A& al = A()) : vector(al){ return; } + + _UCXXEXPORT basic_string(const basic_string& str, size_type pos = 0, size_type n = npos, const A& al = A()); //Below + + _UCXXEXPORT basic_string(const Ch* s, size_type n, const A& al = A()) + : vector(al) + { + if(n == npos){ + __throw_out_of_range(); + } + if (*s > 0){ + resize(n); + Tr::copy(vector::data, s, vector::elements); + } + } + + _UCXXEXPORT basic_string(const Ch* s, const A& al = A()); //Below + + _UCXXEXPORT basic_string(size_type n, Ch c, const A& al = A()) + : vector(n, c, al) + { + } + + template _UCXXEXPORT basic_string(InputIterator begin, InputIterator end, const A& a = A()) + :vector(begin, end) + { + + } + + _UCXXEXPORT ~basic_string() { + return; + } + + _UCXXEXPORT basic_string& operator=(const basic_string& str); //Below + + _UCXXEXPORT basic_string& operator=(const Ch* s){ + vector::clear(); + if(s!=0){ + size_type len = Tr::length(s); + resize(len); + Tr::copy( vector::data, s, len); + } + return *this; + } + + _UCXXEXPORT basic_string& operator=(Ch c){ + vector::clear(); + vector::push_back(c); + return *this; + } + + inline _UCXXEXPORT size_type length() const { return vector::size(); } + + void _UCXXEXPORT resize(size_type n, Ch c = Ch()){ + vector::resize(n, c); + } + + _UCXXEXPORT basic_string& operator+=(const basic_string& str){ + return append(str); + } + + _UCXXEXPORT basic_string& operator+=(const Ch * s){ + return append(s); + } + + _UCXXEXPORT basic_string& operator+=(Ch c){ + vector::push_back(c); + return *this; + } + + _UCXXEXPORT basic_string& append(const basic_string& str){ + size_t temp = vector::elements; + resize(vector::elements + str.elements); + Tr::copy( vector::data + temp, str.vector::data, str.elements); + + return *this; + } + + _UCXXEXPORT basic_string& append(const basic_string& str, size_type pos, size_type n){ + if(pos > str.size()){ + __throw_out_of_range(); + } + + size_type rlen = str.elements - pos; + if(rlen > n){ + rlen = n; + } + if(vector::elements > npos - rlen){ + __throw_length_error(); + } + size_t temp = vector::elements; + resize(vector::elements + rlen); + Tr::copy( vector::data + temp, str.vector::data + pos, rlen); + return *this; + } + + _UCXXEXPORT basic_string& append(const Ch* s, size_type n){ + size_t temp = vector::elements; + resize(vector::elements + n); + Tr::copy( vector::data + temp, s, n); + return *this; + } + + _UCXXEXPORT basic_string& append(const Ch* s){ + size_type strLen = Tr::length(s); + size_t temp = vector::elements; + resize(vector::elements + strLen); + Tr::copy( vector::data + temp, s, strLen); + return *this; + } + + _UCXXEXPORT basic_string& append(size_type n, Ch c){ + vector::resize(vector::elements + n, c); + return *this; + } + + _UCXXEXPORT basic_string& assign(const basic_string& str){ + operator=(str); + return *this; + } + + _UCXXEXPORT basic_string& assign(const basic_string& str, size_type pos, size_type n){ + if(pos > str.elements){ + __throw_out_of_range(); + } + size_type r = str.elements - pos; + if(r > n){ + r = n; + } + resize(r); + Tr::copy(vector::data, str.vector::data + pos, r); + return *this; + } + + _UCXXEXPORT basic_string& assign(const Ch* s, size_type n){ + resize(n); + Tr::copy(vector::data, s, n); + return *this; + } + + _UCXXEXPORT basic_string& assign(const Ch* s){ + size_type len = Tr::length(s); + return assign(s, len); + } + + _UCXXEXPORT basic_string& assign(size_type n, Ch c){ + vector::clear(); + vector::resize(n, c); + return *this; + } + + template _UCXXEXPORT basic_string& assign(InputIterator first, InputIterator last){ + vector::resize(0, Ch()); + while (first != last){ + const Ch x = *first; + append(&x); + ++first; + } + return *this; + } + + _UCXXEXPORT basic_string& insert(size_type pos1, const basic_string& str, size_type pos2=0, size_type n=npos){ + if(pos1 > vector::elements || pos2 > str.elements){ + __throw_out_of_range(); + } + size_type r = str.elements - pos2; + if( r > n){ + r = n; + } + if(vector::elements > npos - r){ + __throw_length_error(); + } + size_type temp = vector::elements; + resize(vector::elements + r); + Tr::move(vector::data + pos1 + r, vector::data + pos1, temp - pos1); + Tr::copy(vector::data + pos1, str.vector::data + pos2, r); + return *this; + } + + _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s, size_type n){ + if(pos > vector::elements){ + __throw_out_of_range(); + } + if(vector::elements > npos - n){ + __throw_length_error(); + } + size_type temp = vector::elements; + resize(vector::elements + n); + Tr::move(vector::data + pos + n, vector::data + pos, temp - pos); + Tr::copy(vector::data + pos, s, n); + return *this; + } + + inline _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s){ + size_type len = Tr::length(s); + return insert(pos, s, len); + } + + _UCXXEXPORT basic_string& insert(size_type pos, size_type n, Ch c){ + if(pos > vector::elements){ + __throw_out_of_range(); + } + if(vector::elements > npos - n){ + __throw_length_error(); + } + size_type temp = vector::elements; + resize(vector::elements + n); + Tr::move(vector::data + pos + n, vector::data + pos, temp - pos); + Tr::assign(vector::data + pos, n, c); + return *this; + } + + using vector::insert; +// void insert(iterator p, size_type n, charT c); +// template void insert(iterator p, InputIterator first, InputIterator last); + + _UCXXEXPORT basic_string& erase(size_type pos = 0, size_type n = npos){ + size_type xlen = vector::elements - pos; + + if(xlen > n){ + xlen = n; + } + size_type temp = vector::elements; + + Tr::move(vector::data + pos, vector::data + pos + xlen, temp - pos - xlen); + resize(temp - xlen); + return *this; + } + + _UCXXEXPORT iterator erase(iterator position){ + if(position == vector::end()){ + return position; + } + + ++position; + + iterator temp = position; + + while(position != vector::end()){ + *(position-1) = *position; + ++position; + } + vector::pop_back(); + return temp; + } + + _UCXXEXPORT iterator erase(iterator first, iterator last){ + size_t count = last - first; + + iterator temp = last; + + while(last != vector::end()){ + *(last - count) = *last; + ++last; + } + + resize( vector::elements-count); + + return temp; + } + + _UCXXEXPORT basic_string& + replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2=0, size_type n2=npos) + { + if(pos1 > vector::elements){ + __throw_out_of_range(); + } + size_type xlen = vector::elements - pos1; + if(xlen > n1){ + xlen = n1; + } + size_type rlen = str.elements - pos2; + if(rlen > n2){ + rlen = n2; + } + if((vector::elements - xlen) >= (npos - rlen)){ + __throw_length_error(); + } + + size_t temp = vector::elements; + + if(rlen > xlen){ //Only if making larger + resize(temp - xlen + rlen); + } + + //Final length = vector::elements - xlen + rlen + //Initial block is of size pos1 + //Block 2 is of size len + + Tr::move(vector::data + pos1 + rlen, vector::data + pos1 + xlen, temp - pos1 - xlen); + Tr::copy(vector::data + pos1, str.vector::data + pos2, rlen); + resize(temp - xlen + rlen); + return *this; + } + + _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s, size_type n2){ + return replace(pos,n1,basic_string(s,n2)); + + } + + inline _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s){ + return replace(pos,n1,basic_string(s)); + } + + _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, size_type n2, Ch c){ + return replace(pos,n1,basic_string(n2,c)); + } +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const basic_string& str); +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s, size_type n); +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s); +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, size_type n, Ch c); +/* template _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, + InputIterator j1, InputIterator j2);*/ + + size_type _UCXXEXPORT copy(Ch* s, size_type n, size_type pos = 0) const{ + if(pos > vector::elements){ + __throw_out_of_range(); + } + size_type r = vector::elements - pos; + if(r > n){ + r = n; + } + Tr::copy(s, vector::data + pos, r); + return r; + } + + _UCXXEXPORT void swap(basic_string& s){ + //Data pointers + + vector::swap(s); + } + + _UCXXEXPORT const Ch* c_str() const{ + const_cast *>(this)->reserve(vector::elements+1); + vector::data[vector::elements] = 0; //Add 0 at the end + return vector::data; + } + + _UCXXEXPORT const Ch* data() const{ + return vector::data; + } + _UCXXEXPORT allocator_type get_allocator() const{ + return vector::a; + } + + _UCXXEXPORT size_type find (const basic_string& str, size_type pos = 0) const; //Below + + _UCXXEXPORT size_type find (const Ch* s, size_type pos, size_type n) const{ + return find(basic_string(s,n), pos); + } + _UCXXEXPORT size_type find (const Ch* s, size_type pos = 0) const{ + return find(basic_string(s), pos); + } + _UCXXEXPORT size_type find (Ch c, size_type pos = 0) const{ + for(size_type i = pos; i < length(); ++i){ + if(this->operator[](i) == c){ + return i; + } + } + return npos; + } + _UCXXEXPORT size_type rfind(const basic_string& str, size_type pos = npos) const{ + if(pos >= length()){ + pos = length(); + } + for(size_type i = pos; i > 0; --i){ + if(str == substr(i-1, str.length())){ + return i-1; + } + } + return npos; + } + _UCXXEXPORT size_type rfind(const Ch* s, size_type pos, size_type n) const{ + return rfind(basic_string(s,n),pos); + } + _UCXXEXPORT size_type rfind(const Ch* s, size_type pos = npos) const{ + return rfind(basic_string(s),pos); + } + _UCXXEXPORT size_type rfind(Ch c, size_type pos = npos) const{ + return rfind(basic_string(1,c),pos); + } + + _UCXXEXPORT size_type find_first_of(const basic_string& str, size_type pos = 0) const{ + for(size_type i = pos; i < length(); ++i){ + for(size_type j = 0; j < str.length() ; ++j){ + if( Tr::eq(str[j], this->operator[](i)) ){ + return i; + } + } + } + return npos; + } + + _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos, size_type n) const{ + return find_first_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos = 0) const{ + return find_first_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_first_of(Ch c, size_type pos = 0) const{ + for(size_type i = pos; i< length(); ++i){ + if( Tr::eq(this->operator[](i), c) ){ + return i; + } + } + return npos; + } + + _UCXXEXPORT size_type find_last_of (const basic_string& str, size_type pos = npos) const{ + if(pos > length()){ + pos = length(); + } + for(size_type i = pos; i >0 ; --i){ + for(size_type j = 0 ; j < str.length(); ++j){ + if( Tr::eq(this->operator[](i-1), str[j]) ){ + return i-1; + } + } + } + return npos; + } + _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos, size_type n) const{ + return find_last_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos = npos) const{ + return find_last_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_last_of (Ch c, size_type pos = npos) const{ + if(pos > length()){ + pos = length(); + } + for(size_type i = pos; i >0 ; --i){ + if( Tr::eq(this->operator[](i-1), c) ){ + return i-1; + } + } + return npos; + } + + _UCXXEXPORT size_type find_first_not_of(const basic_string& str, size_type pos = 0) const{ + bool foundCharacter; + for(size_type i = pos; i < length(); ++i){ + foundCharacter = false; + for(size_type j = 0; j < str.length() ; ++j){ + if( Tr::eq(str[j], this->operator[](i)) ){ + foundCharacter = true; + } + } + if(foundCharacter == false){ + return i; + } + } + return npos; + } + + _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos, size_type n) const{ + return find_first_not_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos = 0) const{ + return find_first_not_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_first_not_of(Ch c, size_type pos = 0) const{ + for(size_type i = pos; i < length() ; ++i){ + if(this->operator[](i) != c){ + return i; + } + } + return npos; + } + _UCXXEXPORT size_type find_last_not_of (const basic_string& str, size_type pos = npos) const{ + size_type xpos(length() - 1); + if(xpos > pos){ + xpos = pos; + } + + while(xpos != npos && npos != str.find_first_of(this->at(xpos))){ + --xpos; + } + + return xpos; + } + + _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos, size_type n) const{ + return find_last_not_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos = npos) const{ + return find_last_not_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_last_not_of (Ch c, size_type pos = npos) const{ + size_type xpos(length() - 1); + if(xpos > pos){ + xpos = pos; + } + while(xpos != npos && Tr::eq(this->at(xpos), c)){ + --xpos; + } + return xpos; + + } + + _UCXXEXPORT basic_string substr(size_type pos = 0, size_type n = npos) const; + + _UCXXEXPORT int compare(const basic_string& str) const{ + size_type rlen = vector::elements; + if(rlen > str.elements){ + rlen = str.elements; + } + int retval = Tr::compare(vector::data, str.vector::data, rlen); + if(retval == 0){ + if(vector::elements < str.elements){ + retval = -1; + } + if(vector::elements > str.elements){ + retval = 1; + } + } + return retval; + } + + _UCXXEXPORT int compare(size_type pos1, size_type n1, const basic_string& str, + size_type pos2=0, size_type n2=npos) const{ + size_type len1 = vector::elements - pos1; + if(len1 > n1){ + len1 = n1; + } + size_type len2 = str.vector::elements - pos2; + if(len2 > n2){ + len2 = n2; + } + size_type rlen = len1; + if(rlen > len2){ + rlen = len2; + } + int retval = Tr::compare(vector::data + pos1, str.vector::data + pos2, rlen); + if(retval == 0){ + if(len1 < len2){ + retval = -1; + } + if(len1 > len2){ + retval = 1; + } + } + return retval; + } + + _UCXXEXPORT int compare(const Ch* s) const{ + size_type slen = Tr::length(s); + size_type rlen = slen; + if(rlen > vector::elements){ + rlen=vector::elements; + } + int retval = Tr::compare(vector::data, s, rlen); + if(retval==0){ + if(vector::elements < slen){ + retval = -1; + } + if(vector::elements > slen){ + retval = 1; + } + } + return retval; + } + + _UCXXEXPORT int compare(size_type pos1, size_type n1, const Ch* s, size_type n2 = npos) const{ + size_type len1 = vector::elements - pos1; + if(len1 > n1){ + len1 = n1; + } + size_type slen = Tr::length(s); + size_type len2 = slen; + if(len2 > n2){ + len2 = n2; + } + size_type rlen = len1; + if(rlen > len2){ + rlen = len2; + } + int retval = Tr::compare(vector::data + pos1, s, rlen); + if(retval == 0){ + if(len1 < len2){ + retval = -1; + } + if(len1 > len2){ + retval = 1; + } + } + return retval; + } + +}; + + +//Functions + +template _UCXXEXPORT basic_string::basic_string(const Ch* s, const A& al) + : vector(al) +{ + if(s!=0){ + size_type temp = Tr::length(s); + append(s, temp); + } +} + +template _UCXXEXPORT basic_string:: + basic_string(const basic_string& str, size_type pos, size_type n, const A& al) + : vector(al) +{ + if(pos>str.size()){ + __throw_out_of_range(); + } + size_type rlen = str.size() - pos; + if( rlen > n){ + rlen = n; + } + resize(rlen); + Tr::copy(vector::data, str.vector::data + pos, vector::elements); +} + +template _UCXXEXPORT basic_string& + basic_string::operator=(const basic_string & str) +{ + if(&str == this){ //Check if we are doing a=a + return *this; + } + vector::clear(); + resize(str.elements); + Tr::copy( vector::data, str.vector::data, str.elements); + return *this; +} + + +template _UCXXEXPORT typename basic_string::size_type + basic_string::find (const basic_string& str, size_type pos) const +{ + if(str.length() > length()){ + return npos; + } + size_type max_string_start = 1 + length() - str.length(); + for(size_type i = pos; i < max_string_start; ++i){ + if(str == substr(i, str.length())){ + return i; + } + } + return npos; +} + + +template + _UCXXEXPORT basic_string basic_string::substr(size_type pos, size_type n) const +{ + if(pos > vector::elements){ + __throw_out_of_range(); + } + size_type rlen = vector::elements - pos; + if(rlen > n){ + rlen = n; + } + return basic_string(vector::data + pos,rlen); +} + + + + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STRING__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT string::basic_string(const allocator &); + template <> _UCXXEXPORT string::basic_string(size_type n, char c, const allocator & ); + template <> _UCXXEXPORT string::basic_string(const char* s, const allocator& al); + template <> _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator& al); + template <> _UCXXEXPORT string::~basic_string(); + +#endif + + template <> _UCXXEXPORT string & string::append(const char * s, size_type n); + + + template <> _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const; + template <> _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const; + template <> _UCXXEXPORT string::size_type string::find (char c, size_type pos) const; + + template <> _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const; + template <> _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const; + template <> _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const; + + template <> _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const; + template <> _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const; + template <> _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const; + template <> _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const; + + template <> _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const; + template <> _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const; + template <> _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const; + template <> _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const; + + template <> _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const; + template <> _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const; + template <> _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const; + template <> _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const; + + template <> _UCXXEXPORT int string::compare(const string & str) const; + template <> _UCXXEXPORT int string::compare( + size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const; + + template <> _UCXXEXPORT string string::substr(size_type pos, size_type n) const; + + template <> _UCXXEXPORT string & string::operator=(const string & str); + template <> _UCXXEXPORT string & string::operator=(const char * s); + +#endif +#endif + + + + +//typedef basic_string string; + +template _UCXXEXPORT basic_string + operator+(const basic_string& lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + temp.append(rhs); + return temp; +} + +template _UCXXEXPORT basic_string + operator+(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + temp.append(rhs); + return temp; +} + + +template _UCXXEXPORT basic_string + operator+(charT lhs, const basic_string& rhs) +{ + basic_string temp(1, lhs); + temp.append(rhs); + return temp; +} + +template _UCXXEXPORT basic_string + operator+(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(lhs); + temp.append(rhs); + return temp; +} + +template _UCXXEXPORT basic_string + operator+(const basic_string& lhs, charT rhs) +{ + basic_string temp(lhs); + temp+=rhs; + return temp; +} + +template _UCXXEXPORT bool + operator==(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) == 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator==(const charT* lhs, const basic_string& rhs) +{ + if(rhs.compare(lhs) == 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator==(const basic_string& lhs, const charT* rhs) +{ + if(lhs.compare(rhs)==0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator!=(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) !=0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator!=(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + return (temp != rhs); +} + +template _UCXXEXPORT bool + operator!=(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + return (lhs != temp); +} + +template _UCXXEXPORT bool + operator< (const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) < 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator< (const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(rhs) < 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator< (const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) < 0){ + return true; + } + return false; +} + + +template _UCXXEXPORT bool + operator> (const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) > 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator> (const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(rhs) > 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator> (const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) > 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator<=(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) <=0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator<=(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(temp) <=0 ){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator<=(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) <= 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator>=(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) >=0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator>=(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(temp) >=0 ){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator>=(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) >=0 ){ + return true; + } + return false; +} + +template _UCXXEXPORT void + swap(basic_string& lhs, basic_string& rhs) +{ + lhs.swap(rhs); +} + +/*template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const basic_string& str) +{ + return os.write(str.data(), str.length()); +}*/ + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STRING__ + +//Operators we can avoid duplication of + +template <> _UCXXEXPORT bool operator==(const string & lhs, const string & rhs); +template <> _UCXXEXPORT bool operator==(const char * lhs, const string & rhs); +template <> _UCXXEXPORT bool operator==(const string & lhs, const char * rhs); + +template <> _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs); +template <> _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs); +template <> _UCXXEXPORT bool operator!=(const string & lhs, const char * rhs); + +template <> _UCXXEXPORT string operator+(const string & lhs, const char* rhs); +template <> _UCXXEXPORT string operator+(const char* lhs, const string & rhs); +template <> _UCXXEXPORT string operator+(const string & lhs, const string & rhs); + +template <> _UCXXEXPORT bool operator> (const string & lhs, const string & rhs); +template <> _UCXXEXPORT bool operator< (const string & lhs, const string & rhs); + + +#endif +#endif + + +} + +#pragma GCC visibility pop + +#endif diff --git a/include/string_iostream b/include/string_iostream new file mode 100644 index 0000000..355fd58 --- /dev/null +++ b/include/string_iostream @@ -0,0 +1,146 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif + +#ifndef __HEADER_STD_STRING_IOSTREAM +#define __HEADER_STD_STRING_IOSTREAM 1 + +#pragma GCC visibility push(default) + +namespace std{ + + + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const basic_string& str) +{ + return os.write(str.data(), str.length()); +} + +template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, basic_string& str) +{ + + typename basic_istream::sentry s(is); + if(s == false){ + return is; + } + + str.clear(); + + typename basic_istream::int_type c; + typename Allocator::size_type n = is.width(); + bool exitnow = false; + if(n == 0){ + n = str.max_size(); + } + +// //Clear out preliminary spaces first +// c = is.get(); +// while(isspace(c)){ +// c = is.get(); +// } +// +// is.putback(c); + + do{ + c = is.get(); + if(c == traits::eof() || isspace(c) || n == 0){ + is.putback(c); + exitnow = true; + }else{ + str.append(1, traits::to_char_type(c) ); + --n; + } + }while(exitnow == false); + return is; +} + +template _UCXXEXPORT basic_istream& + getline(basic_istream& is, basic_string& str, charT delim) +{ + typename basic_istream::sentry s(is, true); + if(s == false){ + return is; + } + + str.erase(); + + streamsize i = 0; + typename basic_istream::int_type c_i; + charT c; + unsigned int n = str.max_size(); + for(i=0;i _UCXXEXPORT basic_istream& + getline(basic_istream& is, basic_string& str) +{ + return getline(is, str, '\n'); +} + + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STRING__ + + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ +template<> _UCXXEXPORT basic_istream >& operator>>( + basic_istream >& is, + basic_string, allocator >& str); +#endif + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +template<> _UCXXEXPORT basic_ostream >& + operator<<(basic_ostream >& os, + const basic_string, std::allocator >& str); + +#endif + + +#endif +#endif + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/support b/include/support new file mode 100644 index 0000000..9279987 --- /dev/null +++ b/include/support @@ -0,0 +1,165 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef HEADER_ULC_SUPPORT +#define HEADER_ULC_SUPPORT 1 + +using namespace std; + +//From C++ ABI spec +typedef enum { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + + +typedef void (*_Unwind_Exception_Cleanup_Fn) + (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc); + +//The following definitions were grabbed from the gcc implementation +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); +typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); +typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); +typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); +typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception *); + +typedef int _Unwind_Action; +static const _Unwind_Action _UA_SEARCH_PHASE = 1; +static const _Unwind_Action _UA_CLEANUP_PHASE = 2; +static const _Unwind_Action _UA_HANDLER_FRAME = 4; +static const _Unwind_Action _UA_FORCE_UNWIND = 8; + +const _Unwind_Exception_Class __uclibcxx_exception_class = (((((((( + _Unwind_Exception_Class) 'u' << 8 | (_Unwind_Exception_Class) 'l') << 8 + | (_Unwind_Exception_Class) 'i') << 8 | (_Unwind_Exception_Class) 'b') << 8 + | (_Unwind_Exception_Class) 'C')<< 8 | (_Unwind_Exception_Class) '+') << 8 + | (_Unwind_Exception_Class) '+') << 8 | (_Unwind_Exception_Class) '\0'); + + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 +#define _UA_END_OF_STACK 16 + +struct _Unwind_Exception{ + _Unwind_Exception_Class exception_class; //Type of exception, eg ulibC++\0 + _Unwind_Exception_Cleanup_Fn exception_cleanup; //Destructor if from diff runtime + _Unwind_Word private_1; //Don't touch at all! + _Unwind_Word private_2; //Don't touch at all! +} __attribute__((__aligned__)); + + +//The following structure is system-dependent and defined by the compiler +//Thus it's definition was copied from the gcc 3.4.0 header files +struct _Unwind_Context; +//{ +// void *reg[DWARF_FRAME_REGISTERS+1]; +// void *cfa; +// void *ra; +// void *lsda; +// struct dwarf_eh_bases bases; +// _Unwind_Word args_size; +//}; + + + +_Unwind_Reason_Code _Unwind_RaiseException ( struct _Unwind_Exception *exception_object ); + +//_Unwind_ForcedUnwind + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) + (int version, _Unwind_Action actions, _Unwind_Exception_Class exceptionClass, + struct _Unwind_Exception *exceptionObject, + struct _Unwind_Context *context, void *stop_parameter ); + +_Unwind_Reason_Code _Unwind_ForcedUnwind ( + struct _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, + void *stop_parameter ); + +void _Unwind_Resume (struct _Unwind_Exception *exception_object); +void _Unwind_DeleteException (struct _Unwind_Exception *exception_object); + +_Unwind_Word _Unwind_GetGR (struct _Unwind_Context *context, int index); +void _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word); + +_Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *context); +void _Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr new_value); + +_Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context); +_Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *context); + +_Unwind_Reason_Code (*__personality_routine) + (int version, //Should be 1 + _Unwind_Action actions, //Actions the routine will perform (bitmask) + _Unwind_Exception_Class exceptionClass, //Type of exception - vendor is high 4 bytes + struct _Unwind_Exception *exceptionObject, //Points to exception header + struct _Unwind_Context *context); //Unwinder state information + + +/*The following part is the Level II ABI which is required for compatability*/ +//This might be the only stuff that *I* need to implement + +struct __cxa_exception { + std::type_info *exceptionType; //Type of thrown exception + void (*exceptionDestructor) (void *); //Pointer to the destructor + unexpected_handler unexpectedHandler; //Unexpected handler to use + terminate_handler terminateHandler; //Terminate handle to use + __cxa_exception *nextException; //per thread linked list + + int handlerCount; //How many handlers have caught this + int handlerSwitchValue; + const char *actionRecord; + const char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; + + _Unwind_Exception unwindHeader; +}; + +struct __cxa_eh_globals { + __cxa_exception *caughtExceptions; + unsigned int uncaughtExceptions; +}; + +extern "C" __cxa_eh_globals *__cxa_get_globals(void); //Return ptr to the eh_globals object for current thread +extern "C" __cxa_eh_globals *__cxa_get_globals_fast(void); //Same as above, assumes that above called at least once + +extern "C" void *__cxa_allocate_exception(size_t thrown_size); //Allocate space for exception plus header +extern "C" void __cxa_free_exception(void *thrown_exception); //Free space allocated from the above + +extern "C" void __cxa_throw (void *thrown_exception, //This is the actual throw call +// std::type_info *tinfo, //Type of object + void * tinfo, //Type of object + void (*dest) (void *) ); //Pointer to destructor destroy object + + +#endif + diff --git a/include/type_traits b/include/type_traits new file mode 100644 index 0000000..fa1de40 --- /dev/null +++ b/include/type_traits @@ -0,0 +1,92 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + 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 +#include +#include +#include +#include + +#ifndef __HEADER_TYPE_TRAITS +#define __HEADER_TYPE_TRAITS 1 + +#pragma GCC visibility push(default) + +namespace std{ + + struct _UCXXEXPORT __true_type{}; + struct _UCXXEXPORT __false_type{}; + + template class _UCXXEXPORT __is_integer{ + public: + typedef __false_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + + +} + +#pragma GCC visibility pop + +#endif + diff --git a/include/typeinfo b/include/typeinfo new file mode 100644 index 0000000..7863af2 --- /dev/null +++ b/include/typeinfo @@ -0,0 +1,156 @@ +// RTTI support for -*- C++ -*- +// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 +// Free Software Foundation +// +// This file is part of GNU CC. +// +// GNU CC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// GNU CC 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 GNU CC; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file typeinfo + * This header provides RTTI support. + */ + +#ifndef __TYPEINFO__ +#define __TYPEINFO__ + +#include + +extern "C++" { + +namespace __cxxabiv1 +{ + class __class_type_info; +} // namespace __cxxabiv1 + +#if !__GXX_WEAK__ + // If weak symbols are not supported, typeinfo names are not merged. + #define __GXX_MERGED_TYPEINFO_NAMES 0 +#else + // On platforms that support weak symbols, typeinfo names are merged. + #define __GXX_MERGED_TYPEINFO_NAMES 1 +#endif + +namespace std +{ + /** + * @brief Part of RTTI. + * + * The @c type_info class describes type information generated by + * an implementation. + */ + class type_info + { + public: + /** Destructor. Being the first non-inline virtual function, this + * controls in which translation unit the vtable is emitted. The + * compiler makes use of that information to know where to emit + * the runtime-mandated type_info structures in the new-abi. */ + virtual ~type_info(); + + private: + /// Assigning type_info is not supported. Made private. + type_info& operator=(const type_info&); + type_info(const type_info&); + + protected: + const char *__name; + + protected: + explicit type_info(const char *__n): __name(__n) { } + + public: + // the public interface + /** Returns an @e implementation-defined byte string; this is not + * portable between compilers! */ + const char* name() const + { return __name; } + +#if !__GXX_MERGED_TYPEINFO_NAMES + bool before(const type_info& __arg) const; + // In old abi, or when weak symbols are not supported, there can + // be multiple instances of a type_info object for one + // type. Uniqueness must use the _name value, not object address. + bool operator==(const type_info& __arg) const; +#else + /** Returns true if @c *this precedes @c __arg in the implementation's + * collation order. */ + // In new abi we can rely on type_info's NTBS being unique, + // and therefore address comparisons are sufficient. + bool before(const type_info& __arg) const + { return __name < __arg.__name; } + bool operator==(const type_info& __arg) const + { return __name == __arg.__name; } +#endif + bool operator!=(const type_info& __arg) const + { return !operator==(__arg); } + + // the internal interface + public: + // return true if this is a pointer type of some kind + virtual bool __is_pointer_p() const; + // return true if this is a function type + virtual bool __is_function_p() const; + + // Try and catch a thrown type. Store an adjusted pointer to the + // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then + // THR_OBJ points to the thrown object. If THR_TYPE is a pointer + // type, then THR_OBJ is the pointer itself. OUTER indicates the + // number of outer pointers, and whether they were const + // qualified. + virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; + + // internally used during catch matching + virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, + void **__obj_ptr) const; + }; + + /** + * @brief Thrown during incorrect typecasting. + * + * If you attempt an invalid @c dynamic_cast expression, an instance of + * this class (or something derived from this class) is thrown. */ + class bad_cast : public exception + { + public: + bad_cast() _UCXX_USE_NOEXCEPT { } + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_cast() _UCXX_USE_NOEXCEPT; + }; + + /** If you use a NULL pointer in a @c typeid expression, this is thrown. */ + class bad_typeid : public exception + { + public: + bad_typeid () _UCXX_USE_NOEXCEPT { } + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_typeid() _UCXX_USE_NOEXCEPT; + }; +} // namespace std + +} // extern "C++" +#endif diff --git a/include/unwind-cxx.h b/include/unwind-cxx.h new file mode 100644 index 0000000..f1e8fab --- /dev/null +++ b/include/unwind-cxx.h @@ -0,0 +1,247 @@ +// -*- C++ -*- Exception handling and frame unwind runtime interface routines. +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// GCC 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 GCC; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This is derived from the C++ ABI for IA-64. Where we diverge +// for cross-architecture compatibility are noted with "@@@". + +#ifndef _UNWIND_CXX_H +#define _UNWIND_CXX_H 1 + +// Level 2: C++ ABI + +#include +#include +#include +#include "unwind.h" + +#ifdef __aarch64__ +typedef long _Atomic_word; +#elif defined __cris__ +typedef int _Atomic_word __attribute__ ((__aligned__ (4))); +#else +typedef int _Atomic_word; +#endif + +#pragma GCC visibility push(default) + +namespace __cxxabiv1 +{ + +// A primary C++ exception object consists of a header, which is a wrapper +// around an unwind object header with additional C++ specific information, +// followed by the exception object itself. + +struct __cxa_exception +{ + // Manage the exception object itself. + std::type_info *exceptionType; + void (*exceptionDestructor)(void *); + + // The C++ standard has entertaining rules wrt calling set_terminate + // and set_unexpected in the middle of the exception cleanup process. + std::unexpected_handler unexpectedHandler; + std::terminate_handler terminateHandler; + + // The caught exception stack threads through here. + __cxa_exception *nextException; + + // How many nested handlers have caught this exception. A negated + // value is a signal that this object has been rethrown. + int handlerCount; + + // Cache parsed handler data from the personality routine Phase 1 + // for Phase 2 and __cxa_call_unexpected. + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + _Unwind_Ptr catchTemp; + void *adjustedPtr; + + // The generic exception header. Must be last. + _Unwind_Exception unwindHeader; +}; + +struct __cxa_refcounted_exception +{ + // Manage this header. + _Atomic_word referenceCount; + // __cxa_exception must be last, and no padding can be after it. + __cxa_exception exc; +}; + +// A dependent C++ exception object consists of a header, which is a wrapper +// around an unwind object header with additional C++ specific information, +// followed by the exception object itself. +struct __cxa_dependent_exception +{ + // The primary exception + void *primaryException; + + // The C++ standard has entertaining rules wrt calling set_terminate + // and set_unexpected in the middle of the exception cleanup process. + std::unexpected_handler unexpectedHandler; + std::terminate_handler terminateHandler; + + // The caught exception stack threads through here. + __cxa_exception *nextException; + + // How many nested handlers have caught this exception. A negated + // value is a signal that this object has been rethrown. + int handlerCount; + + // Cache parsed handler data from the personality routine Phase 1 + // for Phase 2 and __cxa_call_unexpected. + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + _Unwind_Ptr catchTemp; + void *adjustedPtr; + + // The generic exception header. Must be last. + _Unwind_Exception unwindHeader; +}; + + +// Each thread in a C++ program has access to a __cxa_eh_globals object. +struct __cxa_eh_globals +{ + __cxa_exception *caughtExceptions; + unsigned int uncaughtExceptions; +}; + + +// The __cxa_eh_globals for the current thread can be obtained by using +// either of the following functions. The "fast" version assumes at least +// one prior call of __cxa_get_globals has been made from the current +// thread, so no initialization is necessary. +extern "C" __cxa_eh_globals *__cxa_get_globals () _UCXX_USE_NOEXCEPT; +extern "C" __cxa_eh_globals *__cxa_get_globals_fast () _UCXX_USE_NOEXCEPT; + +// Allocate memory for the primary exception plus the thrown object. +extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) _UCXX_USE_NOEXCEPT; +// Allocate memory for dependent exception. +extern "C" __cxa_dependent_exception *__cxa_allocate_dependent_exception() _UCXX_USE_NOEXCEPT; + +// Free the space allocated for the primary exception. +extern "C" void __cxa_free_exception(void *thrown_exception) _UCXX_USE_NOEXCEPT; +// Free the space allocated for the dependent exception. +extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *dependent_exception) _UCXX_USE_NOEXCEPT; + +// Throw the exception. +extern "C" void __cxa_throw (void *thrown_exception, + std::type_info *tinfo, + void (*dest) (void *)) + __attribute__((noreturn)); + +// Used to implement exception handlers. +extern "C" void *__cxa_begin_catch (void *) _UCXX_USE_NOEXCEPT; +extern "C" void __cxa_end_catch (); +extern "C" void __cxa_rethrow () __attribute__((noreturn)); + +// These facilitate code generation for recurring situations. +extern "C" void __cxa_bad_cast (); +extern "C" void __cxa_bad_typeid (); + +// @@@ These are not directly specified by the IA-64 C++ ABI. + +// Handles re-checking the exception specification if unexpectedHandler +// throws, and if bad_exception needs to be thrown. Called from the +// compiler. +extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn)); + +// Invokes given handler, dying appropriately if the user handler was +// so inconsiderate as to return. +extern void __terminate(std::terminate_handler) _UCXX_USE_NOEXCEPT __attribute__((noreturn)); +extern void __unexpected(std::unexpected_handler) __attribute__((noreturn)); + +// The current installed user handlers. +extern std::terminate_handler __terminate_handler; +extern std::unexpected_handler __unexpected_handler; + +// These are explicitly GNU C++ specific. + +// This is the exception class we report -- "GNUCC++\0". +const _Unwind_Exception_Class __gxx_exception_class +#ifndef __ARM_EABI_UNWINDER__ += ((((((((_Unwind_Exception_Class) 'G' + << 8 | (_Unwind_Exception_Class) 'N') + << 8 | (_Unwind_Exception_Class) 'U') + << 8 | (_Unwind_Exception_Class) 'C') + << 8 | (_Unwind_Exception_Class) 'C') + << 8 | (_Unwind_Exception_Class) '+') + << 8 | (_Unwind_Exception_Class) '+') + << 8 | (_Unwind_Exception_Class) '\0'); +#else += "GNUCC++"; +#endif + +// GNU C++ personality routine, Version 0. +extern "C" _Unwind_Reason_Code __gxx_personality_v0 + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *); + +// GNU C++ sjlj personality routine, Version 0. +extern "C" _Unwind_Reason_Code __gxx_personality_sj0 + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *); + +// Acquire the C++ exception header from the C++ object. +static inline __cxa_exception * +__get_exception_header_from_obj (void *ptr) +{ + return reinterpret_cast<__cxa_exception *>(ptr) - 1; +} + +// Acquire the C++ exception header from the generic exception header. +static inline __cxa_exception * +__get_exception_header_from_ue (_Unwind_Exception *exc) +{ + return reinterpret_cast<__cxa_exception *>(exc + 1) - 1; +} + +// Acquire the C++ refcounted exception header from the C++ object. +static inline __cxa_refcounted_exception * +__get_refcounted_exception_header_from_obj (void *ptr) +{ + return reinterpret_cast<__cxa_refcounted_exception *>(ptr) - 1; +} + +// Acquire the C++ refcounted exception header from the generic exception +// header. +static inline __cxa_refcounted_exception * +__get_refcounted_exception_header_from_ue (_Unwind_Exception *exc) +{ + return reinterpret_cast<__cxa_refcounted_exception *>(exc + 1) - 1; +} + +} /* namespace __cxxabiv1 */ + +#pragma GCC visibility pop + +#endif // _UNWIND_CXX_H diff --git a/include/utility b/include/utility new file mode 100644 index 0000000..b654679 --- /dev/null +++ b/include/utility @@ -0,0 +1,88 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +#ifndef __STD_HEADER_UTILITY +#define __STD_HEADER_UTILITY 1 + +#pragma GCC visibility push(default) + +namespace std{ + + namespace rel_ops { + template inline bool operator!=(const T& x, const T& y){ + return !(x == y); + } + + template inline bool operator> (const T& x, const T& y){ + return ( y < x); + } + + template inline bool operator<=(const T& x, const T& y){ + return !( y < x ); + } + + template inline bool operator>=(const T& x, const T& y){ + return !(x < y); + } + } + + template struct _UCXXEXPORT pair { + typedef T1 first_type; + typedef T2 second_type; + + T1 first; + T2 second; + pair() : first(), second() { } + pair(const T1& x, const T2& y) : first(x), second(y) { } + template pair(const pair &p) : first(p.first), second(p.second) { } + }; + + template bool operator==(const pair& x, const pair& y){ + using namespace rel_ops; + return (x.first == y.first && x.second==y.second); + } + template bool operator< (const pair& x, const pair& y){ + return x.first < y.first || (!(y.first < x.first) && x.second < y.second); + } + template bool operator!=(const pair& x, const pair& y){ + return !(x == y); + } + template bool operator> (const pair& x, const pair& y){ + return y < x; + } + template bool operator>=(const pair& x, const pair& y){ + return !(x < y); + } + template bool operator<=(const pair& x, const pair& y){ + return !(y < x); + } + template pair make_pair(const T1& x, const T2& y){ + return pair(x, y); + } + + +} + +#pragma GCC visibility pop + +#endif //__STD_HEADER_UTILITY diff --git a/include/valarray b/include/valarray new file mode 100644 index 0000000..09d929c --- /dev/null +++ b/include/valarray @@ -0,0 +1,1042 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +#ifndef __HEADER_STD_VALARRAY +#define __HEADER_STD_VALARRAY 1 + +#include +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template class valarray; + class slice; + template class slice_array; + class gslice; + template class gslice_array; + template class mask_array; + template class indirect_array; + + //Actual class definitions + + + class _UCXXEXPORT slice { + protected: + size_t sta; + size_t siz; + size_t str; + + public: + slice() : sta(0), siz(0), str(0){ } + slice(size_t a, size_t b, size_t c) : sta(a), siz(b), str(c) { } + slice(const slice& s) : sta(s.sta), siz(s.siz), str(s.str) { } + ~slice() { } + size_t start() const{ + return sta; + } + size_t size() const{ + return siz; + } + size_t stride() const{ + return str; + } + }; + + + + template class _UCXXEXPORT valarray { + friend class slice_array; + protected: + T * data; + size_t length; + + public: + typedef T value_type; + + valarray() : data(0), length(0) { } + + explicit valarray(size_t t) : data(0), length(t){ + data = new T[length]; + } + + valarray(const T& v, size_t t) : data(0), length(t){ + data = new T[length]; + for(size_t i = 0; i < length; ++i){ + data[i] = v; + } + } + valarray(const T* p, size_t t) : data(0), length(t) { + data = new T[length]; + for(size_t i = 0; i < length; ++i){ + data[i] = p[i]; + } + } + valarray(const valarray& v) : data(0), length(v.length){ + data = new T[length]; + for(size_t i = 0; i < length; ++i){ + data[i] = v.data[i]; + } + } + valarray(const slice_array & sa) : data(0), length(sa.s.size()){ + data = new T[length]; + for(unsigned int i = 0; i < length; ++i){ + data[i] = sa.array->data[sa.s.start() + i * sa.s.stride()]; + } + } + valarray(const gslice_array&); + valarray(const mask_array&); + valarray(const indirect_array&); + ~valarray(){ + delete [] data; + data = 0; + length = 0; + } + + valarray& operator=(const valarray& v){ + if (length != v.length) { // DR 630 + delete [] data; + length = v.length; + data = new T[length]; + } + for (size_t i = 0; i < length; ++i) { + data[i] = v.data[i]; + } + return *this; + } + valarray& operator=(const T& t){ + for(size_t i = 0; i < length; ++i){ + data[i] = t; + } + return *this; + } + valarray& operator=(const slice_array& sa){ + for(size_t i =0; i < length; ++i){ + data[i] = sa.data[sa.s.start() + i * sa.s.stride()]; + } + return *this; + } + valarray& operator=(const gslice_array&); + valarray& operator=(const mask_array&); + valarray& operator=(const indirect_array&); + + const T& operator[](size_t t) const{ + return data[t]; + } + T& operator[](size_t t){ + return data[t]; + } + + valarray operator[](slice s) const{ + valarray retval(s.size()); + for(unsigned int i = 0; i< s.size(); ++i){ + retval.data[i] = data[s.start() + i * s.stride()]; + } + return retval; + } + + slice_array operator[](slice sl){ + slice_array retval; + retval.s = sl; + retval.array = this; + return retval; + } + + valarray operator[](const gslice&) const; + gslice_array operator[](const gslice&); + valarray operator[](const valarray&) const; + mask_array operator[](const valarray&); + valarray operator[](const valarray&) const; + indirect_array operator[](const valarray&); + + valarray operator+() const{ + valarray retval(length); + for(size_t i = 0; i< length ; ++i){ + retval.data[i] = +data[i]; + } + return retval; + } + valarray operator-() const{ + valarray retval(length); + for(size_t i = 0; i< length; ++i){ + retval.data[i] = -data[i]; + } + return retval; + } + valarray operator~() const{ + valarray retval(length); + for(size_t i = 0; i< length ; ++i){ + retval.data[i] = ~data[i]; + } + return retval; + } + valarray operator!() const{ + valarray retval(length); + for (size_t i = 0; i < length ; ++i){ + retval[i] = !data[i]; + } + return retval; + } + valarray& operator*= (const T& t){ + for(size_t i=0;i& operator/= (const T& t){ + for(size_t i=0;i& operator%= (const T& t){ + for(size_t i=0;i& operator+= (const T& t){ + for(size_t i=0;i& operator-= (const T& t){ + for(size_t i=0;i& operator^= (const T& t){ + for(size_t i=0;i& operator&= (const T& t){ + for(size_t i=0;i& operator|= (const T& t){ + for(size_t i=0;i& operator<<=(const T& t){ + for(size_t i=0;i& operator>>=(const T& t){ + for(size_t i=0;i>= t; + } + return *this; + } + valarray& operator*= (const valarray& a){ + for(size_t i=0;i& operator/= (const valarray& a){ + for(size_t i=0;i& operator%= (const valarray& a){ + for(size_t i=0;i& operator+= (const valarray& a){ + for(size_t i=0;i& operator-= (const valarray& a){ + for(size_t i=0;i& operator^= (const valarray& a){ + for(size_t i=0;i& operator|= (const valarray& a){ + for(size_t i=0;i& operator&= (const valarray& a){ + for(size_t i=0;i& operator<<=(const valarray& a){ + for(size_t i=0;i& operator>>=(const valarray& a){ + for(size_t i=0;i>= a.data[i]; + } + return *this; + } +#if 0 + void swap(valarray& other) noexcept { + std::swap(length, other.length); + std::swap(data, other.data); + } +#endif + size_t size() const{ + return length; + } + + T sum() const{ + T retval(data[0]); + for(size_t i = 1; i< length; ++i){ + retval += data[i]; + } + return retval; + } + + T min() const{ + T retval(data[0]); + for(size_t i = 1; i< length; ++i){ + if(data[i] < retval){ + retval = data[i]; + } + } + return retval; + } + + T max() const{ + T retval(data[0]); + for(size_t i = 1; i< length; ++i){ + if(retval < data[i]){ + retval = data[i]; + } + } + return retval; + } + + valarray shift (int n) const{ + valarray retval(length); + if (n < 0) { + if (-size_t(n) > length) + n = -int(length); + } else { + if (size_t(n) > length) + n = int(length); + } + for (size_t i = 0; i < length ; ++i) { + if ((n + i) < length) + retval.data[i] = data[n + i]; + } + return retval; + } + valarray cshift(int n) const{ + valarray retval(length); + if (length == 0) + return retval; + if (n < 0) { + if (-size_t(n) > length) + n = -int(-size_t(n) % length); + n = length + n; + } else { + if (size_t(n) > length) + n = int(size_t(n) % length); + } + for (size_t i = 0; i < length ; ++i){ + retval.data[i] = data[(n + i) % length]; + } + return retval; + } + valarray apply(T func(T) ) const{ + valarray retval(length); + for(size_t i = 0; i< length; ++i){ + retval.data[i] = func(data[i]); + } + return retval; + } + valarray apply(T func(const T&)) const{ + valarray retval(length); + for(size_t i = 0; i< length; ++i){ + retval.data[i] = func(data[i]); + } + return retval; + } + void resize(size_t sz, T c = T()){ + delete [] data; + data = 0; + if(sz > 0){ + data = new T[sz]; + for(size_t i = 0; i < sz; ++i){ + data[i] = c; + } + } + length = sz; + } + }; + + + + template class _UCXXEXPORT slice_array { + friend class valarray; + public: + typedef T value_type; + + void operator= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] = v[i]; + } + } + void operator= (const T & v){ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] = v; + } + } + void fill(const T & v){ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] = v; + } + } + void operator*= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] *= v[i]; + } + } + void operator/= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] /= v[i]; + } + } + void operator%= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] %= v[i]; + } + } + void operator+= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] += v[i]; + } + } + void operator-= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] -= v[i]; + } + } + void operator^= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] ^= v[i]; + } + } + void operator&= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] &= v[i]; + } + } + void operator|= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] |= v[i]; + } + } + void operator<<=(const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] <<= v[i]; + } + } + void operator>>=(const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] >>= v[i]; + } + } + ~slice_array(){ + array = 0; + } + + private: + slice_array() : array(0){ } + + public: + slice_array(const slice_array& sa) : array(sa.array), s(sa.s){ } + slice_array& operator=(const slice_array& sa){ + array = sa.array; + s = sa.s; + return *this; + } + + private: + valarray * array; + slice s; + }; + + + class _UCXXEXPORT gslice { + private: + size_t sta; + valarray siz; + valarray str; + + public: + gslice() : sta(0), siz(), str() { } // DR 543 + gslice(size_t s, const valarray& l, const valarray& d) + : sta(s), siz(l), str(d) { } + + size_t start() const{ + return sta; + } + valarray size() const{ + return siz; + } + valarray stride() const{ + return str; + } + }; + + template class gslice_array { + private: + friend class valarray; + + public: + ~gslice_array(); + + void operator=(const valarray& array) const; + void operator*=(const valarray& array) const; + void operator/=(const valarray& array) const; + void operator%=(const valarray& array) const; + void operator+=(const valarray& array) const; + void operator-=(const valarray& array) const; + void operator^=(const valarray& array) const; + void operator&=(const valarray& array) const; + void operator|=(const valarray& array) const; + void operator<<=(const valarray& array) const; + void operator>>=(const valarray& array) const; + + void operator=(const T&); + + private: + gslice_array(); + gslice_array(const gslice_array&); + gslice_array& operator= (const gslice_array& array); + }; + + + + template valarray operator* (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval *= rhs; + return retval; + } + + template valarray operator* (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval *= rhs; + return retval; + } + template valarray operator* (const T& lhs, const valarray& rhs){ + valarray retval(rhs); + retval *= lhs; + return retval; + } + template valarray operator/ (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval /= rhs; + return retval; + } + template valarray operator/ (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval /= rhs; + return retval; + } + template valarray operator/ (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval /= rhs; + return retval; + } + template valarray operator% (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval %= rhs; + return retval; + } + template valarray operator% (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval %= rhs; + return retval; + } + template valarray operator% (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval %= rhs; + return retval; + } + template valarray operator+ (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval += rhs; + return retval; + } + template valarray operator+ (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval += rhs; + return retval; + } + template valarray operator+ (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval += rhs; + return retval; + } + template valarray operator- (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval -= rhs; + return retval; + } + template valarray operator- (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval -= rhs; + return retval; + } + template valarray operator- (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval -= rhs; + return retval; + } + template valarray operator^ (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval ^= rhs; + return retval; + } + template valarray operator^ (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval ^= rhs; + return retval; + } + template valarray operator^ (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval ^= rhs; + return retval; + } + template valarray operator& (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval &= rhs; + return retval; + } + template valarray operator& (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval &= rhs; + return retval; + } + template valarray operator& (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval &= rhs; + return retval; + } + template valarray operator| (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval |= rhs; + return retval; + } + template valarray operator| (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval |= rhs; + return retval; + } + template valarray operator| (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval |= rhs; + return retval; + } + template valarray operator<<(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval <<= rhs; + return retval; + } + template valarray operator<<(const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval <<= rhs; + return retval; + } + template valarray operator<<(const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval <<= rhs; + return retval; + } + template valarray operator>>(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval >>= rhs; + return retval; + } + template valarray operator>>(const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval >>= rhs; + return retval; + } + template valarray operator>>(const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval >>= rhs; + return retval; + } + + template valarray operator&&(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs[i] && rhs[i]; + } + return retval; + } + template valarray operator&&(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator&&(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator||(const valarray&lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator||(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator||(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs || rhs[i]; + } + return retval; + } + + template valarray operator==(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator==(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs[i] == rhs; + } + return retval; + } + template valarray operator==(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs == rhs[i]; + } + return retval; + } + template valarray operator!=(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator!=(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator!=(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator< (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator< (const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator< (const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator> (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i rhs[i]; + } + return retval; + } + template valarray operator> (const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i rhs; + } + return retval; + } + template valarray operator> (const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i rhs[i]; + } + return retval; + } + template valarray operator<=(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator<=(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator<=(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator>=(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i = rhs[i]; + } + return retval; + } + template valarray operator>=(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i = rhs; + } + return retval; + } + template valarray operator>=(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i = rhs[i]; + } + return retval; + } + template T min(const valarray& x){ + T retval(x[0]); + for(size_t i = 1; i < x.size(); ++i){ + if(x[i] < retval){ + retval = x[i]; + } + } + } + template T max(const valarray& x){ + T retval(x[0]); + for(size_t i = 1; i < x.size(); ++i){ + if(x[i] > retval){ + retval = x[i]; + } + } + } + + template valarray abs (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = abs(x[i]); + } + return retval; + } + template valarray acos (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = acos(x[i]); + } + return retval; + } + template valarray asin (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = asin(x[i]); + } + return retval; + } + template valarray atan (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan(x[i]); + } + return retval; + } + template valarray atan2(const valarray& y, const valarray& x){ + valarray retval(y.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan2(y[i], x[i]); + } + return retval; + } + template valarray atan2(const valarray& y, const T& x){ + valarray retval(y.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan2(y[i], x); + } + return retval; + } + template valarray atan2(const T& y, const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan2(y, x[i]); + } + return retval; + } + template valarray cos (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = cos(x[i]); + } + return retval; + } + template valarray cosh (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = cosh(x[i]); + } + return retval; + } + template valarray exp (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = exp(x[i]); + } + return retval; + } + template valarray log (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = log(x[i]); + } + return retval; + } + template valarray log10(const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = log10(x[i]); + } + return retval; + } + template valarray pow (const valarray& x, const valarray& y){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = pow(x[i], y[i]); + } + return retval; + } + template valarray pow (const valarray& x, const T& y){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = pow(x[i], y); + } + return retval; + } + template valarray pow (const T& x, const valarray& y){ + valarray retval(y.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = pow(x, y[i]); + } + return retval; + } + template valarray sin (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = sin(x[i]); + } + return retval; + } + template valarray sinh (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = sinh(x[i]); + } + return retval; + } + template valarray sqrt (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = sqrt(x[i]); + } + return retval; + } + template valarray tan (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = tan(x[i]); + } + return retval; + } + template valarray tanh (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = tanh(x[i]); + } + return retval; + } +} + +#pragma GCC visibility pop + +#endif diff --git a/include/vector b/include/vector new file mode 100644 index 0000000..8310bc1 --- /dev/null +++ b/include/vector @@ -0,0 +1,517 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include +#include + + +#ifndef __STD_HEADER_VECTOR +#define __STD_HEADER_VECTOR + +#pragma GCC visibility push(default) + +namespace std{ + + template > class vector; + template bool operator==(const vector& x, const vector& y); + template bool operator< (const vector& x, const vector& y); + template bool operator!=(const vector& x, const vector& y); + template bool operator> (const vector& x, const vector& y); + template bool operator>=(const vector& x, const vector& y); + template bool operator<=(const vector& x, const vector& y); + template void swap(vector& x, vector& y); + + template class _UCXXEXPORT vector { + public: + + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + + typedef T* iterator; + typedef const T* const_iterator; + typedef T value_type; + typedef Allocator allocator_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + explicit _UCXXEXPORT vector(const Allocator& al= Allocator()): data(0), //defaultValue(T()), + data_size(__UCLIBCXX_STL_BUFFER_SIZE__), elements(0), a(al) + { + data = a.allocate(data_size); + } + + explicit _UCXXEXPORT vector(size_type n, const T& value = T(), const Allocator& al= Allocator()) : + data(0), data_size(0), elements(0), a(al) + { + data_size = n + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + + resize(n, value); + } + + template _UCXXEXPORT + vector(InputIterator first, InputIterator last, const Allocator& al = Allocator()): + data(0), data_size(__UCLIBCXX_STL_BUFFER_SIZE__), elements(0), a(al) + { + data = a.allocate(data_size); + assign(first, last); + } + + _UCXXEXPORT vector(const vector& x){ + a = x.a; + + elements = x.elements; + data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + + for(size_type i = 0; i < elements; i++){ + a.construct(data+i, x.data[i]); + } + } + + _UCXXEXPORT ~vector(); //Below + + _UCXXEXPORT vector& operator=(const vector& x){ + if(&x == this){ + return *this; + } + + reserve(x.elements); //Make sure that we have enough actual memory + + + //Copy as many elements as possible + + size_t minElements = elements; + if(minElements > x.elements){ + minElements = x.elements; + } + for(size_t i = 0; i < minElements; ++i){ + data[i] = x.data[i]; + } + + //If we need to add new elements + if(elements < x.elements){ + for(size_t i = elements; i< x.elements; ++i){ + a.construct(data+i, x.data[i]); + ++elements; + } + } + + if(elements > x.elements){ + downsize(x.elements); + } + + return *this; + } + + template _UCXXEXPORT void assign(InputIterator first, InputIterator last){ + clear(); + insert(begin(), first, last); + } + + template _UCXXEXPORT void assign(Size n, const U& u = U()){ + clear(); + resize(n, u); + } + + inline allocator_type get_allocator() const{ + return a; + } + + inline iterator begin(){ + return data; + } + + inline const_iterator begin() const{ + return data; + } + + inline iterator end(){ + return (data + elements); + } + + inline const_iterator end() const{ + return (data + elements); + } + + inline reverse_iterator rbegin(){ + return reverse_iterator(end()); + } + + inline const_reverse_iterator rbegin() const{ + return const_reverse_iterator(end()); + } + + inline reverse_iterator rend(){ + return reverse_iterator(begin()); + } + + inline const_reverse_iterator rend() const{ + return const_reverse_iterator(begin()); + } + + inline size_type size() const{ + return elements; + } + + _UCXXEXPORT size_type max_size() const{ + return ((size_type)(-1)) / sizeof(T); + } + + void downsize(size_type sz); + void resize(size_type sz, const T & c = T()); + + inline size_type capacity() const{ + return data_size; + } + + inline bool empty() const{ + return (size() == 0); + } + + void reserve(size_type n); + + inline reference operator[](size_type n){ + return data[n]; + } + + inline const_reference operator[](size_type n) const{ + return data[n]; + } + + _UCXXEXPORT const_reference at(size_type n) const{ + if(n >= elements){ + __throw_out_of_range("Invalid subscript"); + } + return data[n]; + } + + _UCXXEXPORT reference at(size_type n){ + if(n >= elements){ + __throw_out_of_range("Invalid subscript"); + } + return data[n]; + } + + inline reference front(){ + return data[0]; + } + + inline const_reference front() const{ + return data[0]; + } + + inline reference back(){ + return data[ size() - 1]; + } + + inline const_reference back() const{ + return data[ size() - 1 ]; + } + + inline void push_back(const T& x){ + resize( size() + 1, x); + } + + inline void pop_back(){ + downsize(size() - 1); + } + + _UCXXEXPORT iterator insert(iterator position, const T& x = T()){ + size_type index = position - data; + resize(size() + 1, x); + for(size_type i = elements - 1; i > index; --i){ + data[i] = data[i-1]; + } + data[index] = x; + return (data + index); + } + + _UCXXEXPORT void _insert_fill(iterator position, size_type n, const T & x){ + size_type index = position - data; + resize(size() + n, x); + + for(size_type i = elements -1; (i > (index+n-1)); --i){ + data[i] = data[i-n]; + } + for(size_type i = 0; i < n; i++){ + data[i + index] = x; + } + } + + template _UCXXEXPORT + void _insert_from_iterator(iterator position, InputIterator first, InputIterator last) + { + T temp; + while(first !=last){ + temp = *first; + position = insert(position, temp); + ++position; + ++first; + } + } + + template + inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __true_type) + { + _insert_fill(position, first, last); + } + + template + inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __false_type) + { + _insert_from_iterator(position, first, last); + } + + inline void insert(iterator position, size_type n, const T& x ){ + _insert_fill(position, n, x); + } + + template inline void insert(iterator position, InputIterator first, InputIterator last){ + typedef typename __is_integer::value __some_type; + _dispatch_insert(position, first, last, __some_type()); + } + + _UCXXEXPORT iterator erase(iterator position){ + size_type index = position - data; + for(size_type i = index; i < (elements - 1); ++i){ + data[i] = data[i+1]; + } + downsize(size() - 1); + return (data + index); + } + + _UCXXEXPORT iterator erase(iterator first, iterator last){ + size_type index = first - data; + size_type width = last - first; + for(size_type i = index; i < (elements - width) ;++i){ + data[i] = data[i+width]; + } + downsize(size() - width); + return (data + index); + } + + _UCXXEXPORT void swap(vector& v){ + if(this == &v){ //Avoid dv.swap(v) + return; + } + T* ptr; + size_type temp; + + //Swap pointers first + ptr = data; + data = v.data; + v.data = ptr; + + //Swap element counts + temp = elements; + elements = v.elements; + v.elements = temp; + + //Swap data size + temp = data_size; + data_size = v.data_size; + v.data_size = temp; + } + + _UCXXEXPORT void clear(){ + downsize(0); + } + + protected: + T* data; + size_type data_size; + size_type elements; + Allocator a; + }; + + + + //Here go template instantiations + + template _UCXXEXPORT vector::~vector(){ + for(size_t i = 0; i < elements; ++i){ + a.destroy(data + i); + } + a.deallocate(data, data_size); + } + + + template _UCXXEXPORT void vector::reserve(size_type n){ + if(n > data_size){ //We never shrink... + T * temp_ptr = data; + size_type temp_size = data_size; + + data_size = n; + data = a.allocate(data_size); + + for(size_type i = 0; i _UCXXEXPORT void vector::resize(size_type sz, const T & c){ + if(sz > elements){ //Need to actually call constructor + if(sz > data_size){ + reserve(sz + __UCLIBCXX_STL_BUFFER_SIZE__); + } + + for(size_type i = elements; i _UCXXEXPORT void vector::downsize(size_type sz){ + if(sz < elements){ //Actually are downsizing + for(size_t i = sz; i< elements; ++i){ + a.destroy(data+i); + } + elements = sz; + } + } + + +#ifndef __UCLIBCXX_COMPILE_VECTOR__ +#ifdef __UCLIBCXX_EXPAND_VECTOR_BASIC__ + + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + template<> _UCXXEXPORT vector >::vector(const allocator& al); + template<> _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); + + template<> _UCXXEXPORT vector >::~vector(); + template<> _UCXXEXPORT vector >::~vector(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::reserve(size_type n); + + template<> _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + template<> _UCXXEXPORT void + vector >::resize(size_type sz, const unsigned char & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const short & c); + template<> _UCXXEXPORT void + vector >::resize(size_type sz, const unsigned short int & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const int & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const unsigned int & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const long int & c); + template<> _UCXXEXPORT void + vector >::resize(size_type sz, const unsigned long int & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const float & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const double & c); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const bool & c); + +#elif defined __UCLIBCXX_EXPAND_STRING_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template<> _UCXXEXPORT vector >::vector(const allocator& al); + template<> _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); + template<> _UCXXEXPORT vector >::~vector(); + +#endif + + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + +#endif +#endif + + + + template _UCXXEXPORT bool + operator==(const vector& x, const vector& y) + { + if(x.size() !=y.size() ){ + return false; + } + for(size_t i = 0; i < x.size(); ++i){ + if(x[i] != y[i]){ + return false; + } + } + return true; + } + + template _UCXXEXPORT bool + operator< (const vector& x, const vector& y) + { + less::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + template _UCXXEXPORT bool + operator!=(const vector& x, const vector& y) + { + return !(x == y); + } + template _UCXXEXPORT bool + operator> (const vector& x, const vector& y) + { + greater::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + template _UCXXEXPORT bool + operator>=(const vector& x, const vector& y) + { + greater_equal::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + template _UCXXEXPORT bool + operator<=(const vector& x, const vector& y) + { + less_equal::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + + template _UCXXEXPORT void swap(vector& x, vector& y){ + x.swap(y); + } + +} + +#pragma GCC visibility pop + +#endif + diff --git a/scripts/find_libgcc_eh.sh b/scripts/find_libgcc_eh.sh new file mode 100755 index 0000000..b70868c --- /dev/null +++ b/scripts/find_libgcc_eh.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +#This purpose of this file is to return the filename for libgcc_eh to be used. We use the script so that it +#can be easily replaced by system developers and cross-compilers so that the user doesn't require an installed +#instance of libstdc++ on their system to use the library - just point at the appropriate location in the +#gcc build directory and rip it apart. + +$CC -print-file-name=libgcc_eh.a + diff --git a/scripts/find_libsupc.sh b/scripts/find_libsupc.sh new file mode 100755 index 0000000..107443f --- /dev/null +++ b/scripts/find_libsupc.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +#This purpose of this file is to return the filename for libsupc++.a to be used. We use the script so that it +#can be easily replaced by system developers and cross-compilers so that the user doesn't require an installed +#instance of libstdc++ on their system to use the library - just point at the appropriate location in the +#gcc build directory and rip it apart. + +$CC -print-file-name=libsupc++.a + diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..370f700 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,6 @@ +top_srcdir=../ +top_builddir=../ +lib: +include $(top_srcdir)Rules.mak +include Makefile.in +include $(top_srcdir)Makefile.end diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..352b056 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,58 @@ +WR_CXX := WRAPPER_INCLUDEDIR=-I$(top_srcdir)include $(WRAPPER) + +LDFLAGS-$(if $(DODEBUG),,y)-$(LIBNAME).so += -Wl,-s +LDFLAGS-$(LIBNAME).so += -nodefaultlibs -shared +LIBS-$(LIBNAME).so += $(BUILD_EXTRA_LIBRARIES) $(LIBS) + +SRC_DIR := $(top_srcdir)src/ +SRC_OUT := $(top_builddir)src/ + +SRCS = $(notdir $(wildcard $(SRC_DIR)*.cpp)) +SRCS := $(filter-out support.cpp,$(SRCS)) +SRCS := $(filter-out typeinfo.cpp,$(SRCS)) +SRCS += abi/abi.cpp +EXOBJS := $(patsubst %.cpp,$(SRC_OUT)%.o, $(SRCS)) + +libs-y := +libs-$(BUILD_STATIC_LIB) += $(SRC_OUT)$(LIBNAME).a +libs-$(if $(BUILD_ONLY_STATIC_LIB),,y) += $(SRC_OUT)$(LIBNAME).so + +lib: $(libs-y) + +include $(top_srcdir)src/abi/libgcc_eh/Makefile.in +include $(top_srcdir)src/abi/libsupc/Makefile.in + +install-lib: lib | $(DESTDIR)$(UCLIBCXX_RUNTIME_LIBDIR) + @$(if $(BUILD_STATIC_LIB),$(call disp_install, $(LIBNAME).a)) + @$(if $(BUILD_ONLY_STATIC_LIB),,$(call disp_install, \ + $(SHARED_FULLNAME) $(SHARED_MAJORNAME) $(LIBNAME).so)) + $(Q)(cd $(SRC_OUT); \ + $(TAR) -cf - \ + $(if $(BUILD_STATIC_LIB),$(LIBNAME).a,) \ + $(if $(BUILD_ONLY_STATIC_LIB),, \ + $(SHARED_FULLNAME) \ + $(SHARED_MAJORNAME) $(LIBNAME).so \ + ) \ + ) | $(TAR) -xf - -C $(DESTDIR)$(UCLIBCXX_RUNTIME_LIBDIR) + +libcxx-a-y = $(EXOBJS) $(libgcc_eh-y) $(libsupc-y) +libcxx-so-y = $(EXOBJS) $(libgcc_eh-y) $(libsupc-y) + +$(EXOBJS) $(libgcc_eh-y) $(libsupc-y) : $(WRAPPER) + +$(top_builddir)src/$(LIBNAME).a: $(libcxx-a-y) + $(Q)$(RM) $@ + $(do_ar) + $(do_ranlib) + +$(top_builddir)src/$(LIBNAME).so: $(libcxx-so-y) + $(call link.so,$(SRC_OUT)$(SHARED_FULLNAME),$(ABI_VERSION)) + +CXXFLAGS-del_ops.o = $(CXXFLAG_-std=gnu++14) $(CXXFLAG_-Wno-sized-deallocation) +CXXFLAGS-del_opvs.o = $(CXXFLAG_-std=gnu++14) $(CXXFLAG_-Wno-sized-deallocation) + +CLEAN_src: + $(do_rm) $(addprefix $(SRC_OUT), *.o abi/*.o libuClibc++* core) +DISTCLEAN_src: DISTCLEAN_src/abi/libgcc_eh DISTCLEAN_src/abi/libsupc + $(do_rm) $(addprefix $(SRC_OUT), .*.dep abi/.*.dep) + diff --git a/src/abi/abi.cpp b/src/abi/abi.cpp new file mode 100644 index 0000000..386f35a --- /dev/null +++ b/src/abi/abi.cpp @@ -0,0 +1,39 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc C++ Library. This library is free + software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) + any later version. + + This 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this library; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. +*/ + +#include +#include +#include + +/* This file implements a number of the language support features + * needed to deal with the C++ abi, as originally documented in the + * Itanium C++ ABI, though now industry standard + */ + +extern "C" { + + /* This function is called in the event that a non-overidden + * pure virtual function is called. The compiler should never + * let that happen. We get to choose what to do - we will abort + */ + void __cxa_pure_virtual (){ + abort(); + } + +} diff --git a/src/abi/libgcc_eh/Makefile b/src/abi/libgcc_eh/Makefile new file mode 100644 index 0000000..dede061 --- /dev/null +++ b/src/abi/libgcc_eh/Makefile @@ -0,0 +1,4 @@ +top_srcdir=../../../ +top_builddir=../../../ +include $(top_srcdir)Rules.mak +include Makefile.in diff --git a/src/abi/libgcc_eh/Makefile.in b/src/abi/libgcc_eh/Makefile.in new file mode 100644 index 0000000..46b0017 --- /dev/null +++ b/src/abi/libgcc_eh/Makefile.in @@ -0,0 +1,24 @@ +LIBGCC_EH_OUT := $(top_builddir)src/abi/libgcc_eh/ + +OBJS = $(call list-archive-members,$(LIBGCC_EH)) +libgcc_eh-$(IMPORT_LIBGCC_EH) := $(OBJS) + +LIBGCC_EH_VAR := $(call variablify,$(LIBGCC_EH)) +LIBGCC_EH_DEP := $(LIBGCC_EH_OUT).$(LIBGCC_EH_VAR).dep + +ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) +-include $(LIBGCC_EH_DEP) +endif + + +ifneq ($(libgcc_eh-y),) +$(libgcc_eh-y): $(LIBGCC_EH) +endif +$(LIBGCC_EH_DEP): $(LIBGCC_EH) + $(Q)$(RM) $(LIBGCC_EH_OUT).*dep $(LIBGCC_EH_OUT)*.o + $(Q)$(if $(LIBGCC_EH),(cd $(LIBGCC_EH_OUT) && $(AR) x $(LIBGCC_EH))) + $(Q)echo "libgcc_eh-y := \$$(addprefix \$$(LIBGCC_EH_OUT),$(libgcc_eh-y))" > $@ + +CLEAN_src/abi/libgcc_eh: ; +DISTCLEAN_src/abi/libgcc_eh: + $(do_rm) $(addprefix $(LIBGCC_EH_OUT),.*dep *.o) diff --git a/src/abi/libsupc/Makefile b/src/abi/libsupc/Makefile new file mode 100644 index 0000000..dede061 --- /dev/null +++ b/src/abi/libsupc/Makefile @@ -0,0 +1,4 @@ +top_srcdir=../../../ +top_builddir=../../../ +include $(top_srcdir)Rules.mak +include Makefile.in diff --git a/src/abi/libsupc/Makefile.in b/src/abi/libsupc/Makefile.in new file mode 100644 index 0000000..89e0e8a --- /dev/null +++ b/src/abi/libsupc/Makefile.in @@ -0,0 +1,24 @@ +LIBSUPC_OUT := $(top_builddir)src/abi/libsupc/ + +OBJS = $(call list-archive-members,$(LIBSUP)) +OBJS-OMIT = $(filter new_op%.o del_op%.o pure.o new_handler.o eh_alloc.o eh_globals.o,$(OBJS)) +libsupc-$(IMPORT_LIBSUP) := $(filter-out $(OBJS-OMIT),$(OBJS)) + +LIBSUP_VAR := $(call variablify,$(LIBSUP)) +LIBSUP_DEP :=$(LIBSUPC_OUT).$(LIBSUP_VAR).dep + +ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) +-include $(LIBSUP_DEP) +endif + +ifneq ($(libsupc-y),) +$(libsupc-y): $(LIBSUP) +endif +$(LIBSUP_DEP): $(LIBSUP) $(LIBSUPC_OUT)Makefile.in + $(Q)$(RM) $(LIBSUPC_OUT).*dep $(LIBSUPC_OUT)*.o + $(Q)$(if $(LIBSUP),(cd $(LIBSUPC_OUT) && $(AR) x $(LIBSUP) && $(RM) $(OBJS-OMIT))) + $(Q)echo "libsupc-y := \$$(addprefix \$$(LIBSUPC_OUT),$(libsupc-y))" > $@ + +CLEAN_src/abi/libsupc: ; +DISTCLEAN_src/abi/libsupc: + $(do_rm) $(addprefix $(LIBSUPC_OUT), .*dep *.o) diff --git a/src/algorithm.cpp b/src/algorithm.cpp new file mode 100644 index 0000000..e21b14e --- /dev/null +++ b/src/algorithm.cpp @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +namespace std{ + + + +} + + diff --git a/src/array.cpp b/src/array.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/associative_base.cpp b/src/associative_base.cpp new file mode 100644 index 0000000..cc2d20e --- /dev/null +++ b/src/associative_base.cpp @@ -0,0 +1,26 @@ +/* Copyright (C) 2007 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + +} diff --git a/src/bitset.cpp b/src/bitset.cpp new file mode 100644 index 0000000..f1ece31 --- /dev/null +++ b/src/bitset.cpp @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + +} diff --git a/src/char_traits.cpp b/src/char_traits.cpp new file mode 100644 index 0000000..2a91bd9 --- /dev/null +++ b/src/char_traits.cpp @@ -0,0 +1,69 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +*/ + +#define __UCLIBCXX_COMPILE_CHAR_TRAITS__ 1 + + +#include +#include + +namespace std{ + +_UCXXEXPORT const char_traits::char_type* char_traits::find(const char_type* s, int n, const char_type& a){ + for(int i=0; i < n; i++){ + if(eq(s[i], a)){ + return (s+i); + } + } + return 0; +} + +_UCXXEXPORT bool char_traits::eq(const char_type& c1, const char_type& c2){ + if(strncmp(&c1, &c2, 1) == 0){ + return true; + } + return false; +} + +_UCXXEXPORT char_traits::char_type char_traits::to_char_type(const int_type & i){ + if(i > 0 && i <= 255){ + return (char)(unsigned char)i; + } + + //Out of range + return 0; +} + + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + +_UCXXEXPORT const char_traits::char_type* char_traits::find(const char_type* s, int n, const char_type& a){ + for(int i=0; i < n; i++){ + if(eq(s[i], a)){ + return (s+i); + } + } + return 0; +} + +#endif + +} diff --git a/src/complex.cpp b/src/complex.cpp new file mode 100644 index 0000000..6b895a8 --- /dev/null +++ b/src/complex.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +namespace std{ + + + template class _UCXXEXPORT complex; + + +} diff --git a/src/del_op.cpp b/src/del_op.cpp new file mode 100644 index 0000000..9485cee --- /dev/null +++ b/src/del_op.cpp @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +_UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT{ + free(ptr); +} diff --git a/src/del_opnt.cpp b/src/del_opnt.cpp new file mode 100644 index 0000000..4825912 --- /dev/null +++ b/src/del_opnt.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef NO_NOTHROW +_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT { + free(ptr); +} +#endif diff --git a/src/del_ops.cpp b/src/del_ops.cpp new file mode 100644 index 0000000..b914fc5 --- /dev/null +++ b/src/del_ops.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2015 Bernhard Reutner-Fischer + + This file is part of the uClibc++ Library. + + 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 +*/ +/* C++14 sized deallocation */ + +#include +#include +#include + +_UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT{ + ::operator delete (ptr); +} diff --git a/src/del_opv.cpp b/src/del_opv.cpp new file mode 100644 index 0000000..deaad78 --- /dev/null +++ b/src/del_opv.cpp @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +_UCXXEXPORT void operator delete[](void * ptr) _UCXX_USE_NOEXCEPT{ + free(ptr); +} diff --git a/src/del_opvnt.cpp b/src/del_opvnt.cpp new file mode 100644 index 0000000..71b7631 --- /dev/null +++ b/src/del_opvnt.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef NO_NOTHROW +_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{ + free(ptr); +} +#endif diff --git a/src/del_opvs.cpp b/src/del_opvs.cpp new file mode 100644 index 0000000..53ab7cc --- /dev/null +++ b/src/del_opvs.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2015 Bernhard Reutner-Fischer + + This file is part of the uClibc++ Library. + + 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 +*/ +/* C++14 sized deallocation */ + +#include +#include +#include + +_UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT{ + ::operator delete[] (ptr); +} diff --git a/src/deque.cpp b/src/deque.cpp new file mode 100644 index 0000000..c515580 --- /dev/null +++ b/src/deque.cpp @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +namespace std{ + + + + + + + + + + + + + + +} + + + + diff --git a/src/eh_alloc.cpp b/src/eh_alloc.cpp new file mode 100644 index 0000000..270ef10 --- /dev/null +++ b/src/eh_alloc.cpp @@ -0,0 +1,65 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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, version 2.1 + of the License. + + 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 +#include +#include + +//This is a system-specific header which does all of the error-handling management +#include + +namespace __cxxabiv1 +{ + +extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) _UCXX_USE_NOEXCEPT{ + void *e; + // The sizeof crap is required by Itanium ABI because we need to + // provide space for accounting information which is implementation + // (gcc) defined. + e = malloc (thrown_size + sizeof(__cxa_refcounted_exception)); + if (0 == e){ + std::terminate(); + } + memset (e, 0, sizeof(__cxa_refcounted_exception)); + return (void *)((unsigned char *)e + sizeof(__cxa_refcounted_exception)); +} + +extern "C" void __cxa_free_exception(void *vptr) _UCXX_USE_NOEXCEPT{ + free( (char *)(vptr) - sizeof(__cxa_refcounted_exception) ); +} + + +extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() _UCXX_USE_NOEXCEPT{ + __cxa_dependent_exception *retval; + // The sizeof crap is required by Itanium ABI because we need to + // provide space for accounting information which is implementation + // (gcc) defined. + retval = static_cast<__cxa_dependent_exception*>(malloc (sizeof(__cxa_dependent_exception))); + if (0 == retval){ + std::terminate(); + } + memset (retval, 0, sizeof(__cxa_dependent_exception)); + return retval; +} + +extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *vptr) _UCXX_USE_NOEXCEPT{ + free( (char *)(vptr) ); +} + +} /* namespace __cxxabiv1 */ diff --git a/src/eh_globals.cpp b/src/eh_globals.cpp new file mode 100644 index 0000000..9915433 --- /dev/null +++ b/src/eh_globals.cpp @@ -0,0 +1,42 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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, version 2.1 + of the License. + + 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 +#include +#include + +//This is a system-specific header which does all of the error-handling management +#include + +//The following functionality is derived from reading of the GNU libstdc++ code and making it...simple + + +namespace __cxxabiv1{ + +static __UCLIBCXX_TLS __cxa_eh_globals eh_globals; + +extern "C" __cxa_eh_globals* __cxa_get_globals() _UCXX_USE_NOEXCEPT{ + return &eh_globals; +} + +extern "C" __cxa_eh_globals* __cxa_get_globals_fast() _UCXX_USE_NOEXCEPT{ + return &eh_globals; +} + +} diff --git a/src/exception.cpp b/src/exception.cpp new file mode 100644 index 0000000..5f4e896 --- /dev/null +++ b/src/exception.cpp @@ -0,0 +1,52 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +//We can't do this yet because gcc is too stupid to be able to handle +//different implementations of exception class. + +#undef __UCLIBCXX_EXCEPTION_SUPPORT__ + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +namespace std{ + _UCXXEXPORT static char * __std_exception_what_value = "exception"; + + //We are providing our own versions to be sneaky + + + _UCXXEXPORT exception::~exception() _UCXX_USE_NOEXCEPT{ + //Empty function + } + + _UCXXEXPORT const char* exception::what() const _UCXX_USE_NOEXCEPT{ + return __std_exception_what_value; + } + + _UCXXEXPORT bad_exception::~bad_exception() _UCXX_USE_NOEXCEPT{ + + } + + +} + + +#endif diff --git a/src/fstream.cpp b/src/fstream.cpp new file mode 100644 index 0000000..535fe9a --- /dev/null +++ b/src/fstream.cpp @@ -0,0 +1,174 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_FSTREAM__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT filebuf::basic_filebuf(); + template _UCXXEXPORT filebuf::~basic_filebuf(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT filebuf::int_type filebuf::pbackfail(filebuf::int_type c); + template _UCXXEXPORT filebuf * filebuf::open(const char* s, ios_base::openmode mode); + template _UCXXEXPORT filebuf * filebuf::close(); + template _UCXXEXPORT filebuf::int_type filebuf::overflow(filebuf::int_type); + template _UCXXEXPORT filebuf::int_type filebuf::underflow (); + template _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n); + + template _UCXXEXPORT basic_streambuf >* + filebuf::setbuf(char * s, streamsize n); + + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT basic_ofstream >::basic_ofstream(); + template _UCXXEXPORT basic_ofstream >::basic_ofstream(const char* s, ios_base::openmode mode); + template _UCXXEXPORT basic_ofstream >::~basic_ofstream(); + + template _UCXXEXPORT basic_ifstream >::basic_ifstream(); + template _UCXXEXPORT basic_ifstream >::basic_ifstream(const char* s, ios_base::openmode mode); + template _UCXXEXPORT basic_ifstream >::~basic_ifstream(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + +#endif + + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::overflow(int_type c) +{ + typedef basic_streambuf > wstreambuf; + typedef char_traits wtraits; + + if(is_open() == false){ + //Can't do much + return wtraits::eof(); + } + + mbstate_t ps = { 0 }; + char out_array[8]; + size_t out_size; + + + if( wstreambuf::pbase() != 0 ){ + + //Write all possible character from the existing array first + size_t chars_written = 0; + while(wstreambuf::pbase() && (wstreambuf::pbase() + chars_written !=wstreambuf::pptr()) ){ + out_size = wcrtomb(out_array, wstreambuf::pbase()[chars_written], &ps); + if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){ + break; + } + ++chars_written; + } + + if( wstreambuf::pbase() + chars_written == wstreambuf::pptr() ){ + wstreambuf::pbump(-chars_written); + }else{ + //Shuffle data back into order + size_t chars_left = wstreambuf::pptr() - wstreambuf::pbase() - chars_written; + for(size_t i = 0; i < chars_left; ++i){ + wstreambuf::pbase()[i] = (wstreambuf::pptr() - chars_written)[i]; + } + return wtraits::eof(); + } + } + + if( !wtraits::eq_int_type(c, wtraits::eof()) ){ + out_size = wcrtomb(out_array, c, &ps); + if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){ + return wtraits::eof(); + } + return c; + } + + return wtraits::not_eof(c); +} + + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::underflow() +{ + /*Some variables used internally: + Buffer pointers: + + charT * mgbeg; + charT * mgnext; + charT * mgend; + + eback() returns mgbeg + gptr() returns mgnext + egptr() returns mgend + + gbump(int n) mgnext+=n + */ + + typedef char_traits traits; + typedef basic_streambuf wstreambuf; + + + if(wstreambuf::eback() == wstreambuf::gptr() && 0 != wstreambuf::eback()){ //Buffer is full + return traits::to_int_type(*wstreambuf::gptr()); + } + + size_t in_size; + + wchar_t c = 0; + wint_t wi = 0; + in_size = 0; + + wi = fgetwc(fp); + if(WEOF == wi){ + fprintf(stderr, "WEOF returned by fgetwc\n"); + return traits::eof(); + } + + c = traits::to_char_type(wi); + + if(wstreambuf::eback() == 0){ + return traits::to_int_type(c); + } + + for(wchar_t * i = wstreambuf::gptr(); i < wstreambuf::egptr(); ++i){ + *(i-1) = *i; + } + + *(wstreambuf::egptr()-1) = c; + + wstreambuf::mgnext -= 1; + + return traits::to_int_type(*wstreambuf::gptr()); +} + +#endif // __UCLIBCXX_HAS_WCHAR__ + + +} diff --git a/src/func_exception.cpp b/src/func_exception.cpp new file mode 100644 index 0000000..fab095f --- /dev/null +++ b/src/func_exception.cpp @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +_UCXXEXPORT void __throw_bad_alloc(){ + throw bad_alloc(); +} + +_UCXXEXPORT void __throw_out_of_range( const char * message){ + if(message == 0){ + throw out_of_range(); + } + throw out_of_range(message); +} + +_UCXXEXPORT void __throw_overflow_error( const char * message){ + if(message == 0){ + throw overflow_error(); + } + throw overflow_error(message); +} + +_UCXXEXPORT void __throw_length_error(const char * message){ + if(message == 0){ + throw length_error(); + } + throw length_error(message); +} + +_UCXXEXPORT void __throw_invalid_argument(const char * message){ + if(message == 0){ + throw invalid_argument(); + } + throw invalid_argument(message); +} + +#else + +_UCXXEXPORT void __throw_bad_alloc(){ + abort(); +} + +_UCXXEXPORT void __throw_out_of_range( const char * ){ + abort(); +} + +_UCXXEXPORT void __throw_overflow_error( const char * ){ + abort(); +} + +_UCXXEXPORT void __throw_length_error(const char * ){ + abort(); +} + +_UCXXEXPORT void __throw_invalid_argument(const char *){ + abort(); +} + +#endif + + + +} diff --git a/src/iomanip.cpp b/src/iomanip.cpp new file mode 100644 index 0000000..c5e60cc --- /dev/null +++ b/src/iomanip.cpp @@ -0,0 +1,29 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + + +} + + diff --git a/src/ios.cpp b/src/ios.cpp new file mode 100644 index 0000000..3b85d5b --- /dev/null +++ b/src/ios.cpp @@ -0,0 +1,189 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_IOS__ 1 + +#include +#include +#include +#include +#include + +namespace std{ + + +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + _UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created + +//Create buffers first +#ifdef __UCLIBCXX_SUPPORT_COUT__ + _UCXXEXPORT filebuf _cout_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_CIN__ + _UCXXEXPORT filebuf _cin_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_CERR__ + _UCXXEXPORT filebuf _cerr_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_CLOG__ + _UCXXEXPORT filebuf _clog_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + _UCXXEXPORT wfilebuf _wcout_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + _UCXXEXPORT wfilebuf _wcin_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + _UCXXEXPORT wfilebuf _wcerr_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + _UCXXEXPORT wfilebuf _wclog_filebuf; +#endif + +//Then create streams +#ifdef __UCLIBCXX_SUPPORT_COUT__ + _UCXXEXPORT ostream cout(&_cout_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_CIN__ + _UCXXEXPORT istream cin(&_cin_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_CERR__ + _UCXXEXPORT ostream cerr(&_cerr_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_CLOG__ + _UCXXEXPORT ostream clog(&_clog_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + _UCXXEXPORT wostream wcout(&_wcout_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + _UCXXEXPORT wistream wcin(&_wcin_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + _UCXXEXPORT wostream wcerr(&_wcerr_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + _UCXXEXPORT wostream wclog(&_wclog_filebuf); +#endif + + + _UCXXEXPORT ios_base::Init::Init(){ + if(init_cnt == 0){ //Need to construct cout et al +#ifdef __UCLIBCXX_SUPPORT_COUT__ + _cout_filebuf.fp = stdout; + _cout_filebuf.openedFor = ios_base::out; +#endif +#ifdef __UCLIBCXX_SUPPORT_CERR__ + _cerr_filebuf.fp = stderr; + _cerr_filebuf.openedFor = ios_base::out; + cerr.mformat |= ios_base::unitbuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_CLOG__ + _clog_filebuf.fp = stderr; + _clog_filebuf.openedFor = ios_base::out; +#endif +#ifdef __UCLIBCXX_SUPPORT_CIN__ + _cin_filebuf.fp = stdin; + _cin_filebuf.openedFor = ios_base::in; + +#ifdef __UCLIBCXX_SUPPORT_COUT__ + cin.tie(&cout); +#endif + +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + _wcout_filebuf.fp = stdout; + _wcout_filebuf.openedFor = ios_base::out; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + _wcerr_filebuf.fp = stderr; + _wcerr_filebuf.openedFor = ios_base::out; + wcerr.mformat |= ios_base::unitbuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + _wclog_filebuf.fp = stderr; + _wclog_filebuf.openedFor = ios_base::out; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + _wcin_filebuf.fp = stdin; + _wcin_filebuf.openedFor = ios_base::in; + +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + wcin.tie(&wcout); +#endif + +#endif + } + init_cnt++; + } + + _UCXXEXPORT ios_base::Init::~Init(){ + --init_cnt; + if(init_cnt==0){ + + } + } +#endif + + +#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ + + template _UCXXEXPORT void basic_ios >::clear(iostate state); + template _UCXXEXPORT void basic_ios >::setstate(iostate state); + +#endif + + + _UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){ + fmtflags temp = mformat; + mformat = fmtfl; + return temp; + } + + _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){ + return flags(flags() | fmtfl); + } + + _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){ + return flags( (flags()& ~mask) | (fmtfl & mask)); + } + + _UCXXEXPORT streamsize ios_base::precision(streamsize prec){ + streamsize temp = mprecision; + mprecision = prec; + return temp; + } + + _UCXXEXPORT streamsize ios_base::width(streamsize wide){ + streamsize temp = mwidth; + mwidth = wide; + return temp; + } + + _UCXXEXPORT locale ios_base::imbue(const locale& loc){ + locale retval = mLocale; + mLocale = loc; + return retval; + } + +} + + + diff --git a/src/iostream.cpp b/src/iostream.cpp new file mode 100644 index 0000000..7a190a2 --- /dev/null +++ b/src/iostream.cpp @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_IOSTREAM__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + + template _UCXXEXPORT basic_iostream >:: + basic_iostream(basic_streambuf >* sb); + template _UCXXEXPORT basic_iostream >::~basic_iostream(); + +#endif +#endif + +} + + diff --git a/src/istream.cpp b/src/istream.cpp new file mode 100644 index 0000000..9e96139 --- /dev/null +++ b/src/istream.cpp @@ -0,0 +1,75 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +*/ + +#define __UCLIBCXX_COMPILE_ISTREAM__ 1 + +#include + + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + + template <> _UCXXEXPORT string _readToken >(istream & stream) + { + string temp; + char_traits::int_type c; + while(true){ + c = stream.rdbuf()->sgetc(); + if(c != char_traits::eof() && isspace(c) == false){ + stream.rdbuf()->sbumpc(); + temp.append(1, char_traits::to_char_type(c)); + }else{ + break; + } + } + if (temp.size() == 0) + stream.setstate(ios_base::eofbit|ios_base::failbit); + + return temp; + } + + template _UCXXEXPORT istream::int_type istream::get(); + template _UCXXEXPORT istream & istream::get(char &c); + + template _UCXXEXPORT istream & istream::operator>>(bool &n); + template _UCXXEXPORT istream & istream::operator>>(short &n); + template _UCXXEXPORT istream & istream::operator>>(unsigned short &n); + template _UCXXEXPORT istream & istream::operator>>(int &n); + template _UCXXEXPORT istream & istream::operator>>(unsigned int &n); + template _UCXXEXPORT istream & istream::operator>>(long unsigned &n); + template _UCXXEXPORT istream & istream::operator>>(long int &n); + template _UCXXEXPORT istream & istream::operator>>(void *& p); + template _UCXXEXPORT istream & operator>>(istream & is, char & c); + + +#ifdef __UCLIBCXX_HAS_FLOATS__ + template _UCXXEXPORT istream & istream::operator>>(float &f); + template _UCXXEXPORT istream & istream::operator>>(double &f); + template _UCXXEXPORT istream & istream::operator>>(long double &f); +#endif + + template _UCXXEXPORT void __skipws(basic_istream >& is); + +#endif + + +} + diff --git a/src/iterator.cpp b/src/iterator.cpp new file mode 100644 index 0000000..2e21517 --- /dev/null +++ b/src/iterator.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + +} + + diff --git a/src/limits.cpp b/src/limits.cpp new file mode 100644 index 0000000..0fd42d5 --- /dev/null +++ b/src/limits.cpp @@ -0,0 +1,25 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + +} diff --git a/src/list.cpp b/src/list.cpp new file mode 100644 index 0000000..cfc44e0 --- /dev/null +++ b/src/list.cpp @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + + +} + + diff --git a/src/locale.cpp b/src/locale.cpp new file mode 100644 index 0000000..bc41792 --- /dev/null +++ b/src/locale.cpp @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include +#include +#include + +namespace std{ + +} + diff --git a/src/map.cpp b/src/map.cpp new file mode 100644 index 0000000..06e56a0 --- /dev/null +++ b/src/map.cpp @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + + + + + + + + +} diff --git a/src/new_handler.cpp b/src/new_handler.cpp new file mode 100644 index 0000000..a6efb9c --- /dev/null +++ b/src/new_handler.cpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +const std::nothrow_t std::nothrow = { }; + +//Name selected to be compatable with g++ code +std::new_handler __new_handler; + +_UCXXEXPORT std::new_handler std::set_new_handler(std::new_handler new_p) _UCXX_USE_NOEXCEPT{ + std::new_handler retval = __new_handler; + __new_handler = new_p; + return retval; +} diff --git a/src/new_op.cpp b/src/new_op.cpp new file mode 100644 index 0000000..b0d2b78 --- /dev/null +++ b/src/new_op.cpp @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +_UCXXEXPORT void* operator new(std::size_t numBytes) _UCXX_THROW(std::bad_alloc) +{ + //C++ stardard 5.3.4.8 requires that a valid pointer be returned for + //a call to new(0). Thus: + if(numBytes == 0){ + numBytes = 1; + } + void * p = malloc(numBytes); + if(p == 0){ + std::__throw_bad_alloc(); + } + return p; +} diff --git a/src/new_opnt.cpp b/src/new_opnt.cpp new file mode 100644 index 0000000..c37903e --- /dev/null +++ b/src/new_opnt.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef NO_NOTHROW +_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{ + return malloc(numBytes); +} +#endif diff --git a/src/new_opv.cpp b/src/new_opv.cpp new file mode 100644 index 0000000..e39d5e5 --- /dev/null +++ b/src/new_opv.cpp @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +_UCXXEXPORT void* operator new[](std::size_t numBytes)_UCXX_THROW(std::bad_alloc){ + //C++ stardard 5.3.4.8 requires that a valid pointer be returned for + //a call to new(0). Thus: + if(numBytes == 0){ + numBytes = 1; + } + void * p = malloc(numBytes); + if(p == 0){ + std::__throw_bad_alloc(); + } + return p; +} diff --git a/src/new_opvnt.cpp b/src/new_opvnt.cpp new file mode 100644 index 0000000..4874a7f --- /dev/null +++ b/src/new_opvnt.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include +#include + +#ifndef NO_NOTHROW +_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{ + return malloc(numBytes); +} +#endif diff --git a/src/numeric.cpp b/src/numeric.cpp new file mode 100644 index 0000000..eb93f2e --- /dev/null +++ b/src/numeric.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + +} + + diff --git a/src/ostream.cpp b/src/ostream.cpp new file mode 100644 index 0000000..0973871 --- /dev/null +++ b/src/ostream.cpp @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_OSTREAM__ 1 + +#include + +namespace std{ + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + template _UCXXEXPORT ostream::~basic_ostream(); +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT ostream & ostream::flush(); + + template _UCXXEXPORT ostream & ostream::operator<<(bool n); + template _UCXXEXPORT ostream & ostream::operator<<(short int n); + template _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n); + template _UCXXEXPORT ostream & ostream::operator<<(int n); + template _UCXXEXPORT ostream & ostream::operator<<(unsigned int n); + template _UCXXEXPORT ostream & ostream::operator<<(long n); + template _UCXXEXPORT ostream & ostream::operator<<(unsigned long n); + template _UCXXEXPORT ostream & ostream::operator<<(float f); + template _UCXXEXPORT ostream & ostream::operator<<(double f); + template _UCXXEXPORT ostream & ostream::operator<<(long double f); + template _UCXXEXPORT ostream & ostream::operator<<(void* p); + template _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf >* sb); + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT ostream::sentry::sentry(ostream & os); + template _UCXXEXPORT ostream::sentry::~sentry(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT ostream & endl(ostream & os); + template _UCXXEXPORT ostream & flush(ostream & os); + template _UCXXEXPORT ostream & operator<<(ostream & out, char c); + template _UCXXEXPORT ostream & operator<<(ostream & out, const char* c); + template _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c); + template _UCXXEXPORT ostream & operator<<(ostream & out, const unsigned char* c); + +#endif + + +} diff --git a/src/queue.cpp b/src/queue.cpp new file mode 100644 index 0000000..356efeb --- /dev/null +++ b/src/queue.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +namespace std{ + + + + +} diff --git a/src/set.cpp b/src/set.cpp new file mode 100644 index 0000000..61ec56a --- /dev/null +++ b/src/set.cpp @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + + + + + + + + +} diff --git a/src/sstream.cpp b/src/sstream.cpp new file mode 100644 index 0000000..e712b67 --- /dev/null +++ b/src/sstream.cpp @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_SSTREAM__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ + + typedef char_traits tr_ch; + typedef basic_stringbuf > char_stringbuf; + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT char_stringbuf::basic_stringbuf(ios_base::openmode which); + template _UCXXEXPORT char_stringbuf::~basic_stringbuf(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT basic_string, allocator > char_stringbuf::str() const; + template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::pbackfail(char_stringbuf::int_type c); + template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::overflow(char_stringbuf::int_type c); + template _UCXXEXPORT char_stringbuf::pos_type + char_stringbuf::seekoff(char_stringbuf::off_type, ios_base::seekdir, ios_base::openmode); + template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::underflow (); + template _UCXXEXPORT streamsize char_stringbuf::xsputn(const char* s, streamsize n); + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT basic_stringstream >::basic_stringstream(ios_base::openmode which); + template _UCXXEXPORT basic_istringstream >::~basic_istringstream(); + template _UCXXEXPORT basic_ostringstream >::~basic_ostringstream(); + template _UCXXEXPORT basic_stringstream >::~basic_stringstream(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + +#endif + +} + + diff --git a/src/stack.cpp b/src/stack.cpp new file mode 100644 index 0000000..53a21bb --- /dev/null +++ b/src/stack.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +namespace std{ + + + + +} diff --git a/src/stdexcept.cpp b/src/stdexcept.cpp new file mode 100644 index 0000000..b812b6f --- /dev/null +++ b/src/stdexcept.cpp @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +#include + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +namespace std{ + + _UCXXEXPORT logic_error::logic_error() _UCXX_USE_NOEXCEPT : mstring(){ + + } + + _UCXXEXPORT logic_error::logic_error(const string& what_arg) : mstring(what_arg){ + + } + + _UCXXEXPORT const char * logic_error::what() const _UCXX_USE_NOEXCEPT{ + return mstring.c_str(); + } + + + _UCXXEXPORT out_of_range::out_of_range() : logic_error(){ + + } + + _UCXXEXPORT out_of_range::out_of_range(const string & what_arg) : logic_error(what_arg) { + + } + + _UCXXEXPORT runtime_error::runtime_error() : mstring(){ + + } + + _UCXXEXPORT runtime_error::runtime_error(const string& what_arg) : mstring(what_arg){ + + } + + _UCXXEXPORT const char * runtime_error::what() const _UCXX_USE_NOEXCEPT{ + return mstring.c_str(); + } + +} + +#endif + diff --git a/src/streambuf.cpp b/src/streambuf.cpp new file mode 100644 index 0000000..5417324 --- /dev/null +++ b/src/streambuf.cpp @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_STREAMBUF__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT streambuf::basic_streambuf(); + template _UCXXEXPORT streambuf::~basic_streambuf(); + +#endif + + template _UCXXEXPORT locale streambuf::pubimbue(const locale &loc); + template _UCXXEXPORT streamsize streambuf::in_avail(); + template _UCXXEXPORT streambuf::int_type streambuf::sbumpc(); + template _UCXXEXPORT streambuf::int_type streambuf::snextc(); + template _UCXXEXPORT streambuf::int_type streambuf::sgetc(); + template _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c); + template _UCXXEXPORT streambuf::int_type streambuf::sungetc(); + template _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c); + +#endif + + +} + + diff --git a/src/string.cpp b/src/string.cpp new file mode 100644 index 0000000..1edf69b --- /dev/null +++ b/src/string.cpp @@ -0,0 +1,112 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_STRING__ 1 + +#include +#include +#include +#include +#include +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT string::basic_string(const allocator &); + template _UCXXEXPORT string::basic_string(size_type n, char c, const allocator & ); + template _UCXXEXPORT string::basic_string(const char* s, const allocator& al); + template _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator& al); + template _UCXXEXPORT string::~basic_string(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT string & string::append(const char * s, size_type n); + + template _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const; + template _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const; + template _UCXXEXPORT string::size_type string::find (char c, size_type pos) const; + template _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const; + template _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const; + template _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const; + + template _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const; + template _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const; + template _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const; + + template _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const; + template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const; + template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const; + template _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const; + + template _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const; + + template _UCXXEXPORT int string::compare(const string & str) const; +// template _UCXXEXPORT int string::compare(size_type pos1, size_type n1, const string & str) const; + template _UCXXEXPORT int string::compare( + size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const; + + template _UCXXEXPORT string string::substr(size_type pos, size_type n) const; + + template _UCXXEXPORT string & string::operator=(const string & str); + template _UCXXEXPORT string & string::operator=(const char * s); + + template _UCXXEXPORT bool operator==(const string & lhs, const string & rhs); + template _UCXXEXPORT bool operator==(const char * lhs, const string & rhs); + template _UCXXEXPORT bool operator==(const string & lhs, const char * rhs); + + template _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs); + template _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs); + template _UCXXEXPORT bool operator!=(const string & lhs, const char * rhs); + + template _UCXXEXPORT string operator+(const string & lhs, const char* rhs); + template _UCXXEXPORT string operator+(const char* lhs, const string & rhs); + template _UCXXEXPORT string operator+(const string & lhs, const string & rhs); + + template _UCXXEXPORT bool operator> (const string & lhs, const string & rhs); + template _UCXXEXPORT bool operator< (const string & lhs, const string & rhs); + + +//Functions dependent upon OSTREAM +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ + +template _UCXXEXPORT ostream & operator<<(ostream & os, const string & str); + +#endif + + +//Functions dependent upon ISTREAM +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + +template _UCXXEXPORT istream & operator>>(istream & is, string & str); + + +#endif + + +#endif + +} diff --git a/src/support.cpp b/src/support.cpp new file mode 100644 index 0000000..ebdcded --- /dev/null +++ b/src/support.cpp @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +/*extern "C" void *__cxa_allocate_exception(size_t thrown_size){ + void * retval; + + /*The amount of data needed is the size of the object *PLUS* + the size of the header. The header is of struct __cxa_exception + The address needs to be adjusted because the pointer we return + should not point to the start of the memory, but to the point + where the object being thrown actually starts*/ + + retval = malloc(thrown_size + sizeof(__cxa_exception)); + +// Check to see that we actuall allocated memory + if(retval == 0){ + std::terminate(); + } + + //Need to do a typecast to char* otherwize we are doing math with + //a void* which makes the compiler cranky (Like me) + return ((char *)retval + sizeof(__cxa_exception)); +} + +extern "C" void __cxa_free_exception(void *thrown_exception){ + + + +} + +extern "C" void __cxa_throw (void *thrown_exception, std::type_info *tinfo,void (*dest) (void *) ){ + + +} +*/ diff --git a/src/typeinfo.cpp b/src/typeinfo.cpp new file mode 100644 index 0000000..c9f9d23 --- /dev/null +++ b/src/typeinfo.cpp @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + _UCXXEXPORT bad_cast::~bad_cast() _UCXX_USE_NOEXCEPT{ + + } + + _UCXXEXPORT bad_typeid::~bad_typeid() _UCXX_USE_NOEXCEPT{ + + } + +} + + diff --git a/src/utility.cpp b/src/utility.cpp new file mode 100644 index 0000000..b2f8995 --- /dev/null +++ b/src/utility.cpp @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + 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 + + +namespace std{ + + + +} + + diff --git a/src/valarray.cpp b/src/valarray.cpp new file mode 100644 index 0000000..e4bd504 --- /dev/null +++ b/src/valarray.cpp @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 + +namespace std{ + + + + +} + + diff --git a/src/vector.cpp b/src/vector.cpp new file mode 100644 index 0000000..5ee0de1 --- /dev/null +++ b/src/vector.cpp @@ -0,0 +1,83 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + 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 +*/ + +#define __UCLIBCXX_COMPILE_VECTOR__ 1 + + +#include + +namespace std{ + + +#ifdef __UCLIBCXX_EXPAND_VECTOR_BASIC__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT vector >::vector(const allocator& al); + template _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); + + template _UCXXEXPORT vector >::~vector(); + template _UCXXEXPORT vector >::~vector(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + + template _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const unsigned char & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const short & c); + template _UCXXEXPORT void vector > + ::resize(size_type sz, const unsigned short int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const unsigned int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const long int & c); + template _UCXXEXPORT void vector >:: + resize(size_type sz, const unsigned long int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const float & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const double & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const bool & c); + +#elif defined __UCLIBCXX_EXPAND_STRING_CHAR__ + + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + template _UCXXEXPORT vector >::vector(const allocator& al); + template _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); + template _UCXXEXPORT vector >::~vector(); +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + +#endif + + + + +} diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..adb0471 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,42 @@ +# +# Never ignore these +# +!.gitignore +# +# Generated files +# +*.test +# +# Executable test +# +*_glibc +*_uc +*-old +*.out +algotest +bitsettest +chartraitstest +combotest +dequetest +excepttest +fstreamtest +functionaltest +ioexceptiontest +iotest +listtest +maptest +memorytest +mmaptest +newdeltest +numerictest +settest +sstreamtest +stacktest +streambuftest +streamitertest +stringtest +testframework +utilitytest +valarraytest +vectortest +wchartest diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..afd83ef --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,7 @@ +top_srcdir=../ +top_builddir=../ +all: +include $(top_srcdir)Rules.mak +include Makefile.in +include $(top_srcdir)bin/Makefile.in +include $(top_srcdir)Makefile.end diff --git a/tests/Makefile.in b/tests/Makefile.in new file mode 100644 index 0000000..43e8601 --- /dev/null +++ b/tests/Makefile.in @@ -0,0 +1,47 @@ +TESTS_DIR := $(top_srcdir)tests/ +TESTS_OUT := $(top_builddir)tests/ + +WR_CXX := WRAPPER_INCLUDEDIR=-I$(top_srcdir)include WRAPPER_LIBDIR=-L$(top_builddir)src $(WRAPPER) + +LIBS-y := $(call link.asneeded,-lgcc_eh) + +TESTS_SRCS := $(wildcard *test.cpp) +TESTS_SRCS-y := $(TESTS_SRCS) +UTILITY_SRCS := testframework.cpp + +TESTS_OMIT-$(UCLIBCXX_HAS_WCHAR) := wchartest.cpp +TESTS_OMIT-$(UCLIBCXX_EXCEPTION_SUPPORT) := excepttest.cpp + +TESTS_SRCS-y := $(filter-out $(TESTS_OMIT-),$(TESTS_SRCS-y)) + +EXOBJS := $(patsubst %.cpp,%.o, $(TESTS_SRCS-y)) +UTILITY_OBJS := $(patsubst %.cpp,%.o, $(UTILITY_SRCS)) +ALLBIN := $(patsubst %.cpp,%, $(TESTS_SRCS-y)) +HOST_OBJS := $(patsubst %.cpp,%-old.o, $(TESTS_SRCS-y)) +HOST_UTILITY_OBJS := $(patsubst %.cpp,%-old.o, $(UTILITY_SRCS)) +HOST_BIN := $(patsubst %.cpp,%-old, $(TESTS_SRCS-y)) + +all: $(ALLBIN) $(if $(DODEBUG),$(HOST_BIN)) +include $(TESTS_DIR)testoutput/Makefile.in + +LIBS-valarraytest := -lm +CXXFLAGS-vectortest.o += $(CXXFLAG_-Wno-tautological-compare) + +$(EXOBJS) $(UTILITY_OBJS): $(WRAPPER) +%.o: %.cpp ; $(compile.oxx) +%: %.o ; $(compile.uxx) + +%-old.o: %.cpp ; $(hcompile.oxx) +%-old: %-old.o ; $(hcompile.uxx) + +$(ALLBIN): % : %.o $(UTILITY_OBJS) +$(HOST_BIN): % : %.o $(HOST_UTILITY_OBJS) + +CLEAN_tests: + $(do_rm) $(addprefix $(TESTS_OUT),$(patsubst %.cpp,%, $(TESTS_SRCS)) $(patsubst %.cpp,%-old, $(TESTS_SRCS)) *.o core) + +distclean: clean + $(Q)$(RM) $(addprefix $(TESTS_OUT), .*.dep) + +clean: CLEAN_tests/testoutput CLEAN_tests + diff --git a/tests/algotest.cpp b/tests/algotest.cpp new file mode 100644 index 0000000..2e629ad --- /dev/null +++ b/tests/algotest.cpp @@ -0,0 +1,631 @@ +#include +#include +#include +#include +#include +#include "testframework.h" + + +template class less_than : public std::unary_function { + T arg; +public: + explicit less_than(const T & x) : arg(x) { } + bool operator()(const T& x) const { return x < arg; } +}; + + +std::vector giveVec(int a, int b, int c, int d){ + std::vector retval; + retval.push_back(a); + retval.push_back(b); + retval.push_back(c); + retval.push_back(d); + return retval; +} + + + +bool canSortList(){ + int s[6] = {12, 26, 33, 64, 85, 93}; + + std::vector a; + a.push_back(12); + a.push_back(33); + a.push_back(85); + a.push_back(26); + a.push_back(64); + a.push_back(93); + + std::sort::iterator>(a.begin(), a.end()); + + for(int i = 0; i < 6; ++i){ + if(a[i] != s[i]){ + return false; + } + } + + if(a.size() != 6){ + return false; + } + + return true; +} + +bool canSearchList(){ + std::vector a; + a.push_back(12); + a.push_back(33); + a.push_back(85); + a.push_back(26); + a.push_back(64); + a.push_back(93); + + std::sort::iterator>(a.begin(), a.end()); + + + if(1 != std::binary_search(a.begin(), a.end(), 33)){ + return false; + } + if(0 != std::binary_search(a.begin(), a.end(), 99)){ + return false; + } + if(0 != std::binary_search(a.begin(), a.end(), 1)){ + return false; + } + if(0 != std::binary_search(a.begin(), a.end(), 28)){ + return false; + } + if(0 != std::binary_search(a.begin(), a.end(), -26)){ + return false; + } + if(1 != std::binary_search(a.begin(), a.end(), 12)){ + return false; + } + return true; +} + +bool canLowerBound(){ + std::vector a, b; + a.push_back(12); + a.push_back(26); + a.push_back(33); + a.push_back(64); + a.push_back(85); + a.push_back(93); + + b.clear(); + b.push_back(2); + b.push_back(3); + b.push_back(3); + b.push_back(3); + b.push_back(4); + b.push_back(7); + b.push_back(8); + b.push_back(9); + + if(33 != *(std::lower_bound(a.begin(), a.end(), 33))){ + return false; + } + if(3 != *(std::lower_bound(b.begin(), b.end(), 3))){ + return false; + } + if(2 != *(std::lower_bound(b.begin(), b.end(), 1))){ + return false; + } + + return true; +} + +bool canUpperBound(){ + std::vector a, b; + a.push_back(12); + a.push_back(26); + a.push_back(33); + a.push_back(64); + a.push_back(85); + a.push_back(93); + + if(33 != *(std::upper_bound(a.begin(), a.end(), 27))){ + return false; + } + + b.push_back(2); + b.push_back(3); + b.push_back(3); + b.push_back(3); + b.push_back(4); + b.push_back(7); + b.push_back(8); + b.push_back(9); + + int v[4] = {4, 7, 8, 9}; + + std::vector::iterator i; + i = std::upper_bound(b.begin(), b.end(), 3); + for(int j = 0; j < 4; ++j){ + if(*i != v[j]){ + return false; + } + ++i; + } + + return true; +} + +bool canIterateFromLowerBound(){ + std::vector b; + std::vector::iterator i; + + int v[7] = {3, 3, 3, 4, 7, 8, 9}; + + b.push_back(2); + b.push_back(3); + b.push_back(3); + b.push_back(3); + b.push_back(4); + b.push_back(7); + b.push_back(8); + b.push_back(9); + + i = std::lower_bound(b.begin(), b.end(), 3); + for(int j = 0; j < 7; ++j){ + if(v[j] != *i){ + return false; + } + ++i; + } + + if(b.end() != i){ + return false; + } + + return true; +} + +bool testStablePartition(){ + std::vector b; + std::vector::iterator i, j; + + b.push_back(12); + b.push_back(33); + b.push_back(11); + b.push_back(93); + b.push_back(23); + b.push_back(12); + b.push_back(39); + b.push_back(53); + b.push_back(72); + b.push_back(20); + + std::multiset testValues; + std::multiset::iterator k; + + + testValues.clear(); + testValues.insert(33); + testValues.insert(23); + testValues.insert(39); + testValues.insert(53); + testValues.insert(72); + testValues.insert(20); + testValues.insert(93); + + i = std::stable_partition(b.begin(), b.end(), less_than(20) ); + j = i; + while(j != b.end()){ + k = testValues.find(*j); + if(k == testValues.end()){ + //Value in partion which shouldn't be there + return false; + } + testValues.erase(k); + ++j; + } + + //At this point, testValues should be empty + if(0 != testValues.size()){ + return false; + } + + testValues.insert(12); + testValues.insert(11); + testValues.insert(12); + + j = b.begin(); + while(j != i){ + k = testValues.find(*j); + if(k == testValues.end()){ + //Value in partion which shouldn't be there + return false; + } + testValues.erase(k); + ++j; + } + + //At this point, testValues should be empty + if(0 != testValues.size()){ + return false; + } + + return true; +} + +bool testPushHeap(){ + std::vector a; + + a.push_back(12); + std::push_heap::iterator>(a.begin(), a.end()); + if(1 != a.size() || a[0] != 12){ + return false; + } + + a.clear(); + a.push_back(12); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(7); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(27); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(22); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(93); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(36); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(55); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(5); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(68); + std::push_heap::iterator>(a.begin(), a.end()); + + std::multiset testValues; + std::multiset::iterator k; + testValues.insert(93); + testValues.insert(68); + testValues.insert(55); + testValues.insert(36); + testValues.insert(27); + testValues.insert(22); + testValues.insert(12); + testValues.insert(7); + testValues.insert(5); + + std::vector::iterator i; + + //BUG - we need to make sure that all elements are in the vector after push_heap, even though + //they aren't guaranteed to be sorted. Do multiset thing again? + + if(a[0] != 93){ + printf("Largest value isn't at the start of the heap\n"); + return false; + } + + i = a.begin(); + while(i != a.end()){ + k = testValues.find(*i); + if(k == testValues.end()){ + printf("Could not find epexted value %i\n", *i); + return false; + } + testValues.erase(k); + ++i; + } + if(a.size() != 9){ + printf("a not 9 elements long\n"); + return false; + } + if(testValues.size() != 0){ + printf("Testvalues not empty\n"); + return false; + } + + return true; +} + +bool testSortHeap(){ + std::vector a; + int v[9] = {5, 7, 12, 22, 27, 36, 55, 68, 93}; + + a.push_back(12); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(7); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(27); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(22); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(93); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(36); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(55); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(5); + std::push_heap::iterator>(a.begin(), a.end()); + a.push_back(68); + std::push_heap::iterator>(a.begin(), a.end()); + + std::sort_heap::iterator>(a.begin(), a.end() ); + + for(int j = 0; j < 9; ++j){ + if(v[j] != a[j]){ + printf("Key %i should be %i but is %i\n", j, v[j], a[j]); + return false; + } + } + + return true; +} + +bool testPartialSort(){ + std::vector a; + std::vector::iterator i; + int v[5] = {11, 12, 12, 20, 23}; + + a.push_back(12); + a.push_back(32); + a.push_back(11); + a.push_back(93); + a.push_back(12); + a.push_back(23); + a.push_back(38); + a.push_back(53); + a.push_back(72); + a.push_back(20); + + i = a.begin(); + i+=4; + + std::partial_sort::iterator>(a.begin(), i, a.end()); + + for(int j = 0; j < 4; ++j){ + if(v[j] != a[j]){ + printf("Key %i should be %i but is %i\n", j, v[j], a[j]); + return false; + } + } + + return true; +} + +/* C++-03 and earlier: 14.3.1 Template type arguments [temp.arg.type]: + A local type, a type with no linkage, an unnamed type or a type + compounded from any of these types shall not be used as a + template-argument for a template type-parameter. +*/ +#if __cplusplus < 201103L + struct _my_comp { + inline bool operator()(const int &a, const int &b) const { + return a > b; + } + }; +#endif + +bool testSort() { + /* in C++-11 this restriction was lifted */ +#if __cplusplus >= 201103L + struct _my_comp { + inline bool operator()(const int &a, const int &b) const { + return a > b; + } + }; +#endif + std::vector a; + std::vector::iterator i; + + a.push_back(5); + a.push_back(2); + a.push_back(4); + a.push_back(3); + a.push_back(1); + a.push_back(0); + + i = a.begin(); + + std::sort::iterator>(a.begin(), a.end(), _my_comp()); + + for (int j = 0; j < 6; ++j) { + if (a[j] != 5 - j) { + printf("Key %i should be %i but is %i\n", j, 5-j, a[j]); + return false; + } + } + + return true; +} + +bool testInplaceMerge(){ + std::vector a; + std::vector::iterator i; + + a.push_back(11); + a.push_back(12); + a.push_back(33); + a.push_back(72); + + a.push_back(12); + a.push_back(19); + a.push_back(23); + a.push_back(38); + a.push_back(53); + a.push_back(93); + + i = a.begin(); + i = i + 4; + + std::inplace_merge::iterator>(a.begin(), i, a.end()); + + int v[10] = {11, 12, 12, 19, 23, 33, 38, 53, 72, 93}; + + for(int j = 0; j < 5; ++j){ + if(v[j] != a[j]){ + printf("Key %i should be %i but is %i\n", j, v[j], a[j]); + return false; + } + } + + return true; +} + +bool testNextPermutation(){ + std::vector a; + + a.push_back(1); + a.push_back(2); + a.push_back(3); + a.push_back(4); + + std::multiset > testValues; + std::multiset >::iterator k; + std::vector vec; + + + //OK - populate the multiset with the possible permutations + testValues.insert(giveVec(1, 2, 3, 4)); + testValues.insert(giveVec(1, 2, 4, 3)); + testValues.insert(giveVec(1, 3, 2, 4)); + testValues.insert(giveVec(1, 3, 4, 2)); + testValues.insert(giveVec(1, 4, 2, 3)); + testValues.insert(giveVec(1, 4, 3, 2)); + testValues.insert(giveVec(2, 1, 3, 4)); + testValues.insert(giveVec(2, 1, 4, 3)); + testValues.insert(giveVec(2, 3, 1, 4)); + testValues.insert(giveVec(2, 3, 4, 1)); + testValues.insert(giveVec(2, 4, 1, 3)); + testValues.insert(giveVec(2, 4, 3, 1)); + testValues.insert(giveVec(3, 1, 2, 4)); + testValues.insert(giveVec(3, 1, 4, 2)); + testValues.insert(giveVec(3, 2, 1, 4)); + testValues.insert(giveVec(3, 2, 4, 1)); + testValues.insert(giveVec(3, 4, 1, 2)); + testValues.insert(giveVec(3, 4, 2, 1)); + testValues.insert(giveVec(4, 1, 2, 3)); + testValues.insert(giveVec(4, 1, 3, 2)); + testValues.insert(giveVec(4, 2, 1, 3)); + testValues.insert(giveVec(4, 2, 3, 1)); + testValues.insert(giveVec(4, 3, 1, 2)); + testValues.insert(giveVec(4, 3, 2, 1)); + + for(int x = 0; x < 24; ++x){ + std::next_permutation(a.begin(), a.end()); + vec.clear(); + vec.push_back(a[0]); + vec.push_back(a[1]); + vec.push_back(a[2]); + vec.push_back(a[3]); + + k = testValues.find(vec); + if(k == testValues.end()){ + //Value in partion which shouldn't be there + printf("Expected to find value %i, %i, %i, %i, but didn't\n", a[0], a[1], a[2], a[3]); + return false; + } + testValues.erase(k); + } + + if( testValues.size() != 0 ){ + printf("Left over values in testValues\n"); + return false; + } + + return true; +} + +bool testPrevPermutation(){ + std::vector a; + + a.push_back(1); + a.push_back(2); + a.push_back(3); + a.push_back(4); + + std::multiset > testValues; + std::multiset >::iterator k; + std::vector vec; + + + //OK - populate the multiset with the possible permutations + testValues.insert(giveVec(1, 2, 3, 4)); + testValues.insert(giveVec(1, 2, 4, 3)); + testValues.insert(giveVec(1, 3, 2, 4)); + testValues.insert(giveVec(1, 3, 4, 2)); + testValues.insert(giveVec(1, 4, 2, 3)); + testValues.insert(giveVec(1, 4, 3, 2)); + testValues.insert(giveVec(2, 1, 3, 4)); + testValues.insert(giveVec(2, 1, 4, 3)); + testValues.insert(giveVec(2, 3, 1, 4)); + testValues.insert(giveVec(2, 3, 4, 1)); + testValues.insert(giveVec(2, 4, 1, 3)); + testValues.insert(giveVec(2, 4, 3, 1)); + testValues.insert(giveVec(3, 1, 2, 4)); + testValues.insert(giveVec(3, 1, 4, 2)); + testValues.insert(giveVec(3, 2, 1, 4)); + testValues.insert(giveVec(3, 2, 4, 1)); + testValues.insert(giveVec(3, 4, 1, 2)); + testValues.insert(giveVec(3, 4, 2, 1)); + testValues.insert(giveVec(4, 1, 2, 3)); + testValues.insert(giveVec(4, 1, 3, 2)); + testValues.insert(giveVec(4, 2, 1, 3)); + testValues.insert(giveVec(4, 2, 3, 1)); + testValues.insert(giveVec(4, 3, 1, 2)); + testValues.insert(giveVec(4, 3, 2, 1)); + + for(int x = 0; x < 24; ++x){ + std::prev_permutation(a.begin(), a.end()); + vec.clear(); + vec.push_back(a[0]); + vec.push_back(a[1]); + vec.push_back(a[2]); + vec.push_back(a[3]); + + k = testValues.find(vec); + if(k == testValues.end()){ + //Value in partion which shouldn't be there + printf("Expected to find value %i, %i, %i, %i, but didn't\n", a[0], a[1], a[2], a[3]); + return false; + } + testValues.erase(k); + } + + if( testValues.size() != 0 ){ + printf("Left over values in testValues\n"); + return false; + } + + return true; +} + +bool checkMinDefault(){ + return std::min(3, 5) == 3; +} + +bool checkMinLess(){ + return std::min(3, 5, std::less()) == 3; +} + +int main(){ + std::cout << "Beginning algorithm test" << std::endl; + + TestFramework::init(); + + TestFramework::AssertReturns(canSortList, true); + TestFramework::AssertReturns(canSearchList, true); + TestFramework::AssertReturns(canUpperBound, true); + TestFramework::AssertReturns(canLowerBound, true); + TestFramework::AssertReturns(canIterateFromLowerBound, true); + TestFramework::AssertReturns(testStablePartition, true); + TestFramework::AssertReturns(testPushHeap, true); + TestFramework::AssertReturns(testSortHeap, true); + TestFramework::AssertReturns(testPartialSort, true); + TestFramework::AssertReturns(testSort, true); + TestFramework::AssertReturns(testInplaceMerge, true); + TestFramework::AssertReturns(testNextPermutation, true); + TestFramework::AssertReturns(testPrevPermutation, true); + TestFramework::AssertReturns(checkMinDefault, true); + TestFramework::AssertReturns(checkMinLess, true); + + TestFramework::results(); + + return 0; +} diff --git a/tests/bitsettest.cpp b/tests/bitsettest.cpp new file mode 100644 index 0000000..3537b37 --- /dev/null +++ b/tests/bitsettest.cpp @@ -0,0 +1,80 @@ +#include +#include +#include + + +int main(){ + std::bitset<10> a; + std::cout << a.to_string, std::allocator >() << std::endl; + + a.flip(); + std::cout << a.to_string, std::allocator >() << std::endl; + + a.flip(1); + a.flip(3); + a.flip(4); + a.flip(5); + a.flip(7); + a.flip(8); + a.flip(9); + std::cout << a.to_string, std::allocator >() << std::endl; + + a.flip(); + std::cout << a.to_string, std::allocator >() << std::endl; + + std::bitset<10> b(std::string("10110111011110"), 4); + std::cout << b.to_string, std::allocator >(); + std::cout << " should read : 0111011110" << std::endl; + + + std::bitset<10> c(std::string("10110111011110"), 2, 8); + std::cout << c.to_string, std::allocator >(); + std::cout << " should read : 0011011101" << std::endl; + + + a.reset(); + std::cout << a.to_string, std::allocator >() << std::endl; + + a[2] = true; + a[3] = ~a[5]; + a[8].flip(); + a[5] = a[6]; + + a.flip(6); + a.flip(); + + std::cout << a.to_string, std::allocator >(); + std::cout << " should read : 1010110011" << std::endl; + + b = a << 3; + std::cout << b.to_string, std::allocator >(); + std::cout << " should read : 0110011000" << std::endl; + + + c = a >> 2; + std::cout << c.to_string, std::allocator >(); + std::cout << " should read : 0010101100" << std::endl; + + a = b & c; + std::cout << a.to_string, std::allocator >(); + std::cout << " should read : 0010001000" << std::endl; + + + a = b | c; + std::cout << a.to_string, std::allocator >(); + std::cout << " should read : 0110111100" << std::endl; + + a = b ^ c; + std::cout << a; + std::cout << " should read : 0100110100" << std::endl; + + + std::stringstream s; + s.str("1100100100"); + + s >> a; + std::cout << a << " should read : 1100100100" << std::endl; + + + return 0; +} diff --git a/tests/chartraitstest.cpp b/tests/chartraitstest.cpp new file mode 100644 index 0000000..5b9417a --- /dev/null +++ b/tests/chartraitstest.cpp @@ -0,0 +1,177 @@ +#include + +template void testClass(std::string tname); + +int main(){ + testClass("char"); + return 0; +} + + +template void testClass(std::string tname){ + typename std::char_traits::int_type i1, i2; + typename std::char_traits::char_type c1, c2; + const T* a1 = "teststring"; + // const T* a2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~!@#$%^&*()_+{}|[]\\:;\"'<>?,./"; + + //Check to make sure that EOF values are comparable and set properly + i1 = std::char_traits::eof(); + i2 = i1; + + std::char_traits::assign(c1, 'a'); + std::char_traits::assign(c2, 'a'); + + if(std::char_traits::eq(c1, c2)){ + std::cout << "eq() properly compares identical values for " << tname << std::endl; + }else{ + std::cout << "eq() does not properly compare identical values for " << tname << std::endl; + } + + std::char_traits::assign(c1, 'a'); + std::char_traits::assign(c2, 'b'); + + if(std::char_traits::eq(c1, c2)){ + std::cout << "eq() does not properly compares disimilar values for " << tname << std::endl; + }else{ + std::cout << "eq() properly compares disimilar values for " << tname << std::endl; + } + + std::char_traits::assign(c1, 'a'); + std::char_traits::assign(c2, 'b'); + + if(std::char_traits::lt(c1, c2)){ + std::cout << "lt() properly compares values for " << tname << std::endl; + }else{ + std::cout << "lt() does not properly compares values for " << tname << std::endl; + } + + std::char_traits::assign(c1, 'b'); + std::char_traits::assign(c2, 'a'); + + if(std::char_traits::lt(c1, c2)){ + std::cout << "lt() does not properly compare reversed values for " << tname << std::endl; + }else{ + std::cout << "lt() properly compares reversed values for " << tname << std::endl; + } + + std::char_traits::assign(c1, 'a'); + std::char_traits::assign(c2, 'a'); + + if(std::char_traits::lt(c1, c2)){ + std::cout << "lt() does not properly compare equal values for " << tname << std::endl; + }else{ + std::cout << "lt() properly compares equal values for " << tname << std::endl; + } + + if(std::char_traits::compare("test","test", 4) == 0){ + std::cout << "compare() properly compares identical strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare identical strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","test", 3) == 0){ + std::cout << "compare() properly compares partial identical strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare partial identical strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","test", 6) == 0){ + std::cout << "compare() properly compares undersized identical strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare undersized identical strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","testing", 4) == 0){ + std::cout << "compare() properly compares different sized identical strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare different sized identical strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","testing", 5) < 0){ + std::cout << "compare() properly compares different strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare different strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","aaaa", 4) > 0){ + std::cout << "compare() properly compares different strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare different strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","testa", 4) == 0){ + std::cout << "compare() properly compares different sized identical strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare different sized identical strings for " << tname << std::endl; + } + + if(std::char_traits::compare("test","testa", 5) < 0){ + std::cout << "compare() properly compares different sized identical strings for " << tname << std::endl; + }else{ + std::cout << "compare() does not properly compare different sized identical strings for " << tname << std::endl; + } + + if(std::char_traits::length("test") == 4){ + std::cout << "length() properly computes length of 'test' for " << tname << std::endl; + }else{ + std::cout << "length() does not properly computer length of 'test' " << tname << std::endl; + } + + if(std::char_traits::length("") == 0){ + std::cout << "length() properly computes length of '' for " << tname << std::endl; + }else{ + std::cout << "length() does not properly computer length of '' " << tname << std::endl; + } + + if(std::char_traits::length("a0b1c2") == 6){ + std::cout << "length() properly computes length of 'a0b1c2' for " << tname << std::endl; + }else{ + std::cout << "length() does not properly computer length of 'a0b1c2' " << tname << std::endl; + } + + if(std::char_traits::find(a1, sizeof(a1), 't') == a1){ + std::cout << "find() properly locates the location of 't' starting at the beginning for " << tname << std::endl; + }else{ + std::cout << "find() does not properly locate the location of 't' starting at the beginning for " << tname << std::endl; + } + + if(std::char_traits::find(a1 + 1, sizeof(a1) - 1, 't') == (a1 + 3)){ + std::cout << "find() properly locates the location of 't' with offset 1 for " << tname << std::endl; + }else{ + std::cout << "find() does not properly locate the location of 't' starting at the beginning for " << tname << std::endl; + } + + if(std::char_traits::find(a1 + 3, sizeof(a1) - 3, 't') == (a1 + 3)){ + std::cout << "find() properly locates the location of 't' with offset 3 for " << tname << std::endl; + }else{ + std::cout << "find() does not properly locate the location of 't' starting at the beginning for " << tname << std::endl; + } + + if(std::char_traits::find(a1, 0, 't') == 0){ + std::cout << "find() properly returns NULL in 0-sized searches for " << tname << std::endl; + }else{ + std::cout << "find() does not properly return NULL in 0-sized searches for " << tname << std::endl; + } + + if(std::char_traits::find(a1, sizeof(a1), 'q') == 0){ + std::cout << "find() properly returns NULL when not found for " << tname << std::endl; + }else{ + std::cout << "find() does not properly return NULL when not found for " << tname << std::endl; + } + + + + + if(std::char_traits::eof() == i2){ + std::cout << "eof() works properly for " << tname << std::endl; + }else{ + std::cout << "eof() does not work properly for " << tname << std::endl; + } + + i1 = std::char_traits::eof(); + if(std::char_traits::not_eof(i1) != i1){ + std::cout << "not_eof() works properly for " << tname << std::endl; + }else{ + std::cout << "not_eof() does not work properly for " << tname << std::endl; + } +} diff --git a/tests/combotest.cpp b/tests/combotest.cpp new file mode 100644 index 0000000..b921dc4 --- /dev/null +++ b/tests/combotest.cpp @@ -0,0 +1,63 @@ +/* + * The purpose of theses tests is to test strange combinations of code which doesn't + * properly belong in a unit test. For example, does pushing an object into a vector + * contained in a map work properly? That doesn't really belong in either the map + * or the vector tests. So we put it here until we find some place better to put things. + */ + + +#include +#include +#include +#include + +#include "testframework.h" + +bool canInsertIntoVectorInMap() { + std::map > test; + + std::vector tempvec; + + tempvec.clear(); + tempvec.push_back((void *)1); + tempvec.push_back((void *)2); + test["2e"] = tempvec; + + tempvec.clear(); + tempvec.push_back((void *)1); + test["1e"] = tempvec; + + tempvec.clear(); + test["0e"] = tempvec; + + if( test["0e"].size() != 0 ){ + return false; + } + if( test["1e"].size() != 1 ){ + return false; + } + if( test["2e"].size() != 2 ){ + return false; + } + + test["2e"].push_back((void *)7); + if( test["2e"].size() != 3 ){ + return false; + } + + + return true; +} + + +int main() { + + std::cout << "Beginning combo tests" << std::endl; + + TestFramework::init(); + + TestFramework::AssertReturns(canInsertIntoVectorInMap, true); + + TestFramework::results(); + +} diff --git a/tests/dequetest.cpp b/tests/dequetest.cpp new file mode 100644 index 0000000..85bd79a --- /dev/null +++ b/tests/dequetest.cpp @@ -0,0 +1,267 @@ +#include +#include +#include "testframework.h" + +void test_const(const std::deque d); + +bool canSwapUnary(){ + std::deque a, b; + + a.push_back(1); + a.push_back(3); + a.push_back(5); + a.push_back(7); + a.push_back(9); + b.push_back(2); + b.push_back(4); + b.push_back(6); + b.push_back(8); + + a.swap(b); + + for(int i = 0; i < 5; ++i){ + if(b[i] != ((2 * i) + 1) ){ + return false; + } + } + + for(int i = 0; i < 4; ++i){ + if(a[i] != (2 * (i + 1)) ){ + return false; + } + } + + return true; +} + +bool canSwapBinary(){ + std::deque a, b; + + a.push_back(1); + a.push_back(3); + a.push_back(5); + a.push_back(7); + a.push_back(9); + b.push_back(2); + b.push_back(4); + b.push_back(6); + b.push_back(8); + + std::swap(a, b); + + for(int i = 0; i < 5; ++i){ + if(b[i] != ((2 * i) + 1) ){ + return false; + } + } + + for(int i = 0; i < 4; ++i){ + if(a[i] != (2 * (i + 1)) ){ + return false; + } + } + + return true; +} + +bool canCompareConstNonConstIter() { + std::deque d; + d.push_back(5); + d.push_back(6); + d.push_back(7); + std::deque::const_iterator i = d.begin(); + std::deque::iterator j = d.begin(); + std::deque::iterator k = d.end(); + + if (i == i && i == j && j == i && j == j) { + // Do nothing + } else { + return false; + } + + if (i != i || i != j || j != i || j != j) { + return false; + } + + return true; +} + +int main(){ + std::deque test; + std::deque::iterator i,j; + unsigned int k; + + std::cout << "deque test start" << std::endl; + + TestFramework::init(); + + i = test.begin(); + + std::cout << "\nTest of push_back():\n"; + std::cout << "The following two lines should be identical.\n"; + + test.push_back(12); + test.push_back(13); + test.push_back(14); + + std::cout << "12 13 14 " << std::endl; + + for(i = test.begin(); i !=test.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + std::cout << "\nTest of subscripting:\n"; + std::cout << "The following two lines should be identical\n"; + std::cout << "12 13 14 " << std::endl; + for(k = 0; k < test.size(); ++k){ + std::cout << test[k] << " "; + } + std::cout << std::endl; + + std::cout << "Pushing many elements to the front:" << std::endl; + for(k = 1; k < 24; ++k){ + std::cout << "Pushing in: " << k; + test.push_front(static_cast(k)); + std::cout << " " << test.front() << std::endl; + } + + std::cout << "Complete list of elements:\n"; + std::cout << "The following two lines should be identical\n"; + std::cout << "23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 \n"; + for(k = 0; k < test.size(); ++k){ + std::cout << test[k] << " "; + } + std::cout << std::endl; + + + std::cout << "\n Testing push_back():" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 2.5\n"; + test.push_back(2.5); + for(k = 0; k < test.size(); ++k){ + std::cout << test[k] << " "; + } + std::cout << std::endl; + + std::cout << "\nTesting pop_front:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 2.5\n"; + test.pop_front(); + for(i = test.begin(); i !=test.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + + std::cout << "\nTesting pop_back:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 \n"; + test.pop_back(); + for(i = test.begin(); i !=test.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + + std::cout << "\nCopy constructor:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 \n"; + std::deque test2(test); + i = test2.begin(); + while(i !=test2.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + std::cout << "\nAssignement:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 \n"; + test2.clear(); + test2 = test; + for(i = test2.begin(); i !=test2.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + std::cout << "\nInsert near beginning:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 25 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 \n"; + i = test.begin(); + ++i; + i++; + test.insert(i, 25); + for(i = test.begin(); i !=test.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + std::cout << "\nInsert near end:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 25 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 27 13 14 \n"; + i=test.end(); + --i; + i--; + test.insert(i, 27); + for(i = test.begin(); i !=test.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + std::cout << "\nErase near beginning:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 27 13 14 \n"; + i = test.begin(); + ++i; + i++; + test.erase(i); + for(i = test.begin(); i !=test.end(); ++i){ + std::cout << *i << " "; + } + std::cout << std::endl; + + std::cout << "\nErase near end:" << std::endl; + std::cout << "The following two lines should be identical\n"; + std::cout << "22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 \n"; + i = test.end(); + i--; + --i; + i--; + i = test.erase(i); + for(j = test.begin(); j !=test.end(); ++j){ + std::cout << *j << " "; + } + std::cout << std::endl; + std::cout << "Returned iterator points to: " << *i << " - should be 13" << std::endl; + + test.clear(); + test.push_back(12); + test.push_back(13); + test.push_back(14); + test.push_back(7); + test.push_back(25); + test.push_back(0); + test_const(test); + + TestFramework::AssertReturns(canSwapUnary, true); + TestFramework::AssertReturns(canSwapBinary, true); + TestFramework::AssertReturns(canCompareConstNonConstIter, true); + + TestFramework::results(); + + return 0; +} + +void test_const(const std::deque d){ + std::cout << "Test of const_iterator" << std::endl; + std::cout << "The following two lines should be identical:" << std::endl; + std::deque::const_iterator i = d.begin(); + while(i!=d.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + std::cout << "12 13 14 7 25 0 " << std::endl; +} diff --git a/tests/excepttest.cpp b/tests/excepttest.cpp new file mode 100644 index 0000000..77522e1 --- /dev/null +++ b/tests/excepttest.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +int main(){ + printf("Starting exception testing\n"); + + try{ + printf("Throwing out of range\n"); + throw std::out_of_range("This is text"); + printf("If you are seeing this, this is ***BAD***\n"); + + }catch(std::out_of_range &e){ + if(strcmp(e.what(), "This is text") == 0){ + printf("Caught thrown exception\n"); + }else{ + printf("Caught exception with different exception text\n"); + printf("Exception text: %s\n", e.what() ); + } + }catch(...){ + printf("Missed catching exception - this is BAD\n"); + } + + + printf("Testing inheriting exception handler\n"); + try{ + printf("Throwing length_error\n"); + throw std::length_error("Length error test text"); + printf("Exception not thrown (bad)\n"); + }catch( std::out_of_range &e){ + printf("Caught out_of_range (bad)\n"); + }catch( std::logic_error &e){ + printf("Caught logic_error (good)\n"); + }catch(...){ + printf("Caught generic exception (bad)\n"); + } + + + printf("Testing generic excepetion handler\n"); + try{ + printf("Throwing length_error\n"); + throw std::length_error("Length error test text"); + printf("Exception not thrown (bad)\n"); + }catch( std::out_of_range &e){ + printf("Caught out_of_range (bad)\n"); + }catch(...){ + printf("Caught generic exception (good)\n"); + } + + return 0; +} diff --git a/tests/fstreamtest.cpp b/tests/fstreamtest.cpp new file mode 100644 index 0000000..e5923dd --- /dev/null +++ b/tests/fstreamtest.cpp @@ -0,0 +1,150 @@ +#include +#include + +unsigned char correctValue(unsigned long int pos); +bool testIFStreamUnderflowOnUnopened(); + + +int main() +{ + std::ofstream outFile("fstreamtest.out", std::ios::out); + outFile << "output data from fstreamtest" ; + for(unsigned char a = 0; a < 255 ; ++a){ + outFile << a; + } + outFile.close(); + outFile.open("fstreamtest.out", std::ios::app | std::ios::out); + outFile.seekp(0); + outFile << "This should be at the end"; + outFile.close(); + + std::ifstream inFile; + inFile.open("fstreamtest.out", std::ios::in | std::ios::binary ); + char a; + unsigned char b; + for(int i = 0 ; i < 28; ++i){ + inFile >> a; + } + while (!inFile.eof()){ + inFile.get(a); + std::cout << "Read in character: " << (unsigned int)(unsigned char)a << " " << a << std::endl; + } + + + inFile.close(); + + outFile.clear(); + outFile.open("fstreamtest2.out", std::ios::out); + outFile.write("abcd", 4); + outFile.put('e'); + outFile.write("fghi", 4); + outFile.close(); + + inFile.clear(); + inFile.open("fstreamtest2.out", std::ios::in | std::ios::binary); + + inFile >> a; + if (a != 'a'){ + std::cout << "Error reading character a, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'b'){ + std::cout << "Error reading character b, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'c'){ + std::cout << "Error reading character c, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'd'){ + std::cout << "Error reading character d, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'e'){ + std::cout << "Error reading character e, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'f'){ + std::cout << "Error reading character f, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'g'){ + std::cout << "Error reading character g, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'h'){ + std::cout << "Error reading character h, was instead: " << a << std::endl; + } + inFile >> a; + if (a != 'i'){ + std::cout << "Error reading character i, was instead: " << a << std::endl; + } + inFile.close(); + inFile.clear(); + + + std::cout << "Now reading other input file to see what wonderful goodness we can discover" << std::endl; + + inFile.open("fstreamtest.input", std::ios::in | std::ios::binary ); + if( !inFile.is_open()){ + std::cout << "Could not open fstreamtest.input" << std::endl; + std::cout << "Are you in the correct directory?" << std::endl; + std::cout << "This test wasn't designed to run without the uClibc++ driver behind it" << std::endl; + return 1; + } + inFile.seekg(27); + inFile.read(&a, 1); + b = a; + if(correctValue(27) != b){ + std::cout << "Read in invalid value. Read in " << (int)b << ", expected " << (int)correctValue(27) << std::endl; + }else{ + std::cout << "Character 27 read in correctly\n"; + } + + std::cout << "The following two lines should be identical\n"; + std::cout << "Current position: 28\n"; + std::cout << "Current position: " << inFile.tellg() << std::endl; + + inFile.seekg(1, std::ios::cur); + inFile.read(&a, 1); + b = a; + if(correctValue(29) != b){ + std::cout << "Read in invalid value. Read in " << (int)b << ", expected " << (int)correctValue(29) << std::endl; + }else{ + std::cout << "Character 29 read in correctly\n"; + } + + std::cout << "The following two lines should be identical\n"; + std::cout << "Current position: 30\n"; + std::cout << "Current position: " << inFile.tellg() << std::endl; + + std::cout << "Checking input on an unopened fstream: " << std::endl; + + if( testIFStreamUnderflowOnUnopened() ){ + std::cout << "OK\n"; + }else{ + std::cout << "ERROR\n"; + } + + + + return 0; +} + + +unsigned char correctValue(unsigned long int pos){ + if(pos < 16){ + return 0; + } + return (pos - 16); + +} + + +bool testIFStreamUnderflowOnUnopened(){ + std::ifstream test; + if(test.get() == std::char_traits::eof() ){ + return true; + } + return false; +} diff --git a/tests/functionaltest.cpp b/tests/functionaltest.cpp new file mode 100644 index 0000000..14b2d3b --- /dev/null +++ b/tests/functionaltest.cpp @@ -0,0 +1,408 @@ +#include +#include + +class Foo{ +public: + Foo() : q(0) { } + Foo(int d) : q(d) { } + Foo(const Foo & f): q(f.q) { } + ~Foo() { } + + Foo & operator=(const Foo & f){ + q = f.q; + return *this; + } + bool operator==(const Foo & f) const{ + return (q == f.q); + } + bool operator!=(const Foo & f) const{ + return (q != f.q); + } + bool operator<(const Foo & f) const{ + return (q < f.q); + } + bool operator<=(const Foo & f) const{ + return (q <= f.q); + } + bool operator>(const Foo & f) const{ + return (q > f.q); + } + bool operator>=(const Foo & f) const{ + return (q >= f.q); + } + Foo operator+(const Foo & rhs) const{ + return Foo(q + rhs.q); + } + Foo operator-(const Foo & rhs) const{ + return Foo(q - rhs.q); + } + Foo operator*(const Foo & rhs) const{ + return Foo(q * rhs.q); + } + Foo operator/(const Foo & rhs) const{ + return Foo(q / rhs.q); + } + Foo operator%(const Foo & rhs) const{ + return Foo(q % rhs.q); + } + Foo operator-() const{ + return Foo(-q); + } + bool operator&&(const Foo & rhs) const{ + return q && rhs.q; + } + bool operator||(const Foo & rhs) const{ + return q || rhs.q; + } + bool operator!() const{ + return !q; + } + void printout(const int i) const{ + printf("%i", i); + } + +private: + long int q; +}; + +int main(){ + Foo result; + Foo a(0); + Foo b(1); + Foo c(5); + Foo d; + Foo e(6); + const Foo f(12); + + std::plus foo_plus; + d = foo_plus(a, c); + + if(d == c){ + printf("d == c (correct)\n"); + }else{ + printf("d !== c (WRONG)\n"); + } + + d = foo_plus(b, c); + if(d == Foo(6)){ + printf("d == 6 (correct)\n"); + }else{ + printf("d !== 6 (WRONG)\n"); + } + + std::minus foo_minus; + d = foo_minus(c, a); + if(d == c){ + printf("d == c (correct)\n"); + }else{ + printf("d !== c (WRONG)\n"); + } + + d = foo_minus(c, b); + if(d == Foo(4)){ + printf("d == 4 (correct)\n"); + }else{ + printf("d !== 4 (WRONG)\n"); + } + + std::multiplies foo_multiplies; + d = foo_multiplies(c, b); + if(d == c){ + printf("d == c (correct)\n"); + }else{ + printf("d !== c (WRONG)\n"); + } + + d = foo_multiplies(c, c); + if(d == Foo(25)){ + printf("d == 25 (correct)\n"); + }else{ + printf("d !== 25 (WRONG)\n"); + } + + std::divides foo_divides; + d = foo_divides(c, b); + if (d == c){ + printf("d == c (correct)\n"); + }else{ + printf("d !== c (WRONG)\n"); + } + + d = foo_divides(c, c); + if (d == b){ + printf("d == b (correct)\n"); + }else{ + printf("d !==b (WRONG)\n"); + } + + std::modulus foo_modulus; + d = foo_modulus(c, c); + if(d == a){ + printf("d == a (correct)\n"); + }else{ + printf("d !==a (WRONG)\n"); + } + + d = foo_modulus(e, c); + if(d == b){ + printf("d == b (correct)\n"); + }else{ + printf("d !== b (WRONG)\n"); + } + + std::negate foo_negate; + d = foo_negate(c); + if( d == Foo(-5)){ + printf("d == -5 (correct)\n"); + }else{ + printf("d !== -5 (WRONG)\n"); + } + + d = foo_negate(b); + if(d == Foo(-1)){ + printf("d == -1 (correct)\n"); + }else{ + printf("d !== -1 (WRONG)\n"); + } + + std::equal_to foo_equal_to; + if(foo_equal_to(c, Foo(5))){ + printf("c == 5 (correct)\n"); + }else{ + printf("c !== 5 (WRONG)\n"); + } + + if(foo_equal_to(a, a)){ + printf("a == a (correct)\n"); + }else{ + printf("a !== a (WRONG)\n"); + } + + if(foo_equal_to(a, b)){ + printf("a == b (WRONG)\n"); + }else{ + printf("a !==b (correct)\n"); + } + + std::not_equal_to foo_not_equal_to; + + if(foo_not_equal_to(a, b)){ + printf("a != b (correct)\n"); + }else{ + printf("a !!=b (WRONG)\n"); + } + + if(foo_not_equal_to(c, c)){ + printf("a != b (WRONG)\n"); + }else{ + printf("a !!=b (correct)\n"); + } + + std::greater foo_greater; + if(foo_greater(c, b)){ + printf("c > b (correct)\n"); + }else{ + printf("c !> b (WRONG)\n"); + } + + if(foo_greater(a, a)){ + printf("a > a (WRONG)\n"); + }else{ + printf("a !>a (correct)\n"); + } + + std::less foo_less; + if(foo_less(b, c)){ + printf("b < c (correct)\n"); + }else{ + printf("b !< c (WRONG)\n"); + } + + if(foo_less(c, c)){ + printf("c < c (WRONG)\n"); + }else{ + printf("c !< c (correct)\n"); + } + + std::greater_equal foo_greater_equal; + if(foo_greater_equal(c, b)){ + printf("c >= b (correct)\n"); + }else{ + printf("c !>= b (WRONG)\n"); + } + + if(foo_greater_equal(b, b)){ + printf("b >= b (correct)\n"); + }else{ + printf("b !>= b (WRONG)\n"); + } + + if(foo_greater_equal(b, c)){ + printf("b >= c (WRONG)\n"); + }else{ + printf("b !>= c (correct)\n"); + } + + std::less_equal foo_less_equal; + if(foo_less_equal(b, c)){ + printf("b <= c (correct)\n"); + }else{ + printf("b !<= c (WRONG)\n"); + } + + if(foo_less_equal(c, b)){ + printf("c >= b (WRONG)\n"); + }else{ + printf("c !>= b (correct)\n"); + } + + if(foo_less_equal(b, b)){ + printf("b >= b (correct)\n"); + }else{ + printf("b !>= b (WRONG)\n"); + } + + std::logical_and foo_logical_and; + if(foo_logical_and(c, c)){ + printf("c && c (correct)\n"); + }else{ + printf("c !&& c (WRONG)\n"); + } + + + if(foo_logical_and(c, b)){ + printf("c && b (correct)\n"); + }else{ + printf("c !&& b (WRONG)\n"); + } + + if(foo_logical_and(a, b)){ + printf("a && b (WRONG)\n"); + }else{ + printf("a !&& b (correct)\n"); + } + + if(foo_logical_and(a, a)){ + printf("a && a (WRONG)\n"); + }else{ + printf("a !&& a (correct)\n"); + } + + std::logical_or foo_logical_or; + if(foo_logical_or(c, c)){ + printf("c || c (correct)\n"); + }else{ + printf("c !|| c (WRONG)\n"); + } + + + if(foo_logical_or(c, b)){ + printf("c || b (correct)\n"); + }else{ + printf("c !|| b (WRONG)\n"); + } + + if(foo_logical_or(a, b)){ + printf("a || b (correct)\n"); + }else{ + printf("a !|| b (WRONG)\n"); + } + + if(foo_logical_or(a, a)){ + printf("a || a (WRONG)\n"); + }else{ + printf("a !|| a (correct)\n"); + } + + std::logical_not foo_logical_not; + if(foo_logical_not(a)){ + printf("!a (correct)\n"); + }else{ + printf("!!a (WRONG)\n"); + } + + if(foo_logical_not(b)){ + printf("!a (WRONG)\n"); + }else{ + printf("!!a (correct)\n"); + } + + //Checking out std::not1 + if(std::not1(foo_logical_not)(b)){ + printf("!!b (correct)\n"); + }else{ + printf("!!!b (WRONG)\n"); + } + if(std::not1(foo_logical_not)(c)){ + printf("!!b (correct)\n"); + }else{ + printf("!!!b (WRONG)\n"); + } + if(std::not1(foo_logical_not)(a)){ + printf("!!b (WRONG)\n"); + }else{ + printf("!!!b (correct)\n"); + } + + //Checking out std::not2 + if(std::not2(std::equal_to())(c, c)){ + printf("c !== c (WRONG)\n"); + }else{ + printf("c !!== c (correct)\n"); + } + + if(std::not2(std::equal_to())(a, b)){ + printf("a !== b (correct)\n"); + }else{ + printf("a !!== b (WRONG)\n"); + } + + if(std::binder1st >(std::less(), b)(c)){ + printf("b < c (correct)\n"); + }else{ + printf("b !< c (WRONG)\n"); + } + + if(std::binder1st >(std::less(), c)(c)){ + printf("c < c (WRONG)\n"); + }else{ + printf("c !< c (correct)\n"); + } + + if(std::binder1st >(std::less(), c)(a)){ + printf("c < a (WRONG)\n"); + }else{ + printf("c !< a (correct)\n"); + } + + if(std::binder2nd >(std::less(), c)(a)){ + printf("a < c (correct)\n"); + }else{ + printf("a !< c (WRONG)\n"); + } + + if(std::binder2nd >(std::less(), b)(c)){ + printf("c < b (WRONG)\n"); + }else{ + printf("c !< b (correct)\n"); + } + + if(std::binder2nd >(std::less(), c)(c)){ + printf("c < c (WRONG)\n"); + }else{ + printf("c !< c (correct)\n"); + } + + + + printf("The following should print 7:"); + std::mem_fun(&Foo::printout)(&c, 7); + printf("\n"); + + printf("The following should print 12:"); + std::mem_fun(&Foo::printout)(&f, 12); + printf("\n"); + + return 0; +} + diff --git a/tests/ioexceptiontest.cpp b/tests/ioexceptiontest.cpp new file mode 100644 index 0000000..3beaedb --- /dev/null +++ b/tests/ioexceptiontest.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include "testframework.h" + +bool found_no_exception(){ + std::stringstream s("http://myurl.com"); + char buffer[10]; + + s.get(buffer, 8); + + if(0 == strncmp("http://", buffer, 8)){ + return true; + } + + return false; +} + +void no_found_throws(){ + std::stringstream s("http"); + char buffer[10]; + + s.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit); + + s.get(buffer, 8); + + return; +} + +int main(){ + std::cout << "Beginning ioexception test" << std::endl; + + TestFramework::init(); + + TestFramework::AssertReturns(found_no_exception, true); + TestFramework::AssertThrows(no_found_throws); + + TestFramework::results(); + + return 0; +} diff --git a/tests/iotest.cpp b/tests/iotest.cpp new file mode 100644 index 0000000..0114c5c --- /dev/null +++ b/tests/iotest.cpp @@ -0,0 +1,150 @@ +#include +#include +#include +#include +#include + +#include "testframework.h" + +//using namespace std; + +std::basic_istream > & + myIstreamTestFunction(std::basic_istream >& stream) +{ + std::cout << "Number of characters most recently read in: " << stream.gcount() << std::endl; + return stream; +} + +std::basic_ios > & + myIosTestFunction(std::basic_ios >& stream) +{ + std::cout << "Good status: " << stream.good() << std::endl; + return stream; +} + +bool canSeeIosBaseProperties() { + std::ios_base::openmode a; + a = std::ios_base::app; + a = std::ios_base::in; + a = std::ios_base::out; + + return true; +} + +void testFieldWidth() { + std::streamsize ioswidth_backup = std::cout.width(); + std::ios_base::fmtflags iosflags_backup = std::cout.flags(); + + std::cout.width(10); + + std::cout.setf(std::ios_base::right); + std::cout << 5; + std::cout << 5.1; + std::cout << "5.2"; + std::cout << std::endl; + + std::cout.setf(std::ios_base::left); + std::cout << 6; + std::cout << 6.1; + std::cout << "6.2"; + std::cout << std::endl; + + std::cout.setf(std::ios_base::internal); + std::cout << 7; + std::cout << 7.1; + std::cout << "7.2"; + std::cout << std::endl; + + std::cout.unsetf(std::ios_base::internal | std::ios_base::left | std::ios_base::right); + std::cout << 8; + std::cout << 8.1; + std::cout << "8.2"; + std::cout << std::endl; + + // Restore flags from backup + std::cout.flags(iosflags_backup); + std::cout.width(ioswidth_backup); +} + +int main(){ +// double q; +// std::cin >> q; + + std::basic_string temp("Test string"); + + std::cout << "Hello, World!\n"; + + std::cout << "Test string: " << temp << std::endl; + std::cout.setf(std::ios_base::boolalpha); + std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield); + std::cout << "This is the number 200:" << 200.1 << std::endl; + std::cout << "This is the number 200:" << (short)200 << std::endl; + std::cout << "True: " << true << std::endl; + std::cout << "True: " << (bool)1 << std::endl; + std::cout << "not True: " << std::noboolalpha << "true" << "(the string), " << true << std::boolalpha << std::endl; + std::cout << "boolalpha set: " << (bool)(std::cout.flags() & std::ios_base::boolalpha) << std::endl; + std::cout << "not True: " << 1U << std::endl; + std::cout << "not True: " << -1L << std::endl; + std::cout << "not True: " << (1?1:0) << std::endl; + //std::cout << "not True: " << __builtin_constant_p(-1) << std::endl; + std::cout << "False: " << false << std::endl; + std::cout << "False: " << (bool)0 << std::endl; + std::cout << "not False: " << 0 << std::endl; + //std::cout << "not False: " << '\0' << std::endl; + //std::cout << "not False: " << L'\0' << std::endl; + std::cout << "not False: " << -0 << std::endl; + std::cout << "not False: " << -0U << std::endl; + std::cout << "not False: " << -0L << std::endl; + + float i = 0; + long double j = 0; + + void * p = (void *)12345678; + + std::cout << "Pointer: " << p << std::endl; + std::cout << "Please enter two floats:" << std::flush; + std::cin >> i >> j; + + std::cout << "You entered: " << i << " " << j << std::endl; + + + std::cout << "Checking ostream_iterator\n"; + std::ostream_iterator a(std::cout, " "); + + std::cout << std::endl << "Checking length of remaining input" << std::flush << std::endl; + std::istream::pos_type cur; + std::istream::pos_type end; + + std::istream & s_r = std::cin; + + cur = s_r.tellg(); + std::streampos o_pos(cur); + + std::cout << "Current position in stream: " << cur << std::endl; + s_r.seekg(0, std::ios::end); + end = s_r.tellg(); + std::streampos n_pos(end); + s_r.seekg(cur); + std::cout << "Remaining bytes: " << end-cur << std::endl; + + std::cout << "fpos o_pos == n_pos ? " << + (o_pos == n_pos ? "true" : "false") << std::endl; + std::cout << "fpos !(o_pos == n_pos) ? " << + (!(o_pos == n_pos) ? "true" : "false") << std::endl; + std::cout << "fpos o_pos != n_pos ? " << + (o_pos != n_pos ? "true" : "false") << std::endl; + + std::cout << "Test of reading istream into a function: " << std::endl; + s_r >> myIstreamTestFunction; + std::cout << "Test of reading ios into a function: " << std::endl; + s_r >> myIosTestFunction; + + testFieldWidth(); + + TestFramework::AssertReturns(canSeeIosBaseProperties, true); + + TestFramework::results(); + + + return 0; +} diff --git a/tests/listtest.cpp b/tests/listtest.cpp new file mode 100644 index 0000000..639654c --- /dev/null +++ b/tests/listtest.cpp @@ -0,0 +1,527 @@ +#include +#include +#include +#include + +class testClass{ +public: + virtual void write(){ + std::cout << "testClass::write()" << std::endl; + } +}; + +class testSubClass : public testClass{ +public: + virtual void write(){ + std::cout << "testSubClass::write()" << std::endl; + } +}; + + +int main(){ + std::string test; + std::listtemp(5, 12.0); + std::list a; + std::list::iterator i, j; + std::list testPointer; + std::list::iterator testPointerIterator; + + + int array1 [] = { 1, 2}; + int array2 [] = { 3, 4}; + + std::list list_int_1( array1, array1 + 2); + std::list list_int_2( array2, array2 + 2); + std::list::iterator list_iter_1; + std::list::iterator list_iter_2; + + + test = "Beginning of list test"; + + std::cout << test << std::endl; + for(i = temp.begin(); i!=temp.end(); i++){ + std::cout << "i: " << *i << std::endl; + } + + + + std::cout << "\nList insert test\n"; + i = temp.begin(); + i++; + ++i; + i=temp.insert(i, 52.8); + temp.insert(i,52.4); + for(j = temp.begin(); j!=temp.end(); j++){ + std::cout << "j: " << *j << std::endl; + } + + std::cout << "\nList multi-insert test\n"; + i = temp.end(); + --i; + i--; + temp.insert(i, 3, 33.3); + for(j = temp.begin(); j!=temp.end(); j++){ + std::cout << "j: " << *j << std::endl; + } + + std::cout << "First element in list:" << temp.front() << std::endl; + + + std::cout << "Erasing 2nd element in list" << std::endl; + i = temp.begin(); + ++i; + i = temp.erase(i); + std::cout << "Second element in list: " << *i << std::endl; + for(j = temp.begin(); j!=temp.end(); j++){ + std::cout << "j: " << *j << std::endl; + } + + std::cout << "Erasing last 3 elements\n"; + i = temp.end(); + i--; + i--; + i--; + i = temp.erase(i,temp.end()); + --i; + std::cout << "Last element in list: " << *i << std::endl; + for(j = temp.begin(); j!=temp.end(); j++){ + std::cout << "j: " << *j << std::endl; + } + + std::cout << "Erasing first element\n"; + + i = temp.begin(); + i = temp.erase(i); + for(j = temp.begin(); j!=temp.end(); j++){ + std::cout << "j: " << *j << std::endl; + } + if(i == temp.begin()){ + std::cout << "Proper iterator returned\n"; + }else{ + std::cout << "Incorrect iterator returned\n"; + } + + std::cout << "\nTesting reverse\n"; + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + temp.reverse(); + + std::cout << "The following two lines should be identical:\n"; + std::cout << "21.2 48.5 37.9 22.4 12.8\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 22.4 37.9 48.5 21.2\n"; + i = temp.end(); + while(i != temp.begin()){ + --i; + std::cout << *i << " "; + } + std::cout << std::endl; + + std::cout << "\nTesting front() and back()\n"; + std::cout << "Front (should be 21.2): " << temp.front() << std::endl; + std::cout << "Back (should be 12.8): " << temp.back() << std::endl; + + + std::cout << "\nTesting splice" << std::endl; + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + temp.splice(++temp.begin(), a); + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 85.4 24.6 69.7 22.4 37.9 48.5 21.2\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + temp.splice(temp.begin(), a); + std::cout << "The following two lines should be identical:\n"; + std::cout << "85.4 24.6 69.7 12.8 22.4 37.9 48.5 21.2\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + temp.splice(temp.end(), a); + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 22.4 37.9 48.5 21.2 85.4 24.6 69.7\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + i = temp.begin(); + ++i; + ++i; + + temp.splice(i, a, ++a.begin()); + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 22.4 24.6 37.9 48.5 21.2\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + temp.splice(temp.begin(), a, ++a.begin()); + std::cout << "The following two lines should be identical:\n"; + std::cout << "24.6 12.8 22.4 37.9 48.5 21.2\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + temp.splice(temp.end(), a, ++a.begin()); + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 22.4 37.9 48.5 21.2 24.6\n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + + a.clear(); + a.push_back(85.4); + a.push_back(24.6); + a.push_back(69.7); + + i = temp.begin(); + ++i; + j = i; + ++j; + ++j; + + a.splice(++a.begin(), temp, i, j); + std::cout << "The following two lines should be identical:\n"; + std::cout << "85.4 22.4 37.9 24.6 69.7\n"; + i = a.begin(); + while(i != a.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + std::cout << "The following two lines should be identical\n"; + std::cout << "1 2 3 4 \n"; + + list_iter_1 = list_int_1.begin(); + while(list_iter_1 != list_int_1.end()){ + std::cout << *list_iter_1 << " "; + ++list_iter_1; + } + list_iter_1 = list_int_2.begin(); + while(list_iter_1 != list_int_2.end()){ + std::cout << *list_iter_1 << " "; + ++list_iter_1; + } + std::cout << std::endl; + + list_iter_1 = list_int_1.begin(); + list_iter_1++; + + + std::cout << "The following two lines should be identical\n"; + std::cout << "1 3 4 2 \n"; + + list_int_1.splice(list_iter_1, list_int_2, list_int_2.begin(), list_int_2.end()); + + list_iter_1 = list_int_1.begin(); + while(list_iter_1 != list_int_1.end()){ + std::cout << *list_iter_1 << " "; + ++list_iter_1; + } + std::cout << std::endl; + + + /* bug 11361: splice to empty list from other.begin() segfaulted */ + temp.clear(); + a.clear(); + temp.push_back(1.0); + temp.push_back(2.0); + a.splice(a.end(), temp, temp.begin()); + std::cout << "temp.size(): " << temp.size() << std::endl; + std::cout << "a.size(): " << a.size() << std::endl; + std::cout << "temp:"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << " " << *i; + ++i; + } + std::cout << std::endl; + std::cout << "a:"; + i = a.begin(); + while(i != a.end()){ + std::cout << " " << *i; + ++i; + } + std::cout << std::endl; + + + std::cout << "Testing operator=()\n"; + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + temp.push_back(85.4); + temp.push_back(24.6); + temp.push_back(69.7); + + std::cout << "The following three lines should be identical\n"; + std::cout << "12.8 22.4 37.9 48.5 21.2 85.4 24.6 69.7 \n"; + a = temp; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + i = a.end(); + while(i != a.begin()){ + --i; + std::cout << *i << " "; + } + std::cout << std::endl; + + + std::cout << "\nTesting lists with pointer parameters" << std::endl; + + testPointer.clear(); + + testPointer.insert(testPointer.end(), new testSubClass()); + + if(testPointer.size() > 0){ + + testPointerIterator = testPointer.begin(); + while(testPointerIterator != testPointer.end()){ + (*testPointerIterator)->write(); + ++testPointerIterator; + } + } + delete (testPointer.back()); + testPointer.pop_back(); + + + std::cout << "\nTesting sorting\n"; + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(21.2); + temp.push_back(85.4); + temp.push_back(24.6); + temp.push_back(69.7); + + temp.sort(); + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 21.2 22.4 24.6 37.9 48.5 69.7 85.4 \n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + + std::cout << "\nTesting merging\n"; + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + + a.clear(); + a.push_back(11.7); + a.push_back(29.1); + a.push_back(94.3); + a.push_back(99.9); + + temp.merge(a); + std::cout << "The following two lines should be identical:\n"; + std::cout << "11.7 12.8 22.4 29.1 37.9 48.5 94.3 99.9 \n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + + + + std::cout << "\nTesting remove\n"; + + temp.clear(); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(11.7); + temp.push_back(29.1); + temp.push_back(37.9); + temp.push_back(99.9); + + temp.remove(37.9); + std::cout << "The following two lines should be identical:\n"; + std::cout << "12.8 22.4 48.5 11.7 29.7 99.9 \n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + std::cout << "\nTesting unique\n"; + + temp.clear(); + temp.push_back(11.7); + temp.push_back(12.8); + temp.push_back(12.8); + temp.push_back(22.4); + temp.push_back(29.1); + temp.push_back(37.9); + temp.push_back(37.9); + temp.push_back(37.9); + temp.push_back(37.9); + temp.push_back(48.5); + temp.push_back(99.9); + + temp.unique(); + std::cout << "The following two lines should be identical:\n"; + std::cout << "11.7 12.8 22.4 29.1 37.9 48.5 99.9 \n"; + i = temp.begin(); + while(i != temp.end()){ + std::cout << *i << " "; + ++i; + } + std::cout << std::endl; + + list_int_1.clear(); + list_int_1.push_back(1); + list_int_1.push_back(2); + list_int_1.push_back(3); + list_int_1.push_back(4); + + int d(3); + int * p = &d; + for( list_iter_1 = list_int_1.begin(); list_iter_1 != list_int_1.end(); ++list_iter_1){ + if(*list_iter_1==*p){ + std::cout << "Found 3 == 3" << std::endl; + } + } + + + return 0; +} diff --git a/tests/maptest.cpp b/tests/maptest.cpp new file mode 100644 index 0000000..30177f6 --- /dev/null +++ b/tests/maptest.cpp @@ -0,0 +1,351 @@ +#include +#include +#include "testframework.h" + + +struct Int { + Int(int x = 0) : val(x) { }; + int val; +}; + +std::ostream& operator<<(std::ostream& s, Int x) + { return s << x.val; } + + +bool canForwardIterateCorrectly(){ + std::map a; + + a[3] = 13; + a[5] = 15; + + std::map::iterator i; + int count; + + for(i = a.begin(), count=0; i != a.end() && count < 20; i++, count++){ + } + + if(2 == count){ + return true; + } + return false; +} + +bool canCompareConstNonConstIter() { + std::map m; + m[5] = 2.3; + m[6] = 3.3; + m[7] = 3.4; + std::map::const_iterator i = m.begin(); + std::map::iterator j = m.begin(); + std::map::iterator k = m.end(); + + if (i == i && i == j && j == i && j == j) { + // Do nothing + } else { + return false; + } + + if (i != i || i != j || j != i || j != j) { + return false; + } + + return true; +} + + +bool canSwapCorrectly(){ + std::map a, b; + + a[3] = 13; + a[5] = 15; + + b[3] = 23; + b[9] = 27; + + std::map::iterator i; + + i = a.find(3); + if (i == a.end()) { + return false; + } + i = a.find(9); + if (i != a.end()) { + return false; + } + + i = b.find(3); + if (i == b.end()) { + return false; + } + + i = b.find(5); + if (i != b.end()) { + return false; + } + + a.swap(b); + + i = a.find(3); + if (i == a.end()) { + return false; + } + i = a.find(5); + if (i != a.end()) { + return false; + } + i = a.find(9); + if (i == a.end()) { + return false; + } + + i = b.find(3); + if (i == b.end()) { + return false; + } + i = b.find(5); + if (i == b.end()) { + return false; + } + i = b.find(9); + if (i != b.end()) { + return false; + } + + return true; +} + +class my_type { +public: + my_type() : id(count++) { } + void test() { } + + int id; + static int count; +}; + +int my_type::count = 0; + + +bool canSubscriptWithoutExtraObjectCreation() { + std::map mymap; + mymap[1].test(); + mymap[1].test(); + + if (my_type::count != 1) { + return false; + } + + return true; +} + + +int main(){ + std::map test; + std::map::iterator i, j; + std::map::const_iterator k; + + std::map::reverse_iterator ri; + + std::cout << "Start of map test" << std::endl; + + std::cout << "Checking to make sure that map::iterator can be compared" << std::endl; + std::cout << "to map::const_iterator: "; + + i = test.begin(); + k = test.begin(); + if( i == k ){ + std::cout << "OK" << std::endl; + }else{ + std::cout << "FAIL" << std::endl; + } + + std::cout << "Checking to make sure that map::iterator can be compared" << std::endl; + std::cout << "to map::const_iterator: "; + + i = test.begin(); + k = test.begin(); + if( k == i ){ + std::cout << "OK" << std::endl; + }else{ + std::cout << "FAIL" << std::endl; + } + + + std::cout << "Adding a few elements..." << std::endl; + + + std::pair a; + std::pair b; + std::pair::iterator, bool> c; + + test["b"] = 2; + test["k"] = 11; + test["c"] = 3; + test["a"] = 1; + + + std::cout << "Elements:" << std::endl; + std::cout << "test[\"b\"] = " << test["b"] << " - should be 2" << std::endl; + std::cout << "test[\"a\"] = " << test["a"] << " - should be 1" << std::endl; + std::cout << "test[\"k\"] = " << test["k"] << " - should be 11" << std::endl; + + + std::cout << "Reasigning the value of a" << std::endl; + test["a"] = 65; + std::cout << "test[\"a\"] = " << test["a"] << " - should be 65" << std::endl; + + std::cout << "All of the contents of test:" << std::endl; + + i = test.begin(); + std::cout << "First element: " << (*i).first << ": " << (*i).second << std::endl; + std::cout << "First element: " << i->first << ": " << i->second << std::endl; + j = test.end(); + while(i != test.end() ){ + std::cout << i->first << ": " << i->second << std::endl; + ++i; + --i; + ++i; + i--; + i++; + } + + std::cout << "Elements in reverse order:\n"; + ri = test.rbegin(); + while(ri != test.rend()){ + std::cout << (*ri).first << ": " << (*ri).second << std::endl; + ++ri; + } + + + + std::cout << "Number of elements: " << test.size() << std::endl; + std::cout << "Container empty? " << test.empty() << std::endl; + + std::pair q; + + q.first = "Inserted value"; + q.second = 1.0; + + + std::cout << "Finding element \"c\"" << std::endl; + j = test.find("c"); + if(j == test.end()){ + std::cout << "Not found (bad)\n"; + }else{ + std::cout << "Found value for c: " << j->second << std::endl; + } + + std::cout << "Count of elements with key \"c\": " << test.count("c") << std::endl; + + + std::cout << "Inserting element g: " << std::endl; + a.first = "g"; + a.second = 6; + c = test.insert(a); + std::cout << "Value inserted? " << c.second << std::endl; + std::cout << "Key: " << c.first->first << ", value: " << c.first->second << std::endl; + + i = test.begin(); + while(i != test.end() ){ + std::cout << i->first << ": " << i->second << std::endl; + ++i; + } + + std::cout << "Attempting to insert same element again: "; + a.first="g"; + a.second = 6; + c = test.insert(a); + if(c.second == true){ + std::cout << "inserted - FAILED\n"; + }else{ + std::cout << "no insert - PASSED\n"; + } + + j = test.find("g"); + std::cout << "Erasing element \"g\"" << std::endl; + test.erase(j); + + i=test.begin(); + while(i != test.end() ){ + std::cout << i->first << ": " << i->second << std::endl; + ++i; + } + + std::cout << "Erasing element \"c\"" << std::endl; + test.erase("c"); + + i=test.begin(); + while(i != test.end() ){ + std::cout << i->first << ": " << i->second << std::endl; + ++i; + } + + j = test.lower_bound("b"); + std::cout << "This should read 2: " << j->second << std::endl; + j = test.lower_bound("c"); + std::cout << "This should read 11: " << j->second << std::endl; + j = test.lower_bound("z"); + std::cout << "This should read end: " << ((j == test.end()) ? "end" : "noend") << std::endl; + + k = test.lower_bound("b"); + std::cout << "This should read 2: " << k->second << std::endl; + k = test.lower_bound("c"); + std::cout << "This should read 11: " << k->second << std::endl; + k = test.lower_bound("z"); + std::cout << "This should read end: " << ((k == test.end()) ? "end" : "noend") << std::endl; + + std::cout << "This should read 11: " << test.equal_range("k").first->second << std::endl; + + std::cout << "test roman numerals" << std::endl; + + typedef std::map > maptype; + + maptype map_char_myClass; + // Store mappings between roman numerals and decimals. + + std::cout << "Inserting values now" << std::endl; + + map_char_myClass['l'] = 50; + map_char_myClass['x'] = 20; // Deliberate mistake. + map_char_myClass['v'] = 5; + map_char_myClass['i'] = 1; + std::cout << "map_char_myClass['x'] = " << map_char_myClass['x'] << std::endl; + map_char_myClass['x'] = 10; // Correct mistake. + std::cout << "map_char_myClass['x'] = " << map_char_myClass['x'] << std::endl; + std::cout << "map_char_myClass['z'] = " << map_char_myClass['z'] << std::endl; // Note default value is added. + + std::cout << "Here is the bit which is currently non-compliant:" << std::endl; + //This needs to be fixed + + std::map m; + + m.insert(std::make_pair(1, std::string("one"))); + m.insert(std::make_pair(2, std::string("two"))); + m.insert(std::make_pair(3, std::string("three"))); + + std::map::const_iterator m_2(m.find(2)); + std::map::const_iterator m_3(m.find(3)); + + std::cout << "m_2 is " << m_2->second << std::endl; + std::cout << "m_3 is " << m_3->second << std::endl; + + m.erase(1); + + std::cout << "m_2 is now " << m_2->second << std::endl; + std::cout << "m_3 is now " << m_3->second << std::endl; + + std::cout << "Beginning map test" << std::endl; + + TestFramework::init(); + + TestFramework::AssertReturns(canForwardIterateCorrectly, true); + TestFramework::AssertReturns(canCompareConstNonConstIter, true); + TestFramework::AssertReturns(canSwapCorrectly, true); + TestFramework::AssertReturns(canSubscriptWithoutExtraObjectCreation, true); + + TestFramework::results(); + + return 0; +} + + diff --git a/tests/memorytest.cpp b/tests/memorytest.cpp new file mode 100644 index 0000000..d362056 --- /dev/null +++ b/tests/memorytest.cpp @@ -0,0 +1,60 @@ +#include +#include + +std::auto_ptr intMaker(); + +int main(){ + std::auto_ptr a(new int (12)); + if(0 == a.get()){ + printf("a pointer is zero (BAD)\n"); + }else{ + printf("a pointer is non-zero (GOOD)\n"); + } + printf("a value (should be 12): %i\n", *a); + + std::auto_ptr b(a); + if(0 == b.get()){ + printf("b pointer is zero (BAD)\n"); + }else{ + printf("b pointer is non-zero (GOOD)\n"); + } + if(0 == a.get()){ + printf("a pointer is zero (GOOD)\n"); + }else{ + printf("a pointer is non-zero (BAD)\n"); + } + printf("b value (should be 12): %i\n", *b); + + *b = 7; + if(0 == b.get()){ + printf("b pointer is zero (BAD)\n"); + }else{ + printf("b pointer is non-zero (GOOD)\n"); + } + printf("b value (should be 7): %i\n", *b); + + std::auto_ptr c(intMaker()); + if(0 == c.get()){ + printf("c pointer is zero (BAD)\n"); + }else{ + printf("c pointer is non-zero (GOOD)\n"); + } + printf("c value (should be 5): %i\n", *c); + c.reset(); + if(0 == c.get()){ + printf("c pointer is zero (GOOD)\n"); + }else{ + printf("c pointer is non-zero (BAD)\n"); + } + + std::auto_ptr x( new int(5) ); + std::auto_ptr y( std::auto_ptr( x ) ); + + + return 0; +} + + +std::auto_ptr intMaker(){ + return std::auto_ptr ( new int(5)); +} diff --git a/tests/mmaptest.cpp b/tests/mmaptest.cpp new file mode 100644 index 0000000..ee621c3 --- /dev/null +++ b/tests/mmaptest.cpp @@ -0,0 +1,230 @@ +#include +#include +#include "testframework.h" + +bool test_added_elements(){ + std::multimap test; + std::multimap::iterator i; + std::pair a; + + a.first="a"; + a.second=1; + test.insert(a); + + a.first="c"; + a.second=3; + test.insert(a); + + a.first="c"; + a.second=3.1; + test.insert(a); + + a.first="d"; + a.second=4; + test.insert(a); + + a.first="g"; + a.second=7; + test.insert(a); + + + if(test.count("a") != 1){ + return false; + } + if(test.count("c") != 2){ + return false; + } + if(test.count("d") != 1){ + return false; + } + if(test.count("g") != 1){ + return false; + } + if(test.count("q") != 0){ + return false; + } + + std::map b; + for(i = test.lower_bound("c"); i != test.upper_bound("c"); ++i){ + b.insert(std::pair(i->second, (*i).second)); + } + if(b.count(3.1) != 1){ + return false; + } + if(b.count(3) != 1){ + return false; + } + if(b.size() != 2){ + return false; + } + return true; +} + +bool test_positioned_insert(){ + std::multimap test; + std::multimap::iterator i; + std::pair a; + + a.first="a"; + a.second=1; + test.insert(a); + + a.first="c"; + a.second=3; + test.insert(a); + + a.first="c"; + a.second=3.1; + test.insert(a); + + a.first="d"; + a.second=4; + test.insert(a); + + a.first="g"; + a.second=7; + test.insert(a); + + a.first="c"; + a.second=3.14; + i=test.begin(); + ++i; + ++i; + + test.insert(i, a); + + if(test.count("a") != 1){ + return false; + } + if(test.count("c") != 3){ + return false; + } + if(test.count("d") != 1){ + return false; + } + if(test.count("g") != 1){ + return false; + } + if(test.count("q") != 0){ + return false; + } + + std::map b; + for(i = test.lower_bound("c"); i != test.upper_bound("c"); ++i){ + b.insert(std::pair(i->second, (*i).second)); + } + if(b.count(3.1) != 1){ + return false; + } + if(b.count(3) != 1){ + return false; + } + if(b.count(3.14) != 1){ + return false; + } + if(b.size() != 3){ + return false; + } + + + return true; +} + +static bool erase_both_iters() { + typedef std::multimap testmap; + testmap tst; + tst.insert(std::pair(1, 1)); + tst.insert(std::pair(2, 1)); + tst.insert(std::pair(3, 1)); + tst.erase(tst.begin(), tst.end()); + if (tst.empty() == true + && tst.size() == 0 + && tst.rbegin() == tst.rend() + && tst.begin() == tst.end() + && tst.find(42) == tst.end()) + return true; + return false; +} + + +int main(){ + + TestFramework::init(); + + TestFramework::AssertReturns(test_added_elements, true); + TestFramework::AssertReturns(test_positioned_insert, true); + TestFramework::AssertReturns(erase_both_iters, true); + + TestFramework::results(); + + + + std::multimap test; + std::multimap::iterator i, j; + std::multimap::const_iterator k; + + std::cout << "Start of multimap test" << std::endl; + + std::cout << "Adding a few elements..." << std::endl; + + std::pair a; + std::pair b; + std::pair::iterator, bool> c; + + a.first="a"; + a.second=1; + test.insert(a); + + a.first="c"; + a.second=3; + test.insert(a); + + a.first="c"; + a.second=3.1; + test.insert(a); + + a.first="d"; + a.second=4; + test.insert(a); + + a.first="g"; + a.second=7; + test.insert(a); + + std::cout << "Checking locations\n"; + + i = test.find("c"); + std::cout << "Element c: " << i->first << ": " << std::endl; + + i = test.find("d"); + std::cout << "Element d: " << i->first << ": " << std::endl; + + + i = test.lower_bound("c"); + std::cout << "lower bound for c: " << i->first << std::endl; + + std::cout << "Erasing all \"c\" elements\n"; + test.erase("c"); + + i = test.begin(); + while(i != test.end()){ + std::cout << "Element " << i->first << ": " << i->second << std::endl; + ++i; + } + + std::cout << "Inserting \"c\": 3.7\n"; + + a.first = "c"; + a.second=3.7; + test.insert(a); + + i = test.begin(); + while(i != test.end()){ + std::cout << "Element " << i->first << ": " << i->second << std::endl; + ++i; + } + + return 0; +} + + diff --git a/tests/newdeltest.cpp b/tests/newdeltest.cpp new file mode 100644 index 0000000..06e41a1 --- /dev/null +++ b/tests/newdeltest.cpp @@ -0,0 +1,94 @@ +#include +#include +#include + +struct test{ + int a; + float b; +}; + +class base { +protected: + int a; + +public: + base() : a(0){ + printf("Executing default base class constructor. a: %i\n", a); + } + + virtual ~base(){ + printf("Executing base class destructor\n"); + } + + virtual void print(){ + printf("Base class print function with a=%i\n", a); + } + +}; + +class sub : public base{ +protected: + float f; +public: + sub() : f(0){ + printf("Executing default sub class constructor. a: %i, f: %f\n", base::a, f); + } + virtual ~sub(){ + printf("Executing sub class destructor\n"); + } + + virtual void print(){ + printf("Sub class print function with a=%i and f=%f\n", a, f); + } + +}; + + +int main(){ + test * temp = new test; + temp->a = 5; + delete temp; + temp = 0; + + temp = new test[25]; + delete [] temp; + temp = 0; + + base * b = new base; + b->print(); + delete b; + b=0; + + b = new base[3]; + for(int i = 0; i < 3; ++i){ + b[i].print(); + } + delete [] b; + b = 0; + + b = new sub; + b->print(); + delete b; + b = 0; + + //We can only create one because we can't step through the array properly + b = new sub[1]; + b[0].print(); + delete [] b; + b = 0; + + printf("Testing nothrow new\n"); + + b = new(std::nothrow) base; + + printf("Checking allocator\n"); + std::allocator al; + b = al.allocate(1); + al.construct(b, base()); + b->print(); + al.destroy(b); + al.deallocate(b, 1); + b = 0; + + return 0; +} diff --git a/tests/numerictest.cpp b/tests/numerictest.cpp new file mode 100644 index 0000000..527dfda --- /dev/null +++ b/tests/numerictest.cpp @@ -0,0 +1,60 @@ +#include +#include +#include + +int main(){ + + std::vector src; + std::vector dest; + std::vector::iterator i; + + src.clear(); + dest.clear(); + + src.push_back(17); + src.push_back(19); + src.push_back(20); + src.push_back(20); + src.push_back(17); + + dest.push_back(0); + dest.push_back(0); + dest.push_back(0); + dest.push_back(0); + dest.push_back(0); + + + std::adjacent_difference::iterator, std::vector::iterator> + (src.begin(), src.end(), dest.begin()); + + std::cout << "Results from adjacent_difference\n"; + i = dest.begin(); + while(i != dest.end()){ + std::cout << "Element: " << *i << std::endl; + ++i; + } + + src.clear(); + src.push_back(0); + src.push_back(0); + src.push_back(0); + src.push_back(0); + src.push_back(0); + + std::partial_sum::iterator, std::vector::iterator> + (dest.begin(), dest.end(), src.begin()); + + std::cout << "Results from partial_sum\n"; + i = src.begin(); + while(i != src.end()){ + std::cout << "Element: " << *i << std::endl; + ++i; + } + + + + std::cout << "End of numeric test" << std::endl; + + return 0; +} + diff --git a/tests/settest.cpp b/tests/settest.cpp new file mode 100644 index 0000000..8df6ba1 --- /dev/null +++ b/tests/settest.cpp @@ -0,0 +1,342 @@ +#include +#include +#include +#include + +class TEST_A +{ +private: + std::set _s; + std::set::iterator _t; + +public: + TEST_A(){ + _s.insert(1); + _t = _s.begin(); + } + + int f() const { + return *_t; + } +}; + + +int main(){ + std::cout << "Starting set test\n"; + std::set a; + std::vector c; + std::vector::iterator k, l; + int z; + + c.clear(); + + if(a.empty() == false){ + std::cout << "ERROR - set should be empty\n"; + }else{ + std::cout << "OK - set is empty\n"; + } + + a.clear(); + + std::pair::iterator, bool> p; + + p = a.insert(57); + p = a.insert(75); + p = a.insert(11); + p = a.insert(29); + p = a.insert(128); + p = a.insert(103); + p = a.insert(56); + + std::cout << *(p.first) << " should read 56\n"; + + + + std::set::iterator i, j; + std::set::const_iterator q; + + std::cout << "Element list" << std::endl; + i = a.begin(); + while(i != a.end() ){ + std::cout << "Element : " << *i << std::endl; + ++i; + } + + std::cout << "Element list" << std::endl; + q = a.begin(); + while(q != a.end() ){ + std::cout << "Element : " << *q << std::endl; + ++q; + } + + + //Deleting element 56 + i = a.find(56); + std::cout << *i << " should read 56\n"; + + a.erase(i); + + + std::cout << "Element list (56 should be deleted)\n"; + i = a.begin(); + while(i != a.end() ){ + std::cout << "Element : " << *i << std::endl; + ++i; + } + + + std::cout << "Checking to make sure that iterator is comparable to" << std::endl; + std::cout << "const_iterator: "; + + i = a.begin(); + q = a.begin(); + +// if( std::set::const_iterator(i) == q){ + if(i == q){ + std::cout << "OK" << std::endl; + }else{ + std::cout << "FAIL" << std::endl; + } + + std::cout << "Checking to make sure that iterator is comparable to" << std::endl; + std::cout << "const_iterator: "; + + i = a.begin(); + q = a.begin(); + +// if( std::set::const_iterator(i) == q){ + if(q == i){ + std::cout << "OK" << std::endl; + }else{ + std::cout << "FAIL" << std::endl; + } + + std::cout << "Set algorithms test" << std::endl; + std::cout << "Testing std::includes\n"; + + a.clear(); + a.insert(12); + a.insert(32); + a.insert(85); + a.insert(25); + a.insert(63); + a.insert(92); + + std::set b(a); + + + b.clear(); + b.insert(12); + b.insert(32); + b.insert(92); + + std::cout << "The following should be 1 : "; + std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end()); + std::cout << std::endl; + + b.clear(); + b.insert(12); + b.insert(92); + b.insert(91); + + std::cout << "The following should be 0 : "; + std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end()); + std::cout << std::endl; + + b.clear(); + std::cout << "The following should be 1 : "; + std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end()); + std::cout << std::endl; + + b.insert(12); + std::cout << "The following should be 1 : "; + std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end()); + std::cout << std::endl; + + + b.clear(); + b.insert(1); + std::cout << "The following should be 0 : "; + std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end()); + std::cout << std::endl; + + + std::cout << "Set union\n"; + a.clear(); + a.insert(10); + a.insert(12); + a.insert(32); + a.insert(52); + a.insert(72); + + b.clear(); + b.insert(12); + b.insert(19); + b.insert(22); + b.insert(32); + b.insert(38); + b.insert(52); + b.insert(92); + + c.assign(20, 0); + + std::cout << "The following two lines should be identical:\n"; + std::cout << "10 12 19 22 32 38 52 72 92 " << std::endl; + + l = std::set_union(a.begin(), a.end(), b.begin(), b.end(), c.begin() ); + k = c.begin(); + while(k != l){ + std::cout << *k << " " ; + ++k; + } + std::cout << std::endl; + + + std::cout << "Set intersection\n"; + a.clear(); + a.insert(10); + a.insert(12); + a.insert(32); + a.insert(52); + a.insert(72); + + b.clear(); + b.insert(12); + b.insert(19); + b.insert(22); + b.insert(32); + b.insert(38); + b.insert(52); + b.insert(92); + + c.assign(20, 0); + std::cout << "Size of c: " << c.size() << std::endl; + + std::cout << "The following two lines should be identical:\n"; + std::cout << "12 32 52 " << std::endl; + + l = std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), c.begin() ); + k = c.begin(); + while(k != l){ + std::cout << *k << " " ; + ++k; + } + std::cout << std::endl; + + + + std::cout << "Set difference\n"; + a.clear(); + a.insert(10); + a.insert(12); + a.insert(32); + a.insert(52); + a.insert(72); + + b.clear(); + b.insert(12); + b.insert(19); + b.insert(22); + b.insert(32); + b.insert(38); + b.insert(52); + b.insert(92); + + c.assign(20, 0); + + std::cout << "The following two lines should be identical:\n"; + std::cout << "10 72 " << std::endl; + + l = std::set_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin() ); + k = c.begin(); + while(k != l){ + std::cout << *k << " " ; + ++k; + } + std::cout << std::endl; + + + std::cout << "Set symmetric difference\n"; + a.clear(); + a.insert(10); + a.insert(12); + a.insert(32); + a.insert(52); + a.insert(72); + + b.clear(); + b.insert(12); + b.insert(19); + b.insert(22); + b.insert(32); + b.insert(38); + b.insert(52); + b.insert(92); + + c.assign(20, 0); + + std::cout << "The following two lines should be identical:\n"; + std::cout << "10 19 22 38 72 92 " << std::endl; + + l = std::set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin() ); + k = c.begin(); + while(k != l){ + std::cout << *k << " " ; + ++k; + } + std::cout << std::endl; + + a.clear(); + b.clear(); + + a.insert(5); + a.insert(3); + a.insert(17); + a.insert(12); + + b.insert(5); + b.insert(3); + b.insert(17); + b.insert(15); + + if(a < b){ + std::cout << "Set a < b" << std::endl; + }else{ + std::cout << "Set a !< b" << std::endl; + } + + if(a == b){ + std::cout << "Set a == b" << std::endl; + }else{ + std::cout << "Set a !== b" << std::endl; + } + + if(a > b){ + std::cout << "Set a > b" << std::endl; + }else{ + std::cout << "Set a !> b" << std::endl; + } + + if(a != b){ + std::cout << "Set a != b" << std::endl; + }else{ + std::cout << "Set a !!= b" << std::endl; + } + + if(a <= b){ + std::cout << "Set a <= b" << std::endl; + }else{ + std::cout << "Set a !<= b" << std::endl; + } + + if(a >= b){ + std::cout << "Set a >= b" << std::endl; + }else{ + std::cout << "Set a !>= b" << std::endl; + } + + TEST_A test_a; + z = test_a.f(); + + return 0; +} diff --git a/tests/sstreamtest.cpp b/tests/sstreamtest.cpp new file mode 100644 index 0000000..36b3470 --- /dev/null +++ b/tests/sstreamtest.cpp @@ -0,0 +1,204 @@ +#include +#include + +int main(){ + std::cout << "Beginning sstream test\n"; + + std::stringstream a; + float f; + int i; + std::string s; + char c; +#ifndef __STRICT_ANSI__ + long long ll; + unsigned long long ull; +#endif + + a << "Starting testing "; + a << 2 ; + a << " " << 2.0; + + std::cout << a.str() << std::endl; + + a.str("abcdefg"); + a.get(c); + std::cout << "Character getted: " << c << std::endl; + a.get(c); + std::cout << "Character getted: " << c << std::endl; + + s = a.str(); + std::cout << "input buffer: " << s << std::endl; + std::cout << "Character 0: " << s[0] << ", character 1: " << s[1] << std::endl; + + + +#ifndef __STRICT_ANSI__ + a.str("678 76 54"); + a >> ll >> ull >> s; + std::cout << "ll (should be 678): " << ll << std::endl; + std::cout << "ull (should be 76): " << ull << std::endl; +#else + /* Fake output for simplicity */ + std::cout << "ll (should be 678): 678" << std::endl; + std::cout << "ull (should be 76): 76" << ull << std::endl; +#endif + + a.str("2.35 5 Test"); + a >> f >> i >> s; + + std::cout << "f (should be 2.35): " << f << std::endl; + std::cout << "i (should be 5): " << i << std::endl; + std::cout << "s (should be Test): " << s << std::endl; + + a.clear(); + std::cout << "Buffer after flag clear: " << a.str() << std::endl; + + std::cout <<"Combining read and write activities\n"; + a.str("Testing data"); + s = ""; + a << 2.5 << " ";// << 't' << "T"; + a >> s; + std::cout << "Read out: " << "'" << s << "'" << std::endl; + a >> s; + std::cout << "Read out: " << "'" << s << "'" << std::endl; + std::cout << "Current buffer value: " << a.str() << std::endl; + + std::cout << "Appending more text by a number of methods\n"; + a << "trd" << std::endl << std::endl; + a.put(10); + a << "4635"; + std::cout << "String stream text:" << a.str() << std::endl; + std::cout << "String stream test:" << a.str().c_str() << std::endl; + + + std::cout << "Checking ostringstream" << std::endl; + + std::ostringstream o; + + s = "This is a test string"; + s = "Test string"; + + o << "Test string "; + o << 5 << " "; + o << 3.5 << " "; + o << "Another test string"; + o << " " << std::endl << "abcdefghiojklmnopqrstuvwxyz"; + o << " " << std::endl << "abcdefghiojklmnopqrstuvwxyz"; + o << " " << std::endl << "abcdefghiojklmnopqrstuvwxyz"; + o << " " << std::endl << "abcdefghiojklmnopqrstuvwxyz"; + o << " " << std::endl << s << std::endl; + + std::cout << o.str() << std::endl; + + { + std::stringstream ss; + if (ss.flags() &~ (std::ios_base::skipws | std::ios_base::dec)) + std::cout << "ERROR: stream constructor with invalid additional flags " + << (ss.flags() &~ (std::ios_base::skipws | std::ios_base::dec)) + << " set" << std::endl; + } + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + /* test __istream_readin + Check that we handle boolalpha correctly + */ + std::cout << "Checking __istream_readin" << std::endl; + struct tests_s { + unsigned format; + std::string input; + std::string output; + bool b; + bool fail; + }; + struct tests_s tests[] = { + {0, "true", "0", 0, 1}, + {0, "True", "0", 0, 1}, + {0, "TRUE", "0", 0, 1}, + {0, "false", "0", 0, 1}, + {0, "-1", "1", 1, 1}, + {0, "0", "0", 0, 0}, + {0, "1", "1", 1, 0}, + {0, "2", "1", 1, 1}, + + {3, "true", "0", 0, 1}, + {3, "True", "0", 0, 1}, + {3, "TRUE", "0", 0, 1}, + {3, "false", "1", 1, 1}, + {3, "-0x1", "1", 1, 1}, + {3, "0x0", "0", 0, 0}, + {3, "0x1", "1", 1, 0}, + {3, "0x2", "1", 1, 1}, + + {1, "true", "0", 0, 1}, + {1, "True", "0", 0, 1}, + {1, "TRUE", "0", 0, 1}, + {1, "false", "0", 0, 1}, + {1, "-1", "1", 1, 1}, + {1, "0", "0", 0, 0}, + {1, "1", "1", 1, 0}, + {1, "2", "1", 1, 1}, + + {2, "true", "1", 1, 0}, + {2, "True", "0", 0, 1}, + {2, "TRUE", "0", 0, 1}, + {2, "false", "0", 0, 0}, + {2, "-1", "0", 0, 1}, + {2, "0", "0", 0, 1}, + {2, "1", "0", 0, 1}, + {2, "2", "0", 0, 1}, + }; + for (unsigned int i = 0; i < ARRAY_SIZE(tests); i++) { + struct tests_s *test = tests + i; + std::string brief; + std::stringstream ss; + bool b; + + if (test->format == 3) { + brief = "no manip., hex"; + ss << std::hex; + if (!(ss.flags() & ss.hex)) + std::cout << "FAILED to set hex via operator<<" + << std::endl; + } else if (test->format == 2) { + brief = "boolalpha "; + ss << std::boolalpha; + if (!(ss.flags() & ss.boolalpha)) + std::cout << "FAILED to set boolalpha via operator<<" + << std::endl; + } else if (test->format == 1) { + brief = "noboolalpha "; + ss << std::noboolalpha; + if (ss.flags() & ss.boolalpha) + std::cout << "FAILED to unset boolalpha via operator<<" + << std::endl; + } else { + brief = "no manipulator"; + } + ss.str(test->input); + ss >> b; + std::ostringstream os; + os << b; + std::cout << brief << ": " + << test->input << " >> bool == \"" << os.str() << "\"" + << " (expected " << test->output << ")" + << ((os.str() == test->output && ss.fail() == test->fail) + ? ", ok" : ", FAILED") + << std::endl; + if (b != test->b) + std::cout + << "WRONG intermediate result bool(" << int(b) + << "), expected " << int(test->b) + << " for input " << test->input + << std::endl; + if (ss.fail() != test->fail) + std::cout + << "WRONG failbit " << int(ss.fail()) + << ", expected " << int(test->fail) + << " for input " << test->input + << std::endl; + } + std::cout << std::endl; + return 0; +} diff --git a/tests/stacktest.cpp b/tests/stacktest.cpp new file mode 100644 index 0000000..a73feab --- /dev/null +++ b/tests/stacktest.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include "testframework.h" + + +unsigned long int checkStackSize(){ + std::stack > s; + s.push(42); + s.push(101); + s.push(69); + return s.size(); +} + +bool checkStackPop(){ + std::stack > s; + s.push(42); + s.push(101); + s.push(69); + + int i; + + i = s.top(); + if(69 != i){ + printf("Popped %i instead of 69\n", i); + return false; + } + s.pop(); + i = s.top(); + if(101 != i){ + printf("Popped %i instead of 101\n", i); + return false; + } + s.pop(); + i = s.top(); + if(42 != i){ + printf("Popped %i instead of 42\n", i); + return false; + } + s.pop(); + + return s.size() == 0; +} + +bool checkStackEquality(){ + std::stack > s, t; + s.push(42); + s.push(101); + s.push(69); + t.push(42); + t.push(101); + t.push(69); + + return s == t; +} + + +int main(){ + + std::cout<<"Starting stack test" << std::endl; + + TestFramework::init(); + + TestFramework::AssertReturns(checkStackSize, 3); + TestFramework::AssertReturns(checkStackPop, true); + TestFramework::AssertReturns(checkStackEquality, true); + + TestFramework::results(); + + return 0; +} diff --git a/tests/streambuftest.cpp b/tests/streambuftest.cpp new file mode 100644 index 0000000..1e4afcb --- /dev/null +++ b/tests/streambuftest.cpp @@ -0,0 +1,18 @@ +#include +#include + + +int main(){ + //We will work on the stream buffer for std::cin + std::streambuf * buf; + buf = std::cin.rdbuf(); + + int c; + + while ( (c = buf->snextc()) != std::char_traits::eof() ){ + std::cout << "Read in char: " << std::char_traits::to_char_type(c) << std::endl; + } + + + return 0; +} diff --git a/tests/streamitertest.cpp b/tests/streamitertest.cpp new file mode 100644 index 0000000..835e1d6 --- /dev/null +++ b/tests/streamitertest.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + + +int main(){ + char buffer [100]; + int i = 0; + std::istream_iterator s(std::cin); + + std::cin.unsetf(std::ios::skipws); + + while(*s != '\n' && i < 100){ + buffer[i++] = *s++; + } + buffer[i] = '\0'; + + std::cout << "Read: " << buffer << std::endl; + + return 0; +} diff --git a/tests/stringtest.cpp b/tests/stringtest.cpp new file mode 100644 index 0000000..85d451b --- /dev/null +++ b/tests/stringtest.cpp @@ -0,0 +1,553 @@ +#include +#include +#include "testframework.h" + +bool checkStringCompareEquals(){ + std::string b = "This is test string b"; + std::string c = "This is test string c"; + + return (b == c); +} + +bool checkStringCompareCompare(){ + std::string l = "Tommi Maekitalo"; + std::string s = "Mae"; + int c = l.compare(6, 3, s); + + return (0 == c); +} + +bool checkStringCompareNotEquals(){ + std::string b = "This is test string b"; + std::string c = "This is test string c"; + + return b != c; +} + +bool checkStringCompareForwardsEqual(){ + std::string a = "This is test string a"; + std::string b = "This is test string b"; + + a = b + "Test cstring"; + a = b; + return (a == b); +} + +bool checkStringCompareBackwardsEqual(){ + std::string a = "This is test string a"; + std::string b = "This is test string b"; + + a = b + "Test cstring"; + a = b; + return (b == a); +} + +bool checkStringCompareForwardsNotEqual(){ + std::string a = "This is test string a"; + std::string b = "This is test string b"; + + a = b + "Test cstring"; + a = b; + return (a != b); +} + +bool checkStringCompareBackwardsNotEqual(){ + std::string a = "This is test string a"; + std::string b = "This is test string b"; + + a = b + "Test cstring"; + a = b; + return (b != a); +} + +bool checkStringTextForwardsComparison(){ + std::string a = "Test text comparison"; + + return (a == "Test text comparison"); +} + +bool checkStringTextBackwardsComparison(){ + std::string a = "Test text comparison"; + + return (a == "Test text comparison"); +} + +bool checkStringOperatorLess(){ + std::string b = "This is test string b"; + std::string c = "This is test string c"; + + return (b < c); +} + +bool checkStringOperatorGreater(){ + std::string b = "This is test string b"; + std::string c = "This is test string c"; + + return (b > c); +} + +bool checkStringSubstr(){ + std::string a = "This is the base string"; + + return ("is th" == a.substr(5, 5) ); +} + +bool checkStringCharConstructor(){ + std::string a = std::string(1, 'w'); + std::string b = "w"; + + return (a == b); +} + +bool checkStringOpPlusChar(){ + std::string a = std::string("test"); + std::string b = '1' + a; + + return ("1test" == b ); +} + +bool checkStringOpCharPlus(){ + std::string a = std::string("test"); + std::string b = a + '1'; + + return ("test1" == b); +} + +bool checkStringOpPlusString(){ + std::string a = std::string("test"); + std::string b = "1" + a; + + return ("1test" == b ); +} + +bool checkStringOpStringPlus(){ + std::string a = std::string("test"); + std::string b = a + "1"; + + return ("test1" == b); +} + +bool checkStringOpSubscript(){ + std::string a = "abcdefg"; + + return('a' == a[0] && 'b' == a[1] && 'c' == a[2] && 'd' == a[3] && 'e' == a[4] && 'f' == a[5] && 'g' == a[6]); +} + +bool checkStringErase(){ + std::string a = "this should be empty"; + a.erase(); + + return ("" == a); +} + +bool checkFindThe(){ + std::string a = "This is the string we are searching through"; + std::string b = "the"; + std::string::size_type retval = a.find(b); + return 8 == retval; +} + +bool checkFindCharG(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find('g'); + return 17 == retval; +} + +bool checkFindSearch(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find("search"); + return 26 == retval; +} + +bool checkFindThrough(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find("through"); + return 36 == retval; +} + +bool checkFindIsChar3(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find("is", 3); + return 5 == retval; +} + +bool checkFindQ(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find("q"); + return a.npos == retval; +} + +bool checkFindQCast(){ + std::string a = "This is the string we are searching through"; + + if( (long)a.find("q") >= 0){ + return false; + }else{ + if((long)a.find("q") < 0){ + return true; + }else{ + return false; + } + } + return false; +} + +bool checkRfindThe(){ + std::string a = "This is the string we are searching through"; + std::string b = "the"; + std::string::size_type retval = a.rfind(b); + return 8 == retval; +} + +bool checkRfindCharG(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.rfind('g'); + return 41 == retval; +} + +bool checkRfindSearch(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.rfind("search"); + return 26 == retval; +} + +bool checkRfindIsChar3(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.rfind("is", 3); + return 2 == retval; +} + +bool checkRfindQ(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.rfind("q"); + return a.npos == retval; +} + +bool checkRfindThis(){ + std::string a = "This is the string we are searching through"; + std::string b = "This"; + std::string::size_type retval = a.rfind(b); + return 0 == retval; +} + +bool checkFindFirstOfThe(){ + std::string a = "This is the string we are searching through"; + std::string b = "the"; + std::string::size_type retval = a.find_first_of(b); + return 1 == retval; +} + +bool checkFindFirstOfCharG(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_of('g'); + return 17 == retval; +} + +bool checkFindFirstOfSearch(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_of("search"); + return 1 == retval; +} + +bool checkFindFirstOfIsChar4(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_of("is", 4); + return 5 == retval; +} + +bool checkFindFirstOfQ(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_of("q"); + return a.npos == retval; +} + +bool checkFindFirstOfThis(){ + std::string a = "This is the string we are searching through"; + std::string b = "This"; + std::string::size_type retval = a.find_first_of(b); + return 0 == retval; +} + +bool checkFindLastOfThe(){ + std::string a = "This is the string we are searching through"; + std::string b = "the"; + std::string::size_type retval = a.find_last_of(b); + return 42 == retval; +} + +bool checkFindLastOfCharG(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_of('g'); + return 41 == retval; +} + +bool checkFindLastOfSearch(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_of("search"); + return 42 == retval; +} + +bool checkFindLastOfIsChar4(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_of("is", 4); + return 3 == retval; +} + +bool checkFindLastOfQ(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_of("q"); + return a.npos == retval; +} + +bool checkFindLastOfThis(){ + std::string a = "This is the string we are searching through"; + std::string b = "This"; + std::string::size_type retval = a.find_last_of(b); + return 42 == retval; +} + +bool checkFindFirstNotOfThe(){ + std::string a = "This is the string we are searching through"; + std::string b = "the"; + std::string::size_type retval = a.find_first_not_of(b); + return 0 == retval; +} + +bool checkFindFirstNotOfCharG(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_not_of('g'); + return 0 == retval; +} + +bool checkFindFirstNotOfSearch(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_not_of("search"); + return 0 == retval; +} + +bool checkFindFirstNotOfIsChar5(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_not_of("is", 5); + return 7 == retval; +} + +bool checkFindFirstNotOfQ(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_first_not_of("q"); + return 0 == retval; +} + +bool checkFindFirstNotOfThis(){ + std::string a = "This is the string we are searching through"; + std::string b = "This"; + std::string::size_type retval = a.find_first_not_of(b); + return 4 == retval; +} + +bool checkFindLastNotOfThe(){ + std::string a = "This is the string we are searching through"; + std::string b = "the"; + std::string::size_type retval = a.find_last_not_of(b); + return 41 == retval; +} + +bool checkFindLastNotOfCharG(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_not_of('g'); + return 42 == retval; +} + +bool checkFindLastNotOfSearch(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_not_of("search"); + return 41 == retval; +} + +bool checkFindLastNotOfIsChar7(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_not_of("is", 7); + return 7 == retval; +} + +bool checkFindLastNotOfQ(){ + std::string a = "This is the string we are searching through"; + std::string::size_type retval = a.find_last_not_of("q"); + return 42 == retval; +} + +bool checkFindLastNotOfThis(){ + std::string a = "This is the string we are searching through"; + std::string b = "This"; + std::string::size_type retval = a.find_last_not_of(b); + return 41 == retval; +} + +bool checkInsertAtInteractor() { + std::string a = "abcd"; + a.insert(a.end(), 'q'); + if (a != "abcdq") { + return false; + } + return true; +} + +bool checkAssignFillType() { + return true; +#if 0 + std::string a; + a.assign(10, 0x2B); + return a == "++++++++++"; +#endif +} + +bool checkAssignFillChar() { + std::string a; + a.assign(10, '+'); + return a == "++++++++++"; +} + +bool checkAssignString() { + std::string a = "This is a string"; + std::string b; + b.assign(a); + return b == a; +} +bool checkAssignSubstring() { + std::string a = "This is a string"; + std::string b; + b.assign(a, 2, 5); + return b == "is is"; +} + +bool checkAssignCstring() { + std::string a; + a.assign("This is a c string"); + return a == "This is a c string"; +} + +bool checkAssignBuffer() { + std::string a; + a.assign("This is a c string", 8); + return a == "This is "; +} + +bool checkAssignIterator() { + std::string a = "This is a string"; + std::string b; + b.assign(a.begin() + 2, a.end() - 6); + return b == "is is a "; +} + +int main(){ + TestFramework::init(); + + std::string a("Testing string constructor"); + std::string b, c; + + std::cout << "Value of a: " << a << std::endl; + + a = "This is test string a"; + b = "This is test string b"; + c = "This is test string c"; + + std::cout << "Test string initial values:\n"; + + std::cout << a << std::endl << b << std::endl << c << std::endl; + + a = b; + std::cout << "a = b: " << a << std::endl; + + a = b + c; + std::cout << "a = b + c: " << a << std::endl; + + a = "Test cstring" + b; + std::cout << "a = \"Test cstring\" + b: " << a << std::endl; + + std::cout << "Please enter a test string:" << std::flush; + std::cin >> a; + std::cout << std::endl << "You entered: " << a << std::endl; + + TestFramework::AssertReturns(checkStringCompareEquals, false); + TestFramework::AssertReturns(checkStringCompareCompare, true); + TestFramework::AssertReturns(checkStringCompareNotEquals, true); + + TestFramework::AssertReturns(checkStringCompareForwardsEqual, true); + TestFramework::AssertReturns(checkStringCompareBackwardsEqual, true); + TestFramework::AssertReturns(checkStringCompareForwardsNotEqual, false); + TestFramework::AssertReturns(checkStringCompareBackwardsNotEqual, false); + + TestFramework::AssertReturns(checkStringTextForwardsComparison, true); + TestFramework::AssertReturns(checkStringTextBackwardsComparison, true); + + TestFramework::AssertReturns(checkStringOperatorLess, true); + TestFramework::AssertReturns(checkStringOperatorGreater, false); + + TestFramework::AssertReturns(checkStringSubstr, true); + TestFramework::AssertReturns(checkStringCharConstructor, true); + + TestFramework::AssertReturns(checkStringOpPlusChar, true); + TestFramework::AssertReturns(checkStringOpCharPlus, true); + TestFramework::AssertReturns(checkStringOpPlusString, true); + TestFramework::AssertReturns(checkStringOpStringPlus, true); + + TestFramework::AssertReturns(checkStringOpSubscript, true); + TestFramework::AssertReturns(checkStringErase, true); + + TestFramework::AssertReturns(checkFindThe, true); + TestFramework::AssertReturns(checkFindCharG, true); + TestFramework::AssertReturns(checkFindSearch, true); + TestFramework::AssertReturns(checkFindThrough, true); + TestFramework::AssertReturns(checkFindIsChar3, true); + TestFramework::AssertReturns(checkFindQ, true); + TestFramework::AssertReturns(checkFindQCast, true); + + TestFramework::AssertReturns(checkRfindThe, true); + TestFramework::AssertReturns(checkRfindCharG, true); + TestFramework::AssertReturns(checkRfindSearch, true); + TestFramework::AssertReturns(checkRfindIsChar3, true); + TestFramework::AssertReturns(checkRfindQ, true); + TestFramework::AssertReturns(checkRfindThis, true); + + TestFramework::AssertReturns(checkFindFirstOfThe, true); + TestFramework::AssertReturns(checkFindFirstOfCharG, true); + TestFramework::AssertReturns(checkFindFirstOfSearch, true); + TestFramework::AssertReturns(checkFindFirstOfIsChar4, true); + TestFramework::AssertReturns(checkFindFirstOfQ, true); + TestFramework::AssertReturns(checkFindFirstOfThis, true); + + TestFramework::AssertReturns(checkFindLastOfThe, true); + TestFramework::AssertReturns(checkFindLastOfCharG, true); + TestFramework::AssertReturns(checkFindLastOfSearch, true); + TestFramework::AssertReturns(checkFindLastOfIsChar4, true); + TestFramework::AssertReturns(checkFindLastOfQ, true); + TestFramework::AssertReturns(checkFindLastOfThis, true); + + TestFramework::AssertReturns(checkFindFirstNotOfThe, true); + TestFramework::AssertReturns(checkFindFirstNotOfCharG, true); + TestFramework::AssertReturns(checkFindFirstNotOfSearch, true); + TestFramework::AssertReturns(checkFindFirstNotOfIsChar5, true); + TestFramework::AssertReturns(checkFindFirstNotOfQ, true); + TestFramework::AssertReturns(checkFindFirstNotOfThis, true); + + TestFramework::AssertReturns(checkFindLastNotOfThe, true); + TestFramework::AssertReturns(checkFindLastNotOfCharG, true); + TestFramework::AssertReturns(checkFindLastNotOfSearch, true); + TestFramework::AssertReturns(checkFindLastNotOfIsChar7, true); + TestFramework::AssertReturns(checkFindLastNotOfQ, true); + TestFramework::AssertReturns(checkFindLastNotOfThis, true); + + TestFramework::AssertReturns(checkInsertAtInteractor, true); + + TestFramework::AssertReturns(checkAssignFillType, true); + TestFramework::AssertReturns(checkAssignFillChar, true); + TestFramework::AssertReturns(checkAssignString, true); + TestFramework::AssertReturns(checkAssignSubstring, true); + TestFramework::AssertReturns(checkAssignCstring, true); + TestFramework::AssertReturns(checkAssignBuffer, true); + TestFramework::AssertReturns(checkAssignIterator, true); + + TestFramework::results(); + + return 0; +} + diff --git a/tests/testframework.cpp b/tests/testframework.cpp new file mode 100644 index 0000000..8a4b2c4 --- /dev/null +++ b/tests/testframework.cpp @@ -0,0 +1,40 @@ +#include "testframework.h" + +namespace TestFramework{ + unsigned long int goodcount; + unsigned long int badcount; + unsigned long int totalcount; + + unsigned long int getTotalTests(){ + return totalcount; + } + unsigned long int getBadTests(){ + return badcount; + } + unsigned long int getGoodTests(){ + return goodcount; + } + + void init(){ + totalcount = 0; + badcount = 0; + goodcount = 0; + } + + void results(){ + printf("\n"); + + for(int i = 0; i < 30; ++i){ + printf("-"); + } + + printf("\nRan %lu tests\n", totalcount); + if(goodcount == totalcount && 0 == badcount){ + printf("\nOK\n"); + }else{ + printf("\nPassed: %lu\nFailed: %lu\n", goodcount, badcount); + } + } + + +} diff --git a/tests/testframework.h b/tests/testframework.h new file mode 100644 index 0000000..1902ec3 --- /dev/null +++ b/tests/testframework.h @@ -0,0 +1,62 @@ +#include +#include +#include + +namespace TestFramework{ + extern unsigned long int goodcount; + extern unsigned long int badcount; + extern unsigned long int totalcount; + + unsigned long int getTotalTests(); + unsigned long int getBadTests(); + unsigned long int getGoodTests(); + + void init(); + void results(); + + // The following functions take a pointer to a function return type T and compare + // it to the specified value. If this is true then the goodcount is increased. + template void AssertReturns(T (*f)(), const T val){ + ++totalcount; + printf("."); + T retval; + try{ + retval = f(); + if( val == retval){ + ++goodcount; + }else{ + printf("(%lu)", totalcount); + ++badcount; + } + } + catch (...) { + printf("(e%lu)", totalcount); + ++badcount; + } + } + + template void AssertThrows( void (*f)()){ + ++totalcount; + printf("."); + try { + f(); + //No exception thrown - something unexpected happened + printf("N %lu", totalcount); + ++badcount; + } + catch (const T & e) { + ++goodcount; + } + catch (...) { + printf("(e %lu)", totalcount); + //Caught the wrong type of exception + ++badcount; + } + + } + + +} + + + diff --git a/tests/testoutput/Makefile.in b/tests/testoutput/Makefile.in new file mode 100644 index 0000000..b5f8b55 --- /dev/null +++ b/tests/testoutput/Makefile.in @@ -0,0 +1,7 @@ +TESTOUTPUT_DIR := $(TESTS_DIR)testoutput/ +TESTOUTPUT_OUT := $(TESTS_OUT)testoutput/ +test: all + cd $(TESTOUTPUT_DIR) && V="$(V)" ./runtests.sh $(if $(DODEBUG),DODEBUG) + +CLEAN_tests/testoutput: + $(do_rm) $(addprefix $(TESTOUTPUT_OUT),*.test *.out) diff --git a/tests/testoutput/algotest.good b/tests/testoutput/algotest.good new file mode 100644 index 0000000..4d30e0a --- /dev/null +++ b/tests/testoutput/algotest.good @@ -0,0 +1,6 @@ +Beginning algorithm test +............... +------------------------------ +Ran 15 tests + +OK diff --git a/tests/testoutput/bitsettest.good b/tests/testoutput/bitsettest.good new file mode 100644 index 0000000..a613c62 --- /dev/null +++ b/tests/testoutput/bitsettest.good @@ -0,0 +1,14 @@ +0000000000 +1111111111 +0001000101 +1110111010 +0111011110 should read : 0111011110 +0011011101 should read : 0011011101 +0000000000 +1010110011 should read : 1010110011 +0110011000 should read : 0110011000 +0010101100 should read : 0010101100 +0010001000 should read : 0010001000 +0110111100 should read : 0110111100 +0100110100 should read : 0100110100 +1100100100 should read : 1100100100 diff --git a/tests/testoutput/chartraitstest.good b/tests/testoutput/chartraitstest.good new file mode 100644 index 0000000..94432cb --- /dev/null +++ b/tests/testoutput/chartraitstest.good @@ -0,0 +1,23 @@ +eq() properly compares identical values for char +eq() properly compares disimilar values for char +lt() properly compares values for char +lt() properly compares reversed values for char +lt() properly compares equal values for char +compare() properly compares identical strings for char +compare() properly compares partial identical strings for char +compare() properly compares undersized identical strings for char +compare() properly compares different sized identical strings for char +compare() properly compares different strings for char +compare() properly compares different strings for char +compare() properly compares different sized identical strings for char +compare() properly compares different sized identical strings for char +length() properly computes length of 'test' for char +length() properly computes length of '' for char +length() properly computes length of 'a0b1c2' for char +find() properly locates the location of 't' starting at the beginning for char +find() properly locates the location of 't' with offset 1 for char +find() properly locates the location of 't' with offset 3 for char +find() properly returns NULL in 0-sized searches for char +find() properly returns NULL when not found for char +eof() works properly for char +not_eof() works properly for char diff --git a/tests/testoutput/combotest.good b/tests/testoutput/combotest.good new file mode 100644 index 0000000..000b73c --- /dev/null +++ b/tests/testoutput/combotest.good @@ -0,0 +1,6 @@ +Beginning combo tests +. +------------------------------ +Ran 1 tests + +OK diff --git a/tests/testoutput/dequetest.good b/tests/testoutput/dequetest.good new file mode 100644 index 0000000..87cf141 --- /dev/null +++ b/tests/testoutput/dequetest.good @@ -0,0 +1,94 @@ +deque test start + +Test of push_back(): +The following two lines should be identical. +12 13 14 +12 13 14 + +Test of subscripting: +The following two lines should be identical +12 13 14 +12 13 14 +Pushing many elements to the front: +Pushing in: 1 1 +Pushing in: 2 2 +Pushing in: 3 3 +Pushing in: 4 4 +Pushing in: 5 5 +Pushing in: 6 6 +Pushing in: 7 7 +Pushing in: 8 8 +Pushing in: 9 9 +Pushing in: 10 10 +Pushing in: 11 11 +Pushing in: 12 12 +Pushing in: 13 13 +Pushing in: 14 14 +Pushing in: 15 15 +Pushing in: 16 16 +Pushing in: 17 17 +Pushing in: 18 18 +Pushing in: 19 19 +Pushing in: 20 20 +Pushing in: 21 21 +Pushing in: 22 22 +Pushing in: 23 23 +Complete list of elements: +The following two lines should be identical +23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 + + Testing push_back(): +The following two lines should be identical +23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 2.5 +23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 2.5 + +Testing pop_front: +The following two lines should be identical +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 2.5 +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 2.5 + +Testing pop_back: +The following two lines should be identical +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 + +Copy constructor: +The following two lines should be identical +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 + +Assignement: +The following two lines should be identical +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 + +Insert near beginning: +The following two lines should be identical +22 21 25 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +22 21 25 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 + +Insert near end: +The following two lines should be identical +22 21 25 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 27 13 14 +22 21 25 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 27 13 14 + +Erase near beginning: +The following two lines should be identical +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 27 13 14 +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 27 13 14 + +Erase near end: +The following two lines should be identical +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 12 13 14 +Returned iterator points to: 13 - should be 13 +Test of const_iterator +The following two lines should be identical: +12 13 14 7 25 0 +12 13 14 7 25 0 +... +------------------------------ +Ran 3 tests + +OK diff --git a/tests/testoutput/excepttest.good b/tests/testoutput/excepttest.good new file mode 100644 index 0000000..3eff6d0 --- /dev/null +++ b/tests/testoutput/excepttest.good @@ -0,0 +1,9 @@ +Starting exception testing +Throwing out of range +Caught thrown exception +Testing inheriting exception handler +Throwing length_error +Caught logic_error (good) +Testing generic excepetion handler +Throwing length_error +Caught generic exception (good) diff --git a/tests/testoutput/fstreamtest.good b/tests/testoutput/fstreamtest.good new file mode 100644 index 0000000..4d468be --- /dev/null +++ b/tests/testoutput/fstreamtest.good @@ -0,0 +1,290 @@ +Read in character: 3  +Read in character: 4  +Read in character: 5  +Read in character: 6  +Read in character: 7  +Read in character: 8  +Read in character: 9 +Read in character: 10 + +Read in character: 11 +Read in character: 12 +Read in character: 13 +Read in character: 14  +Read in character: 15  +Read in character: 16  +Read in character: 17  +Read in character: 18  +Read in character: 19  +Read in character: 20  +Read in character: 21  +Read in character: 22  +Read in character: 23  +Read in character: 24  +Read in character: 25  +Read in character: 26  +Read in character: 27  +Read in character: 28  +Read in character: 29  +Read in character: 30  +Read in character: 31  +Read in character: 32 +Read in character: 33 ! +Read in character: 34 " +Read in character: 35 # +Read in character: 36 $ +Read in character: 37 % +Read in character: 38 & +Read in character: 39 ' +Read in character: 40 ( +Read in character: 41 ) +Read in character: 42 * +Read in character: 43 + +Read in character: 44 , +Read in character: 45 - +Read in character: 46 . +Read in character: 47 / +Read in character: 48 0 +Read in character: 49 1 +Read in character: 50 2 +Read in character: 51 3 +Read in character: 52 4 +Read in character: 53 5 +Read in character: 54 6 +Read in character: 55 7 +Read in character: 56 8 +Read in character: 57 9 +Read in character: 58 : +Read in character: 59 ; +Read in character: 60 < +Read in character: 61 = +Read in character: 62 > +Read in character: 63 ? +Read in character: 64 @ +Read in character: 65 A +Read in character: 66 B +Read in character: 67 C +Read in character: 68 D +Read in character: 69 E +Read in character: 70 F +Read in character: 71 G +Read in character: 72 H +Read in character: 73 I +Read in character: 74 J +Read in character: 75 K +Read in character: 76 L +Read in character: 77 M +Read in character: 78 N +Read in character: 79 O +Read in character: 80 P +Read in character: 81 Q +Read in character: 82 R +Read in character: 83 S +Read in character: 84 T +Read in character: 85 U +Read in character: 86 V +Read in character: 87 W +Read in character: 88 X +Read in character: 89 Y +Read in character: 90 Z +Read in character: 91 [ +Read in character: 92 \ +Read in character: 93 ] +Read in character: 94 ^ +Read in character: 95 _ +Read in character: 96 ` +Read in character: 97 a +Read in character: 98 b +Read in character: 99 c +Read in character: 100 d +Read in character: 101 e +Read in character: 102 f +Read in character: 103 g +Read in character: 104 h +Read in character: 105 i +Read in character: 106 j +Read in character: 107 k +Read in character: 108 l +Read in character: 109 m +Read in character: 110 n +Read in character: 111 o +Read in character: 112 p +Read in character: 113 q +Read in character: 114 r +Read in character: 115 s +Read in character: 116 t +Read in character: 117 u +Read in character: 118 v +Read in character: 119 w +Read in character: 120 x +Read in character: 121 y +Read in character: 122 z +Read in character: 123 { +Read in character: 124 | +Read in character: 125 } +Read in character: 126 ~ +Read in character: 127  +Read in character: 128 +Read in character: 129 +Read in character: 130 +Read in character: 131 +Read in character: 132 +Read in character: 133 +Read in character: 134 +Read in character: 135 +Read in character: 136 +Read in character: 137 +Read in character: 138 +Read in character: 139 +Read in character: 140 +Read in character: 141 +Read in character: 142 +Read in character: 143 +Read in character: 144 +Read in character: 145 +Read in character: 146 +Read in character: 147 +Read in character: 148 +Read in character: 149 +Read in character: 150 +Read in character: 151 +Read in character: 152 +Read in character: 153 +Read in character: 154 +Read in character: 155 +Read in character: 156 +Read in character: 157 +Read in character: 158 +Read in character: 159 +Read in character: 160 +Read in character: 161 +Read in character: 162 +Read in character: 163 +Read in character: 164 +Read in character: 165 +Read in character: 166 +Read in character: 167 +Read in character: 168 +Read in character: 169 +Read in character: 170 +Read in character: 171 +Read in character: 172 +Read in character: 173 +Read in character: 174 +Read in character: 175 +Read in character: 176 +Read in character: 177 +Read in character: 178 +Read in character: 179 +Read in character: 180 +Read in character: 181 +Read in character: 182 +Read in character: 183 +Read in character: 184 +Read in character: 185 +Read in character: 186 +Read in character: 187 +Read in character: 188 +Read in character: 189 +Read in character: 190 +Read in character: 191 +Read in character: 192 +Read in character: 193 +Read in character: 194 +Read in character: 195 +Read in character: 196 +Read in character: 197 +Read in character: 198 +Read in character: 199 +Read in character: 200 +Read in character: 201 +Read in character: 202 +Read in character: 203 +Read in character: 204 +Read in character: 205 +Read in character: 206 +Read in character: 207 +Read in character: 208 +Read in character: 209 +Read in character: 210 +Read in character: 211 +Read in character: 212 +Read in character: 213 +Read in character: 214 +Read in character: 215 +Read in character: 216 +Read in character: 217 +Read in character: 218 +Read in character: 219 +Read in character: 220 +Read in character: 221 +Read in character: 222 +Read in character: 223 +Read in character: 224 +Read in character: 225 +Read in character: 226 +Read in character: 227 +Read in character: 228 +Read in character: 229 +Read in character: 230 +Read in character: 231 +Read in character: 232 +Read in character: 233 +Read in character: 234 +Read in character: 235 +Read in character: 236 +Read in character: 237 +Read in character: 238 +Read in character: 239 +Read in character: 240 +Read in character: 241 +Read in character: 242 +Read in character: 243 +Read in character: 244 +Read in character: 245 +Read in character: 246 +Read in character: 247 +Read in character: 248 +Read in character: 249 +Read in character: 250 +Read in character: 251 +Read in character: 252 +Read in character: 253 +Read in character: 254 +Read in character: 84 T +Read in character: 104 h +Read in character: 105 i +Read in character: 115 s +Read in character: 32 +Read in character: 115 s +Read in character: 104 h +Read in character: 111 o +Read in character: 117 u +Read in character: 108 l +Read in character: 100 d +Read in character: 32 +Read in character: 98 b +Read in character: 101 e +Read in character: 32 +Read in character: 97 a +Read in character: 116 t +Read in character: 32 +Read in character: 116 t +Read in character: 104 h +Read in character: 101 e +Read in character: 32 +Read in character: 101 e +Read in character: 110 n +Read in character: 100 d +Read in character: 100 d +Now reading other input file to see what wonderful goodness we can discover +Character 27 read in correctly +The following two lines should be identical +Current position: 28 +Current position: 28 +Character 29 read in correctly +The following two lines should be identical +Current position: 30 +Current position: 30 +Checking input on an unopened fstream: +OK diff --git a/tests/testoutput/fstreamtest.input b/tests/testoutput/fstreamtest.input new file mode 100644 index 0000000000000000000000000000000000000000..e13482f937cc781072eacec3826d2d90029cb999 GIT binary patch literal 272 zcmZQzKm&|S%q*;I>>Qk2+&sK|`~reP!Xlz#;u4Zl(lWAg@(PMd$||aA>Kd9_+B&*= z`UZwZ#wMm_<`$M#);6|w_709t&MvNQ?jD|A-afv5{sDnO!6Bhx;SrHh(J`@c@d=4Z z$tkI6=^2?>**Up+`2~eV#U-U>ECr+L^edg@B^A|2&x_ss8wd*%--nxC~?!EgD9zJ^flG{`&pr@4x>5t_FXB literal 0 HcmV?d00001 diff --git a/tests/testoutput/functionaltest.good b/tests/testoutput/functionaltest.good new file mode 100644 index 0000000..eec6f70 --- /dev/null +++ b/tests/testoutput/functionaltest.good @@ -0,0 +1,50 @@ +d == c (correct) +d == 6 (correct) +d == c (correct) +d == 4 (correct) +d == c (correct) +d == 25 (correct) +d == c (correct) +d == b (correct) +d == a (correct) +d == b (correct) +d == -5 (correct) +d == -1 (correct) +c == 5 (correct) +a == a (correct) +a !==b (correct) +a != b (correct) +a !!=b (correct) +c > b (correct) +a !>a (correct) +b < c (correct) +c !< c (correct) +c >= b (correct) +b >= b (correct) +b !>= c (correct) +b <= c (correct) +c !>= b (correct) +b >= b (correct) +c && c (correct) +c && b (correct) +a !&& b (correct) +a !&& a (correct) +c || c (correct) +c || b (correct) +a || b (correct) +a !|| a (correct) +!a (correct) +!!a (correct) +!!b (correct) +!!b (correct) +!!!b (correct) +c !!== c (correct) +a !== b (correct) +b < c (correct) +c !< c (correct) +c !< a (correct) +a < c (correct) +c !< b (correct) +c !< c (correct) +The following should print 7:7 +The following should print 12:12 diff --git a/tests/testoutput/ioexceptiontest.good b/tests/testoutput/ioexceptiontest.good new file mode 100644 index 0000000..04910b1 --- /dev/null +++ b/tests/testoutput/ioexceptiontest.good @@ -0,0 +1,6 @@ +Beginning ioexception test +.. +------------------------------ +Ran 2 tests + +OK diff --git a/tests/testoutput/iotest.good b/tests/testoutput/iotest.good new file mode 100644 index 0000000..2f1497d --- /dev/null +++ b/tests/testoutput/iotest.good @@ -0,0 +1,40 @@ +Hello, World! +Test string: Test string +This is the number 200:200.100000 +This is the number 200:200 +True: true +True: true +not True: true(the string), 1 +boolalpha set: true +not True: 1 +not True: -1 +not True: 1 +False: false +False: false +not False: 0 +not False: 0 +not False: 0 +not False: 0 +Pointer: 0xbc614e +Please enter two floats:You entered: 14564.264648 98347.000000 +Checking ostream_iterator + +Checking length of remaining input +Current position in stream: 15 +Remaining bytes: 45 +fpos o_pos == n_pos ? false +fpos !(o_pos == n_pos) ? true +fpos o_pos != n_pos ? true +Test of reading istream into a function: +Number of characters most recently read in: 0 +Test of reading ios into a function: +Good status: true + 55.1000005.2 +66.1000006.2 +77.1000007.2 +88.1000008.2 +. +------------------------------ +Ran 1 tests + +OK diff --git a/tests/testoutput/iotest.input b/tests/testoutput/iotest.input new file mode 100644 index 0000000..9c759b3 --- /dev/null +++ b/tests/testoutput/iotest.input @@ -0,0 +1,2 @@ +14564.265 98347 +This is another string which can be read in diff --git a/tests/testoutput/listtest.good b/tests/testoutput/listtest.good new file mode 100644 index 0000000..2434490 --- /dev/null +++ b/tests/testoutput/listtest.good @@ -0,0 +1,128 @@ +Beginning of list test +i: 12 +i: 12 +i: 12 +i: 12 +i: 12 + +List insert test +j: 12 +j: 12 +j: 52.4 +j: 52.8 +j: 12 +j: 12 +j: 12 + +List multi-insert test +j: 12 +j: 12 +j: 52.4 +j: 52.8 +j: 12 +j: 33.3 +j: 33.3 +j: 33.3 +j: 12 +j: 12 +First element in list:12 +Erasing 2nd element in list +Second element in list: 52.4 +j: 12 +j: 52.4 +j: 52.8 +j: 12 +j: 33.3 +j: 33.3 +j: 33.3 +j: 12 +j: 12 +Erasing last 3 elements +Last element in list: 33.3 +j: 12 +j: 52.4 +j: 52.8 +j: 12 +j: 33.3 +j: 33.3 +Erasing first element +j: 52.4 +j: 52.8 +j: 12 +j: 33.3 +j: 33.3 +Proper iterator returned + +Testing reverse +The following two lines should be identical: +21.2 48.5 37.9 22.4 12.8 +21.2 48.5 37.9 22.4 12.8 +The following two lines should be identical: +12.8 22.4 37.9 48.5 21.2 +12.8 22.4 37.9 48.5 21.2 + +Testing front() and back() +Front (should be 21.2): 21.2 +Back (should be 12.8): 12.8 + +Testing splice +The following two lines should be identical: +12.8 85.4 24.6 69.7 22.4 37.9 48.5 21.2 +12.8 85.4 24.6 69.7 22.4 37.9 48.5 21.2 +The following two lines should be identical: +85.4 24.6 69.7 12.8 22.4 37.9 48.5 21.2 +85.4 24.6 69.7 12.8 22.4 37.9 48.5 21.2 +The following two lines should be identical: +12.8 22.4 37.9 48.5 21.2 85.4 24.6 69.7 +12.8 22.4 37.9 48.5 21.2 85.4 24.6 69.7 +The following two lines should be identical: +12.8 22.4 24.6 37.9 48.5 21.2 +12.8 22.4 24.6 37.9 48.5 21.2 +The following two lines should be identical: +24.6 12.8 22.4 37.9 48.5 21.2 +24.6 12.8 22.4 37.9 48.5 21.2 +The following two lines should be identical: +12.8 22.4 37.9 48.5 21.2 24.6 +12.8 22.4 37.9 48.5 21.2 24.6 +The following two lines should be identical: +85.4 22.4 37.9 24.6 69.7 +85.4 22.4 37.9 24.6 69.7 +The following two lines should be identical +1 2 3 4 +1 2 3 4 +The following two lines should be identical +1 3 4 2 +1 3 4 2 +temp.size(): 1 +a.size(): 1 +temp: 2 +a: 1 +Testing operator=() +The following three lines should be identical +12.8 22.4 37.9 48.5 21.2 85.4 24.6 69.7 +12.8 22.4 37.9 48.5 21.2 85.4 24.6 69.7 +69.7 24.6 85.4 21.2 48.5 37.9 22.4 12.8 + +Testing lists with pointer parameters +testSubClass::write() + +Testing sorting +The following two lines should be identical: +12.8 21.2 22.4 24.6 37.9 48.5 69.7 85.4 +12.8 21.2 22.4 24.6 37.9 48.5 69.7 85.4 + +Testing merging +The following two lines should be identical: +11.7 12.8 22.4 29.1 37.9 48.5 94.3 99.9 +11.7 12.8 22.4 29.1 37.9 48.5 94.3 99.9 + +Testing remove +The following two lines should be identical: +12.8 22.4 48.5 11.7 29.7 99.9 +12.8 22.4 48.5 11.7 29.1 99.9 + +Testing unique +The following two lines should be identical: +11.7 12.8 22.4 29.1 37.9 48.5 99.9 +11.7 12.8 22.4 29.1 37.9 48.5 99.9 +Found 3 == 3 diff --git a/tests/testoutput/maptest.good b/tests/testoutput/maptest.good new file mode 100644 index 0000000..46d6fe8 --- /dev/null +++ b/tests/testoutput/maptest.good @@ -0,0 +1,70 @@ +Start of map test +Checking to make sure that map::iterator can be compared +to map::const_iterator: OK +Checking to make sure that map::iterator can be compared +to map::const_iterator: OK +Adding a few elements... +Elements: +test["b"] = 2 - should be 2 +test["a"] = 1 - should be 1 +test["k"] = 11 - should be 11 +Reasigning the value of a +test["a"] = 65 - should be 65 +All of the contents of test: +First element: a: 65 +First element: a: 65 +a: 65 +b: 2 +c: 3 +k: 11 +Elements in reverse order: +k: 11 +c: 3 +b: 2 +a: 65 +Number of elements: 4 +Container empty? 0 +Finding element "c" +Found value for c: 3 +Count of elements with key "c": 1 +Inserting element g: +Value inserted? 1 +Key: g, value: 6 +a: 65 +b: 2 +c: 3 +g: 6 +k: 11 +Attempting to insert same element again: no insert - PASSED +Erasing element "g" +a: 65 +b: 2 +c: 3 +k: 11 +Erasing element "c" +a: 65 +b: 2 +k: 11 +This should read 2: 2 +This should read 11: 11 +This should read end: end +This should read 2: 2 +This should read 11: 11 +This should read end: end +This should read 11: 11 +test roman numerals +Inserting values now +map_char_myClass['x'] = 20 +map_char_myClass['x'] = 10 +map_char_myClass['z'] = 0 +Here is the bit which is currently non-compliant: +m_2 is two +m_3 is three +m_2 is now two +m_3 is now three +Beginning map test +.... +------------------------------ +Ran 4 tests + +OK diff --git a/tests/testoutput/memorytest.good b/tests/testoutput/memorytest.good new file mode 100644 index 0000000..97058fa --- /dev/null +++ b/tests/testoutput/memorytest.good @@ -0,0 +1,10 @@ +a pointer is non-zero (GOOD) +a value (should be 12): 12 +b pointer is non-zero (GOOD) +a pointer is zero (GOOD) +b value (should be 12): 12 +b pointer is non-zero (GOOD) +b value (should be 7): 7 +c pointer is non-zero (GOOD) +c value (should be 5): 5 +c pointer is zero (GOOD) diff --git a/tests/testoutput/mmaptest.good b/tests/testoutput/mmaptest.good new file mode 100644 index 0000000..a08c83e --- /dev/null +++ b/tests/testoutput/mmaptest.good @@ -0,0 +1,20 @@ +... +------------------------------ +Ran 3 tests + +OK +Start of multimap test +Adding a few elements... +Checking locations +Element c: c: +Element d: d: +lower bound for c: c +Erasing all "c" elements +Element a: 1 +Element d: 4 +Element g: 7 +Inserting "c": 3.7 +Element a: 1 +Element c: 3.7 +Element d: 4 +Element g: 7 diff --git a/tests/testoutput/newdeltest.good b/tests/testoutput/newdeltest.good new file mode 100644 index 0000000..c1cc8e3 --- /dev/null +++ b/tests/testoutput/newdeltest.good @@ -0,0 +1,29 @@ +Executing default base class constructor. a: 0 +Base class print function with a=0 +Executing base class destructor +Executing default base class constructor. a: 0 +Executing default base class constructor. a: 0 +Executing default base class constructor. a: 0 +Base class print function with a=0 +Base class print function with a=0 +Base class print function with a=0 +Executing base class destructor +Executing base class destructor +Executing base class destructor +Executing default base class constructor. a: 0 +Executing default sub class constructor. a: 0, f: 0.000000 +Sub class print function with a=0 and f=0.000000 +Executing sub class destructor +Executing base class destructor +Executing default base class constructor. a: 0 +Executing default sub class constructor. a: 0, f: 0.000000 +Sub class print function with a=0 and f=0.000000 +Executing sub class destructor +Executing base class destructor +Testing nothrow new +Executing default base class constructor. a: 0 +Checking allocator +Executing default base class constructor. a: 0 +Executing base class destructor +Base class print function with a=0 +Executing base class destructor diff --git a/tests/testoutput/runtests.sh b/tests/testoutput/runtests.sh new file mode 100755 index 0000000..d8c992e --- /dev/null +++ b/tests/testoutput/runtests.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +RETURNVALUE=0 + +case "$V" in + 1|2) DODIFF=1 ;; + *) DODIFF=0 ;; +esac + +for x in *.good ; do + TEST=$(basename ${x} .good) + if [ -x ../${TEST} ] ; then + if [ -f ${TEST}.input ] ; then + LD_LIBRARY_PATH="../../src" ${SIM} ../${TEST} < ${TEST}.input > ${TEST}.test + else + LD_LIBRARY_PATH="../../src" ${SIM} ../${TEST} > ${TEST}.test + fi + cmp ${TEST}.good ${TEST}.test + if [ $? -eq 1 ] ; then + printf "%-25sFAILED\n" ${TEST} + RETURNVALUE=1 + [ $DODIFF -eq 1 ] && diff -a -u ${TEST}.good ${TEST}.test + else + printf "%-25sOK\n" ${TEST} + fi + else + printf "%-25smissing/not built\n" ${TEST} + fi +done + +if [ "$1" = "DODEBUG" ] ; then + for x in *.good ; do + TEST=$(basename ${x} .good) + if [ -x ../${TEST}-old ] ; then + if [ -f ${TEST}.input ] ; then + ../${TEST}-old < ${TEST}.input > ${TEST}-old.test + else + ../${TEST}-old > ${TEST}-old.test + fi + cmp ${TEST}.good ${TEST}-old.test + if [ $? -eq 1 ] ; then + printf "%-25sFAILED\n" ${TEST}-old + [ $DODIFF -eq 1 ] && diff -a -u ${TEST}.good ${TEST}-old.test + RETURNVALUE=1 + else + printf "%-25sOK\n" ${TEST}-old + fi + else + printf "%-25smissing/not built\n" ${TEST}-old + fi + done +fi + +exit $RETURNVALUE diff --git a/tests/testoutput/settest.good b/tests/testoutput/settest.good new file mode 100644 index 0000000..13554cf --- /dev/null +++ b/tests/testoutput/settest.good @@ -0,0 +1,61 @@ +Starting set test +OK - set is empty +56 should read 56 +Element list +Element : 11 +Element : 29 +Element : 56 +Element : 57 +Element : 75 +Element : 103 +Element : 128 +Element list +Element : 11 +Element : 29 +Element : 56 +Element : 57 +Element : 75 +Element : 103 +Element : 128 +56 should read 56 +Element list (56 should be deleted) +Element : 11 +Element : 29 +Element : 57 +Element : 75 +Element : 103 +Element : 128 +Checking to make sure that iterator is comparable to +const_iterator: OK +Checking to make sure that iterator is comparable to +const_iterator: OK +Set algorithms test +Testing std::includes +The following should be 1 : 1 +The following should be 0 : 0 +The following should be 1 : 1 +The following should be 1 : 1 +The following should be 0 : 0 +Set union +The following two lines should be identical: +10 12 19 22 32 38 52 72 92 +10 12 19 22 32 38 52 72 92 +Set intersection +Size of c: 20 +The following two lines should be identical: +12 32 52 +12 32 52 +Set difference +The following two lines should be identical: +10 72 +10 72 +Set symmetric difference +The following two lines should be identical: +10 19 22 38 72 92 +10 19 22 38 72 92 +Set a < b +Set a !== b +Set a !> b +Set a != b +Set a <= b +Set a !>= b diff --git a/tests/testoutput/sstreamtest.good b/tests/testoutput/sstreamtest.good new file mode 100644 index 0000000..e754c35 --- /dev/null +++ b/tests/testoutput/sstreamtest.good @@ -0,0 +1,67 @@ +Beginning sstream test +Starting testing 2 2 +Character getted: a +Character getted: b +input buffer: abcdefg +Character 0: a, character 1: b +ll (should be 678): 678 +ull (should be 76): 76 +f (should be 2.35): 2.35 +i (should be 5): 5 +s (should be Test): Test +Buffer after flag clear: 2.35 5 Test +Combining read and write activities +Read out: '2.5' +Read out: 'ing' +Current buffer value: 2.5 ing data +Appending more text by a number of methods +String stream text:2.5 trd + + +4635 +String stream test:2.5 trd + + +4635 +Checking ostringstream +Test string 5 3.5 Another test string +abcdefghiojklmnopqrstuvwxyz +abcdefghiojklmnopqrstuvwxyz +abcdefghiojklmnopqrstuvwxyz +abcdefghiojklmnopqrstuvwxyz +Test string + +Checking __istream_readin +no manipulator: true >> bool == "0" (expected 0), ok +no manipulator: True >> bool == "0" (expected 0), ok +no manipulator: TRUE >> bool == "0" (expected 0), ok +no manipulator: false >> bool == "0" (expected 0), ok +no manipulator: -1 >> bool == "1" (expected 1), ok +no manipulator: 0 >> bool == "0" (expected 0), ok +no manipulator: 1 >> bool == "1" (expected 1), ok +no manipulator: 2 >> bool == "1" (expected 1), ok +no manip., hex: true >> bool == "0" (expected 0), ok +no manip., hex: True >> bool == "0" (expected 0), ok +no manip., hex: TRUE >> bool == "0" (expected 0), ok +no manip., hex: false >> bool == "1" (expected 1), ok +no manip., hex: -0x1 >> bool == "1" (expected 1), ok +no manip., hex: 0x0 >> bool == "0" (expected 0), ok +no manip., hex: 0x1 >> bool == "1" (expected 1), ok +no manip., hex: 0x2 >> bool == "1" (expected 1), ok +noboolalpha : true >> bool == "0" (expected 0), ok +noboolalpha : True >> bool == "0" (expected 0), ok +noboolalpha : TRUE >> bool == "0" (expected 0), ok +noboolalpha : false >> bool == "0" (expected 0), ok +noboolalpha : -1 >> bool == "1" (expected 1), ok +noboolalpha : 0 >> bool == "0" (expected 0), ok +noboolalpha : 1 >> bool == "1" (expected 1), ok +noboolalpha : 2 >> bool == "1" (expected 1), ok +boolalpha : true >> bool == "1" (expected 1), ok +boolalpha : True >> bool == "0" (expected 0), ok +boolalpha : TRUE >> bool == "0" (expected 0), ok +boolalpha : false >> bool == "0" (expected 0), ok +boolalpha : -1 >> bool == "0" (expected 0), ok +boolalpha : 0 >> bool == "0" (expected 0), ok +boolalpha : 1 >> bool == "0" (expected 0), ok +boolalpha : 2 >> bool == "0" (expected 0), ok + diff --git a/tests/testoutput/stacktest.good b/tests/testoutput/stacktest.good new file mode 100644 index 0000000..d6213f4 --- /dev/null +++ b/tests/testoutput/stacktest.good @@ -0,0 +1,6 @@ +Starting stack test +... +------------------------------ +Ran 3 tests + +OK diff --git a/tests/testoutput/streambuftest.good b/tests/testoutput/streambuftest.good new file mode 100644 index 0000000..fed37ee --- /dev/null +++ b/tests/testoutput/streambuftest.good @@ -0,0 +1,22 @@ +Read in char: h +Read in char: i +Read in char: s +Read in char: +Read in char: i +Read in char: s +Read in char: +Read in char: a +Read in char: +Read in char: t +Read in char: e +Read in char: s +Read in char: t +Read in char: +Read in char: s +Read in char: t +Read in char: r +Read in char: i +Read in char: n +Read in char: g +Read in char: + diff --git a/tests/testoutput/streambuftest.input b/tests/testoutput/streambuftest.input new file mode 100644 index 0000000..d7d2a20 --- /dev/null +++ b/tests/testoutput/streambuftest.input @@ -0,0 +1 @@ +This is a test string diff --git a/tests/testoutput/stringtest.good b/tests/testoutput/stringtest.good new file mode 100644 index 0000000..78067ba --- /dev/null +++ b/tests/testoutput/stringtest.good @@ -0,0 +1,15 @@ +Value of a: Testing string constructor +Test string initial values: +This is test string a +This is test string b +This is test string c +a = b: This is test string b +a = b + c: This is test string bThis is test string c +a = "Test cstring" + b: Test cstringThis is test string b +Please enter a test string: +You entered: word1 +................................................................ +------------------------------ +Ran 64 tests + +OK diff --git a/tests/testoutput/stringtest.input b/tests/testoutput/stringtest.input new file mode 100644 index 0000000..81cde37 --- /dev/null +++ b/tests/testoutput/stringtest.input @@ -0,0 +1,2 @@ +word1 word2 word3 word4 + diff --git a/tests/testoutput/utilitytest.good b/tests/testoutput/utilitytest.good new file mode 100644 index 0000000..9214030 --- /dev/null +++ b/tests/testoutput/utilitytest.good @@ -0,0 +1,5 @@ +...................... +------------------------------ +Ran 22 tests + +OK diff --git a/tests/testoutput/valarraytest.good b/tests/testoutput/valarraytest.good new file mode 100644 index 0000000..ea8cdd8 --- /dev/null +++ b/tests/testoutput/valarraytest.good @@ -0,0 +1,72 @@ +Value of valarray a: 0 1 2 3 4 5 6 7 8 9 +Value of slice_array: 1 3 5 7 9 + +valarray operators +Value of -a: 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 +Value of +a: 0 1 2 3 4 5 6 7 8 9 +Value of ~a: -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 +valarray = !a: 1 0 0 0 0 0 0 0 0 0 +(valarray = !valarray).max() = 1 +(valarray = !valarray).min() = 0 + +valarray algo +valarray.max() = 9 +Result of abs(a): 0 1 2 3 4 5 6 7 8 9 +Result of acos(d): 1.5708 0 nan nan nan nan nan nan nan nan +Result of acos(f): 1.5708 nan nan nan nan nan nan nan nan nan +Result of acos(ld): 1.5708 0 nan nan nan nan nan nan nan nan +Result of asin(d): 0 1.5708 nan nan nan nan nan nan nan nan +Result of asin(f): 0 nan nan nan nan nan nan nan nan nan +Result of asin(ld): 0 1.5708 nan nan nan nan nan nan nan nan +Result of atan(d): 0 0.785398 1.10715 1.24905 1.32582 1.3734 1.40565 1.4289 1.44644 1.46014 +Result of atan(f): 0 0.832981 1.14417 1.27656 1.34732 1.39094 1.42042 1.44165 1.45765 1.47013 +Result of atan(ld): 0 0.7854 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 +Result of atan2(d, d): 0 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 +Result of atan2(type, d): 0 0 0 0 0 0 0 0 0 0 +Result of atan2(d, type): 0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 +Result of atan2(f, f): 0 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 0.785398 +Result of atan2(type, f): 0 0 0 0 0 0 0 0 0 0 +Result of atan2(f, type): 0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 +Result of atan2(ld, ld): 0 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 0.7854 +Result of atan2(type, ld): 0 0 0 0 0 0 0 0 0 0 +Result of atan2(ld, type): 0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 +Result of cos(d): 1 0.540302 -0.416147 -0.989992 -0.653644 0.283662 0.96017 0.753902 -0.1455 -0.91113 +Result of cos(f): 1 0.453596 -0.588501 -0.98748 -0.307333 0.70867 0.950233 0.153374 -0.811093 -0.889191 +Result of cos(ld): 1 0.5403 -0.72183 -0.90761 -0.88689 0.91581 0.62868 0.037697 0.99158 0.81721 +Result of cosh(d): 1 1.54308 3.7622 10.0677 27.3082 74.2099 201.716 548.317 1490.48 4051.54 +Result of cosh(f): 1 1.66852 4.56791 13.5748 40.7316 122.348 367.548 1104.17 3317.12 9965.18 +Result of cosh(ld): 1 1.5431 inf inf inf inf inf inf inf inf +Result of exp(d): 1 2.71828 7.38906 20.0855 54.5982 148.413 403.429 1096.63 2980.96 8103.08 +Result of exp(f): 1 3.00417 9.02501 27.1126 81.4509 244.692 735.095 2208.35 6634.25 19930.4 +Result of exp(ld): 1 2.7183 inf inf inf inf inf inf inf inf +Result of log(d): -inf 0 0.693147 1.09861 1.38629 1.60944 1.79176 1.94591 2.07944 2.19722 +Result of log(f): -inf 0.0953102 0.788457 1.19392 1.4816 1.70475 1.88707 2.04122 2.17475 2.29253 +Result of log(ld): -inf 0 11.09 17.578 22.181 25.751 28.668 31.135 33.271 35.156 +Result of log10(d): -inf 0 0.30103 0.477121 0.60206 0.69897 0.778151 0.845098 0.90309 0.954243 +Result of log10(f): -inf 0.0413927 0.342423 0.518514 0.643453 0.740363 0.819544 0.886491 0.944483 0.995635 +Result of log10(ld): -inf 0 4.8165 7.6339 9.633 11.184 12.45 13.522 14.449 15.268 +Result of pow(d, d): 1 1 4 27 256 3125 46656 823543 1.67772e+07 3.8742e+08 +Result of pow(type, d): 1 0 0 0 0 0 0 0 0 0 +Result of pow(d, type): 1 1 1 1 1 1 1 1 1 1 +Result of pow(f, f): 1 1.11053 5.6667 51.4157 677.941 11803.1 256442 6.69851e+06 2.04856e+08 7.19098e+09 +Result of pow(type, f): 1 0 0 0 0 0 0 0 0 0 +Result of pow(f, type): 1 1 1 1 1 1 1 1 1 1 +Result of pow(ld, ld): 1 1 inf inf inf inf inf inf inf inf +Result of pow(type, ld): 1 0 0 0 0 0 0 0 0 0 +Result of pow(ld, type): 1 1 1 1 1 1 1 1 1 1 +Result of sin(d): 0 0.841471 0.909297 0.14112 -0.756802 -0.958924 -0.279415 0.656987 0.989358 0.412118 +Result of sin(f): 0 0.891207 0.808496 -0.157746 -0.951602 -0.70554 0.311541 0.988168 0.584917 -0.457536 +Result of sin(ld): 0 0.84147 0.69207 0.41981 -0.46199 -0.40161 0.77766 -0.99929 0.1295 -0.57634 +Result of sinh(d): 0 1.1752 3.62686 10.0179 27.2899 74.2032 201.713 548.316 1490.48 4051.54 +Result of sinh(f): 0 1.33565 4.45711 13.5379 40.7193 122.344 367.547 1104.17 3317.12 9965.18 +Result of sinh(ld): 0 1.1752 inf inf inf inf inf inf inf inf +Result of sqrt(d): 0 1 1.41421 1.73205 2 2.23607 2.44949 2.64575 2.82843 3 +Result of sqrt(f): 0 1.04881 1.48324 1.81659 2.09762 2.34521 2.56905 2.77489 2.96648 3.14643 +Result of sqrt(ld): 0 1 256 6561 65536 3.9062e+05 1.6796e+06 5.7648e+06 1.6777e+07 4.3047e+07 +Result of tan(d): 0 1.55741 -2.18504 -0.142547 1.15782 -3.38052 -0.291006 0.871448 -6.79971 -0.452316 +Result of tan(f): 0 1.96476 -1.37382 0.159746 3.09632 -0.995584 0.327858 6.44286 -0.721147 0.514552 +Result of tan(ld): 0 1.5574 -0.95876 -0.46255 0.52091 -0.43853 1.237 -26.509 0.1306 -0.70524 +Result of tanh(d): 0 0.761594 0.964028 0.995055 0.999329 0.999909 0.999988 0.999998 1 1 +Result of tanh(f): 0 0.800499 0.975743 0.997283 0.999699 0.999967 0.999996 1 1 1 +Result of tanh(ld): 0 0.76159 1 1 1 1 1 1 1 1 + diff --git a/tests/testoutput/vectortest.good b/tests/testoutput/vectortest.good new file mode 100644 index 0000000..f152301 --- /dev/null +++ b/tests/testoutput/vectortest.good @@ -0,0 +1,115 @@ +Element 0: 1 +Element 1: 2 +Element 2: 3 +Element 3: 4 +Element 4: 5 +Testing at(int) +Element 0: 1 +Element 1: 2 +Element 2: 3 +Element 3: 4 +Element: 1 +Element: 2 +Element: 3 +Element: 4 +Testing iterator insert +Return value points to: 12, should be 12 +Element: 1 +Element: 2 +Element: 12 +Element: 3 +Element: 4 +Testing iterator multi-insert +Element: 1 +Element: 23 +Element: 23 +Element: 23 +Element: 2 +Element: 12 +Element: 3 +Element: 4 +Testing iterator erase +Element: 1 +Element: 23 +Element: 23 +Element: 2 +Element: 12 +Element: 3 +Element: 4 +Testing iterator multierase +Element: 1 +Element: 23 +Element: 12 +Element: 3 +Element: 4 +Testing iterator range insert +The following should be the same as the above: +Element: 1 +Element: 23 +Element: 12 +Element: 3 +Element: 4 + +Testing vectors of pointers +1 +2 +3 +4 +5 +5 +4 +3 +2 +1 +4 +3 +2 +1 +Pushing back instances of myclass created with new +Deleting instances of myclass directly from iterator +Deleteing myclass instance +Calling destructor with num: 0 +Deleteing myclass instance +Calling destructor with num: 0 +Deleteing myclass instance +Calling destructor with num: 0 +Deleteing myclass instance +Calling destructor with num: 0 +Deleteing myclass instance +Calling destructor with num: 0 +Deleteing myclass instance +Calling destructor with num: 0 +Delete completed on myclass instances +The following two lines should be identical: +Vector size: 4 +Vector size: 6 +Testing resize() +The following two lines should be identical: +Vector size: 1 +Vector size: 1 +The following two lines should be identical: +Vector size: 95 +Vector size: 95 +The following two lines should be identical: +Vector size: 1 +Vector size: 1 +The following two lines should be identical: +Vector size: 2 +Vector size: 2 +The following two lines should be identical: +Vector size: 102 +Vector size: 102 +The following two lines should be identical: +Vector size: 103 +Vector size: 103 +Calling destructor with num: 6 +. +------------------------------ +Ran 1 tests + +OK +Calling destructor with num: 5 +Calling destructor with num: 4 +Calling destructor with num: 3 +Calling destructor with num: 2 +Calling destructor with num: 1 diff --git a/tests/testoutput/wchartest.good b/tests/testoutput/wchartest.good new file mode 100644 index 0000000..4ecfc0b --- /dev/null +++ b/tests/testoutput/wchartest.good @@ -0,0 +1,5 @@ +Starting wchar test +Test of wcout output +This is a test of wstring +This_is_a_test_string +ABCD¶ÃÆÇéñöû¼½¾¿ΈΓαγδεζθλξΞωЧдїթע diff --git a/tests/testoutput/wchartest.input b/tests/testoutput/wchartest.input new file mode 100644 index 0000000..7ebae3c --- /dev/null +++ b/tests/testoutput/wchartest.input @@ -0,0 +1,2 @@ +This_is_a_test_string +ABCD¶ÃÆÇéñöû¼½¾¿ΈΓαγδεζθλξΞωЧдїթע diff --git a/tests/utilitytest.cpp b/tests/utilitytest.cpp new file mode 100644 index 0000000..19e19fc --- /dev/null +++ b/tests/utilitytest.cpp @@ -0,0 +1,241 @@ +#include +#include +#include "testframework.h" + +using namespace std::rel_ops; + +class Foo{ +public: + Foo(int i) : q(new int(i)) { } + + Foo(const Foo & f) : q(new int( *(f.q))) { } + + ~Foo(){ + delete q; + } + + bool operator< (const Foo & rhs) const{ + if(*q < *(rhs.q)){ + return true; + } + return false; + } + + Foo & operator=(Foo & rhs){ + if( & rhs == this){ + return *this; + } + *q = *(rhs.q); + return *this; + } + + bool operator==(const Foo & rhs) const{ + return ( *q == *(rhs.q)); + } + +private: + int * q; + +}; + + +bool checkValidPairEquality(){ + Foo a(1); + Foo b(2); + + std::pair p(a, b); + std::pair q(a, b); + + return p == q; +} + +bool checkInvalidPairLessThan(){ + Foo a(1); + Foo b(2); + + std::pair p(a, b); + std::pair q(a, b); + + return p < q; +} +bool checkInvalidPairGreaterThan(){ + //This checks to make sure the operators are being generated by rel_ops + Foo a(1); + Foo b(2); + + std::pair p(a, b); + std::pair q(a, b); + + return p > q; +} +bool checkInvalidPairNotEquals(){ + //This checks to make sure the operators are being generated by rel_ops + Foo a(1); + Foo b(2); + + std::pair p(a, b); + std::pair q(a, b); + + return p != q; +} +bool checkmake_pair(){ + Foo a(1); + Foo b(2); + + std::pair p(a, b); + std::pair r = std::make_pair(a, b); + + return p == r; +} +bool checkInvalidrel_ops_not_equals(){ + using namespace std::rel_ops; + + Foo a(5); + Foo b(5); + return a != b; +} +bool checkValidrel_ops_not_equals(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return a != c; +} +bool checkInvalidrel_ops_greater_than1(){ + using namespace std::rel_ops; + + Foo a(5); + Foo b(5); + return a > b; +} +bool checkInvalidrel_ops_greater_than2(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return a > c; +} +bool checkValidrel_ops_greater_than1(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return c > a; +} +bool checkValidrel_ops_less_than_equals1(){ + using namespace std::rel_ops; + + Foo a(5); + Foo b(5); + return a <= b; +} +bool checkValidrel_ops_less_than_equals2(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return a <= c; +} +bool checkInvalidrel_ops_less_than_equals1(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return c <= a; +} +bool checkInvalidrel_ops_greater_than_equals1(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return a >= c; +} +bool checkValidrel_ops_greater_than_equals1(){ + using namespace std::rel_ops; + + Foo a(5); + Foo c(6); + return c >= a; +} +bool checkValidrel_ops_greater_than_equals2(){ + using namespace std::rel_ops; + + Foo a(5); + Foo b(6); + return b >= a; +} + +bool checkpair_opsConstructor(){ + std::pair a; + a = std::pair('a', 7531); + + return a.first == 'a' && a.second == 7531; +} +bool checkpair_opsAssignmentOperator(){ + std::pair a; + a = std::pair('a', 7531); + + return a.first == 'a' && a.second == 7531; +} +bool checkpair_opsElementAssignment(){ + std::pair a; + + a = std::pair('a', 7531); + a.second=61473; + a.first='b'; + + return a.first == 'b' && a.second == 61473; +} +bool checkpair_opsCopyConstructor(){ + std::pair b; + b = std::pair('b', 61473); + + std::pair c(b); + + return c.first == 'b' && c.second == 61473; +} +bool checkpair_opsReplacementAssignment(){ + std::pair d = std::pair(5, 18); + std::pair e(d); + +#if __cplusplus < 201103L + /* no move, so not deleted */ + e = d; +#endif + return e.first == 5 && e.second == 18; +} + + +int main(){ + TestFramework::init(); + + TestFramework::AssertReturns(checkInvalidrel_ops_not_equals, false); + TestFramework::AssertReturns(checkValidrel_ops_not_equals, true); + TestFramework::AssertReturns(checkInvalidrel_ops_greater_than1, false); + TestFramework::AssertReturns(checkInvalidrel_ops_greater_than2, false); + TestFramework::AssertReturns(checkValidrel_ops_greater_than1, true); + TestFramework::AssertReturns(checkValidrel_ops_less_than_equals1, true); + TestFramework::AssertReturns(checkValidrel_ops_less_than_equals2, true); + TestFramework::AssertReturns(checkInvalidrel_ops_less_than_equals1, false); + TestFramework::AssertReturns(checkValidrel_ops_greater_than_equals1, true); + TestFramework::AssertReturns(checkValidrel_ops_greater_than_equals2, true); + TestFramework::AssertReturns(checkInvalidrel_ops_greater_than_equals1, false); + + TestFramework::AssertReturns(checkpair_opsConstructor, true); + TestFramework::AssertReturns(checkpair_opsAssignmentOperator, true); + TestFramework::AssertReturns(checkpair_opsElementAssignment, true); + TestFramework::AssertReturns(checkpair_opsCopyConstructor, true); + TestFramework::AssertReturns(checkpair_opsCopyConstructor, true); + TestFramework::AssertReturns(checkpair_opsReplacementAssignment, true); + + + TestFramework::AssertReturns(checkValidPairEquality, true); + TestFramework::AssertReturns(checkInvalidPairLessThan, false); + TestFramework::AssertReturns(checkInvalidPairGreaterThan, false); + TestFramework::AssertReturns(checkInvalidPairNotEquals, false); + TestFramework::AssertReturns(checkmake_pair, true); + + TestFramework::results(); + + return 0; +} diff --git a/tests/valarraytest.cpp b/tests/valarraytest.cpp new file mode 100644 index 0000000..d587e71 --- /dev/null +++ b/tests/valarraytest.cpp @@ -0,0 +1,186 @@ +#include +#include + +bool check_array(std::valarray& a, int b[]) { + for (size_t i = 0; i < a.size(); i++) + if (a[i] != b[i]) { + std::cout << "[" << i << "] " + << a[i] << " != " << b[i] << std::endl; + return false; + } + return true; +} + +void print_array(std::string s, std::valarray& a) { + std::cout << s; + for (size_t i = 0; i < a.size(); ++i){ + std::cout << " " << a[i]; + } + std::cout << std::endl; +} +void print_array(std::string s, std::valarray& a) { + std::cout << s; + for (size_t i = 0; i < a.size(); ++i){ + std::cout << " " << a[i]; + } + std::cout << std::endl; +} +void print_array(std::string s, std::valarray& a) { + std::cout << s; + for (size_t i = 0; i < a.size(); ++i){ + std::cout << " " << a[i]; + } + std::cout << std::endl; +} +void print_array(std::string s, std::valarray& a) { + std::cout << s; + for (size_t i = 0; i < a.size(); ++i){ + std::cout << " " << a[i]; + } + std::cout << std::endl; +} +#if defined __UCLIBCXX_HAS_LONG_DOUBLE__ || defined _GLIBCXX_USE_C99_MATH_TR1 +#include +void print_array(std::string s, std::valarray& a) { + std::streamsize old_precision = std::cout.precision(); + std::cout << s << std::setprecision(old_precision - 1); + for (size_t i = 0; i < a.size(); ++i){ + std::cout << " " << a[i]; + } + std::cout << std::setprecision(old_precision) << std::endl; +} +#endif + +int main(){ + + std::valarray a(10); + a[0] = 0; + a[1] = 1; + a[2] = 2; + a[3] = 3; + a[4] = 4; + a[5] = 5; + a[6] = 6; + a[7] = 7; + a[8] = 8; + a[9] = 9; + + print_array("Value of valarray a:", a); + + std::valarray sl(a[std::slice(1, 5, 2)]); + print_array("Value of slice_array:", sl); + + std::cout << std::endl; + std::cout << "valarray operators" << std::endl; + std::valarray c = -a; + print_array("Value of -a:", c); + c = +a; + print_array("Value of +a:", c); + c = ~a; + print_array("Value of ~a:", c); + + std::valarray b = !a; + print_array("valarray = !a:", b); + std::cout << "(valarray = !valarray).max() = " << b.max() << std::endl; + std::cout << "(valarray = !valarray).min() = " << b.min() << std::endl; + + std::cout << std::endl; + std::cout << "valarray algo" << std::endl; + std::cout << "valarray.max() = " << a.max() << std::endl; + c = abs(a); + print_array("Result of abs(a):", c); + + double dd; + float ff; + std::valarray d(10), ret_d(10); + std::valarray f(10), ret_f(10); + d[0] = 0; + d[1] = 1; + d[2] = 2; + d[3] = 3; + d[4] = 4; + d[5] = 5; + d[6] = 6; + d[7] = 7; + d[8] = 8; + d[9] = 9; + f[0] = 0.0; + f[1] = 1.1; + f[2] = 2.2; + f[3] = 3.3; + f[4] = 4.4; + f[5] = 5.5; + f[6] = 6.6; + f[7] = 7.7; + f[8] = 8.8; + f[9] = 9.9; +#if defined __UCLIBCXX_HAS_LONG_DOUBLE__ || defined _GLIBCXX_USE_C99_MATH_TR1 + long double ldld; + std::valarray ld(10), ret_ld(10); + ld[0] = 0; + ld[1] = 1; + ld[2] = 65536; + ld[3] = 43046721; + ld[4] = 4294967296; + ld[5] = 152587890625; + ld[6] = 2821109907456; + ld[7] = 33232930569601; + ld[8] = 281474976710656; + ld[9] = 1853020188851841; +# define MAYBE_LD_1(fn) \ + ret_ld = fn(ld); \ + print_array("Result of " # fn "(ld):", ret_ld); +# define MAYBE_LD_2(fn) \ + ldld = ld[0]; \ + ret_ld = fn(ld, ld); \ + print_array("Result of " # fn "(ld, ld):", ret_ld); \ + ret_ld = fn(ldld, ld); \ + print_array("Result of " # fn "(type, ld):", ret_ld); \ + ret_ld = fn(ld, ldld); \ + print_array("Result of " # fn "(ld, type):", ret_ld); +#else +# define MAYBE_LD_1(fn) /**/ +# define MAYBE_LD_2(fn) /**/ +#endif +#define DO_1(fn) \ + ret_d = fn(d); \ + print_array("Result of " # fn "(d):", ret_d); \ + ret_f = fn(f); \ + print_array("Result of " # fn "(f):", ret_f); \ + MAYBE_LD_1(fn) +#define DO_2(fn) \ + dd = d[0]; \ + ret_d = fn(d, d); \ + print_array("Result of " # fn "(d, d):", ret_d); \ + ret_d = fn(dd, d); \ + print_array("Result of " # fn "(type, d):", ret_d); \ + ret_d = fn(d, dd); \ + print_array("Result of " # fn "(d, type):", ret_d); \ + ff = f[0]; \ + ret_f = fn(f, f); \ + print_array("Result of " # fn "(f, f):", ret_f); \ + ret_f = fn(ff, f); \ + print_array("Result of " # fn "(type, f):", ret_f); \ + ret_f = fn(f, ff); \ + print_array("Result of " # fn "(f, type):", ret_f); \ + MAYBE_LD_2(fn) + + DO_1(acos) + DO_1(asin) + DO_1(atan) + DO_2(atan2) + DO_1(cos) + DO_1(cosh) + DO_1(exp) + DO_1(log) + DO_1(log10) + DO_2(pow) + DO_1(sin) + DO_1(sinh) + DO_1(sqrt) + DO_1(tan) + DO_1(tanh) + std::cout << std::endl; + + return 0; +} diff --git a/tests/vectortest.cpp b/tests/vectortest.cpp new file mode 100644 index 0000000..c88be2b --- /dev/null +++ b/tests/vectortest.cpp @@ -0,0 +1,244 @@ +#include +#include +#include +#include "testframework.h" + +class myclass{ +private: + int num; +public: + myclass() : num(0) { } + myclass(int i): num(i) { } + ~myclass() { + std::cout << "Calling destructor with num: " << num << std::endl; + num = -1; + } + + void printout() const { + std::cout << num << std::endl; + } + int getNum() const { + return num; + } + void setNum(int i){ + num = i; + } +}; + +bool canCompareConstNonConstIter() { + std::vector v; + v.push_back(5); + v.push_back(6); + v.push_back(7); + std::vector::const_iterator i = v.begin(); + std::vector::iterator j = v.begin(); + std::vector::iterator k = v.end(); + + if (i == i && i == j && j == i && j == j) { + // Do nothing + } else { + return false; + } + + if (i != i || i != j || j != i || j != j) { + return false; + } + + return true; +} + + +int main(){ + std::vector > ctest; + std::string stest; + ctest.push_back('t'); + + std::vector test; + std::vector test1; + unsigned int temp; + std::vector::iterator i,j; + + test.push_back(1); + test.push_back(2); + test.push_back(3); + test.push_back(4); + test.push_back(5); + + std::cout << "Element 0: " << test[0] << std::endl; + std::cout << "Element 1: " << test[1] << std::endl; + std::cout << "Element 2: " << test[2] << std::endl; + std::cout << "Element 3: " << test[3] << std::endl; + std::cout << "Element 4: " << test[4] << std::endl; + + test.pop_back(); + + std::cout << "Testing at(int)\n"; + std::cout << "Element 0: " << test.at(0) << std::endl; + std::cout << "Element 1: " << test.at(1) << std::endl; + std::cout << "Element 2: " << test.at(2) << std::endl; + std::cout << "Element 3: " << test.at(3) << std::endl; + for(i=test.begin(); i!=test.end(); i++){ + std::cout << "Element: " << *i << std::endl; + } + + std::cout << "Testing iterator insert\n"; + i = test.begin(); + ++i; + ++i; + i = test.insert(i, 12); + std::cout << "Return value points to: " << *i << ", should be 12\n"; + for(i=test.begin(); i!=test.end(); i++){ + std::cout << "Element: " << *i << std::endl; + } + + std::cout << "Testing iterator multi-insert\n"; + i = test.begin(); + ++i; + temp = 23; + test.insert(i, 3, temp); + for(i=test.begin(); i!=test.end(); i++){ + std::cout << "Element: " << *i << std::endl; + } + + + std::cout << "Testing iterator erase\n"; + i = test.begin(); + ++i; + ++i; + test.erase(i); + for(i=test.begin(); i!=test.end(); i++){ + std::cout << "Element: " << *i << std::endl; + } + + std::cout << "Testing iterator multierase\n"; + i = test.begin(); + j = test.begin(); + ++i; + ++i; + j+=4; + test.erase(i, j); + for(i=test.begin(); i!=test.end(); i++){ + std::cout << "Element: " << *i << std::endl; + } + + std::cout << "Testing iterator range insert\n"; + test1.clear(); + test1.insert(test1.begin(), test.begin(), test.end()); + std::cout << "The following should be the same as the above:\n"; + for(i=test.begin(); i!=test.end(); i++){ + std::cout << "Element: " << *i << std::endl; + } + + + std::cout << std::endl << "Testing vectors of pointers\n"; + + myclass m1(1); + myclass m2(2); + myclass m3(3); + myclass m4(4); + myclass m5(5); + + std::vector mcp; + mcp.push_back(&m1); + mcp.push_back(&m2); + mcp.push_back(&m3); + mcp.push_back(&m4); + mcp.push_back(&m5); + + mcp[0]->printout(); + mcp[1]->printout(); + mcp[2]->printout(); + mcp[3]->printout(); + mcp[4]->printout(); + + std::vector::iterator mcpi; + mcpi = mcp.end(); + while(mcpi != mcp.begin()){ + --mcpi; + (*mcpi)->printout(); + } + + mcp.pop_back(); + mcpi = mcp.end(); + while(mcpi != mcp.begin()){ + --mcpi; + (*mcpi)->printout(); + } + + mcp.clear(); + + std::cout << "Pushing back instances of myclass created with new" << std::endl; + + mcp.push_back(new myclass()); + mcp.push_back(new myclass()); + mcp.push_back(new myclass()); + mcp.push_back(new myclass()); + mcp.push_back(new myclass()); + mcp.push_back(new myclass()); + + std::cout << "Deleting instances of myclass directly from iterator" << std::endl; + + for(mcpi = mcp.begin(); mcpi != mcp.end(); ++mcpi){ + std::cout << "Deleteing myclass instance" << std::endl; + delete *mcpi; + } + + std::cout << "Delete completed on myclass instances" << std::endl; + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 4" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + std::cout << "Testing resize()" << std::endl; + mcp.resize(1, &m5); + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 1" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + mcp.resize(95, &m4); + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 95" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + + mcp.resize(1, &m4); + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 1" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + mcp.push_back(&m3); + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 2" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + for(int j = 0; j < 100; ++j){ + mcp.push_back(&m2); + } + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 102" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + myclass * m6 = new myclass(6); + + mcp.push_back(m6); + + std::cout << "The following two lines should be identical:" << std::endl; + std::cout << "Vector size: 103" << std::endl; + std::cout << "Vector size: " << mcp.size() << std::endl; + + mcp.clear(); + delete m6; + + TestFramework::init(); + + TestFramework::AssertReturns(canCompareConstNonConstIter, true); + + TestFramework::results(); + + return 0; +} diff --git a/tests/wchartest.cpp b/tests/wchartest.cpp new file mode 100644 index 0000000..2792e94 --- /dev/null +++ b/tests/wchartest.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +int main(){ + setlocale(LC_ALL, "en_US.utf8"); + + std::wcout.imbue( std::locale("en_US.utf8") ); + + std::cout << "Starting wchar test" << std::endl; + std::wcout << "Test of wcout output" << std::endl; + + std::wstring test; + test = L"This is a test of wstring"; + std::wcout << test << std::endl; + + std::wcin >> test; + std::wcout << test << std::endl; + std::wcin >> test; + std::wcout << test << std::endl; + + + return 0; +}

+ +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-end + diff --git a/extra/locale/collation/de_AT b/extra/locale/collation/de_AT new file mode 100644 index 0000000..5314a57 --- /dev/null +++ b/extra/locale/collation/de_AT @@ -0,0 +1,2 @@ +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" diff --git a/extra/locale/collation/de_BE b/extra/locale/collation/de_BE new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/de_BE @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/de_CH b/extra/locale/collation/de_CH new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/de_CH @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/de_DE b/extra/locale/collation/de_DE new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/de_DE @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/de_LU b/extra/locale/collation/de_LU new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/de_LU @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/el_GR b/extra/locale/collation/el_GR new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/el_GR @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_AU b/extra/locale/collation/en_AU new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/en_AU @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_BW b/extra/locale/collation/en_BW new file mode 100644 index 0000000..a7e9285 --- /dev/null +++ b/extra/locale/collation/en_BW @@ -0,0 +1 @@ +copy "en_ZA" diff --git a/extra/locale/collation/en_CA b/extra/locale/collation/en_CA new file mode 100644 index 0000000..ab4b690 --- /dev/null +++ b/extra/locale/collation/en_CA @@ -0,0 +1,2061 @@ + +% Base collation scheme: 1994-03-22 + +% Ordering algorithm: +% 1. Spaces and hyphen (but not soft +% hyphen) before punctuation +% characters, punctuation characters +% before numbers, +% numbers before letters. +% 2. Letters with diacritical marks are +% members of equivalence classes +% 3. A distinction is made with regards +% to case as noted below. +% 4. Special characters are ignored +% when comparing letters, but then +% they are considered +% 5. The alphabets are sorted in order +% of first appearance in ISO 10646: +% Latin, Greek, Cyrillic, etc. +% +% According to Greek specifications, +% the steps 2. and 3. above are reversed +% for the Greek script + +% collating symbols + +% The collating symbol naming is +% mostly taken from ISO 10646-1, +% for example the case and accent +% names are from this standard. + +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +% and +% are for cases like Danish +% and Spanish being treated +% as one letter. + +% The ...... collating +% symbols have defined weights as +% the last character in a group of +% Latin letters. They are used +% to specify deltas by locales using +% a locale as the default ordering +% and by "replace-after" statements +% specifying the changed placement +% in an ordering of a character. + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +% letter;accent;case;specials + +order_start forward;backward;forward;position + +% or letters first: + + + + + + +% Accents: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ;;;IGNORE + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; +<"=> IGNORE;IGNORE;IGNORE;<"=> + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; +UNDEFINED IGNORE;IGNORE;IGNORE + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + ;IGNORE;IGNORE;IGNORE + +% Arabic collating + + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + IGNORE;IGNORE;IGNORE; + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + IGNORE;IGNORE;;IGNORE + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +% katakana/hiragana sorting +% base is katakana, as this is present in most charsets +% normal before voiced before semi-voiced +% small vocals before normal vocals +% katakana before hiragana + + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + ;;IGNORE;IGNORE + +order_end + diff --git a/extra/locale/collation/en_DK b/extra/locale/collation/en_DK new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/en_DK @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_GB b/extra/locale/collation/en_GB new file mode 100644 index 0000000..5314a57 --- /dev/null +++ b/extra/locale/collation/en_GB @@ -0,0 +1,2 @@ +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" diff --git a/extra/locale/collation/en_HK b/extra/locale/collation/en_HK new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/en_HK @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_IE b/extra/locale/collation/en_IE new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/en_IE @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_IN b/extra/locale/collation/en_IN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/en_IN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/en_NZ b/extra/locale/collation/en_NZ new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/en_NZ @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_PH b/extra/locale/collation/en_PH new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/en_PH @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/en_SG b/extra/locale/collation/en_SG new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/en_SG @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/en_US b/extra/locale/collation/en_US new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/en_US @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/en_ZA b/extra/locale/collation/en_ZA new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/en_ZA @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/en_ZW b/extra/locale/collation/en_ZW new file mode 100644 index 0000000..a7e9285 --- /dev/null +++ b/extra/locale/collation/en_ZW @@ -0,0 +1 @@ +copy "en_ZA" diff --git a/extra/locale/collation/eo_EO b/extra/locale/collation/eo_EO new file mode 100644 index 0000000..c8057f5 --- /dev/null +++ b/extra/locale/collation/eo_EO @@ -0,0 +1,49 @@ +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE % Ĉ +reorder-after + ;;;IGNORE % ĉ +reorder-after + ;;;IGNORE % Ĝ +reorder-after + ;;;IGNORE % ĝ +reorder-after + ;;;IGNORE % Ĥ +reorder-after + ;;;IGNORE % ĥ +reorder-after + ;;;IGNORE % Ĵ +reorder-after + ;;;IGNORE % ĵ +reorder-after + ;;;IGNORE % Ŝ +reorder-after + ;;;IGNORE % ŝ +reorder-after + ;;;IGNORE % Ŭ +reorder-after + ;;;IGNORE % ŭ + +reorder-end + diff --git a/extra/locale/collation/eu_ES b/extra/locale/collation/eu_ES new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/eu_ES @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/fa_IR b/extra/locale/collation/fa_IR new file mode 100644 index 0000000..a171591 --- /dev/null +++ b/extra/locale/collation/fa_IR @@ -0,0 +1,185 @@ +copy "iso14651_t1" + +% The Persian alphabet order is: ALEF WITH MADDA ABOVE, ALEF, HAMZA (all +% kinds), BEH, PEH, TEH, JEEM, TCHEH, HAH, KHAH, DAL, THAL, REH, ZAIN, JEH, +% SEEN, SHEEN, SAD, DAD, TAH, ZAH, AIN, GHAIN, FEH, QAF, KAF, GAF, LAM, +% MEEM, NOON, WAW, HEH, YEH. +% The various kind of HAMZA are sorted as ALEF WITH HAMZA ABOVE, ALEF WITH +% HAMZA BELOW, WAW WITH HAMZA ABOVE, YEH WITH HAMZA ABOVE. + +collating-symbol % accent hamza over yeh +collating-symbol % dotless +collating-symbol % with dots over +collating-symbol % with wasla over + +collating-symbol +collating-symbol + +% Alternate representations displayed the same +collating-symbol +collating-symbol + +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +reorder-after + + + + + + + + + + +reorder-after + + + +reorder-after + + + + +reorder-after + + + +% Persian uses fatha, kasra, damma, fathatan, kasratan, dammatan order. + +reorder-after + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + +reorder-after + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + IGNORE;IGNORE;IGNORE; % + +% Persian digits are sorted before Arabic ones: they are the basic forms. +reorder-after + <0>;;;IGNORE + <0>;;;IGNORE + <1>;;;IGNORE + <1>;;;IGNORE + <2>;;;IGNORE + <2>;;;IGNORE + <3>;;;IGNORE + <3>;;;IGNORE + <4>;;;IGNORE + <4>;;;IGNORE + <5>;;;IGNORE + <5>;;;IGNORE + <6>;;;IGNORE + <6>;;;IGNORE + <7>;;;IGNORE + <7>;;;IGNORE + <8>;;;IGNORE + <8>;;;IGNORE + <9>;;;IGNORE + <9>;;;IGNORE + +% And then the letters: + ;;;IGNORE % Alef With Madda Above + ;;;IGNORE + ;;;IGNORE % Alef + ;;;IGNORE % Alef Wasla + ;;;IGNORE % Hamza + ;;;IGNORE % Alef With Hamza Above + ;;;IGNORE + ;;;IGNORE % Alef With Hamza Below + ;;;IGNORE + ;;;IGNORE % Waw With Hamza Above + ;;;IGNORE + ;;;IGNORE % Yeh With Hamza Above + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE % Keheh + ;;;IGNORE % Kaf +reorder-after + ;;;IGNORE % Heh + ;;;IGNORE % Teh Marbuta + ;;;IGNORE % Heh With Yeh Above + ;;;IGNORE % Farsi Yeh + ;;;IGNORE % Alef Maksura + ;;;IGNORE % Yeh + +% Finally the letters in Presentation Form: +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + "";"";"";IGNORE % Rial Sign +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-end + diff --git a/extra/locale/collation/fo_FO b/extra/locale/collation/fo_FO new file mode 100644 index 0000000..b7628e7 --- /dev/null +++ b/extra/locale/collation/fo_FO @@ -0,0 +1 @@ +copy "da_DK" diff --git a/extra/locale/collation/fr_BE b/extra/locale/collation/fr_BE new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/fr_BE @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/fr_CA b/extra/locale/collation/fr_CA new file mode 100644 index 0000000..c911095 --- /dev/null +++ b/extra/locale/collation/fr_CA @@ -0,0 +1 @@ +copy "en_CA" diff --git a/extra/locale/collation/fr_CH b/extra/locale/collation/fr_CH new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/fr_CH @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/fr_FR b/extra/locale/collation/fr_FR new file mode 100644 index 0000000..5314a57 --- /dev/null +++ b/extra/locale/collation/fr_FR @@ -0,0 +1,2 @@ +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" diff --git a/extra/locale/collation/fr_LU b/extra/locale/collation/fr_LU new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/fr_LU @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/ga_IE b/extra/locale/collation/ga_IE new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/ga_IE @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/gd_GB b/extra/locale/collation/gd_GB new file mode 100644 index 0000000..d66184e --- /dev/null +++ b/extra/locale/collation/gd_GB @@ -0,0 +1 @@ +copy "en_DK" diff --git a/extra/locale/collation/gl_ES b/extra/locale/collation/gl_ES new file mode 100644 index 0000000..09fd11b --- /dev/null +++ b/extra/locale/collation/gl_ES @@ -0,0 +1 @@ +copy "es_ES" diff --git a/extra/locale/collation/gv_GB b/extra/locale/collation/gv_GB new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/gv_GB @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/he_IL b/extra/locale/collation/he_IL new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/he_IL @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/hi_IN b/extra/locale/collation/hi_IN new file mode 100644 index 0000000..35ae3c6 --- /dev/null +++ b/extra/locale/collation/hi_IN @@ -0,0 +1,4 @@ + +% Copy the template from ISO/IEC 14651 +copy "iso14651_t1" + diff --git a/extra/locale/collation/hu_HU b/extra/locale/collation/hu_HU new file mode 100644 index 0000000..e87bb76 --- /dev/null +++ b/extra/locale/collation/hu_HU @@ -0,0 +1,357 @@ +copy "iso14651_t1" + +%% a b c cs d dz dzs e f g gy h i j k l ly m n ny o o: p q +%% r s sz t ty u u: v w x y z zs +%% +%% a' e' i' o' u' are sorted as if they were unaccented +%% o" and u" are sorted as if they were o: and u: + +collating-symbol +collating-symbol + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" +collating-element from "" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +reorder-after + + + + + + +reorder-after + + + + + + +reorder-after + +reorder-after + + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + +reorder-after + + +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE +reorder-after + ;;;IGNORE + ;;;IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + "";"";"";IGNORE + +reorder-end + diff --git a/extra/locale/collation/hy_AM b/extra/locale/collation/hy_AM new file mode 100644 index 0000000..1132128 --- /dev/null +++ b/extra/locale/collation/hy_AM @@ -0,0 +1,91 @@ + +% Armenian sorting is not yet on iso14651_t1 + +copy "iso14651_t1" + +script + +order_start ;forward;forward;forward;forward,position + + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % + ;;;IGNORE % +order-end + +reorder-sections-after + +reorder-sections-end + diff --git a/extra/locale/collation/id_ID b/extra/locale/collation/id_ID new file mode 100644 index 0000000..3738ee3 --- /dev/null +++ b/extra/locale/collation/id_ID @@ -0,0 +1 @@ +copy "iso14651_t1" diff --git a/extra/locale/collation/iso14651_t1 b/extra/locale/collation/iso14651_t1 new file mode 100644 index 0000000..b44d34a --- /dev/null +++ b/extra/locale/collation/iso14651_t1 @@ -0,0 +1,1495 @@ + +# Dclaration des systmes d'criture / Declaration of scripts +script +script +script +script +script +script +script +script + +# Dclaration des symboles internes / Declaration of internal symbols +# +# SYMB N Expl. +# +collating-symbol +# +# / +# +# +collating-symbol # 2 normal --> voir/see +collating-symbol # 3 isol. +collating-symbol # 4 final +collating-symbol # 5 initial +collating-symbol # 6 medial/mdian +# +collating-symbol # 7 minuscule/minuscule (bas de casse/lower case) +collating-symbol # 8 infrieur min./subscript min. (indice/index) +collating-symbol # 9 supr. min./superscript min. (exposant/exponent) +collating-symbol # 10 capitale/capital (haut de casse/upper case) +collating-symbol # 8 minuscule grecque/Greek lower case +collating-symbol # 11 infrieur en capitale/subscript capital +collating-symbol # 12 suprieur en capitale/superscript capital +# +# / +# +collating-symbol # 13 accent madda +collating-symbol # 14 accent hamza +collating-symbol # 14-1 accent hamza/waw +collating-symbol # 14-2 accent hamza under / hamza souscrit +collating-symbol # 14-3 accent under yeh / accent souscrit du ya' +collating-symbol # 14-4 accent hamza/yeh barree +# +collating-symbol # 15 de base/basic (non accentu/non-accented) +# +collating-symbol # 16 particulier/peculiar +collating-symbol # 17 ligature/ligature +collating-symbol # 18 accent aigu/acute accent +collating-symbol # 20 accent grave/grave accent +collating-symbol # 21 brve/breve +collating-symbol # 22 accent circonflexe/circumflex accent +collating-symbol # 23 caron/caron +collating-symbol # 24 rond suprieur/ring above +collating-symbol # 25 trma/diaeresis (ou/or umlaut) +collating-symbol # 26 double ac. aigu/double acute ac. +collating-symbol # 27 tilde/tilde +collating-symbol # 28 point/dot +collating-symbol # 29 barre oblique/oblique +collating-symbol # 30 cdille/cedilla +collating-symbol # 31 ogonek/ogonek +collating-symbol # 32 macron/macron +# +# GREC +# +collating-symbol # accent aigu/tonos/acute accent +collating-symbol # trma/dialytica/diaeresis +collating-symbol # dialytika tonos +# +collating-symbol <0> +collating-symbol <1> +collating-symbol <2> +collating-symbol <3> +collating-symbol <4> +collating-symbol <5> +collating-symbol <6> +collating-symbol <7> +collating-symbol <8> +collating-symbol <9> +# +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol