From 644fab7770a2f244fb3dae110fff456918e5c1a2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 16 Jul 2020 11:01:06 -0700 Subject: Clean out the obsolete copy of marisa-trie. In preparation for the resurrection of this project and a snap to the current version. Bug: http://b/161375689 Test: treehugger Change-Id: I95d01e670be89dc1fa739666a2b9df397633d77d --- AUTHORS | 1 - Android.mk | 70 - COPYING | 10 - ChangeLog | 0 INSTALL | 237 - MODULE_LICENSE_BSD_LIKE | 0 Makefile.am | 5 - Makefile.in | 665 -- NEWS | 0 README | 55 - README.android | 20 - aclocal.m4 | 951 --- android_diff.txt | 519 -- configure | 6630 -------------------- configure.ac | 41 - depcomp | 589 -- install-sh | 519 -- lib/Makefile.am | 44 - lib/Makefile.in | 746 --- lib/marisa.h | 6 - lib/marisa/base.cc | 21 - lib/marisa/base.h | 233 - lib/marisa/bitvector.cc | 569 -- lib/marisa/bitvector.h | 97 - lib/marisa/cell.h | 46 - lib/marisa/container.h | 62 - lib/marisa/intvector.cc | 138 - lib/marisa/intvector.h | 98 - lib/marisa/io.h | 8 - lib/marisa/key.h | 66 - lib/marisa/mapper.cc | 166 - lib/marisa/mapper.h | 62 - lib/marisa/marisa-string.h | 154 - lib/marisa/popcount.h | 38 - lib/marisa/progress.cc | 55 - lib/marisa/progress.h | 63 - lib/marisa/query.h | 61 - lib/marisa/range.h | 88 - lib/marisa/rank.h | 77 - lib/marisa/reader.cc | 91 - lib/marisa/reader.h | 59 - lib/marisa/tail.cc | 205 - lib/marisa/tail.h | 72 - lib/marisa/trie-build.cc | 328 - lib/marisa/trie-c.cc | 344 - lib/marisa/trie-inline.h | 351 -- lib/marisa/trie-search.cc | 753 --- lib/marisa/trie.cc | 161 - lib/marisa/trie.h | 385 -- lib/marisa/vector-inline.h | 216 - lib/marisa/vector.h | 127 - lib/marisa/writer.cc | 103 - lib/marisa/writer.h | 59 - missing | 367 -- tests/Makefile.am | 32 - tests/Makefile.in | 590 -- tests/assert.h | 24 - tests/c-test.c | 209 - tests/io-test.cc | 236 - tests/tail-test.cc | 242 - tests/trie-test.cc | 645 -- tests/unit-test.cc | 459 -- tests/vector-test.cc | 299 - tools/Makefile.am | 26 - tools/Makefile.in | 524 -- tools/cmdopt.c | 298 - tools/cmdopt.h | 58 - tools/marisa-benchmark.cc | 425 -- tools/marisa-build.cc | 189 - tools/marisa-find.cc | 204 - tools/marisa-lookup.cc | 105 - tools/marisa-predict.cc | 159 - v0_1_5/lib/Makefile.am | 45 - v0_1_5/lib/Makefile.in | 712 --- v0_1_5/lib/marisa_alpha.h | 6 - v0_1_5/lib/marisa_alpha/base.cc | 21 - v0_1_5/lib/marisa_alpha/base.h | 215 - v0_1_5/lib/marisa_alpha/bitvector.cc | 571 -- v0_1_5/lib/marisa_alpha/bitvector.h | 97 - v0_1_5/lib/marisa_alpha/cell.h | 46 - v0_1_5/lib/marisa_alpha/container.h | 62 - v0_1_5/lib/marisa_alpha/intvector.cc | 138 - v0_1_5/lib/marisa_alpha/intvector.h | 98 - v0_1_5/lib/marisa_alpha/io.h | 8 - v0_1_5/lib/marisa_alpha/key.h | 68 - v0_1_5/lib/marisa_alpha/mapper.cc | 170 - v0_1_5/lib/marisa_alpha/mapper.h | 63 - v0_1_5/lib/marisa_alpha/marisa-string.h | 154 - v0_1_5/lib/marisa_alpha/popcount.h | 38 - v0_1_5/lib/marisa_alpha/progress.cc | 56 - v0_1_5/lib/marisa_alpha/progress.h | 63 - v0_1_5/lib/marisa_alpha/query.h | 61 - v0_1_5/lib/marisa_alpha/range.h | 88 - v0_1_5/lib/marisa_alpha/rank.h | 77 - v0_1_5/lib/marisa_alpha/reader.cc | 95 - v0_1_5/lib/marisa_alpha/reader.h | 60 - v0_1_5/lib/marisa_alpha/tail.cc | 205 - v0_1_5/lib/marisa_alpha/tail.h | 73 - v0_1_5/lib/marisa_alpha/trie-build.cc | 342 - v0_1_5/lib/marisa_alpha/trie-c.cc | 381 -- v0_1_5/lib/marisa_alpha/trie-inline.h | 360 -- v0_1_5/lib/marisa_alpha/trie-search.cc | 784 --- v0_1_5/lib/marisa_alpha/trie.cc | 161 - v0_1_5/lib/marisa_alpha/trie.h | 388 -- v0_1_5/lib/marisa_alpha/vector-inline.h | 216 - v0_1_5/lib/marisa_alpha/vector.h | 127 - v0_1_5/lib/marisa_alpha/writer.cc | 107 - v0_1_5/lib/marisa_alpha/writer.h | 60 - v0_1_5/tests/Makefile.am | 32 - v0_1_5/tests/Makefile.in | 663 -- v0_1_5/tests/assert.h | 24 - v0_1_5/tests/c-test.c | 223 - v0_1_5/tests/io-test.cc | 237 - v0_1_5/tests/tail-test.cc | 246 - v0_1_5/tests/trie-test.cc | 665 -- v0_1_5/tests/unit-test.cc | 463 -- v0_1_5/tests/vector-test.cc | 303 - v0_1_5/tools/Makefile.am | 26 - v0_1_5/tools/Makefile.in | 599 -- v0_1_5/tools/cmdopt.c | 298 - v0_1_5/tools/cmdopt.h | 58 - v0_1_5/tools/marisa_alpha-benchmark.cc | 425 -- v0_1_5/tools/marisa_alpha-build.cc | 189 - v0_1_5/tools/marisa_alpha-find.cc | 205 - v0_1_5/tools/marisa_alpha-lookup.cc | 105 - v0_1_5/tools/marisa_alpha-predict.cc | 160 - v0_1_5/vs2008/c-test/c-test.vcproj | 200 - v0_1_5/vs2008/io-test/io-test.vcproj | 199 - .../vs2008/libmarisa_alpha/libmarisa_alpha.vcproj | 303 - .../marisa_alpha-benchmark.vcproj | 203 - .../marisa_alpha-build/marisa_alpha-build.vcproj | 203 - .../marisa_alpha-find/marisa_alpha-find.vcproj | 203 - .../marisa_alpha-lookup/marisa_alpha-lookup.vcproj | 203 - .../marisa_alpha-predict.vcproj | 203 - v0_1_5/vs2008/tail-test/tail-test.vcproj | 199 - v0_1_5/vs2008/trie-test/trie-test.vcproj | 199 - v0_1_5/vs2008/unit-test/unit-test.vcproj | 199 - v0_1_5/vs2008/vector-test/vector-test.vcproj | 199 - v0_1_5/vs2008/vs2008.sln | 119 - v0_1_5/vs2008/vs2008.suo | Bin 25600 -> 0 bytes 140 files changed, 35324 deletions(-) delete mode 100644 AUTHORS delete mode 100644 Android.mk delete mode 100644 COPYING delete mode 100644 ChangeLog delete mode 100644 INSTALL delete mode 100644 MODULE_LICENSE_BSD_LIKE delete mode 100644 Makefile.am delete mode 100644 Makefile.in delete mode 100644 NEWS delete mode 100644 README delete mode 100644 README.android delete mode 100644 aclocal.m4 delete mode 100644 android_diff.txt delete mode 100755 configure delete mode 100644 configure.ac delete mode 100755 depcomp delete mode 100755 install-sh delete mode 100644 lib/Makefile.am delete mode 100644 lib/Makefile.in delete mode 100644 lib/marisa.h delete mode 100644 lib/marisa/base.cc delete mode 100644 lib/marisa/base.h delete mode 100644 lib/marisa/bitvector.cc delete mode 100644 lib/marisa/bitvector.h delete mode 100644 lib/marisa/cell.h delete mode 100644 lib/marisa/container.h delete mode 100644 lib/marisa/intvector.cc delete mode 100644 lib/marisa/intvector.h delete mode 100644 lib/marisa/io.h delete mode 100644 lib/marisa/key.h delete mode 100644 lib/marisa/mapper.cc delete mode 100644 lib/marisa/mapper.h delete mode 100644 lib/marisa/marisa-string.h delete mode 100644 lib/marisa/popcount.h delete mode 100644 lib/marisa/progress.cc delete mode 100644 lib/marisa/progress.h delete mode 100644 lib/marisa/query.h delete mode 100644 lib/marisa/range.h delete mode 100644 lib/marisa/rank.h delete mode 100644 lib/marisa/reader.cc delete mode 100644 lib/marisa/reader.h delete mode 100644 lib/marisa/tail.cc delete mode 100644 lib/marisa/tail.h delete mode 100644 lib/marisa/trie-build.cc delete mode 100644 lib/marisa/trie-c.cc delete mode 100644 lib/marisa/trie-inline.h delete mode 100644 lib/marisa/trie-search.cc delete mode 100644 lib/marisa/trie.cc delete mode 100644 lib/marisa/trie.h delete mode 100644 lib/marisa/vector-inline.h delete mode 100644 lib/marisa/vector.h delete mode 100644 lib/marisa/writer.cc delete mode 100644 lib/marisa/writer.h delete mode 100755 missing delete mode 100644 tests/Makefile.am delete mode 100644 tests/Makefile.in delete mode 100644 tests/assert.h delete mode 100644 tests/c-test.c delete mode 100644 tests/io-test.cc delete mode 100644 tests/tail-test.cc delete mode 100644 tests/trie-test.cc delete mode 100644 tests/unit-test.cc delete mode 100644 tests/vector-test.cc delete mode 100644 tools/Makefile.am delete mode 100644 tools/Makefile.in delete mode 100644 tools/cmdopt.c delete mode 100644 tools/cmdopt.h delete mode 100644 tools/marisa-benchmark.cc delete mode 100644 tools/marisa-build.cc delete mode 100644 tools/marisa-find.cc delete mode 100644 tools/marisa-lookup.cc delete mode 100644 tools/marisa-predict.cc delete mode 100644 v0_1_5/lib/Makefile.am delete mode 100644 v0_1_5/lib/Makefile.in delete mode 100644 v0_1_5/lib/marisa_alpha.h delete mode 100644 v0_1_5/lib/marisa_alpha/base.cc delete mode 100644 v0_1_5/lib/marisa_alpha/base.h delete mode 100644 v0_1_5/lib/marisa_alpha/bitvector.cc delete mode 100644 v0_1_5/lib/marisa_alpha/bitvector.h delete mode 100644 v0_1_5/lib/marisa_alpha/cell.h delete mode 100644 v0_1_5/lib/marisa_alpha/container.h delete mode 100644 v0_1_5/lib/marisa_alpha/intvector.cc delete mode 100644 v0_1_5/lib/marisa_alpha/intvector.h delete mode 100644 v0_1_5/lib/marisa_alpha/io.h delete mode 100644 v0_1_5/lib/marisa_alpha/key.h delete mode 100644 v0_1_5/lib/marisa_alpha/mapper.cc delete mode 100644 v0_1_5/lib/marisa_alpha/mapper.h delete mode 100644 v0_1_5/lib/marisa_alpha/marisa-string.h delete mode 100644 v0_1_5/lib/marisa_alpha/popcount.h delete mode 100644 v0_1_5/lib/marisa_alpha/progress.cc delete mode 100644 v0_1_5/lib/marisa_alpha/progress.h delete mode 100644 v0_1_5/lib/marisa_alpha/query.h delete mode 100644 v0_1_5/lib/marisa_alpha/range.h delete mode 100644 v0_1_5/lib/marisa_alpha/rank.h delete mode 100644 v0_1_5/lib/marisa_alpha/reader.cc delete mode 100644 v0_1_5/lib/marisa_alpha/reader.h delete mode 100644 v0_1_5/lib/marisa_alpha/tail.cc delete mode 100644 v0_1_5/lib/marisa_alpha/tail.h delete mode 100644 v0_1_5/lib/marisa_alpha/trie-build.cc delete mode 100644 v0_1_5/lib/marisa_alpha/trie-c.cc delete mode 100644 v0_1_5/lib/marisa_alpha/trie-inline.h delete mode 100644 v0_1_5/lib/marisa_alpha/trie-search.cc delete mode 100644 v0_1_5/lib/marisa_alpha/trie.cc delete mode 100644 v0_1_5/lib/marisa_alpha/trie.h delete mode 100644 v0_1_5/lib/marisa_alpha/vector-inline.h delete mode 100644 v0_1_5/lib/marisa_alpha/vector.h delete mode 100644 v0_1_5/lib/marisa_alpha/writer.cc delete mode 100644 v0_1_5/lib/marisa_alpha/writer.h delete mode 100644 v0_1_5/tests/Makefile.am delete mode 100644 v0_1_5/tests/Makefile.in delete mode 100644 v0_1_5/tests/assert.h delete mode 100644 v0_1_5/tests/c-test.c delete mode 100644 v0_1_5/tests/io-test.cc delete mode 100644 v0_1_5/tests/tail-test.cc delete mode 100644 v0_1_5/tests/trie-test.cc delete mode 100644 v0_1_5/tests/unit-test.cc delete mode 100644 v0_1_5/tests/vector-test.cc delete mode 100644 v0_1_5/tools/Makefile.am delete mode 100644 v0_1_5/tools/Makefile.in delete mode 100644 v0_1_5/tools/cmdopt.c delete mode 100644 v0_1_5/tools/cmdopt.h delete mode 100644 v0_1_5/tools/marisa_alpha-benchmark.cc delete mode 100644 v0_1_5/tools/marisa_alpha-build.cc delete mode 100644 v0_1_5/tools/marisa_alpha-find.cc delete mode 100644 v0_1_5/tools/marisa_alpha-lookup.cc delete mode 100644 v0_1_5/tools/marisa_alpha-predict.cc delete mode 100644 v0_1_5/vs2008/c-test/c-test.vcproj delete mode 100644 v0_1_5/vs2008/io-test/io-test.vcproj delete mode 100644 v0_1_5/vs2008/libmarisa_alpha/libmarisa_alpha.vcproj delete mode 100644 v0_1_5/vs2008/marisa_alpha-benchmark/marisa_alpha-benchmark.vcproj delete mode 100644 v0_1_5/vs2008/marisa_alpha-build/marisa_alpha-build.vcproj delete mode 100644 v0_1_5/vs2008/marisa_alpha-find/marisa_alpha-find.vcproj delete mode 100644 v0_1_5/vs2008/marisa_alpha-lookup/marisa_alpha-lookup.vcproj delete mode 100644 v0_1_5/vs2008/marisa_alpha-predict/marisa_alpha-predict.vcproj delete mode 100644 v0_1_5/vs2008/tail-test/tail-test.vcproj delete mode 100644 v0_1_5/vs2008/trie-test/trie-test.vcproj delete mode 100644 v0_1_5/vs2008/unit-test/unit-test.vcproj delete mode 100644 v0_1_5/vs2008/vector-test/vector-test.vcproj delete mode 100644 v0_1_5/vs2008/vs2008.sln delete mode 100644 v0_1_5/vs2008/vs2008.suo diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index c7ea22c..0000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Susumu Yata diff --git a/Android.mk b/Android.mk deleted file mode 100644 index 7bcf30c..0000000 --- a/Android.mk +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += $(LOCAL_PATH)/lib/marisa - -LOCAL_CPP_EXTENSION := .cc - -LOCAL_SRC_FILES := lib/marisa/base.cc \ - lib/marisa/intvector.cc \ - lib/marisa/progress.cc \ - lib/marisa/tail.cc \ - lib/marisa/trie.cc \ - lib/marisa/trie-search.cc \ - lib/marisa/bitvector.cc \ - lib/marisa/mapper.cc \ - lib/marisa/reader.cc \ - lib/marisa/trie-build.cc \ - lib/marisa/trie-c.cc \ - lib/marisa/writer.cc - -LOCAL_MODULE := libmarisa-trie-gnustl-rtti -LOCAL_MODULE_TAGS := optional - -LOCAL_NDK_STL_VARIANT := gnustl_static -LOCAL_SDK_VERSION := 14 - -include $(BUILD_STATIC_LIBRARY) - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += $(LOCAL_PATH)/v0_1_5/lib/marisa_alpha - -LOCAL_CPP_EXTENSION := .cc - -LOCAL_SRC_FILES := v0_1_5/lib/marisa_alpha/base.cc \ - v0_1_5/lib/marisa_alpha/bitvector.cc \ - v0_1_5/lib/marisa_alpha/intvector.cc \ - v0_1_5/lib/marisa_alpha/mapper.cc \ - v0_1_5/lib/marisa_alpha/progress.cc \ - v0_1_5/lib/marisa_alpha/reader.cc \ - v0_1_5/lib/marisa_alpha/tail.cc \ - v0_1_5/lib/marisa_alpha/trie-build.cc \ - v0_1_5/lib/marisa_alpha/trie.cc \ - v0_1_5/lib/marisa_alpha/trie-c.cc \ - v0_1_5/lib/marisa_alpha/trie-search.cc \ - v0_1_5/lib/marisa_alpha/writer.cc - -LOCAL_MODULE := libmarisa_alpha-trie-gnustl-rtti -LOCAL_MODULE_TAGS := optional - -LOCAL_CFLAGS := -frtti -fexceptions -LOCAL_NDK_STL_VARIANT := gnustl_static -LOCAL_SDK_VERSION := 14 - -include $(BUILD_STATIC_LIBRARY) diff --git a/COPYING b/COPYING deleted file mode 100644 index c303628..0000000 --- a/COPYING +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (c) 2010-2011, Susumu Yata -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -- Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e69de29..0000000 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index d3c5b40..0000000 --- a/INSTALL +++ /dev/null @@ -1,237 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007 Free Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - -Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 6. Often, you can also type `make uninstall' to remove the installed - files again. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - -Installation Names -================== - -By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - -`configure' recognizes the following options to control how it operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/MODULE_LICENSE_BSD_LIKE b/MODULE_LICENSE_BSD_LIKE deleted file mode 100644 index e69de29..0000000 diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 15ef58b..0000000 --- a/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -SUBDIRS = lib tools tests - -EXTRA_DIST = \ - vs2008/vs2008.* \ - vs2008/*/* diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index bb2135f..0000000 --- a/Makefile.in +++ /dev/null @@ -1,665 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = . -DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ - ChangeLog INSTALL NEWS depcomp install-sh missing -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir dist dist-all distcheck -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = lib tools tests -EXTRA_DIST = \ - vs2008/vs2008.* \ - vs2008/*/* - -all: all-recursive - -.SUFFIXES: -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done - -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r "$(distdir)" -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-lzma: distdir - tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lzma*) \ - lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ - *.tar.xz*) \ - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - test -d $(distdir)/_build || exit 0; \ - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ - && cd "$$am__cwd" \ - || exit 1 - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ - dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ - distclean distclean-generic distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-recursive uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/NEWS b/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/README b/README deleted file mode 100644 index 276ca36..0000000 --- a/README +++ /dev/null @@ -1,55 +0,0 @@ -- Project name - -marisa-trie -http://code.google.com/p/marisa-trie/ - -- Project summary - -Matching Algorithms with Recursively Implemented StorAge - -- Version - -0.1.4 - -- Description - -This project *marisa-trie* provides a C++ library *libmarisa* and command line tools *`marisa-*`* for building and operating nesting patricia tries. The brand-new dictionary structure is designed to be static and space efficient. Also, *marisa-trie* enables not only simple lookups but also prefix searches and predictive searches. - - * Prefix searches are to find keys from prefixes of a given query. - * Predictive searches are to find keys starting with a given query. - -The biggest advantage of *marisa-trie* is that it can build a considerably compact dictionary. See below for the size of dictionaries built with various trie implementations. - - * Input - * Source: enwiki-20110115-all-titles-in-ns0.gz - * Contents: all page titles of English Wikipedia (Jan. 2011) - * Number of keys: 8,279,325 - * Total size: 167,223,035 bytes (plain) / 46,344,646 bytes (gzipped) - -|| *Implementation* || *Size (bytes)* || *Remarks* || -|| darts-clone || 316,065,792 || Compacted double-array trie || -|| tx-trie || 107,119,864 || LOUDS-based trie || -|| *marisa-trie* || *42,688,271* || Nesting patricia trie || - - * Documentation (in Japanese) - * HowTo - * ListOfTools - * LibraryInterface - * BenchmarkResults - -- Version control system - -Subversion - -- Source code license - -New BSD License - -- Project labels - -Nesting -Patricia -Trie -Static -Dictionary -CPlusPlus diff --git a/README.android b/README.android deleted file mode 100644 index d656ae7..0000000 --- a/README.android +++ /dev/null @@ -1,20 +0,0 @@ -URL: http://marisa-trie.googlecode.com/files/marisa-0.1.4.tar.gz -Version: 0.1.4 -License: New BSD -License File: LICENSE - -Description: -C++ library providing implementation of Matching -Algorithm with Recursively Implemented StorAge (MARISA) -- static and -space-efficient trie data structure. - - -Homepage: http://code.google.com/p/marisa-trie/ - -Local Modifications: -- Remove files under vs2008/ as we don't need to build under - visual studio. -- Changes to string.h to avoid a header collision with the C - standard header with the same name. -- Apply patch 30551945 from alexgru to fix a critical bug. -- Remove all the exceptions: see for details. diff --git a/aclocal.m4 b/aclocal.m4 deleted file mode 100644 index e9b7b28..0000000 --- a/aclocal.m4 +++ /dev/null @@ -1,951 +0,0 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, -[m4_warning([this file was generated for autoconf 2.65. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) - -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 9 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 10 - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], UPC, [depcc="$UPC" am_compiler_list=], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 5 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 16 - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl -]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -]) - -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST(install_sh)]) - -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 6 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# ------------------------------ -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) - -# _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; -esac - -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT(yes)]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor `install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir - -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - diff --git a/android_diff.txt b/android_diff.txt deleted file mode 100644 index ecd9eac..0000000 --- a/android_diff.txt +++ /dev/null @@ -1,519 +0,0 @@ -diff --git a/Android.mk b/Android.mk -index 9da2083..9d5fc12 100644 ---- a/Android.mk -+++ b/Android.mk -@@ -16,11 +16,9 @@ LOCAL_PATH := $(call my-dir) - - include $(CLEAR_VARS) - --LOCAL_C_INCLUDES += $(LOCAL_PATH)/lib/marisa --LOCAL_CFLAGS += -fexceptions --LOCAL_CPP_EXTENSION := .cc -+LOCAL_C_INCLUDES += $(LOCAL_PATH)/lib/marisa external/stlport - --LOCAL_NDK_STL_VARIANT := gnustl_static -+LOCAL_CPP_EXTENSION := .cc - - LOCAL_SRC_FILES := lib/marisa/base.cc \ - lib/marisa/intvector.cc \ -@@ -36,7 +34,7 @@ LOCAL_SRC_FILES := lib/marisa/base.cc \ - lib/marisa/writer.cc - - LOCAL_MODULE := libmarisa-trie -+LOCAL_MODULE_TAGS := optional - --LOCAL_SDK_VERSION := 14 -- -+include external/stlport/libstlport.mk - include $(BUILD_STATIC_LIBRARY) -diff --git a/lib/marisa/base.h b/lib/marisa/base.h -index c2b2b07..731b24a 100644 ---- a/lib/marisa/base.h -+++ b/lib/marisa/base.h -@@ -13,6 +13,10 @@ - #include - #endif // __cplusplus - -+#if defined(__ANDROID__) -+#include -+#endif // __ANDROID__ -+ - #ifdef __cplusplus - extern "C" { - #endif // __cplusplus -@@ -183,8 +187,22 @@ class Exception { - }; - - // MARISA_THROW adds a filename and a line number to an exception. -+#if !defined(__ANDROID__) - #define MARISA_THROW(status) \ - (throw Exception(__FILE__, __LINE__, status)) -+#else -+ -+inline int android_log_exception(int status) { -+ char tmpbuf[100]; -+ snprintf(tmpbuf, sizeof(tmpbuf), "marisa exception: %d", status); -+ __android_log_write(ANDROID_LOG_ERROR, "marisa-trie", tmpbuf); -+ return 0; -+} -+ -+#define MARISA_THROW(status) \ -+ (android_log_exception(status)) -+ -+#endif // __ANDROID__ - - // MARISA_THROW_IF throws an exception with `status' if `cond' is true. - #define MARISA_THROW_IF(cond, status) \ -diff --git a/lib/marisa/reader.cc b/lib/marisa/reader.cc -index 6ecc797..df144ef 100644 ---- a/lib/marisa/reader.cc -+++ b/lib/marisa/reader.cc -@@ -80,11 +80,7 @@ void Reader::read_data(void *buf, std::size_t size) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else if (stream_ != NULL) { -- try { -- if (!stream_->read(static_cast(buf), size)) { -- MARISA_THROW(MARISA_IO_ERROR); -- } -- } catch (const std::ios_base::failure &) { -+ if (!stream_->read(static_cast(buf), size)) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else { -diff --git a/lib/marisa/trie-build.cc b/lib/marisa/trie-build.cc -index 4421432..fb7f072 100644 ---- a/lib/marisa/trie-build.cc -+++ b/lib/marisa/trie-build.cc -@@ -63,15 +63,9 @@ void Trie::build_trie(Vector > &keys, - build_trie(keys, static_cast(NULL), flags); - return; - } -- try { -- std::vector temp_key_ids(keys.size()); -- build_trie(keys, temp_key_ids.empty() ? NULL : &temp_key_ids[0], flags); -- key_ids->swap(temp_key_ids); -- } catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); -- } catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); -- } -+ std::vector temp_key_ids(keys.size()); -+ build_trie(keys, temp_key_ids.empty() ? NULL : &temp_key_ids[0], flags); -+ key_ids->swap(temp_key_ids); - } - - void Trie::build_trie(Vector > &keys, -@@ -168,7 +162,7 @@ void Trie::build_trie(Vector > &keys, - - template - void Trie::build_cur(Vector > &keys, -- Vector *terminals, Progress &progress) try { -+ Vector *terminals, Progress &progress) { - num_keys_ = sort_keys(keys); - louds_.push_back(true); - louds_.push_back(false); -@@ -261,10 +255,6 @@ void Trie::build_cur(Vector > &keys, - - build_terminals(keys, terminals); - keys.swap(&rest_keys); --} catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); --} catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); - } - - void Trie::build_next(Vector > &keys, -diff --git a/lib/marisa/trie-c.cc b/lib/marisa/trie-c.cc -index 00ebe80..9e11405 100644 ---- a/lib/marisa/trie-c.cc -+++ b/lib/marisa/trie-c.cc -@@ -79,106 +79,88 @@ marisa_status marisa_end(marisa_trie *h) { - - marisa_status marisa_build(marisa_trie *h, const char * const *keys, - size_t num_keys, const size_t *key_lengths, const double *key_weights, -- marisa_uint32 *key_ids, int flags) try { -+ marisa_uint32 *key_ids, int flags) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.build(keys, num_keys, key_lengths, key_weights, key_ids, flags); - h->mapper.clear(); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_mmap(marisa_trie *h, const char *filename, -- long offset, int whence) try { -+ long offset, int whence) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.mmap(&h->mapper, filename, offset, whence); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - --marisa_status marisa_map(marisa_trie *h, const void *ptr, size_t size) try { -+marisa_status marisa_map(marisa_trie *h, const void *ptr, size_t size) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.map(ptr, size); - h->mapper.clear(); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_load(marisa_trie *h, const char *filename, -- long offset, int whence) try { -+ long offset, int whence) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.load(filename, offset, whence); - h->mapper.clear(); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - --marisa_status marisa_fread(marisa_trie *h, FILE *file) try { -+marisa_status marisa_fread(marisa_trie *h, FILE *file) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.fread(file); - h->mapper.clear(); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - --marisa_status marisa_read(marisa_trie *h, int fd) try { -+marisa_status marisa_read(marisa_trie *h, int fd) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.read(fd); - h->mapper.clear(); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_save(const marisa_trie *h, const char *filename, -- int trunc_flag, long offset, int whence) try { -+ int trunc_flag, long offset, int whence) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.save(filename, trunc_flag != 0, offset, whence); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - --marisa_status marisa_fwrite(const marisa_trie *h, FILE *file) try { -+marisa_status marisa_fwrite(const marisa_trie *h, FILE *file) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.fwrite(file); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - --marisa_status marisa_write(const marisa_trie *h, int fd) try { -+marisa_status marisa_write(const marisa_trie *h, int fd) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.write(fd); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_restore(const marisa_trie *h, marisa_uint32 key_id, -- char *key_buf, size_t key_buf_size, size_t *key_length) try { -+ char *key_buf, size_t key_buf_size, size_t *key_length) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (key_length == NULL) { -@@ -186,12 +168,10 @@ marisa_status marisa_restore(const marisa_trie *h, marisa_uint32 key_id, - } - *key_length = h->trie.restore(key_id, key_buf, key_buf_size); - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_lookup(const marisa_trie *h, -- const char *ptr, size_t length, marisa_uint32 *key_id) try { -+ const char *ptr, size_t length, marisa_uint32 *key_id) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (key_id == NULL) { -@@ -203,14 +183,12 @@ marisa_status marisa_lookup(const marisa_trie *h, - *key_id = h->trie.lookup(ptr, length); - } - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_find(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_ids, size_t *key_lengths, -- size_t max_num_results, size_t *num_results) try { -+ size_t max_num_results, size_t *num_results) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (num_results == NULL) { -@@ -223,8 +201,6 @@ marisa_status marisa_find(const marisa_trie *h, - key_ids, key_lengths, max_num_results); - } - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_find_first(const marisa_trie *h, -@@ -262,7 +238,7 @@ marisa_status marisa_find_last(const marisa_trie *h, - marisa_status marisa_find_callback(const marisa_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_uint32, size_t), -- void *first_arg_to_callback) try { -+ void *first_arg_to_callback) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (callback == NULL) { -@@ -276,8 +252,6 @@ marisa_status marisa_find_callback(const marisa_trie *h, - ::FindCallback(callback, first_arg_to_callback)); - } - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_predict(const marisa_trie *h, -@@ -289,7 +263,7 @@ marisa_status marisa_predict(const marisa_trie *h, - - marisa_status marisa_predict_breadth_first(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, -- size_t max_num_results, size_t *num_results) try { -+ size_t max_num_results, size_t *num_results) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (num_results == NULL) { -@@ -303,13 +277,11 @@ marisa_status marisa_predict_breadth_first(const marisa_trie *h, - ptr, length, key_ids, NULL, max_num_results); - } - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_predict_depth_first(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, -- size_t max_num_results, size_t *num_results) try { -+ size_t max_num_results, size_t *num_results) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (num_results == NULL) { -@@ -323,14 +295,12 @@ marisa_status marisa_predict_depth_first(const marisa_trie *h, - ptr, length, key_ids, NULL, max_num_results); - } - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - marisa_status marisa_predict_callback(const marisa_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_uint32, const char *, size_t), -- void *first_arg_to_callback) try { -+ void *first_arg_to_callback) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (callback == NULL) { -@@ -344,8 +314,6 @@ marisa_status marisa_predict_callback(const marisa_trie *h, - ::PredictCallback(callback, first_arg_to_callback)); - } - return MARISA_OK; --} catch (const marisa::Exception &ex) { -- return ex.status(); - } - - size_t marisa_get_num_tries(const marisa_trie *h) { -diff --git a/lib/marisa/trie-inline.h b/lib/marisa/trie-inline.h -index 6b1e502..2c9218c 100644 ---- a/lib/marisa/trie-inline.h -+++ b/lib/marisa/trie-inline.h -@@ -179,7 +179,7 @@ inline bool Trie::find_child(UInt32 &node, T query, - } - - template --std::size_t Trie::find_callback_(T query, U callback) const try { -+std::size_t Trie::find_callback_(T query, U callback) const { - std::size_t count = 0; - UInt32 node = 0; - std::size_t pos = 0; -@@ -192,10 +192,6 @@ std::size_t Trie::find_callback_(T query, U callback) const try { - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return count; --} catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); --} catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); - } - - template -@@ -235,7 +231,7 @@ inline bool Trie::predict_child(UInt32 &node, T query, std::size_t &pos, - } - - template --std::size_t Trie::predict_callback_(T query, U callback) const try { -+std::size_t Trie::predict_callback_(T query, U callback) const { - std::string key; - UInt32 node = 0; - std::size_t pos = 0; -@@ -299,10 +295,6 @@ std::size_t Trie::predict_callback_(T query, U callback) const try { - ++stack_pos; - } - return count; --} catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); --} catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); - } - - inline UInt32 Trie::key_id_to_node(UInt32 key_id) const { -diff --git a/lib/marisa/trie-search.cc b/lib/marisa/trie-search.cc -index 1f35681..098e0b3 100644 ---- a/lib/marisa/trie-search.cc -+++ b/lib/marisa/trie-search.cc -@@ -247,30 +247,22 @@ std::size_t Trie::predict_depth_first( - - void Trie::restore_(UInt32 key_id, std::string *key) const { - const std::size_t start_pos = key->length(); -- try { -- UInt32 node = key_id_to_node(key_id); -- while (node != 0) { -- if (has_link(node)) { -- const std::size_t prev_pos = key->length(); -- if (has_trie()) { -- trie_->trie_restore(get_link(node), key); -- } else { -- tail_restore(node, key); -- } -- std::reverse(key->begin() + prev_pos, key->end()); -+ UInt32 node = key_id_to_node(key_id); -+ while (node != 0) { -+ if (has_link(node)) { -+ const std::size_t prev_pos = key->length(); -+ if (has_trie()) { -+ trie_->trie_restore(get_link(node), key); - } else { -- *key += labels_[node]; -+ tail_restore(node, key); - } -- node = get_parent(node); -- } -- std::reverse(key->begin() + start_pos, key->end()); -- } catch (const std::bad_alloc &) { -- key->resize(start_pos); -- MARISA_THROW(MARISA_MEMORY_ERROR); -- } catch (const std::length_error &) { -- key->resize(start_pos); -- MARISA_THROW(MARISA_SIZE_ERROR); -+ std::reverse(key->begin() + prev_pos, key->end()); -+ } else { -+ *key += labels_[node]; -+ } -+ node = get_parent(node); - } -+ std::reverse(key->begin() + start_pos, key->end()); - } - - void Trie::trie_restore(UInt32 node, std::string *key) const { -@@ -468,7 +460,7 @@ template std::size_t Trie::tail_match(UInt32 node, - - template - std::size_t Trie::find_(T query, U key_ids, V key_lengths, -- std::size_t max_num_results) const try { -+ std::size_t max_num_results) const { - if (max_num_results == 0) { - return 0; - } -@@ -489,10 +481,6 @@ std::size_t Trie::find_(T query, U key_ids, V key_lengths, - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return count; --} catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); --} catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); - } - - template -@@ -533,7 +521,7 @@ UInt32 Trie::find_last_(T query, std::size_t *key_length) const { - - template - std::size_t Trie::predict_breadth_first_(T query, U key_ids, V keys, -- std::size_t max_num_results) const try { -+ std::size_t max_num_results) const { - if (max_num_results == 0) { - return 0; - } -@@ -596,15 +584,11 @@ std::size_t Trie::predict_breadth_first_(T query, U key_ids, V keys, - node_end = louds_pos_to_node(get_child(node_end), node_end); - } - return count; --} catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); --} catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); - } - - template - std::size_t Trie::predict_depth_first_(T query, U key_ids, V keys, -- std::size_t max_num_results) const try { -+ std::size_t max_num_results) const { - if (max_num_results == 0) { - return 0; - } else if (keys.is_valid()) { -@@ -665,10 +649,6 @@ std::size_t Trie::predict_depth_first_(T query, U key_ids, V keys, - ++stack_pos; - } - return count; --} catch (const std::bad_alloc &) { -- MARISA_THROW(MARISA_MEMORY_ERROR); --} catch (const std::length_error &) { -- MARISA_THROW(MARISA_SIZE_ERROR); - } - - template -diff --git a/lib/marisa/writer.cc b/lib/marisa/writer.cc -index 2256f59..55dcb97 100644 ---- a/lib/marisa/writer.cc -+++ b/lib/marisa/writer.cc -@@ -92,11 +92,7 @@ void Writer::write_data(const void *data, std::size_t size) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else if (stream_ != NULL) { -- try { -- if (!stream_->write(static_cast(data), size)) { -- MARISA_THROW(MARISA_IO_ERROR); -- } -- } catch (const std::ios_base::failure &) { -+ if (!stream_->write(static_cast(data), size)) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else { diff --git a/configure b/configure deleted file mode 100755 index 4b53c9a..0000000 --- a/configure +++ /dev/null @@ -1,6630 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for marisa 0.1.4. -# -# Report bugs to . -# -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org and syata@acm.org -$0: about your system, including any error possibly output -$0: before this message. Then install a modern shell, or -$0: manually run the script under such a shell if you do -$0: have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. -as_fn_error () -{ - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 - fi - $as_echo "$as_me: error: $1" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='marisa' -PACKAGE_TARNAME='marisa' -PACKAGE_VERSION='0.1.4' -PACKAGE_STRING='marisa 0.1.4' -PACKAGE_BUGREPORT='syata@acm.org' -PACKAGE_URL='' - -ac_unique_file="lib/marisa.h" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_header_list= -ac_subst_vars='am__EXEEXT_FALSE -am__EXEEXT_TRUE -LTLIBOBJS -POW_LIB -LIBOBJS -EGREP -GREP -CPP -RANLIB -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -ac_ct_CC -CFLAGS -CC -am__fastdepCXX_FALSE -am__fastdepCXX_TRUE -CXXDEPMODE -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CXX -CPPFLAGS -LDFLAGS -CXXFLAGS -CXX -am__untar -am__tar -AMTAR -am__leading_dot -SET_MAKE -AWK -mkdir_p -MKDIR_P -INSTALL_STRIP_PROGRAM -STRIP -install_sh -MAKEINFO -AUTOHEADER -AUTOMAKE -AUTOCONF -ACLOCAL -VERSION -PACKAGE -CYGPATH_W -am__isrc -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_dependency_tracking -' - ac_precious_vars='build_alias -host_alias -target_alias -CXX -CXXFLAGS -LDFLAGS -LIBS -CPPFLAGS -CCC -CC -CFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures marisa 0.1.4 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/marisa] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of marisa 0.1.4:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - -Some influential environment variables: - CXX C++ compiler command - CXXFLAGS C++ compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CC C compiler command - CFLAGS C compiler flags - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -marisa configure 0.1.4 -generated by GNU Autoconf 2.65 - -Copyright (C) 2009 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_compile - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( cat <<\_ASBOX -## ---------------------------- ## -## Report this to syata@acm.org ## -## ---------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_compile - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_type - -# ac_fn_c_find_uintX_t LINENO BITS VAR -# ------------------------------------ -# Finds an unsigned integer type with width BITS, setting cache variable VAR -# accordingly. -ac_fn_c_find_uintX_t () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 -$as_echo_n "checking for uint$2_t... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - # Order is important - never check a type that is potentially smaller - # than half of the expected target width. - for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - case $ac_type in #( - uint$2_t) : - eval "$3=yes" ;; #( - *) : - eval "$3=\$ac_type" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - eval as_val=\$$3 - if test "x$as_val" = x""no; then : - -else - break -fi - done -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_find_uintX_t - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_func -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by marisa $as_me 0.1.4, which was -generated by GNU Autoconf 2.65. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -as_fn_append ac_header_list " stdlib.h" -as_fn_append ac_header_list " unistd.h" -as_fn_append ac_header_list " sys/param.h" -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -am__api_version='1.11' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done -done -if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; -esac -case $srcdir in - *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; -esac - -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken -alias in your environment" "$LINENO" 5 - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error "newly created file is older than distributed files! -Check your system clock" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. -# By default was `s,x,x', remove it if useless. -ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi - -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - -mkdir_p="$MKDIR_P" -case $mkdir_p in - [\\/$]* | ?:[\\/]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='marisa' - VERSION='0.1.4' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' - - - - - - -# Checks for programs. -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 -$as_echo_n "checking whether the C++ compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C++ compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 -$as_echo_n "checking for C++ compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - -depcc="$CXX" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CXX_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' -else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - - - -# Checks for libraries. - -# Checks for header files. - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in fcntl.h limits.h stddef.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# Checks for typedefs, structures, and compiler characteristics. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 -$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" -#endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -# endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - -int -main () -{ - - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdbool_h=yes -else - ac_cv_header_stdbool_h=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 -$as_echo "$ac_cv_header_stdbool_h" >&6; } -ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" -if test "x$ac_cv_type__Bool" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE__BOOL 1 -_ACEOF - - -fi - -if test $ac_cv_header_stdbool_h = yes; then - -$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - -ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" -if test "x$ac_cv_type_ssize_t" = x""yes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define ssize_t int -_ACEOF - -fi - -ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" -case $ac_cv_c_uint16_t in #( - no|yes) ;; #( - *) - - -cat >>confdefs.h <<_ACEOF -#define uint16_t $ac_cv_c_uint16_t -_ACEOF -;; - esac - -ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" -case $ac_cv_c_uint32_t in #( - no|yes) ;; #( - *) - -$as_echo "#define _UINT32_T 1" >>confdefs.h - - -cat >>confdefs.h <<_ACEOF -#define uint32_t $ac_cv_c_uint32_t -_ACEOF -;; - esac - -ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" -case $ac_cv_c_uint64_t in #( - no|yes) ;; #( - *) - -$as_echo "#define _UINT64_T 1" >>confdefs.h - - -cat >>confdefs.h <<_ACEOF -#define uint64_t $ac_cv_c_uint64_t -_ACEOF -;; - esac - -ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" -case $ac_cv_c_uint8_t in #( - no|yes) ;; #( - *) - -$as_echo "#define _UINT8_T 1" >>confdefs.h - - -cat >>confdefs.h <<_ACEOF -#define uint8_t $ac_cv_c_uint8_t -_ACEOF -;; - esac - - -# Checks for library functions. -for ac_header in stdlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 -$as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_malloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -return ! malloc (0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_malloc_0_nonnull=yes -else - ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_MALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_MALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - - -$as_echo "#define malloc rpl_malloc" >>confdefs.h - -fi - - - - - - for ac_header in $ac_header_list -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - - - -for ac_func in getpagesize -do : - ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" -if test "x$ac_cv_func_getpagesize" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETPAGESIZE 1 -_ACEOF - -fi -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 -$as_echo_n "checking for working mmap... " >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_mmap_fixed_mapped=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc - -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include -#include - -#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H -char *malloc (); -#endif - -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ - -int -main () -{ - char *data, *data2, *data3; - const char *cdata2; - int i, pagesize; - int fd, fd2; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - return 1; - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - return 2; - if (write (fd, data, pagesize) != pagesize) - return 3; - close (fd); - - /* Next, check that the tail of a page is zero-filled. File must have - non-zero length, otherwise we risk SIGBUS for entire page. */ - fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); - if (fd2 < 0) - return 4; - cdata2 = ""; - if (write (fd2, cdata2, 1) != 1) - return 5; - data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); - if (data2 == MAP_FAILED) - return 6; - for (i = 0; i < pagesize; ++i) - if (*(data2 + i)) - return 7; - close (fd2); - if (munmap (data2, pagesize)) - return 8; - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - return 9; - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - return 10; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - return 11; - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - return 12; - if (read (fd, data3, pagesize) != pagesize) - return 13; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - return 14; - close (fd); - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_mmap_fixed_mapped=yes -else - ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 -$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } -if test $ac_cv_func_mmap_fixed_mapped = yes; then - -$as_echo "#define HAVE_MMAP 1" >>confdefs.h - -fi -rm -f conftest.mmap conftest.txt - -for ac_header in stdlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 -$as_echo_n "checking for GNU libc compatible realloc... " >&6; } -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_realloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *realloc (); -#endif - -int -main () -{ -return ! realloc (0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_realloc_0_nonnull=yes -else - ac_cv_func_realloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } -if test $ac_cv_func_realloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_REALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_REALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" realloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS realloc.$ac_objext" - ;; -esac - - -$as_echo "#define realloc rpl_realloc" >>confdefs.h - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 -$as_echo_n "checking for working strtod... " >&6; } -if test "${ac_cv_func_strtod+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_strtod=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -$ac_includes_default -#ifndef strtod -double strtod (); -#endif -int -main() -{ - { - /* Some versions of Linux strtod mis-parse strings with leading '+'. */ - char *string = " +69"; - char *term; - double value; - value = strtod (string, &term); - if (value != 69 || term != (string + 4)) - return 1; - } - - { - /* Under Solaris 2.4, strtod returns the wrong value for the - terminating character under some conditions. */ - char *string = "NaN"; - char *term; - strtod (string, &term); - if (term != string && *(term - 1) == 0) - return 1; - } - return 0; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_strtod=yes -else - ac_cv_func_strtod=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 -$as_echo "$ac_cv_func_strtod" >&6; } -if test $ac_cv_func_strtod = no; then - case " $LIBOBJS " in - *" strtod.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtod.$ac_objext" - ;; -esac - -ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = x""yes; then : - -fi - -if test $ac_cv_func_pow = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 -$as_echo_n "checking for pow in -lm... " >&6; } -if test "${ac_cv_lib_m_pow+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pow (); -int -main () -{ -return pow (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_pow=yes -else - ac_cv_lib_m_pow=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 -$as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = x""yes; then : - POW_LIB=-lm -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 -$as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} -fi - -fi - -fi - -for ac_func in munmap strtol -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -ac_config_files="$ac_config_files Makefile lib/Makefile tests/Makefile tools/Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - if test -n "$EXEEXT"; then - am__EXEEXT_TRUE= - am__EXEEXT_FALSE='#' -else - am__EXEEXT_TRUE='#' - am__EXEEXT_FALSE= -fi - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - as_fn_error "conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: ${CONFIG_STATUS=./config.status} -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. -as_fn_error () -{ - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 - fi - $as_echo "$as_me: error: $1" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by marisa $as_me 0.1.4, which was -generated by GNU Autoconf 2.65. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Configuration commands: -$config_commands - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -marisa config.status 0.1.4 -configured by $0, generated by GNU Autoconf 2.65, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2009 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' -AWK='$AWK' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; - "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; - "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; - esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - ;; - - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} - ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/configure.ac b/configure.ac deleted file mode 100644 index fdf455b..0000000 --- a/configure.ac +++ /dev/null @@ -1,41 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.65]) -AC_INIT([marisa], [0.1.4], [syata@acm.org]) -AC_CONFIG_SRCDIR([lib/marisa.h]) -AM_INIT_AUTOMAKE - -# Checks for programs. -AC_PROG_CXX -AC_PROG_CC -AC_PROG_RANLIB -AC_PROG_INSTALL - -# Checks for libraries. - -# Checks for header files. -AC_CHECK_HEADERS([fcntl.h limits.h stddef.h stdint.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_C_INLINE -AC_TYPE_SIZE_T -AC_TYPE_SSIZE_T -AC_TYPE_UINT16_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T -AC_TYPE_UINT8_T - -# Checks for library functions. -AC_FUNC_MALLOC -AC_FUNC_MMAP -AC_FUNC_REALLOC -AC_FUNC_STRTOD -AC_CHECK_FUNCS([munmap strtol]) - -AC_CONFIG_FILES([Makefile - lib/Makefile - tests/Makefile - tools/Makefile]) -AC_OUTPUT diff --git a/depcomp b/depcomp deleted file mode 100755 index e5f9736..0000000 --- a/depcomp +++ /dev/null @@ -1,589 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2007-03-29.01 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software -# Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add `dependent.h:' lines. - sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/install-sh b/install-sh deleted file mode 100755 index a5897de..0000000 --- a/install-sh +++ /dev/null @@ -1,519 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2006-12-25.00 - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -no_target_directory= - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) dst_arg=$2 - shift;; - - -T) no_target_directory=true;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call `install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names starting with `-'. - case $src in - -*) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - -*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir - shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/lib/Makefile.am b/lib/Makefile.am deleted file mode 100644 index df837bb..0000000 --- a/lib/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -AM_CXXFLAGS = -Wall -Weffc++ -#AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG - -lib_LIBRARIES = libmarisa.a - -libmarisa_a_SOURCES = \ - marisa/base.cc \ - marisa/progress.cc \ - marisa/mapper.cc \ - marisa/reader.cc \ - marisa/writer.cc \ - marisa/intvector.cc \ - marisa/bitvector.cc \ - marisa/tail.cc \ - marisa/trie.cc \ - marisa/trie-build.cc \ - marisa/trie-search.cc \ - marisa/trie-c.cc - -include_HEADERS = marisa.h - -libmarisa_includedir = ${includedir}/marisa -libmarisa_include_HEADERS = \ - marisa/base.h \ - marisa/popcount.h \ - marisa/rank.h \ - marisa/string.h \ - marisa/key.h \ - marisa/progress.h \ - marisa/range.h \ - marisa/query.h \ - marisa/container.h \ - marisa/cell.h \ - marisa/mapper.h \ - marisa/reader.h \ - marisa/writer.h \ - marisa/io.h \ - marisa/vector.h \ - marisa/vector-inline.h \ - marisa/intvector.h \ - marisa/bitvector.h \ - marisa/tail.h \ - marisa/trie.h \ - marisa/trie-inline.h diff --git a/lib/Makefile.in b/lib/Makefile.in deleted file mode 100644 index 6c705a7..0000000 --- a/lib/Makefile.in +++ /dev/null @@ -1,746 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = lib -DIST_COMMON = $(include_HEADERS) $(libmarisa_include_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" \ - "$(DESTDIR)$(libmarisa_includedir)" -LIBRARIES = $(lib_LIBRARIES) -AR = ar -ARFLAGS = cru -libmarisa_a_AR = $(AR) $(ARFLAGS) -libmarisa_a_LIBADD = -am_libmarisa_a_OBJECTS = base.$(OBJEXT) progress.$(OBJEXT) \ - mapper.$(OBJEXT) reader.$(OBJEXT) writer.$(OBJEXT) \ - intvector.$(OBJEXT) bitvector.$(OBJEXT) tail.$(OBJEXT) \ - trie.$(OBJEXT) trie-build.$(OBJEXT) trie-search.$(OBJEXT) \ - trie-c.$(OBJEXT) -libmarisa_a_OBJECTS = $(am_libmarisa_a_OBJECTS) -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -SOURCES = $(libmarisa_a_SOURCES) -DIST_SOURCES = $(libmarisa_a_SOURCES) -HEADERS = $(include_HEADERS) $(libmarisa_include_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CXXFLAGS = -Wall -Weffc++ -#AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -lib_LIBRARIES = libmarisa.a -libmarisa_a_SOURCES = \ - marisa/base.cc \ - marisa/progress.cc \ - marisa/mapper.cc \ - marisa/reader.cc \ - marisa/writer.cc \ - marisa/intvector.cc \ - marisa/bitvector.cc \ - marisa/tail.cc \ - marisa/trie.cc \ - marisa/trie-build.cc \ - marisa/trie-search.cc \ - marisa/trie-c.cc - -include_HEADERS = marisa.h -libmarisa_includedir = ${includedir}/marisa -libmarisa_include_HEADERS = \ - marisa/base.h \ - marisa/popcount.h \ - marisa/rank.h \ - marisa/string.h \ - marisa/key.h \ - marisa/progress.h \ - marisa/range.h \ - marisa/query.h \ - marisa/container.h \ - marisa/cell.h \ - marisa/mapper.h \ - marisa/reader.h \ - marisa/writer.h \ - marisa/io.h \ - marisa/vector.h \ - marisa/vector-inline.h \ - marisa/intvector.h \ - marisa/bitvector.h \ - marisa/tail.h \ - marisa/trie.h \ - marisa/trie-inline.h - -all: all-am - -.SUFFIXES: -.SUFFIXES: .cc .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu lib/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-libLIBRARIES: $(lib_LIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" - @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(INSTALL_DATA) $$list2 "$(DESTDIR)$(libdir)" || exit $$?; } - @$(POST_INSTALL) - @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - if test -f $$p; then \ - $(am__strip_dir) \ - echo " ( cd '$(DESTDIR)$(libdir)' && $(RANLIB) $$f )"; \ - ( cd "$(DESTDIR)$(libdir)" && $(RANLIB) $$f ) || exit $$?; \ - else :; fi; \ - done - -uninstall-libLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(libdir)' && rm -f "$$files" )"; \ - cd "$(DESTDIR)$(libdir)" && rm -f $$files - -clean-libLIBRARIES: - -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) -libmarisa.a: $(libmarisa_a_OBJECTS) $(libmarisa_a_DEPENDENCIES) - -rm -f libmarisa.a - $(libmarisa_a_AR) libmarisa.a $(libmarisa_a_OBJECTS) $(libmarisa_a_LIBADD) - $(RANLIB) libmarisa.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitvector.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intvector.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progress.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tail.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-build.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-c.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-search.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Po@am__quote@ - -.cc.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cc.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -base.o: marisa/base.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base.o -MD -MP -MF $(DEPDIR)/base.Tpo -c -o base.o `test -f 'marisa/base.cc' || echo '$(srcdir)/'`marisa/base.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/base.Tpo $(DEPDIR)/base.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/base.cc' object='base.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base.o `test -f 'marisa/base.cc' || echo '$(srcdir)/'`marisa/base.cc - -base.obj: marisa/base.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base.obj -MD -MP -MF $(DEPDIR)/base.Tpo -c -o base.obj `if test -f 'marisa/base.cc'; then $(CYGPATH_W) 'marisa/base.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/base.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/base.Tpo $(DEPDIR)/base.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/base.cc' object='base.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base.obj `if test -f 'marisa/base.cc'; then $(CYGPATH_W) 'marisa/base.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/base.cc'; fi` - -progress.o: marisa/progress.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT progress.o -MD -MP -MF $(DEPDIR)/progress.Tpo -c -o progress.o `test -f 'marisa/progress.cc' || echo '$(srcdir)/'`marisa/progress.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/progress.Tpo $(DEPDIR)/progress.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/progress.cc' object='progress.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o progress.o `test -f 'marisa/progress.cc' || echo '$(srcdir)/'`marisa/progress.cc - -progress.obj: marisa/progress.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT progress.obj -MD -MP -MF $(DEPDIR)/progress.Tpo -c -o progress.obj `if test -f 'marisa/progress.cc'; then $(CYGPATH_W) 'marisa/progress.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/progress.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/progress.Tpo $(DEPDIR)/progress.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/progress.cc' object='progress.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o progress.obj `if test -f 'marisa/progress.cc'; then $(CYGPATH_W) 'marisa/progress.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/progress.cc'; fi` - -mapper.o: marisa/mapper.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mapper.o -MD -MP -MF $(DEPDIR)/mapper.Tpo -c -o mapper.o `test -f 'marisa/mapper.cc' || echo '$(srcdir)/'`marisa/mapper.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/mapper.Tpo $(DEPDIR)/mapper.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/mapper.cc' object='mapper.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mapper.o `test -f 'marisa/mapper.cc' || echo '$(srcdir)/'`marisa/mapper.cc - -mapper.obj: marisa/mapper.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mapper.obj -MD -MP -MF $(DEPDIR)/mapper.Tpo -c -o mapper.obj `if test -f 'marisa/mapper.cc'; then $(CYGPATH_W) 'marisa/mapper.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/mapper.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/mapper.Tpo $(DEPDIR)/mapper.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/mapper.cc' object='mapper.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mapper.obj `if test -f 'marisa/mapper.cc'; then $(CYGPATH_W) 'marisa/mapper.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/mapper.cc'; fi` - -reader.o: marisa/reader.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f 'marisa/reader.cc' || echo '$(srcdir)/'`marisa/reader.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/reader.cc' object='reader.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o reader.o `test -f 'marisa/reader.cc' || echo '$(srcdir)/'`marisa/reader.cc - -reader.obj: marisa/reader.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT reader.obj -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.obj `if test -f 'marisa/reader.cc'; then $(CYGPATH_W) 'marisa/reader.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/reader.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/reader.cc' object='reader.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o reader.obj `if test -f 'marisa/reader.cc'; then $(CYGPATH_W) 'marisa/reader.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/reader.cc'; fi` - -writer.o: marisa/writer.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT writer.o -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.o `test -f 'marisa/writer.cc' || echo '$(srcdir)/'`marisa/writer.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/writer.cc' object='writer.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o writer.o `test -f 'marisa/writer.cc' || echo '$(srcdir)/'`marisa/writer.cc - -writer.obj: marisa/writer.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT writer.obj -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.obj `if test -f 'marisa/writer.cc'; then $(CYGPATH_W) 'marisa/writer.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/writer.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/writer.cc' object='writer.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o writer.obj `if test -f 'marisa/writer.cc'; then $(CYGPATH_W) 'marisa/writer.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/writer.cc'; fi` - -intvector.o: marisa/intvector.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT intvector.o -MD -MP -MF $(DEPDIR)/intvector.Tpo -c -o intvector.o `test -f 'marisa/intvector.cc' || echo '$(srcdir)/'`marisa/intvector.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/intvector.Tpo $(DEPDIR)/intvector.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/intvector.cc' object='intvector.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o intvector.o `test -f 'marisa/intvector.cc' || echo '$(srcdir)/'`marisa/intvector.cc - -intvector.obj: marisa/intvector.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT intvector.obj -MD -MP -MF $(DEPDIR)/intvector.Tpo -c -o intvector.obj `if test -f 'marisa/intvector.cc'; then $(CYGPATH_W) 'marisa/intvector.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/intvector.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/intvector.Tpo $(DEPDIR)/intvector.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/intvector.cc' object='intvector.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o intvector.obj `if test -f 'marisa/intvector.cc'; then $(CYGPATH_W) 'marisa/intvector.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/intvector.cc'; fi` - -bitvector.o: marisa/bitvector.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bitvector.o -MD -MP -MF $(DEPDIR)/bitvector.Tpo -c -o bitvector.o `test -f 'marisa/bitvector.cc' || echo '$(srcdir)/'`marisa/bitvector.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/bitvector.Tpo $(DEPDIR)/bitvector.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/bitvector.cc' object='bitvector.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bitvector.o `test -f 'marisa/bitvector.cc' || echo '$(srcdir)/'`marisa/bitvector.cc - -bitvector.obj: marisa/bitvector.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bitvector.obj -MD -MP -MF $(DEPDIR)/bitvector.Tpo -c -o bitvector.obj `if test -f 'marisa/bitvector.cc'; then $(CYGPATH_W) 'marisa/bitvector.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/bitvector.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/bitvector.Tpo $(DEPDIR)/bitvector.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/bitvector.cc' object='bitvector.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bitvector.obj `if test -f 'marisa/bitvector.cc'; then $(CYGPATH_W) 'marisa/bitvector.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/bitvector.cc'; fi` - -tail.o: marisa/tail.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT tail.o -MD -MP -MF $(DEPDIR)/tail.Tpo -c -o tail.o `test -f 'marisa/tail.cc' || echo '$(srcdir)/'`marisa/tail.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/tail.Tpo $(DEPDIR)/tail.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/tail.cc' object='tail.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o tail.o `test -f 'marisa/tail.cc' || echo '$(srcdir)/'`marisa/tail.cc - -tail.obj: marisa/tail.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT tail.obj -MD -MP -MF $(DEPDIR)/tail.Tpo -c -o tail.obj `if test -f 'marisa/tail.cc'; then $(CYGPATH_W) 'marisa/tail.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/tail.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/tail.Tpo $(DEPDIR)/tail.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/tail.cc' object='tail.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o tail.obj `if test -f 'marisa/tail.cc'; then $(CYGPATH_W) 'marisa/tail.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/tail.cc'; fi` - -trie.o: marisa/trie.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie.o -MD -MP -MF $(DEPDIR)/trie.Tpo -c -o trie.o `test -f 'marisa/trie.cc' || echo '$(srcdir)/'`marisa/trie.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie.Tpo $(DEPDIR)/trie.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie.cc' object='trie.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie.o `test -f 'marisa/trie.cc' || echo '$(srcdir)/'`marisa/trie.cc - -trie.obj: marisa/trie.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie.obj -MD -MP -MF $(DEPDIR)/trie.Tpo -c -o trie.obj `if test -f 'marisa/trie.cc'; then $(CYGPATH_W) 'marisa/trie.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie.Tpo $(DEPDIR)/trie.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie.cc' object='trie.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie.obj `if test -f 'marisa/trie.cc'; then $(CYGPATH_W) 'marisa/trie.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie.cc'; fi` - -trie-build.o: marisa/trie-build.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-build.o -MD -MP -MF $(DEPDIR)/trie-build.Tpo -c -o trie-build.o `test -f 'marisa/trie-build.cc' || echo '$(srcdir)/'`marisa/trie-build.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-build.Tpo $(DEPDIR)/trie-build.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie-build.cc' object='trie-build.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-build.o `test -f 'marisa/trie-build.cc' || echo '$(srcdir)/'`marisa/trie-build.cc - -trie-build.obj: marisa/trie-build.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-build.obj -MD -MP -MF $(DEPDIR)/trie-build.Tpo -c -o trie-build.obj `if test -f 'marisa/trie-build.cc'; then $(CYGPATH_W) 'marisa/trie-build.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie-build.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-build.Tpo $(DEPDIR)/trie-build.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie-build.cc' object='trie-build.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-build.obj `if test -f 'marisa/trie-build.cc'; then $(CYGPATH_W) 'marisa/trie-build.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie-build.cc'; fi` - -trie-search.o: marisa/trie-search.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-search.o -MD -MP -MF $(DEPDIR)/trie-search.Tpo -c -o trie-search.o `test -f 'marisa/trie-search.cc' || echo '$(srcdir)/'`marisa/trie-search.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-search.Tpo $(DEPDIR)/trie-search.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie-search.cc' object='trie-search.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-search.o `test -f 'marisa/trie-search.cc' || echo '$(srcdir)/'`marisa/trie-search.cc - -trie-search.obj: marisa/trie-search.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-search.obj -MD -MP -MF $(DEPDIR)/trie-search.Tpo -c -o trie-search.obj `if test -f 'marisa/trie-search.cc'; then $(CYGPATH_W) 'marisa/trie-search.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie-search.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-search.Tpo $(DEPDIR)/trie-search.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie-search.cc' object='trie-search.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-search.obj `if test -f 'marisa/trie-search.cc'; then $(CYGPATH_W) 'marisa/trie-search.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie-search.cc'; fi` - -trie-c.o: marisa/trie-c.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-c.o -MD -MP -MF $(DEPDIR)/trie-c.Tpo -c -o trie-c.o `test -f 'marisa/trie-c.cc' || echo '$(srcdir)/'`marisa/trie-c.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-c.Tpo $(DEPDIR)/trie-c.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie-c.cc' object='trie-c.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-c.o `test -f 'marisa/trie-c.cc' || echo '$(srcdir)/'`marisa/trie-c.cc - -trie-c.obj: marisa/trie-c.cc -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-c.obj -MD -MP -MF $(DEPDIR)/trie-c.Tpo -c -o trie-c.obj `if test -f 'marisa/trie-c.cc'; then $(CYGPATH_W) 'marisa/trie-c.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie-c.cc'; fi` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-c.Tpo $(DEPDIR)/trie-c.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa/trie-c.cc' object='trie-c.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-c.obj `if test -f 'marisa/trie-c.cc'; then $(CYGPATH_W) 'marisa/trie-c.cc'; else $(CYGPATH_W) '$(srcdir)/marisa/trie-c.cc'; fi` -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(includedir)" && rm -f $$files -install-libmarisa_includeHEADERS: $(libmarisa_include_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(libmarisa_includedir)" || $(MKDIR_P) "$(DESTDIR)$(libmarisa_includedir)" - @list='$(libmarisa_include_HEADERS)'; test -n "$(libmarisa_includedir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libmarisa_includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(libmarisa_includedir)" || exit $$?; \ - done - -uninstall-libmarisa_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(libmarisa_include_HEADERS)'; test -n "$(libmarisa_includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(libmarisa_includedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(libmarisa_includedir)" && rm -f $$files - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(libmarisa_includedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libLIBRARIES mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-includeHEADERS \ - install-libmarisa_includeHEADERS - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-libLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-includeHEADERS uninstall-libLIBRARIES \ - uninstall-libmarisa_includeHEADERS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libLIBRARIES ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am \ - install-includeHEADERS install-info install-info-am \ - install-libLIBRARIES install-libmarisa_includeHEADERS \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ - ps ps-am tags uninstall uninstall-am uninstall-includeHEADERS \ - uninstall-libLIBRARIES uninstall-libmarisa_includeHEADERS - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/lib/marisa.h b/lib/marisa.h deleted file mode 100644 index 62b64c0..0000000 --- a/lib/marisa.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MARISA_H_ -#define MARISA_H_ - -#include "marisa/trie.h" - -#endif // MARISA_H_ diff --git a/lib/marisa/base.cc b/lib/marisa/base.cc deleted file mode 100644 index 23306a8..0000000 --- a/lib/marisa/base.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "base.h" - -extern "C" { - -const char *marisa_strerror(marisa_status status) { -#define MARISA_STRERROR_CASE(x) case x: { return #x; } - switch (status) { - MARISA_STRERROR_CASE(MARISA_OK) - MARISA_STRERROR_CASE(MARISA_HANDLE_ERROR) - MARISA_STRERROR_CASE(MARISA_STATE_ERROR) - MARISA_STRERROR_CASE(MARISA_PARAM_ERROR) - MARISA_STRERROR_CASE(MARISA_SIZE_ERROR) - MARISA_STRERROR_CASE(MARISA_MEMORY_ERROR) - MARISA_STRERROR_CASE(MARISA_IO_ERROR) - MARISA_STRERROR_CASE(MARISA_UNEXPECTED_ERROR) - } - return "MARISA_UNKNOWN_ERROR"; -#undef MARISA_STRERROR_CASE -} - -} // extern "C" diff --git a/lib/marisa/base.h b/lib/marisa/base.h deleted file mode 100644 index 098384c..0000000 --- a/lib/marisa/base.h +++ /dev/null @@ -1,233 +0,0 @@ -#ifndef MARISA_BASE_H_ -#define MARISA_BASE_H_ - -// Visual C++ does not provide stdint.h. -#ifndef _MSC_VER -#include -#endif // _MSC_VER - -#ifdef __cplusplus -#include -#include -#else // __cplusplus -#include -#endif // __cplusplus - -#if defined(__ANDROID__) -#include -#include -#endif // __ANDROID__ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#ifdef _MSC_VER -typedef unsigned __int8 marisa_uint8; -typedef unsigned __int16 marisa_uint16; -typedef unsigned __int32 marisa_uint32; -typedef unsigned __int64 marisa_uint64; -#else // _MSC_VER -typedef uint8_t marisa_uint8; -typedef uint16_t marisa_uint16; -typedef uint32_t marisa_uint32; -typedef uint64_t marisa_uint64; -#endif // _MSC_VER - -#define MARISA_UINT8_MAX ((marisa_uint8)-1) -#define MARISA_UINT16_MAX ((marisa_uint16)-1) -#define MARISA_UINT32_MAX ((marisa_uint32)-1) -#define MARISA_UINT64_MAX ((marisa_uint64)-1) -#define MARISA_SIZE_MAX ((size_t)-1) - -#define MARISA_ZERO_TERMINATED MARISA_UINT32_MAX -#define MARISA_NOT_FOUND MARISA_UINT32_MAX -#define MARISA_MISMATCH MARISA_UINT32_MAX - -#define MARISA_MAX_LENGTH (MARISA_UINT32_MAX - 1) -#define MARISA_MAX_NUM_KEYS (MARISA_UINT32_MAX - 1) - -// marisa_status provides a list of error codes. Most of functions in -// libmarisa throw or return an error code. -typedef enum marisa_status_ { - // MARISA_OK means that a requested operation has succeeded. - MARISA_OK = 0, - - // MARISA_HANDLE_ERROR means that a given handle is invalid. - MARISA_HANDLE_ERROR = 1, - - // MARISA_STATE_ERROR means that an object is not ready for a requested - // operation. For example, an operation to modify a fixed container throws - // an exception with this error code. - MARISA_STATE_ERROR = 2, - - // MARISA_PARAM_ERROR means that a given argument is invalid. For example, - // some functions throw an exception with this error code when an - // out-of-range value or a NULL pointer is given. - MARISA_PARAM_ERROR = 3, - - // MARISA_SIZE_ERROR means that a size exceeds its limit. This error code - // is used when a building dictionary is too large or std::length_error is - // catched. - MARISA_SIZE_ERROR = 4, - - // MARISA_MEMORY_ERROR means that a memory allocation has failed. - MARISA_MEMORY_ERROR = 5, - - // MARISA_IO_ERROR means that an I/O failure. - MARISA_IO_ERROR = 6, - - // MARISA_UNEXPECTED_ERROR means that an unexpected error has occurred. - MARISA_UNEXPECTED_ERROR = 7 -} marisa_status; - -// marisa_strerror() returns a name of an error code. -const char *marisa_strerror(marisa_status status); - -// Flags and masks for dictionary settings are defined as follows. Please note -// that unspecified value/flags will be replaced with default value/flags. -typedef enum marisa_flags_ { - // A dictionary consinsts of 3 tries in default. If you want to change the - // number of tries, please give it with other flags. - MARISA_MIN_NUM_TRIES = 0x00001, - MARISA_MAX_NUM_TRIES = 0x000FF, - MARISA_DEFAULT_NUM_TRIES = 0x00003, - - // MARISA_PATRICIA_TRIE is usually a better choice. MARISA_PREFIX_TRIE is - // provided for comparing prefix/patricia tries. - MARISA_PATRICIA_TRIE = 0x00100, - MARISA_PREFIX_TRIE = 0x00200, - MARISA_DEFAULT_TRIE = MARISA_PATRICIA_TRIE, - - // There are 3 kinds of TAIL implementations. - // - MARISA_WITHOUT_TAIL: - // builds a dictionary without a TAIL. Its last trie has only 1-byte - // labels. - // - MARISA_BINARY_TAIL: - // builds a dictionary with a binary-mode TAIL. Its last labels are stored - // as binary data. - // - MARISA_TEXT_TAIL: - // builds a dictionary with a text-mode TAIL if its last labels do not - // contain NULL characters. The last labels are stored as zero-terminated - // string. Otherwise, a dictionary is built with a binary-mode TAIL. - MARISA_WITHOUT_TAIL = 0x01000, - MARISA_BINARY_TAIL = 0x02000, - MARISA_TEXT_TAIL = 0x04000, - MARISA_DEFAULT_TAIL = MARISA_TEXT_TAIL, - - // libmarisa arranges nodes in ascending order of their labels - // (MARISA_LABEL_ORDER) or in descending order of their weights - // (MARISA_WEIGHT_ORDER). MARISA_WEIGHT_ORDER is generally a better choice - // because it enables faster lookups, but MARISA_LABEL_ORDER is still useful - // if an application needs to predict keys in label order. - MARISA_LABEL_ORDER = 0x10000, - MARISA_WEIGHT_ORDER = 0x20000, - MARISA_DEFAULT_ORDER = MARISA_WEIGHT_ORDER, - - // The default settings. 0 is equivalent to MARISA_DEFAULT_FLAGS. - MARISA_DEFAULT_FLAGS = MARISA_DEFAULT_NUM_TRIES - | MARISA_DEFAULT_TRIE | MARISA_DEFAULT_TAIL | MARISA_DEFAULT_ORDER, - - MARISA_NUM_TRIES_MASK = 0x000FF, - MARISA_TRIE_MASK = 0x00F00, - MARISA_TAIL_MASK = 0x0F000, - MARISA_ORDER_MASK = 0xF0000, - MARISA_FLAGS_MASK = 0xFFFFF -} marisa_flags; - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -//#include - -#ifdef __cplusplus -namespace marisa { - -typedef ::marisa_uint8 UInt8; -typedef ::marisa_uint16 UInt16; -typedef ::marisa_uint32 UInt32; -typedef ::marisa_uint64 UInt64; - -typedef ::marisa_status Status; - -// An exception object stores a filename, a line number and an error code. -class Exception { - public: - Exception(const char *filename, int line, Status status) - : filename_(filename), line_(line), status_(status) {} - Exception(const Exception &ex) - : filename_(ex.filename_), line_(ex.line_), status_(ex.status_) {} - - Exception &operator=(const Exception &rhs) { - filename_ = rhs.filename_; - line_ = rhs.line_; - status_ = rhs.status_; - return *this; - } - - const char *filename() const { - return filename_; - } - int line() const { - return line_; - } - Status status() const { - return status_; - } - - // Same as std::exception, what() returns an error message. - const char *what() const { - return ::marisa_strerror(status_); - } - - private: - const char *filename_; - int line_; - Status status_; -}; - -// MARISA_THROW adds a filename and a line number to an exception. -#if !defined(__ANDROID__) -#define MARISA_THROW(status) \ - (throw Exception(__FILE__, __LINE__, status)) -#else - -inline int android_log_exception(int status) { - char tmpbuf[100]; - snprintf(tmpbuf, sizeof(tmpbuf), "marisa exception: %d", status); - __android_log_write(ANDROID_LOG_ERROR, "marisa-trie", tmpbuf); - return 0; -} - -#define MARISA_THROW(status) \ - (android_log_exception(status)) - -#endif // __ANDROID__ - -// MARISA_THROW_IF throws an exception with `status' if `cond' is true. -#define MARISA_THROW_IF(cond, status) \ - (void)((!(cond)) || (MARISA_THROW(status), 0)) - -// MARISA_DEBUG_IF is used for debugging. For example, MARISA_DEBUG_IF is used -// to find out-of-range accesses in marisa::Vector, marisa::IntVector, etc. -#ifdef _DEBUG -#define MARISA_DEBUG_IF(cond, status) \ - MARISA_THROW_IF(cond, status) -#else -#define MARISA_DEBUG_IF(cond, status) -#endif - -// To not include only for std::swap(). -template -void Swap(T *lhs, T *rhs) { - MARISA_THROW_IF((lhs == NULL) || (rhs == NULL), MARISA_PARAM_ERROR); - T temp = *lhs; - *lhs = *rhs; - *rhs = temp; -} - -} // namespace marisa -#endif // __cplusplus - -#endif // MARISA_BASE_H_ diff --git a/lib/marisa/bitvector.cc b/lib/marisa/bitvector.cc deleted file mode 100644 index f5678ca..0000000 --- a/lib/marisa/bitvector.cc +++ /dev/null @@ -1,569 +0,0 @@ -#include "bitvector.h" -#include "popcount.h" - -namespace marisa { -namespace { - -const UInt8 SelectTable[8][256] = { - { - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 - }, - { - 7, 7, 7, 1, 7, 2, 2, 1, 7, 3, 3, 1, 3, 2, 2, 1, - 7, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1, - 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 7, 7, 1, 7, 2, 2, 1, 7, 3, 3, 1, 3, 2, 2, 1, - 7, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1, - 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1 - }, - { - 7, 7, 7, 7, 7, 7, 7, 2, 7, 7, 7, 3, 7, 3, 3, 2, - 7, 7, 7, 4, 7, 4, 4, 2, 7, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 5, 7, 5, 5, 2, 7, 5, 5, 3, 5, 3, 3, 2, - 7, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 6, 7, 6, 6, 2, 7, 6, 6, 3, 6, 3, 3, 2, - 7, 6, 6, 4, 6, 4, 4, 2, 6, 4, 4, 3, 4, 3, 3, 2, - 7, 6, 6, 5, 6, 5, 5, 2, 6, 5, 5, 3, 5, 3, 3, 2, - 6, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 7, 7, 7, 7, 2, 7, 7, 7, 3, 7, 3, 3, 2, - 7, 7, 7, 4, 7, 4, 4, 2, 7, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 5, 7, 5, 5, 2, 7, 5, 5, 3, 5, 3, 3, 2, - 7, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 6, 7, 6, 6, 2, 7, 6, 6, 3, 6, 3, 3, 2, - 7, 6, 6, 4, 6, 4, 4, 2, 6, 4, 4, 3, 4, 3, 3, 2, - 7, 6, 6, 5, 6, 5, 5, 2, 6, 5, 5, 3, 5, 3, 3, 2, - 6, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, - 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 4, 7, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 3, - 7, 7, 7, 5, 7, 5, 5, 4, 7, 5, 5, 4, 5, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 3, - 7, 7, 7, 6, 7, 6, 6, 4, 7, 6, 6, 4, 6, 4, 4, 3, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 3, - 7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, - 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 4, 7, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 3, - 7, 7, 7, 5, 7, 5, 5, 4, 7, 5, 5, 4, 5, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 3, - 7, 7, 7, 6, 7, 6, 6, 4, 7, 6, 6, 4, 6, 4, 4, 3, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 3, - 7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 4, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 4, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 - } -}; - -} // namespace - -BitVector::BitVector() - : blocks_(), size_(0), ranks_(), select0s_(), select1s_() {} - -void BitVector::build() { - Vector ranks; - const UInt32 num_blocks = (size_ / 512) + (((size_ % 512) != 0) ? 1 : 0); - ranks.resize(num_blocks + 1); - Vector select0s; - Vector select1s; - UInt32 num_0s = 0; - UInt32 num_1s = 0; - for (UInt32 i = 0; i < size_; ++i) { - if ((i % 64) == 0) { - UInt32 rank_id = i / 512; - switch ((i / 64) % 8) { - case 0: { - ranks[rank_id].set_abs(num_1s); - break; - } - case 1: { - ranks[rank_id].set_rel1(num_1s - ranks[rank_id].abs()); - break; - } - case 2: { - ranks[rank_id].set_rel2(num_1s - ranks[rank_id].abs()); - break; - } - case 3: { - ranks[rank_id].set_rel3(num_1s - ranks[rank_id].abs()); - break; - } - case 4: { - ranks[rank_id].set_rel4(num_1s - ranks[rank_id].abs()); - break; - } - case 5: { - ranks[rank_id].set_rel5(num_1s - ranks[rank_id].abs()); - break; - } - case 6: { - ranks[rank_id].set_rel6(num_1s - ranks[rank_id].abs()); - break; - } - case 7: { - ranks[rank_id].set_rel7(num_1s - ranks[rank_id].abs()); - break; - } - } - } - if ((*this)[i]) { - if ((num_1s % 512) == 0) { - select1s.push_back(i); - } - ++num_1s; - } else { - if ((num_0s % 512) == 0) { - select0s.push_back(i); - } - ++num_0s; - } - } - if ((size_ % 512) != 0) { - UInt32 rank_id = (size_ - 1) / 512; - switch (((size_ - 1) / 64) % 8) { - case 0: { - ranks[rank_id].set_rel1(num_1s - ranks[rank_id].abs()); - } - case 1: { - ranks[rank_id].set_rel2(num_1s - ranks[rank_id].abs()); - } - case 2: { - ranks[rank_id].set_rel3(num_1s - ranks[rank_id].abs()); - } - case 3: { - ranks[rank_id].set_rel4(num_1s - ranks[rank_id].abs()); - } - case 4: { - ranks[rank_id].set_rel5(num_1s - ranks[rank_id].abs()); - } - case 5: { - ranks[rank_id].set_rel6(num_1s - ranks[rank_id].abs()); - } - case 6: { - ranks[rank_id].set_rel7(num_1s - ranks[rank_id].abs()); - break; - } - } - } - ranks.back().set_abs(num_1s); - select0s.push_back(size_); - select1s.push_back(size_); - select0s.shrink(); - select1s.shrink(); - - blocks_.shrink(); - ranks_.swap(&ranks); - select0s_.swap(&select0s); - select1s_.swap(&select1s); -} - -void BitVector::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_THROW_IF(mapper == NULL, MARISA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void BitVector::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void BitVector::map(Mapper &mapper) { - BitVector temp; - temp.blocks_.map(mapper); - mapper.map(&temp.size_); - temp.ranks_.map(mapper); - temp.select0s_.map(mapper); - temp.select1s_.map(mapper); - temp.swap(this); -} - -void BitVector::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void BitVector::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -void BitVector::read(int fd) { - Reader reader(fd); - read(reader); -} - -void BitVector::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void BitVector::read(Reader &reader) { - BitVector temp; - temp.blocks_.read(reader); - reader.read(&temp.size_); - temp.ranks_.read(reader); - temp.select0s_.read(reader); - temp.select1s_.read(reader); - temp.swap(this); -} - -void BitVector::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void BitVector::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -void BitVector::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void BitVector::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void BitVector::write(Writer &writer) const { - blocks_.write(writer); - writer.write(size_); - ranks_.write(writer); - select0s_.write(writer); - select1s_.write(writer); -} - -UInt32 BitVector::rank1(UInt32 i) const { - MARISA_DEBUG_IF(i > size_, MARISA_PARAM_ERROR); - const Rank &rank = ranks_[i / 512]; - UInt32 offset = rank.abs(); - switch ((i / 64) % 8) { - case 1: { - offset += rank.rel1(); - break; - } - case 2: { - offset += rank.rel2(); - break; - } - case 3: { - offset += rank.rel3(); - break; - } - case 4: { - offset += rank.rel4(); - break; - } - case 5: { - offset += rank.rel5(); - break; - } - case 6: { - offset += rank.rel6(); - break; - } - case 7: { - offset += rank.rel7(); - break; - } - } - switch ((i / 32) % 2) { - case 1: { - offset += PopCount(blocks_[(i / 32) - 1]).lo32(); - } - case 0: { - offset += PopCount(blocks_[i / 32] & ((1U << (i % 32)) - 1)).lo32(); - break; - } - } - return offset; -} - -UInt32 BitVector::select0(UInt32 i) const { - UInt32 select_id = i / 512; - MARISA_DEBUG_IF((select_id + 1) >= select0s_.size(), MARISA_PARAM_ERROR); - if ((i % 512) == 0) { - return select0s_[select_id]; - } - UInt32 begin = select0s_[select_id] / 512; - UInt32 end = (select0s_[select_id + 1] + 511) / 512; - if (begin + 10 >= end) { - while (i >= ((begin + 1) * 512) - ranks_[begin + 1].abs()) { - ++begin; - } - } else { - while (begin + 1 < end) { - UInt32 middle = (begin + end) / 2; - if (i < (middle * 512) - ranks_[middle].abs()) { - end = middle; - } else { - begin = middle; - } - } - } - const UInt32 rank_id = begin; - i -= (rank_id * 512) - ranks_[rank_id].abs(); - - const Rank &rank = ranks_[rank_id]; - UInt32 block_id = rank_id * 16; - if (i < (256U - rank.rel4())) { - if (i < (128U - rank.rel2())) { - if (i >= (64U - rank.rel1())) { - block_id += 2; - i -= 64 - rank.rel1(); - } - } else if (i < (192U - rank.rel3())) { - block_id += 4; - i -= 128 - rank.rel2(); - } else { - block_id += 6; - i -= 192 - rank.rel3(); - } - } else if (i < (384U - rank.rel6())) { - if (i < (320U - rank.rel5())) { - block_id += 8; - i -= 256 - rank.rel4(); - } else { - block_id += 10; - i -= 320 - rank.rel5(); - } - } else if (i < (448U - rank.rel7())) { - block_id += 12; - i -= 384 - rank.rel6(); - } else { - block_id += 14; - i -= 448 - rank.rel7(); - } - - UInt32 block = ~blocks_[block_id]; - PopCount count(block); - if (i >= count.lo32()) { - ++block_id; - i -= count.lo32(); - block = ~blocks_[block_id]; - count = PopCount(block); - } - - UInt32 bit_id = block_id * 32; - if (i < count.lo16()) { - if (i >= count.lo8()) { - bit_id += 8; - block >>= 8; - i -= count.lo8(); - } - } else if (i < count.lo24()) { - bit_id += 16; - block >>= 16; - i -= count.lo16(); - } else { - bit_id += 24; - block >>= 24; - i -= count.lo24(); - } - return bit_id + SelectTable[i][block & 0xFF]; -} - -UInt32 BitVector::select1(UInt32 i) const { - UInt32 select_id = i / 512; - MARISA_DEBUG_IF((select_id + 1) >= select1s_.size(), MARISA_PARAM_ERROR); - if ((i % 512) == 0) { - return select1s_[select_id]; - } - UInt32 begin = select1s_[select_id] / 512; - UInt32 end = (select1s_[select_id + 1] + 511) / 512; - if (begin + 10 >= end) { - while (i >= ranks_[begin + 1].abs()) { - ++begin; - } - } else { - while (begin + 1 < end) { - UInt32 middle = (begin + end) / 2; - if (i < ranks_[middle].abs()) { - end = middle; - } else { - begin = middle; - } - } - } - const UInt32 rank_id = begin; - i -= ranks_[rank_id].abs(); - - const Rank &rank = ranks_[rank_id]; - UInt32 block_id = rank_id * 16; - if (i < rank.rel4()) { - if (i < rank.rel2()) { - if (i >= rank.rel1()) { - block_id += 2; - i -= rank.rel1(); - } - } else if (i < rank.rel3()) { - block_id += 4; - i -= rank.rel2(); - } else { - block_id += 6; - i -= rank.rel3(); - } - } else if (i < rank.rel6()) { - if (i < rank.rel5()) { - block_id += 8; - i -= rank.rel4(); - } else { - block_id += 10; - i -= rank.rel5(); - } - } else if (i < rank.rel7()) { - block_id += 12; - i -= rank.rel6(); - } else { - block_id += 14; - i -= rank.rel7(); - } - - UInt32 block = blocks_[block_id]; - PopCount count(block); - if (i >= count.lo32()) { - ++block_id; - i -= count.lo32(); - block = blocks_[block_id]; - count = PopCount(block); - } - - UInt32 bit_id = block_id * 32; - if (i < count.lo16()) { - if (i >= count.lo8()) { - bit_id += 8; - block >>= 8; - i -= count.lo8(); - } - } else if (i < count.lo24()) { - bit_id += 16; - block >>= 16; - i -= count.lo16(); - } else { - bit_id += 24; - block >>= 24; - i -= count.lo24(); - } - return bit_id + SelectTable[i][block & 0xFF]; -} - -void BitVector::clear() { - BitVector().swap(this); -} - -void BitVector::swap(BitVector *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - blocks_.swap(&rhs->blocks_); - Swap(&size_, &rhs->size_); - ranks_.swap(&rhs->ranks_); - select0s_.swap(&rhs->select0s_); - select1s_.swap(&rhs->select1s_); -} - -} // namespace marisa diff --git a/lib/marisa/bitvector.h b/lib/marisa/bitvector.h deleted file mode 100644 index 4044451..0000000 --- a/lib/marisa/bitvector.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef MARISA_BITVECTOR_H_ -#define MARISA_BITVECTOR_H_ - -#include "rank.h" -#include "vector.h" - -namespace marisa { - -class BitVector { - public: - BitVector(); - - void build(); - - void clear_select0s() { - select0s_.clear(); - } - void clear_select1s() { - select1s_.clear(); - } - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - void push_back(bool bit) { - MARISA_THROW_IF(size_ == max_size(), MARISA_SIZE_ERROR); - if ((size_ % 32) == 0) { - blocks_.push_back(0); - } - if (bit) { - blocks_.back() |= 1U << (size_ % 32); - } - ++size_; - } - - bool operator[](std::size_t i) const { - MARISA_DEBUG_IF(i >= size_, MARISA_PARAM_ERROR); - return (blocks_[i / 32] & (1U << (i % 32))) != 0; - } - - UInt32 rank0(UInt32 i) const { - MARISA_DEBUG_IF(i > size_, MARISA_PARAM_ERROR); - return i - rank1(i); - } - UInt32 rank1(UInt32 i) const; - - UInt32 select0(UInt32 i) const; - UInt32 select1(UInt32 i) const; - - std::size_t size() const { - return size_; - } - bool empty() const { - return blocks_.empty(); - } - std::size_t max_size() const { - return MARISA_UINT32_MAX; - } - std::size_t total_size() const { - return blocks_.total_size() + sizeof(size_) + ranks_.total_size() - + select0s_.total_size() + select1s_.total_size(); - } - - void clear(); - void swap(BitVector *rhs); - - private: - Vector blocks_; - UInt32 size_; - Vector ranks_; - Vector select0s_; - Vector select1s_; - - // Disallows copy and assignment. - BitVector(const BitVector &); - BitVector &operator=(const BitVector &); -}; - -} // namespace marisa - -#endif // MARISA_BITVECTOR_H_ diff --git a/lib/marisa/cell.h b/lib/marisa/cell.h deleted file mode 100644 index 3f3863b..0000000 --- a/lib/marisa/cell.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef MARISA_CELL_H_ -#define MARISA_CELL_H_ - -#include "base.h" - -namespace marisa { - -class Cell { - public: - Cell() : louds_pos_(0), node_(0), key_id_(0), length_(0) {} - - void set_louds_pos(UInt32 louds_pos) { - louds_pos_ = louds_pos; - } - void set_node(UInt32 node) { - node_ = node; - } - void set_key_id(UInt32 key_id) { - key_id_ = key_id; - } - void set_length(std::size_t length) { - length_ = length; - } - - UInt32 louds_pos() const { - return louds_pos_; - } - UInt32 node() const { - return node_; - } - UInt32 key_id() const { - return key_id_; - } - std::size_t length() const { - return length_; - } - - private: - UInt32 louds_pos_; - UInt32 node_; - UInt32 key_id_; - std::size_t length_; -}; -} // namespace marisa - -#endif // MARISA_CELL_H_ diff --git a/lib/marisa/container.h b/lib/marisa/container.h deleted file mode 100644 index 6b47694..0000000 --- a/lib/marisa/container.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef MARISA_CONTAINER_H_ -#define MARISA_CONTAINER_H_ - -#include - -#include "base.h" - -namespace marisa { - -template -class Container; - -template -class Container *> { - public: - Container(std::vector *vec) : vec_(vec) {} - Container(const Container &container) : vec_(container.vec_) {} - - void insert(std::size_t, const T &value) const { - vec_->push_back(value); - } - - bool is_valid() const { - return vec_ != NULL; - } - - private: - std::vector *vec_; - - // Disallows assignment. - Container &operator=(const Container &query); -}; - -template -class Container { - public: - explicit Container(T *ptr) : ptr_(ptr) {} - Container(const Container &container) : ptr_(container.ptr_) {} - - void insert(std::size_t i, const T &value) { - ptr_[i] = value; - } - - bool is_valid() const { - return ptr_ != NULL; - } - - private: - T *ptr_; - - // Disallows assignment. - Container &operator=(const Container &); -}; - -template -inline Container MakeContainer(T *ptr) { - return Container(ptr); -} - -} // namespace marisa - -#endif // MARISA_CONTAINER_H_ diff --git a/lib/marisa/intvector.cc b/lib/marisa/intvector.cc deleted file mode 100644 index d90ae84..0000000 --- a/lib/marisa/intvector.cc +++ /dev/null @@ -1,138 +0,0 @@ -#include "intvector.h" - -namespace marisa { - -IntVector::IntVector() - : units_(), num_bits_per_int_(0), mask_(0), size_(0) {} - -void IntVector::build(const Vector &ints) { - UInt32 max_int = 0; - for (UInt32 i = 0; i < ints.size(); ++i) { - if (ints[i] > max_int) { - max_int = ints[i]; - } - } - build(max_int, ints.size()); - for (UInt32 i = 0; i < ints.size(); ++i) { - set(i, ints[i]); - } -} - -void IntVector::build(UInt32 max_int, std::size_t size) { - UInt32 num_bits_per_int = 0; - do { - ++num_bits_per_int; - max_int >>= 1; - } while (max_int != 0); - - const std::size_t new_size = (std::size_t)( - (((UInt64)num_bits_per_int * size) + 31) / 32); - - Vector temp_units; - temp_units.resize(new_size, 0); - units_.swap(&temp_units); - - num_bits_per_int_ = num_bits_per_int; - mask_ = ~0U; - if (num_bits_per_int != 32) { - mask_ = (1U << num_bits_per_int) - 1; - } - size_ = (UInt32)size; -} - -void IntVector::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_THROW_IF(mapper == NULL, MARISA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void IntVector::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void IntVector::map(Mapper &mapper) { - IntVector temp; - temp.units_.map(mapper); - mapper.map(&temp.num_bits_per_int_); - mapper.map(&temp.mask_); - mapper.map(&temp.size_); - temp.swap(this); -} - -void IntVector::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void IntVector::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -void IntVector::read(int fd) { - Reader reader(fd); - read(reader); -} - -void IntVector::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void IntVector::read(Reader &reader) { - IntVector temp; - temp.units_.read(reader); - reader.read(&temp.num_bits_per_int_); - reader.read(&temp.mask_); - reader.read(&temp.size_); - temp.swap(this); -} - -void IntVector::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void IntVector::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -void IntVector::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void IntVector::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void IntVector::write(Writer &writer) const { - units_.write(writer); - writer.write(num_bits_per_int_); - writer.write(mask_); - writer.write(size_); -} - -void IntVector::clear() { - IntVector().swap(this); -} - -void IntVector::swap(IntVector *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - units_.swap(&rhs->units_); - Swap(&num_bits_per_int_, &rhs->num_bits_per_int_); - Swap(&mask_, &rhs->mask_); - Swap(&size_, &rhs->size_); -} - -} // namespace marisa diff --git a/lib/marisa/intvector.h b/lib/marisa/intvector.h deleted file mode 100644 index 7ec8d8b..0000000 --- a/lib/marisa/intvector.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef MARISA_INTVECTOR_H_ -#define MARISA_INTVECTOR_H_ - -#include "vector.h" - -namespace marisa { - -class IntVector { - public: - IntVector(); - - void build(const Vector &ints); - void build(UInt32 max_int, std::size_t size); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - void set(std::size_t i, UInt32 value) { - MARISA_DEBUG_IF(i >= size_, MARISA_PARAM_ERROR); - std::size_t pos = i * num_bits_per_int_; - std::size_t unit_id = pos / 32; - std::size_t unit_offset = pos % 32; - units_[unit_id] &= ~(mask_ << unit_offset); - units_[unit_id] |= (value & mask_) << unit_offset; - if ((unit_offset + num_bits_per_int_) > 32) { - units_[unit_id + 1] &= ~(mask_ >> (32 - unit_offset)); - units_[unit_id + 1] |= (value & mask_) >> (32 - unit_offset); - } - } - - UInt32 get(std::size_t i) const { - MARISA_DEBUG_IF(i >= size_, MARISA_PARAM_ERROR); - std::size_t pos = i * num_bits_per_int_; - std::size_t unit_id = pos / 32; - std::size_t unit_offset = pos % 32; - if ((unit_offset + num_bits_per_int_) <= 32) { - return (units_[unit_id] >> unit_offset) & mask_; - } else { - return ((units_[unit_id] >> unit_offset) - | (units_[unit_id + 1] << (32 - unit_offset))) & mask_; - } - } - - UInt32 operator[](std::size_t i) const { - MARISA_DEBUG_IF(i >= size_, MARISA_PARAM_ERROR); - return get(i); - } - - std::size_t num_bits_per_int() const { - return num_bits_per_int_; - } - UInt32 mask() const { - return mask_; - } - std::size_t size() const { - return size_; - } - bool empty() const { - return size_ == 0; - } - std::size_t total_size() const { - return units_.total_size() + sizeof(num_bits_per_int_) - + sizeof(mask_) + sizeof(size_); - } - - void clear(); - void swap(IntVector *rhs); - - private: - Vector units_; - UInt32 num_bits_per_int_; - UInt32 mask_; - UInt32 size_; - - // Disallows copy and assignment. - IntVector(const IntVector &); - IntVector &operator=(const IntVector &); -}; - -} // namespace marisa - -#endif // MARISA_INTVECTOR_H_ diff --git a/lib/marisa/io.h b/lib/marisa/io.h deleted file mode 100644 index af34c94..0000000 --- a/lib/marisa/io.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MARISA_IO_H_ -#define MARISA_IO_H_ - -#include "mapper.h" -#include "reader.h" -#include "writer.h" - -#endif // MARISA_IO_H_ diff --git a/lib/marisa/key.h b/lib/marisa/key.h deleted file mode 100644 index eac27be..0000000 --- a/lib/marisa/key.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef MARISA_KEY_H_ -#define MARISA_KEY_H_ - -namespace marisa { - -template -class Key { - public: - Key() : str_(), weight_(0.0), id_(0), terminal_(0) {} - - void set_str(const T &str) { - str_ = str; - } - void set_weight(double weight) { - weight_ = weight; - } - void set_id(UInt32 id) { - id_ = id; - } - void set_terminal(UInt32 terminal) { - terminal_ = terminal; - } - - const T &str() const { - return str_; - } - double weight() const { - return weight_; - } - UInt32 id() const { - return id_; - } - UInt32 terminal() const { - return terminal_; - } - - private: - T str_; - double weight_; - UInt32 id_; - UInt32 terminal_; -}; - -template -inline bool operator<(const Key &lhs, const T &rhs) { - return lhs.str() < rhs; -} - -template -inline bool operator<(const T &lhs, const Key &rhs) { - return lhs < rhs.str(); -} - -template -inline bool operator<(const Key &lhs, const Key &rhs) { - return lhs.str() < rhs.str(); -} - -template -inline bool operator==(const Key &lhs, const Key &rhs) { - return lhs.str() == rhs.str(); -} - -} // namespace marisa - -#endif // MARISA_KEY_H_ diff --git a/lib/marisa/mapper.cc b/lib/marisa/mapper.cc deleted file mode 100644 index 4562a6d..0000000 --- a/lib/marisa/mapper.cc +++ /dev/null @@ -1,166 +0,0 @@ -#if defined _WIN32 || defined _WIN64 -#include -#include -#include -#else // defined _WIN32 || defined _WIN64 -#include -#include -#include -#include -#include -#endif // defined _WIN32 || defined _WIN64 - -#include "mapper.h" - -namespace marisa { - -#if defined _WIN32 || defined _WIN64 -Mapper::Mapper() - : ptr_(NULL), origin_(NULL), avail_(0), size_(0), - file_(NULL), map_(NULL) {} - -Mapper::Mapper(const void *ptr, std::size_t size) - : ptr_(ptr), origin_(NULL), avail_(size), size_(0), - file_(NULL), map_(NULL) { - MARISA_THROW_IF((ptr == NULL) || (size == 0), MARISA_PARAM_ERROR); -} -#else // defined _WIN32 || defined _WIN64 -Mapper::Mapper() - : ptr_(NULL), origin_(MAP_FAILED), avail_(0), size_(0), fd_(-1) {} - -Mapper::Mapper(const void *ptr, std::size_t size) - : ptr_(ptr), origin_(MAP_FAILED), avail_(size), size_(0), fd_(-1) { - MARISA_THROW_IF((ptr == NULL) || (size == 0), MARISA_PARAM_ERROR); -} -#endif // defined _WIN32 || defined _WIN64 - -#if defined _WIN32 || defined _WIN64 -Mapper::~Mapper() { - if (origin_ != NULL) { - ::UnmapViewOfFile(origin_); - } - - if (map_ != NULL) { - ::CloseHandle(map_); - } - - if (file_ != NULL) { - ::CloseHandle(file_); - } -} -#else // defined _WIN32 || defined _WIN64 -Mapper::~Mapper() { - if (origin_ != MAP_FAILED) { - ::munmap(origin_, size_); - } - - if (fd_ != -1) { - ::close(fd_); - } -} -#endif // defined _WIN32 || defined _WIN64 - -#if defined _WIN32 || defined _WIN64 -void Mapper::open(const char *filename, long offset, int whence) { - MARISA_THROW_IF(is_open(), MARISA_STATE_ERROR); - MARISA_THROW_IF(filename == NULL, MARISA_PARAM_ERROR); - - struct __stat64 st; - if (::_stat64(filename, &st) != 0) { - MARISA_THROW(MARISA_IO_ERROR); - } - const UInt64 file_size = st.st_size; - MARISA_THROW_IF(file_size > MARISA_UINT32_MAX, MARISA_SIZE_ERROR); - - Mapper temp; - temp.size_ = (std::size_t)file_size; - - temp.file_ = ::CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - MARISA_THROW_IF(temp.file_ == NULL, MARISA_IO_ERROR); - - temp.map_ = ::CreateFileMapping(temp.file_, NULL, PAGE_READONLY, 0, 0, NULL); - MARISA_THROW_IF(temp.map_ == NULL, MARISA_IO_ERROR); - - temp.origin_ = ::MapViewOfFile(temp.map_, FILE_MAP_READ, 0, 0, 0); - MARISA_THROW_IF(temp.origin_ == NULL, MARISA_IO_ERROR); - - temp.seek(offset, whence); - temp.swap(this); -} -#else // defined _WIN32 || defined _WIN64 -void Mapper::open(const char *filename, long offset, int whence) { - MARISA_THROW_IF(is_open(), MARISA_STATE_ERROR); - MARISA_THROW_IF(filename == NULL, MARISA_PARAM_ERROR); - - struct stat st; - if (::stat(filename, &st) != 0) { - MARISA_THROW(MARISA_IO_ERROR); - } - UInt64 file_size = st.st_size; - MARISA_THROW_IF(file_size > MARISA_UINT32_MAX, MARISA_SIZE_ERROR); - - Mapper temp; - temp.size_ = (std::size_t)file_size; - - temp.fd_ = ::open(filename, O_RDONLY); - MARISA_THROW_IF(temp.fd_ == -1, MARISA_IO_ERROR); - - temp.origin_ = ::mmap(NULL, temp.size_, PROT_READ, MAP_SHARED, temp.fd_, 0); - MARISA_THROW_IF(temp.origin_ == MAP_FAILED, MARISA_IO_ERROR); - - temp.seek(offset, whence); - temp.swap(this); -} -#endif // defined _WIN32 || defined _WIN64 - -void Mapper::clear() { - Mapper().swap(this); -} - -void Mapper::swap(Mapper *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - Swap(&ptr_, &rhs->ptr_); - Swap(&avail_, &rhs->avail_); - Swap(&origin_, &rhs->origin_); - Swap(&size_, &rhs->size_); -#if defined _WIN32 || defined _WIN64 - Swap(&file_, &rhs->file_); - Swap(&map_, &rhs->map_); -#else // defined _WIN32 || defined _WIN64 - Swap(&fd_, &rhs->fd_); -#endif // defined _WIN32 || defined _WIN64 -} - -void Mapper::seek(long offset, int whence) { - switch (whence) { - case SEEK_SET: - case SEEK_CUR: { - MARISA_THROW_IF((offset < 0) || ((unsigned long)offset > size_), - MARISA_IO_ERROR); - ptr_ = static_cast(origin_) + offset; - avail_ = (std::size_t)(size_ - offset); - return; - } - case SEEK_END: { - MARISA_THROW_IF((offset > 0) || ((unsigned long)-offset > size_), - MARISA_IO_ERROR); - ptr_ = static_cast(origin_) + size_ + offset; - avail_ = (std::size_t)-offset; - return; - } - default: { - MARISA_THROW(MARISA_PARAM_ERROR); - } - } -} - -const void *Mapper::map_data(std::size_t size) { - MARISA_THROW_IF(!is_open(), MARISA_STATE_ERROR); - MARISA_THROW_IF(size > avail_, MARISA_IO_ERROR); - ptr_ = static_cast(ptr_) + size; - avail_ -= size; - return static_cast(ptr_) - size; -} - -} // namespace marisa diff --git a/lib/marisa/mapper.h b/lib/marisa/mapper.h deleted file mode 100644 index 3d47305..0000000 --- a/lib/marisa/mapper.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef MARISA_MAPPER_H_ -#define MARISA_MAPPER_H_ - -#include - -#include "base.h" - -namespace marisa { - -class Mapper { - public: - Mapper(); - Mapper(const void *ptr, std::size_t size); - ~Mapper(); - - void open(const char *filename, long offset = 0, int whence = SEEK_SET); - - template - void map(T *obj) { - MARISA_THROW_IF(obj == NULL, MARISA_PARAM_ERROR); - *obj = *static_cast(map_data(sizeof(T))); - } - - template - void map(const T **objs, std::size_t num_objs) { - MARISA_THROW_IF((objs == NULL) && (num_objs != 0), MARISA_PARAM_ERROR); - MARISA_THROW_IF(num_objs > (MARISA_UINT32_MAX / sizeof(T)), - MARISA_SIZE_ERROR); - *objs = static_cast(map_data(sizeof(T) * num_objs)); - } - - bool is_open() const { - return ptr_ != NULL; - } - - void clear(); - void swap(Mapper *rhs); - - private: - const void *ptr_; - void *origin_; - std::size_t avail_; - std::size_t size_; -#if defined _WIN32 || defined _WIN64 - void *file_; - void *map_; -#else // defined _WIN32 || defined _WIN64 - int fd_; -#endif // defined _WIN32 || defined _WIN64 - - void seek(long offset, int whence); - - const void *map_data(std::size_t size); - - // Disallows copy and assignment. - Mapper(const Mapper &); - Mapper &operator=(const Mapper &); -}; - -} // namespace marisa - -#endif // MARISA_MAPPER_H_ diff --git a/lib/marisa/marisa-string.h b/lib/marisa/marisa-string.h deleted file mode 100644 index b0e272e..0000000 --- a/lib/marisa/marisa-string.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef MARISA_STRING_H_ -#define MARISA_STRING_H_ - -#include "base.h" - -namespace marisa { - -class String { - public: - String() : ptr_(NULL), length_(0) {} - explicit String(const char *str) : ptr_(str), length_(0) { - while (str[length_] != '\0') { - ++length_; - } - } - String(const char *ptr, std::size_t length) - : ptr_(ptr), length_(length) {} - String(const String &str) : ptr_(str.ptr_), length_(str.length_) {} - - String substr(std::size_t pos, std::size_t length) const { - MARISA_DEBUG_IF(pos + length > length_, MARISA_PARAM_ERROR); - return String(ptr_ + pos, length); - } - - String &operator=(const String &str) { - ptr_ = str.ptr_; - length_ = str.length_; - return *this; - } - - UInt8 operator[](std::size_t i) const { - MARISA_DEBUG_IF(i >= length_, MARISA_PARAM_ERROR); - return ptr_[i]; - } - - const char *ptr() const { - return ptr_; - } - std::size_t length() const { - return length_; - } - - private: - const char *ptr_; - std::size_t length_; -}; - -inline bool operator==(const String &lhs, const String &rhs) { - if (lhs.length() != rhs.length()) { - return false; - } - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (lhs[i] != rhs[i]) { - return false; - } - } - return true; -} - -inline bool operator!=(const String &lhs, const String &rhs) { - return !(lhs == rhs); -} - -inline bool operator<(const String &lhs, const String &rhs) { - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (i == rhs.length()) { - return false; - } - if (lhs[i] != rhs[i]) { - return lhs[i] < rhs[i]; - } - } - return lhs.length() < rhs.length(); -} - -inline bool operator>(const String &lhs, const String &rhs) { - return rhs < lhs; -} - -class RString { - public: - RString() - : ptr_(static_cast(NULL) - 1), length_(0) {} - explicit RString(const String &str) - : ptr_(str.ptr() + str.length() - 1), length_(str.length()) {} - RString(const RString &str) - : ptr_(str.ptr_), length_(str.length_) {} - - RString substr(std::size_t pos, std::size_t length) const { - MARISA_DEBUG_IF(pos + length > length_, MARISA_PARAM_ERROR); - RString str(*this); - str.ptr_ -= pos; - str.length_ = length; - return str; - } - - RString &operator=(const RString &str) { - ptr_ = str.ptr_; - length_ = str.length_; - return *this; - } - - UInt8 operator[](std::size_t i) const { - MARISA_DEBUG_IF(i >= length_, MARISA_PARAM_ERROR); - return *(ptr_ - i); - } - - const char *ptr() const { - return ptr_ - length_ + 1; - } - std::size_t length() const { - return length_; - } - - private: - const char *ptr_; - std::size_t length_; -}; - -inline bool operator==(const RString &lhs, const RString &rhs) { - if (lhs.length() != rhs.length()) { - return false; - } - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (lhs[i] != rhs[i]) { - return false; - } - } - return true; -} - -inline bool operator!=(const RString &lhs, const RString &rhs) { - return !(lhs == rhs); -} - -inline bool operator<(const RString &lhs, const RString &rhs) { - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (i == rhs.length()) { - return false; - } - if (lhs[i] != rhs[i]) { - return lhs[i] < rhs[i]; - } - } - return lhs.length() < rhs.length(); -} - -inline bool operator>(const RString &lhs, const RString &rhs) { - return rhs < lhs; -} - -} // namespace marisa - -#endif // MARISA_STRING_H_ diff --git a/lib/marisa/popcount.h b/lib/marisa/popcount.h deleted file mode 100644 index 8a06f10..0000000 --- a/lib/marisa/popcount.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef MARISA_POPCOUNT_H_ -#define MARISA_POPCOUNT_H_ - -#include "base.h" - -namespace marisa { - -class PopCount { - public: - PopCount(UInt32 x) : value_() { - x = (x & 0x55555555U) + ((x & 0xAAAAAAAAU) >> 1); - x = (x & 0x33333333U) + ((x & 0xCCCCCCCCU) >> 2); - x = (x + (x >> 4)) & 0x0F0F0F0FU; - x += x << 8; - x += x << 16; - value_ = x; - } - - UInt32 lo8() const { - return value_ & 0xFFU; - } - UInt32 lo16() const { - return (value_ >> 8) & 0xFFU; - } - UInt32 lo24() const { - return (value_ >> 16) & 0xFFU; - } - UInt32 lo32() const { - return value_ >> 24; - } - - private: - UInt32 value_; -}; - -} // namespace marisa - -#endif // MARISA_POPCOUNT_H_ diff --git a/lib/marisa/progress.cc b/lib/marisa/progress.cc deleted file mode 100644 index a17a756..0000000 --- a/lib/marisa/progress.cc +++ /dev/null @@ -1,55 +0,0 @@ -#include "progress.h" - -namespace marisa { - -Progress::Progress(int flags) : flags_(flags), trie_id_(0), total_size_(0) { - if ((flags_ & MARISA_NUM_TRIES_MASK) == 0) { - flags_ = (flags_ & ~MARISA_NUM_TRIES_MASK) | MARISA_DEFAULT_NUM_TRIES; - } - if ((flags & MARISA_TRIE_MASK) == 0) { - flags_ = (flags_ & ~MARISA_TRIE_MASK) | MARISA_DEFAULT_TRIE; - } - if ((flags & MARISA_TAIL_MASK) == 0) { - flags_ = (flags_ & ~MARISA_TAIL_MASK) | MARISA_DEFAULT_TAIL; - } - if ((flags & MARISA_ORDER_MASK) == 0) { - flags_ = (flags_ & ~MARISA_ORDER_MASK) | MARISA_DEFAULT_ORDER; - } -} - -bool Progress::is_valid() const { - if ((flags_ & ~MARISA_FLAGS_MASK) != 0) { - return false; - } - switch (flags_ & MARISA_TRIE_MASK) { - case MARISA_PATRICIA_TRIE: - case MARISA_PREFIX_TRIE: { - break; - } - default: { - return false; - } - } - switch (flags_ & MARISA_TAIL_MASK) { - case MARISA_WITHOUT_TAIL: - case MARISA_BINARY_TAIL: - case MARISA_TEXT_TAIL: { - break; - } - default: { - return false; - } - } - switch (flags_ & MARISA_ORDER_MASK) { - case MARISA_LABEL_ORDER: - case MARISA_WEIGHT_ORDER: { - break; - } - default: { - return false; - } - } - return true; -} - -} // namespace marisa diff --git a/lib/marisa/progress.h b/lib/marisa/progress.h deleted file mode 100644 index 32e2e04..0000000 --- a/lib/marisa/progress.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef MARISA_PROGRESS_H_ -#define MARISA_PROGRESS_H_ - -#include "base.h" - -namespace marisa { - -class Progress { - public: - explicit Progress(int flags); - - bool is_valid() const; - bool is_last() const { - return (trie_id_ + 1) >= num_tries(); - } - - Progress &operator++() { - ++trie_id_; - return *this; - } - - void test_total_size(std::size_t total_size) { - MARISA_THROW_IF(total_size_ > (MARISA_UINT32_MAX - total_size), - MARISA_SIZE_ERROR); - total_size_ += total_size; - } - - int flags() const { - return flags_; - } - int trie_id() const { - return trie_id_; - } - std::size_t total_size() const { - return total_size_; - } - - int num_tries() const { - return flags_ & MARISA_NUM_TRIES_MASK; - } - int trie() const { - return flags_ & MARISA_TRIE_MASK; - } - int tail() const { - return flags_ & MARISA_TAIL_MASK; - } - int order() const { - return flags_ & MARISA_ORDER_MASK; - } - - private: - int flags_; - int trie_id_; - std::size_t total_size_; - - // Disallows copy and assignment. - Progress(const Progress &); - Progress &operator=(const Progress &); -}; - -} // namespace marisa - -#endif // MARISA_PROGRESS_H_ diff --git a/lib/marisa/query.h b/lib/marisa/query.h deleted file mode 100644 index 45019e3..0000000 --- a/lib/marisa/query.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef MARISA_QUERY_H_ -#define MARISA_QUERY_H_ - -#include - -#include "base.h" - -namespace marisa { - -class Query { - public: - Query(const char *ptr, std::size_t length) : ptr_(ptr), length_(length) {} - Query(const Query &query) : ptr_(query.ptr_), length_(query.length_) {} - - void insert(std::string *str) const { - str->insert(0, ptr_, length_); - } - - UInt8 operator[](std::size_t i) const { - MARISA_DEBUG_IF(i >= length_, MARISA_PARAM_ERROR); - return ptr_[i]; - } - bool ends_at(std::size_t i) const { - MARISA_DEBUG_IF(i > length_, MARISA_PARAM_ERROR); - return i == length_; - } - - private: - const char *ptr_; - std::size_t length_; - - // Disallows assignment. - Query &operator=(const Query &query); -}; - -class CQuery { - public: - explicit CQuery(const char *str) : str_(str) {} - CQuery(const CQuery &query) : str_(query.str_) {} - - void insert(std::string *str) const { - str->insert(0, str_); - } - - UInt8 operator[](std::size_t i) const { - return str_[i]; - } - bool ends_at(std::size_t i) const { - return str_[i] == '\0'; - } - - private: - const char *str_; - - // Disallows assignment. - CQuery &operator=(const CQuery &); -}; - -} // namespace marisa - -#endif // MARISA_QUERY_H_ diff --git a/lib/marisa/range.h b/lib/marisa/range.h deleted file mode 100644 index 1414087..0000000 --- a/lib/marisa/range.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef MARISA_RANGE_H_ -#define MARISA_RANGE_H_ - -#include "base.h" - -namespace marisa { - -class Range { - public: - Range() : begin_(0), end_(0), pos_(0) {} - Range(UInt32 begin, UInt32 end, UInt32 pos) - : begin_(begin), end_(end), pos_(pos) {} - - void set_begin(UInt32 begin) { - begin_ = begin; - } - void set_end(UInt32 end) { - end_ = end; - } - void set_pos(UInt32 pos) { - pos_ = pos; - } - - UInt32 begin() const { - return begin_; - } - UInt32 end() const { - return end_; - } - UInt32 pos() const { - return pos_; - } - - private: - UInt32 begin_; - UInt32 end_; - UInt32 pos_; -}; - -class WRange { - public: - WRange() : range_(), weight_(0.0) {} - WRange(const Range &range, double weight) - : range_(range), weight_(weight) {} - WRange(UInt32 begin, UInt32 end, UInt32 pos, double weight) - : range_(begin, end, pos), weight_(weight) {} - - void set_begin(UInt32 begin) { - range_.set_begin(begin); - } - void set_end(UInt32 end) { - range_.set_end(end); - } - void set_pos(UInt32 pos) { - range_.set_pos(pos); - } - void set_weight(double weight) { - weight_ = weight; - } - - const Range &range() const { - return range_; - } - UInt32 begin() const { - return range_.begin(); - } - UInt32 end() const { - return range_.end(); - } - UInt32 pos() const { - return range_.pos(); - } - double weight() const { - return weight_; - } - - private: - Range range_; - double weight_; -}; - -inline bool operator>(const WRange &lhs, const WRange &rhs) { - return lhs.weight() > rhs.weight(); -} - -} // namespace marisa - -#endif // MARISA_RANGE_H_ diff --git a/lib/marisa/rank.h b/lib/marisa/rank.h deleted file mode 100644 index 0d937b8..0000000 --- a/lib/marisa/rank.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MARISA_RANK_H_ -#define MARISA_RANK_H_ - -#include "base.h" - -namespace marisa { - -class Rank { - public: - Rank() : abs_(0), rel_lo_(0), rel_hi_(0) {} - - void set_abs(UInt32 value) { - abs_ = value; - } - void set_rel1(UInt32 value) { - MARISA_DEBUG_IF(value > 64, MARISA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~0x7FU) | (value & 0x7FU); - } - void set_rel2(UInt32 value) { - MARISA_DEBUG_IF(value > 128, MARISA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~(0xFFU << 7)) | ((value & 0xFFU) << 7); - } - void set_rel3(UInt32 value) { - MARISA_DEBUG_IF(value > 192, MARISA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~(0xFFU << 15)) | ((value & 0xFFU) << 15); - } - void set_rel4(UInt32 value) { - MARISA_DEBUG_IF(value > 256, MARISA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~(0x1FFU << 23)) | ((value & 0x1FFU) << 23); - } - void set_rel5(UInt32 value) { - MARISA_DEBUG_IF(value > 320, MARISA_PARAM_ERROR); - rel_hi_ = (rel_hi_ & ~0x1FFU) | (value & 0x1FFU); - } - void set_rel6(UInt32 value) { - MARISA_DEBUG_IF(value > 384, MARISA_PARAM_ERROR); - rel_hi_ = (rel_hi_ & ~(0x1FFU << 9)) | ((value & 0x1FFU) << 9); - } - void set_rel7(UInt32 value) { - MARISA_DEBUG_IF(value > 448, MARISA_PARAM_ERROR); - rel_hi_ = (rel_hi_ & ~(0x1FFU << 18)) | ((value & 0x1FFU) << 18); - } - - UInt32 abs() const { - return abs_; - } - UInt32 rel1() const { - return rel_lo_ & 0x7FU; - } - UInt32 rel2() const { - return (rel_lo_ >> 7) & 0xFFU; - } - UInt32 rel3() const { - return (rel_lo_ >> 15) & 0xFFU; - } - UInt32 rel4() const { - return rel_lo_ >> 23; - } - UInt32 rel5() const { - return rel_hi_ & 0x1FFU; - } - UInt32 rel6() const { - return (rel_hi_ >> 9) & 0x1FFU; - } - UInt32 rel7() const { - return (rel_hi_ >> 18) & 0x1FFU; - } - - private: - UInt32 abs_; - UInt32 rel_lo_; - UInt32 rel_hi_; -}; - -} // namespace marisa - -#endif // MARISA_RANK_H_ diff --git a/lib/marisa/reader.cc b/lib/marisa/reader.cc deleted file mode 100644 index df144ef..0000000 --- a/lib/marisa/reader.cc +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include - -#ifdef _MSC_VER -#include -#else // _MSC_VER -#include -#endif // _MSC_VER - -#include "reader.h" - -namespace marisa { - -Reader::Reader() - : file_(NULL), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Reader::Reader(std::FILE *file) - : file_(file), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Reader::Reader(int fd) - : file_(NULL), fd_(fd), stream_(NULL), needs_fclose_(false) {} - -Reader::Reader(std::istream *stream) - : file_(NULL), fd_(-1), stream_(stream), needs_fclose_(false) {} - -Reader::~Reader() { - if (needs_fclose_) { - ::fclose(file_); - } -} - -void Reader::open(const char *filename, long offset, int whence) { - MARISA_THROW_IF(is_open(), MARISA_STATE_ERROR); - MARISA_THROW_IF(filename == NULL, MARISA_PARAM_ERROR); -#ifdef _MSC_VER - std::FILE *file = NULL; - if (::fopen_s(&file, filename, "rb") != 0) { - MARISA_THROW(MARISA_IO_ERROR); - } -#else // _MSC_VER - std::FILE * const file = ::fopen(filename, "rb"); - MARISA_THROW_IF(file == NULL, MARISA_IO_ERROR); -#endif // _MSC_VER - if (::fseek(file, offset, whence) != 0) { - ::fclose(file); - MARISA_THROW(MARISA_IO_ERROR); - } - file_ = file; - needs_fclose_ = true; -} - -void Reader::clear() { - Reader().swap(this); -} - -void Reader::swap(Reader *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - Swap(&file_, &rhs->file_); - Swap(&fd_, &rhs->fd_); - Swap(&stream_, &rhs->stream_); - Swap(&needs_fclose_, &rhs->needs_fclose_); -} - -void Reader::read_data(void *buf, std::size_t size) { - if (fd_ != -1) { - while (size != 0) { -#ifdef _MSC_VER - const unsigned int count = (size < INT_MAX) ? size : INT_MAX; - const int size_read = _read(fd_, buf, count); -#else // _MSC_VER - const ::size_t count = (size < SSIZE_MAX) ? size : SSIZE_MAX; - const ::ssize_t size_read = ::read(fd_, buf, count); -#endif // _MSC_VER - MARISA_THROW_IF(size_read <= 0, MARISA_IO_ERROR); - buf = static_cast(buf) + size_read; - size -= size_read; - } - } else if (file_ != NULL) { - if (::fread(buf, 1, size, file_) != size) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else if (stream_ != NULL) { - if (!stream_->read(static_cast(buf), size)) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else { - MARISA_THROW(MARISA_STATE_ERROR); - } -} - -} // namespace marisa diff --git a/lib/marisa/reader.h b/lib/marisa/reader.h deleted file mode 100644 index a55d7b8..0000000 --- a/lib/marisa/reader.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef MARISA_READER_H_ -#define MARISA_READER_H_ - -#include -#include - -#include "base.h" - -namespace marisa { - -class Reader { - public: - Reader(); - explicit Reader(std::FILE *file); - explicit Reader(int fd); - explicit Reader(std::istream *stream); - ~Reader(); - - void open(const char *filename, long offset = 0, int whence = SEEK_SET); - - template - void read(T *obj) { - MARISA_THROW_IF(obj == NULL, MARISA_PARAM_ERROR); - read_data(obj, sizeof(T)); - } - - template - void read(T *objs, std::size_t num_objs) { - MARISA_THROW_IF((objs == NULL) && (num_objs != 0), MARISA_PARAM_ERROR); - MARISA_THROW_IF(num_objs > (MARISA_UINT32_MAX / sizeof(T)), - MARISA_SIZE_ERROR); - if (num_objs != 0) { - read_data(objs, sizeof(T) * num_objs); - } - } - - bool is_open() const { - return (file_ != NULL) || (fd_ != -1) || (stream_ != NULL); - } - - void clear(); - void swap(Reader *rhs); - - private: - std::FILE *file_; - int fd_; - std::istream *stream_; - bool needs_fclose_; - - void read_data(void *buf, std::size_t size); - - // Disallows copy and assignment. - Reader(const Reader &); - Reader &operator=(const Reader &); -}; - -} // namespace marisa - -#endif // MARISA_READER_H_ diff --git a/lib/marisa/tail.cc b/lib/marisa/tail.cc deleted file mode 100644 index eb8b11e..0000000 --- a/lib/marisa/tail.cc +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include - -#include "tail.h" - -namespace marisa { - -Tail::Tail() : buf_() {} - -void Tail::build(const Vector &keys, - Vector *offsets, int mode) { - switch (mode) { - case MARISA_BINARY_TAIL: { - build_binary_tail(keys, offsets); - return; - } - case MARISA_TEXT_TAIL: { - if (!build_text_tail(keys, offsets)) { - build_binary_tail(keys, offsets); - } - return; - } - default: { - MARISA_THROW(MARISA_PARAM_ERROR); - } - } -} - -void Tail::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - if (mapper == NULL) { - MARISA_THROW(MARISA_PARAM_ERROR); - } - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void Tail::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void Tail::map(Mapper &mapper) { - Tail temp; - temp.buf_.map(mapper); - temp.swap(this); -} - -void Tail::load(const char *filename, long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void Tail::fread(::FILE *file) { - Reader reader(file); - read(reader); -} - -void Tail::read(int fd) { - Reader reader(fd); - read(reader); -} - -void Tail::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void Tail::read(Reader &reader) { - Tail temp; - temp.buf_.read(reader); - temp.swap(this); -} - -void Tail::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void Tail::fwrite(::FILE *file) const { - Writer writer(file); - write(writer); -} - -void Tail::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void Tail::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void Tail::write(Writer &writer) const { - buf_.write(writer); -} - -void Tail::clear() { - Tail().swap(this); -} - -void Tail::swap(Tail *rhs) { - buf_.swap(&rhs->buf_); -} - -void Tail::build_binary_tail(const Vector &keys, - Vector *offsets) { - if (keys.empty()) { - build_empty_tail(offsets); - return; - } - - Vector buf; - buf.push_back('\0'); - - Vector temp_offsets; - temp_offsets.resize(keys.size() + 1); - - for (std::size_t i = 0; i < keys.size(); ++i) { - temp_offsets[i] = (UInt32)buf.size(); - for (std::size_t j = 0; j < keys[i].length(); ++j) { - buf.push_back(keys[i][j]); - } - } - temp_offsets.back() = (UInt32)buf.size(); - buf.shrink(); - - if (offsets != NULL) { - temp_offsets.swap(offsets); - } - buf_.swap(&buf); -} - -bool Tail::build_text_tail(const Vector &keys, - Vector *offsets) { - if (keys.empty()) { - build_empty_tail(offsets); - return true; - } - - typedef std::pair KeyIdPair; - Vector pairs; - pairs.resize(keys.size()); - for (std::size_t i = 0; i < keys.size(); ++i) { - for (std::size_t j = 0; j < keys[i].length(); ++j) { - if (keys[i][j] == '\0') { - return false; - } - } - pairs[i].first = RString(keys[i]); - pairs[i].second = (UInt32)i; - } - std::sort(pairs.begin(), pairs.end(), std::greater()); - - Vector buf; - buf.push_back('T'); - - Vector temp_offsets; - temp_offsets.resize(pairs.size(), 1); - - const KeyIdPair dummy_key; - const KeyIdPair *last = &dummy_key; - for (std::size_t i = 0; i < pairs.size(); ++i) { - const KeyIdPair &cur = pairs[i]; - std::size_t match = 0; - while ((match < cur.first.length()) && (match < last->first.length()) && - last->first[match] == cur.first[match]) { - ++match; - } - if ((match == cur.first.length()) && (last->first.length() != 0)) { - temp_offsets[cur.second] = (UInt32)(temp_offsets[last->second] - + (last->first.length() - match)); - } else { - temp_offsets[cur.second] = (UInt32)buf.size(); - for (std::size_t j = 1; j <= cur.first.length(); ++j) { - buf.push_back(cur.first[cur.first.length() - j]); - } - buf.push_back('\0'); - } - last = &cur; - } - buf.shrink(); - - if (offsets != NULL) { - temp_offsets.swap(offsets); - } - buf_.swap(&buf); - return true; -} - -void Tail::build_empty_tail(Vector *offsets) { - buf_.clear(); - if (offsets != NULL) { - offsets->clear(); - } -} - -} // namespace marisa diff --git a/lib/marisa/tail.h b/lib/marisa/tail.h deleted file mode 100644 index a8a2b1e..0000000 --- a/lib/marisa/tail.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef MARISA_TAIL_H_ -#define MARISA_TAIL_H_ - -#include "marisa-string.h" -#include "vector.h" - -namespace marisa { - -class Tail { - public: - Tail(); - - void build(const Vector &keys, - Vector *offsets, int mode); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - const UInt8 *operator[](std::size_t offset) const { - MARISA_DEBUG_IF(offset >= buf_.size(), MARISA_PARAM_ERROR); - return &buf_[offset]; - } - - int mode() const { - return (buf_.front() == '\0') ? MARISA_BINARY_TAIL : MARISA_TEXT_TAIL; - } - bool empty() const { - return buf_.empty(); - } - std::size_t size() const { - return buf_.size(); - } - std::size_t total_size() const { - return buf_.total_size(); - } - - void clear(); - void swap(Tail *rhs); - - private: - Vector buf_; - - void build_binary_tail(const Vector &keys, - Vector *offsets); - bool build_text_tail(const Vector &keys, - Vector *offsets); - void build_empty_tail(Vector *offsets); - - // Disallows copy and assignment. - Tail(const Tail &); - Tail &operator=(const Tail &); -}; - -} // namespace marisa - -#endif // MARISA_TAIL_H_ diff --git a/lib/marisa/trie-build.cc b/lib/marisa/trie-build.cc deleted file mode 100644 index fb7f072..0000000 --- a/lib/marisa/trie-build.cc +++ /dev/null @@ -1,328 +0,0 @@ -#include -#include -#include -#include - -#include "range.h" -#include "trie.h" - -namespace marisa { - -void Trie::build(const char * const *keys, std::size_t num_keys, - const std::size_t *key_lengths, const double *key_weights, - UInt32 *key_ids, int flags) { - MARISA_THROW_IF((keys == NULL) && (num_keys != 0), MARISA_PARAM_ERROR); - Vector > temp_keys; - temp_keys.resize(num_keys); - for (std::size_t i = 0; i < temp_keys.size(); ++i) { - MARISA_THROW_IF(keys[i] == NULL, MARISA_PARAM_ERROR); - std::size_t length = 0; - if (key_lengths == NULL) { - while (keys[i][length] != '\0') { - ++length; - } - } else { - length = key_lengths[i]; - } - MARISA_THROW_IF(length > MARISA_MAX_LENGTH, MARISA_SIZE_ERROR); - temp_keys[i].set_str(String(keys[i], length)); - temp_keys[i].set_weight((key_weights != NULL) ? key_weights[i] : 1.0); - } - build_trie(temp_keys, key_ids, flags); -} - -void Trie::build(const std::vector &keys, - std::vector *key_ids, int flags) { - Vector > temp_keys; - temp_keys.resize(keys.size()); - for (std::size_t i = 0; i < temp_keys.size(); ++i) { - MARISA_THROW_IF(keys[i].length() > MARISA_MAX_LENGTH, MARISA_SIZE_ERROR); - temp_keys[i].set_str(String(keys[i].c_str(), keys[i].length())); - temp_keys[i].set_weight(1.0); - } - build_trie(temp_keys, key_ids, flags); -} - -void Trie::build(const std::vector > &keys, - std::vector *key_ids, int flags) { - Vector > temp_keys; - temp_keys.resize(keys.size()); - for (std::size_t i = 0; i < temp_keys.size(); ++i) { - MARISA_THROW_IF(keys[i].first.length() > MARISA_MAX_LENGTH, - MARISA_SIZE_ERROR); - temp_keys[i].set_str(String( - keys[i].first.c_str(), keys[i].first.length())); - temp_keys[i].set_weight(keys[i].second); - } - build_trie(temp_keys, key_ids, flags); -} - -void Trie::build_trie(Vector > &keys, - std::vector *key_ids, int flags) { - if (key_ids == NULL) { - build_trie(keys, static_cast(NULL), flags); - return; - } - std::vector temp_key_ids(keys.size()); - build_trie(keys, temp_key_ids.empty() ? NULL : &temp_key_ids[0], flags); - key_ids->swap(temp_key_ids); -} - -void Trie::build_trie(Vector > &keys, - UInt32 *key_ids, int flags) { - Trie temp; - Vector terminals; - Progress progress(flags); - MARISA_THROW_IF(!progress.is_valid(), MARISA_PARAM_ERROR); - temp.build_trie(keys, &terminals, progress); - - typedef std::pair TerminalIdPair; - Vector pairs; - pairs.resize(terminals.size()); - for (UInt32 i = 0; i < pairs.size(); ++i) { - pairs[i].first = terminals[i]; - pairs[i].second = i; - } - terminals.clear(); - std::sort(pairs.begin(), pairs.end()); - - UInt32 node = 0; - for (UInt32 i = 0; i < pairs.size(); ++i) { - while (node < pairs[i].first) { - temp.terminal_flags_.push_back(false); - ++node; - } - if (node == pairs[i].first) { - temp.terminal_flags_.push_back(true); - ++node; - } - } - while (node < temp.labels_.size()) { - temp.terminal_flags_.push_back(false); - ++node; - } - terminal_flags_.push_back(false); - temp.terminal_flags_.build(); - temp.terminal_flags_.clear_select0s(); - progress.test_total_size(temp.terminal_flags_.total_size()); - - if (key_ids != NULL) { - for (UInt32 i = 0; i < pairs.size(); ++i) { - key_ids[pairs[i].second] = temp.node_to_key_id(pairs[i].first); - } - } - MARISA_THROW_IF(progress.total_size() != temp.total_size(), - MARISA_UNEXPECTED_ERROR); - temp.swap(this); -} - -template -void Trie::build_trie(Vector > &keys, - Vector *terminals, Progress &progress) { - build_cur(keys, terminals, progress); - progress.test_total_size(louds_.total_size()); - progress.test_total_size(sizeof(num_first_branches_)); - progress.test_total_size(sizeof(num_keys_)); - if (link_flags_.empty()) { - labels_.shrink(); - progress.test_total_size(labels_.total_size()); - progress.test_total_size(link_flags_.total_size()); - progress.test_total_size(links_.total_size()); - progress.test_total_size(tail_.total_size()); - return; - } - - Vector next_terminals; - build_next(keys, &next_terminals, progress); - - if (has_trie()) { - progress.test_total_size(trie_->terminal_flags_.total_size()); - } else if (tail_.mode() == MARISA_BINARY_TAIL) { - labels_.push_back('\0'); - link_flags_.push_back(true); - } - link_flags_.build(); - - for (UInt32 i = 0; i < next_terminals.size(); ++i) { - labels_[link_flags_.select1(i)] = (UInt8)(next_terminals[i] % 256); - next_terminals[i] /= 256; - } - link_flags_.clear_select0s(); - if (has_trie() || (tail_.mode() == MARISA_TEXT_TAIL)) { - link_flags_.clear_select1s(); - } - - links_.build(next_terminals); - labels_.shrink(); - progress.test_total_size(labels_.total_size()); - progress.test_total_size(link_flags_.total_size()); - progress.test_total_size(links_.total_size()); - progress.test_total_size(tail_.total_size()); -} - -template -void Trie::build_cur(Vector > &keys, - Vector *terminals, Progress &progress) { - num_keys_ = sort_keys(keys); - louds_.push_back(true); - louds_.push_back(false); - labels_.push_back('\0'); - link_flags_.push_back(false); - - Vector > rest_keys; - std::queue queue; - Vector wranges; - queue.push(Range(0, (UInt32)keys.size(), 0)); - while (!queue.empty()) { - const UInt32 node = (UInt32)(link_flags_.size() - queue.size()); - Range range = queue.front(); - queue.pop(); - - while ((range.begin() < range.end()) && - (keys[range.begin()].str().length() == range.pos())) { - keys[range.begin()].set_terminal(node); - range.set_begin(range.begin() + 1); - } - if (range.begin() == range.end()) { - louds_.push_back(false); - continue; - } - - wranges.clear(); - double weight = keys[range.begin()].weight(); - for (UInt32 i = range.begin() + 1; i < range.end(); ++i) { - if (keys[i - 1].str()[range.pos()] != keys[i].str()[range.pos()]) { - wranges.push_back(WRange(range.begin(), i, range.pos(), weight)); - range.set_begin(i); - weight = 0.0; - } - weight += keys[i].weight(); - } - wranges.push_back(WRange(range, weight)); - if (progress.order() == MARISA_WEIGHT_ORDER) { - std::stable_sort(wranges.begin(), wranges.end(), std::greater()); - } - if (node == 0) { - num_first_branches_ = wranges.size(); - } - for (UInt32 i = 0; i < wranges.size(); ++i) { - const WRange &wrange = wranges[i]; - UInt32 pos = wrange.pos() + 1; - if ((progress.tail() != MARISA_WITHOUT_TAIL) || !progress.is_last()) { - while (pos < keys[wrange.begin()].str().length()) { - UInt32 j; - for (j = wrange.begin() + 1; j < wrange.end(); ++j) { - if (keys[j - 1].str()[pos] != keys[j].str()[pos]) { - break; - } - } - if (j < wrange.end()) { - break; - } - ++pos; - } - } - if ((progress.trie() != MARISA_PATRICIA_TRIE) && - (pos != keys[wrange.end() - 1].str().length())) { - pos = wrange.pos() + 1; - } - louds_.push_back(true); - if (pos == wrange.pos() + 1) { - labels_.push_back(keys[wrange.begin()].str()[wrange.pos()]); - link_flags_.push_back(false); - } else { - labels_.push_back('\0'); - link_flags_.push_back(true); - Key rest_key; - rest_key.set_str(keys[wrange.begin()].str().substr( - wrange.pos(), pos - wrange.pos())); - rest_key.set_weight(wrange.weight()); - rest_keys.push_back(rest_key); - } - wranges[i].set_pos(pos); - queue.push(wranges[i].range()); - } - louds_.push_back(false); - } - louds_.push_back(false); - louds_.build(); - if (progress.trie_id() != 0) { - louds_.clear_select0s(); - } - if (rest_keys.empty()) { - link_flags_.clear(); - } - - build_terminals(keys, terminals); - keys.swap(&rest_keys); -} - -void Trie::build_next(Vector > &keys, - Vector *terminals, Progress &progress) { - if (progress.is_last()) { - Vector strs; - strs.resize(keys.size()); - for (UInt32 i = 0; i < strs.size(); ++i) { - strs[i] = keys[i].str(); - } - tail_.build(strs, terminals, progress.tail()); - return; - } - Vector > rkeys; - rkeys.resize(keys.size()); - for (UInt32 i = 0; i < rkeys.size(); ++i) { - rkeys[i].set_str(RString(keys[i].str())); - rkeys[i].set_weight(keys[i].weight()); - } - keys.clear(); - trie_.reset(new (std::nothrow) Trie); - MARISA_THROW_IF(!has_trie(), MARISA_MEMORY_ERROR); - trie_->build_trie(rkeys, terminals, ++progress); -} - -void Trie::build_next(Vector > &rkeys, - Vector *terminals, Progress &progress) { - if (progress.is_last()) { - Vector strs; - strs.resize(rkeys.size()); - for (UInt32 i = 0; i < strs.size(); ++i) { - strs[i] = String(rkeys[i].str().ptr(), rkeys[i].str().length()); - } - tail_.build(strs, terminals, progress.tail()); - return; - } - trie_.reset(new (std::nothrow) Trie); - MARISA_THROW_IF(!has_trie(), MARISA_MEMORY_ERROR); - trie_->build_trie(rkeys, terminals, ++progress); -} - -template -UInt32 Trie::sort_keys(Vector > &keys) const { - if (keys.empty()) { - return 0; - } - for (UInt32 i = 0; i < keys.size(); ++i) { - keys[i].set_id(i); - } - std::sort(keys.begin(), keys.end()); - UInt32 count = 1; - for (UInt32 i = 1; i < keys.size(); ++i) { - if (keys[i - 1].str() != keys[i].str()) { - ++count; - } - } - return count; -} - -template -void Trie::build_terminals(const Vector > &keys, - Vector *terminals) const { - Vector temp_terminals; - temp_terminals.resize(keys.size()); - for (UInt32 i = 0; i < keys.size(); ++i) { - temp_terminals[keys[i].id()] = keys[i].terminal(); - } - temp_terminals.swap(terminals); -} - -} // namespace marisa diff --git a/lib/marisa/trie-c.cc b/lib/marisa/trie-c.cc deleted file mode 100644 index 9e11405..0000000 --- a/lib/marisa/trie-c.cc +++ /dev/null @@ -1,344 +0,0 @@ -#include "trie.h" - -extern "C" { - -namespace { - -class FindCallback { - public: - typedef int (*Func)(void *, marisa_uint32, size_t); - - FindCallback(Func func, void *first_arg) - : func_(func), first_arg_(first_arg) {} - FindCallback(const FindCallback &callback) - : func_(callback.func_), first_arg_(callback.first_arg_) {} - - bool operator()(marisa::UInt32 key_id, std::size_t key_length) const { - return func_(first_arg_, key_id, key_length) != 0; - } - - private: - Func func_; - void *first_arg_; - - // Disallows assignment. - FindCallback &operator=(const FindCallback &); -}; - -class PredictCallback { - public: - typedef int (*Func)(void *, marisa_uint32, const char *, size_t); - - PredictCallback(Func func, void *first_arg) - : func_(func), first_arg_(first_arg) {} - PredictCallback(const PredictCallback &callback) - : func_(callback.func_), first_arg_(callback.first_arg_) {} - - bool operator()(marisa::UInt32 key_id, const std::string &key) const { - return func_(first_arg_, key_id, key.c_str(), key.length()) != 0; - } - - private: - Func func_; - void *first_arg_; - - // Disallows assignment. - PredictCallback &operator=(const PredictCallback &); -}; - -} // namespace - -struct marisa_trie_ { - public: - marisa_trie_() : trie(), mapper() {} - - marisa::Trie trie; - marisa::Mapper mapper; - - private: - // Disallows copy and assignment. - marisa_trie_(const marisa_trie_ &); - marisa_trie_ &operator=(const marisa_trie_ &); -}; - -marisa_status marisa_init(marisa_trie **h) { - if ((h == NULL) || (*h != NULL)) { - return MARISA_HANDLE_ERROR; - } - *h = new (std::nothrow) marisa_trie_(); - return (*h != NULL) ? MARISA_OK : MARISA_MEMORY_ERROR; -} - -marisa_status marisa_end(marisa_trie *h) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - delete h; - return MARISA_OK; -} - -marisa_status marisa_build(marisa_trie *h, const char * const *keys, - size_t num_keys, const size_t *key_lengths, const double *key_weights, - marisa_uint32 *key_ids, int flags) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.build(keys, num_keys, key_lengths, key_weights, key_ids, flags); - h->mapper.clear(); - return MARISA_OK; -} - -marisa_status marisa_mmap(marisa_trie *h, const char *filename, - long offset, int whence) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.mmap(&h->mapper, filename, offset, whence); - return MARISA_OK; -} - -marisa_status marisa_map(marisa_trie *h, const void *ptr, size_t size) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.map(ptr, size); - h->mapper.clear(); - return MARISA_OK; -} - -marisa_status marisa_load(marisa_trie *h, const char *filename, - long offset, int whence) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.load(filename, offset, whence); - h->mapper.clear(); - return MARISA_OK; -} - -marisa_status marisa_fread(marisa_trie *h, FILE *file) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.fread(file); - h->mapper.clear(); - return MARISA_OK; -} - -marisa_status marisa_read(marisa_trie *h, int fd) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.read(fd); - h->mapper.clear(); - return MARISA_OK; -} - -marisa_status marisa_save(const marisa_trie *h, const char *filename, - int trunc_flag, long offset, int whence) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.save(filename, trunc_flag != 0, offset, whence); - return MARISA_OK; -} - -marisa_status marisa_fwrite(const marisa_trie *h, FILE *file) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.fwrite(file); - return MARISA_OK; -} - -marisa_status marisa_write(const marisa_trie *h, int fd) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.write(fd); - return MARISA_OK; -} - -marisa_status marisa_restore(const marisa_trie *h, marisa_uint32 key_id, - char *key_buf, size_t key_buf_size, size_t *key_length) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (key_length == NULL) { - return MARISA_PARAM_ERROR; - } - *key_length = h->trie.restore(key_id, key_buf, key_buf_size); - return MARISA_OK; -} - -marisa_status marisa_lookup(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_id) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (key_id == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - *key_id = h->trie.lookup(ptr); - } else { - *key_id = h->trie.lookup(ptr, length); - } - return MARISA_OK; -} - -marisa_status marisa_find(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_ids, size_t *key_lengths, - size_t max_num_results, size_t *num_results) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (num_results == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - *num_results = h->trie.find(ptr, key_ids, key_lengths, max_num_results); - } else { - *num_results = h->trie.find(ptr, length, - key_ids, key_lengths, max_num_results); - } - return MARISA_OK; -} - -marisa_status marisa_find_first(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_id, size_t *key_length) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (key_id == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - *key_id = h->trie.find_first(ptr, key_length); - } else { - *key_id = h->trie.find_first(ptr, length, key_length); - } - return MARISA_OK; -} - -marisa_status marisa_find_last(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_id, size_t *key_length) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (key_id == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - *key_id = h->trie.find_last(ptr, key_length); - } else { - *key_id = h->trie.find_last(ptr, length, key_length); - } - return MARISA_OK; -} - -marisa_status marisa_find_callback(const marisa_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_uint32, size_t), - void *first_arg_to_callback) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (callback == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - h->trie.find_callback(ptr, - ::FindCallback(callback, first_arg_to_callback)); - } else { - h->trie.find_callback(ptr, length, - ::FindCallback(callback, first_arg_to_callback)); - } - return MARISA_OK; -} - -marisa_status marisa_predict(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, - size_t max_num_results, size_t *num_results) { - return marisa_predict_breadth_first(h, ptr, length, - key_ids, max_num_results, num_results); -} - -marisa_status marisa_predict_breadth_first(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, - size_t max_num_results, size_t *num_results) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (num_results == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - *num_results = h->trie.predict_breadth_first( - ptr, key_ids, NULL, max_num_results); - } else { - *num_results = h->trie.predict_breadth_first( - ptr, length, key_ids, NULL, max_num_results); - } - return MARISA_OK; -} - -marisa_status marisa_predict_depth_first(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, - size_t max_num_results, size_t *num_results) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (num_results == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - *num_results = h->trie.predict_depth_first( - ptr, key_ids, NULL, max_num_results); - } else { - *num_results = h->trie.predict_depth_first( - ptr, length, key_ids, NULL, max_num_results); - } - return MARISA_OK; -} - -marisa_status marisa_predict_callback(const marisa_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_uint32, const char *, size_t), - void *first_arg_to_callback) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } else if (callback == NULL) { - return MARISA_PARAM_ERROR; - } - if (length == MARISA_ZERO_TERMINATED) { - h->trie.predict_callback(ptr, - ::PredictCallback(callback, first_arg_to_callback)); - } else { - h->trie.predict_callback(ptr, length, - ::PredictCallback(callback, first_arg_to_callback)); - } - return MARISA_OK; -} - -size_t marisa_get_num_tries(const marisa_trie *h) { - return (h != NULL) ? h->trie.num_tries() : 0; -} - -size_t marisa_get_num_keys(const marisa_trie *h) { - return (h != NULL) ? h->trie.num_keys() : 0; -} - -size_t marisa_get_num_nodes(const marisa_trie *h) { - return (h != NULL) ? h->trie.num_nodes() : 0; -} - -size_t marisa_get_total_size(const marisa_trie *h) { - return (h != NULL) ? h->trie.total_size() : 0; -} - -marisa_status marisa_clear(marisa_trie *h) { - if (h == NULL) { - return MARISA_HANDLE_ERROR; - } - h->trie.clear(); - h->mapper.clear(); - return MARISA_OK; -} - -} // extern "C" diff --git a/lib/marisa/trie-inline.h b/lib/marisa/trie-inline.h deleted file mode 100644 index 2c9218c..0000000 --- a/lib/marisa/trie-inline.h +++ /dev/null @@ -1,351 +0,0 @@ -#ifndef MARISA_TRIE_INLINE_H_ -#define MARISA_TRIE_INLINE_H_ - -#include - -#include "cell.h" - -namespace marisa { - -inline std::string Trie::operator[](UInt32 key_id) const { - std::string key; - restore(key_id, &key); - return key; -} - -inline UInt32 Trie::operator[](const char *str) const { - return lookup(str); -} - -inline UInt32 Trie::operator[](const std::string &str) const { - return lookup(str); -} - -inline UInt32 Trie::lookup(const std::string &str) const { - return lookup(str.c_str(), str.length()); -} - -inline std::size_t Trie::find(const std::string &str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const { - return find(str.c_str(), str.length(), - key_ids, key_lengths, max_num_results); -} - -inline std::size_t Trie::find(const std::string &str, - std::vector *key_ids, std::vector *key_lengths, - std::size_t max_num_results) const { - return find(str.c_str(), str.length(), - key_ids, key_lengths, max_num_results); -} - -inline UInt32 Trie::find_first(const std::string &str, - std::size_t *key_length) const { - return find_first(str.c_str(), str.length(), key_length); -} - -inline UInt32 Trie::find_last(const std::string &str, - std::size_t *key_length) const { - return find_last(str.c_str(), str.length(), key_length); -} - -template -inline std::size_t Trie::find_callback(const char *str, - T callback) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return find_callback_(CQuery(str), callback); -} - -template -inline std::size_t Trie::find_callback(const char *ptr, std::size_t length, - T callback) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return find_callback_(Query(ptr, length), callback); -} - -template -inline std::size_t Trie::find_callback(const std::string &str, - T callback) const { - return find_callback(str.c_str(), str.length(), callback); -} - -inline std::size_t Trie::predict(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - return predict(str.c_str(), str.length(), key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict(const std::string &str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - return predict(str.c_str(), str.length(), key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_breadth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - return predict_breadth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_breadth_first(const std::string &str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - return predict_breadth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_depth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - return predict_depth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_depth_first(const std::string &str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - return predict_depth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -template -inline std::size_t Trie::predict_callback( - const char *str, T callback) const { - return predict_callback_(CQuery(str), callback); -} - -template -inline std::size_t Trie::predict_callback( - const char *ptr, std::size_t length, - T callback) const { - return predict_callback_(Query(ptr, length), callback); -} - -template -inline std::size_t Trie::predict_callback( - const std::string &str, T callback) const { - return predict_callback(str.c_str(), str.length(), callback); -} - -inline bool Trie::empty() const { - return louds_.empty(); -} - -inline std::size_t Trie::num_keys() const { - return num_keys_; -} - -inline UInt32 Trie::notfound() { - return MARISA_NOT_FOUND; -} - -inline std::size_t Trie::mismatch() { - return MARISA_MISMATCH; -} - -template -inline bool Trie::find_child(UInt32 &node, T query, - std::size_t &pos) const { - UInt32 louds_pos = get_child(node); - if (!louds_[louds_pos]) { - return false; - } - node = louds_pos_to_node(louds_pos, node); - UInt32 link_id = MARISA_UINT32_MAX; - do { - if (has_link(node)) { - if (link_id == MARISA_UINT32_MAX) { - link_id = get_link_id(node); - } else { - ++link_id; - } - std::size_t next_pos = has_trie() ? - trie_->trie_match(get_link(node, link_id), query, pos) : - tail_match(node, link_id, query, pos); - if (next_pos == mismatch()) { - return false; - } else if (next_pos != pos) { - pos = next_pos; - return true; - } - } else if (labels_[node] == query[pos]) { - ++pos; - return true; - } - ++node; - ++louds_pos; - } while (louds_[louds_pos]); - return false; -} - -template -std::size_t Trie::find_callback_(T query, U callback) const { - std::size_t count = 0; - UInt32 node = 0; - std::size_t pos = 0; - do { - if (terminal_flags_[node]) { - ++count; - if (!callback(node_to_key_id(node), pos)) { - return count; - } - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return count; -} - -template -inline bool Trie::predict_child(UInt32 &node, T query, std::size_t &pos, - std::string *key) const { - UInt32 louds_pos = get_child(node); - if (!louds_[louds_pos]) { - return false; - } - node = louds_pos_to_node(louds_pos, node); - UInt32 link_id = MARISA_UINT32_MAX; - do { - if (has_link(node)) { - if (link_id == MARISA_UINT32_MAX) { - link_id = get_link_id(node); - } else { - ++link_id; - } - std::size_t next_pos = has_trie() ? - trie_->trie_prefix_match( - get_link(node, link_id), query, pos, key) : - tail_prefix_match(node, link_id, query, pos, key); - if (next_pos == mismatch()) { - return false; - } else if (next_pos != pos) { - pos = next_pos; - return true; - } - } else if (labels_[node] == query[pos]) { - ++pos; - return true; - } - ++node; - ++louds_pos; - } while (louds_[louds_pos]); - return false; -} - -template -std::size_t Trie::predict_callback_(T query, U callback) const { - std::string key; - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!predict_child(node, query, pos, &key)) { - return 0; - } - } - query.insert(&key); - std::size_t count = 0; - if (terminal_flags_[node]) { - ++count; - if (!callback(node_to_key_id(node), key)) { - return count; - } - } - Cell cell; - cell.set_louds_pos(get_child(node)); - if (!louds_[cell.louds_pos()]) { - return count; - } - cell.set_node(louds_pos_to_node(cell.louds_pos(), node)); - cell.set_key_id(node_to_key_id(cell.node())); - cell.set_length(key.length()); - Vector stack; - stack.push_back(cell); - std::size_t stack_pos = 1; - while (stack_pos != 0) { - Cell &cur = stack[stack_pos - 1]; - if (!louds_[cur.louds_pos()]) { - cur.set_louds_pos(cur.louds_pos() + 1); - --stack_pos; - continue; - } - cur.set_louds_pos(cur.louds_pos() + 1); - key.resize(cur.length()); - if (has_link(cur.node())) { - if (has_trie()) { - trie_->trie_restore(get_link(cur.node()), &key); - } else { - tail_restore(cur.node(), &key); - } - } else { - key += labels_[cur.node()]; - } - if (terminal_flags_[cur.node()]) { - ++count; - if (!callback(cur.key_id(), key)) { - return count; - } - cur.set_key_id(cur.key_id() + 1); - } - if (stack_pos == stack.size()) { - cell.set_louds_pos(get_child(cur.node())); - cell.set_node(louds_pos_to_node(cell.louds_pos(), cur.node())); - cell.set_key_id(node_to_key_id(cell.node())); - stack.push_back(cell); - } - stack[stack_pos].set_length(key.length()); - stack[stack_pos - 1].set_node(stack[stack_pos - 1].node() + 1); - ++stack_pos; - } - return count; -} - -inline UInt32 Trie::key_id_to_node(UInt32 key_id) const { - return terminal_flags_.select1(key_id); -} - -inline UInt32 Trie::node_to_key_id(UInt32 node) const { - return terminal_flags_.rank1(node); -} - -inline UInt32 Trie::louds_pos_to_node(UInt32 louds_pos, - UInt32 parent_node) const { - return louds_pos - parent_node - 1; -} - -inline UInt32 Trie::get_child(UInt32 node) const { - return louds_.select0(node) + 1; -} - -inline UInt32 Trie::get_parent(UInt32 node) const { - return (node > num_first_branches_) ? (louds_.select1(node) - node - 1) : 0; -} - -inline bool Trie::has_link(UInt32 node) const { - return (link_flags_.empty()) ? false : link_flags_[node]; -} - -inline UInt32 Trie::get_link_id(UInt32 node) const { - return link_flags_.rank1(node); -} - -inline UInt32 Trie::get_link(UInt32 node) const { - return get_link(node, get_link_id(node)); -} - -inline UInt32 Trie::get_link(UInt32 node, UInt32 link_id) const { - return (links_[link_id] * 256) + labels_[node]; -} - -inline bool Trie::has_link() const { - return !link_flags_.empty(); -} - -inline bool Trie::has_trie() const { - return trie_.get() != NULL; -} - -inline bool Trie::has_tail() const { - return !tail_.empty(); -} - -} // namespace marisa - -#endif // MARISA_TRIE_INLINE_H_ diff --git a/lib/marisa/trie-search.cc b/lib/marisa/trie-search.cc deleted file mode 100644 index 098e0b3..0000000 --- a/lib/marisa/trie-search.cc +++ /dev/null @@ -1,753 +0,0 @@ -#include -#include - -#include "trie.h" - -namespace marisa { -namespace { - -template -class PredictCallback { - public: - PredictCallback(T key_ids, U keys, std::size_t max_num_results) - : key_ids_(key_ids), keys_(keys), - max_num_results_(max_num_results), num_results_(0) {} - PredictCallback(const PredictCallback &callback) - : key_ids_(callback.key_ids_), keys_(callback.keys_), - max_num_results_(callback.max_num_results_), - num_results_(callback.num_results_) {} - - bool operator()(marisa::UInt32 key_id, const std::string &key) { - if (key_ids_.is_valid()) { - key_ids_.insert(num_results_, key_id); - } - if (keys_.is_valid()) { - keys_.insert(num_results_, key); - } - return ++num_results_ < max_num_results_; - } - - private: - T key_ids_; - U keys_; - const std::size_t max_num_results_; - std::size_t num_results_; - - // Disallows assignment. - PredictCallback &operator=(const PredictCallback &); -}; - -} // namespace - -std::string Trie::restore(UInt32 key_id) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(key_id >= num_keys_, MARISA_PARAM_ERROR); - std::string key; - restore_(key_id, &key); - return key; -} - -void Trie::restore(UInt32 key_id, std::string *key) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(key_id >= num_keys_, MARISA_PARAM_ERROR); - MARISA_THROW_IF(key == NULL, MARISA_PARAM_ERROR); - restore_(key_id, key); -} - -std::size_t Trie::restore(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(key_id >= num_keys_, MARISA_PARAM_ERROR); - MARISA_THROW_IF((key_buf == NULL) && (key_buf_size != 0), - MARISA_PARAM_ERROR); - return restore_(key_id, key_buf, key_buf_size); -} - -UInt32 Trie::lookup(const char *str) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return lookup_(CQuery(str)); -} - -UInt32 Trie::lookup(const char *ptr, std::size_t length) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return lookup_(Query(ptr, length)); -} - -std::size_t Trie::find(const char *str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return find_(CQuery(str), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -std::size_t Trie::find(const char *ptr, std::size_t length, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return find_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -std::size_t Trie::find(const char *str, - std::vector *key_ids, std::vector *key_lengths, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return find_(CQuery(str), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -std::size_t Trie::find(const char *ptr, std::size_t length, - std::vector *key_ids, std::vector *key_lengths, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return find_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -UInt32 Trie::find_first(const char *str, - std::size_t *key_length) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return find_first_(CQuery(str), key_length); -} - -UInt32 Trie::find_first(const char *ptr, std::size_t length, - std::size_t *key_length) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return find_first_(Query(ptr, length), key_length); -} - -UInt32 Trie::find_last(const char *str, - std::size_t *key_length) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return find_last_(CQuery(str), key_length); -} - -UInt32 Trie::find_last(const char *ptr, std::size_t length, - std::size_t *key_length) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return find_last_(Query(ptr, length), key_length); -} - -std::size_t Trie::predict(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(str, key_ids, keys, max_num_results) : - predict_depth_first(str, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(ptr, length, key_ids, keys, max_num_results) : - predict_depth_first(ptr, length, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict(const char *str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(str, key_ids, keys, max_num_results) : - predict_depth_first(str, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict(const char *ptr, std::size_t length, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(ptr, length, key_ids, keys, max_num_results) : - predict_depth_first(ptr, length, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return predict_breadth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return predict_breadth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return predict_breadth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *ptr, std::size_t length, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return predict_breadth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return predict_depth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return predict_depth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first( - const char *str, std::vector *key_ids, - std::vector *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF(str == NULL, MARISA_PARAM_ERROR); - return predict_depth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first( - const char *ptr, std::size_t length, std::vector *key_ids, - std::vector *keys, std::size_t max_num_results) const { - MARISA_THROW_IF(empty(), MARISA_STATE_ERROR); - MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_PARAM_ERROR); - return predict_depth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -void Trie::restore_(UInt32 key_id, std::string *key) const { - const std::size_t start_pos = key->length(); - UInt32 node = key_id_to_node(key_id); - while (node != 0) { - if (has_link(node)) { - const std::size_t prev_pos = key->length(); - if (has_trie()) { - trie_->trie_restore(get_link(node), key); - } else { - tail_restore(node, key); - } - std::reverse(key->begin() + prev_pos, key->end()); - } else { - *key += labels_[node]; - } - node = get_parent(node); - } - std::reverse(key->begin() + start_pos, key->end()); -} - -void Trie::trie_restore(UInt32 node, std::string *key) const { - do { - if (has_link(node)) { - if (has_trie()) { - trie_->trie_restore(get_link(node), key); - } else { - tail_restore(node, key); - } - } else { - *key += labels_[node]; - } - node = get_parent(node); - } while (node != 0); -} - -void Trie::tail_restore(UInt32 node, std::string *key) const { - const UInt32 link_id = link_flags_.rank1(node); - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - if (tail_.mode() == MARISA_BINARY_TAIL) { - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - key->append(reinterpret_cast(tail_[offset]), length); - } else { - key->append(reinterpret_cast(tail_[offset])); - } -} - -std::size_t Trie::restore_(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const { - std::size_t pos = 0; - UInt32 node = key_id_to_node(key_id); - while (node != 0) { - if (has_link(node)) { - const std::size_t prev_pos = pos; - if (has_trie()) { - trie_->trie_restore(get_link(node), key_buf, key_buf_size, pos); - } else { - tail_restore(node, key_buf, key_buf_size, pos); - } - if (pos < key_buf_size) { - std::reverse(key_buf + prev_pos, key_buf + pos); - } - } else { - if (pos < key_buf_size) { - key_buf[pos] = labels_[node]; - } - ++pos; - } - node = get_parent(node); - } - if (pos < key_buf_size) { - key_buf[pos] = '\0'; - std::reverse(key_buf, key_buf + pos); - } - return pos; -} - -void Trie::trie_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &pos) const { - do { - if (has_link(node)) { - if (has_trie()) { - trie_->trie_restore(get_link(node), key_buf, key_buf_size, pos); - } else { - tail_restore(node, key_buf, key_buf_size, pos); - } - } else { - if (pos < key_buf_size) { - key_buf[pos] = labels_[node]; - } - ++pos; - } - node = get_parent(node); - } while (node != 0); -} - -void Trie::tail_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &pos) const { - const UInt32 link_id = link_flags_.rank1(node); - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - if (tail_.mode() == MARISA_BINARY_TAIL) { - const UInt8 *ptr = tail_[offset]; - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - for (UInt32 i = 0; i < length; ++i) { - if (pos < key_buf_size) { - key_buf[pos] = ptr[i]; - } - ++pos; - } - } else { - for (const UInt8 *str = tail_[offset]; *str != '\0'; ++str) { - if (pos < key_buf_size) { - key_buf[pos] = *str; - } - ++pos; - } - } -} - -template -UInt32 Trie::lookup_(T query) const { - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!find_child(node, query, pos)) { - return notfound(); - } - } - return terminal_flags_[node] ? node_to_key_id(node) : notfound(); -} - -template -std::size_t Trie::trie_match(UInt32 node, T query, - std::size_t pos) const { - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_match(get_link(node), query, pos); - } else { - next_pos = tail_match(node, get_link_id(node), query, pos); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return next_pos; - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return pos; - } else { - ++pos; - } - node = get_parent(node); - while (node != 0) { - if (query.ends_at(pos)) { - return mismatch(); - } - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_match(get_link(node), query, pos); - } else { - next_pos = tail_match(node, get_link_id(node), query, pos); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return mismatch(); - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return mismatch(); - } else { - ++pos; - } - node = get_parent(node); - } - return pos; -} - -template std::size_t Trie::trie_match(UInt32 node, - CQuery query, std::size_t pos) const; -template std::size_t Trie::trie_match(UInt32 node, - const Query &query, std::size_t pos) const; - -template -std::size_t Trie::tail_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos) const { - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - const UInt8 *ptr = tail_[offset]; - if (*ptr != query[pos]) { - return pos; - } else if (tail_.mode() == MARISA_BINARY_TAIL) { - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - for (UInt32 i = 1; i < length; ++i) { - if (query.ends_at(pos + i) || (ptr[i] != query[pos + i])) { - return mismatch(); - } - } - return pos + length; - } else { - for (++ptr, ++pos; *ptr != '\0'; ++ptr, ++pos) { - if (query.ends_at(pos) || (*ptr != query[pos])) { - return mismatch(); - } - } - return pos; - } -} - -template std::size_t Trie::tail_match(UInt32 node, - UInt32 link_id, CQuery query, std::size_t pos) const; -template std::size_t Trie::tail_match(UInt32 node, - UInt32 link_id, const Query &query, std::size_t pos) const; - -template -std::size_t Trie::find_(T query, U key_ids, V key_lengths, - std::size_t max_num_results) const { - if (max_num_results == 0) { - return 0; - } - std::size_t count = 0; - UInt32 node = 0; - std::size_t pos = 0; - do { - if (terminal_flags_[node]) { - if (key_ids.is_valid()) { - key_ids.insert(count, node_to_key_id(node)); - } - if (key_lengths.is_valid()) { - key_lengths.insert(count, pos); - } - if (++count >= max_num_results) { - return count; - } - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return count; -} - -template -UInt32 Trie::find_first_(T query, std::size_t *key_length) const { - UInt32 node = 0; - std::size_t pos = 0; - do { - if (terminal_flags_[node]) { - if (key_length != NULL) { - *key_length = pos; - } - return node_to_key_id(node); - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return notfound(); -} - -template -UInt32 Trie::find_last_(T query, std::size_t *key_length) const { - UInt32 node = 0; - UInt32 node_found = notfound(); - std::size_t pos = 0; - std::size_t pos_found = mismatch(); - do { - if (terminal_flags_[node]) { - node_found = node; - pos_found = pos; - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - if (node_found != notfound()) { - if (key_length != NULL) { - *key_length = pos_found; - } - return node_to_key_id(node_found); - } - return notfound(); -} - -template -std::size_t Trie::predict_breadth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const { - if (max_num_results == 0) { - return 0; - } - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!predict_child(node, query, pos, NULL)) { - return 0; - } - } - std::string key; - std::size_t count = 0; - if (terminal_flags_[node]) { - const UInt32 key_id = node_to_key_id(node); - if (key_ids.is_valid()) { - key_ids.insert(count, key_id); - } - if (keys.is_valid()) { - restore(key_id, &key); - keys.insert(count, key); - } - if (++count >= max_num_results) { - return count; - } - } - const UInt32 louds_pos = get_child(node); - if (!louds_[louds_pos]) { - return count; - } - UInt32 node_begin = louds_pos_to_node(louds_pos, node); - UInt32 node_end = louds_pos_to_node(get_child(node + 1), node + 1); - while (node_begin < node_end) { - const UInt32 key_id_begin = node_to_key_id(node_begin); - const UInt32 key_id_end = node_to_key_id(node_end); - if (key_ids.is_valid()) { - UInt32 temp_count = count; - for (UInt32 key_id = key_id_begin; key_id < key_id_end; ++key_id) { - key_ids.insert(temp_count, key_id); - if (++temp_count >= max_num_results) { - break; - } - } - } - if (keys.is_valid()) { - UInt32 temp_count = count; - for (UInt32 key_id = key_id_begin; key_id < key_id_end; ++key_id) { - key.clear(); - restore(key_id, &key); - keys.insert(temp_count, key); - if (++temp_count >= max_num_results) { - break; - } - } - } - count += key_id_end - key_id_begin; - if (count >= max_num_results) { - return max_num_results; - } - node_begin = louds_pos_to_node(get_child(node_begin), node_begin); - node_end = louds_pos_to_node(get_child(node_end), node_end); - } - return count; -} - -template -std::size_t Trie::predict_depth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const { - if (max_num_results == 0) { - return 0; - } else if (keys.is_valid()) { - PredictCallback callback(key_ids, keys, max_num_results); - return predict_callback_(query, callback); - } - - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!predict_child(node, query, pos, NULL)) { - return 0; - } - } - std::size_t count = 0; - if (terminal_flags_[node]) { - if (key_ids.is_valid()) { - key_ids.insert(count, node_to_key_id(node)); - } - if (++count >= max_num_results) { - return count; - } - } - Cell cell; - cell.set_louds_pos(get_child(node)); - if (!louds_[cell.louds_pos()]) { - return count; - } - cell.set_node(louds_pos_to_node(cell.louds_pos(), node)); - cell.set_key_id(node_to_key_id(cell.node())); - Vector stack; - stack.push_back(cell); - std::size_t stack_pos = 1; - while (stack_pos != 0) { - Cell &cur = stack[stack_pos - 1]; - if (!louds_[cur.louds_pos()]) { - cur.set_louds_pos(cur.louds_pos() + 1); - --stack_pos; - continue; - } - cur.set_louds_pos(cur.louds_pos() + 1); - if (terminal_flags_[cur.node()]) { - if (key_ids.is_valid()) { - key_ids.insert(count, cur.key_id()); - } - if (++count >= max_num_results) { - return count; - } - cur.set_key_id(cur.key_id() + 1); - } - if (stack_pos == stack.size()) { - cell.set_louds_pos(get_child(cur.node())); - cell.set_node(louds_pos_to_node(cell.louds_pos(), cur.node())); - cell.set_key_id(node_to_key_id(cell.node())); - stack.push_back(cell); - } - stack[stack_pos - 1].set_node(stack[stack_pos - 1].node() + 1); - ++stack_pos; - } - return count; -} - -template -std::size_t Trie::trie_prefix_match(UInt32 node, T query, - std::size_t pos, std::string *key) const { - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_prefix_match(get_link(node), query, pos, key); - } else { - next_pos = tail_prefix_match( - node, get_link_id(node), query, pos, key); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return next_pos; - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return pos; - } else { - ++pos; - } - node = get_parent(node); - while (node != 0) { - if (query.ends_at(pos)) { - if (key != NULL) { - trie_restore(node, key); - } - return pos; - } - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_prefix_match( - get_link(node), query, pos, key); - } else { - next_pos = tail_prefix_match( - node, get_link_id(node), query, pos, key); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return next_pos; - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return mismatch(); - } else { - ++pos; - } - node = get_parent(node); - } - return pos; -} - -template std::size_t Trie::trie_prefix_match(UInt32 node, - CQuery query, std::size_t pos, std::string *key) const; -template std::size_t Trie::trie_prefix_match(UInt32 node, - const Query &query, std::size_t pos, std::string *key) const; - -template -std::size_t Trie::tail_prefix_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos, std::string *key) const { - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - const UInt8 *ptr = tail_[offset]; - if (*ptr != query[pos]) { - return pos; - } else if (tail_.mode() == MARISA_BINARY_TAIL) { - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - for (UInt32 i = 1; i < length; ++i) { - if (query.ends_at(pos + i)) { - if (key != NULL) { - key->append(reinterpret_cast(ptr + i), length - i); - } - return pos + i; - } else if (ptr[i] != query[pos + i]) { - return mismatch(); - } - } - return pos + length; - } else { - for (++ptr, ++pos; *ptr != '\0'; ++ptr, ++pos) { - if (query.ends_at(pos)) { - if (key != NULL) { - key->append(reinterpret_cast(ptr)); - } - return pos; - } else if (*ptr != query[pos]) { - return mismatch(); - } - } - return pos; - } -} - -template std::size_t Trie::tail_prefix_match( - UInt32 node, UInt32 link_id, - CQuery query, std::size_t pos, std::string *key) const; -template std::size_t Trie::tail_prefix_match( - UInt32 node, UInt32 link_id, - const Query &query, std::size_t pos, std::string *key) const; - -} // namespace marisa diff --git a/lib/marisa/trie.cc b/lib/marisa/trie.cc deleted file mode 100644 index 6ef22b8..0000000 --- a/lib/marisa/trie.cc +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include - -#include "trie.h" - -namespace marisa { - -Trie::Trie() - : louds_(), labels_(), terminal_flags_(), link_flags_(), links_(), - trie_(), tail_(), num_first_branches_(0), num_keys_(0) {} - -void Trie::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_THROW_IF(mapper == NULL, MARISA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void Trie::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void Trie::map(Mapper &mapper) { - Trie temp; - temp.louds_.map(mapper); - temp.labels_.map(mapper); - temp.terminal_flags_.map(mapper); - temp.link_flags_.map(mapper); - temp.links_.map(mapper); - temp.tail_.map(mapper); - mapper.map(&temp.num_first_branches_); - mapper.map(&temp.num_keys_); - - if (temp.has_link() && !temp.has_tail()) { - temp.trie_.reset(new (std::nothrow) Trie); - MARISA_THROW_IF(!temp.has_trie(), MARISA_MEMORY_ERROR); - temp.trie_->map(mapper); - } - temp.swap(this); -} - -void Trie::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void Trie::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -void Trie::read(int fd) { - Reader reader(fd); - read(reader); -} - -void Trie::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void Trie::read(Reader &reader) { - Trie temp; - temp.louds_.read(reader); - temp.labels_.read(reader); - temp.terminal_flags_.read(reader); - temp.link_flags_.read(reader); - temp.links_.read(reader); - temp.tail_.read(reader); - reader.read(&temp.num_first_branches_); - reader.read(&temp.num_keys_); - - if (temp.has_link() && !temp.has_tail()) { - temp.trie_.reset(new (std::nothrow) Trie); - MARISA_THROW_IF(!temp.has_trie(), MARISA_MEMORY_ERROR); - temp.trie_->read(reader); - } - temp.swap(this); -} - -void Trie::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void Trie::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -void Trie::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void Trie::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void Trie::write(Writer &writer) const { - louds_.write(writer); - labels_.write(writer); - terminal_flags_.write(writer); - link_flags_.write(writer); - links_.write(writer); - tail_.write(writer); - writer.write(num_first_branches_); - writer.write(num_keys_); - if (has_trie()) { - trie_->write(writer); - } -} - -std::size_t Trie::num_tries() const { - return has_trie() ? (trie_->num_tries() + 1) : (louds_.empty() ? 0 : 1); -} - -std::size_t Trie::num_nodes() const { - if (louds_.empty()) { - return 0; - } - std::size_t num_nodes = (louds_.size() / 2) - 1; - if (has_trie()) { - num_nodes += trie_->num_nodes(); - } - return num_nodes; -} - -std::size_t Trie::total_size() const { - return louds_.total_size() + labels_.total_size() - + terminal_flags_.total_size() + link_flags_.total_size() - + links_.total_size() + (has_trie() ? trie_->total_size() : 0) - + tail_.total_size() + sizeof(num_first_branches_) + sizeof(num_keys_); -} - -void Trie::clear() { - Trie().swap(this); -} - -void Trie::swap(Trie *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - louds_.swap(&rhs->louds_); - labels_.swap(&rhs->labels_); - terminal_flags_.swap(&rhs->terminal_flags_); - link_flags_.swap(&rhs->link_flags_); - links_.swap(&rhs->links_); - Swap(&trie_, &rhs->trie_); - tail_.swap(&rhs->tail_); - Swap(&num_first_branches_, &rhs->num_first_branches_); - Swap(&num_keys_, &rhs->num_keys_); -} - -} // namespace marisa diff --git a/lib/marisa/trie.h b/lib/marisa/trie.h deleted file mode 100644 index 785bcd5..0000000 --- a/lib/marisa/trie.h +++ /dev/null @@ -1,385 +0,0 @@ -#ifndef MARISA_TRIE_H_ -#define MARISA_TRIE_H_ - -#include "base.h" - -#ifdef __cplusplus - -#include -#include - -#include "progress.h" -#include "key.h" -#include "query.h" -#include "container.h" -#include "intvector.h" -#include "bitvector.h" -#include "tail.h" - -namespace marisa { - -class Trie { - public: - Trie(); - - void build(const char * const *keys, std::size_t num_keys, - const std::size_t *key_lengths = NULL, - const double *key_weights = NULL, - UInt32 *key_ids = NULL, int flags = 0); - - void build(const std::vector &keys, - std::vector *key_ids = NULL, int flags = 0); - void build(const std::vector > &keys, - std::vector *key_ids = NULL, int flags = 0); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - std::string operator[](UInt32 key_id) const; - - UInt32 operator[](const char *str) const; - UInt32 operator[](const std::string &str) const; - - std::string restore(UInt32 key_id) const; - void restore(UInt32 key_id, std::string *key) const; - std::size_t restore(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const; - - UInt32 lookup(const char *str) const; - UInt32 lookup(const char *ptr, std::size_t length) const; - UInt32 lookup(const std::string &str) const; - - std::size_t find(const char *str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const; - std::size_t find(const char *ptr, std::size_t length, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const; - std::size_t find(const std::string &str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const; - - std::size_t find(const char *str, - std::vector *key_ids = NULL, - std::vector *key_lengths = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t find(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *key_lengths = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t find(const std::string &str, - std::vector *key_ids = NULL, - std::vector *key_lengths = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - - UInt32 find_first(const char *str, - std::size_t *key_length = NULL) const; - UInt32 find_first(const char *ptr, std::size_t length, - std::size_t *key_length = NULL) const; - UInt32 find_first(const std::string &str, - std::size_t *key_length = NULL) const; - - UInt32 find_last(const char *str, - std::size_t *key_length = NULL) const; - UInt32 find_last(const char *ptr, std::size_t length, - std::size_t *key_length = NULL) const; - UInt32 find_last(const std::string &str, - std::size_t *key_length = NULL) const; - - // bool callback(UInt32 key_id, std::size_t key_length); - template - std::size_t find_callback(const char *str, T callback) const; - template - std::size_t find_callback(const char *ptr, std::size_t length, - T callback) const; - template - std::size_t find_callback(const std::string &str, T callback) const; - - std::size_t predict(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - - std::size_t predict(const char *str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t predict(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t predict(const std::string &str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - - std::size_t predict_breadth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_breadth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_breadth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - - std::size_t predict_breadth_first(const char *str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t predict_breadth_first(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t predict_breadth_first(const std::string &str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - - std::size_t predict_depth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_depth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_depth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - - std::size_t predict_depth_first(const char *str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t predict_depth_first(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - std::size_t predict_depth_first(const std::string &str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_MAX_NUM_KEYS) const; - - // bool callback(UInt32 key_id, const std::string &key); - template - std::size_t predict_callback(const char *str, T callback) const; - template - std::size_t predict_callback(const char *ptr, std::size_t length, - T callback) const; - template - std::size_t predict_callback(const std::string &str, T callback) const; - - bool empty() const; - std::size_t num_tries() const; - std::size_t num_keys() const; - std::size_t num_nodes() const; - std::size_t total_size() const; - - void clear(); - void swap(Trie *rhs); - - static UInt32 notfound(); - static std::size_t mismatch(); - - private: - BitVector louds_; - Vector labels_; - BitVector terminal_flags_; - BitVector link_flags_; - IntVector links_; - std::auto_ptr trie_; - Tail tail_; - UInt32 num_first_branches_; - UInt32 num_keys_; - - void build_trie(Vector > &keys, - std::vector *key_ids, int flags); - void build_trie(Vector > &keys, - UInt32 *key_ids, int flags); - - template - void build_trie(Vector > &keys, - Vector *terminals, Progress &progress); - - template - void build_cur(Vector > &keys, - Vector *terminals, Progress &progress); - - void build_next(Vector > &keys, - Vector *terminals, Progress &progress); - void build_next(Vector > &rkeys, - Vector *terminals, Progress &progress); - - template - UInt32 sort_keys(Vector > &keys) const; - - template - void build_terminals(const Vector > &keys, - Vector *terminals) const; - - void restore_(UInt32 key_id, std::string *key) const; - void trie_restore(UInt32 node, std::string *key) const; - void tail_restore(UInt32 node, std::string *key) const; - - std::size_t restore_(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const; - void trie_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &key_pos) const; - void tail_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &key_pos) const; - - template - UInt32 lookup_(T query) const; - template - bool find_child(UInt32 &node, T query, std::size_t &pos) const; - template - std::size_t trie_match(UInt32 node, T query, std::size_t pos) const; - template - std::size_t tail_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos) const; - - template - std::size_t find_(T query, U key_ids, V key_lengths, - std::size_t max_num_results) const; - template - UInt32 find_first_(T query, std::size_t *key_length) const; - template - UInt32 find_last_(T query, std::size_t *key_length) const; - template - std::size_t find_callback_(T query, U callback) const; - - template - std::size_t predict_breadth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const; - template - std::size_t predict_depth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const; - template - std::size_t predict_callback_(T query, U callback) const; - - template - bool predict_child(UInt32 &node, T query, std::size_t &pos, - std::string *key) const; - template - std::size_t trie_prefix_match(UInt32 node, T query, - std::size_t pos, std::string *key) const; - template - std::size_t tail_prefix_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos, std::string *key) const; - - UInt32 key_id_to_node(UInt32 key_id) const; - UInt32 node_to_key_id(UInt32 node) const; - UInt32 louds_pos_to_node(UInt32 louds_pos, UInt32 parent_node) const; - - UInt32 get_child(UInt32 node) const; - UInt32 get_parent(UInt32 node) const; - - bool has_link(UInt32 node) const; - UInt32 get_link_id(UInt32 node) const; - UInt32 get_link(UInt32 node) const; - UInt32 get_link(UInt32 node, UInt32 link_id) const; - - bool has_link() const; - bool has_trie() const; - bool has_tail() const; - - // Disallows copy and assignment. - Trie(const Trie &); - Trie &operator=(const Trie &); -}; - -} // namespace marisa - -#include "trie-inline.h" - -#else // __cplusplus - -#include - -#endif // __cplusplus - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -typedef struct marisa_trie_ marisa_trie; - -marisa_status marisa_init(marisa_trie **h); -marisa_status marisa_end(marisa_trie *h); - -marisa_status marisa_build(marisa_trie *h, const char * const *keys, - size_t num_keys, const size_t *key_lengths, const double *key_weights, - marisa_uint32 *key_ids, int flags); - -marisa_status marisa_mmap(marisa_trie *h, const char *filename, - long offset, int whence); -marisa_status marisa_map(marisa_trie *h, const void *ptr, size_t size); - -marisa_status marisa_load(marisa_trie *h, const char *filename, - long offset, int whence); -marisa_status marisa_fread(marisa_trie *h, FILE *file); -marisa_status marisa_read(marisa_trie *h, int fd); - -marisa_status marisa_save(const marisa_trie *h, const char *filename, - int trunc_flag, long offset, int whence); -marisa_status marisa_fwrite(const marisa_trie *h, FILE *file); -marisa_status marisa_write(const marisa_trie *h, int fd); - -marisa_status marisa_restore(const marisa_trie *h, marisa_uint32 key_id, - char *key_buf, size_t key_buf_size, size_t *key_length); - -marisa_status marisa_lookup(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_id); - -marisa_status marisa_find(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_ids, size_t *key_lengths, - size_t max_num_results, size_t *num_results); -marisa_status marisa_find_first(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_id, size_t *key_length); -marisa_status marisa_find_last(const marisa_trie *h, - const char *ptr, size_t length, - marisa_uint32 *key_id, size_t *key_length); -marisa_status marisa_find_callback(const marisa_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_uint32, size_t), - void *first_arg_to_callback); - -marisa_status marisa_predict(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, - size_t max_num_results, size_t *num_results); -marisa_status marisa_predict_breadth_first(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, - size_t max_num_results, size_t *num_results); -marisa_status marisa_predict_depth_first(const marisa_trie *h, - const char *ptr, size_t length, marisa_uint32 *key_ids, - size_t max_num_results, size_t *num_results); -marisa_status marisa_predict_callback(const marisa_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_uint32, const char *, size_t), - void *first_arg_to_callback); - -size_t marisa_get_num_tries(const marisa_trie *h); -size_t marisa_get_num_keys(const marisa_trie *h); -size_t marisa_get_num_nodes(const marisa_trie *h); -size_t marisa_get_total_size(const marisa_trie *h); - -marisa_status marisa_clear(marisa_trie *h); - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // MARISA_TRIE_H_ diff --git a/lib/marisa/vector-inline.h b/lib/marisa/vector-inline.h deleted file mode 100644 index 79100be..0000000 --- a/lib/marisa/vector-inline.h +++ /dev/null @@ -1,216 +0,0 @@ -#ifndef MARISA_VECTOR_INLINE_H_ -#define MARISA_VECTOR_INLINE_H_ - -namespace marisa { - -template -Vector::Vector() - : buf_(NULL), objs_(NULL), size_(0), capacity_(0), fixed_(false) {} - -template -Vector::~Vector() { - if (buf_ != NULL) { - for (std::size_t i = 0; i < size_; ++i) { - buf_[i].~T(); - } - delete [] reinterpret_cast(buf_); - } -} - -template -void Vector::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_THROW_IF(mapper == NULL, MARISA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -template -void Vector::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -template -void Vector::map(Mapper &mapper) { - UInt32 size; - mapper.map(&size); - Vector temp; - mapper.map(&temp.objs_, size); - temp.size_ = size; - temp.fix(); - temp.swap(this); -} - -template -void Vector::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -template -void Vector::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -template -void Vector::read(int fd) { - Reader reader(fd); - read(reader); -} - -template -void Vector::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -template -void Vector::read(Reader &reader) { - UInt32 size; - reader.read(&size); - Vector temp; - temp.resize(size); - reader.read(temp.buf_, size); - temp.swap(this); -} - -template -void Vector::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -template -void Vector::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -template -void Vector::write(int fd) const { - Writer writer(fd); - write(writer); -} - -template -void Vector::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -template -void Vector::write(Writer &writer) const { - writer.write(size_); - writer.write(objs_, size_); -} - -template -void Vector::push_back(const T &x) { - MARISA_THROW_IF(fixed_, MARISA_STATE_ERROR); - MARISA_THROW_IF(size_ == max_size(), MARISA_SIZE_ERROR); - reserve(size_ + 1); - new (&buf_[size_++]) T(x); -} - -template -void Vector::pop_back() { - MARISA_THROW_IF(fixed_ || (size_ == 0), MARISA_STATE_ERROR); - buf_[--size_].~T(); -} - -template -void Vector::resize(std::size_t size) { - MARISA_THROW_IF(fixed_, MARISA_STATE_ERROR); - reserve(size); - for (std::size_t i = size_; i < size; ++i) { - new (&buf_[i]) T; - } - for (std::size_t i = size; i < size_; ++i) { - buf_[i].~T(); - } - size_ = (UInt32)size; -} - -template -void Vector::resize(std::size_t size, const T &x) { - MARISA_THROW_IF(fixed_, MARISA_STATE_ERROR); - reserve(size); - for (std::size_t i = size_; i < size; ++i) { - new (&buf_[i]) T(x); - } - for (std::size_t i = size; i < size_; ++i) { - buf_[i].~T(); - } - size_ = (UInt32)size; -} - -template -void Vector::reserve(std::size_t capacity) { - MARISA_THROW_IF(fixed_, MARISA_STATE_ERROR); - MARISA_THROW_IF(capacity > max_size(), MARISA_SIZE_ERROR); - if (capacity <= capacity_) { - return; - } - std::size_t new_capacity = capacity; - if (capacity_ > (capacity / 2)) { - if (capacity_ > (max_size() / 2)) { - new_capacity = max_size(); - } else { - new_capacity = capacity_ * 2; - } - } - realloc(new_capacity); -} - -template -void Vector::shrink() { - MARISA_THROW_IF(fixed_, MARISA_STATE_ERROR); - if (size_ != capacity_) { - realloc(size_); - } -} - -template -void Vector::fix() { - MARISA_THROW_IF(fixed_, MARISA_STATE_ERROR); - fixed_ = true; -} - -template -void Vector::swap(Vector *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - Swap(&buf_, &rhs->buf_); - Swap(&objs_, &rhs->objs_); - Swap(&size_, &rhs->size_); - Swap(&capacity_, &rhs->capacity_); - Swap(&fixed_, &rhs->fixed_); -} - -template -void Vector::realloc(std::size_t new_capacity) { - MARISA_THROW_IF(new_capacity > (MARISA_SIZE_MAX / sizeof(T)), - MARISA_SIZE_ERROR); - T * const new_buf = reinterpret_cast( - new (std::nothrow) char[sizeof(T) * new_capacity]); - MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR); - for (std::size_t i = 0; i < size_; ++i) { - new (&new_buf[i]) T(buf_[i]); - buf_[i].~T(); - } - delete [] reinterpret_cast(buf_); - buf_ = new_buf; - objs_ = new_buf; - capacity_ = (UInt32)new_capacity; -} - -} // namespace marisa - -#endif // MARISA_VECTOR_INLINE_H_ diff --git a/lib/marisa/vector.h b/lib/marisa/vector.h deleted file mode 100644 index e6eeaae..0000000 --- a/lib/marisa/vector.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef MARISA_VECTOR_H_ -#define MARISA_VECTOR_H_ - -#include "io.h" - -namespace marisa { - -template -class Vector { - public: - Vector(); - ~Vector(); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = false, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - void push_back(const T &x); - void pop_back(); - - void resize(std::size_t size); - void resize(std::size_t size, const T &x); - void reserve(std::size_t capacity); - void shrink(); - - void fix(); - - const T *begin() const { - return objs_; - } - const T *end() const { - return objs_ + size_; - } - const T &operator[](std::size_t i) const { - MARISA_DEBUG_IF(i > size_, MARISA_PARAM_ERROR); - return objs_[i]; - } - const T &front() const { - MARISA_DEBUG_IF(size_ == 0, MARISA_STATE_ERROR); - return objs_[0]; - } - const T &back() const { - MARISA_DEBUG_IF(size_ == 0, MARISA_STATE_ERROR); - return objs_[size_ - 1]; - } - - T *begin() { - MARISA_DEBUG_IF(fixed_, MARISA_STATE_ERROR); - return buf_; - } - T *end() { - MARISA_DEBUG_IF(fixed_, MARISA_STATE_ERROR); - return buf_ + size_; - } - T &operator[](std::size_t i) { - MARISA_DEBUG_IF(fixed_, MARISA_STATE_ERROR); - MARISA_DEBUG_IF(i > size_, MARISA_PARAM_ERROR); - return buf_[i]; - } - T &front() { - MARISA_DEBUG_IF(fixed_ || (size_ == 0), MARISA_STATE_ERROR); - return buf_[0]; - } - T &back() { - MARISA_DEBUG_IF(fixed_ || (size_ == 0), MARISA_STATE_ERROR); - return buf_[size_ - 1]; - } - - bool empty() const { - return size_ == 0; - } - std::size_t size() const { - return size_; - } - std::size_t capacity() const { - return capacity_; - } - bool fixed() const { - return fixed_; - } - std::size_t total_size() const { - return (sizeof(T) * size_) + sizeof(size_); - } - - void clear() { - Vector().swap(this); - } - void swap(Vector *rhs); - - static std::size_t max_size() { - return MARISA_UINT32_MAX; - } - - private: - T *buf_; - const T *objs_; - UInt32 size_; - UInt32 capacity_; - bool fixed_; - - void realloc(std::size_t new_capacity); - - // Disallows copy and assignment. - Vector(const Vector &); - Vector &operator=(const Vector &); -}; - -} // namespace marisa - -#include "vector-inline.h" - -#endif // MARISA_VECTOR_H_ diff --git a/lib/marisa/writer.cc b/lib/marisa/writer.cc deleted file mode 100644 index 55dcb97..0000000 --- a/lib/marisa/writer.cc +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include - -#ifdef _MSC_VER -#include -#else // _MSC_VER -#include -#endif // _MSC_VER - -#include "writer.h" - -namespace marisa { - -Writer::Writer() - : file_(NULL), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Writer::Writer(std::FILE *file) - : file_(file), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Writer::Writer(int fd) - : file_(NULL), fd_(fd), stream_(NULL), needs_fclose_(false) {} - -Writer::Writer(std::ostream *stream) - : file_(NULL), fd_(-1), stream_(stream), needs_fclose_(false) {} - -Writer::~Writer() { - if (needs_fclose_) { - ::fclose(file_); - } -} - -void Writer::open(const char *filename, bool trunc_flag, - long offset, int whence) { - MARISA_THROW_IF(is_open(), MARISA_STATE_ERROR); - MARISA_THROW_IF(filename == NULL, MARISA_PARAM_ERROR); -#ifdef _MSC_VER - std::FILE *file = NULL; - if (!trunc_flag) { - ::fopen_s(&file, filename, "rb+"); - } - if (file == NULL) { - if (::fopen_s(&file, filename, "wb") != 0) { - MARISA_THROW(MARISA_IO_ERROR); - } - } -#else // _MSC_VER - std::FILE *file = NULL; - if (!trunc_flag) { - file = ::fopen(filename, "rb+"); - } - if (file == NULL) { - file = ::fopen(filename, "wb"); - MARISA_THROW_IF(file == NULL, MARISA_IO_ERROR); - } -#endif // _MSC_VER - if (::fseek(file, offset, whence) != 0) { - ::fclose(file); - MARISA_THROW(MARISA_IO_ERROR); - } - file_ = file; - needs_fclose_ = true; -} - -void Writer::clear() { - Writer().swap(this); -} - -void Writer::swap(Writer *rhs) { - MARISA_THROW_IF(rhs == NULL, MARISA_PARAM_ERROR); - Swap(&file_, &rhs->file_); - Swap(&fd_, &rhs->fd_); - Swap(&stream_, &rhs->stream_); - Swap(&needs_fclose_, &rhs->needs_fclose_); -} - -void Writer::write_data(const void *data, std::size_t size) { - if (fd_ != -1) { - while (size != 0) { -#ifdef _MSC_VER - const unsigned int count = (size < INT_MAX) ? size : INT_MAX; - const int size_written = _write(fd_, data, count); -#else // _MSC_VER - const ::size_t count = (size < SSIZE_MAX) ? size : SSIZE_MAX; - const ::ssize_t size_written = ::write(fd_, data, count); -#endif // _MSC_VER - MARISA_THROW_IF(size_written <= 0, MARISA_IO_ERROR); - data = static_cast(data) + size_written; - size -= size_written; - } - } else if (file_ != NULL) { - if ((::fwrite(data, 1, size, file_) != size) || (::fflush(file_) != 0)) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else if (stream_ != NULL) { - if (!stream_->write(static_cast(data), size)) { - MARISA_THROW(MARISA_IO_ERROR); - } - } else { - MARISA_THROW(MARISA_STATE_ERROR); - } -} - -} // namespace marisa diff --git a/lib/marisa/writer.h b/lib/marisa/writer.h deleted file mode 100644 index 92e7c74..0000000 --- a/lib/marisa/writer.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef MARISA_WRITER_H_ -#define MARISA_WRITER_H_ - -#include -#include - -#include "base.h" - -namespace marisa { - -class Writer { - public: - Writer(); - explicit Writer(std::FILE *file); - explicit Writer(int fd); - explicit Writer(std::ostream *stream); - ~Writer(); - - void open(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET); - - template - void write(const T &obj) { - write_data(&obj, sizeof(T)); - } - - template - void write(const T *objs, std::size_t num_objs) { - MARISA_THROW_IF((objs == NULL) && (num_objs != 0), MARISA_PARAM_ERROR); - MARISA_THROW_IF(num_objs > (MARISA_UINT32_MAX / sizeof(T)), - MARISA_SIZE_ERROR); - if (num_objs != 0) { - write_data(objs, sizeof(T) * num_objs); - } - } - - bool is_open() const { - return (file_ != NULL) || (fd_ != -1) || (stream_ != NULL); - } - - void clear(); - void swap(Writer *rhs); - - private: - std::FILE *file_; - int fd_; - std::ostream *stream_; - bool needs_fclose_; - - void write_data(const void *data, std::size_t size); - - // Disallows copy and assignment. - Writer(const Writer &); - Writer &operator=(const Writer &); -}; - -} // namespace marisa - -#endif // MARISA_WRITER_H_ diff --git a/missing b/missing deleted file mode 100755 index 1c8ff70..0000000 --- a/missing +++ /dev/null @@ -1,367 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2006-05-10.23 - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case $1 in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $1 in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 8ee3f33..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -AM_CFLAGS = -Wall -D_DEBUG -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -I../lib - -TESTS = \ - unit-test \ - io-test \ - vector-test \ - tail-test \ - trie-test \ - c-test - -check_PROGRAMS = $(TESTS) - -noinst_HEADERS = assert.h - -unit_test_SOURCES = unit-test.cc -unit_test_LDADD = ../lib/libmarisa.a - -io_test_SOURCES = io-test.cc -io_test_LDADD = ../lib/libmarisa.a - -vector_test_SOURCES = vector-test.cc -vector_test_LDADD = ../lib/libmarisa.a - -tail_test_SOURCES = tail-test.cc -tail_test_LDADD = ../lib/libmarisa.a - -trie_test_SOURCES = trie-test.cc -trie_test_LDADD = ../lib/libmarisa.a - -c_test_SOURCES = c-test.c -c_test_LDADD = ../lib/libmarisa.a -lstdc++ diff --git a/tests/Makefile.in b/tests/Makefile.in deleted file mode 100644 index 1d16fb3..0000000 --- a/tests/Makefile.in +++ /dev/null @@ -1,590 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -TESTS = unit-test$(EXEEXT) io-test$(EXEEXT) vector-test$(EXEEXT) \ - tail-test$(EXEEXT) trie-test$(EXEEXT) c-test$(EXEEXT) -check_PROGRAMS = $(am__EXEEXT_1) -subdir = tests -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__EXEEXT_1 = unit-test$(EXEEXT) io-test$(EXEEXT) \ - vector-test$(EXEEXT) tail-test$(EXEEXT) trie-test$(EXEEXT) \ - c-test$(EXEEXT) -am_c_test_OBJECTS = c-test.$(OBJEXT) -c_test_OBJECTS = $(am_c_test_OBJECTS) -c_test_DEPENDENCIES = ../lib/libmarisa.a -am_io_test_OBJECTS = io-test.$(OBJEXT) -io_test_OBJECTS = $(am_io_test_OBJECTS) -io_test_DEPENDENCIES = ../lib/libmarisa.a -am_tail_test_OBJECTS = tail-test.$(OBJEXT) -tail_test_OBJECTS = $(am_tail_test_OBJECTS) -tail_test_DEPENDENCIES = ../lib/libmarisa.a -am_trie_test_OBJECTS = trie-test.$(OBJEXT) -trie_test_OBJECTS = $(am_trie_test_OBJECTS) -trie_test_DEPENDENCIES = ../lib/libmarisa.a -am_unit_test_OBJECTS = unit-test.$(OBJEXT) -unit_test_OBJECTS = $(am_unit_test_OBJECTS) -unit_test_DEPENDENCIES = ../lib/libmarisa.a -am_vector_test_OBJECTS = vector-test.$(OBJEXT) -vector_test_OBJECTS = $(am_vector_test_OBJECTS) -vector_test_DEPENDENCIES = ../lib/libmarisa.a -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -SOURCES = $(c_test_SOURCES) $(io_test_SOURCES) $(tail_test_SOURCES) \ - $(trie_test_SOURCES) $(unit_test_SOURCES) \ - $(vector_test_SOURCES) -DIST_SOURCES = $(c_test_SOURCES) $(io_test_SOURCES) \ - $(tail_test_SOURCES) $(trie_test_SOURCES) $(unit_test_SOURCES) \ - $(vector_test_SOURCES) -HEADERS = $(noinst_HEADERS) -ETAGS = etags -CTAGS = ctags -am__tty_colors = \ -red=; grn=; lgn=; blu=; std= -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CFLAGS = -Wall -D_DEBUG -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -I../lib -noinst_HEADERS = assert.h -unit_test_SOURCES = unit-test.cc -unit_test_LDADD = ../lib/libmarisa.a -io_test_SOURCES = io-test.cc -io_test_LDADD = ../lib/libmarisa.a -vector_test_SOURCES = vector-test.cc -vector_test_LDADD = ../lib/libmarisa.a -tail_test_SOURCES = tail-test.cc -tail_test_LDADD = ../lib/libmarisa.a -trie_test_SOURCES = trie-test.cc -trie_test_LDADD = ../lib/libmarisa.a -c_test_SOURCES = c-test.c -c_test_LDADD = ../lib/libmarisa.a -lstdc++ -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .cc .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu tests/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) -c-test$(EXEEXT): $(c_test_OBJECTS) $(c_test_DEPENDENCIES) - @rm -f c-test$(EXEEXT) - $(LINK) $(c_test_OBJECTS) $(c_test_LDADD) $(LIBS) -io-test$(EXEEXT): $(io_test_OBJECTS) $(io_test_DEPENDENCIES) - @rm -f io-test$(EXEEXT) - $(CXXLINK) $(io_test_OBJECTS) $(io_test_LDADD) $(LIBS) -tail-test$(EXEEXT): $(tail_test_OBJECTS) $(tail_test_DEPENDENCIES) - @rm -f tail-test$(EXEEXT) - $(CXXLINK) $(tail_test_OBJECTS) $(tail_test_LDADD) $(LIBS) -trie-test$(EXEEXT): $(trie_test_OBJECTS) $(trie_test_DEPENDENCIES) - @rm -f trie-test$(EXEEXT) - $(CXXLINK) $(trie_test_OBJECTS) $(trie_test_LDADD) $(LIBS) -unit-test$(EXEEXT): $(unit_test_OBJECTS) $(unit_test_DEPENDENCIES) - @rm -f unit-test$(EXEEXT) - $(CXXLINK) $(unit_test_OBJECTS) $(unit_test_LDADD) $(LIBS) -vector-test$(EXEEXT): $(vector_test_OBJECTS) $(vector_test_DEPENDENCIES) - @rm -f vector-test$(EXEEXT) - $(CXXLINK) $(vector_test_OBJECTS) $(vector_test_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tail-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector-test.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.cc.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cc.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; skip=0; \ - srcdir=$(srcdir); export srcdir; \ - list=' $(TESTS) '; \ - $(am__tty_colors); \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - col=$$red; res=XPASS; \ - ;; \ - *) \ - col=$$grn; res=PASS; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xfail=`expr $$xfail + 1`; \ - col=$$lgn; res=XFAIL; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - col=$$red; res=FAIL; \ - ;; \ - esac; \ - else \ - skip=`expr $$skip + 1`; \ - col=$$blu; res=SKIP; \ - fi; \ - echo "$${col}$$res$${std}: $$tst"; \ - done; \ - if test "$$all" -eq 1; then \ - tests="test"; \ - All=""; \ - else \ - tests="tests"; \ - All="All "; \ - fi; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="$$All$$all $$tests passed"; \ - else \ - if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ - banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ - fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all $$tests failed"; \ - else \ - if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ - banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ - fi; \ - fi; \ - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - if test "$$skip" -eq 1; then \ - skipped="($$skip test was not run)"; \ - else \ - skipped="($$skip tests were not run)"; \ - fi; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ - fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ - fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ - else \ - echo "$$red$$dashes"; \ - fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ - test "$$failed" -eq 0; \ - else :; fi - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(HEADERS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ - clean-checkPROGRAMS clean-generic ctags distclean \ - distclean-compile distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/tests/assert.h b/tests/assert.h deleted file mode 100644 index c898abb..0000000 --- a/tests/assert.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MARISA_ASSERT_H_ -#define MARISA_ASSERT_H_ - -#include -#include - -#define ASSERT(cond) (void)((!!(cond)) || \ - (printf("%d: Assertion `%s' failed.\n", __LINE__, #cond), exit(-1), 0)) - -#define EXCEPT(code, expected_status) try { \ - code; \ - printf("%d: Exception `%s' failed.\n", __LINE__, #code); \ - exit(-1); \ -} catch (const marisa::Exception &ex) { \ - ASSERT(ex.status() == expected_status); \ -} - -#define TEST_START() \ - printf("%s:%d: %s(): ", __FILE__, __LINE__, __FUNCTION__) - -#define TEST_END() \ - printf("ok\n") - -#endif // MARISA_ASSERT_H_ diff --git a/tests/c-test.c b/tests/c-test.c deleted file mode 100644 index 0479485..0000000 --- a/tests/c-test.c +++ /dev/null @@ -1,209 +0,0 @@ -#include - -#include - -#include "assert.h" - -void TestHandle(void) { - marisa_trie *trie = NULL; - - TEST_START(); - - ASSERT(marisa_init(&trie) == MARISA_OK); - ASSERT(marisa_init(&trie) == MARISA_HANDLE_ERROR); - ASSERT(marisa_end(trie) == MARISA_OK); - ASSERT(marisa_end(NULL) == MARISA_HANDLE_ERROR); - - ASSERT(marisa_build(NULL, NULL, 0, NULL, NULL, NULL, 0) == - MARISA_HANDLE_ERROR); - - ASSERT(marisa_mmap(NULL, NULL, 0, 0) == MARISA_HANDLE_ERROR); - ASSERT(marisa_map(NULL, NULL, 0) == MARISA_HANDLE_ERROR); - - ASSERT(marisa_load(NULL, NULL, 0, 0) == MARISA_HANDLE_ERROR); - ASSERT(marisa_fread(NULL, NULL) == MARISA_HANDLE_ERROR); - ASSERT(marisa_read(NULL, 0) == MARISA_HANDLE_ERROR); - - ASSERT(marisa_save(NULL, NULL, 0, 0, 0) == MARISA_HANDLE_ERROR); - ASSERT(marisa_fwrite(NULL, NULL) == MARISA_HANDLE_ERROR); - ASSERT(marisa_write(NULL, 0) == MARISA_HANDLE_ERROR); - - ASSERT(marisa_restore(NULL, 0, NULL, 0, NULL) == MARISA_HANDLE_ERROR); - - ASSERT(marisa_lookup(NULL, NULL, 0, NULL) == MARISA_HANDLE_ERROR); - - ASSERT(marisa_find(NULL, NULL, 0, NULL, NULL, 0, NULL) == - MARISA_HANDLE_ERROR); - ASSERT(marisa_find_first(NULL, NULL, 0, NULL, NULL) == MARISA_HANDLE_ERROR); - ASSERT(marisa_find_last(NULL, NULL, 0, NULL, NULL) == MARISA_HANDLE_ERROR); - ASSERT(marisa_find_callback(NULL, NULL, 0, NULL, NULL) == - MARISA_HANDLE_ERROR); - - ASSERT(marisa_predict(NULL, NULL, 0, NULL, 0, NULL) == MARISA_HANDLE_ERROR); - ASSERT(marisa_predict_breadth_first(NULL, NULL, 0, NULL, 0, NULL) == - MARISA_HANDLE_ERROR); - ASSERT(marisa_predict_depth_first(NULL, NULL, 0, NULL, 0, NULL) == - MARISA_HANDLE_ERROR); - ASSERT(marisa_predict_callback(NULL, NULL, 0, NULL, NULL) == - MARISA_HANDLE_ERROR); - - ASSERT(marisa_get_num_tries(NULL) == 0); - ASSERT(marisa_get_num_keys(NULL) == 0); - ASSERT(marisa_get_num_nodes(NULL) == 0); - ASSERT(marisa_get_total_size(NULL) == 0); - - ASSERT(marisa_clear(NULL) == MARISA_HANDLE_ERROR); - - TEST_END(); -} - -int callback_for_find(void *num_keys, - marisa_uint32 key_id, size_t key_length) { - ASSERT(*(size_t *)num_keys == 0); - ASSERT(key_id == 1); - ASSERT(key_length == 3); - ++*(size_t *)num_keys; - return 1; -} - -int callback_for_predict(void *num_keys, - marisa_uint32 key_id, const char *key, size_t key_length) { - ASSERT(*(size_t *)num_keys < 2); - switch (*(size_t *)num_keys) { - case 0: { - ASSERT(key_id == 0); - ASSERT(key_length == 3); - ASSERT(strcmp(key, "app") == 0); - break; - } - case 1: { - ASSERT(key_id == 3); - ASSERT(key_length == 5); - ASSERT(strcmp(key, "apple") == 0); - break; - } - } - ++*(size_t *)num_keys; - return 1; -} - -void TestTrie() { - marisa_trie *trie = NULL; - const char *keys[8]; - marisa_uint32 key_ids[8]; - size_t i; - char key_buf[16]; - size_t key_length; - marisa_uint32 key_id; - marisa_uint32 found_key_ids[8]; - size_t found_key_lengths[8]; - size_t num_found_keys; - - TEST_START(); - - ASSERT(marisa_init(&trie) == MARISA_OK); - - ASSERT(marisa_get_num_tries(trie) == 0); - ASSERT(marisa_get_num_keys(trie) == 0); - ASSERT(marisa_get_num_nodes(trie) == 0); - ASSERT(marisa_get_total_size(trie) == (sizeof(marisa_uint32) * 23)); - - ASSERT(marisa_build(trie, NULL, 0, NULL, NULL, NULL, 0) == MARISA_OK); - - ASSERT(marisa_get_num_tries(trie) == 1); - ASSERT(marisa_get_num_keys(trie) == 0); - ASSERT(marisa_get_num_nodes(trie) == 1); - - keys[0] = "apple"; - keys[1] = "and"; - keys[2] = "Bad"; - keys[3] = "apple"; - keys[4] = "app"; - - ASSERT(marisa_build(trie, keys, 5, NULL, NULL, key_ids, - 1 | MARISA_WITHOUT_TAIL | MARISA_LABEL_ORDER) == MARISA_OK); - - ASSERT(marisa_get_num_tries(trie) == 1); - ASSERT(marisa_get_num_keys(trie) == 4); - ASSERT(marisa_get_num_nodes(trie) == 11); - - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 0); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 2); - - for (i = 0; i < marisa_get_num_tries(trie); ++i) { - ASSERT(marisa_restore(trie, - key_ids[i], key_buf, sizeof(key_buf), &key_length) == MARISA_OK); - ASSERT(key_length == strlen(keys[i])); - ASSERT(strcmp(key_buf, keys[i]) == 0); - - ASSERT(marisa_lookup(trie, - keys[i], MARISA_ZERO_TERMINATED, &key_id) == MARISA_OK); - ASSERT(key_id == key_ids[i]); - - ASSERT(marisa_lookup(trie, - keys[i], strlen(keys[i]), &key_id) == MARISA_OK); - ASSERT(key_id == key_ids[i]); - } - - ASSERT(marisa_clear(trie) == MARISA_OK); - - ASSERT(marisa_get_num_tries(trie) == 0); - ASSERT(marisa_get_num_keys(trie) == 0); - ASSERT(marisa_get_num_nodes(trie) == 0); - ASSERT(marisa_get_total_size(trie) == (sizeof(marisa_uint32) * 23)); - - ASSERT(marisa_build(trie, keys, 5, NULL, NULL, key_ids, - 1 | MARISA_WITHOUT_TAIL | MARISA_WEIGHT_ORDER) == MARISA_OK); - - ASSERT(marisa_get_num_tries(trie) == 1); - ASSERT(marisa_get_num_keys(trie) == 4); - ASSERT(marisa_get_num_nodes(trie) == 11); - - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 2); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 0); - - ASSERT(marisa_find(trie, "ap", MARISA_ZERO_TERMINATED, - found_key_ids, found_key_lengths, 8, &num_found_keys) == MARISA_OK); - ASSERT(num_found_keys == 0); - - ASSERT(marisa_find(trie, "applex", MARISA_ZERO_TERMINATED, - found_key_ids, found_key_lengths, 8, &num_found_keys) == MARISA_OK); - ASSERT(num_found_keys == 2); - ASSERT(found_key_ids[0] == key_ids[4]); - ASSERT(found_key_lengths[0] == 3); - ASSERT(found_key_ids[1] == key_ids[0]); - ASSERT(found_key_lengths[1] == 5); - - num_found_keys = 0; - ASSERT(marisa_find_callback(trie, "anderson", MARISA_ZERO_TERMINATED, - callback_for_find, &num_found_keys) == MARISA_OK); - ASSERT(num_found_keys == 1); - - ASSERT(marisa_predict(trie, "a", MARISA_ZERO_TERMINATED, - found_key_ids, 8, &num_found_keys) == MARISA_OK); - ASSERT(num_found_keys == 3); - ASSERT(found_key_ids[0] == key_ids[4]); - ASSERT(found_key_ids[1] == key_ids[1]); - ASSERT(found_key_ids[2] == key_ids[0]); - - num_found_keys = 0; - ASSERT(marisa_predict_callback(trie, "app", MARISA_ZERO_TERMINATED, - callback_for_predict, &num_found_keys) == MARISA_OK); - - ASSERT(marisa_end(trie) == MARISA_OK); - - TEST_END(); -} - -int main(void) { - TestHandle(); - TestTrie(); - - return 0; -} diff --git a/tests/io-test.cc b/tests/io-test.cc deleted file mode 100644 index a223c0a..0000000 --- a/tests/io-test.cc +++ /dev/null @@ -1,236 +0,0 @@ -#ifdef _MSC_VER -#include -#else -#include -#endif // _MSC_VER - -#include -#include -#include - -#include - -#include - -#include "assert.h" - -namespace { - -void TestFilename() { - TEST_START(); - - { - marisa::Writer writer; - writer.open("io-test.dat"); - marisa::UInt32 value = 123; - writer.write(value); - writer.write(value); - double values[] = { 345, 456 }; - writer.write(values, 2); - EXCEPT(writer.write(values, 1U << 30), MARISA_SIZE_ERROR); - } - - { - marisa::Writer writer; - writer.open("io-test.dat", false, 4, SEEK_SET); - marisa::UInt32 value = 234; - writer.write(value); - } - - { - marisa::Writer writer; - writer.open("io-test.dat", false, 0, SEEK_END); - double value = 567; - writer.write(value); - } - - { - marisa::Reader reader; - reader.open("io-test.dat"); - marisa::UInt32 value; - reader.read(&value); - ASSERT(value == 123); - reader.read(&value); - ASSERT(value == 234); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 345); - ASSERT(values[1] == 456); - ASSERT(values[2] == 567); - char byte; - EXCEPT(reader.read(&byte), MARISA_IO_ERROR); - } - - { - marisa::Mapper mapper; - mapper.open("io-test.dat"); - marisa::UInt32 value; - mapper.map(&value); - ASSERT(value == 123); - mapper.map(&value); - ASSERT(value == 234); - const double *values; - mapper.map(&values, 3); - ASSERT(values[0] == 345); - ASSERT(values[1] == 456); - ASSERT(values[2] == 567); - char byte; - EXCEPT(mapper.map(&byte), MARISA_IO_ERROR); - } - - { - marisa::Writer writer; - writer.open("io-test.dat"); - } - - { - marisa::Reader reader; - reader.open("io-test.dat"); - char byte; - EXCEPT(reader.read(&byte), MARISA_IO_ERROR); - } - - TEST_END(); -} - -void TestFd() { - TEST_START(); - - { -#ifdef _MSC_VER - int fd = -1; - ASSERT(::_sopen_s(&fd, "io-test.dat", - _O_BINARY | _O_CREAT | _O_WRONLY | _O_TRUNC, - _SH_DENYRW, _S_IREAD | _S_IWRITE) == 0); -#else // _MSC_VER - int fd = ::creat("io-test.dat", 0644); - ASSERT(fd != -1); -#endif // _MSC_VER - marisa::Writer writer(fd); - marisa::UInt32 value = 345; - writer.write(value); - double values[] = { 456, 567, 678 }; - writer.write(values, 3); -#ifdef _MSC_VER - ASSERT(::_close(fd) == 0); -#else // _MSC_VER - ASSERT(::close(fd) == 0); -#endif // _MSC_VER - } - - { -#ifdef _MSC_VER - int fd = -1; - ASSERT(::_sopen_s(&fd, "io-test.dat", _O_BINARY | _O_RDONLY, - _SH_DENYRW, _S_IREAD) == 0); -#else // _MSC_VER - int fd = ::open("io-test.dat", O_RDONLY); - ASSERT(fd != -1); -#endif // _MSC_VER - marisa::Reader reader(fd); - marisa::UInt32 value; - reader.read(&value); - ASSERT(value == 345); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 456); - ASSERT(values[1] == 567); - ASSERT(values[2] == 678); - char byte; - EXCEPT(reader.read(&byte), MARISA_IO_ERROR); -#ifdef _MSC_VER - ASSERT(::_close(fd) == 0); -#else // _MSC_VER - ASSERT(::close(fd) == 0); -#endif // _MSC_VER - } - - TEST_END(); -} - -void TestFile() { - TEST_START(); - - { -#ifdef _MSC_VER - FILE *file = NULL; - ASSERT(::fopen_s(&file, "io-test.dat", "wb") == 0); -#else // _MSC_VER - FILE *file = std::fopen("io-test.dat", "wb"); - ASSERT(file != NULL); -#endif // _MSC_VER - marisa::Writer writer(file); - marisa::UInt32 value = 345; - writer.write(value); - double values[3] = { 456, 567, 678 }; - writer.write(values, 3); - ASSERT(std::fclose(file) == 0); - } - - { -#ifdef _MSC_VER - FILE *file = NULL; - ASSERT(::fopen_s(&file, "io-test.dat", "rb") == 0); -#else // _MSC_VER - FILE *file = std::fopen("io-test.dat", "rb"); - ASSERT(file != NULL); -#endif // _MSC_VER - marisa::Reader reader(file); - marisa::UInt32 value; - reader.read(&value); - ASSERT(value == 345); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 456); - ASSERT(values[1] == 567); - ASSERT(values[2] == 678); - char byte; - EXCEPT(reader.read(&byte), MARISA_IO_ERROR); - ASSERT(std::fclose(file) == 0); - } - - TEST_END(); -} - -void TestStream() { - TEST_START(); - - { - std::ofstream file("io-test.dat", std::ios::binary); - ASSERT(file.is_open()); - marisa::Writer writer(&file); - marisa::UInt32 value = 345; - writer.write(value); - double values[3] = { 456, 567, 678 }; - writer.write(values, 3); - } - - { - std::ifstream file("io-test.dat", std::ios::binary); - ASSERT(file.is_open()); - marisa::Reader reader(&file); - marisa::UInt32 value; - reader.read(&value); - ASSERT(value == 345); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 456); - ASSERT(values[1] == 567); - ASSERT(values[2] == 678); - char byte; - EXCEPT(reader.read(&byte), MARISA_IO_ERROR); - } - - TEST_END(); -} - -} // namespace - -int main() { - TestFilename(); - TestFd(); - TestFile(); - TestStream(); - - return 0; -} diff --git a/tests/tail-test.cc b/tests/tail-test.cc deleted file mode 100644 index 73fa10c..0000000 --- a/tests/tail-test.cc +++ /dev/null @@ -1,242 +0,0 @@ -#include -#include - -#include - -#include "assert.h" - -namespace { - -void TestBinaryTail() { - TEST_START(); - - marisa::Tail tail; - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32)); - - marisa::Vector keys; - tail.build(keys, NULL, MARISA_BINARY_TAIL); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32)); - - keys.push_back(marisa::String("")); - marisa::Vector offsets; - tail.build(keys, &offsets, MARISA_BINARY_TAIL); - - ASSERT(tail.size() == 1); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size() + 1); - ASSERT(offsets[0] == 1); - ASSERT(offsets[1] == tail.size()); - - const char binary_key[] = { 'N', 'P', '\0', 'T', 'r', 'i', 'e' }; - keys[0] = marisa::String(binary_key, sizeof(binary_key)); - tail.build(keys, &offsets, MARISA_TEXT_TAIL); - - ASSERT(tail.size() == sizeof(binary_key) + 1); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size() + 1); - ASSERT(offsets[0] == 1); - ASSERT(offsets[1] == tail.size()); - - tail.build(keys, &offsets, MARISA_BINARY_TAIL); - - ASSERT(tail.size() == sizeof(binary_key) + 1); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size() + 1); - ASSERT(offsets[0] == 1); - ASSERT(offsets[1] == tail.size()); - - keys.clear(); - keys.push_back(marisa::String("abc")); - keys.push_back(marisa::String("bc")); - keys.push_back(marisa::String("abc")); - keys.push_back(marisa::String("c")); - keys.push_back(marisa::String("ABC")); - keys.push_back(marisa::String("AB")); - - tail.build(keys, NULL, MARISA_BINARY_TAIL); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - - tail.build(keys, &offsets, MARISA_BINARY_TAIL); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - ASSERT(offsets.size() == 7); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - tail.save("tail-test.dat"); - tail.clear(); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32)); - - marisa::Mapper mapper; - tail.mmap(&mapper, "tail-test.dat"); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - tail.clear(); - tail.load("tail-test.dat"); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - std::stringstream stream; - tail.write(stream); - - tail.clear(); - tail.read(stream); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - TEST_END(); -} - -void TestTextTail() { - TEST_START(); - - marisa::Tail tail; - marisa::Vector keys; - tail.build(keys, NULL, MARISA_TEXT_TAIL); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32)); - - keys.push_back(marisa::String("")); - marisa::Vector offsets; - tail.build(keys, &offsets, MARISA_TEXT_TAIL); - - ASSERT(tail.size() == 2); - ASSERT(tail.mode() == MARISA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size()); - ASSERT(offsets[0] == 1); - ASSERT(*tail[offsets[0]] == '\0'); - - keys.clear(); - keys.push_back(marisa::String("abc")); - keys.push_back(marisa::String("bc")); - keys.push_back(marisa::String("abc")); - keys.push_back(marisa::String("c")); - keys.push_back(marisa::String("ABC")); - keys.push_back(marisa::String("AB")); - - tail.build(keys, NULL, MARISA_TEXT_TAIL); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - - tail.build(keys, &offsets, MARISA_TEXT_TAIL); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size()); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - tail.save("tail-test.dat"); - tail.clear(); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32)); - - marisa::Mapper mapper; - tail.mmap(&mapper, "tail-test.dat"); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32) + tail.size()); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - tail.clear(); - tail.load("tail-test.dat"); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32) + tail.size()); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - std::stringstream stream; - tail.write(stream); - - tail.clear(); - tail.read(stream); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa::UInt32) + tail.size()); - for (marisa::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - TEST_END(); -} - -} // namespace - -int main() { - TestBinaryTail(); - TestTextTail(); - - return 0; -} diff --git a/tests/trie-test.cc b/tests/trie-test.cc deleted file mode 100644 index 8d36267..0000000 --- a/tests/trie-test.cc +++ /dev/null @@ -1,645 +0,0 @@ -#include - -#include - -#include "assert.h" - -namespace { - -class FindCallback { - public: - FindCallback(std::vector *key_ids, - std::vector *key_lengths) - : key_ids_(key_ids), key_lengths_(key_lengths) {} - FindCallback(const FindCallback &callback) - : key_ids_(callback.key_ids_), key_lengths_(callback.key_lengths_) {} - - bool operator()(marisa::UInt32 key_id, std::size_t key_length) const { - key_ids_->push_back(key_id); - key_lengths_->push_back(key_length); - return true; - } - - private: - std::vector *key_ids_; - std::vector *key_lengths_; - - // Disallows assignment. - FindCallback &operator=(const FindCallback &); -}; - -class PredictCallback { - public: - PredictCallback(std::vector *key_ids, - std::vector *keys) - : key_ids_(key_ids), keys_(keys) {} - PredictCallback(const PredictCallback &callback) - : key_ids_(callback.key_ids_), keys_(callback.keys_) {} - - bool operator()(marisa::UInt32 key_id, const std::string &key) const { - key_ids_->push_back(key_id); - keys_->push_back(key); - return true; - } - - private: - std::vector *key_ids_; - std::vector *keys_; - - // Disallows assignment. - PredictCallback &operator=(const PredictCallback &); -}; - -void TestTrie() { - TEST_START(); - - marisa::Trie trie; - - ASSERT(trie.num_tries() == 0); - ASSERT(trie.num_keys() == 0); - ASSERT(trie.num_nodes() == 0); - ASSERT(trie.total_size() == (sizeof(marisa::UInt32) * 23)); - - std::vector keys; - trie.build(keys); - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 0); - ASSERT(trie.num_nodes() == 1); - - keys.push_back("apple"); - keys.push_back("and"); - keys.push_back("Bad"); - keys.push_back("apple"); - keys.push_back("app"); - - std::vector key_ids; - trie.build(keys, &key_ids, 1 | MARISA_WITHOUT_TAIL | MARISA_LABEL_ORDER); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 11); - - ASSERT(key_ids.size() == 5); - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 0); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 2); - - char key_buf[256]; - std::size_t key_length; - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.clear(); - - ASSERT(trie.num_tries() == 0); - ASSERT(trie.num_keys() == 0); - ASSERT(trie.num_nodes() == 0); - ASSERT(trie.total_size() == (sizeof(marisa::UInt32) * 23)); - - trie.build(keys, &key_ids, 1 | MARISA_WITHOUT_TAIL | MARISA_WEIGHT_ORDER); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 11); - - ASSERT(key_ids.size() == 5); - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 2); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 0); - - for (std::size_t i = 0; i < keys.size(); ++i) { - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - } - - ASSERT(trie["appl"] == trie.notfound()); - ASSERT(trie["applex"] == trie.notfound()); - ASSERT(trie.find_first("ap") == trie.notfound()); - ASSERT(trie.find_first("applex") == trie["app"]); - ASSERT(trie.find_last("ap") == trie.notfound()); - ASSERT(trie.find_last("applex") == trie["apple"]); - - std::vector ids; - ASSERT(trie.find("ap", &ids) == 0); - ASSERT(trie.find("applex", &ids) == 2); - ASSERT(ids.size() == 2); - ASSERT(ids[0] == trie["app"]); - ASSERT(ids[1] == trie["apple"]); - - std::vector lengths; - ASSERT(trie.find("Baddie", &ids, &lengths) == 1); - ASSERT(ids.size() == 3); - ASSERT(ids[2] == trie["Bad"]); - ASSERT(lengths.size() == 1); - ASSERT(lengths[0] == 3); - - ASSERT(trie.find_callback("anderson", FindCallback(&ids, &lengths)) == 1); - ASSERT(ids.size() == 4); - ASSERT(ids[3] == trie["and"]); - ASSERT(lengths.size() == 2); - ASSERT(lengths[1] == 3); - - ASSERT(trie.predict("") == 4); - ASSERT(trie.predict("a") == 3); - ASSERT(trie.predict("ap") == 2); - ASSERT(trie.predict("app") == 2); - ASSERT(trie.predict("appl") == 1); - ASSERT(trie.predict("apple") == 1); - ASSERT(trie.predict("appleX") == 0); - ASSERT(trie.predict("X") == 0); - - ids.clear(); - ASSERT(trie.predict("a", &ids) == 3); - ASSERT(ids.size() == 3); - ASSERT(ids[0] == trie["app"]); - ASSERT(ids[1] == trie["and"]); - ASSERT(ids[2] == trie["apple"]); - - std::vector strs; - ASSERT(trie.predict("a", &ids, &strs) == 3); - ASSERT(ids.size() == 6); - ASSERT(ids[3] == trie["app"]); - ASSERT(ids[4] == trie["apple"]); - ASSERT(ids[5] == trie["and"]); - ASSERT(strs[0] == "app"); - ASSERT(strs[1] == "apple"); - ASSERT(strs[2] == "and"); - - TEST_END(); -} - -void TestPrefixTrie() { - TEST_START(); - - std::vector keys; - keys.push_back("after"); - keys.push_back("bar"); - keys.push_back("car"); - keys.push_back("caster"); - - marisa::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids, 1 | MARISA_PREFIX_TRIE - | MARISA_TEXT_TAIL | MARISA_LABEL_ORDER); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 7); - - char key_buf[256]; - std::size_t key_length; - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - key_length = trie.restore(key_ids[0], NULL, 0); - - ASSERT(key_length == keys[0].length()); - EXCEPT(trie.restore(key_ids[0], NULL, 5), MARISA_PARAM_ERROR); - - key_length = trie.restore(key_ids[0], key_buf, 5); - - ASSERT(key_length == keys[0].length()); - - key_length = trie.restore(key_ids[0], key_buf, 6); - - ASSERT(key_length == keys[0].length()); - - trie.build(keys, &key_ids, 2 | MARISA_PREFIX_TRIE - | MARISA_WITHOUT_TAIL | MARISA_WEIGHT_ORDER); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 16); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - key_length = trie.restore(key_ids[0], NULL, 0); - - ASSERT(key_length == keys[0].length()); - EXCEPT(trie.restore(key_ids[0], NULL, 5), MARISA_PARAM_ERROR); - - key_length = trie.restore(key_ids[0], key_buf, 5); - - ASSERT(key_length == keys[0].length()); - - key_length = trie.restore(key_ids[0], key_buf, 6); - - ASSERT(key_length == keys[0].length()); - - trie.build(keys, &key_ids, 2 | MARISA_PREFIX_TRIE - | MARISA_TEXT_TAIL | MARISA_LABEL_ORDER); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.save("trie-test.dat"); - trie.clear(); - marisa::Mapper mapper; - trie.mmap(&mapper, "trie-test.dat"); - - ASSERT(mapper.is_open()); - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - std::stringstream stream; - trie.write(stream); - trie.clear(); - trie.read(stream); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 3 | MARISA_PREFIX_TRIE - | MARISA_WITHOUT_TAIL | MARISA_WEIGHT_ORDER); - - ASSERT(trie.num_tries() == 3); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 19); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - ASSERT(trie["ca"] == trie.notfound()); - ASSERT(trie["card"] == trie.notfound()); - - std::size_t length = 0; - ASSERT(trie.find_first("ca") == trie.notfound()); - ASSERT(trie.find_first("car") == trie["car"]); - ASSERT(trie.find_first("card", &length) == trie["car"]); - ASSERT(length == 3); - - ASSERT(trie.find_last("afte") == trie.notfound()); - ASSERT(trie.find_last("after") == trie["after"]); - ASSERT(trie.find_last("afternoon", &length) == trie["after"]); - ASSERT(length == 5); - - { - std::vector ids; - std::vector lengths; - ASSERT(trie.find("card", &ids, &lengths) == 1); - ASSERT(ids.size() == 1); - ASSERT(ids[0] == trie["car"]); - ASSERT(lengths.size() == 1); - ASSERT(lengths[0] == 3); - - ASSERT(trie.predict("ca", &ids) == 2); - ASSERT(ids.size() == 3); - ASSERT(ids[1] == trie["car"]); - ASSERT(ids[2] == trie["caster"]); - - ASSERT(trie.predict("ca", &ids, NULL, 1) == 1); - ASSERT(ids.size() == 4); - ASSERT(ids[3] == trie["car"]); - - std::vector strs; - ASSERT(trie.predict("ca", &ids, &strs, 1) == 1); - ASSERT(ids.size() == 5); - ASSERT(ids[4] == trie["car"]); - ASSERT(strs.size() == 1); - ASSERT(strs[0] == "car"); - - ASSERT(trie.predict_callback("", PredictCallback(&ids, &strs)) == 4); - ASSERT(ids.size() == 9); - ASSERT(ids[5] == trie["car"]); - ASSERT(ids[6] == trie["caster"]); - ASSERT(ids[7] == trie["after"]); - ASSERT(ids[8] == trie["bar"]); - ASSERT(strs.size() == 5); - ASSERT(strs[1] == "car"); - ASSERT(strs[2] == "caster"); - ASSERT(strs[3] == "after"); - ASSERT(strs[4] == "bar"); - } - - { - marisa::UInt32 ids[10]; - std::size_t lengths[10]; - ASSERT(trie.find("card", ids, lengths, 10) == 1); - ASSERT(ids[0] == trie["car"]); - ASSERT(lengths[0] == 3); - - ASSERT(trie.predict("ca", ids, NULL, 10) == 2); - ASSERT(ids[0] == trie["car"]); - ASSERT(ids[1] == trie["caster"]); - - ASSERT(trie.predict("ca", ids, NULL, 1) == 1); - ASSERT(ids[0] == trie["car"]); - - std::string strs[10]; - ASSERT(trie.predict("ca", ids, strs, 1) == 1); - ASSERT(ids[0] == trie["car"]); - ASSERT(strs[0] == "car"); - - ASSERT(trie.predict("", ids, strs, 10) == 4); - ASSERT(ids[0] == trie["car"]); - ASSERT(ids[1] == trie["caster"]); - ASSERT(ids[2] == trie["after"]); - ASSERT(ids[3] == trie["bar"]); - ASSERT(strs[0] == "car"); - ASSERT(strs[1] == "caster"); - ASSERT(strs[2] == "after"); - ASSERT(strs[3] == "bar"); - } - - TEST_END(); -} - -void TestPatriciaTrie() { - TEST_START(); - - std::vector keys; - keys.push_back("bach"); - keys.push_back("bet"); - keys.push_back("chat"); - keys.push_back("check"); - keys.push_back("check"); - - marisa::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids, 1); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 7); - - ASSERT(key_ids.size() == 5); - ASSERT(key_ids[0] == 2); - ASSERT(key_ids[1] == 3); - ASSERT(key_ids[2] == 1); - ASSERT(key_ids[3] == 0); - ASSERT(key_ids[4] == 0); - - char key_buf[256]; - std::size_t key_length; - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 2 | MARISA_WITHOUT_TAIL); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 17); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 2); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 3 | MARISA_WITHOUT_TAIL); - - ASSERT(trie.num_tries() == 3); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 20); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - std::stringstream stream; - trie.write(stream); - trie.clear(); - trie.read(stream); - - ASSERT(trie.num_tries() == 3); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 20); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - TEST_END(); -} - -void TestEmptyString() { - TEST_START(); - - std::vector keys; - keys.push_back(""); - - marisa::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 1); - - ASSERT(key_ids.size() == 1); - ASSERT(key_ids[0] == 0); - - ASSERT(trie[""] == 0); - ASSERT(trie[(marisa::UInt32)0] == ""); - - ASSERT(trie["x"] == trie.notfound()); - ASSERT(trie.find_first("") == 0); - ASSERT(trie.find_first("x") == 0); - ASSERT(trie.find_last("") == 0); - ASSERT(trie.find_last("x") == 0); - - std::vector ids; - ASSERT(trie.find("xyz", &ids) == 1); - ASSERT(ids.size() == 1); - ASSERT(ids[0] == trie[""]); - - std::vector lengths; - ASSERT(trie.find("xyz", &ids, &lengths) == 1); - ASSERT(ids.size() == 2); - ASSERT(ids[0] == trie[""]); - ASSERT(ids[1] == trie[""]); - ASSERT(lengths.size() == 1); - ASSERT(lengths[0] == 0); - - ASSERT(trie.find_callback("xyz", FindCallback(&ids, &lengths)) == 1); - ASSERT(ids.size() == 3); - ASSERT(ids[2] == trie[""]); - ASSERT(lengths.size() == 2); - ASSERT(lengths[1] == 0); - - ASSERT(trie.predict("xyz", &ids) == 0); - - ASSERT(trie.predict("", &ids) == 1); - ASSERT(ids.size() == 4); - ASSERT(ids[3] == trie[""]); - - std::vector strs; - ASSERT(trie.predict("", &ids, &strs) == 1); - ASSERT(ids.size() == 5); - ASSERT(ids[4] == trie[""]); - ASSERT(strs[0] == ""); - - TEST_END(); -} - -void TestBinaryKey() { - TEST_START(); - - std::string binary_key = "NP"; - binary_key += '\0'; - binary_key += "Trie"; - - std::vector keys; - keys.push_back(binary_key); - - marisa::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids, 1 | MARISA_WITHOUT_TAIL); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 8); - ASSERT(key_ids.size() == 1); - - char key_buf[256]; - std::size_t key_length; - key_length = trie.restore(0, key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[0]] == key_ids[0]); - ASSERT(trie[key_ids[0]] == keys[0]); - ASSERT(std::string(key_buf, key_length) == keys[0]); - - trie.build(keys, &key_ids, 1 | MARISA_PREFIX_TRIE | MARISA_BINARY_TAIL); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 2); - ASSERT(key_ids.size() == 1); - - key_length = trie.restore(0, key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[0]] == key_ids[0]); - ASSERT(trie[key_ids[0]] == keys[0]); - ASSERT(std::string(key_buf, key_length) == keys[0]); - - trie.build(keys, &key_ids, 1 | MARISA_PREFIX_TRIE | MARISA_TEXT_TAIL); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 2); - ASSERT(key_ids.size() == 1); - - key_length = trie.restore(0, key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[0]] == key_ids[0]); - ASSERT(trie[key_ids[0]] == keys[0]); - ASSERT(std::string(key_buf, key_length) == keys[0]); - - std::vector ids; - ASSERT(trie.predict_breadth_first("", &ids) == 1); - ASSERT(ids.size() == 1); - ASSERT(ids[0] == key_ids[0]); - - std::vector strs; - ASSERT(trie.predict_depth_first("NP", &ids, &strs) == 1); - ASSERT(ids.size() == 2); - ASSERT(ids[1] == key_ids[0]); - ASSERT(strs[0] == keys[0]); - - TEST_END(); -} - -} // namespace - -int main() { - TestTrie(); - TestPrefixTrie(); - TestPatriciaTrie(); - TestEmptyString(); - TestBinaryKey(); - - return 0; -} diff --git a/tests/unit-test.cc b/tests/unit-test.cc deleted file mode 100644 index 9d33bcb..0000000 --- a/tests/unit-test.cc +++ /dev/null @@ -1,459 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "assert.h" - -namespace { - -void TestBase() { - TEST_START(); - - ASSERT(sizeof(marisa_uint8) == 1); - ASSERT(sizeof(marisa_uint16) == 2); - ASSERT(sizeof(marisa_uint32) == 4); - ASSERT(sizeof(marisa_uint64) == 8); - - ASSERT(MARISA_UINT8_MAX == 0xFFU); - ASSERT(MARISA_UINT16_MAX == 0xFFFFU); - ASSERT(MARISA_UINT32_MAX == 0xFFFFFFFFU); - ASSERT(MARISA_UINT64_MAX == 0xFFFFFFFFFFFFFFFFULL); - - ASSERT(sizeof(marisa::UInt8) == 1); - ASSERT(sizeof(marisa::UInt16) == 2); - ASSERT(sizeof(marisa::UInt32) == 4); - ASSERT(sizeof(marisa::UInt64) == 8); - - int x = 100, y = 200; - marisa::Swap(&x, &y); - ASSERT(x == 200); - ASSERT(y == 100); - - EXCEPT(marisa::Swap(static_cast(NULL), &y), MARISA_PARAM_ERROR); - EXCEPT(marisa::Swap(&x, static_cast(NULL)), MARISA_PARAM_ERROR); - - TEST_END(); -} - -marisa::UInt32 NaivePopCount(marisa::UInt32 x) { - marisa::UInt32 count = 0; - while (x) { - count += x & 1; - x >>= 1; - } - return count; -} - -void TestPopCount() { - TEST_START(); - - ASSERT(marisa::PopCount(0).lo8() == 0); - ASSERT(marisa::PopCount(0).lo16() == 0); - ASSERT(marisa::PopCount(0).lo24() == 0); - ASSERT(marisa::PopCount(0).lo32() == 0); - - ASSERT(marisa::PopCount(0xFFFFFFFFU).lo8() == 8); - ASSERT(marisa::PopCount(0xFFFFFFFFU).lo16() == 16); - ASSERT(marisa::PopCount(0xFFFFFFFFU).lo24() == 24); - ASSERT(marisa::PopCount(0xFFFFFFFFU).lo32() == 32); - - for (std::size_t i = 0; i < 1024; ++i) { - marisa::UInt32 value = std::rand(); - marisa::PopCount popcount(value); - ASSERT(popcount.lo8() == NaivePopCount(value & 0xFFU)); - ASSERT(popcount.lo16() == NaivePopCount(value & 0xFFFFU)); - ASSERT(popcount.lo24() == NaivePopCount(value & 0xFFFFFFU)); - ASSERT(popcount.lo32() == NaivePopCount(value)); - } - - TEST_END(); -} - -void TestRank() { - TEST_START(); - - marisa::Rank rank; - - ASSERT(rank.abs() == 0); - ASSERT(rank.rel1() == 0); - ASSERT(rank.rel2() == 0); - ASSERT(rank.rel3() == 0); - ASSERT(rank.rel4() == 0); - ASSERT(rank.rel5() == 0); - ASSERT(rank.rel6() == 0); - ASSERT(rank.rel7() == 0); - - rank.set_abs(0xFFFFFFFFU); - rank.set_rel1(64); - rank.set_rel2(128); - rank.set_rel3(192); - rank.set_rel4(256); - rank.set_rel5(320); - rank.set_rel6(384); - rank.set_rel7(448); - - ASSERT(rank.abs() == 0xFFFFFFFFU); - ASSERT(rank.rel1() == 64); - ASSERT(rank.rel2() == 128); - ASSERT(rank.rel3() == 192); - ASSERT(rank.rel4() == 256); - ASSERT(rank.rel5() == 320); - ASSERT(rank.rel6() == 384); - ASSERT(rank.rel7() == 448); - - TEST_END(); -} - -void TestString() { - TEST_START(); - - marisa::String str; - - ASSERT(str.ptr() == NULL); - ASSERT(str.length() == 0); - - marisa::RString rstr; - - ASSERT(rstr.ptr() == NULL); - ASSERT(rstr.length() == 0); - - const char *s = "ab"; - str = marisa::String(s); - - ASSERT(str.ptr() == s); - ASSERT(str.length() == 2); - ASSERT(str[0] == s[0]); - ASSERT(str[1] == s[1]); - - rstr = marisa::RString(str); - ASSERT(rstr.ptr() == s); - ASSERT(rstr.length() == 2); - ASSERT(rstr[0] == s[1]); - ASSERT(rstr[1] == s[0]); - - std::string s2 = "xyz"; - str = marisa::String(s2.c_str(), s2.length()); - - ASSERT(str.ptr() == s2.c_str()); - ASSERT(str.length() == 3); - ASSERT(str[0] == s2[0]); - ASSERT(str[1] == s2[1]); - ASSERT(str[2] == s2[2]); - - ASSERT(str.substr(0, 2).length() == 2); - ASSERT(str.substr(0, 2)[0] == 'x'); - ASSERT(str.substr(0, 2)[1] == 'y'); - - rstr = marisa::RString(str); - - ASSERT(rstr.ptr() == s2.c_str()); - ASSERT(rstr.length() == 3); - ASSERT(rstr[0] == s2[2]); - ASSERT(rstr[1] == s2[1]); - ASSERT(rstr[2] == s2[0]); - - ASSERT(rstr.substr(1, 2).length() == 2); - ASSERT(rstr.substr(1, 2)[0] == 'y'); - ASSERT(rstr.substr(1, 2)[1] == 'x'); - - ASSERT(marisa::String("abc") == marisa::String("abc")); - ASSERT(marisa::String("abc") != marisa::String("bcd")); - ASSERT(marisa::String("abc") < marisa::String("bcd")); - ASSERT(marisa::String("ab") < marisa::String("abc")); - ASSERT(marisa::String("bcd") > marisa::String("abc")); - ASSERT(marisa::String("abc") > marisa::String("ab")); - - ASSERT(marisa::String("abcde").substr(1, 2) == marisa::String("bc")); - - TEST_END(); -} - -void TestKey() { - TEST_START(); - - marisa::Key key; - - ASSERT(key.str().length() == 0); - ASSERT(key.weight() == 0.0); - ASSERT(key.id() == 0); - ASSERT(key.terminal() == 0); - - key.set_str(marisa::String("abc")); - key.set_weight(1.0); - key.set_id(2); - key.set_terminal(3); - - ASSERT(key.str() == marisa::String("abc")); - ASSERT(key.weight() == 1.0); - ASSERT(key.id() == 2); - ASSERT(key.terminal() == 3); - - marisa::String str("string"); - marisa::Key rkey; - - ASSERT(rkey.str().length() == 0); - ASSERT(rkey.weight() == 0.0); - ASSERT(rkey.id() == 0); - ASSERT(rkey.terminal() == 0); - - rkey.set_str(marisa::RString(str)); - rkey.set_weight(4.0); - rkey.set_id(5); - rkey.set_terminal(6); - - ASSERT(rkey.str() == marisa::RString(str)); - ASSERT(rkey.weight() == 4.0); - ASSERT(rkey.id() == 5); - ASSERT(rkey.terminal() == 6); - - TEST_END(); -} -void TestProgress() { - TEST_START(); - - { - marisa::Progress progress(0); - - ASSERT(progress.is_valid()); - while (!progress.is_last()) { - ++progress; - } - ASSERT(progress.is_last()); - ASSERT(progress.flags() == MARISA_DEFAULT_FLAGS); - ASSERT(progress.trie_id() == progress.num_tries() - 1); - ASSERT(progress.total_size() == 0); - - progress.test_total_size(0); - progress.test_total_size(1); - EXCEPT(progress.test_total_size(MARISA_UINT32_MAX), MARISA_SIZE_ERROR); - progress.test_total_size(MARISA_UINT32_MAX - 1); - progress.test_total_size(0); - EXCEPT(progress.test_total_size(1), MARISA_SIZE_ERROR); - - ASSERT(progress.num_tries() == MARISA_DEFAULT_NUM_TRIES); - ASSERT(progress.trie() == MARISA_DEFAULT_TRIE); - ASSERT(progress.tail() == MARISA_DEFAULT_TAIL); - ASSERT(progress.order() == MARISA_DEFAULT_ORDER); - } - - { - marisa::Progress progress(MARISA_DEFAULT_FLAGS); - - ASSERT(progress.is_valid()); - ASSERT(!progress.is_last()); - ASSERT(progress.num_tries() == MARISA_DEFAULT_NUM_TRIES); - ASSERT(progress.trie() == MARISA_DEFAULT_TRIE); - ASSERT(progress.tail() == MARISA_DEFAULT_TAIL); - ASSERT(progress.order() == MARISA_DEFAULT_ORDER); - } - - { - marisa::Progress progress(255 | MARISA_PREFIX_TRIE - | MARISA_BINARY_TAIL | MARISA_LABEL_ORDER); - - ASSERT(progress.is_valid()); - ASSERT(!progress.is_last()); - ASSERT(progress.num_tries() == 255); - ASSERT(progress.trie() == MARISA_PREFIX_TRIE); - ASSERT(progress.tail() == MARISA_BINARY_TAIL); - ASSERT(progress.order() == MARISA_LABEL_ORDER); - } - - { - marisa::Progress progress(~MARISA_FLAGS_MASK); - - ASSERT(!progress.is_valid()); - } - - TEST_END(); -} - -void TestRange() { - TEST_START(); - - marisa::Range range; - - ASSERT(range.begin() == 0); - ASSERT(range.end() == 0); - ASSERT(range.pos() == 0); - - range.set_begin(1); - range.set_end(2); - range.set_pos(3); - - ASSERT(range.begin() == 1); - ASSERT(range.end() == 2); - ASSERT(range.pos() == 3); - - marisa::WRange wrange; - - ASSERT(wrange.range().begin() == 0); - ASSERT(wrange.range().end() == 0); - ASSERT(wrange.range().pos() == 0); - - ASSERT(wrange.begin() == 0); - ASSERT(wrange.end() == 0); - ASSERT(wrange.pos() == 0); - ASSERT(wrange.weight() == 0.0); - - wrange = marisa::WRange(range, 4.0); - - ASSERT(wrange.range().begin() == 1); - ASSERT(wrange.range().end() == 2); - ASSERT(wrange.range().pos() == 3); - - ASSERT(wrange.begin() == 1); - ASSERT(wrange.end() == 2); - ASSERT(wrange.pos() == 3); - ASSERT(wrange.weight() == 4.0); - - wrange.set_begin(5); - wrange.set_end(6); - wrange.set_pos(7); - wrange.set_weight(8.0); - - ASSERT(wrange.begin() == 5); - ASSERT(wrange.end() == 6); - ASSERT(wrange.pos() == 7); - ASSERT(wrange.weight() == 8.0); - - TEST_END(); -} - -void TestQuery() { - TEST_START(); - - marisa::Query query("abc", 3); - - ASSERT(query[0] == 'a'); - ASSERT(!query.ends_at(0)); - - ASSERT(query[1] == 'b'); - ASSERT(!query.ends_at(1)); - - ASSERT(query[2] == 'c'); - ASSERT(!query.ends_at(2)); - - ASSERT(query.ends_at(3)); - - std::string str("str"); - - query.insert(&str); - ASSERT(str == "abcstr"); - - marisa::CQuery cquery("xyz"); - - ASSERT(cquery[0] == 'x'); - ASSERT(!cquery.ends_at(0)); - - ASSERT(cquery[1] == 'y'); - ASSERT(!cquery.ends_at(1)); - - ASSERT(cquery[2] == 'z'); - ASSERT(!cquery.ends_at(2)); - - ASSERT(cquery.ends_at(3)); - - cquery.insert(&str); - ASSERT(str == "xyzabcstr"); - - TEST_END(); -} - -void TestContainer() { - TEST_START(); - - int array[1024]; - marisa::Container array_container(array); - - ASSERT(array_container.is_valid()); - for (int i = 0; i < 1024; ++i) { - int value = std::rand(); - array_container.insert(i, value); - ASSERT(array[i] == value); - } - - marisa::Container array_container2(NULL); - - ASSERT(!array_container2.is_valid()); - - std::vector vec; - marisa::Container *> vec_container(&vec); - - ASSERT(vec_container.is_valid()); - for (int i = 0; i < 1024; ++i) { - int value = std::rand(); - vec_container.insert(i, value); - ASSERT(vec.back() == value); - ASSERT(vec[i] == value); - } - ASSERT(vec.size() == 1024); - - marisa::Container *> vec_container2(&vec); - - ASSERT(vec_container2.is_valid()); - for (int i = 0; i < 1024; ++i) { - int value = std::rand(); - vec_container2.insert(i, value); - ASSERT(vec.back() == value); - ASSERT(vec[i + 1024] == value); - } - ASSERT(vec.size() == 2048); - - marisa::Container *> vec_container3(NULL); - ASSERT(!vec_container3.is_valid()); - - TEST_END(); -} - -void TestCell() { - TEST_START(); - - marisa::Cell cell; - - ASSERT(cell.louds_pos() == 0); - ASSERT(cell.node() == 0); - ASSERT(cell.key_id() == 0); - ASSERT(cell.length() == 0); - - cell.set_louds_pos(1); - cell.set_node(2); - cell.set_key_id(3); - cell.set_length(4); - - ASSERT(cell.louds_pos() == 1); - ASSERT(cell.node() == 2); - ASSERT(cell.key_id() == 3); - ASSERT(cell.length() == 4); - - TEST_END(); -} - -} // namespace - -int main() { - std::srand((unsigned int)time(NULL)); - - TestBase(); - TestPopCount(); - TestRank(); - TestString(); - TestKey(); - TestProgress(); - TestRange(); - TestQuery(); - TestContainer(); - TestCell(); - - return 0; -} diff --git a/tests/vector-test.cc b/tests/vector-test.cc deleted file mode 100644 index 50e339e..0000000 --- a/tests/vector-test.cc +++ /dev/null @@ -1,299 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "assert.h" - -namespace { - -void TestVector() { - TEST_START(); - - std::vector values; - for (std::size_t i = 0; i < 1000; ++i) { - values.push_back(std::rand()); - } - - marisa::Vector vec; - - ASSERT(vec.max_size() == MARISA_UINT32_MAX); - ASSERT(vec.size() == 0); - ASSERT(vec.capacity() == 0); - ASSERT(!vec.fixed()); - ASSERT(vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32)); - - for (std::size_t i = 0; i < values.size(); ++i) { - vec.push_back(values[i]); - ASSERT(vec[i] == values[i]); - ASSERT(static_cast &>(vec)[i] == values[i]); - } - - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() >= vec.size()); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32) - + ((sizeof(int) * values.size()))); - - ASSERT(static_cast &>(vec).front() - == values.front()); - ASSERT(static_cast &>(vec).back() - == values.back()); - ASSERT(vec.front() == values.front()); - ASSERT(vec.back() == values.back()); - - vec.shrink(); - - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() == vec.size()); - for (std::size_t i = 0; i < values.size(); ++i) { - ASSERT(vec[i] == values[i]); - ASSERT(static_cast &>(vec)[i] == values[i]); - } - - vec.save("vector-test.dat"); - vec.clear(); - - ASSERT(vec.empty()); - ASSERT(vec.capacity() == 0); - - marisa::Mapper mapper; - vec.mmap(&mapper, "vector-test.dat"); - - ASSERT(mapper.is_open()); - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() == 0); - ASSERT(vec.fixed()); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32) - + ((sizeof(int) * values.size()))); - - for (std::size_t i = 0; i < values.size(); ++i) { - ASSERT(static_cast &>(vec)[i] == values[i]); - } - - vec.clear(); - vec.load("vector-test.dat"); - - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() == vec.size()); - ASSERT(!vec.fixed()); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32) - + ((sizeof(int) * values.size()))); - - for (std::size_t i = 0; i < values.size(); ++i) { - ASSERT(vec[i] == values[i]); - ASSERT(static_cast &>(vec)[i] == values[i]); - } - - vec.clear(); - - vec.push_back(0); - ASSERT(vec.capacity() == 1); - vec.push_back(1); - ASSERT(vec.capacity() == 2); - vec.push_back(2); - ASSERT(vec.capacity() == 4); - vec.resize(5); - ASSERT(vec.capacity() == 8); - vec.resize(100); - ASSERT(vec.capacity() == 100); - - vec.fix(); - ASSERT(vec.fixed()); - EXCEPT(vec.fix(), MARISA_STATE_ERROR); - EXCEPT(vec.push_back(0), MARISA_STATE_ERROR); - EXCEPT(vec.resize(0), MARISA_STATE_ERROR); - EXCEPT(vec.reserve(0), MARISA_STATE_ERROR); - - TEST_END(); -} - -void TestIntVector() { - TEST_START(); - - marisa::IntVector vec; - - ASSERT(vec.num_bits_per_int() == 0); - ASSERT(vec.mask() == 0); - ASSERT(vec.size() == 0); - ASSERT(vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32) * 4); - - marisa::Vector values; - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 1); - ASSERT(vec.mask() == 1); - ASSERT(vec.size() == 0); - ASSERT(vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32) * 4); - - values.push_back(0); - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 1); - ASSERT(vec.mask() == 1); - ASSERT(vec.size() == 1); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa::UInt32) * 5); - ASSERT(vec[0] == 0); - - values.push_back(255); - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 8); - ASSERT(vec.mask() == 0xFF); - ASSERT(vec.size() == 2); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - - values.push_back(65536); - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 17); - ASSERT(vec.mask() == 0x1FFFF); - ASSERT(vec.size() == 3); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - ASSERT(vec[2] == 65536); - - vec.save("vector-test.dat"); - vec.clear(); - - ASSERT(vec.num_bits_per_int() == 0); - ASSERT(vec.mask() == 0); - ASSERT(vec.size() == 0); - - marisa::Mapper mapper; - vec.mmap(&mapper, "vector-test.dat"); - - ASSERT(mapper.is_open()); - ASSERT(vec.num_bits_per_int() == 17); - ASSERT(vec.mask() == 0x1FFFF); - ASSERT(vec.size() == 3); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - ASSERT(vec[2] == 65536); - - vec.clear(); - vec.load("vector-test.dat"); - - ASSERT(vec.num_bits_per_int() == 17); - ASSERT(vec.mask() == 0x1FFFF); - ASSERT(vec.size() == 3); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - ASSERT(vec[2] == 65536); - - values.clear(); - for (std::size_t i = 0; i < 500; ++i) { - values.push_back(std::rand()); - } - vec.build(values); - - ASSERT(vec.size() == values.size()); - for (std::size_t i = 0; i < vec.size(); ++i) { - ASSERT(vec[i] == values[i]); - } - - TEST_END(); -} - -void TestBitVector(marisa::UInt32 size) { - marisa::BitVector bv; - - ASSERT(bv.size() == 0); - ASSERT(bv.empty()); - ASSERT(bv.total_size() == sizeof(marisa::UInt32) * 5); - - std::vector bits(size); - std::vector zeros, ones; - for (marisa::UInt32 i = 0; i < size; ++i) { - const bool bit = (std::rand() % 2) == 0; - bits[i] = bit; - bv.push_back(bit); - (bit ? ones : zeros).push_back(i); - ASSERT(bv[i] == bits[i]); - } - - ASSERT(bv.size() == bits.size()); - ASSERT((size == 0) || !bv.empty()); - - bv.build(); - - marisa::UInt32 num_zeros = 0, num_ones = 0; - for (marisa::UInt32 i = 0; i < bits.size(); ++i) { - ASSERT(bv[i] == bits[i]); - ASSERT(bv.rank0(i) == num_zeros); - ASSERT(bv.rank1(i) == num_ones); - ++(bv[i] ? num_ones : num_zeros); - } - for (marisa::UInt32 i = 0; i < zeros.size(); ++i) { - ASSERT(bv.select0(i) == zeros[i]); - } - for (marisa::UInt32 i = 0; i < ones.size(); ++i) { - ASSERT(bv.select1(i) == ones[i]); - } - - std::stringstream stream; - bv.write(stream); - bv.clear(); - - ASSERT(bv.size() == 0); - ASSERT(bv.empty()); - ASSERT(bv.total_size() == sizeof(marisa::UInt32) * 5); - - bv.read(stream); - - ASSERT(bv.size() == bits.size()); - - num_zeros = 0, num_ones = 0; - for (marisa::UInt32 i = 0; i < bits.size(); ++i) { - ASSERT(bv[i] == bits[i]); - ASSERT(bv.rank0(i) == num_zeros); - ASSERT(bv.rank1(i) == num_ones); - ++(bv[i] ? num_ones : num_zeros); - } - for (marisa::UInt32 i = 0; i < zeros.size(); ++i) { - ASSERT(bv.select0(i) == zeros[i]); - } - for (marisa::UInt32 i = 0; i < ones.size(); ++i) { - ASSERT(bv.select1(i) == ones[i]); - } -} - -void TestBitVector() { - TEST_START(); - - TestBitVector(0); - TestBitVector(1); - TestBitVector(511); - TestBitVector(512); - TestBitVector(513); - - for (marisa::UInt32 i = 0; i < 100; ++i) { - TestBitVector(std::rand() % 4096); - } - - TEST_END(); -} - -} // namespace - -int main() { - std::srand((unsigned int)time(NULL)); - - TestVector(); - TestIntVector(); - TestBitVector(); - - return 0; -} diff --git a/tools/Makefile.am b/tools/Makefile.am deleted file mode 100644 index 54f6ada..0000000 --- a/tools/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -AM_CFLAGS = -Wall -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -I../lib - -bin_PROGRAMS = \ - marisa-build \ - marisa-lookup \ - marisa-benchmark \ - marisa-find \ - marisa-predict - -noinst_HEADERS = cmdopt.h - -marisa_build_SOURCES = marisa-build.cc cmdopt.c -marisa_build_LDADD = ../lib/libmarisa.a - -marisa_lookup_SOURCES = marisa-lookup.cc cmdopt.c -marisa_lookup_LDADD = ../lib/libmarisa.a - -marisa_find_SOURCES = marisa-find.cc cmdopt.c -marisa_find_LDADD = ../lib/libmarisa.a - -marisa_predict_SOURCES = marisa-predict.cc cmdopt.c -marisa_predict_LDADD = ../lib/libmarisa.a - -marisa_benchmark_SOURCES = marisa-benchmark.cc cmdopt.c -marisa_benchmark_LDADD = ../lib/libmarisa.a diff --git a/tools/Makefile.in b/tools/Makefile.in deleted file mode 100644 index 349a6b9..0000000 --- a/tools/Makefile.in +++ /dev/null @@ -1,524 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -bin_PROGRAMS = marisa-build$(EXEEXT) marisa-lookup$(EXEEXT) \ - marisa-benchmark$(EXEEXT) marisa-find$(EXEEXT) \ - marisa-predict$(EXEEXT) -subdir = tools -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -PROGRAMS = $(bin_PROGRAMS) -am_marisa_benchmark_OBJECTS = marisa-benchmark.$(OBJEXT) \ - cmdopt.$(OBJEXT) -marisa_benchmark_OBJECTS = $(am_marisa_benchmark_OBJECTS) -marisa_benchmark_DEPENDENCIES = ../lib/libmarisa.a -am_marisa_build_OBJECTS = marisa-build.$(OBJEXT) cmdopt.$(OBJEXT) -marisa_build_OBJECTS = $(am_marisa_build_OBJECTS) -marisa_build_DEPENDENCIES = ../lib/libmarisa.a -am_marisa_find_OBJECTS = marisa-find.$(OBJEXT) cmdopt.$(OBJEXT) -marisa_find_OBJECTS = $(am_marisa_find_OBJECTS) -marisa_find_DEPENDENCIES = ../lib/libmarisa.a -am_marisa_lookup_OBJECTS = marisa-lookup.$(OBJEXT) cmdopt.$(OBJEXT) -marisa_lookup_OBJECTS = $(am_marisa_lookup_OBJECTS) -marisa_lookup_DEPENDENCIES = ../lib/libmarisa.a -am_marisa_predict_OBJECTS = marisa-predict.$(OBJEXT) cmdopt.$(OBJEXT) -marisa_predict_OBJECTS = $(am_marisa_predict_OBJECTS) -marisa_predict_DEPENDENCIES = ../lib/libmarisa.a -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -SOURCES = $(marisa_benchmark_SOURCES) $(marisa_build_SOURCES) \ - $(marisa_find_SOURCES) $(marisa_lookup_SOURCES) \ - $(marisa_predict_SOURCES) -DIST_SOURCES = $(marisa_benchmark_SOURCES) $(marisa_build_SOURCES) \ - $(marisa_find_SOURCES) $(marisa_lookup_SOURCES) \ - $(marisa_predict_SOURCES) -HEADERS = $(noinst_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CFLAGS = -Wall -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -I../lib -noinst_HEADERS = cmdopt.h -marisa_build_SOURCES = marisa-build.cc cmdopt.c -marisa_build_LDADD = ../lib/libmarisa.a -marisa_lookup_SOURCES = marisa-lookup.cc cmdopt.c -marisa_lookup_LDADD = ../lib/libmarisa.a -marisa_find_SOURCES = marisa-find.cc cmdopt.c -marisa_find_LDADD = ../lib/libmarisa.a -marisa_predict_SOURCES = marisa-predict.cc cmdopt.c -marisa_predict_LDADD = ../lib/libmarisa.a -marisa_benchmark_SOURCES = marisa-benchmark.cc cmdopt.c -marisa_benchmark_LDADD = ../lib/libmarisa.a -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .cc .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu tools/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p; \ - then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(bindir)" && rm -f $$files - -clean-binPROGRAMS: - -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) -marisa-benchmark$(EXEEXT): $(marisa_benchmark_OBJECTS) $(marisa_benchmark_DEPENDENCIES) - @rm -f marisa-benchmark$(EXEEXT) - $(CXXLINK) $(marisa_benchmark_OBJECTS) $(marisa_benchmark_LDADD) $(LIBS) -marisa-build$(EXEEXT): $(marisa_build_OBJECTS) $(marisa_build_DEPENDENCIES) - @rm -f marisa-build$(EXEEXT) - $(CXXLINK) $(marisa_build_OBJECTS) $(marisa_build_LDADD) $(LIBS) -marisa-find$(EXEEXT): $(marisa_find_OBJECTS) $(marisa_find_DEPENDENCIES) - @rm -f marisa-find$(EXEEXT) - $(CXXLINK) $(marisa_find_OBJECTS) $(marisa_find_LDADD) $(LIBS) -marisa-lookup$(EXEEXT): $(marisa_lookup_OBJECTS) $(marisa_lookup_DEPENDENCIES) - @rm -f marisa-lookup$(EXEEXT) - $(CXXLINK) $(marisa_lookup_OBJECTS) $(marisa_lookup_LDADD) $(LIBS) -marisa-predict$(EXEEXT): $(marisa_predict_OBJECTS) $(marisa_predict_DEPENDENCIES) - @rm -f marisa-predict$(EXEEXT) - $(CXXLINK) $(marisa_predict_OBJECTS) $(marisa_predict_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmdopt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa-benchmark.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa-build.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa-find.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa-lookup.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa-predict.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.cc.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cc.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-binPROGRAMS - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/tools/cmdopt.c b/tools/cmdopt.c deleted file mode 100644 index 468d0fe..0000000 --- a/tools/cmdopt.c +++ /dev/null @@ -1,298 +0,0 @@ -#include - -#include "cmdopt.h" - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -// Moves `optind' to the end and shifts other arguments. -static void cmdopt_shift(cmdopt_t *h) { - int i; - char *tmp; - - tmp = h->argv[h->optind]; - for (i = h->optind; i < h->argc - 1; i++) { - h->argv[i] = h->argv[i + 1]; - } - h->argv[i] = tmp; - - h->nextchar = NULL; - h->optnum--; -} - -// Moves to the next argument. -static void cmdopt_next(cmdopt_t *h) { - h->optind++; - h->nextchar = NULL; -} - -// Checks if the current argument is an option or not. -static int cmdopt_check(cmdopt_t *h) { - int ret = 1; - const char *arg = h->argv[h->optind]; - - if (*arg++ != '-') { - return 0; - } - - if (*arg == '-') { - arg++; - ret++; - } - - return ret - (*arg == '\0'); -} - -// Gets an argument of the current option. -static void cmdopt_getopt(cmdopt_t *h) { - // Moves to the next argument if the current argument has no more characters. - if (*h->nextchar == '\0') { - cmdopt_next(h); - h->nextchar = h->argv[h->optind]; - } - - // Checks whether the current option has an argument or not. - if (h->optind < h->optnum) { - h->optarg = h->nextchar; - cmdopt_next(h); - } else { - h->optarg = NULL; - } -} - -// Searches an option. -static int cmdopt_search(cmdopt_t *h) { - const char *ptr; - - // Updates an option character. - h->optopt = *h->nextchar++; - - for (ptr = h->optstring; *ptr != '\0'; ptr++) { - if (*ptr == h->optopt) { - // Gets an option argument if required. - if (ptr[1] == ':') { - cmdopt_getopt(h); - - // Returns ':' if there is no argument. - if (h->optarg == NULL && ptr[2] != ':') { - return ':'; - } - } - return h->optopt; - } - } - - if (h->optopt == '-') { - cmdopt_next(h); - while (h->optind < h->optnum) { - cmdopt_shift(h); - } - return -1; - } - - // Returns '?' if the option character is undefined. - return '?'; -} - -// Compares a long option with an argument and returns the length of the -// matched prefix. -static int cmdopt_match_len(const char *opt, const char *arg) { - int len = 0; - - // Returns 0 if there is a mismatch. - while ((*arg != '\0') && (*arg != '=')) { - if (*arg++ != *opt++) { - return 0; - } - len++; - } - - // Returns a negative value in case of a perfect match. - if ((*arg == '\0') || (*arg == '=')) { - return -len; - } - - return len; -} - -// Checks long options. -static int cmdopt_match(cmdopt_t *h) { - int i, len; - int max = 0, max_optind = -1; - - // Returns -1 if there are no long options. - if (h->longopts == NULL) { - return max_optind; - } - - for (i = 0; h->longopts[i].name != NULL; i++) { - len = cmdopt_match_len(h->longopts[i].name, h->nextchar); - if (len < 0) { - // In case of a perfect match. - h->nextchar -= len; - return i; - } else if (len > max) { - // In case of a prefix match. - max = len; - max_optind = i; - } else if (len == max) { - // There are other candidates. - max_optind = -1; - } - } - - // If there is no perfect match, adopts the longest one. - h->nextchar += max; - return max_optind; -} - -// Gets an argument of a long option. -static void cmdopt_getopt_long(cmdopt_t *h) { - if (*h->nextchar == '=') { - h->optarg = h->nextchar + 1; - cmdopt_next(h); - } else { - cmdopt_next(h); - - // Checks whether there are more options or not. - if (h->optind < h->optnum) { - h->optarg = h->argv[h->optind]; - cmdopt_next(h); - } else { - h->optarg = NULL; - } - } -} - -// Searches long options. -static int cmdopt_search_long(cmdopt_t *h) { - const cmdopt_option *option; - - // Keeps the long option. - h->optlong = h->argv[h->optind]; - - // Gets the next option. - h->longindex = cmdopt_match(h); - if (h->longindex < 0) { - cmdopt_next(h); - return '?'; - } - - // Gets an argument if required. - option = h->longopts + h->longindex; - if (option->has_arg) { - cmdopt_getopt_long(h); - - // Return ':' if there are no more arguments. - if (h->optarg == NULL) { - return ':'; - } - } else if (*h->nextchar == '=') { - // Returns '?' for an extra option argument. - cmdopt_getopt_long(h); - return '?'; - } - - // Overwrites a variable if specified in settings. - if (option->flag != NULL) { - *option->flag = option->val; - return 0; - } - - return option->val; -} - -// Analyze command line option. -static int cmdopt_main(cmdopt_t *h) { - int type; - - // Initializes the internal state. - h->optopt = 0; - h->optlong = NULL; - h->optarg = NULL; - h->longindex = 0; - - while (h->optind < h->optnum) { - if (h->nextchar == NULL) { - // Checks whether the next argument is an option or not. - type = cmdopt_check(h); - if (type == 0) { - cmdopt_shift(h); - } else { - h->nextchar = h->argv[h->optind] + type; - if (type == 2) { - return cmdopt_search_long(h); - } - } - } else { - if (*h->nextchar == '\0') { - cmdopt_next(h); - continue; - } - // Searches an option string. - return cmdopt_search(h); - } - } - - return -1; -} - -// cmdopt_init() initializes a cmdopt_t for successive cmdopt_get()s. -void cmdopt_init(cmdopt_t *h, int argc, char **argv, - const char *optstring, const cmdopt_option *longopts) { - static const char empty_optstring[] = ""; - - h->argc = argc; - h->argv = argv; - h->optnum = h->argc; - - h->longopts = longopts; - h->optstring = (optstring != NULL) ? optstring : empty_optstring; - - h->optind = 1; - h->nextchar = NULL; - h->optarg = NULL; - h->optopt = 0; - h->optlong = NULL; - h->opterr = 1; - h->longindex = 0; -} - -// cmdopt_get() analyzes command line arguments and gets the next option. -int cmdopt_get(cmdopt_t *h) { - int value = cmdopt_main(h); - - // Prints a warning to the standard error stream if enabled. - if (h->opterr) { - if (value == ':') { - // Warning for a lack of an option argument. - if (h->optlong == NULL) { - fprintf(stderr, "option requires an argument -- %c\n", h->optopt); - } else { - fprintf(stderr, "option `--%s' requires an argument\n", - h->longopts[h->longindex].name); - } - } else if (value == '?') { - // Warning for an invalid option. - if (h->optlong == NULL) { - fprintf(stderr, "invalid option -- %c\n", h->optopt); - } else { - fprintf(stderr, "unrecognized option `%s'\n", h->optlong); - } - } else if ((value != -1) && (h->opterr == 2)) { - // Actually this is not for warning, but for debugging. - if (h->optlong == NULL) { - fprintf(stderr, "option with `%s' -- %c\n", h->optarg, h->optopt); - } else { - fprintf(stderr, "option `--%s' with `%s'\n", - h->longopts[h->longindex].name, h->optarg); - } - } - } - return value; -} - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus diff --git a/tools/cmdopt.h b/tools/cmdopt.h deleted file mode 100644 index 1c611d6..0000000 --- a/tools/cmdopt.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef MARISA_CMDOPT_H_ -#define MARISA_CMDOPT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct cmdopt_option_ { - // `name' specifies the name of this option. - // An array of options must be terminated with an option whose name == NULL. - const char *name; - - // `has_name' specifies whether an option takes an argument or not. - // 0 specifies that this option does not have any argument. - // 1 specifies that this option has an argument. - // 2 specifies that this option may have an argument. - int has_arg; - - // `flag' specifies an integer variable which is overwritten by cmdopt_next() - // with its return value. - int *flag; - - // `val' specifies a return value of cmdopt_next(). This value is returned - // when cmdopt_next() finds this option. - int val; -} cmdopt_option; - -typedef struct cmdopt_t_ { - // Command line arguments. - int argc; - char **argv; - - // Option settings. - const cmdopt_option *longopts; - const char *optstring; - - int optind; // Index of the next argument. - char *nextchar; // Next character. - char *optarg; // Argument of the last option. - int optopt; // Label of the last option. - char *optlong; // Long option. - int opterr; // Warning level (0: nothing, 1: warning, 2: all). - int longindex; // Index of the last long option. - int optnum; // Number of options. -} cmdopt_t; - -// cmdopt_init() initializes a cmdopt_t for successive cmdopt_next()s. -void cmdopt_init(cmdopt_t *h, int argc, char **argv, - const char *optstring, const cmdopt_option *longopts); - -// cmdopt_get() analyzes command line arguments and gets the next option. -int cmdopt_get(cmdopt_t *h); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // MARISA_CMDOPT_H_ diff --git a/tools/marisa-benchmark.cc b/tools/marisa-benchmark.cc deleted file mode 100644 index 0de9743..0000000 --- a/tools/marisa-benchmark.cc +++ /dev/null @@ -1,425 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -typedef std::pair Key; - -int param_min_num_tries = 1; -int param_max_num_tries = 10; -int param_trie = MARISA_DEFAULT_TRIE; -int param_tail = MARISA_DEFAULT_TAIL; -int param_order = MARISA_DEFAULT_ORDER; -bool predict_strs_flag = false; -bool speed_flag = true; - -class Clock { - public: - Clock() : cl_(std::clock()) {} - - void reset() { - cl_ = std::clock(); - } - - double elasped() const { - std::clock_t cur = std::clock(); - return (cur == cl_) ? 0.01 : (1.0 * (cur - cl_) / CLOCKS_PER_SEC); - } - - private: - std::clock_t cl_; -}; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... [FILE]...\n\n" - "Options:\n" - " -N, --min-num-tries=[N] limits the number of tries to N" - " (default: 1)\n" - " -n, --max-num-tries=[N] limits the number of tries to N" - " (default: 10)\n" - " -P, --patricia-trie build patricia tries (default)\n" - " -p, --prefix-trie build prefix tries\n" - " -T, --text-tail build a dictionary with text TAIL (default)\n" - " -b, --binary-tail build a dictionary with binary TAIL\n" - " -t, --without-tail build a dictionary without TAIL\n" - " -w, --weight-order arrange siblings in weight order (default)\n" - " -l, --label-order arrange siblings in label order\n" - " -I, --predict-ids get key IDs in predictive searches (default)\n" - " -i, --predict-strs restore key strings in predictive searches\n" - " -S, --print-speed print speed [1000 keys/s] (default)\n" - " -s, --print-time print time [us/key]\n" - " -h, --help print this help\n" - << std::endl; -} - -void print_config() { - std::cout << "#tries: " << param_min_num_tries - << " - " << param_max_num_tries << std::endl; - - switch (param_trie) { - case MARISA_PATRICIA_TRIE: { - std::cout << "trie: patricia" << std::endl; - break; - } - case MARISA_PREFIX_TRIE: { - std::cout << "trie: prefix" << std::endl; - break; - } - } - - switch (param_tail) { - case MARISA_WITHOUT_TAIL: { - std::cout << "tail: no" << std::endl; - break; - } - case MARISA_BINARY_TAIL: { - std::cout << "tail: binary" << std::endl; - break; - } - case MARISA_TEXT_TAIL: { - std::cout << "tail: text" << std::endl; - break; - } - } - - switch (param_order) { - case MARISA_LABEL_ORDER: { - std::cout << "order: label" << std::endl; - break; - } - case MARISA_WEIGHT_ORDER: { - std::cout << "order: weight" << std::endl; - break; - } - } - - if (predict_strs_flag) { - std::cout << "predict: both IDs and strings" << std::endl; - } else { - std::cout << "predict: only IDs" << std::endl; - } -} - -void print_time_info(std::size_t num_keys, double elasped) { - if (speed_flag) { - if (elasped == 0.0) { - std::printf(" %7s", "-"); - } else { - std::printf(" %7.2f", num_keys / elasped / 1000.0); - } - } else { - if (num_keys == 0) { - std::printf(" %7s", "-"); - } else { - std::printf(" %7.3f", 1000000.0 * elasped / num_keys); - } - } -} - -void read_keys(std::istream *input, std::vector *keys) { - Key key; - std::string line; - while (std::getline(*input, line)) { - const std::string::size_type delim_pos = line.find_last_of('\t'); - if (delim_pos != line.npos) { - char *end_of_value; - key.second = std::strtod(&line[delim_pos + 1], &end_of_value); - if (*end_of_value == '\0') { - line.resize(delim_pos); - } else { - key.second = 1.0; - } - } else { - key.second = 1.0; - } - key.first = line; - keys->push_back(key); - } -} - -int read_keys(const char * const *args, std::size_t num_args, - std::vector *keys) { - if (num_args == 0) { - read_keys(&std::cin, keys); - } - for (std::size_t i = 0; i < num_args; ++i) { - std::ifstream input_file(args[i], std::ios::binary); - if (!input_file) { - std::cerr << "error: failed to open a keyset file: " - << args[i] << std::endl; - return 10; - } - read_keys(&input_file, keys); - } - std::cout << "#keys: " << keys->size() << std::endl; - std::size_t total_length = 0; - for (std::size_t i = 0; i < keys->size(); ++i) { - total_length += (*keys)[i].first.length(); - } - std::cout << "total length: " << total_length << std::endl; - return 0; -} - -void benchmark_build(const std::vector &keys, int num_tries, - marisa::Trie *trie, std::vector *key_ids) { - Clock cl; - trie->build(keys, key_ids, num_tries - | param_trie | param_tail | param_order); - std::printf(" %9lu", (unsigned long)trie->num_nodes()); - std::printf(" %9lu", (unsigned long)trie->total_size()); - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_restore(const marisa::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::string key; - for (std::size_t i = 0; i < key_ids.size(); ++i) { - key.clear(); - trie.restore(key_ids[i], &key); - if (key != keys[i].first) { - std::cerr << "error: restore() failed" << std::endl; - return; - } - } - print_time_info(key_ids.size(), cl.elasped()); -} - -void benchmark_lookup(const marisa::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - for (std::size_t i = 0; i < keys.size(); ++i) { - const marisa::UInt32 key_id = trie.lookup(keys[i].first); - if (key_id != key_ids[i]) { - std::cerr << "error: lookup() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_find(const marisa::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::vector found_key_ids; - for (std::size_t i = 0; i < keys.size(); ++i) { - found_key_ids.clear(); - const std::size_t num_keys = trie.find(keys[i].first, &found_key_ids); - if ((num_keys == 0) || (found_key_ids.back() != key_ids[i])) { - std::cerr << "error: find() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_predict_breadth_first(const marisa::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::vector found_key_ids; - std::vector found_keys; - std::vector *found_keys_ref = - predict_strs_flag ? &found_keys : NULL; - for (std::size_t i = 0; i < keys.size(); ++i) { - found_key_ids.clear(); - found_keys.clear(); - const std::size_t num_keys = trie.predict_breadth_first( - keys[i].first, &found_key_ids, found_keys_ref); - if ((num_keys == 0) || (found_key_ids.front() != key_ids[i])) { - std::cerr << "error: predict() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_predict_depth_first(const marisa::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::vector found_key_ids; - std::vector found_keys; - std::vector *found_keys_ref = - predict_strs_flag ? &found_keys : NULL; - for (std::size_t i = 0; i < keys.size(); ++i) { - found_key_ids.clear(); - found_keys.clear(); - const std::size_t num_keys = trie.predict_depth_first( - keys[i].first, &found_key_ids, found_keys_ref); - if ((num_keys == 0) || (found_key_ids.front() != key_ids[i])) { - std::cerr << "error: predict() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark(const std::vector &keys, int num_tries) { - std::printf("%6d", num_tries); - marisa::Trie trie; - std::vector key_ids; - benchmark_build(keys, num_tries, &trie, &key_ids); - if (!trie.empty()) { - benchmark_restore(trie, keys, key_ids); - benchmark_lookup(trie, keys, key_ids); - benchmark_find(trie, keys, key_ids); - benchmark_predict_breadth_first(trie, keys, key_ids); - benchmark_predict_depth_first(trie, keys, key_ids); - } - std::printf("\n"); -} - -int benchmark(const char * const *args, std::size_t num_args) try { - std::vector keys; - const int ret = read_keys(args, num_args, &keys); - if (ret != 0) { - return ret; - } - std::printf("------+---------+---------+-------+" - "-------+-------+-------+-------+-------\n"); - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "#tries", "#nodes", "size", - "build", "restore", "lookup", "find", "predict", "predict"); - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "", "", "", "", "", "", "", "breadth", "depth"); - if (speed_flag) { - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "", "", "[bytes]", - "[K/s]", "[K/s]", "[K/s]", "[K/s]", "[K/s]", "[K/s]"); - } else { - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "", "", "[bytes]", "[us]", "[us]", "[us]", "[us]", "[us]", "[us]"); - } - std::printf("------+---------+---------+-------+" - "-------+-------+-------+-------+-------\n"); - for (int i = param_min_num_tries; i <= param_max_num_tries; ++i) { - benchmark(keys, i); - } - std::printf("------+---------+---------+-------+" - "-------+-------+-------+-------+-------\n"); - return 0; -} catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() - << ": " << ex.what() << std::endl; - return -1; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "min-num-tries", 1, NULL, 'N' }, - { "max-num-tries", 1, NULL, 'n' }, - { "patricia-trie", 0, NULL, 'P' }, - { "prefix-trie", 0, NULL, 'p' }, - { "text-tail", 0, NULL, 'T' }, - { "binary-tail", 0, NULL, 'b' }, - { "without-tail", 0, NULL, 't' }, - { "weight-order", 0, NULL, 'w' }, - { "label-order", 0, NULL, 'l' }, - { "predict-ids", 0, NULL, 'I' }, - { "predict-strs", 0, NULL, 'i' }, - { "print-speed", 0, NULL, 'S' }, - { "print-time", 0, NULL, 's' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "N:n:PpTbtwlIiSsh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'N': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value <= 0) || - (value > MARISA_MAX_NUM_TRIES)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - param_min_num_tries = (int)value; - break; - } - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value <= 0) || - (value > MARISA_MAX_NUM_TRIES)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - param_max_num_tries = (int)value; - break; - } - case 'P': { - param_trie = MARISA_PATRICIA_TRIE; - break; - } - case 'p': { - param_trie = MARISA_PREFIX_TRIE; - break; - } - case 'T': { - param_tail = MARISA_TEXT_TAIL; - break; - } - case 'b': { - param_tail = MARISA_BINARY_TAIL; - break; - } - case 't': { - param_tail = MARISA_WITHOUT_TAIL; - break; - } - case 'w': { - param_order = MARISA_WEIGHT_ORDER; - break; - } - case 'l': { - param_order = MARISA_LABEL_ORDER; - break; - } - case 'I': { - predict_strs_flag = false; - break; - } - case 'i': { - predict_strs_flag = true; - break; - } - case 'S': { - speed_flag = true; - break; - } - case 's': { - speed_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - print_config(); - return benchmark(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/tools/marisa-build.cc b/tools/marisa-build.cc deleted file mode 100644 index 22aa246..0000000 --- a/tools/marisa-build.cc +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -typedef std::pair Key; - -int param_num_tries = MARISA_DEFAULT_NUM_TRIES; -int param_trie = MARISA_DEFAULT_TRIE; -int param_tail = MARISA_DEFAULT_TAIL; -int param_order = MARISA_DEFAULT_ORDER; -const char *output_filename = NULL; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... [FILE]...\n\n" - "Options:\n" - " -n, --num-tries=[N] limits the number of tries to N" - " (default: 3)\n" - " -P, --patricia-trie build patricia tries (default)\n" - " -p, --prefix-trie build prefix tries\n" - " -T, --text-tail build a dictionary with text TAIL (default)\n" - " -b, --binary-tail build a dictionary with binary TAIL\n" - " -t, --without-tail build a dictionary without TAIL\n" - " -w, --weight-order arranges siblings in weight order (default)\n" - " -l, --label-order arranges siblings in label order\n" - " -o, --output=[FILE] write tries to FILE (default: stdout)\n" - " -h, --help print this help\n" - << std::endl; -} - -void read_keys(std::istream *input, std::vector *keys) { - Key key; - std::string line; - while (std::getline(*input, line)) { - const std::string::size_type delim_pos = line.find_last_of('\t'); - if (delim_pos != line.npos) { - char *end_of_value; - key.second = std::strtod(&line[delim_pos + 1], &end_of_value); - if (*end_of_value == '\0') { - line.resize(delim_pos); - } else { - key.second = 1.0; - } - } else { - key.second = 1.0; - } - key.first = line; - keys->push_back(key); - } -} - -int build(const char * const *args, std::size_t num_args) { - std::vector keys; - if (num_args == 0) { - read_keys(&std::cin, &keys); - } - - for (std::size_t i = 0; i < num_args; ++i) { - std::ifstream input_file(args[i], std::ios::binary); - if (!input_file) { - std::cerr << "error: failed to open a keyset file: " - << args[i] << std::endl; - return 10; - } - read_keys(&input_file, &keys); - } - - marisa::Trie trie; - try { - trie.build(keys, NULL, param_num_tries - | param_trie | param_tail | param_order); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to build a dictionary" << std::endl; - return 20; - } - - std::cerr << "#keys: " << trie.num_keys() << std::endl; - std::cerr << "#tries: " << trie.num_tries() << std::endl; - std::cerr << "#nodes: " << trie.num_nodes() << std::endl; - std::cerr << "size: " << trie.total_size() << std::endl; - - if (output_filename != NULL) { - try { - trie.save(output_filename); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to write a dictionary to file: " - << output_filename << std::endl; - return 30; - } - } else { - try { - trie.write(std::cout); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to write a dictionary to standard output" << std::endl; - return 31; - } - } - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "max-num-tries", 1, NULL, 'n' }, - { "patricia-trie", 0, NULL, 'P' }, - { "prefix-trie", 0, NULL, 'p' }, - { "text-tail", 0, NULL, 'T' }, - { "binary-tail", 0, NULL, 'b' }, - { "without-tail", 0, NULL, 't' }, - { "weight-order", 0, NULL, 'w' }, - { "label-order", 0, NULL, 'l' }, - { "output", 1, NULL, 'o' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "n:PpTbtwlo:h", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value <= 0) || - (value > MARISA_MAX_NUM_TRIES)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - param_num_tries = (int)value; - break; - } - case 'P': { - param_trie = MARISA_PATRICIA_TRIE; - break; - } - case 'p': { - param_trie = MARISA_PREFIX_TRIE; - break; - } - case 'T': { - param_tail = MARISA_TEXT_TAIL; - break; - } - case 'b': { - param_tail = MARISA_BINARY_TAIL; - break; - } - case 't': { - param_tail = MARISA_WITHOUT_TAIL; - break; - } - case 'w': { - param_order = MARISA_WEIGHT_ORDER; - break; - } - case 'l': { - param_order = MARISA_LABEL_ORDER; - break; - } - case 'o': { - output_filename = cmdopt.optarg; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return build(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/tools/marisa-find.cc b/tools/marisa-find.cc deleted file mode 100644 index d7bed93..0000000 --- a/tools/marisa-find.cc +++ /dev/null @@ -1,204 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -enum FindMode { - FIND_ALL, - FIND_FIRST, - FIND_LAST -}; - -std::size_t max_num_results = 10; -FindMode find_mode = FIND_ALL; -bool mmap_flag = true; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... DIC\n\n" - "Options:\n" - " -n, --max-num-results=[N] limits the number of results to N" - " (default: 10)\n" - " 0: no limit\n" - " -a, --find-all find all prefix keys (default)\n" - " -f, --find-first find a shortest prefix key\n" - " -l, --find-last find a longest prefix key\n" - " -m, --mmap-dictionary use memory-mapped I/O to load a dictionary" - " (default)\n" - " -r, --read-dictionary read an entire dictionary into memory\n" - " -h, --help print this help\n" - << std::endl; -} - -void find_all(const marisa::Trie &trie, const std::string &str) { - static std::vector key_ids; - static std::vector lengths; - const std::size_t num_keys = trie.find(str, &key_ids, &lengths); - if (num_keys != 0) { - std::cout << num_keys << " found" << std::endl; - for (std::size_t i = 0; (i < num_keys) && (i < max_num_results); ++i) { - std::cout << key_ids[i] << '\t'; - std::cout.write(str.c_str(), lengths[i]) << '\t' << str << '\n'; - } - } else { - std::cout << "not found" << std::endl; - } - key_ids.clear(); - lengths.clear(); -} - -void find_first(const marisa::Trie &trie, const std::string &str) { - std::size_t length = 0; - const marisa::UInt32 key_id = trie.find_first(str, &length); - if (key_id != trie.notfound()) { - std::cout << key_id << '\t'; - std::cout.write(str.c_str(), length) << '\t' << str << '\n'; - } else { - std::cout << "-1\t" << str << '\n'; - } -} - -void find_last(const marisa::Trie &trie, const std::string &str) { - std::size_t length = 0; - const marisa::UInt32 key_id = trie.find_last(str, &length); - if (key_id != trie.notfound()) { - std::cout << key_id << '\t'; - std::cout.write(str.c_str(), length) << '\t' << str << '\n'; - } else { - std::cout << "-1\t" << str << '\n'; - } -} - -int find(const char * const *args, std::size_t num_args) { - if (num_args == 0) { - std::cerr << "error: a dictionary is not specified" << std::endl; - return 10; - } else if (num_args > 1) { - std::cerr << "error: more than one dictionaries are specified" - << std::endl; - return 11; - } - - marisa::Trie trie; - marisa::Mapper mapper; - if (mmap_flag) { - try { - trie.mmap(&mapper, args[0]); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to mmap a dictionary file: " << args[0] << std::endl; - return 20; - } - } else { - try { - trie.load(args[0]); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to load a dictionary file: " << args[0] << std::endl; - return 21; - } - } - - std::string str; - while (std::getline(std::cin, str)) { - try { - switch (find_mode) { - case FIND_ALL: { - find_all(trie, str); - break; - } - case FIND_FIRST: { - find_first(trie, str); - break; - } - case FIND_LAST: { - find_last(trie, str); - break; - } - } - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to find keys in: " << str << std::endl; - return 30; - } - if (!std::cout) { - std::cerr << "error: failed to write results to standard output" - << std::endl; - return 31; - } - } - - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "max-num-results", 1, NULL, 'n' }, - { "find-all", 0, NULL, 'a' }, - { "find-first", 0, NULL, 'f' }, - { "find-last", 0, NULL, 'l' }, - { "mmap-dictionary", 0, NULL, 'm' }, - { "read-dictionary", 0, NULL, 'r' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "n:aflmrh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value < 0)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - if ((value == 0) || ((unsigned long)value > MARISA_MAX_NUM_KEYS)) { - max_num_results = MARISA_MAX_NUM_KEYS; - } else { - max_num_results = (std::size_t)(value); - } - break; - } - case 'a': { - find_mode = FIND_ALL; - break; - } - case 'f': { - find_mode = FIND_FIRST; - break; - } - case 'l': { - find_mode = FIND_LAST; - break; - } - case 'm': { - mmap_flag = true; - break; - } - case 'r': { - mmap_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return find(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/tools/marisa-lookup.cc b/tools/marisa-lookup.cc deleted file mode 100644 index 9674fa7..0000000 --- a/tools/marisa-lookup.cc +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -bool mmap_flag = true; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... DIC\n\n" - "Options:\n" - " -m, --mmap-dictionary use memory-mapped I/O to load a dictionary" - " (default)\n" - " -r, --read-dictionary read an entire dictionary into memory\n" - " -h, --help print this help\n" - << std::endl; -} - -int lookup(const char * const *args, std::size_t num_args) { - if (num_args == 0) { - std::cerr << "error: a dictionary is not specified" << std::endl; - return 10; - } else if (num_args > 1) { - std::cerr << "error: more than one dictionaries are specified" - << std::endl; - return 11; - } - - marisa::Trie trie; - marisa::Mapper mapper; - if (mmap_flag) { - try { - trie.mmap(&mapper, args[0]); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to mmap a dictionary file: " << args[0] << std::endl; - return 20; - } - } else { - try { - trie.load(args[0]); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to load a dictionary file: " << args[0] << std::endl; - return 21; - } - } - - std::string str; - while (std::getline(std::cin, str)) { - const marisa::UInt32 key_id = trie.lookup(str); - if (key_id != trie.notfound()) { - std::cout << key_id << '\t' << str << '\n'; - } else { - std::cout << "-1\t" << str << '\n'; - } - if (!std::cout) { - std::cerr << "error: failed to write results to standard output" - << std::endl; - return 30; - } - } - - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "mmap-dictionary", 0, NULL, 'm' }, - { "read-dictionary", 0, NULL, 'r' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "mrh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'm': { - mmap_flag = true; - break; - } - case 'r': { - mmap_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return lookup(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/tools/marisa-predict.cc b/tools/marisa-predict.cc deleted file mode 100644 index e3b1b38..0000000 --- a/tools/marisa-predict.cc +++ /dev/null @@ -1,159 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -std::size_t max_num_results = 10; -bool mmap_flag = true; -bool depth_first_flag = true; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... DIC\n\n" - "Options:\n" - " -n, --max-num-results=[N] limits the number of outputs to N" - " (default: 10)\n" - " 0: no limit\n" - " -d, --depth-first predict keys in depth first order(default)\n" - " -b, --breadth-first predict keys in breadth first order\n" - " -m, --mmap-dictionary use memory-mapped I/O to load a dictionary" - " (default)\n" - " -r, --read-dictionary read an entire dictionary into memory\n" - " -h, --help print this help\n" - << std::endl; -} - -int predict(const char * const *args, std::size_t num_args) { - if (num_args == 0) { - std::cerr << "error: a dictionary is not specified" << std::endl; - return 10; - } else if (num_args > 1) { - std::cerr << "error: more than one dictionaries are specified" - << std::endl; - return 11; - } - - marisa::Trie trie; - marisa::Mapper mapper; - if (mmap_flag) { - try { - trie.mmap(&mapper, args[0]); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to mmap a dictionary file: " << args[0] << std::endl; - return 20; - } - } else { - try { - trie.load(args[0]); - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to load a dictionary file: " << args[0] << std::endl; - return 21; - } - } - - std::vector key_ids; - std::vector keys; - std::string str; - while (std::getline(std::cin, str)) { - std::size_t num_keys = trie.predict(str); - if (num_keys != 0) { - std::cout << num_keys << " found" << std::endl; - key_ids.clear(); - keys.clear(); - try { - if (depth_first_flag) { - num_keys = trie.predict_depth_first( - str, &key_ids, &keys, max_num_results); - } else { - num_keys = trie.predict_breadth_first( - str, &key_ids, &keys, max_num_results); - } - } catch (const marisa::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to predict keys from: " << str << std::endl; - return 30; - } - for (std::size_t i = 0; i < num_keys; ++i) { - std::cout << key_ids[i] << '\t' << keys[i] << '\t' << str << '\n'; - } - } else { - std::cout << "not found" << std::endl; - } - if (!std::cout) { - std::cerr << "error: failed to write results to standard output" - << std::endl; - return 31; - } - } - - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "max-num-results", 1, NULL, 'n' }, - { "depth-first", 0, NULL, 'd' }, - { "breadth-first", 0, NULL, 'b' }, - { "mmap-dictionary", 0, NULL, 'm' }, - { "read-dictionary", 0, NULL, 'r' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "n:dbmrh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value < 0)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - if ((value == 0) || ((unsigned long)value > MARISA_MAX_NUM_KEYS)) { - max_num_results = MARISA_MAX_NUM_KEYS; - } else { - max_num_results = (std::size_t)(value); - } - break; - } - case 'd': { - depth_first_flag = true; - break; - } - case 'b': { - depth_first_flag = false; - break; - } - case 'm': { - mmap_flag = true; - break; - } - case 'r': { - mmap_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return predict(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/v0_1_5/lib/Makefile.am b/v0_1_5/lib/Makefile.am deleted file mode 100644 index 9f65fdb..0000000 --- a/v0_1_5/lib/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -AM_CXXFLAGS = -Wall -Weffc++ -#AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -ACLOCAL_AMFLAGS = -I m4 - -lib_LTLIBRARIES = libmarisa_alpha.la - -libmarisa_alpha_la_SOURCES = \ - marisa_alpha/base.cc \ - marisa_alpha/progress.cc \ - marisa_alpha/mapper.cc \ - marisa_alpha/reader.cc \ - marisa_alpha/writer.cc \ - marisa_alpha/intvector.cc \ - marisa_alpha/bitvector.cc \ - marisa_alpha/tail.cc \ - marisa_alpha/trie.cc \ - marisa_alpha/trie-build.cc \ - marisa_alpha/trie-search.cc \ - marisa_alpha/trie-c.cc - -include_HEADERS = marisa_alpha.h - -libmarisa_alpha_includedir = ${includedir}/marisa_alpha -libmarisa_alpha_include_HEADERS = \ - marisa_alpha/base.h \ - marisa_alpha/popcount.h \ - marisa_alpha/rank.h \ - marisa_alpha/string.h \ - marisa_alpha/key.h \ - marisa_alpha/progress.h \ - marisa_alpha/range.h \ - marisa_alpha/query.h \ - marisa_alpha/container.h \ - marisa_alpha/cell.h \ - marisa_alpha/mapper.h \ - marisa_alpha/reader.h \ - marisa_alpha/writer.h \ - marisa_alpha/io.h \ - marisa_alpha/vector.h \ - marisa_alpha/vector-inline.h \ - marisa_alpha/intvector.h \ - marisa_alpha/bitvector.h \ - marisa_alpha/tail.h \ - marisa_alpha/trie.h \ - marisa_alpha/trie-inline.h diff --git a/v0_1_5/lib/Makefile.in b/v0_1_5/lib/Makefile.in deleted file mode 100644 index 3ea9c72..0000000 --- a/v0_1_5/lib/Makefile.in +++ /dev/null @@ -1,712 +0,0 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = lib -DIST_COMMON = $(include_HEADERS) $(libmarisa_alpha_include_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" \ - "$(DESTDIR)$(libmarisa_alpha_includedir)" -LTLIBRARIES = $(lib_LTLIBRARIES) -libmarisa_alpha_la_LIBADD = -am_libmarisa_alpha_la_OBJECTS = base.lo progress.lo mapper.lo \ - reader.lo writer.lo intvector.lo bitvector.lo tail.lo trie.lo \ - trie-build.lo trie-search.lo trie-c.lo -libmarisa_alpha_la_OBJECTS = $(am_libmarisa_alpha_la_OBJECTS) -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(libmarisa_alpha_la_SOURCES) -DIST_SOURCES = $(libmarisa_alpha_la_SOURCES) -HEADERS = $(include_HEADERS) $(libmarisa_alpha_include_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CXXFLAGS = -Wall -Weffc++ -#AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -ACLOCAL_AMFLAGS = -I m4 -lib_LTLIBRARIES = libmarisa_alpha.la -libmarisa_alpha_la_SOURCES = \ - marisa_alpha/base.cc \ - marisa_alpha/progress.cc \ - marisa_alpha/mapper.cc \ - marisa_alpha/reader.cc \ - marisa_alpha/writer.cc \ - marisa_alpha/intvector.cc \ - marisa_alpha/bitvector.cc \ - marisa_alpha/tail.cc \ - marisa_alpha/trie.cc \ - marisa_alpha/trie-build.cc \ - marisa_alpha/trie-search.cc \ - marisa_alpha/trie-c.cc - -include_HEADERS = marisa_alpha.h -libmarisa_alpha_includedir = ${includedir}/marisa_alpha -libmarisa_alpha_include_HEADERS = \ - marisa_alpha/base.h \ - marisa_alpha/popcount.h \ - marisa_alpha/rank.h \ - marisa_alpha/string.h \ - marisa_alpha/key.h \ - marisa_alpha/progress.h \ - marisa_alpha/range.h \ - marisa_alpha/query.h \ - marisa_alpha/container.h \ - marisa_alpha/cell.h \ - marisa_alpha/mapper.h \ - marisa_alpha/reader.h \ - marisa_alpha/writer.h \ - marisa_alpha/io.h \ - marisa_alpha/vector.h \ - marisa_alpha/vector-inline.h \ - marisa_alpha/intvector.h \ - marisa_alpha/bitvector.h \ - marisa_alpha/tail.h \ - marisa_alpha/trie.h \ - marisa_alpha/trie-inline.h - -all: all-am - -.SUFFIXES: -.SUFFIXES: .cc .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu lib/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libmarisa_alpha.la: $(libmarisa_alpha_la_OBJECTS) $(libmarisa_alpha_la_DEPENDENCIES) $(EXTRA_libmarisa_alpha_la_DEPENDENCIES) - $(CXXLINK) -rpath $(libdir) $(libmarisa_alpha_la_OBJECTS) $(libmarisa_alpha_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitvector.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intvector.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progress.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tail.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-build.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-c.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-search.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Plo@am__quote@ - -.cc.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cc.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cc.lo: -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -base.lo: marisa_alpha/base.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base.lo -MD -MP -MF $(DEPDIR)/base.Tpo -c -o base.lo `test -f 'marisa_alpha/base.cc' || echo '$(srcdir)/'`marisa_alpha/base.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/base.Tpo $(DEPDIR)/base.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/base.cc' object='base.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base.lo `test -f 'marisa_alpha/base.cc' || echo '$(srcdir)/'`marisa_alpha/base.cc - -progress.lo: marisa_alpha/progress.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT progress.lo -MD -MP -MF $(DEPDIR)/progress.Tpo -c -o progress.lo `test -f 'marisa_alpha/progress.cc' || echo '$(srcdir)/'`marisa_alpha/progress.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/progress.Tpo $(DEPDIR)/progress.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/progress.cc' object='progress.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o progress.lo `test -f 'marisa_alpha/progress.cc' || echo '$(srcdir)/'`marisa_alpha/progress.cc - -mapper.lo: marisa_alpha/mapper.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mapper.lo -MD -MP -MF $(DEPDIR)/mapper.Tpo -c -o mapper.lo `test -f 'marisa_alpha/mapper.cc' || echo '$(srcdir)/'`marisa_alpha/mapper.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/mapper.Tpo $(DEPDIR)/mapper.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/mapper.cc' object='mapper.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mapper.lo `test -f 'marisa_alpha/mapper.cc' || echo '$(srcdir)/'`marisa_alpha/mapper.cc - -reader.lo: marisa_alpha/reader.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT reader.lo -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.lo `test -f 'marisa_alpha/reader.cc' || echo '$(srcdir)/'`marisa_alpha/reader.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/reader.cc' object='reader.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o reader.lo `test -f 'marisa_alpha/reader.cc' || echo '$(srcdir)/'`marisa_alpha/reader.cc - -writer.lo: marisa_alpha/writer.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT writer.lo -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.lo `test -f 'marisa_alpha/writer.cc' || echo '$(srcdir)/'`marisa_alpha/writer.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/writer.cc' object='writer.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o writer.lo `test -f 'marisa_alpha/writer.cc' || echo '$(srcdir)/'`marisa_alpha/writer.cc - -intvector.lo: marisa_alpha/intvector.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT intvector.lo -MD -MP -MF $(DEPDIR)/intvector.Tpo -c -o intvector.lo `test -f 'marisa_alpha/intvector.cc' || echo '$(srcdir)/'`marisa_alpha/intvector.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/intvector.Tpo $(DEPDIR)/intvector.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/intvector.cc' object='intvector.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o intvector.lo `test -f 'marisa_alpha/intvector.cc' || echo '$(srcdir)/'`marisa_alpha/intvector.cc - -bitvector.lo: marisa_alpha/bitvector.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bitvector.lo -MD -MP -MF $(DEPDIR)/bitvector.Tpo -c -o bitvector.lo `test -f 'marisa_alpha/bitvector.cc' || echo '$(srcdir)/'`marisa_alpha/bitvector.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/bitvector.Tpo $(DEPDIR)/bitvector.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/bitvector.cc' object='bitvector.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bitvector.lo `test -f 'marisa_alpha/bitvector.cc' || echo '$(srcdir)/'`marisa_alpha/bitvector.cc - -tail.lo: marisa_alpha/tail.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT tail.lo -MD -MP -MF $(DEPDIR)/tail.Tpo -c -o tail.lo `test -f 'marisa_alpha/tail.cc' || echo '$(srcdir)/'`marisa_alpha/tail.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/tail.Tpo $(DEPDIR)/tail.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/tail.cc' object='tail.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o tail.lo `test -f 'marisa_alpha/tail.cc' || echo '$(srcdir)/'`marisa_alpha/tail.cc - -trie.lo: marisa_alpha/trie.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie.lo -MD -MP -MF $(DEPDIR)/trie.Tpo -c -o trie.lo `test -f 'marisa_alpha/trie.cc' || echo '$(srcdir)/'`marisa_alpha/trie.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie.Tpo $(DEPDIR)/trie.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/trie.cc' object='trie.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie.lo `test -f 'marisa_alpha/trie.cc' || echo '$(srcdir)/'`marisa_alpha/trie.cc - -trie-build.lo: marisa_alpha/trie-build.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-build.lo -MD -MP -MF $(DEPDIR)/trie-build.Tpo -c -o trie-build.lo `test -f 'marisa_alpha/trie-build.cc' || echo '$(srcdir)/'`marisa_alpha/trie-build.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-build.Tpo $(DEPDIR)/trie-build.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/trie-build.cc' object='trie-build.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-build.lo `test -f 'marisa_alpha/trie-build.cc' || echo '$(srcdir)/'`marisa_alpha/trie-build.cc - -trie-search.lo: marisa_alpha/trie-search.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-search.lo -MD -MP -MF $(DEPDIR)/trie-search.Tpo -c -o trie-search.lo `test -f 'marisa_alpha/trie-search.cc' || echo '$(srcdir)/'`marisa_alpha/trie-search.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-search.Tpo $(DEPDIR)/trie-search.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/trie-search.cc' object='trie-search.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-search.lo `test -f 'marisa_alpha/trie-search.cc' || echo '$(srcdir)/'`marisa_alpha/trie-search.cc - -trie-c.lo: marisa_alpha/trie-c.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT trie-c.lo -MD -MP -MF $(DEPDIR)/trie-c.Tpo -c -o trie-c.lo `test -f 'marisa_alpha/trie-c.cc' || echo '$(srcdir)/'`marisa_alpha/trie-c.cc -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/trie-c.Tpo $(DEPDIR)/trie-c.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='marisa_alpha/trie-c.cc' object='trie-c.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trie-c.lo `test -f 'marisa_alpha/trie-c.cc' || echo '$(srcdir)/'`marisa_alpha/trie-c.cc - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) -install-libmarisa_alpha_includeHEADERS: $(libmarisa_alpha_include_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(libmarisa_alpha_includedir)" || $(MKDIR_P) "$(DESTDIR)$(libmarisa_alpha_includedir)" - @list='$(libmarisa_alpha_include_HEADERS)'; test -n "$(libmarisa_alpha_includedir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libmarisa_alpha_includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(libmarisa_alpha_includedir)" || exit $$?; \ - done - -uninstall-libmarisa_alpha_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(libmarisa_alpha_include_HEADERS)'; test -n "$(libmarisa_alpha_includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(libmarisa_alpha_includedir)'; $(am__uninstall_files_from_dir) - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(libmarisa_alpha_includedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-includeHEADERS \ - install-libmarisa_alpha_includeHEADERS - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-libLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \ - uninstall-libmarisa_alpha_includeHEADERS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-includeHEADERS install-info \ - install-info-am install-libLTLIBRARIES \ - install-libmarisa_alpha_includeHEADERS install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-includeHEADERS \ - uninstall-libLTLIBRARIES \ - uninstall-libmarisa_alpha_includeHEADERS - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/v0_1_5/lib/marisa_alpha.h b/v0_1_5/lib/marisa_alpha.h deleted file mode 100644 index 985faf6..0000000 --- a/v0_1_5/lib/marisa_alpha.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MARISA_ALPHA_H_ -#define MARISA_ALPHA_H_ - -#include "marisa_alpha/trie.h" - -#endif // MARISA_ALPHA_H_ diff --git a/v0_1_5/lib/marisa_alpha/base.cc b/v0_1_5/lib/marisa_alpha/base.cc deleted file mode 100644 index 0261dad..0000000 --- a/v0_1_5/lib/marisa_alpha/base.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "base.h" - -extern "C" { - -const char *marisa_alpha_strerror(marisa_alpha_status status) { -#define MARISA_ALPHA_STRERROR_CASE(x) case x: { return #x; } - switch (status) { - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_OK) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_HANDLE_ERROR) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_STATE_ERROR) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_PARAM_ERROR) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_SIZE_ERROR) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_MEMORY_ERROR) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_IO_ERROR) - MARISA_ALPHA_STRERROR_CASE(MARISA_ALPHA_UNEXPECTED_ERROR) - } - return "MARISA_ALPHA_UNKNOWN_ERROR"; -#undef MARISA_ALPHA_STRERROR_CASE -} - -} // extern "C" diff --git a/v0_1_5/lib/marisa_alpha/base.h b/v0_1_5/lib/marisa_alpha/base.h deleted file mode 100644 index 28c7622..0000000 --- a/v0_1_5/lib/marisa_alpha/base.h +++ /dev/null @@ -1,215 +0,0 @@ -#ifndef MARISA_ALPHA_BASE_H_ -#define MARISA_ALPHA_BASE_H_ - -// Visual C++ does not provide stdint.h. -#ifndef _MSC_VER -#include -#endif // _MSC_VER - -#ifdef __cplusplus -#include -#include -#else // __cplusplus -#include -#endif // __cplusplus - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#ifdef _MSC_VER -typedef unsigned __int8 marisa_alpha_uint8; -typedef unsigned __int16 marisa_alpha_uint16; -typedef unsigned __int32 marisa_alpha_uint32; -typedef unsigned __int64 marisa_alpha_uint64; -#else // _MSC_VER -typedef uint8_t marisa_alpha_uint8; -typedef uint16_t marisa_alpha_uint16; -typedef uint32_t marisa_alpha_uint32; -typedef uint64_t marisa_alpha_uint64; -#endif // _MSC_VER - -#define MARISA_ALPHA_UINT8_MAX ((marisa_alpha_uint8)-1) -#define MARISA_ALPHA_UINT16_MAX ((marisa_alpha_uint16)-1) -#define MARISA_ALPHA_UINT32_MAX ((marisa_alpha_uint32)-1) -#define MARISA_ALPHA_UINT64_MAX ((marisa_alpha_uint64)-1) -#define MARISA_ALPHA_SIZE_MAX ((size_t)-1) - -#define MARISA_ALPHA_ZERO_TERMINATED MARISA_ALPHA_UINT32_MAX -#define MARISA_ALPHA_NOT_FOUND MARISA_ALPHA_UINT32_MAX -#define MARISA_ALPHA_MISMATCH MARISA_ALPHA_UINT32_MAX - -#define MARISA_ALPHA_MAX_LENGTH (MARISA_ALPHA_UINT32_MAX - 1) -#define MARISA_ALPHA_MAX_NUM_KEYS (MARISA_ALPHA_UINT32_MAX - 1) - -// marisa_alpha_status provides a list of error codes. Most of functions in -// libmarisa throw or return an error code. -typedef enum marisa_alpha_status_ { - // MARISA_ALPHA_OK means that a requested operation has succeeded. - MARISA_ALPHA_OK = 0, - - // MARISA_ALPHA_HANDLE_ERROR means that a given handle is invalid. - MARISA_ALPHA_HANDLE_ERROR = 1, - - // MARISA_ALPHA_STATE_ERROR means that an object is not ready for a requested - // operation. For example, an operation to modify a fixed container throws - // an exception with this error code. - MARISA_ALPHA_STATE_ERROR = 2, - - // MARISA_ALPHA_PARAM_ERROR means that a given argument is invalid. For - // example, some functions throw an exception with this error code when an - // out-of-range value or a NULL pointer is given. - MARISA_ALPHA_PARAM_ERROR = 3, - - // MARISA_ALPHA_SIZE_ERROR means that a size exceeds its limit. This error - // code is used when a building dictionary is too large or std::length_error - // is catched. - MARISA_ALPHA_SIZE_ERROR = 4, - - // MARISA_ALPHA_MEMORY_ERROR means that a memory allocation has failed. - MARISA_ALPHA_MEMORY_ERROR = 5, - - // MARISA_ALPHA_IO_ERROR means that an I/O failure. - MARISA_ALPHA_IO_ERROR = 6, - - // MARISA_ALPHA_UNEXPECTED_ERROR means that an unexpected error has occurred. - MARISA_ALPHA_UNEXPECTED_ERROR = 7 -} marisa_alpha_status; - -// marisa_alpha_strerror() returns a name of an error code. -const char *marisa_alpha_strerror(marisa_alpha_status status); - -// Flags and masks for dictionary settings are defined as follows. Please note -// that unspecified value/flags will be replaced with default value/flags. -typedef enum marisa_alpha_flags_ { - // A dictionary consinsts of 3 tries in default. If you want to change the - // number of tries, please give it with other flags. - MARISA_ALPHA_MIN_NUM_TRIES = 0x00001, - MARISA_ALPHA_MAX_NUM_TRIES = 0x000FF, - MARISA_ALPHA_DEFAULT_NUM_TRIES = 0x00003, - - // MARISA_ALPHA_PATRICIA_TRIE is usually a better choice. MARISA_ALPHA_PREFIX_TRIE is - // provided for comparing prefix/patricia tries. - MARISA_ALPHA_PATRICIA_TRIE = 0x00100, - MARISA_ALPHA_PREFIX_TRIE = 0x00200, - MARISA_ALPHA_DEFAULT_TRIE = MARISA_ALPHA_PATRICIA_TRIE, - - // There are 3 kinds of TAIL implementations. - // - MARISA_ALPHA_WITHOUT_TAIL: - // builds a dictionary without a TAIL. Its last trie has only 1-byte - // labels. - // - MARISA_ALPHA_BINARY_TAIL: - // builds a dictionary with a binary-mode TAIL. Its last labels are stored - // as binary data. - // - MARISA_ALPHA_TEXT_TAIL: - // builds a dictionary with a text-mode TAIL if its last labels do not - // contain NULL characters. The last labels are stored as zero-terminated - // string. Otherwise, a dictionary is built with a binary-mode TAIL. - MARISA_ALPHA_WITHOUT_TAIL = 0x01000, - MARISA_ALPHA_BINARY_TAIL = 0x02000, - MARISA_ALPHA_TEXT_TAIL = 0x04000, - MARISA_ALPHA_DEFAULT_TAIL = MARISA_ALPHA_TEXT_TAIL, - - // libmarisa arranges nodes in ascending order of their labels - // (MARISA_ALPHA_LABEL_ORDER) or in descending order of their weights - // (MARISA_ALPHA_WEIGHT_ORDER). MARISA_ALPHA_WEIGHT_ORDER is generally a - // better choice because it enables faster lookups, but - // MARISA_ALPHA_LABEL_ORDER is still useful if an application needs to - // predict keys in label order. - MARISA_ALPHA_LABEL_ORDER = 0x10000, - MARISA_ALPHA_WEIGHT_ORDER = 0x20000, - MARISA_ALPHA_DEFAULT_ORDER = MARISA_ALPHA_WEIGHT_ORDER, - - // The default settings. 0 is equivalent to MARISA_ALPHA_DEFAULT_FLAGS. - MARISA_ALPHA_DEFAULT_FLAGS = MARISA_ALPHA_DEFAULT_NUM_TRIES - | MARISA_ALPHA_DEFAULT_TRIE | MARISA_ALPHA_DEFAULT_TAIL | MARISA_ALPHA_DEFAULT_ORDER, - - MARISA_ALPHA_NUM_TRIES_MASK = 0x000FF, - MARISA_ALPHA_TRIE_MASK = 0x00F00, - MARISA_ALPHA_TAIL_MASK = 0x0F000, - MARISA_ALPHA_ORDER_MASK = 0xF0000, - MARISA_ALPHA_FLAGS_MASK = 0xFFFFF -} marisa_alpha_flags; - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#ifdef __cplusplus -namespace marisa_alpha { - -typedef ::marisa_alpha_uint8 UInt8; -typedef ::marisa_alpha_uint16 UInt16; -typedef ::marisa_alpha_uint32 UInt32; -typedef ::marisa_alpha_uint64 UInt64; - -typedef ::marisa_alpha_status Status; - -// An exception object stores a filename, a line number and an error code. -class Exception { - public: - Exception(const char *filename, int line, Status status) - : filename_(filename), line_(line), status_(status) {} - Exception(const Exception &ex) - : filename_(ex.filename_), line_(ex.line_), status_(ex.status_) {} - - Exception &operator=(const Exception &rhs) { - filename_ = rhs.filename_; - line_ = rhs.line_; - status_ = rhs.status_; - return *this; - } - - const char *filename() const { - return filename_; - } - int line() const { - return line_; - } - Status status() const { - return status_; - } - - // Same as std::exception, what() returns an error message. - const char *what() const { - return ::marisa_alpha_strerror(status_); - } - - private: - const char *filename_; - int line_; - Status status_; -}; - -// MARISA_ALPHA_THROW adds a filename and a line number to an exception. -#define MARISA_ALPHA_THROW(status) \ - (throw Exception(__FILE__, __LINE__, status)) - -// MARISA_ALPHA_THROW_IF throws an exception with `status' if `cond' is true. -#define MARISA_ALPHA_THROW_IF(cond, status) \ - (void)((!(cond)) || (MARISA_ALPHA_THROW(status), 0)) - -// MARISA_ALPHA_DEBUG_IF is used for debugging. For example, -// MARISA_ALPHA_DEBUG_IF is used to find out-of-range accesses in -// marisa::Vector, marisa::IntVector, etc. -#ifdef _DEBUG -#define MARISA_ALPHA_DEBUG_IF(cond, status) \ - MARISA_ALPHA_THROW_IF(cond, status) -#else -#define MARISA_ALPHA_DEBUG_IF(cond, status) -#endif - -// To not include only for std::swap(). -template -void Swap(T *lhs, T *rhs) { - MARISA_ALPHA_THROW_IF((lhs == NULL) || (rhs == NULL), - MARISA_ALPHA_PARAM_ERROR); - T temp = *lhs; - *lhs = *rhs; - *rhs = temp; -} - -} // namespace marisa_alpha -#endif // __cplusplus - -#endif // MARISA_ALPHA_BASE_H_ diff --git a/v0_1_5/lib/marisa_alpha/bitvector.cc b/v0_1_5/lib/marisa_alpha/bitvector.cc deleted file mode 100644 index e949999..0000000 --- a/v0_1_5/lib/marisa_alpha/bitvector.cc +++ /dev/null @@ -1,571 +0,0 @@ -#include "bitvector.h" -#include "popcount.h" - -namespace marisa_alpha { -namespace { - -const UInt8 SelectTable[8][256] = { - { - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 - }, - { - 7, 7, 7, 1, 7, 2, 2, 1, 7, 3, 3, 1, 3, 2, 2, 1, - 7, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1, - 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 7, 7, 1, 7, 2, 2, 1, 7, 3, 3, 1, 3, 2, 2, 1, - 7, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 7, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1, - 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, - 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, - 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1 - }, - { - 7, 7, 7, 7, 7, 7, 7, 2, 7, 7, 7, 3, 7, 3, 3, 2, - 7, 7, 7, 4, 7, 4, 4, 2, 7, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 5, 7, 5, 5, 2, 7, 5, 5, 3, 5, 3, 3, 2, - 7, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 6, 7, 6, 6, 2, 7, 6, 6, 3, 6, 3, 3, 2, - 7, 6, 6, 4, 6, 4, 4, 2, 6, 4, 4, 3, 4, 3, 3, 2, - 7, 6, 6, 5, 6, 5, 5, 2, 6, 5, 5, 3, 5, 3, 3, 2, - 6, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 7, 7, 7, 7, 2, 7, 7, 7, 3, 7, 3, 3, 2, - 7, 7, 7, 4, 7, 4, 4, 2, 7, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 5, 7, 5, 5, 2, 7, 5, 5, 3, 5, 3, 3, 2, - 7, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2, - 7, 7, 7, 6, 7, 6, 6, 2, 7, 6, 6, 3, 6, 3, 3, 2, - 7, 6, 6, 4, 6, 4, 4, 2, 6, 4, 4, 3, 4, 3, 3, 2, - 7, 6, 6, 5, 6, 5, 5, 2, 6, 5, 5, 3, 5, 3, 3, 2, - 6, 5, 5, 4, 5, 4, 4, 2, 5, 4, 4, 3, 4, 3, 3, 2 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, - 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 4, 7, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 3, - 7, 7, 7, 5, 7, 5, 5, 4, 7, 5, 5, 4, 5, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 3, - 7, 7, 7, 6, 7, 6, 6, 4, 7, 6, 6, 4, 6, 4, 4, 3, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 3, - 7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, - 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 4, 7, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 3, - 7, 7, 7, 5, 7, 5, 5, 4, 7, 5, 5, 4, 5, 4, 4, 3, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 3, - 7, 7, 7, 6, 7, 6, 6, 4, 7, 6, 6, 4, 6, 4, 4, 3, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 3, - 7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 4, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 5, 7, 5, 5, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 4, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5, - 7, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 6, 7, 6, 6, 5 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6 - }, - { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 - } -}; - -} // namespace - -BitVector::BitVector() - : blocks_(), size_(0), ranks_(), select0s_(), select1s_() {} - -void BitVector::build() { - Vector ranks; - const UInt32 num_blocks = (size_ / 512) + (((size_ % 512) != 0) ? 1 : 0); - ranks.resize(num_blocks + 1); - Vector select0s; - Vector select1s; - UInt32 num_0s = 0; - UInt32 num_1s = 0; - for (UInt32 i = 0; i < size_; ++i) { - if ((i % 64) == 0) { - UInt32 rank_id = i / 512; - switch ((i / 64) % 8) { - case 0: { - ranks[rank_id].set_abs(num_1s); - break; - } - case 1: { - ranks[rank_id].set_rel1(num_1s - ranks[rank_id].abs()); - break; - } - case 2: { - ranks[rank_id].set_rel2(num_1s - ranks[rank_id].abs()); - break; - } - case 3: { - ranks[rank_id].set_rel3(num_1s - ranks[rank_id].abs()); - break; - } - case 4: { - ranks[rank_id].set_rel4(num_1s - ranks[rank_id].abs()); - break; - } - case 5: { - ranks[rank_id].set_rel5(num_1s - ranks[rank_id].abs()); - break; - } - case 6: { - ranks[rank_id].set_rel6(num_1s - ranks[rank_id].abs()); - break; - } - case 7: { - ranks[rank_id].set_rel7(num_1s - ranks[rank_id].abs()); - break; - } - } - } - if ((*this)[i]) { - if ((num_1s % 512) == 0) { - select1s.push_back(i); - } - ++num_1s; - } else { - if ((num_0s % 512) == 0) { - select0s.push_back(i); - } - ++num_0s; - } - } - if ((size_ % 512) != 0) { - UInt32 rank_id = (size_ - 1) / 512; - switch (((size_ - 1) / 64) % 8) { - case 0: { - ranks[rank_id].set_rel1(num_1s - ranks[rank_id].abs()); - } - case 1: { - ranks[rank_id].set_rel2(num_1s - ranks[rank_id].abs()); - } - case 2: { - ranks[rank_id].set_rel3(num_1s - ranks[rank_id].abs()); - } - case 3: { - ranks[rank_id].set_rel4(num_1s - ranks[rank_id].abs()); - } - case 4: { - ranks[rank_id].set_rel5(num_1s - ranks[rank_id].abs()); - } - case 5: { - ranks[rank_id].set_rel6(num_1s - ranks[rank_id].abs()); - } - case 6: { - ranks[rank_id].set_rel7(num_1s - ranks[rank_id].abs()); - break; - } - } - } - ranks.back().set_abs(num_1s); - select0s.push_back(size_); - select1s.push_back(size_); - select0s.shrink(); - select1s.shrink(); - - blocks_.shrink(); - ranks_.swap(&ranks); - select0s_.swap(&select0s); - select1s_.swap(&select1s); -} - -void BitVector::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_ALPHA_THROW_IF(mapper == NULL, MARISA_ALPHA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void BitVector::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void BitVector::map(Mapper &mapper) { - BitVector temp; - temp.blocks_.map(mapper); - mapper.map(&temp.size_); - temp.ranks_.map(mapper); - temp.select0s_.map(mapper); - temp.select1s_.map(mapper); - temp.swap(this); -} - -void BitVector::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void BitVector::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -void BitVector::read(int fd) { - Reader reader(fd); - read(reader); -} - -void BitVector::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void BitVector::read(Reader &reader) { - BitVector temp; - temp.blocks_.read(reader); - reader.read(&temp.size_); - temp.ranks_.read(reader); - temp.select0s_.read(reader); - temp.select1s_.read(reader); - temp.swap(this); -} - -void BitVector::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void BitVector::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -void BitVector::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void BitVector::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void BitVector::write(Writer &writer) const { - blocks_.write(writer); - writer.write(size_); - ranks_.write(writer); - select0s_.write(writer); - select1s_.write(writer); -} - -UInt32 BitVector::rank1(UInt32 i) const { - MARISA_ALPHA_DEBUG_IF(i > size_, MARISA_ALPHA_PARAM_ERROR); - const Rank &rank = ranks_[i / 512]; - UInt32 offset = rank.abs(); - switch ((i / 64) % 8) { - case 1: { - offset += rank.rel1(); - break; - } - case 2: { - offset += rank.rel2(); - break; - } - case 3: { - offset += rank.rel3(); - break; - } - case 4: { - offset += rank.rel4(); - break; - } - case 5: { - offset += rank.rel5(); - break; - } - case 6: { - offset += rank.rel6(); - break; - } - case 7: { - offset += rank.rel7(); - break; - } - } - switch ((i / 32) % 2) { - case 1: { - offset += PopCount(blocks_[(i / 32) - 1]).lo32(); - } - case 0: { - offset += PopCount(blocks_[i / 32] & ((1U << (i % 32)) - 1)).lo32(); - break; - } - } - return offset; -} - -UInt32 BitVector::select0(UInt32 i) const { - UInt32 select_id = i / 512; - MARISA_ALPHA_DEBUG_IF((select_id + 1) >= select0s_.size(), - MARISA_ALPHA_PARAM_ERROR); - if ((i % 512) == 0) { - return select0s_[select_id]; - } - UInt32 begin = select0s_[select_id] / 512; - UInt32 end = (select0s_[select_id + 1] + 511) / 512; - if (begin + 10 >= end) { - while (i >= ((begin + 1) * 512) - ranks_[begin + 1].abs()) { - ++begin; - } - } else { - while (begin + 1 < end) { - UInt32 middle = (begin + end) / 2; - if (i < (middle * 512) - ranks_[middle].abs()) { - end = middle; - } else { - begin = middle; - } - } - } - const UInt32 rank_id = begin; - i -= (rank_id * 512) - ranks_[rank_id].abs(); - - const Rank &rank = ranks_[rank_id]; - UInt32 block_id = rank_id * 16; - if (i < (256U - rank.rel4())) { - if (i < (128U - rank.rel2())) { - if (i >= (64U - rank.rel1())) { - block_id += 2; - i -= 64 - rank.rel1(); - } - } else if (i < (192U - rank.rel3())) { - block_id += 4; - i -= 128 - rank.rel2(); - } else { - block_id += 6; - i -= 192 - rank.rel3(); - } - } else if (i < (384U - rank.rel6())) { - if (i < (320U - rank.rel5())) { - block_id += 8; - i -= 256 - rank.rel4(); - } else { - block_id += 10; - i -= 320 - rank.rel5(); - } - } else if (i < (448U - rank.rel7())) { - block_id += 12; - i -= 384 - rank.rel6(); - } else { - block_id += 14; - i -= 448 - rank.rel7(); - } - - UInt32 block = ~blocks_[block_id]; - PopCount count(block); - if (i >= count.lo32()) { - ++block_id; - i -= count.lo32(); - block = ~blocks_[block_id]; - count = PopCount(block); - } - - UInt32 bit_id = block_id * 32; - if (i < count.lo16()) { - if (i >= count.lo8()) { - bit_id += 8; - block >>= 8; - i -= count.lo8(); - } - } else if (i < count.lo24()) { - bit_id += 16; - block >>= 16; - i -= count.lo16(); - } else { - bit_id += 24; - block >>= 24; - i -= count.lo24(); - } - return bit_id + SelectTable[i][block & 0xFF]; -} - -UInt32 BitVector::select1(UInt32 i) const { - UInt32 select_id = i / 512; - MARISA_ALPHA_DEBUG_IF((select_id + 1) >= select1s_.size(), - MARISA_ALPHA_PARAM_ERROR); - if ((i % 512) == 0) { - return select1s_[select_id]; - } - UInt32 begin = select1s_[select_id] / 512; - UInt32 end = (select1s_[select_id + 1] + 511) / 512; - if (begin + 10 >= end) { - while (i >= ranks_[begin + 1].abs()) { - ++begin; - } - } else { - while (begin + 1 < end) { - UInt32 middle = (begin + end) / 2; - if (i < ranks_[middle].abs()) { - end = middle; - } else { - begin = middle; - } - } - } - const UInt32 rank_id = begin; - i -= ranks_[rank_id].abs(); - - const Rank &rank = ranks_[rank_id]; - UInt32 block_id = rank_id * 16; - if (i < rank.rel4()) { - if (i < rank.rel2()) { - if (i >= rank.rel1()) { - block_id += 2; - i -= rank.rel1(); - } - } else if (i < rank.rel3()) { - block_id += 4; - i -= rank.rel2(); - } else { - block_id += 6; - i -= rank.rel3(); - } - } else if (i < rank.rel6()) { - if (i < rank.rel5()) { - block_id += 8; - i -= rank.rel4(); - } else { - block_id += 10; - i -= rank.rel5(); - } - } else if (i < rank.rel7()) { - block_id += 12; - i -= rank.rel6(); - } else { - block_id += 14; - i -= rank.rel7(); - } - - UInt32 block = blocks_[block_id]; - PopCount count(block); - if (i >= count.lo32()) { - ++block_id; - i -= count.lo32(); - block = blocks_[block_id]; - count = PopCount(block); - } - - UInt32 bit_id = block_id * 32; - if (i < count.lo16()) { - if (i >= count.lo8()) { - bit_id += 8; - block >>= 8; - i -= count.lo8(); - } - } else if (i < count.lo24()) { - bit_id += 16; - block >>= 16; - i -= count.lo16(); - } else { - bit_id += 24; - block >>= 24; - i -= count.lo24(); - } - return bit_id + SelectTable[i][block & 0xFF]; -} - -void BitVector::clear() { - BitVector().swap(this); -} - -void BitVector::swap(BitVector *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - blocks_.swap(&rhs->blocks_); - Swap(&size_, &rhs->size_); - ranks_.swap(&rhs->ranks_); - select0s_.swap(&rhs->select0s_); - select1s_.swap(&rhs->select1s_); -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/bitvector.h b/v0_1_5/lib/marisa_alpha/bitvector.h deleted file mode 100644 index 41e2be2..0000000 --- a/v0_1_5/lib/marisa_alpha/bitvector.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef MARISA_ALPHA_BITVECTOR_H_ -#define MARISA_ALPHA_BITVECTOR_H_ - -#include "rank.h" -#include "vector.h" - -namespace marisa_alpha { - -class BitVector { - public: - BitVector(); - - void build(); - - void clear_select0s() { - select0s_.clear(); - } - void clear_select1s() { - select1s_.clear(); - } - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - void push_back(bool bit) { - MARISA_ALPHA_THROW_IF(size_ == max_size(), MARISA_ALPHA_SIZE_ERROR); - if ((size_ % 32) == 0) { - blocks_.push_back(0); - } - if (bit) { - blocks_.back() |= 1U << (size_ % 32); - } - ++size_; - } - - bool operator[](std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i >= size_, MARISA_ALPHA_PARAM_ERROR); - return (blocks_[i / 32] & (1U << (i % 32))) != 0; - } - - UInt32 rank0(UInt32 i) const { - MARISA_ALPHA_DEBUG_IF(i > size_, MARISA_ALPHA_PARAM_ERROR); - return i - rank1(i); - } - UInt32 rank1(UInt32 i) const; - - UInt32 select0(UInt32 i) const; - UInt32 select1(UInt32 i) const; - - std::size_t size() const { - return size_; - } - bool empty() const { - return blocks_.empty(); - } - std::size_t max_size() const { - return MARISA_ALPHA_UINT32_MAX; - } - std::size_t total_size() const { - return blocks_.total_size() + sizeof(size_) + ranks_.total_size() - + select0s_.total_size() + select1s_.total_size(); - } - - void clear(); - void swap(BitVector *rhs); - - private: - Vector blocks_; - UInt32 size_; - Vector ranks_; - Vector select0s_; - Vector select1s_; - - // Disallows copy and assignment. - BitVector(const BitVector &); - BitVector &operator=(const BitVector &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_BITVECTOR_H_ diff --git a/v0_1_5/lib/marisa_alpha/cell.h b/v0_1_5/lib/marisa_alpha/cell.h deleted file mode 100644 index d5329cb..0000000 --- a/v0_1_5/lib/marisa_alpha/cell.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef MARISA_ALPHA_CELL_H_ -#define MARISA_ALPHA_CELL_H_ - -#include "base.h" - -namespace marisa_alpha { - -class Cell { - public: - Cell() : louds_pos_(0), node_(0), key_id_(0), length_(0) {} - - void set_louds_pos(UInt32 louds_pos) { - louds_pos_ = louds_pos; - } - void set_node(UInt32 node) { - node_ = node; - } - void set_key_id(UInt32 key_id) { - key_id_ = key_id; - } - void set_length(std::size_t length) { - length_ = length; - } - - UInt32 louds_pos() const { - return louds_pos_; - } - UInt32 node() const { - return node_; - } - UInt32 key_id() const { - return key_id_; - } - std::size_t length() const { - return length_; - } - - private: - UInt32 louds_pos_; - UInt32 node_; - UInt32 key_id_; - std::size_t length_; -}; -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_CELL_H_ diff --git a/v0_1_5/lib/marisa_alpha/container.h b/v0_1_5/lib/marisa_alpha/container.h deleted file mode 100644 index eb8a2af..0000000 --- a/v0_1_5/lib/marisa_alpha/container.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef MARISA_ALPHA_CONTAINER_H_ -#define MARISA_ALPHA_CONTAINER_H_ - -#include - -#include "base.h" - -namespace marisa_alpha { - -template -class Container; - -template -class Container *> { - public: - Container(std::vector *vec) : vec_(vec) {} - Container(const Container &container) : vec_(container.vec_) {} - - void insert(std::size_t, const T &value) const { - vec_->push_back(value); - } - - bool is_valid() const { - return vec_ != NULL; - } - - private: - std::vector *vec_; - - // Disallows assignment. - Container &operator=(const Container &query); -}; - -template -class Container { - public: - explicit Container(T *ptr) : ptr_(ptr) {} - Container(const Container &container) : ptr_(container.ptr_) {} - - void insert(std::size_t i, const T &value) { - ptr_[i] = value; - } - - bool is_valid() const { - return ptr_ != NULL; - } - - private: - T *ptr_; - - // Disallows assignment. - Container &operator=(const Container &); -}; - -template -inline Container MakeContainer(T *ptr) { - return Container(ptr); -} - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_CONTAINER_H_ diff --git a/v0_1_5/lib/marisa_alpha/intvector.cc b/v0_1_5/lib/marisa_alpha/intvector.cc deleted file mode 100644 index b18c33e..0000000 --- a/v0_1_5/lib/marisa_alpha/intvector.cc +++ /dev/null @@ -1,138 +0,0 @@ -#include "intvector.h" - -namespace marisa_alpha { - -IntVector::IntVector() - : units_(), num_bits_per_int_(0), mask_(0), size_(0) {} - -void IntVector::build(const Vector &ints) { - UInt32 max_int = 0; - for (UInt32 i = 0; i < ints.size(); ++i) { - if (ints[i] > max_int) { - max_int = ints[i]; - } - } - build(max_int, ints.size()); - for (UInt32 i = 0; i < ints.size(); ++i) { - set(i, ints[i]); - } -} - -void IntVector::build(UInt32 max_int, std::size_t size) { - UInt32 num_bits_per_int = 0; - do { - ++num_bits_per_int; - max_int >>= 1; - } while (max_int != 0); - - const std::size_t new_size = (std::size_t)( - (((UInt64)num_bits_per_int * size) + 31) / 32); - - Vector temp_units; - temp_units.resize(new_size, 0); - units_.swap(&temp_units); - - num_bits_per_int_ = num_bits_per_int; - mask_ = ~0U; - if (num_bits_per_int != 32) { - mask_ = (1U << num_bits_per_int) - 1; - } - size_ = (UInt32)size; -} - -void IntVector::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_ALPHA_THROW_IF(mapper == NULL, MARISA_ALPHA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void IntVector::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void IntVector::map(Mapper &mapper) { - IntVector temp; - temp.units_.map(mapper); - mapper.map(&temp.num_bits_per_int_); - mapper.map(&temp.mask_); - mapper.map(&temp.size_); - temp.swap(this); -} - -void IntVector::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void IntVector::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -void IntVector::read(int fd) { - Reader reader(fd); - read(reader); -} - -void IntVector::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void IntVector::read(Reader &reader) { - IntVector temp; - temp.units_.read(reader); - reader.read(&temp.num_bits_per_int_); - reader.read(&temp.mask_); - reader.read(&temp.size_); - temp.swap(this); -} - -void IntVector::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void IntVector::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -void IntVector::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void IntVector::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void IntVector::write(Writer &writer) const { - units_.write(writer); - writer.write(num_bits_per_int_); - writer.write(mask_); - writer.write(size_); -} - -void IntVector::clear() { - IntVector().swap(this); -} - -void IntVector::swap(IntVector *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - units_.swap(&rhs->units_); - Swap(&num_bits_per_int_, &rhs->num_bits_per_int_); - Swap(&mask_, &rhs->mask_); - Swap(&size_, &rhs->size_); -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/intvector.h b/v0_1_5/lib/marisa_alpha/intvector.h deleted file mode 100644 index 3304347..0000000 --- a/v0_1_5/lib/marisa_alpha/intvector.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef MARISA_ALPHA_INTVECTOR_H_ -#define MARISA_ALPHA_INTVECTOR_H_ - -#include "vector.h" - -namespace marisa_alpha { - -class IntVector { - public: - IntVector(); - - void build(const Vector &ints); - void build(UInt32 max_int, std::size_t size); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - void set(std::size_t i, UInt32 value) { - MARISA_ALPHA_DEBUG_IF(i >= size_, MARISA_ALPHA_PARAM_ERROR); - std::size_t pos = i * num_bits_per_int_; - std::size_t unit_id = pos / 32; - std::size_t unit_offset = pos % 32; - units_[unit_id] &= ~(mask_ << unit_offset); - units_[unit_id] |= (value & mask_) << unit_offset; - if ((unit_offset + num_bits_per_int_) > 32) { - units_[unit_id + 1] &= ~(mask_ >> (32 - unit_offset)); - units_[unit_id + 1] |= (value & mask_) >> (32 - unit_offset); - } - } - - UInt32 get(std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i >= size_, MARISA_ALPHA_PARAM_ERROR); - std::size_t pos = i * num_bits_per_int_; - std::size_t unit_id = pos / 32; - std::size_t unit_offset = pos % 32; - if ((unit_offset + num_bits_per_int_) <= 32) { - return (units_[unit_id] >> unit_offset) & mask_; - } else { - return ((units_[unit_id] >> unit_offset) - | (units_[unit_id + 1] << (32 - unit_offset))) & mask_; - } - } - - UInt32 operator[](std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i >= size_, MARISA_ALPHA_PARAM_ERROR); - return get(i); - } - - std::size_t num_bits_per_int() const { - return num_bits_per_int_; - } - UInt32 mask() const { - return mask_; - } - std::size_t size() const { - return size_; - } - bool empty() const { - return size_ == 0; - } - std::size_t total_size() const { - return units_.total_size() + sizeof(num_bits_per_int_) - + sizeof(mask_) + sizeof(size_); - } - - void clear(); - void swap(IntVector *rhs); - - private: - Vector units_; - UInt32 num_bits_per_int_; - UInt32 mask_; - UInt32 size_; - - // Disallows copy and assignment. - IntVector(const IntVector &); - IntVector &operator=(const IntVector &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_INTVECTOR_H_ diff --git a/v0_1_5/lib/marisa_alpha/io.h b/v0_1_5/lib/marisa_alpha/io.h deleted file mode 100644 index 758c832..0000000 --- a/v0_1_5/lib/marisa_alpha/io.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MARISA_ALPHA_IO_H_ -#define MARISA_ALPHA_IO_H_ - -#include "mapper.h" -#include "reader.h" -#include "writer.h" - -#endif // MARISA_ALPHA_IO_H_ diff --git a/v0_1_5/lib/marisa_alpha/key.h b/v0_1_5/lib/marisa_alpha/key.h deleted file mode 100644 index 621d2f2..0000000 --- a/v0_1_5/lib/marisa_alpha/key.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MARISA_ALPHA_KEY_H_ -#define MARISA_ALPHA_KEY_H_ - -#include "marisa-string.h" - -namespace marisa_alpha { - -template -class Key { - public: - Key() : str_(), weight_(0.0), id_(0), terminal_(0) {} - - void set_str(const T &str) { - str_ = str; - } - void set_weight(double weight) { - weight_ = weight; - } - void set_id(UInt32 id) { - id_ = id; - } - void set_terminal(UInt32 terminal) { - terminal_ = terminal; - } - - const T &str() const { - return str_; - } - double weight() const { - return weight_; - } - UInt32 id() const { - return id_; - } - UInt32 terminal() const { - return terminal_; - } - - private: - T str_; - double weight_; - UInt32 id_; - UInt32 terminal_; -}; - -template -inline bool operator<(const Key &lhs, const T &rhs) { - return lhs.str() < rhs; -} - -template -inline bool operator<(const T &lhs, const Key &rhs) { - return lhs < rhs.str(); -} - -template -inline bool operator<(const Key &lhs, const Key &rhs) { - return lhs.str() < rhs.str(); -} - -template -inline bool operator==(const Key &lhs, const Key &rhs) { - return lhs.str() == rhs.str(); -} - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_KEY_H_ diff --git a/v0_1_5/lib/marisa_alpha/mapper.cc b/v0_1_5/lib/marisa_alpha/mapper.cc deleted file mode 100644 index 893e61d..0000000 --- a/v0_1_5/lib/marisa_alpha/mapper.cc +++ /dev/null @@ -1,170 +0,0 @@ -#if defined _WIN32 || defined _WIN64 -#include -#include -#include -#else // defined _WIN32 || defined _WIN64 -#include -#include -#include -#include -#include -#endif // defined _WIN32 || defined _WIN64 - -#include "mapper.h" - -namespace marisa_alpha { - -#if defined _WIN32 || defined _WIN64 -Mapper::Mapper() - : ptr_(NULL), origin_(NULL), avail_(0), size_(0), - file_(NULL), map_(NULL) {} - -Mapper::Mapper(const void *ptr, std::size_t size) - : ptr_(ptr), origin_(NULL), avail_(size), size_(0), - file_(NULL), map_(NULL) { - MARISA_ALPHA_THROW_IF((ptr == NULL) && (size != 0), - MARISA_ALPHA_PARAM_ERROR); -} -#else // defined _WIN32 || defined _WIN64 -Mapper::Mapper() - : ptr_(NULL), origin_(MAP_FAILED), avail_(0), size_(0), fd_(-1) {} - -Mapper::Mapper(const void *ptr, std::size_t size) - : ptr_(ptr), origin_(MAP_FAILED), avail_(size), size_(0), fd_(-1) { - MARISA_ALPHA_THROW_IF((ptr == NULL) && (size != 0), - MARISA_ALPHA_PARAM_ERROR); -} -#endif // defined _WIN32 || defined _WIN64 - -#if defined _WIN32 || defined _WIN64 -Mapper::~Mapper() { - if (origin_ != NULL) { - ::UnmapViewOfFile(origin_); - } - - if (map_ != NULL) { - ::CloseHandle(map_); - } - - if (file_ != NULL) { - ::CloseHandle(file_); - } -} -#else // defined _WIN32 || defined _WIN64 -Mapper::~Mapper() { - if (origin_ != MAP_FAILED) { - ::munmap(origin_, size_); - } - - if (fd_ != -1) { - ::close(fd_); - } -} -#endif // defined _WIN32 || defined _WIN64 - -#if defined _WIN32 || defined _WIN64 -void Mapper::open(const char *filename, long offset, int whence) { - MARISA_ALPHA_THROW_IF(is_open(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(filename == NULL, MARISA_ALPHA_PARAM_ERROR); - - struct __stat64 st; - if (::_stat64(filename, &st) != 0) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - const UInt64 file_size = st.st_size; - MARISA_ALPHA_THROW_IF(file_size > MARISA_ALPHA_UINT32_MAX, - MARISA_ALPHA_SIZE_ERROR); - - Mapper temp; - temp.size_ = (std::size_t)file_size; - - temp.file_ = ::CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - MARISA_ALPHA_THROW_IF(temp.file_ == NULL, MARISA_ALPHA_IO_ERROR); - - temp.map_ = ::CreateFileMapping(temp.file_, NULL, PAGE_READONLY, 0, 0, NULL); - MARISA_ALPHA_THROW_IF(temp.map_ == NULL, MARISA_ALPHA_IO_ERROR); - - temp.origin_ = ::MapViewOfFile(temp.map_, FILE_MAP_READ, 0, 0, 0); - MARISA_ALPHA_THROW_IF(temp.origin_ == NULL, MARISA_ALPHA_IO_ERROR); - - temp.seek(offset, whence); - temp.swap(this); -} -#else // defined _WIN32 || defined _WIN64 -void Mapper::open(const char *filename, long offset, int whence) { - MARISA_ALPHA_THROW_IF(is_open(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(filename == NULL, MARISA_ALPHA_PARAM_ERROR); - - struct stat st; - if (::stat(filename, &st) != 0) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - UInt64 file_size = st.st_size; - MARISA_ALPHA_THROW_IF(file_size > MARISA_ALPHA_UINT32_MAX, - MARISA_ALPHA_SIZE_ERROR); - - Mapper temp; - temp.size_ = (std::size_t)file_size; - - temp.fd_ = ::open(filename, O_RDONLY); - MARISA_ALPHA_THROW_IF(temp.fd_ == -1, MARISA_ALPHA_IO_ERROR); - - temp.origin_ = ::mmap(NULL, temp.size_, PROT_READ, MAP_SHARED, temp.fd_, 0); - MARISA_ALPHA_THROW_IF(temp.origin_ == MAP_FAILED, MARISA_ALPHA_IO_ERROR); - - temp.seek(offset, whence); - temp.swap(this); -} -#endif // defined _WIN32 || defined _WIN64 - -void Mapper::clear() { - Mapper().swap(this); -} - -void Mapper::swap(Mapper *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - Swap(&ptr_, &rhs->ptr_); - Swap(&avail_, &rhs->avail_); - Swap(&origin_, &rhs->origin_); - Swap(&size_, &rhs->size_); -#if defined _WIN32 || defined _WIN64 - Swap(&file_, &rhs->file_); - Swap(&map_, &rhs->map_); -#else // defined _WIN32 || defined _WIN64 - Swap(&fd_, &rhs->fd_); -#endif // defined _WIN32 || defined _WIN64 -} - -void Mapper::seek(long offset, int whence) { - switch (whence) { - case SEEK_SET: - case SEEK_CUR: { - MARISA_ALPHA_THROW_IF((offset < 0) || ((unsigned long)offset > size_), - MARISA_ALPHA_IO_ERROR); - ptr_ = static_cast(origin_) + offset; - avail_ = (std::size_t)(size_ - offset); - return; - } - case SEEK_END: { - MARISA_ALPHA_THROW_IF((offset > 0) || ((unsigned long)-offset > size_), - MARISA_ALPHA_IO_ERROR); - ptr_ = static_cast(origin_) + size_ + offset; - avail_ = (std::size_t)-offset; - return; - } - default: { - MARISA_ALPHA_THROW(MARISA_ALPHA_PARAM_ERROR); - } - } -} - -const void *Mapper::map_data(std::size_t size) { - MARISA_ALPHA_THROW_IF(!is_open(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(size > avail_, MARISA_ALPHA_IO_ERROR); - ptr_ = static_cast(ptr_) + size; - avail_ -= size; - return static_cast(ptr_) - size; -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/mapper.h b/v0_1_5/lib/marisa_alpha/mapper.h deleted file mode 100644 index 455581d..0000000 --- a/v0_1_5/lib/marisa_alpha/mapper.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef MARISA_ALPHA_MAPPER_H_ -#define MARISA_ALPHA_MAPPER_H_ - -#include - -#include "base.h" - -namespace marisa_alpha { - -class Mapper { - public: - Mapper(); - Mapper(const void *ptr, std::size_t size); - ~Mapper(); - - void open(const char *filename, long offset = 0, int whence = SEEK_SET); - - template - void map(T *obj) { - MARISA_ALPHA_THROW_IF(obj == NULL, MARISA_ALPHA_PARAM_ERROR); - *obj = *static_cast(map_data(sizeof(T))); - } - - template - void map(const T **objs, std::size_t num_objs) { - MARISA_ALPHA_THROW_IF((objs == NULL) && (num_objs != 0), - MARISA_ALPHA_PARAM_ERROR); - MARISA_ALPHA_THROW_IF(num_objs > (MARISA_ALPHA_UINT32_MAX / sizeof(T)), - MARISA_ALPHA_SIZE_ERROR); - *objs = static_cast(map_data(sizeof(T) * num_objs)); - } - - bool is_open() const { - return ptr_ != NULL; - } - - void clear(); - void swap(Mapper *rhs); - - private: - const void *ptr_; - void *origin_; - std::size_t avail_; - std::size_t size_; -#if defined _WIN32 || defined _WIN64 - void *file_; - void *map_; -#else // defined _WIN32 || defined _WIN64 - int fd_; -#endif // defined _WIN32 || defined _WIN64 - - void seek(long offset, int whence); - - const void *map_data(std::size_t size); - - // Disallows copy and assignment. - Mapper(const Mapper &); - Mapper &operator=(const Mapper &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_MAPPER_H_ diff --git a/v0_1_5/lib/marisa_alpha/marisa-string.h b/v0_1_5/lib/marisa_alpha/marisa-string.h deleted file mode 100644 index d0746d8..0000000 --- a/v0_1_5/lib/marisa_alpha/marisa-string.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef MARISA_ALPHA_STRING_H_ -#define MARISA_ALPHA_STRING_H_ - -#include "base.h" - -namespace marisa_alpha { - -class String { - public: - String() : ptr_(NULL), length_(0) {} - explicit String(const char *str) : ptr_(str), length_(0) { - while (str[length_] != '\0') { - ++length_; - } - } - String(const char *ptr, std::size_t length) - : ptr_(ptr), length_(length) {} - String(const String &str) : ptr_(str.ptr_), length_(str.length_) {} - - String substr(std::size_t pos, std::size_t length) const { - MARISA_ALPHA_DEBUG_IF(pos + length > length_, MARISA_ALPHA_PARAM_ERROR); - return String(ptr_ + pos, length); - } - - String &operator=(const String &str) { - ptr_ = str.ptr_; - length_ = str.length_; - return *this; - } - - UInt8 operator[](std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i >= length_, MARISA_ALPHA_PARAM_ERROR); - return ptr_[i]; - } - - const char *ptr() const { - return ptr_; - } - std::size_t length() const { - return length_; - } - - private: - const char *ptr_; - std::size_t length_; -}; - -inline bool operator==(const String &lhs, const String &rhs) { - if (lhs.length() != rhs.length()) { - return false; - } - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (lhs[i] != rhs[i]) { - return false; - } - } - return true; -} - -inline bool operator!=(const String &lhs, const String &rhs) { - return !(lhs == rhs); -} - -inline bool operator<(const String &lhs, const String &rhs) { - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (i == rhs.length()) { - return false; - } - if (lhs[i] != rhs[i]) { - return lhs[i] < rhs[i]; - } - } - return lhs.length() < rhs.length(); -} - -inline bool operator>(const String &lhs, const String &rhs) { - return rhs < lhs; -} - -class RString { - public: - RString() - : ptr_(static_cast(NULL) - 1), length_(0) {} - explicit RString(const String &str) - : ptr_(str.ptr() + str.length() - 1), length_(str.length()) {} - RString(const RString &str) - : ptr_(str.ptr_), length_(str.length_) {} - - RString substr(std::size_t pos, std::size_t length) const { - MARISA_ALPHA_DEBUG_IF(pos + length > length_, MARISA_ALPHA_PARAM_ERROR); - RString str(*this); - str.ptr_ -= pos; - str.length_ = length; - return str; - } - - RString &operator=(const RString &str) { - ptr_ = str.ptr_; - length_ = str.length_; - return *this; - } - - UInt8 operator[](std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i >= length_, MARISA_ALPHA_PARAM_ERROR); - return *(ptr_ - i); - } - - const char *ptr() const { - return ptr_ - length_ + 1; - } - std::size_t length() const { - return length_; - } - - private: - const char *ptr_; - std::size_t length_; -}; - -inline bool operator==(const RString &lhs, const RString &rhs) { - if (lhs.length() != rhs.length()) { - return false; - } - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (lhs[i] != rhs[i]) { - return false; - } - } - return true; -} - -inline bool operator!=(const RString &lhs, const RString &rhs) { - return !(lhs == rhs); -} - -inline bool operator<(const RString &lhs, const RString &rhs) { - for (std::size_t i = 0; i < lhs.length(); ++i) { - if (i == rhs.length()) { - return false; - } - if (lhs[i] != rhs[i]) { - return lhs[i] < rhs[i]; - } - } - return lhs.length() < rhs.length(); -} - -inline bool operator>(const RString &lhs, const RString &rhs) { - return rhs < lhs; -} - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_STRING_H_ diff --git a/v0_1_5/lib/marisa_alpha/popcount.h b/v0_1_5/lib/marisa_alpha/popcount.h deleted file mode 100644 index 9c10cf9..0000000 --- a/v0_1_5/lib/marisa_alpha/popcount.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef MARISA_ALPHA_POPCOUNT_H_ -#define MARISA_ALPHA_POPCOUNT_H_ - -#include "base.h" - -namespace marisa_alpha { - -class PopCount { - public: - PopCount(UInt32 x) : value_() { - x = (x & 0x55555555U) + ((x & 0xAAAAAAAAU) >> 1); - x = (x & 0x33333333U) + ((x & 0xCCCCCCCCU) >> 2); - x = (x + (x >> 4)) & 0x0F0F0F0FU; - x += x << 8; - x += x << 16; - value_ = x; - } - - UInt32 lo8() const { - return value_ & 0xFFU; - } - UInt32 lo16() const { - return (value_ >> 8) & 0xFFU; - } - UInt32 lo24() const { - return (value_ >> 16) & 0xFFU; - } - UInt32 lo32() const { - return value_ >> 24; - } - - private: - UInt32 value_; -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_POPCOUNT_H_ diff --git a/v0_1_5/lib/marisa_alpha/progress.cc b/v0_1_5/lib/marisa_alpha/progress.cc deleted file mode 100644 index 73247a6..0000000 --- a/v0_1_5/lib/marisa_alpha/progress.cc +++ /dev/null @@ -1,56 +0,0 @@ -#include "progress.h" - -namespace marisa_alpha { - -Progress::Progress(int flags) : flags_(flags), trie_id_(0), total_size_(0) { - if ((flags_ & MARISA_ALPHA_NUM_TRIES_MASK) == 0) { - flags_ = (flags_ & ~MARISA_ALPHA_NUM_TRIES_MASK) - | MARISA_ALPHA_DEFAULT_NUM_TRIES; - } - if ((flags & MARISA_ALPHA_TRIE_MASK) == 0) { - flags_ = (flags_ & ~MARISA_ALPHA_TRIE_MASK) | MARISA_ALPHA_DEFAULT_TRIE; - } - if ((flags & MARISA_ALPHA_TAIL_MASK) == 0) { - flags_ = (flags_ & ~MARISA_ALPHA_TAIL_MASK) | MARISA_ALPHA_DEFAULT_TAIL; - } - if ((flags & MARISA_ALPHA_ORDER_MASK) == 0) { - flags_ = (flags_ & ~MARISA_ALPHA_ORDER_MASK) | MARISA_ALPHA_DEFAULT_ORDER; - } -} - -bool Progress::is_valid() const { - if ((flags_ & ~MARISA_ALPHA_FLAGS_MASK) != 0) { - return false; - } - switch (flags_ & MARISA_ALPHA_TRIE_MASK) { - case MARISA_ALPHA_PATRICIA_TRIE: - case MARISA_ALPHA_PREFIX_TRIE: { - break; - } - default: { - return false; - } - } - switch (flags_ & MARISA_ALPHA_TAIL_MASK) { - case MARISA_ALPHA_WITHOUT_TAIL: - case MARISA_ALPHA_BINARY_TAIL: - case MARISA_ALPHA_TEXT_TAIL: { - break; - } - default: { - return false; - } - } - switch (flags_ & MARISA_ALPHA_ORDER_MASK) { - case MARISA_ALPHA_LABEL_ORDER: - case MARISA_ALPHA_WEIGHT_ORDER: { - break; - } - default: { - return false; - } - } - return true; -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/progress.h b/v0_1_5/lib/marisa_alpha/progress.h deleted file mode 100644 index b5f851a..0000000 --- a/v0_1_5/lib/marisa_alpha/progress.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef MARISA_ALPHA_PROGRESS_H_ -#define MARISA_ALPHA_PROGRESS_H_ - -#include "base.h" - -namespace marisa_alpha { - -class Progress { - public: - explicit Progress(int flags); - - bool is_valid() const; - bool is_last() const { - return (trie_id_ + 1) >= num_tries(); - } - - Progress &operator++() { - ++trie_id_; - return *this; - } - - void test_total_size(std::size_t total_size) { - MARISA_ALPHA_THROW_IF(total_size_ > (MARISA_ALPHA_UINT32_MAX - total_size), - MARISA_ALPHA_SIZE_ERROR); - total_size_ += total_size; - } - - int flags() const { - return flags_; - } - int trie_id() const { - return trie_id_; - } - std::size_t total_size() const { - return total_size_; - } - - int num_tries() const { - return flags_ & MARISA_ALPHA_NUM_TRIES_MASK; - } - int trie() const { - return flags_ & MARISA_ALPHA_TRIE_MASK; - } - int tail() const { - return flags_ & MARISA_ALPHA_TAIL_MASK; - } - int order() const { - return flags_ & MARISA_ALPHA_ORDER_MASK; - } - - private: - int flags_; - int trie_id_; - std::size_t total_size_; - - // Disallows copy and assignment. - Progress(const Progress &); - Progress &operator=(const Progress &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_PROGRESS_H_ diff --git a/v0_1_5/lib/marisa_alpha/query.h b/v0_1_5/lib/marisa_alpha/query.h deleted file mode 100644 index 5a19f2a..0000000 --- a/v0_1_5/lib/marisa_alpha/query.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef MARISA_ALPHA_QUERY_H_ -#define MARISA_ALPHA_QUERY_H_ - -#include - -#include "base.h" - -namespace marisa_alpha { - -class Query { - public: - Query(const char *ptr, std::size_t length) : ptr_(ptr), length_(length) {} - Query(const Query &query) : ptr_(query.ptr_), length_(query.length_) {} - - void insert(std::string *str) const { - str->insert(0, ptr_, length_); - } - - UInt8 operator[](std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i >= length_, MARISA_ALPHA_PARAM_ERROR); - return ptr_[i]; - } - bool ends_at(std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i > length_, MARISA_ALPHA_PARAM_ERROR); - return i == length_; - } - - private: - const char *ptr_; - std::size_t length_; - - // Disallows assignment. - Query &operator=(const Query &query); -}; - -class CQuery { - public: - explicit CQuery(const char *str) : str_(str) {} - CQuery(const CQuery &query) : str_(query.str_) {} - - void insert(std::string *str) const { - str->insert(0, str_); - } - - UInt8 operator[](std::size_t i) const { - return str_[i]; - } - bool ends_at(std::size_t i) const { - return str_[i] == '\0'; - } - - private: - const char *str_; - - // Disallows assignment. - CQuery &operator=(const CQuery &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_QUERY_H_ diff --git a/v0_1_5/lib/marisa_alpha/range.h b/v0_1_5/lib/marisa_alpha/range.h deleted file mode 100644 index cf25767..0000000 --- a/v0_1_5/lib/marisa_alpha/range.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef MARISA_ALPHA_RANGE_H_ -#define MARISA_ALPHA_RANGE_H_ - -#include "base.h" - -namespace marisa_alpha { - -class Range { - public: - Range() : begin_(0), end_(0), pos_(0) {} - Range(UInt32 begin, UInt32 end, UInt32 pos) - : begin_(begin), end_(end), pos_(pos) {} - - void set_begin(UInt32 begin) { - begin_ = begin; - } - void set_end(UInt32 end) { - end_ = end; - } - void set_pos(UInt32 pos) { - pos_ = pos; - } - - UInt32 begin() const { - return begin_; - } - UInt32 end() const { - return end_; - } - UInt32 pos() const { - return pos_; - } - - private: - UInt32 begin_; - UInt32 end_; - UInt32 pos_; -}; - -class WRange { - public: - WRange() : range_(), weight_(0.0) {} - WRange(const Range &range, double weight) - : range_(range), weight_(weight) {} - WRange(UInt32 begin, UInt32 end, UInt32 pos, double weight) - : range_(begin, end, pos), weight_(weight) {} - - void set_begin(UInt32 begin) { - range_.set_begin(begin); - } - void set_end(UInt32 end) { - range_.set_end(end); - } - void set_pos(UInt32 pos) { - range_.set_pos(pos); - } - void set_weight(double weight) { - weight_ = weight; - } - - const Range &range() const { - return range_; - } - UInt32 begin() const { - return range_.begin(); - } - UInt32 end() const { - return range_.end(); - } - UInt32 pos() const { - return range_.pos(); - } - double weight() const { - return weight_; - } - - private: - Range range_; - double weight_; -}; - -inline bool operator>(const WRange &lhs, const WRange &rhs) { - return lhs.weight() > rhs.weight(); -} - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_RANGE_H_ diff --git a/v0_1_5/lib/marisa_alpha/rank.h b/v0_1_5/lib/marisa_alpha/rank.h deleted file mode 100644 index 1452076..0000000 --- a/v0_1_5/lib/marisa_alpha/rank.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MARISA_ALPHA_RANK_H_ -#define MARISA_ALPHA_RANK_H_ - -#include "base.h" - -namespace marisa_alpha { - -class Rank { - public: - Rank() : abs_(0), rel_lo_(0), rel_hi_(0) {} - - void set_abs(UInt32 value) { - abs_ = value; - } - void set_rel1(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 64, MARISA_ALPHA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~0x7FU) | (value & 0x7FU); - } - void set_rel2(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 128, MARISA_ALPHA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~(0xFFU << 7)) | ((value & 0xFFU) << 7); - } - void set_rel3(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 192, MARISA_ALPHA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~(0xFFU << 15)) | ((value & 0xFFU) << 15); - } - void set_rel4(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 256, MARISA_ALPHA_PARAM_ERROR); - rel_lo_ = (rel_lo_ & ~(0x1FFU << 23)) | ((value & 0x1FFU) << 23); - } - void set_rel5(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 320, MARISA_ALPHA_PARAM_ERROR); - rel_hi_ = (rel_hi_ & ~0x1FFU) | (value & 0x1FFU); - } - void set_rel6(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 384, MARISA_ALPHA_PARAM_ERROR); - rel_hi_ = (rel_hi_ & ~(0x1FFU << 9)) | ((value & 0x1FFU) << 9); - } - void set_rel7(UInt32 value) { - MARISA_ALPHA_DEBUG_IF(value > 448, MARISA_ALPHA_PARAM_ERROR); - rel_hi_ = (rel_hi_ & ~(0x1FFU << 18)) | ((value & 0x1FFU) << 18); - } - - UInt32 abs() const { - return abs_; - } - UInt32 rel1() const { - return rel_lo_ & 0x7FU; - } - UInt32 rel2() const { - return (rel_lo_ >> 7) & 0xFFU; - } - UInt32 rel3() const { - return (rel_lo_ >> 15) & 0xFFU; - } - UInt32 rel4() const { - return rel_lo_ >> 23; - } - UInt32 rel5() const { - return rel_hi_ & 0x1FFU; - } - UInt32 rel6() const { - return (rel_hi_ >> 9) & 0x1FFU; - } - UInt32 rel7() const { - return (rel_hi_ >> 18) & 0x1FFU; - } - - private: - UInt32 abs_; - UInt32 rel_lo_; - UInt32 rel_hi_; -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_RANK_H_ diff --git a/v0_1_5/lib/marisa_alpha/reader.cc b/v0_1_5/lib/marisa_alpha/reader.cc deleted file mode 100644 index 48347ba..0000000 --- a/v0_1_5/lib/marisa_alpha/reader.cc +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include - -#ifdef _MSC_VER -#include -#else // _MSC_VER -#include -#endif // _MSC_VER - -#include "reader.h" - -namespace marisa_alpha { - -Reader::Reader() - : file_(NULL), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Reader::Reader(std::FILE *file) - : file_(file), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Reader::Reader(int fd) - : file_(NULL), fd_(fd), stream_(NULL), needs_fclose_(false) {} - -Reader::Reader(std::istream *stream) - : file_(NULL), fd_(-1), stream_(stream), needs_fclose_(false) {} - -Reader::~Reader() { - if (needs_fclose_) { - ::fclose(file_); - } -} - -void Reader::open(const char *filename, long offset, int whence) { - MARISA_ALPHA_THROW_IF(is_open(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(filename == NULL, MARISA_ALPHA_PARAM_ERROR); -#ifdef _MSC_VER - std::FILE *file = NULL; - if (::fopen_s(&file, filename, "rb") != 0) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } -#else // _MSC_VER - std::FILE * const file = ::fopen(filename, "rb"); - MARISA_ALPHA_THROW_IF(file == NULL, MARISA_ALPHA_IO_ERROR); -#endif // _MSC_VER - if (::fseek(file, offset, whence) != 0) { - ::fclose(file); - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - file_ = file; - needs_fclose_ = true; -} - -void Reader::clear() { - Reader().swap(this); -} - -void Reader::swap(Reader *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - Swap(&file_, &rhs->file_); - Swap(&fd_, &rhs->fd_); - Swap(&stream_, &rhs->stream_); - Swap(&needs_fclose_, &rhs->needs_fclose_); -} - -void Reader::read_data(void *buf, std::size_t size) { - if (fd_ != -1) { - while (size != 0) { -#ifdef _MSC_VER - const unsigned int count = (size < INT_MAX) ? size : INT_MAX; - const int size_read = _read(fd_, buf, count); -#else // _MSC_VER - const ::size_t count = (size < SSIZE_MAX) ? size : SSIZE_MAX; - const ::ssize_t size_read = ::read(fd_, buf, count); -#endif // _MSC_VER - MARISA_ALPHA_THROW_IF(size_read <= 0, MARISA_ALPHA_IO_ERROR); - buf = static_cast(buf) + size_read; - size -= size_read; - } - } else if (file_ != NULL) { - if (::fread(buf, 1, size, file_) != size) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } else if (stream_ != NULL) { - try { - if (!stream_->read(static_cast(buf), size)) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } catch (const std::ios_base::failure &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } else { - MARISA_ALPHA_THROW(MARISA_ALPHA_STATE_ERROR); - } -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/reader.h b/v0_1_5/lib/marisa_alpha/reader.h deleted file mode 100644 index ee7de76..0000000 --- a/v0_1_5/lib/marisa_alpha/reader.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef MARISA_ALPHA_READER_H_ -#define MARISA_ALPHA_READER_H_ - -#include -#include - -#include "base.h" - -namespace marisa_alpha { - -class Reader { - public: - Reader(); - explicit Reader(std::FILE *file); - explicit Reader(int fd); - explicit Reader(std::istream *stream); - ~Reader(); - - void open(const char *filename, long offset = 0, int whence = SEEK_SET); - - template - void read(T *obj) { - MARISA_ALPHA_THROW_IF(obj == NULL, MARISA_ALPHA_PARAM_ERROR); - read_data(obj, sizeof(T)); - } - - template - void read(T *objs, std::size_t num_objs) { - MARISA_ALPHA_THROW_IF((objs == NULL) && (num_objs != 0), - MARISA_ALPHA_PARAM_ERROR); - MARISA_ALPHA_THROW_IF(num_objs > (MARISA_ALPHA_UINT32_MAX / sizeof(T)), - MARISA_ALPHA_SIZE_ERROR); - if (num_objs != 0) { - read_data(objs, sizeof(T) * num_objs); - } - } - - bool is_open() const { - return (file_ != NULL) || (fd_ != -1) || (stream_ != NULL); - } - - void clear(); - void swap(Reader *rhs); - - private: - std::FILE *file_; - int fd_; - std::istream *stream_; - bool needs_fclose_; - - void read_data(void *buf, std::size_t size); - - // Disallows copy and assignment. - Reader(const Reader &); - Reader &operator=(const Reader &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_READER_H_ diff --git a/v0_1_5/lib/marisa_alpha/tail.cc b/v0_1_5/lib/marisa_alpha/tail.cc deleted file mode 100644 index 4394500..0000000 --- a/v0_1_5/lib/marisa_alpha/tail.cc +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include - -#include "tail.h" - -namespace marisa_alpha { - -Tail::Tail() : buf_() {} - -void Tail::build(const Vector &keys, - Vector *offsets, int mode) { - switch (mode) { - case MARISA_ALPHA_BINARY_TAIL: { - build_binary_tail(keys, offsets); - return; - } - case MARISA_ALPHA_TEXT_TAIL: { - if (!build_text_tail(keys, offsets)) { - build_binary_tail(keys, offsets); - } - return; - } - default: { - MARISA_ALPHA_THROW(MARISA_ALPHA_PARAM_ERROR); - } - } -} - -void Tail::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - if (mapper == NULL) { - MARISA_ALPHA_THROW(MARISA_ALPHA_PARAM_ERROR); - } - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void Tail::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void Tail::map(Mapper &mapper) { - Tail temp; - temp.buf_.map(mapper); - temp.swap(this); -} - -void Tail::load(const char *filename, long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void Tail::fread(::FILE *file) { - Reader reader(file); - read(reader); -} - -void Tail::read(int fd) { - Reader reader(fd); - read(reader); -} - -void Tail::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void Tail::read(Reader &reader) { - Tail temp; - temp.buf_.read(reader); - temp.swap(this); -} - -void Tail::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void Tail::fwrite(::FILE *file) const { - Writer writer(file); - write(writer); -} - -void Tail::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void Tail::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void Tail::write(Writer &writer) const { - buf_.write(writer); -} - -void Tail::clear() { - Tail().swap(this); -} - -void Tail::swap(Tail *rhs) { - buf_.swap(&rhs->buf_); -} - -void Tail::build_binary_tail(const Vector &keys, - Vector *offsets) { - if (keys.empty()) { - build_empty_tail(offsets); - return; - } - - Vector buf; - buf.push_back('\0'); - - Vector temp_offsets; - temp_offsets.resize(keys.size() + 1); - - for (std::size_t i = 0; i < keys.size(); ++i) { - temp_offsets[i] = (UInt32)buf.size(); - for (std::size_t j = 0; j < keys[i].length(); ++j) { - buf.push_back(keys[i][j]); - } - } - temp_offsets.back() = (UInt32)buf.size(); - buf.shrink(); - - if (offsets != NULL) { - temp_offsets.swap(offsets); - } - buf_.swap(&buf); -} - -bool Tail::build_text_tail(const Vector &keys, - Vector *offsets) { - if (keys.empty()) { - build_empty_tail(offsets); - return true; - } - - typedef std::pair KeyIdPair; - Vector pairs; - pairs.resize(keys.size()); - for (std::size_t i = 0; i < keys.size(); ++i) { - for (std::size_t j = 0; j < keys[i].length(); ++j) { - if (keys[i][j] == '\0') { - return false; - } - } - pairs[i].first = RString(keys[i]); - pairs[i].second = (UInt32)i; - } - std::sort(pairs.begin(), pairs.end(), std::greater()); - - Vector buf; - buf.push_back('T'); - - Vector temp_offsets; - temp_offsets.resize(pairs.size(), 1); - - const KeyIdPair dummy_key; - const KeyIdPair *last = &dummy_key; - for (std::size_t i = 0; i < pairs.size(); ++i) { - const KeyIdPair &cur = pairs[i]; - std::size_t match = 0; - while ((match < cur.first.length()) && (match < last->first.length()) && - last->first[match] == cur.first[match]) { - ++match; - } - if ((match == cur.first.length()) && (last->first.length() != 0)) { - temp_offsets[cur.second] = (UInt32)(temp_offsets[last->second] - + (last->first.length() - match)); - } else { - temp_offsets[cur.second] = (UInt32)buf.size(); - for (std::size_t j = 1; j <= cur.first.length(); ++j) { - buf.push_back(cur.first[cur.first.length() - j]); - } - buf.push_back('\0'); - } - last = &cur; - } - buf.shrink(); - - if (offsets != NULL) { - temp_offsets.swap(offsets); - } - buf_.swap(&buf); - return true; -} - -void Tail::build_empty_tail(Vector *offsets) { - buf_.clear(); - if (offsets != NULL) { - offsets->clear(); - } -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/tail.h b/v0_1_5/lib/marisa_alpha/tail.h deleted file mode 100644 index de05163..0000000 --- a/v0_1_5/lib/marisa_alpha/tail.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef MARISA_ALPHA_TAIL_H_ -#define MARISA_ALPHA_TAIL_H_ - -#include "marisa-string.h" -#include "vector.h" - -namespace marisa_alpha { - -class Tail { - public: - Tail(); - - void build(const Vector &keys, - Vector *offsets, int mode); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - const UInt8 *operator[](std::size_t offset) const { - MARISA_ALPHA_DEBUG_IF(offset >= buf_.size(), MARISA_ALPHA_PARAM_ERROR); - return &buf_[offset]; - } - - int mode() const { - return (buf_.front() == '\0') ? - MARISA_ALPHA_BINARY_TAIL : MARISA_ALPHA_TEXT_TAIL; - } - bool empty() const { - return buf_.empty(); - } - std::size_t size() const { - return buf_.size(); - } - std::size_t total_size() const { - return buf_.total_size(); - } - - void clear(); - void swap(Tail *rhs); - - private: - Vector buf_; - - void build_binary_tail(const Vector &keys, - Vector *offsets); - bool build_text_tail(const Vector &keys, - Vector *offsets); - void build_empty_tail(Vector *offsets); - - // Disallows copy and assignment. - Tail(const Tail &); - Tail &operator=(const Tail &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_TAIL_H_ diff --git a/v0_1_5/lib/marisa_alpha/trie-build.cc b/v0_1_5/lib/marisa_alpha/trie-build.cc deleted file mode 100644 index 4ae3a86..0000000 --- a/v0_1_5/lib/marisa_alpha/trie-build.cc +++ /dev/null @@ -1,342 +0,0 @@ -#include -#include -#include -#include - -#include "range.h" -#include "trie.h" - -namespace marisa_alpha { - -void Trie::build(const char * const *keys, std::size_t num_keys, - const std::size_t *key_lengths, const double *key_weights, - UInt32 *key_ids, int flags) { - MARISA_ALPHA_THROW_IF((keys == NULL) && (num_keys != 0), - MARISA_ALPHA_PARAM_ERROR); - Vector > temp_keys; - temp_keys.resize(num_keys); - for (std::size_t i = 0; i < temp_keys.size(); ++i) { - MARISA_ALPHA_THROW_IF(keys[i] == NULL, MARISA_ALPHA_PARAM_ERROR); - std::size_t length = 0; - if (key_lengths == NULL) { - while (keys[i][length] != '\0') { - ++length; - } - } else { - length = key_lengths[i]; - } - MARISA_ALPHA_THROW_IF(length > MARISA_ALPHA_MAX_LENGTH, - MARISA_ALPHA_SIZE_ERROR); - temp_keys[i].set_str(String(keys[i], length)); - temp_keys[i].set_weight((key_weights != NULL) ? key_weights[i] : 1.0); - } - build_trie(temp_keys, key_ids, flags); -} - -void Trie::build(const std::vector &keys, - std::vector *key_ids, int flags) { - Vector > temp_keys; - temp_keys.resize(keys.size()); - for (std::size_t i = 0; i < temp_keys.size(); ++i) { - MARISA_ALPHA_THROW_IF(keys[i].length() > MARISA_ALPHA_MAX_LENGTH, - MARISA_ALPHA_SIZE_ERROR); - temp_keys[i].set_str(String(keys[i].c_str(), keys[i].length())); - temp_keys[i].set_weight(1.0); - } - build_trie(temp_keys, key_ids, flags); -} - -void Trie::build(const std::vector > &keys, - std::vector *key_ids, int flags) { - Vector > temp_keys; - temp_keys.resize(keys.size()); - for (std::size_t i = 0; i < temp_keys.size(); ++i) { - MARISA_ALPHA_THROW_IF(keys[i].first.length() > MARISA_ALPHA_MAX_LENGTH, - MARISA_ALPHA_SIZE_ERROR); - temp_keys[i].set_str(String( - keys[i].first.c_str(), keys[i].first.length())); - temp_keys[i].set_weight(keys[i].second); - } - build_trie(temp_keys, key_ids, flags); -} - -void Trie::build_trie(Vector > &keys, - std::vector *key_ids, int flags) { - if (key_ids == NULL) { - build_trie(keys, static_cast(NULL), flags); - return; - } - try { - std::vector temp_key_ids(keys.size()); - build_trie(keys, temp_key_ids.empty() ? NULL : &temp_key_ids[0], flags); - key_ids->swap(temp_key_ids); - } catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); - } catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); - } -} - -void Trie::build_trie(Vector > &keys, - UInt32 *key_ids, int flags) { - Trie temp; - Vector terminals; - Progress progress(flags); - MARISA_ALPHA_THROW_IF(!progress.is_valid(), MARISA_ALPHA_PARAM_ERROR); - temp.build_trie(keys, &terminals, progress); - - typedef std::pair TerminalIdPair; - Vector pairs; - pairs.resize(terminals.size()); - for (UInt32 i = 0; i < pairs.size(); ++i) { - pairs[i].first = terminals[i]; - pairs[i].second = i; - } - terminals.clear(); - std::sort(pairs.begin(), pairs.end()); - - UInt32 node = 0; - for (UInt32 i = 0; i < pairs.size(); ++i) { - while (node < pairs[i].first) { - temp.terminal_flags_.push_back(false); - ++node; - } - if (node == pairs[i].first) { - temp.terminal_flags_.push_back(true); - ++node; - } - } - while (node < temp.labels_.size()) { - temp.terminal_flags_.push_back(false); - ++node; - } - terminal_flags_.push_back(false); - temp.terminal_flags_.build(); - temp.terminal_flags_.clear_select0s(); - progress.test_total_size(temp.terminal_flags_.total_size()); - - if (key_ids != NULL) { - for (UInt32 i = 0; i < pairs.size(); ++i) { - key_ids[pairs[i].second] = temp.node_to_key_id(pairs[i].first); - } - } - MARISA_ALPHA_THROW_IF(progress.total_size() != temp.total_size(), - MARISA_ALPHA_UNEXPECTED_ERROR); - temp.swap(this); -} - -template -void Trie::build_trie(Vector > &keys, - Vector *terminals, Progress &progress) { - build_cur(keys, terminals, progress); - progress.test_total_size(louds_.total_size()); - progress.test_total_size(sizeof(num_first_branches_)); - progress.test_total_size(sizeof(num_keys_)); - if (link_flags_.empty()) { - labels_.shrink(); - progress.test_total_size(labels_.total_size()); - progress.test_total_size(link_flags_.total_size()); - progress.test_total_size(links_.total_size()); - progress.test_total_size(tail_.total_size()); - return; - } - - Vector next_terminals; - build_next(keys, &next_terminals, progress); - - if (has_trie()) { - progress.test_total_size(trie_->terminal_flags_.total_size()); - } else if (tail_.mode() == MARISA_ALPHA_BINARY_TAIL) { - labels_.push_back('\0'); - link_flags_.push_back(true); - } - link_flags_.build(); - - for (UInt32 i = 0; i < next_terminals.size(); ++i) { - labels_[link_flags_.select1(i)] = (UInt8)(next_terminals[i] % 256); - next_terminals[i] /= 256; - } - link_flags_.clear_select0s(); - if (has_trie() || (tail_.mode() == MARISA_ALPHA_TEXT_TAIL)) { - link_flags_.clear_select1s(); - } - - links_.build(next_terminals); - labels_.shrink(); - progress.test_total_size(labels_.total_size()); - progress.test_total_size(link_flags_.total_size()); - progress.test_total_size(links_.total_size()); - progress.test_total_size(tail_.total_size()); -} - -template -void Trie::build_cur(Vector > &keys, - Vector *terminals, Progress &progress) try { - num_keys_ = sort_keys(keys); - louds_.push_back(true); - louds_.push_back(false); - labels_.push_back('\0'); - link_flags_.push_back(false); - - Vector > rest_keys; - std::queue queue; - Vector wranges; - queue.push(Range(0, (UInt32)keys.size(), 0)); - while (!queue.empty()) { - const UInt32 node = (UInt32)(link_flags_.size() - queue.size()); - Range range = queue.front(); - queue.pop(); - - while ((range.begin() < range.end()) && - (keys[range.begin()].str().length() == range.pos())) { - keys[range.begin()].set_terminal(node); - range.set_begin(range.begin() + 1); - } - if (range.begin() == range.end()) { - louds_.push_back(false); - continue; - } - - wranges.clear(); - double weight = keys[range.begin()].weight(); - for (UInt32 i = range.begin() + 1; i < range.end(); ++i) { - if (keys[i - 1].str()[range.pos()] != keys[i].str()[range.pos()]) { - wranges.push_back(WRange(range.begin(), i, range.pos(), weight)); - range.set_begin(i); - weight = 0.0; - } - weight += keys[i].weight(); - } - wranges.push_back(WRange(range, weight)); - if (progress.order() == MARISA_ALPHA_WEIGHT_ORDER) { - std::stable_sort(wranges.begin(), wranges.end(), std::greater()); - } - if (node == 0) { - num_first_branches_ = wranges.size(); - } - for (UInt32 i = 0; i < wranges.size(); ++i) { - const WRange &wrange = wranges[i]; - UInt32 pos = wrange.pos() + 1; - if ((progress.tail() != MARISA_ALPHA_WITHOUT_TAIL) || - !progress.is_last()) { - while (pos < keys[wrange.begin()].str().length()) { - UInt32 j; - for (j = wrange.begin() + 1; j < wrange.end(); ++j) { - if (keys[j - 1].str()[pos] != keys[j].str()[pos]) { - break; - } - } - if (j < wrange.end()) { - break; - } - ++pos; - } - } - if ((progress.trie() != MARISA_ALPHA_PATRICIA_TRIE) && - (pos != keys[wrange.end() - 1].str().length())) { - pos = wrange.pos() + 1; - } - louds_.push_back(true); - if (pos == wrange.pos() + 1) { - labels_.push_back(keys[wrange.begin()].str()[wrange.pos()]); - link_flags_.push_back(false); - } else { - labels_.push_back('\0'); - link_flags_.push_back(true); - Key rest_key; - rest_key.set_str(keys[wrange.begin()].str().substr( - wrange.pos(), pos - wrange.pos())); - rest_key.set_weight(wrange.weight()); - rest_keys.push_back(rest_key); - } - wranges[i].set_pos(pos); - queue.push(wranges[i].range()); - } - louds_.push_back(false); - } - louds_.push_back(false); - louds_.build(); - if (progress.trie_id() != 0) { - louds_.clear_select0s(); - } - if (rest_keys.empty()) { - link_flags_.clear(); - } - - build_terminals(keys, terminals); - keys.swap(&rest_keys); -} catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); -} catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); -} - -void Trie::build_next(Vector > &keys, - Vector *terminals, Progress &progress) { - if (progress.is_last()) { - Vector strs; - strs.resize(keys.size()); - for (UInt32 i = 0; i < strs.size(); ++i) { - strs[i] = keys[i].str(); - } - tail_.build(strs, terminals, progress.tail()); - return; - } - Vector > rkeys; - rkeys.resize(keys.size()); - for (UInt32 i = 0; i < rkeys.size(); ++i) { - rkeys[i].set_str(RString(keys[i].str())); - rkeys[i].set_weight(keys[i].weight()); - } - keys.clear(); - trie_.reset(new (std::nothrow) Trie); - MARISA_ALPHA_THROW_IF(!has_trie(), MARISA_ALPHA_MEMORY_ERROR); - trie_->build_trie(rkeys, terminals, ++progress); -} - -void Trie::build_next(Vector > &rkeys, - Vector *terminals, Progress &progress) { - if (progress.is_last()) { - Vector strs; - strs.resize(rkeys.size()); - for (UInt32 i = 0; i < strs.size(); ++i) { - strs[i] = String(rkeys[i].str().ptr(), rkeys[i].str().length()); - } - tail_.build(strs, terminals, progress.tail()); - return; - } - trie_.reset(new (std::nothrow) Trie); - MARISA_ALPHA_THROW_IF(!has_trie(), MARISA_ALPHA_MEMORY_ERROR); - trie_->build_trie(rkeys, terminals, ++progress); -} - -template -UInt32 Trie::sort_keys(Vector > &keys) const { - if (keys.empty()) { - return 0; - } - for (UInt32 i = 0; i < keys.size(); ++i) { - keys[i].set_id(i); - } - std::sort(keys.begin(), keys.end()); - UInt32 count = 1; - for (UInt32 i = 1; i < keys.size(); ++i) { - if (keys[i - 1].str() != keys[i].str()) { - ++count; - } - } - return count; -} - -template -void Trie::build_terminals(const Vector > &keys, - Vector *terminals) const { - Vector temp_terminals; - temp_terminals.resize(keys.size()); - for (UInt32 i = 0; i < keys.size(); ++i) { - temp_terminals[keys[i].id()] = keys[i].terminal(); - } - temp_terminals.swap(terminals); -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/trie-c.cc b/v0_1_5/lib/marisa_alpha/trie-c.cc deleted file mode 100644 index 6566fa6..0000000 --- a/v0_1_5/lib/marisa_alpha/trie-c.cc +++ /dev/null @@ -1,381 +0,0 @@ -#include "trie.h" - -extern "C" { - -namespace { - -class FindCallback { - public: - typedef int (*Func)(void *, marisa_alpha_uint32, size_t); - - FindCallback(Func func, void *first_arg) - : func_(func), first_arg_(first_arg) {} - FindCallback(const FindCallback &callback) - : func_(callback.func_), first_arg_(callback.first_arg_) {} - - bool operator()(marisa_alpha::UInt32 key_id, std::size_t key_length) const { - return func_(first_arg_, key_id, key_length) != 0; - } - - private: - Func func_; - void *first_arg_; - - // Disallows assignment. - FindCallback &operator=(const FindCallback &); -}; - -class PredictCallback { - public: - typedef int (*Func)(void *, marisa_alpha_uint32, const char *, size_t); - - PredictCallback(Func func, void *first_arg) - : func_(func), first_arg_(first_arg) {} - PredictCallback(const PredictCallback &callback) - : func_(callback.func_), first_arg_(callback.first_arg_) {} - - bool operator()(marisa_alpha::UInt32 key_id, const std::string &key) const { - return func_(first_arg_, key_id, key.c_str(), key.length()) != 0; - } - - private: - Func func_; - void *first_arg_; - - // Disallows assignment. - PredictCallback &operator=(const PredictCallback &); -}; - -} // namespace - -struct marisa_alpha_trie_ { - public: - marisa_alpha_trie_() : trie(), mapper() {} - - marisa_alpha::Trie trie; - marisa_alpha::Mapper mapper; - - private: - // Disallows copy and assignment. - marisa_alpha_trie_(const marisa_alpha_trie_ &); - marisa_alpha_trie_ &operator=(const marisa_alpha_trie_ &); -}; - -marisa_alpha_status marisa_alpha_init(marisa_alpha_trie **h) { - if ((h == NULL) || (*h != NULL)) { - return MARISA_ALPHA_HANDLE_ERROR; - } - *h = new (std::nothrow) marisa_alpha_trie_(); - return (*h != NULL) ? MARISA_ALPHA_OK : MARISA_ALPHA_MEMORY_ERROR; -} - -marisa_alpha_status marisa_alpha_end(marisa_alpha_trie *h) { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - delete h; - return MARISA_ALPHA_OK; -} - -marisa_alpha_status marisa_alpha_build(marisa_alpha_trie *h, - const char * const *keys, size_t num_keys, const size_t *key_lengths, - const double *key_weights, marisa_alpha_uint32 *key_ids, int flags) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.build(keys, num_keys, key_lengths, key_weights, key_ids, flags); - h->mapper.clear(); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_mmap(marisa_alpha_trie *h, - const char *filename, long offset, int whence) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.mmap(&h->mapper, filename, offset, whence); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_map(marisa_alpha_trie *h, const void *ptr, - size_t size) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.map(ptr, size); - h->mapper.clear(); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_load(marisa_alpha_trie *h, - const char *filename, long offset, int whence) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.load(filename, offset, whence); - h->mapper.clear(); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_fread(marisa_alpha_trie *h, FILE *file) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.fread(file); - h->mapper.clear(); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_read(marisa_alpha_trie *h, int fd) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.read(fd); - h->mapper.clear(); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_save(const marisa_alpha_trie *h, - const char *filename, int trunc_flag, long offset, int whence) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.save(filename, trunc_flag != 0, offset, whence); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_fwrite(const marisa_alpha_trie *h, - FILE *file) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.fwrite(file); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_write(const marisa_alpha_trie *h, int fd) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.write(fd); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_restore(const marisa_alpha_trie *h, - marisa_alpha_uint32 key_id, char *key_buf, size_t key_buf_size, - size_t *key_length) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (key_length == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - *key_length = h->trie.restore(key_id, key_buf, key_buf_size); - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_lookup(const marisa_alpha_trie *h, - const char *ptr, size_t length, marisa_alpha_uint32 *key_id) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (key_id == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - *key_id = h->trie.lookup(ptr); - } else { - *key_id = h->trie.lookup(ptr, length); - } - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_find(const marisa_alpha_trie *h, - const char *ptr, size_t length, - marisa_alpha_uint32 *key_ids, size_t *key_lengths, - size_t max_num_results, size_t *num_results) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (num_results == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - *num_results = h->trie.find(ptr, key_ids, key_lengths, max_num_results); - } else { - *num_results = h->trie.find(ptr, length, - key_ids, key_lengths, max_num_results); - } - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_find_first(const marisa_alpha_trie *h, - const char *ptr, size_t length, - marisa_alpha_uint32 *key_id, size_t *key_length) { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (key_id == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - *key_id = h->trie.find_first(ptr, key_length); - } else { - *key_id = h->trie.find_first(ptr, length, key_length); - } - return MARISA_ALPHA_OK; -} - -marisa_alpha_status marisa_alpha_find_last(const marisa_alpha_trie *h, - const char *ptr, size_t length, - marisa_alpha_uint32 *key_id, size_t *key_length) { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (key_id == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - *key_id = h->trie.find_last(ptr, key_length); - } else { - *key_id = h->trie.find_last(ptr, length, key_length); - } - return MARISA_ALPHA_OK; -} - -marisa_alpha_status marisa_alpha_find_callback(const marisa_alpha_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_alpha_uint32, size_t), - void *first_arg_to_callback) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (callback == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - h->trie.find_callback(ptr, - ::FindCallback(callback, first_arg_to_callback)); - } else { - h->trie.find_callback(ptr, length, - ::FindCallback(callback, first_arg_to_callback)); - } - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_predict(const marisa_alpha_trie *h, - const char *ptr, size_t length, marisa_alpha_uint32 *key_ids, - size_t max_num_results, size_t *num_results) { - return marisa_alpha_predict_breadth_first(h, ptr, length, - key_ids, max_num_results, num_results); -} - -marisa_alpha_status marisa_alpha_predict_breadth_first( - const marisa_alpha_trie *h, const char *ptr, size_t length, - marisa_alpha_uint32 *key_ids, size_t max_num_results, - size_t *num_results) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (num_results == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - *num_results = h->trie.predict_breadth_first( - ptr, key_ids, NULL, max_num_results); - } else { - *num_results = h->trie.predict_breadth_first( - ptr, length, key_ids, NULL, max_num_results); - } - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_predict_depth_first( - const marisa_alpha_trie *h, const char *ptr, size_t length, - marisa_alpha_uint32 *key_ids, size_t max_num_results, - size_t *num_results) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (num_results == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - *num_results = h->trie.predict_depth_first( - ptr, key_ids, NULL, max_num_results); - } else { - *num_results = h->trie.predict_depth_first( - ptr, length, key_ids, NULL, max_num_results); - } - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -marisa_alpha_status marisa_alpha_predict_callback(const marisa_alpha_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_alpha_uint32, const char *, size_t), - void *first_arg_to_callback) try { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } else if (callback == NULL) { - return MARISA_ALPHA_PARAM_ERROR; - } - if (length == MARISA_ALPHA_ZERO_TERMINATED) { - h->trie.predict_callback(ptr, - ::PredictCallback(callback, first_arg_to_callback)); - } else { - h->trie.predict_callback(ptr, length, - ::PredictCallback(callback, first_arg_to_callback)); - } - return MARISA_ALPHA_OK; -} catch (const marisa_alpha::Exception &ex) { - return ex.status(); -} - -size_t marisa_alpha_get_num_tries(const marisa_alpha_trie *h) { - return (h != NULL) ? h->trie.num_tries() : 0; -} - -size_t marisa_alpha_get_num_keys(const marisa_alpha_trie *h) { - return (h != NULL) ? h->trie.num_keys() : 0; -} - -size_t marisa_alpha_get_num_nodes(const marisa_alpha_trie *h) { - return (h != NULL) ? h->trie.num_nodes() : 0; -} - -size_t marisa_alpha_get_total_size(const marisa_alpha_trie *h) { - return (h != NULL) ? h->trie.total_size() : 0; -} - -marisa_alpha_status marisa_alpha_clear(marisa_alpha_trie *h) { - if (h == NULL) { - return MARISA_ALPHA_HANDLE_ERROR; - } - h->trie.clear(); - h->mapper.clear(); - return MARISA_ALPHA_OK; -} - -} // extern "C" diff --git a/v0_1_5/lib/marisa_alpha/trie-inline.h b/v0_1_5/lib/marisa_alpha/trie-inline.h deleted file mode 100644 index 09f072f..0000000 --- a/v0_1_5/lib/marisa_alpha/trie-inline.h +++ /dev/null @@ -1,360 +0,0 @@ -#ifndef MARISA_ALPHA_TRIE_INLINE_H_ -#define MARISA_ALPHA_TRIE_INLINE_H_ - -#include - -#include "cell.h" - -namespace marisa_alpha { - -inline std::string Trie::operator[](UInt32 key_id) const { - std::string key; - restore(key_id, &key); - return key; -} - -inline UInt32 Trie::operator[](const char *str) const { - return lookup(str); -} - -inline UInt32 Trie::operator[](const std::string &str) const { - return lookup(str); -} - -inline UInt32 Trie::lookup(const std::string &str) const { - return lookup(str.c_str(), str.length()); -} - -inline std::size_t Trie::find(const std::string &str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const { - return find(str.c_str(), str.length(), - key_ids, key_lengths, max_num_results); -} - -inline std::size_t Trie::find(const std::string &str, - std::vector *key_ids, std::vector *key_lengths, - std::size_t max_num_results) const { - return find(str.c_str(), str.length(), - key_ids, key_lengths, max_num_results); -} - -inline UInt32 Trie::find_first(const std::string &str, - std::size_t *key_length) const { - return find_first(str.c_str(), str.length(), key_length); -} - -inline UInt32 Trie::find_last(const std::string &str, - std::size_t *key_length) const { - return find_last(str.c_str(), str.length(), key_length); -} - -template -inline std::size_t Trie::find_callback(const char *str, - T callback) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return find_callback_(CQuery(str), callback); -} - -template -inline std::size_t Trie::find_callback(const char *ptr, std::size_t length, - T callback) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return find_callback_(Query(ptr, length), callback); -} - -template -inline std::size_t Trie::find_callback(const std::string &str, - T callback) const { - return find_callback(str.c_str(), str.length(), callback); -} - -inline std::size_t Trie::predict(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - return predict(str.c_str(), str.length(), key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict(const std::string &str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - return predict(str.c_str(), str.length(), key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_breadth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - return predict_breadth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_breadth_first(const std::string &str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - return predict_breadth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_depth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - return predict_depth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -inline std::size_t Trie::predict_depth_first(const std::string &str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - return predict_depth_first(str.c_str(), str.length(), - key_ids, keys, max_num_results); -} - -template -inline std::size_t Trie::predict_callback( - const char *str, T callback) const { - return predict_callback_(CQuery(str), callback); -} - -template -inline std::size_t Trie::predict_callback( - const char *ptr, std::size_t length, - T callback) const { - return predict_callback_(Query(ptr, length), callback); -} - -template -inline std::size_t Trie::predict_callback( - const std::string &str, T callback) const { - return predict_callback(str.c_str(), str.length(), callback); -} - -inline bool Trie::empty() const { - return louds_.empty(); -} - -inline std::size_t Trie::num_keys() const { - return num_keys_; -} - -inline UInt32 Trie::notfound() { - return MARISA_ALPHA_NOT_FOUND; -} - -inline std::size_t Trie::mismatch() { - return MARISA_ALPHA_MISMATCH; -} - -template -inline bool Trie::find_child(UInt32 &node, T query, - std::size_t &pos) const { - UInt32 louds_pos = get_child(node); - if (!louds_[louds_pos]) { - return false; - } - node = louds_pos_to_node(louds_pos, node); - UInt32 link_id = MARISA_ALPHA_UINT32_MAX; - do { - if (has_link(node)) { - if (link_id == MARISA_ALPHA_UINT32_MAX) { - link_id = get_link_id(node); - } else { - ++link_id; - } - std::size_t next_pos = has_trie() ? - trie_->trie_match(get_link(node, link_id), query, pos) : - tail_match(node, link_id, query, pos); - if (next_pos == mismatch()) { - return false; - } else if (next_pos != pos) { - pos = next_pos; - return true; - } - } else if (labels_[node] == query[pos]) { - ++pos; - return true; - } - ++node; - ++louds_pos; - } while (louds_[louds_pos]); - return false; -} - -template -std::size_t Trie::find_callback_(T query, U callback) const try { - std::size_t count = 0; - UInt32 node = 0; - std::size_t pos = 0; - do { - if (terminal_flags_[node]) { - ++count; - if (!callback(node_to_key_id(node), pos)) { - return count; - } - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return count; -} catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); -} catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); -} - -template -inline bool Trie::predict_child(UInt32 &node, T query, std::size_t &pos, - std::string *key) const { - UInt32 louds_pos = get_child(node); - if (!louds_[louds_pos]) { - return false; - } - node = louds_pos_to_node(louds_pos, node); - UInt32 link_id = MARISA_ALPHA_UINT32_MAX; - do { - if (has_link(node)) { - if (link_id == MARISA_ALPHA_UINT32_MAX) { - link_id = get_link_id(node); - } else { - ++link_id; - } - std::size_t next_pos = has_trie() ? - trie_->trie_prefix_match( - get_link(node, link_id), query, pos, key) : - tail_prefix_match(node, link_id, query, pos, key); - if (next_pos == mismatch()) { - return false; - } else if (next_pos != pos) { - pos = next_pos; - return true; - } - } else if (labels_[node] == query[pos]) { - ++pos; - return true; - } - ++node; - ++louds_pos; - } while (louds_[louds_pos]); - return false; -} - -template -std::size_t Trie::predict_callback_(T query, U callback) const try { - std::string key; - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!predict_child(node, query, pos, &key)) { - return 0; - } - } - query.insert(&key); - std::size_t count = 0; - if (terminal_flags_[node]) { - ++count; - if (!callback(node_to_key_id(node), key)) { - return count; - } - } - Cell cell; - cell.set_louds_pos(get_child(node)); - if (!louds_[cell.louds_pos()]) { - return count; - } - cell.set_node(louds_pos_to_node(cell.louds_pos(), node)); - cell.set_key_id(node_to_key_id(cell.node())); - cell.set_length(key.length()); - Vector stack; - stack.push_back(cell); - std::size_t stack_pos = 1; - while (stack_pos != 0) { - Cell &cur = stack[stack_pos - 1]; - if (!louds_[cur.louds_pos()]) { - cur.set_louds_pos(cur.louds_pos() + 1); - --stack_pos; - continue; - } - cur.set_louds_pos(cur.louds_pos() + 1); - key.resize(cur.length()); - if (has_link(cur.node())) { - if (has_trie()) { - trie_->trie_restore(get_link(cur.node()), &key); - } else { - tail_restore(cur.node(), &key); - } - } else { - key += labels_[cur.node()]; - } - if (terminal_flags_[cur.node()]) { - ++count; - if (!callback(cur.key_id(), key)) { - return count; - } - cur.set_key_id(cur.key_id() + 1); - } - if (stack_pos == stack.size()) { - cell.set_louds_pos(get_child(cur.node())); - cell.set_node(louds_pos_to_node(cell.louds_pos(), cur.node())); - cell.set_key_id(node_to_key_id(cell.node())); - stack.push_back(cell); - } - stack[stack_pos].set_length(key.length()); - stack[stack_pos - 1].set_node(stack[stack_pos - 1].node() + 1); - ++stack_pos; - } - return count; -} catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); -} catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); -} - -inline UInt32 Trie::key_id_to_node(UInt32 key_id) const { - return terminal_flags_.select1(key_id); -} - -inline UInt32 Trie::node_to_key_id(UInt32 node) const { - return terminal_flags_.rank1(node); -} - -inline UInt32 Trie::louds_pos_to_node(UInt32 louds_pos, - UInt32 parent_node) const { - return louds_pos - parent_node - 1; -} - -inline UInt32 Trie::get_child(UInt32 node) const { - return louds_.select0(node) + 1; -} - -inline UInt32 Trie::get_parent(UInt32 node) const { - return (node > num_first_branches_) ? (louds_.select1(node) - node - 1) : 0; -} - -inline bool Trie::has_link(UInt32 node) const { - return (link_flags_.empty()) ? false : link_flags_[node]; -} - -inline UInt32 Trie::get_link_id(UInt32 node) const { - return link_flags_.rank1(node); -} - -inline UInt32 Trie::get_link(UInt32 node) const { - return get_link(node, get_link_id(node)); -} - -inline UInt32 Trie::get_link(UInt32 node, UInt32 link_id) const { - return (links_[link_id] * 256) + labels_[node]; -} - -inline bool Trie::has_link() const { - return !link_flags_.empty(); -} - -inline bool Trie::has_trie() const { - return trie_.get() != NULL; -} - -inline bool Trie::has_tail() const { - return !tail_.empty(); -} - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_TRIE_INLINE_H_ diff --git a/v0_1_5/lib/marisa_alpha/trie-search.cc b/v0_1_5/lib/marisa_alpha/trie-search.cc deleted file mode 100644 index 2edcdd8..0000000 --- a/v0_1_5/lib/marisa_alpha/trie-search.cc +++ /dev/null @@ -1,784 +0,0 @@ -#include -#include - -#include "trie.h" - -namespace marisa_alpha { -namespace { - -template -class PredictCallback { - public: - PredictCallback(T key_ids, U keys, std::size_t max_num_results) - : key_ids_(key_ids), keys_(keys), - max_num_results_(max_num_results), num_results_(0) {} - PredictCallback(const PredictCallback &callback) - : key_ids_(callback.key_ids_), keys_(callback.keys_), - max_num_results_(callback.max_num_results_), - num_results_(callback.num_results_) {} - - bool operator()(marisa_alpha::UInt32 key_id, const std::string &key) { - if (key_ids_.is_valid()) { - key_ids_.insert(num_results_, key_id); - } - if (keys_.is_valid()) { - keys_.insert(num_results_, key); - } - return ++num_results_ < max_num_results_; - } - - private: - T key_ids_; - U keys_; - const std::size_t max_num_results_; - std::size_t num_results_; - - // Disallows assignment. - PredictCallback &operator=(const PredictCallback &); -}; - -} // namespace - -std::string Trie::restore(UInt32 key_id) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(key_id >= num_keys_, MARISA_ALPHA_PARAM_ERROR); - std::string key; - restore_(key_id, &key); - return key; -} - -void Trie::restore(UInt32 key_id, std::string *key) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(key_id >= num_keys_, MARISA_ALPHA_PARAM_ERROR); - MARISA_ALPHA_THROW_IF(key == NULL, MARISA_ALPHA_PARAM_ERROR); - restore_(key_id, key); -} - -std::size_t Trie::restore(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(key_id >= num_keys_, MARISA_ALPHA_PARAM_ERROR); - MARISA_ALPHA_THROW_IF((key_buf == NULL) && (key_buf_size != 0), - MARISA_ALPHA_PARAM_ERROR); - return restore_(key_id, key_buf, key_buf_size); -} - -UInt32 Trie::lookup(const char *str) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return lookup_(CQuery(str)); -} - -UInt32 Trie::lookup(const char *ptr, std::size_t length) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return lookup_(Query(ptr, length)); -} - -std::size_t Trie::find(const char *str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return find_(CQuery(str), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -std::size_t Trie::find(const char *ptr, std::size_t length, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return find_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -std::size_t Trie::find(const char *str, - std::vector *key_ids, std::vector *key_lengths, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return find_(CQuery(str), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -std::size_t Trie::find(const char *ptr, std::size_t length, - std::vector *key_ids, std::vector *key_lengths, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return find_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(key_lengths), max_num_results); -} - -UInt32 Trie::find_first(const char *str, - std::size_t *key_length) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return find_first_(CQuery(str), key_length); -} - -UInt32 Trie::find_first(const char *ptr, std::size_t length, - std::size_t *key_length) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return find_first_(Query(ptr, length), key_length); -} - -UInt32 Trie::find_last(const char *str, - std::size_t *key_length) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return find_last_(CQuery(str), key_length); -} - -UInt32 Trie::find_last(const char *ptr, std::size_t length, - std::size_t *key_length) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return find_last_(Query(ptr, length), key_length); -} - -std::size_t Trie::predict(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(str, key_ids, keys, max_num_results) : - predict_depth_first(str, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(ptr, length, key_ids, keys, max_num_results) : - predict_depth_first(ptr, length, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict(const char *str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(str, key_ids, keys, max_num_results) : - predict_depth_first(str, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict(const char *ptr, std::size_t length, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return (keys == NULL) ? - predict_breadth_first(ptr, length, key_ids, keys, max_num_results) : - predict_depth_first(ptr, length, key_ids, keys, max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return predict_breadth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return predict_breadth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *str, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return predict_breadth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_breadth_first(const char *ptr, std::size_t length, - std::vector *key_ids, std::vector *keys, - std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return predict_breadth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return predict_depth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return predict_depth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first( - const char *str, std::vector *key_ids, - std::vector *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(str == NULL, MARISA_ALPHA_PARAM_ERROR); - return predict_depth_first_(CQuery(str), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -std::size_t Trie::predict_depth_first( - const char *ptr, std::size_t length, std::vector *key_ids, - std::vector *keys, std::size_t max_num_results) const { - MARISA_ALPHA_THROW_IF(empty(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF((ptr == NULL) && (length != 0), - MARISA_ALPHA_PARAM_ERROR); - return predict_depth_first_(Query(ptr, length), - MakeContainer(key_ids), MakeContainer(keys), max_num_results); -} - -void Trie::restore_(UInt32 key_id, std::string *key) const { - const std::size_t start_pos = key->length(); - try { - UInt32 node = key_id_to_node(key_id); - while (node != 0) { - if (has_link(node)) { - const std::size_t prev_pos = key->length(); - if (has_trie()) { - trie_->trie_restore(get_link(node), key); - } else { - tail_restore(node, key); - } - std::reverse(key->begin() + prev_pos, key->end()); - } else { - *key += labels_[node]; - } - node = get_parent(node); - } - std::reverse(key->begin() + start_pos, key->end()); - } catch (const std::bad_alloc &) { - key->resize(start_pos); - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); - } catch (const std::length_error &) { - key->resize(start_pos); - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); - } -} - -void Trie::trie_restore(UInt32 node, std::string *key) const { - do { - if (has_link(node)) { - if (has_trie()) { - trie_->trie_restore(get_link(node), key); - } else { - tail_restore(node, key); - } - } else { - *key += labels_[node]; - } - node = get_parent(node); - } while (node != 0); -} - -void Trie::tail_restore(UInt32 node, std::string *key) const { - const UInt32 link_id = link_flags_.rank1(node); - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - if (tail_.mode() == MARISA_ALPHA_BINARY_TAIL) { - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - key->append(reinterpret_cast(tail_[offset]), length); - } else { - key->append(reinterpret_cast(tail_[offset])); - } -} - -std::size_t Trie::restore_(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const { - std::size_t pos = 0; - UInt32 node = key_id_to_node(key_id); - while (node != 0) { - if (has_link(node)) { - const std::size_t prev_pos = pos; - if (has_trie()) { - trie_->trie_restore(get_link(node), key_buf, key_buf_size, pos); - } else { - tail_restore(node, key_buf, key_buf_size, pos); - } - if (pos < key_buf_size) { - std::reverse(key_buf + prev_pos, key_buf + pos); - } - } else { - if (pos < key_buf_size) { - key_buf[pos] = labels_[node]; - } - ++pos; - } - node = get_parent(node); - } - if (pos < key_buf_size) { - key_buf[pos] = '\0'; - std::reverse(key_buf, key_buf + pos); - } - return pos; -} - -void Trie::trie_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &pos) const { - do { - if (has_link(node)) { - if (has_trie()) { - trie_->trie_restore(get_link(node), key_buf, key_buf_size, pos); - } else { - tail_restore(node, key_buf, key_buf_size, pos); - } - } else { - if (pos < key_buf_size) { - key_buf[pos] = labels_[node]; - } - ++pos; - } - node = get_parent(node); - } while (node != 0); -} - -void Trie::tail_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &pos) const { - const UInt32 link_id = link_flags_.rank1(node); - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - if (tail_.mode() == MARISA_ALPHA_BINARY_TAIL) { - const UInt8 *ptr = tail_[offset]; - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - for (UInt32 i = 0; i < length; ++i) { - if (pos < key_buf_size) { - key_buf[pos] = ptr[i]; - } - ++pos; - } - } else { - for (const UInt8 *str = tail_[offset]; *str != '\0'; ++str) { - if (pos < key_buf_size) { - key_buf[pos] = *str; - } - ++pos; - } - } -} - -template -UInt32 Trie::lookup_(T query) const { - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!find_child(node, query, pos)) { - return notfound(); - } - } - return terminal_flags_[node] ? node_to_key_id(node) : notfound(); -} - -template -std::size_t Trie::trie_match(UInt32 node, T query, - std::size_t pos) const { - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_match(get_link(node), query, pos); - } else { - next_pos = tail_match(node, get_link_id(node), query, pos); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return next_pos; - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return pos; - } else { - ++pos; - } - node = get_parent(node); - while (node != 0) { - if (query.ends_at(pos)) { - return mismatch(); - } - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_match(get_link(node), query, pos); - } else { - next_pos = tail_match(node, get_link_id(node), query, pos); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return mismatch(); - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return mismatch(); - } else { - ++pos; - } - node = get_parent(node); - } - return pos; -} - -template std::size_t Trie::trie_match(UInt32 node, - CQuery query, std::size_t pos) const; -template std::size_t Trie::trie_match(UInt32 node, - const Query &query, std::size_t pos) const; - -template -std::size_t Trie::tail_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos) const { - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - const UInt8 *ptr = tail_[offset]; - if (*ptr != query[pos]) { - return pos; - } else if (tail_.mode() == MARISA_ALPHA_BINARY_TAIL) { - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - for (UInt32 i = 1; i < length; ++i) { - if (query.ends_at(pos + i) || (ptr[i] != query[pos + i])) { - return mismatch(); - } - } - return pos + length; - } else { - for (++ptr, ++pos; *ptr != '\0'; ++ptr, ++pos) { - if (query.ends_at(pos) || (*ptr != query[pos])) { - return mismatch(); - } - } - return pos; - } -} - -template std::size_t Trie::tail_match(UInt32 node, - UInt32 link_id, CQuery query, std::size_t pos) const; -template std::size_t Trie::tail_match(UInt32 node, - UInt32 link_id, const Query &query, std::size_t pos) const; - -template -std::size_t Trie::find_(T query, U key_ids, V key_lengths, - std::size_t max_num_results) const try { - if (max_num_results == 0) { - return 0; - } - std::size_t count = 0; - UInt32 node = 0; - std::size_t pos = 0; - do { - if (terminal_flags_[node]) { - if (key_ids.is_valid()) { - key_ids.insert(count, node_to_key_id(node)); - } - if (key_lengths.is_valid()) { - key_lengths.insert(count, pos); - } - if (++count >= max_num_results) { - return count; - } - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return count; -} catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); -} catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); -} - -template -UInt32 Trie::find_first_(T query, std::size_t *key_length) const { - UInt32 node = 0; - std::size_t pos = 0; - do { - if (terminal_flags_[node]) { - if (key_length != NULL) { - *key_length = pos; - } - return node_to_key_id(node); - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - return notfound(); -} - -template -UInt32 Trie::find_last_(T query, std::size_t *key_length) const { - UInt32 node = 0; - UInt32 node_found = notfound(); - std::size_t pos = 0; - std::size_t pos_found = mismatch(); - do { - if (terminal_flags_[node]) { - node_found = node; - pos_found = pos; - } - } while (!query.ends_at(pos) && find_child(node, query, pos)); - if (node_found != notfound()) { - if (key_length != NULL) { - *key_length = pos_found; - } - return node_to_key_id(node_found); - } - return notfound(); -} - -template -std::size_t Trie::predict_breadth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const try { - if (max_num_results == 0) { - return 0; - } - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!predict_child(node, query, pos, NULL)) { - return 0; - } - } - std::string key; - std::size_t count = 0; - if (terminal_flags_[node]) { - const UInt32 key_id = node_to_key_id(node); - if (key_ids.is_valid()) { - key_ids.insert(count, key_id); - } - if (keys.is_valid()) { - restore(key_id, &key); - keys.insert(count, key); - } - if (++count >= max_num_results) { - return count; - } - } - const UInt32 louds_pos = get_child(node); - if (!louds_[louds_pos]) { - return count; - } - UInt32 node_begin = louds_pos_to_node(louds_pos, node); - UInt32 node_end = louds_pos_to_node(get_child(node + 1), node + 1); - while (node_begin < node_end) { - const UInt32 key_id_begin = node_to_key_id(node_begin); - const UInt32 key_id_end = node_to_key_id(node_end); - if (key_ids.is_valid()) { - UInt32 temp_count = count; - for (UInt32 key_id = key_id_begin; key_id < key_id_end; ++key_id) { - key_ids.insert(temp_count, key_id); - if (++temp_count >= max_num_results) { - break; - } - } - } - if (keys.is_valid()) { - UInt32 temp_count = count; - for (UInt32 key_id = key_id_begin; key_id < key_id_end; ++key_id) { - key.clear(); - restore(key_id, &key); - keys.insert(temp_count, key); - if (++temp_count >= max_num_results) { - break; - } - } - } - count += key_id_end - key_id_begin; - if (count >= max_num_results) { - return max_num_results; - } - node_begin = louds_pos_to_node(get_child(node_begin), node_begin); - node_end = louds_pos_to_node(get_child(node_end), node_end); - } - return count; -} catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); -} catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); -} - -template -std::size_t Trie::predict_depth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const try { - if (max_num_results == 0) { - return 0; - } else if (keys.is_valid()) { - PredictCallback callback(key_ids, keys, max_num_results); - return predict_callback_(query, callback); - } - - UInt32 node = 0; - std::size_t pos = 0; - while (!query.ends_at(pos)) { - if (!predict_child(node, query, pos, NULL)) { - return 0; - } - } - std::size_t count = 0; - if (terminal_flags_[node]) { - if (key_ids.is_valid()) { - key_ids.insert(count, node_to_key_id(node)); - } - if (++count >= max_num_results) { - return count; - } - } - Cell cell; - cell.set_louds_pos(get_child(node)); - if (!louds_[cell.louds_pos()]) { - return count; - } - cell.set_node(louds_pos_to_node(cell.louds_pos(), node)); - cell.set_key_id(node_to_key_id(cell.node())); - Vector stack; - stack.push_back(cell); - std::size_t stack_pos = 1; - while (stack_pos != 0) { - Cell &cur = stack[stack_pos - 1]; - if (!louds_[cur.louds_pos()]) { - cur.set_louds_pos(cur.louds_pos() + 1); - --stack_pos; - continue; - } - cur.set_louds_pos(cur.louds_pos() + 1); - if (terminal_flags_[cur.node()]) { - if (key_ids.is_valid()) { - key_ids.insert(count, cur.key_id()); - } - if (++count >= max_num_results) { - return count; - } - cur.set_key_id(cur.key_id() + 1); - } - if (stack_pos == stack.size()) { - cell.set_louds_pos(get_child(cur.node())); - cell.set_node(louds_pos_to_node(cell.louds_pos(), cur.node())); - cell.set_key_id(node_to_key_id(cell.node())); - stack.push_back(cell); - } - stack[stack_pos - 1].set_node(stack[stack_pos - 1].node() + 1); - ++stack_pos; - } - return count; -} catch (const std::bad_alloc &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); -} catch (const std::length_error &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); -} - -template -std::size_t Trie::trie_prefix_match(UInt32 node, T query, - std::size_t pos, std::string *key) const { - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_prefix_match(get_link(node), query, pos, key); - } else { - next_pos = tail_prefix_match( - node, get_link_id(node), query, pos, key); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return next_pos; - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return pos; - } else { - ++pos; - } - node = get_parent(node); - while (node != 0) { - if (query.ends_at(pos)) { - if (key != NULL) { - trie_restore(node, key); - } - return pos; - } - if (has_link(node)) { - std::size_t next_pos; - if (has_trie()) { - next_pos = trie_->trie_prefix_match( - get_link(node), query, pos, key); - } else { - next_pos = tail_prefix_match( - node, get_link_id(node), query, pos, key); - } - if ((next_pos == mismatch()) || (next_pos == pos)) { - return next_pos; - } - pos = next_pos; - } else if (labels_[node] != query[pos]) { - return mismatch(); - } else { - ++pos; - } - node = get_parent(node); - } - return pos; -} - -template std::size_t Trie::trie_prefix_match(UInt32 node, - CQuery query, std::size_t pos, std::string *key) const; -template std::size_t Trie::trie_prefix_match(UInt32 node, - const Query &query, std::size_t pos, std::string *key) const; - -template -std::size_t Trie::tail_prefix_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos, std::string *key) const { - const UInt32 offset = (links_[link_id] * 256) + labels_[node]; - const UInt8 *ptr = tail_[offset]; - if (*ptr != query[pos]) { - return pos; - } else if (tail_.mode() == MARISA_ALPHA_BINARY_TAIL) { - const UInt32 length = (links_[link_id + 1] * 256) - + labels_[link_flags_.select1(link_id + 1)] - offset; - for (UInt32 i = 1; i < length; ++i) { - if (query.ends_at(pos + i)) { - if (key != NULL) { - key->append(reinterpret_cast(ptr + i), length - i); - } - return pos + i; - } else if (ptr[i] != query[pos + i]) { - return mismatch(); - } - } - return pos + length; - } else { - for (++ptr, ++pos; *ptr != '\0'; ++ptr, ++pos) { - if (query.ends_at(pos)) { - if (key != NULL) { - key->append(reinterpret_cast(ptr)); - } - return pos; - } else if (*ptr != query[pos]) { - return mismatch(); - } - } - return pos; - } -} - -template std::size_t Trie::tail_prefix_match( - UInt32 node, UInt32 link_id, - CQuery query, std::size_t pos, std::string *key) const; -template std::size_t Trie::tail_prefix_match( - UInt32 node, UInt32 link_id, - const Query &query, std::size_t pos, std::string *key) const; - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/trie.cc b/v0_1_5/lib/marisa_alpha/trie.cc deleted file mode 100644 index 400555f..0000000 --- a/v0_1_5/lib/marisa_alpha/trie.cc +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include - -#include "trie.h" - -namespace marisa_alpha { - -Trie::Trie() - : louds_(), labels_(), terminal_flags_(), link_flags_(), links_(), - trie_(), tail_(), num_first_branches_(0), num_keys_(0) {} - -void Trie::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_ALPHA_THROW_IF(mapper == NULL, MARISA_ALPHA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -void Trie::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -void Trie::map(Mapper &mapper) { - Trie temp; - temp.louds_.map(mapper); - temp.labels_.map(mapper); - temp.terminal_flags_.map(mapper); - temp.link_flags_.map(mapper); - temp.links_.map(mapper); - temp.tail_.map(mapper); - mapper.map(&temp.num_first_branches_); - mapper.map(&temp.num_keys_); - - if (temp.has_link() && !temp.has_tail()) { - temp.trie_.reset(new (std::nothrow) Trie); - MARISA_ALPHA_THROW_IF(!temp.has_trie(), MARISA_ALPHA_MEMORY_ERROR); - temp.trie_->map(mapper); - } - temp.swap(this); -} - -void Trie::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -void Trie::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -void Trie::read(int fd) { - Reader reader(fd); - read(reader); -} - -void Trie::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -void Trie::read(Reader &reader) { - Trie temp; - temp.louds_.read(reader); - temp.labels_.read(reader); - temp.terminal_flags_.read(reader); - temp.link_flags_.read(reader); - temp.links_.read(reader); - temp.tail_.read(reader); - reader.read(&temp.num_first_branches_); - reader.read(&temp.num_keys_); - - if (temp.has_link() && !temp.has_tail()) { - temp.trie_.reset(new (std::nothrow) Trie); - MARISA_ALPHA_THROW_IF(!temp.has_trie(), MARISA_ALPHA_MEMORY_ERROR); - temp.trie_->read(reader); - } - temp.swap(this); -} - -void Trie::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -void Trie::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -void Trie::write(int fd) const { - Writer writer(fd); - write(writer); -} - -void Trie::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -void Trie::write(Writer &writer) const { - louds_.write(writer); - labels_.write(writer); - terminal_flags_.write(writer); - link_flags_.write(writer); - links_.write(writer); - tail_.write(writer); - writer.write(num_first_branches_); - writer.write(num_keys_); - if (has_trie()) { - trie_->write(writer); - } -} - -std::size_t Trie::num_tries() const { - return has_trie() ? (trie_->num_tries() + 1) : (louds_.empty() ? 0 : 1); -} - -std::size_t Trie::num_nodes() const { - if (louds_.empty()) { - return 0; - } - std::size_t num_nodes = (louds_.size() / 2) - 1; - if (has_trie()) { - num_nodes += trie_->num_nodes(); - } - return num_nodes; -} - -std::size_t Trie::total_size() const { - return louds_.total_size() + labels_.total_size() - + terminal_flags_.total_size() + link_flags_.total_size() - + links_.total_size() + (has_trie() ? trie_->total_size() : 0) - + tail_.total_size() + sizeof(num_first_branches_) + sizeof(num_keys_); -} - -void Trie::clear() { - Trie().swap(this); -} - -void Trie::swap(Trie *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - louds_.swap(&rhs->louds_); - labels_.swap(&rhs->labels_); - terminal_flags_.swap(&rhs->terminal_flags_); - link_flags_.swap(&rhs->link_flags_); - links_.swap(&rhs->links_); - Swap(&trie_, &rhs->trie_); - tail_.swap(&rhs->tail_); - Swap(&num_first_branches_, &rhs->num_first_branches_); - Swap(&num_keys_, &rhs->num_keys_); -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/trie.h b/v0_1_5/lib/marisa_alpha/trie.h deleted file mode 100644 index 74f1e55..0000000 --- a/v0_1_5/lib/marisa_alpha/trie.h +++ /dev/null @@ -1,388 +0,0 @@ -#ifndef MARISA_ALPHA_TRIE_H_ -#define MARISA_ALPHA_TRIE_H_ - -#include "base.h" - -#ifdef __cplusplus - -#include -#include - -#include "progress.h" -#include "key.h" -#include "query.h" -#include "container.h" -#include "intvector.h" -#include "bitvector.h" -#include "tail.h" - -namespace marisa_alpha { - -class Trie { - public: - Trie(); - - void build(const char * const *keys, std::size_t num_keys, - const std::size_t *key_lengths = NULL, - const double *key_weights = NULL, - UInt32 *key_ids = NULL, int flags = 0); - - void build(const std::vector &keys, - std::vector *key_ids = NULL, int flags = 0); - void build(const std::vector > &keys, - std::vector *key_ids = NULL, int flags = 0); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - std::string operator[](UInt32 key_id) const; - - UInt32 operator[](const char *str) const; - UInt32 operator[](const std::string &str) const; - - std::string restore(UInt32 key_id) const; - void restore(UInt32 key_id, std::string *key) const; - std::size_t restore(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const; - - UInt32 lookup(const char *str) const; - UInt32 lookup(const char *ptr, std::size_t length) const; - UInt32 lookup(const std::string &str) const; - - std::size_t find(const char *str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const; - std::size_t find(const char *ptr, std::size_t length, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const; - std::size_t find(const std::string &str, - UInt32 *key_ids, std::size_t *key_lengths, - std::size_t max_num_results) const; - - std::size_t find(const char *str, - std::vector *key_ids = NULL, - std::vector *key_lengths = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t find(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *key_lengths = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t find(const std::string &str, - std::vector *key_ids = NULL, - std::vector *key_lengths = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - - UInt32 find_first(const char *str, - std::size_t *key_length = NULL) const; - UInt32 find_first(const char *ptr, std::size_t length, - std::size_t *key_length = NULL) const; - UInt32 find_first(const std::string &str, - std::size_t *key_length = NULL) const; - - UInt32 find_last(const char *str, - std::size_t *key_length = NULL) const; - UInt32 find_last(const char *ptr, std::size_t length, - std::size_t *key_length = NULL) const; - UInt32 find_last(const std::string &str, - std::size_t *key_length = NULL) const; - - // bool callback(UInt32 key_id, std::size_t key_length); - template - std::size_t find_callback(const char *str, T callback) const; - template - std::size_t find_callback(const char *ptr, std::size_t length, - T callback) const; - template - std::size_t find_callback(const std::string &str, T callback) const; - - std::size_t predict(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - - std::size_t predict(const char *str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t predict(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t predict(const std::string &str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - - std::size_t predict_breadth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_breadth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_breadth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - - std::size_t predict_breadth_first(const char *str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t predict_breadth_first(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t predict_breadth_first(const std::string &str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - - std::size_t predict_depth_first(const char *str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_depth_first(const char *ptr, std::size_t length, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - std::size_t predict_depth_first(const std::string &str, - UInt32 *key_ids, std::string *keys, std::size_t max_num_results) const; - - std::size_t predict_depth_first(const char *str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t predict_depth_first(const char *ptr, std::size_t length, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - std::size_t predict_depth_first(const std::string &str, - std::vector *key_ids = NULL, - std::vector *keys = NULL, - std::size_t max_num_results = MARISA_ALPHA_MAX_NUM_KEYS) const; - - // bool callback(UInt32 key_id, const std::string &key); - template - std::size_t predict_callback(const char *str, T callback) const; - template - std::size_t predict_callback(const char *ptr, std::size_t length, - T callback) const; - template - std::size_t predict_callback(const std::string &str, T callback) const; - - bool empty() const; - std::size_t num_tries() const; - std::size_t num_keys() const; - std::size_t num_nodes() const; - std::size_t total_size() const; - - void clear(); - void swap(Trie *rhs); - - static UInt32 notfound(); - static std::size_t mismatch(); - - private: - BitVector louds_; - Vector labels_; - BitVector terminal_flags_; - BitVector link_flags_; - IntVector links_; - std::auto_ptr trie_; - Tail tail_; - UInt32 num_first_branches_; - UInt32 num_keys_; - - void build_trie(Vector > &keys, - std::vector *key_ids, int flags); - void build_trie(Vector > &keys, - UInt32 *key_ids, int flags); - - template - void build_trie(Vector > &keys, - Vector *terminals, Progress &progress); - - template - void build_cur(Vector > &keys, - Vector *terminals, Progress &progress); - - void build_next(Vector > &keys, - Vector *terminals, Progress &progress); - void build_next(Vector > &rkeys, - Vector *terminals, Progress &progress); - - template - UInt32 sort_keys(Vector > &keys) const; - - template - void build_terminals(const Vector > &keys, - Vector *terminals) const; - - void restore_(UInt32 key_id, std::string *key) const; - void trie_restore(UInt32 node, std::string *key) const; - void tail_restore(UInt32 node, std::string *key) const; - - std::size_t restore_(UInt32 key_id, char *key_buf, - std::size_t key_buf_size) const; - void trie_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &key_pos) const; - void tail_restore(UInt32 node, char *key_buf, - std::size_t key_buf_size, std::size_t &key_pos) const; - - template - UInt32 lookup_(T query) const; - template - bool find_child(UInt32 &node, T query, std::size_t &pos) const; - template - std::size_t trie_match(UInt32 node, T query, std::size_t pos) const; - template - std::size_t tail_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos) const; - - template - std::size_t find_(T query, U key_ids, V key_lengths, - std::size_t max_num_results) const; - template - UInt32 find_first_(T query, std::size_t *key_length) const; - template - UInt32 find_last_(T query, std::size_t *key_length) const; - template - std::size_t find_callback_(T query, U callback) const; - - template - std::size_t predict_breadth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const; - template - std::size_t predict_depth_first_(T query, U key_ids, V keys, - std::size_t max_num_results) const; - template - std::size_t predict_callback_(T query, U callback) const; - - template - bool predict_child(UInt32 &node, T query, std::size_t &pos, - std::string *key) const; - template - std::size_t trie_prefix_match(UInt32 node, T query, - std::size_t pos, std::string *key) const; - template - std::size_t tail_prefix_match(UInt32 node, UInt32 link_id, - T query, std::size_t pos, std::string *key) const; - - UInt32 key_id_to_node(UInt32 key_id) const; - UInt32 node_to_key_id(UInt32 node) const; - UInt32 louds_pos_to_node(UInt32 louds_pos, UInt32 parent_node) const; - - UInt32 get_child(UInt32 node) const; - UInt32 get_parent(UInt32 node) const; - - bool has_link(UInt32 node) const; - UInt32 get_link_id(UInt32 node) const; - UInt32 get_link(UInt32 node) const; - UInt32 get_link(UInt32 node, UInt32 link_id) const; - - bool has_link() const; - bool has_trie() const; - bool has_tail() const; - - // Disallows copy and assignment. - Trie(const Trie &); - Trie &operator=(const Trie &); -}; - -} // namespace marisa_alpha - -#include "trie-inline.h" - -#else // __cplusplus - -#include - -#endif // __cplusplus - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -typedef struct marisa_alpha_trie_ marisa_alpha_trie; - -marisa_alpha_status marisa_alpha_init(marisa_alpha_trie **h); -marisa_alpha_status marisa_alpha_end(marisa_alpha_trie *h); - -marisa_alpha_status marisa_alpha_build(marisa_alpha_trie *h, - const char * const *keys, size_t num_keys, const size_t *key_lengths, - const double *key_weights, marisa_alpha_uint32 *key_ids, int flags); - -marisa_alpha_status marisa_alpha_mmap(marisa_alpha_trie *h, - const char *filename, long offset, int whence); -marisa_alpha_status marisa_alpha_map(marisa_alpha_trie *h, const void *ptr, - size_t size); - -marisa_alpha_status marisa_alpha_load(marisa_alpha_trie *h, - const char *filename, long offset, int whence); -marisa_alpha_status marisa_alpha_fread(marisa_alpha_trie *h, FILE *file); -marisa_alpha_status marisa_alpha_read(marisa_alpha_trie *h, int fd); - -marisa_alpha_status marisa_alpha_save(const marisa_alpha_trie *h, - const char *filename, int trunc_flag, long offset, int whence); -marisa_alpha_status marisa_alpha_fwrite(const marisa_alpha_trie *h, - FILE *file); -marisa_alpha_status marisa_alpha_write(const marisa_alpha_trie *h, int fd); - -marisa_alpha_status marisa_alpha_restore(const marisa_alpha_trie *h, - marisa_alpha_uint32 key_id, char *key_buf, size_t key_buf_size, - size_t *key_length); - -marisa_alpha_status marisa_alpha_lookup(const marisa_alpha_trie *h, - const char *ptr, size_t length, marisa_alpha_uint32 *key_id); - -marisa_alpha_status marisa_alpha_find(const marisa_alpha_trie *h, - const char *ptr, size_t length, - marisa_alpha_uint32 *key_ids, size_t *key_lengths, - size_t max_num_results, size_t *num_results); -marisa_alpha_status marisa_alpha_find_first(const marisa_alpha_trie *h, - const char *ptr, size_t length, - marisa_alpha_uint32 *key_id, size_t *key_length); -marisa_alpha_status marisa_alpha_find_last(const marisa_alpha_trie *h, - const char *ptr, size_t length, - marisa_alpha_uint32 *key_id, size_t *key_length); -marisa_alpha_status marisa_alpha_find_callback(const marisa_alpha_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_alpha_uint32, size_t), - void *first_arg_to_callback); - -marisa_alpha_status marisa_alpha_predict(const marisa_alpha_trie *h, - const char *ptr, size_t length, marisa_alpha_uint32 *key_ids, - size_t max_num_results, size_t *num_results); -marisa_alpha_status marisa_alpha_predict_breadth_first( - const marisa_alpha_trie *h, const char *ptr, size_t length, - marisa_alpha_uint32 *key_ids, size_t max_num_results, size_t *num_results); -marisa_alpha_status marisa_alpha_predict_depth_first( - const marisa_alpha_trie *h, const char *ptr, size_t length, - marisa_alpha_uint32 *key_ids, size_t max_num_results, size_t *num_results); -marisa_alpha_status marisa_alpha_predict_callback(const marisa_alpha_trie *h, - const char *ptr, size_t length, - int (*callback)(void *, marisa_alpha_uint32, const char *, size_t), - void *first_arg_to_callback); - -size_t marisa_alpha_get_num_tries(const marisa_alpha_trie *h); -size_t marisa_alpha_get_num_keys(const marisa_alpha_trie *h); -size_t marisa_alpha_get_num_nodes(const marisa_alpha_trie *h); -size_t marisa_alpha_get_total_size(const marisa_alpha_trie *h); - -marisa_alpha_status marisa_alpha_clear(marisa_alpha_trie *h); - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // MARISA_ALPHA_TRIE_H_ diff --git a/v0_1_5/lib/marisa_alpha/vector-inline.h b/v0_1_5/lib/marisa_alpha/vector-inline.h deleted file mode 100644 index a0de4f2..0000000 --- a/v0_1_5/lib/marisa_alpha/vector-inline.h +++ /dev/null @@ -1,216 +0,0 @@ -#ifndef MARISA_ALPHA_VECTOR_INLINE_H_ -#define MARISA_ALPHA_VECTOR_INLINE_H_ - -namespace marisa_alpha { - -template -Vector::Vector() - : buf_(NULL), objs_(NULL), size_(0), capacity_(0), fixed_(false) {} - -template -Vector::~Vector() { - if (buf_ != NULL) { - for (std::size_t i = 0; i < size_; ++i) { - buf_[i].~T(); - } - delete [] reinterpret_cast(buf_); - } -} - -template -void Vector::mmap(Mapper *mapper, const char *filename, - long offset, int whence) { - MARISA_ALPHA_THROW_IF(mapper == NULL, MARISA_ALPHA_PARAM_ERROR); - Mapper temp_mapper; - temp_mapper.open(filename, offset, whence); - map(temp_mapper); - temp_mapper.swap(mapper); -} - -template -void Vector::map(const void *ptr, std::size_t size) { - Mapper mapper(ptr, size); - map(mapper); -} - -template -void Vector::map(Mapper &mapper) { - UInt32 size; - mapper.map(&size); - Vector temp; - mapper.map(&temp.objs_, size); - temp.size_ = size; - temp.fix(); - temp.swap(this); -} - -template -void Vector::load(const char *filename, - long offset, int whence) { - Reader reader; - reader.open(filename, offset, whence); - read(reader); -} - -template -void Vector::fread(std::FILE *file) { - Reader reader(file); - read(reader); -} - -template -void Vector::read(int fd) { - Reader reader(fd); - read(reader); -} - -template -void Vector::read(std::istream &stream) { - Reader reader(&stream); - read(reader); -} - -template -void Vector::read(Reader &reader) { - UInt32 size; - reader.read(&size); - Vector temp; - temp.resize(size); - reader.read(temp.buf_, size); - temp.swap(this); -} - -template -void Vector::save(const char *filename, bool trunc_flag, - long offset, int whence) const { - Writer writer; - writer.open(filename, trunc_flag, offset, whence); - write(writer); -} - -template -void Vector::fwrite(std::FILE *file) const { - Writer writer(file); - write(writer); -} - -template -void Vector::write(int fd) const { - Writer writer(fd); - write(writer); -} - -template -void Vector::write(std::ostream &stream) const { - Writer writer(&stream); - write(writer); -} - -template -void Vector::write(Writer &writer) const { - writer.write(size_); - writer.write(objs_, size_); -} - -template -void Vector::push_back(const T &x) { - MARISA_ALPHA_THROW_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(size_ == max_size(), MARISA_ALPHA_SIZE_ERROR); - reserve(size_ + 1); - new (&buf_[size_++]) T(x); -} - -template -void Vector::pop_back() { - MARISA_ALPHA_THROW_IF(fixed_ || (size_ == 0), MARISA_ALPHA_STATE_ERROR); - buf_[--size_].~T(); -} - -template -void Vector::resize(std::size_t size) { - MARISA_ALPHA_THROW_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - reserve(size); - for (std::size_t i = size_; i < size; ++i) { - new (&buf_[i]) T; - } - for (std::size_t i = size; i < size_; ++i) { - buf_[i].~T(); - } - size_ = (UInt32)size; -} - -template -void Vector::resize(std::size_t size, const T &x) { - MARISA_ALPHA_THROW_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - reserve(size); - for (std::size_t i = size_; i < size; ++i) { - new (&buf_[i]) T(x); - } - for (std::size_t i = size; i < size_; ++i) { - buf_[i].~T(); - } - size_ = (UInt32)size; -} - -template -void Vector::reserve(std::size_t capacity) { - MARISA_ALPHA_THROW_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(capacity > max_size(), MARISA_ALPHA_SIZE_ERROR); - if (capacity <= capacity_) { - return; - } - std::size_t new_capacity = capacity; - if (capacity_ > (capacity / 2)) { - if (capacity_ > (max_size() / 2)) { - new_capacity = max_size(); - } else { - new_capacity = capacity_ * 2; - } - } - realloc(new_capacity); -} - -template -void Vector::shrink() { - MARISA_ALPHA_THROW_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - if (size_ != capacity_) { - realloc(size_); - } -} - -template -void Vector::fix() { - MARISA_ALPHA_THROW_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - fixed_ = true; -} - -template -void Vector::swap(Vector *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - Swap(&buf_, &rhs->buf_); - Swap(&objs_, &rhs->objs_); - Swap(&size_, &rhs->size_); - Swap(&capacity_, &rhs->capacity_); - Swap(&fixed_, &rhs->fixed_); -} - -template -void Vector::realloc(std::size_t new_capacity) { - MARISA_ALPHA_THROW_IF(new_capacity > (MARISA_ALPHA_SIZE_MAX / sizeof(T)), - MARISA_ALPHA_SIZE_ERROR); - T * const new_buf = reinterpret_cast( - new (std::nothrow) char[sizeof(T) * new_capacity]); - MARISA_ALPHA_THROW_IF(new_buf == NULL, MARISA_ALPHA_MEMORY_ERROR); - for (std::size_t i = 0; i < size_; ++i) { - new (&new_buf[i]) T(buf_[i]); - buf_[i].~T(); - } - delete [] reinterpret_cast(buf_); - buf_ = new_buf; - objs_ = new_buf; - capacity_ = (UInt32)new_capacity; -} - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_VECTOR_INLINE_H_ diff --git a/v0_1_5/lib/marisa_alpha/vector.h b/v0_1_5/lib/marisa_alpha/vector.h deleted file mode 100644 index 0e1c9f0..0000000 --- a/v0_1_5/lib/marisa_alpha/vector.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef MARISA_ALPHA_VECTOR_H_ -#define MARISA_ALPHA_VECTOR_H_ - -#include "io.h" - -namespace marisa_alpha { - -template -class Vector { - public: - Vector(); - ~Vector(); - - void mmap(Mapper *mapper, const char *filename, - long offset = 0, int whence = SEEK_SET); - void map(const void *ptr, std::size_t size); - void map(Mapper &mapper); - - void load(const char *filename, - long offset = 0, int whence = SEEK_SET); - void fread(std::FILE *file); - void read(int fd); - void read(std::istream &stream); - void read(Reader &reader); - - void save(const char *filename, bool trunc_flag = false, - long offset = 0, int whence = SEEK_SET) const; - void fwrite(std::FILE *file) const; - void write(int fd) const; - void write(std::ostream &stream) const; - void write(Writer &writer) const; - - void push_back(const T &x); - void pop_back(); - - void resize(std::size_t size); - void resize(std::size_t size, const T &x); - void reserve(std::size_t capacity); - void shrink(); - - void fix(); - - const T *begin() const { - return objs_; - } - const T *end() const { - return objs_ + size_; - } - const T &operator[](std::size_t i) const { - MARISA_ALPHA_DEBUG_IF(i > size_, MARISA_ALPHA_PARAM_ERROR); - return objs_[i]; - } - const T &front() const { - MARISA_ALPHA_DEBUG_IF(size_ == 0, MARISA_ALPHA_STATE_ERROR); - return objs_[0]; - } - const T &back() const { - MARISA_ALPHA_DEBUG_IF(size_ == 0, MARISA_ALPHA_STATE_ERROR); - return objs_[size_ - 1]; - } - - T *begin() { - MARISA_ALPHA_DEBUG_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - return buf_; - } - T *end() { - MARISA_ALPHA_DEBUG_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - return buf_ + size_; - } - T &operator[](std::size_t i) { - MARISA_ALPHA_DEBUG_IF(fixed_, MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_DEBUG_IF(i > size_, MARISA_ALPHA_PARAM_ERROR); - return buf_[i]; - } - T &front() { - MARISA_ALPHA_DEBUG_IF(fixed_ || (size_ == 0), MARISA_ALPHA_STATE_ERROR); - return buf_[0]; - } - T &back() { - MARISA_ALPHA_DEBUG_IF(fixed_ || (size_ == 0), MARISA_ALPHA_STATE_ERROR); - return buf_[size_ - 1]; - } - - bool empty() const { - return size_ == 0; - } - std::size_t size() const { - return size_; - } - std::size_t capacity() const { - return capacity_; - } - bool fixed() const { - return fixed_; - } - std::size_t total_size() const { - return (sizeof(T) * size_) + sizeof(size_); - } - - void clear() { - Vector().swap(this); - } - void swap(Vector *rhs); - - static std::size_t max_size() { - return MARISA_ALPHA_UINT32_MAX; - } - - private: - T *buf_; - const T *objs_; - UInt32 size_; - UInt32 capacity_; - bool fixed_; - - void realloc(std::size_t new_capacity); - - // Disallows copy and assignment. - Vector(const Vector &); - Vector &operator=(const Vector &); -}; - -} // namespace marisa_alpha - -#include "vector-inline.h" - -#endif // MARISA_ALPHA_VECTOR_H_ diff --git a/v0_1_5/lib/marisa_alpha/writer.cc b/v0_1_5/lib/marisa_alpha/writer.cc deleted file mode 100644 index 05c851f..0000000 --- a/v0_1_5/lib/marisa_alpha/writer.cc +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -#ifdef _MSC_VER -#include -#else // _MSC_VER -#include -#endif // _MSC_VER - -#include "writer.h" - -namespace marisa_alpha { - -Writer::Writer() - : file_(NULL), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Writer::Writer(std::FILE *file) - : file_(file), fd_(-1), stream_(NULL), needs_fclose_(false) {} - -Writer::Writer(int fd) - : file_(NULL), fd_(fd), stream_(NULL), needs_fclose_(false) {} - -Writer::Writer(std::ostream *stream) - : file_(NULL), fd_(-1), stream_(stream), needs_fclose_(false) {} - -Writer::~Writer() { - if (needs_fclose_) { - ::fclose(file_); - } -} - -void Writer::open(const char *filename, bool trunc_flag, - long offset, int whence) { - MARISA_ALPHA_THROW_IF(is_open(), MARISA_ALPHA_STATE_ERROR); - MARISA_ALPHA_THROW_IF(filename == NULL, MARISA_ALPHA_PARAM_ERROR); -#ifdef _MSC_VER - std::FILE *file = NULL; - if (!trunc_flag) { - ::fopen_s(&file, filename, "rb+"); - } - if (file == NULL) { - if (::fopen_s(&file, filename, "wb") != 0) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } -#else // _MSC_VER - std::FILE *file = NULL; - if (!trunc_flag) { - file = ::fopen(filename, "rb+"); - } - if (file == NULL) { - file = ::fopen(filename, "wb"); - MARISA_ALPHA_THROW_IF(file == NULL, MARISA_ALPHA_IO_ERROR); - } -#endif // _MSC_VER - if (::fseek(file, offset, whence) != 0) { - ::fclose(file); - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - file_ = file; - needs_fclose_ = true; -} - -void Writer::clear() { - Writer().swap(this); -} - -void Writer::swap(Writer *rhs) { - MARISA_ALPHA_THROW_IF(rhs == NULL, MARISA_ALPHA_PARAM_ERROR); - Swap(&file_, &rhs->file_); - Swap(&fd_, &rhs->fd_); - Swap(&stream_, &rhs->stream_); - Swap(&needs_fclose_, &rhs->needs_fclose_); -} - -void Writer::write_data(const void *data, std::size_t size) { - if (fd_ != -1) { - while (size != 0) { -#ifdef _MSC_VER - const unsigned int count = (size < INT_MAX) ? size : INT_MAX; - const int size_written = _write(fd_, data, count); -#else // _MSC_VER - const ::size_t count = (size < SSIZE_MAX) ? size : SSIZE_MAX; - const ::ssize_t size_written = ::write(fd_, data, count); -#endif // _MSC_VER - MARISA_ALPHA_THROW_IF(size_written <= 0, MARISA_ALPHA_IO_ERROR); - data = static_cast(data) + size_written; - size -= size_written; - } - } else if (file_ != NULL) { - if ((::fwrite(data, 1, size, file_) != size) || (::fflush(file_) != 0)) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } else if (stream_ != NULL) { - try { - if (!stream_->write(static_cast(data), size)) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } catch (const std::ios_base::failure &) { - MARISA_ALPHA_THROW(MARISA_ALPHA_IO_ERROR); - } - } else { - MARISA_ALPHA_THROW(MARISA_ALPHA_STATE_ERROR); - } -} - -} // namespace marisa_alpha diff --git a/v0_1_5/lib/marisa_alpha/writer.h b/v0_1_5/lib/marisa_alpha/writer.h deleted file mode 100644 index a31f266..0000000 --- a/v0_1_5/lib/marisa_alpha/writer.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef MARISA_ALPHA_WRITER_H_ -#define MARISA_ALPHA_WRITER_H_ - -#include -#include - -#include "base.h" - -namespace marisa_alpha { - -class Writer { - public: - Writer(); - explicit Writer(std::FILE *file); - explicit Writer(int fd); - explicit Writer(std::ostream *stream); - ~Writer(); - - void open(const char *filename, bool trunc_flag = true, - long offset = 0, int whence = SEEK_SET); - - template - void write(const T &obj) { - write_data(&obj, sizeof(T)); - } - - template - void write(const T *objs, std::size_t num_objs) { - MARISA_ALPHA_THROW_IF((objs == NULL) && (num_objs != 0), - MARISA_ALPHA_PARAM_ERROR); - MARISA_ALPHA_THROW_IF(num_objs > (MARISA_ALPHA_UINT32_MAX / sizeof(T)), - MARISA_ALPHA_SIZE_ERROR); - if (num_objs != 0) { - write_data(objs, sizeof(T) * num_objs); - } - } - - bool is_open() const { - return (file_ != NULL) || (fd_ != -1) || (stream_ != NULL); - } - - void clear(); - void swap(Writer *rhs); - - private: - std::FILE *file_; - int fd_; - std::ostream *stream_; - bool needs_fclose_; - - void write_data(const void *data, std::size_t size); - - // Disallows copy and assignment. - Writer(const Writer &); - Writer &operator=(const Writer &); -}; - -} // namespace marisa_alpha - -#endif // MARISA_ALPHA_WRITER_H_ diff --git a/v0_1_5/tests/Makefile.am b/v0_1_5/tests/Makefile.am deleted file mode 100644 index e0fabd8..0000000 --- a/v0_1_5/tests/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -AM_CFLAGS = -Wall -D_DEBUG -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -I../lib - -TESTS = \ - unit-test \ - io-test \ - vector-test \ - tail-test \ - trie-test \ - c-test - -check_PROGRAMS = $(TESTS) - -noinst_HEADERS = assert.h - -unit_test_SOURCES = unit-test.cc -unit_test_LDADD = ../lib/libmarisa_alpha.la - -io_test_SOURCES = io-test.cc -io_test_LDADD = ../lib/libmarisa_alpha.la - -vector_test_SOURCES = vector-test.cc -vector_test_LDADD = ../lib/libmarisa_alpha.la - -tail_test_SOURCES = tail-test.cc -tail_test_LDADD = ../lib/libmarisa_alpha.la - -trie_test_SOURCES = trie-test.cc -trie_test_LDADD = ../lib/libmarisa_alpha.la - -c_test_SOURCES = c-test.c -c_test_LDADD = ../lib/libmarisa_alpha.la -lstdc++ diff --git a/v0_1_5/tests/Makefile.in b/v0_1_5/tests/Makefile.in deleted file mode 100644 index 231c433..0000000 --- a/v0_1_5/tests/Makefile.in +++ /dev/null @@ -1,663 +0,0 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -TESTS = unit-test$(EXEEXT) io-test$(EXEEXT) vector-test$(EXEEXT) \ - tail-test$(EXEEXT) trie-test$(EXEEXT) c-test$(EXEEXT) -check_PROGRAMS = $(am__EXEEXT_1) -subdir = tests -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__EXEEXT_1 = unit-test$(EXEEXT) io-test$(EXEEXT) \ - vector-test$(EXEEXT) tail-test$(EXEEXT) trie-test$(EXEEXT) \ - c-test$(EXEEXT) -am_c_test_OBJECTS = c-test.$(OBJEXT) -c_test_OBJECTS = $(am_c_test_OBJECTS) -c_test_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_io_test_OBJECTS = io-test.$(OBJEXT) -io_test_OBJECTS = $(am_io_test_OBJECTS) -io_test_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_tail_test_OBJECTS = tail-test.$(OBJEXT) -tail_test_OBJECTS = $(am_tail_test_OBJECTS) -tail_test_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_trie_test_OBJECTS = trie-test.$(OBJEXT) -trie_test_OBJECTS = $(am_trie_test_OBJECTS) -trie_test_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_unit_test_OBJECTS = unit-test.$(OBJEXT) -unit_test_OBJECTS = $(am_unit_test_OBJECTS) -unit_test_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_vector_test_OBJECTS = vector-test.$(OBJEXT) -vector_test_OBJECTS = $(am_vector_test_OBJECTS) -vector_test_DEPENDENCIES = ../lib/libmarisa_alpha.la -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(c_test_SOURCES) $(io_test_SOURCES) $(tail_test_SOURCES) \ - $(trie_test_SOURCES) $(unit_test_SOURCES) \ - $(vector_test_SOURCES) -DIST_SOURCES = $(c_test_SOURCES) $(io_test_SOURCES) \ - $(tail_test_SOURCES) $(trie_test_SOURCES) $(unit_test_SOURCES) \ - $(vector_test_SOURCES) -HEADERS = $(noinst_HEADERS) -ETAGS = etags -CTAGS = ctags -am__tty_colors = \ -red=; grn=; lgn=; blu=; std= -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CFLAGS = -Wall -D_DEBUG -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -D_DEBUG -I../lib -noinst_HEADERS = assert.h -unit_test_SOURCES = unit-test.cc -unit_test_LDADD = ../lib/libmarisa_alpha.la -io_test_SOURCES = io-test.cc -io_test_LDADD = ../lib/libmarisa_alpha.la -vector_test_SOURCES = vector-test.cc -vector_test_LDADD = ../lib/libmarisa_alpha.la -tail_test_SOURCES = tail-test.cc -tail_test_LDADD = ../lib/libmarisa_alpha.la -trie_test_SOURCES = trie-test.cc -trie_test_LDADD = ../lib/libmarisa_alpha.la -c_test_SOURCES = c-test.c -c_test_LDADD = ../lib/libmarisa_alpha.la -lstdc++ -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .cc .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu tests/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -c-test$(EXEEXT): $(c_test_OBJECTS) $(c_test_DEPENDENCIES) $(EXTRA_c_test_DEPENDENCIES) - @rm -f c-test$(EXEEXT) - $(LINK) $(c_test_OBJECTS) $(c_test_LDADD) $(LIBS) -io-test$(EXEEXT): $(io_test_OBJECTS) $(io_test_DEPENDENCIES) $(EXTRA_io_test_DEPENDENCIES) - @rm -f io-test$(EXEEXT) - $(CXXLINK) $(io_test_OBJECTS) $(io_test_LDADD) $(LIBS) -tail-test$(EXEEXT): $(tail_test_OBJECTS) $(tail_test_DEPENDENCIES) $(EXTRA_tail_test_DEPENDENCIES) - @rm -f tail-test$(EXEEXT) - $(CXXLINK) $(tail_test_OBJECTS) $(tail_test_LDADD) $(LIBS) -trie-test$(EXEEXT): $(trie_test_OBJECTS) $(trie_test_DEPENDENCIES) $(EXTRA_trie_test_DEPENDENCIES) - @rm -f trie-test$(EXEEXT) - $(CXXLINK) $(trie_test_OBJECTS) $(trie_test_LDADD) $(LIBS) -unit-test$(EXEEXT): $(unit_test_OBJECTS) $(unit_test_DEPENDENCIES) $(EXTRA_unit_test_DEPENDENCIES) - @rm -f unit-test$(EXEEXT) - $(CXXLINK) $(unit_test_OBJECTS) $(unit_test_LDADD) $(LIBS) -vector-test$(EXEEXT): $(vector_test_OBJECTS) $(vector_test_DEPENDENCIES) $(EXTRA_vector_test_DEPENDENCIES) - @rm -f vector-test$(EXEEXT) - $(CXXLINK) $(vector_test_OBJECTS) $(vector_test_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tail-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector-test.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -.cc.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cc.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cc.lo: -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; skip=0; \ - srcdir=$(srcdir); export srcdir; \ - list=' $(TESTS) '; \ - $(am__tty_colors); \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - col=$$red; res=XPASS; \ - ;; \ - *) \ - col=$$grn; res=PASS; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xfail=`expr $$xfail + 1`; \ - col=$$lgn; res=XFAIL; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - col=$$red; res=FAIL; \ - ;; \ - esac; \ - else \ - skip=`expr $$skip + 1`; \ - col=$$blu; res=SKIP; \ - fi; \ - echo "$${col}$$res$${std}: $$tst"; \ - done; \ - if test "$$all" -eq 1; then \ - tests="test"; \ - All=""; \ - else \ - tests="tests"; \ - All="All "; \ - fi; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="$$All$$all $$tests passed"; \ - else \ - if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ - banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ - fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all $$tests failed"; \ - else \ - if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ - banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ - fi; \ - fi; \ - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - if test "$$skip" -eq 1; then \ - skipped="($$skip test was not run)"; \ - else \ - skipped="($$skip tests were not run)"; \ - fi; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ - fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ - fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - if test "$$failed" -eq 0; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - fi; \ - echo "$${col}$$dashes$${std}"; \ - echo "$${col}$$banner$${std}"; \ - test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ - test -z "$$report" || echo "$${col}$$report$${std}"; \ - echo "$${col}$$dashes$${std}"; \ - test "$$failed" -eq 0; \ - else :; fi - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(HEADERS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ - clean-checkPROGRAMS clean-generic clean-libtool ctags \ - distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/v0_1_5/tests/assert.h b/v0_1_5/tests/assert.h deleted file mode 100644 index 9ca6a0d..0000000 --- a/v0_1_5/tests/assert.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MARISA_ALPHA_ASSERT_H_ -#define MARISA_ALPHA_ASSERT_H_ - -#include -#include - -#define ASSERT(cond) (void)((!!(cond)) || \ - (printf("%d: Assertion `%s' failed.\n", __LINE__, #cond), exit(-1), 0)) - -#define EXCEPT(code, expected_status) try { \ - code; \ - printf("%d: Exception `%s' failed.\n", __LINE__, #code); \ - exit(-1); \ -} catch (const marisa_alpha::Exception &ex) { \ - ASSERT(ex.status() == expected_status); \ -} - -#define TEST_START() \ - printf("%s:%d: %s(): ", __FILE__, __LINE__, __FUNCTION__) - -#define TEST_END() \ - printf("ok\n") - -#endif // MARISA_ALPHA_ASSERT_H_ diff --git a/v0_1_5/tests/c-test.c b/v0_1_5/tests/c-test.c deleted file mode 100644 index 03d6bb0..0000000 --- a/v0_1_5/tests/c-test.c +++ /dev/null @@ -1,223 +0,0 @@ -#include - -#include - -#include "assert.h" - -void TestHandle(void) { - marisa_alpha_trie *trie = NULL; - - TEST_START(); - - ASSERT(marisa_alpha_init(&trie) == MARISA_ALPHA_OK); - ASSERT(marisa_alpha_init(&trie) == MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_end(trie) == MARISA_ALPHA_OK); - ASSERT(marisa_alpha_end(NULL) == MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_build(NULL, NULL, 0, NULL, NULL, NULL, 0) == - MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_mmap(NULL, NULL, 0, 0) == MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_map(NULL, NULL, 0) == MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_load(NULL, NULL, 0, 0) == MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_fread(NULL, NULL) == MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_read(NULL, 0) == MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_save(NULL, NULL, 0, 0, 0) == MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_fwrite(NULL, NULL) == MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_write(NULL, 0) == MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_restore(NULL, 0, NULL, 0, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_lookup(NULL, NULL, 0, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_find(NULL, NULL, 0, NULL, NULL, 0, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_find_first(NULL, NULL, 0, NULL, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_find_last(NULL, NULL, 0, NULL, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_find_callback(NULL, NULL, 0, NULL, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_predict(NULL, NULL, 0, NULL, 0, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_predict_breadth_first(NULL, NULL, 0, NULL, 0, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_predict_depth_first(NULL, NULL, 0, NULL, 0, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - ASSERT(marisa_alpha_predict_callback(NULL, NULL, 0, NULL, NULL) == - MARISA_ALPHA_HANDLE_ERROR); - - ASSERT(marisa_alpha_get_num_tries(NULL) == 0); - ASSERT(marisa_alpha_get_num_keys(NULL) == 0); - ASSERT(marisa_alpha_get_num_nodes(NULL) == 0); - ASSERT(marisa_alpha_get_total_size(NULL) == 0); - - ASSERT(marisa_alpha_clear(NULL) == MARISA_ALPHA_HANDLE_ERROR); - - TEST_END(); -} - -int callback_for_find(void *num_keys, - marisa_alpha_uint32 key_id, size_t key_length) { - ASSERT(*(size_t *)num_keys == 0); - ASSERT(key_id == 1); - ASSERT(key_length == 3); - ++*(size_t *)num_keys; - return 1; -} - -int callback_for_predict(void *num_keys, - marisa_alpha_uint32 key_id, const char *key, size_t key_length) { - ASSERT(*(size_t *)num_keys < 2); - switch (*(size_t *)num_keys) { - case 0: { - ASSERT(key_id == 0); - ASSERT(key_length == 3); - ASSERT(strcmp(key, "app") == 0); - break; - } - case 1: { - ASSERT(key_id == 3); - ASSERT(key_length == 5); - ASSERT(strcmp(key, "apple") == 0); - break; - } - } - ++*(size_t *)num_keys; - return 1; -} - -void TestTrie() { - marisa_alpha_trie *trie = NULL; - const char *keys[8]; - marisa_alpha_uint32 key_ids[8]; - size_t i; - char key_buf[16]; - size_t key_length; - marisa_alpha_uint32 key_id; - marisa_alpha_uint32 found_key_ids[8]; - size_t found_key_lengths[8]; - size_t num_found_keys; - - TEST_START(); - - ASSERT(marisa_alpha_init(&trie) == MARISA_ALPHA_OK); - - ASSERT(marisa_alpha_get_num_tries(trie) == 0); - ASSERT(marisa_alpha_get_num_keys(trie) == 0); - ASSERT(marisa_alpha_get_num_nodes(trie) == 0); - ASSERT(marisa_alpha_get_total_size(trie) == - (sizeof(marisa_alpha_uint32) * 23)); - - ASSERT(marisa_alpha_build(trie, NULL, 0, NULL, NULL, NULL, 0) == - MARISA_ALPHA_OK); - - ASSERT(marisa_alpha_get_num_tries(trie) == 1); - ASSERT(marisa_alpha_get_num_keys(trie) == 0); - ASSERT(marisa_alpha_get_num_nodes(trie) == 1); - - keys[0] = "apple"; - keys[1] = "and"; - keys[2] = "Bad"; - keys[3] = "apple"; - keys[4] = "app"; - - ASSERT(marisa_alpha_build(trie, keys, 5, NULL, NULL, key_ids, - 1 | MARISA_ALPHA_WITHOUT_TAIL | MARISA_ALPHA_LABEL_ORDER) == - MARISA_ALPHA_OK); - - ASSERT(marisa_alpha_get_num_tries(trie) == 1); - ASSERT(marisa_alpha_get_num_keys(trie) == 4); - ASSERT(marisa_alpha_get_num_nodes(trie) == 11); - - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 0); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 2); - - for (i = 0; i < marisa_alpha_get_num_tries(trie); ++i) { - ASSERT(marisa_alpha_restore(trie, - key_ids[i], key_buf, sizeof(key_buf), &key_length) == MARISA_ALPHA_OK); - ASSERT(key_length == strlen(keys[i])); - ASSERT(strcmp(key_buf, keys[i]) == 0); - - ASSERT(marisa_alpha_lookup(trie, - keys[i], MARISA_ALPHA_ZERO_TERMINATED, &key_id) == MARISA_ALPHA_OK); - ASSERT(key_id == key_ids[i]); - - ASSERT(marisa_alpha_lookup(trie, - keys[i], strlen(keys[i]), &key_id) == MARISA_ALPHA_OK); - ASSERT(key_id == key_ids[i]); - } - - ASSERT(marisa_alpha_clear(trie) == MARISA_ALPHA_OK); - - ASSERT(marisa_alpha_get_num_tries(trie) == 0); - ASSERT(marisa_alpha_get_num_keys(trie) == 0); - ASSERT(marisa_alpha_get_num_nodes(trie) == 0); - ASSERT(marisa_alpha_get_total_size(trie) == - (sizeof(marisa_alpha_uint32) * 23)); - - ASSERT(marisa_alpha_build(trie, keys, 5, NULL, NULL, key_ids, - 1 | MARISA_ALPHA_WITHOUT_TAIL | MARISA_ALPHA_WEIGHT_ORDER) == - MARISA_ALPHA_OK); - - ASSERT(marisa_alpha_get_num_tries(trie) == 1); - ASSERT(marisa_alpha_get_num_keys(trie) == 4); - ASSERT(marisa_alpha_get_num_nodes(trie) == 11); - - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 2); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 0); - - ASSERT(marisa_alpha_find(trie, "ap", MARISA_ALPHA_ZERO_TERMINATED, - found_key_ids, found_key_lengths, 8, &num_found_keys) == - MARISA_ALPHA_OK); - ASSERT(num_found_keys == 0); - - ASSERT(marisa_alpha_find(trie, "applex", MARISA_ALPHA_ZERO_TERMINATED, - found_key_ids, found_key_lengths, 8, &num_found_keys) == - MARISA_ALPHA_OK); - ASSERT(num_found_keys == 2); - ASSERT(found_key_ids[0] == key_ids[4]); - ASSERT(found_key_lengths[0] == 3); - ASSERT(found_key_ids[1] == key_ids[0]); - ASSERT(found_key_lengths[1] == 5); - - num_found_keys = 0; - ASSERT(marisa_alpha_find_callback(trie, "anderson", - MARISA_ALPHA_ZERO_TERMINATED, - callback_for_find, &num_found_keys) == MARISA_ALPHA_OK); - ASSERT(num_found_keys == 1); - - ASSERT(marisa_alpha_predict(trie, "a", MARISA_ALPHA_ZERO_TERMINATED, - found_key_ids, 8, &num_found_keys) == MARISA_ALPHA_OK); - ASSERT(num_found_keys == 3); - ASSERT(found_key_ids[0] == key_ids[4]); - ASSERT(found_key_ids[1] == key_ids[1]); - ASSERT(found_key_ids[2] == key_ids[0]); - - num_found_keys = 0; - ASSERT(marisa_alpha_predict_callback(trie, "app", - MARISA_ALPHA_ZERO_TERMINATED, - callback_for_predict, &num_found_keys) == MARISA_ALPHA_OK); - - ASSERT(marisa_alpha_end(trie) == MARISA_ALPHA_OK); - - TEST_END(); -} - -int main(void) { - TestHandle(); - TestTrie(); - - return 0; -} diff --git a/v0_1_5/tests/io-test.cc b/v0_1_5/tests/io-test.cc deleted file mode 100644 index afe730b..0000000 --- a/v0_1_5/tests/io-test.cc +++ /dev/null @@ -1,237 +0,0 @@ -#ifdef _MSC_VER -#include -#else -#include -#endif // _MSC_VER - -#include -#include -#include - -#include -#include - -#include - -#include "assert.h" - -namespace { - -void TestFilename() { - TEST_START(); - - { - marisa_alpha::Writer writer; - writer.open("io-test.dat"); - marisa_alpha::UInt32 value = 123; - writer.write(value); - writer.write(value); - double values[] = { 345, 456 }; - writer.write(values, 2); - EXCEPT(writer.write(values, 1U << 30), MARISA_ALPHA_SIZE_ERROR); - } - - { - marisa_alpha::Writer writer; - writer.open("io-test.dat", false, 4, SEEK_SET); - marisa_alpha::UInt32 value = 234; - writer.write(value); - } - - { - marisa_alpha::Writer writer; - writer.open("io-test.dat", false, 0, SEEK_END); - double value = 567; - writer.write(value); - } - - { - marisa_alpha::Reader reader; - reader.open("io-test.dat"); - marisa_alpha::UInt32 value; - reader.read(&value); - ASSERT(value == 123); - reader.read(&value); - ASSERT(value == 234); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 345); - ASSERT(values[1] == 456); - ASSERT(values[2] == 567); - char byte; - EXCEPT(reader.read(&byte), MARISA_ALPHA_IO_ERROR); - } - - { - marisa_alpha::Mapper mapper; - mapper.open("io-test.dat"); - marisa_alpha::UInt32 value; - mapper.map(&value); - ASSERT(value == 123); - mapper.map(&value); - ASSERT(value == 234); - const double *values; - mapper.map(&values, 3); - ASSERT(values[0] == 345); - ASSERT(values[1] == 456); - ASSERT(values[2] == 567); - char byte; - EXCEPT(mapper.map(&byte), MARISA_ALPHA_IO_ERROR); - } - - { - marisa_alpha::Writer writer; - writer.open("io-test.dat"); - } - - { - marisa_alpha::Reader reader; - reader.open("io-test.dat"); - char byte; - EXCEPT(reader.read(&byte), MARISA_ALPHA_IO_ERROR); - } - - TEST_END(); -} - -void TestFd() { - TEST_START(); - - { -#ifdef _MSC_VER - int fd = -1; - ASSERT(::_sopen_s(&fd, "io-test.dat", - _O_BINARY | _O_CREAT | _O_WRONLY | _O_TRUNC, - _SH_DENYRW, _S_IREAD | _S_IWRITE) == 0); -#else // _MSC_VER - int fd = ::creat("io-test.dat", 0644); - ASSERT(fd != -1); -#endif // _MSC_VER - marisa_alpha::Writer writer(fd); - marisa_alpha::UInt32 value = 345; - writer.write(value); - double values[] = { 456, 567, 678 }; - writer.write(values, 3); -#ifdef _MSC_VER - ASSERT(::_close(fd) == 0); -#else // _MSC_VER - ASSERT(::close(fd) == 0); -#endif // _MSC_VER - } - - { -#ifdef _MSC_VER - int fd = -1; - ASSERT(::_sopen_s(&fd, "io-test.dat", _O_BINARY | _O_RDONLY, - _SH_DENYRW, _S_IREAD) == 0); -#else // _MSC_VER - int fd = ::open("io-test.dat", O_RDONLY); - ASSERT(fd != -1); -#endif // _MSC_VER - marisa_alpha::Reader reader(fd); - marisa_alpha::UInt32 value; - reader.read(&value); - ASSERT(value == 345); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 456); - ASSERT(values[1] == 567); - ASSERT(values[2] == 678); - char byte; - EXCEPT(reader.read(&byte), MARISA_ALPHA_IO_ERROR); -#ifdef _MSC_VER - ASSERT(::_close(fd) == 0); -#else // _MSC_VER - ASSERT(::close(fd) == 0); -#endif // _MSC_VER - } - - TEST_END(); -} - -void TestFile() { - TEST_START(); - - { -#ifdef _MSC_VER - FILE *file = NULL; - ASSERT(::fopen_s(&file, "io-test.dat", "wb") == 0); -#else // _MSC_VER - FILE *file = std::fopen("io-test.dat", "wb"); - ASSERT(file != NULL); -#endif // _MSC_VER - marisa_alpha::Writer writer(file); - marisa_alpha::UInt32 value = 345; - writer.write(value); - double values[3] = { 456, 567, 678 }; - writer.write(values, 3); - ASSERT(std::fclose(file) == 0); - } - - { -#ifdef _MSC_VER - FILE *file = NULL; - ASSERT(::fopen_s(&file, "io-test.dat", "rb") == 0); -#else // _MSC_VER - FILE *file = std::fopen("io-test.dat", "rb"); - ASSERT(file != NULL); -#endif // _MSC_VER - marisa_alpha::Reader reader(file); - marisa_alpha::UInt32 value; - reader.read(&value); - ASSERT(value == 345); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 456); - ASSERT(values[1] == 567); - ASSERT(values[2] == 678); - char byte; - EXCEPT(reader.read(&byte), MARISA_ALPHA_IO_ERROR); - ASSERT(std::fclose(file) == 0); - } - - TEST_END(); -} - -void TestStream() { - TEST_START(); - - { - std::ofstream file("io-test.dat", std::ios::binary); - ASSERT(file.is_open()); - marisa_alpha::Writer writer(&file); - marisa_alpha::UInt32 value = 345; - writer.write(value); - double values[3] = { 456, 567, 678 }; - writer.write(values, 3); - } - - { - std::ifstream file("io-test.dat", std::ios::binary); - ASSERT(file.is_open()); - marisa_alpha::Reader reader(&file); - marisa_alpha::UInt32 value; - reader.read(&value); - ASSERT(value == 345); - double values[3]; - reader.read(values, 3); - ASSERT(values[0] == 456); - ASSERT(values[1] == 567); - ASSERT(values[2] == 678); - char byte; - EXCEPT(reader.read(&byte), MARISA_ALPHA_IO_ERROR); - } - - TEST_END(); -} - -} // namespace - -int main() { - TestFilename(); - TestFd(); - TestFile(); - TestStream(); - - return 0; -} diff --git a/v0_1_5/tests/tail-test.cc b/v0_1_5/tests/tail-test.cc deleted file mode 100644 index ddebb68..0000000 --- a/v0_1_5/tests/tail-test.cc +++ /dev/null @@ -1,246 +0,0 @@ -#include -#include - -#include - -#include "assert.h" - -namespace { - -void TestBinaryTail() { - TEST_START(); - - marisa_alpha::Tail tail; - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32)); - - marisa_alpha::Vector keys; - tail.build(keys, NULL, MARISA_ALPHA_BINARY_TAIL); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32)); - - keys.push_back(marisa_alpha::String("")); - marisa_alpha::Vector offsets; - tail.build(keys, &offsets, MARISA_ALPHA_BINARY_TAIL); - - ASSERT(tail.size() == 1); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size() + 1); - ASSERT(offsets[0] == 1); - ASSERT(offsets[1] == tail.size()); - - const char binary_key[] = { 'N', 'P', '\0', 'T', 'r', 'i', 'e' }; - keys[0] = marisa_alpha::String(binary_key, sizeof(binary_key)); - tail.build(keys, &offsets, MARISA_ALPHA_TEXT_TAIL); - - ASSERT(tail.size() == sizeof(binary_key) + 1); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size() + 1); - ASSERT(offsets[0] == 1); - ASSERT(offsets[1] == tail.size()); - - tail.build(keys, &offsets, MARISA_ALPHA_BINARY_TAIL); - - ASSERT(tail.size() == sizeof(binary_key) + 1); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size() + 1); - ASSERT(offsets[0] == 1); - ASSERT(offsets[1] == tail.size()); - - keys.clear(); - keys.push_back(marisa_alpha::String("abc")); - keys.push_back(marisa_alpha::String("bc")); - keys.push_back(marisa_alpha::String("abc")); - keys.push_back(marisa_alpha::String("c")); - keys.push_back(marisa_alpha::String("ABC")); - keys.push_back(marisa_alpha::String("AB")); - - tail.build(keys, NULL, MARISA_ALPHA_BINARY_TAIL); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - - tail.build(keys, &offsets, MARISA_ALPHA_BINARY_TAIL); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - ASSERT(offsets.size() == 7); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String( - reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - tail.save("tail-test.dat"); - tail.clear(); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32)); - - marisa_alpha::Mapper mapper; - tail.mmap(&mapper, "tail-test.dat"); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String( - reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - tail.clear(); - tail.load("tail-test.dat"); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String( - reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - std::stringstream stream; - tail.write(stream); - - tail.clear(); - tail.read(stream); - - ASSERT(tail.size() == 15); - ASSERT(tail.mode() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String( - reinterpret_cast(tail[offsets[i]]), - offsets[i + 1] - offsets[i]) == keys[i]); - } - - TEST_END(); -} - -void TestTextTail() { - TEST_START(); - - marisa_alpha::Tail tail; - marisa_alpha::Vector keys; - tail.build(keys, NULL, MARISA_ALPHA_TEXT_TAIL); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32)); - - keys.push_back(marisa_alpha::String("")); - marisa_alpha::Vector offsets; - tail.build(keys, &offsets, MARISA_ALPHA_TEXT_TAIL); - - ASSERT(tail.size() == 2); - ASSERT(tail.mode() == MARISA_ALPHA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size()); - ASSERT(offsets[0] == 1); - ASSERT(*tail[offsets[0]] == '\0'); - - keys.clear(); - keys.push_back(marisa_alpha::String("abc")); - keys.push_back(marisa_alpha::String("bc")); - keys.push_back(marisa_alpha::String("abc")); - keys.push_back(marisa_alpha::String("c")); - keys.push_back(marisa_alpha::String("ABC")); - keys.push_back(marisa_alpha::String("AB")); - - tail.build(keys, NULL, MARISA_ALPHA_TEXT_TAIL); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_ALPHA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - - tail.build(keys, &offsets, MARISA_ALPHA_TEXT_TAIL); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_ALPHA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == (sizeof(marisa_alpha::UInt32) + tail.size())); - ASSERT(offsets.size() == keys.size()); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - tail.save("tail-test.dat"); - tail.clear(); - - ASSERT(tail.size() == 0); - ASSERT(tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32)); - - marisa_alpha::Mapper mapper; - tail.mmap(&mapper, "tail-test.dat"); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_ALPHA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32) + tail.size()); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - tail.clear(); - tail.load("tail-test.dat"); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_ALPHA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32) + tail.size()); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - std::stringstream stream; - tail.write(stream); - - tail.clear(); - tail.read(stream); - - ASSERT(tail.size() == 12); - ASSERT(tail.mode() == MARISA_ALPHA_TEXT_TAIL); - ASSERT(!tail.empty()); - ASSERT(tail.total_size() == sizeof(marisa_alpha::UInt32) + tail.size()); - for (marisa_alpha::UInt32 i = 0; i < keys.size(); ++i) { - ASSERT(marisa_alpha::String(reinterpret_cast( - tail[offsets[i]])) == keys[i]); - } - - TEST_END(); -} - -} // namespace - -int main() { - TestBinaryTail(); - TestTextTail(); - - return 0; -} diff --git a/v0_1_5/tests/trie-test.cc b/v0_1_5/tests/trie-test.cc deleted file mode 100644 index f63cf6b..0000000 --- a/v0_1_5/tests/trie-test.cc +++ /dev/null @@ -1,665 +0,0 @@ -#include - -#include - -#include "assert.h" - -namespace { - -class FindCallback { - public: - FindCallback(std::vector *key_ids, - std::vector *key_lengths) - : key_ids_(key_ids), key_lengths_(key_lengths) {} - FindCallback(const FindCallback &callback) - : key_ids_(callback.key_ids_), key_lengths_(callback.key_lengths_) {} - - bool operator()(marisa_alpha::UInt32 key_id, std::size_t key_length) const { - key_ids_->push_back(key_id); - key_lengths_->push_back(key_length); - return true; - } - - private: - std::vector *key_ids_; - std::vector *key_lengths_; - - // Disallows assignment. - FindCallback &operator=(const FindCallback &); -}; - -class PredictCallback { - public: - PredictCallback(std::vector *key_ids, - std::vector *keys) - : key_ids_(key_ids), keys_(keys) {} - PredictCallback(const PredictCallback &callback) - : key_ids_(callback.key_ids_), keys_(callback.keys_) {} - - bool operator()(marisa_alpha::UInt32 key_id, const std::string &key) const { - key_ids_->push_back(key_id); - keys_->push_back(key); - return true; - } - - private: - std::vector *key_ids_; - std::vector *keys_; - - // Disallows assignment. - PredictCallback &operator=(const PredictCallback &); -}; - -void TestTrie() { - TEST_START(); - - marisa_alpha::Trie trie; - - ASSERT(trie.num_tries() == 0); - ASSERT(trie.num_keys() == 0); - ASSERT(trie.num_nodes() == 0); - ASSERT(trie.total_size() == (sizeof(marisa_alpha::UInt32) * 23)); - - std::vector keys; - trie.build(keys); - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 0); - ASSERT(trie.num_nodes() == 1); - - keys.push_back("apple"); - keys.push_back("and"); - keys.push_back("Bad"); - keys.push_back("apple"); - keys.push_back("app"); - - std::vector key_ids; - trie.build(keys, &key_ids, - 1 | MARISA_ALPHA_WITHOUT_TAIL | MARISA_ALPHA_LABEL_ORDER); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 11); - - ASSERT(key_ids.size() == 5); - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 0); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 2); - - char key_buf[256]; - std::size_t key_length; - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.clear(); - - ASSERT(trie.num_tries() == 0); - ASSERT(trie.num_keys() == 0); - ASSERT(trie.num_nodes() == 0); - ASSERT(trie.total_size() == (sizeof(marisa_alpha::UInt32) * 23)); - - trie.build(keys, &key_ids, - 1 | MARISA_ALPHA_WITHOUT_TAIL | MARISA_ALPHA_WEIGHT_ORDER); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 11); - - ASSERT(key_ids.size() == 5); - ASSERT(key_ids[0] == 3); - ASSERT(key_ids[1] == 1); - ASSERT(key_ids[2] == 2); - ASSERT(key_ids[3] == 3); - ASSERT(key_ids[4] == 0); - - for (std::size_t i = 0; i < keys.size(); ++i) { - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - } - - ASSERT(trie["appl"] == trie.notfound()); - ASSERT(trie["applex"] == trie.notfound()); - ASSERT(trie.find_first("ap") == trie.notfound()); - ASSERT(trie.find_first("applex") == trie["app"]); - ASSERT(trie.find_last("ap") == trie.notfound()); - ASSERT(trie.find_last("applex") == trie["apple"]); - - std::vector ids; - ASSERT(trie.find("ap", &ids) == 0); - ASSERT(trie.find("applex", &ids) == 2); - ASSERT(ids.size() == 2); - ASSERT(ids[0] == trie["app"]); - ASSERT(ids[1] == trie["apple"]); - - std::vector lengths; - ASSERT(trie.find("Baddie", &ids, &lengths) == 1); - ASSERT(ids.size() == 3); - ASSERT(ids[2] == trie["Bad"]); - ASSERT(lengths.size() == 1); - ASSERT(lengths[0] == 3); - - ASSERT(trie.find_callback("anderson", FindCallback(&ids, &lengths)) == 1); - ASSERT(ids.size() == 4); - ASSERT(ids[3] == trie["and"]); - ASSERT(lengths.size() == 2); - ASSERT(lengths[1] == 3); - - ASSERT(trie.predict("") == 4); - ASSERT(trie.predict("a") == 3); - ASSERT(trie.predict("ap") == 2); - ASSERT(trie.predict("app") == 2); - ASSERT(trie.predict("appl") == 1); - ASSERT(trie.predict("apple") == 1); - ASSERT(trie.predict("appleX") == 0); - ASSERT(trie.predict("X") == 0); - - ids.clear(); - ASSERT(trie.predict("a", &ids) == 3); - ASSERT(ids.size() == 3); - ASSERT(ids[0] == trie["app"]); - ASSERT(ids[1] == trie["and"]); - ASSERT(ids[2] == trie["apple"]); - - std::vector strs; - ASSERT(trie.predict("a", &ids, &strs) == 3); - ASSERT(ids.size() == 6); - ASSERT(ids[3] == trie["app"]); - ASSERT(ids[4] == trie["apple"]); - ASSERT(ids[5] == trie["and"]); - ASSERT(strs[0] == "app"); - ASSERT(strs[1] == "apple"); - ASSERT(strs[2] == "and"); - - TEST_END(); -} - -void TestPrefixTrie() { - TEST_START(); - - std::vector keys; - keys.push_back("after"); - keys.push_back("bar"); - keys.push_back("car"); - keys.push_back("caster"); - - marisa_alpha::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids, 1 | MARISA_ALPHA_PREFIX_TRIE - | MARISA_ALPHA_TEXT_TAIL | MARISA_ALPHA_LABEL_ORDER); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 7); - - char key_buf[256]; - std::size_t key_length; - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - key_length = trie.restore(key_ids[0], NULL, 0); - - ASSERT(key_length == keys[0].length()); - EXCEPT(trie.restore(key_ids[0], NULL, 5), MARISA_ALPHA_PARAM_ERROR); - - key_length = trie.restore(key_ids[0], key_buf, 5); - - ASSERT(key_length == keys[0].length()); - - key_length = trie.restore(key_ids[0], key_buf, 6); - - ASSERT(key_length == keys[0].length()); - - trie.build(keys, &key_ids, 2 | MARISA_ALPHA_PREFIX_TRIE - | MARISA_ALPHA_WITHOUT_TAIL | MARISA_ALPHA_WEIGHT_ORDER); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 16); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - key_length = trie.restore(key_ids[0], NULL, 0); - - ASSERT(key_length == keys[0].length()); - EXCEPT(trie.restore(key_ids[0], NULL, 5), MARISA_ALPHA_PARAM_ERROR); - - key_length = trie.restore(key_ids[0], key_buf, 5); - - ASSERT(key_length == keys[0].length()); - - key_length = trie.restore(key_ids[0], key_buf, 6); - - ASSERT(key_length == keys[0].length()); - - trie.build(keys, &key_ids, 2 | MARISA_ALPHA_PREFIX_TRIE - | MARISA_ALPHA_TEXT_TAIL | MARISA_ALPHA_LABEL_ORDER); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.save("trie-test.dat"); - trie.clear(); - marisa_alpha::Mapper mapper; - trie.mmap(&mapper, "trie-test.dat"); - - ASSERT(mapper.is_open()); - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - std::stringstream stream; - trie.write(stream); - trie.clear(); - trie.read(stream); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 3 | MARISA_ALPHA_PREFIX_TRIE - | MARISA_ALPHA_WITHOUT_TAIL | MARISA_ALPHA_WEIGHT_ORDER); - - ASSERT(trie.num_tries() == 3); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 19); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - ASSERT(trie["ca"] == trie.notfound()); - ASSERT(trie["card"] == trie.notfound()); - - std::size_t length = 0; - ASSERT(trie.find_first("ca") == trie.notfound()); - ASSERT(trie.find_first("car") == trie["car"]); - ASSERT(trie.find_first("card", &length) == trie["car"]); - ASSERT(length == 3); - - ASSERT(trie.find_last("afte") == trie.notfound()); - ASSERT(trie.find_last("after") == trie["after"]); - ASSERT(trie.find_last("afternoon", &length) == trie["after"]); - ASSERT(length == 5); - - { - std::vector ids; - std::vector lengths; - ASSERT(trie.find("card", &ids, &lengths) == 1); - ASSERT(ids.size() == 1); - ASSERT(ids[0] == trie["car"]); - ASSERT(lengths.size() == 1); - ASSERT(lengths[0] == 3); - - ASSERT(trie.predict("ca", &ids) == 2); - ASSERT(ids.size() == 3); - ASSERT(ids[1] == trie["car"]); - ASSERT(ids[2] == trie["caster"]); - - ASSERT(trie.predict("ca", &ids, NULL, 1) == 1); - ASSERT(ids.size() == 4); - ASSERT(ids[3] == trie["car"]); - - std::vector strs; - ASSERT(trie.predict("ca", &ids, &strs, 1) == 1); - ASSERT(ids.size() == 5); - ASSERT(ids[4] == trie["car"]); - ASSERT(strs.size() == 1); - ASSERT(strs[0] == "car"); - - ASSERT(trie.predict_callback("", PredictCallback(&ids, &strs)) == 4); - ASSERT(ids.size() == 9); - ASSERT(ids[5] == trie["car"]); - ASSERT(ids[6] == trie["caster"]); - ASSERT(ids[7] == trie["after"]); - ASSERT(ids[8] == trie["bar"]); - ASSERT(strs.size() == 5); - ASSERT(strs[1] == "car"); - ASSERT(strs[2] == "caster"); - ASSERT(strs[3] == "after"); - ASSERT(strs[4] == "bar"); - } - - { - marisa_alpha::UInt32 ids[10]; - std::size_t lengths[10]; - ASSERT(trie.find("card", ids, lengths, 10) == 1); - ASSERT(ids[0] == trie["car"]); - ASSERT(lengths[0] == 3); - - ASSERT(trie.predict("ca", ids, NULL, 10) == 2); - ASSERT(ids[0] == trie["car"]); - ASSERT(ids[1] == trie["caster"]); - - ASSERT(trie.predict("ca", ids, NULL, 1) == 1); - ASSERT(ids[0] == trie["car"]); - - std::string strs[10]; - ASSERT(trie.predict("ca", ids, strs, 1) == 1); - ASSERT(ids[0] == trie["car"]); - ASSERT(strs[0] == "car"); - - ASSERT(trie.predict("", ids, strs, 10) == 4); - ASSERT(ids[0] == trie["car"]); - ASSERT(ids[1] == trie["caster"]); - ASSERT(ids[2] == trie["after"]); - ASSERT(ids[3] == trie["bar"]); - ASSERT(strs[0] == "car"); - ASSERT(strs[1] == "caster"); - ASSERT(strs[2] == "after"); - ASSERT(strs[3] == "bar"); - } - - std::string trie_data = stream.str(); - trie.map(trie_data.c_str(), trie_data.length()); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - TEST_END(); -} - -void TestPatriciaTrie() { - TEST_START(); - - std::vector keys; - keys.push_back("bach"); - keys.push_back("bet"); - keys.push_back("chat"); - keys.push_back("check"); - keys.push_back("check"); - - marisa_alpha::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids, 1); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 7); - - ASSERT(key_ids.size() == 5); - ASSERT(key_ids[0] == 2); - ASSERT(key_ids[1] == 3); - ASSERT(key_ids[2] == 1); - ASSERT(key_ids[3] == 0); - ASSERT(key_ids[4] == 0); - - char key_buf[256]; - std::size_t key_length; - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 2 | MARISA_ALPHA_WITHOUT_TAIL); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 17); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 2); - - ASSERT(trie.num_tries() == 2); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 14); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - trie.build(keys, &key_ids, 3 | MARISA_ALPHA_WITHOUT_TAIL); - - ASSERT(trie.num_tries() == 3); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 20); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - std::stringstream stream; - trie.write(stream); - trie.clear(); - trie.read(stream); - - ASSERT(trie.num_tries() == 3); - ASSERT(trie.num_keys() == 4); - ASSERT(trie.num_nodes() == 20); - - for (std::size_t i = 0; i < keys.size(); ++i) { - key_length = trie.restore(key_ids[i], key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[i]] == key_ids[i]); - ASSERT(trie[key_ids[i]] == keys[i]); - ASSERT(key_length == keys[i].length()); - ASSERT(keys[i] == key_buf); - } - - TEST_END(); -} - -void TestEmptyString() { - TEST_START(); - - std::vector keys; - keys.push_back(""); - - marisa_alpha::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 1); - - ASSERT(key_ids.size() == 1); - ASSERT(key_ids[0] == 0); - - ASSERT(trie[""] == 0); - ASSERT(trie[(marisa_alpha::UInt32)0] == ""); - - ASSERT(trie["x"] == trie.notfound()); - ASSERT(trie.find_first("") == 0); - ASSERT(trie.find_first("x") == 0); - ASSERT(trie.find_last("") == 0); - ASSERT(trie.find_last("x") == 0); - - std::vector ids; - ASSERT(trie.find("xyz", &ids) == 1); - ASSERT(ids.size() == 1); - ASSERT(ids[0] == trie[""]); - - std::vector lengths; - ASSERT(trie.find("xyz", &ids, &lengths) == 1); - ASSERT(ids.size() == 2); - ASSERT(ids[0] == trie[""]); - ASSERT(ids[1] == trie[""]); - ASSERT(lengths.size() == 1); - ASSERT(lengths[0] == 0); - - ASSERT(trie.find_callback("xyz", FindCallback(&ids, &lengths)) == 1); - ASSERT(ids.size() == 3); - ASSERT(ids[2] == trie[""]); - ASSERT(lengths.size() == 2); - ASSERT(lengths[1] == 0); - - ASSERT(trie.predict("xyz", &ids) == 0); - - ASSERT(trie.predict("", &ids) == 1); - ASSERT(ids.size() == 4); - ASSERT(ids[3] == trie[""]); - - std::vector strs; - ASSERT(trie.predict("", &ids, &strs) == 1); - ASSERT(ids.size() == 5); - ASSERT(ids[4] == trie[""]); - ASSERT(strs[0] == ""); - - TEST_END(); -} - -void TestBinaryKey() { - TEST_START(); - - std::string binary_key = "NP"; - binary_key += '\0'; - binary_key += "Trie"; - - std::vector keys; - keys.push_back(binary_key); - - marisa_alpha::Trie trie; - std::vector key_ids; - trie.build(keys, &key_ids, 1 | MARISA_ALPHA_WITHOUT_TAIL); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 8); - ASSERT(key_ids.size() == 1); - - char key_buf[256]; - std::size_t key_length; - key_length = trie.restore(0, key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[0]] == key_ids[0]); - ASSERT(trie[key_ids[0]] == keys[0]); - ASSERT(std::string(key_buf, key_length) == keys[0]); - - trie.build(keys, &key_ids, - 1 | MARISA_ALPHA_PREFIX_TRIE | MARISA_ALPHA_BINARY_TAIL); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 2); - ASSERT(key_ids.size() == 1); - - key_length = trie.restore(0, key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[0]] == key_ids[0]); - ASSERT(trie[key_ids[0]] == keys[0]); - ASSERT(std::string(key_buf, key_length) == keys[0]); - - trie.build(keys, &key_ids, - 1 | MARISA_ALPHA_PREFIX_TRIE | MARISA_ALPHA_TEXT_TAIL); - - ASSERT(trie.num_tries() == 1); - ASSERT(trie.num_keys() == 1); - ASSERT(trie.num_nodes() == 2); - ASSERT(key_ids.size() == 1); - - key_length = trie.restore(0, key_buf, sizeof(key_buf)); - - ASSERT(trie[keys[0]] == key_ids[0]); - ASSERT(trie[key_ids[0]] == keys[0]); - ASSERT(std::string(key_buf, key_length) == keys[0]); - - std::vector ids; - ASSERT(trie.predict_breadth_first("", &ids) == 1); - ASSERT(ids.size() == 1); - ASSERT(ids[0] == key_ids[0]); - - std::vector strs; - ASSERT(trie.predict_depth_first("NP", &ids, &strs) == 1); - ASSERT(ids.size() == 2); - ASSERT(ids[1] == key_ids[0]); - ASSERT(strs[0] == keys[0]); - - TEST_END(); -} - -} // namespace - -int main() { - TestTrie(); - TestPrefixTrie(); - TestPatriciaTrie(); - TestEmptyString(); - TestBinaryKey(); - - return 0; -} diff --git a/v0_1_5/tests/unit-test.cc b/v0_1_5/tests/unit-test.cc deleted file mode 100644 index 37225fc..0000000 --- a/v0_1_5/tests/unit-test.cc +++ /dev/null @@ -1,463 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "assert.h" - -namespace { - -void TestBase() { - TEST_START(); - - ASSERT(sizeof(marisa_alpha_uint8) == 1); - ASSERT(sizeof(marisa_alpha_uint16) == 2); - ASSERT(sizeof(marisa_alpha_uint32) == 4); - ASSERT(sizeof(marisa_alpha_uint64) == 8); - - ASSERT(MARISA_ALPHA_UINT8_MAX == 0xFFU); - ASSERT(MARISA_ALPHA_UINT16_MAX == 0xFFFFU); - ASSERT(MARISA_ALPHA_UINT32_MAX == 0xFFFFFFFFU); - ASSERT(MARISA_ALPHA_UINT64_MAX == 0xFFFFFFFFFFFFFFFFULL); - - ASSERT(sizeof(marisa_alpha::UInt8) == 1); - ASSERT(sizeof(marisa_alpha::UInt16) == 2); - ASSERT(sizeof(marisa_alpha::UInt32) == 4); - ASSERT(sizeof(marisa_alpha::UInt64) == 8); - - int x = 100, y = 200; - marisa_alpha::Swap(&x, &y); - ASSERT(x == 200); - ASSERT(y == 100); - - EXCEPT(marisa_alpha::Swap(static_cast(NULL), &y), - MARISA_ALPHA_PARAM_ERROR); - EXCEPT(marisa_alpha::Swap(&x, static_cast(NULL)), - MARISA_ALPHA_PARAM_ERROR); - - TEST_END(); -} - -marisa_alpha::UInt32 NaivePopCount(marisa_alpha::UInt32 x) { - marisa_alpha::UInt32 count = 0; - while (x) { - count += x & 1; - x >>= 1; - } - return count; -} - -void TestPopCount() { - TEST_START(); - - ASSERT(marisa_alpha::PopCount(0).lo8() == 0); - ASSERT(marisa_alpha::PopCount(0).lo16() == 0); - ASSERT(marisa_alpha::PopCount(0).lo24() == 0); - ASSERT(marisa_alpha::PopCount(0).lo32() == 0); - - ASSERT(marisa_alpha::PopCount(0xFFFFFFFFU).lo8() == 8); - ASSERT(marisa_alpha::PopCount(0xFFFFFFFFU).lo16() == 16); - ASSERT(marisa_alpha::PopCount(0xFFFFFFFFU).lo24() == 24); - ASSERT(marisa_alpha::PopCount(0xFFFFFFFFU).lo32() == 32); - - for (std::size_t i = 0; i < 1024; ++i) { - marisa_alpha::UInt32 value = std::rand(); - marisa_alpha::PopCount popcount(value); - ASSERT(popcount.lo8() == NaivePopCount(value & 0xFFU)); - ASSERT(popcount.lo16() == NaivePopCount(value & 0xFFFFU)); - ASSERT(popcount.lo24() == NaivePopCount(value & 0xFFFFFFU)); - ASSERT(popcount.lo32() == NaivePopCount(value)); - } - - TEST_END(); -} - -void TestRank() { - TEST_START(); - - marisa_alpha::Rank rank; - - ASSERT(rank.abs() == 0); - ASSERT(rank.rel1() == 0); - ASSERT(rank.rel2() == 0); - ASSERT(rank.rel3() == 0); - ASSERT(rank.rel4() == 0); - ASSERT(rank.rel5() == 0); - ASSERT(rank.rel6() == 0); - ASSERT(rank.rel7() == 0); - - rank.set_abs(0xFFFFFFFFU); - rank.set_rel1(64); - rank.set_rel2(128); - rank.set_rel3(192); - rank.set_rel4(256); - rank.set_rel5(320); - rank.set_rel6(384); - rank.set_rel7(448); - - ASSERT(rank.abs() == 0xFFFFFFFFU); - ASSERT(rank.rel1() == 64); - ASSERT(rank.rel2() == 128); - ASSERT(rank.rel3() == 192); - ASSERT(rank.rel4() == 256); - ASSERT(rank.rel5() == 320); - ASSERT(rank.rel6() == 384); - ASSERT(rank.rel7() == 448); - - TEST_END(); -} - -void TestString() { - TEST_START(); - - marisa_alpha::String str; - - ASSERT(str.ptr() == NULL); - ASSERT(str.length() == 0); - - marisa_alpha::RString rstr; - - ASSERT(rstr.ptr() == NULL); - ASSERT(rstr.length() == 0); - - const char *s = "ab"; - str = marisa_alpha::String(s); - - ASSERT(str.ptr() == s); - ASSERT(str.length() == 2); - ASSERT(str[0] == s[0]); - ASSERT(str[1] == s[1]); - - rstr = marisa_alpha::RString(str); - ASSERT(rstr.ptr() == s); - ASSERT(rstr.length() == 2); - ASSERT(rstr[0] == s[1]); - ASSERT(rstr[1] == s[0]); - - std::string s2 = "xyz"; - str = marisa_alpha::String(s2.c_str(), s2.length()); - - ASSERT(str.ptr() == s2.c_str()); - ASSERT(str.length() == 3); - ASSERT(str[0] == s2[0]); - ASSERT(str[1] == s2[1]); - ASSERT(str[2] == s2[2]); - - ASSERT(str.substr(0, 2).length() == 2); - ASSERT(str.substr(0, 2)[0] == 'x'); - ASSERT(str.substr(0, 2)[1] == 'y'); - - rstr = marisa_alpha::RString(str); - - ASSERT(rstr.ptr() == s2.c_str()); - ASSERT(rstr.length() == 3); - ASSERT(rstr[0] == s2[2]); - ASSERT(rstr[1] == s2[1]); - ASSERT(rstr[2] == s2[0]); - - ASSERT(rstr.substr(1, 2).length() == 2); - ASSERT(rstr.substr(1, 2)[0] == 'y'); - ASSERT(rstr.substr(1, 2)[1] == 'x'); - - ASSERT(marisa_alpha::String("abc") == marisa_alpha::String("abc")); - ASSERT(marisa_alpha::String("abc") != marisa_alpha::String("bcd")); - ASSERT(marisa_alpha::String("abc") < marisa_alpha::String("bcd")); - ASSERT(marisa_alpha::String("ab") < marisa_alpha::String("abc")); - ASSERT(marisa_alpha::String("bcd") > marisa_alpha::String("abc")); - ASSERT(marisa_alpha::String("abc") > marisa_alpha::String("ab")); - - ASSERT(marisa_alpha::String("abcde").substr(1, 2) == - marisa_alpha::String("bc")); - - TEST_END(); -} - -void TestKey() { - TEST_START(); - - marisa_alpha::Key key; - - ASSERT(key.str().length() == 0); - ASSERT(key.weight() == 0.0); - ASSERT(key.id() == 0); - ASSERT(key.terminal() == 0); - - key.set_str(marisa_alpha::String("abc")); - key.set_weight(1.0); - key.set_id(2); - key.set_terminal(3); - - ASSERT(key.str() == marisa_alpha::String("abc")); - ASSERT(key.weight() == 1.0); - ASSERT(key.id() == 2); - ASSERT(key.terminal() == 3); - - marisa_alpha::String str("string"); - marisa_alpha::Key rkey; - - ASSERT(rkey.str().length() == 0); - ASSERT(rkey.weight() == 0.0); - ASSERT(rkey.id() == 0); - ASSERT(rkey.terminal() == 0); - - rkey.set_str(marisa_alpha::RString(str)); - rkey.set_weight(4.0); - rkey.set_id(5); - rkey.set_terminal(6); - - ASSERT(rkey.str() == marisa_alpha::RString(str)); - ASSERT(rkey.weight() == 4.0); - ASSERT(rkey.id() == 5); - ASSERT(rkey.terminal() == 6); - - TEST_END(); -} -void TestProgress() { - TEST_START(); - - { - marisa_alpha::Progress progress(0); - - ASSERT(progress.is_valid()); - while (!progress.is_last()) { - ++progress; - } - ASSERT(progress.is_last()); - ASSERT(progress.flags() == MARISA_ALPHA_DEFAULT_FLAGS); - ASSERT(progress.trie_id() == progress.num_tries() - 1); - ASSERT(progress.total_size() == 0); - - progress.test_total_size(0); - progress.test_total_size(1); - EXCEPT(progress.test_total_size(MARISA_ALPHA_UINT32_MAX), - MARISA_ALPHA_SIZE_ERROR); - progress.test_total_size(MARISA_ALPHA_UINT32_MAX - 1); - progress.test_total_size(0); - EXCEPT(progress.test_total_size(1), MARISA_ALPHA_SIZE_ERROR); - - ASSERT(progress.num_tries() == MARISA_ALPHA_DEFAULT_NUM_TRIES); - ASSERT(progress.trie() == MARISA_ALPHA_DEFAULT_TRIE); - ASSERT(progress.tail() == MARISA_ALPHA_DEFAULT_TAIL); - ASSERT(progress.order() == MARISA_ALPHA_DEFAULT_ORDER); - } - - { - marisa_alpha::Progress progress(MARISA_ALPHA_DEFAULT_FLAGS); - - ASSERT(progress.is_valid()); - ASSERT(!progress.is_last()); - ASSERT(progress.num_tries() == MARISA_ALPHA_DEFAULT_NUM_TRIES); - ASSERT(progress.trie() == MARISA_ALPHA_DEFAULT_TRIE); - ASSERT(progress.tail() == MARISA_ALPHA_DEFAULT_TAIL); - ASSERT(progress.order() == MARISA_ALPHA_DEFAULT_ORDER); - } - - { - marisa_alpha::Progress progress(255 | MARISA_ALPHA_PREFIX_TRIE - | MARISA_ALPHA_BINARY_TAIL | MARISA_ALPHA_LABEL_ORDER); - - ASSERT(progress.is_valid()); - ASSERT(!progress.is_last()); - ASSERT(progress.num_tries() == 255); - ASSERT(progress.trie() == MARISA_ALPHA_PREFIX_TRIE); - ASSERT(progress.tail() == MARISA_ALPHA_BINARY_TAIL); - ASSERT(progress.order() == MARISA_ALPHA_LABEL_ORDER); - } - - { - marisa_alpha::Progress progress(~MARISA_ALPHA_FLAGS_MASK); - - ASSERT(!progress.is_valid()); - } - - TEST_END(); -} - -void TestRange() { - TEST_START(); - - marisa_alpha::Range range; - - ASSERT(range.begin() == 0); - ASSERT(range.end() == 0); - ASSERT(range.pos() == 0); - - range.set_begin(1); - range.set_end(2); - range.set_pos(3); - - ASSERT(range.begin() == 1); - ASSERT(range.end() == 2); - ASSERT(range.pos() == 3); - - marisa_alpha::WRange wrange; - - ASSERT(wrange.range().begin() == 0); - ASSERT(wrange.range().end() == 0); - ASSERT(wrange.range().pos() == 0); - - ASSERT(wrange.begin() == 0); - ASSERT(wrange.end() == 0); - ASSERT(wrange.pos() == 0); - ASSERT(wrange.weight() == 0.0); - - wrange = marisa_alpha::WRange(range, 4.0); - - ASSERT(wrange.range().begin() == 1); - ASSERT(wrange.range().end() == 2); - ASSERT(wrange.range().pos() == 3); - - ASSERT(wrange.begin() == 1); - ASSERT(wrange.end() == 2); - ASSERT(wrange.pos() == 3); - ASSERT(wrange.weight() == 4.0); - - wrange.set_begin(5); - wrange.set_end(6); - wrange.set_pos(7); - wrange.set_weight(8.0); - - ASSERT(wrange.begin() == 5); - ASSERT(wrange.end() == 6); - ASSERT(wrange.pos() == 7); - ASSERT(wrange.weight() == 8.0); - - TEST_END(); -} - -void TestQuery() { - TEST_START(); - - marisa_alpha::Query query("abc", 3); - - ASSERT(query[0] == 'a'); - ASSERT(!query.ends_at(0)); - - ASSERT(query[1] == 'b'); - ASSERT(!query.ends_at(1)); - - ASSERT(query[2] == 'c'); - ASSERT(!query.ends_at(2)); - - ASSERT(query.ends_at(3)); - - std::string str("str"); - - query.insert(&str); - ASSERT(str == "abcstr"); - - marisa_alpha::CQuery cquery("xyz"); - - ASSERT(cquery[0] == 'x'); - ASSERT(!cquery.ends_at(0)); - - ASSERT(cquery[1] == 'y'); - ASSERT(!cquery.ends_at(1)); - - ASSERT(cquery[2] == 'z'); - ASSERT(!cquery.ends_at(2)); - - ASSERT(cquery.ends_at(3)); - - cquery.insert(&str); - ASSERT(str == "xyzabcstr"); - - TEST_END(); -} - -void TestContainer() { - TEST_START(); - - int array[1024]; - marisa_alpha::Container array_container(array); - - ASSERT(array_container.is_valid()); - for (int i = 0; i < 1024; ++i) { - int value = std::rand(); - array_container.insert(i, value); - ASSERT(array[i] == value); - } - - marisa_alpha::Container array_container2(NULL); - - ASSERT(!array_container2.is_valid()); - - std::vector vec; - marisa_alpha::Container *> vec_container(&vec); - - ASSERT(vec_container.is_valid()); - for (int i = 0; i < 1024; ++i) { - int value = std::rand(); - vec_container.insert(i, value); - ASSERT(vec.back() == value); - ASSERT(vec[i] == value); - } - ASSERT(vec.size() == 1024); - - marisa_alpha::Container *> vec_container2(&vec); - - ASSERT(vec_container2.is_valid()); - for (int i = 0; i < 1024; ++i) { - int value = std::rand(); - vec_container2.insert(i, value); - ASSERT(vec.back() == value); - ASSERT(vec[i + 1024] == value); - } - ASSERT(vec.size() == 2048); - - marisa_alpha::Container *> vec_container3(NULL); - ASSERT(!vec_container3.is_valid()); - - TEST_END(); -} - -void TestCell() { - TEST_START(); - - marisa_alpha::Cell cell; - - ASSERT(cell.louds_pos() == 0); - ASSERT(cell.node() == 0); - ASSERT(cell.key_id() == 0); - ASSERT(cell.length() == 0); - - cell.set_louds_pos(1); - cell.set_node(2); - cell.set_key_id(3); - cell.set_length(4); - - ASSERT(cell.louds_pos() == 1); - ASSERT(cell.node() == 2); - ASSERT(cell.key_id() == 3); - ASSERT(cell.length() == 4); - - TEST_END(); -} - -} // namespace - -int main() { - std::srand((unsigned int)time(NULL)); - - TestBase(); - TestPopCount(); - TestRank(); - TestString(); - TestKey(); - TestProgress(); - TestRange(); - TestQuery(); - TestContainer(); - TestCell(); - - return 0; -} diff --git a/v0_1_5/tests/vector-test.cc b/v0_1_5/tests/vector-test.cc deleted file mode 100644 index fd517ad..0000000 --- a/v0_1_5/tests/vector-test.cc +++ /dev/null @@ -1,303 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "assert.h" - -namespace { - -void TestVector() { - TEST_START(); - - std::vector values; - for (std::size_t i = 0; i < 1000; ++i) { - values.push_back(std::rand()); - } - - marisa_alpha::Vector vec; - - ASSERT(vec.max_size() == MARISA_ALPHA_UINT32_MAX); - ASSERT(vec.size() == 0); - ASSERT(vec.capacity() == 0); - ASSERT(!vec.fixed()); - ASSERT(vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32)); - - for (std::size_t i = 0; i < values.size(); ++i) { - vec.push_back(values[i]); - ASSERT(vec[i] == values[i]); - ASSERT(static_cast &>(vec)[i] == - values[i]); - } - - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() >= vec.size()); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32) - + ((sizeof(int) * values.size()))); - - ASSERT(static_cast &>(vec).front() - == values.front()); - ASSERT(static_cast &>(vec).back() - == values.back()); - ASSERT(vec.front() == values.front()); - ASSERT(vec.back() == values.back()); - - vec.shrink(); - - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() == vec.size()); - for (std::size_t i = 0; i < values.size(); ++i) { - ASSERT(vec[i] == values[i]); - ASSERT(static_cast &>(vec)[i] == - values[i]); - } - - vec.save("vector-test.dat"); - vec.clear(); - - ASSERT(vec.empty()); - ASSERT(vec.capacity() == 0); - - marisa_alpha::Mapper mapper; - vec.mmap(&mapper, "vector-test.dat"); - - ASSERT(mapper.is_open()); - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() == 0); - ASSERT(vec.fixed()); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32) - + ((sizeof(int) * values.size()))); - - for (std::size_t i = 0; i < values.size(); ++i) { - ASSERT(static_cast &>(vec)[i] == - values[i]); - } - - vec.clear(); - vec.load("vector-test.dat"); - - ASSERT(vec.size() == values.size()); - ASSERT(vec.capacity() == vec.size()); - ASSERT(!vec.fixed()); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32) - + ((sizeof(int) * values.size()))); - - for (std::size_t i = 0; i < values.size(); ++i) { - ASSERT(vec[i] == values[i]); - ASSERT(static_cast &>(vec)[i] == - values[i]); - } - - vec.clear(); - - vec.push_back(0); - ASSERT(vec.capacity() == 1); - vec.push_back(1); - ASSERT(vec.capacity() == 2); - vec.push_back(2); - ASSERT(vec.capacity() == 4); - vec.resize(5); - ASSERT(vec.capacity() == 8); - vec.resize(100); - ASSERT(vec.capacity() == 100); - - vec.fix(); - ASSERT(vec.fixed()); - EXCEPT(vec.fix(), MARISA_ALPHA_STATE_ERROR); - EXCEPT(vec.push_back(0), MARISA_ALPHA_STATE_ERROR); - EXCEPT(vec.resize(0), MARISA_ALPHA_STATE_ERROR); - EXCEPT(vec.reserve(0), MARISA_ALPHA_STATE_ERROR); - - TEST_END(); -} - -void TestIntVector() { - TEST_START(); - - marisa_alpha::IntVector vec; - - ASSERT(vec.num_bits_per_int() == 0); - ASSERT(vec.mask() == 0); - ASSERT(vec.size() == 0); - ASSERT(vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32) * 4); - - marisa_alpha::Vector values; - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 1); - ASSERT(vec.mask() == 1); - ASSERT(vec.size() == 0); - ASSERT(vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32) * 4); - - values.push_back(0); - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 1); - ASSERT(vec.mask() == 1); - ASSERT(vec.size() == 1); - ASSERT(!vec.empty()); - ASSERT(vec.total_size() == sizeof(marisa_alpha::UInt32) * 5); - ASSERT(vec[0] == 0); - - values.push_back(255); - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 8); - ASSERT(vec.mask() == 0xFF); - ASSERT(vec.size() == 2); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - - values.push_back(65536); - vec.build(values); - - ASSERT(vec.num_bits_per_int() == 17); - ASSERT(vec.mask() == 0x1FFFF); - ASSERT(vec.size() == 3); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - ASSERT(vec[2] == 65536); - - vec.save("vector-test.dat"); - vec.clear(); - - ASSERT(vec.num_bits_per_int() == 0); - ASSERT(vec.mask() == 0); - ASSERT(vec.size() == 0); - - marisa_alpha::Mapper mapper; - vec.mmap(&mapper, "vector-test.dat"); - - ASSERT(mapper.is_open()); - ASSERT(vec.num_bits_per_int() == 17); - ASSERT(vec.mask() == 0x1FFFF); - ASSERT(vec.size() == 3); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - ASSERT(vec[2] == 65536); - - vec.clear(); - vec.load("vector-test.dat"); - - ASSERT(vec.num_bits_per_int() == 17); - ASSERT(vec.mask() == 0x1FFFF); - ASSERT(vec.size() == 3); - ASSERT(vec[0] == 0); - ASSERT(vec[1] == 255); - ASSERT(vec[2] == 65536); - - values.clear(); - for (std::size_t i = 0; i < 500; ++i) { - values.push_back(std::rand()); - } - vec.build(values); - - ASSERT(vec.size() == values.size()); - for (std::size_t i = 0; i < vec.size(); ++i) { - ASSERT(vec[i] == values[i]); - } - - TEST_END(); -} - -void TestBitVector(marisa_alpha::UInt32 size) { - marisa_alpha::BitVector bv; - - ASSERT(bv.size() == 0); - ASSERT(bv.empty()); - ASSERT(bv.total_size() == sizeof(marisa_alpha::UInt32) * 5); - - std::vector bits(size); - std::vector zeros, ones; - for (marisa_alpha::UInt32 i = 0; i < size; ++i) { - const bool bit = (std::rand() % 2) == 0; - bits[i] = bit; - bv.push_back(bit); - (bit ? ones : zeros).push_back(i); - ASSERT(bv[i] == bits[i]); - } - - ASSERT(bv.size() == bits.size()); - ASSERT((size == 0) || !bv.empty()); - - bv.build(); - - marisa_alpha::UInt32 num_zeros = 0, num_ones = 0; - for (marisa_alpha::UInt32 i = 0; i < bits.size(); ++i) { - ASSERT(bv[i] == bits[i]); - ASSERT(bv.rank0(i) == num_zeros); - ASSERT(bv.rank1(i) == num_ones); - ++(bv[i] ? num_ones : num_zeros); - } - for (marisa_alpha::UInt32 i = 0; i < zeros.size(); ++i) { - ASSERT(bv.select0(i) == zeros[i]); - } - for (marisa_alpha::UInt32 i = 0; i < ones.size(); ++i) { - ASSERT(bv.select1(i) == ones[i]); - } - - std::stringstream stream; - bv.write(stream); - bv.clear(); - - ASSERT(bv.size() == 0); - ASSERT(bv.empty()); - ASSERT(bv.total_size() == sizeof(marisa_alpha::UInt32) * 5); - - bv.read(stream); - - ASSERT(bv.size() == bits.size()); - - num_zeros = 0, num_ones = 0; - for (marisa_alpha::UInt32 i = 0; i < bits.size(); ++i) { - ASSERT(bv[i] == bits[i]); - ASSERT(bv.rank0(i) == num_zeros); - ASSERT(bv.rank1(i) == num_ones); - ++(bv[i] ? num_ones : num_zeros); - } - for (marisa_alpha::UInt32 i = 0; i < zeros.size(); ++i) { - ASSERT(bv.select0(i) == zeros[i]); - } - for (marisa_alpha::UInt32 i = 0; i < ones.size(); ++i) { - ASSERT(bv.select1(i) == ones[i]); - } -} - -void TestBitVector() { - TEST_START(); - - TestBitVector(0); - TestBitVector(1); - TestBitVector(511); - TestBitVector(512); - TestBitVector(513); - - for (marisa_alpha::UInt32 i = 0; i < 100; ++i) { - TestBitVector(std::rand() % 4096); - } - - TEST_END(); -} - -} // namespace - -int main() { - std::srand((unsigned int)time(NULL)); - - TestVector(); - TestIntVector(); - TestBitVector(); - - return 0; -} diff --git a/v0_1_5/tools/Makefile.am b/v0_1_5/tools/Makefile.am deleted file mode 100644 index a22cec8..0000000 --- a/v0_1_5/tools/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -AM_CFLAGS = -Wall -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -I../lib - -bin_PROGRAMS = \ - marisa_alpha-build \ - marisa_alpha-lookup \ - marisa_alpha-find \ - marisa_alpha-predict \ - marisa_alpha-benchmark - -noinst_HEADERS = cmdopt.h - -marisa_alpha_build_SOURCES = marisa_alpha-build.cc cmdopt.c -marisa_alpha_build_LDADD = ../lib/libmarisa_alpha.la - -marisa_alpha_lookup_SOURCES = marisa_alpha-lookup.cc cmdopt.c -marisa_alpha_lookup_LDADD = ../lib/libmarisa_alpha.la - -marisa_alpha_find_SOURCES = marisa_alpha-find.cc cmdopt.c -marisa_alpha_find_LDADD = ../lib/libmarisa_alpha.la - -marisa_alpha_predict_SOURCES = marisa_alpha-predict.cc cmdopt.c -marisa_alpha_predict_LDADD = ../lib/libmarisa_alpha.la - -marisa_alpha_benchmark_SOURCES = marisa_alpha-benchmark.cc cmdopt.c -marisa_alpha_benchmark_LDADD = ../lib/libmarisa_alpha.la diff --git a/v0_1_5/tools/Makefile.in b/v0_1_5/tools/Makefile.in deleted file mode 100644 index 98e2278..0000000 --- a/v0_1_5/tools/Makefile.in +++ /dev/null @@ -1,599 +0,0 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -bin_PROGRAMS = marisa_alpha-build$(EXEEXT) \ - marisa_alpha-lookup$(EXEEXT) marisa_alpha-find$(EXEEXT) \ - marisa_alpha-predict$(EXEEXT) marisa_alpha-benchmark$(EXEEXT) -subdir = tools -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -PROGRAMS = $(bin_PROGRAMS) -am_marisa_alpha_benchmark_OBJECTS = marisa_alpha-benchmark.$(OBJEXT) \ - cmdopt.$(OBJEXT) -marisa_alpha_benchmark_OBJECTS = $(am_marisa_alpha_benchmark_OBJECTS) -marisa_alpha_benchmark_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_marisa_alpha_build_OBJECTS = marisa_alpha-build.$(OBJEXT) \ - cmdopt.$(OBJEXT) -marisa_alpha_build_OBJECTS = $(am_marisa_alpha_build_OBJECTS) -marisa_alpha_build_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_marisa_alpha_find_OBJECTS = marisa_alpha-find.$(OBJEXT) \ - cmdopt.$(OBJEXT) -marisa_alpha_find_OBJECTS = $(am_marisa_alpha_find_OBJECTS) -marisa_alpha_find_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_marisa_alpha_lookup_OBJECTS = marisa_alpha-lookup.$(OBJEXT) \ - cmdopt.$(OBJEXT) -marisa_alpha_lookup_OBJECTS = $(am_marisa_alpha_lookup_OBJECTS) -marisa_alpha_lookup_DEPENDENCIES = ../lib/libmarisa_alpha.la -am_marisa_alpha_predict_OBJECTS = marisa_alpha-predict.$(OBJEXT) \ - cmdopt.$(OBJEXT) -marisa_alpha_predict_OBJECTS = $(am_marisa_alpha_predict_OBJECTS) -marisa_alpha_predict_DEPENDENCIES = ../lib/libmarisa_alpha.la -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(marisa_alpha_benchmark_SOURCES) \ - $(marisa_alpha_build_SOURCES) $(marisa_alpha_find_SOURCES) \ - $(marisa_alpha_lookup_SOURCES) $(marisa_alpha_predict_SOURCES) -DIST_SOURCES = $(marisa_alpha_benchmark_SOURCES) \ - $(marisa_alpha_build_SOURCES) $(marisa_alpha_find_SOURCES) \ - $(marisa_alpha_lookup_SOURCES) $(marisa_alpha_predict_SOURCES) -HEADERS = $(noinst_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POW_LIB = @POW_LIB@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CFLAGS = -Wall -I../lib -AM_CXXFLAGS = -Wall -Weffc++ -I../lib -noinst_HEADERS = cmdopt.h -marisa_alpha_build_SOURCES = marisa_alpha-build.cc cmdopt.c -marisa_alpha_build_LDADD = ../lib/libmarisa_alpha.la -marisa_alpha_lookup_SOURCES = marisa_alpha-lookup.cc cmdopt.c -marisa_alpha_lookup_LDADD = ../lib/libmarisa_alpha.la -marisa_alpha_find_SOURCES = marisa_alpha-find.cc cmdopt.c -marisa_alpha_find_LDADD = ../lib/libmarisa_alpha.la -marisa_alpha_predict_SOURCES = marisa_alpha-predict.cc cmdopt.c -marisa_alpha_predict_LDADD = ../lib/libmarisa_alpha.la -marisa_alpha_benchmark_SOURCES = marisa_alpha-benchmark.cc cmdopt.c -marisa_alpha_benchmark_LDADD = ../lib/libmarisa_alpha.la -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .cc .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu tools/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p || test -f $$p1; \ - then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(bindir)" && rm -f $$files - -clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -marisa_alpha-benchmark$(EXEEXT): $(marisa_alpha_benchmark_OBJECTS) $(marisa_alpha_benchmark_DEPENDENCIES) $(EXTRA_marisa_alpha_benchmark_DEPENDENCIES) - @rm -f marisa_alpha-benchmark$(EXEEXT) - $(CXXLINK) $(marisa_alpha_benchmark_OBJECTS) $(marisa_alpha_benchmark_LDADD) $(LIBS) -marisa_alpha-build$(EXEEXT): $(marisa_alpha_build_OBJECTS) $(marisa_alpha_build_DEPENDENCIES) $(EXTRA_marisa_alpha_build_DEPENDENCIES) - @rm -f marisa_alpha-build$(EXEEXT) - $(CXXLINK) $(marisa_alpha_build_OBJECTS) $(marisa_alpha_build_LDADD) $(LIBS) -marisa_alpha-find$(EXEEXT): $(marisa_alpha_find_OBJECTS) $(marisa_alpha_find_DEPENDENCIES) $(EXTRA_marisa_alpha_find_DEPENDENCIES) - @rm -f marisa_alpha-find$(EXEEXT) - $(CXXLINK) $(marisa_alpha_find_OBJECTS) $(marisa_alpha_find_LDADD) $(LIBS) -marisa_alpha-lookup$(EXEEXT): $(marisa_alpha_lookup_OBJECTS) $(marisa_alpha_lookup_DEPENDENCIES) $(EXTRA_marisa_alpha_lookup_DEPENDENCIES) - @rm -f marisa_alpha-lookup$(EXEEXT) - $(CXXLINK) $(marisa_alpha_lookup_OBJECTS) $(marisa_alpha_lookup_LDADD) $(LIBS) -marisa_alpha-predict$(EXEEXT): $(marisa_alpha_predict_OBJECTS) $(marisa_alpha_predict_DEPENDENCIES) $(EXTRA_marisa_alpha_predict_DEPENDENCIES) - @rm -f marisa_alpha-predict$(EXEEXT) - $(CXXLINK) $(marisa_alpha_predict_OBJECTS) $(marisa_alpha_predict_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmdopt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa_alpha-benchmark.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa_alpha-build.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa_alpha-find.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa_alpha-lookup.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marisa_alpha-predict.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -.cc.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cc.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cc.lo: -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-binPROGRAMS - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-libtool ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-binPROGRAMS - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/v0_1_5/tools/cmdopt.c b/v0_1_5/tools/cmdopt.c deleted file mode 100644 index 468d0fe..0000000 --- a/v0_1_5/tools/cmdopt.c +++ /dev/null @@ -1,298 +0,0 @@ -#include - -#include "cmdopt.h" - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -// Moves `optind' to the end and shifts other arguments. -static void cmdopt_shift(cmdopt_t *h) { - int i; - char *tmp; - - tmp = h->argv[h->optind]; - for (i = h->optind; i < h->argc - 1; i++) { - h->argv[i] = h->argv[i + 1]; - } - h->argv[i] = tmp; - - h->nextchar = NULL; - h->optnum--; -} - -// Moves to the next argument. -static void cmdopt_next(cmdopt_t *h) { - h->optind++; - h->nextchar = NULL; -} - -// Checks if the current argument is an option or not. -static int cmdopt_check(cmdopt_t *h) { - int ret = 1; - const char *arg = h->argv[h->optind]; - - if (*arg++ != '-') { - return 0; - } - - if (*arg == '-') { - arg++; - ret++; - } - - return ret - (*arg == '\0'); -} - -// Gets an argument of the current option. -static void cmdopt_getopt(cmdopt_t *h) { - // Moves to the next argument if the current argument has no more characters. - if (*h->nextchar == '\0') { - cmdopt_next(h); - h->nextchar = h->argv[h->optind]; - } - - // Checks whether the current option has an argument or not. - if (h->optind < h->optnum) { - h->optarg = h->nextchar; - cmdopt_next(h); - } else { - h->optarg = NULL; - } -} - -// Searches an option. -static int cmdopt_search(cmdopt_t *h) { - const char *ptr; - - // Updates an option character. - h->optopt = *h->nextchar++; - - for (ptr = h->optstring; *ptr != '\0'; ptr++) { - if (*ptr == h->optopt) { - // Gets an option argument if required. - if (ptr[1] == ':') { - cmdopt_getopt(h); - - // Returns ':' if there is no argument. - if (h->optarg == NULL && ptr[2] != ':') { - return ':'; - } - } - return h->optopt; - } - } - - if (h->optopt == '-') { - cmdopt_next(h); - while (h->optind < h->optnum) { - cmdopt_shift(h); - } - return -1; - } - - // Returns '?' if the option character is undefined. - return '?'; -} - -// Compares a long option with an argument and returns the length of the -// matched prefix. -static int cmdopt_match_len(const char *opt, const char *arg) { - int len = 0; - - // Returns 0 if there is a mismatch. - while ((*arg != '\0') && (*arg != '=')) { - if (*arg++ != *opt++) { - return 0; - } - len++; - } - - // Returns a negative value in case of a perfect match. - if ((*arg == '\0') || (*arg == '=')) { - return -len; - } - - return len; -} - -// Checks long options. -static int cmdopt_match(cmdopt_t *h) { - int i, len; - int max = 0, max_optind = -1; - - // Returns -1 if there are no long options. - if (h->longopts == NULL) { - return max_optind; - } - - for (i = 0; h->longopts[i].name != NULL; i++) { - len = cmdopt_match_len(h->longopts[i].name, h->nextchar); - if (len < 0) { - // In case of a perfect match. - h->nextchar -= len; - return i; - } else if (len > max) { - // In case of a prefix match. - max = len; - max_optind = i; - } else if (len == max) { - // There are other candidates. - max_optind = -1; - } - } - - // If there is no perfect match, adopts the longest one. - h->nextchar += max; - return max_optind; -} - -// Gets an argument of a long option. -static void cmdopt_getopt_long(cmdopt_t *h) { - if (*h->nextchar == '=') { - h->optarg = h->nextchar + 1; - cmdopt_next(h); - } else { - cmdopt_next(h); - - // Checks whether there are more options or not. - if (h->optind < h->optnum) { - h->optarg = h->argv[h->optind]; - cmdopt_next(h); - } else { - h->optarg = NULL; - } - } -} - -// Searches long options. -static int cmdopt_search_long(cmdopt_t *h) { - const cmdopt_option *option; - - // Keeps the long option. - h->optlong = h->argv[h->optind]; - - // Gets the next option. - h->longindex = cmdopt_match(h); - if (h->longindex < 0) { - cmdopt_next(h); - return '?'; - } - - // Gets an argument if required. - option = h->longopts + h->longindex; - if (option->has_arg) { - cmdopt_getopt_long(h); - - // Return ':' if there are no more arguments. - if (h->optarg == NULL) { - return ':'; - } - } else if (*h->nextchar == '=') { - // Returns '?' for an extra option argument. - cmdopt_getopt_long(h); - return '?'; - } - - // Overwrites a variable if specified in settings. - if (option->flag != NULL) { - *option->flag = option->val; - return 0; - } - - return option->val; -} - -// Analyze command line option. -static int cmdopt_main(cmdopt_t *h) { - int type; - - // Initializes the internal state. - h->optopt = 0; - h->optlong = NULL; - h->optarg = NULL; - h->longindex = 0; - - while (h->optind < h->optnum) { - if (h->nextchar == NULL) { - // Checks whether the next argument is an option or not. - type = cmdopt_check(h); - if (type == 0) { - cmdopt_shift(h); - } else { - h->nextchar = h->argv[h->optind] + type; - if (type == 2) { - return cmdopt_search_long(h); - } - } - } else { - if (*h->nextchar == '\0') { - cmdopt_next(h); - continue; - } - // Searches an option string. - return cmdopt_search(h); - } - } - - return -1; -} - -// cmdopt_init() initializes a cmdopt_t for successive cmdopt_get()s. -void cmdopt_init(cmdopt_t *h, int argc, char **argv, - const char *optstring, const cmdopt_option *longopts) { - static const char empty_optstring[] = ""; - - h->argc = argc; - h->argv = argv; - h->optnum = h->argc; - - h->longopts = longopts; - h->optstring = (optstring != NULL) ? optstring : empty_optstring; - - h->optind = 1; - h->nextchar = NULL; - h->optarg = NULL; - h->optopt = 0; - h->optlong = NULL; - h->opterr = 1; - h->longindex = 0; -} - -// cmdopt_get() analyzes command line arguments and gets the next option. -int cmdopt_get(cmdopt_t *h) { - int value = cmdopt_main(h); - - // Prints a warning to the standard error stream if enabled. - if (h->opterr) { - if (value == ':') { - // Warning for a lack of an option argument. - if (h->optlong == NULL) { - fprintf(stderr, "option requires an argument -- %c\n", h->optopt); - } else { - fprintf(stderr, "option `--%s' requires an argument\n", - h->longopts[h->longindex].name); - } - } else if (value == '?') { - // Warning for an invalid option. - if (h->optlong == NULL) { - fprintf(stderr, "invalid option -- %c\n", h->optopt); - } else { - fprintf(stderr, "unrecognized option `%s'\n", h->optlong); - } - } else if ((value != -1) && (h->opterr == 2)) { - // Actually this is not for warning, but for debugging. - if (h->optlong == NULL) { - fprintf(stderr, "option with `%s' -- %c\n", h->optarg, h->optopt); - } else { - fprintf(stderr, "option `--%s' with `%s'\n", - h->longopts[h->longindex].name, h->optarg); - } - } - } - return value; -} - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus diff --git a/v0_1_5/tools/cmdopt.h b/v0_1_5/tools/cmdopt.h deleted file mode 100644 index bd0b049..0000000 --- a/v0_1_5/tools/cmdopt.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef MARISA_ALPHA_CMDOPT_H_ -#define MARISA_ALPHA_CMDOPT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct cmdopt_option_ { - // `name' specifies the name of this option. - // An array of options must be terminated with an option whose name == NULL. - const char *name; - - // `has_name' specifies whether an option takes an argument or not. - // 0 specifies that this option does not have any argument. - // 1 specifies that this option has an argument. - // 2 specifies that this option may have an argument. - int has_arg; - - // `flag' specifies an integer variable which is overwritten by cmdopt_next() - // with its return value. - int *flag; - - // `val' specifies a return value of cmdopt_next(). This value is returned - // when cmdopt_next() finds this option. - int val; -} cmdopt_option; - -typedef struct cmdopt_t_ { - // Command line arguments. - int argc; - char **argv; - - // Option settings. - const cmdopt_option *longopts; - const char *optstring; - - int optind; // Index of the next argument. - char *nextchar; // Next character. - char *optarg; // Argument of the last option. - int optopt; // Label of the last option. - char *optlong; // Long option. - int opterr; // Warning level (0: nothing, 1: warning, 2: all). - int longindex; // Index of the last long option. - int optnum; // Number of options. -} cmdopt_t; - -// cmdopt_init() initializes a cmdopt_t for successive cmdopt_next()s. -void cmdopt_init(cmdopt_t *h, int argc, char **argv, - const char *optstring, const cmdopt_option *longopts); - -// cmdopt_get() analyzes command line arguments and gets the next option. -int cmdopt_get(cmdopt_t *h); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // MARISA_ALPHA_CMDOPT_H_ diff --git a/v0_1_5/tools/marisa_alpha-benchmark.cc b/v0_1_5/tools/marisa_alpha-benchmark.cc deleted file mode 100644 index aa677b9..0000000 --- a/v0_1_5/tools/marisa_alpha-benchmark.cc +++ /dev/null @@ -1,425 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -typedef std::pair Key; - -int param_min_num_tries = 1; -int param_max_num_tries = 10; -int param_trie = MARISA_ALPHA_DEFAULT_TRIE; -int param_tail = MARISA_ALPHA_DEFAULT_TAIL; -int param_order = MARISA_ALPHA_DEFAULT_ORDER; -bool predict_strs_flag = false; -bool speed_flag = true; - -class Clock { - public: - Clock() : cl_(std::clock()) {} - - void reset() { - cl_ = std::clock(); - } - - double elasped() const { - std::clock_t cur = std::clock(); - return (cur == cl_) ? 0.01 : (1.0 * (cur - cl_) / CLOCKS_PER_SEC); - } - - private: - std::clock_t cl_; -}; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... [FILE]...\n\n" - "Options:\n" - " -N, --min-num-tries=[N] limits the number of tries to N" - " (default: 1)\n" - " -n, --max-num-tries=[N] limits the number of tries to N" - " (default: 10)\n" - " -P, --patricia-trie build patricia tries (default)\n" - " -p, --prefix-trie build prefix tries\n" - " -T, --text-tail build a dictionary with text TAIL (default)\n" - " -b, --binary-tail build a dictionary with binary TAIL\n" - " -t, --without-tail build a dictionary without TAIL\n" - " -w, --weight-order arrange siblings in weight order (default)\n" - " -l, --label-order arrange siblings in label order\n" - " -I, --predict-ids get key IDs in predictive searches (default)\n" - " -i, --predict-strs restore key strings in predictive searches\n" - " -S, --print-speed print speed [1000 keys/s] (default)\n" - " -s, --print-time print time [us/key]\n" - " -h, --help print this help\n" - << std::endl; -} - -void print_config() { - std::cout << "#tries: " << param_min_num_tries - << " - " << param_max_num_tries << std::endl; - - switch (param_trie) { - case MARISA_ALPHA_PATRICIA_TRIE: { - std::cout << "trie: patricia" << std::endl; - break; - } - case MARISA_ALPHA_PREFIX_TRIE: { - std::cout << "trie: prefix" << std::endl; - break; - } - } - - switch (param_tail) { - case MARISA_ALPHA_WITHOUT_TAIL: { - std::cout << "tail: no" << std::endl; - break; - } - case MARISA_ALPHA_BINARY_TAIL: { - std::cout << "tail: binary" << std::endl; - break; - } - case MARISA_ALPHA_TEXT_TAIL: { - std::cout << "tail: text" << std::endl; - break; - } - } - - switch (param_order) { - case MARISA_ALPHA_LABEL_ORDER: { - std::cout << "order: label" << std::endl; - break; - } - case MARISA_ALPHA_WEIGHT_ORDER: { - std::cout << "order: weight" << std::endl; - break; - } - } - - if (predict_strs_flag) { - std::cout << "predict: both IDs and strings" << std::endl; - } else { - std::cout << "predict: only IDs" << std::endl; - } -} - -void print_time_info(std::size_t num_keys, double elasped) { - if (speed_flag) { - if (elasped == 0.0) { - std::printf(" %7s", "-"); - } else { - std::printf(" %7.2f", num_keys / elasped / 1000.0); - } - } else { - if (num_keys == 0) { - std::printf(" %7s", "-"); - } else { - std::printf(" %7.3f", 1000000.0 * elasped / num_keys); - } - } -} - -void read_keys(std::istream *input, std::vector *keys) { - Key key; - std::string line; - while (std::getline(*input, line)) { - const std::string::size_type delim_pos = line.find_last_of('\t'); - if (delim_pos != line.npos) { - char *end_of_value; - key.second = std::strtod(&line[delim_pos + 1], &end_of_value); - if (*end_of_value == '\0') { - line.resize(delim_pos); - } else { - key.second = 1.0; - } - } else { - key.second = 1.0; - } - key.first = line; - keys->push_back(key); - } -} - -int read_keys(const char * const *args, std::size_t num_args, - std::vector *keys) { - if (num_args == 0) { - read_keys(&std::cin, keys); - } - for (std::size_t i = 0; i < num_args; ++i) { - std::ifstream input_file(args[i], std::ios::binary); - if (!input_file) { - std::cerr << "error: failed to open a keyset file: " - << args[i] << std::endl; - return 10; - } - read_keys(&input_file, keys); - } - std::cout << "#keys: " << keys->size() << std::endl; - std::size_t total_length = 0; - for (std::size_t i = 0; i < keys->size(); ++i) { - total_length += (*keys)[i].first.length(); - } - std::cout << "total length: " << total_length << std::endl; - return 0; -} - -void benchmark_build(const std::vector &keys, int num_tries, - marisa_alpha::Trie *trie, std::vector *key_ids) { - Clock cl; - trie->build(keys, key_ids, num_tries - | param_trie | param_tail | param_order); - std::printf(" %9lu", (unsigned long)trie->num_nodes()); - std::printf(" %9lu", (unsigned long)trie->total_size()); - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_restore(const marisa_alpha::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::string key; - for (std::size_t i = 0; i < key_ids.size(); ++i) { - key.clear(); - trie.restore(key_ids[i], &key); - if (key != keys[i].first) { - std::cerr << "error: restore() failed" << std::endl; - return; - } - } - print_time_info(key_ids.size(), cl.elasped()); -} - -void benchmark_lookup(const marisa_alpha::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - for (std::size_t i = 0; i < keys.size(); ++i) { - const marisa_alpha::UInt32 key_id = trie.lookup(keys[i].first); - if (key_id != key_ids[i]) { - std::cerr << "error: lookup() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_find(const marisa_alpha::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::vector found_key_ids; - for (std::size_t i = 0; i < keys.size(); ++i) { - found_key_ids.clear(); - const std::size_t num_keys = trie.find(keys[i].first, &found_key_ids); - if ((num_keys == 0) || (found_key_ids.back() != key_ids[i])) { - std::cerr << "error: find() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_predict_breadth_first(const marisa_alpha::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::vector found_key_ids; - std::vector found_keys; - std::vector *found_keys_ref = - predict_strs_flag ? &found_keys : NULL; - for (std::size_t i = 0; i < keys.size(); ++i) { - found_key_ids.clear(); - found_keys.clear(); - const std::size_t num_keys = trie.predict_breadth_first( - keys[i].first, &found_key_ids, found_keys_ref); - if ((num_keys == 0) || (found_key_ids.front() != key_ids[i])) { - std::cerr << "error: predict() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark_predict_depth_first(const marisa_alpha::Trie &trie, - const std::vector &keys, - const std::vector &key_ids) { - Clock cl; - std::vector found_key_ids; - std::vector found_keys; - std::vector *found_keys_ref = - predict_strs_flag ? &found_keys : NULL; - for (std::size_t i = 0; i < keys.size(); ++i) { - found_key_ids.clear(); - found_keys.clear(); - const std::size_t num_keys = trie.predict_depth_first( - keys[i].first, &found_key_ids, found_keys_ref); - if ((num_keys == 0) || (found_key_ids.front() != key_ids[i])) { - std::cerr << "error: predict() failed" << std::endl; - return; - } - } - print_time_info(keys.size(), cl.elasped()); -} - -void benchmark(const std::vector &keys, int num_tries) { - std::printf("%6d", num_tries); - marisa_alpha::Trie trie; - std::vector key_ids; - benchmark_build(keys, num_tries, &trie, &key_ids); - if (!trie.empty()) { - benchmark_restore(trie, keys, key_ids); - benchmark_lookup(trie, keys, key_ids); - benchmark_find(trie, keys, key_ids); - benchmark_predict_breadth_first(trie, keys, key_ids); - benchmark_predict_depth_first(trie, keys, key_ids); - } - std::printf("\n"); -} - -int benchmark(const char * const *args, std::size_t num_args) try { - std::vector keys; - const int ret = read_keys(args, num_args, &keys); - if (ret != 0) { - return ret; - } - std::printf("------+---------+---------+-------+" - "-------+-------+-------+-------+-------\n"); - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "#tries", "#nodes", "size", - "build", "restore", "lookup", "find", "predict", "predict"); - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "", "", "", "", "", "", "", "breadth", "depth"); - if (speed_flag) { - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "", "", "[bytes]", - "[K/s]", "[K/s]", "[K/s]", "[K/s]", "[K/s]", "[K/s]"); - } else { - std::printf("%6s %9s %9s %7s %7s %7s %7s %7s %7s\n", - "", "", "[bytes]", "[us]", "[us]", "[us]", "[us]", "[us]", "[us]"); - } - std::printf("------+---------+---------+-------+" - "-------+-------+-------+-------+-------\n"); - for (int i = param_min_num_tries; i <= param_max_num_tries; ++i) { - benchmark(keys, i); - } - std::printf("------+---------+---------+-------+" - "-------+-------+-------+-------+-------\n"); - return 0; -} catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() - << ": " << ex.what() << std::endl; - return -1; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "min-num-tries", 1, NULL, 'N' }, - { "max-num-tries", 1, NULL, 'n' }, - { "patricia-trie", 0, NULL, 'P' }, - { "prefix-trie", 0, NULL, 'p' }, - { "text-tail", 0, NULL, 'T' }, - { "binary-tail", 0, NULL, 'b' }, - { "without-tail", 0, NULL, 't' }, - { "weight-order", 0, NULL, 'w' }, - { "label-order", 0, NULL, 'l' }, - { "predict-ids", 0, NULL, 'I' }, - { "predict-strs", 0, NULL, 'i' }, - { "print-speed", 0, NULL, 'S' }, - { "print-time", 0, NULL, 's' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "N:n:PpTbtwlIiSsh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'N': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value <= 0) || - (value > MARISA_ALPHA_MAX_NUM_TRIES)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - param_min_num_tries = (int)value; - break; - } - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value <= 0) || - (value > MARISA_ALPHA_MAX_NUM_TRIES)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - param_max_num_tries = (int)value; - break; - } - case 'P': { - param_trie = MARISA_ALPHA_PATRICIA_TRIE; - break; - } - case 'p': { - param_trie = MARISA_ALPHA_PREFIX_TRIE; - break; - } - case 'T': { - param_tail = MARISA_ALPHA_TEXT_TAIL; - break; - } - case 'b': { - param_tail = MARISA_ALPHA_BINARY_TAIL; - break; - } - case 't': { - param_tail = MARISA_ALPHA_WITHOUT_TAIL; - break; - } - case 'w': { - param_order = MARISA_ALPHA_WEIGHT_ORDER; - break; - } - case 'l': { - param_order = MARISA_ALPHA_LABEL_ORDER; - break; - } - case 'I': { - predict_strs_flag = false; - break; - } - case 'i': { - predict_strs_flag = true; - break; - } - case 'S': { - speed_flag = true; - break; - } - case 's': { - speed_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - print_config(); - return benchmark(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/v0_1_5/tools/marisa_alpha-build.cc b/v0_1_5/tools/marisa_alpha-build.cc deleted file mode 100644 index d335352..0000000 --- a/v0_1_5/tools/marisa_alpha-build.cc +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -typedef std::pair Key; - -int param_num_tries = MARISA_ALPHA_DEFAULT_NUM_TRIES; -int param_trie = MARISA_ALPHA_DEFAULT_TRIE; -int param_tail = MARISA_ALPHA_DEFAULT_TAIL; -int param_order = MARISA_ALPHA_DEFAULT_ORDER; -const char *output_filename = NULL; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... [FILE]...\n\n" - "Options:\n" - " -n, --num-tries=[N] limits the number of tries to N" - " (default: 3)\n" - " -P, --patricia-trie build patricia tries (default)\n" - " -p, --prefix-trie build prefix tries\n" - " -T, --text-tail build a dictionary with text TAIL (default)\n" - " -b, --binary-tail build a dictionary with binary TAIL\n" - " -t, --without-tail build a dictionary without TAIL\n" - " -w, --weight-order arranges siblings in weight order (default)\n" - " -l, --label-order arranges siblings in label order\n" - " -o, --output=[FILE] write tries to FILE (default: stdout)\n" - " -h, --help print this help\n" - << std::endl; -} - -void read_keys(std::istream *input, std::vector *keys) { - Key key; - std::string line; - while (std::getline(*input, line)) { - const std::string::size_type delim_pos = line.find_last_of('\t'); - if (delim_pos != line.npos) { - char *end_of_value; - key.second = std::strtod(&line[delim_pos + 1], &end_of_value); - if (*end_of_value == '\0') { - line.resize(delim_pos); - } else { - key.second = 1.0; - } - } else { - key.second = 1.0; - } - key.first = line; - keys->push_back(key); - } -} - -int build(const char * const *args, std::size_t num_args) { - std::vector keys; - if (num_args == 0) { - read_keys(&std::cin, &keys); - } - - for (std::size_t i = 0; i < num_args; ++i) { - std::ifstream input_file(args[i], std::ios::binary); - if (!input_file) { - std::cerr << "error: failed to open a keyset file: " - << args[i] << std::endl; - return 10; - } - read_keys(&input_file, &keys); - } - - marisa_alpha::Trie trie; - try { - trie.build(keys, NULL, param_num_tries - | param_trie | param_tail | param_order); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to build a dictionary" << std::endl; - return 20; - } - - std::cerr << "#keys: " << trie.num_keys() << std::endl; - std::cerr << "#tries: " << trie.num_tries() << std::endl; - std::cerr << "#nodes: " << trie.num_nodes() << std::endl; - std::cerr << "size: " << trie.total_size() << std::endl; - - if (output_filename != NULL) { - try { - trie.save(output_filename); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to write a dictionary to file: " - << output_filename << std::endl; - return 30; - } - } else { - try { - trie.write(std::cout); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to write a dictionary to standard output" << std::endl; - return 31; - } - } - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "max-num-tries", 1, NULL, 'n' }, - { "patricia-trie", 0, NULL, 'P' }, - { "prefix-trie", 0, NULL, 'p' }, - { "text-tail", 0, NULL, 'T' }, - { "binary-tail", 0, NULL, 'b' }, - { "without-tail", 0, NULL, 't' }, - { "weight-order", 0, NULL, 'w' }, - { "label-order", 0, NULL, 'l' }, - { "output", 1, NULL, 'o' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "n:PpTbtwlo:h", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value <= 0) || - (value > MARISA_ALPHA_MAX_NUM_TRIES)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - param_num_tries = (int)value; - break; - } - case 'P': { - param_trie = MARISA_ALPHA_PATRICIA_TRIE; - break; - } - case 'p': { - param_trie = MARISA_ALPHA_PREFIX_TRIE; - break; - } - case 'T': { - param_tail = MARISA_ALPHA_TEXT_TAIL; - break; - } - case 'b': { - param_tail = MARISA_ALPHA_BINARY_TAIL; - break; - } - case 't': { - param_tail = MARISA_ALPHA_WITHOUT_TAIL; - break; - } - case 'w': { - param_order = MARISA_ALPHA_WEIGHT_ORDER; - break; - } - case 'l': { - param_order = MARISA_ALPHA_LABEL_ORDER; - break; - } - case 'o': { - output_filename = cmdopt.optarg; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return build(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/v0_1_5/tools/marisa_alpha-find.cc b/v0_1_5/tools/marisa_alpha-find.cc deleted file mode 100644 index 03a1a32..0000000 --- a/v0_1_5/tools/marisa_alpha-find.cc +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -enum FindMode { - FIND_ALL, - FIND_FIRST, - FIND_LAST -}; - -std::size_t max_num_results = 10; -FindMode find_mode = FIND_ALL; -bool mmap_flag = true; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... DIC\n\n" - "Options:\n" - " -n, --max-num-results=[N] limits the number of results to N" - " (default: 10)\n" - " 0: no limit\n" - " -a, --find-all find all prefix keys (default)\n" - " -f, --find-first find a shortest prefix key\n" - " -l, --find-last find a longest prefix key\n" - " -m, --mmap-dictionary use memory-mapped I/O to load a dictionary" - " (default)\n" - " -r, --read-dictionary read an entire dictionary into memory\n" - " -h, --help print this help\n" - << std::endl; -} - -void find_all(const marisa_alpha::Trie &trie, const std::string &str) { - static std::vector key_ids; - static std::vector lengths; - const std::size_t num_keys = trie.find(str, &key_ids, &lengths); - if (num_keys != 0) { - std::cout << num_keys << " found" << std::endl; - for (std::size_t i = 0; (i < num_keys) && (i < max_num_results); ++i) { - std::cout << key_ids[i] << '\t'; - std::cout.write(str.c_str(), lengths[i]) << '\t' << str << '\n'; - } - } else { - std::cout << "not found" << std::endl; - } - key_ids.clear(); - lengths.clear(); -} - -void find_first(const marisa_alpha::Trie &trie, const std::string &str) { - std::size_t length = 0; - const marisa_alpha::UInt32 key_id = trie.find_first(str, &length); - if (key_id != trie.notfound()) { - std::cout << key_id << '\t'; - std::cout.write(str.c_str(), length) << '\t' << str << '\n'; - } else { - std::cout << "-1\t" << str << '\n'; - } -} - -void find_last(const marisa_alpha::Trie &trie, const std::string &str) { - std::size_t length = 0; - const marisa_alpha::UInt32 key_id = trie.find_last(str, &length); - if (key_id != trie.notfound()) { - std::cout << key_id << '\t'; - std::cout.write(str.c_str(), length) << '\t' << str << '\n'; - } else { - std::cout << "-1\t" << str << '\n'; - } -} - -int find(const char * const *args, std::size_t num_args) { - if (num_args == 0) { - std::cerr << "error: a dictionary is not specified" << std::endl; - return 10; - } else if (num_args > 1) { - std::cerr << "error: more than one dictionaries are specified" - << std::endl; - return 11; - } - - marisa_alpha::Trie trie; - marisa_alpha::Mapper mapper; - if (mmap_flag) { - try { - trie.mmap(&mapper, args[0]); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to mmap a dictionary file: " << args[0] << std::endl; - return 20; - } - } else { - try { - trie.load(args[0]); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to load a dictionary file: " << args[0] << std::endl; - return 21; - } - } - - std::string str; - while (std::getline(std::cin, str)) { - try { - switch (find_mode) { - case FIND_ALL: { - find_all(trie, str); - break; - } - case FIND_FIRST: { - find_first(trie, str); - break; - } - case FIND_LAST: { - find_last(trie, str); - break; - } - } - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to find keys in: " << str << std::endl; - return 30; - } - if (!std::cout) { - std::cerr << "error: failed to write results to standard output" - << std::endl; - return 31; - } - } - - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "max-num-results", 1, NULL, 'n' }, - { "find-all", 0, NULL, 'a' }, - { "find-first", 0, NULL, 'f' }, - { "find-last", 0, NULL, 'l' }, - { "mmap-dictionary", 0, NULL, 'm' }, - { "read-dictionary", 0, NULL, 'r' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "n:aflmrh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value < 0)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - if ((value == 0) || - ((unsigned long)value > MARISA_ALPHA_MAX_NUM_KEYS)) { - max_num_results = MARISA_ALPHA_MAX_NUM_KEYS; - } else { - max_num_results = (std::size_t)(value); - } - break; - } - case 'a': { - find_mode = FIND_ALL; - break; - } - case 'f': { - find_mode = FIND_FIRST; - break; - } - case 'l': { - find_mode = FIND_LAST; - break; - } - case 'm': { - mmap_flag = true; - break; - } - case 'r': { - mmap_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return find(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/v0_1_5/tools/marisa_alpha-lookup.cc b/v0_1_5/tools/marisa_alpha-lookup.cc deleted file mode 100644 index 6c02c6d..0000000 --- a/v0_1_5/tools/marisa_alpha-lookup.cc +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -bool mmap_flag = true; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... DIC\n\n" - "Options:\n" - " -m, --mmap-dictionary use memory-mapped I/O to load a dictionary" - " (default)\n" - " -r, --read-dictionary read an entire dictionary into memory\n" - " -h, --help print this help\n" - << std::endl; -} - -int lookup(const char * const *args, std::size_t num_args) { - if (num_args == 0) { - std::cerr << "error: a dictionary is not specified" << std::endl; - return 10; - } else if (num_args > 1) { - std::cerr << "error: more than one dictionaries are specified" - << std::endl; - return 11; - } - - marisa_alpha::Trie trie; - marisa_alpha::Mapper mapper; - if (mmap_flag) { - try { - trie.mmap(&mapper, args[0]); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to mmap a dictionary file: " << args[0] << std::endl; - return 20; - } - } else { - try { - trie.load(args[0]); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to load a dictionary file: " << args[0] << std::endl; - return 21; - } - } - - std::string str; - while (std::getline(std::cin, str)) { - const marisa_alpha::UInt32 key_id = trie.lookup(str); - if (key_id != trie.notfound()) { - std::cout << key_id << '\t' << str << '\n'; - } else { - std::cout << "-1\t" << str << '\n'; - } - if (!std::cout) { - std::cerr << "error: failed to write results to standard output" - << std::endl; - return 30; - } - } - - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "mmap-dictionary", 0, NULL, 'm' }, - { "read-dictionary", 0, NULL, 'r' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "mrh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'm': { - mmap_flag = true; - break; - } - case 'r': { - mmap_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return lookup(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/v0_1_5/tools/marisa_alpha-predict.cc b/v0_1_5/tools/marisa_alpha-predict.cc deleted file mode 100644 index 2b094f5..0000000 --- a/v0_1_5/tools/marisa_alpha-predict.cc +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include "./cmdopt.h" - -namespace { - -std::size_t max_num_results = 10; -bool mmap_flag = true; -bool depth_first_flag = true; - -void print_help(const char *cmd) { - std::cerr << "Usage: " << cmd << " [OPTION]... DIC\n\n" - "Options:\n" - " -n, --max-num-results=[N] limits the number of outputs to N" - " (default: 10)\n" - " 0: no limit\n" - " -d, --depth-first predict keys in depth first order(default)\n" - " -b, --breadth-first predict keys in breadth first order\n" - " -m, --mmap-dictionary use memory-mapped I/O to load a dictionary" - " (default)\n" - " -r, --read-dictionary read an entire dictionary into memory\n" - " -h, --help print this help\n" - << std::endl; -} - -int predict(const char * const *args, std::size_t num_args) { - if (num_args == 0) { - std::cerr << "error: a dictionary is not specified" << std::endl; - return 10; - } else if (num_args > 1) { - std::cerr << "error: more than one dictionaries are specified" - << std::endl; - return 11; - } - - marisa_alpha::Trie trie; - marisa_alpha::Mapper mapper; - if (mmap_flag) { - try { - trie.mmap(&mapper, args[0]); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to mmap a dictionary file: " << args[0] << std::endl; - return 20; - } - } else { - try { - trie.load(args[0]); - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to load a dictionary file: " << args[0] << std::endl; - return 21; - } - } - - std::vector key_ids; - std::vector keys; - std::string str; - while (std::getline(std::cin, str)) { - std::size_t num_keys = trie.predict(str); - if (num_keys != 0) { - std::cout << num_keys << " found" << std::endl; - key_ids.clear(); - keys.clear(); - try { - if (depth_first_flag) { - num_keys = trie.predict_depth_first( - str, &key_ids, &keys, max_num_results); - } else { - num_keys = trie.predict_breadth_first( - str, &key_ids, &keys, max_num_results); - } - } catch (const marisa_alpha::Exception &ex) { - std::cerr << ex.filename() << ':' << ex.line() << ": " << ex.what() - << ": failed to predict keys from: " << str << std::endl; - return 30; - } - for (std::size_t i = 0; i < num_keys; ++i) { - std::cout << key_ids[i] << '\t' << keys[i] << '\t' << str << '\n'; - } - } else { - std::cout << "not found" << std::endl; - } - if (!std::cout) { - std::cerr << "error: failed to write results to standard output" - << std::endl; - return 31; - } - } - - return 0; -} - -} // namespace - -int main(int argc, char *argv[]) { - std::ios::sync_with_stdio(false); - - ::cmdopt_option long_options[] = { - { "max-num-results", 1, NULL, 'n' }, - { "depth-first", 0, NULL, 'd' }, - { "breadth-first", 0, NULL, 'b' }, - { "mmap-dictionary", 0, NULL, 'm' }, - { "read-dictionary", 0, NULL, 'r' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } - }; - ::cmdopt_t cmdopt; - ::cmdopt_init(&cmdopt, argc, argv, "n:dbmrh", long_options); - int label; - while ((label = ::cmdopt_get(&cmdopt)) != -1) { - switch (label) { - case 'n': { - char *end_of_value; - const long value = std::strtol(cmdopt.optarg, &end_of_value, 10); - if ((*end_of_value != '\0') || (value < 0)) { - std::cerr << "error: option `-n' with an invalid argument: " - << cmdopt.optarg << std::endl; - } - if ((value == 0) || - ((unsigned long)value > MARISA_ALPHA_MAX_NUM_KEYS)) { - max_num_results = MARISA_ALPHA_MAX_NUM_KEYS; - } else { - max_num_results = (std::size_t)(value); - } - break; - } - case 'd': { - depth_first_flag = true; - break; - } - case 'b': { - depth_first_flag = false; - break; - } - case 'm': { - mmap_flag = true; - break; - } - case 'r': { - mmap_flag = false; - break; - } - case 'h': { - print_help(argv[0]); - return 0; - } - default: { - return 1; - } - } - } - return predict(cmdopt.argv + cmdopt.optind, cmdopt.argc - cmdopt.optind); -} diff --git a/v0_1_5/vs2008/c-test/c-test.vcproj b/v0_1_5/vs2008/c-test/c-test.vcproj deleted file mode 100644 index dc57f74..0000000 --- a/v0_1_5/vs2008/c-test/c-test.vcproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/io-test/io-test.vcproj b/v0_1_5/vs2008/io-test/io-test.vcproj deleted file mode 100644 index 70a07d2..0000000 --- a/v0_1_5/vs2008/io-test/io-test.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/libmarisa_alpha/libmarisa_alpha.vcproj b/v0_1_5/vs2008/libmarisa_alpha/libmarisa_alpha.vcproj deleted file mode 100644 index 50f9c9b..0000000 --- a/v0_1_5/vs2008/libmarisa_alpha/libmarisa_alpha.vcproj +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/marisa_alpha-benchmark/marisa_alpha-benchmark.vcproj b/v0_1_5/vs2008/marisa_alpha-benchmark/marisa_alpha-benchmark.vcproj deleted file mode 100644 index c39f524..0000000 --- a/v0_1_5/vs2008/marisa_alpha-benchmark/marisa_alpha-benchmark.vcproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/marisa_alpha-build/marisa_alpha-build.vcproj b/v0_1_5/vs2008/marisa_alpha-build/marisa_alpha-build.vcproj deleted file mode 100644 index 6ed86a9..0000000 --- a/v0_1_5/vs2008/marisa_alpha-build/marisa_alpha-build.vcproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/marisa_alpha-find/marisa_alpha-find.vcproj b/v0_1_5/vs2008/marisa_alpha-find/marisa_alpha-find.vcproj deleted file mode 100644 index b996424..0000000 --- a/v0_1_5/vs2008/marisa_alpha-find/marisa_alpha-find.vcproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/marisa_alpha-lookup/marisa_alpha-lookup.vcproj b/v0_1_5/vs2008/marisa_alpha-lookup/marisa_alpha-lookup.vcproj deleted file mode 100644 index 38ae4a1..0000000 --- a/v0_1_5/vs2008/marisa_alpha-lookup/marisa_alpha-lookup.vcproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/marisa_alpha-predict/marisa_alpha-predict.vcproj b/v0_1_5/vs2008/marisa_alpha-predict/marisa_alpha-predict.vcproj deleted file mode 100644 index 4d49303..0000000 --- a/v0_1_5/vs2008/marisa_alpha-predict/marisa_alpha-predict.vcproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/tail-test/tail-test.vcproj b/v0_1_5/vs2008/tail-test/tail-test.vcproj deleted file mode 100644 index d5e1c4f..0000000 --- a/v0_1_5/vs2008/tail-test/tail-test.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/trie-test/trie-test.vcproj b/v0_1_5/vs2008/trie-test/trie-test.vcproj deleted file mode 100644 index 7295779..0000000 --- a/v0_1_5/vs2008/trie-test/trie-test.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/unit-test/unit-test.vcproj b/v0_1_5/vs2008/unit-test/unit-test.vcproj deleted file mode 100644 index 4f236d1..0000000 --- a/v0_1_5/vs2008/unit-test/unit-test.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/vector-test/vector-test.vcproj b/v0_1_5/vs2008/vector-test/vector-test.vcproj deleted file mode 100644 index 5762836..0000000 --- a/v0_1_5/vs2008/vector-test/vector-test.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0_1_5/vs2008/vs2008.sln b/v0_1_5/vs2008/vs2008.sln deleted file mode 100644 index fbfe6f7..0000000 --- a/v0_1_5/vs2008/vs2008.sln +++ /dev/null @@ -1,119 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmarisa_alpha", "libmarisa_alpha\libmarisa_alpha.vcproj", "{69872893-89E5-4D16-829E-8B120BACE2AD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "marisa_alpha-benchmark", "marisa_alpha-benchmark\marisa_alpha-benchmark.vcproj", "{85E7F33D-2053-47AD-AEA4-4DB8B754BCD7}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "marisa_alpha-build", "marisa_alpha-build\marisa_alpha-build.vcproj", "{104CFCC9-11DF-4894-894B-BFE5F5C13DCA}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "marisa_alpha-lookup", "marisa_alpha-lookup\marisa_alpha-lookup.vcproj", "{98C25734-1D4B-48A7-B8B2-D6559410FF3F}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "marisa_alpha-find", "marisa_alpha-find\marisa_alpha-find.vcproj", "{C59566AA-D2C9-40CF-897F-EA7C3F839FA1}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "marisa_alpha-predict", "marisa_alpha-predict\marisa_alpha-predict.vcproj", "{C8070F3E-843A-4FEE-BB34-5C05C54750AB}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "io-test", "io-test\io-test.vcproj", "{24807515-7B42-4E76-B630-E82BDA83845C}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tail-test", "tail-test\tail-test.vcproj", "{7881BE8D-40CA-4FAE-81D1-CD10026AE3CE}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "trie-test", "trie-test\trie-test.vcproj", "{F1876AD7-43C2-4D95-BB45-E1EAED974C75}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vector-test", "vector-test\vector-test.vcproj", "{B20AE738-2F4F-4E96-A673-F5A02591D50E}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-test", "unit-test\unit-test.vcproj", "{6A83AFE2-2AF8-4BD2-A3BD-D26AFBE96C87}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c-test", "c-test\c-test.vcproj", "{64EBFBDC-4EAF-42D7-A47F-0A36B2E750AF}" - ProjectSection(ProjectDependencies) = postProject - {69872893-89E5-4D16-829E-8B120BACE2AD} = {69872893-89E5-4D16-829E-8B120BACE2AD} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {69872893-89E5-4D16-829E-8B120BACE2AD}.Debug|Win32.ActiveCfg = Debug|Win32 - {69872893-89E5-4D16-829E-8B120BACE2AD}.Debug|Win32.Build.0 = Debug|Win32 - {69872893-89E5-4D16-829E-8B120BACE2AD}.Release|Win32.ActiveCfg = Release|Win32 - {69872893-89E5-4D16-829E-8B120BACE2AD}.Release|Win32.Build.0 = Release|Win32 - {85E7F33D-2053-47AD-AEA4-4DB8B754BCD7}.Debug|Win32.ActiveCfg = Debug|Win32 - {85E7F33D-2053-47AD-AEA4-4DB8B754BCD7}.Debug|Win32.Build.0 = Debug|Win32 - {85E7F33D-2053-47AD-AEA4-4DB8B754BCD7}.Release|Win32.ActiveCfg = Release|Win32 - {85E7F33D-2053-47AD-AEA4-4DB8B754BCD7}.Release|Win32.Build.0 = Release|Win32 - {104CFCC9-11DF-4894-894B-BFE5F5C13DCA}.Debug|Win32.ActiveCfg = Debug|Win32 - {104CFCC9-11DF-4894-894B-BFE5F5C13DCA}.Debug|Win32.Build.0 = Debug|Win32 - {104CFCC9-11DF-4894-894B-BFE5F5C13DCA}.Release|Win32.ActiveCfg = Release|Win32 - {104CFCC9-11DF-4894-894B-BFE5F5C13DCA}.Release|Win32.Build.0 = Release|Win32 - {98C25734-1D4B-48A7-B8B2-D6559410FF3F}.Debug|Win32.ActiveCfg = Debug|Win32 - {98C25734-1D4B-48A7-B8B2-D6559410FF3F}.Debug|Win32.Build.0 = Debug|Win32 - {98C25734-1D4B-48A7-B8B2-D6559410FF3F}.Release|Win32.ActiveCfg = Release|Win32 - {98C25734-1D4B-48A7-B8B2-D6559410FF3F}.Release|Win32.Build.0 = Release|Win32 - {C59566AA-D2C9-40CF-897F-EA7C3F839FA1}.Debug|Win32.ActiveCfg = Debug|Win32 - {C59566AA-D2C9-40CF-897F-EA7C3F839FA1}.Debug|Win32.Build.0 = Debug|Win32 - {C59566AA-D2C9-40CF-897F-EA7C3F839FA1}.Release|Win32.ActiveCfg = Release|Win32 - {C59566AA-D2C9-40CF-897F-EA7C3F839FA1}.Release|Win32.Build.0 = Release|Win32 - {C8070F3E-843A-4FEE-BB34-5C05C54750AB}.Debug|Win32.ActiveCfg = Debug|Win32 - {C8070F3E-843A-4FEE-BB34-5C05C54750AB}.Debug|Win32.Build.0 = Debug|Win32 - {C8070F3E-843A-4FEE-BB34-5C05C54750AB}.Release|Win32.ActiveCfg = Release|Win32 - {C8070F3E-843A-4FEE-BB34-5C05C54750AB}.Release|Win32.Build.0 = Release|Win32 - {24807515-7B42-4E76-B630-E82BDA83845C}.Debug|Win32.ActiveCfg = Debug|Win32 - {24807515-7B42-4E76-B630-E82BDA83845C}.Debug|Win32.Build.0 = Debug|Win32 - {24807515-7B42-4E76-B630-E82BDA83845C}.Release|Win32.ActiveCfg = Release|Win32 - {24807515-7B42-4E76-B630-E82BDA83845C}.Release|Win32.Build.0 = Release|Win32 - {7881BE8D-40CA-4FAE-81D1-CD10026AE3CE}.Debug|Win32.ActiveCfg = Debug|Win32 - {7881BE8D-40CA-4FAE-81D1-CD10026AE3CE}.Debug|Win32.Build.0 = Debug|Win32 - {7881BE8D-40CA-4FAE-81D1-CD10026AE3CE}.Release|Win32.ActiveCfg = Release|Win32 - {7881BE8D-40CA-4FAE-81D1-CD10026AE3CE}.Release|Win32.Build.0 = Release|Win32 - {F1876AD7-43C2-4D95-BB45-E1EAED974C75}.Debug|Win32.ActiveCfg = Debug|Win32 - {F1876AD7-43C2-4D95-BB45-E1EAED974C75}.Debug|Win32.Build.0 = Debug|Win32 - {F1876AD7-43C2-4D95-BB45-E1EAED974C75}.Release|Win32.ActiveCfg = Release|Win32 - {F1876AD7-43C2-4D95-BB45-E1EAED974C75}.Release|Win32.Build.0 = Release|Win32 - {B20AE738-2F4F-4E96-A673-F5A02591D50E}.Debug|Win32.ActiveCfg = Debug|Win32 - {B20AE738-2F4F-4E96-A673-F5A02591D50E}.Debug|Win32.Build.0 = Debug|Win32 - {B20AE738-2F4F-4E96-A673-F5A02591D50E}.Release|Win32.ActiveCfg = Release|Win32 - {B20AE738-2F4F-4E96-A673-F5A02591D50E}.Release|Win32.Build.0 = Release|Win32 - {6A83AFE2-2AF8-4BD2-A3BD-D26AFBE96C87}.Debug|Win32.ActiveCfg = Debug|Win32 - {6A83AFE2-2AF8-4BD2-A3BD-D26AFBE96C87}.Debug|Win32.Build.0 = Debug|Win32 - {6A83AFE2-2AF8-4BD2-A3BD-D26AFBE96C87}.Release|Win32.ActiveCfg = Release|Win32 - {6A83AFE2-2AF8-4BD2-A3BD-D26AFBE96C87}.Release|Win32.Build.0 = Release|Win32 - {64EBFBDC-4EAF-42D7-A47F-0A36B2E750AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {64EBFBDC-4EAF-42D7-A47F-0A36B2E750AF}.Debug|Win32.Build.0 = Debug|Win32 - {64EBFBDC-4EAF-42D7-A47F-0A36B2E750AF}.Release|Win32.ActiveCfg = Release|Win32 - {64EBFBDC-4EAF-42D7-A47F-0A36B2E750AF}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/v0_1_5/vs2008/vs2008.suo b/v0_1_5/vs2008/vs2008.suo deleted file mode 100644 index 3607b3b..0000000 Binary files a/v0_1_5/vs2008/vs2008.suo and /dev/null differ -- cgit v1.2.3 From d1c8e741687459a0b387a1e5abdfec936835e752 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Mon, 2 Nov 2020 15:04:54 +0000 Subject: Set min_sdk_version to be 30 Bug: 170298047 Test: m com.android.extservices Change-Id: Ifd74d99bcd457f838d09e087dcff37fb69e0793a --- Android.bp | 1 + 1 file changed, 1 insertion(+) diff --git a/Android.bp b/Android.bp index c37c7c1..817ece6 100644 --- a/Android.bp +++ b/Android.bp @@ -16,6 +16,7 @@ cc_library { name: "marisa-trie", sdk_version: "current", + min_sdk_version: "30", cflags: [ "-Werror", "-Wall", -- cgit v1.2.3 From ae3315be4a1907aa56366e42538f37256c7eaaa2 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Mon, 2 Nov 2020 15:04:54 +0000 Subject: Set min_sdk_version to be 30 Bug: 170298047 Test: m com.android.extservices Merged-In: Ifd74d99bcd457f838d09e087dcff37fb69e0793a Change-Id: Ifd74d99bcd457f838d09e087dcff37fb69e0793a --- Android.bp | 1 + 1 file changed, 1 insertion(+) diff --git a/Android.bp b/Android.bp index c37c7c1..817ece6 100644 --- a/Android.bp +++ b/Android.bp @@ -16,6 +16,7 @@ cc_library { name: "marisa-trie", sdk_version: "current", + min_sdk_version: "30", cflags: [ "-Werror", "-Wall", -- cgit v1.2.3