Imported Upstream version 1.8.2 upstream upstream/1.8.2
authorTizenOpenSource <tizenopensrc@samsung.com>
Thu, 28 Dec 2023 06:22:16 +0000 (15:22 +0900)
committerTizenOpenSource <tizenopensrc@samsung.com>
Thu, 28 Dec 2023 06:22:16 +0000 (15:22 +0900)
388 files changed:
BUILD.bazel
Makefile.in
NEWS
WORKSPACE.bazel
aclocal.m4
ar-lib
compile
config.h.in
configure
configure.ac
depcomp
ltmain.sh [changed mode: 0644->0755]
m4/libtool.m4
missing
src/Makefile.in
src/bin/Makefile.in
src/bin/fstclosure-main.cc
src/bin/fstclosure.cc
src/bin/fstcompile-main.cc
src/bin/fstdraw-main.cc
src/bin/fstencode-main.cc
src/bin/fstencode.cc
src/bin/fstepsnormalize-main.cc
src/bin/fstepsnormalize.cc
src/bin/fstequal-main.cc
src/bin/fstequivalent-main.cc
src/bin/fstequivalent.cc
src/bin/fstinfo-main.cc
src/bin/fstisomorphic-main.cc
src/bin/fstmap-main.cc
src/bin/fstprint-main.cc
src/bin/fstpush-main.cc
src/bin/fstpush.cc
src/bin/fstrandgen.cc
src/bin/fstrelabel-main.cc
src/bin/fstreplace-main.cc
src/bin/fstreweight-main.cc
src/bin/fstreweight.cc
src/bin/fstshortestdistance-main.cc
src/bin/fstsymbols-main.cc
src/extensions/Makefile.in
src/extensions/compact/Makefile.am
src/extensions/compact/Makefile.in
src/extensions/compact/compact16_acceptor-fst.cc
src/extensions/compact/compact16_string-fst.cc
src/extensions/compact/compact16_unweighted-fst.cc
src/extensions/compact/compact16_unweighted_acceptor-fst.cc
src/extensions/compact/compact16_weighted_string-fst.cc
src/extensions/compact/compact64_acceptor-fst.cc
src/extensions/compact/compact64_string-fst.cc
src/extensions/compact/compact64_unweighted-fst.cc
src/extensions/compact/compact64_unweighted_acceptor-fst.cc
src/extensions/compact/compact64_weighted_string-fst.cc
src/extensions/compact/compact8_acceptor-fst.cc
src/extensions/compact/compact8_string-fst.cc
src/extensions/compact/compact8_unweighted-fst.cc
src/extensions/compact/compact8_unweighted_acceptor-fst.cc
src/extensions/compact/compact8_weighted_string-fst.cc
src/extensions/compress/Makefile.am
src/extensions/compress/Makefile.in
src/extensions/compress/compressscript.cc
src/extensions/const/Makefile.am
src/extensions/const/Makefile.in
src/extensions/const/const16-fst.cc
src/extensions/const/const64-fst.cc
src/extensions/const/const8-fst.cc
src/extensions/far/Makefile.am
src/extensions/far/Makefile.in
src/extensions/far/compile-strings.cc [moved from src/extensions/far/strings.cc with 95% similarity]
src/extensions/far/far-class.cc
src/extensions/far/farcompilestrings-main.cc
src/extensions/far/farconvert-main.cc
src/extensions/far/farconvert.cc
src/extensions/far/farcreate-main.cc
src/extensions/far/farencode-main.cc [new file with mode: 0644]
src/extensions/far/farencode.cc [new file with mode: 0644]
src/extensions/far/farequal-main.cc
src/extensions/far/farextract-main.cc
src/extensions/far/farinfo-main.cc
src/extensions/far/farisomorphic-main.cc
src/extensions/far/farprintstrings-main.cc
src/extensions/far/farscript.cc
src/extensions/far/getters.cc
src/extensions/far/stlist.cc
src/extensions/far/sttable.cc
src/extensions/linear/Makefile.am
src/extensions/linear/Makefile.in
src/extensions/linear/fstloglinearapply-main.cc
src/extensions/linear/linearscript.cc
src/extensions/lookahead/Makefile.am
src/extensions/lookahead/Makefile.in
src/extensions/mpdt/Makefile.am
src/extensions/mpdt/Makefile.in
src/extensions/mpdt/mpdtcompose-main.cc
src/extensions/mpdt/mpdtexpand-main.cc
src/extensions/mpdt/mpdtinfo-main.cc
src/extensions/mpdt/mpdtreverse-main.cc
src/extensions/mpdt/mpdtscript.cc
src/extensions/ngram/Makefile.am
src/extensions/ngram/Makefile.in
src/extensions/ngram/bitmap-index.cc
src/extensions/ngram/nthbit.cc
src/extensions/pdt/Makefile.am
src/extensions/pdt/Makefile.in
src/extensions/pdt/getters.cc
src/extensions/pdt/pdtcompose-main.cc
src/extensions/pdt/pdtexpand-main.cc
src/extensions/pdt/pdtinfo-main.cc
src/extensions/pdt/pdtreplace-main.cc
src/extensions/pdt/pdtreverse-main.cc
src/extensions/pdt/pdtscript.cc
src/extensions/pdt/pdtshortestpath-main.cc
src/extensions/python/Makefile.am
src/extensions/python/Makefile.in
src/extensions/python/cios.pxd
src/extensions/python/cmemory.pxd [moved from src/extensions/python/cintegral_types.pxd with 71% similarity]
src/extensions/python/cpywrapfst.pxd
src/extensions/python/cutility.pxd [deleted file]
src/extensions/python/pywrapfst.pxd
src/extensions/python/pywrapfst.pyx
src/extensions/special/Makefile.am
src/extensions/special/Makefile.in
src/extensions/special/phi-fst.cc
src/extensions/special/rho-fst.cc
src/extensions/special/sigma-fst.cc
src/include/Makefile.am
src/include/Makefile.in
src/include/fst/accumulator.h
src/include/fst/add-on.h
src/include/fst/arc-arena.h
src/include/fst/arc-map.h
src/include/fst/arc.h
src/include/fst/arcsort.h
src/include/fst/bi-table.h
src/include/fst/cache.h
src/include/fst/closure.h
src/include/fst/compact-fst.h
src/include/fst/compat.h
src/include/fst/complement.h
src/include/fst/compose-filter.h
src/include/fst/compose.h
src/include/fst/concat.h
src/include/fst/config.h [deleted file]
src/include/fst/config.h.in [deleted file]
src/include/fst/connect.h
src/include/fst/const-fst.h
src/include/fst/determinize.h
src/include/fst/dfs-visit.h
src/include/fst/disambiguate.h
src/include/fst/edit-fst.h
src/include/fst/encode.h
src/include/fst/equal.h
src/include/fst/equivalent.h
src/include/fst/error-weight.h
src/include/fst/expanded-fst.h
src/include/fst/expectation-weight.h
src/include/fst/extensions/compress/compress.h
src/include/fst/extensions/far/compile-strings.h
src/include/fst/extensions/far/convert.h
src/include/fst/extensions/far/create.h
src/include/fst/extensions/far/encode.h [new file with mode: 0644]
src/include/fst/extensions/far/equal.h
src/include/fst/extensions/far/extract.h
src/include/fst/extensions/far/far-class.h
src/include/fst/extensions/far/far.h
src/include/fst/extensions/far/farscript.h
src/include/fst/extensions/far/getters.h
src/include/fst/extensions/far/info.h
src/include/fst/extensions/far/isomorphic.h
src/include/fst/extensions/far/map-reduce.h [new file with mode: 0644]
src/include/fst/extensions/far/print-strings.h
src/include/fst/extensions/far/stlist.h
src/include/fst/extensions/far/sttable.h
src/include/fst/extensions/linear/linear-fst-data-builder.h
src/include/fst/extensions/linear/linear-fst-data.h
src/include/fst/extensions/linear/linear-fst.h
src/include/fst/extensions/linear/trie.h
src/include/fst/extensions/mpdt/compose.h
src/include/fst/extensions/mpdt/expand.h
src/include/fst/extensions/mpdt/info.h
src/include/fst/extensions/mpdt/mpdt.h
src/include/fst/extensions/mpdt/mpdtscript.h
src/include/fst/extensions/mpdt/read_write_utils.h
src/include/fst/extensions/ngram/bitmap-index.h
src/include/fst/extensions/ngram/ngram-fst.h
src/include/fst/extensions/ngram/nthbit.h
src/include/fst/extensions/pdt/collection.h
src/include/fst/extensions/pdt/compose.h
src/include/fst/extensions/pdt/expand.h
src/include/fst/extensions/pdt/getters.h
src/include/fst/extensions/pdt/info.h
src/include/fst/extensions/pdt/paren.h
src/include/fst/extensions/pdt/pdtscript.h
src/include/fst/extensions/pdt/replace.h
src/include/fst/extensions/pdt/shortest-path.h
src/include/fst/extensions/special/phi-fst.h
src/include/fst/extensions/special/rho-fst.h
src/include/fst/extensions/special/sigma-fst.h
src/include/fst/factor-weight.h
src/include/fst/filter-state.h
src/include/fst/flags.h
src/include/fst/float-weight.h
src/include/fst/fst-decl.h
src/include/fst/fst.h
src/include/fst/fstlib.h
src/include/fst/generic-register.h
src/include/fst/heap.h
src/include/fst/icu.h
src/include/fst/interval-set.h
src/include/fst/invert.h
src/include/fst/isomorphic.h
src/include/fst/label-reachable.h
src/include/fst/lexicographic-weight.h
src/include/fst/lock.h
src/include/fst/log.h
src/include/fst/lookahead-filter.h
src/include/fst/lookahead-matcher.h
src/include/fst/map.h [deleted file]
src/include/fst/matcher-fst.h
src/include/fst/matcher.h
src/include/fst/memory.h
src/include/fst/minimize.h
src/include/fst/mutable-fst.h
src/include/fst/pair-weight.h
src/include/fst/partition.h
src/include/fst/power-weight.h
src/include/fst/product-weight.h
src/include/fst/project.h
src/include/fst/properties.h
src/include/fst/push.h
src/include/fst/queue.h
src/include/fst/randequivalent.h
src/include/fst/randgen.h
src/include/fst/rational.h
src/include/fst/register.h
src/include/fst/relabel.h
src/include/fst/replace-util.h
src/include/fst/replace.h
src/include/fst/reverse.h
src/include/fst/reweight.h
src/include/fst/rmepsilon.h
src/include/fst/rmfinalepsilon.h
src/include/fst/script/arc-class.h
src/include/fst/script/arcfilter-impl.h [new file with mode: 0644]
src/include/fst/script/arciterator-class.h
src/include/fst/script/arcsort.h
src/include/fst/script/arg-packs.h
src/include/fst/script/closure.h
src/include/fst/script/compile-impl.h
src/include/fst/script/compile.h
src/include/fst/script/compose.h
src/include/fst/script/concat.h
src/include/fst/script/convert.h
src/include/fst/script/decode.h
src/include/fst/script/determinize.h
src/include/fst/script/difference.h
src/include/fst/script/disambiguate.h
src/include/fst/script/draw-impl.h
src/include/fst/script/draw.h
src/include/fst/script/encode.h
src/include/fst/script/encodemapper-class.h
src/include/fst/script/epsnormalize.h
src/include/fst/script/equal.h
src/include/fst/script/equivalent.h
src/include/fst/script/fst-class.h
src/include/fst/script/fstscript.h
src/include/fst/script/getters.h
src/include/fst/script/info-impl.h
src/include/fst/script/info.h
src/include/fst/script/intersect.h
src/include/fst/script/isomorphic.h
src/include/fst/script/map.h
src/include/fst/script/minimize.h
src/include/fst/script/print-impl.h
src/include/fst/script/print.h
src/include/fst/script/project.h
src/include/fst/script/prune.h
src/include/fst/script/push.h
src/include/fst/script/randequivalent.h
src/include/fst/script/randgen.h
src/include/fst/script/relabel.h
src/include/fst/script/replace.h
src/include/fst/script/reverse.h
src/include/fst/script/reweight.h
src/include/fst/script/rmepsilon.h
src/include/fst/script/script-impl.h
src/include/fst/script/shortest-distance.h
src/include/fst/script/shortest-path.h
src/include/fst/script/stateiterator-class.h
src/include/fst/script/synchronize.h
src/include/fst/script/text-io.h
src/include/fst/script/topsort.h
src/include/fst/script/union.h
src/include/fst/script/verify.h
src/include/fst/script/weight-class.h
src/include/fst/set-weight.h
src/include/fst/shortest-distance.h
src/include/fst/shortest-path.h
src/include/fst/signed-log-weight.h
src/include/fst/sparse-power-weight.h
src/include/fst/sparse-tuple-weight.h
src/include/fst/state-map.h
src/include/fst/state-table.h
src/include/fst/statesort.h
src/include/fst/string-weight.h
src/include/fst/string.h
src/include/fst/symbol-table-ops.h
src/include/fst/symbol-table.h
src/include/fst/synchronize.h
src/include/fst/test-properties.h
src/include/fst/test/algo_test.h
src/include/fst/test/compactors.h
src/include/fst/test/fst_test.h
src/include/fst/test/rand-fst.h
src/include/fst/test/weight-tester.h
src/include/fst/tuple-weight.h
src/include/fst/types.h [deleted file]
src/include/fst/union-find.h
src/include/fst/union-weight.h
src/include/fst/union.h
src/include/fst/util.h
src/include/fst/vector-fst.h
src/include/fst/verify.h
src/include/fst/visit.h
src/include/fst/weight.h
src/lib/Makefile.am
src/lib/Makefile.in
src/lib/compat.cc
src/lib/encode.cc
src/lib/flags.cc
src/lib/fst.cc
src/lib/mapped-file.cc
src/lib/properties.cc
src/lib/symbol-table-ops.cc
src/lib/symbol-table.cc
src/lib/util.cc
src/script/Makefile.am
src/script/Makefile.in
src/script/arciterator-class.cc
src/script/arcsort.cc
src/script/closure.cc
src/script/compile.cc
src/script/compose.cc
src/script/concat.cc
src/script/convert.cc
src/script/decode.cc
src/script/determinize.cc
src/script/difference.cc
src/script/disambiguate.cc
src/script/draw.cc
src/script/encode.cc
src/script/encodemapper-class.cc
src/script/epsnormalize.cc
src/script/equal.cc
src/script/equivalent.cc
src/script/fst-class.cc
src/script/getters.cc
src/script/info-impl.cc
src/script/info.cc
src/script/intersect.cc
src/script/isomorphic.cc
src/script/map.cc
src/script/minimize.cc
src/script/print.cc
src/script/project.cc
src/script/prune.cc
src/script/push.cc
src/script/randequivalent.cc
src/script/randgen.cc
src/script/relabel.cc
src/script/replace.cc
src/script/reverse.cc
src/script/reweight.cc
src/script/rmepsilon.cc
src/script/shortest-distance.cc
src/script/shortest-path.cc
src/script/stateiterator-class.cc
src/script/synchronize.cc
src/script/text-io.cc
src/script/topsort.cc
src/script/union.cc
src/script/verify.cc
src/script/weight-class.cc
src/test/Makefile.in
src/test/algo_test.cc
src/test/fst_test.cc
src/test/weight_test.cc
test-driver

index 4ba1eab..aa2c84b 100644 (file)
@@ -30,6 +30,13 @@ DEFINES = select({
     "//conditions:default": [],
 })
 
+# Following default compile options will disable signed/unsigned integer
+# comparison warning for gcc/clang and Microsoft Visual Studio compilers.
+COPTS = select({
+    "@bazel_tools//src/conditions:windows": ["/wd4388"],
+    "//conditions:default": ["-Wno-sign-compare"],
+})
+
 prefix_dir = "src/"
 
 static_binary = 1
@@ -85,7 +92,6 @@ PUBLIC_HEADERS = [
     prefix_dir + "include/fst/label-reachable.h",
     prefix_dir + "include/fst/lookahead-filter.h",
     prefix_dir + "include/fst/lookahead-matcher.h",
-    prefix_dir + "include/fst/map.h",
     prefix_dir + "include/fst/matcher-fst.h",
     prefix_dir + "include/fst/matcher.h",
     prefix_dir + "include/fst/memory.h",
@@ -136,7 +142,7 @@ cc_library(
         prefix_dir + "lib/symbol-table-ops.cc",
     ],
     hdrs = PUBLIC_HEADERS,
-    copts = ["-Wno-sign-compare"],
+    copts = COPTS,
     defines = DEFINES,
     includes = [prefix_dir + "include"],
     linkopts = ["-lm"],
@@ -182,7 +188,7 @@ cc_library(
     name = "symbol-table",
     srcs = [prefix_dir + "lib/symbol-table.cc"],
     hdrs = [prefix_dir + "include/fst/symbol-table.h"],
-    copts = ["-Wno-sign-compare"],
+    copts = COPTS,
     defines = DEFINES,
     includes = [prefix_dir + "include"],
     deps = [
@@ -280,12 +286,10 @@ cc_library(
     ],
     hdrs = [
         prefix_dir + "include/fst/compat.h",
-        prefix_dir + "include/fst/config.h",
         prefix_dir + "include/fst/flags.h",
         prefix_dir + "include/fst/icu.h",
         prefix_dir + "include/fst/lock.h",
         prefix_dir + "include/fst/log.h",
-        prefix_dir + "include/fst/types.h",
         prefix_dir + "include/fst/windows_defs.inc",
     ],
     defines = select({
@@ -325,7 +329,10 @@ cc_test(
     name = "weight_test",
     timeout = "short",
     srcs = [prefix_dir + "test/weight_test.cc"],
-    copts = ["-Wno-unused-local-typedefs"],
+    copts = COPTS + select({
+        "@bazel_tools//src/conditions:windows": [],
+        "//conditions:default": ["-Wno-unused-local-typedefs"],
+    }),
     deps = [
         ":fst",
         ":weight-tester",
@@ -367,6 +374,7 @@ cc_library(
     ],
     hdrs = [
         prefix_dir + "include/fst/script/arc-class.h",
+        prefix_dir + "include/fst/script/arcfilter-impl.h",
         prefix_dir + "include/fst/script/arciterator-class.h",
         prefix_dir + "include/fst/script/arg-packs.h",
         prefix_dir + "include/fst/script/encodemapper-class.h",
@@ -423,7 +431,7 @@ cc_library(
         prefix_dir + "include/fst/script/union.h",
         prefix_dir + "include/fst/script/verify.h",
     ],
-    copts = ["-Wno-sign-compare"],
+    copts = COPTS,
     includes = [prefix_dir + "include"],
     deps = [":fst"],
 )
@@ -753,7 +761,6 @@ cc_library(
 
 cc_library(
     name = "far",
-    srcs = [prefix_dir + "extensions/far/strings.cc"],
     hdrs = [
         prefix_dir + "include/fst/extensions/far/compile-strings.h",
         prefix_dir + "include/fst/extensions/far/convert.h",
@@ -775,11 +782,11 @@ cc_library(
 cc_library(
     name = "farscript",
     srcs = [
+        prefix_dir + "extensions/far/compile-strings.cc",
         prefix_dir + "extensions/far/far-class.cc",
         prefix_dir + "extensions/far/farscript.cc",
         prefix_dir + "extensions/far/getters.cc",
         prefix_dir + "extensions/far/script-impl.cc",
-        prefix_dir + "extensions/far/strings.cc",
     ],
     hdrs = [
         prefix_dir + "include/fst/extensions/far/compile-strings.h",
@@ -1080,6 +1087,7 @@ cc_library(
     linkstatic = 1,
     deps = [
         ":fst",
+        ":pdt",
     ],
 )
 
@@ -1096,6 +1104,7 @@ cc_library(
         ":base",
         ":fstscript_base",
         ":linear-fst",
+        ":pdt",
     ],
 )
 
index 2e5456b..06b7ea1 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -100,7 +100,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_@AM_V@)
@@ -156,14 +156,10 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
-CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
-am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
-       $(top_srcdir)/src/include/fst/config.h.in AUTHORS COPYING \
-       INSTALL NEWS README ar-lib compile config.guess config.sub \
-       install-sh ltmain.sh missing
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
+       COPYING INSTALL NEWS README ar-lib compile config.guess \
+       config.sub depcomp install-sh ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -219,8 +215,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -236,6 +233,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -398,16 +396,8 @@ $(srcdir)/config.h.in:  $(am__configure_deps)
        rm -f stamp-h1
        touch $@
 
-src/include/fst/config.h: src/include/fst/stamp-h2
-       @test -f $@ || rm -f src/include/fst/stamp-h2
-       @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) src/include/fst/stamp-h2
-
-src/include/fst/stamp-h2: $(top_srcdir)/src/include/fst/config.h.in $(top_builddir)/config.status
-       @rm -f src/include/fst/stamp-h2
-       cd $(top_builddir) && $(SHELL) ./config.status src/include/fst/config.h
-
 distclean-hdr:
-       -rm -f config.h stamp-h1 src/include/fst/config.h src/include/fst/stamp-h2
+       -rm -f config.h stamp-h1
 
 mostlyclean-libtool:
        -rm -f *.lo
@@ -523,7 +513,6 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
        -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
diff --git a/NEWS b/NEWS
index 5dda925..e7dd25b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,7 @@
 OpenFst: Release 1.8
+   * Adds farencode (1.8.2)
+   * Deletes MakeArcMapFst in favor of CTAD on ArcMapFst (1.8.2)
+   * Removes `int64` (etc.) type shims in place of <cstdint> (1.8.2)
    * Expands smart-pointer use (1.8.1)
    * Expands std::string_view use (1.8.1)
    * Removes SymbolTableReadOptions (1.8.1)
index 768503b..6da25a1 100644 (file)
@@ -28,6 +28,6 @@ http_archive(
 
 http_archive(
     name = "com_google_googletest",
-    strip_prefix = "googletest-master",
-    urls = ["https://github.com/google/googletest/archive/master.zip"],
+    strip_prefix = "googletest-main",
+    urls = ["https://github.com/google/googletest/archive/main.zip"],
 )
index f7d7d3e..fda39b1 100644 (file)
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.16.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
 
-# Copyright (C) 1996-2020 Free Software Foundation, Inc.
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
-[m4_warning([this file was generated for autoconf 2.69.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
+[m4_warning([this file was generated for autoconf 2.71.
 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-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
 [am__api_version='1.16'
 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.16.3], [],
+m4_if([$1], [1.16.5], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_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.16.3])dnl
+[AM_AUTOMAKE_VERSION([1.16.5])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
-# Copyright (C) 2011-2020 Free Software Foundation, Inc.
+# Copyright (C) 2011-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -118,7 +118,7 @@ AC_SUBST([AR])dnl
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -170,7 +170,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2020 Free Software Foundation, Inc.
+# Copyright (C) 1997-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -201,7 +201,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2020 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -392,7 +392,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2020 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -460,7 +460,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2020 Free Software Foundation, Inc.
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -488,6 +488,10 @@ m4_defn([AC_PROG_CC])
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
 [AC_PREREQ([2.65])dnl
+m4_ifdef([_$0_ALREADY_INIT],
+  [m4_fatal([$0 expanded multiple times
+]m4_defn([_$0_ALREADY_INIT]))],
+  [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])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
@@ -524,7 +528,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
 [_AM_SET_OPTIONS([$1])dnl
 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
 m4_if(
-  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
   [ok:ok],,
   [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
@@ -576,6 +580,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
                  [m4_define([AC_PROG_OBJCXX],
                             m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
 ])
+# Variables for tags utilities; see am/tags.am
+if test -z "$CTAGS"; then
+  CTAGS=ctags
+fi
+AC_SUBST([CTAGS])
+if test -z "$ETAGS"; then
+  ETAGS=etags
+fi
+AC_SUBST([ETAGS])
+if test -z "$CSCOPE"; then
+  CSCOPE=cscope
+fi
+AC_SUBST([CSCOPE])
+
 AC_REQUIRE([AM_SILENT_RULES])dnl
 dnl The testsuite driver may need to know about EXEEXT, so add the
 dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
@@ -657,7 +675,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -678,7 +696,7 @@ if test x"${install_sh+set}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2020 Free Software Foundation, Inc.
+# Copyright (C) 2003-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -699,7 +717,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.                 -*- Autoconf -*-
 
-# Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -742,7 +760,7 @@ AC_SUBST([am__quote])])
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2020 Free Software Foundation, Inc.
+# Copyright (C) 1997-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -776,7 +794,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -805,7 +823,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2020 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -852,7 +870,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 1999-2020 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -887,6 +905,7 @@ AC_DEFUN([AM_PATH_PYTHON],
   dnl supported. (2.0 was released on October 16, 2000).
   m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
 [python python2 python3 dnl
+ python3.11 python3.10 dnl
  python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 dnl
  python3.2 python3.1 python3.0 dnl
  python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 dnl
@@ -931,7 +950,7 @@ AC_DEFUN([AM_PATH_PYTHON],
   ])
 
   if test "$PYTHON" = :; then
-  dnl Run any user-specified action, or abort.
+    dnl Run any user-specified action, or abort.
     m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
   else
 
@@ -940,27 +959,132 @@ AC_DEFUN([AM_PATH_PYTHON],
   dnl trailing zero was eliminated. So now we output just the major
   dnl and minor version numbers, as numbers. Apparently the tertiary
   dnl version is not of interest.
-
+  dnl
   AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
-    [am_cv_python_version=`$PYTHON -c "import sys; print('%u.%u' % sys.version_info[[:2]])"`])
+    [am_cv_python_version=`$PYTHON -c "import sys; print ('%u.%u' % sys.version_info[[:2]])"`])
   AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
 
-  dnl Use the values of $prefix and $exec_prefix for the corresponding
-  dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
-  dnl distinct variables so they can be overridden if need be.  However,
-  dnl general consensus is that you shouldn't need this ability.
-
-  AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
-  AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
-
-  dnl At times (like when building shared libraries) you may want
+  dnl At times, e.g., when building shared libraries, you may want
   dnl to know which OS platform Python thinks this is.
-
+  dnl
   AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
     [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
   AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
 
-  # Just factor out some code duplication.
+  dnl emacs-page
+  dnl If --with-python-sys-prefix is given, use the values of sys.prefix
+  dnl and sys.exec_prefix for the corresponding values of PYTHON_PREFIX
+  dnl and PYTHON_EXEC_PREFIX. Otherwise, use the GNU ${prefix} and
+  dnl ${exec_prefix} variables.
+  dnl
+  dnl The two are made distinct variables so they can be overridden if
+  dnl need be, although general consensus is that you shouldn't need
+  dnl this separation.
+  dnl
+  dnl Also allow directly setting the prefixes via configure options,
+  dnl overriding any default.
+  dnl
+  if test "x$prefix" = xNONE; then
+    am__usable_prefix=$ac_default_prefix
+  else
+    am__usable_prefix=$prefix
+  fi
+
+  # Allow user to request using sys.* values from Python,
+  # instead of the GNU $prefix values.
+  AC_ARG_WITH([python-sys-prefix],
+  [AS_HELP_STRING([--with-python-sys-prefix],
+                  [use Python's sys.prefix and sys.exec_prefix values])],
+  [am_use_python_sys=:],
+  [am_use_python_sys=false])
+
+  # Allow user to override whatever the default Python prefix is.
+  AC_ARG_WITH([python_prefix],
+  [AS_HELP_STRING([--with-python_prefix],
+                  [override the default PYTHON_PREFIX])],
+  [am_python_prefix_subst=$withval
+   am_cv_python_prefix=$withval
+   AC_MSG_CHECKING([for explicit $am_display_PYTHON prefix])
+   AC_MSG_RESULT([$am_cv_python_prefix])],
+  [
+   if $am_use_python_sys; then
+     # using python sys.prefix value, not GNU
+     AC_CACHE_CHECK([for python default $am_display_PYTHON prefix],
+     [am_cv_python_prefix],
+     [am_cv_python_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`])
+
+     dnl If sys.prefix is a subdir of $prefix, replace the literal value of
+     dnl $prefix with a variable reference so it can be overridden.
+     case $am_cv_python_prefix in
+     $am__usable_prefix*)
+       am__strip_prefix=`echo "$am__usable_prefix" | sed 's|.|.|g'`
+       am_python_prefix_subst=`echo "$am_cv_python_prefix" | sed "s,^$am__strip_prefix,\\${prefix},"`
+       ;;
+     *)
+       am_python_prefix_subst=$am_cv_python_prefix
+       ;;
+     esac
+   else # using GNU prefix value, not python sys.prefix
+     am_python_prefix_subst='${prefix}'
+     am_python_prefix=$am_python_prefix_subst
+     AC_MSG_CHECKING([for GNU default $am_display_PYTHON prefix])
+     AC_MSG_RESULT([$am_python_prefix])
+   fi])
+  # Substituting python_prefix_subst value.
+  AC_SUBST([PYTHON_PREFIX], [$am_python_prefix_subst])
+
+  # emacs-page Now do it all over again for Python exec_prefix, but with yet
+  # another conditional: fall back to regular prefix if that was specified.
+  AC_ARG_WITH([python_exec_prefix],
+  [AS_HELP_STRING([--with-python_exec_prefix],
+                  [override the default PYTHON_EXEC_PREFIX])],
+  [am_python_exec_prefix_subst=$withval
+   am_cv_python_exec_prefix=$withval
+   AC_MSG_CHECKING([for explicit $am_display_PYTHON exec_prefix])
+   AC_MSG_RESULT([$am_cv_python_exec_prefix])],
+  [
+   # no explicit --with-python_exec_prefix, but if
+   # --with-python_prefix was given, use its value for python_exec_prefix too.
+   AS_IF([test -n "$with_python_prefix"],
+   [am_python_exec_prefix_subst=$with_python_prefix
+    am_cv_python_exec_prefix=$with_python_prefix
+    AC_MSG_CHECKING([for python_prefix-given $am_display_PYTHON exec_prefix])
+    AC_MSG_RESULT([$am_cv_python_exec_prefix])],
+   [
+    # Set am__usable_exec_prefix whether using GNU or Python values,
+    # since we use that variable for pyexecdir.
+    if test "x$exec_prefix" = xNONE; then
+      am__usable_exec_prefix=$am__usable_prefix
+    else
+      am__usable_exec_prefix=$exec_prefix
+    fi
+    #
+    if $am_use_python_sys; then # using python sys.exec_prefix, not GNU
+      AC_CACHE_CHECK([for python default $am_display_PYTHON exec_prefix],
+      [am_cv_python_exec_prefix],
+      [am_cv_python_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`])
+      dnl If sys.exec_prefix is a subdir of $exec_prefix, replace the
+      dnl literal value of $exec_prefix with a variable reference so it can
+      dnl be overridden.
+      case $am_cv_python_exec_prefix in
+      $am__usable_exec_prefix*)
+        am__strip_prefix=`echo "$am__usable_exec_prefix" | sed 's|.|.|g'`
+        am_python_exec_prefix_subst=`echo "$am_cv_python_exec_prefix" | sed "s,^$am__strip_prefix,\\${exec_prefix},"`
+        ;;
+      *)
+        am_python_exec_prefix_subst=$am_cv_python_exec_prefix
+        ;;
+     esac
+   else # using GNU $exec_prefix, not python sys.exec_prefix
+     am_python_exec_prefix_subst='${exec_prefix}'
+     am_python_exec_prefix=$am_python_exec_prefix_subst
+     AC_MSG_CHECKING([for GNU default $am_display_PYTHON exec_prefix])
+     AC_MSG_RESULT([$am_python_exec_prefix])
+   fi])])
+  # Substituting python_exec_prefix_subst.
+  AC_SUBST([PYTHON_EXEC_PREFIX], [$am_python_exec_prefix_subst])
+
+  # Factor out some code duplication into this shell variable.
   am_python_setup_sysconfig="\
 import sys
 # Prefer sysconfig over distutils.sysconfig, for better compatibility
@@ -980,96 +1104,95 @@ try:
 except ImportError:
     pass"
 
-  dnl Set up 4 directories:
+  dnl emacs-page Set up 4 directories:
 
-  dnl pythondir -- where to install python scripts.  This is the
-  dnl   site-packages directory, not the python standard library
-  dnl   directory like in previous automake betas.  This behavior
-  dnl   is more consistent with lispdir.m4 for example.
+  dnl 1. pythondir: where to install python scripts.  This is the
+  dnl    site-packages directory, not the python standard library
+  dnl    directory like in previous automake betas.  This behavior
+  dnl    is more consistent with lispdir.m4 for example.
   dnl Query distutils for this directory.
-  AC_CACHE_CHECK([for $am_display_PYTHON script directory],
-    [am_cv_python_pythondir],
-    [if test "x$prefix" = xNONE
-     then
-       am_py_prefix=$ac_default_prefix
-     else
-       am_py_prefix=$prefix
-     fi
-     am_cv_python_pythondir=`$PYTHON -c "
+  dnl
+  AC_CACHE_CHECK([for $am_display_PYTHON script directory (pythondir)],
+  [am_cv_python_pythondir],
+  [if test "x$am_cv_python_prefix" = x; then
+     am_py_prefix=$am__usable_prefix
+   else
+     am_py_prefix=$am_cv_python_prefix
+   fi
+   am_cv_python_pythondir=`$PYTHON -c "
 $am_python_setup_sysconfig
 if can_use_sysconfig:
-    sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+  sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
 else:
-    from distutils import sysconfig
-    sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
+  from distutils import sysconfig
+  sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
 sys.stdout.write(sitedir)"`
-     case $am_cv_python_pythondir in
-     $am_py_prefix*)
-       am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
-       am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
-       ;;
-     *)
-       case $am_py_prefix in
-         /usr|/System*) ;;
-         *)
-         am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
-         ;;
-       esac
-       ;;
+   #
+   case $am_cv_python_pythondir in
+   $am_py_prefix*)
+     am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+     am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,\\${PYTHON_PREFIX},"`
+     ;;
+   *)
+     case $am_py_prefix in
+       /usr|/System*) ;;
+       *) am_cv_python_pythondir="\${PYTHON_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
+          ;;
      esac
-    ])
+     ;;
+   esac
+  ])
   AC_SUBST([pythondir], [$am_cv_python_pythondir])
 
-  dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
-  dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
-  dnl   more consistent with the rest of automake.
-
+  dnl 2. pkgpythondir: $PACKAGE directory under pythondir.  Was
+  dnl    PYTHON_SITE_PACKAGE in previous betas, but this naming is
+  dnl    more consistent with the rest of automake.
+  dnl
   AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
 
-  dnl pyexecdir -- directory for installing python extension modules
-  dnl   (shared libraries)
+  dnl 3. pyexecdir: directory for installing python extension modules
+  dnl    (shared libraries).
   dnl Query distutils for this directory.
-  AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
-    [am_cv_python_pyexecdir],
-    [if test "x$exec_prefix" = xNONE
-     then
-       am_py_exec_prefix=$am_py_prefix
-     else
-       am_py_exec_prefix=$exec_prefix
-     fi
-     am_cv_python_pyexecdir=`$PYTHON -c "
+  dnl
+  AC_CACHE_CHECK([for $am_display_PYTHON extension module directory (pyexecdir)],
+  [am_cv_python_pyexecdir],
+  [if test "x$am_cv_python_exec_prefix" = x; then
+     am_py_exec_prefix=$am__usable_exec_prefix
+   else
+     am_py_exec_prefix=$am_cv_python_exec_prefix
+   fi
+   am_cv_python_pyexecdir=`$PYTHON -c "
 $am_python_setup_sysconfig
 if can_use_sysconfig:
-    sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
+  sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_exec_prefix'})
 else:
-    from distutils import sysconfig
-    sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
+  from distutils import sysconfig
+  sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_exec_prefix')
 sys.stdout.write(sitedir)"`
-     case $am_cv_python_pyexecdir in
-     $am_py_exec_prefix*)
-       am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
-       am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
-       ;;
-     *)
-       case $am_py_exec_prefix in
-         /usr|/System*) ;;
-         *)
-          am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
-          ;;
-       esac
-       ;;
+   #
+   case $am_cv_python_pyexecdir in
+   $am_py_exec_prefix*)
+     am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+     am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,\\${PYTHON_EXEC_PREFIX},"`
+     ;;
+   *)
+     case $am_py_exec_prefix in
+       /usr|/System*) ;;
+       *) am_cv_python_pyexecdir="\${PYTHON_EXEC_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
+          ;;
      esac
-    ])
+     ;;
+   esac
+  ])
   AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
 
-  dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
-
+  dnl 4. pkgpyexecdir: $(pyexecdir)/$(PACKAGE)
+  dnl
   AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
 
   dnl Run any user-specified action.
   $2
   fi
-
 ])
 
 
@@ -1092,7 +1215,7 @@ for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
 sys.exit(sys.hexversion < minverhex)"
   AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
 
-# Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1111,7 +1234,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2020 Free Software Foundation, Inc.
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1192,7 +1315,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2020 Free Software Foundation, Inc.
+# Copyright (C) 2009-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1252,7 +1375,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1280,7 +1403,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2020 Free Software Foundation, Inc.
+# Copyright (C) 2006-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1299,7 +1422,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2020 Free Software Foundation, Inc.
+# Copyright (C) 2004-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/ar-lib b/ar-lib
index 1e9388e..c349042 100755 (executable)
--- a/ar-lib
+++ b/ar-lib
@@ -4,7 +4,7 @@
 me=ar-lib
 scriptversion=2019-07-04.01; # UTC
 
-# Copyright (C) 2010-2020 Free Software Foundation, Inc.
+# Copyright (C) 2010-2021 Free Software Foundation, Inc.
 # Written by Peter Rosin <peda@lysator.liu.se>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/compile b/compile
index 23fcba0..df363c8 100755 (executable)
--- a/compile
+++ b/compile
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2020 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
index 82ee330..55ca5f8 100644 (file)
@@ -6,15 +6,15 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
 /* If available, contains the Python version number currently in use. */
 #undef HAVE_PYTHON
 
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
@@ -57,7 +57,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
 #undef STDC_HEADERS
 
 /* Version number of package */
index c0f5f80..3567f3a 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,11 +1,12 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for OpenFst 1.8.1.
+# Generated by GNU Autoconf 2.71 for OpenFst 1.8.2.
 #
 # Report bugs to <help@www.openfst.org>.
 #
 #
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
+# Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+as_nop=:
+if test ${ZSH_VERSION+y} && (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
+else $as_nop
   case `(set -o) 2>/dev/null` in #(
   *posix*) :
     set -o posix ;; #(
@@ -33,46 +36,46 @@ esac
 fi
 
 
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
 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
+IFS=" ""       $as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 
 # The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if ${PATH_SEPARATOR+false} :; 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 ||
@@ -81,13 +84,6 @@ if test "${PATH_SEPARATOR+set}" != set; then
 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.
 as_myself=
 case $0 in #((
@@ -96,8 +92,12 @@ case $0 in #((
 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
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
   done
 IFS=$as_save_IFS
 
@@ -109,30 +109,10 @@ 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
+  printf "%s\n" "$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
 
 # Use a proper internal environment variable to ensure we don't fall
   # into an infinite loop, continuously re-executing ourselves.
@@ -154,20 +134,22 @@ esac
 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
 # Admittedly, this is quite paranoid, since all the known shells bail
 # out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
   fi
   # We don't want this to propagate to other subprocesses.
           { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  as_bourne_compatible="as_nop=:
+if test \${ZSH_VERSION+y} && (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
+else \$as_nop
   case \`(set -o) 2>/dev/null\` in #(
   *posix*) :
     set -o posix ;; #(
@@ -187,12 +169,15 @@ 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 :
+if ( set x; as_fn_ret_success y && test x = \"\$1\" )
+then :
 
-else
+else \$as_nop
   exitcode=1; echo positional parameters were not saved.
 fi
 test x\$exitcode = x0 || exit 1
+blah=\$(echo \$(echo blah))
+test x\"\$blah\" = xblah || exit 1
 test -x / || 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
@@ -207,30 +192,38 @@ test -x / || exit 1"
     test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
       || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
 test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
+  if (eval "$as_required") 2>/dev/null
+then :
   as_have_required=yes
-else
+else $as_nop
   as_have_required=no
 fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null
+then :
 
-else
+else $as_nop
   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=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
   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
+            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 :
+                   as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 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 :
+                  if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null
+then :
   break 2
 fi
 fi
@@ -238,14 +231,21 @@ fi
        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 $as_found
+then :
+
+else $as_nop
+  if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi
+fi
 
 
-      if test "x$CONFIG_SHELL" != x; then :
+      if test "x$CONFIG_SHELL" != x
+then :
   export CONFIG_SHELL
              # We cannot yet assume a decent shell, so we have to provide a
 # neutralization value for shells without unset; and this also
@@ -263,18 +263,19 @@ esac
 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
 # Admittedly, this is quite paranoid, since all the known shells bail
 # out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2
 exit 255
 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."
+    if test x$as_have_required = xno
+then :
+  printf "%s\n" "$0: This script requires a shell more modern than all"
+  printf "%s\n" "$0: the shells that I found on your system."
+  if test ${ZSH_VERSION+y} ; then
+    printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later."
   else
-    $as_echo "$0: Please tell bug-autoconf@gnu.org and
+    printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and
 $0: help@www.openfst.org about your system, including any
 $0: error possibly output before this message. Then install
 $0: a modern shell, or manually run the script under such a
@@ -302,6 +303,7 @@ as_fn_unset ()
 }
 as_unset=as_fn_unset
 
+
 # as_fn_set_status STATUS
 # -----------------------
 # Set $? to STATUS, without forking.
@@ -319,6 +321,14 @@ as_fn_exit ()
   as_fn_set_status $1
   exit $1
 } # as_fn_exit
+# as_fn_nop
+# ---------
+# Do nothing but, unlike ":", preserve the value of $?.
+as_fn_nop ()
+{
+  return $?
+}
+as_nop=as_fn_nop
 
 # as_fn_mkdir_p
 # -------------
@@ -333,7 +343,7 @@ as_fn_mkdir_p ()
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
@@ -342,7 +352,7 @@ $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" |
+printf "%s\n" X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
            s//\1/
            q
@@ -381,12 +391,13 @@ as_fn_executable_p ()
 # 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 :
+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
+else $as_nop
   as_fn_append ()
   {
     eval $1=\$$1\$2
@@ -398,18 +409,27 @@ fi # as_fn_append
 # 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 :
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
   eval 'as_fn_arith ()
   {
     as_val=$(( $* ))
   }'
-else
+else $as_nop
   as_fn_arith ()
   {
     as_val=`expr "$@" || test $? -eq 1`
   }
 fi # as_fn_arith
 
+# as_fn_nop
+# ---------
+# Do nothing but, unlike ":", preserve the value of $?.
+as_fn_nop ()
+{
+  return $?
+}
+as_nop=as_fn_nop
 
 # as_fn_error STATUS ERROR [LINENO LOG_FD]
 # ----------------------------------------
@@ -421,9 +441,9 @@ as_fn_error ()
   as_status=$1; test $as_status -eq 0 && as_status=1
   if test "$4"; then
     as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $2" >&2
+  printf "%s\n" "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -450,7 +470,7 @@ as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
         X"$0" : 'X\(//\)$' \| \
         X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
+printf "%s\n" X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
            s//\1/
            q
@@ -494,7 +514,7 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
       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; }
+    { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
   # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
   # already done that, so ensure we don't try to do so again and fall
@@ -508,6 +528,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   exit
 }
 
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
 ECHO_C= ECHO_N= ECHO_T=
 case `echo -n x` in #(((((
 -n*)
@@ -521,6 +545,13 @@ case `echo -n x` in #(((((
   ECHO_N='-n';;
 esac
 
+# For backward compatibility with old third-party macros, we provide
+# the shell variables $as_echo and $as_echo_n.  New code should use
+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.
+as_echo='printf %s\n'
+as_echo_n='printf %s'
+
+
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
@@ -590,47 +621,43 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='OpenFst'
 PACKAGE_TARNAME='openfst'
-PACKAGE_VERSION='1.8.1'
-PACKAGE_STRING='OpenFst 1.8.1'
+PACKAGE_VERSION='1.8.2'
+PACKAGE_STRING='OpenFst 1.8.2'
 PACKAGE_BUGREPORT='help@www.openfst.org'
 PACKAGE_URL=''
 
 # Factoring default headers for most tests.
 ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
+#include <stddef.h>
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
 #endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
+#ifdef HAVE_STDLIB_H
 # include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
 #endif
 #ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
 # include <string.h>
 #endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
 #ifdef HAVE_INTTYPES_H
 # include <inttypes.h>
 #endif
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
 #endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif"
 
+ac_header_c_list=
 ac_unique_file="src/lib/fst.cc"
 ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
@@ -657,9 +684,9 @@ pkgpyexecdir
 pyexecdir
 pkgpythondir
 pythondir
-PYTHON_PLATFORM
 PYTHON_EXEC_PREFIX
 PYTHON_PREFIX
+PYTHON_PLATFORM
 PYTHON_VERSION
 PYTHON
 HAVE_PYTHON_FALSE
@@ -683,7 +710,6 @@ HAVE_COMPRESS_TRUE
 HAVE_COMPACT_FALSE
 HAVE_COMPACT_TRUE
 CXXCPP
-CPP
 LT_SYS_LIBRARY_PATH
 OTOOL64
 OTOOL
@@ -740,6 +766,9 @@ AM_BACKSLASH
 AM_DEFAULT_VERBOSITY
 AM_DEFAULT_V
 AM_V
+CSCOPE
+ETAGS
+CTAGS
 am__untar
 am__tar
 AMTAR
@@ -826,6 +855,9 @@ enable_mpdt
 enable_ngram_fsts
 enable_pdt
 enable_python
+with_python_sys_prefix
+with_python_prefix
+with_python_exec_prefix
 enable_special
 enable_bin
 enable_fsts
@@ -844,7 +876,6 @@ CXX
 CXXFLAGS
 CCC
 LT_SYS_LIBRARY_PATH
-CPP
 CXXCPP
 PYTHON
 PYTHON_VERSION'
@@ -916,8 +947,6 @@ do
   *)    ac_optarg=yes ;;
   esac
 
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
   case $ac_dashdash$ac_option in
   --)
     ac_dashdash=yes ;;
@@ -958,9 +987,9 @@ do
     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"
+      as_fn_error $? "invalid feature name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "enable_$ac_useropt"
@@ -984,9 +1013,9 @@ do
     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"
+      as_fn_error $? "invalid feature name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "enable_$ac_useropt"
@@ -1197,9 +1226,9 @@ do
     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"
+      as_fn_error $? "invalid package name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "with_$ac_useropt"
@@ -1213,9 +1242,9 @@ do
     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"
+      as_fn_error $? "invalid package name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "with_$ac_useropt"
@@ -1259,9 +1288,9 @@ Try \`$0 --help' for more information"
 
   *)
     # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    printf "%s\n" "$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
+      printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2
     : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
     ;;
 
@@ -1277,7 +1306,7 @@ 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 ;;
+    *)     printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
 
@@ -1341,7 +1370,7 @@ $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" |
+printf "%s\n" X"$as_myself" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
            s//\1/
            q
@@ -1398,7 +1427,7 @@ 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 OpenFst 1.8.1 to adapt to many kinds of systems.
+\`configure' configures OpenFst 1.8.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1469,7 +1498,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of OpenFst 1.8.1:";;
+     short | recursive ) echo "Configuration of OpenFst 1.8.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1514,6 +1543,11 @@ Optional Packages:
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
                           compiler's sysroot if not specified).
+  --with-python-sys-prefix
+                          use Python's sys.prefix and sys.exec_prefix values
+  --with-python_prefix    override the default PYTHON_PREFIX
+  --with-python_exec_prefix
+                          override the default PYTHON_EXEC_PREFIX
 --with-libfstdir=DIR fst dynamic extensions [LIBDIR/fst]
 
 Some influential environment variables:
@@ -1528,7 +1562,6 @@ Some influential environment variables:
   CXXFLAGS    C++ compiler flags
   LT_SYS_LIBRARY_PATH
               User-defined run-time library search path.
-  CPP         C preprocessor
   CXXCPP      C++ preprocessor
   PYTHON      the Python interpreter
   PYTHON_VERSION
@@ -1555,9 +1588,9 @@ if test "$ac_init_help" = "recursive"; then
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  ac_dir_suffix=/`printf "%s\n" "$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|/||'`
+  ac_top_builddir_sub=`printf "%s\n" "$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/ ;;
@@ -1585,7 +1618,8 @@ esac
 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 
     cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
+    # Check for configure.gnu first; this name is used for a wrapper for
+    # Metaconfig's "Configure" on case-insensitive file systems.
     if test -f "$ac_srcdir/configure.gnu"; then
       echo &&
       $SHELL "$ac_srcdir/configure.gnu" --help=recursive
@@ -1593,7 +1627,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
       echo &&
       $SHELL "$ac_srcdir/configure" --help=recursive
     else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+      printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2
     fi || ac_status=$?
     cd "$ac_pwd" || { ac_status=$?; break; }
   done
@@ -1602,10 +1636,10 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-OpenFst configure 1.8.1
-generated by GNU Autoconf 2.69
+OpenFst configure 1.8.2
+generated by GNU Autoconf 2.71
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1622,14 +1656,14 @@ fi
 ac_fn_c_try_compile ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
+  rm -f conftest.$ac_objext conftest.beam
   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
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -1637,14 +1671,15 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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 :
+       } && test -s conftest.$ac_objext
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
        ac_retval=1
@@ -1660,14 +1695,14 @@ fi
 ac_fn_cxx_try_compile ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
+  rm -f conftest.$ac_objext conftest.beam
   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
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -1675,14 +1710,15 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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 :
+       } && test -s conftest.$ac_objext
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
        ac_retval=1
@@ -1698,14 +1734,14 @@ fi
 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
+  rm -f conftest.$ac_objext conftest.beam 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
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -1713,17 +1749,18 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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 ||
         test -x conftest$ac_exeext
-       }; then :
+       }
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
        ac_retval=1
 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 eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $4
 #include <$2>
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   eval "$3=yes"
-else
+else $as_nop
   eval "$3=no"
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
+              { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_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; } > conftest.i && {
-        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; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# 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; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
 ac_fn_c_check_func ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 /* Define $2 to an innocuous variant, in case <limits.h> declares $2.
@@ -1866,16 +1827,9 @@ else
 #define $2 innocuous_$2
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
+   which can conflict with char $2 (); below.  */
 
+#include <limits.h>
 #undef $2
 
 /* Override any GCC internal prototype to avoid an error.
@@ -1893,24 +1847,25 @@ choke me
 #endif
 
 int
-main ()
+main (void)
 {
 return $2 ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   eval "$3=yes"
-else
+else $as_nop
   eval "$3=no"
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     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; }
+              { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_func
@@ -1927,7 +1882,7 @@ case "(($ac_try" in
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -1935,14 +1890,15 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } > conftest.i && {
         test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       }; then :
+       }
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
     ac_retval=1
@@ -1958,14 +1914,14 @@ fi
 ac_fn_cxx_try_link ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
+  rm -f conftest.$ac_objext conftest.beam 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
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -1973,17 +1929,18 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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_exeext && {
         test "$cross_compiling" = yes ||
         test -x conftest$ac_exeext
-       }; then :
+       }
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
        ac_retval=1
@@ -2000,8 +1957,8 @@ fi
 
 # ac_fn_cxx_try_run LINENO
 # ------------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
+# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that
+# executables *can* be run.
 ac_fn_cxx_try_run ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
@@ -2011,25 +1968,26 @@ case "(($ac_try" in
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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
+printf "%s\n" "$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 :
+  printf "%s\n" "$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
+else $as_nop
+  printf "%s\n" "$as_me: program exited with status $ac_status" >&5
+       printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
        ac_retval=$ac_status
@@ -2039,14 +1997,34 @@ fi
   as_fn_set_status $ac_retval
 
 } # ac_fn_cxx_try_run
+ac_configure_args_raw=
+for ac_arg
+do
+  case $ac_arg in
+  *\'*)
+    ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  as_fn_append ac_configure_args_raw " '$ac_arg'"
+done
+
+case $ac_configure_args_raw in
+  *$as_nl*)
+    ac_safe_unquote= ;;
+  *)
+    ac_unsafe_z='|&;<>()$`\\"*?[ ''    ' # This string ends in space, tab.
+    ac_unsafe_a="$ac_unsafe_z#~"
+    ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"
+    ac_configure_args_raw=`      printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;
+esac
+
 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 OpenFst $as_me 1.8.1, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+It was created by OpenFst $as_me 1.8.2, which was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
-  $ $0 $@
+  $ $0$ac_configure_args_raw
 
 _ACEOF
 exec 5>>config.log
@@ -2079,8 +2057,12 @@ 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"
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    printf "%s\n" "PATH: $as_dir"
   done
 IFS=$as_save_IFS
 
@@ -2115,7 +2097,7 @@ do
     | -silent | --silent | --silen | --sile | --sil)
       continue ;;
     *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
     1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
@@ -2150,11 +2132,13 @@ done
 # 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=$?
+  # Sanitize IFS.
+  IFS=" ""     $as_nl"
   # Save into config.log some information that might help in debugging.
   {
     echo
 
-    $as_echo "## ---------------- ##
+    printf "%s\n" "## ---------------- ##
 ## Cache variables. ##
 ## ---------------- ##"
     echo
@@ -2165,8 +2149,8 @@ trap 'exit_status=$?
     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;} ;;
+      *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
@@ -2190,7 +2174,7 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
 )
     echo
 
-    $as_echo "## ----------------- ##
+    printf "%s\n" "## ----------------- ##
 ## Output variables. ##
 ## ----------------- ##"
     echo
@@ -2198,14 +2182,14 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
     do
       eval ac_val=\$$ac_var
       case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
       esac
-      $as_echo "$ac_var='\''$ac_val'\''"
+      printf "%s\n" "$ac_var='\''$ac_val'\''"
     done | sort
     echo
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      printf "%s\n" "## ------------------- ##
 ## File substitutions. ##
 ## ------------------- ##"
       echo
@@ -2213,15 +2197,15 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       do
        eval ac_val=\$$ac_var
        case $ac_val in
-       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
        esac
-       $as_echo "$ac_var='\''$ac_val'\''"
+       printf "%s\n" "$ac_var='\''$ac_val'\''"
       done | sort
       echo
     fi
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      printf "%s\n" "## ----------- ##
 ## confdefs.h. ##
 ## ----------- ##"
       echo
@@ -2229,8 +2213,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       echo
     fi
     test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
+      printf "%s\n" "$as_me: caught signal $ac_signal"
+    printf "%s\n" "$as_me: exit $exit_status"
   } >&5
   rm -f core *.core core.conftest.* &&
     rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
@@ -2244,63 +2228,48 @@ 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
+printf "%s\n" "/* confdefs.h */" > confdefs.h
 
 # Predefined preprocessor variables.
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
+printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
+printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
+printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
+printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
+printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
+printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h
 
 
 # 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
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_files="$CONFIG_SITE"
 elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
+  ac_site_files="$prefix/share/config.site $prefix/etc/config.site"
 else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
+  ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
 fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+
+for ac_site_file in $ac_site_files
 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;}
+  case $ac_site_file in #(
+  */*) :
+     ;; #(
+  *) :
+    ac_site_file=./$ac_site_file ;;
+esac
+  if test -f "$ac_site_file" && test -r "$ac_site_file"; then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
     . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+      || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "failed to load site script $ac_site_file
 See \`config.log' for more details" "$LINENO" 5; }
   fi
@@ -2310,120 +2279,725 @@ 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;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+printf "%s\n" "$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;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+printf "%s\n" "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $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. ##
-## -------------------- ##
+# Test code for whether the C compiler supports C89 (global declarations)
+ac_c_conftest_c89_globals='
+/* Does the compiler advertise C89 conformance?
+   Do not test the value of __STDC__, because some compilers set it to 0
+   while being otherwise adequately conformant. */
+#if !defined __STDC__
+# error "Compiler does not advertise C89 conformance"
+#endif
 
-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
+#include <stddef.h>
+#include <stdarg.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh.  */
+struct buf { int x; };
+struct buf * (*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 do not provoke an error unfortunately, instead are silently treated
+   as an "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 is necessary to write \x00 == 0 to get something
+   that is true only with -std.  */
+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];
 
-am__api_version='1.16'
+/* 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];
 
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-fi
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
+               int, int);'
 
-# 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.
+# Test code for whether the C compiler supports C89 (body of main).
+ac_c_conftest_c89_main='
+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
+'
 
+# Test code for whether the C compiler supports C99 (global declarations)
+ac_c_conftest_c99_globals='
+// Does the compiler advertise C99 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
+# error "Compiler does not advertise C99 conformance"
+#endif
 
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
+#include <stdbool.h>
+extern int puts (const char *);
+extern int printf (const char *, ...);
+extern int dprintf (int, const char *, ...);
+extern void *malloc (size_t);
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+// dprintf is used instead of fprintf to avoid needing to declare
+// FILE and stderr.
+#define debug(...) dprintf (2, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  #error "your preprocessor is broken"
+#endif
+#if BIG_OK
+#else
+  #error "your preprocessor is broken"
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static bool
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str = "";
+  int number = 0;
+  float fnumber = 0;
+
+  while (*format)
+    {
+      switch (*format++)
+       {
+       case '\''s'\'': // string
+         str = va_arg (args_copy, const char *);
+         break;
+       case '\''d'\'': // int
+         number = va_arg (args_copy, int);
+         break;
+       case '\''f'\'': // float
+         fnumber = va_arg (args_copy, double);
+         break;
+       default:
+         break;
+       }
+    }
+  va_end (args_copy);
+  va_end (args);
+
+  return *str && number && fnumber;
+}
+'
+
+# Test code for whether the C compiler supports C99 (body of main).
+ac_c_conftest_c99_main='
+  // Check bool.
+  _Bool success = false;
+  success |= (argc != 0);
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[0] = argv[0][0];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''
+        || dynamic_array[ni.number - 1] != 543);
+'
+
+# Test code for whether the C compiler supports C11 (global declarations)
+ac_c_conftest_c11_globals='
+// Does the compiler advertise C11 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
+# error "Compiler does not advertise C11 conformance"
+#endif
+
+// Check _Alignas.
+char _Alignas (double) aligned_as_double;
+char _Alignas (0) no_special_alignment;
+extern char aligned_as_int;
+char _Alignas (0) _Alignas (int) aligned_as_int;
+
+// Check _Alignof.
+enum
+{
+  int_alignment = _Alignof (int),
+  int_array_alignment = _Alignof (int[100]),
+  char_alignment = _Alignof (char)
+};
+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
+
+// Check _Noreturn.
+int _Noreturn does_not_return (void) { for (;;) continue; }
+
+// Check _Static_assert.
+struct test_static_assert
+{
+  int x;
+  _Static_assert (sizeof (int) <= sizeof (long int),
+                  "_Static_assert does not work in struct");
+  long int y;
+};
+
+// Check UTF-8 literals.
+#define u8 syntax error!
+char const utf8_literal[] = u8"happens to be ASCII" "another string";
+
+// Check duplicate typedefs.
+typedef long *long_ptr;
+typedef long int *long_ptr;
+typedef long_ptr long_ptr;
+
+// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
+struct anonymous
+{
+  union {
+    struct { int i; int j; };
+    struct { int k; long int l; } w;
+  };
+  int m;
+} v1;
+'
+
+# Test code for whether the C compiler supports C11 (body of main).
+ac_c_conftest_c11_main='
+  _Static_assert ((offsetof (struct anonymous, i)
+                  == offsetof (struct anonymous, w.k)),
+                 "Anonymous union alignment botch");
+  v1.i = 2;
+  v1.w.k = 5;
+  ok |= v1.i != 5;
+'
+
+# Test code for whether the C compiler supports C11 (complete).
+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+${ac_c_conftest_c11_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  ${ac_c_conftest_c11_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C99 (complete).
+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C89 (complete).
+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  return ok;
+}
+"
+
+# Test code for whether the C++ compiler supports C++98 (global declarations)
+ac_cxx_conftest_cxx98_globals='
+// Does the compiler advertise C++98 conformance?
+#if !defined __cplusplus || __cplusplus < 199711L
+# error "Compiler does not advertise C++98 conformance"
+#endif
+
+// These inclusions are to reject old compilers that
+// lack the unsuffixed header files.
+#include <cstdlib>
+#include <exception>
+
+// <cassert> and <cstring> are *not* freestanding headers in C++98.
+extern void assert (int);
+namespace std {
+  extern int strcmp (const char *, const char *);
+}
+
+// Namespaces, exceptions, and templates were all added after "C++ 2.0".
+using std::exception;
+using std::strcmp;
+
+namespace {
+
+void test_exception_syntax()
+{
+  try {
+    throw "test";
+  } catch (const char *s) {
+    // Extra parentheses suppress a warning when building autoconf itself,
+    // due to lint rules shared with more typical C programs.
+    assert (!(strcmp) (s, "test"));
+  }
+}
+
+template <typename T> struct test_template
+{
+  T const val;
+  explicit test_template(T t) : val(t) {}
+  template <typename U> T add(U u) { return static_cast<T>(u) + val; }
+};
+
+} // anonymous namespace
+'
+
+# Test code for whether the C++ compiler supports C++98 (body of main)
+ac_cxx_conftest_cxx98_main='
+  assert (argc);
+  assert (! argv[0]);
+{
+  test_exception_syntax ();
+  test_template<double> tt (2.0);
+  assert (tt.add (4) == 6.0);
+  assert (true && !false);
+}
+'
+
+# Test code for whether the C++ compiler supports C++11 (global declarations)
+ac_cxx_conftest_cxx11_globals='
+// Does the compiler advertise C++ 2011 conformance?
+#if !defined __cplusplus || __cplusplus < 201103L
+# error "Compiler does not advertise C++11 conformance"
+#endif
+
+namespace cxx11test
+{
+  constexpr int get_val() { return 20; }
+
+  struct testinit
+  {
+    int i;
+    double d;
+  };
+
+  class delegate
+  {
+  public:
+    delegate(int n) : n(n) {}
+    delegate(): delegate(2354) {}
+
+    virtual int getval() { return this->n; };
+  protected:
+    int n;
+  };
+
+  class overridden : public delegate
+  {
+  public:
+    overridden(int n): delegate(n) {}
+    virtual int getval() override final { return this->n * 2; }
+  };
+
+  class nocopy
+  {
+  public:
+    nocopy(int i): i(i) {}
+    nocopy() = default;
+    nocopy(const nocopy&) = delete;
+    nocopy & operator=(const nocopy&) = delete;
+  private:
+    int i;
+  };
+
+  // for testing lambda expressions
+  template <typename Ret, typename Fn> Ret eval(Fn f, Ret v)
+  {
+    return f(v);
+  }
+
+  // for testing variadic templates and trailing return types
+  template <typename V> auto sum(V first) -> V
+  {
+    return first;
+  }
+  template <typename V, typename... Args> auto sum(V first, Args... rest) -> V
+  {
+    return first + sum(rest...);
+  }
+}
+'
+
+# Test code for whether the C++ compiler supports C++11 (body of main)
+ac_cxx_conftest_cxx11_main='
+{
+  // Test auto and decltype
+  auto a1 = 6538;
+  auto a2 = 48573953.4;
+  auto a3 = "String literal";
+
+  int total = 0;
+  for (auto i = a3; *i; ++i) { total += *i; }
+
+  decltype(a2) a4 = 34895.034;
+}
+{
+  // Test constexpr
+  short sa[cxx11test::get_val()] = { 0 };
+}
+{
+  // Test initializer lists
+  cxx11test::testinit il = { 4323, 435234.23544 };
+}
+{
+  // Test range-based for
+  int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3,
+                 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
+  for (auto &x : array) { x += 23; }
+}
+{
+  // Test lambda expressions
+  using cxx11test::eval;
+  assert (eval ([](int x) { return x*2; }, 21) == 42);
+  double d = 2.0;
+  assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0);
+  assert (d == 5.0);
+  assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0);
+  assert (d == 5.0);
+}
+{
+  // Test use of variadic templates
+  using cxx11test::sum;
+  auto a = sum(1);
+  auto b = sum(1, 2);
+  auto c = sum(1.0, 2.0, 3.0);
+}
+{
+  // Test constructor delegation
+  cxx11test::delegate d1;
+  cxx11test::delegate d2();
+  cxx11test::delegate d3(45);
+}
+{
+  // Test override and final
+  cxx11test::overridden o1(55464);
+}
+{
+  // Test nullptr
+  char *c = nullptr;
+}
+{
+  // Test template brackets
+  test_template<::test_template<int>> v(test_template<int>(12));
+}
+{
+  // Unicode literals
+  char const *utf8 = u8"UTF-8 string \u2500";
+  char16_t const *utf16 = u"UTF-8 string \u2500";
+  char32_t const *utf32 = U"UTF-32 string \u2500";
+}
+'
+
+# Test code for whether the C compiler supports C++11 (complete).
+ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals}
+${ac_cxx_conftest_cxx11_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_cxx_conftest_cxx98_main}
+  ${ac_cxx_conftest_cxx11_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C++98 (complete).
+ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals}
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_cxx_conftest_cxx98_main}
+  return ok;
+}
+"
+
+as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H"
+as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H"
+as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H"
+as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H"
+as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H"
+as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"
+as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
+as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
+as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
+
+# Auxiliary files required by this configure script.
+ac_aux_files="config.guess config.sub ltmain.sh compile ar-lib missing install-sh"
+
+# Locations in which to look for auxiliary files.
+ac_aux_dir_candidates="${srcdir}${PATH_SEPARATOR}${srcdir}/..${PATH_SEPARATOR}${srcdir}/../.."
+
+# Search for a directory containing all of the required auxiliary files,
+# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates.
+# If we don't find one directory that contains all the files we need,
+# we report the set of missing files from the *first* directory in
+# $ac_aux_dir_candidates and give up.
+ac_missing_aux_files=""
+ac_first_candidate=:
+printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in $ac_aux_dir_candidates
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+  as_found=:
+
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}:  trying $as_dir" >&5
+  ac_aux_dir_found=yes
+  ac_install_sh=
+  for ac_aux in $ac_aux_files
+  do
+    # As a special case, if "install-sh" is required, that requirement
+    # can be satisfied by any of "install-sh", "install.sh", or "shtool",
+    # and $ac_install_sh is set appropriately for whichever one is found.
+    if test x"$ac_aux" = x"install-sh"
+    then
+      if test -f "${as_dir}install-sh"; then
+        printf "%s\n" "$as_me:${as_lineno-$LINENO}:   ${as_dir}install-sh found" >&5
+        ac_install_sh="${as_dir}install-sh -c"
+      elif test -f "${as_dir}install.sh"; then
+        printf "%s\n" "$as_me:${as_lineno-$LINENO}:   ${as_dir}install.sh found" >&5
+        ac_install_sh="${as_dir}install.sh -c"
+      elif test -f "${as_dir}shtool"; then
+        printf "%s\n" "$as_me:${as_lineno-$LINENO}:   ${as_dir}shtool found" >&5
+        ac_install_sh="${as_dir}shtool install -c"
+      else
+        ac_aux_dir_found=no
+        if $ac_first_candidate; then
+          ac_missing_aux_files="${ac_missing_aux_files} install-sh"
+        else
+          break
+        fi
+      fi
+    else
+      if test -f "${as_dir}${ac_aux}"; then
+        printf "%s\n" "$as_me:${as_lineno-$LINENO}:   ${as_dir}${ac_aux} found" >&5
+      else
+        ac_aux_dir_found=no
+        if $ac_first_candidate; then
+          ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}"
+        else
+          break
+        fi
+      fi
+    fi
+  done
+  if test "$ac_aux_dir_found" = yes; then
+    ac_aux_dir="$as_dir"
+    break
+  fi
+  ac_first_candidate=false
+
+  as_found=false
+done
+IFS=$as_save_IFS
+if $as_found
+then :
+
+else $as_nop
+  as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$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.
+if test -f "${ac_aux_dir}config.guess"; then
+  ac_config_guess="$SHELL ${ac_aux_dir}config.guess"
+fi
+if test -f "${ac_aux_dir}config.sub"; then
+  ac_config_sub="$SHELL ${ac_aux_dir}config.sub"
+fi
+if test -f "$ac_aux_dir/configure"; then
+  ac_configure="$SHELL ${ac_aux_dir}configure"
+fi
+
+# 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,)
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+printf "%s\n" "$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
+         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+printf "%s\n" "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+printf "%s\n" "$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=`printf "%s\n" "$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
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`${MAKE-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.16'
+
+
+
+  # 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
@@ -2436,20 +3010,25 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 # 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+printf %s "checking for a BSD-compatible install... " >&6; }
 if test -z "$INSTALL"; then
-if ${ac_cv_path_install+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+if test ${ac_cv_path_install+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   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]/* | \
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    # Account for fact that we put trailing slashes in our PATH walk.
+case $as_dir in #((
+  ./ | /[cC]/* | \
   /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
   ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
   /usr/ucb/* ) ;;
@@ -2459,13 +3038,13 @@ case $as_dir/ in #((
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-       if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+       if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then
          if test $ac_prog = install &&
-           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           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
+           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
@@ -2473,12 +3052,12 @@ case $as_dir/ in #((
            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" &&
+           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"
+             ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c"
              break 3
            fi
          fi
@@ -2494,7 +3073,7 @@ IFS=$as_save_IFS
 rm -rf conftest.one conftest.two conftest.dir
 
 fi
-  if test "${ac_cv_path_install+set}" = set; then
+  if test ${ac_cv_path_install+y}; then
     INSTALL=$ac_cv_path_install
   else
     # As a last resort, use the slow shell script.  Don't cache a
@@ -2504,8 +3083,8 @@ fi
     INSTALL=$ac_install_sh
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+printf "%s\n" "$INSTALL" >&6; }
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 # It thinks the first close brace ends the variable substitution.
@@ -2515,8 +3094,8 @@ 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+printf %s "checking whether build environment is sane... " >&6; }
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -2570,8 +3149,8 @@ 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 # If we didn't sleep, we still need to ensure time stamps of config.status and
 # generated files are strictly newer.
 am_sleep_pid=
@@ -2590,12 +3169,14 @@ test "$program_suffix" != NONE &&
 # 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"`
+program_transform_name=`printf "%s\n" "$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
+
+  if test x"${MISSING+set}" != xset; then
   MISSING="\${SHELL} '$am_aux_dir/missing'"
 fi
 # Use eval to expand $SHELL
@@ -2603,8 +3184,8 @@ if eval "$MISSING --is-lightweight"; then
   am_missing_run="$MISSING "
 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;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+printf "%s\n" "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
 if test x"${install_sh+set}" != xset; then
@@ -2624,11 +3205,12 @@ 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 ${ac_cv_prog_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_STRIP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$STRIP"; then
   ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
 else
@@ -2636,11 +3218,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -2651,11 +3237,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+printf "%s\n" "$STRIP" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -2664,11 +3250,12 @@ 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 ${ac_cv_prog_ac_ct_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_STRIP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_STRIP"; then
   ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
 else
@@ -2676,11 +3263,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -2691,11 +3282,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+printf "%s\n" "$ac_ct_STRIP" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_STRIP" = x; then
@@ -2703,8 +3294,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     STRIP=$ac_ct_STRIP
@@ -2716,25 +3307,31 @@ 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; }
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5
+printf %s "checking for a race-free mkdir -p... " >&6; }
 if test -z "$MKDIR_P"; then
-  if ${ac_cv_path_mkdir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${ac_cv_path_mkdir+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   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=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_prog in mkdir gmkdir; do
         for ac_exec_ext in '' $ac_executable_extensions; do
-          as_fn_executable_p "$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) '* | \
+          as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue
+          case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir ('*'coreutils) '* | \
+            'BusyBox '* | \
             'mkdir (fileutils) '4.1*)
-              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext
               break 3;;
           esac
         done
@@ -2745,7 +3342,7 @@ IFS=$as_save_IFS
 fi
 
   test -d ./--version && rmdir ./--version
-  if test "${ac_cv_path_mkdir+set}" = set; then
+  if test ${ac_cv_path_mkdir+y}; then
     MKDIR_P="$ac_cv_path_mkdir -p"
   else
     # As a last resort, use the slow shell script.  Don't cache a
@@ -2755,18 +3352,19 @@ fi
     MKDIR_P="$ac_install_sh -d"
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
-$as_echo "$MKDIR_P" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+printf "%s\n" "$MKDIR_P" >&6; }
 
 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 ${ac_cv_prog_AWK+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_AWK+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$AWK"; then
   ac_cv_prog_AWK="$AWK" # Let the user override the test.
 else
@@ -2774,11 +3372,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -2789,24 +3391,25 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+printf "%s\n" "$AWK" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+printf %s "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 eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval test \${ac_cv_prog_make_${ac_make}_set+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat >conftest.make <<\_ACEOF
 SHELL = /bin/sh
 all:
@@ -2822,12 +3425,12 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
   SET_MAKE=
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
@@ -2841,7 +3444,8 @@ fi
 rmdir .tst 2>/dev/null
 
 # Check whether --enable-silent-rules was given.
-if test "${enable_silent_rules+set}" = set; then :
+if test ${enable_silent_rules+y}
+then :
   enableval=$enable_silent_rules;
 fi
 
@@ -2851,12 +3455,13 @@ case $enable_silent_rules in # (((
     *) AM_DEFAULT_VERBOSITY=1;;
 esac
 am_make=${MAKE-make}
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
-$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
-if ${am_cv_make_support_nested_variables+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if $as_echo 'TRUE=$(BAR$(V))
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+printf %s "checking whether $am_make supports nested variables... " >&6; }
+if test ${am_cv_make_support_nested_variables+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if printf "%s\n" 'TRUE=$(BAR$(V))
 BAR0=false
 BAR1=true
 V=1
@@ -2868,8 +3473,8 @@ else
   am_cv_make_support_nested_variables=no
 fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
-$as_echo "$am_cv_make_support_nested_variables" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+printf "%s\n" "$am_cv_make_support_nested_variables" >&6; }
 if test $am_cv_make_support_nested_variables = yes; then
     AM_V='$(V)'
   AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
@@ -2901,17 +3506,13 @@ fi
 
 # Define the identity of the package.
  PACKAGE='openfst'
- VERSION='1.8.1'
+ VERSION='1.8.2'
 
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE "$PACKAGE"
-_ACEOF
+printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
 
 
-cat >>confdefs.h <<_ACEOF
-#define VERSION "$VERSION"
-_ACEOF
+printf "%s\n" "#define VERSION \"$VERSION\"" >>confdefs.h
 
 # Some tools Automake needs.
 
@@ -2951,6 +3552,20 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
+# Variables for tags utilities; see am/tags.am
+if test -z "$CTAGS"; then
+  CTAGS=ctags
+fi
+
+if test -z "$ETAGS"; then
+  ETAGS=etags
+fi
+
+if test -z "$CSCOPE"; then
+  CSCOPE=cscope
+fi
+
+
 
 # POSIX will say in a future version that running "rm -f" with no argument
 # is OK; and we want to be able to make that assumption in our Makefile
@@ -2994,12 +3609,21 @@ END
   fi
 fi
 
+
+
+
+
+
+
+
+
+
 DEPDIR="${am__leading_dot}deps"
 
 ac_config_commands="$ac_config_commands depfiles"
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5
-$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5
+printf %s "checking whether ${MAKE-make} supports the include directive... " >&6; }
 cat > confinc.mk << 'END'
 am__doit:
        @echo this is the am__doit target >confinc.out
@@ -3035,11 +3659,12 @@ esac
   fi
 done
 rm -f confinc.* confmf.*
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5
-$as_echo "${_am_result}" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5
+printf "%s\n" "${_am_result}" >&6; }
 
 # Check whether --enable-dependency-tracking was given.
-if test "${enable_dependency_tracking+set}" = set; then :
+if test ${enable_dependency_tracking+y}
+then :
   enableval=$enable_dependency_tracking;
 fi
 
@@ -3065,11 +3690,12 @@ 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 ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
@@ -3077,11 +3703,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -3092,11 +3722,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -3105,11 +3735,12 @@ 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 ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
@@ -3117,11 +3748,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -3132,11 +3767,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_CC" = x; then
@@ -3144,8 +3779,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
@@ -3158,11 +3793,12 @@ 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 ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
@@ -3170,11 +3806,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -3185,11 +3825,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -3198,11 +3838,12 @@ 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 ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
@@ -3211,15 +3852,19 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
      fi
     ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -3235,18 +3880,18 @@ if test $ac_prog_rejected = yes; then
     # 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+' '}$@"
+    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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -3257,11 +3902,12 @@ if test -z "$CC"; then
   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 ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
@@ -3269,11 +3915,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -3284,11 +3934,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -3301,11 +3951,12 @@ if test -z "$CC"; then
 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 ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
@@ -3313,11 +3964,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -3328,11 +3983,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -3344,34 +3999,138 @@ done
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.
+set dummy ${ac_tool_prefix}clang; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  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
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}clang"
+    printf "%s\n" "$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
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "clang", so it can be a program name with args.
+set dummy clang; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  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
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="clang"
+    printf "%s\n" "$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
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$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
 
 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;}
+test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$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
+printf "%s\n" "$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
+for ac_option in --version -v -V -qversion -version; 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
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compiler $ac_option >&5") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -3381,7 +4140,7 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
   fi
   rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
 done
 
@@ -3389,7 +4148,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -3401,9 +4160,9 @@ 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[^ ]*//'`
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+printf %s "checking whether the C compiler works... " >&6; }
+ac_link_default=`printf "%s\n" "$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.*"
@@ -3424,11 +4183,12 @@ case "(($ac_try" in
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$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 :
+  printf "%s\n" "$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,
@@ -3445,7 +4205,7 @@ do
        # certainly right.
        break;;
     *.* )
-       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;
        then :; else
           ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
        fi
@@ -3461,44 +4221,46 @@ do
 done
 test "$ac_cv_exeext" = no && ac_cv_exeext=
 
-else
+else $as_nop
   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
+if test -z "$ac_file"
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+printf "%s\n" "$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;}
+{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error 77 "C compiler cannot create executables
 See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-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; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+printf %s "checking for C compiler default output file name... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+printf "%s\n" "$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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+printf %s "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
+printf "%s\n" "$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 :
+  printf "%s\n" "$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
@@ -3512,15 +4274,15 @@ for ac_file in conftest.exe conftest conftest.*; do
     * ) 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;}
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+printf "%s\n" "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
@@ -3529,7 +4291,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 FILE *f = fopen ("conftest.out", "w");
  return ferror (f) || fclose (f) != 0;
@@ -3541,8 +4303,8 @@ _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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+printf %s "checking whether we are cross compiling... " >&6; }
 if test "$cross_compiling" != yes; then
   { { ac_try="$ac_link"
 case "(($ac_try" in
@@ -3550,10 +4312,10 @@ case "(($ac_try" in
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
   if { ac_try='./conftest$ac_cv_exeext'
   { { case "(($ac_try" in
@@ -3561,39 +4323,40 @@ $as_echo "$ac_try_echo"; } >&5
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_try") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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.
+       { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+printf "%s\n" "$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 ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+printf %s "checking for suffix of object files... " >&6; }
+if test ${ac_cv_objext+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -3607,11 +4370,12 @@ case "(($ac_try" in
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$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 :
+  printf "%s\n" "$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
@@ -3620,31 +4384,32 @@ $as_echo "$ac_try_echo"; } >&5
        break;;
   esac
 done
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$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;}
+{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+printf "%s\n" "$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 ${ac_cv_c_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5
+printf %s "checking whether the compiler supports GNU C... " >&6; }
+if test ${ac_cv_c_compiler_gnu+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
@@ -3654,29 +4419,33 @@ main ()
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_compiler_gnu=yes
-else
+else $as_nop
   ac_compiler_gnu=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; }
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 if test $ac_compiler_gnu = yes; then
   GCC=yes
 else
   GCC=
 fi
-ac_test_CFLAGS=${CFLAGS+set}
+ac_test_CFLAGS=${CFLAGS+y}
 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 ${ac_cv_prog_cc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+printf %s "checking whether $CC accepts -g... " >&6; }
+if test ${ac_cv_prog_cc_g+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
@@ -3685,57 +4454,60 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_g=yes
-else
+else $as_nop
   CFLAGS=""
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
 
-else
+else $as_nop
   ac_c_werror_flag=$ac_save_c_werror_flag
         CFLAGS="-g"
         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+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
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam 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
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+printf "%s\n" "$ac_cv_prog_cc_g" >&6; }
+if test $ac_test_CFLAGS; then
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
   if test "$GCC" = yes; then
@@ -3750,94 +4522,144 @@ 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 ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
+ac_prog_cc_stdc=no
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
+printf %s "checking for $CC option to enable C11 features... " >&6; }
+if test ${ac_cv_prog_cc_c11+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c11=no
 ac_save_CC=$CC
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* 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];
+$ac_c_conftest_c11_program
+_ACEOF
+for ac_arg in '' -std=gnu11
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c11=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c11" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+fi
 
-/* 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];
+if test "x$ac_cv_prog_cc_c11" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c11" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }
+     CC="$CC $ac_cv_prog_cc_c11"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
+  ac_prog_cc_stdc=c11
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5
+printf %s "checking for $CC option to enable C99 features... " >&6; }
+if test ${ac_cv_prog_cc_c99+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c99_program
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+fi
 
-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;
-}
+if test "x$ac_cv_prog_cc_c99" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c99" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }
+     CC="$CC $ac_cv_prog_cc_c99"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+  ac_prog_cc_stdc=c99
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5
+printf %s "checking for $CC option to enable C89 features... " >&6; }
+if test ${ac_cv_prog_cc_c89+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c89_program
 _ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
+  if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_c89=$ac_arg
 fi
-rm -f core conftest.err conftest.$ac_objext
+rm -f core conftest.err conftest.$ac_objext conftest.beam
   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 :
 
+if test "x$ac_cv_prog_cc_c89" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c89" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }
+     CC="$CC $ac_cv_prog_cc_c89"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+  ac_prog_cc_stdc=c89
+fi
 fi
 
 ac_ext=c
@@ -3846,21 +4668,23 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-ac_ext=c
+
+  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 whether $CC understands -c and -o together" >&5
-$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
-if ${am_cv_prog_cc_c_o+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+printf %s "checking whether $CC understands -c and -o together... " >&6; }
+if test ${am_cv_prog_cc_c_o+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -3888,8 +4712,8 @@ _ACEOF
   rm -f core conftest*
   unset am_i
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
-$as_echo "$am_cv_prog_cc_c_o" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+printf "%s\n" "$am_cv_prog_cc_c_o" >&6; }
 if test "$am_cv_prog_cc_c_o" != yes; then
    # Losing compiler, so override with the script.
    # FIXME: It is wrong to rewrite CC.
@@ -3907,11 +4731,12 @@ 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 ${am_cv_CC_dependencies_compiler_type+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+printf %s "checking dependency style of $depcc... " >&6; }
+if test ${am_cv_CC_dependencies_compiler_type+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   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
@@ -4018,8 +4843,8 @@ else
 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+printf "%s\n" "$am_cv_CC_dependencies_compiler_type" >&6; }
 CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
 
  if
@@ -4034,16 +4859,18 @@ fi
 
 
 
-if test -n "$ac_tool_prefix"; then
+
+  if test -n "$ac_tool_prefix"; then
   for ac_prog in ar lib "link -lib"
   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 ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
@@ -4051,11 +4878,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -4066,11 +4897,11 @@ fi
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+printf "%s\n" "$AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -4083,11 +4914,12 @@ if test -z "$AR"; then
 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 ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_AR"; then
   ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
 else
@@ -4095,11 +4927,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -4110,11 +4946,11 @@ fi
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+printf "%s\n" "$ac_ct_AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -4126,8 +4962,8 @@ done
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     AR=$ac_ct_AR
@@ -4136,11 +4972,12 @@ fi
 
 : ${AR=ar}
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5
-$as_echo_n "checking the archiver ($AR) interface... " >&6; }
-if ${am_cv_ar_interface+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5
+printf %s "checking the archiver ($AR) interface... " >&6; }
+if test ${am_cv_ar_interface+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4152,12 +4989,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 /* end confdefs.h.  */
 int some_variable = 0;
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'
       { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
   (eval $am_ar_try) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
       if test "$ac_status" -eq 0; then
         am_cv_ar_interface=ar
@@ -4166,7 +5004,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
         { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
   (eval $am_ar_try) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
         if test "$ac_status" -eq 0; then
           am_cv_ar_interface=lib
@@ -4177,7 +5015,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
       rm -f conftest.lib libconftest.a
 
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
    ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4185,8 +5023,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
-$as_echo "$am_cv_ar_interface" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
+printf "%s\n" "$am_cv_ar_interface" >&6; }
 
 case $am_cv_ar_interface in
 ar)
@@ -4206,6 +5044,12 @@ unknown)
 esac
 
 
+
+
+
+
+
+
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4216,15 +5060,16 @@ if test -z "$CXX"; 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
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++
   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 ${ac_cv_prog_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
@@ -4232,11 +5077,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -4247,11 +5096,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+printf "%s\n" "$CXX" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -4260,15 +5109,16 @@ fi
 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
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++
 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 ${ac_cv_prog_ac_ct_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CXX"; then
   ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
 else
@@ -4276,11 +5126,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -4291,11 +5145,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+printf "%s\n" "$ac_ct_CXX" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -4307,8 +5161,8 @@ done
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CXX=$ac_ct_CXX
@@ -4318,7 +5172,7 @@ fi
   fi
 fi
 # Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+printf "%s\n" "$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
@@ -4328,7 +5182,7 @@ case "(($ac_try" in
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compiler $ac_option >&5") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
@@ -4338,20 +5192,21 @@ $as_echo "$ac_try_echo"; } >&5
     cat conftest.er1 >&5
   fi
   rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$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 ${ac_cv_cxx_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5
+printf %s "checking whether the compiler supports GNU C++... " >&6; }
+if test ${ac_cv_cxx_compiler_gnu+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
@@ -4361,29 +5216,33 @@ main ()
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"
+then :
   ac_compiler_gnu=yes
-else
+else $as_nop
   ac_compiler_gnu=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; }
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
 if test $ac_compiler_gnu = yes; then
   GXX=yes
 else
   GXX=
 fi
-ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_test_CXXFLAGS=${CXXFLAGS+y}
 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 ${ac_cv_prog_cxx_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+printf %s "checking whether $CXX accepts -g... " >&6; }
+if test ${ac_cv_prog_cxx_g+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_save_cxx_werror_flag=$ac_cxx_werror_flag
    ac_cxx_werror_flag=yes
    ac_cv_prog_cxx_g=no
@@ -4392,71 +5251,168 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"
+then :
   ac_cv_prog_cxx_g=yes
-else
+else $as_nop
   CXXFLAGS=""
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"
+then :
 
-else
+else $as_nop
   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
         CXXFLAGS="-g"
         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
+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
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+printf "%s\n" "$ac_cv_prog_cxx_g" >&6; }
+if test $ac_test_CXXFLAGS; 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_prog_cxx_stdcxx=no
+if test x$ac_prog_cxx_stdcxx = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
+printf %s "checking for $CXX option to enable C++11 features... " >&6; }
+if test ${ac_cv_prog_cxx_11+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cxx_11=no
+ac_save_CXX=$CXX
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_cxx_conftest_cxx11_program
+_ACEOF
+for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA
+do
+  CXX="$ac_save_CXX $ac_arg"
+  if ac_fn_cxx_try_compile "$LINENO"
+then :
+  ac_cv_prog_cxx_cxx11=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cxx_cxx11" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CXX=$ac_save_CXX
+fi
+
+if test "x$ac_cv_prog_cxx_cxx11" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cxx_cxx11" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5
+printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; }
+     CXX="$CXX $ac_cv_prog_cxx_cxx11"
+fi
+  ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
+  ac_prog_cxx_stdcxx=cxx11
+fi
+fi
+if test x$ac_prog_cxx_stdcxx = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
+printf %s "checking for $CXX option to enable C++98 features... " >&6; }
+if test ${ac_cv_prog_cxx_98+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cxx_98=no
+ac_save_CXX=$CXX
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_cxx_conftest_cxx98_program
+_ACEOF
+for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA
+do
+  CXX="$ac_save_CXX $ac_arg"
+  if ac_fn_cxx_try_compile "$LINENO"
+then :
+  ac_cv_prog_cxx_cxx98=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cxx_cxx98" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CXX=$ac_save_CXX
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test "x$ac_cv_prog_cxx_cxx98" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cxx_cxx98" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5
+printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; }
+     CXX="$CXX $ac_cv_prog_cxx_cxx98"
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+  ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98
+  ac_prog_cxx_stdcxx=cxx98
 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'
@@ -4465,11 +5421,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 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 ${am_cv_CXX_dependencies_compiler_type+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+printf %s "checking dependency style of $depcc... " >&6; }
+if test ${am_cv_CXX_dependencies_compiler_type+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   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
@@ -4576,8 +5533,8 @@ else
 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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+printf "%s\n" "$am_cv_CXX_dependencies_compiler_type" >&6; }
 CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
 
  if
@@ -4596,7 +5553,8 @@ fi
 CXX="$CXX -std=c++17 -fno-exceptions -Wno-deprecated-declarations"
 
 # Check whether --enable-static was given.
-if test "${enable_static+set}" = set; then :
+if test ${enable_static+y}
+then :
   enableval=$enable_static; p=${PACKAGE-default}
     case $enableval in
     yes) enable_static=yes ;;
@@ -4614,7 +5572,7 @@ if test "${enable_static+set}" = set; then :
       IFS=$lt_save_ifs
       ;;
     esac
-else
+else $as_nop
   enable_static=no
 fi
 
@@ -4628,8 +5586,8 @@ fi
 
 case `pwd` in
   *\ * | *\    *)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
-$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
 esac
 
 
@@ -4649,28 +5607,32 @@ macro_revision='2.4.6'
 
 
 
+
 ltmain=$ac_aux_dir/ltmain.sh
 
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if ${ac_cv_build+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+
+  # Make sure we can run config.sub.
+$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+printf %s "checking build system type... " >&6; }
+if test ${ac_cv_build+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_build_alias=$build_alias
 test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+  ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"`
 test "x$ac_build_alias" = x &&
   as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` ||
+  as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+printf "%s\n" "$ac_cv_build" >&6; }
 case $ac_cv_build in
 *-*-*) ;;
 *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
@@ -4689,21 +5651,22 @@ IFS=$ac_save_IFS
 case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if ${ac_cv_host+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+printf %s "checking host system type... " >&6; }
+if test ${ac_cv_host+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test "x$host_alias" = x; then
   ac_cv_host=$ac_cv_build
 else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+  ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` ||
+    as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5
 fi
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+printf "%s\n" "$ac_cv_host" >&6; }
 case $ac_cv_host in
 *-*-*) ;;
 *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
@@ -4743,8 +5706,8 @@ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
-$as_echo_n "checking how to print strings... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+printf %s "checking how to print strings... " >&6; }
 # Test print first, because it will be a builtin if present.
 if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
    test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
@@ -4770,12 +5733,12 @@ func_echo_all ()
 }
 
 case $ECHO in
-  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
-$as_echo "printf" >&6; } ;;
-  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
-$as_echo "print -r" >&6; } ;;
-  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
-$as_echo "cat" >&6; } ;;
+  printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+printf "%s\n" "printf" >&6; } ;;
+  print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+printf "%s\n" "print -r" >&6; } ;;
+  *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+printf "%s\n" "cat" >&6; } ;;
 esac
 
 
@@ -4791,11 +5754,12 @@ esac
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
-$as_echo_n "checking for a sed that does not truncate output... " >&6; }
-if ${ac_cv_path_SED+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+printf %s "checking for a sed that does not truncate output... " >&6; }
+if test ${ac_cv_path_SED+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
             ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
      for ac_i in 1 2 3 4 5 6 7; do
        ac_script="$ac_script$as_nl$ac_script"
@@ -4809,10 +5773,15 @@ else
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in sed gsed; do
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in sed gsed
+   do
     for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      ac_path_SED="$as_dir$ac_prog$ac_exec_ext"
       as_fn_executable_p "$ac_path_SED" || continue
 # Check for GNU ac_path_SED and select it if it is found.
   # Check for GNU $ac_path_SED
@@ -4821,13 +5790,13 @@ case `"$ac_path_SED" --version 2>&1` in
   ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
 *)
   ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
+  printf %s 0123456789 >"conftest.in"
   while :
   do
     cat "conftest.in" "conftest.in" >"conftest.tmp"
     mv "conftest.tmp" "conftest.in"
     cp "conftest.in" "conftest.nl"
-    $as_echo '' >> "conftest.nl"
+    printf "%s\n" '' >> "conftest.nl"
     "$ac_path_SED" -f conftest.sed < "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
@@ -4855,8 +5824,8 @@ else
 fi
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
-$as_echo "$ac_cv_path_SED" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+printf "%s\n" "$ac_cv_path_SED" >&6; }
  SED="$ac_cv_path_SED"
   rm -f conftest.sed
 
@@ -4873,11 +5842,12 @@ Xsed="$SED -e 1s/^X//"
 
 
 
-{ $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 ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+printf %s "checking for grep that handles long lines and -e... " >&6; }
+if test ${ac_cv_path_GREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -z "$GREP"; then
   ac_path_GREP_found=false
   # Loop through the user's path and test for each of PROGNAME-LIST
@@ -4885,10 +5855,15 @@ else
 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
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    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"
+      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
       as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
@@ -4897,13 +5872,13 @@ case `"$ac_path_GREP" --version 2>&1` in
   ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
 *)
   ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
+  printf %s 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"
+    printf "%s\n" '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
@@ -4931,16 +5906,17 @@ else
 fi
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+printf "%s\n" "$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 ${ac_cv_path_EGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
    then ac_cv_path_EGREP="$GREP -E"
    else
@@ -4951,10 +5927,15 @@ else
 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
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    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"
+      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
       as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
@@ -4963,13 +5944,13 @@ case `"$ac_path_EGREP" --version 2>&1` in
   ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
 *)
   ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
+  printf %s 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"
+    printf "%s\n" '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
@@ -4998,16 +5979,17 @@ fi
 
    fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+printf "%s\n" "$ac_cv_path_EGREP" >&6; }
  EGREP="$ac_cv_path_EGREP"
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
-$as_echo_n "checking for fgrep... " >&6; }
-if ${ac_cv_path_FGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+printf %s "checking for fgrep... " >&6; }
+if test ${ac_cv_path_FGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
    then ac_cv_path_FGREP="$GREP -F"
    else
@@ -5018,10 +6000,15 @@ else
 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 fgrep; do
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in fgrep
+   do
     for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+      ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext"
       as_fn_executable_p "$ac_path_FGREP" || continue
 # Check for GNU ac_path_FGREP and select it if it is found.
   # Check for GNU $ac_path_FGREP
@@ -5030,13 +6017,13 @@ case `"$ac_path_FGREP" --version 2>&1` in
   ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
 *)
   ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
+  printf %s 0123456789 >"conftest.in"
   while :
   do
     cat "conftest.in" "conftest.in" >"conftest.tmp"
     mv "conftest.tmp" "conftest.in"
     cp "conftest.in" "conftest.nl"
-    $as_echo 'FGREP' >> "conftest.nl"
+    printf "%s\n" 'FGREP' >> "conftest.nl"
     "$ac_path_FGREP" FGREP < "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
@@ -5065,8 +6052,8 @@ fi
 
    fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
-$as_echo "$ac_cv_path_FGREP" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+printf "%s\n" "$ac_cv_path_FGREP" >&6; }
  FGREP="$ac_cv_path_FGREP"
 
 
@@ -5091,17 +6078,18 @@ test -z "$GREP" && GREP=grep
 
 
 # Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then :
+if test ${with_gnu_ld+y}
+then :
   withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
-else
+else $as_nop
   with_gnu_ld=no
 fi
 
 ac_prog=ld
 if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
-$as_echo_n "checking for ld used by $CC... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+printf %s "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return, which upsets mingw
@@ -5130,15 +6118,16 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     ;;
   esac
 elif test yes = "$with_gnu_ld"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
-$as_echo_n "checking for GNU ld... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+printf %s "checking for GNU ld... " >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-$as_echo_n "checking for non-GNU ld... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+printf %s "checking for non-GNU ld... " >&6; }
 fi
-if ${lt_cv_path_LD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+if test ${lt_cv_path_LD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -z "$LD"; then
   lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
@@ -5167,18 +6156,19 @@ fi
 
 LD=$lt_cv_path_LD
 if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+printf "%s\n" "$LD" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
-$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
-if ${lt_cv_prog_gnu_ld+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+printf %s "checking if the linker ($LD) is GNU ld... " >&6; }
+if test ${lt_cv_prog_gnu_ld+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   # I'd rather use --version here, but apparently some GNU lds only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
@@ -5189,8 +6179,8 @@ case `$LD -v 2>&1 </dev/null` in
   ;;
 esac
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
-$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; }
 with_gnu_ld=$lt_cv_prog_gnu_ld
 
 
@@ -5201,11 +6191,12 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
-$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
-if ${lt_cv_path_NM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if test ${lt_cv_path_NM+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$NM"; then
   # Let the user override the test.
   lt_cv_path_NM=$NM
@@ -5255,8 +6246,8 @@ else
   : ${lt_cv_path_NM=no}
 fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
-$as_echo "$lt_cv_path_NM" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+printf "%s\n" "$lt_cv_path_NM" >&6; }
 if test no != "$lt_cv_path_NM"; then
   NM=$lt_cv_path_NM
 else
@@ -5269,11 +6260,12 @@ else
   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 ${ac_cv_prog_DUMPBIN+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_DUMPBIN+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$DUMPBIN"; then
   ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
 else
@@ -5281,11 +6273,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -5296,11 +6292,11 @@ fi
 fi
 DUMPBIN=$ac_cv_prog_DUMPBIN
 if test -n "$DUMPBIN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
-$as_echo "$DUMPBIN" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+printf "%s\n" "$DUMPBIN" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -5313,11 +6309,12 @@ if test -z "$DUMPBIN"; then
 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 ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_DUMPBIN+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_DUMPBIN"; then
   ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
 else
@@ -5325,11 +6322,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -5340,11 +6341,11 @@ fi
 fi
 ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
 if test -n "$ac_ct_DUMPBIN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
-$as_echo "$ac_ct_DUMPBIN" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+printf "%s\n" "$ac_ct_DUMPBIN" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -5356,8 +6357,8 @@ done
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     DUMPBIN=$ac_ct_DUMPBIN
@@ -5385,11 +6386,12 @@ test -z "$NM" && NM=nm
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
-$as_echo_n "checking the name lister ($NM) interface... " >&6; }
-if ${lt_cv_nm_interface+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+printf %s "checking the name lister ($NM) interface... " >&6; }
+if test ${lt_cv_nm_interface+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
   (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
@@ -5405,26 +6407,27 @@ else
   fi
   rm -f conftest*
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
-$as_echo "$lt_cv_nm_interface" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+printf "%s\n" "$lt_cv_nm_interface" >&6; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
-$as_echo_n "checking whether ln -s works... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+printf %s "checking whether ln -s works... " >&6; }
 LN_S=$as_ln_s
 if test "$LN_S" = "ln -s"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
-$as_echo "no, using $LN_S" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+printf "%s\n" "no, using $LN_S" >&6; }
 fi
 
 # find the maximum length of command line arguments
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
-$as_echo_n "checking the maximum length of command line arguments... " >&6; }
-if ${lt_cv_sys_max_cmd_len+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+printf %s "checking the maximum length of command line arguments... " >&6; }
+if test ${lt_cv_sys_max_cmd_len+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
     i=0
   teststring=ABCD
 
@@ -5551,11 +6554,11 @@ else
 fi
 
 if test -n "$lt_cv_sys_max_cmd_len"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
-$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
-$as_echo "none" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
 fi
 max_cmd_len=$lt_cv_sys_max_cmd_len
 
@@ -5599,11 +6602,12 @@ esac
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
-$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
-if ${lt_cv_to_host_file_cmd+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+printf %s "checking how to convert $build file names to $host format... " >&6; }
+if test ${lt_cv_to_host_file_cmd+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   case $host in
   *-*-mingw* )
     case $build in
@@ -5639,18 +6643,19 @@ esac
 fi
 
 to_host_file_cmd=$lt_cv_to_host_file_cmd
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
-$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; }
 
 
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
-$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
-if ${lt_cv_to_tool_file_cmd+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+printf %s "checking how to convert $build file names to toolchain format... " >&6; }
+if test ${lt_cv_to_tool_file_cmd+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   #assume ordinary cross tools, or native build.
 lt_cv_to_tool_file_cmd=func_convert_file_noop
 case $host in
@@ -5666,22 +6671,23 @@ esac
 fi
 
 to_tool_file_cmd=$lt_cv_to_tool_file_cmd
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
-$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; }
 
 
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
-$as_echo_n "checking for $LD option to reload object files... " >&6; }
-if ${lt_cv_ld_reload_flag+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+printf %s "checking for $LD option to reload object files... " >&6; }
+if test ${lt_cv_ld_reload_flag+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_ld_reload_flag='-r'
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
-$as_echo "$lt_cv_ld_reload_flag" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+printf "%s\n" "$lt_cv_ld_reload_flag" >&6; }
 reload_flag=$lt_cv_ld_reload_flag
 case $reload_flag in
 "" | " "*) ;;
@@ -5714,11 +6720,12 @@ esac
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
 set dummy ${ac_tool_prefix}objdump; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OBJDUMP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_OBJDUMP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$OBJDUMP"; then
   ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
 else
@@ -5726,11 +6733,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -5741,11 +6752,11 @@ fi
 fi
 OBJDUMP=$ac_cv_prog_OBJDUMP
 if test -n "$OBJDUMP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
-$as_echo "$OBJDUMP" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+printf "%s\n" "$OBJDUMP" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -5754,11 +6765,12 @@ if test -z "$ac_cv_prog_OBJDUMP"; then
   ac_ct_OBJDUMP=$OBJDUMP
   # Extract the first word of "objdump", so it can be a program name with args.
 set dummy objdump; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_OBJDUMP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_OBJDUMP"; then
   ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
 else
@@ -5766,11 +6778,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJDUMP="objdump"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -5781,11 +6797,11 @@ fi
 fi
 ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
 if test -n "$ac_ct_OBJDUMP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
-$as_echo "$ac_ct_OBJDUMP" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+printf "%s\n" "$ac_ct_OBJDUMP" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_OBJDUMP" = x; then
@@ -5793,8 +6809,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     OBJDUMP=$ac_ct_OBJDUMP
@@ -5813,11 +6829,12 @@ test -z "$OBJDUMP" && OBJDUMP=objdump
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
-$as_echo_n "checking how to recognize dependent libraries... " >&6; }
-if ${lt_cv_deplibs_check_method+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+printf %s "checking how to recognize dependent libraries... " >&6; }
+if test ${lt_cv_deplibs_check_method+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_file_magic_cmd='$MAGIC_CMD'
 lt_cv_file_magic_test_file=
 lt_cv_deplibs_check_method='unknown'
@@ -5935,7 +6952,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd*)
+netbsd* | netbsdelf*-gnu)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
   else
@@ -6013,8 +7030,8 @@ os2*)
 esac
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
-$as_echo "$lt_cv_deplibs_check_method" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+printf "%s\n" "$lt_cv_deplibs_check_method" >&6; }
 
 file_magic_glob=
 want_nocaseglob=no
@@ -6058,11 +7075,12 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
 set dummy ${ac_tool_prefix}dlltool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_DLLTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_DLLTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$DLLTOOL"; then
   ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
 else
@@ -6070,11 +7088,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6085,11 +7107,11 @@ fi
 fi
 DLLTOOL=$ac_cv_prog_DLLTOOL
 if test -n "$DLLTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
-$as_echo "$DLLTOOL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+printf "%s\n" "$DLLTOOL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -6098,11 +7120,12 @@ if test -z "$ac_cv_prog_DLLTOOL"; then
   ac_ct_DLLTOOL=$DLLTOOL
   # Extract the first word of "dlltool", so it can be a program name with args.
 set dummy dlltool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_DLLTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_DLLTOOL"; then
   ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
 else
@@ -6110,11 +7133,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6125,11 +7152,11 @@ fi
 fi
 ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
 if test -n "$ac_ct_DLLTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
-$as_echo "$ac_ct_DLLTOOL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+printf "%s\n" "$ac_ct_DLLTOOL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_DLLTOOL" = x; then
@@ -6137,8 +7164,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     DLLTOOL=$ac_ct_DLLTOOL
@@ -6158,11 +7185,12 @@ test -z "$DLLTOOL" && DLLTOOL=dlltool
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
-$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
-if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+printf %s "checking how to associate runtime and link libraries... " >&6; }
+if test ${lt_cv_sharedlib_from_linklib_cmd+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_sharedlib_from_linklib_cmd='unknown'
 
 case $host_os in
@@ -6185,8 +7213,8 @@ cygwin* | mingw* | pw32* | cegcc*)
 esac
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
-$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
 sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
 test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
 
@@ -6201,11 +7229,12 @@ if test -n "$ac_tool_prefix"; then
   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 ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
@@ -6213,11 +7242,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6228,11 +7261,11 @@ fi
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+printf "%s\n" "$AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -6245,11 +7278,12 @@ if test -z "$AR"; then
 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 ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_AR"; then
   ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
 else
@@ -6257,11 +7291,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6272,11 +7310,11 @@ fi
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+printf "%s\n" "$ac_ct_AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -6288,8 +7326,8 @@ done
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     AR=$ac_ct_AR
@@ -6297,7 +7335,7 @@ esac
 fi
 
 : ${AR=ar}
-: ${AR_FLAGS=cru}
+: ${AR_FLAGS=cr}
 
 
 
@@ -6309,30 +7347,32 @@ fi
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
-$as_echo_n "checking for archiver @FILE support... " >&6; }
-if ${lt_cv_ar_at_file+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+printf %s "checking for archiver @FILE support... " >&6; }
+if test ${lt_cv_ar_at_file+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_ar_at_file=no
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   echo conftest.$ac_objext > conftest.lst
       lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
       { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
   (eval $lt_ar_try) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
       if test 0 -eq "$ac_status"; then
        # Ensure the archiver fails upon bogus file names.
@@ -6340,7 +7380,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
        { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
   (eval $lt_ar_try) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
        if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
@@ -6349,11 +7389,11 @@ if ac_fn_c_try_compile "$LINENO"; then :
       rm -f conftest.* libconftest.a
 
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
-$as_echo "$lt_cv_ar_at_file" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+printf "%s\n" "$lt_cv_ar_at_file" >&6; }
 
 if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
@@ -6370,11 +7410,12 @@ fi
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_STRIP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$STRIP"; then
   ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
 else
@@ -6382,11 +7423,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6397,11 +7442,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+printf "%s\n" "$STRIP" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -6410,11 +7455,12 @@ 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 ${ac_cv_prog_ac_ct_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_STRIP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_STRIP"; then
   ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
 else
@@ -6422,11 +7468,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6437,11 +7487,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+printf "%s\n" "$ac_ct_STRIP" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_STRIP" = x; then
@@ -6449,8 +7499,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     STRIP=$ac_ct_STRIP
@@ -6469,11 +7519,12 @@ test -z "$STRIP" && STRIP=:
 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 ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_RANLIB+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
@@ -6481,11 +7532,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6496,11 +7551,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+printf "%s\n" "$RANLIB" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -6509,11 +7564,12 @@ 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 ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_RANLIB+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_RANLIB"; then
   ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 else
@@ -6521,11 +7577,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$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
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -6536,11 +7596,11 @@ 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; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+printf "%s\n" "$ac_ct_RANLIB" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_RANLIB" = x; then
@@ -6548,8 +7608,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     RANLIB=$ac_ct_RANLIB
@@ -6638,11 +7698,12 @@ compiler=$CC
 
 
 # Check for command to grab the raw symbol name followed by C symbol from nm.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
-$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
-if ${lt_cv_sys_global_symbol_pipe+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+printf %s "checking command to parse $NM output from $compiler object... " >&6; }
+if test ${lt_cv_sys_global_symbol_pipe+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 # These are sane defaults that work on at least a few old systems.
 # [They come from Ultrix.  What could be older than Ultrix?!! ;)]
@@ -6794,15 +7855,12 @@ _LT_EOF
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
     # Now try to grab the symbols.
     nlist=conftest.nm
-    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
-  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s "$nlist"; then
+    $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5
+    if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then
       # Try sorting and uniquifying the output.
       if sort "$nlist" | uniq > "$nlist"T; then
        mv -f "$nlist"T "$nlist"
@@ -6870,7 +7928,7 @@ _LT_EOF
          if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && test -s conftest$ac_exeext; then
            pipe_works=yes
          fi
@@ -6905,11 +7963,11 @@ if test -z "$lt_cv_sys_global_symbol_pipe"; then
   lt_cv_sys_global_symbol_to_cdecl=
 fi
 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
-$as_echo "failed" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+printf "%s\n" "failed" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
-$as_echo "ok" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+printf "%s\n" "ok" >&6; }
 fi
 
 # Response file support.
@@ -6955,13 +8013,14 @@ fi
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
-$as_echo_n "checking for sysroot... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+printf %s "checking for sysroot... " >&6; }
 
 # Check whether --with-sysroot was given.
-if test "${with_sysroot+set}" = set; then :
+if test ${with_sysroot+y}
+then :
   withval=$with_sysroot;
-else
+else $as_nop
   with_sysroot=no
 fi
 
@@ -6979,24 +8038,25 @@ case $with_sysroot in #(
  no|'')
    ;; #(
  *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
-$as_echo "$with_sysroot" >&6; }
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+printf "%s\n" "$with_sysroot" >&6; }
    as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
    ;;
 esac
 
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
-$as_echo "${lt_sysroot:-no}" >&6; }
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+printf "%s\n" "${lt_sysroot:-no}" >&6; }
 
 
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
-$as_echo_n "checking for a working dd... " >&6; }
-if ${ac_cv_path_lt_DD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+printf %s "checking for a working dd... " >&6; }
+if test ${ac_cv_path_lt_DD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   printf 0123456789abcdef0123456789abcdef >conftest.i
 cat conftest.i conftest.i >conftest2.i
 : ${lt_DD:=$DD}
@@ -7007,10 +8067,15 @@ if test -z "$lt_DD"; then
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in dd; do
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in dd
+   do
     for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext"
+      ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext"
       as_fn_executable_p "$ac_path_lt_DD" || continue
 if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
   cmp -s conftest.i conftest.out \
@@ -7030,15 +8095,16 @@ fi
 
 rm -f conftest.i conftest2.i conftest.out
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
-$as_echo "$ac_cv_path_lt_DD" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+printf "%s\n" "$ac_cv_path_lt_DD" >&6; }
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
-$as_echo_n "checking how to truncate binary pipes... " >&6; }
-if ${lt_cv_truncate_bin+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+printf %s "checking how to truncate binary pipes... " >&6; }
+if test ${lt_cv_truncate_bin+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   printf 0123456789abcdef0123456789abcdef >conftest.i
 cat conftest.i conftest.i >conftest2.i
 lt_cv_truncate_bin=
@@ -7049,8 +8115,8 @@ fi
 rm -f conftest.i conftest2.i conftest.out
 test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
-$as_echo "$lt_cv_truncate_bin" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+printf "%s\n" "$lt_cv_truncate_bin" >&6; }
 
 
 
@@ -7073,7 +8139,8 @@ func_cc_basename ()
 }
 
 # Check whether --enable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then :
+if test ${enable_libtool_lock+y}
+then :
   enableval=$enable_libtool_lock;
 fi
 
@@ -7089,7 +8156,7 @@ ia64-*-hpux*)
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
@@ -7109,7 +8176,7 @@ ia64-*-hpux*)
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
     if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
@@ -7147,7 +8214,7 @@ mips64*-*linux*)
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
     emul=elf
     case `/usr/bin/file conftest.$ac_objext` in
@@ -7188,7 +8255,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.o` in
       *32-bit*)
@@ -7251,11 +8318,12 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
   SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
-$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
-if ${lt_cv_cc_needs_belf+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+printf %s "checking whether the C compiler needs -belf... " >&6; }
+if test ${lt_cv_cc_needs_belf+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -7266,19 +8334,20 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   lt_cv_cc_needs_belf=yes
-else
+else $as_nop
   lt_cv_cc_needs_belf=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
      ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -7287,8 +8356,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
-$as_echo "$lt_cv_cc_needs_belf" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+printf "%s\n" "$lt_cv_cc_needs_belf" >&6; }
   if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
     CFLAGS=$SAVE_CFLAGS
@@ -7301,7 +8370,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.o` in
     *64-bit*)
@@ -7338,11 +8407,12 @@ need_locks=$enable_libtool_lock
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
 set dummy ${ac_tool_prefix}mt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_MANIFEST_TOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$MANIFEST_TOOL"; then
   ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
 else
@@ -7350,11 +8420,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7365,11 +8439,11 @@ fi
 fi
 MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
 if test -n "$MANIFEST_TOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
-$as_echo "$MANIFEST_TOOL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+printf "%s\n" "$MANIFEST_TOOL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -7378,11 +8452,12 @@ if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
   ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
   # Extract the first word of "mt", so it can be a program name with args.
 set dummy mt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_MANIFEST_TOOL"; then
   ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
 else
@@ -7390,11 +8465,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7405,11 +8484,11 @@ fi
 fi
 ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
 if test -n "$ac_ct_MANIFEST_TOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
-$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_MANIFEST_TOOL" = x; then
@@ -7417,8 +8496,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
@@ -7428,11 +8507,12 @@ else
 fi
 
 test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
-$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
-if ${lt_cv_path_mainfest_tool+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if test ${lt_cv_path_mainfest_tool+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_path_mainfest_tool=no
   echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
   $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
@@ -7442,8 +8522,8 @@ else
   fi
   rm -f conftest*
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
-$as_echo "$lt_cv_path_mainfest_tool" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; }
 if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
@@ -7458,11 +8538,12 @@ fi
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
 set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_DSYMUTIL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_DSYMUTIL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$DSYMUTIL"; then
   ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
 else
@@ -7470,11 +8551,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7485,11 +8570,11 @@ fi
 fi
 DSYMUTIL=$ac_cv_prog_DSYMUTIL
 if test -n "$DSYMUTIL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
-$as_echo "$DSYMUTIL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+printf "%s\n" "$DSYMUTIL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -7498,11 +8583,12 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then
   ac_ct_DSYMUTIL=$DSYMUTIL
   # Extract the first word of "dsymutil", so it can be a program name with args.
 set dummy dsymutil; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_DSYMUTIL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_DSYMUTIL"; then
   ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
 else
@@ -7510,11 +8596,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7525,11 +8615,11 @@ fi
 fi
 ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
 if test -n "$ac_ct_DSYMUTIL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
-$as_echo "$ac_ct_DSYMUTIL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+printf "%s\n" "$ac_ct_DSYMUTIL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_DSYMUTIL" = x; then
@@ -7537,8 +8627,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     DSYMUTIL=$ac_ct_DSYMUTIL
@@ -7550,11 +8640,12 @@ fi
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
 set dummy ${ac_tool_prefix}nmedit; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_NMEDIT+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_NMEDIT+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$NMEDIT"; then
   ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
 else
@@ -7562,11 +8653,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7577,11 +8672,11 @@ fi
 fi
 NMEDIT=$ac_cv_prog_NMEDIT
 if test -n "$NMEDIT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
-$as_echo "$NMEDIT" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+printf "%s\n" "$NMEDIT" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -7590,11 +8685,12 @@ if test -z "$ac_cv_prog_NMEDIT"; then
   ac_ct_NMEDIT=$NMEDIT
   # Extract the first word of "nmedit", so it can be a program name with args.
 set dummy nmedit; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_NMEDIT+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_NMEDIT"; then
   ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
 else
@@ -7602,11 +8698,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_NMEDIT="nmedit"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7617,11 +8717,11 @@ fi
 fi
 ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
 if test -n "$ac_ct_NMEDIT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
-$as_echo "$ac_ct_NMEDIT" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+printf "%s\n" "$ac_ct_NMEDIT" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_NMEDIT" = x; then
@@ -7629,8 +8729,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     NMEDIT=$ac_ct_NMEDIT
@@ -7642,11 +8742,12 @@ fi
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
 set dummy ${ac_tool_prefix}lipo; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_LIPO+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_LIPO+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$LIPO"; then
   ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
 else
@@ -7654,11 +8755,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7669,11 +8774,11 @@ fi
 fi
 LIPO=$ac_cv_prog_LIPO
 if test -n "$LIPO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
-$as_echo "$LIPO" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+printf "%s\n" "$LIPO" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -7682,11 +8787,12 @@ if test -z "$ac_cv_prog_LIPO"; then
   ac_ct_LIPO=$LIPO
   # Extract the first word of "lipo", so it can be a program name with args.
 set dummy lipo; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_LIPO+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_LIPO"; then
   ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
 else
@@ -7694,11 +8800,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_LIPO="lipo"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7709,11 +8819,11 @@ fi
 fi
 ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
 if test -n "$ac_ct_LIPO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
-$as_echo "$ac_ct_LIPO" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+printf "%s\n" "$ac_ct_LIPO" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_LIPO" = x; then
@@ -7721,8 +8831,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     LIPO=$ac_ct_LIPO
@@ -7734,11 +8844,12 @@ fi
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
 set dummy ${ac_tool_prefix}otool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_OTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$OTOOL"; then
   ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
 else
@@ -7746,11 +8857,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7761,11 +8876,11 @@ fi
 fi
 OTOOL=$ac_cv_prog_OTOOL
 if test -n "$OTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
-$as_echo "$OTOOL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+printf "%s\n" "$OTOOL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -7774,11 +8889,12 @@ if test -z "$ac_cv_prog_OTOOL"; then
   ac_ct_OTOOL=$OTOOL
   # Extract the first word of "otool", so it can be a program name with args.
 set dummy otool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_OTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_OTOOL"; then
   ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
 else
@@ -7786,11 +8902,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL="otool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7801,11 +8921,11 @@ fi
 fi
 ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
 if test -n "$ac_ct_OTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
-$as_echo "$ac_ct_OTOOL" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+printf "%s\n" "$ac_ct_OTOOL" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_OTOOL" = x; then
@@ -7813,8 +8933,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     OTOOL=$ac_ct_OTOOL
@@ -7826,11 +8946,12 @@ fi
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
 set dummy ${ac_tool_prefix}otool64; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OTOOL64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_OTOOL64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$OTOOL64"; then
   ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
 else
@@ -7838,11 +8959,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7853,11 +8978,11 @@ fi
 fi
 OTOOL64=$ac_cv_prog_OTOOL64
 if test -n "$OTOOL64"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
-$as_echo "$OTOOL64" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+printf "%s\n" "$OTOOL64" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -7866,11 +8991,12 @@ if test -z "$ac_cv_prog_OTOOL64"; then
   ac_ct_OTOOL64=$OTOOL64
   # Extract the first word of "otool64", so it can be a program name with args.
 set dummy otool64; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_OTOOL64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_OTOOL64"; then
   ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
 else
@@ -7878,11 +9004,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL64="otool64"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -7893,11 +9023,11 @@ fi
 fi
 ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
 if test -n "$ac_ct_OTOOL64"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
-$as_echo "$ac_ct_OTOOL64" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+printf "%s\n" "$ac_ct_OTOOL64" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_OTOOL64" = x; then
@@ -7905,8 +9035,8 @@ fi
   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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     OTOOL64=$ac_ct_OTOOL64
@@ -7941,11 +9071,12 @@ fi
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
-$as_echo_n "checking for -single_module linker flag... " >&6; }
-if ${lt_cv_apple_cc_single_mod+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+printf %s "checking for -single_module linker flag... " >&6; }
+if test ${lt_cv_apple_cc_single_mod+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_apple_cc_single_mod=no
       if test -z "$LT_MULTI_MODULE"; then
        # By default we will add the -single_module flag. You can override
@@ -7974,14 +9105,15 @@ else
        rm -f conftest.*
       fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
-$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
-$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
-if ${lt_cv_ld_exported_symbols_list+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+printf %s "checking for -exported_symbols_list linker flag... " >&6; }
+if test ${lt_cv_ld_exported_symbols_list+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_ld_exported_symbols_list=no
       save_LDFLAGS=$LDFLAGS
       echo "_main" > conftest.sym
@@ -7990,39 +9122,41 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   lt_cv_ld_exported_symbols_list=yes
-else
+else $as_nop
   lt_cv_ld_exported_symbols_list=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
        LDFLAGS=$save_LDFLAGS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
-$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
-$as_echo_n "checking for -force_load linker flag... " >&6; }
-if ${lt_cv_ld_force_load+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+printf %s "checking for -force_load linker flag... " >&6; }
+if test ${lt_cv_ld_force_load+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_ld_force_load=no
       cat > conftest.c << _LT_EOF
 int forced_loaded() { return 2;}
 _LT_EOF
       echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
       $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
-      echo "$AR cru libconftest.a conftest.o" >&5
-      $AR cru libconftest.a conftest.o 2>&5
+      echo "$AR cr libconftest.a conftest.o" >&5
+      $AR cr libconftest.a conftest.o 2>&5
       echo "$RANLIB libconftest.a" >&5
       $RANLIB libconftest.a 2>&5
       cat > conftest.c << _LT_EOF
@@ -8042,8 +9176,8 @@ _LT_EOF
         rm -rf conftest.dSYM
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
-$as_echo "$lt_cv_ld_force_load" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+printf "%s\n" "$lt_cv_ld_force_load" >&6; }
     case $host_os in
     rhapsody* | darwin1.[012])
       _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
@@ -8054,11 +9188,11 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-       10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+       10.0,*86*-darwin8*|10.0,*-darwin[912]*)
          _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
        10.[012][,.]*)
          _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
-       10.*)
+       10.*|11.*)
          _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
@@ -8114,285 +9248,42 @@ func_munge_path_list ()
     esac
 }
 
-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 ${ac_cv_prog_CPP+:} false; 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 <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> 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 <limits.h>
-#else
-# include <assert.h>
-#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.i 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 <ac_nonexistent.h>
-_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.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i 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
+ac_header= ac_cache=
+for ac_item in $ac_header_c_list
 do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> 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 <limits.h>
-#else
-# include <assert.h>
-#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.i 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 <ac_nonexistent.h>
-_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.i conftest.$ac_ext
-
+  if test $ac_cache; then
+    ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default"
+    if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then
+      printf "%s\n" "#define $ac_item 1" >> confdefs.h
+    fi
+    ac_header= ac_cache=
+  elif test $ac_header; then
+    ac_cache=$ac_item
+  else
+    ac_header=$ac_item
+  fi
 done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i 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 ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-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 <string.h>
-
-_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 <stdlib.h>
-
-_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 <ctype.h>
-#include <stdlib.h>
-#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
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
 
-fi
 
-done
 
+if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes
+then :
 
-for ac_header in dlfcn.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
-"
-if test "x$ac_cv_header_dlfcn_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DLFCN_H 1
-_ACEOF
+printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h
 
 fi
+ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h
 
-done
+fi
 
 
 
@@ -8420,7 +9311,8 @@ func_stripname_cnf ()
 
 
             # Check whether --enable-shared was given.
-if test "${enable_shared+set}" = set; then :
+if test ${enable_shared+y}
+then :
   enableval=$enable_shared; p=${PACKAGE-default}
     case $enableval in
     yes) enable_shared=yes ;;
@@ -8438,7 +9330,7 @@ if test "${enable_shared+set}" = set; then :
       IFS=$lt_save_ifs
       ;;
     esac
-else
+else $as_nop
   enable_shared=yes
 fi
 
@@ -8453,7 +9345,8 @@ fi
 
 
 # Check whether --with-pic was given.
-if test "${with_pic+set}" = set; then :
+if test ${with_pic+y}
+then :
   withval=$with_pic; lt_p=${PACKAGE-default}
     case $withval in
     yes|no) pic_mode=$withval ;;
@@ -8470,7 +9363,7 @@ if test "${with_pic+set}" = set; then :
       IFS=$lt_save_ifs
       ;;
     esac
-else
+else $as_nop
   pic_mode=default
 fi
 
@@ -8482,7 +9375,8 @@ fi
 
 
   # Check whether --enable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then :
+if test ${enable_fast_install+y}
+then :
   enableval=$enable_fast_install; p=${PACKAGE-default}
     case $enableval in
     yes) enable_fast_install=yes ;;
@@ -8500,7 +9394,7 @@ if test "${enable_fast_install+set}" = set; then :
       IFS=$lt_save_ifs
       ;;
     esac
-else
+else $as_nop
   enable_fast_install=yes
 fi
 
@@ -8514,11 +9408,12 @@ fi
   shared_archive_member_spec=
 case $host,$enable_shared in
 power*-*-aix[5-9]*,yes)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
-$as_echo_n "checking which variant of shared library versioning to provide... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+printf %s "checking which variant of shared library versioning to provide... " >&6; }
 
 # Check whether --with-aix-soname was given.
-if test "${with_aix_soname+set}" = set; then :
+if test ${with_aix_soname+y}
+then :
   withval=$with_aix_soname; case $withval in
     aix|svr4|both)
       ;;
@@ -8527,18 +9422,19 @@ if test "${with_aix_soname+set}" = set; then :
       ;;
     esac
     lt_cv_with_aix_soname=$with_aix_soname
-else
-  if ${lt_cv_with_aix_soname+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+else $as_nop
+  if test ${lt_cv_with_aix_soname+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_with_aix_soname=aix
 fi
 
     with_aix_soname=$lt_cv_with_aix_soname
 fi
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
-$as_echo "$with_aix_soname" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+printf "%s\n" "$with_aix_soname" >&6; }
   if test aix != "$with_aix_soname"; then
     # For the AIX way of multilib, we name the shared archive member
     # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
@@ -8620,11 +9516,12 @@ if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
-$as_echo_n "checking for objdir... " >&6; }
-if ${lt_cv_objdir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+printf %s "checking for objdir... " >&6; }
+if test ${lt_cv_objdir+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   rm -f .libs 2>/dev/null
 mkdir .libs 2>/dev/null
 if test -d .libs; then
@@ -8635,17 +9532,15 @@ else
 fi
 rmdir .libs 2>/dev/null
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
-$as_echo "$lt_cv_objdir" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+printf "%s\n" "$lt_cv_objdir" >&6; }
 objdir=$lt_cv_objdir
 
 
 
 
 
-cat >>confdefs.h <<_ACEOF
-#define LT_OBJDIR "$lt_cv_objdir/"
-_ACEOF
+printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h
 
 
 
@@ -8691,11 +9586,12 @@ test -z "$MAGIC_CMD" && MAGIC_CMD=file
 case $deplibs_check_method in
 file_magic*)
   if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
-$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
-if ${lt_cv_path_MAGIC_CMD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+printf %s "checking for ${ac_tool_prefix}file... " >&6; }
+if test ${lt_cv_path_MAGIC_CMD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
   lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
@@ -8744,11 +9640,11 @@ fi
 
 MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
-$as_echo "$MAGIC_CMD" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+printf "%s\n" "$MAGIC_CMD" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -8757,11 +9653,12 @@ fi
 
 if test -z "$lt_cv_path_MAGIC_CMD"; then
   if test -n "$ac_tool_prefix"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
-$as_echo_n "checking for file... " >&6; }
-if ${lt_cv_path_MAGIC_CMD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+printf %s "checking for file... " >&6; }
+if test ${lt_cv_path_MAGIC_CMD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
   lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
@@ -8810,11 +9707,11 @@ fi
 
 MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
-$as_echo "$MAGIC_CMD" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+printf "%s\n" "$MAGIC_CMD" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
@@ -8899,11 +9796,12 @@ if test yes = "$GCC"; then
     lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
   esac
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
-if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test ${lt_cv_prog_compiler_rtti_exceptions+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_rtti_exceptions=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
@@ -8934,8 +9832,8 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
 if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
     lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
@@ -9132,6 +10030,12 @@ lt_prog_compiler_static=
        lt_prog_compiler_pic='-KPIC'
        lt_prog_compiler_static='-static'
         ;;
+      # flang / f18. f95 an alias for gfortran or flang on Debian
+      flang* | f18* | f95*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fPIC'
+       lt_prog_compiler_static='-static'
+        ;;
       # icc used to be incompatible with GCC.
       # ICC 10 doesn't accept -KPIC any more.
       icc* | ifort*)
@@ -9292,26 +10196,28 @@ case $host_os in
     ;;
 esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
-if ${lt_cv_prog_compiler_pic+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+printf %s "checking for $compiler option to produce PIC... " >&6; }
+if test ${lt_cv_prog_compiler_pic+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
-$as_echo "$lt_cv_prog_compiler_pic" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
+printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; }
 lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
 
 #
 # Check to make sure the PIC flag actually works.
 #
 if test -n "$lt_prog_compiler_pic"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
-if ${lt_cv_prog_compiler_pic_works+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test ${lt_cv_prog_compiler_pic_works+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_pic_works=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
@@ -9342,8 +10248,8 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; }
 
 if test yes = "$lt_cv_prog_compiler_pic_works"; then
     case $lt_prog_compiler_pic in
 # Check to make sure the static flag actually works.
 #
 wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if ${lt_cv_prog_compiler_static_works+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test ${lt_cv_prog_compiler_static_works+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_static_works=no
    save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
@@ -9399,8 +10306,8 @@ else
    LDFLAGS=$save_LDFLAGS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
-$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; }
 
 if test yes = "$lt_cv_prog_compiler_static_works"; then
     :
 
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test ${lt_cv_prog_compiler_c_o+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_c_o=no
    $RM -r conftest 2>/dev/null
    mkdir conftest
@@ -9461,19 +10369,20 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
-$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test ${lt_cv_prog_compiler_c_o+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_c_o=no
    $RM -r conftest 2>/dev/null
    mkdir conftest
@@ -9516,8 +10425,8 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
-$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
@@ -9525,19 +10434,19 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 hard_links=nottested
 if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+printf %s "checking if we can lock with hard links... " >&6; }
   hard_links=yes
   $RM conftest*
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   touch conftest.a
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+printf "%s\n" "$hard_links" >&6; }
   if test no = "$hard_links"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -9549,8 +10458,8 @@ fi
 
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
   runpath_var=
   allow_undefined_flag=
@@ -9608,6 +10517,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
+  linux* | k*bsd*-gnu | gnu*)
+    link_all_deplibs=no
+    ;;
   esac
 
   ld_shlibs=yes
@@ -9862,7 +10774,7 @@ _LT_EOF
       fi
       ;;
 
-    netbsd*)
+    netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
        archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
        wlarc=
@@ -10105,21 +11017,23 @@ _LT_EOF
         if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
-  if ${lt_cv_aix_libpath_+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${lt_cv_aix_libpath_+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
 
   lt_aix_libpath_sed='
       /Import File Strings/,/^$/ {
@@ -10134,7 +11048,7 @@ if ac_fn_c_try_link "$LINENO"; then :
     lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
     lt_cv_aix_libpath_=/usr/lib:/lib
         if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
-  if ${lt_cv_aix_libpath_+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${lt_cv_aix_libpath_+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
 
   lt_aix_libpath_sed='
       /Import File Strings/,/^$/ {
@@ -10187,7 +11103,7 @@ if ac_fn_c_try_link "$LINENO"; then :
     lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
     lt_cv_aix_libpath_=/usr/lib:/lib
 
          # Older versions of the 11.00 compiler do not understand -b yet
          # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
-         { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
-$as_echo_n "checking if $CC understands -b... " >&6; }
-if ${lt_cv_prog_compiler__b+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+printf %s "checking if $CC understands -b... " >&6; }
+if test ${lt_cv_prog_compiler__b+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler__b=no
    save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS -b"
@@ -10466,8 +11383,8 @@ else
    LDFLAGS=$save_LDFLAGS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
-$as_echo "$lt_cv_prog_compiler__b" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+printf "%s\n" "$lt_cv_prog_compiler__b" >&6; }
 
 if test yes = "$lt_cv_prog_compiler__b"; then
     archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
        # work, assume that -exports_file does not work either and
        # implicitly export all symbols.
        # This should be the same for all languages, so no per-tag cache variable.
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
-$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
-if ${lt_cv_irix_exported_symbol+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if test ${lt_cv_irix_exported_symbol+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   save_LDFLAGS=$LDFLAGS
           LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo (void) { return 0; }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   lt_cv_irix_exported_symbol=yes
-else
+else $as_nop
   lt_cv_irix_exported_symbol=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
            LDFLAGS=$save_LDFLAGS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
-$as_echo "$lt_cv_irix_exported_symbol" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; }
        if test yes = "$lt_cv_irix_exported_symbol"; then
           archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
        fi
+       link_all_deplibs=no
       else
        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
        archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
@@ -10553,7 +11473,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       esac
       ;;
 
-    netbsd*)
+    netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
        archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -10808,8 +11728,8 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     fi
   fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
-$as_echo "$ld_shlibs" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+printf "%s\n" "$ld_shlibs" >&6; }
 test no = "$ld_shlibs" && can_build_shared=no
 
 with_gnu_ld=$with_gnu_ld
@@ -10845,18 +11765,19 @@ x|xyes)
       # Test whether the compiler implicitly links with -lc since on some
       # systems, -lgcc has to come before -lc. If gcc already passes -lc
       # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-if ${lt_cv_archive_cmds_need_lc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+printf %s "checking whether -lc should be explicitly linked in... " >&6; }
+if test ${lt_cv_archive_cmds_need_lc+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   $RM conftest*
        echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } 2>conftest.err; then
          soname=conftest
          lib=conftest
@@ -10874,7 +11795,7 @@ else
          if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
   (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
          then
            lt_cv_archive_cmds_need_lc=no
@@ -10888,8 +11809,8 @@ else
        $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
-$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; }
       archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
       ;;
     esac
@@ -11048,8 +11969,8 @@ esac
 
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+printf %s "checking dynamic linker characteristics... " >&6; }
 
 if test yes = "$GCC"; then
   case $host_os in
@@ -11610,9 +12531,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   shlibpath_overrides_runpath=no
 
   # Some binutils ld are patched to set DT_RUNPATH
-  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${lt_cv_shlibpath_overrides_runpath+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_shlibpath_overrides_runpath=no
     save_LDFLAGS=$LDFLAGS
     save_libdir=$libdir
@@ -11622,19 +12544,21 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+if ac_fn_c_try_link "$LINENO"
+then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null
+then :
   lt_cv_shlibpath_overrides_runpath=yes
 fi
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
     LDFLAGS=$save_LDFLAGS
     libdir=$save_libdir
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
+
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -11866,8 +12802,8 @@ uts4*)
   dynamic_linker=no
   ;;
 esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+printf "%s\n" "$dynamic_linker" >&6; }
 test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
@@ -11988,8 +12924,8 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
 
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+printf %s "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" ||
    test -n "$runpath_var" ||
@@ -12013,8 +12949,8 @@ else
   # directories.
   hardcode_action=unsupported
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
-$as_echo "$hardcode_action" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+printf "%s\n" "$hardcode_action" >&6; }
 
 if test relink = "$hardcode_action" ||
    test yes = "$inherit_rpath"; then
@@ -12058,11 +12994,12 @@ else
 
   darwin*)
     # if libdl is installed we need to link against it
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-$as_echo_n "checking for dlopen in -ldl... " >&6; }
-if ${ac_cv_lib_dl_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+printf %s "checking for dlopen in -ldl... " >&6; }
+if test ${ac_cv_lib_dl_dlopen+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldl  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12071,32 +13008,31 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* 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 dlopen ();
 int
-main ()
+main (void)
 {
 return dlopen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dl_dlopen=yes
-else
+else $as_nop
   ac_cv_lib_dl_dlopen=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes
+then :
   lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
-else
+else $as_nop
 
     lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
 
   *)
     ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
-if test "x$ac_cv_func_shl_load" = xyes; then :
+if test "x$ac_cv_func_shl_load" = xyes
+then :
   lt_cv_dlopen=shl_load
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
-$as_echo_n "checking for shl_load in -ldld... " >&6; }
-if ${ac_cv_lib_dld_shl_load+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+printf %s "checking for shl_load in -ldld... " >&6; }
+if test ${ac_cv_lib_dld_shl_load+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldld  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12132,41 +13070,42 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* 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 shl_load ();
 int
-main ()
+main (void)
 {
 return shl_load ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dld_shl_load=yes
-else
+else $as_nop
   ac_cv_lib_dld_shl_load=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
-$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
-if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes
+then :
   lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
-else
+else $as_nop
   ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
-if test "x$ac_cv_func_dlopen" = xyes; then :
+if test "x$ac_cv_func_dlopen" = xyes
+then :
   lt_cv_dlopen=dlopen
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-$as_echo_n "checking for dlopen in -ldl... " >&6; }
-if ${ac_cv_lib_dl_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+printf %s "checking for dlopen in -ldl... " >&6; }
+if test ${ac_cv_lib_dl_dlopen+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldl  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12175,37 +13114,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* 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 dlopen ();
 int
-main ()
+main (void)
 {
 return dlopen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dl_dlopen=yes
-else
+else $as_nop
   ac_cv_lib_dl_dlopen=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes
+then :
   lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
-$as_echo_n "checking for dlopen in -lsvld... " >&6; }
-if ${ac_cv_lib_svld_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+printf %s "checking for dlopen in -lsvld... " >&6; }
+if test ${ac_cv_lib_svld_dlopen+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lsvld  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12214,37 +13153,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* 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 dlopen ();
 int
-main ()
+main (void)
 {
 return dlopen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_svld_dlopen=yes
-else
+else $as_nop
   ac_cv_lib_svld_dlopen=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
-$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
-if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes
+then :
   lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
-$as_echo_n "checking for dld_link in -ldld... " >&6; }
-if ${ac_cv_lib_dld_dld_link+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+printf %s "checking for dld_link in -ldld... " >&6; }
+if test ${ac_cv_lib_dld_dld_link+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldld  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12253,30 +13192,29 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* 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 dld_link ();
 int
-main ()
+main (void)
 {
 return dld_link ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dld_dld_link=yes
-else
+else $as_nop
   ac_cv_lib_dld_dld_link=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
-$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
-if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes
+then :
   lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
 
     save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
-$as_echo_n "checking whether a program can dlopen itself... " >&6; }
-if ${lt_cv_dlopen_self+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+printf %s "checking whether a program can dlopen itself... " >&6; }
+if test ${lt_cv_dlopen_self+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
          if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self=cross
 else
@@ -12398,7 +13337,7 @@ _LT_EOF
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
@@ -12416,16 +13355,17 @@ rm -fr conftest*
 
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
-$as_echo "$lt_cv_dlopen_self" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+printf "%s\n" "$lt_cv_dlopen_self" >&6; }
 
     if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
-$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
-if ${lt_cv_dlopen_self_static+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+printf %s "checking whether a statically linked program can dlopen itself... " >&6; }
+if test ${lt_cv_dlopen_self_static+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
          if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self_static=cross
 else
@@ -12504,7 +13444,7 @@ _LT_EOF
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
@@ -12522,8 +13462,8 @@ rm -fr conftest*
 
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
-$as_echo "$lt_cv_dlopen_self_static" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+printf "%s\n" "$lt_cv_dlopen_self_static" >&6; }
     fi
 
     CPPFLAGS=$save_CPPFLAGS
 
 striplib=
 old_striplib=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
-$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+printf %s "checking whether stripping libraries is possible... " >&6; }
 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
   test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
   test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
@@ -12575,16 +13515,16 @@ else
     if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
     else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
     fi
     ;;
   *)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
     ;;
   esac
 fi
 
 
   # Report what library types will actually be built
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+printf %s "checking if libtool supports shared libraries... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+printf "%s\n" "$can_build_shared" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+printf %s "checking whether to build shared libraries... " >&6; }
   test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
@@ -12631,15 +13571,15 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     fi
     ;;
   esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+printf "%s\n" "$enable_shared" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+printf %s "checking whether to build static libraries... " >&6; }
   # Make sure either enable_shared or enable_static is yes.
   test yes = "$enable_shared" || enable_static=yes
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+printf "%s\n" "$enable_static" >&6; }
 
 
 
@@ -12661,36 +13601,32 @@ 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
-{ $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; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+printf %s "checking how to run the C++ preprocessor... " >&6; }
 if test -z "$CXXCPP"; then
-  if ${ac_cv_prog_CXXCPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CXXCPP needs to be expanded
-    for CXXCPP in "$CXX -E" "/lib/cpp"
+  if test ${ac_cv_prog_CXXCPP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+      # Double quotes because $CXX needs to be expanded
+    for CXXCPP in "$CXX -E" cpp /lib/cpp
     do
       ac_preproc_ok=false
 for ac_cxx_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> 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 <limits.h>
-#else
-# include <assert.h>
-#endif
+#include <limits.h>
                     Syntax error
 _ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
+if ac_fn_cxx_try_cpp "$LINENO"
+then :
 
-else
+else $as_nop
   # Broken: fails on valid input.
 continue
 fi
@@ -12702,10 +13638,11 @@ rm -f conftest.err conftest.i conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
+if ac_fn_cxx_try_cpp "$LINENO"
+then :
   # Broken: success on invalid input.
 continue
-else
+else $as_nop
   # Passes both tests.
 ac_preproc_ok=:
 break
@@ -12715,7 +13652,8 @@ rm -f conftest.err conftest.i conftest.$ac_ext
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
+if $ac_preproc_ok
+then :
   break
 fi
 
 else
   ac_cv_prog_CXXCPP=$CXXCPP
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
-$as_echo "$CXXCPP" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+printf "%s\n" "$CXXCPP" >&6; }
 ac_preproc_ok=false
 for ac_cxx_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> 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 <limits.h>
-#else
-# include <assert.h>
-#endif
+#include <limits.h>
                     Syntax error
 _ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
+if ac_fn_cxx_try_cpp "$LINENO"
+then :
 
-else
+else $as_nop
   # Broken: fails on valid input.
 continue
 fi
@@ -12761,10 +13694,11 @@ rm -f conftest.err conftest.i conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
+if ac_fn_cxx_try_cpp "$LINENO"
+then :
   # Broken: success on invalid input.
 continue
-else
+else $as_nop
   # Passes both tests.
 ac_preproc_ok=:
 break
@@ -12774,11 +13708,12 @@ rm -f conftest.err conftest.i conftest.$ac_ext
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
+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;}
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
 See \`config.log' for more details" "$LINENO" 5; }
 fi
@@ -12914,17 +13849,18 @@ cc_basename=$func_cc_basename_result
 
 
 # Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then :
+if test ${with_gnu_ld+y}
+then :
   withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
-else
+else $as_nop
   with_gnu_ld=no
 fi
 
 ac_prog=ld
 if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
-$as_echo_n "checking for ld used by $CC... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+printf %s "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return, which upsets mingw
@@ -12953,15 +13889,16 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     ;;
   esac
 elif test yes = "$with_gnu_ld"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
-$as_echo_n "checking for GNU ld... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+printf %s "checking for GNU ld... " >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-$as_echo_n "checking for non-GNU ld... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+printf %s "checking for non-GNU ld... " >&6; }
 fi
-if ${lt_cv_path_LD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+if test ${lt_cv_path_LD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -z "$LD"; then
   lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
 
 LD=$lt_cv_path_LD
 if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+printf "%s\n" "$LD" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
-$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
-if ${lt_cv_prog_gnu_ld+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+printf %s "checking if the linker ($LD) is GNU ld... " >&6; }
+if test ${lt_cv_prog_gnu_ld+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   # I'd rather use --version here, but apparently some GNU lds only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
@@ -13012,8 +13950,8 @@ case `$LD -v 2>&1 </dev/null` in
   ;;
 esac
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
-$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; }
 with_gnu_ld=$lt_cv_prog_gnu_ld
 
 
@@ -13058,7 +13996,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
       # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 
     else
       GXX=no
@@ -13067,8 +14005,8 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
     fi
 
     # PORTME: fill in a description of your system's C++ link characteristics
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
     ld_shlibs_CXX=yes
     case $host_os in
       aix3*)
@@ -13206,21 +14144,23 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
           if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
-  if ${lt_cv_aix_libpath__CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${lt_cv_aix_libpath__CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
+if ac_fn_cxx_try_link "$LINENO"
+then :
 
   lt_aix_libpath_sed='
       /Import File Strings/,/^$/ {
@@ -13235,7 +14175,7 @@ if ac_fn_cxx_try_link "$LINENO"; then :
     lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
     lt_cv_aix_libpath__CXX=/usr/lib:/lib
            if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
-  if ${lt_cv_aix_libpath__CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${lt_cv_aix_libpath__CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
+if ac_fn_cxx_try_link "$LINENO"
+then :
 
   lt_aix_libpath_sed='
       /Import File Strings/,/^$/ {
@@ -13289,7 +14231,7 @@ if ac_fn_cxx_try_link "$LINENO"; then :
     lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
     lt_cv_aix_libpath__CXX=/usr/lib:/lib
@@ -13550,7 +14492,7 @@ fi
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
             if test yes = "$GXX"; then
@@ -13615,7 +14557,7 @@ fi
            # explicitly linking system object files so we need to strip them
            # from the output so that they don't get included in the library
            # dependencies.
-           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
            ;;
           *)
            if test yes = "$GXX"; then
@@ -13954,7 +14896,7 @@ fi
              # Commands to make compiler produce verbose output that lists
              # what "hidden" libraries, object files and flags are used when
              # linking a shared library.
-             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 
            else
              # FIXME: insert proper C++ library support
@@ -14038,7 +14980,7 @@ fi
                # Commands to make compiler produce verbose output that lists
                # what "hidden" libraries, object files and flags are used when
                # linking a shared library.
-               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
              else
                # g++ 2.7 appears to require '-G' NOT '-shared' on this
                # platform.
@@ -14049,7 +14991,7 @@ fi
                # Commands to make compiler produce verbose output that lists
                # what "hidden" libraries, object files and flags are used when
                # linking a shared library.
-               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
              fi
 
              hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir'
@@ -14140,8 +15082,8 @@ fi
         ;;
     esac
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
-$as_echo "$ld_shlibs_CXX" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+printf "%s\n" "$ld_shlibs_CXX" >&6; }
     test no = "$ld_shlibs_CXX" && can_build_shared=no
 
     GCC_CXX=$GXX
@@ -14179,7 +15121,7 @@ esac
 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   # Parse the compiler output and extract the necessary
   # objects, libraries and library flags.
@@ -14562,7 +15504,7 @@ lt_prog_compiler_static_CXX=
            ;;
        esac
        ;;
-      netbsd*)
+      netbsd* | netbsdelf*-gnu)
        ;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -14660,26 +15602,28 @@ case $host_os in
     ;;
 esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
-if ${lt_cv_prog_compiler_pic_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+printf %s "checking for $compiler option to produce PIC... " >&6; }
+if test ${lt_cv_prog_compiler_pic_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
+printf "%s\n" "$lt_cv_prog_compiler_pic_CXX" >&6; }
 lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX
 
 #
 # Check to make sure the PIC flag actually works.
 #
 if test -n "$lt_prog_compiler_pic_CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
-if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if test ${lt_cv_prog_compiler_pic_works_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_pic_works_CXX=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
@@ -14710,8 +15654,8 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+printf "%s\n" "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
 
 if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then
     case $lt_prog_compiler_pic_CXX in
 # Check to make sure the static flag actually works.
 #
 wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test ${lt_cv_prog_compiler_static_works_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_static_works_CXX=no
    save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
@@ -14761,8 +15706,8 @@ else
    LDFLAGS=$save_LDFLAGS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+printf "%s\n" "$lt_cv_prog_compiler_static_works_CXX" >&6; }
 
 if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then
     :
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test ${lt_cv_prog_compiler_c_o_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_c_o_CXX=no
    $RM -r conftest 2>/dev/null
    mkdir conftest
@@ -14820,16 +15766,17 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test ${lt_cv_prog_compiler_c_o_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_prog_compiler_c_o_CXX=no
    $RM -r conftest 2>/dev/null
    mkdir conftest
@@ -14872,8 +15819,8 @@ else
    $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 
 
 
@@ -14881,19 +15828,19 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 hard_links=nottested
 if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+printf %s "checking if we can lock with hard links... " >&6; }
   hard_links=yes
   $RM conftest*
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   touch conftest.a
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+printf "%s\n" "$hard_links" >&6; }
   if test no = "$hard_links"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -14902,8 +15849,8 @@ fi
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
   export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
@@ -14937,13 +15884,16 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
       ;;
     esac
     ;;
+  linux* | k*bsd*-gnu | gnu*)
+    link_all_deplibs_CXX=no
+    ;;
   *)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
     ;;
   esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
-$as_echo "$ld_shlibs_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+printf "%s\n" "$ld_shlibs_CXX" >&6; }
 test no = "$ld_shlibs_CXX" && can_build_shared=no
 
 with_gnu_ld_CXX=$with_gnu_ld
@@ -14970,18 +15920,19 @@ x|xyes)
       # Test whether the compiler implicitly links with -lc since on some
       # systems, -lgcc has to come before -lc. If gcc already passes -lc
       # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+printf %s "checking whether -lc should be explicitly linked in... " >&6; }
+if test ${lt_cv_archive_cmds_need_lc_CXX+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   $RM conftest*
        echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } 2>conftest.err; then
          soname=conftest
          lib=conftest
@@ -14999,7 +15950,7 @@ else
          if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
   (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
          then
            lt_cv_archive_cmds_need_lc_CXX=no
@@ -15013,8 +15964,8 @@ else
        $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
-$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
+printf "%s\n" "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
       archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX
       ;;
     esac
@@ -15083,8 +16034,8 @@ esac
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+printf %s "checking dynamic linker characteristics... " >&6; }
 
 library_names_spec=
 libname_spec='lib$name'
@@ -15572,9 +16523,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   shlibpath_overrides_runpath=no
 
   # Some binutils ld are patched to set DT_RUNPATH
-  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  if test ${lt_cv_shlibpath_overrides_runpath+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   lt_cv_shlibpath_overrides_runpath=no
     save_LDFLAGS=$LDFLAGS
     save_libdir=$libdir
@@ -15584,19 +16536,21 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+if ac_fn_cxx_try_link "$LINENO"
+then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null
+then :
   lt_cv_shlibpath_overrides_runpath=yes
 fi
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
     LDFLAGS=$save_LDFLAGS
     libdir=$save_libdir
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
+
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -15828,8 +16794,8 @@ uts4*)
   dynamic_linker=no
   ;;
 esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+printf "%s\n" "$dynamic_linker" >&6; }
 test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
@@ -15893,8 +16859,8 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+printf %s "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" ||
    test -n "$runpath_var_CXX" ||
@@ -15918,8 +16884,8 @@ else
   # directories.
   hardcode_action_CXX=unsupported
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
-$as_echo "$hardcode_action_CXX" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+printf "%s\n" "$hardcode_action_CXX" >&6; }
 
 if test relink = "$hardcode_action_CXX" ||
    test yes = "$inherit_rpath_CXX"; then
@@ -15980,7 +16946,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_headers="$ac_config_headers config.h src/include/fst/config.h"
+ac_config_headers="$ac_config_headers config.h"
 
 
 ac_config_files="$ac_config_files Makefile src/Makefile src/include/Makefile src/lib/Makefile src/bin/Makefile src/test/Makefile src/extensions/Makefile src/extensions/compact/Makefile src/extensions/compress/Makefile src/extensions/const/Makefile src/extensions/far/Makefile src/extensions/linear/Makefile src/extensions/lookahead/Makefile src/extensions/mpdt/Makefile src/extensions/ngram/Makefile src/extensions/pdt/Makefile src/extensions/python/Makefile src/extensions/special/Makefile src/script/Makefile"
@@ -15994,9 +16960,10 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 
 # Check whether --enable-compact-fsts was given.
-if test "${enable_compact_fsts+set}" = set; then :
+if test ${enable_compact_fsts+y}
+then :
   enableval=$enable_compact_fsts;
-else
+else $as_nop
   enable_compact_fsts=no
 fi
 
 
 
 # Check whether --enable-compress was given.
-if test "${enable_compress+set}" = set; then :
+if test ${enable_compress+y}
+then :
   enableval=$enable_compress;
-else
+else $as_nop
   enable_compress=no
 fi
 
 
 
 # Check whether --enable-const-fsts was given.
-if test "${enable_const_fsts+set}" = set; then :
+if test ${enable_const_fsts+y}
+then :
   enableval=$enable_const_fsts;
-else
+else $as_nop
   enable_const_fsts=no
 fi
 
 
 
 # Check whether --enable-far was given.
-if test "${enable_far+set}" = set; then :
+if test ${enable_far+y}
+then :
   enableval=$enable_far;
-else
+else $as_nop
   enable_far=no
 fi
 
 
 
 # Check whether --enable-linear-fsts was given.
-if test "${enable_linear_fsts+set}" = set; then :
+if test ${enable_linear_fsts+y}
+then :
   enableval=$enable_linear_fsts;
-else
+else $as_nop
   enable_linear_fsts=no
 fi
 
 
 
 # Check whether --enable-lookahead-fsts was given.
-if test "${enable_lookahead_fsts+set}" = set; then :
+if test ${enable_lookahead_fsts+y}
+then :
   enableval=$enable_lookahead_fsts;
-else
+else $as_nop
   enable_lookahead_fsts=no
 fi
 
 
 
 # Check whether --enable-mpdt was given.
-if test "${enable_mpdt+set}" = set; then :
+if test ${enable_mpdt+y}
+then :
   enableval=$enable_mpdt;
-else
+else $as_nop
   enable_mpdt=no
 fi
 
 
 
 # Check whether --enable-ngram-fsts was given.
-if test "${enable_ngram_fsts+set}" = set; then :
+if test ${enable_ngram_fsts+y}
+then :
   enableval=$enable_ngram_fsts;
-else
+else $as_nop
   enable_ngram_fsts=no
 fi
 
 
 
 # Check whether --enable-pdt was given.
-if test "${enable_pdt+set}" = set; then :
+if test ${enable_pdt+y}
+then :
   enableval=$enable_pdt;
-else
+else $as_nop
   enable_pdt=no
 fi
 
 
 
 # Check whether --enable-python was given.
-if test "${enable_python+set}" = set; then :
+if test ${enable_python+y}
+then :
   enableval=$enable_python;
-else
+else $as_nop
   enable_python=no
 fi
 
@@ -16161,8 +17137,8 @@ if test "x$enable_python" != xno; then
 
         if test -n "$PYTHON"; then
       # If the user set $PYTHON, use it and don't search something else.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 3.6" >&5
-$as_echo_n "checking whether $PYTHON version is >= 3.6... " >&6; }
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 3.6" >&5
+printf %s "checking whether $PYTHON version is >= 3.6... " >&6; }
       prog="import sys
 # split strings by '.' and convert to numeric.  Append some zeros
 # because we need at least 4 digits for the hex conversion.
@@ -16176,25 +17152,27 @@ sys.exit(sys.hexversion < minverhex)"
    ($PYTHON -c "$prog") >&5 2>&5
    ac_status=$?
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   (exit $ac_status); }; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+   (exit $ac_status); }
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
                               as_fn_error $? "Python interpreter is too old" "$LINENO" 5
 fi
       am_display_PYTHON=$PYTHON
     else
       # Otherwise, try each interpreter until we find one that satisfies
       # VERSION.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 3.6" >&5
-$as_echo_n "checking for a Python interpreter with version >= 3.6... " >&6; }
-if ${am_cv_pathless_PYTHON+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-       for am_cv_pathless_PYTHON in python python2 python3  python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3  python3.2 python3.1 python3.0  python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1  python2.0 none; do
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 3.6" >&5
+printf %s "checking for a Python interpreter with version >= 3.6... " >&6; }
+if test ${am_cv_pathless_PYTHON+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+       for am_cv_pathless_PYTHON in python python2 python3  python3.11 python3.10  python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3  python3.2 python3.1 python3.0  python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1  python2.0 none; do
          test "$am_cv_pathless_PYTHON" = none && break
          prog="import sys
 # split strings by '.' and convert to numeric.  Append some zeros
@@ -16209,24 +17187,26 @@ sys.exit(sys.hexversion < minverhex)"
    ($am_cv_pathless_PYTHON -c "$prog") >&5 2>&5
    ac_status=$?
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   (exit $ac_status); }; then :
+   (exit $ac_status); }
+then :
   break
 fi
        done
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_pathless_PYTHON" >&5
-$as_echo "$am_cv_pathless_PYTHON" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_pathless_PYTHON" >&5
+printf "%s\n" "$am_cv_pathless_PYTHON" >&6; }
       # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
       if test "$am_cv_pathless_PYTHON" = none; then
        PYTHON=:
       else
         # Extract the first word of "$am_cv_pathless_PYTHON", so it can be a program name with args.
 set dummy $am_cv_pathless_PYTHON; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_PYTHON+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_path_PYTHON+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   case $PYTHON in
   [\\/]* | ?:[\\/]*)
   ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
@@ -16236,11 +17216,15 @@ else
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_path_PYTHON="$as_dir$ac_word$ac_exec_ext"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -16252,11 +17236,11 @@ esac
 fi
 PYTHON=$ac_cv_path_PYTHON
 if test -n "$PYTHON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
-$as_echo "$PYTHON" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
+printf "%s\n" "$PYTHON" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 
 
   if test "$PYTHON" = :; then
-      as_fn_error $? "no suitable Python interpreter found" "$LINENO" 5
+        as_fn_error $? "no suitable Python interpreter found" "$LINENO" 5
   else
 
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5
-$as_echo_n "checking for $am_display_PYTHON version... " >&6; }
-if ${am_cv_python_version+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  am_cv_python_version=`$PYTHON -c "import sys; print('%u.%u' % sys.version_info[:2])"`
+              { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5
+printf %s "checking for $am_display_PYTHON version... " >&6; }
+if test ${am_cv_python_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  am_cv_python_version=`$PYTHON -c "import sys; print ('%u.%u' % sys.version_info[:2])"`
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5
-$as_echo "$am_cv_python_version" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5
+printf "%s\n" "$am_cv_python_version" >&6; }
   PYTHON_VERSION=$am_cv_python_version
 
 
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5
+printf %s "checking for $am_display_PYTHON platform... " >&6; }
+if test ${am_cv_python_platform+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5
+printf "%s\n" "$am_cv_python_platform" >&6; }
+  PYTHON_PLATFORM=$am_cv_python_platform
 
-  PYTHON_PREFIX='${prefix}'
-
-  PYTHON_EXEC_PREFIX='${exec_prefix}'
 
+                            if test "x$prefix" = xNONE; then
+    am__usable_prefix=$ac_default_prefix
+  else
+    am__usable_prefix=$prefix
+  fi
 
+  # Allow user to request using sys.* values from Python,
+  # instead of the GNU $prefix values.
+
+# Check whether --with-python-sys-prefix was given.
+if test ${with_python_sys_prefix+y}
+then :
+  withval=$with_python_sys_prefix; am_use_python_sys=:
+else $as_nop
+  am_use_python_sys=false
+fi
+
+
+  # Allow user to override whatever the default Python prefix is.
+
+# Check whether --with-python_prefix was given.
+if test ${with_python_prefix+y}
+then :
+  withval=$with_python_prefix; am_python_prefix_subst=$withval
+   am_cv_python_prefix=$withval
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for explicit $am_display_PYTHON prefix" >&5
+printf %s "checking for explicit $am_display_PYTHON prefix... " >&6; }
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_prefix" >&5
+printf "%s\n" "$am_cv_python_prefix" >&6; }
+else $as_nop
+
+   if $am_use_python_sys; then
+     # using python sys.prefix value, not GNU
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for python default $am_display_PYTHON prefix" >&5
+printf %s "checking for python default $am_display_PYTHON prefix... " >&6; }
+if test ${am_cv_python_prefix+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  am_cv_python_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_prefix" >&5
+printf "%s\n" "$am_cv_python_prefix" >&6; }
+
+               case $am_cv_python_prefix in
+     $am__usable_prefix*)
+       am__strip_prefix=`echo "$am__usable_prefix" | sed 's|.|.|g'`
+       am_python_prefix_subst=`echo "$am_cv_python_prefix" | sed "s,^$am__strip_prefix,\\${prefix},"`
+       ;;
+     *)
+       am_python_prefix_subst=$am_cv_python_prefix
+       ;;
+     esac
+   else # using GNU prefix value, not python sys.prefix
+     am_python_prefix_subst='${prefix}'
+     am_python_prefix=$am_python_prefix_subst
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU default $am_display_PYTHON prefix" >&5
+printf %s "checking for GNU default $am_display_PYTHON prefix... " >&6; }
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_python_prefix" >&5
+printf "%s\n" "$am_python_prefix" >&6; }
+   fi
+fi
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5
-$as_echo_n "checking for $am_display_PYTHON platform... " >&6; }
-if ${am_cv_python_platform+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`
+  # Substituting python_prefix_subst value.
+  PYTHON_PREFIX=$am_python_prefix_subst
+
+
+  # emacs-page Now do it all over again for Python exec_prefix, but with yet
+  # another conditional: fall back to regular prefix if that was specified.
+
+# Check whether --with-python_exec_prefix was given.
+if test ${with_python_exec_prefix+y}
+then :
+  withval=$with_python_exec_prefix; am_python_exec_prefix_subst=$withval
+   am_cv_python_exec_prefix=$withval
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for explicit $am_display_PYTHON exec_prefix" >&5
+printf %s "checking for explicit $am_display_PYTHON exec_prefix... " >&6; }
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_exec_prefix" >&5
+printf "%s\n" "$am_cv_python_exec_prefix" >&6; }
+else $as_nop
+
+   # no explicit --with-python_exec_prefix, but if
+   # --with-python_prefix was given, use its value for python_exec_prefix too.
+   if test -n "$with_python_prefix"
+then :
+  am_python_exec_prefix_subst=$with_python_prefix
+    am_cv_python_exec_prefix=$with_python_prefix
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for python_prefix-given $am_display_PYTHON exec_prefix" >&5
+printf %s "checking for python_prefix-given $am_display_PYTHON exec_prefix... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_exec_prefix" >&5
+printf "%s\n" "$am_cv_python_exec_prefix" >&6; }
+else $as_nop
+
+    # Set am__usable_exec_prefix whether using GNU or Python values,
+    # since we use that variable for pyexecdir.
+    if test "x$exec_prefix" = xNONE; then
+      am__usable_exec_prefix=$am__usable_prefix
+    else
+      am__usable_exec_prefix=$exec_prefix
+    fi
+    #
+    if $am_use_python_sys; then # using python sys.exec_prefix, not GNU
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for python default $am_display_PYTHON exec_prefix" >&5
+printf %s "checking for python default $am_display_PYTHON exec_prefix... " >&6; }
+if test ${am_cv_python_exec_prefix+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  am_cv_python_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_exec_prefix" >&5
+printf "%s\n" "$am_cv_python_exec_prefix" >&6; }
+                        case $am_cv_python_exec_prefix in
+      $am__usable_exec_prefix*)
+        am__strip_prefix=`echo "$am__usable_exec_prefix" | sed 's|.|.|g'`
+        am_python_exec_prefix_subst=`echo "$am_cv_python_exec_prefix" | sed "s,^$am__strip_prefix,\\${exec_prefix},"`
+        ;;
+      *)
+        am_python_exec_prefix_subst=$am_cv_python_exec_prefix
+        ;;
+     esac
+   else # using GNU $exec_prefix, not python sys.exec_prefix
+     am_python_exec_prefix_subst='${exec_prefix}'
+     am_python_exec_prefix=$am_python_exec_prefix_subst
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU default $am_display_PYTHON exec_prefix" >&5
+printf %s "checking for GNU default $am_display_PYTHON exec_prefix... " >&6; }
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_python_exec_prefix" >&5
+printf "%s\n" "$am_python_exec_prefix" >&6; }
+   fi
+fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5
-$as_echo "$am_cv_python_platform" >&6; }
-  PYTHON_PLATFORM=$am_cv_python_platform
 
+  # Substituting python_exec_prefix_subst.
+  PYTHON_EXEC_PREFIX=$am_python_exec_prefix_subst
 
-  # Just factor out some code duplication.
+
+  # Factor out some code duplication into this shell variable.
   am_python_setup_sysconfig="\
 import sys
 # Prefer sysconfig over distutils.sysconfig, for better compatibility
@@ -16322,99 +17436,96 @@ except ImportError:
     pass"
 
 
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5
-$as_echo_n "checking for $am_display_PYTHON script directory... " >&6; }
-if ${am_cv_python_pythondir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$prefix" = xNONE
-     then
-       am_py_prefix=$ac_default_prefix
-     else
-       am_py_prefix=$prefix
-     fi
-     am_cv_python_pythondir=`$PYTHON -c "
+              { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory (pythondir)" >&5
+printf %s "checking for $am_display_PYTHON script directory (pythondir)... " >&6; }
+if test ${am_cv_python_pythondir+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test "x$am_cv_python_prefix" = x; then
+     am_py_prefix=$am__usable_prefix
+   else
+     am_py_prefix=$am_cv_python_prefix
+   fi
+   am_cv_python_pythondir=`$PYTHON -c "
 $am_python_setup_sysconfig
 if can_use_sysconfig:
-    sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+  sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
 else:
-    from distutils import sysconfig
-    sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
+  from distutils import sysconfig
+  sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
 sys.stdout.write(sitedir)"`
-     case $am_cv_python_pythondir in
-     $am_py_prefix*)
-       am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
-       am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
-       ;;
-     *)
-       case $am_py_prefix in
-         /usr|/System*) ;;
-         *)
-         am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
-         ;;
-       esac
-       ;;
+   #
+   case $am_cv_python_pythondir in
+   $am_py_prefix*)
+     am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+     am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,\\${PYTHON_PREFIX},"`
+     ;;
+   *)
+     case $am_py_prefix in
+       /usr|/System*) ;;
+       *) am_cv_python_pythondir="\${PYTHON_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
+          ;;
      esac
+     ;;
+   esac
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5
-$as_echo "$am_cv_python_pythondir" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5
+printf "%s\n" "$am_cv_python_pythondir" >&6; }
   pythondir=$am_cv_python_pythondir
 
 
-
-  pkgpythondir=\${pythondir}/$PACKAGE
+          pkgpythondir=\${pythondir}/$PACKAGE
 
 
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory" >&5
-$as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; }
-if ${am_cv_python_pyexecdir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$exec_prefix" = xNONE
-     then
-       am_py_exec_prefix=$am_py_prefix
-     else
-       am_py_exec_prefix=$exec_prefix
-     fi
-     am_cv_python_pyexecdir=`$PYTHON -c "
+          { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory (pyexecdir)" >&5
+printf %s "checking for $am_display_PYTHON extension module directory (pyexecdir)... " >&6; }
+if test ${am_cv_python_pyexecdir+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test "x$am_cv_python_exec_prefix" = x; then
+     am_py_exec_prefix=$am__usable_exec_prefix
+   else
+     am_py_exec_prefix=$am_cv_python_exec_prefix
+   fi
+   am_cv_python_pyexecdir=`$PYTHON -c "
 $am_python_setup_sysconfig
 if can_use_sysconfig:
-    sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
+  sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_exec_prefix'})
 else:
-    from distutils import sysconfig
-    sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
+  from distutils import sysconfig
+  sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_exec_prefix')
 sys.stdout.write(sitedir)"`
-     case $am_cv_python_pyexecdir in
-     $am_py_exec_prefix*)
-       am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
-       am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
-       ;;
-     *)
-       case $am_py_exec_prefix in
-         /usr|/System*) ;;
-         *)
-          am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
-          ;;
-       esac
-       ;;
+   #
+   case $am_cv_python_pyexecdir in
+   $am_py_exec_prefix*)
+     am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+     am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,\\${PYTHON_EXEC_PREFIX},"`
+     ;;
+   *)
+     case $am_py_exec_prefix in
+       /usr|/System*) ;;
+       *) am_cv_python_pyexecdir="\${PYTHON_EXEC_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
+          ;;
      esac
+     ;;
+   esac
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5
-$as_echo "$am_cv_python_pyexecdir" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5
+printf "%s\n" "$am_cv_python_pyexecdir" >&6; }
   pyexecdir=$am_cv_python_pyexecdir
 
 
-
-  pkgpyexecdir=\${pyexecdir}/$PACKAGE
+      pkgpyexecdir=\${pyexecdir}/$PACKAGE
 
 
 
   fi
 
 
-
        #
        # Allow the use of a (user set) custom python version
        #
@@ -16422,11 +17533,12 @@ $as_echo "$am_cv_python_pyexecdir" >&6; }
 
        # Extract the first word of "python[$PYTHON_VERSION]", so it can be a program name with args.
 set dummy python$PYTHON_VERSION; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_PYTHON+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_path_PYTHON+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   case $PYTHON in
   [\\/]* | ?:[\\/]*)
   ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
@@ -16436,11 +17548,15 @@ else
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_path_PYTHON="$as_dir$ac_word$ac_exec_ext"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
@@ -16452,11 +17568,11 @@ esac
 fi
 PYTHON=$ac_cv_path_PYTHON
 if test -n "$PYTHON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
-$as_echo "$PYTHON" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
+printf "%s\n" "$PYTHON" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
        #
        # Check for a version of Python >= 2.1.0
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a version of Python >= '2.1.0'" >&5
-$as_echo_n "checking for a version of Python >= '2.1.0'... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a version of Python >= '2.1.0'" >&5
+printf %s "checking for a version of Python >= '2.1.0'... " >&6; }
        ac_supports_python_ver=`$PYTHON -c "import sys; \
                ver = sys.version.split ()[0]; \
                print (ver >= '2.1.0')"`
        if test "$ac_supports_python_ver" != "True"; then
                if test -z "$PYTHON_NOVERSIONCHECK"; then
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-                       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+                       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+                       { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "
 This version of the AC_PYTHON_DEVEL macro
 doesn't work properly with versions of Python before
@@ -16490,29 +17606,29 @@ to something else than an empty string.
 
 See \`config.log' for more details" "$LINENO" 5; }
                else
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: skip at user request" >&5
-$as_echo "skip at user request" >&6; }
+                       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: skip at user request" >&5
+printf "%s\n" "skip at user request" >&6; }
                fi
        else
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+               { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
        fi
 
        #
        # if the macro parameter ``version'' is set, honour it
        #
        if test -n ">= '3.6'"; then
-               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a version of Python >= '3.6'" >&5
-$as_echo_n "checking for a version of Python >= '3.6'... " >&6; }
+               { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a version of Python >= '3.6'" >&5
+printf %s "checking for a version of Python >= '3.6'... " >&6; }
                ac_supports_python_ver=`$PYTHON -c "import sys; \
                        ver = sys.version.split ()[0]; \
                        print (ver >= '3.6')"`
                if test "$ac_supports_python_ver" = "True"; then
-                  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+                  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
                else
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+                       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
                        as_fn_error $? "this package requires Python >= '3.6'.
 If you have it installed, but it isn't the default Python
 interpreter in your system path, please pass the PYTHON_VERSION
@@ -16525,15 +17641,15 @@ variable to configure. See \`\`configure --help'' for reference.
        #
        # Check if you have distutils, else fail
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the distutils Python package" >&5
-$as_echo_n "checking for the distutils Python package... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the distutils Python package" >&5
+printf %s "checking for the distutils Python package... " >&6; }
        ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
        if test $? -eq 0; then
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+               { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
        else
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+               { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
                as_fn_error $? "cannot import Python module \"distutils\".
 Please check your Python installation. The error was:
 $ac_distutils_result" "$LINENO" 5
@@ -16543,8 +17659,8 @@ $ac_distutils_result" "$LINENO" 5
        #
        # Check for Python include path
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python include path" >&5
-$as_echo_n "checking for Python include path... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python include path" >&5
+printf %s "checking for Python include path... " >&6; }
        if test -z "$PYTHON_CPPFLAGS"; then
                python_path=`$PYTHON -c "import distutils.sysconfig; \
                        print (distutils.sysconfig.get_python_inc ());"`
@@ -16559,15 +17675,15 @@ $as_echo_n "checking for Python include path... " >&6; }
                fi
                PYTHON_CPPFLAGS=$python_path
        fi
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CPPFLAGS" >&5
-$as_echo "$PYTHON_CPPFLAGS" >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CPPFLAGS" >&5
+printf "%s\n" "$PYTHON_CPPFLAGS" >&6; }
 
 
        #
        # Check for Python library path
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python library path" >&5
-$as_echo_n "checking for Python library path... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python library path" >&5
+printf %s "checking for Python library path... " >&6; }
        if test -z "$PYTHON_LIBS"; then
                # (makes two attempts to ensure we've got a version number
                # from the interpreter)
@@ -16592,9 +17708,7 @@ EOD`
 
                # Make the versioning information available to the compiler
 
-cat >>confdefs.h <<_ACEOF
-#define HAVE_PYTHON "$ac_python_version"
-_ACEOF
+printf "%s\n" "#define HAVE_PYTHON \"$ac_python_version\"" >>confdefs.h
 
 
                # First, the library directory:
@@ -16643,56 +17757,56 @@ EOD`
                        " "$LINENO" 5
                fi
        fi
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LIBS" >&5
-$as_echo "$PYTHON_LIBS" >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LIBS" >&5
+printf "%s\n" "$PYTHON_LIBS" >&6; }
 
 
        #
        # Check for site packages
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python site-packages path" >&5
-$as_echo_n "checking for Python site-packages path... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python site-packages path" >&5
+printf %s "checking for Python site-packages path... " >&6; }
        if test -z "$PYTHON_SITE_PKG"; then
                PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
                        print (distutils.sysconfig.get_python_lib(0,0));"`
        fi
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_SITE_PKG" >&5
-$as_echo "$PYTHON_SITE_PKG" >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_SITE_PKG" >&5
+printf "%s\n" "$PYTHON_SITE_PKG" >&6; }
 
 
        #
        # libraries which must be linked in when embedding
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking python extra libraries" >&5
-$as_echo_n "checking python extra libraries... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking python extra libraries" >&5
+printf %s "checking python extra libraries... " >&6; }
        if test -z "$PYTHON_EXTRA_LIBS"; then
           PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
                 conf = distutils.sysconfig.get_config_var; \
                 print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
        fi
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LIBS" >&5
-$as_echo "$PYTHON_EXTRA_LIBS" >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LIBS" >&5
+printf "%s\n" "$PYTHON_EXTRA_LIBS" >&6; }
 
 
        #
        # linking flags needed when embedding
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking python extra linking flags" >&5
-$as_echo_n "checking python extra linking flags... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking python extra linking flags" >&5
+printf %s "checking python extra linking flags... " >&6; }
        if test -z "$PYTHON_EXTRA_LDFLAGS"; then
                PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
                        conf = distutils.sysconfig.get_config_var; \
                        print (conf('LINKFORSHARED'))"`
        fi
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LDFLAGS" >&5
-$as_echo "$PYTHON_EXTRA_LDFLAGS" >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LDFLAGS" >&5
+printf "%s\n" "$PYTHON_EXTRA_LDFLAGS" >&6; }
 
 
        #
        # final check to see if everything compiles alright
        #
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking consistency of all components of python development environment" >&5
-$as_echo_n "checking consistency of all components of python development environment... " >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking consistency of all components of python development environment" >&5
+printf %s "checking consistency of all components of python development environment... " >&6; }
        # save current global flags
        ac_save_LIBS="$LIBS"
        ac_save_LDFLAGS="$LDFLAGS"
@@ -16711,7 +17825,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
                #include <Python.h>
 int
-main ()
+main (void)
 {
 Py_Initialize();
   ;
@@ -16719,12 +17833,13 @@ Py_Initialize();
 }
 
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   pythonexists=yes
-else
+else $as_nop
   pythonexists=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
        ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
@@ -16737,12 +17852,12 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
        LIBS="$ac_save_LIBS"
        LDFLAGS="$ac_save_LDFLAGS"
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pythonexists" >&5
-$as_echo "$pythonexists" >&6; }
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $pythonexists" >&5
+printf "%s\n" "$pythonexists" >&6; }
 
         if test ! "x$pythonexists" = "xyes"; then
-          { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+          { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "
   Could not link test program to Python. Maybe the main Python library has been
   installed in some non-standard library path. If so, pass it to configure,
@@ -16765,9 +17880,10 @@ See \`config.log' for more details" "$LINENO" 5; }
 fi
 
 # Check whether --enable-special was given.
-if test "${enable_special+set}" = set; then :
+if test ${enable_special+y}
+then :
   enableval=$enable_special;
-else
+else $as_nop
   enable_special=no
 fi
 
 
 # --enable-bin enables script and bin "extensions".
 # Check whether --enable-bin was given.
-if test "${enable_bin+set}" = set; then :
+if test ${enable_bin+y}
+then :
   enableval=$enable_bin;
-else
+else $as_nop
   enable_bin=yes
 fi
 
 # --enable-fsts is an alias to enable FST SO extensions: compact, const,
 # linear, lookahead, and ngram.
 # Check whether --enable-fsts was given.
-if test "${enable_fsts+set}" = set; then :
+if test ${enable_fsts+y}
+then :
   enableval=$enable_fsts;
-else
+else $as_nop
   enable_fsts=no
 fi
 
 # --enable-grm is an alias to enable all dependencies of OpenGrm: far, mpdt,
 # and pdt.
 # Check whether --enable-grm was given.
-if test "${enable_grm+set}" = set; then :
+if test ${enable_grm+y}
+then :
   enableval=$enable_grm;
-else
+else $as_nop
   enable_grm=no
 fi
 
 
 
 # Check whether --with-libfstdir was given.
-if test "${with_libfstdir+set}" = set; then :
+if test ${with_libfstdir+y}
+then :
   withval=$with_libfstdir;
-else
+else $as_nop
   with_libfstdir=${libdir}/fst
 fi
 
@@ -16856,12 +17976,13 @@ libfstdir=$with_libfstdir
 # Flags may be changed after configuring, so this is checked again by
 # weight_test.cc.  The check here is to save time in the common case,
 # or when someone does not run `make check`.
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+if test "$cross_compiling" = yes
+then :
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot run test program while cross compiling
 See \`config.log' for more details" "$LINENO" 5; }
-else
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -16879,7 +18000,7 @@ else
                  }
 
 int
-main ()
+main (void)
 {
 
                  volatile double test_value = 1.1;
@@ -16896,11 +18017,12 @@ main ()
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_run "$LINENO"; then :
+if ac_fn_cxx_try_run "$LINENO"
+then :
   echo "Float equality is good"
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "Test float equality failed! Compile with -msse -mfpmath=sse if using g++.
 See \`config.log' for more details" "$LINENO" 5; }
 fi
@@ -16909,43 +18031,42 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-$as_echo_n "checking for dlopen in -ldl... " >&6; }
-if ${ac_cv_lib_dl_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+printf %s "checking for dlopen in -ldl... " >&6; }
+if test ${ac_cv_lib_dl_dlopen+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldl  $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 dlopen ();
+namespace conftest {
+  extern "C" int dlopen ();
+}
 int
-main ()
+main (void)
 {
-return dlopen ();
+return conftest::dlopen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
+if ac_fn_cxx_try_link "$LINENO"
+then :
   ac_cv_lib_dl_dlopen=yes
-else
+else $as_nop
   ac_cv_lib_dl_dlopen=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes
+then :
   DL_LIBS=-ldl
 fi
 
@@ -16978,8 +18099,8 @@ _ACEOF
     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;} ;;
+      *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
@@ -17009,15 +18130,15 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
      /^ac_cv_env_/b end
      t clear
      :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/
      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
     if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+printf "%s\n" "$as_me: updating cache $cache_file" >&6;}
       if test ! -f "$cache_file" || test -h "$cache_file"; then
        cat confcache >"$cache_file"
       else
@@ -17031,8 +18152,8 @@ $as_echo "$as_me: updating cache $cache_file" >&6;}
       fi
     fi
   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;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
@@ -17049,7 +18170,7 @@ U=
 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"`
+  ac_i=`printf "%s\n" "$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"
@@ -17060,14 +18181,14 @@ LIBOBJS=$ac_libobjs
 LTLIBOBJS=$ac_ltlibobjs
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
-$as_echo_n "checking that generated files are newer than configure... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+printf %s "checking that generated files are newer than configure... " >&6; }
    if test -n "$am_sleep_pid"; then
      # Hide warnings about reused PIDs.
      wait $am_sleep_pid 2>/dev/null
    fi
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
-$as_echo "done" >&6; }
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5
+printf "%s\n" "done" >&6; }
  if test -n "$EXEEXT"; then
   am__EXEEXT_TRUE=
   am__EXEEXT_FALSE='#'
@@ -17153,8 +18274,8 @@ fi
 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;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;}
 as_write_fail=0
 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
 #! $SHELL
@@ -17177,14 +18298,16 @@ cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+as_nop=:
+if test ${ZSH_VERSION+y} && (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
+else $as_nop
   case `(set -o) 2>/dev/null` in #(
   *posix*) :
     set -o posix ;; #(
@@ -17194,46 +18317,46 @@ esac
 fi
 
 
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
 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
+IFS=" ""       $as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 
 # The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if ${PATH_SEPARATOR+false} :; 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 ||
@@ -17242,13 +18365,6 @@ if test "${PATH_SEPARATOR+set}" != set; then
 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.
 as_myself=
 case $0 in #((
@@ -17257,8 +18373,12 @@ case $0 in #((
 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
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
   done
 IFS=$as_save_IFS
 
@@ -17270,30 +18390,10 @@ 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
+  printf "%s\n" "$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 STATUS ERROR [LINENO LOG_FD]
@@ -17306,13 +18406,14 @@ as_fn_error ()
   as_status=$1; test $as_status -eq 0 && as_status=1
   if test "$4"; then
     as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $2" >&2
+  printf "%s\n" "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
 
+
 # as_fn_set_status STATUS
 # -----------------------
 # Set $? to STATUS, without forking.
@@ -17339,18 +18440,20 @@ 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 :
+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
+else $as_nop
   as_fn_append ()
   {
     eval $1=\$$1\$2
@@ -17362,12 +18465,13 @@ fi # as_fn_append
 # 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 :
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
   eval 'as_fn_arith ()
   {
     as_val=$(( $* ))
   }'
-else
+else $as_nop
   as_fn_arith ()
   {
     as_val=`expr "$@" || test $? -eq 1`
@@ -17398,7 +18502,7 @@ as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
         X"$0" : 'X\(//\)$' \| \
         X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
+printf "%s\n" X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
            s//\1/
            q
@@ -17420,6 +18524,10 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS
 as_cr_digits='0123456789'
 as_cr_alnum=$as_cr_Letters$as_cr_digits
 
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
 ECHO_C= ECHO_N= ECHO_T=
 case `echo -n x` in #(((((
 -n*)
@@ -17433,6 +18541,12 @@ case `echo -n x` in #(((((
   ECHO_N='-n';;
 esac
 
+# For backward compatibility with old third-party macros, we provide
+# the shell variables $as_echo and $as_echo_n.  New code should use
+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.
+as_echo='printf %s\n'
+as_echo_n='printf %s'
+
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
@@ -17474,7 +18588,7 @@ as_fn_mkdir_p ()
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
@@ -17483,7 +18597,7 @@ $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" |
+printf "%s\n" X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
            s//\1/
            q
@@ -17545,8 +18659,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by OpenFst $as_me 1.8.1, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+This file was extended by OpenFst $as_me 1.8.2, which was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -17608,14 +18722,16 @@ $config_commands
 Report bugs to <help@www.openfst.org>."
 
 _ACEOF
+ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`
+ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-OpenFst config.status 1.8.1
-configured by $0, generated by GNU Autoconf 2.69,
+OpenFst config.status 1.8.2
+configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
   -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 ;;
+    printf "%s\n" "$ac_cs_version"; exit ;;
   --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
+    printf "%s\n" "$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"` ;;
+    *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
     '') as_fn_error $? "missing file argument" ;;
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
@@ -17671,7 +18787,7 @@ do
   --header | --heade | --head | --hea )
     $ac_shift
     case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     as_fn_append CONFIG_HEADERS " '$ac_optarg'"
     ac_need_defaults=false;;
@@ -17680,7 +18796,7 @@ do
     as_fn_error $? "ambiguous option: \`$1'
 Try \`$0 --help' for more information.";;
   --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
+    printf "%s\n" "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
     ac_cs_silent=: ;;
@@ -17708,7 +18824,7 @@ 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
+  \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
   export CONFIG_SHELL
   exec "\$@"
@@ -17722,7 +18838,7 @@ exec 5>>config.log
   sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
 ## Running $as_me. ##
 _ASBOX
-  $as_echo "$ac_log"
+  printf "%s\n" "$ac_log"
 } >&5
 
 _ACEOF
@@ -18124,7 +19240,6 @@ do
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
-    "src/include/fst/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/fst/config.h" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "src/include/Makefile") CONFIG_FILES="$CONFIG_FILES src/include/Makefile" ;;
@@ -18155,9 +19270,9 @@ done
 # We use the long form for the default assignment because of an extremely
 # bizarre bug on SunOS 4.1.3.
 if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+  test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files
+  test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers
+  test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands
 fi
 
 # Have a temporary directory for convenience.  Make it in the build tree
@@ -18493,7 +19608,7 @@ do
           esac ||
           as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
     done
 
     # 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'
+         printf "%s\n" "$*" | 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;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+printf "%s\n" "$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" |
+       ac_sed_conf_input=`printf "%s\n" "$configure_input" |
        sed 's/[\\\\&|]/\\\\&/g'`;; #(
     *) ac_sed_conf_input=$configure_input;;
     esac
@@ -18528,7 +19643,7 @@ $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" |
+printf "%s\n" X"$ac_file" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
            s//\1/
            q
@@ -18552,9 +19667,9 @@ $as_echo X"$ac_file" |
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  ac_dir_suffix=/`printf "%s\n" "$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|/||'`
+  ac_top_builddir_sub=`printf "%s\n" "$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/ ;;
@@ -18616,8 +19731,8 @@ ac_sed_dataroot='
 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;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+printf "%s\n" "$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='
@@ -18661,9 +19776,9 @@ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
   { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' \
       "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+  { printf "%s\n" "$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'
+printf "%s\n" "$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 "$ac_tmp/stdin"
@@ -18679,20 +19794,20 @@ which seems to be undefined.  Please make sure it is defined" >&2;}
   #
   if test x"$ac_file" != x-; then
     {
-      $as_echo "/* $configure_input  */" \
+      printf "%s\n" "/* $configure_input  */" >&1 \
       && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
     } >"$ac_tmp/config.h" \
       || as_fn_error $? "could not create $ac_file" "$LINENO" 5
     if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+printf "%s\n" "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
       mv "$ac_tmp/config.h" "$ac_file" \
        || as_fn_error $? "could not create $ac_file" "$LINENO" 5
     fi
   else
-    $as_echo "/* $configure_input  */" \
+    printf "%s\n" "/* $configure_input  */" >&1 \
       && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
       || as_fn_error $? "could not create -" "$LINENO" 5
   fi
@@ -18712,7 +19827,7 @@ $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
         X"$_am_arg" : 'X\(//\)[^/]' \| \
         X"$_am_arg" : 'X\(//\)$' \| \
         X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$_am_arg" |
+printf "%s\n" X"$_am_arg" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
            s//\1/
            q
@@ -18732,8 +19847,8 @@ $as_echo X"$_am_arg" |
          s/.*/./; q'`/stamp-h$_am_stamp_count
  ;;
 
-  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
-$as_echo "$as_me: executing $ac_file commands" >&6;}
+  :C)  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+printf "%s\n" "$as_me: executing $ac_file commands" >&6;}
  ;;
   esac
 
@@ -18759,7 +19874,7 @@ esac
   for am_mf
   do
     # Strip MF so we end up with the name of the file.
-    am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'`
+    am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile which includes
     # dependency-tracking related rules and includes.
     # Grep'ing the whole file directly is not great: AIX grep has a line
@@ -18771,7 +19886,7 @@ $as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
         X"$am_mf" : 'X\(//\)[^/]' \| \
         X"$am_mf" : 'X\(//\)$' \| \
         X"$am_mf" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$am_mf" |
+printf "%s\n" X"$am_mf" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
            s//\1/
            q
@@ -18793,7 +19908,7 @@ $as_echo X"$am_mf" |
 $as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \
         X"$am_mf" : 'X\(//\)$' \| \
         X"$am_mf" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$am_mf" |
+printf "%s\n" X/"$am_mf" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
            s//\1/
            q
@@ -18818,8 +19933,8 @@ $as_echo X/"$am_mf" |
    (exit $ac_status); } || am_rc=$?
   done
   if test $am_rc -ne 0; then
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+    { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "Something went wrong bootstrapping makefile fragments
     for automatic dependency tracking.  If GNU make was not used, consider
     re-running the configure script with MAKE=\"gmake\" (or whatever is
@@ -18850,7 +19965,6 @@ See \`config.log' for more details" "$LINENO" 5; }
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
@@ -19377,6 +20491,7 @@ _LT_EOF
   esac
 
 
+
 ltmain=$ac_aux_dir/ltmain.sh
 
 
@@ -19579,7 +20694,8 @@ if test "$no_create" != yes; then
   $ac_cs_success || as_fn_exit 1
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
+
index 54d332a..a2328ff 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT([OpenFst], [1.8.1], [help@www.openfst.org])
+AC_INIT([OpenFst],[1.8.2],[help@www.openfst.org])
 AM_INIT_AUTOMAKE([foreign nostdinc -Wall -Werror subdir-objects])
 AM_PROG_AR
 
@@ -8,9 +8,9 @@ AC_PROG_CXX
 CXX="$CXX -std=c++17 -fno-exceptions -Wno-deprecated-declarations"
 
 AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
+LT_INIT
 
-AC_CONFIG_HEADERS([config.h src/include/fst/config.h])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_SRCDIR([src/lib/fst.cc])
 AC_CONFIG_FILES([
   Makefile
@@ -106,7 +106,7 @@ AC_ARG_ENABLE([python],
 AM_CONDITIONAL([HAVE_PYTHON], [test "x$enable_python" != xno])
 if test "x$enable_python" != xno; then
   AM_PATH_PYTHON(3.6)
-  AC_PYTHON_DEVEL([>= '3.6'])
+  AX_PYTHON_DEVEL([>= '3.6'])
 fi
 
 AC_ARG_ENABLE([special],
diff --git a/depcomp b/depcomp
index 6b39162..715e343 100755 (executable)
--- a/depcomp
+++ b/depcomp
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2020 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 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
old mode 100644 (file)
new mode 100755 (executable)
index b6f1800..21e5e07
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -31,7 +31,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION=2.4.6
+VERSION="2.4.6 Debian-2.4.6-15"
 package_revision=2.4.6
 
 
@@ -387,7 +387,7 @@ EXIT_SKIP=77          # $? = 77 is used to indicate a skipped test to automake.
 # putting '$debug_cmd' at the start of all your functions, you can get
 # bash to show function call trace with:
 #
-#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+#    debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
 debug_cmd=${debug_cmd-":"}
 exit_cmd=:
 
@@ -1370,7 +1370,7 @@ func_lt_ver ()
 #! /bin/sh
 
 # Set a version string for this script.
-scriptversion=2014-01-07.03; # UTC
+scriptversion=2015-10-07.11; # UTC
 
 # A portable, pluggable option parser for Bourne shell.
 # Written by Gary V. Vaughan, 2010
@@ -1530,6 +1530,8 @@ func_run_hooks ()
 {
     $debug_cmd
 
+    _G_rc_run_hooks=false
+
     case " $hookable_fns " in
       *" $1 "*) ;;
       *) func_fatal_error "'$1' does not support hook funcions.n" ;;
@@ -1538,16 +1540,16 @@ func_run_hooks ()
     eval _G_hook_fns=\$$1_hooks; shift
 
     for _G_hook in $_G_hook_fns; do
-      eval $_G_hook '"$@"'
-
-      # store returned options list back into positional
-      # parameters for next 'cmd' execution.
-      eval _G_hook_result=\$${_G_hook}_result
-      eval set dummy "$_G_hook_result"; shift
+      if eval $_G_hook '"$@"'; then
+        # store returned options list back into positional
+        # parameters for next 'cmd' execution.
+        eval _G_hook_result=\$${_G_hook}_result
+        eval set dummy "$_G_hook_result"; shift
+        _G_rc_run_hooks=:
+      fi
     done
 
-    func_quote_for_eval ${1+"$@"}
-    func_run_hooks_result=$func_quote_for_eval_result
+    $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
 }
 
 
@@ -1557,10 +1559,16 @@ func_run_hooks ()
 ## --------------- ##
 
 # In order to add your own option parsing hooks, you must accept the
-# full positional parameter list in your hook function, remove any
-# options that you action, and then pass back the remaining unprocessed
+# full positional parameter list in your hook function, you may remove/edit
+# any options that you action, and then pass back the remaining unprocessed
 # options in '<hooked_function_name>_result', escaped suitably for
-# 'eval'.  Like this:
+# 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
+# hook's caller know that it should pay attention to
+# '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
+# arguments are left untouched by the hook and therefore caller will ignore the
+# result variable.
+#
+# Like this:
 #
 #    my_options_prep ()
 #    {
@@ -1570,9 +1578,11 @@ func_run_hooks ()
 #        usage_message=$usage_message'
 #      -s, --silent       don'\''t print informational messages
 #    '
-#
-#        func_quote_for_eval ${1+"$@"}
-#        my_options_prep_result=$func_quote_for_eval_result
+#        # No change in '$@' (ignored completely by this hook).  There is
+#        # no need to do the equivalent (but slower) action:
+#        # func_quote_for_eval ${1+"$@"}
+#        # my_options_prep_result=$func_quote_for_eval_result
+#        false
 #    }
 #    func_add_hook func_options_prep my_options_prep
 #
@@ -1581,25 +1591,37 @@ func_run_hooks ()
 #    {
 #        $debug_cmd
 #
+#        args_changed=false
+#
 #        # Note that for efficiency, we parse as many options as we can
 #        # recognise in a loop before passing the remainder back to the
 #        # caller on the first unrecognised argument we encounter.
 #        while test $# -gt 0; do
 #          opt=$1; shift
 #          case $opt in
-#            --silent|-s) opt_silent=: ;;
+#            --silent|-s) opt_silent=:
+#                         args_changed=:
+#                         ;;
 #            # Separate non-argument short options:
 #            -s*)         func_split_short_opt "$_G_opt"
 #                         set dummy "$func_split_short_opt_name" \
 #                             "-$func_split_short_opt_arg" ${1+"$@"}
 #                         shift
+#                         args_changed=:
 #                         ;;
-#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#            *)           # Make sure the first unrecognised option "$_G_opt"
+#                         # is added back to "$@", we could need that later
+#                         # if $args_changed is true.
+#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
 #          esac
 #        done
 #
-#        func_quote_for_eval ${1+"$@"}
-#        my_silent_option_result=$func_quote_for_eval_result
+#        if $args_changed; then
+#          func_quote_for_eval ${1+"$@"}
+#          my_silent_option_result=$func_quote_for_eval_result
+#        fi
+#
+#        $args_changed
 #    }
 #    func_add_hook func_parse_options my_silent_option
 #
@@ -1611,16 +1633,32 @@ func_run_hooks ()
 #        $opt_silent && $opt_verbose && func_fatal_help "\
 #    '--silent' and '--verbose' options are mutually exclusive."
 #
-#        func_quote_for_eval ${1+"$@"}
-#        my_option_validation_result=$func_quote_for_eval_result
+#        false
 #    }
 #    func_add_hook func_validate_options my_option_validation
 #
-# You'll alse need to manually amend $usage_message to reflect the extra
+# You'll also need to manually amend $usage_message to reflect the extra
 # options you parse.  It's preferable to append if you can, so that
 # multiple option parsing hooks can be added safely.
 
 
+# func_options_finish [ARG]...
+# ----------------------------
+# Finishing the option parse loop (call 'func_options' hooks ATM).
+func_options_finish ()
+{
+    $debug_cmd
+
+    _G_func_options_finish_exit=false
+    if func_run_hooks func_options ${1+"$@"}; then
+      func_options_finish_result=$func_run_hooks_result
+      _G_func_options_finish_exit=:
+    fi
+
+    $_G_func_options_finish_exit
+}
+
+
 # func_options [ARG]...
 # ---------------------
 # All the functions called inside func_options are hookable. See the
@@ -1630,17 +1668,28 @@ func_options ()
 {
     $debug_cmd
 
-    func_options_prep ${1+"$@"}
-    eval func_parse_options \
-        ${func_options_prep_result+"$func_options_prep_result"}
-    eval func_validate_options \
-        ${func_parse_options_result+"$func_parse_options_result"}
+    _G_rc_options=false
 
-    eval func_run_hooks func_options \
-        ${func_validate_options_result+"$func_validate_options_result"}
+    for my_func in options_prep parse_options validate_options options_finish
+    do
+      if eval func_$my_func '${1+"$@"}'; then
+        eval _G_res_var='$'"func_${my_func}_result"
+        eval set dummy "$_G_res_var" ; shift
+        _G_rc_options=:
+      fi
+    done
+
+    # Save modified positional parameters for caller.  As a top-level
+    # options-parser function we always need to set the 'func_options_result'
+    # variable (regardless the $_G_rc_options value).
+    if $_G_rc_options; then
+      func_options_result=$_G_res_var
+    else
+      func_quote_for_eval ${1+"$@"}
+      func_options_result=$func_quote_for_eval_result
+    fi
 
-    # save modified positional parameters for caller
-    func_options_result=$func_run_hooks_result
+    $_G_rc_options
 }
 
 
@@ -1649,9 +1698,9 @@ func_options ()
 # All initialisations required before starting the option parse loop.
 # Note that when calling hook functions, we pass through the list of
 # positional parameters.  If a hook function modifies that list, and
-# needs to propogate that back to rest of this script, then the complete
+# needs to propagate that back to rest of this script, then the complete
 # modified list must be put in 'func_run_hooks_result' before
-# returning.
+# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
 func_hookable func_options_prep
 func_options_prep ()
 {
@@ -1661,10 +1710,14 @@ func_options_prep ()
     opt_verbose=false
     opt_warning_types=
 
-    func_run_hooks func_options_prep ${1+"$@"}
+    _G_rc_options_prep=false
+    if func_run_hooks func_options_prep ${1+"$@"}; then
+      _G_rc_options_prep=:
+      # save modified positional parameters for caller
+      func_options_prep_result=$func_run_hooks_result
+    fi
 
-    # save modified positional parameters for caller
-    func_options_prep_result=$func_run_hooks_result
+    $_G_rc_options_prep
 }
 
 
@@ -1678,18 +1731,20 @@ func_parse_options ()
 
     func_parse_options_result=
 
+    _G_rc_parse_options=false
     # this just eases exit handling
     while test $# -gt 0; do
       # Defer to hook functions for initial option parsing, so they
       # get priority in the event of reusing an option name.
-      func_run_hooks func_parse_options ${1+"$@"}
-
-      # Adjust func_parse_options positional parameters to match
-      eval set dummy "$func_run_hooks_result"; shift
+      if func_run_hooks func_parse_options ${1+"$@"}; then
+        eval set dummy "$func_run_hooks_result"; shift
+        _G_rc_parse_options=:
+      fi
 
       # Break out of the loop if we already parsed every option.
       test $# -gt 0 || break
 
+      _G_match_parse_options=:
       _G_opt=$1
       shift
       case $_G_opt in
@@ -1704,7 +1759,10 @@ func_parse_options ()
                      ;;
 
         --warnings|--warning|-W)
-                      test $# = 0 && func_missing_arg $_G_opt && break
+                      if test $# = 0 && func_missing_arg $_G_opt; then
+                        _G_rc_parse_options=:
+                        break
+                      fi
                       case " $warning_categories $1" in
                         *" $1 "*)
                           # trailing space prevents matching last $1 above
@@ -1757,15 +1815,25 @@ func_parse_options ()
                       shift
                       ;;
 
-        --)           break ;;
+        --)           _G_rc_parse_options=: ; break ;;
         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
-        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift
+                      _G_match_parse_options=false
+                      break
+                      ;;
       esac
+
+      $_G_match_parse_options && _G_rc_parse_options=:
     done
 
-    # save modified positional parameters for caller
-    func_quote_for_eval ${1+"$@"}
-    func_parse_options_result=$func_quote_for_eval_result
+
+    if $_G_rc_parse_options; then
+      # save modified positional parameters for caller
+      func_quote_for_eval ${1+"$@"}
+      func_parse_options_result=$func_quote_for_eval_result
+    fi
+
+    $_G_rc_parse_options
 }
 
 
@@ -1778,16 +1846,21 @@ func_validate_options ()
 {
     $debug_cmd
 
+    _G_rc_validate_options=false
+
     # Display all warnings if -W was not given.
     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 
-    func_run_hooks func_validate_options ${1+"$@"}
+    if func_run_hooks func_validate_options ${1+"$@"}; then
+      # save modified positional parameters for caller
+      func_validate_options_result=$func_run_hooks_result
+      _G_rc_validate_options=:
+    fi
 
     # Bail if the options were screwed!
     $exit_cmd $EXIT_FAILURE
 
-    # save modified positional parameters for caller
-    func_validate_options_result=$func_run_hooks_result
+    $_G_rc_validate_options
 }
 
 
@@ -2068,12 +2141,12 @@ include the following information:
        compiler:       $LTCC
        compiler flags: $LTCFLAGS
        linker:         $LD (gnu? $with_gnu_ld)
-       version:        $progname (GNU libtool) 2.4.6
+       version:        $progname $scriptversion Debian-2.4.6-15
        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
 
 Report bugs to <bug-libtool@gnu.org>.
-GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+GNU libtool home page: <http://www.gnu.org/s/libtool/>.
 General help using GNU software: <http://www.gnu.org/gethelp/>."
     exit 0
 }
@@ -2270,6 +2343,8 @@ libtool_options_prep ()
     nonopt=
     preserve_args=
 
+    _G_rc_lt_options_prep=:
+
     # Shorthand for --mode=foo, only valid as the first argument
     case $1 in
     clean|clea|cle|cl)
@@ -2293,11 +2368,18 @@ libtool_options_prep ()
     uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
       shift; set dummy --mode uninstall ${1+"$@"}; shift
       ;;
+    *)
+      _G_rc_lt_options_prep=false
+      ;;
     esac
 
-    # Pass back the list of options.
-    func_quote_for_eval ${1+"$@"}
-    libtool_options_prep_result=$func_quote_for_eval_result
+    if $_G_rc_lt_options_prep; then
+      # Pass back the list of options.
+      func_quote_for_eval ${1+"$@"}
+      libtool_options_prep_result=$func_quote_for_eval_result
+    fi
+
+    $_G_rc_lt_options_prep
 }
 func_add_hook func_options_prep libtool_options_prep
 
@@ -2309,9 +2391,12 @@ libtool_parse_options ()
 {
     $debug_cmd
 
+    _G_rc_lt_parse_options=false
+
     # Perform our own loop to consume as many options as possible in
     # each iteration.
     while test $# -gt 0; do
+      _G_match_lt_parse_options=:
       _G_opt=$1
       shift
       case $_G_opt in
@@ -2386,15 +2471,22 @@ libtool_parse_options ()
                         func_append preserve_args " $_G_opt"
                         ;;
 
-       # An option not handled by this hook function:
-        *)             set dummy "$_G_opt" ${1+"$@"};  shift; break  ;;
+        # An option not handled by this hook function:
+        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
+                        _G_match_lt_parse_options=false
+                        break
+                        ;;
       esac
+      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
     done
 
+    if $_G_rc_lt_parse_options; then
+      # save modified positional parameters for caller
+      func_quote_for_eval ${1+"$@"}
+      libtool_parse_options_result=$func_quote_for_eval_result
+    fi
 
-    # save modified positional parameters for caller
-    func_quote_for_eval ${1+"$@"}
-    libtool_parse_options_result=$func_quote_for_eval_result
+    $_G_rc_lt_parse_options
 }
 func_add_hook func_parse_options libtool_parse_options
 
@@ -7220,11 +7312,6 @@ func_mode_link ()
        arg=$func_stripname_result
        ;;
 
-      -Wl,--as-needed)
-       deplibs="$deplibs $arg"
-       continue
-       ;;
-
       -Wl,*)
        func_stripname '-Wl,' '' "$arg"
        args=$func_stripname_result
@@ -7277,10 +7364,16 @@ func_mode_link ()
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
       # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -specs=*             GCC specs files
       # -stdlib=*            select c++ std lib with clang
+      # -fsanitize=*         Clang/GCC memory and address sanitizer
+      # -fuse-ld=*           Linker select flags for GCC
+      # -static-*            direct GCC to link specific libraries statically
+      # -fcilkplus           Cilk Plus language extension features for C/C++
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
+      -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus)
         func_quote_for_eval "$arg"
        arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
@@ -7529,7 +7622,6 @@ func_mode_link ()
 
     case $linkmode in
     lib)
-       as_needed_flag=
        passes="conv dlpreopen link"
        for file in $dlfiles $dlprefiles; do
          case $file in
@@ -7541,7 +7633,6 @@ func_mode_link ()
        done
        ;;
     prog)
-       as_needed_flag=
        compile_deplibs=
        finalize_deplibs=
        alldeplibs=false
@@ -7575,7 +7666,10 @@ func_mode_link ()
        case $pass in
        dlopen) libs=$dlfiles ;;
        dlpreopen) libs=$dlprefiles ;;
-       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+       link)
+         libs="$deplibs %DEPLIBS%"
+         test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+         ;;
        esac
       fi
       if test lib,dlpreopen = "$linkmode,$pass"; then
@@ -7611,15 +7705,6 @@ func_mode_link ()
        lib=
        found=false
        case $deplib in
-       -Wl,--as-needed)
-         if test prog,link = "$linkmode,$pass" ||
-            test lib,link = "$linkmode,$pass"; then
-           as_needed_flag="$deplib "
-         else
-           deplibs="$deplib $deplibs"
-         fi
-         continue
-         ;;
        -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
          if test prog,link = "$linkmode,$pass"; then
@@ -7903,19 +7988,19 @@ func_mode_link ()
            # It is a libtool convenience library, so add in its objects.
            func_append convenience " $ladir/$objdir/$old_library"
            func_append old_convenience " $ladir/$objdir/$old_library"
+           tmp_libs=
+           for deplib in $dependency_libs; do
+             deplibs="$deplib $deplibs"
+             if $opt_preserve_dup_deps; then
+               case "$tmp_libs " in
+               *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+               esac
+             fi
+             func_append tmp_libs " $deplib"
+           done
          elif test prog != "$linkmode" && test lib != "$linkmode"; then
            func_fatal_error "'$lib' is not a convenience library"
          fi
-         tmp_libs=
-         for deplib in $dependency_libs; do
-           deplibs="$deplib $deplibs"
-           if $opt_preserve_dup_deps; then
-             case "$tmp_libs " in
-             *" $deplib "*) func_append specialdeplibs " $deplib" ;;
-             esac
-           fi
-           func_append tmp_libs " $deplib"
-         done
          continue
        fi # $pass = conv
 
@@ -8839,6 +8924,9 @@ func_mode_link ()
            revision=$number_minor
            lt_irix_increment=no
            ;;
+         *)
+           func_fatal_configuration "$modename: unknown library version type '$version_type'"
+           ;;
          esac
          ;;
        no)
@@ -10037,13 +10125,6 @@ EOF
          test "X$libobjs" = "X " && libobjs=
        fi
 
-       # A bit hacky. I had wanted to add \$as_needed_flag to archive_cmds instead, but that
-       # comes from libtool.m4 which is part of the project being built. This should put it
-       # in the right place though.
-       if test lib,link = "$linkmode,$pass" && test -n "$as_needed_flag"; then
-         libobjs=$as_needed_flag$libobjs
-       fi
-
        save_ifs=$IFS; IFS='~'
        for cmd in $cmds; do
          IFS=$sp$nl
@@ -10276,8 +10357,8 @@ EOF
       compile_deplibs=$new_libs
 
 
-      func_append compile_command " $as_needed_flag $compile_deplibs"
-      func_append finalize_command " $as_needed_flag $finalize_deplibs"
+      func_append compile_command " $compile_deplibs"
+      func_append finalize_command " $finalize_deplibs"
 
       if test -n "$rpath$xrpath"; then
        # If the user specified any rpath flags, then add them.
index a3bc337..c4c0294 100644 (file)
@@ -728,7 +728,6 @@ _LT_CONFIG_SAVE_COMMANDS([
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
@@ -1042,8 +1041,8 @@ int forced_loaded() { return 2;}
 _LT_EOF
       echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
       $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
-      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
-      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+      echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+      $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
       echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
       $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
       cat > conftest.c << _LT_EOF
@@ -1072,11 +1071,11 @@ _LT_EOF
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-       10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+       10.0,*86*-darwin8*|10.0,*-darwin[[912]]*)
          _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
        10.[[012]][[,.]]*)
          _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
-       10.*)
+       10.*|11.*)
          _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
@@ -1493,7 +1492,7 @@ need_locks=$enable_libtool_lock
 m4_defun([_LT_PROG_AR],
 [AC_CHECK_TOOLS(AR, [ar], false)
 : ${AR=ar}
-: ${AR_FLAGS=cru}
+: ${AR_FLAGS=cr}
 _LT_DECL([], [AR], [1], [The archiver])
 _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
 
@@ -2887,6 +2886,18 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
+
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -3546,7 +3557,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd*)
+netbsd* | netbsdelf*-gnu)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   else
@@ -4052,7 +4063,8 @@ _LT_EOF
   if AC_TRY_EVAL(ac_compile); then
     # Now try to grab the symbols.
     nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+    $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD
+    if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then
       # Try sorting and uniquifying the output.
       if sort "$nlist" | uniq > "$nlist"T; then
        mv -f "$nlist"T "$nlist"
@@ -4424,7 +4436,7 @@ m4_if([$1], [CXX], [
            ;;
        esac
        ;;
-      netbsd*)
+      netbsd* | netbsdelf*-gnu)
        ;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -4692,6 +4704,12 @@ m4_if([$1], [CXX], [
        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
        _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
+      # flang / f18. f95 an alias for gfortran or flang on Debian
+      flang* | f18* | f95*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
       # icc used to be incompatible with GCC.
       # ICC 10 doesn't accept -KPIC any more.
       icc* | ifort*)
@@ -4936,6 +4954,9 @@ m4_if([$1], [CXX], [
       ;;
     esac
     ;;
+  linux* | k*bsd*-gnu | gnu*)
+    _LT_TAGVAR(link_all_deplibs, $1)=no
+    ;;
   *)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
     ;;
@@ -4998,6 +5019,9 @@ dnl Note also adjust exclude_expsyms for C++ above.
   openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
+  linux* | k*bsd*-gnu | gnu*)
+    _LT_TAGVAR(link_all_deplibs, $1)=no
+    ;;
   esac
 
   _LT_TAGVAR(ld_shlibs, $1)=yes
@@ -5252,7 +5276,7 @@ _LT_EOF
       fi
       ;;
 
-    netbsd*)
+    netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
        _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
        wlarc=
@@ -5773,6 +5797,7 @@ _LT_EOF
        if test yes = "$lt_cv_irix_exported_symbol"; then
           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
        fi
+       _LT_TAGVAR(link_all_deplibs, $1)=no
       else
        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
@@ -5794,7 +5819,7 @@ _LT_EOF
       esac
       ;;
 
-    netbsd*)
+    netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
        _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -6420,7 +6445,7 @@ if test yes != "$_lt_caught_CXX_error"; then
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
       # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 
     else
       GXX=no
@@ -6795,7 +6820,7 @@ if test yes != "$_lt_caught_CXX_error"; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
             if test yes = "$GXX"; then
@@ -6860,7 +6885,7 @@ if test yes != "$_lt_caught_CXX_error"; then
            # explicitly linking system object files so we need to strip them
            # from the output so that they don't get included in the library
            # dependencies.
-           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
            ;;
           *)
            if test yes = "$GXX"; then
@@ -7199,7 +7224,7 @@ if test yes != "$_lt_caught_CXX_error"; then
              # Commands to make compiler produce verbose output that lists
              # what "hidden" libraries, object files and flags are used when
              # linking a shared library.
-             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 
            else
              # FIXME: insert proper C++ library support
@@ -7283,7 +7308,7 @@ if test yes != "$_lt_caught_CXX_error"; then
                # Commands to make compiler produce verbose output that lists
                # what "hidden" libraries, object files and flags are used when
                # linking a shared library.
-               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
              else
                # g++ 2.7 appears to require '-G' NOT '-shared' on this
                # platform.
@@ -7294,7 +7319,7 @@ if test yes != "$_lt_caught_CXX_error"; then
                # Commands to make compiler produce verbose output that lists
                # what "hidden" libraries, object files and flags are used when
                # linking a shared library.
-               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
              fi
 
              _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
diff --git a/missing b/missing
index 8d0eaad..1fe1611 100755 (executable)
--- a/missing
+++ b/missing
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1996-2020 Free Software Foundation, Inc.
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
index 458a1bd..7f6012a 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -97,8 +97,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_@AM_V@)
@@ -153,8 +152,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
 am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -194,8 +191,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -211,6 +209,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -458,7 +457,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 75ad15f..1c6ac15 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -118,8 +118,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
@@ -537,8 +536,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -552,8 +549,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -569,6 +567,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -1116,7 +1115,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 95abae8..5fb199a 100644 (file)
 #include <fst/script/closure.h>
 #include <fst/script/getters.h>
 
-DECLARE_bool(closure_plus);
+DECLARE_string(closure_type);
 
 int fstclosure_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::ClosureType;
   using fst::script::MutableFstClass;
 
   std::string usage = "Creates the Kleene closure of an FST.\n\n  Usage: ";
@@ -50,7 +51,14 @@ int fstclosure_main(int argc, char **argv) {
   std::unique_ptr<MutableFstClass> fst(MutableFstClass::Read(in_name, true));
   if (!fst) return 1;
 
-  s::Closure(fst.get(), s::GetClosureType(FST_FLAGS_closure_plus));
+  ClosureType closure_type;
+  if (!s::GetClosureType(FST_FLAGS_closure_type, &closure_type)) {
+    LOG(ERROR) << argv[0] << ": Unknown or unsupported closure type: "
+               << FST_FLAGS_closure_type;
+    return 1;
+  }
+
+  s::Closure(fst.get(), closure_type);
 
   return !fst->Write(out_name);
 }
index 4fd3093..c6356c3 100644 (file)
@@ -17,8 +17,9 @@
 
 #include <fst/flags.h>
 
-DEFINE_bool(closure_plus, false,
-            "Do not add the empty path (T+ instead of T*)?");
+DEFINE_string(closure_type, "star",
+              "Do not add the empty path (T+ instead of T*)?, one of: "
+              "\"star\", \"plus\"");
 
 int fstclosure_main(int argc, char **argv);
 
index 029e9c8..2adb8ae 100644 (file)
@@ -18,6 +18,7 @@
 // Creates binary FSTs from simple text format used by AT&T.
 
 #include <cstring>
+#include <iostream>
 #include <istream>
 #include <memory>
 #include <string>
@@ -89,13 +90,13 @@ int fstcompile_main(int argc, char **argv) {
 
   const std::string dest = argc > 2 && strcmp(argv[2], "-") != 0 ? argv[2] : "";
 
-  s::CompileFst(istrm, source, dest, FST_FLAGS_fst_type,
-                FST_FLAGS_arc_type, isyms.get(), osyms.get(),
-                ssyms.get(), FST_FLAGS_acceptor,
-                FST_FLAGS_keep_isymbols,
-                FST_FLAGS_keep_osymbols,
-                FST_FLAGS_keep_state_numbering,
-                FST_FLAGS_allow_negative_labels);
+  s::Compile(istrm, source, dest, FST_FLAGS_fst_type,
+             FST_FLAGS_arc_type, isyms.get(), osyms.get(),
+             ssyms.get(), FST_FLAGS_acceptor,
+             FST_FLAGS_keep_isymbols,
+             FST_FLAGS_keep_osymbols,
+             FST_FLAGS_keep_state_numbering,
+             FST_FLAGS_allow_negative_labels);
 
   return 0;
 }
index f8a7042..75b11d8 100644 (file)
@@ -18,6 +18,7 @@
 // Draws a binary FSTs in the Graphviz dot text format.
 
 #include <cstring>
+#include <iostream>
 #include <memory>
 #include <ostream>
 #include <string>
index 186b7a8..8680df4 100644 (file)
 #include <string>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/script/decode.h>
 #include <fst/script/encode.h>
 #include <fst/script/getters.h>
 
+DECLARE_bool(decode);
 DECLARE_bool(encode_labels);
 DECLARE_bool(encode_weights);
 DECLARE_bool(encode_reuse);
-DECLARE_bool(decode);
 
 int fstencode_main(int argc, char **argv) {
   namespace s = fst::script;
@@ -59,6 +58,7 @@ int fstencode_main(int argc, char **argv) {
   if (FST_FLAGS_decode) {
     std::unique_ptr<EncodeMapperClass> mapper(
         EncodeMapperClass::Read(mapper_name));
+    if (!mapper) return 1;
     s::Decode(fst.get(), *mapper);
   } else if (FST_FLAGS_encode_reuse) {
     std::unique_ptr<EncodeMapperClass> mapper(
index 7b45bbf..2ada3f8 100644 (file)
 
 #include <fst/flags.h>
 
+DEFINE_bool(decode, false, "Decode labels and/or weights");
 DEFINE_bool(encode_labels, false, "Encode output labels");
 DEFINE_bool(encode_weights, false, "Encode weights");
 DEFINE_bool(encode_reuse, false, "Re-use existing mapper");
-DEFINE_bool(decode, false, "Decode labels and/or weights");
 
 int fstencode_main(int argc, char **argv);
 
index 7c72aae..b9ad4ec 100644 (file)
 #include <fst/script/epsnormalize.h>
 #include <fst/script/getters.h>
 
-DECLARE_bool(eps_norm_output);
+DECLARE_string(eps_norm_type);
 
 int fstepsnormalize_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::EpsNormalizeType;
   using fst::script::FstClass;
   using fst::script::VectorFstClass;
 
@@ -53,8 +54,16 @@ int fstepsnormalize_main(int argc, char **argv) {
 
   VectorFstClass ofst(ifst->ArcType());
 
-  s::EpsNormalize(*ifst, &ofst,
-                  s::GetEpsNormalizeType(FST_FLAGS_eps_norm_output));
+  EpsNormalizeType eps_norm_type;
+  if (!s::GetEpsNormalizeType(FST_FLAGS_eps_norm_type,
+                              &eps_norm_type)) {
+    LOG(ERROR) << argv[0]
+               << ": Unknown or unsupported epsilon normalization type: "
+               << FST_FLAGS_eps_norm_type;
+    return 1;
+  }
+
+  s::EpsNormalize(*ifst, &ofst, eps_norm_type);
 
   return !ofst.Write(out_name);
 }
index 5aaa339..032c07a 100644 (file)
@@ -17,7 +17,8 @@
 
 #include <fst/flags.h>
 
-DEFINE_bool(eps_norm_output, false, "Normalize output epsilons");
+DEFINE_string(eps_norm_type, "input",
+              "Side to epsilon normalize, one of: \"input\", \"output\"");
 
 int fstepsnormalize_main(int argc, char **argv);
 
index 5f551ba..000bed6 100644 (file)
@@ -57,8 +57,8 @@ int fstequal_main(int argc, char **argv) {
   std::unique_ptr<FstClass> ifst2(FstClass::Read(in2_name));
   if (!ifst2) return 1;
 
-  bool result = s::Equal(*ifst1, *ifst2, FST_FLAGS_delta);
-  if (!result) VLOG(1) << "FSTs are not equal.";
+  const bool result = s::Equal(*ifst1, *ifst2, FST_FLAGS_delta);
+  if (!result) VLOG(1) << "FSTs are not equal";
 
   return result ? 0 : 2;
 }
index d2338ac..b0159d4 100644 (file)
@@ -67,7 +67,8 @@ int fstequivalent_main(int argc, char **argv) {
   if (!ifst2) return 1;
 
   if (!FST_FLAGS_random) {
-    bool result = s::Equivalent(*ifst1, *ifst2, FST_FLAGS_delta);
+    const bool result =
+        s::Equivalent(*ifst1, *ifst2, FST_FLAGS_delta);
     if (!result) VLOG(1) << "FSTs are not equivalent";
     return result ? 0 : 2;
   } else {
@@ -79,9 +80,9 @@ int fstequivalent_main(int argc, char **argv) {
     }
     const RandGenOptions<s::RandArcSelection> opts(
         ras, FST_FLAGS_max_length);
-    bool result = s::RandEquivalent(*ifst1, *ifst2, FST_FLAGS_npath,
-                                    opts, FST_FLAGS_delta,
-                                    FST_FLAGS_seed);
+    const bool result = s::RandEquivalent(
+        *ifst1, *ifst2, FST_FLAGS_npath, opts,
+        FST_FLAGS_delta, FST_FLAGS_seed);
     if (!result) VLOG(1) << "FSTs are not equivalent";
     return result ? 0 : 2;
   }
index a67acc7..8395968 100644 (file)
@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
+#include <cstdint>
 #include <limits>
 #include <random>
 
@@ -21,7 +22,7 @@
 DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
 DEFINE_bool(random, false,
             "Test equivalence by randomly selecting paths in the input FSTs");
-DEFINE_int32(max_length, std::numeric_limits<int32>::max(),
+DEFINE_int32(max_length, std::numeric_limits<int32_t>::max(),
              "Maximum path length");
 DEFINE_int32(npath, 1, "Number of paths to generate");
 DEFINE_uint64(seed, std::random_device()(), "Random seed");
index 085c330..6e39640 100644 (file)
 
 #include <cstring>
 #include <ios>
+#include <iostream>
 #include <memory>
 #include <string>
 
 #include <fst/flags.h>
+#include <fst/script/arcfilter-impl.h>
+#include <fst/script/getters.h>
 #include <fst/script/info.h>
 
 DECLARE_string(arc_filter);
@@ -87,9 +90,14 @@ int fstinfo_main(int argc, char **argv) {
     std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
     if (!ifst) return 1;
 
-    s::Info(*ifst, FST_FLAGS_test_properties,
-            FST_FLAGS_arc_filter, FST_FLAGS_info_type,
-            FST_FLAGS_fst_verify);
+    s::ArcFilterType arc_filter;
+    if (!s::GetArcFilterType(FST_FLAGS_arc_filter, &arc_filter)) {
+      LOG(ERROR) << argv[0] << ": Unknown or unsupported arc filter type "
+                 << FST_FLAGS_arc_filter;
+      return 1;
+    }
+    s::Info(*ifst, FST_FLAGS_test_properties, arc_filter,
+            FST_FLAGS_info_type, FST_FLAGS_fst_verify);
   }
 
   return 0;
index 20f89eb..b4751b2 100644 (file)
@@ -59,7 +59,7 @@ int fstisomorphic_main(int argc, char **argv) {
   std::unique_ptr<FstClass> ifst2(FstClass::Read(in2_name));
   if (!ifst2) return 1;
 
-  bool result = s::Isomorphic(*ifst1, *ifst2, FST_FLAGS_delta);
+  const bool result = s::Isomorphic(*ifst1, *ifst2, FST_FLAGS_delta);
   if (!result) VLOG(1) << "FSTs are not isomorphic";
 
   return result ? 0 : 2;
index 295cf0c..a1eb028 100644 (file)
@@ -63,11 +63,12 @@ int fstmap_main(int argc, char **argv) {
     return 1;
   }
 
-  const auto weight_param = !FST_FLAGS_weight.empty()
-                                ? WeightClass(ifst->WeightType(), FST_FLAGS_weight)
-                                : (FST_FLAGS_map_type == "times"
-                                       ? WeightClass::One(ifst->WeightType())
-                                       : WeightClass::Zero(ifst->WeightType()));
+  const auto weight_param =
+      !FST_FLAGS_weight.empty()
+          ? WeightClass(ifst->WeightType(), FST_FLAGS_weight)
+          : (FST_FLAGS_map_type == "times"
+                 ? WeightClass::One(ifst->WeightType())
+                 : WeightClass::Zero(ifst->WeightType()));
 
   std::unique_ptr<FstClass> ofst(
       s::Map(*ifst, map_type, FST_FLAGS_delta,
index a1d5976..cb24ce4 100644 (file)
@@ -18,6 +18,7 @@
 // Prints out binary FSTs in simple text format used by AT&T.
 
 #include <cstring>
+#include <iostream>
 #include <memory>
 #include <ostream>
 #include <string>
index 59ba277..db813ab 100644 (file)
@@ -23,7 +23,6 @@
 #include <string>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/script/getters.h>
 #include <fst/script/push.h>
 
@@ -32,10 +31,11 @@ DECLARE_bool(push_weights);
 DECLARE_bool(push_labels);
 DECLARE_bool(remove_total_weight);
 DECLARE_bool(remove_common_affix);
-DECLARE_bool(to_final);
+DECLARE_string(reweight_type);
 
 int fstpush_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::ReweightType;
   using fst::script::FstClass;
   using fst::script::VectorFstClass;
 
@@ -65,9 +65,14 @@ int fstpush_main(int argc, char **argv) {
 
   VectorFstClass ofst(ifst->ArcType());
 
-  s::Push(*ifst, &ofst, flags,
-          s::GetReweightType(FST_FLAGS_to_final),
-          FST_FLAGS_delta);
+  ReweightType reweight_type;
+  if (!s::GetReweightType(FST_FLAGS_reweight_type, &reweight_type)) {
+    LOG(ERROR) << argv[0] << ": Unknown or unsupported reweight type: "
+               << FST_FLAGS_reweight_type;
+    return 1;
+  }
+
+  s::Push(*ifst, &ofst, flags, reweight_type, FST_FLAGS_delta);
 
   return !ofst.Write(out_name);
 }
index 5543007..0030726 100644 (file)
@@ -25,7 +25,9 @@ DEFINE_bool(remove_total_weight, false,
             "Remove total weight when pushing weights");
 DEFINE_bool(remove_common_affix, false,
             "Remove common prefix/suffix when pushing labels");
-DEFINE_bool(to_final, false, "Push/reweight to final (vs. to initial) states");
+DEFINE_string(reweight_type, "to_initial",
+              "Push/reweight to final (vs. to initial) states: one of "
+              "\"to_initial\", \"to_final\"");
 
 int fstpush_main(int argc, char **argv);
 
index be6809a..654120a 100644 (file)
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
+#include <cstdint>
 #include <limits>
 #include <random>
 
 #include <fst/flags.h>
 
-DEFINE_int32(max_length, std::numeric_limits<int32>::max(),
+DEFINE_int32(max_length, std::numeric_limits<int32_t>::max(),
              "Maximum path length");
 DEFINE_int32(npath, 1, "Number of paths to generate");
 DEFINE_uint64(seed, std::random_device()(), "Random seed");
index 8c704f0..22c9b75 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Relabels input or output space of an FST.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/util.h>
 #include <fst/script/relabel.h>
 #include <fst/script/weight-class.h>
@@ -107,13 +107,13 @@ int fstrelabel_main(int argc, char **argv) {
                attach_new_osymbols);
   } else {
     // Reads in relabeling pairs.
-    std::vector<std::pair<int64, int64>> ipairs;
+    std::vector<std::pair<int64_t, int64_t>> ipairs;
     if (!FST_FLAGS_relabel_ipairs.empty()) {
       if (!ReadLabelPairs(FST_FLAGS_relabel_ipairs, &ipairs,
                           FST_FLAGS_allow_negative_labels))
         return 1;
     }
-    std::vector<std::pair<int64, int64>> opairs;
+    std::vector<std::pair<int64_t, int64_t>> opairs;
     if (!FST_FLAGS_relabel_opairs.empty()) {
       if (!ReadLabelPairs(FST_FLAGS_relabel_opairs, &opairs,
                           FST_FLAGS_allow_negative_labels))
index 61912b7..5676e1c 100644 (file)
@@ -18,6 +18,7 @@
 // Performs the dynamic replacement of arcs in one FST with another FST,
 // allowing for the definition of FSTs analogous to RTNs.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -25,7 +26,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/script/getters.h>
 #include <fst/script/replace.h>
 
@@ -55,7 +55,7 @@ int fstreplace_main(int argc, char **argv) {
 
   const std::string out_name = argc % 2 == 0 ? argv[argc - 1] : "";
 
-  std::vector<std::pair<int64, std::unique_ptr<const FstClass>>> pairs;
+  std::vector<std::pair<int64_t, std::unique_ptr<const FstClass>>> pairs;
   for (auto i = 1; i < argc - 1; i += 2) {
     std::unique_ptr<const FstClass> ifst(FstClass::Read(argv[i]));
     if (!ifst) return 1;
index 8e58441..5638b54 100644 (file)
 #include <fst/script/reweight.h>
 #include <fst/script/text-io.h>
 
-DECLARE_bool(to_final);
+DECLARE_string(reweight_type);
 
 int fstreweight_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::ReweightType;
   using fst::script::MutableFstClass;
   using fst::script::WeightClass;
 
@@ -57,8 +58,14 @@ int fstreweight_main(int argc, char **argv) {
     return 1;
   }
 
-  s::Reweight(fst.get(), potential,
-              s::GetReweightType(FST_FLAGS_to_final));
+  ReweightType reweight_type;
+  if (!s::GetReweightType(FST_FLAGS_reweight_type, &reweight_type)) {
+    LOG(ERROR) << argv[0] << ": Unknown or unsupported reweight type: "
+               << FST_FLAGS_reweight_type;
+    return 1;
+  }
+
+  s::Reweight(fst.get(), potential, reweight_type);
 
   return !fst->Write(out_name);
 }
index b196681..6038d03 100644 (file)
@@ -17,7 +17,9 @@
 
 #include <fst/flags.h>
 
-DEFINE_bool(to_final, false, "Push/reweight to final (vs. to initial) states");
+DEFINE_string(reweight_type, "to_initial",
+              "Push/reweight to final (vs. to initial) states: one of "
+              "\"to_initial\", \"to_final\"");
 
 int fstreweight_main(int argc, char **argv);
 
index 0512b4d..f505137 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <fst/flags.h>
 #include <fst/log.h>
+#include <fst/script/arcfilter-impl.h>
 #include <fst/script/getters.h>
 #include <fst/script/shortest-distance.h>
 #include <fst/script/text-io.h>
index 329a762..483f0f9 100644 (file)
 // Performs operations (set, clear, relabel) on the symbols table attached to an
 // input FST.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/util.h>
 #include <fst/script/fst-class.h>
 #include <fst/script/verify.h>
@@ -105,7 +106,7 @@ int fstsymbols_main(int argc, char **argv) {
     fst->SetOutputSymbols(nullptr);
   }
 
-  using Label = int64;
+  using Label = int64_t;
   if (!FST_FLAGS_relabel_ipairs.empty()) {
     std::vector<std::pair<Label, Label>> ipairs;
     ReadLabelPairs(FST_FLAGS_relabel_ipairs, &ipairs,
index 7090a14..7f8d3dd 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -97,8 +97,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_@AM_V@)
@@ -153,8 +152,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 DIST_SUBDIRS = compact compress const far linear lookahead pdt mpdt \
        ngram python special
 am__DIST_COMMON = $(srcdir)/Makefile.in
@@ -195,8 +192,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -212,6 +210,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -483,7 +482,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index c3c70ae..425531d 100644 (file)
@@ -7,7 +7,7 @@ libfst_LTLIBRARIES = compact8_acceptor-fst.la compact8_string-fst.la compact8_un
 lib_LTLIBRARIES = libfstcompact.la
 
 libfstcompact_la_SOURCES = compact8_acceptor-fst.cc compact8_string-fst.cc compact8_unweighted-fst.cc compact8_unweighted_acceptor-fst.cc compact8_weighted_string-fst.cc compact16_acceptor-fst.cc compact16_string-fst.cc compact16_unweighted-fst.cc compact16_unweighted_acceptor-fst.cc compact16_weighted_string-fst.cc compact64_acceptor-fst.cc compact64_string-fst.cc compact64_unweighted-fst.cc compact64_unweighted_acceptor-fst.cc compact64_weighted_string-fst.cc
-libfstcompact_la_LDFLAGS = -version-info 24:0:0
+libfstcompact_la_LDFLAGS = -version-info 25:0:0
 
 compact8_acceptor_fst_la_SOURCES = compact8_acceptor-fst.cc
 compact8_acceptor_fst_la_LDFLAGS = -avoid-version -module
index f0feccc..13d6077 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -98,8 +98,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -382,8 +381,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -397,8 +394,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -414,6 +412,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -527,7 +526,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS)
 libfst_LTLIBRARIES = compact8_acceptor-fst.la compact8_string-fst.la compact8_unweighted-fst.la compact8_unweighted_acceptor-fst.la compact8_weighted_string-fst.la compact16_acceptor-fst.la compact16_string-fst.la compact16_unweighted-fst.la compact16_unweighted_acceptor-fst.la compact16_weighted_string-fst.la compact64_acceptor-fst.la compact64_string-fst.la compact64_unweighted-fst.la compact64_unweighted_acceptor-fst.la compact64_weighted_string-fst.la
 lib_LTLIBRARIES = libfstcompact.la
 libfstcompact_la_SOURCES = compact8_acceptor-fst.cc compact8_string-fst.cc compact8_unweighted-fst.cc compact8_unweighted_acceptor-fst.cc compact8_weighted_string-fst.cc compact16_acceptor-fst.cc compact16_string-fst.cc compact16_unweighted-fst.cc compact16_unweighted_acceptor-fst.cc compact16_weighted_string-fst.cc compact64_acceptor-fst.cc compact64_string-fst.cc compact64_unweighted-fst.cc compact64_unweighted_acceptor-fst.cc compact64_weighted_string-fst.cc
-libfstcompact_la_LDFLAGS = -version-info 24:0:0
+libfstcompact_la_LDFLAGS = -version-info 25:0:0
 compact8_acceptor_fst_la_SOURCES = compact8_acceptor-fst.cc
 compact8_acceptor_fst_la_LDFLAGS = -avoid-version -module
 compact8_string_fst_la_SOURCES = compact8_string-fst.cc
@@ -819,7 +818,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -856,6 +854,8 @@ distdir-am: $(DISTFILES)
 check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES)
+install-libfstLTLIBRARIES: install-libLTLIBRARIES
+
 installdirs:
        for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfstdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
index d675996..7cc08a2 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactAcceptorFst<StdArc, uint16>>
+static FstRegisterer<CompactAcceptorFst<StdArc, uint16_t>>
     CompactAcceptorFst_StdArc_uint16_registerer;
 
-static FstRegisterer<CompactAcceptorFst<LogArc, uint16>>
+static FstRegisterer<CompactAcceptorFst<LogArc, uint16_t>>
     CompactAcceptorFst_LogArc_uint16_registerer;
 
-static FstRegisterer<CompactAcceptorFst<Log64Arc, uint16>>
+static FstRegisterer<CompactAcceptorFst<Log64Arc, uint16_t>>
     CompactAcceptorFst_Log64Arc_uint16_registerer;
 
 }  // namespace fst
index e846303..19063e4 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactStringFst<StdArc, uint16>>
+static FstRegisterer<CompactStringFst<StdArc, uint16_t>>
     CompactStringFst_StdArc_uint16_registerer;
 
-static FstRegisterer<CompactStringFst<LogArc, uint16>>
+static FstRegisterer<CompactStringFst<LogArc, uint16_t>>
     CompactStringFst_LogArc_uint16_registerer;
 
-static FstRegisterer<CompactStringFst<Log64Arc, uint16>>
+static FstRegisterer<CompactStringFst<Log64Arc, uint16_t>>
     CompactStringFst_Log64Arc_uint16_registerer;
 
 }  // namespace fst
index 893221b..964631e 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactUnweightedFst<StdArc, uint16>>
+static FstRegisterer<CompactUnweightedFst<StdArc, uint16_t>>
     CompactUnweightedFst_StdArc_uint16_registerer;
 
-static FstRegisterer<CompactUnweightedFst<LogArc, uint16>>
+static FstRegisterer<CompactUnweightedFst<LogArc, uint16_t>>
     CompactUnweightedFst_LogArc_uint16_registerer;
 
-static FstRegisterer<CompactUnweightedFst<Log64Arc, uint16>>
+static FstRegisterer<CompactUnweightedFst<Log64Arc, uint16_t>>
     CompactUnweightedFst_Log64Arc_uint16_registerer;
 
 }  // namespace fst
index 4a855f0..2879005 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactUnweightedAcceptorFst<StdArc, uint16>>
+static FstRegisterer<CompactUnweightedAcceptorFst<StdArc, uint16_t>>
     CompactUnweightedAcceptorFst_StdArc_uint16_registerer;
 
-static FstRegisterer<CompactUnweightedAcceptorFst<LogArc, uint16>>
+static FstRegisterer<CompactUnweightedAcceptorFst<LogArc, uint16_t>>
     CompactUnweightedAcceptorFst_LogArc_uint16_registerer;
 
-static FstRegisterer<CompactUnweightedAcceptorFst<Log64Arc, uint16>>
+static FstRegisterer<CompactUnweightedAcceptorFst<Log64Arc, uint16_t>>
     CompactUnweightedAcceptorFst_Log64Arc_uint16_registerer;
 
 }  // namespace fst
index 599e9fe..ba38a7a 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactWeightedStringFst<StdArc, uint16>>
+static FstRegisterer<CompactWeightedStringFst<StdArc, uint16_t>>
     CompactWeightedStringFst_StdArc_uint16_registerer;
 
-static FstRegisterer<CompactWeightedStringFst<LogArc, uint16>>
+static FstRegisterer<CompactWeightedStringFst<LogArc, uint16_t>>
     CompactWeightedStringFst_LogArc_uint16_registerer;
 
-static FstRegisterer<CompactWeightedStringFst<Log64Arc, uint16>>
+static FstRegisterer<CompactWeightedStringFst<Log64Arc, uint16_t>>
     CompactWeightedStringFst_Log64Arc_uint16_registerer;
 
 }  // namespace fst
index 03d362a..d3db036 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactAcceptorFst<StdArc, uint64>>
+static FstRegisterer<CompactAcceptorFst<StdArc, uint64_t>>
     CompactAcceptorFst_StdArc_uint64_registerer;
 
-static FstRegisterer<CompactAcceptorFst<LogArc, uint64>>
+static FstRegisterer<CompactAcceptorFst<LogArc, uint64_t>>
     CompactAcceptorFst_LogArc_uint64_registerer;
 
-static FstRegisterer<CompactAcceptorFst<Log64Arc, uint64>>
+static FstRegisterer<CompactAcceptorFst<Log64Arc, uint64_t>>
     CompactAcceptorFst_Log64Arc_uint64_registerer;
 
 }  // namespace fst
index 17c78eb..296f0d5 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactStringFst<StdArc, uint64>>
+static FstRegisterer<CompactStringFst<StdArc, uint64_t>>
     CompactStringFst_StdArc_uint64_registerer;
 
-static FstRegisterer<CompactStringFst<LogArc, uint64>>
+static FstRegisterer<CompactStringFst<LogArc, uint64_t>>
     CompactStringFst_LogArc_uint64_registerer;
 
-static FstRegisterer<CompactStringFst<Log64Arc, uint64>>
+static FstRegisterer<CompactStringFst<Log64Arc, uint64_t>>
     CompactStringFst_Log64Arc_uint64_registerer;
 
 }  // namespace fst
index 207cc39..a234536 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactUnweightedFst<StdArc, uint64>>
+static FstRegisterer<CompactUnweightedFst<StdArc, uint64_t>>
     CompactUnweightedFst_StdArc_uint64_registerer;
 
-static FstRegisterer<CompactUnweightedFst<LogArc, uint64>>
+static FstRegisterer<CompactUnweightedFst<LogArc, uint64_t>>
     CompactUnweightedFst_LogArc_uint64_registerer;
 
-static FstRegisterer<CompactUnweightedFst<Log64Arc, uint64>>
+static FstRegisterer<CompactUnweightedFst<Log64Arc, uint64_t>>
     CompactUnweightedFst_Log64Arc_uint64_registerer;
 
 }  // namespace fst
index f1ea7d3..02b2833 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactUnweightedAcceptorFst<StdArc, uint64>>
+static FstRegisterer<CompactUnweightedAcceptorFst<StdArc, uint64_t>>
     CompactUnweightedAcceptorFst_StdArc_uint64_registerer;
 
-static FstRegisterer<CompactUnweightedAcceptorFst<LogArc, uint64>>
+static FstRegisterer<CompactUnweightedAcceptorFst<LogArc, uint64_t>>
     CompactUnweightedAcceptorFst_LogArc_uint64_registerer;
 
-static FstRegisterer<CompactUnweightedAcceptorFst<Log64Arc, uint64>>
+static FstRegisterer<CompactUnweightedAcceptorFst<Log64Arc, uint64_t>>
     CompactUnweightedAcceptorFst_Log64Arc_uint64_registerer;
 
 }  // namespace fst
index 7f06faa..f5d9c3d 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactWeightedStringFst<StdArc, uint64>>
+static FstRegisterer<CompactWeightedStringFst<StdArc, uint64_t>>
     CompactWeightedStringFst_StdArc_uint64_registerer;
 
-static FstRegisterer<CompactWeightedStringFst<LogArc, uint64>>
+static FstRegisterer<CompactWeightedStringFst<LogArc, uint64_t>>
     CompactWeightedStringFst_LogArc_uint64_registerer;
 
-static FstRegisterer<CompactWeightedStringFst<Log64Arc, uint64>>
+static FstRegisterer<CompactWeightedStringFst<Log64Arc, uint64_t>>
     CompactWeightedStringFst_Log64Arc_uint64_registerer;
 
 }  // namespace fst
index d1ed7a5..85ca136 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactAcceptorFst<StdArc, uint8>>
+static FstRegisterer<CompactAcceptorFst<StdArc, uint8_t>>
     CompactAcceptorFst_StdArc_uint8_registerer;
 
-static FstRegisterer<CompactAcceptorFst<LogArc, uint8>>
+static FstRegisterer<CompactAcceptorFst<LogArc, uint8_t>>
     CompactAcceptorFst_LogArc_uint8_registerer;
 
-static FstRegisterer<CompactAcceptorFst<Log64Arc, uint8>>
+static FstRegisterer<CompactAcceptorFst<Log64Arc, uint8_t>>
     CompactAcceptorFst_Log64Arc_uint8_registerer;
 
 }  // namespace fst
index 3361641..479ab25 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactStringFst<StdArc, uint8>>
+static FstRegisterer<CompactStringFst<StdArc, uint8_t>>
     CompactStringFst_StdArc_uint8_registerer;
 
-static FstRegisterer<CompactStringFst<LogArc, uint8>>
+static FstRegisterer<CompactStringFst<LogArc, uint8_t>>
     CompactStringFst_LogArc_uint8_registerer;
 
-static FstRegisterer<CompactStringFst<Log64Arc, uint8>>
+static FstRegisterer<CompactStringFst<Log64Arc, uint8_t>>
     CompactStringFst_Log64Arc_uint8_registerer;
 
 }  // namespace fst
index 858c5a0..80a3213 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactUnweightedFst<StdArc, uint8>>
+static FstRegisterer<CompactUnweightedFst<StdArc, uint8_t>>
     CompactUnweightedFst_StdArc_uint8_registerer;
 
-static FstRegisterer<CompactUnweightedFst<LogArc, uint8>>
+static FstRegisterer<CompactUnweightedFst<LogArc, uint8_t>>
     CompactUnweightedFst_LogArc_uint8_registerer;
 
-static FstRegisterer<CompactUnweightedFst<Log64Arc, uint8>>
+static FstRegisterer<CompactUnweightedFst<Log64Arc, uint8_t>>
     CompactUnweightedFst_Log64Arc_uint8_registerer;
 
 }  // namespace fst
index 5a757c0..616bed6 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactUnweightedAcceptorFst<StdArc, uint8>>
+static FstRegisterer<CompactUnweightedAcceptorFst<StdArc, uint8_t>>
     CompactUnweightedAcceptorFst_StdArc_uint8_registerer;
 
-static FstRegisterer<CompactUnweightedAcceptorFst<LogArc, uint8>>
+static FstRegisterer<CompactUnweightedAcceptorFst<LogArc, uint8_t>>
     CompactUnweightedAcceptorFst_LogArc_uint8_registerer;
 
-static FstRegisterer<CompactUnweightedAcceptorFst<Log64Arc, uint8>>
+static FstRegisterer<CompactUnweightedAcceptorFst<Log64Arc, uint8_t>>
     CompactUnweightedAcceptorFst_Log64Arc_uint8_registerer;
 
 }  // namespace fst
index e9939a0..bb0fe0e 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/compact-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<CompactWeightedStringFst<StdArc, uint8>>
+static FstRegisterer<CompactWeightedStringFst<StdArc, uint8_t>>
     CompactWeightedStringFst_StdArc_uint8_registerer;
 
-static FstRegisterer<CompactWeightedStringFst<LogArc, uint8>>
+static FstRegisterer<CompactWeightedStringFst<LogArc, uint8_t>>
     CompactWeightedStringFst_LogArc_uint8_registerer;
 
-static FstRegisterer<CompactWeightedStringFst<Log64Arc, uint8>>
+static FstRegisterer<CompactWeightedStringFst<Log64Arc, uint8_t>>
     CompactWeightedStringFst_Log64Arc_uint8_registerer;
 
 }  // namespace fst
index c6c5b79..f42ff79 100644 (file)
@@ -13,7 +13,7 @@ endif
 
 if HAVE_SCRIPT
 libfstcompressscript_la_SOURCES = compressscript.cc
-libfstcompressscript_la_LDFLAGS = -version-info 24:0:0
+libfstcompressscript_la_LDFLAGS = -version-info 25:0:0
 libfstcompressscript_la_LIBADD = ../../script/libfstscript.la \
                                  ../../lib/libfst.la \
                                  -lm $(DL_LIBS)
index 17b7fc2..1a791db 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -100,8 +100,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)"
@@ -221,8 +220,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -236,8 +233,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -253,6 +251,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -370,7 +369,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS)
 
 @HAVE_BIN_TRUE@fstcompress_SOURCES = fstcompress.cc fstcompress-main.cc
 @HAVE_SCRIPT_TRUE@libfstcompressscript_la_SOURCES = compressscript.cc
-@HAVE_SCRIPT_TRUE@libfstcompressscript_la_LDFLAGS = -version-info 24:0:0
+@HAVE_SCRIPT_TRUE@libfstcompressscript_la_LDFLAGS = -version-info 25:0:0
 @HAVE_SCRIPT_TRUE@libfstcompressscript_la_LIBADD = ../../script/libfstscript.la \
 @HAVE_SCRIPT_TRUE@                                 ../../lib/libfst.la \
 @HAVE_SCRIPT_TRUE@                                 -lm $(DL_LIBS)
@@ -598,7 +597,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 197b101..d160566 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <fst/extensions/compress/compressscript.h>
 
+#include <string>
+
 #include <fst/arc-map.h>
 #include <fst/script/script-impl.h>
 
index 8292b82..e751e72 100644 (file)
@@ -7,7 +7,7 @@ libfst_LTLIBRARIES = const8-fst.la const16-fst.la const64-fst.la
 lib_LTLIBRARIES = libfstconst.la
 
 libfstconst_la_SOURCES = const8-fst.cc const16-fst.cc const64-fst.cc
-libfstconst_la_LDFLAGS = -version-info 24:0:0
+libfstconst_la_LDFLAGS = -version-info 25:0:0
 
 const8_fst_la_SOURCES = const8-fst.cc
 const8_fst_la_LDFLAGS = -avoid-version -module
index 9376855..1a06f25 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -98,8 +98,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -226,8 +225,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -241,8 +238,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -258,6 +256,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -371,7 +370,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS)
 libfst_LTLIBRARIES = const8-fst.la const16-fst.la const64-fst.la
 lib_LTLIBRARIES = libfstconst.la
 libfstconst_la_SOURCES = const8-fst.cc const16-fst.cc const64-fst.cc
-libfstconst_la_LDFLAGS = -version-info 24:0:0
+libfstconst_la_LDFLAGS = -version-info 25:0:0
 const8_fst_la_SOURCES = const8-fst.cc
 const8_fst_la_LDFLAGS = -avoid-version -module
 const16_fst_la_SOURCES = const16-fst.cc
@@ -591,7 +590,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -628,6 +626,8 @@ distdir-am: $(DISTFILES)
 check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES)
+install-libfstLTLIBRARIES: install-libLTLIBRARIES
+
 installdirs:
        for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfstdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
index 6b6a1d3..de2ca35 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/const-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<ConstFst<StdArc, uint16>>
+static FstRegisterer<ConstFst<StdArc, uint16_t>>
     ConstFst_StdArc_uint16_registerer;
-static FstRegisterer<ConstFst<LogArc, uint16>>
+static FstRegisterer<ConstFst<LogArc, uint16_t>>
     ConstFst_LogArc_uint16_registerer;
-static FstRegisterer<ConstFst<Log64Arc, uint16>>
+static FstRegisterer<ConstFst<Log64Arc, uint16_t>>
     ConstFst_Log64Arc_uint16_registerer;
 
 }  // namespace fst
index b1f996c..915f0aa 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/const-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<ConstFst<StdArc, uint64>>
+static FstRegisterer<ConstFst<StdArc, uint64_t>>
     ConstFst_StdArc_uint64_registerer;
-static FstRegisterer<ConstFst<LogArc, uint64>>
+static FstRegisterer<ConstFst<LogArc, uint64_t>>
     ConstFst_LogArc_uint64_registerer;
-static FstRegisterer<ConstFst<Log64Arc, uint64>>
+static FstRegisterer<ConstFst<Log64Arc, uint64_t>>
     ConstFst_Log64Arc_uint64_registerer;
 
 }  // namespace fst
index 25d0d9c..7bbc4d2 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <cstdint>
+
 #include <fst/const-fst.h>
 #include <fst/fst.h>
 
 namespace fst {
 
-static FstRegisterer<ConstFst<StdArc, uint8>> ConstFst_StdArc_uint8_registerer;
-static FstRegisterer<ConstFst<LogArc, uint8>> ConstFst_LogArc_uint8_registerer;
-static FstRegisterer<ConstFst<Log64Arc, uint8>>
+static FstRegisterer<ConstFst<StdArc, uint8_t>>
+    ConstFst_StdArc_uint8_registerer;
+static FstRegisterer<ConstFst<LogArc, uint8_t>>
+    ConstFst_LogArc_uint8_registerer;
+static FstRegisterer<ConstFst<Log64Arc, uint8_t>>
     ConstFst_Log64Arc_uint8_registerer;
 
 }  // namespace fst
index 8b66c9f..b4295c0 100644 (file)
@@ -9,21 +9,20 @@ lib_LTLIBRARIES = libfstfar.la
 endif
 
 libfstfar_la_SOURCES = sttable.cc stlist.cc
-libfstfar_la_LDFLAGS = -version-info 24:0:0
+libfstfar_la_LDFLAGS = -version-info 25:0:0
 libfstfar_la_LIBADD = ../../lib/libfst.la -lm $(DL_LIBS)
 
 if HAVE_SCRIPT
-libfstfarscript_la_SOURCES = far-class.cc farscript.cc getters.cc script-impl.cc \
-                             strings.cc sttable.cc stlist.cc
-libfstfarscript_la_LDFLAGS = -version-info 24:0:0
-libfstfarscript_la_LIBADD = \
-    libfstfar.la ../../script/libfstscript.la \
-        ../../lib/libfst.la -lm $(DL_LIBS)
+libfstfarscript_la_SOURCES = compile-strings.cc far-class.cc farscript.cc \
+                                                        getters.cc script-impl.cc sttable.cc stlist.cc
+libfstfarscript_la_LDFLAGS = -version-info 25:0:0
+libfstfarscript_la_LIBADD = libfstfar.la ../../script/libfstscript.la \
+                                               ../../lib/libfst.la -lm $(DL_LIBS)
 endif
 
 if HAVE_BIN
-bin_PROGRAMS = farcompilestrings farconvert farcreate farequal farextract \
-    farinfo farisomorphic farprintstrings
+bin_PROGRAMS = farcompilestrings farconvert farcreate farencode farequal \
+                          farextract farinfo farisomorphic farprintstrings
 
 LDADD = libfstfarscript.la ../../script/libfstscript.la \
         ../../lib/libfst.la -lm $(DL_LIBS)
@@ -36,6 +35,8 @@ farcreate_SOURCES = farcreate.cc farcreate-main.cc
 
 farequal_SOURCES = farequal.cc farequal-main.cc
 
+farencode_SOURCES = farencode.cc farencode-main.cc
+
 farextract_SOURCES = farextract.cc farextract-main.cc
 
 farinfo_SOURCES = farinfo.cc farinfo-main.cc
index e0cea4d..1c9d385 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -91,9 +91,9 @@ build_triplet = @build@
 host_triplet = @host@
 @HAVE_BIN_TRUE@bin_PROGRAMS = farcompilestrings$(EXEEXT) \
 @HAVE_BIN_TRUE@        farconvert$(EXEEXT) farcreate$(EXEEXT) \
-@HAVE_BIN_TRUE@        farequal$(EXEEXT) farextract$(EXEEXT) \
-@HAVE_BIN_TRUE@        farinfo$(EXEEXT) farisomorphic$(EXEEXT) \
-@HAVE_BIN_TRUE@        farprintstrings$(EXEEXT)
+@HAVE_BIN_TRUE@        farencode$(EXEEXT) farequal$(EXEEXT) \
+@HAVE_BIN_TRUE@        farextract$(EXEEXT) farinfo$(EXEEXT) \
+@HAVE_BIN_TRUE@        farisomorphic$(EXEEXT) farprintstrings$(EXEEXT)
 subdir = src/extensions/far
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_python_devel.m4 \
@@ -104,8 +104,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)"
@@ -154,11 +153,11 @@ libfstfar_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 @HAVE_SCRIPT_TRUE@libfstfarscript_la_DEPENDENCIES = libfstfar.la \
 @HAVE_SCRIPT_TRUE@     ../../script/libfstscript.la \
 @HAVE_SCRIPT_TRUE@     ../../lib/libfst.la $(am__DEPENDENCIES_1)
-am__libfstfarscript_la_SOURCES_DIST = far-class.cc farscript.cc \
-       getters.cc script-impl.cc strings.cc sttable.cc stlist.cc
-@HAVE_SCRIPT_TRUE@am_libfstfarscript_la_OBJECTS = far-class.lo \
-@HAVE_SCRIPT_TRUE@     farscript.lo getters.lo script-impl.lo \
-@HAVE_SCRIPT_TRUE@     strings.lo sttable.lo stlist.lo
+am__libfstfarscript_la_SOURCES_DIST = compile-strings.cc far-class.cc \
+       farscript.cc getters.cc script-impl.cc sttable.cc stlist.cc
+@HAVE_SCRIPT_TRUE@am_libfstfarscript_la_OBJECTS = compile-strings.lo \
+@HAVE_SCRIPT_TRUE@     far-class.lo farscript.lo getters.lo \
+@HAVE_SCRIPT_TRUE@     script-impl.lo sttable.lo stlist.lo
 libfstfarscript_la_OBJECTS = $(am_libfstfarscript_la_OBJECTS)
 libfstfarscript_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
        $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -191,6 +190,14 @@ farcreate_LDADD = $(LDADD)
 @HAVE_BIN_TRUE@farcreate_DEPENDENCIES = libfstfarscript.la \
 @HAVE_BIN_TRUE@        ../../script/libfstscript.la \
 @HAVE_BIN_TRUE@        ../../lib/libfst.la $(am__DEPENDENCIES_1)
+am__farencode_SOURCES_DIST = farencode.cc farencode-main.cc
+@HAVE_BIN_TRUE@am_farencode_OBJECTS = farencode.$(OBJEXT) \
+@HAVE_BIN_TRUE@        farencode-main.$(OBJEXT)
+farencode_OBJECTS = $(am_farencode_OBJECTS)
+farencode_LDADD = $(LDADD)
+@HAVE_BIN_TRUE@farencode_DEPENDENCIES = libfstfarscript.la \
+@HAVE_BIN_TRUE@        ../../script/libfstscript.la \
+@HAVE_BIN_TRUE@        ../../lib/libfst.la $(am__DEPENDENCIES_1)
 am__farequal_SOURCES_DIST = farequal.cc farequal-main.cc
 @HAVE_BIN_TRUE@am_farequal_OBJECTS = farequal.$(OBJEXT) \
 @HAVE_BIN_TRUE@        farequal-main.$(OBJEXT)
@@ -248,11 +255,13 @@ am__v_at_1 =
 DEFAULT_INCLUDES = 
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__maybe_remake_depfiles = depfiles
-am__depfiles_remade = ./$(DEPDIR)/far-class.Plo \
+am__depfiles_remade = ./$(DEPDIR)/compile-strings.Plo \
+       ./$(DEPDIR)/far-class.Plo \
        ./$(DEPDIR)/farcompilestrings-main.Po \
        ./$(DEPDIR)/farcompilestrings.Po \
        ./$(DEPDIR)/farconvert-main.Po ./$(DEPDIR)/farconvert.Po \
        ./$(DEPDIR)/farcreate-main.Po ./$(DEPDIR)/farcreate.Po \
+       ./$(DEPDIR)/farencode-main.Po ./$(DEPDIR)/farencode.Po \
        ./$(DEPDIR)/farequal-main.Po ./$(DEPDIR)/farequal.Po \
        ./$(DEPDIR)/farextract-main.Po ./$(DEPDIR)/farextract.Po \
        ./$(DEPDIR)/farinfo-main.Po ./$(DEPDIR)/farinfo.Po \
@@ -260,8 +269,7 @@ am__depfiles_remade = ./$(DEPDIR)/far-class.Plo \
        ./$(DEPDIR)/farprintstrings-main.Po \
        ./$(DEPDIR)/farprintstrings.Po ./$(DEPDIR)/farscript.Plo \
        ./$(DEPDIR)/getters.Plo ./$(DEPDIR)/script-impl.Plo \
-       ./$(DEPDIR)/stlist.Plo ./$(DEPDIR)/strings.Plo \
-       ./$(DEPDIR)/sttable.Plo
+       ./$(DEPDIR)/stlist.Plo ./$(DEPDIR)/sttable.Plo
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
@@ -283,15 +291,16 @@ am__v_CXXLD_0 = @echo "  CXXLD   " $@;
 am__v_CXXLD_1 = 
 SOURCES = $(libfstfar_la_SOURCES) $(libfstfarscript_la_SOURCES) \
        $(farcompilestrings_SOURCES) $(farconvert_SOURCES) \
-       $(farcreate_SOURCES) $(farequal_SOURCES) $(farextract_SOURCES) \
-       $(farinfo_SOURCES) $(farisomorphic_SOURCES) \
-       $(farprintstrings_SOURCES)
+       $(farcreate_SOURCES) $(farencode_SOURCES) $(farequal_SOURCES) \
+       $(farextract_SOURCES) $(farinfo_SOURCES) \
+       $(farisomorphic_SOURCES) $(farprintstrings_SOURCES)
 DIST_SOURCES = $(libfstfar_la_SOURCES) \
        $(am__libfstfarscript_la_SOURCES_DIST) \
        $(am__farcompilestrings_SOURCES_DIST) \
        $(am__farconvert_SOURCES_DIST) $(am__farcreate_SOURCES_DIST) \
-       $(am__farequal_SOURCES_DIST) $(am__farextract_SOURCES_DIST) \
-       $(am__farinfo_SOURCES_DIST) $(am__farisomorphic_SOURCES_DIST) \
+       $(am__farencode_SOURCES_DIST) $(am__farequal_SOURCES_DIST) \
+       $(am__farextract_SOURCES_DIST) $(am__farinfo_SOURCES_DIST) \
+       $(am__farisomorphic_SOURCES_DIST) \
        $(am__farprintstrings_SOURCES_DIST)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -315,8 +324,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -330,8 +337,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -347,6 +355,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -461,15 +470,14 @@ EXTRA_DIST = build_defs.bzl
 @HAVE_SCRIPT_FALSE@lib_LTLIBRARIES = libfstfar.la
 @HAVE_SCRIPT_TRUE@lib_LTLIBRARIES = libfstfar.la libfstfarscript.la
 libfstfar_la_SOURCES = sttable.cc stlist.cc
-libfstfar_la_LDFLAGS = -version-info 24:0:0
+libfstfar_la_LDFLAGS = -version-info 25:0:0
 libfstfar_la_LIBADD = ../../lib/libfst.la -lm $(DL_LIBS)
-@HAVE_SCRIPT_TRUE@libfstfarscript_la_SOURCES = far-class.cc farscript.cc getters.cc script-impl.cc \
-@HAVE_SCRIPT_TRUE@                             strings.cc sttable.cc stlist.cc
+@HAVE_SCRIPT_TRUE@libfstfarscript_la_SOURCES = compile-strings.cc far-class.cc farscript.cc \
+@HAVE_SCRIPT_TRUE@                                                      getters.cc script-impl.cc sttable.cc stlist.cc
 
-@HAVE_SCRIPT_TRUE@libfstfarscript_la_LDFLAGS = -version-info 24:0:0
-@HAVE_SCRIPT_TRUE@libfstfarscript_la_LIBADD = \
-@HAVE_SCRIPT_TRUE@    libfstfar.la ../../script/libfstscript.la \
-@HAVE_SCRIPT_TRUE@        ../../lib/libfst.la -lm $(DL_LIBS)
+@HAVE_SCRIPT_TRUE@libfstfarscript_la_LDFLAGS = -version-info 25:0:0
+@HAVE_SCRIPT_TRUE@libfstfarscript_la_LIBADD = libfstfar.la ../../script/libfstscript.la \
+@HAVE_SCRIPT_TRUE@                                             ../../lib/libfst.la -lm $(DL_LIBS)
 
 @HAVE_BIN_TRUE@LDADD = libfstfarscript.la ../../script/libfstscript.la \
 @HAVE_BIN_TRUE@        ../../lib/libfst.la -lm $(DL_LIBS)
@@ -478,6 +486,7 @@ libfstfar_la_LIBADD = ../../lib/libfst.la -lm $(DL_LIBS)
 @HAVE_BIN_TRUE@farconvert_SOURCES = farconvert.cc farconvert-main.cc
 @HAVE_BIN_TRUE@farcreate_SOURCES = farcreate.cc farcreate-main.cc
 @HAVE_BIN_TRUE@farequal_SOURCES = farequal.cc farequal-main.cc
+@HAVE_BIN_TRUE@farencode_SOURCES = farencode.cc farencode-main.cc
 @HAVE_BIN_TRUE@farextract_SOURCES = farextract.cc farextract-main.cc
 @HAVE_BIN_TRUE@farinfo_SOURCES = farinfo.cc farinfo-main.cc
 @HAVE_BIN_TRUE@farisomorphic_SOURCES = farisomorphic.cc farisomorphic-main.cc
@@ -618,6 +627,10 @@ farcreate$(EXEEXT): $(farcreate_OBJECTS) $(farcreate_DEPENDENCIES) $(EXTRA_farcr
        @rm -f farcreate$(EXEEXT)
        $(AM_V_CXXLD)$(CXXLINK) $(farcreate_OBJECTS) $(farcreate_LDADD) $(LIBS)
 
+farencode$(EXEEXT): $(farencode_OBJECTS) $(farencode_DEPENDENCIES) $(EXTRA_farencode_DEPENDENCIES) 
+       @rm -f farencode$(EXEEXT)
+       $(AM_V_CXXLD)$(CXXLINK) $(farencode_OBJECTS) $(farencode_LDADD) $(LIBS)
+
 farequal$(EXEEXT): $(farequal_OBJECTS) $(farequal_DEPENDENCIES) $(EXTRA_farequal_DEPENDENCIES) 
        @rm -f farequal$(EXEEXT)
        $(AM_V_CXXLD)$(CXXLINK) $(farequal_OBJECTS) $(farequal_LDADD) $(LIBS)
@@ -644,6 +657,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compile-strings.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/far-class.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farcompilestrings-main.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farcompilestrings.Po@am__quote@ # am--include-marker
@@ -651,6 +665,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farconvert.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farcreate-main.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farcreate.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farencode-main.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farencode.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farequal-main.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farequal.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farextract-main.Po@am__quote@ # am--include-marker
@@ -665,7 +681,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getters.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script-impl.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stlist.Plo@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strings.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sttable.Plo@am__quote@ # am--include-marker
 
 $(am__depfiles_remade):
@@ -755,7 +770,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -834,13 +848,16 @@ clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
        clean-libtool mostlyclean-am
 
 distclean: distclean-am
-               -rm -f ./$(DEPDIR)/far-class.Plo
+               -rm -f ./$(DEPDIR)/compile-strings.Plo
+       -rm -f ./$(DEPDIR)/far-class.Plo
        -rm -f ./$(DEPDIR)/farcompilestrings-main.Po
        -rm -f ./$(DEPDIR)/farcompilestrings.Po
        -rm -f ./$(DEPDIR)/farconvert-main.Po
        -rm -f ./$(DEPDIR)/farconvert.Po
        -rm -f ./$(DEPDIR)/farcreate-main.Po
        -rm -f ./$(DEPDIR)/farcreate.Po
+       -rm -f ./$(DEPDIR)/farencode-main.Po
+       -rm -f ./$(DEPDIR)/farencode.Po
        -rm -f ./$(DEPDIR)/farequal-main.Po
        -rm -f ./$(DEPDIR)/farequal.Po
        -rm -f ./$(DEPDIR)/farextract-main.Po
@@ -855,7 +872,6 @@ distclean: distclean-am
        -rm -f ./$(DEPDIR)/getters.Plo
        -rm -f ./$(DEPDIR)/script-impl.Plo
        -rm -f ./$(DEPDIR)/stlist.Plo
-       -rm -f ./$(DEPDIR)/strings.Plo
        -rm -f ./$(DEPDIR)/sttable.Plo
        -rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
@@ -902,13 +918,16 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-               -rm -f ./$(DEPDIR)/far-class.Plo
+               -rm -f ./$(DEPDIR)/compile-strings.Plo
+       -rm -f ./$(DEPDIR)/far-class.Plo
        -rm -f ./$(DEPDIR)/farcompilestrings-main.Po
        -rm -f ./$(DEPDIR)/farcompilestrings.Po
        -rm -f ./$(DEPDIR)/farconvert-main.Po
        -rm -f ./$(DEPDIR)/farconvert.Po
        -rm -f ./$(DEPDIR)/farcreate-main.Po
        -rm -f ./$(DEPDIR)/farcreate.Po
+       -rm -f ./$(DEPDIR)/farencode-main.Po
+       -rm -f ./$(DEPDIR)/farencode.Po
        -rm -f ./$(DEPDIR)/farequal-main.Po
        -rm -f ./$(DEPDIR)/farequal.Po
        -rm -f ./$(DEPDIR)/farextract-main.Po
@@ -923,7 +942,6 @@ maintainer-clean: maintainer-clean-am
        -rm -f ./$(DEPDIR)/getters.Plo
        -rm -f ./$(DEPDIR)/script-impl.Plo
        -rm -f ./$(DEPDIR)/stlist.Plo
-       -rm -f ./$(DEPDIR)/strings.Plo
        -rm -f ./$(DEPDIR)/sttable.Plo
        -rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
similarity index 95%
rename from src/extensions/far/strings.cc
rename to src/extensions/far/compile-strings.cc
index 7ec949c..334c3d9 100644 (file)
@@ -26,11 +26,12 @@ DEFINE_string(far_field_separator, "\t",
               "Set of characters used as a separator between printed fields");
 
 namespace fst {
+namespace internal {
 
 // Computes the minimal length required to encode each line number as a decimal
 // number, or zero if the number of lines could not be determined because the
 // file was not seekable.
-int KeySize(const char *source) {
+int KeySize(const std::string &source) {
   std::ifstream istrm(source);
   istrm.seekg(0);
   // TODO(jrosenstock): Change this to is_regular_file when <filesystem> is
@@ -49,4 +50,5 @@ int KeySize(const char *source) {
   return nline ? ceil(log10(nline + 1)) : 1;
 }
 
+}  // namespace internal
 }  // namespace fst
index 16d8f11..4a2da9b 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <fst/extensions/far/far-class.h>
 
+#include <string>
+#include <utility>
+
 #include <fst/extensions/far/script-impl.h>
 #include <fst/arc.h>
 #include <fst/script/script-impl.h>
index a79f1ef..c16146d 100644 (file)
@@ -17,6 +17,8 @@
 //
 // Compiles a set of stings as FSTs and stores them in a finite-state archive.
 
+#include <cstring>
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -42,6 +44,7 @@ DECLARE_bool(initial_symbols);
 
 int farcompilestrings_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarWriterClass;
 
   std::string usage = "Compiles a set of strings as FSTs and stores them in";
   usage += " a finite-state archive.\n\n  Usage:";
@@ -52,26 +55,25 @@ int farcompilestrings_main(int argc, char **argv) {
   SET_FLAGS(usage.c_str(), &argc, &argv, true);
   s::ExpandArgs(argc, argv, &argc, &argv);
 
-  std::vector<std::string> in_sources;
+  std::vector<std::string> sources;
   if (FST_FLAGS_file_list_input) {
     for (int i = 1; i < argc - 1; ++i) {
       std::ifstream istrm(argv[i]);
       std::string str;
-      while (std::getline(istrm, str)) in_sources.push_back(str);
+      while (std::getline(istrm, str)) sources.push_back(str);
     }
   } else {
     for (int i = 1; i < argc - 1; ++i)
-      in_sources.push_back(strcmp(argv[i], "-") != 0 ? argv[i] : "");
-    if (in_sources.empty()) {
+      sources.push_back(strcmp(argv[i], "-") != 0 ? argv[i] : "");
+    if (sources.empty()) {
       // argc == 1 || argc == 2. This cleverly handles both the no-file case
       // and the one (input) file case together.
-      in_sources.push_back(argc == 2 && strcmp(argv[1], "-") != 0 ? argv[1]
-                                                                  : "");
+      sources.push_back(argc == 2 && strcmp(argv[1], "-") != 0 ? argv[1] : "");
     }
   }
 
   // argc <= 2 means the file (if any) is an input file, so write to stdout.
-  const std::string out_source =
+  const std::string out_far =
       argc > 2 && strcmp(argv[argc - 1], "-") != 0 ? argv[argc - 1] : "";
 
   fst::FarEntryType entry_type;
@@ -101,13 +103,25 @@ int farcompilestrings_main(int argc, char **argv) {
                                    ? "vector"
                                    : FST_FLAGS_fst_type;
 
-  s::FarCompileStrings(
-      in_sources, out_source, FST_FLAGS_arc_type, fst_type, far_type,
-      FST_FLAGS_generate_keys, entry_type, token_type,
-      FST_FLAGS_symbols, FST_FLAGS_unknown_symbol,
-      FST_FLAGS_keep_symbols, FST_FLAGS_initial_symbols,
+  const auto arc_type = FST_FLAGS_arc_type;
+  if (arc_type.empty()) return 1;
+
+  std::unique_ptr<FarWriterClass> writer(
+      FarWriterClass::Create(out_far, arc_type, far_type));
+  if (!writer) return 1;
+
+  s::CompileStrings(
+      sources, *writer, fst_type, FST_FLAGS_generate_keys,
+      entry_type, token_type, FST_FLAGS_symbols,
+      FST_FLAGS_unknown_symbol, FST_FLAGS_keep_symbols,
+      FST_FLAGS_initial_symbols,
       FST_FLAGS_allow_negative_labels,
       FST_FLAGS_key_prefix, FST_FLAGS_key_suffix);
 
+  if (writer->Error()) {
+    FSTERROR() << "Error writing FAR: " << out_far;
+    return 1;
+  }
+
   return 0;
 }
index 3445f04..c702384 100644 (file)
@@ -18,6 +18,7 @@
 // Converts FST and container type of FARs.
 
 #include <cstring>
+#include <memory>
 #include <string>
 
 #include <fst/flags.h>
 DECLARE_string(far_type);
 DECLARE_string(fst_type);
 
-int farconvert_main(int argc, char *argv[]) {
+int farconvert_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarReaderClass;
+  using fst::script::FarWriterClass;
 
   std::string usage = "Converts FST and container types.\n\n Usage:";
   usage += argv[0];
@@ -37,19 +40,19 @@ int farconvert_main(int argc, char *argv[]) {
 
   std::set_new_handler(FailedNewHandler);
   SET_FLAGS(usage.c_str(), &argc, &argv, true);
+  s::ExpandArgs(argc, argv, &argc, &argv);
 
   if (argc > 3) {
     ShowUsage();
     return 1;
   }
 
-  // 0 file args means read from stdin and write to stdout.
-  // 1 file arg means read from in.far and write to stdout.
-  // Only STList can be written to stdout; there will be
-  // an error in Write() when another format is used.
-  const std::string in_far =
+  // No args: read from stdin and write to stdout.
+  // One arg: read from in.far and write to stdout.
+  // Note that only STList can be written to stdout.
+  const std::string in_name =
       argc > 1 && std::strcmp(argv[1], "-") != 0 ? argv[1] : "";
-  const std::string out_far =
+  const std::string out_name =
       argc > 2 && std::strcmp(argv[2], "-") != 0 ? argv[2] : "";
 
   fst::FarType far_type;
@@ -58,33 +61,31 @@ int farconvert_main(int argc, char *argv[]) {
     return 1;
   }
 
-  // We use a different meaning of far_type. DEFAULT means "same as input",
-  // so snoop the input far_type.
-  if (far_type == fst::FarType::DEFAULT) {
-    fst::FarHeader hdr;
-    if (!hdr.Read(in_far)) {
-      LOG(ERROR) << "Couldn't open " << in_far;
-      return 1;
-    }
-    // GetFarType returns STLIST for stdin, regardless of the actual FAR type.
-    // If the input actually has another type, it Open() will fail later.
-    if (!s::GetFarType(hdr.FarType(), &far_type)) {
-      LOG(ERROR) << "Failed to retrieve archive type from " << in_far;
-      return 1;
-    }
-  }
+  std::unique_ptr<FarReaderClass> reader(FarReaderClass::Open(in_name));
+  if (!reader) return 1;
+
+  // This uses a different meaning of far_type; since DEFAULT means "same as
+  // input", we must determine the input FarType.
+  if (far_type == fst::FarType::DEFAULT) far_type = reader->Type();
+
+  const auto arc_type = reader->ArcType();
+  if (arc_type.empty()) return 1;
+
+  std::unique_ptr<FarWriterClass> writer(
+      FarWriterClass::Create(out_name, arc_type, far_type));
+  if (!writer) return 1;
 
-  // LoadArcTypeFromFar returns arc_type=="standard" for stdin. As above
-  // with FarType, Open() will fail later if it actually has a different type.
-  const std::string arc_type = s::LoadArcTypeFromFar(in_far);
-  if (arc_type.empty()) {
-    LOG(ERROR) << "Could not determine arc type for " << in_far;
+  // An unspecified fst_type entails that the input FST types are preserved.
+  s::Convert(*reader, *writer, FST_FLAGS_fst_type);
+
+  if (reader->Error()) {
+    FSTERROR() << "Error reading FAR: " << in_name;
+    return 1;
+  }
+  if (writer->Error()) {
+    FSTERROR() << "Error writing FAR: " << out_name;
     return 1;
   }
-
-  // Empty fst_type means use input fst type for each fst individually.
-  s::FarConvert(in_far, out_far, arc_type, FST_FLAGS_fst_type,
-                far_type);
 
   return 0;
 }
index afbcd0b..4a10e47 100644 (file)
@@ -12,6 +12,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
+// See www.openfst.org for extensive documentation on this weighted
+// finite-state transducer library.
+
 #include <fst/flags.h>
 
 DEFINE_string(fst_type, "",
@@ -19,8 +22,8 @@ DEFINE_string(fst_type, "",
               "If empty, each FST's type is unchanged");
 DEFINE_string(far_type, "default",
               "FAR file format type: one of: \"default\", \"fst\", "
-              "\"stlist\", \"sttable\". "
-              "\"default\" means use type of input FAR.");
+              "\"stlist\", \"sttable\"; "
+              "\"default\" means use type of input FAR");
 
 int farconvert_main(int argc, char **argv);
 
index ab86463..883ac8e 100644 (file)
@@ -34,6 +34,7 @@ DECLARE_bool(file_list_input);
 
 int farcreate_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarWriterClass;
 
   std::string usage =
       "Creates a finite-state archive from input FSTs.\n\n Usage:";
@@ -44,34 +45,27 @@ int farcreate_main(int argc, char **argv) {
   SET_FLAGS(usage.c_str(), &argc, &argv, true);
   s::ExpandArgs(argc, argv, &argc, &argv);
 
-  std::vector<std::string> in_sources;
+  std::vector<std::string> sources;
   if (FST_FLAGS_file_list_input) {
     for (int i = 1; i < argc - 1; ++i) {
       std::ifstream istrm(argv[i]);
       std::string str;
-      while (std::getline(istrm, str)) in_sources.push_back(str);
+      while (std::getline(istrm, str)) sources.push_back(str);
     }
   } else {
     for (int i = 1; i < argc - 1; ++i)
-      in_sources.push_back(strcmp(argv[i], "-") != 0 ? argv[i] : "");
-    if (in_sources.empty()) {
+      sources.push_back(strcmp(argv[i], "-") != 0 ? argv[i] : "");
+    if (sources.empty()) {
       // argc == 1 || argc == 2. This cleverly handles both the no-file case
       // and the one (input) file case together.
-      in_sources.push_back(argc == 2 && strcmp(argv[1], "-") != 0 ? argv[1]
-                                                                  : "");
+      sources.push_back(argc == 2 && strcmp(argv[1], "-") != 0 ? argv[1] : "");
     }
   }
 
   // argc <= 2 means the file (if any) is an input file, so write to stdout.
-  const std::string out_source =
+  const std::string out_far =
       argc > 2 && strcmp(argv[argc - 1], "-") != 0 ? argv[argc - 1] : "";
 
-  std::string arc_type = fst::ErrorArc::Type();
-  if (!in_sources.empty()) {
-    arc_type = s::LoadArcTypeFromFst(in_sources[0]);
-    if (arc_type.empty()) return 1;
-  }
-
   fst::FarType far_type;
   if (!s::GetFarType(FST_FLAGS_far_type, &far_type)) {
     LOG(ERROR) << "Unknown or unsupported FAR type: "
@@ -79,10 +73,23 @@ int farcreate_main(int argc, char **argv) {
     return 1;
   }
 
-  s::FarCreate(in_sources, out_source, arc_type,
-               FST_FLAGS_generate_keys, far_type,
-               FST_FLAGS_key_prefix,
-               FST_FLAGS_key_suffix);
+  std::string arc_type = fst::ErrorArc::Type();
+  if (!sources.empty()) {
+    arc_type = s::LoadArcTypeFromFst(sources[0]);
+    if (arc_type.empty()) return 1;
+  }
+
+  std::unique_ptr<FarWriterClass> writer(
+      FarWriterClass::Create(out_far, arc_type, far_type));
+  if (!writer) return 1;
+
+  s::Create(sources, *writer, FST_FLAGS_generate_keys,
+            FST_FLAGS_key_prefix, FST_FLAGS_key_suffix);
+
+  if (writer->Error()) {
+    FSTERROR() << "Error writing FAR: " << out_far;
+    return 1;
+  }
 
   return 0;
 }
diff --git a/src/extensions/far/farencode-main.cc b/src/extensions/far/farencode-main.cc
new file mode 100644 (file)
index 0000000..5e2be3a
--- /dev/null
@@ -0,0 +1,105 @@
+// Copyright 2005-2020 Google LLC
+//
+// 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.
+//
+// See www.openfst.org for extensive documentation on this weighted
+// finite-state transducer library.
+//
+// Encodes FAR labels and/or weights.
+
+#include <cstring>
+#include <memory>
+#include <string>
+
+#include <fst/flags.h>
+#include <fst/log.h>
+#include <fst/extensions/far/farscript.h>
+#include <fst/extensions/far/getters.h>
+
+DECLARE_bool(decode);
+DECLARE_bool(encode_labels);
+DECLARE_bool(encode_weights);
+DECLARE_bool(encode_reuse);
+DECLARE_string(far_type);
+
+int farencode_main(int argc, char **argv) {
+  namespace s = fst::script;
+  using fst::script::EncodeMapperClass;
+  using fst::script::FarReaderClass;
+  using fst::script::FarWriterClass;
+
+  std::string usage = "Encodes FAR labels and/or weights.\n\n Usage: ";
+  usage += argv[0];
+  usage += " [in.far mapper [out.far]]\n";
+
+  std::set_new_handler(FailedNewHandler);
+  SET_FLAGS(usage.c_str(), &argc, &argv, true);
+  if (argc < 3 || argc > 4) {
+    ShowUsage();
+    return 1;
+  }
+
+  const std::string in_name = (strcmp(argv[1], "-") != 0) ? argv[1] : "";
+  const std::string mapper_name = argv[2];
+  const std::string out_name =
+      argc > 3 && strcmp(argv[3], "-") != 0 ? argv[3] : "";
+
+  std::unique_ptr<FarReaderClass> reader(FarReaderClass::Open(in_name));
+  if (!reader) return 1;
+
+  fst::FarType far_type;
+  if (!s::GetFarType(FST_FLAGS_far_type, &far_type)) {
+    LOG(ERROR) << "Unknown --far_type " << FST_FLAGS_far_type;
+    return 1;
+  }
+
+  // This uses a different meaning of far_type; since DEFAULT means "same as
+  // input", we must determine the input FarType.
+  if (far_type == fst::FarType::DEFAULT) far_type = reader->Type();
+
+  const auto arc_type = reader->ArcType();
+  if (arc_type.empty()) return 1;
+
+  std::unique_ptr<FarWriterClass> writer(
+      FarWriterClass::Create(out_name, arc_type, far_type));
+  if (!writer) return 1;
+
+  if (FST_FLAGS_decode) {
+    std::unique_ptr<EncodeMapperClass> mapper(
+        EncodeMapperClass::Read(mapper_name));
+    if (!mapper) return 1;
+    s::Decode(*reader, *writer, *mapper);
+  } else if (FST_FLAGS_encode_reuse) {
+    std::unique_ptr<EncodeMapperClass> mapper(
+        EncodeMapperClass::Read(mapper_name));
+    if (!mapper) return 1;
+    s::Encode(*reader, *writer, mapper.get());
+  } else {
+    const auto flags = s::GetEncodeFlags(FST_FLAGS_encode_labels,
+                                         FST_FLAGS_encode_weights);
+    EncodeMapperClass mapper(reader->ArcType(), flags);
+    s::Encode(*reader, *writer, &mapper);
+    if (!mapper.Write(mapper_name)) return 1;
+  }
+
+  if (reader->Error()) {
+    FSTERROR() << "Error reading FAR: " << in_name;
+    return 1;
+  }
+  if (writer->Error()) {
+    FSTERROR() << "Error writing FAR: " << out_name;
+    return 1;
+  }
+
+  return 0;
+}
diff --git a/src/extensions/far/farencode.cc b/src/extensions/far/farencode.cc
new file mode 100644 (file)
index 0000000..2c91e1a
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2005-2020 Google LLC
+//
+// 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.
+//
+// See www.openfst.org for extensive documentation on this weighted
+// finite-state transducer library.
+
+#include <fst/flags.h>
+
+DEFINE_bool(decode, false, "Decode labels and/or weights");
+DEFINE_bool(encode_labels, false, "Encode output labels");
+DEFINE_bool(encode_weights, false, "Encode weights");
+DEFINE_bool(encode_reuse, false, "Re-use existing mapper");
+DEFINE_string(far_type, "default",
+              "FAR file format type: one of: \"default\", \"fst\", "
+              "\"stlist\", \"sttable\"; "
+              "\"default\" means use type of input FAR");
+
+int farencode_main(int argc, char **argv);
+
+int main(int argc, char **argv) { return farencode_main(argc, argv); }
index f14dfb4..8474bb3 100644 (file)
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 //
-// Tests if two Far files contains the same (key,fst) pairs.
+// Tests whether two FAR files contains the same (key, fst) pairs.
 
+#include <memory>
 #include <string>
 
 #include <fst/flags.h>
+#include <fst/extensions/far/far-class.h>
 #include <fst/extensions/far/farscript.h>
 #include <fst/extensions/far/getters.h>
 
@@ -29,6 +31,7 @@ DECLARE_double(delta);
 
 int farequal_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarReaderClass;
 
   std::string usage = "Compares the FSTs in two FST archives for equality.";
   usage += "\n\n  Usage:";
@@ -43,14 +46,26 @@ int farequal_main(int argc, char **argv) {
     return 1;
   }
 
-  const auto arc_type = s::LoadArcTypeFromFar(argv[1]);
-  if (arc_type.empty()) return 1;
+  std::unique_ptr<FarReaderClass> reader1(FarReaderClass::Open(argv[1]));
+  if (!reader1) return 1;
 
-  bool result =
-      s::FarEqual(argv[1], argv[2], arc_type, FST_FLAGS_delta,
-                  FST_FLAGS_begin_key, FST_FLAGS_end_key);
+  std::unique_ptr<FarReaderClass> reader2(FarReaderClass::Open(argv[2]));
+  if (!reader2) return 1;
 
-  if (!result) VLOG(1) << "FARs are not equal.";
+  const bool result =
+      s::Equal(*reader1, *reader2, FST_FLAGS_delta,
+               FST_FLAGS_begin_key, FST_FLAGS_end_key);
+
+  if (reader1->Error()) {
+    FSTERROR() << "Error reading FAR: " << argv[1];
+    return 1;
+  }
+  if (reader2->Error()) {
+    FSTERROR() << "Error reading FAR: " << argv[2];
+    return 1;
+  }
+
+  if (!result) VLOG(1) << "FARs are not equal";
 
   return result ? 0 : 2;
 }
index 87095a5..d4b7c19 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Extracts component FSTs from an finite-state archive.
 
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -33,6 +34,7 @@ DECLARE_string(range_delimiter);
 
 int farextract_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarReaderClass;
 
   std::string usage = "Extracts FSTs from a finite-state archive.\n\n Usage:";
   usage += argv[0];
@@ -42,18 +44,22 @@ int farextract_main(int argc, char **argv) {
   SET_FLAGS(usage.c_str(), &argc, &argv, true);
   s::ExpandArgs(argc, argv, &argc, &argv);
 
-  std::vector<std::string> in_sources;
-  for (int i = 1; i < argc; ++i) in_sources.push_back(argv[i]);
-  if (in_sources.empty()) in_sources.push_back("");
+  std::vector<std::string> sources;
+  for (int i = 1; i < argc; ++i) sources.push_back(argv[i]);
+  if (sources.empty()) sources.push_back("");
+  std::unique_ptr<FarReaderClass> reader(FarReaderClass::Open(sources));
+  if (!reader) return 1;
 
-  const auto arc_type = s::LoadArcTypeFromFar(in_sources[0]);
-  if (arc_type.empty()) return 1;
+  s::Extract(*reader, FST_FLAGS_generate_filenames,
+             FST_FLAGS_keys, FST_FLAGS_key_separator,
+             FST_FLAGS_range_delimiter,
+             FST_FLAGS_filename_prefix,
+             FST_FLAGS_filename_suffix);
 
-  s::FarExtract(in_sources, arc_type, FST_FLAGS_generate_filenames,
-                FST_FLAGS_keys, FST_FLAGS_key_separator,
-                FST_FLAGS_range_delimiter,
-                FST_FLAGS_filename_prefix,
-                FST_FLAGS_filename_suffix);
+  if (reader->Error()) {
+    FSTERROR() << "Error reading FAR(s)";
+    return 1;
+  }
 
   return 0;
 }
index 9e9955e..831f3cb 100644 (file)
@@ -41,15 +41,15 @@ int farinfo_main(int argc, char **argv) {
   SET_FLAGS(usage.c_str(), &argc, &argv, true);
   s::ExpandArgs(argc, argv, &argc, &argv);
 
-  std::vector<std::string> in_sources;
-  for (int i = 1; i < argc; ++i) in_sources.push_back(argv[i]);
-  if (in_sources.empty()) in_sources.push_back("");
+  std::vector<std::string> sources;
+  for (int i = 1; i < argc; ++i) sources.push_back(argv[i]);
+  if (sources.empty()) sources.push_back("");
 
-  const auto arc_type = s::LoadArcTypeFromFar(in_sources[0]);
+  const auto arc_type = s::LoadArcTypeFromFar(sources[0]);
   if (arc_type.empty()) return 1;
 
-  s::FarInfo(in_sources, arc_type, FST_FLAGS_begin_key,
-             FST_FLAGS_end_key, FST_FLAGS_list_fsts);
+  s::Info(sources, arc_type, FST_FLAGS_begin_key,
+          FST_FLAGS_end_key, FST_FLAGS_list_fsts);
 
   return 0;
 }
index baafa20..6ab070a 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Tests if two Far files contains isomorphic (key,fst) pairs.
 
+#include <memory>
 #include <string>
 
 #include <fst/flags.h>
@@ -29,6 +30,7 @@ DECLARE_double(delta);
 
 int farisomorphic_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarReaderClass;
 
   std::string usage = "Compares the FSTs in two FST archives for isomorphism.";
   usage += "\n\n  Usage:";
@@ -45,14 +47,26 @@ int farisomorphic_main(int argc, char **argv) {
     return 1;
   }
 
-  const auto arc_type = s::LoadArcTypeFromFar(argv[1]);
-  if (arc_type.empty()) return 1;
+  std::unique_ptr<FarReaderClass> reader1(FarReaderClass::Open(argv[1]));
+  if (!reader1) return 1;
 
-  bool result = s::FarIsomorphic(
-      argv[1], argv[2], arc_type, FST_FLAGS_delta,
+  std::unique_ptr<FarReaderClass> reader2(FarReaderClass::Open(argv[2]));
+  if (!reader2) return 1;
+
+  const bool result = s::Isomorphic(
+      *reader1, *reader2, FST_FLAGS_delta,
       FST_FLAGS_begin_key, FST_FLAGS_end_key);
 
-  if (!result) VLOG(1) << "FARs are not isomorphic.";
+  if (reader1->Error()) {
+    FSTERROR() << "Error reading FAR: " << argv[1];
+    return 1;
+  }
+  if (reader2->Error()) {
+    FSTERROR() << "Error reading FAR: " << argv[2];
+    return 1;
+  }
+
+  if (!result) VLOG(1) << "FARs are not isomorphic";
 
   return result ? 0 : 2;
 }
index 898c222..eee9e31 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Outputs as strings the string FSTs in a finite-state archive.
 
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -38,6 +39,7 @@ DECLARE_bool(initial_symbols);
 
 int farprintstrings_main(int argc, char **argv) {
   namespace s = fst::script;
+  using fst::script::FarReaderClass;
 
   std::string usage =
       "Print as std::string the std::string FSTs in an archive.\n\n  Usage:";
@@ -48,12 +50,11 @@ int farprintstrings_main(int argc, char **argv) {
   SET_FLAGS(usage.c_str(), &argc, &argv, true);
   s::ExpandArgs(argc, argv, &argc, &argv);
 
-  std::vector<std::string> in_sources;
-  for (int i = 1; i < argc; ++i) in_sources.push_back(argv[i]);
-  if (in_sources.empty()) in_sources.push_back("");
-
-  const auto arc_type = s::LoadArcTypeFromFar(in_sources[0]);
-  if (arc_type.empty()) return 1;
+  std::vector<std::string> sources;
+  for (int i = 1; i < argc; ++i) sources.push_back(argv[i]);
+  if (sources.empty()) sources.push_back("");
+  std::unique_ptr<FarReaderClass> reader(FarReaderClass::Open(sources));
+  if (!reader) return 1;
 
   fst::FarEntryType entry_type;
   if (!s::GetFarEntryType(FST_FLAGS_entry_type, &entry_type)) {
@@ -69,14 +70,19 @@ int farprintstrings_main(int argc, char **argv) {
     return 1;
   }
 
-  s::FarPrintStrings(
-      in_sources, arc_type, entry_type, token_type,
-      FST_FLAGS_begin_key, FST_FLAGS_end_key,
-      FST_FLAGS_print_key, FST_FLAGS_print_weight,
-      FST_FLAGS_symbols, FST_FLAGS_initial_symbols,
+  s::PrintStrings(
+      *reader, entry_type, token_type, FST_FLAGS_begin_key,
+      FST_FLAGS_end_key, FST_FLAGS_print_key,
+      FST_FLAGS_print_weight, FST_FLAGS_symbols,
+      FST_FLAGS_initial_symbols,
       FST_FLAGS_generate_filenames,
       FST_FLAGS_filename_prefix,
       FST_FLAGS_filename_suffix);
 
+  if (reader->Error()) {
+    FSTERROR() << "Error reading FAR(s)";
+    return 1;
+  }
+
   return 0;
 }
index 357326e..4114f02 100644 (file)
@@ -20,6 +20,9 @@
 
 #include <fst/extensions/far/farscript.h>
 
+#include <cstdint>
+#include <string>
+
 #include <fst/extensions/far/far.h>
 #include <fst/arc.h>
 #include <fst/script/script-impl.h>
 namespace fst {
 namespace script {
 
-void FarCompileStrings(const std::vector<std::string> &in_sources,
-                       const std::string &out_source,
-                       const std::string &arc_type, const std::string &fst_type,
-                       const FarType &far_type, int32 generate_keys,
-                       FarEntryType fet, TokenType tt,
-                       const std::string &symbols_source,
-                       const std::string &unknown_symbol, bool keep_symbols,
-                       bool initial_symbols, bool allow_negative_labels,
-                       const std::string &key_prefix,
-                       const std::string &key_suffix) {
-  FarCompileStringsArgs args{in_sources, out_source, fst_type, far_type,
-                             generate_keys, fet, tt, symbols_source,
-                             unknown_symbol, keep_symbols, initial_symbols,
-                             allow_negative_labels, key_prefix, key_suffix};
-  Apply<Operation<FarCompileStringsArgs>>("FarCompileStrings", arc_type, &args);
+void CompileStrings(const std::vector<std::string> &sources,
+                    FarWriterClass &writer, std::string_view fst_type,
+                    int32_t generate_keys, FarEntryType fet, TokenType tt,
+                    const std::string &symbols_source,
+                    const std::string &unknown_symbol, bool keep_symbols,
+                    bool initial_symbols, bool allow_negative_labels,
+                    const std::string &key_prefix,
+                    const std::string &key_suffix) {
+  FarCompileStringsArgs args{sources,
+                             writer,
+                             fst_type,
+                             generate_keys,
+                             fet,
+                             tt,
+                             symbols_source,
+                             unknown_symbol,
+                             keep_symbols,
+                             initial_symbols,
+                             allow_negative_labels,
+                             key_prefix,
+                             key_suffix};
+  Apply<Operation<FarCompileStringsArgs>>("CompileStrings", writer.ArcType(),
+                                          &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarCompileStrings, FarCompileStringsArgs);
+REGISTER_FST_OPERATION_4ARCS(CompileStrings, FarCompileStringsArgs);
 
-void FarConvert(const std::string &in_source, const std::string &out_source,
-                const std::string &arc_type, const std::string &fst_type,
-                const FarType &far_type) {
-  FarConvertArgs args{in_source, out_source, fst_type, far_type};
-  Apply<Operation<FarConvertArgs>>("FarConvert", arc_type, &args);
+void Convert(FarReaderClass &reader, FarWriterClass &writer,
+             std::string_view fst_type) {
+  FarConvertArgs args{reader, writer, fst_type};
+  Apply<Operation<FarConvertArgs>>("Convert", reader.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarConvert, FarConvertArgs);
+REGISTER_FST_OPERATION_4ARCS(Convert, FarConvertArgs);
 
-void FarCreate(const std::vector<std::string> &in_sources,
-               const std::string &out_source, const std::string &arc_type,
-               const int32 generate_keys, const FarType &far_type,
-               const std::string &key_prefix, const std::string &key_suffix) {
-  FarCreateArgs args{in_sources, out_source, generate_keys, far_type,
-                     key_prefix, key_suffix};
-  Apply<Operation<FarCreateArgs>>("FarCreate", arc_type, &args);
+void Create(const std::vector<std::string> &sources, FarWriterClass &writer,
+            const int32_t generate_keys, const std::string &key_prefix,
+            const std::string &key_suffix) {
+  FarCreateArgs args{sources, writer, generate_keys, key_prefix, key_suffix};
+  Apply<Operation<FarCreateArgs>>("Create", writer.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarCreate, FarCreateArgs);
+REGISTER_FST_OPERATION_4ARCS(Create, FarCreateArgs);
+
+void Decode(FarReaderClass &reader, FarWriterClass &writer,
+            const EncodeMapperClass &encoder) {
+  if (!internal::ArcTypesMatch(reader, encoder, "Decode") ||
+      !internal::ArcTypesMatch(writer, encoder, "Decode")) {
+    return;
+  }
+  FarDecodeArgs args{reader, writer, encoder};
+  Apply<Operation<FarDecodeArgs>>("Decode", reader.ArcType(), &args);
+}
 
-bool FarEqual(const std::string &source1, const std::string &source2,
-              const std::string &arc_type, float delta,
-              const std::string &begin_key, const std::string &end_key) {
-  FarEqualInnerArgs args{source1, source2, delta, begin_key, end_key};
+REGISTER_FST_OPERATION_4ARCS(Decode, FarDecodeArgs);
+
+void Encode(FarReaderClass &reader, FarWriterClass &writer,
+            EncodeMapperClass *encoder) {
+  if (!internal::ArcTypesMatch(reader, *encoder, "Encode") ||
+      !internal::ArcTypesMatch(writer, *encoder, "Encode")) {
+    return;
+  }
+  FarEncodeArgs args{reader, writer, encoder};
+  Apply<Operation<FarEncodeArgs>>("Encode", reader.ArcType(), &args);
+}
+
+REGISTER_FST_OPERATION_4ARCS(Encode, FarEncodeArgs);
+
+bool Equal(FarReaderClass &reader1, FarReaderClass &reader2, float delta,
+           std::string_view begin_key, std::string_view end_key) {
+  if (!internal::ArcTypesMatch(reader1, reader2, "Equal")) return false;
+  FarEqualInnerArgs args{reader1, reader2, delta, begin_key, end_key};
   FarEqualArgs args_with_retval(args);
-  Apply<Operation<FarEqualArgs>>("FarEqual", arc_type, &args_with_retval);
+  Apply<Operation<FarEqualArgs>>("Equal", reader1.ArcType(), &args_with_retval);
   return args_with_retval.retval;
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarEqual, FarEqualArgs);
-
-void FarExtract(const std::vector<std::string> &isources,
-                const std::string &arc_type, int32 generate_sources,
-                const std::string &keys, const std::string &key_separator,
-                const std::string &range_delimiter,
-                const std::string &source_prefix,
-                const std::string &source_suffix) {
-  FarExtractArgs args{isources, generate_sources, keys, key_separator,
-                      range_delimiter, source_prefix, source_suffix};
-  Apply<Operation<FarExtractArgs>>("FarExtract", arc_type, &args);
+REGISTER_FST_OPERATION_4ARCS(Equal, FarEqualArgs);
+
+void Extract(FarReaderClass &reader, int32_t generate_sources,
+             const std::string &keys, const std::string &key_separator,
+             const std::string &range_delimiter,
+             const std::string &source_prefix,
+             const std::string &source_suffix) {
+  FarExtractArgs args{reader,        generate_sources, keys,
+                      key_separator, range_delimiter,  source_prefix,
+                      source_suffix};
+  Apply<Operation<FarExtractArgs>>("Extract", reader.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarExtract, FarExtractArgs);
+REGISTER_FST_OPERATION_4ARCS(Extract, FarExtractArgs);
 
-void FarInfo(const std::vector<std::string> &sources,
+void GetInfo(const std::vector<std::string> &sources,
              const std::string &arc_type, const std::string &begin_key,
-             const std::string &end_key, bool list_fsts) {
-  FarInfoArgs args{sources, begin_key, end_key, list_fsts};
-  Apply<Operation<FarInfoArgs>>("FarInfo", arc_type, &args);
+             const std::string &end_key, bool list_fsts, FarInfoData *data) {
+  FarGetInfoArgs args{sources, begin_key, end_key, list_fsts, data};
+  Apply<Operation<FarGetInfoArgs>>("GetInfo", arc_type, &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarInfo, FarInfoArgs);
+REGISTER_FST_OPERATION_4ARCS(GetInfo, FarGetInfoArgs);
 
-void GetFarInfo(const std::vector<std::string> &sources,
-                const std::string &arc_type, const std::string &begin_key,
-                const std::string &end_key, bool list_fsts, FarInfoData *data) {
-  GetFarInfoArgs args{sources, begin_key, end_key, list_fsts, data};
-  Apply<Operation<GetFarInfoArgs>>("GetFarInfo", arc_type, &args);
+void Info(const std::vector<std::string> &sources, const std::string &arc_type,
+          const std::string &begin_key, const std::string &end_key,
+          bool list_fsts) {
+  FarInfoArgs args{sources, begin_key, end_key, list_fsts};
+  Apply<Operation<FarInfoArgs>>("Info", arc_type, &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(GetFarInfo, GetFarInfoArgs);
+REGISTER_FST_OPERATION_4ARCS(Info, FarInfoArgs);
 
-bool FarIsomorphic(const std::string &source1, const std::string &source2,
-                   const std::string &arc_type, float delta,
-                   const std::string &begin_key, const std::string &end_key) {
-  FarIsomorphicInnerArgs args{source1, source2, delta, begin_key, end_key};
+bool Isomorphic(FarReaderClass &reader1, FarReaderClass &reader2, float delta,
+                std::string_view begin_key, std::string_view end_key) {
+  if (!internal::ArcTypesMatch(reader1, reader2, "Equal")) return false;
+  FarIsomorphicInnerArgs args{reader1, reader2, delta, begin_key, end_key};
   FarIsomorphicArgs args_with_retval(args);
-  Apply<Operation<FarIsomorphicArgs>>("FarIsomorphic", arc_type,
+  Apply<Operation<FarIsomorphicArgs>>("Isomorphic", reader1.ArcType(),
                                       &args_with_retval);
   return args_with_retval.retval;
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarIsomorphic, FarIsomorphicArgs);
-
-void FarPrintStrings(const std::vector<std::string> &isources,
-                     const std::string &arc_type, const FarEntryType entry_type,
-                     const TokenType token_type, const std::string &begin_key,
-                     const std::string &end_key, bool print_key,
-                     bool print_weight, const std::string &symbols_source,
-                     bool initial_symbols, const int32 generate_sources,
-                     const std::string &source_prefix,
-                     const std::string &source_suffix) {
-  FarPrintStringsArgs args{isources, entry_type, token_type, begin_key, end_key,
-                           print_key, print_weight, symbols_source,
-                           initial_symbols, generate_sources, source_prefix,
-                           source_suffix};
-  Apply<Operation<FarPrintStringsArgs>>("FarPrintStrings", arc_type, &args);
+REGISTER_FST_OPERATION_4ARCS(Isomorphic, FarIsomorphicArgs);
+
+void PrintStrings(FarReaderClass &reader, const FarEntryType entry_type,
+                  const TokenType token_type, const std::string &begin_key,
+                  const std::string &end_key, bool print_key, bool print_weight,
+                  const std::string &symbols_source, bool initial_symbols,
+                  const int32_t generate_sources,
+                  const std::string &source_prefix,
+                  const std::string &source_suffix) {
+  FarPrintStringsArgs args{reader,           entry_type,     token_type,
+                           begin_key,        end_key,        print_key,
+                           print_weight,     symbols_source, initial_symbols,
+                           generate_sources, source_prefix,  source_suffix};
+  Apply<Operation<FarPrintStringsArgs>>("PrintStrings", reader.ArcType(),
+                                        &args);
 }
 
-REGISTER_FST_OPERATION_4ARCS(FarPrintStrings, FarPrintStringsArgs);
+REGISTER_FST_OPERATION_4ARCS(PrintStrings, FarPrintStringsArgs);
 
 }  // namespace script
 }  // namespace fst
index 5307e72..4abba89 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <fst/extensions/far/getters.h>
 
+#include <cstdint>
 #include <string>
 #include <vector>
 
@@ -30,7 +31,7 @@ namespace fst {
 
 namespace script {
 
-bool GetFarType(const std::string &str, FarType *far_type) {
+bool GetFarType(std::string_view str, FarType *far_type) {
   if (str == "fst") {
     *far_type = FarType::FST;
   } else if (str == "stlist") {
@@ -45,7 +46,7 @@ bool GetFarType(const std::string &str, FarType *far_type) {
   return true;
 }
 
-bool GetFarEntryType(const std::string &str, FarEntryType *entry_type) {
+bool GetFarEntryType(std::string_view str, FarEntryType *entry_type) {
   if (str == "line") {
     *entry_type = FarEntryType::LINE;
   } else if (str == "file") {
index 56ba669..6f2e169 100644 (file)
@@ -17,7 +17,9 @@
 
 #include <fst/extensions/far/stlist.h>
 
+#include <cstdint>
 #include <ios>
+#include <string>
 
 #include <fstream>
 
@@ -26,7 +28,7 @@ namespace fst {
 bool IsSTList(const std::string &source) {
   std::ifstream strm(source, std::ios_base::in | std::ios_base::binary);
   if (!strm) return false;
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
   return magic_number == kSTListMagicNumber;
 }
index 24e8fdc..3422154 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <fst/extensions/far/sttable.h>
 
+#include <cstdint>
+#include <string>
+
 #include <fstream>
 
 namespace fst {
@@ -25,7 +28,7 @@ bool IsSTTable(const std::string &source) {
   std::ifstream strm(source);
   if (!strm.good()) return false;
 
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
   return magic_number == kSTTableMagicNumber;
 }
index 6e0cb85..2e7d50a 100644 (file)
@@ -15,7 +15,7 @@ if HAVE_SCRIPT
 lib_LTLIBRARIES = libfstlinearscript.la
 
 libfstlinearscript_la_SOURCES = linearscript.cc
-libfstlinearscript_la_LDFLAGS = -version-info 24:0:0
+libfstlinearscript_la_LDFLAGS = -version-info 25:0:0
 libfstlinearscript_la_LIBADD = ../../script/libfstscript.la
 endif
 
index 1ad15c2..3f5ecca 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -101,8 +101,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \
@@ -248,8 +247,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -263,8 +260,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -280,6 +278,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -396,7 +395,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS)
 @HAVE_BIN_TRUE@fstloglinearapply_LDADD = libfstlinearscript.la ../../script/libfstscript.la
 @HAVE_SCRIPT_TRUE@lib_LTLIBRARIES = libfstlinearscript.la
 @HAVE_SCRIPT_TRUE@libfstlinearscript_la_SOURCES = linearscript.cc
-@HAVE_SCRIPT_TRUE@libfstlinearscript_la_LDFLAGS = -version-info 24:0:0
+@HAVE_SCRIPT_TRUE@libfstlinearscript_la_LDFLAGS = -version-info 25:0:0
 @HAVE_SCRIPT_TRUE@libfstlinearscript_la_LIBADD = ../../script/libfstscript.la
 libfst_LTLIBRARIES = linear_tagger-fst.la linear_classifier-fst.la
 linear_tagger_fst_la_SOURCES = linear-tagger-fst.cc
@@ -674,7 +673,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -713,6 +711,8 @@ check: check-am
 all-am: Makefile $(PROGRAMS) $(LTLIBRARIES)
 install-binPROGRAMS: install-libLTLIBRARIES
 
+install-libfstLTLIBRARIES: install-libLTLIBRARIES
+
 installdirs:
        for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfstdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
index 6de6f22..1d6f3a0 100644 (file)
@@ -15,6 +15,8 @@
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
+#include <string>
+
 #include <fst/flags.h>
 #include <fst/log.h>
 #include <fst/extensions/linear/linear-fst.h>
index 98cf63d..141a2f2 100644 (file)
@@ -21,6 +21,7 @@
 #include <cctype>
 #include <cstdio>
 #include <set>
+#include <string>
 
 #include <fst/flags.h>
 #include <fst/arc.h>
index 6c9b6b8..d741ced 100644 (file)
@@ -9,7 +9,7 @@ lib_LTLIBRARIES = libfstlookahead.la
 
 libfstlookahead_la_SOURCES = arc_lookahead-fst.cc ilabel_lookahead-fst.cc \
                              olabel_lookahead-fst.cc
-libfstlookahead_la_LDFLAGS = -version-info 24:0:0
+libfstlookahead_la_LDFLAGS = -version-info 25:0:0
 
 arc_lookahead_fst_la_SOURCES = arc_lookahead-fst.cc
 arc_lookahead_fst_la_LDFLAGS = -avoid-version -module
index 3b53a40..dcdfa43 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -98,8 +98,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -233,8 +232,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -248,8 +245,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -265,6 +263,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -382,7 +381,7 @@ lib_LTLIBRARIES = libfstlookahead.la
 libfstlookahead_la_SOURCES = arc_lookahead-fst.cc ilabel_lookahead-fst.cc \
                              olabel_lookahead-fst.cc
 
-libfstlookahead_la_LDFLAGS = -version-info 24:0:0
+libfstlookahead_la_LDFLAGS = -version-info 25:0:0
 arc_lookahead_fst_la_SOURCES = arc_lookahead-fst.cc
 arc_lookahead_fst_la_LDFLAGS = -avoid-version -module
 ilabel_lookahead_fst_la_SOURCES = ilabel_lookahead-fst.cc
@@ -602,7 +601,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -639,6 +637,8 @@ distdir-am: $(DISTFILES)
 check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES)
+install-libfstLTLIBRARIES: install-libLTLIBRARIES
+
 installdirs:
        for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfstdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
index 40934d0..48af38e 100644 (file)
@@ -20,7 +20,7 @@ endif
 if HAVE_SCRIPT
 lib_LTLIBRARIES = libfstmpdtscript.la
 libfstmpdtscript_la_SOURCES = mpdtscript.cc
-libfstmpdtscript_la_LDFLAGS = -version-info 24:0:0
+libfstmpdtscript_la_LDFLAGS = -version-info 25:0:0
 libfstmpdtscript_la_LIBADD = ../../script/libfstscript.la \
                              ../../lib/libfst.la -lm $(DL_LIBS)
 endif
index 1bc3fc9..bf3a0d0 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -101,8 +101,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)"
@@ -254,8 +253,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -269,8 +266,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -286,6 +284,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -407,7 +406,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS)
 @HAVE_BIN_TRUE@mpdtreverse_SOURCES = mpdtreverse.cc mpdtreverse-main.cc
 @HAVE_SCRIPT_TRUE@lib_LTLIBRARIES = libfstmpdtscript.la
 @HAVE_SCRIPT_TRUE@libfstmpdtscript_la_SOURCES = mpdtscript.cc
-@HAVE_SCRIPT_TRUE@libfstmpdtscript_la_LDFLAGS = -version-info 24:0:0
+@HAVE_SCRIPT_TRUE@libfstmpdtscript_la_LDFLAGS = -version-info 25:0:0
 @HAVE_SCRIPT_TRUE@libfstmpdtscript_la_LIBADD = ../../script/libfstscript.la \
 @HAVE_SCRIPT_TRUE@                             ../../lib/libfst.la -lm $(DL_LIBS)
 
@@ -651,7 +650,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 3931101..662cd46 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Composes an MPDT and an FST.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/mpdt/mpdtscript.h>
 #include <fst/extensions/mpdt/read_write_utils.h>
@@ -76,8 +76,8 @@ int mpdtcompose_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
-  std::vector<int64> assignments;
+  std::vector<std::pair<int64_t, int64_t>> parens;
+  std::vector<int64_t> assignments;
   if (!ReadLabelTriples(FST_FLAGS_mpdt_parentheses, &parens,
                         &assignments, false)) {
     return 1;
@@ -95,8 +95,8 @@ int mpdtcompose_main(int argc, char **argv) {
 
   const MPdtComposeOptions opts(FST_FLAGS_connect, compose_filter);
 
-  s::MPdtCompose(*ifst1, *ifst2, parens, assignments, &ofst, opts,
-                 FST_FLAGS_left_mpdt);
+  s::Compose(*ifst1, *ifst2, parens, assignments, &ofst, opts,
+             FST_FLAGS_left_mpdt);
 
   return !ofst.Write(out_name);
 }
index 999bce1..eb9b677 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Expands a (bounded-stack) MPDT as an FST.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/mpdt/mpdtscript.h>
 #include <fst/extensions/mpdt/read_write_utils.h>
@@ -65,8 +65,8 @@ int mpdtexpand_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
-  std::vector<int64> assignments;
+  std::vector<std::pair<int64_t, int64_t>> parens;
+  std::vector<int64_t> assignments;
   if (!ReadLabelTriples(FST_FLAGS_mpdt_parentheses, &parens,
                         &assignments, false)) {
     return 1;
@@ -77,7 +77,7 @@ int mpdtexpand_main(int argc, char **argv) {
   const MPdtExpandOptions opts(FST_FLAGS_connect,
                                FST_FLAGS_keep_parentheses);
 
-  s::MPdtExpand(*ifst, parens, assignments, &ofst, opts);
+  s::Expand(*ifst, parens, assignments, &ofst, opts);
 
   return !ofst.Write(out_name);
 }
index c316b23..cfbcd55 100644 (file)
@@ -18,6 +18,7 @@
 // Prints out various information about an MPDT such as number of states, arcs,
 // and parentheses.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -25,7 +26,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/mpdt/mpdtscript.h>
 #include <fst/extensions/mpdt/read_write_utils.h>
@@ -60,14 +60,14 @@ int mpdtinfo_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
-  std::vector<int64> assignments;
+  std::vector<std::pair<int64_t, int64_t>> parens;
+  std::vector<int64_t> assignments;
   if (!ReadLabelTriples(FST_FLAGS_mpdt_parentheses, &parens,
                         &assignments, false)) {
     return 1;
   }
 
-  s::PrintMPdtInfo(*ifst, parens, assignments);
+  s::Info(*ifst, parens, assignments);
 
   return 0;
 }
index f0931da..bdc241c 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Reverses an MPDT.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/mpdt/mpdtscript.h>
 #include <fst/extensions/mpdt/read_write_utils.h>
@@ -69,8 +69,8 @@ int mpdtreverse_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
-  std::vector<int64> assignments;
+  std::vector<std::pair<int64_t, int64_t>> parens;
+  std::vector<int64_t> assignments;
   if (!ReadLabelTriples(FST_FLAGS_mpdt_parentheses, &parens,
                         &assignments, false)) {
     return 1;
@@ -78,7 +78,7 @@ int mpdtreverse_main(int argc, char **argv) {
 
   VectorFstClass ofst(ifst->ArcType());
 
-  s::MPdtReverse(*ifst, parens, &assignments, &ofst);
+  s::Reverse(*ifst, parens, &assignments, &ofst);
 
   if (!ofst.Write(out_name)) return 1;
 
index 56a229e..2bc06e1 100644 (file)
 
 #include <fst/extensions/mpdt/mpdtscript.h>
 
+#include <cstdint>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/extensions/mpdt/compose.h>
 #include <fst/extensions/mpdt/expand.h>
 #include <fst/extensions/mpdt/reverse.h>
 namespace fst {
 namespace script {
 
-void MPdtCompose(const FstClass &ifst1, const FstClass &ifst2,
-                 const std::vector<std::pair<int64, int64>> &parens,
-                 const std::vector<int64> &assignments, MutableFstClass *ofst,
-                 const MPdtComposeOptions &copts, bool left_pdt) {
-  if (!internal::ArcTypesMatch(ifst1, ifst2, "MPdtCompose") ||
-      !internal::ArcTypesMatch(ifst1, *ofst, "MPdtCompose"))
+void Compose(const FstClass &ifst1, const FstClass &ifst2,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             const std::vector<int64_t> &assignments, MutableFstClass *ofst,
+             const MPdtComposeOptions &copts, bool left_pdt) {
+  if (!internal::ArcTypesMatch(ifst1, ifst2, "Compose") ||
+      !internal::ArcTypesMatch(ifst1, *ofst, "Compose"))
     return;
-  MPdtComposeArgs args(ifst1, ifst2, parens, assignments, ofst, copts,
-                       left_pdt);
-  Apply<Operation<MPdtComposeArgs>>("MPdtCompose", ifst1.ArcType(), &args);
+  MPdtComposeArgs args{ifst1, ifst2, parens,  assignments,
+                       ofst,  copts, left_pdt};
+  Apply<Operation<MPdtComposeArgs>>("Compose", ifst1.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(MPdtCompose, MPdtComposeArgs);
+REGISTER_FST_OPERATION_3ARCS(Compose, MPdtComposeArgs);
 
-void MPdtExpand(const FstClass &ifst,
-                const std::vector<std::pair<int64, int64>> &parens,
-                const std::vector<int64> &assignments, MutableFstClass *ofst,
-                const MPdtExpandOptions &opts) {
-  MPdtExpandArgs args(ifst, parens, assignments, ofst, opts);
-  Apply<Operation<MPdtExpandArgs>>("MPdtExpand", ifst.ArcType(), &args);
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            const std::vector<int64_t> &assignments, MutableFstClass *ofst,
+            const MPdtExpandOptions &opts) {
+  MPdtExpandArgs args{ifst, parens, assignments, ofst, opts};
+  Apply<Operation<MPdtExpandArgs>>("Expand", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(MPdtExpand, MPdtExpandArgs);
+REGISTER_FST_OPERATION_3ARCS(Expand, MPdtExpandArgs);
 
-void MPdtExpand(const FstClass &ifst,
-                const std::vector<std::pair<int64, int64>> &parens,
-                const std::vector<int64> &assignments, MutableFstClass *ofst,
-                bool connect) {
-  MPdtExpand(ifst, parens, assignments, ofst, MPdtExpandOptions(connect));
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            const std::vector<int64_t> &assignments, MutableFstClass *ofst,
+            bool connect) {
+  Expand(ifst, parens, assignments, ofst, MPdtExpandOptions(connect));
 }
 
-void MPdtReverse(const FstClass &ifst,
-                 const std::vector<std::pair<int64, int64>> &parens,
-                 std::vector<int64> *assignments, MutableFstClass *ofst) {
-  MPdtReverseArgs args(ifst, parens, assignments, ofst);
-  Apply<Operation<MPdtReverseArgs>>("MPdtReverse", ifst.ArcType(), &args);
+void Reverse(const FstClass &ifst,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             std::vector<int64_t> *assignments, MutableFstClass *ofst) {
+  MPdtReverseArgs args{ifst, parens, assignments, ofst};
+  Apply<Operation<MPdtReverseArgs>>("Reverse", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(MPdtReverse, MPdtReverseArgs);
+REGISTER_FST_OPERATION_3ARCS(Reverse, MPdtReverseArgs);
 
-void PrintMPdtInfo(const FstClass &ifst,
-                   const std::vector<std::pair<int64, int64>> &parens,
-                   const std::vector<int64> &assignments) {
-  PrintMPdtInfoArgs args(ifst, parens, assignments);
-  Apply<Operation<PrintMPdtInfoArgs>>("PrintMPdtInfo", ifst.ArcType(), &args);
+void Info(const FstClass &ifst,
+          const std::vector<std::pair<int64_t, int64_t>> &parens,
+          const std::vector<int64_t> &assignments) {
+  MPdtInfoArgs args{ifst, parens, assignments};
+  Apply<Operation<MPdtInfoArgs>>("Info", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PrintMPdtInfo, PrintMPdtInfoArgs);
+REGISTER_FST_OPERATION_3ARCS(Info, MPdtInfoArgs);
 
 }  // namespace script
 }  // namespace fst
index 7d438c5..67713ff 100644 (file)
@@ -10,4 +10,4 @@ ngram_fst_la_SOURCES = bitmap-index.cc ngram-fst.cc nthbit.cc
 ngram_fst_la_LDFLAGS = -avoid-version -module
 
 libfstngram_la_SOURCES = bitmap-index.cc ngram-fst.cc nthbit.cc
-libfstngram_la_LDFLAGS = -version-info 24:0:0
+libfstngram_la_LDFLAGS = -version-info 25:0:0
index 03497eb..44e41a6 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -98,8 +98,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -208,8 +207,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -223,8 +220,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -240,6 +238,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -355,7 +354,7 @@ lib_LTLIBRARIES = libfstngram.la
 ngram_fst_la_SOURCES = bitmap-index.cc ngram-fst.cc nthbit.cc
 ngram_fst_la_LDFLAGS = -avoid-version -module
 libfstngram_la_SOURCES = bitmap-index.cc ngram-fst.cc nthbit.cc
-libfstngram_la_LDFLAGS = -version-info 24:0:0
+libfstngram_la_LDFLAGS = -version-info 25:0:0
 all: all-am
 
 .SUFFIXES:
@@ -563,7 +562,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -600,6 +598,8 @@ distdir-am: $(DISTFILES)
 check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES)
+install-libfstLTLIBRARIES: install-libLTLIBRARIES
+
 installdirs:
        for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfstdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
index f1a139d..2d11dc5 100644 (file)
 #include <fst/extensions/ngram/bitmap-index.h>
 
 #include <algorithm>
+#include <cstdint>
 #include <iterator>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/ngram/nthbit.h>
 
 namespace fst {
 
-static_assert(sizeof(long long) >= sizeof(uint64),  // NOLINT
-              "__builtin_...ll is used on uint64 values.");
+static_assert(sizeof(long long) >= sizeof(uint64_t),  // NOLINT
+              "__builtin_...ll is used on uint64_t values.");
 
 size_t BitmapIndex::Rank1(size_t end) const {
   DCHECK_LE(end, Bits());
@@ -36,26 +36,26 @@ size_t BitmapIndex::Rank1(size_t end) const {
   // Without this special case, we'd go past the end. It's questionable
   // whether we should support end == Bits().
   if (end >= num_bits_) return GetOnesCount();
-  const uint32 end_word = end / kStorageBitSize;
-  const uint32 sum = GetIndexOnesCount(end_word);
+  const uint32_t end_word = end / kStorageBitSize;
+  const uint32_t sum = GetIndexOnesCount(end_word);
   const int bit_index = end % kStorageBitSize;
   // TODO(jrosenstock): better with or without special case, and does
   // this depend on whether there's a popcnt instruction?
   if (bit_index == 0) return sum;  // Entire answer is in the index.
-  const uint64 mask = (uint64{1} << bit_index) - 1;
+  const uint64_t mask = (uint64_t{1} << bit_index) - 1;
   return sum + __builtin_popcountll(bits_[end_word] & mask);
 }
 
 size_t BitmapIndex::Select1(size_t bit_index) const {
   if (bit_index >= GetOnesCount()) return Bits();
   const RankIndexEntry& entry = FindRankIndexEntry(bit_index);
-  const uint32 block_index = &entry - rank_index_.data();
+  const uint32_t block_index = &entry - rank_index_.data();
   // TODO(jrosenstock): Look at whether word or bit indices are faster.
   static_assert(kUnitsPerRankIndexEntry == 8);
-  uint32 word_index = block_index * kUnitsPerRankIndexEntry;
+  uint32_t word_index = block_index * kUnitsPerRankIndexEntry;
 
   // Find position within this block.
-  uint32 rembits = bit_index - entry.absolute_ones_count();
+  uint32_t rembits = bit_index - entry.absolute_ones_count();
   if (rembits < entry.relative_ones_count_4()) {
     if (rembits < entry.relative_ones_count_2()) {
       if (rembits < entry.relative_ones_count_1()) {
@@ -92,17 +92,17 @@ size_t BitmapIndex::Select1(size_t bit_index) const {
 }
 
 size_t BitmapIndex::Select0(size_t bit_index) const {
-  const uint32 zeros_count = Bits() - GetOnesCount();
+  const uint32_t zeros_count = Bits() - GetOnesCount();
   if (bit_index >= zeros_count) return Bits();
   const RankIndexEntry& entry = FindInvertedRankIndexEntry(bit_index);
-  const uint32 block_index = &entry - rank_index_.data();
+  const uint32_t block_index = &entry - rank_index_.data();
   static_assert(kUnitsPerRankIndexEntry == 8);
-  uint32 word_index = block_index * kUnitsPerRankIndexEntry;
+  uint32_t word_index = block_index * kUnitsPerRankIndexEntry;
 
   // Find position within this block.
-  uint32 entry_zeros_count =
+  uint32_t entry_zeros_count =
       kStorageBitSize * word_index - entry.absolute_ones_count();
-  uint32 remzeros = bit_index - entry_zeros_count;
+  uint32_t remzeros = bit_index - entry_zeros_count;
   if (remzeros < 4 * kStorageBitSize - entry.relative_ones_count_4()) {
     if (remzeros < 2 * kStorageBitSize - entry.relative_ones_count_2()) {
       if (remzeros < kStorageBitSize - entry.relative_ones_count_1()) {
@@ -139,18 +139,18 @@ size_t BitmapIndex::Select0(size_t bit_index) const {
 }
 
 std::pair<size_t, size_t> BitmapIndex::Select0s(size_t bit_index) const {
-  const uint32 zeros_count = Bits() - GetOnesCount();
+  const uint32_t zeros_count = Bits() - GetOnesCount();
   if (bit_index >= zeros_count) return {Bits(), Bits()};
   if (bit_index + 1 >= zeros_count) return {Select0(bit_index), Bits()};
 
   const RankIndexEntry& entry = FindInvertedRankIndexEntry(bit_index);
-  const uint32 block_index = &entry - rank_index_.data();
-  uint32 word_index = block_index * kUnitsPerRankIndexEntry;
+  const uint32_t block_index = &entry - rank_index_.data();
+  uint32_t word_index = block_index * kUnitsPerRankIndexEntry;
 
   // Find position within this block.
-  uint32 entry_zeros_count =
+  uint32_t entry_zeros_count =
       kStorageBitSize * word_index - entry.absolute_ones_count();
-  uint32 remzeros = bit_index - entry_zeros_count;
+  uint32_t remzeros = bit_index - entry_zeros_count;
   if (remzeros < 4 * kStorageBitSize - entry.relative_ones_count_4()) {
     if (remzeros < 2 * kStorageBitSize - entry.relative_ones_count_2()) {
       if (remzeros < kStorageBitSize - entry.relative_ones_count_1()) {
@@ -183,7 +183,7 @@ std::pair<size_t, size_t> BitmapIndex::Select0s(size_t bit_index) const {
   }
 
   // Find the position of the bit_index-th zero.
-  const uint64 inv_word = ~bits_[word_index];
+  const uint64_t inv_word = ~bits_[word_index];
   const int nth = nth_bit(inv_word, remzeros);
 
   // Then, we want to "1-out" everything below that position, and count trailing
@@ -195,8 +195,8 @@ std::pair<size_t, size_t> BitmapIndex::Select0s(size_t bit_index) const {
   // (1 << (nth + 1)) - 1, but doesn't need a special case when nth == 63.
   // We want ~0 in this case anyway. We want nth+1 because if the bit_index-th
   // zero is in position nth, we need to skip nth+1 positions.
-  const uint64 mask = -(uint64{0x2} << nth);  // == ~((2 << nth) - 1)
-  const uint64 masked_inv_word = inv_word & mask;
+  const uint64_t mask = -(uint64_t{0x2} << nth);  // == ~((2 << nth) - 1)
+  const uint64_t masked_inv_word = inv_word & mask;
 
   // If this is 0, then the next zero is not in the same word.
   if (masked_inv_word != 0) {
@@ -212,10 +212,10 @@ std::pair<size_t, size_t> BitmapIndex::Select0s(size_t bit_index) const {
   }
 }
 
-uint32 BitmapIndex::GetIndexOnesCount(size_t array_index) const {
+uint32_t BitmapIndex::GetIndexOnesCount(size_t array_index) const {
   const auto& rank_index_entry =
       rank_index_[array_index / kUnitsPerRankIndexEntry];
-  uint32 ones_count = rank_index_entry.absolute_ones_count();
+  uint32_t ones_count = rank_index_entry.absolute_ones_count();
   static_assert(kUnitsPerRankIndexEntry == 8);
   switch (array_index % kUnitsPerRankIndexEntry) {
     case 1:
@@ -243,13 +243,13 @@ uint32 BitmapIndex::GetIndexOnesCount(size_t array_index) const {
   return ones_count;
 }
 
-void BitmapIndex::BuildIndex(const uint64* bits, size_t num_bits,
+void BitmapIndex::BuildIndex(const uint64_t* bits, size_t num_bits,
                              bool enable_select_0_index,
                              bool enable_select_1_index) {
   // Absolute counts are uint32s, so this is the most *set* bits we support
   // for now. Just check the number of *input* bits is less than this
   // to keep things simple.
-  DCHECK_LT(num_bits, uint64{1} << 32);
+  DCHECK_LT(num_bits, uint64_t{1} << 32);
   bits_ = bits;
   num_bits_ = num_bits;
   rank_index_.resize(rank_index_size());
@@ -265,9 +265,9 @@ void BitmapIndex::BuildIndex(const uint64* bits, size_t num_bits,
     select_1_index_.reserve(num_bits / (2 * kBitsPerSelect1Block) + 1);
   }
 
-  uint32 ones_count = 0;
-  uint32 zeros_count = 0;  // Only updated if enable_select_0_index.
-  for (uint32 word_index = 0; word_index < ArraySize(); ++word_index) {
+  uint32_t ones_count = 0;
+  uint32_t zeros_count = 0;  // Only updated if enable_select_0_index.
+  for (uint32_t word_index = 0; word_index < ArraySize(); ++word_index) {
     auto& rank_index_entry = rank_index_[word_index / kUnitsPerRankIndexEntry];
     static_assert(kUnitsPerRankIndexEntry == 8);
     switch (word_index % kUnitsPerRankIndexEntry) {
@@ -305,16 +305,16 @@ void BitmapIndex::BuildIndex(const uint64* bits, size_t num_bits,
     }
 
     // We can assume that the last word has zeros in the high bits.
-    const uint64 word = bits[word_index];
+    const uint64_t word = bits[word_index];
     const int word_ones_count = __builtin_popcountll(word);
-    const uint32 bit_offset = kStorageBitSize * word_index;
+    const uint32_t bit_offset = kStorageBitSize * word_index;
 
     if (enable_select_0_index) {
       // Zeros count is somewhat move involved to compute, so only do it
       // if we need it. The last word has zeros in the high bits, so
       // that needs to be accounted for when computing the zeros count
       // from the ones count.
-      const uint32 bits_remaining = num_bits - bit_offset;
+      const uint32_t bits_remaining = num_bits - bit_offset;
       const int word_zeros_count =
           std::min(bits_remaining, kStorageBitSize) - word_ones_count;
 
@@ -323,7 +323,7 @@ void BitmapIndex::BuildIndex(const uint64* bits, size_t num_bits,
       // zeros_count is 1 mod kBitsPerSelect0Block, we need to skip
       // kBitsPerSelect0Block - 1 zeros, then record a zero. And so on.
       // What function is this?  It's -zeros_count % kBitsPerSelect0Block.
-      const uint32 zeros_to_skip = -zeros_count % kBitsPerSelect0Block;
+      const uint32_t zeros_to_skip = -zeros_count % kBitsPerSelect0Block;
       if (word_zeros_count > zeros_to_skip) {
         const int nth = nth_bit(~word, zeros_to_skip);
         select_0_index_.push_back(bit_offset + nth);
@@ -333,7 +333,7 @@ void BitmapIndex::BuildIndex(const uint64* bits, size_t num_bits,
     }
 
     if (enable_select_1_index) {
-      const uint32 ones_to_skip = -ones_count % kBitsPerSelect1Block;
+      const uint32_t ones_to_skip = -ones_count % kBitsPerSelect1Block;
       if (word_ones_count > ones_to_skip) {
         const int nth = nth_bit(word, ones_to_skip);
         select_1_index_.push_back(bit_offset + nth);
@@ -407,7 +407,7 @@ const BitmapIndex::RankIndexEntry& BitmapIndex::FindRankIndexEntry(
     begin = &rank_index_[0];
     end = begin + rank_index_.size();
   } else {
-    const uint32 select_index = bit_index / kBitsPerSelect1Block;
+    const uint32_t select_index = bit_index / kBitsPerSelect1Block;
     DCHECK_LT(select_index + 1, select_1_index_.size());
 
     // TODO(jrosenstock): It would be nice to handle the exact hit
@@ -417,8 +417,8 @@ const BitmapIndex::RankIndexEntry& BitmapIndex::FindRankIndexEntry(
     // or out param, etc.
 
     // The bit is between these indices.
-    const uint32 lo_bit_index = select_1_index_[select_index];
-    const uint32 hi_bit_index = select_1_index_[select_index + 1];
+    const uint32_t lo_bit_index = select_1_index_[select_index];
+    const uint32_t hi_bit_index = select_1_index_[select_index + 1];
 
     begin = &rank_index_[lo_bit_index / kBitsPerSelect1Block];
     end = &rank_index_[(hi_bit_index + kBitsPerSelect1Block - 1) /
@@ -453,12 +453,12 @@ const BitmapIndex::RankIndexEntry& BitmapIndex::FindInvertedRankIndexEntry(
   DCHECK_GE(bit_index, 0);
   DCHECK_LT(bit_index, num_bits_ - rank_index_.back().absolute_ones_count());
 
-  uint32 lo = 0, hi = 0;
+  uint32_t lo = 0, hi = 0;
   if (select_0_index_.empty()) {
     lo = 0;
     hi = (num_bits_ + kBitsPerRankIndexEntry - 1) / kBitsPerRankIndexEntry;
   } else {
-    const uint32 select_index = bit_index / kBitsPerSelect0Block;
+    const uint32_t select_index = bit_index / kBitsPerSelect0Block;
     DCHECK_LT(select_index + 1, select_0_index_.size());
 
     // TODO(jrosenstock): Same special case for exact hit.
@@ -474,7 +474,7 @@ const BitmapIndex::RankIndexEntry& BitmapIndex::FindInvertedRankIndexEntry(
   // or because the ranges are larger, so linear search is triggered less often,
   // and the difference is harder to measure.
   while (lo + 1 < hi) {
-    const uint32 mid = lo + (hi - lo) / 2;
+    const uint32_t mid = lo + (hi - lo) / 2;
     if (bit_index <
         kBitsPerRankIndexEntry * mid - rank_index_[mid].absolute_ones_count()) {
       hi = mid;
index 518604f..fdbf304 100644 (file)
@@ -17,7 +17,8 @@
 
 #include <fst/extensions/ngram/nthbit.h>
 
-#include <fst/types.h>
+#include <cstdint>
+
 
 namespace fst {
 
@@ -30,7 +31,7 @@ namespace fst {
 
 // These tables were generated using:
 //
-//  uint32 nth_bit_scan(uint64 v, uint32 r) {
+//  uint32_t nth_bit_scan(uint64_t v, uint32_t r) {
 //    for (int i = 0; i < 64; ++i) {
 //      if ((r -= v & 1) == 0) return i;
 //      v >>= 1;
@@ -38,17 +39,17 @@ namespace fst {
 //    return -1;
 //  }
 //
-//  printf("static const uint8 nth_bit_bit_count[256] = {\n");
+//  printf("static const uint8_t nth_bit_bit_count[256] = {\n");
 //  for (size_t i = 0; i < 256; ++i) {
 //    printf("%d, ", __builtin_popcount(i));
 //    if (i % 16 == 15) printf("\n");
 //  }
 //  printf("};\n");
 //
-//  printf("static const uint8 nth_bit_bit_pos[8][256] = {{\n");
+//  printf("static const uint8_t nth_bit_bit_pos[8][256] = {{\n");
 //  for (size_t j = 0; j < 8; ++j) {
 //    for (size_t i = 0; i < 256; ++i) {
-//      uint8 pos = nth_bit_scan(i, j);
+//      uint8_t pos = nth_bit_scan(i, j);
 //      printf("%d, ", pos);
 //      if (i % 16 == 15) printf("\n");
 //    }
@@ -58,7 +59,7 @@ namespace fst {
 //
 // This table contains the popcount of 1-byte values:
 // nth_bit_bit_count[v] == __builtin_popcount(v).
-static const uint8 nth_bit_bit_count[256] = {
+static const uint8_t nth_bit_bit_count[256] = {
     0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4,
     2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
     2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4,
@@ -75,7 +76,7 @@ static const uint8 nth_bit_bit_count[256] = {
 // This table contains the bit position of the r-th set bit in v, for 1-byte v,
 // (or 255 if there are fewer than r bits set, but those values are never used):
 // nth_bit_bit_pos[r][v] == nth_bit_scan(v, r).
-static const uint8 nth_bit_bit_pos[8][256] = {
+static const uint8_t nth_bit_bit_pos[8][256] = {
     {
         255, 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,
@@ -231,13 +232,13 @@ static const uint8 nth_bit_bit_pos[8][256] = {
         255, 255, 255, 7,
     }};
 
-uint32 nth_bit(const uint64 v, uint32 r) {
+uint32_t nth_bit(const uint64_t v, uint32_t r) {
   DCHECK_NE(v, 0);
   DCHECK_LE(0, r);
   DCHECK_LT(r, __builtin_popcountll(v));
 
-  uint32 next_byte = v & 255;
-  uint32 byte_popcount = nth_bit_bit_count[next_byte];
+  uint32_t next_byte = v & 255;
+  uint32_t byte_popcount = nth_bit_bit_count[next_byte];
   if (r < byte_popcount) return nth_bit_bit_pos[r][next_byte];
   r -= byte_popcount;
   next_byte = (v >> 8) & 255;
@@ -273,14 +274,14 @@ uint32 nth_bit(const uint64 v, uint32 r) {
 #elif SIZE_MAX == UINT64_MAX  // 64-bit, non-BMI2
 // These tables are generated using:
 //
-//  constexpr uint64 kOnesStep8 = 0x0101010101010101;
-//  printf("const uint64 kPrefixSumOverflow[64] = {\n");
+//  constexpr uint64_t kOnesStep8 = 0x0101010101010101;
+//  printf("const uint64_t kPrefixSumOverflow[64] = {\n");
 //  for (int k = 0; k < 64; ++k) {
 //    printf("  0x%x,\n",  (0x7F - k) * kOnesStep8);
 //  }
 //  printf("};\n");
 //
-//  printf("const uint8 kSelectInByte[8 * 256] = {\n");
+//  printf("const uint8_t kSelectInByte[8 * 256] = {\n");
 //  for (int j = 0; j < 8; ++j) {
 //    for (int i = 0; i < 256; ++i) {
 //      if (i > 0) printf(" ");
@@ -295,7 +296,7 @@ uint32 nth_bit(const uint64 v, uint32 r) {
 namespace internal {
 
 // clang-format off
-const uint64 kPrefixSumOverflow[64] = {
+const uint64_t kPrefixSumOverflow[64] = {
   0x7f7f7f7f7f7f7f7f,
   0x7e7e7e7e7e7e7e7e,
   0x7d7d7d7d7d7d7d7d,
@@ -362,7 +363,7 @@ const uint64 kPrefixSumOverflow[64] = {
   0x4040404040404040
 };
 
-const uint8 kSelectInByte[8 * 256] = {
+const uint8_t kSelectInByte[8 * 256] = {
   0, 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,
index c930d5c..a62f545 100644 (file)
@@ -24,7 +24,7 @@ endif
 if HAVE_SCRIPT
 lib_LTLIBRARIES = libfstpdtscript.la
 libfstpdtscript_la_SOURCES = getters.cc pdtscript.cc
-libfstpdtscript_la_LDFLAGS = -version-info 24:0:0
+libfstpdtscript_la_LDFLAGS = -version-info 25:0:0
 libfstpdtscript_la_LIBADD = ../../script/libfstscript.la \
                             ../../lib/libfst.la -lm $(DL_LIBS)
 endif
index d8c10c9..4913b06 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -102,8 +102,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)"
@@ -274,8 +273,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -289,8 +286,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -306,6 +304,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -428,7 +427,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS)
 @HAVE_BIN_TRUE@pdtshortestpath_SOURCES = pdtshortestpath.cc pdtshortestpath-main.cc
 @HAVE_SCRIPT_TRUE@lib_LTLIBRARIES = libfstpdtscript.la
 @HAVE_SCRIPT_TRUE@libfstpdtscript_la_SOURCES = getters.cc pdtscript.cc
-@HAVE_SCRIPT_TRUE@libfstpdtscript_la_LDFLAGS = -version-info 24:0:0
+@HAVE_SCRIPT_TRUE@libfstpdtscript_la_LDFLAGS = -version-info 25:0:0
 @HAVE_SCRIPT_TRUE@libfstpdtscript_la_LIBADD = ../../script/libfstscript.la \
 @HAVE_SCRIPT_TRUE@                            ../../lib/libfst.la -lm $(DL_LIBS)
 
@@ -685,7 +684,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index f91fa6a..3566df0 100644 (file)
@@ -20,7 +20,7 @@
 namespace fst {
 namespace script {
 
-bool GetPdtComposeFilter(const std::string &str, PdtComposeFilter *cf) {
+bool GetPdtComposeFilter(std::string_view str, PdtComposeFilter *cf) {
   if (str == "expand") {
     *cf = PdtComposeFilter::EXPAND;
   } else if (str == "expand_paren") {
@@ -33,7 +33,7 @@ bool GetPdtComposeFilter(const std::string &str, PdtComposeFilter *cf) {
   return true;
 }
 
-bool GetPdtParserType(const std::string &str, PdtParserType *pt) {
+bool GetPdtParserType(std::string_view str, PdtParserType *pt) {
   if (str == "left") {
     *pt = PdtParserType::LEFT;
   } else if (str == "left_sr") {
index 822f814..3573c26 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Composes a PDT and an FST.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/getters.h>
 #include <fst/extensions/pdt/pdtscript.h>
@@ -75,7 +75,7 @@ int pdtcompose_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
+  std::vector<std::pair<int64_t, int64_t>> parens;
   if (!ReadLabelPairs(FST_FLAGS_pdt_parentheses, &parens, false))
     return 1;
 
@@ -91,8 +91,8 @@ int pdtcompose_main(int argc, char **argv) {
 
   const PdtComposeOptions copts(FST_FLAGS_connect, compose_filter);
 
-  s::PdtCompose(*ifst1, *ifst2, parens, &ofst, copts,
-                FST_FLAGS_left_pdt);
+  s::Compose(*ifst1, *ifst2, parens, &ofst, copts,
+             FST_FLAGS_left_pdt);
 
   return !ofst.Write(out_name);
 }
index 3c1ce03..3263b6d 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Expands a (bounded-stack) PDT as an FST.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/pdtscript.h>
 #include <fst/util.h>
@@ -65,7 +65,7 @@ int pdtexpand_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
+  std::vector<std::pair<int64_t, int64_t>> parens;
   if (!ReadLabelPairs(FST_FLAGS_pdt_parentheses, &parens, false))
     return 1;
 
@@ -75,10 +75,10 @@ int pdtexpand_main(int argc, char **argv) {
           : WeightClass(ifst->WeightType(), FST_FLAGS_weight);
 
   VectorFstClass ofst(ifst->ArcType());
-  s::PdtExpand(*ifst, parens, &ofst,
-               s::PdtExpandOptions(FST_FLAGS_connect,
-                                   FST_FLAGS_keep_parentheses,
-                                   weight_threshold));
+  s::Expand(*ifst, parens, &ofst,
+            s::PdtExpandOptions(FST_FLAGS_connect,
+                                FST_FLAGS_keep_parentheses,
+                                weight_threshold));
 
   return !ofst.Write(out_name);
 }
index 13665b8..6f4a26b 100644 (file)
@@ -18,6 +18,7 @@
 // Prints out various information about a PDT such as number of states, arcs,
 // and parentheses.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -25,7 +26,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/pdtscript.h>
 #include <fst/util.h>
@@ -59,11 +59,12 @@ int pdtinfo_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
-  if (!ReadLabelPairs(FST_FLAGS_pdt_parentheses, &parens, false))
+  std::vector<std::pair<int64_t, int64_t>> parens;
+  if (!ReadLabelPairs(FST_FLAGS_pdt_parentheses, &parens, false)) {
     return 1;
+  }
 
-  s::PrintPdtInfo(*ifst, parens);
+  s::Info(*ifst, parens);
 
   return 0;
 }
index 656e50e..b676b18 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Converts an RTN represented by FSTs and non-terminal labels into a PDT.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/extensions/pdt/getters.h>
 #include <fst/extensions/pdt/pdtscript.h>
 #include <fst/util.h>
@@ -65,7 +65,7 @@ int pdtreplace_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, std::unique_ptr<const FstClass>>> pairs;
+  std::vector<std::pair<int64_t, std::unique_ptr<const FstClass>>> pairs;
   for (auto i = 1; i < argc - 1; i += 2) {
     std::unique_ptr<const FstClass> ifst(FstClass::Read(argv[i]));
     if (!ifst) return 1;
@@ -81,15 +81,15 @@ int pdtreplace_main(int argc, char **argv) {
   }
   const auto root = pairs.front().first;
   VectorFstClass ofst(pairs.back().second->ArcType());
-  std::vector<std::pair<int64, int64>> parens;
-  s::PdtReplace(s::BorrowPairs(pairs), &ofst, &parens, root, parser_type,
-                FST_FLAGS_start_paren_labels,
-                FST_FLAGS_left_paren_prefix,
-                FST_FLAGS_right_paren_prefix);
+  std::vector<std::pair<int64_t, int64_t>> parens;
+  s::Replace(s::BorrowPairs(pairs), &ofst, &parens, root, parser_type,
+             FST_FLAGS_start_paren_labels,
+             FST_FLAGS_left_paren_prefix,
+             FST_FLAGS_right_paren_prefix);
 
-  if (!FST_FLAGS_pdt_parentheses.empty()) {
-    if (!WriteLabelPairs(FST_FLAGS_pdt_parentheses, parens))
-      return 1;
+  if (!FST_FLAGS_pdt_parentheses.empty() &&
+      !WriteLabelPairs(FST_FLAGS_pdt_parentheses, parens)) {
+    return 1;
   }
 
   return !ofst.Write(out_name);
index 66dfe84..2944e56 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Reverses a PDT.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/pdtscript.h>
 #include <fst/util.h>
@@ -61,13 +61,13 @@ int pdtreverse_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
+  std::vector<std::pair<int64_t, int64_t>> parens;
   if (!ReadLabelPairs(FST_FLAGS_pdt_parentheses, &parens, false))
     return 1;
 
   VectorFstClass ofst(ifst->ArcType());
 
-  s::PdtReverse(*ifst, parens, &ofst);
+  s::Reverse(*ifst, parens, &ofst);
 
   return !ofst.Write(out_name);
 }
index bc246a5..e1b1857 100644 (file)
 
 #include <fst/extensions/pdt/pdtscript.h>
 
+#include <cstdint>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/extensions/pdt/compose.h>
 #include <fst/extensions/pdt/expand.h>
 #include <fst/extensions/pdt/replace.h>
 namespace fst {
 namespace script {
 
-void PdtCompose(const FstClass &ifst1, const FstClass &ifst2,
-                const std::vector<std::pair<int64, int64>> &parens,
-                MutableFstClass *ofst, const PdtComposeOptions &copts,
-                bool left_pdt) {
-  if (!internal::ArcTypesMatch(ifst1, ifst2, "PdtCompose") ||
-      !internal::ArcTypesMatch(ifst1, *ofst, "PdtCompose")) {
+void Compose(const FstClass &ifst1, const FstClass &ifst2,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             MutableFstClass *ofst, const PdtComposeOptions &copts,
+             bool left_pdt) {
+  if (!internal::ArcTypesMatch(ifst1, ifst2, "Compose") ||
+      !internal::ArcTypesMatch(ifst1, *ofst, "Compose")) {
     return;
   }
-  PdtComposeArgs args(ifst1, ifst2, parens, ofst, copts, left_pdt);
-  Apply<Operation<PdtComposeArgs>>("PdtCompose", ifst1.ArcType(), &args);
+  PdtComposeArgs args{ifst1, ifst2, parens, ofst, copts, left_pdt};
+  Apply<Operation<PdtComposeArgs>>("Compose", ifst1.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PdtCompose, PdtComposeArgs);
+REGISTER_FST_OPERATION_3ARCS(Compose, PdtComposeArgs);
 
-void PdtExpand(const FstClass &ifst,
-               const std::vector<std::pair<int64, int64>> &parens,
-               MutableFstClass *ofst, const PdtExpandOptions &opts) {
-  PdtExpandArgs args(ifst, parens, ofst, opts);
-  Apply<Operation<PdtExpandArgs>>("PdtExpand", ifst.ArcType(), &args);
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            MutableFstClass *ofst, const PdtExpandOptions &opts) {
+  PdtExpandArgs args{ifst, parens, ofst, opts};
+  Apply<Operation<PdtExpandArgs>>("Expand", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PdtExpand, PdtExpandArgs);
+REGISTER_FST_OPERATION_3ARCS(Expand, PdtExpandArgs);
 
-void PdtExpand(const FstClass &ifst,
-               const std::vector<std::pair<int64, int64>> &parens,
-               MutableFstClass *ofst, bool connect, bool keep_parentheses,
-               const WeightClass &weight_threshold) {
-  PdtExpand(ifst, parens, ofst,
-            PdtExpandOptions(connect, keep_parentheses, weight_threshold));
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            MutableFstClass *ofst, bool connect, bool keep_parentheses,
+            const WeightClass &weight_threshold) {
+  Expand(ifst, parens, ofst,
+         PdtExpandOptions(connect, keep_parentheses, weight_threshold));
 }
 
-void PdtReplace(const std::vector<std::pair<int64, const FstClass *>> &pairs,
-                MutableFstClass *ofst,
-                std::vector<std::pair<int64, int64>> *parens, int64 root,
-                PdtParserType parser_type, int64 start_paren_labels,
-                const std::string &left_paren_prefix,
-                const std::string &right_paren_prefix) {
+void Replace(const std::vector<std::pair<int64_t, const FstClass *>> &pairs,
+             MutableFstClass *ofst,
+             std::vector<std::pair<int64_t, int64_t>> *parens, int64_t root,
+             PdtParserType parser_type, int64_t start_paren_labels,
+             const std::string &left_paren_prefix,
+             const std::string &right_paren_prefix) {
   for (size_t i = 1; i < pairs.size(); ++i) {
     if (!internal::ArcTypesMatch(*pairs[i - 1].second, *pairs[i].second,
-                                 "PdtReplace"))
+                                 "Replace"))
       return;
   }
   if (!internal::ArcTypesMatch(*pairs[0].second, *ofst, "PdtReplace")) return;
-  PdtReplaceArgs args(pairs, ofst, parens, root, parser_type,
-                      start_paren_labels, left_paren_prefix,
-                      right_paren_prefix);
-  Apply<Operation<PdtReplaceArgs>>("PdtReplace", ofst->ArcType(), &args);
+  PdtReplaceArgs args{pairs,
+                      ofst,
+                      parens,
+                      root,
+                      parser_type,
+                      start_paren_labels,
+                      left_paren_prefix,
+                      right_paren_prefix};
+  Apply<Operation<PdtReplaceArgs>>("Replace", ofst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PdtReplace, PdtReplaceArgs);
+REGISTER_FST_OPERATION_3ARCS(Replace, PdtReplaceArgs);
 
-void PdtReverse(const FstClass &ifst,
-                const std::vector<std::pair<int64, int64>> &parens,
-                MutableFstClass *ofst) {
-  PdtReverseArgs args(ifst, parens, ofst);
-  Apply<Operation<PdtReverseArgs>>("PdtReverse", ifst.ArcType(), &args);
+void Reverse(const FstClass &ifst,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             MutableFstClass *ofst) {
+  PdtReverseArgs args{ifst, parens, ofst};
+  Apply<Operation<PdtReverseArgs>>("Reverse", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PdtReverse, PdtReverseArgs);
+REGISTER_FST_OPERATION_3ARCS(Reverse, PdtReverseArgs);
 
-void PdtShortestPath(const FstClass &ifst,
-                     const std::vector<std::pair<int64, int64>> &parens,
-                     MutableFstClass *ofst,
-                     const PdtShortestPathOptions &opts) {
-  PdtShortestPathArgs args(ifst, parens, ofst, opts);
-  Apply<Operation<PdtShortestPathArgs>>("PdtShortestPath", ifst.ArcType(),
-                                        &args);
+void ShortestPath(const FstClass &ifst,
+                  const std::vector<std::pair<int64_t, int64_t>> &parens,
+                  MutableFstClass *ofst, const PdtShortestPathOptions &opts) {
+  PdtShortestPathArgs args{ifst, parens, ofst, opts};
+  Apply<Operation<PdtShortestPathArgs>>("ShortestPath", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PdtShortestPath, PdtShortestPathArgs);
+REGISTER_FST_OPERATION_3ARCS(ShortestPath, PdtShortestPathArgs);
 
-void PrintPdtInfo(const FstClass &ifst,
-                  const std::vector<std::pair<int64, int64>> &parens) {
-  PrintPdtInfoArgs args(ifst, parens);
-  Apply<Operation<PrintPdtInfoArgs>>("PrintPdtInfo", ifst.ArcType(), &args);
+void Info(const FstClass &ifst,
+          const std::vector<std::pair<int64_t, int64_t>> &parens) {
+  PdtInfoArgs args(ifst, parens);
+  Apply<Operation<PdtInfoArgs>>("Info", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(PrintPdtInfo, PrintPdtInfoArgs);
+REGISTER_FST_OPERATION_3ARCS(Info, PdtInfoArgs);
 
 }  // namespace script
 }  // namespace fst
index 5c14c3e..7523ba2 100644 (file)
@@ -17,6 +17,7 @@
 //
 // Returns the shortest path in a (bounded-stack) PDT.
 
+#include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
@@ -24,7 +25,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/pdtscript.h>
 #include <fst/util.h>
@@ -65,7 +65,7 @@ int pdtshortestpath_main(int argc, char **argv) {
     return 1;
   }
 
-  std::vector<std::pair<int64, int64>> parens;
+  std::vector<std::pair<int64_t, int64_t>> parens;
   if (!ReadLabelPairs(FST_FLAGS_pdt_parentheses, &parens, false))
     return 1;
 
@@ -86,7 +86,7 @@ int pdtshortestpath_main(int argc, char **argv) {
   const s::PdtShortestPathOptions opts(
       qt, FST_FLAGS_keep_parentheses, FST_FLAGS_path_gc);
 
-  s::PdtShortestPath(*ifst, parens, &ofst, opts);
+  s::ShortestPath(*ifst, parens, &ofst, opts);
 
   return !ofst.Write(out_name);
 }
index d8fa6a1..273fd06 100644 (file)
@@ -15,5 +15,4 @@ pywrapfst_la_LIBADD = ../far/libfstfarscript.la ../far/libfstfar.la \
                       -lm $(DL_LIBS) $(PYTHON_LIBS)
 
 # Exports the *.pxd/*.pxd source files.
-EXTRA_DIST = cintegral_types.pxd cios.pxd cpywrapfst.pxd \
-             cutility.pxd pywrapfst.pxd pywrapfst.pyx
+EXTRA_DIST = cios.pxd cmemory.pxd cpywrapfst.pxd pywrapfst.pxd pywrapfst.pyx
index 6a9c9c4..839435b 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -102,8 +102,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -208,8 +207,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -223,8 +220,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -240,6 +238,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -361,9 +360,7 @@ pywrapfst_la_LIBADD = ../far/libfstfarscript.la ../far/libfstfar.la \
 
 
 # Exports the *.pxd/*.pxd source files.
-EXTRA_DIST = cintegral_types.pxd cios.pxd cpywrapfst.pxd \
-             cutility.pxd pywrapfst.pxd pywrapfst.pyx
-
+EXTRA_DIST = cios.pxd cmemory.pxd cpywrapfst.pxd pywrapfst.pxd pywrapfst.pyx
 all: all-am
 
 .SUFFIXES:
@@ -538,7 +535,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 9b0a120..92b46c5 100644 (file)
 
 from libcpp.string cimport string
 
-from cintegral_types cimport int8
-from cintegral_types cimport int16
-from cintegral_types cimport int32
-from cintegral_types cimport int64
-from cintegral_types cimport uint8
-from cintegral_types cimport uint16
-from cintegral_types cimport uint32
-from cintegral_types cimport uint64
+from libc.stdint cimport int8_t
+from libc.stdint cimport int16_t
+from libc.stdint cimport int32_t
+from libc.stdint cimport int64_t
+from libc.stdint cimport uint8_t
+from libc.stdint cimport uint16_t
+from libc.stdint cimport uint32_t
+from libc.stdint cimport uint64_t
 
 
 cdef extern from "<iostream>" namespace "std" nogil:
@@ -70,23 +70,23 @@ cdef extern from "<sstream>" namespace "std" nogil:
 
     stringstream &operator<<(bool)
 
-    # We define these in terms of the Google cintegral_types.
+    # We define these in terms of the cstdint types.
 
-    stringstream &operator<<(int8)
+    stringstream &operator<<(int8_t)
 
-    stringstream &operator<<(uint8)
+    stringstream &operator<<(uint8_t)
 
-    stringstream &operator<<(int16)
+    stringstream &operator<<(int16_t)
 
-    stringstream &operator<<(uint16)
+    stringstream &operator<<(uint16_t)
 
-    stringstream &operator<<(int32)
+    stringstream &operator<<(int32_t)
 
-    stringstream &operator<<(uint32)
+    stringstream &operator<<(uint32_t)
 
-    stringstream &operator<<(int64)
+    stringstream &operator<<(int64_t)
 
-    stringstream &operator<<(uint64)
+    stringstream &operator<<(uint64_t)
 
     stringstream &operator<<(double)
 
similarity index 71%
rename from src/extensions/python/cintegral_types.pxd
rename to src/extensions/python/cmemory.pxd
index 2f43cfe..a261e4a 100644 (file)
 # finite-state transducer library.
 
 
-from libc.stdint cimport *
+from libcpp.memory cimport unique_ptr
 
 
-cdef extern from "base/integral_types.h" nogil:
+cdef extern from <fst/compat.h> namespace "fst" nogil:
 
-  ctypedef int8_t int8
-  ctypedef int16_t int16
-  ctypedef int32_t int32
-  ctypedef int64_t int64
-  ctypedef uint8_t uint8
-  ctypedef uint16_t uint16
-  ctypedef uint32_t uint32
-  ctypedef uint64_t uint64
+  unique_ptr[T] WrapUnique[T](T *)
index 3fa870b..3e9cd86 100644 (file)
 # See www.openfst.org for extensive documentation on this weighted
 # finite-state transducer library.
 
+from libc.stdint cimport int8_t
+from libc.stdint cimport int16_t
+from libc.stdint cimport int32_t
+from libc.stdint cimport int64_t
+from libc.stdint cimport uint8_t
+from libc.stdint cimport uint16_t
+from libc.stdint cimport uint32_t
+from libc.stdint cimport uint64_t
 
 from libcpp cimport bool
 from libcpp.memory cimport unique_ptr
@@ -24,7 +32,6 @@ from libcpp.vector cimport vector
 from libcpp.utility cimport pair
 
 from cios cimport *
-from cintegral_types cimport *
 
 
 cdef extern from "<fst/util.h>" nogil:
@@ -35,85 +42,85 @@ cdef extern from "<fst/util.h>" nogil:
 cdef extern from "<fst/fstlib.h>" namespace "fst" nogil:
 
   # FST properties.
-  const uint64 kExpanded
-  const uint64 kMutable
-  const uint64 kError
-  const uint64 kAcceptor
-  const uint64 kNotAcceptor
-  const uint64 kIDeterministic
-  const uint64 kNonIDeterministic
-  const uint64 kODeterministic
-  const uint64 kNonODeterministic
-  const uint64 kEpsilons
-  const uint64 kNoEpsilons
-  const uint64 kIEpsilons
-  const uint64 kNoIEpsilons
-  const uint64 kOEpsilons
-  const uint64 kNoOEpsilons
-  const uint64 kILabelSorted
-  const uint64 kNotILabelSorted
-  const uint64 kOLabelSorted
-  const uint64 kNotOLabelSorted
-  const uint64 kWeighted
-  const uint64 kUnweighted
-  const uint64 kCyclic
-  const uint64 kAcyclic
-  const uint64 kInitialCyclic
-  const uint64 kInitialAcyclic
-  const uint64 kTopSorted
-  const uint64 kNotTopSorted
-  const uint64 kAccessible
-  const uint64 kNotAccessible
-  const uint64 kCoAccessible
-  const uint64 kNotCoAccessible
-  const uint64 kString
-  const uint64 kNotString
-  const uint64 kWeightedCycles
-  const uint64 kUnweightedCycles
-  const uint64 kNullProperties
-  const uint64 kCopyProperties
-  const uint64 kIntrinsicProperties
-  const uint64 kExtrinsicProperties
-  const uint64 kSetStartProperties
-  const uint64 kSetFinalProperties
-  const uint64 kAddStateProperties
-  const uint64 kAddArcProperties
-  const uint64 kSetArcProperties
-  const uint64 kDeleteStatesProperties
-  const uint64 kDeleteArcsProperties
-  const uint64 kStateSortProperties
-  const uint64 kArcSortProperties
-  const uint64 kILabelInvariantProperties
-  const uint64 kOLabelInvariantProperties
-  const uint64 kWeightInvariantProperties
-  const uint64 kAddSuperFinalProperties
-  const uint64 kRmSuperFinalProperties
-  const uint64 kBinaryProperties
-  const uint64 kTrinaryProperties
-  const uint64 kPosTrinaryProperties
-  const uint64 kNegTrinaryProperties
-  const uint64 kFstProperties
+  const uint64_t kExpanded
+  const uint64_t kMutable
+  const uint64_t kError
+  const uint64_t kAcceptor
+  const uint64_t kNotAcceptor
+  const uint64_t kIDeterministic
+  const uint64_t kNonIDeterministic
+  const uint64_t kODeterministic
+  const uint64_t kNonODeterministic
+  const uint64_t kEpsilons
+  const uint64_t kNoEpsilons
+  const uint64_t kIEpsilons
+  const uint64_t kNoIEpsilons
+  const uint64_t kOEpsilons
+  const uint64_t kNoOEpsilons
+  const uint64_t kILabelSorted
+  const uint64_t kNotILabelSorted
+  const uint64_t kOLabelSorted
+  const uint64_t kNotOLabelSorted
+  const uint64_t kWeighted
+  const uint64_t kUnweighted
+  const uint64_t kCyclic
+  const uint64_t kAcyclic
+  const uint64_t kInitialCyclic
+  const uint64_t kInitialAcyclic
+  const uint64_t kTopSorted
+  const uint64_t kNotTopSorted
+  const uint64_t kAccessible
+  const uint64_t kNotAccessible
+  const uint64_t kCoAccessible
+  const uint64_t kNotCoAccessible
+  const uint64_t kString
+  const uint64_t kNotString
+  const uint64_t kWeightedCycles
+  const uint64_t kUnweightedCycles
+  const uint64_t kNullProperties
+  const uint64_t kCopyProperties
+  const uint64_t kIntrinsicProperties
+  const uint64_t kExtrinsicProperties
+  const uint64_t kSetStartProperties
+  const uint64_t kSetFinalProperties
+  const uint64_t kAddStateProperties
+  const uint64_t kAddArcProperties
+  const uint64_t kSetArcProperties
+  const uint64_t kDeleteStatesProperties
+  const uint64_t kDeleteArcsProperties
+  const uint64_t kStateSortProperties
+  const uint64_t kArcSortProperties
+  const uint64_t kILabelInvariantProperties
+  const uint64_t kOLabelInvariantProperties
+  const uint64_t kWeightInvariantProperties
+  const uint64_t kAddSuperFinalProperties
+  const uint64_t kRmSuperFinalProperties
+  const uint64_t kBinaryProperties
+  const uint64_t kTrinaryProperties
+  const uint64_t kPosTrinaryProperties
+  const uint64_t kNegTrinaryProperties
+  const uint64_t kFstProperties
 
   # ArcIterator flags.
-  const uint8 kArcILabelValue
-  const uint8 kArcOLabelValue
-  const uint8 kArcWeightValue
-  const uint8 kArcNextStateValue
-  const uint8 kArcNoCache
-  const uint8 kArcValueFlags
-  const uint8 kArcFlags
+  const uint8_t kArcILabelValue
+  const uint8_t kArcOLabelValue
+  const uint8_t kArcWeightValue
+  const uint8_t kArcNextStateValue
+  const uint8_t kArcNoCache
+  const uint8_t kArcValueFlags
+  const uint8_t kArcFlags
 
   # EncodeMapper flags.
-  const uint8 kEncodeLabels
-  const uint8 kEncodeWeights
-  const uint8 kEncodeFlags
+  const uint8_t kEncodeLabels
+  const uint8_t kEncodeWeights
+  const uint8_t kEncodeFlags
 
   # Default argument constants.
   const float kDelta
   const float kShortestDelta
   const int kNoLabel
   const int kNoStateId
-  const int64 kNoSymbol
+  const int64_t kNoSymbol
 
   enum ClosureType:
     CLOSURE_STAR
@@ -165,7 +172,7 @@ cdef extern from "<fst/fstlib.h>" namespace "fst" nogil:
   # templated structs unless we pretend they are full-blown classes.
   cdef cppclass RandGenOptions[RandArcSelection]:
 
-    RandGenOptions(const RandArcSelection &, int32, int32, bool, bool)
+    RandGenOptions(const RandArcSelection &, int32_t, int32_t, bool, bool)
 
   enum ReplaceLabelType:
     REPLACE_LABEL_NEITHER
@@ -188,7 +195,7 @@ cdef extern from "<fst/fstlib.h>" namespace "fst" nogil:
 
       cppclass value_type:
 
-        int64 Label()
+        int64_t Label()
         string Symbol()
 
       # When wrapped in a unique_ptr siter.Label() and siter.Symbol() are
@@ -207,7 +214,7 @@ cdef extern from "<fst/fstlib.h>" namespace "fst" nogil:
   cdef cppclass SymbolTable:
 
     @staticmethod
-    int64 kNoSymbol
+    int64_t kNoSymbol
 
     SymbolTable()
 
@@ -223,27 +230,27 @@ cdef extern from "<fst/fstlib.h>" namespace "fst" nogil:
     @staticmethod
     SymbolTable *ReadText(const string &, const SymbolTableTextOptions &)
 
-    int64 AddSymbol(const string &, int64)
+    int64_t AddSymbol(const string &, int64_t)
 
-    int64 AddSymbol(const string &)
+    int64_t AddSymbol(const string &)
 
     SymbolTable *Copy()
 
     # Aliased for overload.
-    string FindSymbol "Find"(int64)
+    string FindSymbol "Find"(int64_t)
 
     # Aliased for overload.
-    int64 FindIndex "Find"(const string &)
+    int64_t FindIndex "Find"(const string &)
 
     # Aliased for overload.
     bool MemberSymbol "Member"(const string &)
 
     # Aliased for overload.
-    bool MemberIndex "Member"(int64)
+    bool MemberIndex "Member"(int64_t)
 
     void AddTable(const SymbolTable &)
 
-    int64 GetNthKey(ssize_t)
+    int64_t GetNthKey(ssize_t)
 
     const string &Name()
 
@@ -265,7 +272,7 @@ cdef extern from "<fst/fstlib.h>" namespace "fst" nogil:
 
     SymbolTableIterator end()
 
-    int64 AvailableKey()
+    int64_t AvailableKey()
 
     size_t NumSymbols()
 
@@ -327,33 +334,33 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     ArcClass(const ArcClass &)
 
-    ArcClass(int64, int64, const WeightClass &, int64)
+    ArcClass(int64_t, int64_t, const WeightClass &, int64_t)
 
-    int64 ilabel
-    int64 olabel
+    int64_t ilabel
+    int64_t olabel
     WeightClass weight
-    int64 nextstate
+    int64_t nextstate
 
   cdef cppclass FstClass:
 
     FstClass(const FstClass &)
 
     @staticmethod
-    FstClass *Read(const string &)
+    unique_ptr[FstClass] Read(const string &)
 
     # Aliased for overload.
     @staticmethod
-    FstClass *ReadStream "Read"(istream &, const string &)
+    unique_ptr[FstClass] ReadStream "Read"(istream &, const string &)
 
-    int64 Start()
+    int64_t Start()
 
-    WeightClass Final(int64)
+    WeightClass Final(int64_t)
 
-    size_t NumArcs(int64)
+    size_t NumArcs(int64_t)
 
-    size_t NumInputEpsilons(int64)
+    size_t NumInputEpsilons(int64_t)
 
-    size_t NumOutputEpsilons(int64)
+    size_t NumOutputEpsilons(int64_t)
 
     const string &ArcType()
 
@@ -369,23 +376,23 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     bool Write(ostream &, const string &)
 
-    uint64 Properties(uint64, bool)
+    uint64_t Properties(uint64_t, bool)
 
-    bool ValidStateId(int64)
+    bool ValidStateId(int64_t)
 
   cdef cppclass MutableFstClass(FstClass):
 
-    bool AddArc(int64, const ArcClass &)
+    bool AddArc(int64_t, const ArcClass &)
 
-    int64 AddState()
+    int64_t AddState()
 
     void AddStates(size_t)
 
-    bool DeleteArcs(int64, size_t)
+    bool DeleteArcs(int64_t, size_t)
 
-    bool DeleteArcs(int64)
+    bool DeleteArcs(int64_t)
 
-    bool DeleteStates(const vector[int64] &)
+    bool DeleteStates(const vector[int64_t] &)
 
     void DeleteStates()
 
@@ -393,21 +400,21 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     SymbolTable *MutableOutputSymbols()
 
-    int64 NumStates()
+    int64_t NumStates()
 
-    bool ReserveArcs(int64, size_t)
+    bool ReserveArcs(int64_t, size_t)
 
-    void ReserveStates(int64)
+    void ReserveStates(int64_t)
 
-    bool SetStart(int64)
+    bool SetStart(int64_t)
 
-    bool SetFinal(int64, const WeightClass &)
+    bool SetFinal(int64_t, const WeightClass &)
 
     void SetInputSymbols(const SymbolTable *)
 
     void SetOutputSymbols(const SymbolTable *)
 
-    void SetProperties(uint64, uint64)
+    void SetProperties(uint64_t, uint64_t)
 
   cdef cppclass VectorFstClass(MutableFstClass):
 
@@ -417,7 +424,7 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef cppclass EncodeMapperClass:
 
-    EncodeMapperClass(const string &, uint32, EncodeType)
+    EncodeMapperClass(const string &, uint32_t, EncodeType)
 
     # Aliased to __call__ as Cython doesn't have good support for operator().
     ArcClass __call__ "operator()"(const ArcClass &)
@@ -426,16 +433,16 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     const string &WeightType()
 
-    uint32 Flags()
+    uint32_t Flags()
 
-    uint64 Properties(uint64)
+    uint64_t Properties(uint64_t)
 
     @staticmethod
-    EncodeMapperClass *Read(const string &)
+    unique_ptr[EncodeMapperClass] Read(const string &)
 
     # Aliased for overload.
     @staticmethod
-    EncodeMapperClass *ReadStream "Read"(istream &, const string &)
+    unique_ptr[EncodeMapperClass] ReadStream "Read"(istream &, const string &)
 
     bool Write(const string &)
 
@@ -452,7 +459,7 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef cppclass ArcIteratorClass:
 
-    ArcIteratorClass(const FstClass &, int64)
+    ArcIteratorClass(const FstClass &, int64_t)
 
     bool Done()
 
@@ -466,13 +473,13 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     size_t Position()
 
-    uint8 Flags()
+    uint8_t Flags()
 
-    void SetFlags(uint8, uint8)
+    void SetFlags(uint8_t, uint8_t)
 
   cdef cppclass MutableArcIteratorClass:
 
-    MutableArcIteratorClass(MutableFstClass *, int64)
+    MutableArcIteratorClass(MutableFstClass *, int64_t)
 
     bool Done()
 
@@ -488,9 +495,9 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     size_t Position()
 
-    uint8 Flags()
+    uint8_t Flags()
 
-    void SetFlags(uint8, uint8)
+    void SetFlags(uint8_t, uint8_t)
 
   cdef cppclass StateIteratorClass:
 
@@ -498,16 +505,16 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     bool Done()
 
-    int64 Value()
+    int64_t Value()
 
     void Next()
 
     void Reset()
 
 
-ctypedef pair[int64, const FstClass *] LabelFstClassPair
+ctypedef pair[int64_t, const FstClass *] LabelFstClassPair
 
-ctypedef pair[int64, int64] LabelPair
+ctypedef pair[int64_t, int64_t] LabelPair
 
 
 cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
@@ -528,22 +535,22 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef void ArcSort(MutableFstClass *, ArcSortType)
 
-  cdef ClosureType GetClosureType(bool)
+  cdef bool GetClosureType(const string &, ClosureType *)
 
   cdef void Closure(MutableFstClass *, ClosureType)
 
-  cdef unique_ptr[FstClass] CompileFstInternal(istream &,
-                                               const string &,
-                                               const string &,
-                                               const string &,
-                                               const SymbolTable *,
-                                               const SymbolTable *,
-                                               const SymbolTable*,
-                                               bool,
-                                               bool,
-                                               bool,
-                                               bool,
-                                               bool)
+  cdef unique_ptr[FstClass] CompileInternal(istream &,
+                                            const string &,
+                                            const string &,
+                                            const string &,
+                                            const SymbolTable *,
+                                            const SymbolTable *,
+                                            const SymbolTable*,
+                                            bool,
+                                            bool,
+                                            bool,
+                                            bool,
+                                            bool)
 
   cdef void Compose(FstClass &, FstClass &, MutableFstClass *,
                     const ComposeOptions &)
@@ -560,8 +567,8 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
     DeterminizeOptions(float,
                        const WeightClass &,
-                       int64,
-                       int64,
+                       int64_t,
+                       int64_t,
                        DeterminizeType,
                        bool)
 
@@ -571,7 +578,7 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef cppclass DisambiguateOptions:
 
-    DisambiguateOptions(float, const WeightClass &, int64, int64)
+    DisambiguateOptions(float, const WeightClass &, int64_t, int64_t)
 
   cdef void Disambiguate(const FstClass &,
                          MutableFstClass *,
@@ -603,7 +610,7 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef void Encode(MutableFstClass *, EncodeMapperClass *)
 
-  cdef EpsNormalizeType GetEpsNormalizeType(bool)
+  cdef bool GetEpsNormalizeType(const string &, EpsNormalizeType *)
 
   cdef void EpsNormalize(const FstClass &, MutableFstClass *, EpsNormalizeType)
 
@@ -662,13 +669,13 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
   cdef void Prune(const FstClass &,
                   MutableFstClass *,
                   const WeightClass &,
-                  int64, float)
+                  int64_t, float)
 
-  cdef void Prune(MutableFstClass *, const WeightClass &, int64, float)
+  cdef void Prune(MutableFstClass *, const WeightClass &, int64_t, float)
 
   cdef void Push(const FstClass &,
                  MutableFstClass *,
-                 uint8 flags,
+                 uint8_t flags,
                  ReweightType, float)
 
   cdef void Push(MutableFstClass *, ReweightType, float, bool)
@@ -682,15 +689,15 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef bool RandEquivalent(const FstClass &,
                            const FstClass &,
-                           int32,
+                           int32_t,
                            const RandGenOptions[RandArcSelection] &,
                            float,
-                           uint64)
+                           uint64_t)
 
   cdef void RandGen(const FstClass &,
                     MutableFstClass *,
                     const RandGenOptions[RandArcSelection] &,
-                    uint64)
+                    uint64_t)
 
   cdef void Relabel(MutableFstClass *,
                     const SymbolTable *,
@@ -707,7 +714,7 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef cppclass ReplaceOptions:
 
-     ReplaceOptions(int64, ReplaceLabelType, ReplaceLabelType, int64)
+     ReplaceOptions(int64_t, ReplaceLabelType, ReplaceLabelType, int64_t)
 
   cdef void Replace(const vector[LabelFstClassPair] &,
                     MutableFstClass *,
@@ -721,13 +728,13 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
 
   cdef cppclass RmEpsilonOptions:
 
-    RmEpsilonOptions(QueueType, bool, const WeightClass &, int64, float)
+    RmEpsilonOptions(QueueType, bool, const WeightClass &, int64_t, float)
 
   cdef void RmEpsilon(MutableFstClass *, const RmEpsilonOptions &)
 
   cdef cppclass ShortestDistanceOptions:
 
-    ShortestDistanceOptions(QueueType, ArcFilterType, int64, float)
+    ShortestDistanceOptions(QueueType, ArcFilterType, int64_t, float)
 
   cdef void ShortestDistance(const FstClass &,
                              vector[WeightClass] *,
@@ -740,11 +747,11 @@ cdef extern from "<fst/script/fstscript.h>" namespace "fst::script" nogil:
   cdef cppclass ShortestPathOptions:
 
     ShortestPathOptions(QueueType,
-                        int32,
+                        int32_t,
                         bool,
                         float,
                         const WeightClass &,
-                        int64)
+                        int64_t)
 
   cdef void ShortestPath(const FstClass &,
                          MutableFstClass *,
@@ -767,11 +774,11 @@ cdef extern from "<fst/script/getters.h>" namespace "fst::script" nogil:
 
   cdef bool GetDeterminizeType(const string &, DeterminizeType *)
 
-  cdef uint8 GetEncodeFlags(bool, bool)
+  cdef uint8_t GetEncodeFlags(bool, bool)
 
   cdef bool GetMapType(const string &, MapType *)
 
-  cdef uint8 GetPushFlags(bool, bool, bool, bool)
+  cdef uint8_t GetPushFlags(bool, bool, bool, bool)
 
   cdef bool GetQueueType(const string &, QueueType *)
 
@@ -779,7 +786,7 @@ cdef extern from "<fst/script/getters.h>" namespace "fst::script" nogil:
 
   cdef bool GetReplaceLabelType(string, bool, ReplaceLabelType *)
 
-  cdef ReweightType GetReweightType(bool)
+  cdef bool GetReweightType(const string &, ReweightType *)
 
   cdef bool GetTokenType(const string &, TokenType *)
 
diff --git a/src/extensions/python/cutility.pxd b/src/extensions/python/cutility.pxd
deleted file mode 100644 (file)
index 1944e01..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#cython: language_level=3
-# Copyright 2005-2020 Google LLC
-#
-# 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.
-#
-# See www.openfst.org for extensive documentation on this weighted
-# finite-state transducer library.
-
-
-#TODO(kbg): When/if PR https://github.com/cython/cython/pull/3358 is merged
-# and we update third-party Cython up to or beyond a version that includes
-# this, delete this file and instead use libcpp.utility.move.
-cdef extern from * namespace "fst":
-    """
-    #include <type_traits>
-    #include <utility>
-
-    namespace fst {
-
-    template <typename T>
-    inline typename std::remove_reference<T>::type &&move(T &t) {
-        return std::move(t);
-    }
-
-    template <typename T>
-    inline typename std::remove_reference<T>::type &&move(T &&t) {
-        return std::move(t);
-    }
-
-    }  // namespace fst
-    """
-    cdef T move[T](T)
index 09ac17a..e342f9e 100644 (file)
 # See www.openfst.org for extensive documentation on this weighted
 # finite-state transducer library.
 
+from libc.stdint cimport int32_t
+from libc.stdint cimport int64_t
+from libc.stdint cimport uint8_t
+from libc.stdint cimport uint64_t
 
 from libcpp cimport bool
 from libcpp.memory cimport shared_ptr
@@ -24,10 +28,6 @@ from libcpp.string cimport string
 from libcpp.utility cimport pair
 from libcpp.vector cimport vector
 
-from cintegral_types cimport int32
-from cintegral_types cimport int64
-from cintegral_types cimport uint8
-from cintegral_types cimport uint64
 from cios cimport ostream
 from cios cimport stringstream
 
@@ -112,13 +112,13 @@ cdef class SymbolTableView:
 
   cdef const fst.SymbolTable *_raw_ptr_or_raise(self) except *
 
-  cpdef int64 available_key(self) except *
+  cpdef int64_t available_key(self) except *
 
   cpdef bytes checksum(self)
 
   cpdef SymbolTable copy(self)
 
-  cpdef int64 get_nth_key(self, ssize_t pos) except *
+  cpdef int64_t get_nth_key(self, ssize_t pos) except *
 
   cpdef bytes labeled_checksum(self)
 
@@ -157,7 +157,7 @@ cdef class _MutableSymbolTable(SymbolTableView):
 
   cdef fst.SymbolTable *_mutable_raw_ptr_or_raise(self) except *
 
-  cpdef int64 add_symbol(self, symbol, int64 key=?) except *
+  cpdef int64_t add_symbol(self, symbol, int64_t key=?) except *
 
   cpdef void add_table(self, SymbolTableView syms) except *
 
@@ -215,7 +215,7 @@ cdef class EncodeMapper:
 
   cpdef string weight_type(self)
 
-  cpdef uint8 flags(self)
+  cpdef uint8_t flags(self)
 
   cpdef void write(self, source) except *
 
@@ -253,7 +253,7 @@ cdef class Fst:
 
   cpdef string arc_type(self)
 
-  cpdef _ArcIterator arcs(self, int64 state)
+  cpdef _ArcIterator arcs(self, int64_t state)
 
   cpdef Fst copy(self)
 
@@ -270,22 +270,22 @@ cdef class Fst:
                   bool vertical=?,
                   double ranksep=?,
                   double nodesep=?,
-                  int32 fontsize=?,
-                  int32 precision=?,
+                  int32_t fontsize=?,
+                  int32_t precision=?,
                   float_format=?,
                   bool show_weight_one=?) except *
 
-  cpdef Weight final(self, int64 state)
+  cpdef Weight final(self, int64_t state)
 
   cpdef string fst_type(self)
 
   cpdef _FstSymbolTableView input_symbols(self)
 
-  cpdef size_t num_arcs(self, int64 state) except *
+  cpdef size_t num_arcs(self, int64_t state) except *
 
-  cpdef size_t num_input_epsilons(self, int64 state) except *
+  cpdef size_t num_input_epsilons(self, int64_t state) except *
 
-  cpdef size_t num_output_epsilons(self, int64 state) except *
+  cpdef size_t num_output_epsilons(self, int64_t state) except *
 
   cpdef _FstSymbolTableView output_symbols(self)
 
@@ -297,7 +297,7 @@ cdef class Fst:
                     bool show_weight_one=?,
                     missing_sym=?) except *
 
-  cpdef int64 start(self)
+  cpdef int64_t start(self)
 
   cpdef _StateIterator states(self)
 
@@ -316,15 +316,15 @@ cdef class MutableFst(Fst):
 
   cdef void _check_mutating_imethod(self) except *
 
-  cdef void _add_arc(self, int64 state, Arc arc) except *
+  cdef void _add_arc(self, int64_t state, Arc arc) except *
 
-  cpdef int64 add_state(self)
+  cpdef int64_t add_state(self)
 
   cpdef void add_states(self, size_t)
 
   cdef void _arcsort(self, sort_type=?) except *
 
-  cdef void _closure(self, bool closure_plus=?)
+  cdef void _closure(self, closure_type=?)
 
   cdef void _concat(self, Fst fst2) except *
 
@@ -332,7 +332,7 @@ cdef class MutableFst(Fst):
 
   cdef void _decode(self, EncodeMapper) except *
 
-  cdef void _delete_arcs(self, int64 state, size_t n=?) except *
+  cdef void _delete_arcs(self, int64_t state, size_t n=?) except *
 
   cdef void _delete_states(self, states=?) except *
 
@@ -342,18 +342,18 @@ cdef class MutableFst(Fst):
 
   cdef void _minimize(self, float delta=?, bool allow_nondet=?) except *
 
-  cpdef _MutableArcIterator mutable_arcs(self, int64 state)
+  cpdef _MutableArcIterator mutable_arcs(self, int64_t state)
 
-  cpdef int64 num_states(self)
+  cpdef int64_t num_states(self)
 
   cdef void _project(self, project_type) except *
 
-  cdef void _prune(self, float delta=?, int64 nstate=?, weight=?) except *
+  cdef void _prune(self, float delta=?, int64_t nstate=?, weight=?) except *
 
   cdef void _push(self,
                   float delta=?,
                   bool remove_total_weight=?,
-                  bool to_final=?)
+                  reweight_type=?)
 
   cdef void _relabel_pairs(self, ipairs=?, opairs=?) except *
 
@@ -367,22 +367,22 @@ cdef class MutableFst(Fst):
                             unknown_osymbol=?,
                             bool attach_new_osymbols=?) except *
 
-  cdef void _reserve_arcs(self, int64 state, size_t n) except *
+  cdef void _reserve_arcs(self, int64_t state, size_t n) except *
 
-  cdef void _reserve_states(self, int64 n)
+  cdef void _reserve_states(self, int64_t n)
 
-  cdef void _reweight(self, potentials, bool to_final=?) except *
+  cdef void _reweight(self, potentials, reweight_type=?) except *
 
   cdef void _rmepsilon(self,
                        queue_type=?,
                        bool connect=?,
                        weight=?,
-                       int64 nstate=?,
+                       int64_t nstate=?,
                        float delta=?) except *
 
-  cdef void _set_final(self, int64 state, weight=?) except *
+  cdef void _set_final(self, int64_t state, weight=?) except *
 
-  cdef void _set_start(self, int64 state) except *
+  cdef void _set_start(self, int64_t state) except *
 
   cdef void _set_input_symbols(self, SymbolTableView syms) except *
 
@@ -430,7 +430,7 @@ cdef class _ArcIterator:
 
   cpdef bool done(self)
 
-  cpdef uint8 flags(self)
+  cpdef uint8_t flags(self)
 
   cpdef void next(self)
 
@@ -440,9 +440,9 @@ cdef class _ArcIterator:
 
   cpdef void seek(self, size_t a)
 
-  cpdef void set_flags(self, uint8 flags, uint8 mask)
+  cpdef void set_flags(self, uint8_t flags, uint8_t mask)
 
-  cpdef object value(self)
+  cdef Arc _value(self)
 
 
 cdef class _MutableArcIterator:
@@ -452,7 +452,7 @@ cdef class _MutableArcIterator:
 
   cpdef bool done(self)
 
-  cpdef uint8 flags(self)
+  cpdef uint8_t flags(self)
 
   cpdef void next(self)
 
@@ -462,11 +462,11 @@ cdef class _MutableArcIterator:
 
   cpdef void seek(self, size_t a)
 
-  cpdef void set_flags(self, uint8 flags, uint8 mask)
+  cpdef void set_flags(self, uint8_t flags, uint8_t mask)
 
-  cpdef void set_value(self, Arc arc)
+  cdef void _set_value(self, Arc arc)
 
-  cpdef object value(self)
+  cdef Arc _value(self)
 
 
 cdef class _StateIterator:
@@ -480,7 +480,9 @@ cdef class _StateIterator:
 
   cpdef void reset(self)
 
-  cpdef int64 value(self)
+  cdef int64_t _value(self)
+
+  cpdef int64_t value(self) except *
 
 
 # Constructive operations on Fst.
@@ -500,8 +502,8 @@ cpdef Fst convert(Fst ifst, fst_type=?)
 cpdef MutableFst determinize(Fst ifst,
                              float delta=?,
                              det_type=?,
-                             int64 nstate=?,
-                             int64 subsequential_label=?,
+                             int64_t nstate=?,
+                             int64_t subsequential_label=?,
                              weight=?,
                              bool increment_subsequential_label=?)
 
@@ -512,11 +514,11 @@ cpdef MutableFst difference(Fst ifst1,
 
 cpdef MutableFst disambiguate(Fst ifst,
                               float delta=?,
-                              int64 nstate=?,
-                              int64 subsequential_label=?,
+                              int64_t nstate=?,
+                              int64_t subsequential_label=?,
                               weight=?)
 
-cpdef MutableFst epsnormalize(Fst ifst, bool eps_norm_output=?)
+cpdef MutableFst epsnormalize(Fst ifst, eps_norm_type=?)
 
 cpdef bool equal(Fst ifst1, Fst ifst2, float delta=?)
 
@@ -531,7 +533,7 @@ cpdef bool isomorphic(Fst ifst1, Fst ifst2, float delta=?)
 
 cpdef MutableFst prune(Fst ifst,
                        float delta=?,
-                       int64 nstate=?,
+                       int64_t nstate=?,
                        weight=?)
 
 cpdef MutableFst push(Fst ifst,
@@ -540,43 +542,43 @@ cpdef MutableFst push(Fst ifst,
                       bool push_labels=?,
                       bool remove_common_affix=?,
                       bool remove_total_weight=?,
-                      bool to_final=?)
+                      reweight_type=?)
 
 cpdef bool randequivalent(Fst ifst1,
                           Fst ifst2,
-                          int32 npath=?,
+                          int32_t npath=?,
                           float delta=?,
                           select=?,
-                          int32 max_length=?,
-                          uint64 seed=?) except *
+                          int32_t max_length=?,
+                          uint64_t seed=?) except *
 
 cpdef MutableFst randgen(Fst ifst,
-                         int32 npath=?,
+                         int32_t npath=?,
                          select=?,
-                         int32 max_length=?,
+                         int32_t max_length=?,
                          bool remove_total_weight=?,
                          bool weighted=?,
-                         uint64 seed=?)
+                         uint64_t seed=?)
 
 cpdef MutableFst replace(pairs,
                          call_arc_labeling=?,
                          return_arc_labeling=?,
                          bool epsilon_on_replace=?,
-                         int64 return_label=?)
+                         int64_t return_label=?)
 
 cpdef MutableFst reverse(Fst ifst, bool require_superinitial=?)
 
 cdef void _shortestdistance(Fst ifst,
                             vector[fst.WeightClass] *,
                             float delta=?,
-                            int64 nstate=?,
+                            int64_t nstate=?,
                             queue_type=?,
                             bool reverse=?) except *
 
 cpdef MutableFst shortestpath(Fst ifst,
                               float delta=?,
-                              int32 nshortest=?,
-                              int64 nstate=?,
+                              int32_t nshortest=?,
+                              int64_t nstate=?,
                               queue_type=?,
                               bool unique=?,
                               weight=?)
index c5944e0..df8249f 100644 (file)
@@ -82,22 +82,21 @@ from cython.operator cimport dereference as deref  # *foo
 from cython.operator cimport preincrement as inc   # ++foo
 
 # C imports.
-from libc.stdint cimport INT32_MAX
-from libc.stdint cimport SIZE_MAX
 from libc.time cimport time
 
 # C++ imports.
 from libcpp cimport bool
 from libcpp.cast cimport static_cast
+from libcpp.limits cimport numeric_limits
 from libcpp.memory cimport static_pointer_cast
+from libcpp.utility cimport move
 
 # Missing C++ imports.
 from cios cimport ofstream
 from cmemory cimport WrapUnique
-from cutility cimport move
 
 # Python imports.
-import logging
+from absl import logging
 import enum
 import numbers
 import os
@@ -116,11 +115,13 @@ ArcMapType = """typing.Literal["identity", "input_epsilon", "invert",
                                "rmweight", "superfinal", "times", "to_log",
                                # NOTE: Both spellings of "to_std"
                                "to_log64", "to_std", "to_standard"]"""
+ClosureType = """Literal["star", "plus"]"""
 ComposeFilter = """typing.Literal["alt_sequence", "auto", "match", "no_match",
                            "null", "sequence", "trivial"]"""
 DeterminizeType = """typing.Literal["functional", "nonfunctional",
                                     "disambiguate"]"""
 DrawFloatFormat = """typing.Literal["e", "f", "g"]"""
+EpsNormalizeType = """typing.Literal["input", "output"]"""
 FarType = """typing.Literal[
   "fst",
   "stlist",
@@ -132,6 +133,7 @@ QueueType = """typing.Literal["auto", "fifo", "lifo", "shortest", "state",
                               "top"]"""
 RandArcSelection = """typing.Literal["uniform", "log_prob", "fast_log_prob"]"""
 ReplaceLabelType = """typing.Literal["neither", "input", "output", "both"]"""
+ReweightType = """typing.Literal["to_inital", "to_final"]"""
 SortType = """typing.Literal["ilabel", "olabel"]"""
 StateMapType = """typing.Literal["arc_sum", "arc_unique", "identity"]"""
 
@@ -252,6 +254,25 @@ cdef fst.FarType _get_far_type(const string &far_type) except *:
     raise FstArgError(f"Unknown FAR type: {far_type!r}")
   return _far_type
 
+cdef fst.ClosureType _get_closure_type(const string &closure_type) except *:
+  """Matches string with the appropriate ClosureType enum value.
+
+  Args:
+    closure_type: A string matching a known projection type; one of:
+        "star", "plus".
+
+  Returns:
+    A ClosureType enum value.
+
+  Raises:
+    FstArgError: Unknown closure type.
+
+  This function is not visible to Python users.
+  """
+  cdef fst.ClosureType _closure_type
+  if not fst.GetClosureType(closure_type, addr(_closure_type)):
+    raise FstArgError(f"Unknown projection type: {closure_type!r}")
+  return _closure_type
 
 cdef fst.ComposeFilter _get_compose_filter(
     const string &compose_filter) except *:
@@ -300,6 +321,26 @@ cdef fst.DeterminizeType _get_determinize_type(const string &det_type) except *:
     raise FstArgError(f"Unknown determinization type: {det_type!r}")
   return _det_type
 
+cdef fst.EpsNormalizeType _get_eps_norm_type(const string &eps_norm_type) except *:
+  """Matches string with the appropriate EpsNormalizeType enum value.
+
+  Args:
+    eps_norm_type: A string matching a known epsilon normalization type; one of:
+        "input", "output".
+
+  Returns:
+    A EpsNormalizeType enum value.
+
+  Raises:
+    FstArgError: Unknown epsilon normalization type.
+
+  This function is not visible to Python users.
+  """
+  cdef fst.EpsNormalizeType _eps_norm_type
+  if not fst.GetEpsNormalizeType(eps_norm_type, addr(_eps_norm_type)):
+    raise FstArgError(f"Unknown epsilon normalization type: {eps_norm_type!r}")
+  return _eps_norm_type
+
 
 cdef fst.ProjectType _get_project_type(const string &project_type) except *:
   """Matches string with the appropriate ProjectType enum value.
@@ -399,6 +440,26 @@ cdef fst.ReplaceLabelType _get_replace_label_type(
   return _replace_label_type
 
 
+cdef fst.ReweightType _get_reweight_type(const string &reweight_type) except *:
+  """Matches string with the appropriate ReweightType enum value.
+
+  Args:
+    reweight_type: A string matching a known reweight type; one of:
+        "to_initial", "to_final".
+
+  Returns:
+    A ReweightType enum value.
+
+  Raises:
+    FstArgError: Unknown reweight type.
+
+  This function is not visible to Python users.
+  """
+  cdef fst.ReweightType _reweight_type
+  if not fst.GetReweightType(reweight_type, addr(_reweight_type)):
+    raise FstArgError(f"Unknown reweight type: {reweight_type!r}")
+  return _reweight_type
+
 ## Weight and helpers.
 
 
@@ -773,7 +834,7 @@ cdef class SymbolTableView:
       self._raise_nonexistent()
     return _raw
 
-  cpdef int64 available_key(self) except *:
+  cpdef int64_t available_key(self) except *:
     """
     available_key(self)
 
@@ -820,7 +881,7 @@ cdef class SymbolTableView:
     except TypeError:
       return _raw.FindSymbol(key)
 
-  cpdef int64 get_nth_key(self, ssize_t pos) except *:
+  cpdef int64_t get_nth_key(self, ssize_t pos) except *:
     """
     get_nth_key(self, pos)
 
@@ -1008,7 +1069,7 @@ cdef class _MutableSymbolTable(SymbolTableView):
       self._raise_nonexistent()
     return mutable_raw
 
-  cpdef int64 add_symbol(self, symbol, int64 key=fst.kNoSymbol) except *:
+  cpdef int64_t add_symbol(self, symbol, int64_t key=fst.kNoSymbol) except *:
     """
     add_symbol(self, symbol, key=NO_SYMBOL)
 
@@ -1285,7 +1346,7 @@ cdef class _SymbolTableIterator:
   def __next__(self):
     if self._table._raw_ptr_or_raise().end() == deref(self._siter):
       raise StopIteration
-    cdef int64 _label = self._siter.get().Pair().Label()
+    cdef int64_t _label = self._siter.get().Pair().Label()
     cdef string _symbol = self._siter.get().Pair().Symbol()
     inc(deref(self._siter))
     return (_label, _symbol)
@@ -1324,7 +1385,7 @@ cdef class EncodeMapper:
                arc_type="standard",
                bool encode_labels=False,
                bool encode_weights=False):
-    cdef uint8 _flags = fst.GetEncodeFlags(encode_labels, encode_weights)
+    cdef uint8_t _flags = fst.GetEncodeFlags(encode_labels, encode_weights)
     self._mapper.reset(
         new fst.EncodeMapperClass(tostring(arc_type), _flags, fst.ENCODE))
     if self._mapper.get() == NULL:
@@ -1371,7 +1432,7 @@ cdef class EncodeMapper:
     """
     return self._mapper.get().WeightType()
 
-  cpdef uint8 flags(self):
+  cpdef uint8_t flags(self):
     """
     flags(self)
 
@@ -1412,8 +1473,8 @@ cdef class EncodeMapper:
     Returns:
       A new EncodeMapper instance.
     """
-    cdef unique_ptr[fst.EncodeMapperClass] _mapper
-    _mapper.reset(fst.EncodeMapperClass.Read(path_tostring(source)))
+    cdef unique_ptr[fst.EncodeMapperClass] _mapper = fst.EncodeMapperClass.Read(
+        path_tostring(source))
     if _mapper.get() == NULL:
       raise FstIOError(f"Read failed: {source!r}")
     return _init_EncodeMapper(_mapper.release())
@@ -1545,8 +1606,9 @@ cdef EncodeMapper _init_EncodeMapper(EncodeMapperClass_ptr mapper):
 cpdef EncodeMapper _read_EncodeMapper_from_string(string state):
   cdef stringstream _sstrm
   _sstrm << state
-  cdef unique_ptr[fst.EncodeMapperClass] _mapper
-  _mapper.reset(fst.EncodeMapperClass.ReadStream(_sstrm, b"<pywrapfst>"))
+  cdef unique_ptr[
+      fst.EncodeMapperClass] _mapper = fst.EncodeMapperClass.ReadStream(
+          _sstrm, b"<pywrapfst>")
   if _mapper.get() == NULL:
     raise FstIOError("Read from string failed")
   return _init_EncodeMapper(_mapper.release())
@@ -1576,7 +1638,9 @@ cdef class Fst:
 
   @staticmethod
   cdef string _local_render_svg(const string &dot):
-    proc = subprocess.Popen(("dot", "-Tsvg"),
+    # As suggested in the following, we now use the Cairo renderer:
+    # https://github.com/kylebgorman/pynini/issues/35
+    proc = subprocess.Popen(["dot", "-Tsvg:cairo"],
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE)
     return proc.communicate(dot.encode("utf8"))[0]
@@ -1637,7 +1701,7 @@ cdef class Fst:
     """
     return self._fst.get().ArcType()
 
-  cpdef _ArcIterator arcs(self, int64 state):
+  cpdef _ArcIterator arcs(self, int64_t state):
     """
     arcs(self, state)
 
@@ -1672,8 +1736,8 @@ cdef class Fst:
                   bool vertical=False,
                   double ranksep=0.4,
                   double nodesep=0.25,
-                  int32 fontsize=14,
-                  int32 precision=5,
+                  int32_t fontsize=14,
+                  int32_t precision=5,
                   float_format="g",
                   bool show_weight_one=False) except *:
     """
@@ -1738,7 +1802,7 @@ cdef class Fst:
              deref(_fstrm),
              _source)
 
-  cpdef Weight final(self, int64 state):
+  cpdef Weight final(self, int64_t state):
     """
     final(self, state)
 
@@ -1777,7 +1841,7 @@ cdef class Fst:
       return
     return _init_FstSymbolTableView(self._fst, input_side=True)
 
-  cpdef size_t num_arcs(self, int64 state) except *:
+  cpdef size_t num_arcs(self, int64_t state) except *:
     """
     num_arcs(self, state)
 
@@ -1793,11 +1857,11 @@ cdef class Fst:
       FstIndexError: State index out of range.
     """
     cdef size_t _result = self._fst.get().NumArcs(state)
-    if _result == SIZE_MAX:
+    if _result == numeric_limits[size_t].max():
       raise FstIndexError("State index out of range")
     return _result
 
-  cpdef size_t num_input_epsilons(self, int64 state) except *:
+  cpdef size_t num_input_epsilons(self, int64_t state) except *:
     """
     num_input_epsilons(self, state)
 
@@ -1813,11 +1877,11 @@ cdef class Fst:
       FstIndexError: State index out of range.
     """
     cdef size_t _result = self._fst.get().NumInputEpsilons(state)
-    if _result == SIZE_MAX:
+    if _result == numeric_limits[size_t].max():
       raise FstIndexError("State index out of range")
     return _result
 
-  cpdef size_t num_output_epsilons(self, int64 state) except *:
+  cpdef size_t num_output_epsilons(self, int64_t state) except *:
     """
     num_output_epsilons(self, state)
 
@@ -1833,7 +1897,7 @@ cdef class Fst:
       FstIndexError: State index out of range.
     """
     cdef size_t _result = self._fst.get().NumOutputEpsilons(state)
-    if _result == SIZE_MAX:
+    if _result == numeric_limits[size_t].max():
       raise FstIndexError("State index out of range")
     return _result
 
@@ -1950,7 +2014,7 @@ cdef class Fst:
     """
     return _read_Fst_from_string(state)
 
-  cpdef int64 start(self):
+  cpdef int64_t start(self):
     """
     start(self)
 
@@ -2043,13 +2107,13 @@ cdef class MutableFst(Fst):
     """
     if self._fst.get().Properties(fst.kError, True) == fst.kError:
       raise FstOpError("Operation failed")
-  cdef void _add_arc(self, int64 state, Arc arc) except *:
+  cdef void _add_arc(self, int64_t state, Arc arc) except *:
     if not self._fst.get().ValidStateId(state):
       raise FstIndexError("State index out of range")
     if not self._mfst.get().AddArc(state, deref(arc._arc)):
       raise FstOpError("Incompatible or invalid weight type")
 
-  def add_arc(self, int64 state, Arc arc):
+  def add_arc(self, int64_t state, Arc arc):
     """
     add_arc(self, state, arc)
 
@@ -2069,7 +2133,7 @@ cdef class MutableFst(Fst):
     self._add_arc(state, arc)
     return self
 
-  cpdef int64 add_state(self):
+  cpdef int64_t add_state(self):
     """
     add_state(self)
 
@@ -2119,12 +2183,12 @@ cdef class MutableFst(Fst):
     self._arcsort(sort_type)
     return self
 
-  cdef void _closure(self, bool closure_plus=False):
-    fst.Closure(self._mfst.get(), fst.GetClosureType(closure_plus))
+  cdef void _closure(self, closure_type="star"):
+    fst.Closure(self._mfst.get(), _get_closure_type(tostring(closure_type)))
 
-  def closure(self, bool closure_plus=False):
+  def closure(self, closure_type="star"):
     """
-    closure(self, closure_plus=False)
+    closure(self, closure_type="star")
 
     Computes concatenative closure.
 
@@ -2132,15 +2196,15 @@ cdef class MutableFst(Fst):
     If A transduces string x to y with weight a, then the closure transduces x
     to y with weight a, xx to yy with weight a \otimes a, xxx to yyy with weight
     a \otimes a \otimes a, and so on. The empty string is also transduced to
-    itself with semiring One if `closure_plus` is False.
+    itself with semiring One if `closure_type` is "star".
 
     Args:
-      closure_plus: If False, do not accept the empty string.
+      closure_type: If "star", do not accept the empty string. If "plus", accept the empty string.
 
     Returns:
       self.
     """
-    self._closure(closure_plus)
+    self._closure(closure_type)
     return self
 
   cdef void _concat(self, Fst fst2) except *:
@@ -2206,13 +2270,13 @@ cdef class MutableFst(Fst):
     self._decode(mapper)
     return self
 
-  cdef void _delete_arcs(self, int64 state, size_t n=0) except *:
+  cdef void _delete_arcs(self, int64_t state, size_t n=0) except *:
     if not (self._mfst.get().DeleteArcs(state, n) if n else
             self._mfst.get().DeleteArcs(state)):
       raise FstIndexError("State index out of range")
     self._check_mutating_imethod()
 
-  def delete_arcs(self, int64 state, size_t n=0):
+  def delete_arcs(self, int64_t state, size_t n=0):
     """
     delete_arcs(self, state, n=0)
 
@@ -2236,7 +2300,7 @@ cdef class MutableFst(Fst):
   cdef void _delete_states(self, states=None) except *:
     # Only the former signature has a possible indexing failure.
     if states:
-      if not self._mfst.get().DeleteStates(<const vector[int64]> states):
+      if not self._mfst.get().DeleteStates(<const vector[int64_t]> states):
         raise FstIndexError("State index out of range")
     else:
       self._mfst.get().DeleteStates()
@@ -2341,7 +2405,7 @@ cdef class MutableFst(Fst):
     self._minimize(delta, allow_nondet)
     return self
 
-  cpdef _MutableArcIterator mutable_arcs(self, int64 state):
+  cpdef _MutableArcIterator mutable_arcs(self, int64_t state):
     """
     mutable_arcs(self, state)
 
@@ -2375,7 +2439,7 @@ cdef class MutableFst(Fst):
       return
     return _init_MutableFstSymbolTableView(self._mfst, input_side=False)
 
-  cpdef int64 num_states(self):
+  cpdef int64_t num_states(self):
     """
     num_states(self)
 
@@ -2408,7 +2472,7 @@ cdef class MutableFst(Fst):
 
   cdef void _prune(self,
                    float delta=fst.kDelta,
-                   int64 nstate=fst.kNoStateId,
+                   int64_t nstate=fst.kNoStateId,
                    weight=None) except *:
     # Threshold is set to semiring Zero (no pruning) if no weight is specified.
     cdef fst.WeightClass _weight = _get_WeightClass_or_zero(self.weight_type(),
@@ -2418,7 +2482,7 @@ cdef class MutableFst(Fst):
 
   def prune(self,
             float delta=fst.kDelta,
-            int64 nstate=fst.kNoStateId,
+            int64_t nstate=fst.kNoStateId,
             weight=None):
     """
     prune(self, delta=0.0009765625, nstate=NO_STATE_ID, weight=None)
@@ -2445,18 +2509,18 @@ cdef class MutableFst(Fst):
   cdef void _push(self,
                   float delta=fst.kShortestDelta,
                   bool remove_total_weight=False,
-                  bool to_final=False):
+                  reweight_type="to_initial"):
     fst.Push(self._mfst.get(),
-             fst.GetReweightType(to_final),
+             _get_reweight_type(tostring(reweight_type)),
              delta,
              remove_total_weight)
 
   def push(self,
            float delta=fst.kShortestDelta,
            bool remove_total_weight=False,
-           bool to_final=False):
+           reweight_type="to_initial"):
     """
-    push(self, delta=1-e6, remove_total_weight=False, to_final=False)
+    push(self, delta=1-e6, remove_total_weight=False, reweight_type="to_initial")
 
     Pushes weights towards the initial or final states.
 
@@ -2473,12 +2537,13 @@ cdef class MutableFst(Fst):
       delta: Comparison/quantization delta.
       remove_total_weight: If pushing weights, should the total weight be
           removed?
-      to_final: Push towards final states?
+      reweight_type: Push towards initial or final states: a string matching a
+          known reweight type: one of "to_initial", "to_final"
 
     Returns:
       self.
     """
-    self._push(delta, remove_total_weight, to_final)
+    self._push(delta, remove_total_weight, reweight_type)
     return self
 
   cdef void _relabel_pairs(self, ipairs=None, opairs=None) except *:
@@ -2604,12 +2669,12 @@ cdef class MutableFst(Fst):
                          attach_new_osymbols)
     return self
 
-  cdef void _reserve_arcs(self, int64 state, size_t n) except *:
+  cdef void _reserve_arcs(self, int64_t state, size_t n) except *:
     if not self._mfst.get().ReserveArcs(state, n):
       raise FstIndexError("State index out of range")
     self._check_mutating_imethod()
 
-  def reserve_arcs(self, int64 state, size_t n):
+  def reserve_arcs(self, int64_t state, size_t n):
     """
     reserve_arcs(self, state, n)
 
@@ -2628,10 +2693,10 @@ cdef class MutableFst(Fst):
     self._reserve_arcs(state, n)
     return self
 
-  cdef void _reserve_states(self, int64 n):
+  cdef void _reserve_states(self, int64_t n):
     self._mfst.get().ReserveStates(n)
 
-  def reserve_states(self, int64 n):
+  def reserve_states(self, int64_t n):
     """
     reserve_states(self, n)
 
@@ -2646,17 +2711,18 @@ cdef class MutableFst(Fst):
     self._reserve_states(n)
     return self
 
-  cdef void _reweight(self, potentials, bool to_final=False) except *:
+  cdef void _reweight(self, potentials, reweight_type="to_initial") except *:
     cdef string _weight_type = self.weight_type()
     cdef vector[fst.WeightClass] _potentials
     for weight in potentials:
       _potentials.push_back(_get_WeightClass_or_one(_weight_type, weight))
-    fst.Reweight(self._mfst.get(), _potentials, fst.GetReweightType(to_final))
+    fst.Reweight(self._mfst.get(), _potentials,
+                 _get_reweight_type(tostring(reweight_type)))
     self._check_mutating_imethod()
 
-  def reweight(self, potentials, bool to_final=False):
+  def reweight(self, potentials, reweight_type="to_initial"):
     """
-    reweight(self, potentials, to_final=False)
+    reweight(self, potentials, reweight_type="to_initial")
 
     Reweights an FST using an iterable of potentials.
 
@@ -2671,19 +2737,20 @@ cdef class MutableFst(Fst):
 
     Args:
       potentials: An iterable of Weight or weight strings.
-      to_final: Push towards final states?
+      reweight_type: Push towards initial or final states: a string matching a
+          known reweight type: one of "to_initial", "to_final"
 
     Returns:
       self.
     """
-    self._reweight(potentials, to_final)
+    self._reweight(potentials, reweight_type)
     return self
 
   cdef void _rmepsilon(self,
                        queue_type="auto",
                        bool connect=True,
                        weight=None,
-                       int64 nstate=fst.kNoStateId,
+                       int64_t nstate=fst.kNoStateId,
                        float delta=fst.kShortestDelta) except *:
     cdef fst.WeightClass _weight = _get_WeightClass_or_zero(self.weight_type(),
                                                             weight)
@@ -2701,7 +2768,7 @@ cdef class MutableFst(Fst):
                 queue_type="auto",
                 bool connect=True,
                 weight=None,
-                int64 nstate=fst.kNoStateId,
+                int64_t nstate=fst.kNoStateId,
                 float delta=fst.kShortestDelta):
     """
     rmepsilon(self, queue_type="auto", connect=True, weight=None,
@@ -2727,7 +2794,7 @@ cdef class MutableFst(Fst):
     self._rmepsilon(queue_type, connect, weight, nstate, delta)
     return self
 
-  cdef void _set_final(self, int64 state, weight=None) except *:
+  cdef void _set_final(self, int64_t state, weight=None) except *:
     if not self._mfst.get().ValidStateId(state):
       raise FstIndexError("State index out of range")
     cdef fst.WeightClass _weight = _get_WeightClass_or_one(self.weight_type(),
@@ -2736,7 +2803,7 @@ cdef class MutableFst(Fst):
       raise FstOpError("Incompatible or invalid weight")
     self._check_mutating_imethod()
 
-  def set_final(self, int64 state, weight=None):
+  def set_final(self, int64_t state, weight=None):
     """
     set_final(self, state, weight)
 
@@ -2820,11 +2887,11 @@ cdef class MutableFst(Fst):
     self._mfst.get().SetProperties(props.value, mask.value)
     return self
 
-  cdef void _set_start(self, int64 state) except *:
+  cdef void _set_start(self, int64_t state) except *:
     if not self._mfst.get().SetStart(state):
       raise FstIndexError("State index out of range")
 
-  def set_start(self, int64 state):
+  def set_start(self, int64_t state):
     """
     set_start(self, state)
 
@@ -2954,8 +3021,7 @@ cdef Fst _init_XFst(FstClass_ptr tfst):
 
 
 cpdef Fst _read_Fst(source):
-  cdef unique_ptr[fst.FstClass] _tfst
-  _tfst.reset(fst.FstClass.Read(path_tostring(source)))
+  cdef unique_ptr[fst.FstClass] _tfst = fst.FstClass.Read(path_tostring(source))
   if _tfst.get() == NULL:
     raise FstIOError(f"Read failed: {source!r}")
   return _init_XFst(_tfst.release())
@@ -2964,8 +3030,8 @@ cpdef Fst _read_Fst(source):
 cpdef Fst _read_Fst_from_string(string state):
   cdef stringstream _sstrm
   _sstrm << state
-  cdef unique_ptr[fst.FstClass] _tfst
-  _tfst.reset(fst.FstClass.ReadStream(_sstrm, b"<pywrapfst>"))
+  cdef unique_ptr[fst.FstClass] _tfst = fst.FstClass.ReadStream(_sstrm,
+                                                                b"<pywrapfst>")
   if _tfst.get() == NULL:
     raise FstIOError("Read from string failed")
   return _init_XFst(_tfst.release())
@@ -3090,7 +3156,7 @@ cdef class Arc:
   def __repr__(self):
     return f"<Arc at 0x{id(self):x}>"
 
-  def __init__(self, int64 ilabel, int64 olabel, weight, int64 nextstate):
+  def __init__(self, int64_t ilabel, int64_t olabel, weight, int64_t nextstate):
     cdef fst.WeightClass _weight = _get_WeightClass_or_one(b"tropical", weight)
     self._arc.reset(new fst.ArcClass(ilabel, olabel, _weight, nextstate))
 
@@ -3102,7 +3168,7 @@ cdef class Arc:
     def __get__(self):
       return deref(self._arc).ilabel
 
-    def __set__(self, int64 value):
+    def __set__(self, int64_t value):
       deref(self._arc).ilabel = value
 
   property olabel:
@@ -3110,7 +3176,7 @@ cdef class Arc:
     def __get__(self):
       return deref(self._arc).olabel
 
-    def __set__(self, int64 value):
+    def __set__(self, int64_t value):
       deref(self._arc).olabel = value
 
   property weight:
@@ -3128,7 +3194,7 @@ cdef class Arc:
     def __get__(self):
       return deref(self._arc).nextstate
 
-    def __set__(self, int64 value):
+    def __set__(self, int64_t value):
       deref(self._arc).nextstate = value
 
 
@@ -3152,7 +3218,7 @@ cdef class _ArcIterator:
   def __repr__(self):
     return f"<_ArcIterator at 0x{id(self):x}>"
 
-  def __init__(self, Fst ifst, int64 state):
+  def __init__(self, Fst ifst, int64_t state):
     if not ifst._fst.get().ValidStateId(state):
       raise FstIndexError("State index out of range")
     # Makes copy of the shared_ptr, potentially extending the FST's lifetime.
@@ -3167,7 +3233,7 @@ cdef class _ArcIterator:
   def __next__(self):
     if self.done():
       raise StopIteration
-    result = self.value()
+    result = self._value()
     self.next()
     return result
 
@@ -3182,7 +3248,7 @@ cdef class _ArcIterator:
     """
     return self._aiter.get().Done()
 
-  cpdef uint8 flags(self):
+  cpdef uint8_t flags(self):
     """
     flags(self)
 
@@ -3231,7 +3297,7 @@ cdef class _ArcIterator:
     """
     self._aiter.get().Seek(a)
 
-  cpdef void set_flags(self, uint8 flags, uint8 mask):
+  cpdef void set_flags(self, uint8_t flags, uint8_t mask):
     """
     set_flags(self, flags, mask)
 
@@ -3243,14 +3309,33 @@ cdef class _ArcIterator:
     """
     self._aiter.get().SetFlags(flags, mask)
 
-  cpdef object value(self):
+  cdef Arc _value(self):
     """
     value(self)
 
-    Returns the current arc.
+    Returns the current arc without checking whether the iterator is exhasuted.
+
+    Returns:
+       The current arc.
     """
     return _init_Arc(self._aiter.get().Value())
 
+  def value(self):
+    """
+    value(self)
+
+    Returns the current arc.
+
+    Returns:
+       The current arc.
+
+    Raises:
+      FstOpError: Can't get value from an exhausted iterator.
+    """
+    if self._aiter.get().Done():
+      raise FstOpError("Can't get value from an exhausted iterator")
+    return self._value()
+
 
 cdef class _MutableArcIterator:
 
@@ -3264,7 +3349,7 @@ cdef class _MutableArcIterator:
   def __repr__(self):
     return f"<_MutableArcIterator at 0x{id(self):x}>"
 
-  def __init__(self, MutableFst ifst, int64 state):
+  def __init__(self, MutableFst ifst, int64_t state):
     if not ifst._fst.get().ValidStateId(state):
       raise FstIndexError("State index out of range")
     # Makes copy of the shared_ptr, potentially extending the FST's lifetime.
@@ -3281,7 +3366,7 @@ cdef class _MutableArcIterator:
   def __next__(self):
     if self.done():
       raise StopIteration
-    result = self.value()
+    result = self._value()
     self.next()
     return result
 
@@ -3296,7 +3381,7 @@ cdef class _MutableArcIterator:
     """
     return self._aiter.get().Done()
 
-  cpdef uint8 flags(self):
+  cpdef uint8_t flags(self):
     """
     flags(self)
 
@@ -3345,7 +3430,7 @@ cdef class _MutableArcIterator:
     """
     self._aiter.get().Seek(a)
 
-  cpdef void set_flags(self, uint8 flags, uint8 mask):
+  cpdef void set_flags(self, uint8_t flags, uint8_t mask):
     """
     set_flags(self, flags, mask)
 
@@ -3357,25 +3442,61 @@ cdef class _MutableArcIterator:
     """
     self._aiter.get().SetFlags(flags, mask)
 
-  cpdef void set_value(self, Arc arc):
+  cdef void _set_value(self, Arc arc):
     """
     set_value(self, arc)
 
-    Replace the current arc with a new arc.
+    Replace the current arc with a new arc without checking whether the iterator
+    is exhausted.
 
     Args:
       arc: The arc to replace the current arc with.
     """
     self._aiter.get().SetValue(deref(arc._arc))
 
-  cpdef object value(self):
+  def set_value(self, Arc arc):
+    """
+    set_value(self, arc)
+
+    Replace the current arc with a new arc.
+
+    Args:
+      arc: The arc to replace the current arc with.
+
+    Raises:
+      FstOpError: Can't set value on an exhausted iterator.
+    """
+    if self._aiter.get().Done():
+      raise FstOpError("Can't set value on an exhausted iterator")
+    self._set_value(arc)
+
+  cdef Arc _value(self):
     """
     value(self)
 
-    Returns the current arc.
+    Returns the current arc, without checking.
+
+    Returns:
+       The current arc.
     """
     return _init_Arc(self._aiter.get().Value())
 
+  def value(self):
+    """
+    value(self)
+
+    Returns the current arc.
+
+    Returns:
+      The current arc.
+
+    Raises:
+      FstOpError: Can't get value from an exhausted iterator.
+    """
+    if self._aiter.get().Done():
+      raise FstOpError("Can't get value from an exhausted iterator")
+    return self._value()
+
 
 ## _StateIterator.
 
@@ -3404,7 +3525,7 @@ cdef class _StateIterator:
   def __next__(self):
     if self.done():
       raise StopIteration
-    cdef int64 result = self.value()
+    cdef int64_t result = self._value()
     self.next()
     return result
 
@@ -3435,14 +3556,34 @@ cdef class _StateIterator:
     """
     self._siter.get().Reset()
 
-  cpdef int64 value(self):
+  cdef int64_t _value(self):
     """
-    value(self)
+    _value(self)
 
-    Returns the current state index.
+    Returns the current state without checking whether the iterator is
+    exhausted.
+
+    Returns:
+       The current state.
     """
     return self._siter.get().Value()
 
+  cpdef int64_t value(self) except *:
+    """
+    value(self)
+
+    Returns the current state.
+
+    Returns:
+       The current state.
+
+    Raises:
+      FstOpError: Can't get value from an exhausted iterator.
+    """
+    if self._siter.get().Done():
+      raise FstOpError("Can't get value from an exhausted iterator")
+    return self._value()
+
 
 ## FST operations.
 
@@ -3576,8 +3717,8 @@ cpdef Fst convert(Fst ifst, fst_type=""):
 cpdef MutableFst determinize(Fst ifst,
                              float delta=fst.kShortestDelta,
                              det_type="functional",
-                             int64 nstate=fst.kNoStateId,
-                             int64 subsequential_label=0,
+                             int64_t nstate=fst.kNoStateId,
+                             int64_t subsequential_label=0,
                              weight=None,
                              bool increment_subsequential_label=False):
   """
@@ -3674,8 +3815,8 @@ cpdef MutableFst difference(Fst ifst1,
 
 cpdef MutableFst disambiguate(Fst ifst,
                               float delta=fst.kDelta,
-                              int64 nstate=fst.kNoStateId,
-                              int64 subsequential_label=0,
+                              int64_t nstate=fst.kNoStateId,
+                              int64_t subsequential_label=0,
                               weight=None):
   """
   disambiguate(ifst, delta=0.0009765625, nstate=NO_STATE_ID,
@@ -3715,9 +3856,9 @@ cpdef MutableFst disambiguate(Fst ifst,
   return _init_MutableFst(_tfst.release())
 
 
-cpdef MutableFst epsnormalize(Fst ifst, bool eps_norm_output=False):
+cpdef MutableFst epsnormalize(Fst ifst, eps_norm_type="input"):
   """
-  epsnormalize(ifst, eps_norm_output=False)
+  epsnormalize(ifst, eps_norm_type="input")
 
   Constructively epsilon-normalizes an FST.
 
@@ -3730,7 +3871,8 @@ cpdef MutableFst epsnormalize(Fst ifst, bool eps_norm_output=False):
 
   Args:
     ifst: The input FST.
-    eps_norm_output: Should the FST be output epsilon-normalized?
+    eps_norm_type: A string matching a known epsilon normalization type; one of:
+          "input", "output".
 
   Returns:
     An equivalent epsilon-normalized FST.
@@ -3740,7 +3882,7 @@ cpdef MutableFst epsnormalize(Fst ifst, bool eps_norm_output=False):
   fst.EpsNormalize(
       deref(ifst._fst),
       _tfst.get(),
-      fst.EPS_NORM_OUTPUT if eps_norm_output else fst.EPS_NORM_INPUT)
+    _get_eps_norm_type(tostring(eps_norm_type)))
   return _init_MutableFst(_tfst.release())
 
 
@@ -3847,7 +3989,7 @@ cpdef bool isomorphic(Fst ifst1, Fst ifst2, float delta=fst.kDelta):
 
 cpdef MutableFst prune(Fst ifst,
                        float delta=fst.kDelta,
-                       int64 nstate=fst.kNoStateId,
+                       int64_t nstate=fst.kNoStateId,
                        weight=None):
   """
   prune(ifst, delta=0.0009765625, nstate=NO_STATE_ID, weight=None)
@@ -3883,10 +4025,10 @@ cpdef MutableFst push(Fst ifst,
                       bool push_labels=False,
                       bool remove_common_affix=False,
                       bool remove_total_weight=False,
-                      bool to_final=False):
+                      reweight_type="to_initial"):
   """
   push(ifst, delta=0.0009765625, push_weights=False, push_labels=False,
-       remove_common_affix=False, remove_total_weight=False, to_final=False)
+       remove_common_affix=False, remove_total_weight=False, reweight_type="to_initial")
 
   Constructively pushes weights/labels towards initial or final states.
 
@@ -3914,32 +4056,33 @@ cpdef MutableFst push(Fst ifst,
     remove_common_affix: If pushing labels, should common prefix/suffix be
         removed?
     remove_total_weight: If pushing weights, should total weight be removed?
-    to_final: Push towards final states?
+    reweight_type: Push towards initial or final states?: a string matching a
+        known reweight type: one of "to_initial", "to_final"
 
   Returns:
     An equivalent pushed FST.
   """
   cdef unique_ptr[fst.VectorFstClass] _tfst
   _tfst.reset(new fst.VectorFstClass(ifst.arc_type()))
-  cdef uint8 flags = fst.GetPushFlags(push_weights,
+  cdef uint8_t flags = fst.GetPushFlags(push_weights,
                                       push_labels,
                                       remove_common_affix,
                                       remove_total_weight)
   fst.Push(deref(ifst._fst),
            _tfst.get(),
            flags,
-           fst.GetReweightType(to_final),
+           _get_reweight_type(tostring(reweight_type)),
            delta)
   return _init_MutableFst(_tfst.release())
 
 
 cpdef bool randequivalent(Fst ifst1,
                           Fst ifst2,
-                          int32 npath=1,
+                          int32_t npath=1,
                           float delta=fst.kDelta,
                           select="uniform",
-                          int32 max_length=INT32_MAX,
-                          uint64 seed=0) except *:
+                          int32_t max_length=numeric_limits[int32_t].max(),
+                          uint64_t seed=0) except *:
   """
   randequivalent(ifst1, ifst2, npath=1, delta=0.0009765625, select="uniform",
                  max_length=2147483647, seed=0)
@@ -3986,12 +4129,12 @@ cpdef bool randequivalent(Fst ifst1,
 
 
 cpdef MutableFst randgen(Fst ifst,
-                         int32 npath=1,
+                         int32_t npath=1,
                          select="uniform",
-                         int32 max_length=INT32_MAX,
+                         int32_t max_length=numeric_limits[int32_t].max(),
                          bool weighted=False,
                          bool remove_total_weight=False,
-                         uint64 seed=0):
+                         uint64_t seed=0):
   """
   randgen(ifst, npath=1, seed=0, select="uniform", max_length=2147483647,
           weighted=False, remove_total_weight=False)
@@ -4041,7 +4184,7 @@ cpdef MutableFst replace(pairs,
                          call_arc_labeling="input",
                          return_arc_labeling="neither",
                          bool epsilon_on_replace=False,
-                         int64 return_label=0):
+                         int64_t return_label=0):
   """
   replace(pairs, call_arc_labeling="input", return_arc_labeling="neither",
           epsilon_on_replace=False, return_label=0)
@@ -4078,7 +4221,7 @@ cpdef MutableFst replace(pairs,
   Returns:
     An FST resulting from expanding the input RTN.
   """
-  cdef int64 _label
+  cdef int64_t _label
   cdef Fst _pfst
   cdef vector[fst.LabelFstClassPair] _pairs
   for (_label, _pfst) in pairs:
@@ -4128,7 +4271,7 @@ cpdef MutableFst reverse(Fst ifst, bool require_superinitial=True):
 cdef void _shortestdistance(Fst ifst,
                             vector[fst.WeightClass] *distance,
                             float delta=fst.kShortestDelta,
-                            int64 nstate=fst.kNoStateId,
+                            int64_t nstate=fst.kNoStateId,
                             queue_type="auto",
                             bool reverse=False) except *:
   cdef unique_ptr[fst.ShortestDistanceOptions] _opts
@@ -4147,7 +4290,7 @@ cdef void _shortestdistance(Fst ifst,
 
 def shortestdistance(Fst ifst,
                      float delta=fst.kShortestDelta,
-                     int64 nstate=fst.kNoStateId,
+                     int64_t nstate=fst.kNoStateId,
                      queue_type="auto",
                      bool reverse=False):
   """
@@ -4184,8 +4327,8 @@ def shortestdistance(Fst ifst,
 
 cpdef MutableFst shortestpath(Fst ifst,
                               float delta=fst.kShortestDelta,
-                              int32 nshortest=1,
-                              int64 nstate=fst.kNoStateId,
+                              int32_t nshortest=1,
+                              int64_t nstate=fst.kNoStateId,
                               queue_type="auto",
                               bool unique=False,
                               weight=None):
@@ -4385,18 +4528,18 @@ cdef class Compiler:
       FstOpError: Compilation failed.
     """
     cdef unique_ptr[fst.FstClass] _tfst
-    _tfst = fst.CompileFstInternal(deref(self._sstrm),
-                                   b"<pywrapfst>",
-                                   self._fst_type,
-                                   self._arc_type,
-                                   self._isymbols,
-                                   self._osymbols,
-                                   self._ssymbols,
-                                   self._acceptor,
-                                   self._keep_isymbols,
-                                   self._keep_osymbols,
-                                   self._keep_state_numbering,
-                                   self._allow_negative_labels)
+    _tfst = fst.CompileInternal(deref(self._sstrm),
+                                b"<pywrapfst>",
+                                self._fst_type,
+                                self._arc_type,
+                                self._isymbols,
+                                self._osymbols,
+                                self._ssymbols,
+                                self._acceptor,
+                                self._keep_isymbols,
+                                self._keep_osymbols,
+                                self._keep_state_numbering,
+                                self._allow_negative_labels)
     self._sstrm.reset(new stringstream())
     if _tfst.get() == NULL:
       raise FstOpError("Compilation failed")
index d65ad64..99e09b2 100644 (file)
@@ -15,7 +15,7 @@ libfst_LTLIBRARIES = phi-fst.la rho-fst.la sigma-fst.la
 lib_LTLIBRARIES = libfstspecial.la
 
 libfstspecial_la_SOURCES = phi-fst.cc rho-fst.cc sigma-fst.cc
-libfstspecial_la_LDFLAGS = -version-info 24:0:0
+libfstspecial_la_LDFLAGS = -version-info 25:0:0
 
 phi_fst_la_SOURCES = phi-fst.cc
 phi_fst_la_LDFLAGS = -avoid-version -module
index 0f48e74..75fc862 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -100,8 +100,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \
@@ -240,8 +239,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -255,8 +252,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -272,6 +270,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -388,7 +387,7 @@ AM_CPPFLAGS = -I$(srcdir)/../../include -I$(srcdir)/../../bin $(ICU_CPPFLAGS)
 libfst_LTLIBRARIES = phi-fst.la rho-fst.la sigma-fst.la
 lib_LTLIBRARIES = libfstspecial.la
 libfstspecial_la_SOURCES = phi-fst.cc rho-fst.cc sigma-fst.cc
-libfstspecial_la_LDFLAGS = -version-info 24:0:0
+libfstspecial_la_LDFLAGS = -version-info 25:0:0
 phi_fst_la_SOURCES = phi-fst.cc
 phi_fst_la_LDFLAGS = -avoid-version -module
 rho_fst_la_SOURCES = rho-fst.cc
@@ -721,7 +720,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
@@ -760,6 +758,8 @@ check: check-am
 all-am: Makefile $(PROGRAMS) $(LTLIBRARIES)
 install-binPROGRAMS: install-libLTLIBRARIES
 
+install-libfstLTLIBRARIES: install-libLTLIBRARIES
+
 installdirs:
        for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfstdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
index 91e7f5a..a44c00d 100644 (file)
@@ -32,10 +32,6 @@ DEFINE_string(phi_fst_rewrite_mode, "auto",
 
 namespace fst {
 
-const char phi_fst_type[] = "phi";
-const char input_phi_fst_type[] = "input_phi";
-const char output_phi_fst_type[] = "output_phi";
-
 REGISTER_FST(PhiFst, StdArc);
 REGISTER_FST(PhiFst, LogArc);
 REGISTER_FST(PhiFst, Log64Arc);
index bfad94e..95057ab 100644 (file)
@@ -30,10 +30,6 @@ DEFINE_string(rho_fst_rewrite_mode, "auto",
 
 namespace fst {
 
-const char rho_fst_type[] = "rho";
-const char input_rho_fst_type[] = "input_rho";
-const char output_rho_fst_type[] = "output_rho";
-
 REGISTER_FST(RhoFst, StdArc);
 REGISTER_FST(RhoFst, LogArc);
 REGISTER_FST(RhoFst, Log64Arc);
index 7a9e567..52f6d75 100644 (file)
@@ -30,10 +30,6 @@ DEFINE_string(sigma_fst_rewrite_mode, "auto",
 
 namespace fst {
 
-const char sigma_fst_type[] = "sigma";
-const char input_sigma_fst_type[] = "input_sigma";
-const char output_sigma_fst_type[] = "output_sigma";
-
 REGISTER_FST(SigmaFst, StdArc);
 REGISTER_FST(SigmaFst, LogArc);
 REGISTER_FST(SigmaFst, Log64Arc);
index e1ee85d..043a2b3 100644 (file)
@@ -6,11 +6,12 @@ endif
 if HAVE_FAR
 far_include_headers = fst/extensions/far/compile-strings.h \
 fst/extensions/far/convert.h fst/extensions/far/create.h \
-fst/extensions/far/equal.h fst/extensions/far/extract.h \
-fst/extensions/far/far.h fst/extensions/far/far-class.h \
-fst/extensions/far/farlib.h fst/extensions/far/farscript.h \
-fst/extensions/far/getters.h fst/extensions/far/info.h \
-fst/extensions/far/isomorphic.h fst/extensions/far/print-strings.h \
+fst/extensions/far/encode.h fst/extensions/far/equal.h \
+fst/extensions/far/extract.h fst/extensions/far/far.h \
+fst/extensions/far/far-class.h fst/extensions/far/farlib.h \
+fst/extensions/far/farscript.h fst/extensions/far/getters.h \
+fst/extensions/far/info.h fst/extensions/far/isomorphic.h \
+fst/extensions/far/map-reduce.h fst/extensions/far/print-strings.h \
 fst/extensions/far/script-impl.h fst/extensions/far/stlist.h \
 fst/extensions/far/sttable.h
 endif
@@ -52,13 +53,15 @@ endif
 
 if HAVE_GRM
 far_include_headers = fst/extensions/far/compile-strings.h \
-fst/extensions/far/create.h fst/extensions/far/equal.h \
+fst/extensions/far/convert.h fst/extensions/far/create.h \
+fst/extensions/far/encode.h fst/extensions/far/equal.h \
 fst/extensions/far/extract.h fst/extensions/far/far.h \
 fst/extensions/far/far-class.h fst/extensions/far/farlib.h \
 fst/extensions/far/farscript.h fst/extensions/far/getters.h \
 fst/extensions/far/info.h fst/extensions/far/isomorphic.h \
-fst/extensions/far/print-strings.h fst/extensions/far/script-impl.h \
-fst/extensions/far/stlist.h fst/extensions/far/sttable.h
+fst/extensions/far/map-reduce.h fst/extensions/far/print-strings.h \
+fst/extensions/far/script-impl.h fst/extensions/far/stlist.h \
+fst/extensions/far/sttable.h
 mpdt_include_headers = fst/extensions/mpdt/compose.h \
 fst/extensions/mpdt/expand.h fst/extensions/mpdt/info.h \
 fst/extensions/mpdt/mpdt.h fst/extensions/mpdt/mpdtlib.h \
@@ -74,25 +77,26 @@ fst/extensions/pdt/shortest-path.h
 endif
 
 script_include_headers = fst/script/arc-class.h \
-fst/script/arciterator-class.h fst/script/arcsort.h \
-fst/script/arg-packs.h fst/script/closure.h fst/script/compile-impl.h \
-fst/script/compile.h fst/script/compose.h fst/script/concat.h \
-fst/script/connect.h fst/script/convert.h fst/script/decode.h \
-fst/script/determinize.h fst/script/difference.h fst/script/disambiguate.h \
-fst/script/draw-impl.h fst/script/draw.h fst/script/encode.h \
-fst/script/encodemapper-class.h fst/script/epsnormalize.h fst/script/equal.h \
-fst/script/equivalent.h fst/script/fst-class.h fst/script/fstscript.h \
-fst/script/getters.h fst/script/info-impl.h fst/script/info.h \
-fst/script/intersect.h fst/script/invert.h fst/script/isomorphic.h \
-fst/script/map.h fst/script/minimize.h fst/script/print-impl.h \
-fst/script/print.h fst/script/project.h fst/script/prune.h \
-fst/script/push.h fst/script/randequivalent.h fst/script/randgen.h \
-fst/script/relabel.h fst/script/replace.h fst/script/reverse.h \
-fst/script/reweight.h fst/script/rmepsilon.h fst/script/script-impl.h \
-fst/script/shortest-distance.h fst/script/shortest-path.h \
-fst/script/stateiterator-class.h fst/script/synchronize.h \
-fst/script/text-io.h fst/script/topsort.h fst/script/union.h \
-fst/script/weight-class.h fst/script/fstscript-decl.h fst/script/verify.h
+fst/script/arcfilter-impl.h fst/script/arciterator-class.h \
+fst/script/arcsort.h fst/script/arg-packs.h fst/script/closure.h \
+fst/script/compile-impl.h fst/script/compile.h fst/script/compose.h \
+fst/script/concat.h fst/script/connect.h fst/script/convert.h \
+fst/script/decode.h fst/script/determinize.h fst/script/difference.h \
+fst/script/disambiguate.h fst/script/draw-impl.h fst/script/draw.h \
+fst/script/encode.h fst/script/encodemapper-class.h fst/script/epsnormalize.h \
+fst/script/equal.h fst/script/equivalent.h fst/script/fst-class.h \
+fst/script/fstscript.h fst/script/getters.h fst/script/info-impl.h \
+fst/script/info.h fst/script/intersect.h fst/script/invert.h \
+fst/script/isomorphic.h fst/script/map.h fst/script/minimize.h \
+fst/script/print-impl.h fst/script/print.h fst/script/project.h \
+fst/script/prune.h fst/script/push.h fst/script/randequivalent.h \
+fst/script/randgen.h fst/script/relabel.h fst/script/replace.h \
+fst/script/reverse.h fst/script/reweight.h fst/script/rmepsilon.h \
+fst/script/script-impl.h fst/script/shortest-distance.h \
+fst/script/shortest-path.h fst/script/stateiterator-class.h \
+fst/script/synchronize.h fst/script/text-io.h fst/script/topsort.h \
+fst/script/union.h fst/script/weight-class.h fst/script/fstscript-decl.h \
+fst/script/verify.h
 
 test_include_headers = fst/test/algo_test.h fst/test/compactors.h \
 fst/test/fst_test.h fst/test/rand-fst.h fst/test/weight-tester.h
@@ -100,30 +104,29 @@ fst/test/fst_test.h fst/test/rand-fst.h fst/test/weight-tester.h
 nobase_include_HEADERS = fst/accumulator.h fst/add-on.h fst/arc-arena.h \
 fst/arc-map.h fst/arc.h fst/arcfilter.h fst/arcsort.h fst/bi-table.h \
 fst/cache.h fst/closure.h fst/compact-fst.h fst/compat.h fst/complement.h \
-fst/compose-filter.h fst/compose.h fst/concat.h fst/config.h fst/connect.h \
-fst/const-fst.h fst/determinize.h fst/dfs-visit.h fst/difference.h \
-fst/disambiguate.h fst/edit-fst.h fst/encode.h fst/epsnormalize.h fst/equal.h \
-fst/equivalent.h fst/error-weight.h fst/expanded-fst.h fst/expander-cache.h \
+fst/compose-filter.h fst/compose.h fst/concat.h fst/connect.h fst/const-fst.h \
+fst/determinize.h fst/dfs-visit.h fst/difference.h fst/disambiguate.h \
+fst/edit-fst.h fst/encode.h fst/epsnormalize.h fst/equal.h fst/equivalent.h \
+fst/error-weight.h fst/expanded-fst.h fst/expander-cache.h \
 fst/expectation-weight.h fst/factor-weight.h fst/filter-state.h fst/flags.h \
 fst/float-weight.h fst/fst-decl.h fst/fst.h fst/fstlib.h \
 fst/generic-register.h fst/heap.h fst/icu.h fst/intersect.h \
 fst/interval-set.h fst/invert.h fst/isomorphic.h fst/label-reachable.h \
 fst/lexicographic-weight.h fst/lock.h fst/log.h fst/lookahead-filter.h \
-fst/lookahead-matcher.h fst/map.h fst/mapped-file.h fst/matcher-fst.h \
-fst/matcher.h fst/memory.h fst/minimize.h fst/mutable-fst.h \
-fst/pair-weight.h fst/partition.h fst/power-weight.h \
-fst/power-weight-mappers.h fst/product-weight.h fst/project.h \
-fst/properties.h fst/prune.h fst/push.h fst/queue.h fst/randequivalent.h \
-fst/randgen.h fst/rational.h fst/register.h fst/relabel.h fst/replace-util.h \
-fst/replace.h fst/reverse.h fst/reweight.h fst/rmepsilon.h \
-fst/rmfinalepsilon.h fst/set-weight.h fst/shortest-distance.h \
+fst/lookahead-matcher.h fst/mapped-file.h fst/matcher-fst.h \
+fst/matcher.h fst/memory.h fst/minimize.h fst/mutable-fst.h fst/pair-weight.h \
+fst/partition.h fst/power-weight.h fst/power-weight-mappers.h \
+fst/product-weight.h fst/project.h fst/properties.h fst/prune.h fst/push.h \
+fst/queue.h fst/randequivalent.h fst/randgen.h fst/rational.h fst/register.h \
+fst/relabel.h fst/replace-util.h fst/replace.h fst/reverse.h fst/reweight.h \
+fst/rmepsilon.h fst/rmfinalepsilon.h fst/set-weight.h fst/shortest-distance.h \
 fst/shortest-path.h fst/signed-log-weight.h fst/sparse-power-weight.h \
 fst/sparse-tuple-weight.h fst/state-map.h fst/state-reachable.h \
 fst/state-table.h fst/statesort.h fst/string-weight.h fst/string.h \
 fst/symbol-table-ops.h fst/symbol-table.h fst/synchronize.h \
-fst/test-properties.h fst/topsort.h fst/tuple-weight.h fst/types.h \
-fst/union-find.h fst/union-weight.h fst/union.h fst/util.h fst/vector-fst.h \
-fst/verify.h fst/visit.h fst/windows_defs.inc fst/weight.h \
+fst/test-properties.h fst/topsort.h fst/tuple-weight.h fst/union-find.h \
+fst/union-weight.h fst/union.h fst/util.h fst/vector-fst.h fst/verify.h \
+fst/visit.h fst/windows_defs.inc fst/weight.h \
 $(compress_include_headers) \
 $(far_include_headers) \
 $(linear_include_headers) \
index 53d0e1c..6e35e65 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -99,8 +99,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 DIST_COMMON = $(srcdir)/Makefile.am $(am__nobase_include_HEADERS_DIST) \
        $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_@AM_V@)
@@ -126,46 +125,46 @@ am__nobase_include_HEADERS_DIST = fst/accumulator.h fst/add-on.h \
        fst/arc-arena.h fst/arc-map.h fst/arc.h fst/arcfilter.h \
        fst/arcsort.h fst/bi-table.h fst/cache.h fst/closure.h \
        fst/compact-fst.h fst/compat.h fst/complement.h \
-       fst/compose-filter.h fst/compose.h fst/concat.h fst/config.h \
-       fst/connect.h fst/const-fst.h fst/determinize.h \
-       fst/dfs-visit.h fst/difference.h fst/disambiguate.h \
-       fst/edit-fst.h fst/encode.h fst/epsnormalize.h fst/equal.h \
-       fst/equivalent.h fst/error-weight.h fst/expanded-fst.h \
-       fst/expander-cache.h fst/expectation-weight.h \
-       fst/factor-weight.h fst/filter-state.h fst/flags.h \
-       fst/float-weight.h fst/fst-decl.h fst/fst.h fst/fstlib.h \
-       fst/generic-register.h fst/heap.h fst/icu.h fst/intersect.h \
-       fst/interval-set.h fst/invert.h fst/isomorphic.h \
-       fst/label-reachable.h fst/lexicographic-weight.h fst/lock.h \
-       fst/log.h fst/lookahead-filter.h fst/lookahead-matcher.h \
-       fst/map.h fst/mapped-file.h fst/matcher-fst.h fst/matcher.h \
-       fst/memory.h fst/minimize.h fst/mutable-fst.h \
-       fst/pair-weight.h fst/partition.h fst/power-weight.h \
-       fst/power-weight-mappers.h fst/product-weight.h fst/project.h \
-       fst/properties.h fst/prune.h fst/push.h fst/queue.h \
-       fst/randequivalent.h fst/randgen.h fst/rational.h \
-       fst/register.h fst/relabel.h fst/replace-util.h fst/replace.h \
-       fst/reverse.h fst/reweight.h fst/rmepsilon.h \
-       fst/rmfinalepsilon.h fst/set-weight.h fst/shortest-distance.h \
-       fst/shortest-path.h fst/signed-log-weight.h \
-       fst/sparse-power-weight.h fst/sparse-tuple-weight.h \
-       fst/state-map.h fst/state-reachable.h fst/state-table.h \
-       fst/statesort.h fst/string-weight.h fst/string.h \
-       fst/symbol-table-ops.h fst/symbol-table.h fst/synchronize.h \
-       fst/test-properties.h fst/topsort.h fst/tuple-weight.h \
-       fst/types.h fst/union-find.h fst/union-weight.h fst/union.h \
-       fst/util.h fst/vector-fst.h fst/verify.h fst/visit.h \
-       fst/windows_defs.inc fst/weight.h \
+       fst/compose-filter.h fst/compose.h fst/concat.h fst/connect.h \
+       fst/const-fst.h fst/determinize.h fst/dfs-visit.h \
+       fst/difference.h fst/disambiguate.h fst/edit-fst.h \
+       fst/encode.h fst/epsnormalize.h fst/equal.h fst/equivalent.h \
+       fst/error-weight.h fst/expanded-fst.h fst/expander-cache.h \
+       fst/expectation-weight.h fst/factor-weight.h \
+       fst/filter-state.h fst/flags.h fst/float-weight.h \
+       fst/fst-decl.h fst/fst.h fst/fstlib.h fst/generic-register.h \
+       fst/heap.h fst/icu.h fst/intersect.h fst/interval-set.h \
+       fst/invert.h fst/isomorphic.h fst/label-reachable.h \
+       fst/lexicographic-weight.h fst/lock.h fst/log.h \
+       fst/lookahead-filter.h fst/lookahead-matcher.h \
+       fst/mapped-file.h fst/matcher-fst.h fst/matcher.h fst/memory.h \
+       fst/minimize.h fst/mutable-fst.h fst/pair-weight.h \
+       fst/partition.h fst/power-weight.h fst/power-weight-mappers.h \
+       fst/product-weight.h fst/project.h fst/properties.h \
+       fst/prune.h fst/push.h fst/queue.h fst/randequivalent.h \
+       fst/randgen.h fst/rational.h fst/register.h fst/relabel.h \
+       fst/replace-util.h fst/replace.h fst/reverse.h fst/reweight.h \
+       fst/rmepsilon.h fst/rmfinalepsilon.h fst/set-weight.h \
+       fst/shortest-distance.h fst/shortest-path.h \
+       fst/signed-log-weight.h fst/sparse-power-weight.h \
+       fst/sparse-tuple-weight.h fst/state-map.h \
+       fst/state-reachable.h fst/state-table.h fst/statesort.h \
+       fst/string-weight.h fst/string.h fst/symbol-table-ops.h \
+       fst/symbol-table.h fst/synchronize.h fst/test-properties.h \
+       fst/topsort.h fst/tuple-weight.h fst/union-find.h \
+       fst/union-weight.h fst/union.h fst/util.h fst/vector-fst.h \
+       fst/verify.h fst/visit.h fst/windows_defs.inc fst/weight.h \
        fst/extensions/compress/compress.h \
        fst/extensions/compress/compressscript.h \
        fst/extensions/compress/elias.h \
        fst/extensions/far/compile-strings.h \
        fst/extensions/far/convert.h fst/extensions/far/create.h \
-       fst/extensions/far/equal.h fst/extensions/far/extract.h \
-       fst/extensions/far/far.h fst/extensions/far/far-class.h \
-       fst/extensions/far/farlib.h fst/extensions/far/farscript.h \
-       fst/extensions/far/getters.h fst/extensions/far/info.h \
-       fst/extensions/far/isomorphic.h \
+       fst/extensions/far/encode.h fst/extensions/far/equal.h \
+       fst/extensions/far/extract.h fst/extensions/far/far.h \
+       fst/extensions/far/far-class.h fst/extensions/far/farlib.h \
+       fst/extensions/far/farscript.h fst/extensions/far/getters.h \
+       fst/extensions/far/info.h fst/extensions/far/isomorphic.h \
+       fst/extensions/far/map-reduce.h \
        fst/extensions/far/print-strings.h \
        fst/extensions/far/script-impl.h fst/extensions/far/stlist.h \
        fst/extensions/far/sttable.h \
@@ -189,11 +188,11 @@ am__nobase_include_HEADERS_DIST = fst/accumulator.h fst/add-on.h \
        fst/extensions/pdt/pdtscript.h fst/extensions/pdt/replace.h \
        fst/extensions/pdt/reverse.h \
        fst/extensions/pdt/shortest-path.h fst/script/arc-class.h \
-       fst/script/arciterator-class.h fst/script/arcsort.h \
-       fst/script/arg-packs.h fst/script/closure.h \
-       fst/script/compile-impl.h fst/script/compile.h \
-       fst/script/compose.h fst/script/concat.h fst/script/connect.h \
-       fst/script/convert.h fst/script/decode.h \
+       fst/script/arcfilter-impl.h fst/script/arciterator-class.h \
+       fst/script/arcsort.h fst/script/arg-packs.h \
+       fst/script/closure.h fst/script/compile-impl.h \
+       fst/script/compile.h fst/script/compose.h fst/script/concat.h \
+       fst/script/connect.h fst/script/convert.h fst/script/decode.h \
        fst/script/determinize.h fst/script/difference.h \
        fst/script/disambiguate.h fst/script/draw-impl.h \
        fst/script/draw.h fst/script/encode.h \
@@ -264,8 +263,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -279,8 +276,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -296,6 +294,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -410,22 +409,25 @@ top_srcdir = @top_srcdir@
 
 @HAVE_FAR_TRUE@far_include_headers = fst/extensions/far/compile-strings.h \
 @HAVE_FAR_TRUE@fst/extensions/far/convert.h fst/extensions/far/create.h \
-@HAVE_FAR_TRUE@fst/extensions/far/equal.h fst/extensions/far/extract.h \
-@HAVE_FAR_TRUE@fst/extensions/far/far.h fst/extensions/far/far-class.h \
-@HAVE_FAR_TRUE@fst/extensions/far/farlib.h fst/extensions/far/farscript.h \
-@HAVE_FAR_TRUE@fst/extensions/far/getters.h fst/extensions/far/info.h \
-@HAVE_FAR_TRUE@fst/extensions/far/isomorphic.h fst/extensions/far/print-strings.h \
+@HAVE_FAR_TRUE@fst/extensions/far/encode.h fst/extensions/far/equal.h \
+@HAVE_FAR_TRUE@fst/extensions/far/extract.h fst/extensions/far/far.h \
+@HAVE_FAR_TRUE@fst/extensions/far/far-class.h fst/extensions/far/farlib.h \
+@HAVE_FAR_TRUE@fst/extensions/far/farscript.h fst/extensions/far/getters.h \
+@HAVE_FAR_TRUE@fst/extensions/far/info.h fst/extensions/far/isomorphic.h \
+@HAVE_FAR_TRUE@fst/extensions/far/map-reduce.h fst/extensions/far/print-strings.h \
 @HAVE_FAR_TRUE@fst/extensions/far/script-impl.h fst/extensions/far/stlist.h \
 @HAVE_FAR_TRUE@fst/extensions/far/sttable.h
 
 @HAVE_GRM_TRUE@far_include_headers = fst/extensions/far/compile-strings.h \
-@HAVE_GRM_TRUE@fst/extensions/far/create.h fst/extensions/far/equal.h \
+@HAVE_GRM_TRUE@fst/extensions/far/convert.h fst/extensions/far/create.h \
+@HAVE_GRM_TRUE@fst/extensions/far/encode.h fst/extensions/far/equal.h \
 @HAVE_GRM_TRUE@fst/extensions/far/extract.h fst/extensions/far/far.h \
 @HAVE_GRM_TRUE@fst/extensions/far/far-class.h fst/extensions/far/farlib.h \
 @HAVE_GRM_TRUE@fst/extensions/far/farscript.h fst/extensions/far/getters.h \
 @HAVE_GRM_TRUE@fst/extensions/far/info.h fst/extensions/far/isomorphic.h \
-@HAVE_GRM_TRUE@fst/extensions/far/print-strings.h fst/extensions/far/script-impl.h \
-@HAVE_GRM_TRUE@fst/extensions/far/stlist.h fst/extensions/far/sttable.h
+@HAVE_GRM_TRUE@fst/extensions/far/map-reduce.h fst/extensions/far/print-strings.h \
+@HAVE_GRM_TRUE@fst/extensions/far/script-impl.h fst/extensions/far/stlist.h \
+@HAVE_GRM_TRUE@fst/extensions/far/sttable.h
 
 @HAVE_LINEAR_TRUE@linear_include_headers = fst/extensions/linear/linear-fst-data-builder.h \
 @HAVE_LINEAR_TRUE@fst/extensions/linear/linear-fst-data.h fst/extensions/linear/linear-fst.h \
@@ -467,25 +469,26 @@ top_srcdir = @top_srcdir@
 @HAVE_SPECIAL_TRUE@fst/extensions/special/rho-fst.h fst/extensions/special/sigma-fst.h
 
 script_include_headers = fst/script/arc-class.h \
-fst/script/arciterator-class.h fst/script/arcsort.h \
-fst/script/arg-packs.h fst/script/closure.h fst/script/compile-impl.h \
-fst/script/compile.h fst/script/compose.h fst/script/concat.h \
-fst/script/connect.h fst/script/convert.h fst/script/decode.h \
-fst/script/determinize.h fst/script/difference.h fst/script/disambiguate.h \
-fst/script/draw-impl.h fst/script/draw.h fst/script/encode.h \
-fst/script/encodemapper-class.h fst/script/epsnormalize.h fst/script/equal.h \
-fst/script/equivalent.h fst/script/fst-class.h fst/script/fstscript.h \
-fst/script/getters.h fst/script/info-impl.h fst/script/info.h \
-fst/script/intersect.h fst/script/invert.h fst/script/isomorphic.h \
-fst/script/map.h fst/script/minimize.h fst/script/print-impl.h \
-fst/script/print.h fst/script/project.h fst/script/prune.h \
-fst/script/push.h fst/script/randequivalent.h fst/script/randgen.h \
-fst/script/relabel.h fst/script/replace.h fst/script/reverse.h \
-fst/script/reweight.h fst/script/rmepsilon.h fst/script/script-impl.h \
-fst/script/shortest-distance.h fst/script/shortest-path.h \
-fst/script/stateiterator-class.h fst/script/synchronize.h \
-fst/script/text-io.h fst/script/topsort.h fst/script/union.h \
-fst/script/weight-class.h fst/script/fstscript-decl.h fst/script/verify.h
+fst/script/arcfilter-impl.h fst/script/arciterator-class.h \
+fst/script/arcsort.h fst/script/arg-packs.h fst/script/closure.h \
+fst/script/compile-impl.h fst/script/compile.h fst/script/compose.h \
+fst/script/concat.h fst/script/connect.h fst/script/convert.h \
+fst/script/decode.h fst/script/determinize.h fst/script/difference.h \
+fst/script/disambiguate.h fst/script/draw-impl.h fst/script/draw.h \
+fst/script/encode.h fst/script/encodemapper-class.h fst/script/epsnormalize.h \
+fst/script/equal.h fst/script/equivalent.h fst/script/fst-class.h \
+fst/script/fstscript.h fst/script/getters.h fst/script/info-impl.h \
+fst/script/info.h fst/script/intersect.h fst/script/invert.h \
+fst/script/isomorphic.h fst/script/map.h fst/script/minimize.h \
+fst/script/print-impl.h fst/script/print.h fst/script/project.h \
+fst/script/prune.h fst/script/push.h fst/script/randequivalent.h \
+fst/script/randgen.h fst/script/relabel.h fst/script/replace.h \
+fst/script/reverse.h fst/script/reweight.h fst/script/rmepsilon.h \
+fst/script/script-impl.h fst/script/shortest-distance.h \
+fst/script/shortest-path.h fst/script/stateiterator-class.h \
+fst/script/synchronize.h fst/script/text-io.h fst/script/topsort.h \
+fst/script/union.h fst/script/weight-class.h fst/script/fstscript-decl.h \
+fst/script/verify.h
 
 test_include_headers = fst/test/algo_test.h fst/test/compactors.h \
 fst/test/fst_test.h fst/test/rand-fst.h fst/test/weight-tester.h
@@ -493,30 +496,29 @@ fst/test/fst_test.h fst/test/rand-fst.h fst/test/weight-tester.h
 nobase_include_HEADERS = fst/accumulator.h fst/add-on.h fst/arc-arena.h \
 fst/arc-map.h fst/arc.h fst/arcfilter.h fst/arcsort.h fst/bi-table.h \
 fst/cache.h fst/closure.h fst/compact-fst.h fst/compat.h fst/complement.h \
-fst/compose-filter.h fst/compose.h fst/concat.h fst/config.h fst/connect.h \
-fst/const-fst.h fst/determinize.h fst/dfs-visit.h fst/difference.h \
-fst/disambiguate.h fst/edit-fst.h fst/encode.h fst/epsnormalize.h fst/equal.h \
-fst/equivalent.h fst/error-weight.h fst/expanded-fst.h fst/expander-cache.h \
+fst/compose-filter.h fst/compose.h fst/concat.h fst/connect.h fst/const-fst.h \
+fst/determinize.h fst/dfs-visit.h fst/difference.h fst/disambiguate.h \
+fst/edit-fst.h fst/encode.h fst/epsnormalize.h fst/equal.h fst/equivalent.h \
+fst/error-weight.h fst/expanded-fst.h fst/expander-cache.h \
 fst/expectation-weight.h fst/factor-weight.h fst/filter-state.h fst/flags.h \
 fst/float-weight.h fst/fst-decl.h fst/fst.h fst/fstlib.h \
 fst/generic-register.h fst/heap.h fst/icu.h fst/intersect.h \
 fst/interval-set.h fst/invert.h fst/isomorphic.h fst/label-reachable.h \
 fst/lexicographic-weight.h fst/lock.h fst/log.h fst/lookahead-filter.h \
-fst/lookahead-matcher.h fst/map.h fst/mapped-file.h fst/matcher-fst.h \
-fst/matcher.h fst/memory.h fst/minimize.h fst/mutable-fst.h \
-fst/pair-weight.h fst/partition.h fst/power-weight.h \
-fst/power-weight-mappers.h fst/product-weight.h fst/project.h \
-fst/properties.h fst/prune.h fst/push.h fst/queue.h fst/randequivalent.h \
-fst/randgen.h fst/rational.h fst/register.h fst/relabel.h fst/replace-util.h \
-fst/replace.h fst/reverse.h fst/reweight.h fst/rmepsilon.h \
-fst/rmfinalepsilon.h fst/set-weight.h fst/shortest-distance.h \
+fst/lookahead-matcher.h fst/mapped-file.h fst/matcher-fst.h \
+fst/matcher.h fst/memory.h fst/minimize.h fst/mutable-fst.h fst/pair-weight.h \
+fst/partition.h fst/power-weight.h fst/power-weight-mappers.h \
+fst/product-weight.h fst/project.h fst/properties.h fst/prune.h fst/push.h \
+fst/queue.h fst/randequivalent.h fst/randgen.h fst/rational.h fst/register.h \
+fst/relabel.h fst/replace-util.h fst/replace.h fst/reverse.h fst/reweight.h \
+fst/rmepsilon.h fst/rmfinalepsilon.h fst/set-weight.h fst/shortest-distance.h \
 fst/shortest-path.h fst/signed-log-weight.h fst/sparse-power-weight.h \
 fst/sparse-tuple-weight.h fst/state-map.h fst/state-reachable.h \
 fst/state-table.h fst/statesort.h fst/string-weight.h fst/string.h \
 fst/symbol-table-ops.h fst/symbol-table.h fst/synchronize.h \
-fst/test-properties.h fst/topsort.h fst/tuple-weight.h fst/types.h \
-fst/union-find.h fst/union-weight.h fst/union.h fst/util.h fst/vector-fst.h \
-fst/verify.h fst/visit.h fst/windows_defs.inc fst/weight.h \
+fst/test-properties.h fst/topsort.h fst/tuple-weight.h fst/union-find.h \
+fst/union-weight.h fst/union.h fst/util.h fst/vector-fst.h fst/verify.h \
+fst/visit.h fst/windows_defs.inc fst/weight.h \
 $(compress_include_headers) \
 $(far_include_headers) \
 $(linear_include_headers) \
@@ -641,7 +643,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 9ac08ec..262f414 100644 (file)
@@ -772,8 +772,8 @@ class ReplaceAccumulator {
       offset_ = 0;
       offset_weight_ = Weight::Zero();
     }
-    aiter_.reset(
-        new ArcIterator<Fst<Arc>>(*data_->GetFst(fst_id_), tuple.fst_state));
+    aiter_ = std::make_unique<ArcIterator<Fst<Arc>>>(*data_->GetFst(fst_id_),
+                                                      tuple.fst_state);
   }
 
   Weight Sum(Weight w, Weight v) {
index f26eb99..3d9e01c 100644 (file)
 
 #include <stddef.h>
 
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/fst.h>
@@ -36,7 +36,7 @@
 namespace fst {
 
 // Identifies stream data as an add-on FST.
-static constexpr int32 kAddOnMagicNumber = 446681434;
+inline constexpr int32_t kAddOnMagicNumber = 446681434;
 
 // Nothing to save.
 class NullAddOn {
@@ -176,7 +176,7 @@ class AddOnImpl : public FstImpl<typename FST::Arc> {
     auto impl = fst::WrapUnique(new AddOnImpl(nopts.header->FstType()));
     if (!impl->ReadHeader(strm, nopts, kMinFileVersion, &hdr)) return nullptr;
     impl.reset();
-    int32 magic_number = 0;
+    int32_t magic_number = 0;
     ReadType(strm, &magic_number);  // Ensures this is an add-on FST.
     if (magic_number != kAddOnMagicNumber) {
       LOG(ERROR) << "AddOnImpl::Read: Bad add-on header: " << nopts.source;
@@ -248,12 +248,6 @@ class AddOnImpl : public FstImpl<typename FST::Arc> {
   AddOnImpl &operator=(const AddOnImpl &) = delete;
 };
 
-template <class FST, class T>
-constexpr int AddOnImpl<FST, T>::kFileVersion;
-
-template <class FST, class T>
-constexpr int AddOnImpl<FST, T>::kMinFileVersion;
-
 }  // namespace internal
 }  // namespace fst
 
index e8a1eda..f80108a 100644 (file)
 #ifndef FST_ARC_ARENA_H_
 #define FST_ARC_ARENA_H_
 
+#include <cstdint>
 #include <deque>
 #include <memory>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/fst.h>
 #include <fst/memory.h>
 #include <unordered_map>
@@ -129,8 +129,8 @@ class ArcArena {
     end_ = arcs_ + new_block_size;
   }
 
-  std::shared_ptr<Arc> MakeSharedBlock(size_t size) {
-    return std::shared_ptr<Arc>(new Arc[size], std::default_delete<Arc[]>());
+  std::shared_ptr<Arc[]> MakeSharedBlock(size_t size) {
+    return std::shared_ptr<Arc[]>(new Arc[size]);
   }
 
   Arc *arcs_;
@@ -140,7 +140,7 @@ class ArcArena {
   size_t first_block_size_;
   size_t total_size_;
   size_t max_retained_size_;
-  std::list<std::shared_ptr<Arc>> blocks_;
+  std::list<std::shared_ptr<Arc[]>> blocks_;
 };
 
 // ArcArenaStateStore uses a resusable ArcArena to store arc arrays and does not
@@ -172,8 +172,8 @@ class ArcArenaStateStore {
     int *MutableRefCount() const { return nullptr; }
 
    private:
-    State(Weight final_weight, int32 niepsilons, int32 noepsilons, int32 narcs,
-          const Arc *arcs)
+    State(Weight final_weight, int32_t niepsilons, int32_t noepsilons,
+          int32_t narcs, const Arc *arcs)
         : final_weight_(std::move(final_weight)),
           niepsilons_(niepsilons),
           noepsilons_(noepsilons),
@@ -191,8 +191,8 @@ class ArcArenaStateStore {
 
   template <class Expander>
   State *FindOrExpand(Expander &expander, StateId state_id) {
-    auto it = cache_.insert(std::pair<StateId, State *>(state_id, nullptr));
-    if (!it.second) return it.first->second;
+    const auto &[it, success] = cache_.emplace(state_id, nullptr);
+    if (!success) return it->second;
     // Needs a new state.
     StateBuilder builder(&arena_);
     expander.Expand(state_id, &builder);
@@ -208,7 +208,7 @@ class ArcArenaStateStore {
         State(builder.final_weight_, niepsilons, noepsilons, narcs, arcs));
     // Places it in the cache.
     auto state = &states_.back();
-    it.first->second = state;
+    it->second = state;
     return state;
   }
 
index 48de960..44e0740 100644 (file)
 #ifndef FST_ARC_MAP_H_
 #define FST_ARC_MAP_H_
 
+#include <cstdint>
 #include <string>
+#include <type_traits>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
@@ -87,7 +88,7 @@ enum MapSymbolsAction {
 //
 //   // This specifies the known properties of an FST mapped by this mapper. It
 //   takes as argument the input FSTs's known properties.
-//   uint64 Properties(uint64 props) const;
+//   uint64_t Properties(uint64_t props) const;
 // };
 //
 // The ArcMap functions and classes below will use the FinalAction()
@@ -413,10 +414,10 @@ class ArcMapFstImpl : public CacheImpl<B> {
     return CacheImpl<B>::NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && (fst_->Properties(kError, false) ||
                             (mapper_->Properties(0) & kError))) {
       SetProperties(kError, kError);
@@ -491,7 +492,7 @@ class ArcMapFstImpl : public CacheImpl<B> {
       SetProperties(kNullProperties);
     } else {
       final_action_ = mapper_->FinalAction();
-      uint64 props = fst_->Properties(kCopyProperties, false);
+      uint64_t props = fst_->Properties(kCopyProperties, false);
       SetProperties(mapper_->Properties(props));
       if (final_action_ == MAP_REQUIRE_SUPERFINAL) superfinal_ = 0;
     }
@@ -540,8 +541,8 @@ class ArcMapFst : public ImplToFst<internal::ArcMapFstImpl<A, B, C>> {
   friend class ArcIterator<ArcMapFst<A, B, C>>;
   friend class StateIterator<ArcMapFst<A, B, C>>;
 
-  ArcMapFst(const Fst<A> &fst, const C &mapper,
-            const ArcMapFstOptions &opts = ArcMapFstOptions())
+  explicit ArcMapFst(const Fst<A> &fst, const C &mapper = C(),
+                     const ArcMapFstOptions &opts = ArcMapFstOptions())
       : ImplToFst<Impl>(std::make_shared<Impl>(fst, mapper, opts)) {}
 
   ArcMapFst(const Fst<A> &fst, C *mapper,
@@ -643,25 +644,18 @@ inline void ArcMapFst<A, B, C>::InitStateIterator(
   data->base = std::make_unique<StateIterator<ArcMapFst<A, B, C>>>(*this);
 }
 
-// Constructs and returns an ArcMapFst. This allows constructing ArcMapFsts
-// without specifying all the types. The template argument is typically
-// not specified, so a call looks like: MakeArcMapFst(fst, Mapper(...)).
+// CTAD deduction guides
+// This allows constructing ArcMapFsts without specifying all the types.
 template <class ArcMapper>
-ArcMapFst<typename ArcMapper::FromArc, typename ArcMapper::ToArc, ArcMapper>
-MakeArcMapFst(const Fst<typename ArcMapper::FromArc> &fst,
-              const ArcMapper &mapper) {
-  return ArcMapFst<typename ArcMapper::FromArc, typename ArcMapper::ToArc,
-                   ArcMapper>(fst, mapper);
-}
+ArcMapFst(const Fst<typename ArcMapper::FromArc> &, const ArcMapper &)
+    -> ArcMapFst<typename ArcMapper::FromArc, typename ArcMapper::ToArc,
+                 ArcMapper>;
 
-// Constructs and returns an ArcMapFst. As above, but using the
-// ArcMapFst(..., ArcMapper *) constructor.
+// As above, but using the ArcMapFst(..., ArcMapper *) constructor.
 template <class ArcMapper>
-ArcMapFst<typename ArcMapper::FromArc, typename ArcMapper::ToArc, ArcMapper>
-MakeArcMapFst(const Fst<typename ArcMapper::FromArc> &fst, ArcMapper *mapper) {
-  return ArcMapFst<typename ArcMapper::FromArc, typename ArcMapper::ToArc,
-                   ArcMapper>(fst, mapper);
-}
+ArcMapFst(const Fst<typename ArcMapper::FromArc> &, ArcMapper *)
+    -> ArcMapFst<typename ArcMapper::FromArc, typename ArcMapper::ToArc,
+                 ArcMapper>;
 
 // Utility Mappers.
 
@@ -684,7 +678,7 @@ class IdentityArcMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const { return props; }
+  constexpr uint64_t Properties(uint64_t props) const { return props; }
 };
 
 // Mapper that converts all input symbols to epsilon.
@@ -708,7 +702,7 @@ class InputEpsilonMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return (props & kSetArcProperties) | kIEpsilons | kILabelSorted;
   }
 };
@@ -734,7 +728,7 @@ class OutputEpsilonMapper {
     return MAP_CLEAR_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return (props & kSetArcProperties) | kOEpsilons | kOLabelSorted;
   }
 };
@@ -774,7 +768,7 @@ class SuperFinalMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     if (final_label_ == 0) {
       return props & kAddSuperFinalProperties;
     } else {
@@ -819,7 +813,7 @@ class WeightConvertMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const { return props; }
+  constexpr uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   const Converter convert_weight_;
@@ -881,7 +875,7 @@ class ToGallicMapper {
     return MAP_CLEAR_SYMBOLS;
   }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     return ProjectProperties(props, true) & kWeightInvariantProperties;
   }
 };
@@ -931,9 +925,9 @@ class FromGallicMapper {
     return MAP_CLEAR_SYMBOLS;
   }
 
-  uint64 Properties(uint64 inprops) const {
-    uint64 outprops = inprops & kOLabelInvariantProperties &
-                      kWeightInvariantProperties & kAddSuperFinalProperties;
+  uint64_t Properties(uint64_t inprops) const {
+    uint64_t outprops = inprops & kOLabelInvariantProperties &
+                        kWeightInvariantProperties & kAddSuperFinalProperties;
     if (error_) outprops |= kError;
     return outprops;
   }
@@ -995,7 +989,7 @@ class GallicToNewSymbolsMapper {
       std::string name = osymbols_->Name() + "_from_gallic";
       fst_->SetInputSymbols(new SymbolTable(name));
       isymbols_ = fst_->MutableInputSymbols();
-      const int64 zero = 0;
+      const int64_t zero = 0;
       isymbols_->AddSymbol(osymbols_->Find(zero), 0);
     } else {
       fst_->SetInputSymbols(nullptr);
@@ -1012,27 +1006,23 @@ class GallicToNewSymbolsMapper {
     Label l;
     if (w1.Size() == 0) {
       l = 0;
+    } else if (auto [it, inserted] = map_.emplace(w1, kNoLabel); !inserted) {
+      l = it->second;
     } else {
-      auto insert_result = map_.emplace(w1, kNoLabel);
-      if (!insert_result.second) {
-        l = insert_result.first->second;
-      } else {
-        l = ++lmax_;
-        insert_result.first->second = l;
-        StringWeightIterator<SW> iter1(w1);
-        StateId n;
-        std::string s;
-        for (size_t i = 0, p = state_; i < w1.Size();
-             ++i, iter1.Next(), p = n) {
-          n = i == w1.Size() - 1 ? state_ : fst_->AddState();
-          fst_->AddArc(p, ToArc(i ? 0 : l, iter1.Value(), n));
-          if (isymbols_) {
-            if (i) s = s + "_";
-            s = s + osymbols_->Find(iter1.Value());
-          }
+      l = ++lmax_;
+      it->second = l;
+      StringWeightIterator<SW> iter1(w1);
+      StateId n;
+      std::string s;
+      for (size_t i = 0, p = state_; i < w1.Size(); ++i, iter1.Next(), p = n) {
+        n = i == w1.Size() - 1 ? state_ : fst_->AddState();
+        fst_->AddArc(p, ToArc(i ? 0 : l, iter1.Value(), n));
+        if (isymbols_) {
+          if (i) s = s + "_";
+          s = s + osymbols_->Find(iter1.Value());
         }
-        if (isymbols_) isymbols_->AddSymbol(s, l);
       }
+      if (isymbols_) isymbols_->AddSymbol(s, l);
     }
     if (l == kStringInfinity || l == kStringBad || arc.ilabel != arc.olabel) {
       FSTERROR() << "GallicToNewSymbolMapper: Unrepresentable weight: " << l;
@@ -1051,9 +1041,9 @@ class GallicToNewSymbolsMapper {
     return MAP_CLEAR_SYMBOLS;
   }
 
-  uint64 Properties(uint64 inprops) const {
-    uint64 outprops = inprops & kOLabelInvariantProperties &
-                      kWeightInvariantProperties & kAddSuperFinalProperties;
+  uint64_t Properties(uint64_t inprops) const {
+    uint64_t outprops = inprops & kOLabelInvariantProperties &
+                        kWeightInvariantProperties & kAddSuperFinalProperties;
     if (error_) outprops |= kError;
     return outprops;
   }
@@ -1104,7 +1094,7 @@ class PlusMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return props & kWeightInvariantProperties;
   }
 
@@ -1138,7 +1128,7 @@ class TimesMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return props & kWeightInvariantProperties;
   }
 
@@ -1175,7 +1165,7 @@ class PowerMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return props & kWeightInvariantProperties;
   }
 
@@ -1207,7 +1197,7 @@ class InvertWeightMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return props & kWeightInvariantProperties;
   }
 };
@@ -1238,7 +1228,7 @@ class RmWeightMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return (props & kWeightInvariantProperties) | kUnweighted;
   }
 };
@@ -1271,7 +1261,7 @@ class QuantizeMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return props & kWeightInvariantProperties;
   }
 
@@ -1291,6 +1281,14 @@ class ReverseWeightMapper {
  public:
   using FromArc = A;
   using ToArc = B;
+  static_assert(std::is_same_v<typename ToArc::Weight,
+                               typename FromArc::Weight::ReverseWeight>,
+                "ToArc::Weight must be FromArc::Weight::ReverseWeight");
+  static_assert(std::is_same_v<typename ToArc::Label, typename FromArc::Label>,
+                "ToArc::Label must be FromArc::Label");
+  static_assert(
+      std::is_same_v<typename ToArc::StateId, typename FromArc::StateId>,
+      "ToArc::StateId must be FromArc::StateId");
 
   constexpr ToArc operator()(const FromArc &arc) const {
     return ToArc(arc.ilabel, arc.olabel, arc.weight.Reverse(), arc.nextstate);
@@ -1306,7 +1304,7 @@ class ReverseWeightMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const { return props; }
+  constexpr uint64_t Properties(uint64_t props) const { return props; }
 };
 
 }  // namespace fst
index f8ff51d..f0f5881 100644 (file)
@@ -21,6 +21,7 @@
 #define FST_ARC_H_
 
 #include <climits>
+#include <cstdint>
 #include <string>
 #include <type_traits>
 #include <utility>
@@ -51,7 +52,7 @@ struct ArcTpl {
   Weight weight;
   StateId nextstate;
 
-  ArcTpl() noexcept(std::is_nothrow_default_constructible<Weight>::value) {}
+  ArcTpl() noexcept(std::is_nothrow_default_constructible_v<Weight>) {}
 
   template <class T>
   ArcTpl(Label ilabel, Label olabel, T &&weight, StateId nextstate)
@@ -197,65 +198,11 @@ struct ReverseArc {
 
 // Arc with integer labels and state IDs and lexicographic weights.
 template <class Weight1, class Weight2>
-struct LexicographicArc {
-  using Label = int;
-  using StateId = int;
-  using Weight = LexicographicWeight<Weight1, Weight2>;
-
-  Label ilabel;
-  Label olabel;
-  Weight weight;
-  StateId nextstate;
-
-  LexicographicArc() = default;
-
-  template <class T>
-  LexicographicArc(Label ilabel, Label olabel, T &&weight, StateId nextstate)
-      : ilabel(ilabel),
-        olabel(olabel),
-        weight(std::forward<T>(weight)),
-        nextstate(nextstate) {}
-
-  // Arc with weight One.
-  LexicographicArc(Label ilabel, Label olabel, StateId nextstate)
-      : LexicographicArc(ilabel, olabel, Weight::One(), nextstate) {}
-
-  static const std::string &Type() {
-    static const std::string *const type = new std::string(Weight::Type());
-    return *type;
-  }
-};
+using LexicographicArc = ArcTpl<LexicographicWeight<Weight1, Weight2>>;
 
 // Arc with integer labels and state IDs and product weights.
 template <class Weight1, class Weight2>
-struct ProductArc {
-  using Label = int;
-  using StateId = int;
-  using Weight = ProductWeight<Weight1, Weight2>;
-
-  Label ilabel;
-  Label olabel;
-  Weight weight;
-  StateId nextstate;
-
-  ProductArc() = default;
-
-  template <class T>
-  ProductArc(Label ilabel, Label olabel, T &&weight, StateId nextstate)
-      : ilabel(ilabel),
-        olabel(olabel),
-        weight(std::forward<T>(weight)),
-        nextstate(nextstate) {}
-
-  // Arc with weight One.
-  ProductArc(Label ilabel, Label olabel, StateId nextstate)
-      : ProductArc(ilabel, olabel, Weight::One(), nextstate) {}
-
-  static const std::string &Type() {
-    static const auto *const type = new std::string(Weight::Type());
-    return *type;
-  }
-};
+using ProductArc = ArcTpl<ProductWeight<Weight1, Weight2>>;
 
 // Arc with label and state ID type the same as first template argument and with
 // weights over the n-th Cartesian power of the weight type of the template
@@ -322,7 +269,7 @@ struct SparsePowerArc {
   static const std::string &Type() {
     static const std::string *const type = [] {
       std::string type = Arc::Type() + "_^n";
-      if (sizeof(K) != sizeof(uint32)) {
+      if (sizeof(K) != sizeof(uint32_t)) {
         type += "_" + std::to_string(CHAR_BIT * sizeof(K));
       }
       return new std::string(type);
index 8558a73..26023f6 100644 (file)
 #define FST_ARCSORT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
-
 #include <fst/cache.h>
 #include <fst/state-map.h>
 #include <fst/test-properties.h>
@@ -61,7 +60,7 @@ class ArcSortMapper {
     for (ArcIterator<Fst<Arc>> aiter(fst_, s); !aiter.Done(); aiter.Next()) {
       arcs_.push_back(aiter.Value());
     }
-    std::sort(arcs_.begin(), arcs_.end(), comp_);
+    std::stable_sort(arcs_.begin(), arcs_.end(), comp_);
   }
 
   bool Done() const { return i_ >= arcs_.size(); }
@@ -74,7 +73,7 @@ class ArcSortMapper {
 
   MapSymbolsAction OutputSymbolsAction() const { return MAP_COPY_SYMBOLS; }
 
-  uint64 Properties(uint64 props) const { return comp_.Properties(props); }
+  uint64_t Properties(uint64_t props) const { return comp_.Properties(props); }
 
  private:
   const Fst<Arc> &fst_;
@@ -89,7 +88,7 @@ class ArcSortMapper {
 // This version modifies its input. Comparison function objects ILabelCompare
 // and OLabelCompare are provided by the library. In general, Compare must meet
 // the requirements for a  comparison function object (e.g., similar to those
-// used by std::sort). It must also have a member Properties(uint64) that
+// used by std::sort). It must also have a member Properties(uint64_t) that
 // specifies the known properties of the sorted FST; it takes as argument the
 // input FST's known properties before the sort.
 //
@@ -111,7 +110,7 @@ using ArcSortFstOptions = CacheOptions;
 // This version is a delayed FST. Comparsion function objects ILabelCompare and
 // OLabelCompare are provided by the library. In general, Compare must meet the
 // requirements for a comparision function object (e.g., similar to those
-// used by std::sort). It must also have a member Properties(uint64) that
+// used by std::sort). It must also have a member Properties(uint64_t) that
 // specifies the known properties of the sorted FST; it takes as argument the
 // input FST's known properties.
 //
@@ -192,7 +191,7 @@ class ILabelCompare {
            std::forward_as_tuple(rhs.ilabel, rhs.olabel);
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return (props & kArcSortProperties) | kILabelSorted |
            (props & kAcceptor ? kOLabelSorted : 0);
   }
@@ -209,7 +208,7 @@ class OLabelCompare {
            std::forward_as_tuple(rhs.olabel, rhs.ilabel);
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return (props & kArcSortProperties) | kOLabelSorted |
            (props & kAcceptor ? kILabelSorted : 0);
   }
index 3045f0c..9bc0305 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef FST_BI_TABLE_H_
 #define FST_BI_TABLE_H_
 
+#include <cstdint>
 #include <deque>
 #include <functional>
 #include <memory>
@@ -28,7 +29,6 @@
 #include <unordered_set>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/memory.h>
 #include <fst/windows_defs.inc>
@@ -116,8 +116,10 @@ enum HSType { HS_STL, HS_FLAT };
 // Default hash set is STL hash_set.
 template <class K, class H, class E, HSType HS>
 struct HashSet : public std::unordered_set<K, H, E, PoolAllocator<K>> {
-  explicit HashSet(size_t n = 0, const H &h = H(), const E &e = E())
-      : std::unordered_set<K, H, E, PoolAllocator<K>>(n, h, e) {}
+ private:
+  using Base = std::unordered_set<K, H, E, PoolAllocator<K>>;
+ public:
+  using Base::Base;
 
   void rehash(size_t n) {}
 };
@@ -147,25 +149,24 @@ class CompactHashBiTable {
     if (table_size) id2entry_.reserve(table_size);
   }
 
-  CompactHashBiTable(const CompactHashBiTable<I, T, H, E, HS> &table)
+  CompactHashBiTable(const CompactHashBiTable &table)
       : hash_func_(table.hash_func_),
         hash_equal_(table.hash_equal_),
         compact_hash_func_(*this),
         compact_hash_equal_(*this),
-        keys_(table.keys_.size(), compact_hash_func_, compact_hash_equal_),
-        id2entry_(table.id2entry_) {
-    keys_.insert(table.keys_.begin(), table.keys_.end());
-  }
+        id2entry_(table.id2entry_),
+        keys_(table.keys_.begin(), table.keys_.end(), table.keys_.size(),
+              compact_hash_func_, compact_hash_equal_) {}
 
   I FindId(const T &entry, bool insert = true) {
     current_entry_ = &entry;
     if (insert) {
-      auto result = keys_.insert(kCurrentKey);
-      if (!result.second) return *result.first;  // Already exists.
+      auto [iter, was_inserted] = keys_.insert(kCurrentKey);
+      if (!was_inserted) return *iter;  // Already exists.
       // Overwrites kCurrentKey with a new key value; this is safe because it
       // doesn't affect hashing or equality testing.
       I key = id2entry_.size();
-      const_cast<I &>(*result.first) = key;
+      const_cast<I &>(*iter) = key;
       id2entry_.push_back(entry);
       return key;
     }
@@ -198,7 +199,7 @@ class CompactHashBiTable {
   }
 
  private:
-  static_assert(std::is_signed<I>::value, "I must be a signed type");
+  static_assert(std::is_signed_v<I>, "I must be a signed type");
   // ... otherwise >= kCurrentKey comparisons as used below don't work.
   // TODO(rybach): (1) don't use >= for key comparison, (2) allow unsigned key
   // types.
@@ -252,14 +253,11 @@ class CompactHashBiTable {
   E hash_equal_;
   HashFunc compact_hash_func_;
   HashEqual compact_hash_equal_;
-  KeyHashSet keys_;
   std::vector<T> id2entry_;
+  KeyHashSet keys_;
   const T *current_entry_;
 };
 
-template <class I, class T, class H, class E, HSType HS>
-constexpr I CompactHashBiTable<I, T, H, E, HS>::kCurrentKey;
-
 // An implementation using a vector for the entry to ID mapping. It is passed a
 // function object FP that should fingerprint entries uniquely to an integer
 // that can used as a vector index. Normally, VectorBiTable constructs the FP
@@ -340,7 +338,7 @@ class VectorHashBiTable {
 
   I FindId(const T &entry, bool insert = true) {
     if ((selector_)(entry)) {  // Uses the vector if selector_(entry) == true.
-      uint64 fp = (fp_)(entry);
+      uint64_t fp = (fp_)(entry);
       if (fp2id_.size() <= fp) fp2id_.resize(fp + 1, 0);
       if (fp2id_[fp] == 0) {  // T not found.
         if (insert) {         // Stores and assigns a new ID.
@@ -439,9 +437,6 @@ class VectorHashBiTable {
   const T *current_entry_;
 };
 
-template <class I, class T, class S, class FP, class H, HSType HS>
-constexpr I VectorHashBiTable<I, T, S, FP, H, HS>::kCurrentKey;
-
 // An implementation using a hash map for the entry to ID mapping. This version
 // permits erasing of arbitrary states. The entry T must have == defined and
 // its default constructor must produce a entry that will never be seen. F is
index b8b7465..58a022c 100644 (file)
 #define FST_CACHE_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <functional>
 #include <list>
+#include <memory>
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/vector-fst.h>
@@ -69,11 +70,11 @@ struct CacheImplOptions {
 };
 
 // Cache flags.
-constexpr uint8 kCacheFinal = 0x01;   // Final weight has been cached.
-constexpr uint8 kCacheArcs = 0x02;    // Arcs have been cached.
-constexpr uint8 kCacheInit = 0x04;    // Initialized by GC.
-constexpr uint8 kCacheRecent = 0x08;  // Visited since GC.
-constexpr uint8 kCacheFlags =
+inline constexpr uint8_t kCacheFinal = 0x01;   // Final weight has been cached.
+inline constexpr uint8_t kCacheArcs = 0x02;    // Arcs have been cached.
+inline constexpr uint8_t kCacheInit = 0x04;    // Initialized by GC.
+inline constexpr uint8_t kCacheRecent = 0x08;  // Visited since GC.
+inline constexpr uint8_t kCacheFlags =
     kCacheFinal | kCacheArcs | kCacheInit | kCacheRecent;
 
 // Cache state, with arcs stored in a per-state std::vector.
@@ -86,8 +87,8 @@ class CacheState {
   using Weight = typename Arc::Weight;
 
   using ArcAllocator = M;
-  using StateAllocator =
-      typename ArcAllocator::template rebind<CacheState<A, M>>::other;
+  using StateAllocator = typename std::allocator_traits<
+      ArcAllocator>::template rebind_alloc<CacheState<A, M>>;
 
   // Provides STL allocator for arcs.
   explicit CacheState(const ArcAllocator &alloc)
@@ -129,7 +130,7 @@ class CacheState {
   const Arc *Arcs() const { return !arcs_.empty() ? &arcs_[0] : nullptr; }
 
   // Accesses flags; used by the caller.
-  uint8 Flags() const { return flags_; }
+  uint8_t Flags() const { return flags_; }
 
   // Accesses ref count; used by the caller.
   int RefCount() const { return ref_count_; }
@@ -194,7 +195,7 @@ class CacheState {
   }
 
   // Sets status flags; used by the caller.
-  void SetFlags(uint8 flags, uint8 mask) const {
+  void SetFlags(uint8_t flags, uint8_t mask) const {
     flags_ &= ~mask;
     flags_ |= flags;
   }
@@ -232,7 +233,7 @@ class CacheState {
   size_t niepsilons_;                    // # of input epsilons.
   size_t noepsilons_;                    // # of output epsilons.
   std::vector<Arc, ArcAllocator> arcs_;  // Arcs representation.
-  mutable uint8 flags_;
+  mutable uint8_t flags_;
   mutable int ref_count_;  // If 0, available for GC.
 };
 
@@ -483,8 +484,8 @@ class HashCacheStore {
 
   // Deletes all cached states.
   void Clear() {
-    for (auto it = state_map_.begin(); it != state_map_.end(); ++it) {
-      State::Destroy(it->second, &state_alloc_);
+    for (auto &[unused_state_id, state_ptr] : state_map_) {
+      State::Destroy(state_ptr, &state_alloc_);
     }
     state_map_.clear();
   }
@@ -509,10 +510,8 @@ class HashCacheStore {
  private:
   void CopyStates(const HashCacheStore<State> &store) {
     Clear();
-    for (auto it = store.state_map_.begin(); it != store.state_map_.end();
-         ++it) {
-      state_map_[it->first] =
-          new (&state_alloc_) State(*it->second, arc_alloc_);
+    for (auto &[state_id, state_ptr] : store.state_map_) {
+      state_map_[state_id] = new (&state_alloc_) State(*state_ptr, arc_alloc_);
     }
   }
 
@@ -824,9 +823,6 @@ void GCCacheStore<CacheStore>::GC(const State *current, bool free_recent,
           << ", cache limit = " << cache_limit_ << "\n";
 }
 
-template <class CacheStore>
-constexpr size_t GCCacheStore<CacheStore>::kMinCacheLimit;
-
 // This class is the default cache state and store used by CacheBaseImpl.
 // It uses VectorCacheStore for storage decorated by FirstCacheStore
 // and GCCacheStore to do (optional) garbage collection.
@@ -1223,9 +1219,9 @@ class CacheArcIterator {
 
   void Seek(size_t a) { i_ = a; }
 
-  constexpr uint8 Flags() const { return kArcValueFlags; }
+  constexpr uint8_t Flags() const { return kArcValueFlags; }
 
-  void SetFlags(uint8 flags, uint8 mask) {}
+  void SetFlags(uint8_t flags, uint8_t mask) {}
 
  private:
   const State *state_;
@@ -1271,9 +1267,9 @@ class CacheMutableArcIterator
 
   void SetValue(const Arc &arc) final { state_->SetArc(arc, i_); }
 
-  uint8 Flags() const final { return kArcValueFlags; }
+  uint8_t Flags() const final { return kArcValueFlags; }
 
-  void SetFlags(uint8, uint8) final {}
+  void SetFlags(uint8_t, uint8_t) final {}
 
  private:
   size_t i_;
index ee14f5e..b2cf3d3 100644 (file)
@@ -23,7 +23,6 @@
 #include <algorithm>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/mutable-fst.h>
 #include <fst/rational.h>
index d55fa0a..5202e02 100644 (file)
 #define FST_COMPACT_FST_H_
 
 #include <climits>
+#include <cstdint>
 #include <iterator>
 #include <memory>
 #include <tuple>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
@@ -87,7 +87,7 @@ struct CompactFstOptions : public CacheOptions {
 //     size_t NumArcs() const;
 //     // Gets the 'i'th arc for the state. Requires i < NumArcs().
 //     // Flags are a bitmask of the kArc*Value flags that ArcIterator uses.
-//     Arc GetArc(size_t i, uint8 flags) const;
+//     Arc GetArc(size_t i, uint8_t flags) const;
 //   };
 //
 //   // Modifies 'state' accessor to provide access to state id 's'.
@@ -101,7 +101,7 @@ struct CompactFstOptions : public CacheOptions {
 //   // specified properties is compacted using this compactor.
 //   // This function should clear bits for properties that no longer
 //   // hold and set those for properties that are known to hold.
-//   uint64 Properties(uint64 props) const;
+//   uint64_t Properties(uint64_t props) const;
 //
 //   // Returns a string identifying the type of compactor.
 //   static const std::string &Type();
@@ -177,7 +177,7 @@ struct CompactFstOptions : public CacheOptions {
 //   // Returns the properties that are always true for an FST compacted using
 //   // this compactor. Any Fst with the inverse of these properties should
 //   // be incompatible.
-//   uint64 Properties() const;
+//   uint64_t Properties() const;
 //
 //   // Returns a string identifying the type of compactor.
 //   static const std::string &Type();
@@ -632,7 +632,7 @@ class CompactArcCompactor {
     return arc_compactor_->Write(strm) && compact_store_->Write(strm, opts);
   }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     // ArcCompactor properties can just be or-ed in since it is assumed that
     // if the ArcCompactor sets a property, any FST with the inverse
     // property is incompatible.
@@ -650,7 +650,7 @@ class CompactArcCompactor {
   static const std::string &Type() {
     static const std::string *const type = [] {
       std::string type = "compact";
-      if (sizeof(U) != sizeof(uint32)) type += std::to_string(8 * sizeof(U));
+      if (sizeof(U) != sizeof(uint32_t)) type += std::to_string(8 * sizeof(U));
       type += "_";
       type += ArcCompactor::Type();
       if (CompactStore::Type() != "compact") {
@@ -672,7 +672,7 @@ class CompactArcCompactor {
   std::shared_ptr<CompactStore> SharedCompactStore() { return compact_store_; }
 
   // TODO(allauzen): remove dependencies on this method and make private.
-  Arc ComputeArc(StateId s, Unsigned i, uint8 flags) const {
+  Arc ComputeArc(StateId s, Unsigned i, uint8_t flags) const {
     return arc_compactor_->Expand(s, compact_store_->Compacts(i), flags);
   }
 
@@ -744,7 +744,7 @@ class CompactArcState {
 
   size_t NumArcs() const { return range_.second; }
 
-  Arc GetArc(size_t i, uint8 flags) const {
+  Arc GetArc(size_t i, uint8_t flags) const {
     return compactor_->ComputeArc(s_, range_.first + i, flags);
   }
 
@@ -789,7 +789,7 @@ class CompactArcState<ArcCompactor, U,
 
   size_t NumArcs() const { return num_arcs_; }
 
-  Arc GetArc(size_t i, uint8 flags) const {
+  Arc GetArc(size_t i, uint8_t flags) const {
     return arc_compactor_->Expand(s_, compacts_[i], flags);
   }
 
@@ -881,7 +881,7 @@ class CompactFstImpl
     SetInputSymbols(fst.InputSymbols());
     SetOutputSymbols(fst.OutputSymbols());
     if (compactor_->Error()) SetProperties(kError, kError);
-    uint64 copy_properties =
+    uint64_t copy_properties =
         fst.Properties(kMutable, false)
             ? fst.Properties(kCopyProperties, true)
             : CheckProperties(
@@ -966,7 +966,7 @@ class CompactFstImpl
 
   size_t CountEpsilons(StateId s, bool output_epsilons) {
     compactor_->SetState(s, &state_);
-    const uint8 flags = output_epsilons ? kArcOLabelValue : kArcILabelValue;
+    const uint8_t flags = output_epsilons ? kArcOLabelValue : kArcILabelValue;
     size_t num_eps = 0;
     const size_t num_arcs = state_.NumArcs();
     for (size_t i = 0; i < num_arcs; ++i) {
@@ -1041,7 +1041,7 @@ class CompactFstImpl
   }
 
   // Properties always true of this FST class.
-  static constexpr uint64 kStaticProperties = kExpanded;
+  static constexpr uint64_t kStaticProperties = kExpanded;
 
  protected:
   template <class OtherArc, class OtherCompactor, class OtherCacheStore>
@@ -1073,18 +1073,6 @@ class CompactFstImpl
   typename Compactor::State state_;
 };
 
-template <class Arc, class Compactor, class CacheStore>
-constexpr uint64 CompactFstImpl<Arc, Compactor, CacheStore>::kStaticProperties;
-
-template <class Arc, class Compactor, class CacheStore>
-constexpr int CompactFstImpl<Arc, Compactor, CacheStore>::kFileVersion;
-
-template <class Arc, class Compactor, class CacheStore>
-constexpr int CompactFstImpl<Arc, Compactor, CacheStore>::kAlignedFileVersion;
-
-template <class Arc, class Compactor, class CacheStore>
-constexpr int CompactFstImpl<Arc, Compactor, CacheStore>::kMinFileVersion;
-
 // Returns the compactor for the CompactFst; intended to be called as
 // GetCompactor<CompactorType>(fst), which returns the compactor only if it
 // is of the specified type and otherwise nullptr (via the overload below).
@@ -1261,7 +1249,7 @@ bool WriteCompactArcFst(
   hdr.SetNumStates(num_states);
   hdr.SetNumArcs(num_arcs);
   std::string type = "compact";
-  if (sizeof(Unsigned) != sizeof(uint32)) {
+  if (sizeof(Unsigned) != sizeof(uint32_t)) {
     type += std::to_string(CHAR_BIT * sizeof(Unsigned));
   }
   type += "_";
@@ -1275,7 +1263,7 @@ bool WriteCompactArcFst(
     FSTERROR() << "Fst incompatible with compactor";
     return false;
   }
-  uint64 properties = copy_properties | Impl::kStaticProperties;
+  uint64_t properties = copy_properties | Impl::kStaticProperties;
   internal::FstImpl<Arc>::WriteFstHeader(fst, strm, opts, file_version, type,
                                          properties, &hdr);
   first_pass_arc_compactor.Write(strm);
@@ -1372,9 +1360,9 @@ class ArcIterator<CompactFst<Arc, Compactor, CacheStore>> {
 
   void Seek(size_t pos) { pos_ = pos; }
 
-  uint8 Flags() const { return flags_; }
+  uint8_t Flags() const { return flags_; }
 
-  void SetFlags(uint8 flags, uint8 mask) {
+  void SetFlags(uint8_t flags, uint8_t mask) {
     flags_ &= ~mask;
     flags_ |= (flags & kArcValueFlags);
   }
@@ -1385,7 +1373,7 @@ class ArcIterator<CompactFst<Arc, Compactor, CacheStore>> {
   // Cache the value of NumArcs(), since it is used in Done() and may be slow.
   size_t num_arcs_;
   mutable Arc arc_;
-  uint8 flags_;
+  uint8_t flags_;
 };
 
 // ArcCompactor for unweighted string FSTs.
@@ -1401,13 +1389,14 @@ class StringCompactor {
 
   Element Compact(StateId s, const Arc &arc) const { return arc.ilabel; }
 
-  Arc Expand(StateId s, const Element &p, uint8 flags = kArcValueFlags) const {
+  Arc Expand(StateId s, const Element &p,
+             uint8_t flags = kArcValueFlags) const {
     return Arc(p, p, Weight::One(), p != kNoLabel ? s + 1 : kNoStateId);
   }
 
   constexpr ssize_t Size() const { return 1; }
 
-  constexpr uint64 Properties() const { return kCompiledStringProperties; }
+  constexpr uint64_t Properties() const { return kCompiledStringProperties; }
 
   bool Compatible(const Fst<Arc> &fst) const {
     const auto props = Properties();
@@ -1441,14 +1430,15 @@ class WeightedStringCompactor {
     return std::make_pair(arc.ilabel, arc.weight);
   }
 
-  Arc Expand(StateId s, const Element &p, uint8 flags = kArcValueFlags) const {
+  Arc Expand(StateId s, const Element &p,
+             uint8_t flags = kArcValueFlags) const {
     return Arc(p.first, p.first, p.second,
                p.first != kNoLabel ? s + 1 : kNoStateId);
   }
 
   constexpr ssize_t Size() const { return 1; }
 
-  constexpr uint64 Properties() const { return kString | kAcceptor; }
+  constexpr uint64_t Properties() const { return kString | kAcceptor; }
 
   bool Compatible(const Fst<Arc> &fst) const {
     const auto props = Properties();
@@ -1482,13 +1472,14 @@ class UnweightedAcceptorCompactor {
     return std::make_pair(arc.ilabel, arc.nextstate);
   }
 
-  Arc Expand(StateId s, const Element &p, uint8 flags = kArcValueFlags) const {
+  Arc Expand(StateId s, const Element &p,
+             uint8_t flags = kArcValueFlags) const {
     return Arc(p.first, p.first, Weight::One(), p.second);
   }
 
   constexpr ssize_t Size() const { return -1; }
 
-  constexpr uint64 Properties() const { return kAcceptor | kUnweighted; }
+  constexpr uint64_t Properties() const { return kAcceptor | kUnweighted; }
 
   bool Compatible(const Fst<Arc> &fst) const {
     const auto props = Properties();
@@ -1524,13 +1515,14 @@ class AcceptorCompactor {
                           arc.nextstate);
   }
 
-  Arc Expand(StateId s, const Element &p, uint8 flags = kArcValueFlags) const {
+  Arc Expand(StateId s, const Element &p,
+             uint8_t flags = kArcValueFlags) const {
     return Arc(p.first.first, p.first.first, p.first.second, p.second);
   }
 
   constexpr ssize_t Size() const { return -1; }
 
-  constexpr uint64 Properties() const { return kAcceptor; }
+  constexpr uint64_t Properties() const { return kAcceptor; }
 
   bool Compatible(const Fst<Arc> &fst) const {
     const auto props = Properties();
@@ -1565,13 +1557,14 @@ class UnweightedCompactor {
                           arc.nextstate);
   }
 
-  Arc Expand(StateId s, const Element &p, uint8 flags = kArcValueFlags) const {
+  Arc Expand(StateId s, const Element &p,
+             uint8_t flags = kArcValueFlags) const {
     return Arc(p.first.first, p.first.second, Weight::One(), p.second);
   }
 
   constexpr ssize_t Size() const { return -1; }
 
-  constexpr uint64 Properties() const { return kUnweighted; }
+  constexpr uint64_t Properties() const { return kUnweighted; }
 
   bool Compatible(const Fst<Arc> &fst) const {
     const auto props = Properties();
@@ -1590,38 +1583,38 @@ class UnweightedCompactor {
   }
 };
 
-template <class Arc, class Unsigned /* = uint32 */>
+template <class Arc, class Unsigned /* = uint32_t */>
 using CompactStringFst = CompactArcFst<Arc, StringCompactor<Arc>, Unsigned>;
 
-template <class Arc, class Unsigned /* = uint32 */>
+template <class Arc, class Unsigned /* = uint32_t */>
 using CompactWeightedStringFst =
     CompactArcFst<Arc, WeightedStringCompactor<Arc>, Unsigned>;
 
-template <class Arc, class Unsigned /* = uint32 */>
+template <class Arc, class Unsigned /* = uint32_t */>
 using CompactAcceptorFst = CompactArcFst<Arc, AcceptorCompactor<Arc>, Unsigned>;
 
-template <class Arc, class Unsigned /* = uint32 */>
+template <class Arc, class Unsigned /* = uint32_t */>
 using CompactUnweightedFst =
     CompactArcFst<Arc, UnweightedCompactor<Arc>, Unsigned>;
 
-template <class Arc, class Unsigned /* = uint32 */>
+template <class Arc, class Unsigned /* = uint32_t */>
 using CompactUnweightedAcceptorFst =
     CompactArcFst<Arc, UnweightedAcceptorCompactor<Arc>, Unsigned>;
 
-using StdCompactStringFst = CompactStringFst<StdArc, uint32>;
+using StdCompactStringFst = CompactStringFst<StdArc, uint32_t>;
 
-using StdCompactWeightedStringFst = CompactWeightedStringFst<StdArc, uint32>;
+using StdCompactWeightedStringFst = CompactWeightedStringFst<StdArc, uint32_t>;
 
-using StdCompactAcceptorFst = CompactAcceptorFst<StdArc, uint32>;
+using StdCompactAcceptorFst = CompactAcceptorFst<StdArc, uint32_t>;
 
-using StdCompactUnweightedFst = CompactUnweightedFst<StdArc, uint32>;
+using StdCompactUnweightedFst = CompactUnweightedFst<StdArc, uint32_t>;
 
 using StdCompactUnweightedAcceptorFst =
-    CompactUnweightedAcceptorFst<StdArc, uint32>;
+    CompactUnweightedAcceptorFst<StdArc, uint32_t>;
 
 // Convenience function to make a CompactStringFst from a sequence
 // of Arc::Labels. LabelIterator must be an input iterator.
-template <class Arc, class Unsigned = uint32, class LabelIterator>
+template <class Arc, class Unsigned = uint32_t, class LabelIterator>
 inline CompactStringFst<Arc, Unsigned> MakeCompactStringFst(
     const LabelIterator begin, const LabelIterator end) {
   using CompactStringFst = CompactStringFst<Arc, Unsigned>;
index e15aeeb..b7f2087 100644 (file)
@@ -1,11 +1,13 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Copyright 2005-2020 Google LLC
+//
+// 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
+//     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,
+// 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.
 // See www.openfst.org for extensive documentation on this weighted
 // finite-state transducer library.
 
-#ifndef FST_LIB_COMPAT_H_
-#define FST_LIB_COMPAT_H_
+#ifndef FST_COMPAT_H_
+#define FST_COMPAT_H_
 
+#include <algorithm>
 #include <climits>
+#include <cstdint>
 #include <cstdlib>
 #include <cstring>
 #include <iostream>
 #include <memory>
+#include <numeric>
 #include <string>
+#include <string_view>
 #include <type_traits>
 #include <utility>
 #include <vector>
 #if defined(__GNUC__) || defined(__clang__)
 #define OPENFST_DEPRECATED(message) __attribute__((deprecated(message)))
 #elif defined(_MSC_VER)
-#define OPENFST_DEPRECATED(message) __declspec(deprecated(message))
+#define OPENFST_DEPRECATED(message) [[deprecated(message)]]
 #else
 #define OPENFST_DEPRECATED(message)
 #endif
 
-#include <fst/config.h>
-#include <fst/types.h>
-#include <fst/lock.h>
-#include <fst/flags.h>
-#include <fst/log.h>
-#include <fst/icu.h>
-
 void FailedNewHandler();
 
 namespace fst {
@@ -69,18 +68,19 @@ inline Dest bit_cast(const Source &source) {
 
 namespace internal {
 
+// TODO(kbg): Remove this once we migrate to C++20.
 template <typename T>
-struct identity {
-  typedef T type;
+struct type_identity {
+  using type = T;
 };
 
 template <typename T>
-using identity_t = typename identity<T>::type;
+using type_identity_t = typename type_identity<T>::type;
 
 }  // namespace internal
 
 template <typename To>
-constexpr To implicit_cast(typename internal::identity_t<To> to) {
+constexpr To implicit_cast(typename internal::type_identity_t<To> to) {
   return to;
 }
 
@@ -91,14 +91,12 @@ class CheckSummer {
 
   void Reset();
 
-  void Update(void const *data, int size);
-
-  void Update(std::string const &data);
+  void Update(std::string_view data);
 
   std::string Digest() { return check_sum_; }
 
  private:
-  constexpr static int kCheckSumLength = 32;
+  static constexpr int kCheckSumLength = 32;
   int count_;
   std::string check_sum_;
 
@@ -107,7 +105,10 @@ class CheckSummer {
 };
 
 // Defines make_unique_for_overwrite using a standard definition that should be
-// compatible with the C++20 definition.
+// compatible with the C++20 definition. That is, all compiling uses of
+// `std::make_unique_for_overwrite` should have the same result with
+// `fst::make_unique_for_overwrite`. Note that the reverse doesn't
+// necessarily hold.
 // TODO(kbg): Remove these once we migrate to C++20.
 
 template <typename T>
@@ -116,8 +117,8 @@ std::unique_ptr<T> make_unique_for_overwrite() {
 }
 
 template <typename T>
-std::unique_ptr<T[]> make_unique_for_overwrite(size_t n) {
-  return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]);
+std::unique_ptr<T> make_unique_for_overwrite(size_t n) {
+  return std::unique_ptr<T>(new std::remove_extent_t<T>[n]);
 }
 
 template <typename T>
@@ -161,36 +162,110 @@ iterator_range<T> make_range(T x, T y) {
 
 // String munging.
 
-std::string StringJoin(const std::vector<std::string> &elements,
-                       const std::string &delim);
+namespace internal {
 
-std::string StringJoin(const std::vector<std::string> &elements,
-                       const char *delim);
+// Computes size of joined string.
+template <class S>
+size_t GetResultSize(const std::vector<S> &elements, size_t s_size) {
+  const auto lambda = [](size_t partial, const S &right) {
+    return partial + right.size();
+  };
+  return std::accumulate(elements.begin(), elements.end(), 0, lambda) +
+         elements.size() * s_size - s_size;
+}
 
-std::string StringJoin(const std::vector<std::string> &elements, char delim);
+}  // namespace internal
 
-std::vector<std::string> StringSplit(const std::string &full,
-                                     const std::string &delim);
+template <class S>
+std::string StringJoin(const std::vector<S> &elements, std::string_view delim) {
+  std::string result;
+  if (elements.empty()) return result;
+  const size_t s_size = delim.size();
+  result.reserve(internal::GetResultSize(elements, s_size));
+  auto it = elements.begin();
+  result.append(it->data(), it->size());
+  for (++it; it != elements.end(); ++it) {
+    result.append(delim.data(), s_size);
+    result.append(it->data(), it->size());
+  }
+  return result;
+}
 
-std::vector<std::string> StringSplit(const std::string &full,
-                                     const char *delim);
+template <class S>
+std::string StringJoin(const std::vector<S> &elements, char delim) {
+  const std::string_view view_delim(&delim, 1);
+  return StringJoin(elements, view_delim);
+}
 
-std::vector<std::string> StringSplit(const std::string &full, char delim);
+struct SkipEmpty {};
+
+struct ByAnyChar {
+ public:
+  explicit ByAnyChar(std::string_view sp) : delimiters(sp) {}
+
+  std::string delimiters;
+};
+
+namespace internal {
+
+class StringSplitter {
+ public:
+  using const_iterator = std::vector<std::string_view>::const_iterator;
+  using value_type = std::string_view;
+
+  StringSplitter(std::string_view string, std::string delim,
+                 bool skip_empty = false)
+      : string_(std::move(string)),
+        delim_(std::move(delim)),
+        skip_empty_(skip_empty),
+        vec_(SplitToSv()) {}
+
+  inline operator  // NOLINT(google-explicit-constructor)
+      std::vector<std::string_view>() && {
+    return std::move(vec_);
+  }
+
+  inline operator  // NOLINT(google-explicit-constructor)
+      std::vector<std::string>() {
+    std::vector<std::string> str_vec(vec_.begin(), vec_.end());
+    return str_vec;
+  }
+
+  const_iterator begin() const { return vec_.begin(); }
+  const_iterator end() const { return vec_.end(); }
+
+ private:
+  std::vector<std::string_view> SplitToSv();
+
+  std::string_view string_;
+  std::string delim_;
+  bool skip_empty_;
+  std::vector<std::string_view> vec_;
+};
+
+}  // namespace internal
+
+// `StrSplit` replacements. Only support splitting on `char` or
+// `ByAnyChar` (notable not on a multi-char string delimiter), and with or
+// without `SkipEmpty`.
+internal::StringSplitter StrSplit(std::string_view full, ByAnyChar delim);
+internal::StringSplitter StrSplit(std::string_view full, char delim);
+internal::StringSplitter StrSplit(std::string_view full, ByAnyChar delim,
+                                  SkipEmpty);
+internal::StringSplitter StrSplit(std::string_view full, char delim, SkipEmpty);
 
 void StripTrailingAsciiWhitespace(std::string *full);
 
-std::string StripTrailingAsciiWhitespace(const std::string &full);
+std::string_view StripTrailingAsciiWhitespace(std::string_view full);
 
 class StringOrInt {
  public:
-  StringOrInt(const std::string &s) : str_(s) {}  // NOLINT
-
-  StringOrInt(const char *s) : str_(std::string(s)) {}  // NOLINT
+  template <typename T, typename = std::enable_if_t<
+                            std::is_convertible_v<T, std::string_view>>>
+  StringOrInt(s) : str_(std::string(s)) {}  // NOLINT
 
   StringOrInt(int i) {  // NOLINT
-    char buf[1024];
-    sprintf(buf, "%d", i);
-    str_ = std::string(buf);
+    str_ = std::to_string(i);
   }
 
   const std::string &Get() const { return str_; }
@@ -221,6 +296,20 @@ inline std::string StrCat(const StringOrInt &s1, const StringOrInt &s2,
   return s1.Get() + StrCat(s2, s3, s4, s5);
 }
 
+// TODO(agutkin): Remove this once we migrate to C++20, where `starts_with`
+// is available.
+inline bool StartsWith(std::string_view text, std::string_view prefix) {
+  return prefix.empty() ||
+         (text.size() >= prefix.size() &&
+          memcmp(text.data(), prefix.data(), prefix.size()) == 0);
+}
+
+inline bool ConsumePrefix(std::string_view *s, std::string_view expected) {
+  if (!StartsWith(*s, expected)) return false;
+  s->remove_prefix(expected.size());
+  return true;
+}
+
 }  // namespace fst
 
-#endif  // FST_LIB_COMPAT_H_
+#endif  // FST_COMPAT_H_
index 613d1ac..8af023a 100644 (file)
 #define FST_COMPLEMENT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/fst.h>
@@ -105,10 +105,10 @@ class ComplementFstImpl : public FstImpl<A> {
     return s == 0 ? 0 : fst_->NumOutputEpsilons(s - 1);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && fst_->Properties(kError, false)) {
       SetProperties(kError, kError);
     }
@@ -165,7 +165,7 @@ class ComplementFst : public ImplToFst<internal::ComplementFstImpl<A>> {
 
   // Label that represents the ρ-transition; we use a negative value private to
   // the library and which will preserve FST label sort order.
-  static const Label kRhoLabel = -2;
+  static constexpr Label kRhoLabel = -2;
 
  private:
   using ImplToFst<Impl>::GetImpl;
@@ -173,9 +173,6 @@ class ComplementFst : public ImplToFst<internal::ComplementFstImpl<A>> {
   ComplementFst &operator=(const ComplementFst &) = delete;
 };
 
-template <class Arc>
-const typename Arc::Label ComplementFst<Arc>::kRhoLabel;
-
 // Specialization for ComplementFst.
 template <class Arc>
 class StateIterator<ComplementFst<Arc>> : public StateIteratorBase<Arc> {
@@ -262,9 +259,9 @@ class ArcIterator<ComplementFst<Arc>> : public ArcIteratorBase<Arc> {
     pos_ = a;
   }
 
-  uint8 Flags() const final { return kArcValueFlags; }
+  uint8_t Flags() const final { return kArcValueFlags; }
 
-  void SetFlags(uint8, uint8) final {}
+  void SetFlags(uint8_t, uint8_t) final {}
 
  private:
   std::unique_ptr<ArcIterator<Fst<Arc>>> aiter_;
index 45431e0..51705a9 100644 (file)
@@ -21,7 +21,8 @@
 #ifndef FST_COMPOSE_FILTER_H_
 #define FST_COMPOSE_FILTER_H_
 
-#include <fst/types.h>
+#include <cstdint>
+
 
 #include <fst/filter-state.h>
 #include <fst/fst-decl.h>  // For optional argument declarations
@@ -86,7 +87,7 @@ namespace fst {
 //   // This specifies how the filter affects the composition result properties.
 //   It takes as argument the properties that would apply with a trivial
 //   // composition filter.
-//   uint64 Properties(uint64 props) const;
+//   uint64_t Properties(uint64_t props) const;
 // };
 //
 // This filter allows only exact matching of symbols from FST1 with on FST2;
@@ -134,7 +135,7 @@ class NullComposeFilter {
 
   Matcher2 *GetMatcher2() { return matcher2_.get(); }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   std::unique_ptr<Matcher1> matcher1_;
@@ -194,7 +195,7 @@ class TrivialComposeFilter {
 
   Matcher2 *GetMatcher2() { return matcher2_.get(); }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   std::unique_ptr<Matcher1> matcher1_;
@@ -268,7 +269,7 @@ class SequenceComposeFilter {
 
   Matcher2 *GetMatcher2() { return matcher2_.get(); }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   std::unique_ptr<Matcher1> matcher1_;
@@ -347,7 +348,7 @@ class AltSequenceComposeFilter {
 
   Matcher2 *GetMatcher2() { return matcher2_.get(); }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   std::unique_ptr<Matcher1> matcher1_;
@@ -443,7 +444,7 @@ class MatchComposeFilter {
 
   Matcher2 *GetMatcher2() { return matcher2_.get(); }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   std::unique_ptr<Matcher1> matcher1_;
@@ -513,7 +514,7 @@ class NoMatchComposeFilter {
 
   Matcher2 *GetMatcher2() { return matcher2_.get(); }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   std::unique_ptr<Matcher1> matcher1_;
@@ -572,7 +573,7 @@ class MultiEpsFilter {
 
   Matcher2 *GetMatcher2() { return filter_.GetMatcher2(); }
 
-  uint64 Properties(uint64 iprops) const {
+  uint64_t Properties(uint64_t iprops) const {
     const auto oprops = filter_.Properties(iprops);
     return oprops & kILabelInvariantProperties & kOLabelInvariantProperties;
   }
index eafee10..314e3b3 100644 (file)
 #define FST_COMPOSE_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <memory>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
@@ -274,10 +274,10 @@ class ComposeFstImpl
 
   ComposeFstImpl *Copy() const override { return new ComposeFstImpl(*this); }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) &&
         (fst1_.Properties(kError, false) || fst2_.Properties(kError, false) ||
          (matcher1_->Properties(0) & kError) ||
@@ -746,7 +746,7 @@ class ComposeFstMatcher : public MatcherBase<typename CacheStore::Arc> {
                     MatchType match_type)
       : owned_fst_(fst.Copy()),
         fst_(*owned_fst_),
-        impl_(fst::down_cast<const Impl *>(fst_.GetImpl())),
+        impl_(down_cast<const Impl *>(fst_.GetImpl())),
         s_(kNoStateId),
         match_type_(match_type),
         matcher1_(impl_->matcher1_->Copy()),
@@ -761,7 +761,7 @@ class ComposeFstMatcher : public MatcherBase<typename CacheStore::Arc> {
   ComposeFstMatcher(const ComposeFst<Arc, CacheStore> *fst,
                     MatchType match_type)
       : fst_(*fst),
-        impl_(fst::down_cast<const Impl *>(fst_.GetImpl())),
+        impl_(down_cast<const Impl *>(fst_.GetImpl())),
         s_(kNoStateId),
         match_type_(match_type),
         matcher1_(impl_->matcher1_->Copy()),
@@ -777,7 +777,7 @@ class ComposeFstMatcher : public MatcherBase<typename CacheStore::Arc> {
       bool safe = false)
       : owned_fst_(matcher.fst_.Copy(safe)),
         fst_(*owned_fst_),
-        impl_(fst::down_cast<const Impl *>(fst_.GetImpl())),
+        impl_(down_cast<const Impl *>(fst_.GetImpl())),
         s_(kNoStateId),
         match_type_(matcher.match_type_),
         matcher1_(matcher.matcher1_->Copy(safe)),
@@ -813,7 +813,7 @@ class ComposeFstMatcher : public MatcherBase<typename CacheStore::Arc> {
 
   const Fst<Arc> &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 inprops) const override { return inprops; }
+  uint64_t Properties(uint64_t inprops) const override { return inprops; }
 
   void SetState(StateId s) final {
     if (s_ == s) return;
index 2fce885..ebaf155 100644 (file)
@@ -23,7 +23,6 @@
 #include <algorithm>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/expanded-fst.h>
 #include <fst/mutable-fst.h>
diff --git a/src/include/fst/config.h b/src/include/fst/config.h
deleted file mode 100644 (file)
index 3823268..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* src/include/fst/config.h.  Generated from config.h.in by configure.  */
-// OpenFst config file
-
-/* Define to 1 if you have the ICU library. */
-/* #undef HAVE_ICU */
-
-/* Define to 1 if the system has the type `std::tr1::hash<long long
-   unsigned>'. */
-#define HAVE_STD__TR1__HASH_LONG_LONG_UNSIGNED_ 1
-
-/* Define to 1 if the system has the type `__gnu_cxx::slist<int>'. */
-#define HAVE___GNU_CXX__SLIST_INT_ 1
diff --git a/src/include/fst/config.h.in b/src/include/fst/config.h.in
deleted file mode 100644 (file)
index 50d111d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// OpenFst config file
-
-/* Define to 1 if you have the ICU library. */
-#undef HAVE_ICU
-
-/* Define to 1 if the system has the type `std::tr1::hash<long long
-   unsigned>'. */
-#define HAVE_STD__TR1__HASH_LONG_LONG_UNSIGNED_ 1
-
-/* Define to 1 if the system has the type `__gnu_cxx::slist<int>'. */
-#define HAVE___GNU_CXX__SLIST_INT_ 1
index ae4f1fb..ce8c802 100644 (file)
@@ -21,9 +21,9 @@
 #define FST_CONNECT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/dfs-visit.h>
 #include <fst/mutable-fst.h>
@@ -123,9 +123,9 @@ class SccVisitor {
   // props: related property bits (cyclicity, initial cyclicity,
   //   accessibility, coaccessibility) set/cleared (o.w. unchanged).
   SccVisitor(std::vector<StateId> *scc, std::vector<bool> *access,
-             std::vector<bool> *coaccess, uint64 *props)
+             std::vector<bool> *coaccess, uint64_t *props)
       : scc_(scc), access_(access), coaccess_(coaccess), props_(props) {}
-  explicit SccVisitor(uint64 *props)
+  explicit SccVisitor(uint64_t *props)
       : scc_(nullptr), access_(nullptr), coaccess_(nullptr), props_(props) {}
 
   void InitVisit(const Fst<Arc> &fst);
@@ -174,7 +174,7 @@ class SccVisitor {
   std::vector<StateId> *scc_;    // State's scc number.
   std::vector<bool> *access_;    // State's accessibility.
   std::vector<bool> *coaccess_;  // State's coaccessibility.
-  uint64 *props_;
+  uint64_t *props_;
   const Fst<Arc> *fst_;
   StateId start_;
   StateId nstates_;  // State count.
@@ -279,7 +279,7 @@ void Connect(MutableFst<Arc> *fst) {
   using StateId = typename Arc::StateId;
   std::vector<bool> access;
   std::vector<bool> coaccess;
-  uint64 props = 0;
+  uint64_t props = 0;
   SccVisitor<Arc> scc_visitor(nullptr, &access, &coaccess, &props);
   DfsVisit(*fst, &scc_visitor);
   std::vector<StateId> dstates;
@@ -299,7 +299,7 @@ void Condense(const Fst<Arc> &ifst, MutableFst<Arc> *ofst,
               std::vector<typename Arc::StateId> *scc) {
   using StateId = typename Arc::StateId;
   ofst->DeleteStates();
-  uint64 props = 0;
+  uint64_t props = 0;
   SccVisitor<Arc> scc_visitor(scc, nullptr, nullptr, &props);
   DfsVisit(ifst, &scc_visitor);
   const auto iter = std::max_element(scc->cbegin(), scc->cend());
index 44fef12..134470e 100644 (file)
 #define FST_CONST_FST_H_
 
 #include <climits>
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/expanded-fst.h>
@@ -61,7 +61,7 @@ class ConstFstImpl : public FstImpl<A> {
 
   ConstFstImpl() {
     std::string type = "const";
-    if (sizeof(Unsigned) != sizeof(uint32)) {
+    if (sizeof(Unsigned) != sizeof(uint32_t)) {
       type += std::to_string(CHAR_BIT * sizeof(Unsigned));
     }
     SetType(type);
@@ -116,7 +116,7 @@ class ConstFstImpl : public FstImpl<A> {
   };
 
   // Properties always true of this FST class.
-  static constexpr uint64 kStaticProperties = kExpanded;
+  static constexpr uint64_t kStaticProperties = kExpanded;
   // Current unaligned file format version. The unaligned version was added and
   // made the default since the aligned version does not work on pipes.
   static constexpr int kFileVersion = 2;
@@ -138,21 +138,9 @@ class ConstFstImpl : public FstImpl<A> {
 };
 
 template <class Arc, class Unsigned>
-constexpr uint64 ConstFstImpl<Arc, Unsigned>::kStaticProperties;
-
-template <class Arc, class Unsigned>
-constexpr int ConstFstImpl<Arc, Unsigned>::kFileVersion;
-
-template <class Arc, class Unsigned>
-constexpr int ConstFstImpl<Arc, Unsigned>::kAlignedFileVersion;
-
-template <class Arc, class Unsigned>
-constexpr int ConstFstImpl<Arc, Unsigned>::kMinFileVersion;
-
-template <class Arc, class Unsigned>
 ConstFstImpl<Arc, Unsigned>::ConstFstImpl(const Fst<Arc> &fst) {
   std::string type = "const";
-  if (sizeof(Unsigned) != sizeof(uint32)) {
+  if (sizeof(Unsigned) != sizeof(uint32_t)) {
     type += std::to_string(CHAR_BIT * sizeof(Unsigned));
   }
   SetType(type);
@@ -355,7 +343,7 @@ bool ConstFst<Arc, Unsigned>::WriteFst(const FST &fst, std::ostream &strm,
   hdr.SetNumStates(num_states);
   hdr.SetNumArcs(num_arcs);
   std::string type = "const";
-  if (sizeof(Unsigned) != sizeof(uint32)) {
+  if (sizeof(Unsigned) != sizeof(uint32_t)) {
     type += std::to_string(CHAR_BIT * sizeof(Unsigned));
   }
   const auto properties =
@@ -461,9 +449,9 @@ class ArcIterator<ConstFst<Arc, Unsigned>> {
 
   void Seek(size_t a) { i_ = a; }
 
-  constexpr uint8 Flags() const { return kArcValueFlags; }
+  constexpr uint8_t Flags() const { return kArcValueFlags; }
 
-  void SetFlags(uint8, uint8) {}
+  void SetFlags(uint8_t, uint8_t) {}
 
  private:
   const Arc *arcs_;
index f3e330e..47b688f 100644 (file)
 
 #include <algorithm>
 #include <climits>
+#include <cstdint>
 #include <forward_list>
 #include <map>
+#include <memory>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/const-fst.h>
 
@@ -190,11 +191,14 @@ struct DeterminizeArc {
       : label(kNoLabel), weight(Weight::Zero()), dest_tuple(nullptr) {}
 
   explicit DeterminizeArc(const Arc &arc)
-      : label(arc.ilabel), weight(Weight::Zero()), dest_tuple(new StateTuple) {}
+      : label(arc.ilabel),
+        weight(Weight::Zero()),
+        dest_tuple(fst::make_unique_for_overwrite<StateTuple>()) {}
 
   Label label;             // Arc label.
   Weight weight;           // Arc weight.
-  StateTuple *dest_tuple;  // Destination subset and filter state.
+  std::unique_ptr<StateTuple>
+      dest_tuple;  // Destination subset and filter state.
 };
 
 }  // namespace internal
@@ -226,12 +230,9 @@ class DefaultDeterminizeFilter {
   explicit DefaultDeterminizeFilter(const Fst<Arc> &fst) : fst_(fst.Copy()) {}
 
   // This is needed (e.g.) to go into the gallic domain for transducers.
-  // Ownership of the templated filter argument is given to this class.
   template <class Filter>
-  DefaultDeterminizeFilter(const Fst<Arc> &fst, Filter *filter)
-      : fst_(fst.Copy()) {
-    delete filter;
-  }
+  DefaultDeterminizeFilter(const Fst<Arc> &fst, std::unique_ptr<Filter> filter)
+      : fst_(fst.Copy()) {}
 
   // Copy constructor; the FST can be passed if it has been deep-copied.
   DefaultDeterminizeFilter(const DefaultDeterminizeFilter<Arc> &filter,
@@ -260,7 +261,7 @@ class DefaultDeterminizeFilter {
   // Filters super-final transition, returning new final weight.
   Weight FilterFinal(Weight weight, const Element &element) { return weight; }
 
-  static uint64 Properties(uint64 props) { return props; }
+  static uint64_t Properties(uint64_t props) { return props; }
 
  private:
   std::unique_ptr<Fst<Arc>> fst_;
@@ -290,7 +291,7 @@ class DefaultDeterminizeFilter {
 //   // Looks up state ID by state tuple; if it doesn't exist, then adds it.
 //   // FindState takes ownership of the state tuple argument so that it
 //   // doesn't have to copy it if it creates a new state.
-//   StateId FindState(StateTuple *tuple);
+//   StateId FindState(std::unique_ptr<StateTuple> tuple);
 //
 //   // Looks up state tuple by ID.
 //   const StateTuple *Tuple(StateId id) const;
@@ -327,10 +328,13 @@ class DefaultDeterminizeStateTable {
   // Finds the state corresponding to a state tuple. Only creates a new state if
   // the tuple is not found. FindState takes ownership of the tuple argument so
   // that it doesn't have to copy it if it creates a new state.
-  StateId FindState(StateTuple *tuple) {
+  StateId FindState(std::unique_ptr<StateTuple> tuple) {
+    StateTuple *raw_tuple = tuple.release();
     const StateId ns = tuples_.Size();
-    const auto s = tuples_.FindId(tuple);
-    if (s != ns) delete tuple;  // Tuple found.
+    // TODO(wolfsonkin): Make CompactHashBiTable support move semantics so we
+    // can store a `std::unique_ptr` in `tuples_`.
+    const auto s = tuples_.FindId(raw_tuple);
+    if (s != ns) delete raw_tuple;  // Tuple found.
     return s;
   }
 
@@ -350,11 +354,11 @@ class DefaultDeterminizeStateTable {
    public:
     size_t operator()(const StateTuple *tuple) const {
       size_t h = tuple->filter_state.Hash();
-      for (auto it = tuple->subset.begin(); it != tuple->subset.end(); ++it) {
-        const size_t h1 = it->state_id;
+      for (auto &element : tuple->subset) {
+        const size_t h1 = element.state_id;
         static constexpr auto lshift = 5;
         static constexpr auto rshift = CHAR_BIT * sizeof(size_t) - 5;
-        h ^= h << 1 ^ h1 << lshift ^ h1 >> rshift ^ it->weight.Hash();
+        h ^= h << 1 ^ h1 << lshift ^ h1 >> rshift ^ element.weight.Hash();
       }
       return h;
     }
@@ -588,10 +592,10 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
     return new DeterminizeFsaImpl(*this);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && (GetFst().Properties(kError, false))) {
       SetProperties(kError, kError);
     }
@@ -601,18 +605,17 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
   StateId ComputeStart() override {
     const auto s = GetFst().Start();
     if (s == kNoStateId) return kNoStateId;
-    auto *tuple = new StateTuple;
+    auto tuple = fst::make_unique_for_overwrite<StateTuple>();
     tuple->subset.emplace_front(s, Weight::One());
     tuple->filter_state = filter_->Start();
-    return FindState(tuple);
+    return FindState(std::move(tuple));
   }
 
   Weight ComputeFinal(StateId s) override {
     const auto *tuple = state_table_->Tuple(s);
     filter_->SetState(s, *tuple);
     auto final_weight = Weight::Zero();
-    for (auto it = tuple->subset.begin(); it != tuple->subset.end(); ++it) {
-      const auto &element = *it;
+    for (const auto &element : tuple->subset) {
       final_weight =
           Plus(final_weight,
                Times(element.weight, GetFst().Final(element.state_id)));
@@ -622,10 +625,11 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
     return final_weight;
   }
 
-  StateId FindState(StateTuple *tuple) {
-    const auto s = state_table_->FindState(tuple);
+  StateId FindState(std::unique_ptr<StateTuple> tuple) {
+    const auto &subset = tuple->subset;
+    const auto s = state_table_->FindState(std::move(tuple));
     if (in_dist_ && out_dist_->size() <= s) {
-      out_dist_->push_back(ComputeDistance(tuple->subset));
+      out_dist_->push_back(ComputeDistance(subset));
     }
     return s;
   }
@@ -634,8 +638,7 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
   // distances in the NFA.
   Weight ComputeDistance(const Subset &subset) {
     auto outd = Weight::Zero();
-    for (auto it = subset.begin(); it != subset.end(); ++it) {
-      const auto &element = *it;
+    for (const auto &element : subset) {
       const auto ind =
           (element.state_id < in_dist_->size() ? (*in_dist_)[element.state_id]
                                                : Weight::Zero());
@@ -649,8 +652,8 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
   void Expand(StateId s) override {
     LabelMap label_map;
     GetLabelMap(s, &label_map);
-    for (auto it = label_map.begin(); it != label_map.end(); ++it) {
-      AddArc(s, std::move(it->second));
+    for (auto &[unused_label, arc] : label_map) {
+      AddArc(s, std::move(arc));
     }
     SetArcs(s);
   }
@@ -663,9 +666,7 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
   void GetLabelMap(StateId s, LabelMap *label_map) {
     const auto *src_tuple = state_table_->Tuple(s);
     filter_->SetState(s, *src_tuple);
-    for (auto it = src_tuple->subset.begin(); it != src_tuple->subset.end();
-         ++it) {
-      const auto &src_element = *it;
+    for (const auto &src_element : src_tuple->subset) {
       for (ArcIterator<Fst<Arc>> aiter(GetFst(), src_element.state_id);
            !aiter.Done(); aiter.Next()) {
         const auto &arc = aiter.Value();
@@ -675,15 +676,15 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
                            label_map);
       }
     }
-    for (auto it = label_map->begin(); it != label_map->end(); ++it) {
-      NormArc(&it->second);
+    for (auto &[unused_label, arc] : *label_map) {
+      NormArc(&arc);
     }
   }
 
   // Sorts subsets and removes duplicate elements, normalizing transition and
   // subset weights.
   void NormArc(DetArc *det_arc) {
-    auto *dest_tuple = det_arc->dest_tuple;
+    std::unique_ptr<StateTuple> &dest_tuple = det_arc->dest_tuple;
     dest_tuple->subset.sort();
     auto piter = dest_tuple->subset.begin();
     for (auto diter = dest_tuple->subset.begin();
@@ -705,9 +706,7 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
     }
     // Divides out label weight from destination subset elements, quantizing to
     // ensure comparisons are effective.
-    for (auto diter = dest_tuple->subset.begin();
-         diter != dest_tuple->subset.end(); ++diter) {
-      auto &dest_element = *diter;
+    for (auto &dest_element : dest_tuple->subset) {
       dest_element.weight =
           Divide(dest_element.weight, det_arc->weight, DIVIDE_LEFT);
       dest_element.weight = dest_element.weight.Quantize(delta_);
@@ -719,7 +718,7 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<Arc> {
   void AddArc(StateId s, DetArc &&det_arc) {
     CacheImpl<Arc>::EmplaceArc(s, det_arc.label, det_arc.label,
                                std::move(det_arc.weight),
-                               FindState(det_arc.dest_tuple));
+                               FindState(std::move(det_arc.dest_tuple)));
   }
 
   float delta_;                         // Quantization delta for weights.
@@ -778,7 +777,8 @@ class DeterminizeFstImpl : public DeterminizeFstImplBase<Arc> {
       SetProperties(kError, kError);
       return;
     }
-    Init(GetFst(), opts.filter);
+    // Takes ownership of filter.
+    Init(GetFst(), fst::WrapUnique(opts.filter));
   }
 
   DeterminizeFstImpl(const DeterminizeFstImpl &impl)
@@ -793,10 +793,10 @@ class DeterminizeFstImpl : public DeterminizeFstImplBase<Arc> {
     return new DeterminizeFstImpl(*this);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && (GetFst().Properties(kError, false) ||
                             from_fst_->Properties(kError, false))) {
       SetProperties(kError, kError);
@@ -819,7 +819,7 @@ class DeterminizeFstImpl : public DeterminizeFstImplBase<Arc> {
  private:
   // Initialization of transducer determinization implementation, which is
   // defined after DeterminizeFst since it calls it.
-  void Init(const Fst<Arc> &fst, Filter *filter);
+  void Init(const Fst<Arc> &fst, std::unique_ptr<Filter> filter);
 
   float delta_;
   Label subsequential_label_;
@@ -976,10 +976,11 @@ namespace internal {
 // Initialization of transducer determinization implementation, which is defined
 // after DeterminizeFst since it calls it.
 template <class A, GallicType G, class D, class F, class T>
-void DeterminizeFstImpl<A, G, D, F, T>::Init(const Fst<A> &fst, F *filter) {
+void DeterminizeFstImpl<A, G, D, F, T>::Init(const Fst<A> &fst,
+                                             std::unique_ptr<F> filter) {
   // Mapper to an acceptor.
-  const ToFst to_fst(fst, ToMapper());
-  auto *to_filter = filter ? new ToFilter(to_fst, filter) : nullptr;
+  const ToFst to_fst(fst);
+  auto *to_filter = filter ? new ToFilter(to_fst, std::move(filter)) : nullptr;
   // This recursive call terminates since it is to a (non-recursive)
   // different constructor.
   const CacheOptions copts(GetCacheGc(), GetCacheLimit());
index 16c5db7..3e12843 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef FST_DFS_VISIT_H_
 #define FST_DFS_VISIT_H_
 
+#include <cstdint>
 #include <stack>
 #include <vector>
 
@@ -114,7 +115,7 @@ void DfsVisit(const FST &fst, Visitor *visitor, ArcFilter filter,
     return;
   }
   // An FST state's DFS status
-  enum class StateColor : uint8 {
+  enum class StateColor : uint8_t {
     kWhite = 0,  // Undiscovered.
     kGrey = 1,   // Discovered but unfinished.
     kBlack = 2,  // Finished.
index 9301298..1eac382 100644 (file)
 #ifndef FST_DISAMBIGUATE_H_
 #define FST_DISAMBIGUATE_H_
 
+#include <cstdint>
 #include <list>
 #include <map>
+#include <memory>
 #include <set>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/arcsort.h>
 #include <fst/compose.h>
@@ -81,35 +82,30 @@ class RelationDeterminizeFilter {
   };
 
   explicit RelationDeterminizeFilter(const Fst<Arc> &fst)
-      : fst_(fst.Copy()), r_(new Relation()), s_(kNoStateId), head_(nullptr) {}
-
-  // Ownership of the relation is given to this class.
-  RelationDeterminizeFilter(const Fst<Arc> &fst, Relation *r)
-      : fst_(fst.Copy()), r_(r), s_(kNoStateId), head_(0) {}
+      : fst_(fst.Copy()),
+        head_(nullptr),
+        r_(std::make_unique<Relation>()),
+        s_(kNoStateId) {}
 
-  // Ownership of the relation is given to this class.
-  RelationDeterminizeFilter(const Fst<Arc> &fst, Relation *r,
-                            std::vector<StateId> *head)
-      : fst_(fst.Copy()), r_(r), s_(kNoStateId), head_(head) {}
+  RelationDeterminizeFilter(const Fst<Arc> &fst, std::unique_ptr<Relation> r,
+                            std::vector<StateId> *head = nullptr)
+      : fst_(fst.Copy()), head_(head), r_(std::move(r)), s_(kNoStateId) {}
 
   // This is needed, e.g., to go into the gallic domain for transducers.
-  // Ownership of the templated filter argument is given to this class.
   template <class Filter>
-  RelationDeterminizeFilter(const Fst<Arc> &fst, Filter *filter)
+  RelationDeterminizeFilter(const Fst<Arc> &fst, std::unique_ptr<Filter> filter)
       : fst_(fst.Copy()),
-        r_(new Relation(filter->GetRelation())),
-        s_(kNoStateId),
-        head_(filter->GetHeadStates()) {
-    delete filter;
-  }
+        head_(filter->GetHeadStates()),
+        r_(std::move(*filter).GetRelation()),
+        s_(kNoStateId) {}
 
   // Copy constructor; the FST can be passed if it has been deep-copied.
   RelationDeterminizeFilter(const RelationDeterminizeFilter &filter,
                             const Fst<Arc> *fst = nullptr)
       : fst_(fst ? fst->Copy() : filter.fst_->Copy()),
-        r_(new Relation(*filter.r_)),
-        s_(kNoStateId),
-        head_() {}
+        head_(nullptr) ,
+        r_(std::make_unique<Relation>(*filter.r_)),
+        s_(kNoStateId){}
 
   FilterState Start() const { return FilterState(fst_->Start()); }
 
@@ -136,11 +132,11 @@ class RelationDeterminizeFilter {
     return is_final_ ? final_weight : Weight::Zero();
   }
 
-  static uint64 Properties(uint64 props) {
+  static uint64_t Properties(uint64_t props) {
     return props & ~(kIDeterministic | kODeterministic);
   }
 
-  const Relation &GetRelation() { return *r_; }
+  std::unique_ptr<Relation> GetRelation() && { return std::move(r_); }
 
   std::vector<StateId> *GetHeadStates() { return head_; }
 
@@ -149,12 +145,12 @@ class RelationDeterminizeFilter {
   void InitLabelMap(LabelMap *label_map) const;
 
   std::unique_ptr<Fst<Arc>> fst_;  // Input FST.
+  std::vector<StateId> *head_;     // Head state for a given state,
+                                   // owned by the Disambiguator.
   std::unique_ptr<Relation> r_;    // Relation compatible with inv. trans. fnc.
   StateId s_;                      // Current state.
   const StateTuple *tuple_;        // Current tuple.
   bool is_final_;                  // Is the current head state final?
-  std::vector<StateId> *head_;     // Head state for a given state,
-                                   // owned by the Disambiguator.
 };
 
 template <class Arc, class Relation>
@@ -166,7 +162,7 @@ bool RelationDeterminizeFilter<Arc, Relation>::FilterArc(
   // Adds element to state tuple if element state is related to tuple head.
   for (auto liter = label_map->lower_bound(arc.ilabel);
        liter != label_map->end() && liter->first == arc.ilabel; ++liter) {
-    auto *dest_tuple = liter->second.dest_tuple;
+    const auto &dest_tuple = liter->second.dest_tuple;
     const auto dest_head = dest_tuple->filter_state.GetState();
     if ((*r_)(dest_element.state_id, dest_head)) {
       dest_tuple->subset.push_front(dest_element);
@@ -189,7 +185,7 @@ void RelationDeterminizeFilter<Arc, Relation>::InitLabelMap(
     if (arc.ilabel == label && arc.nextstate == nextstate) continue;
     DeterminizeArc<StateTuple> det_arc(arc);
     det_arc.dest_tuple->filter_state = FilterState(arc.nextstate);
-    label_map->emplace(arc.ilabel, det_arc);
+    label_map->emplace(arc.ilabel, std::move(det_arc));
     label = arc.ilabel;
     nextstate = arc.nextstate;
   }
@@ -234,7 +230,7 @@ class Disambiguator {
              (arc1.ilabel == arc2.ilabel && arc1.nextstate < arc2.nextstate);
     }
 
-    uint64 Properties(uint64 props) const {
+    uint64_t Properties(uint64_t props) const {
       return (props & kArcSortProperties) | kILabelSorted |
              (props & kAcceptor ? kOLabelSorted : 0);
     }
@@ -286,7 +282,7 @@ class Disambiguator {
       opts.state_table = new StateTable(*fsa, *fsa);
       const ComposeFst<Arc> cfst(*fsa, *fsa, opts);
       std::vector<bool> coaccess;
-      uint64 props = 0;
+      uint64_t props = 0;
       SccVisitor<Arc> scc_visitor(nullptr, nullptr, &coaccess, &props);
       DfsVisit(cfst, &scc_visitor);
       for (StateId s = 0; s < coaccess.size(); ++s) {
@@ -388,13 +384,12 @@ void Disambiguator<Arc>::PreDisambiguate(const ExpandedFst<Arc> &ifst,
   // Subset elements with states s1 and s2 (resp.) are in this relation iff they
   // there is a path from s1 to a final state that has the same label as some
   // path from s2 to a final state.
-  auto *common_future = new CommonFuture(ifst);
+  auto common_future = std::make_unique<CommonFuture>(ifst);
   DeterminizeFstOptions<Arc, CommonDivisor, Filter> nopts;
   nopts.delta = opts.delta;
   nopts.subsequential_label = opts.subsequential_label;
-  nopts.filter = new Filter(ifst, common_future, &head_);
-  // The filter takes ownership of 'common_future', and determinization takes
-  // ownership of the filter itself.
+  nopts.filter = new Filter(ifst, std::move(common_future), &head_);
+  // Determinization takes ownership of the filter itself.
   nopts.gc_limit = 0;  // Cache only the last state for fastest copy.
   if (opts.weight_threshold != Weight::Zero() ||
       opts.state_threshold != kNoStateId) {
index 6805351..b9d9009 100644 (file)
 #ifndef FST_EDIT_FST_H_
 #define FST_EDIT_FST_H_
 
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
@@ -135,7 +135,7 @@ class EditFstData {
                                   : edits_.NumOutputEpsilons(it->second);
   }
 
-  void SetEditedProperties(uint64 props, uint64 mask) {
+  void SetEditedProperties(uint64_t props, uint64_t mask) {
     edits_.SetProperties(props, mask);
   }
 
@@ -393,10 +393,10 @@ class EditFstImpl : public FstImpl<A> {
   // As it happens, the API for the ImplToMutableFst<I,F> class requires that
   // the implementation class--the template parameter "I"--have a constructor
   // taking a const Fst<A> reference. Accordingly, the constructor here must
-  // perform a fst::down_cast to the WrappedFstT type required by EditFst and
+  // perform a down_cast to the WrappedFstT type required by EditFst and
   // therefore EditFstImpl.
   explicit EditFstImpl(const Fst<Arc> &wrapped)
-      : wrapped_(fst::down_cast<WrappedFstT *>(wrapped.Copy())) {
+      : wrapped_(down_cast<WrappedFstT *>(wrapped.Copy())) {
     FstImpl<Arc>::SetType("edit");
     data_ = std::make_shared<EditFstData<Arc, WrappedFstT, MutableFstT>>();
     // have edits_ inherit all properties from wrapped_
@@ -409,7 +409,7 @@ class EditFstImpl : public FstImpl<A> {
   // the Copy() method of the Fst interface.
   EditFstImpl(const EditFstImpl &impl)
       : FstImpl<Arc>(),
-        wrapped_(fst::down_cast<WrappedFstT *>(impl.wrapped_->Copy(true))),
+        wrapped_(down_cast<WrappedFstT *>(impl.wrapped_->Copy(true))),
         data_(impl.data_) {
     SetProperties(impl.Properties());
   }
@@ -547,7 +547,7 @@ class EditFstImpl : public FstImpl<A> {
 
  private:
   // Properties always true of this FST class.
-  static constexpr uint64 kStaticProperties = kExpanded | kMutable;
+  static constexpr uint64_t kStaticProperties = kExpanded | kMutable;
   // Current file format version.
   static constexpr int kFileVersion = 2;
   // Minimum file format version supported
@@ -589,15 +589,6 @@ class EditFstImpl : public FstImpl<A> {
 };
 
 template <typename Arc, typename WrappedFstT, typename MutableFstT>
-constexpr uint64 EditFstImpl<Arc, WrappedFstT, MutableFstT>::kStaticProperties;
-
-template <typename Arc, typename WrappedFstT, typename MutableFstT>
-constexpr int EditFstImpl<Arc, WrappedFstT, MutableFstT>::kFileVersion;
-
-template <typename Arc, typename WrappedFstT, typename MutableFstT>
-constexpr int EditFstImpl<Arc, WrappedFstT, MutableFstT>::kMinFileVersion;
-
-template <typename Arc, typename WrappedFstT, typename MutableFstT>
 inline void EditFstImpl<Arc, WrappedFstT, MutableFstT>::DeleteStates() {
   data_->DeleteStates();
   // we are deleting all states, so just forget about pointer to wrapped_
@@ -622,7 +613,7 @@ EditFstImpl<Arc, WrappedFstT, MutableFstT>::Read(std::istream &strm,
   wrapped_opts.header = nullptr;
   std::unique_ptr<Fst<Arc>> wrapped_fst(Fst<Arc>::Read(strm, wrapped_opts));
   if (!wrapped_fst) return nullptr;
-  impl->wrapped_.reset(fst::down_cast<WrappedFstT *>(wrapped_fst.release()));
+  impl->wrapped_.reset(down_cast<WrappedFstT *>(wrapped_fst.release()));
   impl->data_ = std::shared_ptr<EditFstData<Arc, WrappedFstT, MutableFstT>>(
       EditFstData<Arc, WrappedFstT, MutableFstT>::Read(strm, opts));
   if (!impl->data_) return nullptr;
index 901342f..62f7c09 100644 (file)
 #ifndef FST_ENCODE_H_
 #define FST_ENCODE_H_
 
+#include <cstdint>
 #include <iostream>
 #include <memory>
+#include <ostream>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/arc-map.h>
 #include <fstream>
 #include <fst/properties.h>
 #include <fst/rmfinalepsilon.h>
+#include <fst/util.h>
 #include <unordered_map>
 
 namespace fst {
 
 enum EncodeType { ENCODE = 1, DECODE = 2 };
 
-static constexpr uint8 kEncodeLabels = 0x01;
-static constexpr uint8 kEncodeWeights = 0x02;
-static constexpr uint8 kEncodeFlags = 0x03;
+inline constexpr uint8_t kEncodeLabels = 0x01;
+inline constexpr uint8_t kEncodeWeights = 0x02;
+inline constexpr uint8_t kEncodeFlags = 0x03;
 
 namespace internal {
 
 // Bits storing whether or not an encode table has input and/or output symbol
 // tables, for internal use only.
-static constexpr uint8 kEncodeHasISymbols = 0x04;
-static constexpr uint8 kEncodeHasOSymbols = 0x08;
+inline constexpr uint8_t kEncodeHasISymbols = 0x04;
+inline constexpr uint8_t kEncodeHasOSymbols = 0x08;
 
 // Identifies stream data as an encode table (and its endianity).
-static const int32 kEncodeMagicNumber = 2128178506;
-// TODO(b/141172858): deprecated, remove by 2020-01-01.
-static const int32 kEncodeDeprecatedMagicNumber = 2129983209;
+inline constexpr int32_t kEncodeMagicNumber = 2128178506;
 
 }  // namespace internal
 
@@ -65,7 +65,7 @@ class EncodeTableHeader {
 
   const std::string &ArcType() const { return arctype_; }
 
-  uint8 Flags() const { return flags_; }
+  uint8_t Flags() const { return flags_; }
 
   size_t Size() const { return size_; }
 
@@ -73,7 +73,7 @@ class EncodeTableHeader {
 
   void SetArcType(const std::string &arctype) { arctype_ = arctype; }
 
-  void SetFlags(uint8 flags) { flags_ = flags; }
+  void SetFlags(uint8_t flags) { flags_ = flags; }
 
   void SetSize(size_t size) { size_ = size; }
 
@@ -85,7 +85,7 @@ class EncodeTableHeader {
 
  private:
   std::string arctype_;
-  uint8 flags_;
+  uint8_t flags_;
   size_t size_;
 };
 
@@ -109,7 +109,7 @@ class EncodeTable {
         : ilabel(ilabel), olabel(olabel), weight(std::move(weight)) {}
 
     // Constructs from arc and flags.
-    Triple(const Arc &arc, uint8 flags)
+    Triple(const Arc &arc, uint8_t flags)
         : ilabel(arc.ilabel),
           olabel(flags & kEncodeLabels ? arc.olabel : 0),
           weight(flags & kEncodeWeights ? arc.weight : Weight::One()) {}
@@ -122,6 +122,12 @@ class EncodeTable {
       return triple;
     }
 
+    void Write(std::ostream &strm) const {
+      WriteType(strm, ilabel);
+      WriteType(strm, olabel);
+      WriteType(strm, weight);
+    }
+
     // Exploited below for TripleEqual functor.
     bool operator==(const Triple &other) const {
       return (ilabel == other.ilabel && olabel == other.olabel &&
@@ -141,7 +147,7 @@ class EncodeTable {
   // Hash functor for one Triple pointer.
   class TripleHash {
    public:
-    explicit TripleHash(uint8 flags) : flags_(flags) {}
+    explicit TripleHash(uint8_t flags) : flags_(flags) {}
 
     size_t operator()(const Triple *triple) const {
       size_t hash = triple->ilabel;
@@ -157,10 +163,10 @@ class EncodeTable {
     }
 
    private:
-    uint8 flags_;
+    uint8_t flags_;
   };
 
-  explicit EncodeTable(uint8 flags)
+  explicit EncodeTable(uint8_t flags)
       : flags_(flags), triple2label_(1024, TripleHash(flags)) {}
 
   // Given an arc, encodes either input/output labels or input/costs or both.
@@ -192,7 +198,7 @@ class EncodeTable {
 
   // This is masked to hide internal-only isymbol and osymbol bits.
 
-  uint8 Flags() const { return flags_ & kEncodeFlags; }
+  uint8_t Flags() const { return flags_ & kEncodeFlags; }
 
   const SymbolTable *InputSymbols() const { return isymbols_.get(); }
 
@@ -226,7 +232,7 @@ class EncodeTable {
     return insert_result.first->second;
   }
 
-  uint8 flags_;
+  uint8_t flags_;
   std::vector<std::unique_ptr<Triple>> triples_;
   std::unordered_map<const Triple *, Label, TripleHash, TripleEqual>
       triple2label_;
@@ -245,7 +251,7 @@ EncodeTable<Arc> *EncodeTable<Arc>::Read(std::istream &strm,
   const auto flags = hdr.Flags();
   const auto size = hdr.Size();
   auto table = std::make_unique<EncodeTable>(flags);
-  for (int64 i = 0; i < size; ++i) {
+  for (int64_t i = 0; i < size; ++i) {
     table->triples_.emplace_back(std::move(Triple::Read(strm)));
     table->triple2label_[table->triples_.back().get()] = table->triples_.size();
   }
@@ -270,11 +276,7 @@ bool EncodeTable<Arc>::Write(std::ostream &strm,
   hdr.SetFlags(flags_);  // Real flags, not masked ones.
   hdr.SetSize(Size());
   if (!hdr.Write(strm, source)) return false;
-  for (const auto &triple : triples_) {
-    WriteType(strm, triple->ilabel);
-    WriteType(strm, triple->olabel);
-    WriteType(strm, triple->weight);
-  }
+  for (const auto &triple : triples_) triple->Write(strm);
   if (flags_ & kEncodeHasISymbols) isymbols_->Write(strm);
   if (flags_ & kEncodeHasOSymbols) osymbols_->Write(strm);
   strm.flush();
@@ -309,7 +311,7 @@ class EncodeMapper {
   using Weight = typename Arc::Weight;
 
  public:
-  explicit EncodeMapper(uint8 flags, EncodeType type = ENCODE)
+  explicit EncodeMapper(uint8_t flags, EncodeType type = ENCODE)
       : flags_(flags),
         type_(type),
         table_(std::make_shared<internal::EncodeTable<Arc>>(flags)),
@@ -344,12 +346,12 @@ class EncodeMapper {
     return MAP_CLEAR_SYMBOLS;
   }
 
-  uint8 Flags() const { return flags_; }
+  uint8_t Flags() const { return flags_; }
 
-  uint64 Properties(uint64 inprops) {
-    uint64 outprops = inprops;
+  uint64_t Properties(uint64_t inprops) {
+    uint64_t outprops = inprops;
     if (error_) outprops |= kError;
-    uint64 mask = kFstProperties;
+    uint64_t mask = kFstProperties;
     if (flags_ & kEncodeLabels) {
       mask &= kILabelInvariantProperties & kOLabelInvariantProperties;
     }
@@ -407,12 +409,12 @@ class EncodeMapper {
   }
 
  private:
-  uint8 flags_;
+  uint8_t flags_;
   EncodeType type_;
   std::shared_ptr<internal::EncodeTable<Arc>> table_;
   bool error_;
 
-  explicit EncodeMapper(uint8 flags, EncodeType type,
+  explicit EncodeMapper(uint8_t flags, EncodeType type,
                         internal::EncodeTable<Arc> *table)
       : flags_(flags), type_(type), table_(table), error_(false) {}
 
index 0141beb..2057b8f 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef FST_EQUAL_H_
 #define FST_EQUAL_H_
 
+#include <cstdint>
+
 #include <fst/log.h>
 
 #include <fst/fst.h>
 
 namespace fst {
 
-constexpr uint8 kEqualFsts = 0x01;
-constexpr uint8 kEqualFstTypes = 0x02;
-constexpr uint8 kEqualCompatProperties = 0x04;
-constexpr uint8 kEqualCompatSymbols = 0x08;
-constexpr uint8 kEqualAll =
+inline constexpr uint8_t kEqualFsts = 0x01;
+inline constexpr uint8_t kEqualFstTypes = 0x02;
+inline constexpr uint8_t kEqualCompatProperties = 0x04;
+inline constexpr uint8_t kEqualCompatSymbols = 0x08;
+inline constexpr uint8_t kEqualAll =
     kEqualFsts | kEqualFstTypes | kEqualCompatProperties | kEqualCompatSymbols;
 
 class WeightApproxEqual {
@@ -57,7 +59,7 @@ class WeightApproxEqual {
 // (etype & kEqualCompatSymbols).
 template <class Arc, class WeightEqual>
 bool Equal(const Fst<Arc> &fst1, const Fst<Arc> &fst2, WeightEqual weight_equal,
-           uint8 etype = kEqualFsts) {
+           uint8_t etype = kEqualFsts) {
   if ((etype & kEqualFstTypes) && (fst1.Type() != fst2.Type())) {
     VLOG(1) << "Equal: Mismatched FST types (" << fst1.Type()
             << " != " << fst2.Type() << ")";
@@ -162,7 +164,7 @@ bool Equal(const Fst<Arc> &fst1, const Fst<Arc> &fst2, WeightEqual weight_equal,
 
 template <class Arc>
 bool Equal(const Fst<Arc> &fst1, const Fst<Arc> &fst2, float delta = kDelta,
-           uint8 etype = kEqualFsts) {
+           uint8_t etype = kEqualFsts) {
   return Equal(fst1, fst2, WeightApproxEqual(delta), etype);
 }
 
@@ -172,7 +174,7 @@ bool Equal(const Fst<Arc> &fst1, const Fst<Arc> &fst2, float delta = kDelta,
 // the instantiation will fail.
 template <class Arc>
 bool Equal(const Fst<Arc> &fst1, const Fst<Arc> &fst2, double delta,
-           uint8 etype = kEqualFsts) {
+           uint8_t etype = kEqualFsts) {
   return Equal(fst1, fst2, WeightApproxEqual(static_cast<float>(delta)), etype);
 }
 
index 5dc4c9e..d64dc3c 100644 (file)
 #define FST_EQUIVALENT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <queue>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/encode.h>
@@ -64,7 +64,7 @@ struct EquivalenceUtil {
   // Maps state ID to the representative of the corresponding
   // equivalence class. The parameter 'which_fst' takes the values 1
   // and 2, identifying the input FST.
-  static MappedId MapState(StateId s, int32 which_fst) {
+  static MappedId MapState(StateId s, int32_t which_fst) {
     return (kNoStateId == s) ? kDeadState
                              : (static_cast<MappedId>(s) << 1) + which_fst;
   }
@@ -93,14 +93,6 @@ struct EquivalenceUtil {
   }
 };
 
-template <class Arc>
-constexpr
-    typename EquivalenceUtil<Arc>::MappedId EquivalenceUtil<Arc>::kDeadState;
-
-template <class Arc>
-constexpr
-    typename EquivalenceUtil<Arc>::MappedId EquivalenceUtil<Arc>::kInvalidId;
-
 }  // namespace internal
 
 // Equivalence checking algorithm: determines if the two FSTs fst1 and fst2
index e16d3cd..bc99b39 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef FST_ERROR_WEIGHT_H_
 #define FST_ERROR_WEIGHT_H_
 
+#include <cstdint>
 #include <ostream>
 #include <string>
 
@@ -29,13 +30,13 @@ struct ErrorWeight {
 
   ErrorWeight() { FSTERROR() << "ErrorWeight::ErrorWeight called"; }
 
-  uint64 Hash() const { return 0; }
+  uint64_t Hash() const { return 0; }
   bool Member() const { return false; }
   ErrorWeight Quantize(float = 0.0) const { return ErrorWeight(); }
   ReverseWeight Reverse() const { return ErrorWeight(); }
   void Write(std::ostream &) const { }
 
-  static constexpr uint64 Properties() { return 0; }
+  static constexpr uint64_t Properties() { return 0; }
   static ErrorWeight Zero() { return ErrorWeight(); }
   static ErrorWeight One() { return ErrorWeight(); }
   static ErrorWeight NoWeight() { return ErrorWeight(); }
index 8d6c81e..24a21c5 100644 (file)
@@ -70,7 +70,7 @@ class ExpandedFst : public Fst<A> {
     }
     auto *fst = reader(strm, ropts);
     if (!fst) return nullptr;
-    return fst::down_cast<ExpandedFst *>(fst);
+    return down_cast<ExpandedFst *>(fst);
   }
 
   // Read an ExpandedFst from a file; return NULL on error.
@@ -168,7 +168,7 @@ class ImplToExpandedFst : public ImplToFst<Impl, FST> {
 template <class Arc>
 typename Arc::StateId CountStates(const Fst<Arc> &fst) {
   if (fst.Properties(kExpanded, false)) {
-    const auto *efst = fst::down_cast<const ExpandedFst<Arc> *>(&fst);
+    const auto *efst = down_cast<const ExpandedFst<Arc> *>(&fst);
     return efst->NumStates();
   } else {
     typename Arc::StateId nstates = 0;
index ced4e50..16202a9 100644 (file)
@@ -40,9 +40,9 @@
 #ifndef FST_EXPECTATION_WEIGHT_H_
 #define FST_EXPECTATION_WEIGHT_H_
 
+#include <cstdint>
 #include <string>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/pair-weight.h>
@@ -109,7 +109,7 @@ class ExpectationWeight : public PairWeight<W1, W2> {
 
   bool Member() const { return PairWeight<W1, W2>::Member(); }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return W1::Properties() & W2::Properties() &
            (kLeftSemiring | kRightSemiring | kCommutative | kIdempotent);
   }
@@ -214,7 +214,7 @@ class WeightGenerate<ExpectationWeight<W1, W2>> {
   using Weight = ExpectationWeight<W1, W2>;
   using Generate = WeightGenerate<PairWeight<W1, W2>>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true)
       : generate_(seed, allow_zero) {}
 
index 8925fb3..076df3e 100644 (file)
 #define FST_EXTENSIONS_COMPRESS_COMPRESS_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <cstdio>
+#include <ios>
 #include <iostream>
+#include <istream>
 #include <map>
 #include <memory>
+#include <ostream>
 #include <queue>
 #include <string>
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/compress/elias.h>
 #include <fst/encode.h>
@@ -44,7 +47,7 @@
 namespace fst {
 
 // Identifies stream data as a vanilla compressed FST.
-static const int32 kCompressMagicNumber = 1858869554;
+inline constexpr int32_t kCompressMagicNumber = 1858869554;
 
 namespace internal {
 
@@ -151,14 +154,14 @@ void LempelZiv<Var, Edge, EdgeLessThan, EdgeEquals>::BatchEncode(
 template <class Var, class Edge, class EdgeLessThan, class EdgeEquals>
 bool LempelZiv<Var, Edge, EdgeLessThan, EdgeEquals>::BatchDecode(
     const std::vector<std::pair<Var, Edge>> &input, std::vector<Edge> *output) {
-  for (auto it = input.cbegin(); it != input.cend(); ++it) {
+  for (const auto &[var, edge] : input) {
     std::vector<Edge> temp_output;
     EdgeEquals InstEdgeEquals;
-    if (InstEdgeEquals(it->second, default_edge_) != 1) {
-      decode_vector_.push_back(*it);
-      temp_output.push_back(it->second);
+    if (InstEdgeEquals(edge, default_edge_) != 1) {
+      decode_vector_.emplace_back(var, edge);
+      temp_output.push_back(edge);
     }
-    auto temp_integer = it->first;
+    auto temp_integer = var;
     if (temp_integer >= decode_vector_.size()) {
       LOG(ERROR) << "LempelZiv::BatchDecode: "
                  << "Index exceeded the dictionary size";
@@ -168,8 +171,7 @@ bool LempelZiv<Var, Edge, EdgeLessThan, EdgeEquals>::BatchDecode(
         temp_output.push_back(decode_vector_[temp_integer].second);
         temp_integer = decode_vector_[temp_integer].first;
       }
-      std::reverse(temp_output.begin(), temp_output.end());
-      output->insert(output->cend(), temp_output.begin(), temp_output.end());
+      output->insert(output->cend(), temp_output.rbegin(), temp_output.rend());
     }
   }
   return true;
@@ -457,7 +459,7 @@ void Compressor<Arc>::EncodeProcessedFst(const ExpandedFst<Arc> &fst,
     }
   }
   WriteToStream(strm);
-  const uint8 unweighted = fst.Properties(kUnweighted, true) == kUnweighted;
+  const uint8_t unweighted = fst.Properties(kUnweighted, true) == kUnweighted;
   WriteType(strm, unweighted);
   if (unweighted == 0) {
     WriteWeight(arc_weight_, strm);
@@ -644,10 +646,10 @@ void Compressor<Arc>::DecodeProcessedFst(const std::vector<StateId> &input,
 template <class Arc>
 void Compressor<Arc>::ReadWeight(std::istream &strm,
                                  std::vector<Weight> *output) {
-  int64 size;
+  int64_t size;
   Weight weight;
   ReadType(strm, &size);
-  for (int64 i = 0; i < size; ++i) {
+  for (int64_t i = 0; i < size; ++i) {
     weight.Read(strm);
     output->push_back(weight);
   }
@@ -657,7 +659,7 @@ template <class Arc>
 bool Compressor<Arc>::Decompress(std::istream &strm, const std::string &source,
                                  MutableFst<Arc> *fst) {
   fst->DeleteStates();
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
   if (magic_number != kCompressMagicNumber) {
     LOG(ERROR) << "Decompress: Bad compressed Fst: " << source;
@@ -666,14 +668,14 @@ bool Compressor<Arc>::Decompress(std::istream &strm, const std::string &source,
   std::unique_ptr<EncodeMapper<Arc>> encoder(
       EncodeMapper<Arc>::Read(strm, "Decoding", DECODE));
   std::vector<bool> bool_code;
-  uint8 block;
-  uint8 msb = 128;
-  int64 data_size;
+  uint8_t block;
+  uint8_t msb = 128;
+  int64_t data_size;
   ReadType(strm, &data_size);
-  for (int64 i = 0; i < data_size; ++i) {
+  for (int64_t i = 0; i < data_size; ++i) {
     ReadType(strm, &block);
     for (int j = 0; j < 8; ++j) {
-      uint8 temp = msb & block;
+      uint8_t temp = msb & block;
       bool_code.push_back(temp == 128);
       block = block << 1;
     }
@@ -681,7 +683,7 @@ bool Compressor<Arc>::Decompress(std::istream &strm, const std::string &source,
   std::vector<StateId> int_code;
   Elias<StateId>::BatchDecode(bool_code, &int_code);
   bool_code.clear();
-  uint8 unweighted;
+  uint8_t unweighted;
   ReadType(strm, &unweighted);
   if (unweighted == 0) {
     ReadWeight(strm, &arc_weight_);
@@ -695,7 +697,7 @@ bool Compressor<Arc>::Decompress(std::istream &strm, const std::string &source,
 template <class Arc>
 void Compressor<Arc>::WriteWeight(const std::vector<Weight> &input,
                                   std::ostream &strm) {
-  int64 size = input.size();
+  int64_t size = input.size();
   WriteType(strm, size);
   for (auto it = input.begin(); it != input.end(); ++it) {
     it->Write(strm);
@@ -705,10 +707,10 @@ void Compressor<Arc>::WriteWeight(const std::vector<Weight> &input,
 template <class Arc>
 void Compressor<Arc>::WriteToStream(std::ostream &strm) {
   while (buffer_code_.size() % 8 != 0) buffer_code_.push_back(true);
-  int64 data_size = buffer_code_.size() / 8;
+  int64_t data_size = buffer_code_.size() / 8;
   WriteType(strm, data_size);
-  int64 i = 0;
-  uint8 block;
+  int64_t i = 0;
+  uint8_t block;
   for (auto it = buffer_code_.begin(); it != buffer_code_.end(); ++it) {
     if (i % 8 == 0) {
       if (i > 0) WriteType(strm, block);
index 881b0c3..f5d1e06 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <libgen.h>
 
+#include <cstdint>
 #include <fstream>
 #include <istream>
 #include <string>
@@ -30,6 +31,7 @@
 #include <fst/string.h>
 
 namespace fst {
+namespace internal {
 
 // Constructs a reader that provides FSTs from a file (stream) either on a
 // line-by-line basis or on a per-stream basis. Note that the freshly
@@ -132,25 +134,26 @@ class StringReader {
 
 // Computes the minimal length required to encode each line number as a decimal
 // number, or zero if the file is not seekable.
-int KeySize(const char *source);
+int KeySize(const std::string &source);
+
+}  // namespace internal
 
 template <class Arc>
-void FarCompileStrings(const std::vector<std::string> &in_sources,
-                       const std::string &out_source,
-                       const std::string &fst_type, const FarType &far_type,
-                       int32 generate_keys, FarEntryType entry_type,
-                       TokenType token_type, const std::string &symbols_source,
-                       const std::string &unknown_symbol, bool keep_symbols,
-                       bool initial_symbols, bool allow_negative_labels,
-                       const std::string &key_prefix,
-                       const std::string &key_suffix) {
+void CompileStrings(const std::vector<std::string> &sources,
+                    FarWriter<Arc> &writer, std::string_view fst_type,
+                    int32_t generate_keys, FarEntryType entry_type,
+                    TokenType token_type, const std::string &symbols_source,
+                    const std::string &unknown_symbol, bool keep_symbols,
+                    bool initial_symbols, bool allow_negative_labels,
+                    const std::string &key_prefix,
+                    const std::string &key_suffix) {
   bool compact;
   if (fst_type.empty() || (fst_type == "vector")) {
     compact = false;
   } else if (fst_type == "compact") {
     compact = true;
   } else {
-    FSTERROR() << "FarCompileStrings: Unknown FST type: " << fst_type;
+    FSTERROR() << "CompileStrings: Unknown FST type: " << fst_type;
     return;
   }
   std::unique_ptr<const SymbolTable> syms;
@@ -159,36 +162,33 @@ void FarCompileStrings(const std::vector<std::string> &in_sources,
     const SymbolTableTextOptions opts(allow_negative_labels);
     syms.reset(SymbolTable::ReadText(symbols_source, opts));
     if (!syms) {
-      LOG(ERROR) << "FarCompileStrings: Error reading symbol table: "
+      LOG(ERROR) << "CompileStrings: Error reading symbol table: "
                  << symbols_source;
       return;
     }
     if (!unknown_symbol.empty()) {
       unknown_label = syms->Find(unknown_symbol);
       if (unknown_label == kNoLabel) {
-        FSTERROR() << "FarCompileStrings: Label \"" << unknown_label
+        FSTERROR() << "CompileStrings: Label \"" << unknown_label
                    << "\" missing from symbol table: " << symbols_source;
         return;
       }
     }
   }
-  std::unique_ptr<FarWriter<Arc>> far_writer(
-      FarWriter<Arc>::Create(out_source, far_type));
-  if (!far_writer) return;
   int n = 0;
-  for (const auto &in_source : in_sources) {
+  for (const auto &in_source : sources) {
     // Don't try to call KeySize("").
     if (generate_keys == 0 && in_source.empty()) {
-      FSTERROR() << "FarCompileStrings: Read from a file instead of stdin or"
+      FSTERROR() << "CompileStrings: Read from a file instead of stdin or"
                  << " set the --generate_keys flag.";
       return;
     }
     const int key_size = generate_keys ? generate_keys
                                        : (entry_type == FarEntryType::FILE
                                               ? 1
-                                              : KeySize(in_source.c_str()));
+                                              : internal::KeySize(in_source));
     if (key_size == 0) {
-      FSTERROR() << "FarCompileStrings: " << in_source << " is not seekable. "
+      FSTERROR() << "CompileStrings: " << in_source << " is not seekable. "
                  << "Read from a file instead or set the --generate_keys flag.";
       return;
     }
@@ -196,13 +196,13 @@ void FarCompileStrings(const std::vector<std::string> &in_sources,
     if (!in_source.empty()) {
       fstrm.open(in_source);
       if (!fstrm) {
-        FSTERROR() << "FarCompileStrings: Can't open file: " << in_source;
+        FSTERROR() << "CompileStrings: Can't open file: " << in_source;
         return;
       }
     }
     std::istream &istrm = fstrm.is_open() ? fstrm : std::cin;
     bool keep_syms = keep_symbols;
-    for (StringReader<Arc> reader(
+    for (internal::StringReader<Arc> reader(
              istrm, in_source.empty() ? "stdin" : in_source, entry_type,
              token_type, allow_negative_labels, syms.get(), unknown_label);
          !reader.Done(); reader.Next()) {
@@ -215,13 +215,14 @@ void FarCompileStrings(const std::vector<std::string> &in_sources,
       }
       if (initial_symbols) keep_syms = false;
       if (!fst) {
-        FSTERROR()
-            << "FarCompileStrings: Compiling string number " << n << " in file "
-            << in_source << " failed with token_type = " << token_type
-            << " and entry_type = "
-            << (entry_type == FarEntryType::LINE
-                    ? "line"
-                    : (entry_type == FarEntryType::FILE ? "file" : "unknown"));
+        FSTERROR() << "CompileStrings: Compiling string number " << n
+                   << " in file " << in_source
+                   << " failed with token_type = " << token_type
+                   << " and entry_type = "
+                   << (entry_type == FarEntryType::LINE
+                           ? "line"
+                           : (entry_type == FarEntryType::FILE ? "file"
+                                                               : "unknown"));
         return;
       }
       std::ostringstream keybuf;
@@ -232,16 +233,16 @@ void FarCompileStrings(const std::vector<std::string> &in_sources,
       if (generate_keys > 0) {
         key = keybuf.str();
       } else {
-        auto *source = new char[in_source.size() + 1];
-        strcpy(source, in_source.c_str());  // NOLINT
-        key = basename(source);
+        auto source =
+            fst::make_unique_for_overwrite<char[]>(in_source.size() + 1);
+        strcpy(source.get(), in_source.c_str());  // NOLINT(runtime/printf)
+        key = basename(source.get());
         if (entry_type != FarEntryType::FILE) {
           key += "-";
           key += keybuf.str();
         }
-        delete[] source;
       }
-      far_writer->Add(key_prefix + key + key_suffix, *fst);
+      writer.Add(key_prefix + key + key_suffix, *fst);
     }
     if (generate_keys == 0) n = 0;
   }
index f57acc2..1d44c50 100644 (file)
 #ifndef FST_EXTENSIONS_FAR_CONVERT_H_
 #define FST_EXTENSIONS_FAR_CONVERT_H_
 
-#include <memory>
-#include <string>
-
 #include <fst/extensions/far/far.h>
 #include <fst/extensions/far/getters.h>
+#include <fst/extensions/far/map-reduce.h>
 #include <fst/register.h>
+#include <string_view>
 
 namespace fst {
 
 template <class Arc>
-void FarConvert(const std::string &in_source, const std::string &out_source,
-                const std::string &fst_type, const FarType &far_type) {
-  std::unique_ptr<FarReader<Arc>> reader(FarReader<Arc>::Open(in_source));
-  if (!reader) {
-    FSTERROR() << "FarConvert: Cannot open input FAR: " << in_source;
-    return;
-  }
-
-  std::unique_ptr<FarWriter<Arc>> writer(
-      FarWriter<Arc>::Create(out_source, far_type));
-  if (!writer) {
-    FSTERROR() << "FarConvert: Cannot open output FAR as type "
-               << GetFarTypeString(far_type) << " : " << out_source;
-    return;
-  }
-
-  for (; !reader->Done(); reader->Next()) {
-    const std::string key = reader->GetKey();
-    const Fst<Arc> *const fst = reader->GetFst();
-
-    if (fst_type.empty() || fst->Type() == fst_type) {
-      writer->Add(key, *fst);
-    } else {
-      auto converted_fst = fst::WrapUnique(Convert(*fst, fst_type));
-      if (!converted_fst) {
-        FSTERROR() << "FarConvert: Cannot convert FST with key " << key
-                   << " to " << fst_type;
-        return;
-      }
-
-      writer->Add(key, *converted_fst);
-    }
-  }
-
-  if (reader->Error()) {
-    FSTERROR() << "FarConvert: Error reading FAR: " << in_source;
-  }
-  if (writer->Error()) {
-    FSTERROR() << "FarConvert: Error writing FAR: " << out_source;
-  }
+void Convert(FarReader<Arc> &reader, FarWriter<Arc> &writer,
+             std::string_view fst_type) {
+  internal::Map(reader, writer,
+                [&fst_type](std::string_view key, const Fst<Arc> *ifst) {
+                  if (fst_type.empty() || ifst->Type() == fst_type) {
+                    return fst::WrapUnique(ifst->Copy());
+                  }
+                  auto ofst = fst::WrapUnique(Convert(*ifst, fst_type));
+                  if (!ofst) {
+                    FSTERROR() << "FarConvert: Cannot convert FST with key "
+                               << key << " to " << fst_type;
+                  }
+                  return ofst;
+                });
 }
 
 }  // namespace fst
index 29f886f..4874d4e 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <libgen.h>
 
+#include <cstdint>
 #include <sstream>
 #include <string>
 #include <vector>
 namespace fst {
 
 template <class Arc>
-void FarCreate(const std::vector<std::string> &in_sources,
-               const std::string &out_source, const int32 generate_keys,
-               const FarType &far_type, const std::string &key_prefix,
-               const std::string &key_suffix) {
-  std::unique_ptr<FarWriter<Arc>> far_writer(
-      FarWriter<Arc>::Create(out_source, far_type));
-  if (!far_writer) return;
-  for (size_t i = 0; i < in_sources.size(); ++i) {
-    std::unique_ptr<Fst<Arc>> ifst(Fst<Arc>::Read(in_sources[i]));
+void Create(const std::vector<std::string> &sources, FarWriter<Arc> &writer,
+            int32_t generate_keys, const std::string &key_prefix,
+            const std::string &key_suffix) {
+  for (size_t i = 0; i < sources.size(); ++i) {
+    std::unique_ptr<Fst<Arc>> ifst(Fst<Arc>::Read(sources[i]));
     if (!ifst) return;
     std::string key;
     if (generate_keys > 0) {
@@ -49,12 +46,12 @@ void FarCreate(const std::vector<std::string> &in_sources,
       keybuf << i + 1;
       key = keybuf.str();
     } else {
-      auto *source = new char[in_sources[i].size() + 1];
-      strcpy(source, in_sources[i].c_str());  // NOLINT
-      key = basename(source);
-      delete[] source;
+      auto source =
+          fst::make_unique_for_overwrite<char[]>(sources[i].size() + 1);
+      strcpy(source.get(), sources[i].c_str());  // NOLINT(runtime/printf)
+      key = basename(source.get());
     }
-    far_writer->Add(key_prefix + key + key_suffix, *ifst);
+    writer.Add(key_prefix + key + key_suffix, *ifst);
   }
 }
 
diff --git a/src/include/fst/extensions/far/encode.h b/src/include/fst/extensions/far/encode.h
new file mode 100644 (file)
index 0000000..8d7f24d
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright 2005-2020 Google LLC
+//
+// 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.
+//
+#ifndef FST_EXTENSIONS_FAR_ENCODE_H_
+#define FST_EXTENSIONS_FAR_ENCODE_H_
+
+#include <fst/extensions/far/far.h>
+#include <fst/extensions/far/getters.h>
+#include <fst/extensions/far/map-reduce.h>
+#include <fst/encode.h>
+#include <fst/vector-fst.h>
+#include <string_view>
+
+namespace fst {
+
+template <class Arc>
+void Encode(FarReader<Arc> &reader, FarWriter<Arc> &writer,
+            EncodeMapper<Arc> *mapper) {
+  internal::Map(reader, writer,
+                [mapper](std::string_view key, const Fst<Arc> *ifst) {
+                  auto ofst = std::make_unique<VectorFst<Arc>>(*ifst);
+                  Encode(ofst.get(), mapper);
+                  return ofst;
+                });
+}
+
+template <class Arc>
+void Decode(FarReader<Arc> &reader, FarWriter<Arc> &writer,
+            const EncodeMapper<Arc> &mapper) {
+  internal::Map(reader, writer,
+                [&mapper](std::string_view key, const Fst<Arc> *ifst) {
+                  auto ofst = std::make_unique<VectorFst<Arc>>(*ifst);
+                  Decode(ofst.get(), mapper);
+                  return ofst;
+                });
+}
+
+}  // namespace fst
+
+#endif  // FST_EXTENSIONS_FAR_ENCODE_H_
index 65df80b..cf0aa4e 100644 (file)
 #ifndef FST_EXTENSIONS_FAR_EQUAL_H_
 #define FST_EXTENSIONS_FAR_EQUAL_H_
 
-#include <memory>
-#include <string>
-
 #include <fst/extensions/far/far.h>
+#include <fst/extensions/far/map-reduce.h>
 #include <fst/equal.h>
+#include <string_view>
 
 namespace fst {
 
 template <class Arc>
-bool FarEqual(const std::string &source1, const std::string &source2,
-              float delta = kDelta,
-              const std::string &begin_key = std::string(),
-              const std::string &end_key = std::string()) {
-  std::unique_ptr<FarReader<Arc>> reader1(FarReader<Arc>::Open(source1));
-  if (!reader1) {
-    LOG(ERROR) << "FarEqual: Could not open FAR file " << source1;
-    return false;
-  }
-  std::unique_ptr<FarReader<Arc>> reader2(FarReader<Arc>::Open(source2));
-  if (!reader2) {
-    LOG(ERROR) << "FarEqual: Could not open FAR file " << source2;
-    return false;
-  }
-  if (!begin_key.empty()) {
-    bool find_begin1 = reader1->Find(begin_key);
-    bool find_begin2 = reader2->Find(begin_key);
-    if (!find_begin1 || !find_begin2) {
-      bool ret = !find_begin1 && !find_begin2;
-      if (!ret) {
-        LOG(ERROR) << "FarEqual: Key " << begin_key << " missing from "
-                   << (find_begin1 ? "second" : "first") << " archive";
-      }
-      return ret;
-    }
-  }
-  for (; !reader1->Done() && !reader2->Done();
-       reader1->Next(), reader2->Next()) {
-    const auto &key1 = reader1->GetKey();
-    const auto &key2 = reader2->GetKey();
-    if (!end_key.empty() && end_key < key1 && end_key < key2) {
-      return true;
-    }
-    if (key1 != key2) {
-      LOG(ERROR) << "FarEqual: Mismatched keys " << key1 << " and " << key2;
-      return false;
-    }
-    if (!Equal(*(reader1->GetFst()), *(reader2->GetFst()), delta)) {
-      LOG(ERROR) << "FarEqual: FSTs for key " << key1 << " are not equal";
-      return false;
-    }
-  }
-  if (!reader1->Done() || !reader2->Done()) {
-    LOG(ERROR) << "FarEqual: Key "
-               << (reader1->Done() ? reader2->GetKey() : reader1->GetKey())
-               << " missing from " << (reader2->Done() ? "first" : "second")
-               << " archive";
-    return false;
-  }
-  return true;
+bool Equal(FarReader<Arc> &reader1, FarReader<Arc> &reader2,
+           float delta = kDelta, std::string_view begin_key = "",
+           std::string_view end_key = "") {
+  return internal::MapAllReduce(
+      reader1, reader2,
+      [delta](std::string_view key, const Fst<Arc> *fst1,
+              const Fst<Arc> *fst2) {
+        if (!Equal(*fst1, *fst2, delta)) {
+          LOG(ERROR) << "Equal: FSTs for key " << key << " are not equal";
+          return false;
+        }
+        return true;
+      },
+      begin_key, end_key);
 }
 
 }  // namespace fst
index 14443bf..3c6038c 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_EXTENSIONS_FAR_EXTRACT_H_
 #define FST_EXTENSIONS_FAR_EXTRACT_H_
 
+#include <cstdint>
 #include <iomanip>
 #include <memory>
 #include <string>
@@ -33,7 +34,7 @@ namespace fst {
 
 template <class Arc>
 inline void FarWriteFst(const Fst<Arc> *fst, std::string_view key,
-                        std::string *okey, int *nrep, int32 generate_sources,
+                        std::string *okey, int *nrep, int32_t generate_sources,
                         int i, std::string_view source_prefix,
                         std::string_view source_suffix) {
   DCHECK_NE(fst, nullptr);
@@ -58,63 +59,60 @@ inline void FarWriteFst(const Fst<Arc> *fst, std::string_view key,
 }
 
 template <class Arc>
-void FarExtract(const std::vector<std::string> &isources,
-                int32 generate_sources, const std::string &keys,
-                const std::string &key_separator,
-                const std::string &range_delimiter,
-                const std::string &source_prefix,
-                const std::string &source_suffix) {
-  std::unique_ptr<FarReader<Arc>> far_reader(FarReader<Arc>::Open(isources));
-  if (!far_reader) return;
+void Extract(FarReader<Arc> &reader, int32_t generate_sources,
+             const std::string &keys, const std::string &key_separator,
+             const std::string &range_delimiter,
+             const std::string &source_prefix,
+             const std::string &source_suffix) {
   std::string okey;
   int nrep = 0;
   // User has specified a set of FSTs to extract, where some of these may in
   // fact be ranges.
   if (!keys.empty()) {
     std::vector<std::string_view> key_vector =
-        SplitString(keys, key_separator, true);
+        StrSplit(keys, ByAnyChar(key_separator), SkipEmpty());
     int i = 0;
     for (size_t k = 0; k < key_vector.size(); ++k, ++i) {
       std::string_view key = key_vector[k];
       std::vector<std::string_view> range_vector =
-          SplitString(key, range_delimiter, false);
+          StrSplit(key, ByAnyChar(range_delimiter));
       if (range_vector.size() == 1) {  // Not a range
-        if (!far_reader->Find(key)) {
-          LOG(ERROR) << "FarExtract: Cannot find key " << key;
+        if (!reader.Find(key)) {
+          LOG(ERROR) << "Extract: Cannot find key " << key;
           return;
         }
-        const auto *fst = far_reader->GetFst();
+        const auto *fst = reader.GetFst();
         FarWriteFst(fst, key, &okey, &nrep, generate_sources, i, source_prefix,
                     source_suffix);
       } else if (range_vector.size() == 2) {  // A legal range
         std::string_view begin_key = range_vector[0];
         std::string_view end_key = range_vector[1];
         if (begin_key.empty() || end_key.empty()) {
-          LOG(ERROR) << "FarExtract: Illegal range specification " << key;
+          LOG(ERROR) << "Extract: Illegal range specification " << key;
           return;
         }
-        if (!far_reader->Find(begin_key)) {
-          LOG(ERROR) << "FarExtract: Cannot find key " << begin_key;
+        if (!reader.Find(begin_key)) {
+          LOG(ERROR) << "Extract: Cannot find key " << begin_key;
           return;
         }
-        for (; !far_reader->Done(); far_reader->Next(), ++i) {
-          const auto &ikey = far_reader->GetKey();
+        for (; !reader.Done(); reader.Next(), ++i) {
+          const auto &ikey = reader.GetKey();
           if (end_key < ikey) break;
-          const auto *fst = far_reader->GetFst();
+          const auto *fst = reader.GetFst();
           FarWriteFst(fst, ikey, &okey, &nrep, generate_sources, i,
                       source_prefix, source_suffix);
         }
       } else {
-        LOG(ERROR) << "FarExtract: Illegal range specification " << key;
+        LOG(ERROR) << "Extract: Illegal range specification " << key;
         return;
       }
     }
     return;
   }
   // Nothing specified, so just extracts everything.
-  for (size_t i = 1; !far_reader->Done(); far_reader->Next(), ++i) {
-    const auto &key = far_reader->GetKey();
-    const auto *fst = far_reader->GetFst();
+  for (size_t i = 1; !reader.Done(); reader.Next(), ++i) {
+    const auto &key = reader.GetKey();
+    const auto *fst = reader.GetFst();
     FarWriteFst(fst, key, &okey, &nrep, generate_sources, i, source_prefix,
                 source_suffix);
   }
index 0053ce9..3ed9dfe 100644 (file)
@@ -122,7 +122,7 @@ class FarReaderClass {
   const FarReader<Arc> *GetFarReader() const {
     if (Arc::Type() != ArcType()) return nullptr;
     const FarReaderClassImpl<Arc> *typed_impl =
-        fst::down_cast<FarReaderClassImpl<Arc> *>(impl_.get());
+        down_cast<FarReaderClassImpl<Arc> *>(impl_.get());
     return typed_impl->GetFarReader();
   }
 
@@ -130,7 +130,7 @@ class FarReaderClass {
   FarReader<Arc> *GetFarReader() {
     if (Arc::Type() != ArcType()) return nullptr;
     FarReaderClassImpl<Arc> *typed_impl =
-        fst::down_cast<FarReaderClassImpl<Arc> *>(impl_.get());
+        down_cast<FarReaderClassImpl<Arc> *>(impl_.get());
     return typed_impl->GetFarReader();
   }
 
@@ -243,7 +243,7 @@ class FarWriterClass {
   const FarWriter<Arc> *GetFarWriter() const {
     if (Arc::Type() != ArcType()) return nullptr;
     const FarWriterClassImpl<Arc> *typed_impl =
-        fst::down_cast<FarWriterClassImpl<Arc> *>(impl_.get());
+        down_cast<FarWriterClassImpl<Arc> *>(impl_.get());
     return typed_impl->GetFarWriter();
   }
 
@@ -251,7 +251,7 @@ class FarWriterClass {
   FarWriter<Arc> *GetFarWriter() {
     if (Arc::Type() != ArcType()) return nullptr;
     FarWriterClassImpl<Arc> *typed_impl =
-        fst::down_cast<FarWriterClassImpl<Arc> *>(impl_.get());
+        down_cast<FarWriterClassImpl<Arc> *>(impl_.get());
     return typed_impl->GetFarWriter();
   }
 
index 539f4e6..c1d3ae3 100644 (file)
 #ifndef FST_EXTENSIONS_FAR_FAR_H_
 #define FST_EXTENSIONS_FAR_FAR_H_
 
+#include <algorithm>
+#include <cstdint>
 #include <iostream>
 #include <sstream>
+#include <string>
+#include <utility>
 
 #include <fst/log.h>
 #include <fst/extensions/far/stlist.h>
@@ -36,13 +40,20 @@ namespace fst {
 
 enum class FarEntryType { LINE, FILE };
 
+enum class FarType {
+  DEFAULT = 0,
+  STTABLE = 1,
+  STLIST = 2,
+  FST = 3,
+};
+
 // Checks for FST magic number in an input stream (to be opened given the source
 // name), to indicate to the caller function that the stream content is an FST
 // header.
 inline bool IsFst(const std::string &source) {
   std::ifstream strm(source, std::ios_base::in | std::ios_base::binary);
   if (!strm) return false;
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
   bool match = magic_number == kFstMagicNumber;
   return match;
@@ -53,28 +64,28 @@ class FarHeader {
  public:
   const std::string &ArcType() const { return arctype_; }
 
-  const std::string &FarType() const { return fartype_; }
+  enum FarType FarType() const { return fartype_; }
 
   bool Read(const std::string &source) {
     FstHeader fsthdr;
     arctype_ = "unknown";
     if (source.empty()) {
       // Header reading unsupported on stdin. Assumes STList and StdArc.
-      fartype_ = "stlist";
+      fartype_ = FarType::STLIST;
       arctype_ = "standard";
       return true;
     } else if (IsSTTable(source)) {  // Checks if STTable.
-      fartype_ = "sttable";
+      fartype_ = FarType::STTABLE;
       if (!ReadSTTableHeader(source, &fsthdr)) return false;
       arctype_ = fsthdr.ArcType().empty() ? ErrorArc::Type() : fsthdr.ArcType();
       return true;
     } else if (IsSTList(source)) {  // Checks if STList.
-      fartype_ = "stlist";
+      fartype_ = FarType::STLIST;
       if (!ReadSTListHeader(source, &fsthdr)) return false;
       arctype_ = fsthdr.ArcType().empty() ? ErrorArc::Type() : fsthdr.ArcType();
       return true;
     } else if (IsFst(source)) {  // Checks if FST.
-      fartype_ = "fst";
+      fartype_ = FarType::FST;
       std::ifstream istrm(source,
                                std::ios_base::in | std::ios_base::binary);
       if (!fsthdr.Read(istrm, source)) return false;
@@ -85,17 +96,10 @@ class FarHeader {
   }
 
  private:
-  std::string fartype_;
+  enum FarType fartype_;
   std::string arctype_;
 };
 
-enum class FarType {
-  DEFAULT = 0,
-  STTABLE = 1,
-  STLIST = 2,
-  FST = 3,
-};
-
 // This class creates an archive of FSTs.
 template <class A>
 class FarWriter {
@@ -108,7 +112,7 @@ class FarWriter {
 
   // Adds an FST to the end of an archive. Keys must be non-empty and
   // in lexicographic order. FSTs must have a suitable write method.
-  virtual void Add(const std::string &key, const Fst<Arc> &fst) = 0;
+  virtual void Add(std::string_view key, const Fst<Arc> &fst) = 0;
 
   virtual FarType Type() const = 0;
 
@@ -182,7 +186,7 @@ class STTableFarWriter : public FarWriter<A> {
     return new STTableFarWriter(writer);
   }
 
-  void Add(const std::string &key, const Fst<Arc> &fst) final {
+  void Add(std::string_view key, const Fst<Arc> &fst) final {
     writer_->Add(key, fst);
   }
 
@@ -207,7 +211,7 @@ class STListFarWriter : public FarWriter<A> {
     return new STListFarWriter(writer);
   }
 
-  void Add(const std::string &key, const Fst<Arc> &fst) final {
+  void Add(std::string_view key, const Fst<Arc> &fst) final {
     writer_->Add(key, fst);
   }
 
@@ -234,7 +238,7 @@ class FstFarWriter final : public FarWriter<A> {
     return new FstFarWriter(source);
   }
 
-  void Add(const std::string &key, const Fst<A> &fst) final {
+  void Add(std::string_view key, const Fst<A> &fst) final {
     if (written_) {
       LOG(WARNING) << "FstFarWriter::Add: only one FST supported,"
                    << " subsequent entries discarded.";
index 116f044..792cbdc 100644 (file)
 #ifndef FST_EXTENSIONS_FAR_FARSCRIPT_H_
 #define FST_EXTENSIONS_FAR_FARSCRIPT_H_
 
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/extensions/far/compile-strings.h>
 #include <fst/extensions/far/convert.h>
 #include <fst/extensions/far/create.h>
+#include <fst/extensions/far/encode.h>
 #include <fst/extensions/far/equal.h>
 #include <fst/extensions/far/extract.h>
 #include <fst/extensions/far/far-class.h>
@@ -37,6 +38,7 @@
 #include <fst/extensions/far/print-strings.h>
 #include <fst/extensions/far/script-impl.h>
 #include <fst/script/arg-packs.h>
+#include <string_view>
 
 namespace fst {
 namespace script {
@@ -45,11 +47,10 @@ namespace script {
 // only used to pass them deeper in the call graph. Be sure you understand why
 // this is so before using this struct for anything else!
 struct FarCompileStringsArgs {
-  const std::vector<std::string> &in_sources;
-  const std::string &out_source;
-  const std::string &fst_type;
-  const FarType &far_type;
-  const int32 generate_keys;
+  const std::vector<std::string> &sources;
+  FarWriterClass &writer;
+  std::string_view fst_type;
+  const int32_t generate_keys;
   const FarEntryType fet;
   const TokenType tt;
   const std::string &symbols_source;
@@ -62,153 +63,174 @@ struct FarCompileStringsArgs {
 };
 
 template <class Arc>
-void FarCompileStrings(FarCompileStringsArgs *args) {
-  FarCompileStrings<Arc>(
-      args->in_sources, args->out_source, args->fst_type, args->far_type,
-      args->generate_keys, args->fet, args->tt, args->symbols_source,
-      args->unknown_symbol, args->keep_symbols, args->initial_symbols,
-      args->allow_negative_labels, args->key_prefix, args->key_suffix);
+void CompileStrings(FarCompileStringsArgs *args) {
+  FarWriter<Arc> &writer = *args->writer.GetFarWriter<Arc>();
+  ::fst::CompileStrings<Arc>(
+      args->sources, writer, args->fst_type, args->generate_keys, args->fet,
+      args->tt, args->symbols_source, args->unknown_symbol, args->keep_symbols,
+      args->initial_symbols, args->allow_negative_labels, args->key_prefix,
+      args->key_suffix);
 }
 
-void FarCompileStrings(const std::vector<std::string> &in_sources,
-                       const std::string &out_source,
-                       const std::string &arc_type, const std::string &fst_type,
-                       const FarType &far_type, int32 generate_keys,
-                       FarEntryType fet, TokenType tt,
-                       const std::string &symbols_source,
-                       const std::string &unknown_symbol, bool keep_symbols,
-                       bool initial_symbols, bool allow_negative_labels,
-                       const std::string &key_prefix,
-                       const std::string &key_suffix);
-
-struct FarConvertArgs {
-  const std::string &in_source;
-  const std::string &out_source;
-  const std::string &fst_type;
-  const FarType &far_type;
-};
+void CompileStrings(const std::vector<std::string> &sources,
+                    FarWriterClass &writer, std::string_view fst_type,
+                    int32_t generate_keys, FarEntryType fet, TokenType tt,
+                    const std::string &symbols_source,
+                    const std::string &unknown_symbol, bool keep_symbols,
+                    bool initial_symbols, bool allow_negative_labels,
+                    const std::string &key_prefix,
+                    const std::string &key_suffix);
+
+using FarConvertArgs =
+    std::tuple<FarReaderClass &, FarWriterClass &, std::string_view>;
 
 template <class Arc>
-void FarConvert(FarConvertArgs *args) {
-  FarConvert<Arc>(args->in_source, args->out_source, args->fst_type,
-                  args->far_type);
+void Convert(FarConvertArgs *args) {
+  FarReader<Arc> &reader = *std::get<0>(*args).GetFarReader<Arc>();
+  FarWriter<Arc> &writer = *std::get<1>(*args).GetFarWriter<Arc>();
+  ::fst::Convert<Arc>(reader, writer, std::get<2>(*args));
 }
 
-void FarConvert(const std::string &in_source, const std::string &out_source,
-                const std::string &arc_type, const std::string &fst_type,
-                const FarType &far_type);
+void Convert(FarReaderClass &reader, FarWriterClass &writer,
+             std::string_view fst_type);
 
 // Note: it is safe to pass these strings as references because this struct is
 // only used to pass them deeper in the call graph. Be sure you understand why
 // this is so before using this struct for anything else!
 struct FarCreateArgs {
-  const std::vector<std::string> &in_sources;
-  const std::string &out_source;
-  const int32 generate_keys;
-  const FarType &far_type;
+  const std::vector<std::string> &sources;
+  FarWriterClass &writer;
+  const int32_t generate_keys;
   const std::string &key_prefix;
   const std::string &key_suffix;
 };
 
 template <class Arc>
-void FarCreate(FarCreateArgs *args) {
-  FarCreate<Arc>(args->in_sources, args->out_source, args->generate_keys,
-                 args->far_type, args->key_prefix, args->key_suffix);
+void Create(FarCreateArgs *args) {
+  FarWriter<Arc> &writer = *args->writer.GetFarWriter<Arc>();
+  ::fst::Create<Arc>(args->sources, writer, args->generate_keys,
+                         args->key_prefix, args->key_suffix);
+}
+
+void Create(const std::vector<std::string> &sources, FarWriterClass &writer,
+            int32_t generate_keys, const std::string &key_prefix,
+            const std::string &key_suffix);
+
+using FarDecodeArgs =
+    std::tuple<FarReaderClass &, FarWriterClass &, const EncodeMapperClass &>;
+
+template <class Arc>
+void Decode(FarDecodeArgs *args) {
+  FarReader<Arc> &reader = *std::get<0>(*args).GetFarReader<Arc>();
+  FarWriter<Arc> &writer = *std::get<1>(*args).GetFarWriter<Arc>();
+  const EncodeMapper<Arc> &mapper = *std::get<2>(*args).GetEncodeMapper<Arc>();
+  Decode(reader, writer, mapper);
 }
 
-void FarCreate(const std::vector<std::string> &in_sources,
-               const std::string &out_source, const std::string &arc_type,
-               const int32 generate_keys, const FarType &far_type,
-               const std::string &key_prefix, const std::string &key_suffix);
+void Decode(FarReaderClass &reader, FarWriterClass &writer,
+            const EncodeMapperClass &encoder);
 
-using FarEqualInnerArgs =
-    std::tuple<const std::string &, const std::string &, float,
-               const std::string &, const std::string &>;
+using FarEncodeArgs =
+    std::tuple<FarReaderClass &, FarWriterClass &, EncodeMapperClass *>;
+
+template <class Arc>
+void Encode(FarEncodeArgs *args) {
+  FarReader<Arc> &reader = *std::get<0>(*args).GetFarReader<Arc>();
+  FarWriter<Arc> &writer = *std::get<1>(*args).GetFarWriter<Arc>();
+  EncodeMapper<Arc> *mapper = std::get<2>(*args)->GetEncodeMapper<Arc>();
+  Encode(reader, writer, mapper);
+}
+
+void Encode(FarReaderClass &reader, FarWriterClass &writer,
+            EncodeMapperClass *encoder);
+
+using FarEqualInnerArgs = std::tuple<FarReaderClass &, FarReaderClass &, float,
+                                     std::string_view, std::string_view>;
 
 using FarEqualArgs = WithReturnValue<bool, FarEqualInnerArgs>;
 
 template <class Arc>
-void FarEqual(FarEqualArgs *args) {
-  args->retval = fst::FarEqual<Arc>(
-      std::get<0>(args->args), std::get<1>(args->args), std::get<2>(args->args),
-      std::get<3>(args->args), std::get<4>(args->args));
+void Equal(FarEqualArgs *args) {
+  FarReader<Arc> &reader1 = *std::get<0>(args->args).GetFarReader<Arc>();
+  FarReader<Arc> &reader2 = *std::get<1>(args->args).GetFarReader<Arc>();
+  args->retval =
+      ::fst::Equal<Arc>(reader1, reader2, std::get<2>(args->args),
+                            std::get<3>(args->args), std::get<4>(args->args));
 }
 
-bool FarEqual(const std::string &source1, const std::string &source2,
-              const std::string &arc_type, float delta = kDelta,
-              const std::string &begin_key = std::string(),
-              const std::string &end_key = std::string());
+bool Equal(FarReaderClass &reader1, FarReaderClass &reader2,
+           float delta = kDelta, std::string_view begin_key = "",
+           std::string_view end_key = "");
 
 using FarExtractArgs =
-    std::tuple<const std::vector<std::string> &, int32, const std::string &,
+    std::tuple<FarReaderClass &, int32_t, const std::string &,
                const std::string &, const std::string &, const std::string &,
                const std::string &>;
 
 template <class Arc>
-void FarExtract(FarExtractArgs *args) {
-  fst::FarExtract<Arc>(std::get<0>(*args), std::get<1>(*args),
-                           std::get<2>(*args), std::get<3>(*args),
-                           std::get<4>(*args), std::get<5>(*args),
-                           std::get<6>(*args));
+void Extract(FarExtractArgs *args) {
+  FarReader<Arc> &reader = *std::get<0>(*args).GetFarReader<Arc>();
+  ::fst::Extract<Arc>(reader, std::get<1>(*args), std::get<2>(*args),
+                          std::get<3>(*args), std::get<4>(*args),
+                          std::get<5>(*args), std::get<6>(*args));
 }
 
-void FarExtract(const std::vector<std::string> &isources,
-                const std::string &arc_type, int32 generate_sources,
-                const std::string &keys, const std::string &key_separator,
-                const std::string &range_delimiter,
-                const std::string &source_prefix,
-                const std::string &source_suffix);
+void Extract(FarReaderClass &reader, int32_t generate_sources,
+             const std::string &keys, const std::string &key_separator,
+             const std::string &range_delimiter,
+             const std::string &source_prefix,
+             const std::string &source_suffix);
 
 using FarInfoArgs =
     std::tuple<const std::vector<std::string> &, const std::string &,
                const std::string &, const bool>;
 
 template <class Arc>
-void FarInfo(FarInfoArgs *args) {
-  fst::FarInfo<Arc>(std::get<0>(*args), std::get<1>(*args),
-                        std::get<2>(*args), std::get<3>(*args));
+void Info(FarInfoArgs *args) {
+  ::fst::Info<Arc>(std::get<0>(*args), std::get<1>(*args),
+                       std::get<2>(*args), std::get<3>(*args));
 }
 
-void FarInfo(const std::vector<std::string> &sources,
-             const std::string &arc_type, const std::string &begin_key,
-             const std::string &end_key, const bool list_fsts);
+void Info(const std::vector<std::string> &sources, const std::string &arc_type,
+          const std::string &begin_key, const std::string &end_key,
+          const bool list_fsts);
 
-using GetFarInfoArgs =
+using FarGetInfoArgs =
     std::tuple<const std::vector<std::string> &, const std::string &,
                const std::string &, const bool, FarInfoData *>;
 
 template <class Arc>
-void GetFarInfo(GetFarInfoArgs *args) {
-  fst::GetFarInfo<Arc>(std::get<0>(*args), std::get<1>(*args),
-                           std::get<2>(*args), std::get<3>(*args),
-                           std::get<4>(*args));
+void GetInfo(FarGetInfoArgs *args) {
+  ::fst::GetInfo<Arc>(std::get<0>(*args), std::get<1>(*args),
+                          std::get<2>(*args), std::get<3>(*args),
+                          std::get<4>(*args));
 }
 
-void GetFarInfo(const std::vector<std::string> &sources,
-                const std::string &arc_type, const std::string &begin_key,
-                const std::string &end_key, const bool list_fsts,
-                FarInfoData *);
+void GetInfo(const std::vector<std::string> &sources,
+             const std::string &arc_type, const std::string &begin_key,
+             const std::string &end_key, const bool list_fsts, FarInfoData *);
 
 using FarIsomorphicInnerArgs =
-    std::tuple<const std::string &, const std::string &, float,
-               const std::string &, const std::string &>;
+    std::tuple<FarReaderClass &, FarReaderClass &, float, std::string_view,
+               std::string_view>;
 
 using FarIsomorphicArgs = WithReturnValue<bool, FarIsomorphicInnerArgs>;
 
 template <class Arc>
-void FarIsomorphic(FarIsomorphicArgs *args) {
-  args->retval = fst::FarIsomorphic<Arc>(
-      std::get<0>(args->args), std::get<1>(args->args), std::get<2>(args->args),
-      std::get<3>(args->args), std::get<4>(args->args));
+void Isomorphic(FarIsomorphicArgs *args) {
+  FarReader<Arc> &reader1 = *std::get<0>(args->args).GetFarReader<Arc>();
+  FarReader<Arc> &reader2 = *std::get<1>(args->args).GetFarReader<Arc>();
+  args->retval = ::fst::Isomorphic<Arc>(
+      reader1, reader2, std::get<2>(args->args), std::get<3>(args->args),
+      std::get<4>(args->args));
 }
 
-bool FarIsomorphic(const std::string &source1, const std::string &source2,
-                   const std::string &arc_type, float delta = kDelta,
-                   const std::string &begin_key = std::string(),
-                   const std::string &end_key = std::string());
+bool Isomorphic(FarReaderClass &reader1, FarReaderClass &reader2,
+                float delta = kDelta, std::string_view begin_key = "",
+                std::string_view end_key = "");
 
 struct FarPrintStringsArgs {
-  const std::vector<std::string> &isources;
+  FarReaderClass &reader;
   const FarEntryType entry_type;
   const TokenType token_type;
   const std::string &begin_key;
@@ -217,40 +239,40 @@ struct FarPrintStringsArgs {
   const bool print_weight;
   const std::string &symbols_source;
   const bool initial_symbols;
-  const int32 generate_sources;
+  const int32_t generate_sources;
   const std::string &source_prefix;
   const std::string &source_suffix;
 };
 
 template <class Arc>
-void FarPrintStrings(FarPrintStringsArgs *args) {
-  fst::FarPrintStrings<Arc>(
-      args->isources, args->entry_type, args->token_type, args->begin_key,
-      args->end_key, args->print_key, args->print_weight, args->symbols_source,
-      args->initial_symbols, args->generate_sources, args->source_prefix,
-      args->source_suffix);
+void PrintStrings(FarPrintStringsArgs *args) {
+  FarReader<Arc> &reader = *args->reader.GetFarReader<Arc>();
+  ::fst::PrintStrings<Arc>(reader, args->entry_type, args->token_type,
+                               args->begin_key, args->end_key, args->print_key,
+                               args->print_weight, args->symbols_source,
+                               args->initial_symbols, args->generate_sources,
+                               args->source_prefix, args->source_suffix);
 }
 
-void FarPrintStrings(const std::vector<std::string> &isources,
-                     const std::string &arc_type, const FarEntryType entry_type,
-                     const TokenType token_type, const std::string &begin_key,
-                     const std::string &end_key, const bool print_key,
-                     const bool print_weight, const std::string &symbols_source,
-                     const bool initial_symbols, const int32 generate_sources,
-                     const std::string &source_prefix,
-                     const std::string &source_suffix);
+void PrintStrings(FarReaderClass &reader, const FarEntryType entry_type,
+                  const TokenType token_type, const std::string &begin_key,
+                  const std::string &end_key, const bool print_key,
+                  const bool print_weight, const std::string &symbols_source,
+                  const bool initial_symbols, const int32_t generate_sources,
+                  const std::string &source_prefix,
+                  const std::string &source_suffix);
 
 }  // namespace script
 }  // namespace fst
 
-#define REGISTER_FST_FAR_OPERATIONS(ArcType)                                 \
-  REGISTER_FST_OPERATION(FarCompileStrings, ArcType, FarCompileStringsArgs); \
-  REGISTER_FST_OPERATION(FarCreate, ArcType, FarCreateArgs);                 \
-  REGISTER_FST_OPERATION(FarEqual, ArcType, FarEqualArgs);                   \
-  REGISTER_FST_OPERATION(FarExtract, ArcType, FarExtractArgs);               \
-  REGISTER_FST_OPERATION(FarInfo, ArcType, FarInfoArgs);                     \
-  REGISTER_FST_OPERATION(FarIsomorphic, ArcType, FarIsomorphicArgs);         \
-  REGISTER_FST_OPERATION(FarPrintStrings, ArcType, FarPrintStringsArgs);     \
-  REGISTER_FST_OPERATION(GetFarInfo, ArcType, GetFarInfoArgs)
+#define REGISTER_FST_FAR_OPERATIONS(ArcType)                              \
+  REGISTER_FST_OPERATION(CompileStrings, ArcType, FarCompileStringsArgs); \
+  REGISTER_FST_OPERATION(Create, ArcType, FarCreateArgs);                 \
+  REGISTER_FST_OPERATION(Equal, ArcType, FarEqualArgs);                   \
+  REGISTER_FST_OPERATION(Extract, ArcType, FarExtractArgs);               \
+  REGISTER_FST_OPERATION(Info, ArcType, FarInfoArgs);                     \
+  REGISTER_FST_OPERATION(Isomorphic, ArcType, FarIsomorphicArgs);         \
+  REGISTER_FST_OPERATION(PrintStrings, ArcType, FarPrintStringsArgs);     \
+  REGISTER_FST_OPERATION(GetInfo, ArcType, FarGetInfoArgs)
 
 #endif  // FST_EXTENSIONS_FAR_FARSCRIPT_H_
index c517dac..772ce2e 100644 (file)
 #ifndef FST_EXTENSIONS_FAR_GETTERS_H_
 #define FST_EXTENSIONS_FAR_GETTERS_H_
 
+#include <string>
+
 #include <fst/flags.h>
 #include <fst/extensions/far/far.h>
 #include <fst/string.h>
+#include <string_view>
 
 namespace fst {
 namespace script {
 
-bool GetFarType(const std::string &str, FarType *far_type);
+bool GetFarType(std::string_view str, FarType *far_type);
 
-bool GetFarEntryType(const std::string &str, FarEntryType *entry_type);
+bool GetFarEntryType(std::string_view str, FarEntryType *entry_type);
 
 void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp);
 
index f0e5055..c8b15b5 100644 (file)
@@ -62,9 +62,9 @@ struct FarInfoData {
 };
 
 template <class Arc>
-void GetFarInfo(const std::vector<std::string> &sources,
-                const std::string &begin_key, const std::string &end_key,
-                const bool list_fsts, FarInfoData *far_info) {
+void GetInfo(const std::vector<std::string> &sources,
+             const std::string &begin_key, const std::string &end_key,
+             const bool list_fsts, FarInfoData *far_info) {
   *far_info = FarInfoData();
   std::unique_ptr<FarReader<Arc>> reader(FarReader<Arc>::Open(sources));
   if (!reader) {
@@ -98,11 +98,10 @@ void GetFarInfo(const std::vector<std::string> &sources,
 }
 
 template <class Arc>
-void FarInfo(const std::vector<std::string> &sources,
-             const std::string &begin_key, const std::string &end_key,
-             const bool list_fsts) {
+void Info(const std::vector<std::string> &sources, const std::string &begin_key,
+          const std::string &end_key, const bool list_fsts) {
   FarInfoData info;
-  GetFarInfo<Arc>(sources, begin_key, end_key, list_fsts, &info);
+  GetInfo<Arc>(sources, begin_key, end_key, list_fsts, &info);
   if (!list_fsts) {
     std::cout << std::left << std::setw(50) << "far type" << info.far_type
               << std::endl;
index a0cc231..67e4a28 100644 (file)
 #ifndef FST_EXTENSIONS_FAR_ISOMORPHIC_H_
 #define FST_EXTENSIONS_FAR_ISOMORPHIC_H_
 
-#include <memory>
-#include <string>
-
 #include <fst/extensions/far/far.h>
+#include <fst/extensions/far/map-reduce.h>
 #include <fst/isomorphic.h>
+#include <string_view>
 
 namespace fst {
 
 template <class Arc>
-bool FarIsomorphic(const std::string &source1, const std::string &source2,
-                   float delta = kDelta,
-                   const std::string &begin_key = std::string(),
-                   const std::string &end_key = std::string()) {
-  std::unique_ptr<FarReader<Arc>> reader1(FarReader<Arc>::Open(source1));
-  if (!reader1) {
-    LOG(ERROR) << "FarIsomorphic: Cannot open FAR file " << source1;
-    return false;
-  }
-  std::unique_ptr<FarReader<Arc>> reader2(FarReader<Arc>::Open(source2));
-  if (!reader2) {
-    LOG(ERROR) << "FarIsomorphic: Cannot open FAR file " << source2;
-    return false;
-  }
-  if (!begin_key.empty()) {
-    bool find_begin1 = reader1->Find(begin_key);
-    bool find_begin2 = reader2->Find(begin_key);
-    if (!find_begin1 || !find_begin2) {
-      bool ret = !find_begin1 && !find_begin2;
-      if (!ret) {
-        VLOG(1) << "FarIsomorphic: Key " << begin_key << " missing from "
-                << (find_begin1 ? "second" : "first") << " archive.";
-      }
-      return ret;
-    }
-  }
-  for (; !reader1->Done() && !reader2->Done();
-       reader1->Next(), reader2->Next()) {
-    const auto &key1 = reader1->GetKey();
-    const auto &key2 = reader2->GetKey();
-    if (!end_key.empty() && end_key < key1 && end_key < key2) return true;
-    if (key1 != key2) {
-      LOG(ERROR) << "FarIsomorphic: Mismatched keys " << key1 << " and "
-                 << key2;
-      return false;
-    }
-    if (!Isomorphic(*(reader1->GetFst()), *(reader2->GetFst()), delta)) {
-      LOG(ERROR) << "FarIsomorphic: FSTs for key " << key1
-                 << " are not isomorphic";
-      return false;
-    }
-  }
-  if (!reader1->Done() || !reader2->Done()) {
-    LOG(ERROR) << "FarIsomorphic: Key "
-               << (reader1->Done() ? reader2->GetKey() : reader1->GetKey())
-               << " missing form " << (reader2->Done() ? "first" : "second")
-               << " archive";
-    return false;
-  }
-  return true;
+bool Isomorphic(FarReader<Arc> &reader1, FarReader<Arc> &reader2,
+                float delta = kDelta, std::string_view begin_key = "",
+                std::string_view end_key = "") {
+  return internal::MapAllReduce(
+      reader1, reader2,
+      [delta](std::string_view key, const Fst<Arc> *fst1,
+              const Fst<Arc> *fst2) {
+        if (!Isomorphic(*fst1, *fst2, delta)) {
+          LOG(ERROR) << "Isomorphic: FSTs for key " << key << "are not equal";
+          return false;
+        }
+        return true;
+      },
+      begin_key, end_key);
 }
 
 }  // namespace fst
diff --git a/src/include/fst/extensions/far/map-reduce.h b/src/include/fst/extensions/far/map-reduce.h
new file mode 100644 (file)
index 0000000..f903aa3
--- /dev/null
@@ -0,0 +1,110 @@
+// Copyright 2005-2020 Google LLC
+//
+// 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.
+//
+// See www.openfst.org for extensive documentation on this weighted
+// finite-state transducer library.
+//
+// Map helper for FAR processing.
+
+#ifndef FST_EXTENSIONS_FAR_MAP_REDUCE_H_
+#define FST_EXTENSIONS_FAR_MAP_REDUCE_H_
+
+#include <fst/extensions/far/far.h>
+#include <fst/arc.h>
+#include <fst/fst.h>
+#include <string_view>
+
+namespace fst {
+namespace internal {
+
+// This function applies a functor to each FST in a FAR reader, writing the
+// resulting FST to a FAR writer. The functor must support the following
+// interface:
+//
+// std::unique_ptr<Fst<Arc>> operator()(std::string_view key,
+//                                      const Fst<Arc> *fst);
+//
+// The functor signals an error by returning a null pointer.
+//
+// One can imagine more expressive variants of this: e.g., one which also
+// transforms the key, but this can be added as needed.
+//
+// The caller is responsible for rewinding the reader afterwards, if desired,
+// and for checking the error bit of the reader and writer.
+template <class Arc, class Functor>
+void Map(FarReader<Arc> &reader, FarWriter<Arc> &writer, Functor functor) {
+  for (; !reader.Done(); reader.Next()) {
+    const auto &key = reader.GetKey();
+    const auto fst = functor(key, reader.GetFst());
+    if (!fst) return;
+    writer.Add(key, *fst);
+  }
+}
+
+// This function applies a boolean functor to pairs of FSTs passed via FAR
+// readers, returning false if any of the keys do not match or if any of the
+// functor calls are false. The functor must support the following interface:
+//
+// bool operator()(std::string_view key, const Fst<Arc> *fst1,
+//                 const Fst<Arc> *fst2);
+//
+// One can imagine more expressive variants of this, but these can be added as
+// needed.
+//
+// The caller is responsible for rewinding the readers afterwards, if desired,
+// and for checking the error bits of the readers.
+template <class Arc, class Functor>
+bool MapAllReduce(FarReader<Arc> &reader1, FarReader<Arc> &reader2,
+                  Functor functor, std::string_view begin_key = "",
+                  std::string_view end_key = "") {
+  if (!begin_key.empty()) {
+    const bool find_begin1 = reader1.Find(begin_key);
+    const bool find_begin2 = reader2.Find(begin_key);
+    if (!find_begin1 || !find_begin2) {
+      const bool ret = !find_begin1 && !find_begin2;
+      if (!ret) {
+        LOG(ERROR) << "MapAllReduce: Key " << begin_key << " missing from "
+                   << (find_begin1 ? "second" : "first") << " FAR";
+      }
+      return ret;
+    }
+  }
+  for (; !reader1.Done() && !reader2.Done(); reader1.Next(), reader2.Next()) {
+    const auto &key1 = reader1.GetKey();
+    const auto &key2 = reader2.GetKey();
+    if (!end_key.empty() && end_key < key1 && end_key < key2) {
+      return true;
+    }
+    if (key1 != key2) {
+      LOG(ERROR) << "MapAllReduce: Mismatched keys " << key1 << " and " << key2;
+      return false;
+    }
+    if (!functor(key1, reader1.GetFst(), reader2.GetFst())) return false;
+  }
+  if (reader1.Done() && !reader2.Done()) {
+    LOG(ERROR) << "MapAllReduce: Key " << reader2.GetKey()
+               << " missing from first FAR";
+    return false;
+  } else if (reader2.Done() && !reader1.Done()) {
+    LOG(ERROR) << "MapAllReduce: Key " << reader1.GetKey()
+               << " missing from second FAR";
+    return false;
+  }
+  return true;
+}
+
+}  // namespace internal
+}  // namespace fst
+
+#endif  // FST_EXTENSIONS_FAR_MAP_REDUCE_H_
index a5797a8..f4e0b2c 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_EXTENSIONS_FAR_PRINT_STRINGS_H_
 #define FST_EXTENSIONS_FAR_PRINT_STRINGS_H_
 
+#include <cstdint>
 #include <iomanip>
 #include <string>
 #include <vector>
@@ -35,31 +36,28 @@ DECLARE_string(far_field_separator);
 namespace fst {
 
 template <class Arc>
-void FarPrintStrings(const std::vector<std::string> &isources,
-                     FarEntryType entry_type, TokenType token_type,
-                     const std::string &begin_key, const std::string &end_key,
-                     bool print_key, bool print_weight,
-                     const std::string &symbols_source, bool initial_symbols,
-                     int32 generate_sources, const std::string &source_prefix,
-                     const std::string &source_suffix) {
+void PrintStrings(FarReader<Arc> &reader, FarEntryType entry_type,
+                  TokenType token_type, const std::string &begin_key,
+                  const std::string &end_key, bool print_key, bool print_weight,
+                  const std::string &symbols_source, bool initial_symbols,
+                  int32_t generate_sources, const std::string &source_prefix,
+                  const std::string &source_suffix) {
   std::unique_ptr<const SymbolTable> syms;
   if (!symbols_source.empty()) {
     // TODO(kbg): Allow negative flag?
     const SymbolTableTextOptions opts(true);
     syms.reset(SymbolTable::ReadText(symbols_source, opts));
     if (!syms) {
-      LOG(ERROR) << "FarPrintStrings: Error reading symbol table "
+      LOG(ERROR) << "PrintStrings: Error reading symbol table "
                  << symbols_source;
       return;
     }
   }
-  std::unique_ptr<FarReader<Arc>> far_reader(FarReader<Arc>::Open(isources));
-  if (!far_reader) return;
-  if (!begin_key.empty()) far_reader->Find(begin_key);
+  if (!begin_key.empty()) reader.Find(begin_key);
   std::string okey;
   int nrep = 0;
-  for (int i = 1; !far_reader->Done(); far_reader->Next(), ++i) {
-    const auto &key = far_reader->GetKey();
+  for (int i = 1; !reader.Done(); reader.Next(), ++i) {
+    const auto &key = reader.GetKey();
     if (!end_key.empty() && end_key < key) break;
     if (okey == key) {
       ++nrep;
@@ -67,7 +65,7 @@ void FarPrintStrings(const std::vector<std::string> &isources,
       nrep = 0;
     }
     okey = key;
-    const auto *fst = far_reader->GetFst();
+    const auto *fst = reader.GetFst();
     if (i == 1 && initial_symbols && !syms && fst->InputSymbols()) {
       syms.reset(fst->InputSymbols()->Copy());
     }
@@ -99,7 +97,7 @@ void FarPrintStrings(const std::vector<std::string> &isources,
       source = source_prefix + sstrm.str() + source_suffix;
       std::ofstream ostrm(source);
       if (!ostrm) {
-        LOG(ERROR) << "FarPrintStrings: Can't open file: " << source;
+        LOG(ERROR) << "PrintStrings: Can't open file: " << source;
         return;
       }
       ostrm << str;
index 82b1c08..218bd0d 100644 (file)
@@ -24,6 +24,7 @@
 #define FST_EXTENSIONS_FAR_STLIST_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <functional>
 #include <iostream>
 #include <memory>
@@ -38,8 +39,8 @@
 
 namespace fst {
 
-static constexpr int32 kSTListMagicNumber = 5656924;
-static constexpr int32 kSTListFileVersion = 1;
+inline constexpr int32_t kSTListMagicNumber = 5656924;
+inline constexpr int32_t kSTListFileVersion = 1;
 
 // String-type list writing class for object of type T using a functor Writer.
 // The Writer functor must provide at least the following interface:
@@ -69,7 +70,7 @@ class STListWriter {
     return new STListWriter<T, Writer>(source);
   }
 
-  void Add(const std::string &key, const T &t) {
+  void Add(std::string_view key, const T &t) {
     if (key.empty()) {
       FSTERROR() << "STListWriter::Add: Key empty: " << key;
       error_ = true;
@@ -78,7 +79,8 @@ class STListWriter {
       error_ = true;
     }
     if (error_) return;
-    last_key_ = key;
+    // TODO(jrosenstock,glebm): Use assign(key) when C++17 is required
+    last_key_.assign(key.data(), key.size());
     WriteType(*stream_, key);
     entry_writer_(*stream_, t);
   }
@@ -135,9 +137,9 @@ class STListReader {
           return;
         }
       }
-      int32 magic_number = 0;
+      int32_t magic_number = 0;
       ReadType(*streams_[i], &magic_number);
-      int32 file_version = 0;
+      int32_t file_version = 0;
       ReadType(*streams_[i], &file_version);
       if (magic_number != kSTListMagicNumber) {
         FSTERROR() << "STListReader::STListReader: Wrong file type: "
@@ -261,9 +263,9 @@ bool ReadSTListHeader(const std::string &source, Header *header) {
     LOG(ERROR) << "ReadSTListHeader: Could not open file: " << source;
     return false;
   }
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
-  int32 file_version = 0;
+  int32_t file_version = 0;
   ReadType(strm, &file_version);
   if (magic_number != kSTListMagicNumber) {
     LOG(ERROR) << "ReadSTListHeader: Wrong file type: " << source;
index cf8af20..ff7bdff 100644 (file)
 #define FST_EXTENSIONS_FAR_STTABLE_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <istream>
 #include <memory>
+#include <string>
 
 #include <fstream>
 #include <fst/util.h>
@@ -34,8 +36,8 @@
 
 namespace fst {
 
-static constexpr int32 kSTTableMagicNumber = 2125656924;
-static constexpr int32 kSTTableFileVersion = 1;
+inline constexpr int32_t kSTTableMagicNumber = 2125656924;
+inline constexpr int32_t kSTTableFileVersion = 1;
 
 // String-type table writing class for an object of type T using a functor
 // Writer. The Writer functor must provide at least the following interface:
@@ -66,7 +68,7 @@ class STTableWriter {
     return new STTableWriter<T, Writer>(source);
   }
 
-  void Add(const std::string &key, const T &t) {
+  void Add(std::string_view key, const T &t) {
     if (key.empty()) {
       FSTERROR() << "STTableWriter::Add: Key empty: " << key;
       error_ = true;
@@ -75,7 +77,7 @@ class STTableWriter {
       error_ = true;
     }
     if (error_) return;
-    last_key_ = key;
+    last_key_.assign(key.data(), key.size());
     positions_.push_back(stream_.tellp());
     WriteType(stream_, key);
     entry_writer_(stream_, t);
@@ -85,13 +87,13 @@ class STTableWriter {
 
   ~STTableWriter() {
     WriteType(stream_, positions_);
-    WriteType(stream_, static_cast<int64>(positions_.size()));
+    WriteType(stream_, static_cast<int64_t>(positions_.size()));
   }
 
  private:
   Writer entry_writer_;
   std::ofstream stream_;
-  std::vector<int64> positions_;  // Position in file of each key-entry pair.
+  std::vector<int64_t> positions_;  // Position in file of each key-entry pair.
   std::string last_key_;          // Last key.
   bool error_;
 
@@ -124,9 +126,9 @@ class STTableReader {
         error_ = true;
         return;
       }
-      int32 magic_number = 0;
+      int32_t magic_number = 0;
       ReadType(*streams_[i], &magic_number);
-      int32 file_version = 0;
+      int32_t file_version = 0;
       ReadType(*streams_[i], &file_version);
       if (magic_number != kSTTableMagicNumber) {
         FSTERROR() << "STTableReader::STTableReader: Wrong file type: "
@@ -140,12 +142,14 @@ class STTableReader {
         error_ = true;
         return;
       }
-      int64 num_entries;
-      streams_[i]->seekg(-static_cast<int>(sizeof(int64)), std::ios_base::end);
+      int64_t num_entries;
+      streams_[i]->seekg(-static_cast<int>(sizeof(int64_t)),
+                         std::ios_base::end);
       ReadType(*streams_[i], &num_entries);
       if (num_entries > 0) {
-        streams_[i]->seekg(-static_cast<int>(sizeof(int64)) * (num_entries + 1),
-                           std::ios_base::end);
+        streams_[i]->seekg(
+            -static_cast<int>(sizeof(int64_t)) * (num_entries + 1),
+            std::ios_base::end);
         positions_[i].resize(num_entries);
         for (size_t j = 0; (j < num_entries) && (!streams_[i]->fail()); ++j) {
           ReadType(*streams_[i], &(positions_[i][j]));
@@ -183,8 +187,11 @@ class STTableReader {
 
   void Reset() {
     if (error_) return;
-    for (size_t i = 0; i < streams_.size(); ++i)
-      streams_[i]->seekg(positions_[i].front());
+    for (size_t i = 0; i < streams_.size(); ++i) {
+      if (!positions_[i].empty()) {
+        streams_[i]->seekg(positions_[i].front());
+      }
+    }
     MakeHeap();
   }
 
@@ -303,10 +310,11 @@ class STTableReader {
   Reader entry_reader_;
   std::vector<std::istream *> streams_;        // Input streams.
   std::vector<std::string> sources_;           // Corresponding file names.
-  std::vector<std::vector<int64>> positions_;  // Index of positions.
+  std::vector<std::vector<int64_t>> positions_;  // Index of positions.
   std::vector<std::string> keys_;  // Lowest unread key for each stream.
-  std::vector<int64> heap_;  // Heap containing ID of streams with unread keys.
-  int64 current_;            // ID of current stream to be read.
+  std::vector<int64_t>
+      heap_;         // Heap containing ID of streams with unread keys.
+  int64_t current_;  // ID of current stream to be read.
   std::unique_ptr<Compare> compare_;  // Functor comparing stream IDs.
   mutable std::unique_ptr<T> entry_;  // The currently read entry.
   bool error_;
@@ -329,9 +337,9 @@ bool ReadSTTableHeader(const std::string &source, Header *header) {
     LOG(ERROR) << "ReadSTTableHeader: Could not open file: " << source;
     return false;
   }
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
-  int32 file_version = 0;
+  int32_t file_version = 0;
   ReadType(strm, &file_version);
   if (magic_number != kSTTableMagicNumber) {
     LOG(ERROR) << "ReadSTTableHeader: Wrong file type: " << source;
@@ -341,15 +349,15 @@ bool ReadSTTableHeader(const std::string &source, Header *header) {
     LOG(ERROR) << "ReadSTTableHeader: Wrong file version: " << source;
     return false;
   }
-  int64 i = -1;
-  strm.seekg(-static_cast<int>(sizeof(int64)), std::ios_base::end);
+  int64_t i = -1;
+  strm.seekg(-static_cast<int>(sizeof(int64_t)), std::ios_base::end);
   ReadType(strm, &i);  // Reads number of entries
   if (strm.fail()) {
     LOG(ERROR) << "ReadSTTableHeader: Error reading file: " << source;
     return false;
   }
   if (i == 0) return true;  // No entry header to read.
-  strm.seekg(-2 * static_cast<int>(sizeof(int64)), std::ios_base::end);
+  strm.seekg(-2 * static_cast<int>(sizeof(int64_t)), std::ios_base::end);
   ReadType(strm, &i);  // Reads position for last entry in file.
   strm.seekg(i);
   std::string key;
index dda75c6..07cb38b 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef FST_EXTENSIONS_LINEAR_LINEAR_FST_DATA_BUILDER_H_
 #define FST_EXTENSIONS_LINEAR_LINEAR_FST_DATA_BUILDER_H_
 
+#include <cstdint>
 #include <map>
 #include <queue>
 #include <set>
@@ -27,7 +28,6 @@
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/linear/linear-fst-data.h>
 #include <fst/fst.h>
@@ -41,7 +41,7 @@ template <class A>
 class FeatureGroupBuilder;
 
 // For logging purposes
-inline std::string TranslateLabel(int64 label, const SymbolTable *syms);
+inline std::string TranslateLabel(int64_t label, const SymbolTable *syms);
 template <class Iterator>
 std::string JoinLabels(Iterator begin, Iterator end, const SymbolTable *syms);
 template <class Label>
@@ -1013,7 +1013,7 @@ std::string FeatureGroupBuilder<A>::TriePath(int node,
   return strm.str();
 }
 
-inline std::string TranslateLabel(int64 label, const SymbolTable *syms) {
+inline std::string TranslateLabel(int64_t label, const SymbolTable *syms) {
   std::string ret;
   if (syms != nullptr) ret += syms->Find(label);
   if (ret.empty()) {
index 4fc6411..5bfa337 100644 (file)
@@ -56,8 +56,8 @@ class LinearFstData {
 
   // Sentence boundary labels. Both of them are negative labels other
   // than `kNoLabel`.
-  static const Label kStartOfSentence;
-  static const Label kEndOfSentence;
+  static constexpr Label kStartOfSentence = -3;
+  static constexpr Label kEndOfSentence = -2;
 
   // Constructs empty data; for non-trivial ways of construction see
   // `Read()` and `LinearFstDataBuilder`.
@@ -152,11 +152,6 @@ class LinearFstData {
 };
 
 template <class A>
-const typename A::Label LinearFstData<A>::kStartOfSentence = -3;
-template <class A>
-const typename A::Label LinearFstData<A>::kEndOfSentence = -2;
-
-template <class A>
 template <class Iterator>
 void LinearFstData<A>::TakeTransition(Iterator buffer_end,
                                       Iterator trie_state_begin,
index 28f35fe..3f378fa 100644 (file)
 #define FST_EXTENSIONS_LINEAR_LINEAR_FST_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <iostream>
 #include <memory>
+#include <string>
 #include <vector>
 
 #include <fst/compat.h>
@@ -168,8 +170,8 @@ class LinearTaggerFstImpl : public CacheImpl<A> {
   }
 
  private:
-  static const int kMinFileVersion;
-  static const int kFileVersion;
+  static constexpr int kMinFileVersion = 1;
+  static constexpr int kFileVersion = 1;
 
   // A collection of functions to access parts of the state tuple. A
   // state tuple is a vector of `Label`s with two parts:
@@ -294,12 +296,6 @@ class LinearTaggerFstImpl : public CacheImpl<A> {
 };
 
 template <class A>
-const int LinearTaggerFstImpl<A>::kMinFileVersion = 1;
-
-template <class A>
-const int LinearTaggerFstImpl<A>::kFileVersion = 1;
-
-template <class A>
 inline typename A::Label LinearTaggerFstImpl<A>::ShiftBuffer(
     const std::vector<Label> &state, Label ilabel,
     std::vector<Label> *next_stub_) {
@@ -710,8 +706,8 @@ class LinearClassifierFstImpl : public CacheImpl<A> {
   }
 
  private:
-  static const int kMinFileVersion;
-  static const int kFileVersion;
+  static constexpr int kMinFileVersion = 0;
+  static constexpr int kFileVersion = 0;
 
   // A collection of functions to access parts of the state tuple. A
   // state tuple is a vector of `Label`s with two parts:
@@ -813,12 +809,6 @@ class LinearClassifierFstImpl : public CacheImpl<A> {
 };
 
 template <class A>
-const int LinearClassifierFstImpl<A>::kMinFileVersion = 0;
-
-template <class A>
-const int LinearClassifierFstImpl<A>::kFileVersion = 0;
-
-template <class A>
 void LinearClassifierFstImpl<A>::Expand(StateId s) {
   VLOG(3) << "Expand " << s;
   state_stub_.clear();
@@ -1162,12 +1152,12 @@ class LinearFstMatcherTpl : public MatcherBase<typename F::Arc> {
 
   const FST &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 props) const override {
+  uint64_t Properties(uint64_t props) const override {
     if (error_) props |= kError;
     return props;
   }
 
-  uint32 Flags() const override { return kRequireMatch; }
+  uint32_t Flags() const override { return kRequireMatch; }
 
  private:
   std::unique_ptr<const FST> owned_fst_;
index cf6db2d..4ddef73 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace fst {
 
-const int kNoTrieNodeId = -1;
+inline constexpr int kNoTrieNodeId = -1;
 
 // Forward declarations of all available trie topologies.
 template <class L, class H>
index 1f08448..f7477e0 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_EXTENSIONS_MPDT_COMPOSE_H_
 #define FST_EXTENSIONS_MPDT_COMPOSE_H_
 
+#include <cstdint>
 #include <list>
 
 #include <fst/extensions/mpdt/mpdt.h>
@@ -138,7 +139,7 @@ class MPdtParenFilter {
 
   Matcher2 *GetMatcher2() { return filter_.GetMatcher2(); }
 
-  uint64 Properties(uint64 iprops) const {
+  uint64_t Properties(uint64_t iprops) const {
     const auto oprops = filter_.Properties(iprops);
     return oprops & kILabelInvariantProperties & kOLabelInvariantProperties;
   }
index 05d9855..2c28dcc 100644 (file)
@@ -20,9 +20,9 @@
 #ifndef FST_EXTENSIONS_MPDT_EXPAND_H_
 #define FST_EXTENSIONS_MPDT_EXPAND_H_
 
+#include <cstdint>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/extensions/mpdt/mpdt.h>
 #include <fst/extensions/pdt/paren.h>
 #include <fst/cache.h>
@@ -48,7 +48,7 @@ struct MPdtExpandFstOptions : public CacheOptions {
 };
 
 // Properties for an expanded PDT.
-inline uint64 MPdtExpandProperties(uint64 inprops) {
+inline uint64_t MPdtExpandProperties(uint64_t inprops) {
   return inprops & (kAcceptor | kAcyclic | kInitialAcyclic | kUnweighted);
 }
 
index a271843..34efc90 100644 (file)
 #ifndef FST_EXTENSIONS_MPDT_INFO_H_
 #define FST_EXTENSIONS_MPDT_INFO_H_
 
+#include <cstdint>
+#include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/extensions/mpdt/mpdt.h>
 #include <fst/fst.h>
 #include <unordered_map>
@@ -46,28 +47,28 @@ class MPdtInfo {
 
   const std::string &ArcType() const { return Arc::Type(); }
 
-  int64 NumStates() const { return nstates_; }
+  int64_t NumStates() const { return nstates_; }
 
-  int64 NumArcs() const { return narcs_; }
+  int64_t NumArcs() const { return narcs_; }
 
-  int64 NumLevels() const { return nlevels; }
+  int64_t NumLevels() const { return nlevels; }
 
-  int64 NumOpenParens(Label level) const { return nopen_parens_[level]; }
+  int64_t NumOpenParens(Label level) const { return nopen_parens_[level]; }
 
-  int64 NumCloseParens(Label level) const { return nclose_parens_[level]; }
+  int64_t NumCloseParens(Label level) const { return nclose_parens_[level]; }
 
-  int64 NumUniqueOpenParens(Label level) const {
+  int64_t NumUniqueOpenParens(Label level) const {
     return nuniq_open_parens_[level];
   }
 
-  int64 NumUniqueCloseParens(Label level) const {
+  int64_t NumUniqueCloseParens(Label level) const {
     return nuniq_close_parens_[level];
   }
-  int64 NumOpenParenStates(Label level) const {
+  int64_t NumOpenParenStates(Label level) const {
     return nopen_paren_states_[level];
   }
 
-  int64 NumCloseParenStates(Label level) const {
+  int64_t NumCloseParenStates(Label level) const {
     return nclose_paren_states_[level];
   }
 
@@ -75,14 +76,14 @@ class MPdtInfo {
 
  private:
   std::string fst_type_;
-  int64 nstates_;
-  int64 narcs_;
-  int64 nopen_parens_[nlevels];
-  int64 nclose_parens_[nlevels];
-  int64 nuniq_open_parens_[nlevels];
-  int64 nuniq_close_parens_[nlevels];
-  int64 nopen_paren_states_[nlevels];
-  int64 nclose_paren_states_[nlevels];
+  int64_t nstates_;
+  int64_t narcs_;
+  int64_t nopen_parens_[nlevels];
+  int64_t nclose_parens_[nlevels];
+  int64_t nuniq_open_parens_[nlevels];
+  int64_t nuniq_close_parens_[nlevels];
+  int64_t nopen_paren_states_[nlevels];
+  int64_t nclose_paren_states_[nlevels];
   bool error_;
 };
 
@@ -175,22 +176,22 @@ void MPdtInfo<Arc, nlevels>::Print() {
   std::cout.width(50);
   for (typename Arc::Label i = 0; i < nlevels; ++i) {
     int level = i + 1;
-    std::cout << "# of open parentheses at levelel " << level << "\t"
+    std::cout << "# of open parentheses at level " << level << "\t"
               << NumOpenParens(i) << std::endl;
     std::cout.width(50);
-    std::cout << "# of close parentheses at levelel " << level << "\t"
+    std::cout << "# of close parentheses at level " << level << "\t"
               << NumCloseParens(i) << std::endl;
     std::cout.width(50);
-    std::cout << "# of unique open parentheses at levelel " << level << "\t"
+    std::cout << "# of unique open parentheses at level " << level << "\t"
               << NumUniqueOpenParens(i) << std::endl;
     std::cout.width(50);
-    std::cout << "# of unique close parentheses at levelel " << level << "\t"
+    std::cout << "# of unique close parentheses at level " << level << "\t"
               << NumUniqueCloseParens(i) << std::endl;
     std::cout.width(50);
-    std::cout << "# of open parenthesis dest. states at levelel " << level
-              << "\t" << NumOpenParenStates(i) << std::endl;
+    std::cout << "# of open parenthesis dest. states at level " << level << "\t"
+              << NumOpenParenStates(i) << std::endl;
     std::cout.width(50);
-    std::cout << "# of close parenthesis source states at levelel " << level
+    std::cout << "# of close parenthesis source states at level " << level
               << "\t" << NumCloseParenStates(i) << std::endl;
     std::cout.width(50);
   }
index a171c27..89933d7 100644 (file)
 
 #include <algorithm>
 #include <array>
+#include <cstdint>
 #include <functional>
 #include <map>
-#include <memory>
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/extensions/pdt/pdt.h>
 #include <unordered_map>
+#include <optional>
 
 namespace fst {
 
-enum class MPdtType : uint8 {
+enum class MPdtType : uint8_t {
   READ_RESTRICT,   // Can only read from first empty stack
   WRITE_RESTRICT,  // Can only write to first empty stack
   NO_RESTRICT,     // No read-write restrictions
@@ -42,44 +42,8 @@ enum class MPdtType : uint8 {
 
 namespace internal {
 
-// PLEASE READ THIS CAREFULLY:
-//
-// When USEVECTOR is set, the stack configurations --- the statewise
-// representation of the StackId's for each substack --- is stored in a vector.
-// I would like to do this using an array for efficiency reasons, thus the
-// definition of StackConfig below. However, while this *works* in that tests
-// pass, etc. It causes a memory leak in the compose and expand tests, evidently
-// in the map[] that is being used to store the mapping between these
-// StackConfigs and the external StackId that the caller sees. There are no
-// memory leaks when I use a vector, only with this StackId. Why there should be
-// memory leaks given that I am not mallocing anything is a mystery. In case you
-// were wondering, clearing the map at the end does not help.
-
 template <typename StackId, typename Level, Level nlevels>
-class StackConfig {
- public:
-  StackConfig() : array_() {}
-
-  StackConfig(const StackConfig &config) { array_ = config.array_; }
-
-  StackId &operator[](const int index) { return array_[index]; }
-
-  const StackId &operator[](const int index) const { return array_[index]; }
-
-  StackConfig &operator=(const StackConfig &config) {
-    if (this == &config) return *this;
-    array_ = config.array_;
-    return *this;
-  }
-
-  friend bool operator<(const StackConfig &config1,
-                        const StackConfig &config2) {
-    return config1.array_ < config2.array_;
-  }
-
- private:
-  std::array<StackId, nlevels> array_;
-};
+using StackConfig = std::array<StackId, nlevels>;
 
 // Forward declaration so `KeyPair` can declare `KeyPairHasher` its friend.
 template <typename Level>
@@ -133,12 +97,8 @@ class MPdtStack {
         paren_id_map_(other.paren_id_map_),
         config_to_stack_id_map_(other.config_to_stack_id_map_),
         stack_id_to_config_map_(other.stack_id_to_config_map_),
-        next_stack_id_(other.next_stack_id_) {
-    std::transform(other.stacks_.begin(), other.stacks_.end(), stacks_.begin(),
-                   [](const std::unique_ptr<PdtStack<StackId, Label>> &ptr) {
-                     return std::make_unique<PdtStack<StackId, Label>>(*ptr);
-                   });
-  }
+        next_stack_id_(other.next_stack_id_),
+        stacks_(other.stacks_) {}
 
   MPdtStack &operator=(const MPdtStack &other) {
     *this = MPdtStack(other);
@@ -178,19 +138,6 @@ class MPdtStack {
     return it != paren_map_.end() ? it->second : -1;
   }
 
-  // TODO(rws): For debugging purposes only: remove later.
-  std::string PrintConfig(const Config &config) const {
-    std::string result = "[";
-    for (Level i = 0; i < nlevels; ++i) {
-      char s[128];
-      snprintf(s, sizeof(s), "%d", config[i]);
-      result += std::string(s);
-      if (i < nlevels - 1) result += ", ";
-    }
-    result += "]";
-    return result;
-  }
-
   bool Error() { return error_; }
 
   // Each component stack has an internal stack ID for a given configuration and
@@ -247,7 +194,7 @@ class MPdtStack {
   std::unordered_map<StackId, Config> stack_id_to_config_map_;
   StackId next_stack_id_;
   // Array of stacks.
-  std::array<std::unique_ptr<PdtStack<StackId, Label>>, nlevels> stacks_;
+  std::array<std::optional<PdtStack<StackId, Label>>, nlevels> stacks_;
 };
 
 template <typename StackId, typename Level, Level nlevels, MPdtType restrict>
@@ -296,8 +243,7 @@ MPdtStack<StackId, Level, nlevels, restrict>::MPdtStack(
   Config neg_one;
   Config zero;
   for (Level level = 0; level < nlevels; ++level) {
-    stacks_[level] =
-        std::make_unique<PdtStack<StackId, Label>>(vectors[level]);
+    stacks_[level].emplace(vectors[level]);
     neg_one[level] = -1;
     zero[level] = 0;
   }
index efce9e2..e48dc33 100644 (file)
 #define FST_EXTENSIONS_MPDT_MPDTSCRIPT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/mpdt/compose.h>
 #include <fst/extensions/mpdt/expand.h>
@@ -45,12 +45,12 @@ namespace script {
 
 using MPdtComposeArgs =
     std::tuple<const FstClass &, const FstClass &,
-               const std::vector<std::pair<int64, int64>> &,
-               const std::vector<int64> &, MutableFstClass *,
+               const std::vector<std::pair<int64_t, int64_t>> &,
+               const std::vector<int64_t> &, MutableFstClass *,
                const MPdtComposeOptions &, bool>;
 
 template <class Arc>
-void MPdtCompose(MPdtComposeArgs *args) {
+void Compose(MPdtComposeArgs *args) {
   const Fst<Arc> &ifst1 = *(std::get<0>(*args).GetFst<Arc>());
   const Fst<Arc> &ifst2 = *(std::get<1>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<4>(*args)->GetMutableFst<Arc>();
@@ -71,18 +71,17 @@ void MPdtCompose(MPdtComposeArgs *args) {
   }
 }
 
-void MPdtCompose(const FstClass &ifst1, const FstClass &ifst2,
-                 const std::vector<std::pair<int64, int64>> &parens,
-                 const std::vector<int64> &assignments, MutableFstClass *ofst,
-                 const MPdtComposeOptions &copts, bool left_pdt);
+void Compose(const FstClass &ifst1, const FstClass &ifst2,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             const std::vector<int64_t> &assignments, MutableFstClass *ofst,
+             const MPdtComposeOptions &copts, bool left_pdt);
 
-using MPdtExpandArgs =
-    std::tuple<const FstClass &, const std::vector<std::pair<int64, int64>> &,
-               const std::vector<int64> &, MutableFstClass *,
-               const MPdtExpandOptions &>;
+using MPdtExpandArgs = std::tuple<
+    const FstClass &, const std::vector<std::pair<int64_t, int64_t>> &,
+    const std::vector<int64_t> &, MutableFstClass *, const MPdtExpandOptions &>;
 
 template <class Arc>
-void MPdtExpand(MPdtExpandArgs *args) {
+void Expand(MPdtExpandArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<3>(*args)->GetMutableFst<Arc>();
   // In case Arc::Label is not the same as FstClass::Label, we make copies.
@@ -101,17 +100,18 @@ void MPdtExpand(MPdtExpandArgs *args) {
                            std::get<4>(*args).keep_parentheses));
 }
 
-void MPdtExpand(const FstClass &ifst,
-                const std::vector<std::pair<int64, int64>> &parens,
-                const std::vector<int64> &assignments, MutableFstClass *ofst,
-                const MPdtExpandOptions &opts);
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            const std::vector<int64_t> &assignments, MutableFstClass *ofst,
+            const MPdtExpandOptions &opts);
 
 using MPdtReverseArgs =
-    std::tuple<const FstClass &, const std::vector<std::pair<int64, int64>> &,
-               std::vector<int64> *, MutableFstClass *>;
+    std::tuple<const FstClass &,
+               const std::vector<std::pair<int64_t, int64_t>> &,
+               std::vector<int64_t> *, MutableFstClass *>;
 
 template <class Arc>
-void MPdtReverse(MPdtReverseArgs *args) {
+void Reverse(MPdtReverseArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<3>(*args)->GetMutableFst<Arc>();
   // In case Arc::Label is not the same as FstClass::Label, we make copies.
@@ -131,16 +131,17 @@ void MPdtReverse(MPdtReverseArgs *args) {
             std::get<2>(*args)->begin());
 }
 
-void MPdtReverse(const FstClass &ifst,
-                 const std::vector<std::pair<int64, int64>> &parens,
-                 std::vector<int64> *assignments, MutableFstClass *ofst);
+void Reverse(const FstClass &ifst,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             std::vector<int64_t> *assignments, MutableFstClass *ofst);
 
-using PrintMPdtInfoArgs =
-    std::tuple<const FstClass &, const std::vector<std::pair<int64, int64>> &,
-               const std::vector<int64> &>;
+using MPdtInfoArgs =
+    std::tuple<const FstClass &,
+               const std::vector<std::pair<int64_t, int64_t>> &,
+               const std::vector<int64_t> &>;
 
 template <class Arc>
-void PrintMPdtInfo(PrintMPdtInfoArgs *args) {
+void Info(MPdtInfoArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   // In case Arc::Label is not the same as FstClass::Label, we make copies.
   // Truncation may occur if FstClass::Label has more precision than
@@ -157,9 +158,9 @@ void PrintMPdtInfo(PrintMPdtInfoArgs *args) {
   mpdtinfo.Print();
 }
 
-void PrintMPdtInfo(const FstClass &ifst,
-                   const std::vector<std::pair<int64, int64>> &parens,
-                   const std::vector<int64> &assignments);
+void Info(const FstClass &ifst,
+          const std::vector<std::pair<int64_t, int64_t>> &parens,
+          const std::vector<int64_t> &assignments);
 
 }  // namespace script
 }  // namespace fst
index e30d421..92ea4db 100644 (file)
@@ -48,7 +48,8 @@ bool ReadLabelTriples(const std::string &source,
   pairs->clear();
   while (fstrm.getline(line, kLineLen)) {
     ++nline;
-    std::vector<std::string_view> col = SplitString(line, "\n\t ", true);
+    std::vector<std::string_view> col =
+        StrSplit(line, ByAnyChar("\n\t "), SkipEmpty());
     // Empty line or comment?
     if (col.empty() || col[0].empty() || col[0][0] == '#') continue;
     if (col.size() != 3) {
index c314e71..26e8498 100644 (file)
 #ifndef FST_EXTENSIONS_NGRAM_BITMAP_INDEX_H_
 #define FST_EXTENSIONS_NGRAM_BITMAP_INDEX_H_
 
+#include <cstdint>
 #include <utility>
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 // This class is a bitstring storage class with an index that allows
 // beginning of the block.
 //
 // The bitstring itself is stored as uint64s:
-// uint64 *bits_;
+// uint64_t *bits_;
 //
 // The rank index looks like
 // struct RankIndexEntry {
-//   uint32 absolute_ones_count();
-//   uint32 relative_ones_count_1();
+//   uint32_t absolute_ones_count();
+//   uint32_t relative_ones_count_1();
 //   ...
-//   uint32 relative_ones_count_7();
+//   uint32_t relative_ones_count_7();
 // };
 // vector<RankIndexEntry> rank_index_;
 //
 // to reduce these operations to O(log(1/density)) as explained above.
 //
 // The select indexes are stored as
-// vector<uint32> select_0_index_;
+// vector<uint32_t> select_0_index_;
 // where
 // select_0_index_[i] == Select0(512 * i).
 // Similarly for select_1_index_.
 //
-// To save space, the absolute counts are stored as uint32. Therefore,
+// To save space, the absolute counts are stored as uint32_t. Therefore,
 // only bitstrings with < 2**32 ones are supported.
 //
 // For each 64 bytes of input (8 8-byte words) there are 12 bytes of index
@@ -99,7 +99,7 @@ class BitmapIndex {
   BitmapIndex& operator=(BitmapIndex&&) = default;
 
   // Convenience constructor to avoid a separate BuildIndex call.
-  BitmapIndex(const uint64* bits, std::size_t num_bits,
+  BitmapIndex(const uint64_t* bits, std::size_t num_bits,
               bool enable_select_0_index = false,
               bool enable_select_1_index = false) {
     BuildIndex(bits, num_bits, enable_select_0_index, enable_select_1_index);
@@ -107,16 +107,16 @@ class BitmapIndex {
 
   bool Get(size_t index) const { return Get(bits_, index); }
 
-  static bool Get(const uint64* bits, size_t index) {
+  static bool Get(const uint64_t* bits, size_t index) {
     return (bits[index >> kStorageLogBitSize] &
             (kOne << (index & kStorageBlockMask))) != 0;
   }
 
-  static void Set(uint64* bits, size_t index) {
+  static void Set(uint64_t* bits, size_t index) {
     bits[index >> kStorageLogBitSize] |= (kOne << (index & kStorageBlockMask));
   }
 
-  static void Clear(uint64* bits, size_t index) {
+  static void Clear(uint64_t* bits, size_t index) {
     bits[index >> kStorageLogBitSize] &= ~(kOne << (index & kStorageBlockMask));
   }
 
@@ -184,25 +184,25 @@ class BitmapIndex {
   // Rebuilds from index for the associated Bitmap, should be called
   // whenever changes have been made to the Bitmap or else behavior
   // of the indexed bitmap methods will be undefined.
-  void BuildIndex(const uint64* bits, size_t num_bits,
+  void BuildIndex(const uint64_t* bits, size_t num_bits,
                   bool enable_select_0_index = false,
                   bool enable_select_1_index = false);
 
-  static constexpr uint64 kOne = 1;
-  static constexpr uint32 kStorageBitSize = 64;
-  static constexpr uint32 kStorageLogBitSize = 6;
+  static constexpr uint64_t kOne = 1;
+  static constexpr uint32_t kStorageBitSize = 64;
+  static constexpr uint32_t kStorageLogBitSize = 6;
 
  private:
-  static constexpr uint32 kUnitsPerRankIndexEntry = 8;
-  static constexpr uint32 kBitsPerRankIndexEntry =
+  static constexpr uint32_t kUnitsPerRankIndexEntry = 8;
+  static constexpr uint32_t kBitsPerRankIndexEntry =
       kUnitsPerRankIndexEntry * kStorageBitSize;
-  static constexpr uint32 kStorageBlockMask = kStorageBitSize - 1;
+  static constexpr uint32_t kStorageBlockMask = kStorageBitSize - 1;
 
   // TODO(jrosenstock): benchmark different values here.
   // It's reasonable that these are the same since density is typically around
   // 1/2.
-  static constexpr uint32 kBitsPerSelect0Block = 512;
-  static constexpr uint32 kBitsPerSelect1Block = 512;
+  static constexpr uint32_t kBitsPerSelect0Block = 512;
+  static constexpr uint32_t kBitsPerSelect1Block = 512;
 
   // If this many or fewer RankIndexEntry blocks need to be searched by
   // FindRankIndexEntry use a linear search instead of a binary search.
@@ -212,7 +212,7 @@ class BitmapIndex {
   // raising it because there are very few times a higher value would
   // make a difference. Thus, whether a higher value helps or hurts is harder
   // to measure. TODO(jrosenstock): Try to measure with low bit density.
-  static constexpr uint32 kMaxLinearSearchBlocks = 8;
+  static constexpr uint32_t kMaxLinearSearchBlocks = 8;
 
   // A RankIndexEntry covers a block of 8 64-bit words (one cache line on
   // x86_64 and ARM). It consists of an absolute count of all the 1s that
@@ -233,41 +233,41 @@ class BitmapIndex {
           relative_ones_count_6_(0),
           relative_ones_count_7_(0) {}
 
-    uint32 absolute_ones_count() const { return absolute_ones_count_; }
-    uint32 relative_ones_count_1() const { return relative_ones_count_1_; }
-    uint32 relative_ones_count_2() const { return relative_ones_count_2_; }
-    uint32 relative_ones_count_3() const { return relative_ones_count_3_; }
-    uint32 relative_ones_count_4() const { return relative_ones_count_4_; }
-    uint32 relative_ones_count_5() const { return relative_ones_count_5_; }
-    uint32 relative_ones_count_6() const { return relative_ones_count_6_; }
-    uint32 relative_ones_count_7() const { return relative_ones_count_7_; }
-
-    void set_absolute_ones_count(uint32 v) { absolute_ones_count_ = v; }
-    void set_relative_ones_count_1(uint32 v) {
+    uint32_t absolute_ones_count() const { return absolute_ones_count_; }
+    uint32_t relative_ones_count_1() const { return relative_ones_count_1_; }
+    uint32_t relative_ones_count_2() const { return relative_ones_count_2_; }
+    uint32_t relative_ones_count_3() const { return relative_ones_count_3_; }
+    uint32_t relative_ones_count_4() const { return relative_ones_count_4_; }
+    uint32_t relative_ones_count_5() const { return relative_ones_count_5_; }
+    uint32_t relative_ones_count_6() const { return relative_ones_count_6_; }
+    uint32_t relative_ones_count_7() const { return relative_ones_count_7_; }
+
+    void set_absolute_ones_count(uint32_t v) { absolute_ones_count_ = v; }
+    void set_relative_ones_count_1(uint32_t v) {
       DCHECK_LE(v, kStorageBitSize);
       relative_ones_count_1_ = v;
     }
-    void set_relative_ones_count_2(uint32 v) {
+    void set_relative_ones_count_2(uint32_t v) {
       DCHECK_LE(v, 2 * kStorageBitSize);
       relative_ones_count_2_ = v;
     }
-    void set_relative_ones_count_3(uint32 v) {
+    void set_relative_ones_count_3(uint32_t v) {
       DCHECK_LE(v, 3 * kStorageBitSize);
       relative_ones_count_3_ = v;
     }
-    void set_relative_ones_count_4(uint32 v) {
+    void set_relative_ones_count_4(uint32_t v) {
       DCHECK_LE(v, 4 * kStorageBitSize);
       relative_ones_count_4_ = v;
     }
-    void set_relative_ones_count_5(uint32 v) {
+    void set_relative_ones_count_5(uint32_t v) {
       DCHECK_LE(v, 5 * kStorageBitSize);
       relative_ones_count_5_ = v;
     }
-    void set_relative_ones_count_6(uint32 v) {
+    void set_relative_ones_count_6(uint32_t v) {
       DCHECK_LE(v, 6 * kStorageBitSize);
       relative_ones_count_6_ = v;
     }
-    void set_relative_ones_count_7(uint32 v) {
+    void set_relative_ones_count_7(uint32_t v) {
       DCHECK_LE(v, 7 * kStorageBitSize);
       relative_ones_count_7_ = v;
     }
@@ -275,7 +275,7 @@ class BitmapIndex {
    private:
     // Popcount of 1s before this block.
     // rank_index_[i].absolute_ones_count() == Rank1(512 * i).
-    uint32 absolute_ones_count_;
+    uint32_t absolute_ones_count_;
 
     // Popcount of 1s since the beginning of the block.
     // rank_index_[i].relative_ones_count_k() ==
@@ -287,7 +287,7 @@ class BitmapIndex {
     // 7 * 64 == 448, so needs 9 bits.
     //
     // All fields could just be 9 bits and still fit
-    // in an int64, but by using these values (which are also the minimum
+    // in an int64_t, but by using these values (which are also the minimum
     // required width), no field spans 2 int32s, which may be helpful on
     // 32-bit architectures.
     unsigned int relative_ones_count_1_ : 7;
@@ -302,7 +302,7 @@ class BitmapIndex {
                 "RankIndexEntry should be 12 bytes.");
 
   // Returns, from the index, the count of ones up to array_index.
-  uint32 GetIndexOnesCount(size_t array_index) const;
+  uint32_t GetIndexOnesCount(size_t array_index) const;
 
   // Finds the entry in the rank index for the block containing the
   // bit_index-th 1 bit.
@@ -320,7 +320,7 @@ class BitmapIndex {
            1;
   }
 
-  const uint64* bits_ = nullptr;
+  const uint64_t* bits_ = nullptr;
   size_t num_bits_ = 0;
 
   std::vector<RankIndexEntry> rank_index_;
@@ -330,14 +330,14 @@ class BitmapIndex {
   // Empty means there is no index, otherwise, we always add an extra entry
   // with num_bits_. Overhead is 4 bytes / 64 bytes of zeros,
   // so 4/64 times the density of zeros. This is 6.25% * zeros_density.
-  std::vector<uint32> select_0_index_;
+  std::vector<uint32_t> select_0_index_;
 
   // Index of positions for Select1
   // select_1_index_[i] == Select1(kBitsPerSelect1Block * i).
   // Empty means there is no index, otherwise, we always add an extra entry
   // with num_bits_. Overhead is 4 bytes / 64 bytes of ones,
   // so 4/64 times the density of ones. This is 6.25% * ones_density.
-  std::vector<uint32> select_1_index_;
+  std::vector<uint32_t> select_1_index_;
 };
 
 }  // end namespace fst
index 2f0d623..fbefea8 100644 (file)
 
 #include <algorithm>
 #include <cstddef>
+#include <cstdint>
 #include <cstring>
 #include <iostream>
+#include <memory>
 #include <string>
 #include <utility>
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/ngram/bitmap-index.h>
 #include <fstream>
@@ -104,17 +105,11 @@ class NGramFstImpl : public FstImpl<A> {
     SetProperties(kError, kError);
   }
 
-  ~NGramFstImpl() override {
-    if (owned_) {
-      delete[] data_;
-    }
-  }
-
   static NGramFstImpl<A> *Read(std::istream &strm, const FstReadOptions &opts) {
     auto impl = std::make_unique<NGramFstImpl<A>>();
     FstHeader hdr;
     if (!impl->ReadHeader(strm, opts, kMinFileVersion, &hdr)) return nullptr;
-    uint64 num_states, num_futures, num_final;
+    uint64_t num_states, num_futures, num_final;
     const size_t offset =
         sizeof(num_states) + sizeof(num_futures) + sizeof(num_final);
     // Peek at num_states and num_futures to see how much more needs to be read.
@@ -122,7 +117,7 @@ class NGramFstImpl : public FstImpl<A> {
     strm.read(reinterpret_cast<char *>(&num_futures), sizeof(num_futures));
     strm.read(reinterpret_cast<char *>(&num_final), sizeof(num_final));
     size_t size = Storage(num_states, num_futures, num_final);
-    MappedFile *data_region = MappedFile::Allocate(size);
+    std::unique_ptr<MappedFile> data_region(MappedFile::Allocate(size));
     char *data = static_cast<char *>(data_region->mutable_data());
     // Copy num_states, num_futures and num_final back into data.
     memcpy(data, reinterpret_cast<char *>(&num_states), sizeof(num_states));
@@ -132,7 +127,7 @@ class NGramFstImpl : public FstImpl<A> {
            reinterpret_cast<char *>(&num_final), sizeof(num_final));
     strm.read(data + offset, size - offset);
     if (strm.fail()) return nullptr;
-    impl->Init(data, false, data_region);
+    impl->Init(data, std::move(data_region));
     return impl.release();
   }
 
@@ -182,9 +177,9 @@ class NGramFstImpl : public FstImpl<A> {
     data->nstates = num_states_;
   }
 
-  static size_t Storage(uint64 num_states, uint64 num_futures,
-                        uint64 num_final) {
-    uint64 b64;
+  static size_t Storage(uint64_t num_states, uint64_t num_futures,
+                        uint64_t num_final) {
+    uint64_t b64;
     Weight weight;
     Label label;
     size_t offset =
@@ -237,7 +232,8 @@ class NGramFstImpl : public FstImpl<A> {
     return data_;
   }
 
-  void Init(const char *data, bool owned, MappedFile *file = nullptr);
+  void Init(const char *data,
+            std::unique_ptr<MappedFile> data_region);
 
   const std::vector<Label> &GetContext(StateId s, NGramFstInst<A> *inst) const {
     SetInstFuture(s, inst);
@@ -256,7 +252,7 @@ class NGramFstImpl : public FstImpl<A> {
   StateId Transition(const std::vector<Label> &context, Label future) const;
 
   // Properties always true for this Fst class.
-  static constexpr uint64 kStaticProperties =
+  static constexpr uint64_t kStaticProperties =
       kAcceptor | kIDeterministic | kODeterministic | kEpsilons | kIEpsilons |
       kOEpsilons | kILabelSorted | kOLabelSorted | kWeighted | kCyclic |
       kInitialAcyclic | kNotTopSorted | kAccessible | kCoAccessible |
@@ -267,18 +263,17 @@ class NGramFstImpl : public FstImpl<A> {
   static constexpr int kMinFileVersion = 4;
 
   std::unique_ptr<MappedFile> data_region_;
-  const char *data_ = nullptr;
-  bool owned_ = false;  // True if we own data_
+  const char *data_ = nullptr;  // Not owned.
   StateId start_ = fst::kNoStateId;
-  uint64 num_states_ = 0;
-  uint64 num_futures_ = 0;
-  uint64 num_final_ = 0;
+  uint64_t num_states_ = 0;
+  uint64_t num_futures_ = 0;
+  uint64_t num_final_ = 0;
   std::pair<size_t, size_t> select_root_;
   const Label *root_children_ = nullptr;
   // borrowed references
-  const uint64 *context_ = nullptr;
-  const uint64 *future_ = nullptr;
-  const uint64 *final_ = nullptr;
+  const uint64_t *context_ = nullptr;
+  const uint64_t *future_ = nullptr;
+  const uint64_t *final_ = nullptr;
   const Label *context_words_ = nullptr;
   const Label *future_words_ = nullptr;
   const Weight *backoff_ = nullptr;
@@ -362,10 +357,11 @@ class NGramFst : public ImplToExpandedFst<internal::NGramFstImpl<A>> {
 
   NGramFst() : ImplToExpandedFst<Impl>(std::make_shared<Impl>()) {}
 
-  // Non-standard constructor to initialize NGramFst directly from data.
-  NGramFst(const char *data, bool owned)
+  // Non-standard constructor to initialize NGramFst directly from data. Caller
+  // maintains ownership of data, which must outlive the NGramFst.
+  explicit NGramFst(const char *data)
       : ImplToExpandedFst<Impl>(std::make_shared<Impl>()) {
-    GetMutableImpl()->Init(data, owned, nullptr);
+    GetMutableImpl()->Init(data, /*data_region=*/nullptr);
   }
 
   // Get method that gets the data associated with Init().
@@ -504,7 +500,7 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
     return;
   }
 
-  int64 num_states = CountStates(fst);
+  int64_t num_states = CountStates(fst);
   std::vector<Label> context(num_states, 0);
 
   // Find the unigram state by starting from the start state, following
@@ -560,7 +556,7 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
 
   // Build the tree of contexts fst by reversing the epsilon arcs from fst.
   VectorFst<Arc> context_fst;
-  uint64 num_final = 0;
+  uint64_t num_final = 0;
   for (int i = 0; i < num_states; ++i) {
     if (fst.Final(i) != Weight::Zero()) {
       ++num_final;
@@ -570,8 +566,8 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
   context_fst.SetStart(unigram);
   context_fst.SetInputSymbols(fst.InputSymbols());
   context_fst.SetOutputSymbols(fst.OutputSymbols());
-  int64 num_context_arcs = 0;
-  int64 num_futures = 0;
+  int64_t num_context_arcs = 0;
+  int64_t num_futures = 0;
   for (StateIterator<Fst<A>> siter(fst); !siter.Done(); siter.Next()) {
     const StateId &state = siter.Value();
     num_futures += fst.NumArcs(state) - fst.NumInputEpsilons(state);
@@ -597,7 +593,7 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
     SetProperties(kError, kError);
     return;
   }
-  int64 context_props =
+  int64_t context_props =
       context_fst.Properties(kIDeterministic | kILabelSorted, true);
   if (!(context_props & kIDeterministic)) {
     FSTERROR() << "Input Fst is not structured properly";
@@ -608,11 +604,11 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
     ArcSort(&context_fst, ILabelCompare<Arc>());
   }
 
-  uint64 b64;
+  uint64_t b64;
   Weight weight;
   Label label = kNoLabel;
   const size_t storage = Storage(num_states, num_futures, num_final);
-  MappedFile *data_region = MappedFile::Allocate(storage);
+  std::unique_ptr<MappedFile> data_region(MappedFile::Allocate(storage));
   char *data = static_cast<char *>(data_region->mutable_data());
   memset(data, 0, storage);
   size_t offset = 0;
@@ -625,12 +621,12 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
   memcpy(data + offset, reinterpret_cast<char *>(&num_final),
          sizeof(num_final));
   offset += sizeof(num_final);
-  uint64 *context_bits = reinterpret_cast<uint64 *>(data + offset);
+  uint64_t *context_bits = reinterpret_cast<uint64_t *>(data + offset);
   offset += BitmapIndex::StorageSize(num_states * 2 + 1) * sizeof(b64);
-  uint64 *future_bits = reinterpret_cast<uint64 *>(data + offset);
+  uint64_t *future_bits = reinterpret_cast<uint64_t *>(data + offset);
   offset +=
       BitmapIndex::StorageSize(num_futures + num_states + 1) * sizeof(b64);
-  uint64 *final_bits = reinterpret_cast<uint64 *>(data + offset);
+  uint64_t *final_bits = reinterpret_cast<uint64_t *>(data + offset);
   offset += BitmapIndex::StorageSize(num_states) * sizeof(b64);
   Label *context_words = reinterpret_cast<Label *>(data + offset);
   offset += (num_states + 1) * sizeof(label);
@@ -642,8 +638,8 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
   Weight *final_probs = reinterpret_cast<Weight *>(data + offset);
   offset += num_final * sizeof(weight);
   Weight *future_probs = reinterpret_cast<Weight *>(data + offset);
-  int64 context_arc = 0, future_arc = 0, context_bit = 0, future_bit = 0,
-        final_bit = 0;
+  int64_t context_arc = 0, future_arc = 0, context_bit = 0, future_bit = 0,
+          final_bit = 0;
 
   // pseudo-root bits
   BitmapIndex::Set(context_bits, context_bit++);
@@ -708,33 +704,29 @@ NGramFstImpl<A>::NGramFstImpl(const Fst<A> &fst,
     return;
   }
 
-  Init(data, false, data_region);
+  Init(data, std::move(data_region));
 }
 
 template <typename A>
-inline void NGramFstImpl<A>::Init(const char *data, bool owned,
-                                  MappedFile *data_region) {
-  if (owned_) {
-    delete[] data_;
-  }
-  data_region_.reset(data_region);
-  owned_ = owned;
+inline void NGramFstImpl<A>::Init(const char *data,
+                                  std::unique_ptr<MappedFile> data_region) {
+  data_region_ = std::move(data_region);
   data_ = data;
   size_t offset = 0;
-  num_states_ = *(reinterpret_cast<const uint64 *>(data_ + offset));
+  num_states_ = *(reinterpret_cast<const uint64_t *>(data_ + offset));
   offset += sizeof(num_states_);
-  num_futures_ = *(reinterpret_cast<const uint64 *>(data_ + offset));
+  num_futures_ = *(reinterpret_cast<const uint64_t *>(data_ + offset));
   offset += sizeof(num_futures_);
-  num_final_ = *(reinterpret_cast<const uint64 *>(data_ + offset));
+  num_final_ = *(reinterpret_cast<const uint64_t *>(data_ + offset));
   offset += sizeof(num_final_);
-  uint64 bits;
+  uint64_t bits;
   size_t context_bits = num_states_ * 2 + 1;
   size_t future_bits = num_futures_ + num_states_ + 1;
-  context_ = reinterpret_cast<const uint64 *>(data_ + offset);
+  context_ = reinterpret_cast<const uint64_t *>(data_ + offset);
   offset += BitmapIndex::StorageSize(context_bits) * sizeof(bits);
-  future_ = reinterpret_cast<const uint64 *>(data_ + offset);
+  future_ = reinterpret_cast<const uint64_t *>(data_ + offset);
   offset += BitmapIndex::StorageSize(future_bits) * sizeof(bits);
-  final_ = reinterpret_cast<const uint64 *>(data_ + offset);
+  final_ = reinterpret_cast<const uint64_t *>(data_ + offset);
   offset += BitmapIndex::StorageSize(num_states_) * sizeof(bits);
   context_words_ = reinterpret_cast<const Label *>(data_ + offset);
   offset += (num_states_ + 1) * sizeof(*context_words_);
@@ -861,7 +853,7 @@ class NGramFstMatcher : public MatcherBase<A> {
 
   const Fst<A> &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 props) const override { return props; }
+  uint64_t Properties(uint64_t props) const override { return props; }
 
   void SetState(StateId s) final {
     fst_.GetImpl()->SetInstFuture(s, &inst_);
@@ -1023,21 +1015,21 @@ class ArcIterator<NGramFst<A>> : public ArcIteratorBase<A> {
     }
   }
 
-  uint8 Flags() const final { return flags_; }
+  uint8_t Flags() const final { return flags_; }
 
-  void SetFlags(uint8 flags, uint8 mask) final {
+  void SetFlags(uint8_t flags, uint8_t mask) final {
     flags_ &= ~mask;
     flags_ |= (flags & kArcValueFlags);
   }
 
  private:
   mutable Arc arc_;
-  mutable uint8 lazy_;
+  mutable uint8_t lazy_;
   const internal::NGramFstImpl<A> *impl_;  // Borrowed reference.
   mutable NGramFstInst<A> inst_;
 
   size_t i_;
-  uint8 flags_;
+  uint8_t flags_;
 };
 
 }  // namespace fst
index ea3aa81..13018f2 100644 (file)
@@ -24,7 +24,6 @@
 #include <arm_neon.h>
 #endif
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #if defined(__BMI2__)  // Intel Bit Manipulation Instruction Set 2
@@ -35,7 +34,7 @@
 namespace fst {
 // Returns the position (0-63) of the r-th 1 bit in v.
 // 0 <= r < CountOnes(v) <= 64. Therefore, v must not be 0.
-inline uint32 nth_bit(uint64 v, uint32 r) {
+inline uint32_t nth_bit(uint64_t v, uint32_t r) {
   DCHECK_NE(v, 0);
   DCHECK_LE(0, r);
   DCHECK_LT(r, __builtin_popcountll(v));
@@ -43,7 +42,7 @@ inline uint32 nth_bit(uint64 v, uint32 r) {
   // PDEP example from https://stackoverflow.com/a/27453505
   // __builtin_ctzll is UB for 0, but the conditions above ensure that can't
   // happen.
-  return __builtin_ctzll(_pdep_u64(uint64{1} << r, v));
+  return __builtin_ctzll(_pdep_u64(uint64_t{1} << r, v));
 }
 }  // namespace fst
 
@@ -53,7 +52,7 @@ inline uint32 nth_bit(uint64 v, uint32 r) {
 namespace fst {
 // Returns the position (0-63) of the r-th 1 bit in v.
 // 0 <= r < CountOnes(v) <= 64. Therefore, v must not be 0.
-uint32 nth_bit(uint64 v, uint32 r);
+uint32_t nth_bit(uint64_t v, uint32_t r);
 }  // namespace fst
 
 #elif SIZE_MAX == UINT64_MAX
@@ -61,8 +60,8 @@ uint32 nth_bit(uint64 v, uint32 r);
 
 namespace fst {
 namespace internal {
-extern const uint64 kPrefixSumOverflow[64];
-extern const uint8 kSelectInByte[2048];
+extern const uint64_t kPrefixSumOverflow[64];
+extern const uint8_t kSelectInByte[2048];
 }  // namespace internal
 
 // Returns the position (0-63) of the r-th 1 bit in v.
@@ -72,9 +71,9 @@ extern const uint8 kSelectInByte[2048];
 // Rank/Select Queries" by Sebastiano Vigna, p. 5, Algorithm 2, with
 // improvements from "Optimized Succinct Data Structures for Massive Data"
 // by Gog & Petri, 2014.
-inline uint32 nth_bit(const uint64 v, const uint32 r) {
-  constexpr uint64 kOnesStep8 = 0x0101010101010101;
-  constexpr uint64 kMSBsStep8 = 0x80 * kOnesStep8;
+inline uint32_t nth_bit(const uint64_t v, const uint32_t r) {
+  constexpr uint64_t kOnesStep8 = 0x0101010101010101;
+  constexpr uint64_t kMSBsStep8 = 0x80 * kOnesStep8;
 
   DCHECK_NE(v, 0);
   DCHECK_LE(0, r);
@@ -82,11 +81,11 @@ inline uint32 nth_bit(const uint64 v, const uint32 r) {
 
 #if defined(__aarch64__)
   // Use the ARM64 CNT instruction to compute a byte-wise popcount.
-  const uint64 s =
-      reinterpret_cast<uint64>(vcnt_u8(reinterpret_cast<uint8x8_t>(v)));
+  const uint64_t s =
+      reinterpret_cast<uint64_t>(vcnt_u8(reinterpret_cast<uint8x8_t>(v)));
 #else
-  constexpr uint64 kOnesStep4 = 0x1111111111111111;
-  uint64 s = v;
+  constexpr uint64_t kOnesStep4 = 0x1111111111111111;
+  uint64_t s = v;
   s = s - ((s >> 1) & (0x5 * kOnesStep4));
   s = (s & (0x3 * kOnesStep4)) + ((s >> 2) & (0x3 * kOnesStep4));
   s = (s + (s >> 4)) & (0xF * kOnesStep8);
@@ -95,13 +94,13 @@ inline uint32 nth_bit(const uint64 v, const uint32 r) {
 
   // byte_sums contains partial sums of the byte-wise popcounts.
   // That is, byte i contains the popcounts of bytes <= i.
-  uint64 byte_sums = s * kOnesStep8;
+  uint64_t byte_sums = s * kOnesStep8;
 
   // kPrefixSumOverflow[r] == (0x7F - r) * kOnesStep8, so the high bit is
   // still set if byte_sums - r > 0, or byte_sums > r. The first one set
   // is in the byte with the sum larger than r (since r is 0-based),
   // so this is the byte we need.
-  const uint64 b = (byte_sums + internal::kPrefixSumOverflow[r]) & kMSBsStep8;
+  const uint64_t b = (byte_sums + internal::kPrefixSumOverflow[r]) & kMSBsStep8;
   // The first bit set is the high bit in the byte, so
   // num_trailing_zeros == 8 * byte_nr + 7 and the byte number is the
   // number of trailing zeros divided by 8.
@@ -109,7 +108,7 @@ inline uint32 nth_bit(const uint64 v, const uint32 r) {
   const int shift = byte_nr << 3;
   // The top byte contains the whole-word popcount; we never need that.
   byte_sums <<= 8;
-  // Paper uses reinterpret_cast<uint8 *>; use shift/mask instead.
+  // Paper uses reinterpret_cast<uint8_t *>; use shift/mask instead.
   const int rank_in_byte = r - (byte_sums >> shift) & 0xFF;
   return shift +
          internal::kSelectInByte[(rank_in_byte << 8) + ((v >> shift) & 0xFF)];
index 32ad62f..7271622 100644 (file)
@@ -111,9 +111,6 @@ class Collection {
 };
 
 template <class I, class T>
-constexpr I Collection<I, T>::kNoNodeId;
-
-template <class I, class T>
 const std::hash<T> Collection<I, T>::hash_ = {};
 
 }  // namespace fst
index 1fa414b..8b9b8d4 100644 (file)
 #ifndef FST_EXTENSIONS_PDT_COMPOSE_H_
 #define FST_EXTENSIONS_PDT_COMPOSE_H_
 
+#include <cstdint>
 #include <list>
 
-#include <fst/types.h>
 #include <fst/extensions/pdt/pdt.h>
 #include <fst/compose.h>
 
 namespace fst {
 
 // Returns paren arcs for Find(kNoLabel).
-constexpr uint32 kParenList = 0x00000001;
+inline constexpr uint32_t kParenList = 0x00000001;
 
 // Returns a kNolabel loop for Find(paren).
-constexpr uint32 kParenLoop = 0x00000002;
+inline constexpr uint32_t kParenLoop = 0x00000002;
 
 // This class is a matcher that treats parens as multi-epsilon labels.
 // It is most efficient if the parens are in a range non-overlapping with
@@ -49,7 +49,7 @@ class ParenMatcher {
 
   // This makes a copy of the FST.
   ParenMatcher(const FST &fst, MatchType match_type,
-               uint32 flags = (kParenLoop | kParenList))
+               uint32_t flags = (kParenLoop | kParenList))
       : matcher_(fst, match_type), match_type_(match_type), flags_(flags) {
     if (match_type == MATCH_INPUT) {
       loop_.ilabel = kNoLabel;
@@ -64,7 +64,7 @@ class ParenMatcher {
 
   // This doesn't copy the FST.
   ParenMatcher(const FST *fst, MatchType match_type,
-               uint32 flags = (kParenLoop | kParenList))
+               uint32_t flags = (kParenLoop | kParenList))
       : matcher_(fst, match_type), match_type_(match_type), flags_(flags) {
     if (match_type == MATCH_INPUT) {
       loop_.ilabel = kNoLabel;
@@ -113,9 +113,11 @@ class ParenMatcher {
 
   const FST &GetFst() const { return matcher_.GetFst(); }
 
-  uint64 Properties(uint64 props) const { return matcher_.Properties(props); }
+  uint64_t Properties(uint64_t props) const {
+    return matcher_.Properties(props);
+  }
 
-  uint32 Flags() const { return matcher_.Flags(); }
+  uint32_t Flags() const { return matcher_.Flags(); }
 
   void AddOpenParen(Label label) {
     if (label == 0) {
@@ -166,7 +168,7 @@ class ParenMatcher {
 
   M matcher_;
   MatchType match_type_;  // Type of match to perform.
-  uint32 flags_;
+  uint32_t flags_;
   // Open paren label set.
   CompactSet<Label, kNoLabel> open_parens_;
   // Close paren label set.
@@ -369,7 +371,7 @@ class ParenFilter {
 
   Matcher2 *GetMatcher2() { return filter_.GetMatcher2(); }
 
-  uint64 Properties(uint64 iprops) const {
+  uint64_t Properties(uint64_t iprops) const {
     return filter_.Properties(iprops) & kILabelInvariantProperties &
            kOLabelInvariantProperties;
   }
@@ -448,7 +450,7 @@ class PdtComposeFstOptions<Arc, false>
   }
 };
 
-enum class PdtComposeFilter : uint8 {
+enum class PdtComposeFilter : uint8_t {
   PAREN,         // Bar-Hillel construction; keeps parentheses.
   EXPAND,        // Bar-Hillel + expansion; removes parentheses.
   EXPAND_PAREN,  // Bar-Hillel + expansion; keeps parentheses.
index 88afc4c..27fc89b 100644 (file)
 #ifndef FST_EXTENSIONS_PDT_EXPAND_H_
 #define FST_EXTENSIONS_PDT_EXPAND_H_
 
+#include <cstdint>
 #include <forward_list>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/paren.h>
 #include <fst/extensions/pdt/pdt.h>
@@ -192,7 +192,7 @@ class PdtExpandFstImpl : public CacheImpl<Arc> {
 
  private:
   // Properties for an expanded PDT.
-  inline uint64 PdtExpandProperties(uint64 inprops) {
+  inline uint64_t PdtExpandProperties(uint64_t inprops) {
     return inprops & (kAcceptor | kAcyclic | kInitialAcyclic | kUnweighted);
   }
 
@@ -362,9 +362,9 @@ class PdtPrunedExpand {
   void Expand(MutableFst<Arc> *ofst, const Weight &threshold);
 
  private:
-  static constexpr uint8 kEnqueued = 0x01;
-  static constexpr uint8 kExpanded = 0x02;
-  static constexpr uint8 kSourceState = 0x04;
+  static constexpr uint8_t kEnqueued = 0x01;
+  static constexpr uint8_t kExpanded = 0x02;
+  static constexpr uint8_t kSourceState = 0x04;
 
   // Comparison functor used by the queue:
   //
@@ -433,9 +433,9 @@ class PdtPrunedExpand {
 
   Weight DistanceToDest(StateId source, StateId dest) const;
 
-  uint8 Flags(StateId s) const;
+  uint8_t Flags(StateId s) const;
 
-  void SetFlags(StateId s, uint8 flags, uint8 mask);
+  void SetFlags(StateId s, uint8_t flags, uint8_t mask);
 
   Weight Distance(StateId s) const;
 
@@ -490,7 +490,7 @@ class PdtPrunedExpand {
   // Construction time failure?
   bool error_;
   // Status flags for states in efst_/ofst.
-  std::vector<uint8> flags_;
+  std::vector<uint8_t> flags_;
   // PDT source state for each expanded state.
   std::vector<StateId> sources_;
   // Shortest path for rfst_.
@@ -562,13 +562,13 @@ typename Arc::Weight PdtPrunedExpand<Arc>::DistanceToDest(StateId source,
 
 // Returns the flags for state s in ofst_.
 template <class Arc>
-uint8 PdtPrunedExpand<Arc>::Flags(StateId s) const {
+uint8_t PdtPrunedExpand<Arc>::Flags(StateId s) const {
   return s < flags_.size() ? flags_[s] : 0;
 }
 
 // Modifies the flags for state s in ofst_.
 template <class Arc>
-void PdtPrunedExpand<Arc>::SetFlags(StateId s, uint8 flags, uint8 mask) {
+void PdtPrunedExpand<Arc>::SetFlags(StateId s, uint8_t flags, uint8_t mask) {
   while (flags_.size() <= s) flags_.push_back(0);
   flags_[s] &= ~mask;
   flags_[s] |= flags & mask;
index ce06ad3..b0ba54f 100644 (file)
 
 #include <fst/extensions/pdt/compose.h>
 #include <fst/extensions/pdt/replace.h>
+#include <string_view>
 
 namespace fst {
 namespace script {
 
-bool GetPdtComposeFilter(const std::string &str, PdtComposeFilter *cf);
+bool GetPdtComposeFilter(std::string_view str, PdtComposeFilter *cf);
 
-bool GetPdtParserType(const std::string &str, PdtParserType *pt);
+bool GetPdtParserType(std::string_view str, PdtParserType *pt);
 
 }  // namespace script
 }  // namespace fst
index 108a1e2..11fb38a 100644 (file)
 #ifndef FST_EXTENSIONS_PDT_INFO_H_
 #define FST_EXTENSIONS_PDT_INFO_H_
 
+#include <cstdint>
+#include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/extensions/pdt/pdt.h>
 #include <fst/fst.h>
 #include <unordered_map>
@@ -45,32 +46,34 @@ class PdtInfo {
 
   const std::string &ArcType() const { return Arc::Type(); }
 
-  int64 NumStates() const { return nstates_; }
+  int64_t NumStates() const { return nstates_; }
 
-  int64 NumArcs() const { return narcs_; }
+  int64_t NumArcs() const { return narcs_; }
 
-  int64 NumOpenParens() const { return nopen_parens_; }
+  int64_t NumOpenParens() const { return nopen_parens_; }
 
-  int64 NumCloseParens() const { return nclose_parens_; }
+  int64_t NumCloseParens() const { return nclose_parens_; }
 
-  int64 NumUniqueOpenParens() const { return nuniq_open_parens_; }
+  int64_t NumUniqueOpenParens() const { return nuniq_open_parens_; }
 
-  int64 NumUniqueCloseParens() const { return nuniq_close_parens_; }
+  int64_t NumUniqueCloseParens() const { return nuniq_close_parens_; }
 
-  int64 NumOpenParenStates() const { return nopen_paren_states_; }
+  int64_t NumOpenParenStates() const { return nopen_paren_states_; }
 
-  int64 NumCloseParenStates() const { return nclose_paren_states_; }
+  int64_t NumCloseParenStates() const { return nclose_paren_states_; }
+
+  void Print();
 
  private:
   std::string fst_type_;
-  int64 nstates_;
-  int64 narcs_;
-  int64 nopen_parens_;
-  int64 nclose_parens_;
-  int64 nuniq_open_parens_;
-  int64 nuniq_close_parens_;
-  int64 nopen_paren_states_;
-  int64 nclose_paren_states_;
+  int64_t nstates_;
+  int64_t narcs_;
+  int64_t nopen_parens_;
+  int64_t nclose_parens_;
+  int64_t nuniq_open_parens_;
+  int64_t nuniq_close_parens_;
+  int64_t nopen_paren_states_;
+  int64_t nclose_paren_states_;
 };
 
 template <class Arc>
@@ -129,32 +132,32 @@ PdtInfo<Arc>::PdtInfo(
 }
 
 template <class Arc>
-void PrintPdtInfo(const PdtInfo<Arc> &info) {
+void PdtInfo<Arc>::Print() {
   const auto old = std::cout.setf(std::ios::left);
   std::cout.width(50);
-  std::cout << "fst type" << info.FstType() << std::endl;
+  std::cout << "fst type" << FstType() << std::endl;
   std::cout.width(50);
-  std::cout << "arc type" << info.ArcType() << std::endl;
+  std::cout << "arc type" << ArcType() << std::endl;
   std::cout.width(50);
-  std::cout << "# of states" << info.NumStates() << std::endl;
+  std::cout << "# of states" << NumStates() << std::endl;
   std::cout.width(50);
-  std::cout << "# of arcs" << info.NumArcs() << std::endl;
+  std::cout << "# of arcs" << NumArcs() << std::endl;
   std::cout.width(50);
-  std::cout << "# of open parentheses" << info.NumOpenParens() << std::endl;
+  std::cout << "# of open parentheses" << NumOpenParens() << std::endl;
   std::cout.width(50);
-  std::cout << "# of close parentheses" << info.NumCloseParens() << std::endl;
+  std::cout << "# of close parentheses" << NumCloseParens() << std::endl;
   std::cout.width(50);
-  std::cout << "# of unique open parentheses" << info.NumUniqueOpenParens()
+  std::cout << "# of unique open parentheses" << NumUniqueOpenParens()
             << std::endl;
   std::cout.width(50);
-  std::cout << "# of unique close parentheses" << info.NumUniqueCloseParens()
+  std::cout << "# of unique close parentheses" << NumUniqueCloseParens()
             << std::endl;
   std::cout.width(50);
-  std::cout << "# of open parenthesis dest. states" << info.NumOpenParenStates()
+  std::cout << "# of open parenthesis dest. states" << NumOpenParenStates()
             << std::endl;
   std::cout.width(50);
-  std::cout << "# of close parenthesis source states"
-            << info.NumCloseParenStates() << std::endl;
+  std::cout << "# of close parenthesis source states" << NumCloseParenStates()
+            << std::endl;
   std::cout.setf(old);
 }
 
index b32029a..6725820 100644 (file)
 #define FST_EXTENSIONS_PDT_PAREN_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <set>
 #include <vector>
 
 #include <fst/log.h>
-
 #include <fst/extensions/pdt/collection.h>
 #include <fst/extensions/pdt/pdt.h>
 #include <fst/dfs-visit.h>
@@ -33,7 +33,6 @@
 #include <unordered_map>
 #include <unordered_set>
 
-
 namespace fst {
 namespace internal {
 
@@ -217,7 +216,7 @@ class PdtParenReachable {
   // Paren arcs.
   ParenArcMultimap paren_arc_multimap_;
   // DFS states.
-  std::vector<uint8> state_color_;
+  std::vector<uint8_t> state_color_;
   // Reachable states to IDs.
   mutable Collection<ssize_t, StateId> state_sets_;
   // IDs to reachable states.
@@ -231,9 +230,9 @@ class PdtParenReachable {
 // Gathers paren and state set information.
 template <class Arc>
 bool PdtParenReachable<Arc>::DFSearch(StateId s) {
-  static constexpr uint8 kWhiteState = 0x01;  // Undiscovered.
-  static constexpr uint8 kGreyState = 0x02;   // Discovered & unfinished.
-  static constexpr uint8 kBlackState = 0x04;  // Finished.
+  static constexpr uint8_t kWhiteState = 0x01;  // Undiscovered.
+  static constexpr uint8_t kGreyState = 0x02;   // Discovered & unfinished.
+  static constexpr uint8_t kBlackState = 0x04;  // Finished.
   if (s >= state_color_.size()) state_color_.resize(s + 1, kWhiteState);
   if (state_color_[s] == kBlackState) return true;
   if (state_color_[s] == kGreyState) return false;
index 3639d40..87f9093 100644 (file)
 #define FST_EXTENSIONS_PDT_PDTSCRIPT_H_
 
 #include <algorithm>
+#include <cstdint>
+#include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/compose.h>
 #include <fst/extensions/pdt/expand.h>
@@ -44,11 +45,11 @@ namespace script {
 
 using PdtComposeArgs =
     std::tuple<const FstClass &, const FstClass &,
-               const std::vector<std::pair<int64, int64>> &, MutableFstClass *,
-               const PdtComposeOptions &, bool>;
+               const std::vector<std::pair<int64_t, int64_t>> &,
+               MutableFstClass *, const PdtComposeOptions &, bool>;
 
 template <class Arc>
-void PdtCompose(PdtComposeArgs *args) {
+void Compose(PdtComposeArgs *args) {
   const Fst<Arc> &ifst1 = *(std::get<0>(*args).GetFst<Arc>());
   const Fst<Arc> &ifst2 = *(std::get<1>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<3>(*args)->GetMutableFst<Arc>();
@@ -66,10 +67,10 @@ void PdtCompose(PdtComposeArgs *args) {
   }
 }
 
-void PdtCompose(const FstClass &ifst1, const FstClass &ifst2,
-                const std::vector<std::pair<int64, int64>> &parens,
-                MutableFstClass *ofst, const PdtComposeOptions &opts,
-                bool left_pdt);
+void Compose(const FstClass &ifst1, const FstClass &ifst2,
+             const std::vector<std::pair<int64_t, int64_t>> &parens,
+             MutableFstClass *ofst, const PdtComposeOptions &opts,
+             bool left_pdt);
 
 struct PdtExpandOptions {
   bool connect;
@@ -81,11 +82,12 @@ struct PdtExpandOptions {
 };
 
 using PdtExpandArgs =
-    std::tuple<const FstClass &, const std::vector<std::pair<int64, int64>> &,
+    std::tuple<const FstClass &,
+               const std::vector<std::pair<int64_t, int64_t>> &,
                MutableFstClass *, const PdtExpandOptions &>;
 
 template <class Arc>
-void PdtExpand(PdtExpandArgs *args) {
+void Expand(PdtExpandArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<2>(*args)->GetMutableFst<Arc>();
   // In case Arc::Label is not the same as FstClass::Label, we make a
@@ -102,22 +104,23 @@ void PdtExpand(PdtExpandArgs *args) {
                    .weight_threshold.GetWeight<typename Arc::Weight>())));
 }
 
-void PdtExpand(const FstClass &ifst,
-               const std::vector<std::pair<int64, int64>> &parens,
-               MutableFstClass *ofst, const PdtExpandOptions &opts);
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            MutableFstClass *ofst, const PdtExpandOptions &opts);
 
-void PdtExpand(const FstClass &ifst,
-               const std::vector<std::pair<int64, int64>> &parens,
-               MutableFstClass *ofst, bool connect, bool keep_parentheses,
-               const WeightClass &weight_threshold);
+void Expand(const FstClass &ifst,
+            const std::vector<std::pair<int64_t, int64_t>> &parens,
+            MutableFstClass *ofst, bool connect, bool keep_parentheses,
+            const WeightClass &weight_threshold);
 
 using PdtReplaceArgs =
-    std::tuple<const std::vector<std::pair<int64, const FstClass *>> &,
-               MutableFstClass *, std::vector<std::pair<int64, int64>> *, int64,
-               PdtParserType, int64, const std::string &, const std::string &>;
+    std::tuple<const std::vector<std::pair<int64_t, const FstClass *>> &,
+               MutableFstClass *, std::vector<std::pair<int64_t, int64_t>> *,
+               int64_t, PdtParserType, int64_t, const std::string &,
+               const std::string &>;
 
 template <class Arc>
-void PdtReplace(PdtReplaceArgs *args) {
+void Replace(PdtReplaceArgs *args) {
   const auto &untyped_pairs = std::get<0>(*args);
   auto size = untyped_pairs.size();
   std::vector<std::pair<typename Arc::Label, const Fst<Arc> *>> typed_pairs(
@@ -138,20 +141,21 @@ void PdtReplace(PdtReplaceArgs *args) {
             std::get<2>(*args)->begin());
 }
 
-void PdtReplace(const std::vector<std::pair<int64, const FstClass *>> &pairs,
-                MutableFstClass *ofst,
-                std::vector<std::pair<int64, int64>> *parens, int64 root,
-                PdtParserType parser_type = PdtParserType::LEFT,
-                int64 start_paren_labels = kNoLabel,
-                const std::string &left_paren_prefix = "(_",
-                const std::string &right_paren_prefix = "_)");
+void Replace(const std::vector<std::pair<int64_t, const FstClass *>> &pairs,
+             MutableFstClass *ofst,
+             std::vector<std::pair<int64_t, int64_t>> *parens, int64_t root,
+             PdtParserType parser_type = PdtParserType::LEFT,
+             int64_t start_paren_labels = kNoLabel,
+             const std::string &left_paren_prefix = "(_",
+             const std::string &right_paren_prefix = "_)");
 
 using PdtReverseArgs =
-    std::tuple<const FstClass &, const std::vector<std::pair<int64, int64>> &,
+    std::tuple<const FstClass &,
+               const std::vector<std::pair<int64_t, int64_t>> &,
                MutableFstClass *>;
 
 template <class Arc>
-void PdtReverse(PdtReverseArgs *args) {
+void Reverse(PdtReverseArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<2>(*args)->GetMutableFst<Arc>();
   // In case Arc::Label is not the same as FstClass::Label, we make a
@@ -164,9 +168,9 @@ void PdtReverse(PdtReverseArgs *args) {
   Reverse(fst, typed_parens, ofst);
 }
 
-void PdtReverse(const FstClass &ifst,
-                const std::vector<std::pair<int64, int64>> &,
-                MutableFstClass *ofst);
+void Reverse(const FstClass &ifst,
+             const std::vector<std::pair<int64_t, int64_t>> &,
+             MutableFstClass *ofst);
 
 // PDT SHORTESTPATH
 
@@ -181,11 +185,12 @@ struct PdtShortestPathOptions {
 };
 
 using PdtShortestPathArgs =
-    std::tuple<const FstClass &, const std::vector<std::pair<int64, int64>> &,
+    std::tuple<const FstClass &,
+               const std::vector<std::pair<int64_t, int64_t>> &,
                MutableFstClass *, const PdtShortestPathOptions &>;
 
 template <class Arc>
-void PdtShortestPath(PdtShortestPathArgs *args) {
+void ShortestPath(PdtShortestPathArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   MutableFst<Arc> *ofst = std::get<2>(*args)->GetMutableFst<Arc>();
   const PdtShortestPathOptions &opts = std::get<3>(*args);
@@ -223,18 +228,19 @@ void PdtShortestPath(PdtShortestPathArgs *args) {
   }
 }
 
-void PdtShortestPath(
-    const FstClass &ifst, const std::vector<std::pair<int64, int64>> &parens,
+void ShortestPath(
+    const FstClass &ifst,
+    const std::vector<std::pair<int64_t, int64_t>> &parens,
     MutableFstClass *ofst,
     const PdtShortestPathOptions &opts = PdtShortestPathOptions());
 
 // PRINT INFO
 
-using PrintPdtInfoArgs =
-    std::pair<const FstClass &, const std::vector<std::pair<int64, int64>> &>;
+using PdtInfoArgs = std::pair<const FstClass &,
+                              const std::vector<std::pair<int64_t, int64_t>> &>;
 
 template <class Arc>
-void PrintPdtInfo(PrintPdtInfoArgs *args) {
+void Info(PdtInfoArgs *args) {
   const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
   // In case Arc::Label is not the same as FstClass::Label, we make a
   // copy. Truncation may occur if FstClass::Label has more precision than
@@ -244,11 +250,11 @@ void PrintPdtInfo(PrintPdtInfoArgs *args) {
   std::copy(std::get<1>(*args).begin(), std::get<1>(*args).end(),
             typed_parens.begin());
   PdtInfo<Arc> pdtinfo(fst, typed_parens);
-  PrintPdtInfo(pdtinfo);
+  pdtinfo.Print();
 }
 
-void PrintPdtInfo(const FstClass &ifst,
-                  const std::vector<std::pair<int64, int64>> &parens);
+void Info(const FstClass &ifst,
+          const std::vector<std::pair<int64_t, int64_t>> &parens);
 
 }  // namespace script
 }  // namespace fst
index b8298a2..7f6cb2e 100644 (file)
 #ifndef FST_EXTENSIONS_PDT_REPLACE_H_
 #define FST_EXTENSIONS_PDT_REPLACE_H_
 
+#include <cstdint>
 #include <map>
 #include <memory>
 #include <set>
+#include <string>
 #include <type_traits>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/replace-util.h>
 #include <fst/replace.h>
 #include <fst/symbol-table-ops.h>
@@ -56,7 +57,7 @@ struct ReplaceParenHash {
 //
 // Mohri, M., and Pereira, F. 1998. Dynamic compilation of weighted context-free
 // grammars. In Proc. ACL, pages 891-897.
-enum class PdtParserType : uint8 {
+enum class PdtParserType : uint8_t {
   // Top-down construction. Applied to a simple LL(1) grammar (among others),
   // gives a DPDA. If promoted to a DPDT, with outputs being production
   // numbers, gives a leftmost derivation. Left recursive grammars are
@@ -808,7 +809,7 @@ void Replace(
     }
     default:
       FSTERROR() << "Replace: Unknown PDT parser type: "
-                 << static_cast<std::underlying_type<PdtParserType>::type>(
+                 << static_cast<std::underlying_type_t<PdtParserType>>(
                         opts.type);
       ofst->DeleteStates();
       ofst->SetProperties(kError, kError);
index c3c7143..4f6d1f1 100644 (file)
 #ifndef FST_EXTENSIONS_PDT_SHORTEST_PATH_H_
 #define FST_EXTENSIONS_PDT_SHORTEST_PATH_H_
 
+#include <cstdint>
 #include <stack>
 #include <unordered_map>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/extensions/pdt/paren.h>
 #include <fst/extensions/pdt/pdt.h>
@@ -48,9 +48,9 @@ namespace internal {
 
 // Flags for shortest path data.
 
-constexpr uint8 kPdtInited = 0x01;
-constexpr uint8 kPdtFinal = 0x02;
-constexpr uint8 kPdtMarked = 0x04;
+inline constexpr uint8_t kPdtInited = 0x01;
+inline constexpr uint8_t kPdtFinal = 0x02;
+inline constexpr uint8_t kPdtMarked = 0x04;
 
 // Stores shortest path tree info Distance(), Parent(), and ArcParent()
 // information keyed on two types:
@@ -116,8 +116,8 @@ class PdtShortestPathData {
 
     Weight distance;     // Distance to this state from PDT "start" state.
     SearchState parent;  // Parent state in shortest path tree.
-    int16 paren_id;      // If parent arc has paren, paren ID (or kNoLabel).
-    uint8 flags;         // First byte reserved for PdtShortestPathData use.
+    int16_t paren_id;    // If parent arc has paren, paren ID (or kNoLabel).
+    uint8_t flags;       // First byte reserved for PdtShortestPathData use.
   };
 
   explicit PdtShortestPathData(bool gc)
@@ -155,7 +155,7 @@ class PdtShortestPathData {
 
   Label ParenId(SearchState s) const { return GetSearchData(s)->paren_id; }
 
-  uint8 Flags(SearchState s) const { return GetSearchData(s)->flags; }
+  uint8_t Flags(SearchState s) const { return GetSearchData(s)->flags; }
 
   void SetDistance(SearchState s, Weight weight) {
     GetSearchData(s)->distance = std::move(weight);
@@ -173,12 +173,12 @@ class PdtShortestPathData {
 
   void SetParenId(SearchState s, Label p) {
     if (p >= 32768) {
-      FSTERROR() << "PdtShortestPathData: Paren ID does not fit in an int16";
+      FSTERROR() << "PdtShortestPathData: Paren ID does not fit in an int16_t";
     }
     GetSearchData(s)->paren_id = p;
   }
 
-  void SetFlags(SearchState s, uint8 f, uint8 mask) {
+  void SetFlags(SearchState s, uint8_t f, uint8_t mask) {
     auto *data = GetSearchData(s);
     data->flags &= ~mask;
     data->flags |= f & mask;
@@ -433,9 +433,9 @@ class PdtShortestPath {
   ssize_t nenqueued_;
   bool error_;
 
-  static constexpr uint8 kEnqueued = 0x10;
-  static constexpr uint8 kExpanded = 0x20;
-  static constexpr uint8 kFinished = 0x40;
+  static constexpr uint8_t kEnqueued = 0x10;
+  static constexpr uint8_t kExpanded = 0x20;
+  static constexpr uint8_t kFinished = 0x40;
 
   static const Arc kNoArc;
 };
index c2ad4de..482123f 100644 (file)
 #ifndef FST_EXTENSIONS_SPECIAL_PHI_FST_H_
 #define FST_EXTENSIONS_SPECIAL_PHI_FST_H_
 
+#include <cstdint>
+#include <istream>
 #include <memory>
+#include <ostream>
 #include <string>
 
 #include <fst/const-fst.h>
@@ -54,7 +57,7 @@ class PhiFstMatcherData {
     auto *data = new PhiFstMatcherData<Label>();
     ReadType(istrm, &data->phi_label_);
     ReadType(istrm, &data->phi_loop_);
-    int32 rewrite_mode;
+    int32_t rewrite_mode;
     ReadType(istrm, &rewrite_mode);
     data->rewrite_mode_ = static_cast<MatcherRewriteMode>(rewrite_mode);
     return data;
@@ -63,7 +66,7 @@ class PhiFstMatcherData {
   bool Write(std::ostream &ostrm, const FstWriteOptions &opts) const {
     WriteType(ostrm, phi_label_);
     WriteType(ostrm, phi_loop_);
-    WriteType(ostrm, static_cast<int32>(rewrite_mode_));
+    WriteType(ostrm, static_cast<int32_t>(rewrite_mode_));
     return !ostrm ? false : true;
   }
 
@@ -90,10 +93,12 @@ class PhiFstMatcherData {
 
 }  // namespace internal
 
-constexpr uint8 kPhiFstMatchInput = 0x01;   // Input matcher is PhiMatcher.
-constexpr uint8 kPhiFstMatchOutput = 0x02;  // Output matcher is PhiMatcher.
+inline constexpr uint8_t kPhiFstMatchInput =
+    0x01;  // Input matcher is PhiMatcher.
+inline constexpr uint8_t kPhiFstMatchOutput =
+    0x02;  // Output matcher is PhiMatcher.
 
-template <class M, uint8 flags = kPhiFstMatchInput | kPhiFstMatchOutput>
+template <class M, uint8_t flags = kPhiFstMatchInput | kPhiFstMatchOutput>
 class PhiFstMatcher : public PhiMatcher<M> {
  public:
   using FST = typename M::FST;
@@ -103,7 +108,7 @@ class PhiFstMatcher : public PhiMatcher<M> {
   using Weight = typename Arc::Weight;
   using MatcherData = internal::PhiFstMatcherData<Label>;
 
-  enum : uint8 { kFlags = flags };
+  static constexpr uint8_t kFlags = flags;
 
   // This makes a copy of the FST.
   PhiFstMatcher(
@@ -149,9 +154,9 @@ class PhiFstMatcher : public PhiMatcher<M> {
   std::shared_ptr<MatcherData> data_;
 };
 
-extern const char phi_fst_type[];
-extern const char input_phi_fst_type[];
-extern const char output_phi_fst_type[];
+inline constexpr char phi_fst_type[] = "phi";
+inline constexpr char input_phi_fst_type[] = "input_phi";
+inline constexpr char output_phi_fst_type[] = "output_phi";
 
 template <class Arc>
 using PhiFst =
index 7bb3b9b..b2e5b82 100644 (file)
 #ifndef FST_EXTENSIONS_SPECIAL_RHO_FST_H_
 #define FST_EXTENSIONS_SPECIAL_RHO_FST_H_
 
+#include <cstdint>
+#include <istream>
 #include <memory>
+#include <ostream>
 #include <string>
 
 #include <fst/const-fst.h>
@@ -47,7 +50,7 @@ class RhoFstMatcherData {
                                         const FstReadOptions &read) {
     auto *data = new RhoFstMatcherData<Label>();
     ReadType(istrm, &data->rho_label_);
-    int32 rewrite_mode;
+    int32_t rewrite_mode;
     ReadType(istrm, &rewrite_mode);
     data->rewrite_mode_ = static_cast<MatcherRewriteMode>(rewrite_mode);
     return data;
@@ -55,7 +58,7 @@ class RhoFstMatcherData {
 
   bool Write(std::ostream &ostrm, const FstWriteOptions &opts) const {
     WriteType(ostrm, rho_label_);
-    WriteType(ostrm, static_cast<int32>(rewrite_mode_));
+    WriteType(ostrm, static_cast<int32_t>(rewrite_mode_));
     return !ostrm ? false : true;
   }
 
@@ -79,10 +82,12 @@ class RhoFstMatcherData {
 
 }  // namespace internal
 
-constexpr uint8 kRhoFstMatchInput = 0x01;   // Input matcher is RhoMatcher.
-constexpr uint8 kRhoFstMatchOutput = 0x02;  // Output matcher is RhoMatcher.
+inline constexpr uint8_t kRhoFstMatchInput =
+    0x01;  // Input matcher is RhoMatcher.
+inline constexpr uint8_t kRhoFstMatchOutput =
+    0x02;  // Output matcher is RhoMatcher.
 
-template <class M, uint8 flags = kRhoFstMatchInput | kRhoFstMatchOutput>
+template <class M, uint8_t flags = kRhoFstMatchInput | kRhoFstMatchOutput>
 class RhoFstMatcher : public RhoMatcher<M> {
  public:
   using FST = typename M::FST;
@@ -92,7 +97,7 @@ class RhoFstMatcher : public RhoMatcher<M> {
   using Weight = typename Arc::Weight;
   using MatcherData = internal::RhoFstMatcherData<Label>;
 
-  enum : uint8 { kFlags = flags };
+  static constexpr uint8_t kFlags = flags;
 
   // This makes a copy of the FST.
   RhoFstMatcher(
@@ -136,9 +141,9 @@ class RhoFstMatcher : public RhoMatcher<M> {
   std::shared_ptr<MatcherData> data_;
 };
 
-extern const char rho_fst_type[];
-extern const char input_rho_fst_type[];
-extern const char output_rho_fst_type[];
+inline constexpr char rho_fst_type[] = "rho";
+inline constexpr char input_rho_fst_type[] = "input_rho";
+inline constexpr char output_rho_fst_type[] = "output_rho";
 
 template <class Arc>
 using RhoFst =
index 09f4232..f6c2f63 100644 (file)
 #ifndef FST_EXTENSIONS_SPECIAL_SIGMA_FST_H_
 #define FST_EXTENSIONS_SPECIAL_SIGMA_FST_H_
 
+#include <cstdint>
+#include <istream>
 #include <memory>
+#include <ostream>
 #include <string>
 
 #include <fst/const-fst.h>
@@ -47,7 +50,7 @@ class SigmaFstMatcherData {
                                           const FstReadOptions &read) {
     auto *data = new SigmaFstMatcherData<Label>();
     ReadType(istrm, &data->sigma_label_);
-    int32 rewrite_mode;
+    int32_t rewrite_mode;
     ReadType(istrm, &rewrite_mode);
     data->rewrite_mode_ = static_cast<MatcherRewriteMode>(rewrite_mode);
     return data;
@@ -55,7 +58,7 @@ class SigmaFstMatcherData {
 
   bool Write(std::ostream &ostrm, const FstWriteOptions &opts) const {
     WriteType(ostrm, sigma_label_);
-    WriteType(ostrm, static_cast<int32>(rewrite_mode_));
+    WriteType(ostrm, static_cast<int32_t>(rewrite_mode_));
     return !ostrm ? false : true;
   }
 
@@ -79,10 +82,12 @@ class SigmaFstMatcherData {
 
 }  // namespace internal
 
-constexpr uint8 kSigmaFstMatchInput = 0x01;   // Input matcher is SigmaMatcher.
-constexpr uint8 kSigmaFstMatchOutput = 0x02;  // Output matcher is SigmaMatcher.
+inline constexpr uint8_t kSigmaFstMatchInput =
+    0x01;  // Input matcher is SigmaMatcher.
+inline constexpr uint8_t kSigmaFstMatchOutput =
+    0x02;  // Output matcher is SigmaMatcher.
 
-template <class M, uint8 flags = kSigmaFstMatchInput | kSigmaFstMatchOutput>
+template <class M, uint8_t flags = kSigmaFstMatchInput | kSigmaFstMatchOutput>
 class SigmaFstMatcher : public SigmaMatcher<M> {
  public:
   using FST = typename M::FST;
@@ -92,7 +97,7 @@ class SigmaFstMatcher : public SigmaMatcher<M> {
   using Weight = typename Arc::Weight;
   using MatcherData = internal::SigmaFstMatcherData<Label>;
 
-  enum : uint8 { kFlags = flags };
+  static constexpr uint8_t kFlags = flags;
 
   // This makes a copy of the FST.
   SigmaFstMatcher(
@@ -139,9 +144,9 @@ class SigmaFstMatcher : public SigmaMatcher<M> {
   std::shared_ptr<MatcherData> data_;
 };
 
-extern const char sigma_fst_type[];
-extern const char input_sigma_fst_type[];
-extern const char output_sigma_fst_type[];
+inline constexpr char sigma_fst_type[] = "sigma";
+inline constexpr char input_sigma_fst_type[] = "input_sigma";
+inline constexpr char output_sigma_fst_type[] = "output_sigma";
 
 template <class Arc>
 using SigmaFst =
index f6352a6..6ad6d3c 100644 (file)
 #define FST_FACTOR_WEIGHT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
 
 namespace fst {
 
-constexpr uint8 kFactorFinalWeights = 0x01;
-constexpr uint8 kFactorArcWeights = 0x02;
+inline constexpr uint8_t kFactorFinalWeights = 0x01;
+inline constexpr uint8_t kFactorArcWeights = 0x02;
 
 template <class Arc>
 struct FactorWeightOptions : CacheOptions {
   using Label = typename Arc::Label;
 
   float delta;
-  uint8 mode;          // Factor arc weights and/or final weights.
+  uint8_t mode;        // Factor arc weights and/or final weights.
   Label final_ilabel;  // Input label of arc when factoring final weights.
   Label final_olabel;  // Output label of arc when factoring final weights.
   bool increment_final_ilabel;  // When factoring final w' results in > 1 arcs
   bool increment_final_olabel;  // at state, increment labels to make distinct?
 
   explicit FactorWeightOptions(const CacheOptions &opts, float delta = kDelta,
-                               uint8 mode = kFactorArcWeights |
-                                            kFactorFinalWeights,
+                               uint8_t mode = kFactorArcWeights |
+                                              kFactorFinalWeights,
                                Label final_ilabel = 0, Label final_olabel = 0,
                                bool increment_final_ilabel = false,
                                bool increment_final_olabel = false)
@@ -64,8 +64,8 @@ struct FactorWeightOptions : CacheOptions {
         increment_final_olabel(increment_final_olabel) {}
 
   explicit FactorWeightOptions(float delta = kDelta,
-                               uint8 mode = kFactorArcWeights |
-                                            kFactorFinalWeights,
+                               uint8_t mode = kFactorArcWeights |
+                                              kFactorFinalWeights,
                                Label final_ilabel = 0, Label final_olabel = 0,
                                bool increment_final_ilabel = false,
                                bool increment_final_olabel = false)
@@ -325,10 +325,10 @@ class FactorWeightFstImpl : public CacheImpl<Arc> {
     return CacheImpl<Arc>::NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && fst_->Properties(kError, false)) {
       SetProperties(kError, kError);
     }
@@ -429,7 +429,7 @@ class FactorWeightFstImpl : public CacheImpl<Arc> {
 
   std::unique_ptr<const Fst<Arc>> fst_;
   float delta_;
-  uint8 mode_;          // Factoring arc and/or final weights.
+  uint8_t mode_;        // Factoring arc and/or final weights.
   Label final_ilabel_;  // ilabel of arc created when factoring final weights.
   Label final_olabel_;  // olabel of arc created when factoring final weights.
   bool increment_final_ilabel_;    // When factoring final weights results in
index d647664..5984bc8 100644 (file)
@@ -23,7 +23,6 @@
 #include <forward_list>
 #include <utility>
 
-#include <fst/types.h>
 
 #include <fst/fst-decl.h>  // For optional argument declarations
 #include <fst/fst.h>
index ec157ec..9c419ce 100644 (file)
@@ -1,11 +1,13 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Copyright 2005-2020 Google LLC
+//
+// 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
+//     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,
+// 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.
 //
 // Google-style flag handling declarations and inline definitions.
 
-#ifndef FST_LIB_FLAGS_H_
-#define FST_LIB_FLAGS_H_
+#ifndef FST_FLAGS_H_
+#define FST_FLAGS_H_
 
+#include <cstdint>
 #include <cstdlib>
-
 #include <iostream>
 #include <map>
 #include <set>
 #include <sstream>
 #include <string>
+#include <string_view>
+#include <utility>
 
-#include <fst/types.h>
 #include <fst/lock.h>
 
 // FLAGS USAGE:
 
 #define DECLARE_bool(name) extern bool FST_FLAGS_ ## name
 #define DECLARE_string(name) extern std::string FST_FLAGS_##name
-#define DECLARE_int32(name) extern int32 FST_FLAGS_ ## name
-#define DECLARE_int64(name) extern int64 FST_FLAGS_ ## name
-#define DECLARE_uint64(name) extern uint64 FST_FLAGS_##name
+#define DECLARE_int32(name) extern int32_t FST_FLAGS_##name
+#define DECLARE_int64(name) extern int64_t FST_FLAGS_##name
+#define DECLARE_uint64(name) extern uint64_t FST_FLAGS_##name
 #define DECLARE_double(name) extern double FST_FLAGS_ ## name
 
 template <typename T>
 struct FlagDescription {
-  FlagDescription(T *addr, const char *doc, const char *type,
-                  const char *file, const T val)
+  FlagDescription(T *addr, std::string_view doc, std::string_view type,
+                  std::string_view file, const T val)
       : address(addr),
     doc_string(doc),
     type_name(type),
@@ -64,9 +67,9 @@ struct FlagDescription {
     default_value(val) {}
 
   T *address;
-  const char *doc_string;
-  const char *type_name;
-  const char *file_name;
+  std::string_view doc_string;
+  std::string_view type_name;
+  std::string_view file_name;
   const T default_value;
 };
 
@@ -86,7 +89,7 @@ class FlagRegister {
 
   void SetDescription(const std::string &name, const FlagDescription<T> &desc) {
     fst::MutexLock l(&flag_lock_);
-    flag_table_.insert(make_pair(name, desc));
+    flag_table_.insert(std::make_pair(name, desc));
   }
 
   bool SetFlag(const std::string &val, bool *address) const {
@@ -96,8 +99,7 @@ class FlagRegister {
     } else if (val == "false" || val == "0") {
       *address = false;
       return true;
-    }
-    else {
+    } else {
       return false;
     }
   }
@@ -107,20 +109,20 @@ class FlagRegister {
     return true;
   }
 
-  bool SetFlag(const std::string &val, int32 *address) const {
+  bool SetFlag(const std::string &val, int32_t *address) const {
     char *p = nullptr;
     *address = strtol(val.c_str(), &p, 0);
     return !val.empty() && *p == '\0';
   }
 
-  bool SetFlag(const std::string &val, int64 *address) const {
+  bool SetFlag(const std::string &val, int64_t *address) const {
     char *p = nullptr;
     *address = strtoll(val.c_str(), &p, 0);
     return !val.empty() && *p == '\0';
   }
 
-  bool SetFlag(const std::string &val, uint64 *address) const {
-    char *p = 0;
+  bool SetFlag(const std::string &val, uint64_t *address) const {
+    char *p = nullptr;
     *address = strtoull(val.c_str(), &p, 0);
     return !val.empty() && *p == '\0';
   }
@@ -151,7 +153,7 @@ class FlagRegister {
       usage += ", default = ";
       usage += GetDefault(desc.default_value) + "\n  ";
       usage += desc.doc_string;
-      usage_set->insert(make_pair(desc.file_name, usage));
+      usage_set->insert(std::make_pair(std::string(desc.file_name), usage));
     }
   }
 
@@ -171,7 +173,7 @@ class FlagRegister {
     return strm.str();
   }
 
-  mutable fst::Mutex flag_lock_;        // Multithreading lock.
+  mutable fst::Mutex flag_lock_;  // Multithreading lock.
   std::map<std::string, FlagDescription<T>> flag_table_;
 };
 
@@ -201,9 +203,9 @@ class FlagRegisterer {
 #define DEFINE_bool(name, value, doc) DEFINE_VAR(bool, name, value, doc)
 #define DEFINE_string(name, value, doc) \
   DEFINE_VAR(std::string, name, value, doc)
-#define DEFINE_int32(name, value, doc) DEFINE_VAR(int32, name, value, doc)
-#define DEFINE_int64(name, value, doc) DEFINE_VAR(int64, name, value, doc)
-#define DEFINE_uint64(name, value, doc) DEFINE_VAR(uint64, name, value, doc)
+#define DEFINE_int32(name, value, doc) DEFINE_VAR(int32_t, name, value, doc)
+#define DEFINE_int64(name, value, doc) DEFINE_VAR(int64_t, name, value, doc)
+#define DEFINE_uint64(name, value, doc) DEFINE_VAR(uint64_t, name, value, doc)
 #define DEFINE_double(name, value, doc) DEFINE_VAR(double, name, value, doc)
 
 
@@ -213,7 +215,7 @@ DECLARE_string(tmpdir);
 void SetFlags(const char *usage, int *argc, char ***argv, bool remove_flags,
               const char *src = "");
 
-// This is an unpleasant hack around absl::SetFlag API.
+// This is an unpleasant hack around SetFlag API.
 template <typename Type, typename Value>
 void SetFlag(Type *flag, Value value) {
   *flag = Type(value);
@@ -229,4 +231,4 @@ inline void InitFst(const char *usage, int *argc, char ***argv, bool rmflags) {
 
 void ShowUsage(bool long_usage = true);
 
-#endif  // FST_LIB_FLAGS_H_
+#endif  // FST_FLAGS_H_
index d32ba00..38b7d48 100644 (file)
@@ -23,6 +23,7 @@
 #include <algorithm>
 #include <climits>
 #include <cmath>
+#include <cstdint>
 #include <cstring>
 #include <limits>
 #include <random>
 #include <string>
 #include <type_traits>
 
-#include <fst/types.h>
-
 #include <fst/util.h>
 #include <fst/weight.h>
 
+#include <fst/compat.h>
+#include <string_view>
 
 namespace fst {
 
+namespace internal {
+// TODO(wolfsonkin): Replace with `std::isnan` if and when that ends up
+// constexpr. For context, see
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0533r6.pdf.
+template <class T>
+inline constexpr bool IsNan(T value) {
+  return value != value;
+}
+}  // namespace internal
+
 // Numeric limits class.
 template <class T>
 class FloatLimits {
@@ -61,13 +72,6 @@ class FloatWeightTpl {
 
   constexpr FloatWeightTpl(T f) : value_(f) {}  // NOLINT
 
-  // TODO(mjansche): Leave implicit once Android NDK r18 is the default.
-  FloatWeightTpl(const FloatWeightTpl &) = default;
-  FloatWeightTpl(FloatWeightTpl &&) noexcept = default;
-
-  FloatWeightTpl &operator=(const FloatWeightTpl &) = default;
-  FloatWeightTpl &operator=(FloatWeightTpl &&) noexcept = default;
-
   std::istream &Read(std::istream &strm) { return ReadType(strm, &value_); }
 
   std::ostream &Write(std::ostream &strm) const {
@@ -89,7 +93,7 @@ class FloatWeightTpl {
  protected:
   void SetValue(const T &f) { value_ = f; }
 
-  static constexpr const char *GetPrecisionString() {
+  static constexpr std::string_view GetPrecisionString() {
     return sizeof(T) == 4
                ? ""
                : sizeof(T) == 1
@@ -166,7 +170,7 @@ inline std::ostream &operator<<(std::ostream &strm,
     return strm << "Infinity";
   } else if (w.Value() == FloatLimits<T>::NegInfinity()) {
     return strm << "-Infinity";
-  } else if (w.Value() != w.Value()) {  // Fails for IEEE NaN.
+  } else if (internal::IsNan(w.Value())) {
     return strm << "BadNumber";
   } else {
     return strm << w.Value();
@@ -216,7 +220,7 @@ class TropicalWeightTpl : public FloatWeightTpl<T> {
 
   static const std::string &Type() {
     static const std::string *const type = new std::string(
-        std::string("tropical") + FloatWeightTpl<T>::GetPrecisionString());
+        fst::StrCat("tropical", FloatWeightTpl<T>::GetPrecisionString()));
     return *type;
   }
 
@@ -251,7 +255,7 @@ class TropicalWeightTpl : public FloatWeightTpl<T> {
 
   constexpr TropicalWeightTpl<T> Reverse() const { return *this; }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kLeftSemiring | kRightSemiring | kCommutative | kPath | kIdempotent;
   }
 };
@@ -387,11 +391,11 @@ constexpr TropicalWeightTpl<double> Divide(const TropicalWeightTpl<double> &w1,
 // of Power<T, V> is made conditionally available only to that template
 // specialization.
 
-template <class T, class V, bool Enable = !std::is_same<V, size_t>::value,
-          typename std::enable_if<Enable>::type * = nullptr>
+template <class T, class V, bool Enable = !std::is_same_v<V, size_t>,
+          typename std::enable_if_t<Enable> * = nullptr>
 constexpr TropicalWeightTpl<T> Power(const TropicalWeightTpl<T> &w, V n) {
   using Weight = TropicalWeightTpl<T>;
-  return (!w.Member() || n != n)
+  return (!w.Member() || internal::IsNan(n))
              ? Weight::NoWeight()
              : (n == 0 || w == Weight::One()) ? Weight::One()
                                               : Weight(w.Value() * n);
@@ -433,7 +437,7 @@ class LogWeightTpl : public FloatWeightTpl<T> {
 
   static const std::string &Type() {
     static const std::string *const type = new std::string(
-        std::string("log") + FloatWeightTpl<T>::GetPrecisionString());
+        fst::StrCat("log", FloatWeightTpl<T>::GetPrecisionString()));
     return *type;
   }
 
@@ -452,7 +456,7 @@ class LogWeightTpl : public FloatWeightTpl<T> {
 
   constexpr LogWeightTpl<T> Reverse() const { return *this; }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kLeftSemiring | kRightSemiring | kCommutative;
   }
 };
@@ -594,11 +598,11 @@ constexpr LogWeightTpl<double> Divide(const LogWeightTpl<double> &w1,
 
 // The comments for Power<>(Tropical...) above apply here unchanged.
 
-template <class T, class V, bool Enable = !std::is_same<V, size_t>::value,
-          typename std::enable_if<Enable>::type * = nullptr>
+template <class T, class V, bool Enable = !std::is_same_v<V, size_t>,
+          typename std::enable_if_t<Enable> * = nullptr>
 constexpr LogWeightTpl<T> Power(const LogWeightTpl<T> &w, V n) {
   using Weight = LogWeightTpl<T>;
-  return (!w.Member() || n != n)
+  return (!w.Member() || internal::IsNan(n))
              ? Weight::NoWeight()
              : (n == 0 || w == Weight::One()) ? Weight::One()
                                               : Weight(w.Value() * n);
@@ -676,7 +680,7 @@ class RealWeightTpl : public FloatWeightTpl<T> {
 
   static const std::string &Type() {
     static const std::string *const type = new std::string(
-        std::string("real") + FloatWeightTpl<T>::GetPrecisionString());
+        fst::StrCat("real", FloatWeightTpl<T>::GetPrecisionString()));
     return *type;
   }
 
@@ -695,7 +699,7 @@ class RealWeightTpl : public FloatWeightTpl<T> {
 
   constexpr RealWeightTpl<T> Reverse() const { return *this; }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kLeftSemiring | kRightSemiring | kCommutative;
   }
 };
@@ -797,11 +801,11 @@ constexpr RealWeightTpl<double> Divide(const RealWeightTpl<double> &w1,
 
 // The comments for Power<>(Tropical...) above apply here unchanged.
 
-template <class T, class V, bool Enable = !std::is_same<V, size_t>::value,
-          typename std::enable_if<Enable>::type * = nullptr>
+template <class T, class V, bool Enable = !std::is_same_v<V, size_t>,
+          typename std::enable_if_t<Enable> * = nullptr>
 constexpr RealWeightTpl<T> Power(const RealWeightTpl<T> &w, V n) {
   using Weight = RealWeightTpl<T>;
-  return (!w.Member() || n != n)
+  return (!w.Member() || internal::IsNan(n))
              ? Weight::NoWeight()
              : (n == 0 || w == Weight::One()) ? Weight::One()
                                               : Weight(pow(w.Value(), n));
@@ -876,12 +880,12 @@ class MinMaxWeightTpl : public FloatWeightTpl<T> {
 
   static const std::string &Type() {
     static const std::string *const type = new std::string(
-        std::string("minmax") + FloatWeightTpl<T>::GetPrecisionString());
+        fst::StrCat("minmax", FloatWeightTpl<T>::GetPrecisionString()));
     return *type;
   }
 
   // Fails for IEEE NaN.
-  constexpr bool Member() const { return Value() == Value(); }
+  constexpr bool Member() const { return !internal::IsNan(Value()); }
 
   MinMaxWeightTpl<T> Quantize(float delta = kDelta) const {
     // If one of infinities, or a NaN.
@@ -895,7 +899,7 @@ class MinMaxWeightTpl : public FloatWeightTpl<T> {
 
   constexpr MinMaxWeightTpl<T> Reverse() const { return *this; }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kLeftSemiring | kRightSemiring | kCommutative | kIdempotent | kPath;
   }
 };
@@ -1072,7 +1076,7 @@ template <class Weight>
 class FloatWeightGenerate {
  public:
   explicit FloatWeightGenerate(
-      uint64 seed = std::random_device()(), bool allow_zero = true,
+      uint64_t seed = std::random_device()(), bool allow_zero = true,
       const size_t num_random_weights = kNumRandomWeights)
       : rand_(seed),
         allow_zero_(allow_zero),
@@ -1098,7 +1102,7 @@ class WeightGenerate<TropicalWeightTpl<T>>
   using Weight = TropicalWeightTpl<T>;
   using Generate = FloatWeightGenerate<Weight>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : Generate(seed, allow_zero, num_random_weights) {}
@@ -1113,7 +1117,7 @@ class WeightGenerate<LogWeightTpl<T>>
   using Weight = LogWeightTpl<T>;
   using Generate = FloatWeightGenerate<Weight>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : Generate(seed, allow_zero, num_random_weights) {}
@@ -1128,7 +1132,7 @@ class WeightGenerate<RealWeightTpl<T>>
   using Weight = RealWeightTpl<T>;
   using Generate = FloatWeightGenerate<Weight>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : Generate(seed, allow_zero, num_random_weights) {}
@@ -1145,7 +1149,7 @@ class WeightGenerate<MinMaxWeightTpl<T>> {
  public:
   using Weight = MinMaxWeightTpl<T>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : rand_(seed),
index 14f1ab2..0a0f679 100644 (file)
@@ -22,9 +22,9 @@
 
 #include <sys/types.h>
 
+#include <cstdint>
 #include <memory>  // for allocator<>
 
-#include <fst/types.h>
 #include <fst/windows_defs.inc>
 
 namespace fst {
@@ -85,7 +85,7 @@ template <class Arc, class Compactor, class CacheStore = DefaultCacheStore<Arc>>
 class CompactFst;
 
 // The Unsigned type is used to represent indices into the compact arc array.
-template <class Arc, class ArcCompactor, class Unsigned = uint32,
+template <class Arc, class ArcCompactor, class Unsigned = uint32_t,
           class CompactStore =
               CompactArcStore<typename ArcCompactor::Element, Unsigned>,
           class CacheStore = DefaultCacheStore<Arc>>
@@ -93,7 +93,7 @@ using CompactArcFst =
     CompactFst<Arc, CompactArcCompactor<ArcCompactor, Unsigned, CompactStore>,
                CacheStore>;
 
-template <class Arc, class U = uint32>
+template <class Arc, class U = uint32_t>
 class ConstFst;
 
 template <class Arc, class Weight, class Matcher>
@@ -189,20 +189,20 @@ class WeightedStringCompactor;
 
 // Compact Arc FSTs.
 
-template <class Arc, class U = uint32>
+template <class Arc, class U = uint32_t>
 using CompactStringFst = CompactArcFst<Arc, StringCompactor<Arc>, U>;
 
-template <class Arc, class U = uint32>
+template <class Arc, class U = uint32_t>
 using CompactWeightedStringFst =
     CompactArcFst<Arc, WeightedStringCompactor<Arc>, U>;
 
-template <class Arc, class U = uint32>
+template <class Arc, class U = uint32_t>
 using CompactAcceptorFst = CompactArcFst<Arc, AcceptorCompactor<Arc>, U>;
 
-template <class Arc, class U = uint32>
+template <class Arc, class U = uint32_t>
 using CompactUnweightedFst = CompactArcFst<Arc, UnweightedCompactor<Arc>, U>;
 
-template <class Arc, class U = uint32>
+template <class Arc, class U = uint32_t>
 using CompactUnweightedAcceptorFst =
     CompactArcFst<Arc, UnweightedAcceptorCompactor<Arc>, U>;
 
index a207329..80d1150 100644 (file)
@@ -26,6 +26,7 @@
 #include <atomic>
 #include <cmath>
 #include <cstddef>
+#include <cstdint>
 #include <iostream>
 #include <memory>
 #include <sstream>
@@ -34,7 +35,6 @@
 
 #include <fst/compat.h>
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fstream>
 
@@ -52,7 +52,7 @@ DECLARE_bool(fst_align);
 namespace fst {
 
 // Identifies stream data as an FST (and its endianity).
-constexpr int32 kFstMagicNumber = 2125659606;
+inline constexpr int32_t kFstMagicNumber = 2125659606;
 
 class FstHeader;
 
@@ -92,7 +92,7 @@ struct FstReadOptions {
                           const SymbolTable *osymbols = nullptr);
 
   // Helper function to convert strings FileReadModes into their enum value.
-  static FileReadMode ReadMode(const std::string &mode);
+  static FileReadMode ReadMode(std::string_view mode);
 
   // Outputs a debug string for the FstReadOptions object.
   std::string DebugString() const;
@@ -143,33 +143,33 @@ class FstHeader {
 
   const std::string &ArcType() const { return arctype_; }
 
-  int32 Version() const { return version_; }
+  int32_t Version() const { return version_; }
 
-  uint32 GetFlags() const { return flags_; }
+  uint32_t GetFlags() const { return flags_; }
 
-  uint64 Properties() const { return properties_; }
+  uint64_t Properties() const { return properties_; }
 
-  int64 Start() const { return start_; }
+  int64_t Start() const { return start_; }
 
-  int64 NumStates() const { return numstates_; }
+  int64_t NumStates() const { return numstates_; }
 
-  int64 NumArcs() const { return numarcs_; }
+  int64_t NumArcs() const { return numarcs_; }
 
-  void SetFstType(const std::string &type) { fsttype_ = type; }
+  void SetFstType(std::string_view type) { fsttype_ = std::string(type); }
 
-  void SetArcType(const std::string &type) { arctype_ = type; }
+  void SetArcType(std::string_view type) { arctype_ = std::string(type); }
 
-  void SetVersion(int32 version) { version_ = version; }
+  void SetVersion(int32_t version) { version_ = version; }
 
-  void SetFlags(uint32 flags) { flags_ = flags; }
+  void SetFlags(uint32_t flags) { flags_ = flags; }
 
-  void SetProperties(uint64 properties) { properties_ = properties; }
+  void SetProperties(uint64_t properties) { properties_ = properties; }
 
-  void SetStart(int64 start) { start_ = start; }
+  void SetStart(int64_t start) { start_ = start; }
 
-  void SetNumStates(int64 numstates) { numstates_ = numstates; }
+  void SetNumStates(int64_t numstates) { numstates_ = numstates; }
 
-  void SetNumArcs(int64 numarcs) { numarcs_ = numarcs; }
+  void SetNumArcs(int64_t numarcs) { numarcs_ = numarcs; }
 
   bool Read(std::istream &strm, const std::string &source, bool rewind = false);
 
@@ -181,12 +181,12 @@ class FstHeader {
  private:
   std::string fsttype_;  // E.g. "vector".
   std::string arctype_;  // E.g. "standard".
-  int32 version_;        // Type version number.
-  uint32 flags_;         // File format bits.
-  uint64 properties_;    // FST property bits.
-  int64 start_;          // Start state.
-  int64 numstates_;      // # of states.
-  int64 numarcs_;        // # of arcs.
+  int32_t version_;      // Type version number.
+  uint32_t flags_;       // File format bits.
+  uint64_t properties_;  // FST property bits.
+  int64_t start_;        // Start state.
+  int64_t numstates_;    // # of states.
+  int64_t numarcs_;      // # of arcs.
 };
 
 // Specifies matcher action.
@@ -198,8 +198,8 @@ enum MatchType {
   MATCH_UNKNOWN = 5
 };  // Otherwise, match type unknown.
 
-constexpr int kNoLabel = -1;    // Not a valid label.
-constexpr int kNoStateId = -1;  // Not a valid state ID.
+inline constexpr int kNoLabel = -1;    // Not a valid label.
+inline constexpr int kNoStateId = -1;  // Not a valid state ID.
 
 // A generic FST, templated on the arc definition, with common-demoninator
 // methods (use StateIterator and ArcIterator to iterate over its states and
@@ -232,7 +232,7 @@ class Fst {
   // Property bits. If test = false, return stored properties bits for mask
   // (some possibly unknown); if test = true, return property bits for mask
   // (computing o.w. unknown).
-  virtual uint64 Properties(uint64 mask, bool test) const = 0;
+  virtual uint64_t Properties(uint64_t mask, bool test) const = 0;
 
   // FST type name.
   virtual const std::string &Type() const = 0;
@@ -441,18 +441,18 @@ class StateIterator {
 
 // Flags to control the behavior on an arc iterator via SetFlags().
 // Value() gives valid ilabel.
-static constexpr uint8 kArcILabelValue = 0x01;
+inline constexpr uint8_t kArcILabelValue = 0x01;
 // Value() call gives valid olabel.
-static constexpr uint8 kArcOLabelValue = 0x02;
+inline constexpr uint8_t kArcOLabelValue = 0x02;
 // Value() call gives valid weight.
-static constexpr uint8 kArcWeightValue = 0x04;
+inline constexpr uint8_t kArcWeightValue = 0x04;
 // Value() call gives valid nextstate.
-static constexpr uint8 kArcNextStateValue = 0x08;
+inline constexpr uint8_t kArcNextStateValue = 0x08;
 // Arcs need not be cached.
-static constexpr uint8 kArcNoCache = 0x10;
-static constexpr uint8 kArcValueFlags =
+inline constexpr uint8_t kArcNoCache = 0x10;
+inline constexpr uint8_t kArcValueFlags =
     kArcILabelValue | kArcOLabelValue | kArcWeightValue | kArcNextStateValue;
-static constexpr uint8 kArcFlags = kArcValueFlags | kArcNoCache;
+inline constexpr uint8_t kArcFlags = kArcValueFlags | kArcNoCache;
 
 // Arc iterator interface, templated on the arc definition; used for arc
 // iterator specializations that are returned by the InitArcIterator FST method.
@@ -476,9 +476,9 @@ class ArcIteratorBase {
   // Advances to arbitrary arc by position.
   virtual void Seek(size_t) = 0;
   // Returns current behavorial flags, a bitmask of kArcFlags.
-  virtual uint8 Flags() const = 0;
+  virtual uint8_t Flags() const = 0;
   // Sets behavorial flags, a bitmask of kArcFlags.
-  virtual void SetFlags(uint8, uint8) = 0;
+  virtual void SetFlags(uint8_t, uint8_t) = 0;
 };
 
 // ArcIterator initialization data.
@@ -564,11 +564,11 @@ class ArcIterator {
 
   size_t Position() const { return data_.base ? data_.base->Position() : i_; }
 
-  uint8 Flags() const {
+  uint8_t Flags() const {
     return data_.base ? data_.base->Flags() : kArcValueFlags;
   }
 
-  void SetFlags(uint8 flags, uint8 mask) {
+  void SetFlags(uint8_t flags, uint8_t mask) {
     if (data_.base) data_.base->SetFlags(flags, mask);
   }
 
@@ -697,35 +697,35 @@ class FstImpl {
 
   const std::string &Type() const { return type_; }
 
-  void SetType(const std::string &type) { type_ = type; }
+  void SetType(std::string_view type) { type_ = std::string(type); }
 
-  virtual uint64 Properties() const {
+  virtual uint64_t Properties() const {
     return properties_.load(std::memory_order_relaxed);
   }
 
-  virtual uint64 Properties(uint64 mask) const {
+  virtual uint64_t Properties(uint64_t mask) const {
     return properties_.load(std::memory_order_relaxed) & mask;
   }
 
-  void SetProperties(uint64 props) {
-    uint64 properties = properties_.load(std::memory_order_relaxed);
+  void SetProperties(uint64_t props) {
+    uint64_t properties = properties_.load(std::memory_order_relaxed);
     properties &= kError;  // kError can't be cleared.
     properties |= props;
     properties_.store(properties, std::memory_order_relaxed);
   }
 
-  void SetProperties(uint64 props, uint64 mask) {
+  void SetProperties(uint64_t props, uint64_t mask) {
     // Unlike UpdateProperties, does not require compatibility between props
     // and properties_, since it may be used to update properties after
     // a mutation.
-    uint64 properties = properties_.load(std::memory_order_relaxed);
+    uint64_t properties = properties_.load(std::memory_order_relaxed);
     properties &= ~mask | kError;  // kError can't be cleared.
     properties |= props & mask;
     properties_.store(properties, std::memory_order_relaxed);
   }
 
   // Allows (only) setting error bit on const FST implementations.
-  void SetProperties(uint64 props, uint64 mask) const {
+  void SetProperties(uint64_t props, uint64_t mask) const {
     if (mask != kError) {
       FSTERROR() << "FstImpl::SetProperties() const: Can only set kError";
     }
@@ -734,7 +734,7 @@ class FstImpl {
 
   // Sets the subset of the properties that have changed, in a thread-safe
   // manner via atomic bitwise-or..
-  void UpdateProperties(uint64 props, uint64 mask) {
+  void UpdateProperties(uint64_t props, uint64_t mask) {
     // If properties_ and props are compatible (for example kAcceptor and
     // kNoAcceptor cannot both be set), the props can be or-ed in.
     // Compatibility is ensured if props comes from ComputeProperties
@@ -744,12 +744,12 @@ class FstImpl {
     // Therefore, we or in only the newly discovered properties.
     // These cannot become inconsistent, but this means that
     // incorrectly set properties will remain incorrect.
-    const uint64 properties = properties_.load(std::memory_order_relaxed);
+    const uint64_t properties = properties_.load(std::memory_order_relaxed);
     DCHECK(internal::CompatProperties(properties, props));
-    const uint64 old_props = properties & mask;
-    const uint64 old_mask = internal::KnownProperties(old_props);
-    const uint64 discovered_mask = mask & ~old_mask;
-    const uint64 discovered_props = props & discovered_mask;
+    const uint64_t old_props = properties & mask;
+    const uint64_t old_mask = internal::KnownProperties(old_props);
+    const uint64_t discovered_mask = mask & ~old_mask;
+    const uint64_t discovered_props = props & discovered_mask;
     // It is always correct to or these bits in, but do this only when
     // necessary to avoid extra stores and possible cache flushes.
     if (discovered_props != 0) {
@@ -790,7 +790,7 @@ class FstImpl {
       hdr->SetArcType(Arc::Type());
       hdr->SetVersion(version);
       hdr->SetProperties(properties_.load(std::memory_order_relaxed));
-      int32 file_flags = 0;
+      int32_t file_flags = 0;
       if (isymbols_ && opts.write_isymbols) {
         file_flags |= FstHeader::HAS_ISYMBOLS;
       }
@@ -811,14 +811,14 @@ class FstImpl {
   // cross-type serialization methods Fst::WriteFst.
   static void WriteFstHeader(const Fst<Arc> &fst, std::ostream &strm,
                              const FstWriteOptions &opts, int version,
-                             const std::string &type, uint64 properties,
+                             std::string_view type, uint64_t properties,
                              FstHeader *hdr) {
     if (opts.write_header) {
       hdr->SetFstType(type);
       hdr->SetArcType(Arc::Type());
       hdr->SetVersion(version);
       hdr->SetProperties(properties);
-      int32 file_flags = 0;
+      int32_t file_flags = 0;
       if (fst.InputSymbols() && opts.write_isymbols) {
         file_flags |= FstHeader::HAS_ISYMBOLS;
       }
@@ -844,7 +844,7 @@ class FstImpl {
   // success, false on failure.
   static bool UpdateFstHeader(const Fst<Arc> &fst, std::ostream &strm,
                               const FstWriteOptions &opts, int version,
-                              const std::string &type, uint64 properties,
+                              std::string_view type, uint64_t properties,
                               FstHeader *hdr, size_t header_offset) {
     strm.seekp(header_offset);
     if (!strm) {
@@ -868,7 +868,7 @@ class FstImpl {
   // Use atomic so that UpdateProperties() can be thread-safe.
   // This is always used with memory_order_relaxed because it's only used
   // as a cache and not used to synchronize other operations.
-  mutable std::atomic<uint64> properties_;  // Property bits.
+  mutable std::atomic<uint64_t> properties_;  // Property bits.
 
  private:
   std::string type_;  // Unique name of FST class.
@@ -931,7 +931,7 @@ bool FstImpl<Arc>::ReadHeader(std::istream &strm, const FstReadOptions &opts,
 }
 
 template <class Arc>
-uint64 TestProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known);
+uint64_t TestProperties(const Fst<Arc> &fst, uint64_t mask, uint64_t *known);
 
 }  // namespace internal
 
@@ -963,9 +963,9 @@ class ImplToFst : public FST {
 
   // Note that this is a const function, but can set the Impl's properties
   // when test is true.
-  uint64 Properties(uint64 mask, bool test) const override {
+  uint64_t Properties(uint64_t mask, bool test) const override {
     if (test) {
-      uint64 knownprops,
+      uint64_t knownprops,
           testprops = internal::TestProperties(*this, mask, &knownprops);
       // Properties is a const member function, but can set the cached
       // properties. UpdateProperties does this thread-safely via atomics.
index f2db008..820719e 100644 (file)
@@ -67,7 +67,6 @@
 #include <fst/intersect.h>
 #include <fst/invert.h>
 #include <fst/isomorphic.h>
-#include <fst/map.h>
 #include <fst/minimize.h>
 #include <fst/project.h>
 #include <fst/prune.h>
index 49e4224..765ebce 100644 (file)
 #ifndef FST_GENERIC_REGISTER_H_
 #define FST_GENERIC_REGISTER_H_
 
+#include <functional>
+
 #include <fst/compat.h>
+#include <string_view>
+#include <fst/lock.h>
 #ifndef FST_NO_DYNAMIC_LINKING
 #include <dlfcn.h>
 #endif
@@ -33,8 +37,6 @@
 // KeyType must:
 //
 // * be such as can be stored as a key in a std::map<>.
-// * be concatenable with a const char* with the + operator
-//   (or you must subclass and redefine LoadEntryFromSharedObject)
 //
 // EntryType must be default constructible.
 //
 
 namespace fst {
 
+namespace internal {
+template <class T>
+struct KeyLookupReferenceType {
+  using type = const T &;
+};
+
+template <>
+struct KeyLookupReferenceType<std::string> {
+  using type = std::string_view;
+};
+}  // namespace internal
+
 template <class KeyType, class EntryType, class RegisterType>
 class GenericRegister {
  public:
   using Key = KeyType;
+  using KeyLookupRef = typename internal::KeyLookupReferenceType<KeyType>::type;
   using Entry = EntryType;
 
   static RegisterType *GetRegister() {
@@ -60,7 +75,7 @@ class GenericRegister {
     register_table_.emplace(key, entry);
   }
 
-  EntryType GetEntry(const KeyType &key) const {
+  EntryType GetEntry(KeyLookupRef key) const {
     const auto *entry = LookupEntry(key);
     if (entry) {
       return *entry;
@@ -74,7 +89,7 @@ class GenericRegister {
  protected:
   // Override this if you want to be able to load missing definitions from
   // shared object files.
-  virtual EntryType LoadEntryFromSharedObject(const KeyType &key) const {
+  virtual EntryType LoadEntryFromSharedObject(KeyLookupRef key) const {
 #ifdef FST_NO_DYNAMIC_LINKING
     return EntryType();
 #else
@@ -101,9 +116,9 @@ class GenericRegister {
   }
 
   // Override this to define how to turn a key into an SO filename.
-  virtual std::string ConvertKeyToSoFilename(const KeyType &key) const = 0;
+  virtual std::string ConvertKeyToSoFilename(KeyLookupRef key) const = 0;
 
-  virtual const EntryType *LookupEntry(const KeyType &key) const {
+  virtual const EntryType *LookupEntry(KeyLookupRef key) const {
     MutexLock l(&register_lock_);
     const auto it = register_table_.find(key);
     if (it != register_table_.end()) {
@@ -115,7 +130,7 @@ class GenericRegister {
 
  private:
   mutable Mutex register_lock_;
-  std::map<KeyType, EntryType> register_table_;
+  std::map<KeyType, EntryType, std::less<>> register_table_;
 };
 
 // Generic register-er class capable of creating new register entries in the
index 73ffb6c..19dfc9d 100644 (file)
@@ -26,6 +26,8 @@
 #include <vector>
 
 #include <fst/compat.h>
+#include <fst/log.h>
+
 namespace fst {
 
 // A templated heap implementation that supports in-place update of values.
@@ -81,6 +83,7 @@ class Heap {
 
   // Returns the least value.
   Value Pop() {
+    DCHECK(!Empty());
     Value top = values_.front();
     Swap(0, size_ - 1);
     size_--;
@@ -90,10 +93,16 @@ class Heap {
 
   // Returns the least value w.r.t. the comparison function from the
   // heap.
-  const Value &Top() const { return values_.front(); }
+  const Value &Top() const {
+    DCHECK(!Empty());
+    return values_.front();
+  }
 
   // Returns the element for the given key.
-  const Value &Get(int key) const { return values_[pos_[key]]; }
+  const Value &Get(int key) const {
+    DCHECK_LT(key, pos_.size());
+    return values_[pos_[key]];
+  }
 
   // Checks if the heap is empty.
   bool Empty() const { return size_ == 0; }
@@ -174,9 +183,6 @@ class Heap {
   int size_;
 };
 
-template <class T, class Compare>
-constexpr int Heap<T, Compare>::kNoKey;
-
 }  // namespace fst
 
 #endif  // FST_HEAP_H_
index e2fe907..925855e 100644 (file)
 #ifndef FST_ICU_H_
 #define FST_ICU_H_
 
+#include <cstdint>
 #include <sstream>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
+#include <string_view>
 
 namespace fst {
 
@@ -36,7 +37,7 @@ namespace fst {
 // if necessary. It is possible to use this sensibly with as little as 8 bits
 // of Label precision. This returns `true` deterministically for compatibility.
 template <class Label>
-bool ByteStringToLabels(const std::string &str, std::vector<Label> *labels) {
+bool ByteStringToLabels(std::string_view str, std::vector<Label> *labels) {
   for (const unsigned char ch : str) labels->push_back(ch);
   return true;
 }
@@ -48,7 +49,7 @@ bool ByteStringToLabels(const std::string &str, std::vector<Label> *labels) {
 // from the various Astral Planes. Naturally, it is safe to use this with larger
 // Labels (e.g., 64 bits).
 template <class Label>
-bool UTF8StringToLabels(const std::string &str, std::vector<Label> *labels) {
+bool UTF8StringToLabels(std::string_view str, std::vector<Label> *labels) {
   for (auto it = str.begin(); it != str.end();) {
     int c = *it & 0xff;
     ++it;
@@ -61,7 +62,7 @@ bool UTF8StringToLabels(const std::string &str, std::vector<Label> *labels) {
       }
       int count =
           (c >= 0xc0) + (c >= 0xe0) + (c >= 0xf0) + (c >= 0xf8) + (c >= 0xfc);
-      int32 label = c & ((1 << (6 - count)) - 1);
+      int32_t label = c & ((1 << (6 - count)) - 1);
       while (count != 0) {
         if (it == str.end()) {
           LOG(ERROR) << "UTF8StringToLabels: Truncated UTF-8 byte sequence";
@@ -100,7 +101,7 @@ bool LabelsToByteString(const std::vector<Label> &labels, std::string *str) {
 template <class Label>
 bool LabelsToUTF8String(const std::vector<Label> &labels, std::string *str) {
   std::ostringstream ostrm;
-  for (const int32 label : labels) {
+  for (const int32_t label : labels) {
     if (label < 0) {
       LOG(ERROR) << "LabelsToUTF8String: Invalid character found: " << label;
       return false;
index b306b0f..b4eb2db 100644 (file)
@@ -286,13 +286,13 @@ void IntervalSet<T, Store>::Complement(T maxval,
   T count = 0;
   Interval interval;
   interval.begin = 0;
-  for (auto it = intervals_.begin(); it != intervals_.end(); ++it) {
-    interval.end = std::min(it->begin, maxval);
+  for (const auto current_interval : intervals_) {
+    interval.end = std::min(current_interval.begin, maxval);
     if ((interval.begin) < (interval.end)) {
       ointervals->push_back(interval);
       count += interval.end - interval.begin;
     }
-    interval.begin = it->end;
+    interval.begin = current_interval.end;
   }
   interval.end = maxval;
   if ((interval.begin) < (interval.end)) {
index 105e7c7..a6d87ff 100644 (file)
@@ -20,7 +20,8 @@
 #ifndef FST_INVERT_H_
 #define FST_INVERT_H_
 
-#include <fst/types.h>
+#include <cstdint>
+
 
 #include <fst/arc-map.h>
 #include <fst/mutable-fst.h>
@@ -50,7 +51,7 @@ struct InvertMapper {
     return MAP_CLEAR_SYMBOLS;
   }
 
-  uint64 Properties(uint64 props) const { return InvertProperties(props); }
+  uint64_t Properties(uint64_t props) const { return InvertProperties(props); }
 };
 
 // Inverts the transduction corresponding to an FST by exchanging the
@@ -104,8 +105,7 @@ class InvertFst : public ArcMapFst<A, A, InvertMapper<A>> {
   using Mapper = InvertMapper<Arc>;
   using Impl = internal::ArcMapFstImpl<A, A, InvertMapper<A>>;
 
-  explicit InvertFst(const Fst<Arc> &fst)
-      : ArcMapFst<Arc, Arc, Mapper>(fst, Mapper()) {
+  explicit InvertFst(const Fst<Arc> &fst) : ArcMapFst<Arc, Arc, Mapper>(fst) {
     GetMutableImpl()->SetOutputSymbols(fst.InputSymbols());
     GetMutableImpl()->SetInputSymbols(fst.OutputSymbols());
   }
index 8b94d9c..2edae3b 100644 (file)
@@ -37,15 +37,15 @@ namespace fst {
 namespace internal {
 
 // Orders weights for equality checking; delta is ignored.
-template <class Weight, typename std::enable_if<
-                            IsIdempotent<Weight>::value>::type * = nullptr>
+template <class Weight,
+          typename std::enable_if_t<IsIdempotent<Weight>::value> * = nullptr>
 bool WeightCompare(const Weight &w1, const Weight &w2, float, bool *) {
   static const NaturalLess<Weight> less;
   return less(w1, w2);
 }
 
-template <class Weight, typename std::enable_if<
-                            !IsIdempotent<Weight>::value>::type * = nullptr>
+template <class Weight,
+          typename std::enable_if_t<!IsIdempotent<Weight>::value> * = nullptr>
 bool WeightCompare(const Weight &w1, const Weight &w2, float delta,
                    bool *error) {
   // No natural order; use hash.
@@ -85,11 +85,11 @@ class Isomorphism {
     }
     PairState(fst1_->Start(), fst2_->Start());
     while (!queue_.empty()) {
-      const auto &pr = queue_.front();
-      if (!IsIsomorphicState(pr.first, pr.second)) {
+      const auto &[state1, state2] = queue_.front();
+      if (!IsIsomorphicState(state1, state2)) {
         if (nondet_) {
           VLOG(1) << "Isomorphic: Non-determinism as an unweighted automaton. "
-                  << "state1: " << pr.first << " state2: " << pr.second;
+                  << "state1: " << state1 << " state2: " << state2;
           error_ = true;
         }
         return false;
index 5b09666..267e75a 100644 (file)
@@ -25,7 +25,6 @@
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/accumulator.h>
@@ -147,6 +146,60 @@ bool StateSort(LabelReachableData<Label> *data,
   return StateSort(data->MutableIntervalSets(), order);
 }
 
+// Functor to find the LowerBound of a Label using an ArcIterator.
+// Used by LabelReachable.  Other, more efficient implementations of
+// this interface specialized to certain FST types may be used instead.
+template <class Arc>
+class LabelLowerBound {
+ public:
+  using Label = typename Arc::Label;
+  using StateId = typename Arc::StateId;
+
+  // Initializes with the FST that will later supply the ArcIterator for
+  // `operator()`.  `reach_input` specified whether `operator()` will search
+  // input or output labels.  If `is_copy == true`, then `fst` is a copy
+  // of the one previously passed to `Init`, so any expensive initialization
+  // can be skipped.
+  template <class FST>
+  void Init(const FST &fst, bool reach_input, bool is_copy) {
+    reach_input_ = reach_input;
+  }
+
+  // Sets state that will be searched by `operator()`.
+  void SetState(StateId aiter_s) {}
+
+  // Positions `aiter` at the first Arc with `label >= match_label` in the
+  // half-open interval `[aiter_begin, aiter_end)`.  Returns the position
+  // of `aiter`.  `aiter` must be an iterator of the FST that was passed to
+  // `Init`.
+  template <class ArcIterator>
+  ssize_t operator()(ArcIterator *aiter, ssize_t aiter_begin, ssize_t aiter_end,
+                     Label match_label) const {
+    // Only needs to compute the ilabel or olabel of arcs when performing the
+    // binary search.
+    aiter->SetFlags(reach_input_ ? kArcILabelValue : kArcOLabelValue,
+                    kArcValueFlags);
+    ssize_t low = aiter_begin;
+    ssize_t high = aiter_end;
+    while (low < high) {
+      const ssize_t mid = low + (high - low) / 2;
+      aiter->Seek(mid);
+      auto label = reach_input_ ? aiter->Value().ilabel : aiter->Value().olabel;
+      if (label < match_label) {
+        low = mid + 1;
+      } else {
+        high = mid;
+      }
+    }
+    aiter->Seek(low);
+    aiter->SetFlags(kArcValueFlags, kArcValueFlags);
+    return low;
+  }
+
+ private:
+  bool reach_input_ = false;
+};
+
 // Tests reachability of labels from a given state. If reach_input is true, then
 // input labels are considered, o.w. output labels are considered. To test for
 // reachability from a state s, first do SetState(s), then a label l can be
@@ -176,13 +229,15 @@ bool StateSort(LabelReachableData<Label> *data,
 // default uses semiring Plus(). Alternative ones can be used to distribute the
 // weights in composition in various ways.
 template <class Arc, class Accumulator = DefaultAccumulator<Arc>,
-          class D = LabelReachableData<typename Arc::Label>>
+          class D = LabelReachableData<typename Arc::Label>,
+          class LB = LabelLowerBound<Arc>>
 class LabelReachable {
  public:
   using Label = typename Arc::Label;
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
   using Data = D;
+  using LowerBound = LB;
 
   using LabelIntervalSet = typename Data::LabelIntervalSet;
 
@@ -195,11 +250,7 @@ class LabelReachable {
         s_(kNoStateId),
         data_(std::make_shared<Data>(reach_input, keep_relabel_data)),
         accumulator_(accumulator ? std::move(accumulator)
-                                 : std::make_unique<Accumulator>()),
-        ncalls_(0),
-        nintervals_(0),
-        reach_fst_input_(false),
-        error_(false) {
+                                 : std::make_unique<Accumulator>()) {
     const auto ins = fst_->NumStates();
     TransformFst();
     FindIntervals(ins);
@@ -211,20 +262,14 @@ class LabelReachable {
       : s_(kNoStateId),
         data_(std::move(data)),
         accumulator_(accumulator ? std::move(accumulator)
-                                 : std::make_unique<Accumulator>()),
-        ncalls_(0),
-        nintervals_(0),
-        reach_fst_input_(false),
-        error_(false) {}
-
-  LabelReachable(const LabelReachable<Arc, Accumulator, Data> &reachable,
-                 bool safe = false)
+                                 : std::make_unique<Accumulator>()) {}
+
+  LabelReachable(const LabelReachable &reachable, bool safe = false)
       : s_(kNoStateId),
         data_(reachable.data_),
         accumulator_(
             std::make_unique<Accumulator>(*reachable.accumulator_, safe)),
-        ncalls_(0),
-        nintervals_(0),
+        lower_bound_(reachable.lower_bound_),
         reach_fst_input_(reachable.reach_fst_input_),
         error_(reachable.error_) {}
 
@@ -310,6 +355,7 @@ class LabelReachable {
     if (aiter_s != kNoStateId) {
       accumulator_->SetState(aiter_s);
       if (accumulator_->Error()) error_ = true;
+      lower_bound_.SetState(aiter_s);
     }
   }
 
@@ -341,6 +387,7 @@ class LabelReachable {
     }
     accumulator_->Init(fst, copy);
     if (accumulator_->Error()) error_ = true;
+    lower_bound_.Init(fst, /*reach_input=*/reach_input, /*is_copy=*/copy);
   }
 
   // Can reach any arc iterator label between iterator positions
@@ -400,8 +447,8 @@ class LabelReachable {
       auto begin_low = aiter_begin;
       auto end_low = aiter_begin;
       for (const auto &interval : interval_set) {
-        begin_low = LowerBound(aiter, end_low, aiter_end, interval.begin);
-        end_low = LowerBound(aiter, begin_low, aiter_end, interval.end);
+        begin_low = lower_bound_(aiter, end_low, aiter_end, interval.begin);
+        end_low = lower_bound_(aiter, begin_low, aiter_end, interval.end);
         if (end_low - begin_low > 0) {
           if (reach_begin_ < 0) reach_begin_ = begin_low;
           reach_end_ = end_low;
@@ -429,7 +476,7 @@ class LabelReachable {
 
   // Access to the relabeling map. Excludes epsilon (0) label but
   // includes kNoLabel that is used internally for super-final
-  // transitons.
+  // transitions.
   const std::unordered_map<Label, Label> &Label2Index() const {
     return *data_->Label2Index();
   }
@@ -457,8 +504,8 @@ class LabelReachable {
         auto arc = aiter.Value();
         const auto label = data_->ReachInput() ? arc.ilabel : arc.olabel;
         if (label) {
-          auto insert_result = label2state_.emplace(label, ons);
-          if (insert_result.second) {
+          if (auto insert_result = label2state_.emplace(label, ons);
+              insert_result.second) {
             indeg.push_back(0);
             ++ons;
           }
@@ -470,8 +517,8 @@ class LabelReachable {
       // Redirects final weights to new final state.
       auto final_weight = fst_->Final(s);
       if (final_weight != Weight::Zero()) {
-        auto insert_result = label2state_.emplace(kNoLabel, ons);
-        if (insert_result.second) {
+        if (auto insert_result = label2state_.emplace(kNoLabel, ons);
+            insert_result.second) {
           indeg.push_back(0);
           ++ons;
         }
@@ -528,31 +575,6 @@ class LabelReachable {
     VLOG(2) << "# of non-interval states: " << non_intervals;
   }
 
-  template <class Iterator>
-  ssize_t LowerBound(Iterator *aiter, ssize_t aiter_begin, ssize_t aiter_end,
-                     Label match_label) const {
-    // Only needs to compute the ilabel or olabel of arcs when performing the
-    // binary search.
-    aiter->SetFlags(reach_fst_input_ ? kArcILabelValue : kArcOLabelValue,
-                    kArcValueFlags);
-    ssize_t low = aiter_begin;
-    ssize_t high = aiter_end;
-    while (low < high) {
-      const ssize_t mid = low + (high - low) / 2;
-      aiter->Seek(mid);
-      auto label =
-          reach_fst_input_ ? aiter->Value().ilabel : aiter->Value().olabel;
-      if (label < match_label) {
-        low = mid + 1;
-      } else {
-        high = mid;
-      }
-    }
-    aiter->Seek(low);
-    aiter->SetFlags(kArcValueFlags, kArcValueFlags);
-    return low;
-  }
-
   std::unique_ptr<VectorFst<Arc>> fst_;
   // Current state
   StateId s_;
@@ -568,12 +590,14 @@ class LabelReachable {
   std::shared_ptr<Data> data_;
   // Sums arc weights.
   std::unique_ptr<Accumulator> accumulator_;
+  // Functor for computing LowerBound(Iterator*, begin, end, label).
+  LowerBound lower_bound_;
   // Relabeling map for OOV labels.
   std::unordered_map<Label, Label> oov_label2index_;
-  double ncalls_;
-  double nintervals_;
-  bool reach_fst_input_;
-  bool error_;
+  double ncalls_ = 0;
+  double nintervals_ = 0;
+  bool reach_fst_input_ = false;
+  bool error_ = false;
 };
 
 }  // namespace fst
index ed5750c..4bacffb 100644 (file)
 #ifndef FST_LEXICOGRAPHIC_WEIGHT_H_
 #define FST_LEXICOGRAPHIC_WEIGHT_H_
 
+#include <cstdint>
 #include <random>
 #include <string>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/pair-weight.h>
@@ -102,7 +102,7 @@ class LexicographicWeight : public PairWeight<W1, W2> {
     return ReverseWeight(PairWeight<W1, W2>::Reverse());
   }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return W1::Properties() & W2::Properties() &
            (kLeftSemiring | kRightSemiring | kPath | kIdempotent |
             kCommutative);
@@ -151,7 +151,7 @@ class WeightGenerate<LexicographicWeight<W1, W2>> {
   using Generate1 = WeightGenerate<W1>;
   using Generate2 = WeightGenerate<W2>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : rand_(seed),
index 2a3f9ea..aeb36e6 100644 (file)
@@ -1,11 +1,13 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Copyright 2005-2020 Google LLC
+//
+// 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
+//     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,
+// 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.
 //
 // Google-compatibility locking declarations and inline definitions.
 
-#ifndef FST_LIB_LOCK_H_
-#define FST_LIB_LOCK_H_
+#ifndef FST_LOCK_H_
+#define FST_LOCK_H_
 
 #ifdef OPENFST_HAS_ABSL
 
-#include "absl/synchronization/mutex.h"
-
 namespace fst {
 
-using absl::Mutex;
-using absl::MutexLock;
-using absl::ReaderMutexLock;
+using Mutex;
+using MutexLock;
+using ReaderMutexLock;
 
 }  // namespace fst
 
 #else  // OPENFST_HAS_ABSL
 
-#include <mutex>
+#include <shared_mutex>  // NOLINT(build/c++14)
 
 namespace fst {
 
@@ -41,11 +41,13 @@ class Mutex {
   Mutex() {}
 
   inline void Lock() { mu_.lock(); }
-
   inline void Unlock() { mu_.unlock(); }
 
+  inline void ReaderLock() { mu_.lock_shared(); }
+  inline void ReaderUnlock() { mu_.unlock_shared(); }
+
  private:
-  std::mutex mu_;
+  std::shared_mutex mu_;
 
   Mutex(const Mutex &) = delete;
   Mutex &operator=(const Mutex &) = delete;
@@ -54,23 +56,29 @@ class Mutex {
 class MutexLock {
  public:
   explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
-
   ~MutexLock() { mu_->Unlock(); }
 
  private:
-  Mutex *mu_;
+  Mutex *const mu_;
 
   MutexLock(const MutexLock &) = delete;
   MutexLock &operator=(const MutexLock &) = delete;
 };
 
-// Currently, we don't use a separate reader lock.
-// TODO(kbg): Implement this with std::shared_mutex once C++17 becomes widely
-// available.
-using ReaderMutexLock = MutexLock;
+class ReaderMutexLock {
+ public:
+  explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
+  ~ReaderMutexLock() { mu_->ReaderUnlock(); }
+
+ private:
+  Mutex *const mu_;
+
+  ReaderMutexLock(const ReaderMutexLock &) = delete;
+  ReaderMutexLock &operator=(const ReaderMutexLock &) = delete;
+};
 
 }  // namespace fst
 
 #endif  // OPENFST_HAS_ABSL
 
-#endif  // FST_LIB_LOCK_H_
+#endif  // FST_LOCK_H_
index 63c209b..66be8ae 100644 (file)
@@ -1,11 +1,13 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Copyright 2005-2020 Google LLC
+//
+// 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
+//     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,
+// 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.
 //
 // Google-style logging declarations and inline definitions.
 
-#ifndef FST_LIB_LOG_H_
-#define FST_LIB_LOG_H_
+#ifndef FST_LOG_H_
+#define FST_LOG_H_
 
 #include <cassert>
 #include <iostream>
-#include <string>
+#include <ostream>
+#include <string_view>
 
-#include <fst/types.h>
 #include <fst/flags.h>
 
 DECLARE_int32(v);
 
 class LogMessage {
  public:
-  LogMessage(const std::string &type) : fatal_(type == "FATAL") {
+  explicit LogMessage(std::string_view type) : fatal_(type == "FATAL") {
     std::cerr << type << ": ";
   }
+
   ~LogMessage() {
     std::cerr << std::endl;
-    if(fatal_)
-      exit(1);
+    if (fatal_) exit(1);
   }
+
   std::ostream &stream() { return std::cerr; }
 
  private:
@@ -46,12 +49,11 @@ class LogMessage {
 #define LOG(type) LogMessage(#type).stream()
 #define VLOG(level) if ((level) <= FST_FLAGS_v) LOG(INFO)
 
-// Checks
-inline void FstCheck(bool x, const char* expr,
-                const char *file, int line) {
+// Checks.
+inline void FstCheck(bool x, std::string_view expr, std::string_view file,
+                     int line) {
   if (!x) {
-    LOG(FATAL) << "Check failed: \"" << expr
-               << "\" file: " << file
+    LOG(FATAL) << "Check failed: \"" << expr << "\" file: " << file
                << " line: " << line;
   }
 }
@@ -64,7 +66,7 @@ inline void FstCheck(bool x, const char* expr,
 #define CHECK_GE(x, y) CHECK((x) >= (y))
 #define CHECK_NE(x, y) CHECK((x) != (y))
 
-// Debug checks
+// Debug checks.
 #define DCHECK(x) assert(x)
 #define DCHECK_EQ(x, y) DCHECK((x) == (y))
 #define DCHECK_LT(x, y) DCHECK((x) < (y))
@@ -73,8 +75,4 @@ inline void FstCheck(bool x, const char* expr,
 #define DCHECK_GE(x, y) DCHECK((x) >= (y))
 #define DCHECK_NE(x, y) DCHECK((x) != (y))
 
-
-// Ports
-#define ATTRIBUTE_DEPRECATED __attribute__((deprecated))
-
-#endif  // FST_LIB_LOG_H_
+#endif  // FST_LOG_H_
index 332092b..e87784c 100644 (file)
@@ -21,9 +21,9 @@
 #ifndef FST_LOOKAHEAD_FILTER_H_
 #define FST_LOOKAHEAD_FILTER_H_
 
+#include <cstdint>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/filter-state.h>
@@ -232,13 +232,13 @@ class LookAheadComposeFilter {
     return selector_;
   }
 
-  uint64 Properties(uint64 inprops) const {
+  uint64_t Properties(uint64_t inprops) const {
     auto outprops = filter_.Properties(inprops);
     if (lookahead_type_ == MATCH_NONE) outprops |= kError;
     return outprops;
   }
 
-  uint32 LookAheadFlags() const { return flags_; }
+  uint32_t LookAheadFlags() const { return flags_; }
 
   bool LookAheadArc() const { return lookahead_arc_; }
 
@@ -271,7 +271,7 @@ class LookAheadComposeFilter {
   Filter filter_;             // Underlying filter.
   MatchType lookahead_type_;  // Lookahead match type.
   LookAheadSelector<Matcher1, Matcher2, MT> selector_;
-  uint32 flags_;                // Lookahead flags.
+  uint32_t flags_;              // Lookahead flags.
   mutable bool lookahead_arc_;  // Look-ahead performed at last FilterArc()?
 
   LookAheadComposeFilter &operator=(const LookAheadComposeFilter &) = delete;
@@ -354,13 +354,13 @@ class PushWeightsComposeFilter {
     return filter_.Selector();
   }
 
-  uint32 LookAheadFlags() const { return filter_.LookAheadFlags(); }
+  uint32_t LookAheadFlags() const { return filter_.LookAheadFlags(); }
 
   bool LookAheadArc() const { return filter_.LookAheadArc(); }
 
   bool LookAheadOutput() const { return filter_.LookAheadOutput(); }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     return filter_.Properties(props) & kWeightInvariantProperties;
   }
 
@@ -402,10 +402,10 @@ class PushLabelsComposeFilter {
         fst2_(filter_.GetMatcher2()->GetFst()),
         matcher1_(fst1_, MATCH_OUTPUT,
                   filter_.LookAheadOutput() ? kMultiEpsList : kMultiEpsLoop,
-                  filter_.GetMatcher1(), false),
+                  filter_.GetMatcher1(), /*own_matcher=*/false),
         matcher2_(fst2_, MATCH_INPUT,
                   filter_.LookAheadOutput() ? kMultiEpsLoop : kMultiEpsList,
-                  filter_.GetMatcher2(), false) {}
+                  filter_.GetMatcher2(), /*own_matcher=*/false) {}
 
   PushLabelsComposeFilter(
       const PushLabelsComposeFilter<Filter, M1, M2, MT> &filter,
@@ -416,10 +416,10 @@ class PushLabelsComposeFilter {
         fst2_(filter_.GetMatcher2()->GetFst()),
         matcher1_(fst1_, MATCH_OUTPUT,
                   filter_.LookAheadOutput() ? kMultiEpsList : kMultiEpsLoop,
-                  filter_.GetMatcher1(), false),
+                  filter_.GetMatcher1(), /*own_matcher=*/false),
         matcher2_(fst2_, MATCH_INPUT,
                   filter_.LookAheadOutput() ? kMultiEpsLoop : kMultiEpsList,
-                  filter_.GetMatcher2(), false) {}
+                  filter_.GetMatcher2(), /*own_matcher=*/false) {}
 
   FilterState Start() const {
     return FilterState(filter_.Start(), FilterState2(kNoLabel));
@@ -474,7 +474,7 @@ class PushLabelsComposeFilter {
 
   Matcher2 *GetMatcher2() { return &matcher2_; }
 
-  uint64 Properties(uint64 iprops) const {
+  uint64_t Properties(uint64_t iprops) const {
     const auto oprops = filter_.Properties(iprops);
     if (LookAheadOutput()) {
       return oprops & kOLabelInvariantProperties;
@@ -537,7 +537,7 @@ class PushLabelsComposeFilter {
     }
   }
 
-  uint32 LookAheadFlags() const { return filter_.LookAheadFlags(); }
+  uint32_t LookAheadFlags() const { return filter_.LookAheadFlags(); }
 
   bool LookAheadArc() const { return filter_.LookAheadArc(); }
 
index 27afed2..52399e2 100644 (file)
 #ifndef FST_LOOKAHEAD_MATCHER_H_
 #define FST_LOOKAHEAD_MATCHER_H_
 
+#include <cstdint>
 #include <memory>
 #include <utility>
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/add-on.h>
@@ -75,7 +75,7 @@ namespace fst {
 //  void InitLookAheadFst(const Fst<Arc> &fst, bool copy = false) override;
 //
 //  // Are there paths from a state in the lookahead FST that can be read from
-//  // the curent matcher state?
+//  // the current matcher state?
 //  bool LookAheadFst(const Fst<Arc> &fst, StateId s) override;
 //
 //  // Can the label be read from the current matcher state after possibly
@@ -101,35 +101,35 @@ namespace fst {
 
 // Look-ahead flags.
 // Matcher is a lookahead matcher when match_type is MATCH_INPUT.
-constexpr uint32 kInputLookAheadMatcher = 0x00000010;
+inline constexpr uint32_t kInputLookAheadMatcher = 0x00000010;
 
 // Matcher is a lookahead matcher when match_type is MATCH_OUTPUT.
-constexpr uint32 kOutputLookAheadMatcher = 0x00000020;
+inline constexpr uint32_t kOutputLookAheadMatcher = 0x00000020;
 
 // Is a non-trivial implementation of LookAheadWeight() method defined and
 // if so, should it be used?
-constexpr uint32 kLookAheadWeight = 0x00000040;
+inline constexpr uint32_t kLookAheadWeight = 0x00000040;
 
 // Is a non-trivial implementation of LookAheadPrefix() method defined and
 // if so, should it be used?
-constexpr uint32 kLookAheadPrefix = 0x00000080;
+inline constexpr uint32_t kLookAheadPrefix = 0x00000080;
 
 // Look-ahead of matcher FST non-epsilon arcs?
-constexpr uint32 kLookAheadNonEpsilons = 0x00000100;
+inline constexpr uint32_t kLookAheadNonEpsilons = 0x00000100;
 
 // Look-ahead of matcher FST epsilon arcs?
-constexpr uint32 kLookAheadEpsilons = 0x00000200;
+inline constexpr uint32_t kLookAheadEpsilons = 0x00000200;
 
 // Ignore epsilon paths for the lookahead prefix? This gives correct results in
 // composition only with an appropriate composition filter since it depends on
 // the filter blocking the ignored paths.
-constexpr uint32 kLookAheadNonEpsilonPrefix = 0x00000400;
+inline constexpr uint32_t kLookAheadNonEpsilonPrefix = 0x00000400;
 
 // For LabelLookAheadMatcher, save relabeling data to file?
-constexpr uint32 kLookAheadKeepRelabelData = 0x00000800;
+inline constexpr uint32_t kLookAheadKeepRelabelData = 0x00000800;
 
 // Flags used for lookahead matchers.
-constexpr uint32 kLookAheadFlags = 0x00000ff0;
+inline constexpr uint32_t kLookAheadFlags = 0x00000ff0;
 
 // LookAhead Matcher interface, templated on the Arc definition; used
 // for lookahead matcher specializations that are returned by the
@@ -220,11 +220,11 @@ class TrivialLookAheadMatcher
 
   const FST &GetFst() const override { return matcher_.GetFst(); }
 
-  uint64 Properties(uint64 props) const override {
+  uint64_t Properties(uint64_t props) const override {
     return matcher_.Properties(props);
   }
 
-  uint32 Flags() const override {
+  uint32_t Flags() const override {
     return matcher_.Flags() | kInputLookAheadMatcher | kOutputLookAheadMatcher;
   }
 
@@ -246,8 +246,8 @@ class TrivialLookAheadMatcher
 
 // Look-ahead of one transition. Template argument flags accepts flags to
 // control behavior.
-template <class M, uint32 flags = kLookAheadNonEpsilons | kLookAheadEpsilons |
-                                  kLookAheadWeight | kLookAheadPrefix>
+template <class M, uint32_t flags = kLookAheadNonEpsilons | kLookAheadEpsilons |
+                                    kLookAheadWeight | kLookAheadPrefix>
 class ArcLookAheadMatcher : public LookAheadMatcherBase<typename M::FST::Arc> {
  public:
   using FST = typename M::FST;
@@ -264,7 +264,7 @@ class ArcLookAheadMatcher : public LookAheadMatcherBase<typename M::FST::Arc> {
   using LookAheadMatcherBase<Arc>::LookAheadPrefix;
   using LookAheadMatcherBase<Arc>::SetLookAheadPrefix;
 
-  enum : uint32 { kFlags = flags };
+  static constexpr uint32_t kFlags = flags;
 
   // This makes a copy of the FST.
   ArcLookAheadMatcher(const FST &fst, MatchType match_type,
@@ -315,11 +315,11 @@ class ArcLookAheadMatcher : public LookAheadMatcherBase<typename M::FST::Arc> {
 
   const FST &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 props) const override {
+  uint64_t Properties(uint64_t props) const override {
     return matcher_.Properties(props);
   }
 
-  uint32 Flags() const override {
+  uint32_t Flags() const override {
     return matcher_.Flags() | kInputLookAheadMatcher | kOutputLookAheadMatcher |
            kFlags;
   }
@@ -347,7 +347,7 @@ class ArcLookAheadMatcher : public LookAheadMatcherBase<typename M::FST::Arc> {
   StateId state_;         // Matcher state.
 };
 
-template <class M, uint32 flags>
+template <class M, uint32_t flags>
 bool ArcLookAheadMatcher<M, flags>::LookAheadFst(const Fst<Arc> &fst,
                                                  StateId s) {
   if (&fst != lfst_) InitLookAheadFst(fst);
@@ -423,9 +423,9 @@ bool ArcLookAheadMatcher<M, flags>::LookAheadFst(const Fst<Arc> &fst,
 // Template argument flags accepts flags to control behavior. It must include
 // precisely one of kInputLookAheadMatcher or kOutputLookAheadMatcher.
 template <class M,
-          uint32 flags = kLookAheadEpsilons | kLookAheadWeight |
-                         kLookAheadPrefix | kLookAheadNonEpsilonPrefix |
-                         kLookAheadKeepRelabelData,
+          uint32_t flags = kLookAheadEpsilons | kLookAheadWeight |
+                           kLookAheadPrefix | kLookAheadNonEpsilonPrefix |
+                           kLookAheadKeepRelabelData,
           class Accum = DefaultAccumulator<typename M::Arc>,
           class R = LabelReachable<typename M::Arc, Accum>>
 class LabelLookAheadMatcher
@@ -453,7 +453,7 @@ class LabelLookAheadMatcher
                     !(flags & kOutputLookAheadMatcher),
                 "Must include precisely one of kInputLookAheadMatcher and "
                 "kOutputLookAheadMatcher");
-  enum : uint32 { kFlags = flags };
+  static constexpr uint32_t kFlags = flags;
 
   // This makes a copy of the FST.
   LabelLookAheadMatcher(const FST &fst, MatchType match_type,
@@ -521,7 +521,7 @@ class LabelLookAheadMatcher
 
   const FST &GetFst() const override { return matcher_.GetFst(); }
 
-  uint64 Properties(uint64 inprops) const override {
+  uint64_t Properties(uint64_t inprops) const override {
     auto outprops = matcher_.Properties(inprops);
     if (error_ || (label_reachable_ && label_reachable_->Error())) {
       outprops |= kError;
@@ -529,7 +529,7 @@ class LabelLookAheadMatcher
     return outprops;
   }
 
-  uint32 Flags() const override {
+  uint32_t Flags() const override {
     if (label_reachable_ && label_reachable_->GetData()->ReachInput()) {
       return matcher_.Flags() | kFlags | kInputLookAheadMatcher;
     } else if (label_reachable_ && !label_reachable_->GetData()->ReachInput()) {
@@ -613,7 +613,7 @@ class LabelLookAheadMatcher
   bool error_;                                  // Error encountered?
 };
 
-template <class M, uint32 flags, class Accumulator, class Reachable>
+template <class M, uint32_t flags, class Accumulator, class Reachable>
 template <class LFST>
 inline bool LabelLookAheadMatcher<M, flags, Accumulator,
                                   Reachable>::LookAheadFst(const LFST &fst,
@@ -726,7 +726,7 @@ inline LabelLookAheadRelabeler<Arc, Data>::LabelLookAheadRelabeler(
     // Borrow pointer from fst without increasing ref count; it will
     // be released below. We do not want to call Copy() since that would
     // do a deep copy when the Fst is modified.
-    mfst.reset(fst::down_cast<MutableFst<Arc> *>(&fst));
+    mfst.reset(down_cast<MutableFst<Arc> *>(&fst));
   } else {
     mfst = std::make_unique<VectorFst<Arc>>(fst);
   }
@@ -800,15 +800,15 @@ class LookAheadMatcher {
 
   ssize_t Priority(StateId s) { return base_->Priority(s); }
 
-  const FST &GetFst() const { return fst::down_cast<const FST &>(base_->GetFst()); }
+  const FST &GetFst() const { return down_cast<const FST &>(base_->GetFst()); }
 
-  uint64 Properties(uint64 props) const { return base_->Properties(props); }
+  uint64_t Properties(uint64_t props) const { return base_->Properties(props); }
 
-  uint32 Flags() const { return base_->Flags(); }
+  uint32_t Flags() const { return base_->Flags(); }
 
   bool LookAheadLabel(Label label) const {
     if (LookAheadCheck()) {
-      return fst::down_cast<LBase *>(base_.get())->LookAheadLabel(label);
+      return down_cast<LBase *>(base_.get())->LookAheadLabel(label);
     } else {
       return true;
     }
@@ -816,7 +816,7 @@ class LookAheadMatcher {
 
   bool LookAheadFst(const Fst<Arc> &fst, StateId s) {
     if (LookAheadCheck()) {
-      return fst::down_cast<LBase *>(base_.get())->LookAheadFst(fst, s);
+      return down_cast<LBase *>(base_.get())->LookAheadFst(fst, s);
     } else {
       return true;
     }
@@ -824,7 +824,7 @@ class LookAheadMatcher {
 
   Weight LookAheadWeight() const {
     if (LookAheadCheck()) {
-      return fst::down_cast<LBase *>(base_.get())->LookAheadWeight();
+      return down_cast<LBase *>(base_.get())->LookAheadWeight();
     } else {
       return Weight::One();
     }
@@ -832,7 +832,7 @@ class LookAheadMatcher {
 
   bool LookAheadPrefix(Arc *arc) const {
     if (LookAheadCheck()) {
-      return fst::down_cast<LBase *>(base_.get())->LookAheadPrefix(arc);
+      return down_cast<LBase *>(base_.get())->LookAheadPrefix(arc);
     } else {
       return false;
     }
@@ -840,7 +840,7 @@ class LookAheadMatcher {
 
   void InitLookAheadFst(const Fst<Arc> &fst, bool copy = false) {
     if (LookAheadCheck()) {
-      fst::down_cast<LBase *>(base_.get())->InitLookAheadFst(fst, copy);
+      down_cast<LBase *>(base_.get())->InitLookAheadFst(fst, copy);
     }
   }
 
diff --git a/src/include/fst/map.h b/src/include/fst/map.h
deleted file mode 100644 (file)
index 4627110..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2005-2020 Google LLC
-//
-// 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.
-//
-// See www.openfst.org for extensive documentation on this weighted
-// finite-state transducer library.
-//
-// Compatibility file for old-style Map() functions and MapFst class that have
-// been renamed to ArcMap (cf. StateMap).
-
-#ifndef FST_MAP_H_
-#define FST_MAP_H_
-
-
-#include <fst/arc-map.h>
-
-namespace fst {
-
-template <class A, class C>
-OPENFST_DEPRECATED("Use `ArcMap` instead.")
-void Map(MutableFst<A> *fst, C *mapper) {
-  ArcMap(fst, mapper);
-}
-
-template <class A, class C>
-OPENFST_DEPRECATED("Use `ArcMap` instead.")
-void Map(MutableFst<A> *fst, C mapper) {
-  ArcMap(fst, mapper);
-}
-
-template <class A, class B, class C>
-OPENFST_DEPRECATED("Use `ArcMap` instead.")
-void Map(const Fst<A> &ifst, MutableFst<B> *ofst, C *mapper) {
-  ArcMap(ifst, ofst, mapper);
-}
-
-template <class A, class B, class C>
-OPENFST_DEPRECATED("Use `ArcMap` instead.")
-void Map(const Fst<A> &ifst, MutableFst<B> *ofst, C mapper) {
-  ArcMap(ifst, ofst, mapper);
-}
-
-using MapFstOptions OPENFST_DEPRECATED("Use `ArcMapFstOptions` instead.") =
-    ArcMapFstOptions;
-
-template <class A, class B, class C>
-using MapFst OPENFST_DEPRECATED("Use `ArcMapFst` instead.") = ArcMapFst<A, B, C>;
-
-template <class A>
-using IdentityMapper OPENFST_DEPRECATED("Use `IdentityArcMapper` instead.") =
-    IdentityArcMapper<A>;
-
-}  // namespace fst
-
-#endif  // FST_MAP_H_
index 55fe5a6..36b78bb 100644 (file)
 #ifndef FST_MATCHER_FST_H_
 #define FST_MATCHER_FST_H_
 
+#include <cstdint>
 #include <memory>
 #include <string>
 
-#include <fst/types.h>
 
 #include <fst/add-on.h>
 #include <fst/const-fst.h>
@@ -271,9 +271,11 @@ class Matcher<MatcherFst<F, M, Name, Init>> {
 
   void Next() { matcher_->Next(); }
 
-  uint64 Properties(uint64 props) const { return matcher_->Properties(props); }
+  uint64_t Properties(uint64_t props) const {
+    return matcher_->Properties(props);
+  }
 
-  uint32 Flags() const { return matcher_->Flags(); }
+  uint32_t Flags() const { return matcher_->Flags(); }
 
  private:
   std::unique_ptr<M> matcher_;
@@ -314,9 +316,11 @@ class LookAheadMatcher<MatcherFst<F, M, Name, Init>> {
 
   const FST &GetFst() const { return matcher_->GetFst(); }
 
-  uint64 Properties(uint64 props) const { return matcher_->Properties(props); }
+  uint64_t Properties(uint64_t props) const {
+    return matcher_->Properties(props);
+  }
 
-  uint32 Flags() const { return matcher_->Flags(); }
+  uint32_t Flags() const { return matcher_->Flags(); }
 
   bool LookAheadLabel(Label label) const {
     return matcher_->LookAheadLabel(label);
@@ -342,15 +346,15 @@ class LookAheadMatcher<MatcherFst<F, M, Name, Init>> {
 
 // Useful aliases when using StdArc.
 
-extern const char arc_lookahead_fst_type[];
+inline constexpr char arc_lookahead_fst_type[] = "arc_lookahead";
 
 using StdArcLookAheadFst =
     MatcherFst<ConstFst<StdArc>,
                ArcLookAheadMatcher<SortedMatcher<ConstFst<StdArc>>>,
                arc_lookahead_fst_type>;
 
-extern const char ilabel_lookahead_fst_type[];
-extern const char olabel_lookahead_fst_type[];
+inline constexpr char ilabel_lookahead_fst_type[] = "ilabel_lookahead";
+inline constexpr char olabel_lookahead_fst_type[] = "olabel_lookahead";
 
 constexpr auto ilabel_lookahead_flags =
     kInputLookAheadMatcher | kLookAheadWeight | kLookAheadPrefix |
index 8de8174..d8ba619 100644 (file)
 #define FST_MATCHER_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <memory>
+#include <tuple>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/mutable-fst.h>  // for all internal FST accessors.
 
 #include <unordered_map>
+#include <optional>
 
 namespace fst {
 
@@ -104,10 +106,10 @@ namespace fst {
 //
 //   // This specifies the known FST properties as viewed from this matcher. It
 //   // takes as argument the input FST's known properties.
-//   uint64 Properties(uint64 props) const override;
+//   uint64_t Properties(uint64_t props) const override;
 //
 //   // Returns matcher flags.
-//   uint32 Flags() const override;
+//   uint32_t Flags() const override;
 //
 //   // Returns matcher FST.
 //   const FST &GetFst() const override;
@@ -117,13 +119,13 @@ namespace fst {
 
 // Matcher needs to be used as the matching side in composition for
 // at least one state (has kRequirePriority).
-constexpr uint32 kRequireMatch = 0x00000001;
+inline constexpr uint32_t kRequireMatch = 0x00000001;
 
 // Flags used for basic matchers (see also lookahead.h).
-constexpr uint32 kMatcherFlags = kRequireMatch;
+inline constexpr uint32_t kMatcherFlags = kRequireMatch;
 
 // Matcher priority that is mandatory.
-constexpr ssize_t kRequirePriority = -1;
+inline constexpr ssize_t kRequirePriority = -1;
 
 // Matcher interface, templated on the Arc definition; used for matcher
 // specializations that are returned by the InitMatcher FST method.
@@ -147,11 +149,11 @@ class MatcherBase {
   virtual const Arc &Value() const = 0;
   virtual void Next() = 0;
   virtual const Fst<Arc> &GetFst() const = 0;
-  virtual uint64 Properties(uint64) const = 0;
+  virtual uint64_t Properties(uint64_t) const = 0;
 
   // Trivial implementations that can be used by derived classes. Full
   // devirtualization is expected for any derived class marked final.
-  virtual uint32 Flags() const { return 0; }
+  virtual uint32_t Flags() const { return 0; }
 
   virtual Weight Final(StateId s) const { return internal::Final(GetFst(), s); }
 
@@ -189,14 +191,13 @@ class SortedMatcher : public MatcherBase<typename F::Arc> {
   SortedMatcher(const FST *fst, MatchType match_type, Label binary_label = 1)
       : fst_(*fst),
         state_(kNoStateId),
-        aiter_(nullptr),
+        aiter_(std::nullopt),
         match_type_(match_type),
         binary_label_(binary_label),
         match_label_(kNoLabel),
         narcs_(0),
         loop_(kNoLabel, 0, Weight::One(), kNoStateId),
-        error_(false),
-        aiter_pool_(1) {
+        error_(false) {
     switch (match_type_) {
       case MATCH_INPUT:
       case MATCH_NONE:
@@ -216,16 +217,15 @@ class SortedMatcher : public MatcherBase<typename F::Arc> {
       : owned_fst_(matcher.fst_.Copy(safe)),
         fst_(*owned_fst_),
         state_(kNoStateId),
-        aiter_(nullptr),
+        aiter_(std::nullopt),
         match_type_(matcher.match_type_),
         binary_label_(matcher.binary_label_),
         match_label_(kNoLabel),
         narcs_(0),
         loop_(matcher.loop_),
-        error_(matcher.error_),
-        aiter_pool_(1) {}
+        error_(matcher.error_) {}
 
-  ~SortedMatcher() override { Destroy(aiter_, &aiter_pool_); }
+  ~SortedMatcher() override = default;
 
   SortedMatcher *Copy(bool safe = false) const override {
     return new SortedMatcher(*this, safe);
@@ -254,8 +254,7 @@ class SortedMatcher : public MatcherBase<typename F::Arc> {
       FSTERROR() << "SortedMatcher: Bad match type";
       error_ = true;
     }
-    Destroy(aiter_, &aiter_pool_);
-    aiter_ = new (&aiter_pool_) ArcIterator<FST>(fst_, s);
+    aiter_.emplace(fst_, s);
     aiter_->SetFlags(kArcNoCache, kArcNoCache);
     narcs_ = internal::NumArcs(fst_, s);
     loop_.nextstate = s;
@@ -322,7 +321,7 @@ class SortedMatcher : public MatcherBase<typename F::Arc> {
 
   const FST &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 inprops) const override {
+  uint64_t Properties(uint64_t inprops) const override {
     return inprops | (error_ ? kError : 0);
   }
 
@@ -341,16 +340,16 @@ class SortedMatcher : public MatcherBase<typename F::Arc> {
   std::unique_ptr<const FST> owned_fst_;  // FST ptr if owned.
   const FST &fst_;                        // FST for matching.
   StateId state_;                         // Matcher state.
-  ArcIterator<FST> *aiter_;               // Iterator for current state.
-  MatchType match_type_;                  // Type of match to perform.
-  Label binary_label_;                    // Least label for binary search.
-  Label match_label_;                     // Current label to be matched.
-  size_t narcs_;                          // Current state arc count.
-  Arc loop_;                              // For non-consuming symbols.
-  bool current_loop_;                     // Current arc is the implicit loop.
-  bool exact_match_;                      // Exact match or lower bound?
-  bool error_;                            // Error encountered?
-  MemoryPool<ArcIterator<FST>> aiter_pool_;  // Pool of arc iterators.
+  mutable std::optional<ArcIterator<FST>>
+      aiter_;             // Iterator for current state.
+  MatchType match_type_;  // Type of match to perform.
+  Label binary_label_;    // Least label for binary search.
+  Label match_label_;     // Current label to be matched.
+  size_t narcs_;          // Current state arc count.
+  Arc loop_;              // For non-consuming symbols.
+  bool current_loop_;     // Current arc is the implicit loop.
+  bool exact_match_;      // Exact match or lower bound?
+  bool error_;            // Error encountered?
 };
 
 // Returns true iff match to match_label_. The arc iterator is positioned at the
@@ -506,7 +505,7 @@ class HashMatcher : public MatcherBase<typename F::Arc> {
 
   const FST &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 inprops) const override {
+  uint64_t Properties(uint64_t inprops) const override {
     return inprops | (error_ ? kError : 0);
   }
 
@@ -547,12 +546,12 @@ void HashMatcher<FST>::SetState(typename FST::Arc::StateId s) {
     error_ = true;
   }
   // Attempts to insert a new label table.
-  auto it_and_success = state_table_->emplace(
-      state_, std::make_unique<LabelTable>());
+  const auto &[it, success] =
+      state_table_->emplace(state_, std::make_unique<LabelTable>());
   // Sets instance's pointer to the label table for this state.
-  label_table_ = it_and_success.first->second.get();
+  label_table_ = it->second.get();
   // If it already exists, no additional work is done and we simply return.
-  if (!it_and_success.second) return;
+  if (!success) return;
   // Otherwise, populate this new table.
   // Populates the label table.
   label_table_->reserve(internal::NumArcs(fst_, state_));
@@ -568,9 +567,7 @@ void HashMatcher<FST>::SetState(typename FST::Arc::StateId s) {
 
 template <class FST>
 inline bool HashMatcher<FST>::Search(typename FST::Arc::Label match_label) {
-  auto range = label_table_->equal_range(match_label);
-  label_it_ = range.first;
-  label_end_ = range.second;
+  std::tie(label_it_, label_end_) = label_table_->equal_range(match_label);
   if (label_it_ == label_end_) return false;
   aiter_->Seek(label_it_->second);
   return true;
@@ -727,9 +724,9 @@ class PhiMatcher : public MatcherBase<typename M::Arc> {
 
   const FST &GetFst() const override { return matcher_->GetFst(); }
 
-  uint64 Properties(uint64 props) const override;
+  uint64_t Properties(uint64_t props) const override;
 
-  uint32 Flags() const override {
+  uint32_t Flags() const override {
     if (phi_label_ == kNoLabel || match_type_ == MATCH_NONE) {
       return matcher_->Flags();
     }
@@ -804,7 +801,7 @@ inline bool PhiMatcher<M>::Find(Label label) {
 }
 
 template <class M>
-inline uint64 PhiMatcher<M>::Properties(uint64 inprops) const {
+inline uint64_t PhiMatcher<M>::Properties(uint64_t inprops) const {
   auto outprops = matcher_->Properties(inprops);
   if (error_) outprops |= kError;
   if (match_type_ == MATCH_NONE) {
@@ -979,9 +976,9 @@ class RhoMatcher : public MatcherBase<typename M::Arc> {
 
   const FST &GetFst() const override { return matcher_->GetFst(); }
 
-  uint64 Properties(uint64 props) const override;
+  uint64_t Properties(uint64_t props) const override;
 
-  uint32 Flags() const override {
+  uint32_t Flags() const override {
     if (rho_label_ == kNoLabel || match_type_ == MATCH_NONE) {
       return matcher_->Flags();
     }
@@ -1003,7 +1000,7 @@ class RhoMatcher : public MatcherBase<typename M::Arc> {
 };
 
 template <class M>
-inline uint64 RhoMatcher<M>::Properties(uint64 inprops) const {
+inline uint64_t RhoMatcher<M>::Properties(uint64_t inprops) const {
   auto outprops = matcher_->Properties(inprops);
   if (error_) outprops |= kError;
   if (match_type_ == MATCH_NONE) {
@@ -1175,9 +1172,9 @@ class SigmaMatcher : public MatcherBase<typename M::Arc> {
 
   const FST &GetFst() const override { return matcher_->GetFst(); }
 
-  uint64 Properties(uint64 props) const override;
+  uint64_t Properties(uint64_t props) const override;
 
-  uint32 Flags() const override {
+  uint32_t Flags() const override {
     if (sigma_label_ == kNoLabel || match_type_ == MATCH_NONE) {
       return matcher_->Flags();
     }
@@ -1200,7 +1197,7 @@ class SigmaMatcher : public MatcherBase<typename M::Arc> {
 };
 
 template <class M>
-inline uint64 SigmaMatcher<M>::Properties(uint64 inprops) const {
+inline uint64_t SigmaMatcher<M>::Properties(uint64_t inprops) const {
   auto outprops = matcher_->Properties(inprops);
   if (error_) outprops |= kError;
   if (match_type_ == MATCH_NONE) {
@@ -1227,10 +1224,10 @@ inline uint64 SigmaMatcher<M>::Properties(uint64 inprops) const {
 // Flags for MultiEpsMatcher.
 
 // Return multi-epsilon arcs for Find(kNoLabel).
-const uint32 kMultiEpsList = 0x00000001;
+inline constexpr uint32_t kMultiEpsList = 0x00000001;
 
 // Return a kNolabel loop for Find(multi_eps).
-const uint32 kMultiEpsLoop = 0x00000002;
+inline constexpr uint32_t kMultiEpsLoop = 0x00000002;
 
 // MultiEpsMatcher: allows treating multiple non-0 labels as
 // non-consuming labels in addition to 0 that is always
@@ -1250,7 +1247,7 @@ class MultiEpsMatcher {
 
   // This makes a copy of the FST (w/o 'matcher' arg).
   MultiEpsMatcher(const FST &fst, MatchType match_type,
-                  uint32 flags = (kMultiEpsLoop | kMultiEpsList),
+                  uint32_t flags = (kMultiEpsLoop | kMultiEpsList),
                   M *matcher = nullptr, bool own_matcher = true)
       : matcher_(matcher ? matcher : new M(fst, match_type)),
         flags_(flags),
@@ -1260,7 +1257,7 @@ class MultiEpsMatcher {
 
   // This doesn't copy the FST.
   MultiEpsMatcher(const FST *fst, MatchType match_type,
-                  uint32 flags = (kMultiEpsLoop | kMultiEpsList),
+                  uint32_t flags = (kMultiEpsLoop | kMultiEpsList),
                   M *matcher = nullptr, bool own_matcher = true)
       : matcher_(matcher ? matcher : new M(fst, match_type)),
         flags_(flags),
@@ -1322,13 +1319,15 @@ class MultiEpsMatcher {
 
   const FST &GetFst() const { return matcher_->GetFst(); }
 
-  uint64 Properties(uint64 props) const { return matcher_->Properties(props); }
+  uint64_t Properties(uint64_t props) const {
+    return matcher_->Properties(props);
+  }
 
   const M *GetMatcher() const { return matcher_; }
 
   Weight Final(StateId s) const { return matcher_->Final(s); }
 
-  uint32 Flags() const { return matcher_->Flags(); }
+  uint32_t Flags() const { return matcher_->Flags(); }
 
   ssize_t Priority(StateId s) { return matcher_->Priority(s); }
 
@@ -1364,7 +1363,7 @@ class MultiEpsMatcher {
   }
 
   M *matcher_;
-  uint32 flags_;
+  uint32_t flags_;
   bool own_matcher_;  // Does this class delete the matcher?
 
   // Multi-eps label set.
@@ -1477,13 +1476,13 @@ class ExplicitMatcher : public MatcherBase<typename M::Arc> {
 
   const FST &GetFst() const final { return matcher_->GetFst(); }
 
-  uint64 Properties(uint64 inprops) const override {
+  uint64_t Properties(uint64_t inprops) const override {
     return matcher_->Properties(inprops);
   }
 
   const M *GetMatcher() const { return matcher_.get(); }
 
-  uint32 Flags() const override { return matcher_->Flags(); }
+  uint32_t Flags() const override { return matcher_->Flags(); }
 
  private:
   // Checks current arc if available and explicit. If not available, stops. If
@@ -1556,13 +1555,13 @@ class Matcher {
 
   void Next() { base_->Next(); }
 
-  const FST &GetFst() const { return fst::down_cast<const FST &>(base_->GetFst()); }
+  const FST &GetFst() const { return down_cast<const FST &>(base_->GetFst()); }
 
-  uint64 Properties(uint64 props) const { return base_->Properties(props); }
+  uint64_t Properties(uint64_t props) const { return base_->Properties(props); }
 
   Weight Final(StateId s) const { return base_->Final(s); }
 
-  uint32 Flags() const { return base_->Flags() & kMatcherFlags; }
+  uint32_t Flags() const { return base_->Flags() & kMatcherFlags; }
 
   ssize_t Priority(StateId s) { return base_->Priority(s); }
 
index 733e0a2..7299c53 100644 (file)
 namespace fst {
 
 // Default block allocation size.
-constexpr int kAllocSize = 64;
+inline constexpr int kAllocSize = 64;
 
 // Minimum number of allocations per block.
-constexpr int kAllocFit = 4;
+inline constexpr int kAllocFit = 4;
 
 // Base class for MemoryArena that allows (e.g.) MemoryArenaCollection to
 // easily manipulate collections of variously sized arenas.
@@ -54,24 +54,27 @@ namespace internal {
 template <size_t object_size>
 class MemoryArenaImpl : public MemoryArenaBase {
  public:
-  enum { kObjectSize = object_size };
+  static constexpr size_t kObjectSize = object_size;
 
   explicit MemoryArenaImpl(size_t block_size = kAllocSize)
       : block_size_(block_size * kObjectSize), block_pos_(0) {
-    blocks_.emplace_front(std::make_unique<std::byte[]>(block_size_));
+    blocks_.push_front(
+        fst::make_unique_for_overwrite<std::byte[]>(block_size_));
   }
 
   void *Allocate(size_t size) {
     const auto byte_size = size * kObjectSize;
     if (byte_size * kAllocFit > block_size_) {
       // Large block; adds new large block.
-      blocks_.emplace_back(std::make_unique<std::byte[]>(byte_size));
+      blocks_.push_back(
+          fst::make_unique_for_overwrite<std::byte[]>(byte_size));
       return blocks_.back().get();
-  }
+    }
     if (block_pos_ + byte_size > block_size_) {
       // Doesn't fit; adds new standard block.
       block_pos_ = 0;
-      blocks_.emplace_front(std::make_unique<std::byte[]>(block_size_));
+      blocks_.push_front(
+          fst::make_unique_for_overwrite<std::byte[]>(block_size_));
     }
     // Fits; uses current block.
     auto *ptr = &blocks_.front()[block_pos_];
@@ -109,7 +112,7 @@ namespace internal {
 template <size_t object_size>
 class MemoryPoolImpl : public MemoryPoolBase {
  public:
-  enum { kObjectSize = object_size };
+  static constexpr size_t kObjectSize = object_size;
 
   struct Link {
     std::byte buf[kObjectSize];
@@ -120,15 +123,15 @@ class MemoryPoolImpl : public MemoryPoolBase {
       : mem_arena_(pool_size), free_list_(nullptr) {}
 
   void *Allocate() {
+    Link *link;
     if (free_list_ == nullptr) {
-      auto *link = static_cast<Link *>(mem_arena_.Allocate(1));
+      link = static_cast<Link *>(mem_arena_.Allocate(1));
       link->next = nullptr;
-      return link;
     } else {
-      auto *link = free_list_;
+      link = free_list_;
       free_list_ = link->next;
-      return link;
     }
+    return fst::implicit_cast<std::byte *>(link->buf);
   }
 
   void Free(void *ptr) {
@@ -179,7 +182,7 @@ class MemoryArenaCollection {
     if (arena == nullptr) {
       arena = std::make_unique<MemoryArena<T>>(block_size_);
     }
-    return static_cast<MemoryArena<T> *>(arena.get());
+    return down_cast<MemoryArena<T> *>(arena.get());
   }
 
   size_t BlockSize() const { return block_size_; }
@@ -201,7 +204,7 @@ class MemoryPoolCollection {
     if (sizeof(T) >= pools_.size()) pools_.resize(sizeof(T) + 1);
     auto &pool = pools_[sizeof(T)];
     if (pool == nullptr) pool = std::make_unique<MemoryPool<T>>(pool_size_);
-    return static_cast<MemoryPool<T> *>(pool.get());
+    return down_cast<MemoryPool<T> *>(pool.get());
   }
 
   size_t PoolSize() const { return pool_size_; }
@@ -225,55 +228,24 @@ class BlockAllocator {
  public:
   using Allocator = std::allocator<T>;
   using size_type = typename Allocator::size_type;
-  using difference_type = typename Allocator::difference_type;
-  using pointer = typename Allocator::pointer;
-  using const_pointer = typename Allocator::const_pointer;
-  using reference = typename Allocator::reference;
-  using const_reference = typename Allocator::const_reference;
   using value_type = typename Allocator::value_type;
 
-  template <typename U>
-  struct rebind {
-    using other = BlockAllocator<U>;
-  };
-
   explicit BlockAllocator(size_t block_size = kAllocSize)
       : arenas_(std::make_shared<MemoryArenaCollection>(block_size)) {}
 
-  ~BlockAllocator() = default;
-  BlockAllocator(const BlockAllocator &) = default;
-  BlockAllocator(BlockAllocator &&) = default;
-  BlockAllocator &operator=(const BlockAllocator &) = default;
-  BlockAllocator &operator=(BlockAllocator &&) = default;
-
   template <typename U>
   explicit BlockAllocator(const BlockAllocator<U> &arena_alloc)
       : arenas_(arena_alloc.Arenas()) {}
 
-  pointer address(reference ref) const { return Allocator().address(ref); }
-
-  const_pointer address(const_reference ref) const {
-    return Allocator().address(ref);
-  }
-
-  size_type max_size() const { return Allocator().max_size(); }
-
-  template <class U, class... Args>
-  void construct(U *p, Args &&... args) {
-    Allocator().construct(p, std::forward<Args>(args)...);
-  }
-
-  void destroy(pointer p) { Allocator().destroy(p); }
-
-  pointer allocate(size_type n, const void *hint = nullptr) {
+  T *allocate(size_type n, const void *hint = nullptr) {
     if (n * kAllocFit <= kAllocSize) {
-      return static_cast<pointer>(Arena()->Allocate(n));
+      return static_cast<T *>(Arena()->Allocate(n));
     } else {
       return Allocator().allocate(n, hint);
     }
   }
 
-  void deallocate(pointer p, size_type n) {
+  void deallocate(T *p, size_type n) {
     if (n * kAllocFit > kAllocSize) Allocator().deallocate(p, n);
   }
 
@@ -310,67 +282,36 @@ class PoolAllocator {
  public:
   using Allocator = std::allocator<T>;
   using size_type = typename Allocator::size_type;
-  using difference_type = typename Allocator::difference_type;
-  using pointer = typename Allocator::pointer;
-  using const_pointer = typename Allocator::const_pointer;
-  using reference = typename Allocator::reference;
-  using const_reference = typename Allocator::const_reference;
   using value_type = typename Allocator::value_type;
 
-  template <typename U>
-  struct rebind {
-    using other = PoolAllocator<U>;
-  };
-
   explicit PoolAllocator(size_t pool_size = kAllocSize)
       : pools_(std::make_shared<MemoryPoolCollection>(pool_size)) {}
 
-  ~PoolAllocator() = default;
-  PoolAllocator(const PoolAllocator &) = default;
-  PoolAllocator(PoolAllocator &&) = default;
-  PoolAllocator &operator=(const PoolAllocator &) = default;
-  PoolAllocator &operator=(PoolAllocator &&) = default;
-
   template <typename U>
   explicit PoolAllocator(const PoolAllocator<U> &pool_alloc)
       : pools_(pool_alloc.Pools()) {}
 
-  pointer address(reference ref) const { return Allocator().address(ref); }
-
-  const_pointer address(const_reference ref) const {
-    return Allocator().address(ref);
-  }
-
-  size_type max_size() const { return Allocator().max_size(); }
-
-  template <class U, class... Args>
-  void construct(U *p, Args &&... args) {
-    Allocator().construct(p, std::forward<Args>(args)...);
-  }
-
-  void destroy(pointer p) { Allocator().destroy(p); }
-
-  pointer allocate(size_type n, const void *hint = nullptr) {
+  T *allocate(size_type n, const void *hint = nullptr) {
     if (n == 1) {
-      return static_cast<pointer>(Pool<1>()->Allocate());
+      return static_cast<T *>(Pool<1>()->Allocate());
     } else if (n == 2) {
-      return static_cast<pointer>(Pool<2>()->Allocate());
+      return static_cast<T *>(Pool<2>()->Allocate());
     } else if (n <= 4) {
-      return static_cast<pointer>(Pool<4>()->Allocate());
+      return static_cast<T *>(Pool<4>()->Allocate());
     } else if (n <= 8) {
-      return static_cast<pointer>(Pool<8>()->Allocate());
+      return static_cast<T *>(Pool<8>()->Allocate());
     } else if (n <= 16) {
-      return static_cast<pointer>(Pool<16>()->Allocate());
+      return static_cast<T *>(Pool<16>()->Allocate());
     } else if (n <= 32) {
-      return static_cast<pointer>(Pool<32>()->Allocate());
+      return static_cast<T *>(Pool<32>()->Allocate());
     } else if (n <= 64) {
-      return static_cast<pointer>(Pool<64>()->Allocate());
+      return static_cast<T *>(Pool<64>()->Allocate());
     } else {
       return Allocator().allocate(n, hint);
     }
   }
 
-  void deallocate(pointer p, size_type n) {
+  void deallocate(T *p, size_type n) {
     if (n == 1) {
       Pool<1>()->Free(p);
     } else if (n == 2) {
index 261806d..53d06af 100644 (file)
 #include <algorithm>
 #include <cmath>
 #include <map>
+#include <memory>
 #include <queue>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/arcsort.h>
@@ -44,6 +44,7 @@
 #include <fst/shortest-distance.h>
 #include <fst/state-map.h>
 
+#include <fst/weight.h>
 #include <unordered_map>
 
 namespace fst {
@@ -118,6 +119,10 @@ class CyclicMinimizer {
   using ClassId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
   using RevArc = ReverseArc<Arc>;
+  using RevArcIter = ArcIterator<Fst<RevArc>>;
+  // TODO(wolfsonkin): Consider storing ArcIterator<> directly rather than in
+  // unique_ptr when ArcIterator<Fst<>> is made movable.
+  using RevArcIterPtr = std::unique_ptr<RevArcIter>;
 
   explicit CyclicMinimizer(const ExpandedFst<Arc> &fst) {
     Initialize(fst);
@@ -160,26 +165,16 @@ class CyclicMinimizer {
 
   class ArcIterCompare {
    public:
-    explicit ArcIterCompare(const Partition<StateId> &partition)
-        : partition_(partition) {}
-
-    ArcIterCompare(const ArcIterCompare &comp) : partition_(comp.partition_) {}
-
     // Compares two iterators based on their input labels.
-    bool operator()(const ArcIterator<Fst<RevArc>> *x,
-                    const ArcIterator<Fst<RevArc>> *y) const {
+    bool operator()(const RevArcIterPtr &x, const RevArcIterPtr &y) const {
       const auto &xarc = x->Value();
       const auto &yarc = y->Value();
       return xarc.ilabel > yarc.ilabel;
     }
-
-   private:
-    const Partition<StateId> &partition_;
   };
 
   using ArcIterQueue =
-      std::priority_queue<ArcIterator<Fst<RevArc>> *,
-                          std::vector<ArcIterator<Fst<RevArc>> *>,
+      std::priority_queue<RevArcIterPtr, std::vector<RevArcIterPtr>,
                           ArcIterCompare>;
 
  private:
@@ -239,8 +234,7 @@ class CyclicMinimizer {
     // Prepares initial partition.
     PrePartition(fst);
     // Allocates arc iterator queue.
-    ArcIterCompare comp(P_);
-    aiter_queue_ = std::make_unique<ArcIterQueue>(comp);
+    aiter_queue_ = std::make_unique<ArcIterQueue>();
   }
   // Partitions all classes with destination C.
   void Split(ClassId C) {
@@ -249,14 +243,19 @@ class CyclicMinimizer {
     for (PartitionIterator<StateId> siter(P_, C); !siter.Done(); siter.Next()) {
       const auto s = siter.Value();
       if (Tr_.NumArcs(s + 1)) {
-        aiter_queue_->push(new ArcIterator<Fst<RevArc>>(Tr_, s + 1));
+        aiter_queue_->push(std::make_unique<RevArcIter>(Tr_, s + 1));
       }
     }
     // Now pops arc iterator from queue, splits entering equivalence class, and
     // re-inserts updated iterator into queue.
     Label prev_label = -1;
     while (!aiter_queue_->empty()) {
-      std::unique_ptr<ArcIterator<Fst<RevArc>>> aiter(aiter_queue_->top());
+      // NB: There is no way to "move" out of a std::priority_queue given that
+      // the `top` accessor is a const ref. We const-cast to move out the
+      // unique_ptr out of the priority queue. This is fine and doesn't cause an
+      // issue with the invariants of the pqueue since we immediately pop after.
+      RevArcIterPtr aiter =
+          std::move(const_cast<RevArcIterPtr &>(aiter_queue_->top()));
       aiter_queue_->pop();
       if (aiter->Done()) continue;
       const auto &arc = aiter->Value();
@@ -267,7 +266,7 @@ class CyclicMinimizer {
       if (P_.ClassSize(from_class) > 1) P_.SplitOn(from_state);
       prev_label = from_label;
       aiter->Next();
-      if (!aiter->Done()) aiter_queue_->push(aiter.release());
+      if (!aiter->Done()) aiter_queue_->push(std::move(aiter));
     }
     P_.FinalizeSplit(&L_);
   }
@@ -513,7 +512,7 @@ void Minimize(MutableFst<Arc> *fst, MutableFst<Arc> *sfst = nullptr,
     // idempotent semirings---for non-deterministic inputs, a state could have
     // multiple transitions to states that will get merged, and we'd have to
     // sum their weights. The algorithm doesn't handle that.
-    if (!(Weight::Properties() & kIdempotent)) {
+    if constexpr (!IsIdempotent<Weight>::value) {
       fst->SetProperties(kError, kError);
       FSTERROR() << "Cannot minimize a non-deterministic FST over a "
                     "non-idempotent semiring";
index 6351044..1adb88d 100644 (file)
 #include <sys/types.h>
 
 #include <cstddef>
+#include <cstdint>
 #include <istream>
 #include <memory>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fstream>
 
 #include <fst/expanded-fst.h>
+#include <string_view>
 
 
 namespace fst {
@@ -64,7 +65,7 @@ class MutableFst : public ExpandedFst<A> {
   virtual void SetFinal(StateId s, Weight weight = Weight::One()) = 0;
 
   // Sets property bits w.r.t. mask.
-  virtual void SetProperties(uint64 props, uint64 mask) = 0;
+  virtual void SetProperties(uint64_t props, uint64_t mask) = 0;
 
   // Adds a state and returns its ID.
   virtual StateId AddState() = 0;
@@ -141,7 +142,7 @@ class MutableFst : public ExpandedFst<A> {
     }
     auto *fst = reader(strm, ropts);
     if (!fst) return nullptr;
-    return fst::down_cast<MutableFst *>(fst);
+    return down_cast<MutableFst *>(fst);
   }
 
   // Reads a MutableFst from a file; returns nullptr on error. An empty
@@ -149,7 +150,7 @@ class MutableFst : public ExpandedFst<A> {
   // convert to a mutable FST subclass (given by convert_type) in the case
   // that the input FST is non-mutable.
   static MutableFst *Read(const std::string &source, bool convert = false,
-                          const std::string &convert_type = "vector") {
+                          std::string_view convert_type = "vector") {
     if (convert == false) {
       if (!source.empty()) {
         std::ifstream strm(source,
@@ -166,7 +167,7 @@ class MutableFst : public ExpandedFst<A> {
       std::unique_ptr<Fst<Arc>> ifst(Fst<Arc>::Read(source));
       if (!ifst) return nullptr;
       if (ifst->Properties(kMutable, false)) {
-        return fst::down_cast<MutableFst *>(ifst.release());
+        return down_cast<MutableFst *>(ifst.release());
       } else {
         std::unique_ptr<Fst<Arc>> ofst(Convert(*ifst, convert_type));
         ifst.reset();
@@ -174,7 +175,7 @@ class MutableFst : public ExpandedFst<A> {
         if (!ofst->Properties(kMutable, false)) {
           LOG(ERROR) << "MutableFst: Bad convert type: " << convert_type;
         }
-        return fst::down_cast<MutableFst *>(ofst.release());
+        return down_cast<MutableFst *>(ofst.release());
       }
     }
   }
@@ -239,9 +240,9 @@ class MutableArcIterator {
 
   void SetValue(const Arc &arc) { data_.base->SetValue(arc); }
 
-  uint8 Flags() const { return data_.base->Flags(); }
+  uint8_t Flags() const { return data_.base->Flags(); }
 
-  void SetFlags(uint8 flags, uint8 mask) {
+  void SetFlags(uint8_t flags, uint8_t mask) {
     return data_.base->SetFlags(flags, mask);
   }
 
@@ -304,7 +305,7 @@ class ImplToMutableFst : public ImplToExpandedFst<Impl, FST> {
     GetMutableImpl()->SetFinal(s, std::move(weight));
   }
 
-  void SetProperties(uint64 props, uint64 mask) override {
+  void SetProperties(uint64_t props, uint64_t mask) override {
     // Can skip mutate check if extrinsic properties don't change,
     // since it is then safe to update all (shallow) copies
     const auto exprops = kExtrinsicProperties & mask;
index 73b3438..13333c4 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef FST_PAIR_WEIGHT_H_
 #define FST_PAIR_WEIGHT_H_
 
+#include <cstdint>
 #include <random>
 #include <stack>
 #include <string>
@@ -154,7 +155,7 @@ class WeightGenerate<PairWeight<W1, W2>> {
   using Generate1 = WeightGenerate<W1>;
   using Generate2 = WeightGenerate<W2>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true)
       : generate1_(seed, allow_zero), generate2_(seed, allow_zero) {}
 
index ebcfee2..5893931 100644 (file)
@@ -21,6 +21,7 @@
 #define FST_PARTITION_H_
 
 #include <algorithm>
+#include <type_traits>
 #include <vector>
 
 
@@ -65,6 +66,9 @@ class PartitionIterator;
 // a subsequent call to FinalizeSplit()
 template <typename T>
 class Partition {
+  static_assert(std::is_signed_v<T> && std::is_integral_v<T>,
+                "T must be a signed integer type");
+
  public:
   Partition() {}
 
index 30cb4e6..6749045 100644 (file)
 #ifndef FST_POWER_WEIGHT_H_
 #define FST_POWER_WEIGHT_H_
 
+#include <cstdint>
 #include <random>
 #include <string>
 
-#include <fst/types.h>
 
 #include <fst/tuple-weight.h>
 #include <fst/weight.h>
@@ -80,7 +80,7 @@ class PowerWeight : public TupleWeight<W, n> {
     return *type;
   }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return W::Properties() &
            (kLeftSemiring | kRightSemiring | kCommutative | kIdempotent);
   }
@@ -168,7 +168,7 @@ class WeightGenerate<PowerWeight<W, n>> {
   using Weight = PowerWeight<W, n>;
   using Generate = WeightGenerate<W>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true)
       : generate_(seed, allow_zero) {}
 
index d3f5902..e91ebf0 100644 (file)
 #ifndef FST_PRODUCT_WEIGHT_H_
 #define FST_PRODUCT_WEIGHT_H_
 
+#include <cstdint>
 #include <random>
 #include <string>
 #include <utility>
 
-#include <fst/types.h>
 
 #include <fst/pair-weight.h>
 #include <fst/weight.h>
@@ -68,7 +68,7 @@ class ProductWeight : public PairWeight<W1, W2> {
     return *type;
   }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return W1::Properties() & W2::Properties() &
            (kLeftSemiring | kRightSemiring | kCommutative | kIdempotent);
   }
@@ -141,7 +141,7 @@ class WeightGenerate<ProductWeight<W1, W2>> {
   using Weight = ProductWeight<W1, W2>;
   using Generate = WeightGenerate<PairWeight<W1, W2>>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true)
       : generate_(seed, allow_zero) {}
 
index c5c7a5f..1b07683 100644 (file)
@@ -20,7 +20,8 @@
 #ifndef FST_PROJECT_H_
 #define FST_PROJECT_H_
 
-#include <fst/types.h>
+#include <cstdint>
+
 
 #include <fst/arc-map.h>
 #include <fst/mutable-fst.h>
@@ -30,9 +31,9 @@ namespace fst {
 // This specifies whether to project on input or output.
 enum class ProjectType { INPUT = 1, OUTPUT = 2 };
 OPENFST_DEPRECATED("Use `ProjectType::INPUT` instead.")
-static constexpr ProjectType PROJECT_INPUT = ProjectType::INPUT;
+inline constexpr ProjectType PROJECT_INPUT = ProjectType::INPUT;
 OPENFST_DEPRECATED("Use `ProjectType::OUTPUT` instead.")
-static constexpr ProjectType PROJECT_OUTPUT = ProjectType::OUTPUT;
+inline constexpr ProjectType PROJECT_OUTPUT = ProjectType::OUTPUT;
 
 // Mapper to implement projection per arc.
 template <class A>
@@ -62,7 +63,7 @@ class ProjectMapper {
                                                 : MAP_CLEAR_SYMBOLS;
   }
 
-  constexpr uint64 Properties(uint64 props) const {
+  constexpr uint64_t Properties(uint64_t props) const {
     return ProjectProperties(props, project_type_ == ProjectType::INPUT);
   }
 
index 0aa4fa5..c7a110d 100644 (file)
 
 #include <sys/types.h>
 
+#include <cstdint>
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
+#include <string_view>
 
 namespace fst {
 
@@ -41,13 +42,13 @@ namespace fst {
 // true. If it is not set, the property is false.
 
 // The Fst is an ExpandedFst.
-constexpr uint64 kExpanded = 0x0000000000000001ULL;
+inline constexpr uint64_t kExpanded = 0x0000000000000001ULL;
 
 // The Fst is a MutableFst.
-constexpr uint64 kMutable = 0x0000000000000002ULL;
+inline constexpr uint64_t kMutable = 0x0000000000000002ULL;
 
 // An error was detected while constructing/using the FST.
-constexpr uint64 kError = 0x0000000000000004ULL;
+inline constexpr uint64_t kError = 0x0000000000000004ULL;
 
 // TRINARY PROPERTIES
 //
@@ -59,106 +60,106 @@ constexpr uint64 kError = 0x0000000000000004ULL;
 // positive bit at an odd and lower position.
 
 // ilabel == olabel for each arc.
-constexpr uint64 kAcceptor = 0x0000000000010000ULL;
+inline constexpr uint64_t kAcceptor = 0x0000000000010000ULL;
 // ilabel != olabel for some arc.
-constexpr uint64 kNotAcceptor = 0x0000000000020000ULL;
+inline constexpr uint64_t kNotAcceptor = 0x0000000000020000ULL;
 
 // ilabels unique leaving each state.
-constexpr uint64 kIDeterministic = 0x0000000000040000ULL;
+inline constexpr uint64_t kIDeterministic = 0x0000000000040000ULL;
 // ilabels not unique leaving some state.
-constexpr uint64 kNonIDeterministic = 0x0000000000080000ULL;
+inline constexpr uint64_t kNonIDeterministic = 0x0000000000080000ULL;
 
 // olabels unique leaving each state.
-constexpr uint64 kODeterministic = 0x0000000000100000ULL;
+inline constexpr uint64_t kODeterministic = 0x0000000000100000ULL;
 // olabels not unique leaving some state.
-constexpr uint64 kNonODeterministic = 0x0000000000200000ULL;
+inline constexpr uint64_t kNonODeterministic = 0x0000000000200000ULL;
 
 // FST has input/output epsilons.
-constexpr uint64 kEpsilons = 0x0000000000400000ULL;
+inline constexpr uint64_t kEpsilons = 0x0000000000400000ULL;
 // FST has no input/output epsilons.
-constexpr uint64 kNoEpsilons = 0x0000000000800000ULL;
+inline constexpr uint64_t kNoEpsilons = 0x0000000000800000ULL;
 
 // FST has input epsilons.
-constexpr uint64 kIEpsilons = 0x0000000001000000ULL;
+inline constexpr uint64_t kIEpsilons = 0x0000000001000000ULL;
 // FST has no input epsilons.
-constexpr uint64 kNoIEpsilons = 0x0000000002000000ULL;
+inline constexpr uint64_t kNoIEpsilons = 0x0000000002000000ULL;
 
 // FST has output epsilons.
-constexpr uint64 kOEpsilons = 0x0000000004000000ULL;
+inline constexpr uint64_t kOEpsilons = 0x0000000004000000ULL;
 // FST has no output epsilons.
-constexpr uint64 kNoOEpsilons = 0x0000000008000000ULL;
+inline constexpr uint64_t kNoOEpsilons = 0x0000000008000000ULL;
 
 // ilabels sorted wrt < for each state.
-constexpr uint64 kILabelSorted = 0x0000000010000000ULL;
+inline constexpr uint64_t kILabelSorted = 0x0000000010000000ULL;
 // ilabels not sorted wrt < for some state.
-constexpr uint64 kNotILabelSorted = 0x0000000020000000ULL;
+inline constexpr uint64_t kNotILabelSorted = 0x0000000020000000ULL;
 
 // olabels sorted wrt < for each state.
-constexpr uint64 kOLabelSorted = 0x0000000040000000ULL;
+inline constexpr uint64_t kOLabelSorted = 0x0000000040000000ULL;
 // olabels not sorted wrt < for some state.
-constexpr uint64 kNotOLabelSorted = 0x0000000080000000ULL;
+inline constexpr uint64_t kNotOLabelSorted = 0x0000000080000000ULL;
 
 // Non-trivial arc or final weights.
-constexpr uint64 kWeighted = 0x0000000100000000ULL;
+inline constexpr uint64_t kWeighted = 0x0000000100000000ULL;
 // Only trivial arc and final weights.
-constexpr uint64 kUnweighted = 0x0000000200000000ULL;
+inline constexpr uint64_t kUnweighted = 0x0000000200000000ULL;
 
 // FST has cycles.
-constexpr uint64 kCyclic = 0x0000000400000000ULL;
+inline constexpr uint64_t kCyclic = 0x0000000400000000ULL;
 // FST has no cycles.
-constexpr uint64 kAcyclic = 0x0000000800000000ULL;
+inline constexpr uint64_t kAcyclic = 0x0000000800000000ULL;
 
 // FST has cycles containing the initial state.
-constexpr uint64 kInitialCyclic = 0x0000001000000000ULL;
+inline constexpr uint64_t kInitialCyclic = 0x0000001000000000ULL;
 // FST has no cycles containing the initial state.
-constexpr uint64 kInitialAcyclic = 0x0000002000000000ULL;
+inline constexpr uint64_t kInitialAcyclic = 0x0000002000000000ULL;
 
 // FST is topologically sorted.
-constexpr uint64 kTopSorted = 0x0000004000000000ULL;
+inline constexpr uint64_t kTopSorted = 0x0000004000000000ULL;
 // FST is not topologically sorted.
-constexpr uint64 kNotTopSorted = 0x0000008000000000ULL;
+inline constexpr uint64_t kNotTopSorted = 0x0000008000000000ULL;
 
 // All states reachable from the initial state.
-constexpr uint64 kAccessible = 0x0000010000000000ULL;
+inline constexpr uint64_t kAccessible = 0x0000010000000000ULL;
 // Not all states reachable from the initial state.
-constexpr uint64 kNotAccessible = 0x0000020000000000ULL;
+inline constexpr uint64_t kNotAccessible = 0x0000020000000000ULL;
 
 // All states can reach a final state.
-constexpr uint64 kCoAccessible = 0x0000040000000000ULL;
+inline constexpr uint64_t kCoAccessible = 0x0000040000000000ULL;
 // Not all states can reach a final state.
-constexpr uint64 kNotCoAccessible = 0x0000080000000000ULL;
+inline constexpr uint64_t kNotCoAccessible = 0x0000080000000000ULL;
 
 // If NumStates() > 0, then state 0 is initial, state NumStates() - 1 is final,
 // there is a transition from each non-final state i to state i + 1, and there
 // are no other transitions.
-constexpr uint64 kString = 0x0000100000000000ULL;
+inline constexpr uint64_t kString = 0x0000100000000000ULL;
 
 // Not a string FST.
-constexpr uint64 kNotString = 0x0000200000000000ULL;
+inline constexpr uint64_t kNotString = 0x0000200000000000ULL;
 
 // FST has at least one weighted cycle.
-constexpr uint64 kWeightedCycles = 0x0000400000000000ULL;
+inline constexpr uint64_t kWeightedCycles = 0x0000400000000000ULL;
 
 // FST has no weighted cycles. Any cycles that may be present are unweighted.
-constexpr uint64 kUnweightedCycles = 0x0000800000000000ULL;
+inline constexpr uint64_t kUnweightedCycles = 0x0000800000000000ULL;
 
 // COMPOSITE PROPERTIES
 
 // Properties of an empty machine.
-constexpr uint64 kNullProperties =
+inline constexpr uint64_t kNullProperties =
     kAcceptor | kIDeterministic | kODeterministic | kNoEpsilons | kNoIEpsilons |
     kNoOEpsilons | kILabelSorted | kOLabelSorted | kUnweighted | kAcyclic |
     kInitialAcyclic | kTopSorted | kAccessible | kCoAccessible | kString |
     kUnweightedCycles;
 
 // Properties of a string FST compiled into a string.
-constexpr uint64 kCompiledStringProperties =
+inline constexpr uint64_t kCompiledStringProperties =
     kAcceptor | kString | kUnweighted | kIDeterministic | kODeterministic |
     kILabelSorted | kOLabelSorted | kAcyclic | kInitialAcyclic |
     kUnweightedCycles | kTopSorted | kAccessible | kCoAccessible;
 
 // Properties that are preserved when an FST is copied.
-constexpr uint64 kCopyProperties =
+inline constexpr uint64_t kCopyProperties =
     kError | kAcceptor | kNotAcceptor | kIDeterministic | kNonIDeterministic |
     kODeterministic | kNonODeterministic | kEpsilons | kNoEpsilons |
     kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons | kILabelSorted |
@@ -169,7 +170,7 @@ constexpr uint64 kCopyProperties =
     kUnweightedCycles;
 
 // Properties that are intrinsic to the FST.
-constexpr uint64 kIntrinsicProperties =
+inline constexpr uint64_t kIntrinsicProperties =
     kExpanded | kMutable | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -180,10 +181,10 @@ constexpr uint64 kIntrinsicProperties =
     kWeightedCycles | kUnweightedCycles;
 
 // Properties that are (potentially) extrinsic to the FST.
-constexpr uint64 kExtrinsicProperties = kError;
+inline constexpr uint64_t kExtrinsicProperties = kError;
 
 // Properties that are preserved when an FST start state is set.
-constexpr uint64 kSetStartProperties =
+inline constexpr uint64_t kSetStartProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -192,7 +193,7 @@ constexpr uint64 kSetStartProperties =
     kCoAccessible | kNotCoAccessible | kWeightedCycles | kUnweightedCycles;
 
 // Properties that are preserved when an FST final weight is set.
-constexpr uint64 kSetFinalProperties =
+inline constexpr uint64_t kSetFinalProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -202,7 +203,7 @@ constexpr uint64 kSetFinalProperties =
     kUnweightedCycles;
 
 // Properties that are preserved when an FST state is added.
-constexpr uint64 kAddStateProperties =
+inline constexpr uint64_t kAddStateProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -212,31 +213,31 @@ constexpr uint64 kAddStateProperties =
     kNotCoAccessible | kNotString | kWeightedCycles | kUnweightedCycles;
 
 // Properties that are preserved when an FST arc is added.
-constexpr uint64 kAddArcProperties =
+inline constexpr uint64_t kAddArcProperties =
     kExpanded | kMutable | kError | kNotAcceptor | kNonIDeterministic |
     kNonODeterministic | kEpsilons | kIEpsilons | kOEpsilons |
     kNotILabelSorted | kNotOLabelSorted | kWeighted | kCyclic | kInitialCyclic |
     kNotTopSorted | kAccessible | kCoAccessible | kWeightedCycles;
 
 // Properties that are preserved when an FST arc is set.
-constexpr uint64 kSetArcProperties = kExpanded | kMutable | kError;
+inline constexpr uint64_t kSetArcProperties = kExpanded | kMutable | kError;
 
 // Properties that are preserved when FST states are deleted.
-constexpr uint64 kDeleteStatesProperties =
+inline constexpr uint64_t kDeleteStatesProperties =
     kExpanded | kMutable | kError | kAcceptor | kIDeterministic |
     kODeterministic | kNoEpsilons | kNoIEpsilons | kNoOEpsilons |
     kILabelSorted | kOLabelSorted | kUnweighted | kAcyclic | kInitialAcyclic |
     kTopSorted | kUnweightedCycles;
 
 // Properties that are preserved when FST arcs are deleted.
-constexpr uint64 kDeleteArcsProperties =
+inline constexpr uint64_t kDeleteArcsProperties =
     kExpanded | kMutable | kError | kAcceptor | kIDeterministic |
     kODeterministic | kNoEpsilons | kNoIEpsilons | kNoOEpsilons |
     kILabelSorted | kOLabelSorted | kUnweighted | kAcyclic | kInitialAcyclic |
     kTopSorted | kNotAccessible | kNotCoAccessible | kUnweightedCycles;
 
 // Properties that are preserved when an FST's states are reordered.
-constexpr uint64 kStateSortProperties =
+inline constexpr uint64_t kStateSortProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -246,7 +247,7 @@ constexpr uint64 kStateSortProperties =
     kNotCoAccessible | kWeightedCycles | kUnweightedCycles;
 
 // Properties that are preserved when an FST's arcs are reordered.
-constexpr uint64 kArcSortProperties =
+inline constexpr uint64_t kArcSortProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -256,7 +257,7 @@ constexpr uint64 kArcSortProperties =
     kWeightedCycles | kUnweightedCycles;
 
 // Properties that are preserved when an FST's input labels are changed.
-constexpr uint64 kILabelInvariantProperties =
+inline constexpr uint64_t kILabelInvariantProperties =
     kExpanded | kMutable | kError | kODeterministic | kNonODeterministic |
     kOEpsilons | kNoOEpsilons | kOLabelSorted | kNotOLabelSorted | kWeighted |
     kUnweighted | kCyclic | kAcyclic | kInitialCyclic | kInitialAcyclic |
@@ -265,7 +266,7 @@ constexpr uint64 kILabelInvariantProperties =
     kUnweightedCycles;
 
 // Properties that are preserved when an FST's output labels are changed.
-constexpr uint64 kOLabelInvariantProperties =
+inline constexpr uint64_t kOLabelInvariantProperties =
     kExpanded | kMutable | kError | kIDeterministic | kNonIDeterministic |
     kIEpsilons | kNoIEpsilons | kILabelSorted | kNotILabelSorted | kWeighted |
     kUnweighted | kCyclic | kAcyclic | kInitialCyclic | kInitialAcyclic |
@@ -275,7 +276,7 @@ constexpr uint64 kOLabelInvariantProperties =
 
 // Properties that are preserved when an FST's weights are changed. This
 // assumes that the set of states that are non-final is not changed.
-constexpr uint64 kWeightInvariantProperties =
+inline constexpr uint64_t kWeightInvariantProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kNonIDeterministic | kODeterministic | kNonODeterministic | kEpsilons |
     kNoEpsilons | kIEpsilons | kNoIEpsilons | kOEpsilons | kNoOEpsilons |
@@ -286,7 +287,7 @@ constexpr uint64 kWeightInvariantProperties =
 
 // Properties that are preserved when a superfinal state is added and an FST's
 // final weights are directed to it via new transitions.
-constexpr uint64 kAddSuperFinalProperties =
+inline constexpr uint64_t kAddSuperFinalProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor |
     kNonIDeterministic | kNonODeterministic | kEpsilons | kIEpsilons |
     kOEpsilons | kNotILabelSorted | kNotOLabelSorted | kWeighted | kUnweighted |
@@ -296,7 +297,7 @@ constexpr uint64 kAddSuperFinalProperties =
 
 // Properties that are preserved when a superfinal state is removed and the
 // epsilon transitions directed to it are made final weights.
-constexpr uint64 kRmSuperFinalProperties =
+inline constexpr uint64_t kRmSuperFinalProperties =
     kExpanded | kMutable | kError | kAcceptor | kNotAcceptor | kIDeterministic |
     kODeterministic | kNoEpsilons | kNoIEpsilons | kNoOEpsilons |
     kILabelSorted | kOLabelSorted | kWeighted | kUnweighted | kCyclic |
@@ -305,89 +306,93 @@ constexpr uint64 kRmSuperFinalProperties =
     kUnweightedCycles;
 
 // All binary properties.
-constexpr uint64 kBinaryProperties = 0x0000000000000007ULL;
+inline constexpr uint64_t kBinaryProperties = 0x0000000000000007ULL;
 
 // All trinary properties.
-constexpr uint64 kTrinaryProperties = 0x0000ffffffff0000ULL;
+inline constexpr uint64_t kTrinaryProperties = 0x0000ffffffff0000ULL;
 
 // COMPUTED PROPERTIES
 
 // 1st bit of trinary properties.
-constexpr uint64 kPosTrinaryProperties =
+inline constexpr uint64_t kPosTrinaryProperties =
     kTrinaryProperties & 0x5555555555555555ULL;
 
 // 2nd bit of trinary properties.
-constexpr uint64 kNegTrinaryProperties =
+inline constexpr uint64_t kNegTrinaryProperties =
     kTrinaryProperties & 0xaaaaaaaaaaaaaaaaULL;
 
 // All properties.
-constexpr uint64 kFstProperties = kBinaryProperties | kTrinaryProperties;
+inline constexpr uint64_t kFstProperties =
+    kBinaryProperties | kTrinaryProperties;
 
 // PROPERTY FUNCTIONS and STRING NAMES (defined in properties.cc).
 
 // Below are functions for getting property bit vectors when executing
 // mutation operations.
-inline uint64 SetStartProperties(uint64 inprops);
+inline uint64_t SetStartProperties(uint64_t inprops);
 
 template <typename Weight>
-uint64 SetFinalProperties(uint64 inprops, const Weight &old_weight,
-                          const Weight &new_weight);
+uint64_t SetFinalProperties(uint64_t inprops, const Weight &old_weight,
+                            const Weight &new_weight);
 
-inline uint64 AddStateProperties(uint64 inprops);
+inline uint64_t AddStateProperties(uint64_t inprops);
 
 template <typename A>
-uint64 AddArcProperties(uint64 inprops, typename A::StateId s, const A &arc,
-                        const A *prev_arc);
+uint64_t AddArcProperties(uint64_t inprops, typename A::StateId s, const A &arc,
+                          const A *prev_arc);
 
-inline uint64 DeleteStatesProperties(uint64 inprops);
+inline uint64_t DeleteStatesProperties(uint64_t inprops);
 
-inline uint64 DeleteAllStatesProperties(uint64 inprops, uint64 staticProps);
+inline uint64_t DeleteAllStatesProperties(uint64_t inprops,
+                                          uint64_t staticProps);
 
-inline uint64 DeleteArcsProperties(uint64 inprops);
+inline uint64_t DeleteArcsProperties(uint64_t inprops);
 
-uint64 ClosureProperties(uint64 inprops, bool star, bool delayed = false);
+uint64_t ClosureProperties(uint64_t inprops, bool star, bool delayed = false);
 
-uint64 ComplementProperties(uint64 inprops);
+uint64_t ComplementProperties(uint64_t inprops);
 
-uint64 ComposeProperties(uint64 inprops1, uint64 inprops2);
+uint64_t ComposeProperties(uint64_t inprops1, uint64_t inprops2);
 
-uint64 ConcatProperties(uint64 inprops1, uint64 inprops2, bool delayed = false);
+uint64_t ConcatProperties(uint64_t inprops1, uint64_t inprops2,
+                          bool delayed = false);
 
-uint64 DeterminizeProperties(uint64 inprops, bool has_subsequential_label,
-                             bool distinct_psubsequential_labels);
+uint64_t DeterminizeProperties(uint64_t inprops, bool has_subsequential_label,
+                               bool distinct_psubsequential_labels);
 
-uint64 FactorWeightProperties(uint64 inprops);
+uint64_t FactorWeightProperties(uint64_t inprops);
 
-uint64 InvertProperties(uint64 inprops);
+uint64_t InvertProperties(uint64_t inprops);
 
-uint64 ProjectProperties(uint64 inprops, bool project_input);
+uint64_t ProjectProperties(uint64_t inprops, bool project_input);
 
-uint64 RandGenProperties(uint64 inprops, bool weighted);
+uint64_t RandGenProperties(uint64_t inprops, bool weighted);
 
-uint64 RelabelProperties(uint64 inprops);
+uint64_t RelabelProperties(uint64_t inprops);
 
-uint64 ReplaceProperties(const std::vector<uint64> &inprops, size_t root,
-                         bool epsilon_on_call, bool epsilon_on_return,
-                         bool out_epsilon_on_call, bool out_epsilon_on_return,
-                         bool replace_transducer, bool no_empty_fst,
-                         bool all_ilabel_sorted, bool all_olabel_sorted,
-                         bool all_negative_or_dense);
+uint64_t ReplaceProperties(const std::vector<uint64_t> &inprops, size_t root,
+                           bool epsilon_on_call, bool epsilon_on_return,
+                           bool out_epsilon_on_call, bool out_epsilon_on_return,
+                           bool replace_transducer, bool no_empty_fst,
+                           bool all_ilabel_sorted, bool all_olabel_sorted,
+                           bool all_negative_or_dense);
 
-uint64 ReverseProperties(uint64 inprops, bool has_superinitial);
+uint64_t ReverseProperties(uint64_t inprops, bool has_superinitial);
 
-uint64 ReweightProperties(uint64 inprops, bool added_start_epsilon);
+uint64_t ReweightProperties(uint64_t inprops, bool added_start_epsilon);
 
-uint64 RmEpsilonProperties(uint64 inprops, bool delayed = false);
+uint64_t RmEpsilonProperties(uint64_t inprops, bool delayed = false);
 
-uint64 ShortestPathProperties(uint64 props, bool tree = false);
+uint64_t ShortestPathProperties(uint64_t props, bool tree = false);
 
-uint64 SynchronizeProperties(uint64 inprops);
+uint64_t SynchronizeProperties(uint64_t inprops);
 
-uint64 UnionProperties(uint64 inprops1, uint64 inprops2, bool delayed = false);
+uint64_t UnionProperties(uint64_t inprops1, uint64_t inprops2,
+                         bool delayed = false);
 
 // Definitions of inlined functions.
 
-uint64 SetStartProperties(uint64 inprops) {
+uint64_t SetStartProperties(uint64_t inprops) {
   auto outprops = inprops & kSetStartProperties;
   if (inprops & kAcyclic) {
     outprops |= kInitialAcyclic;
@@ -395,28 +400,28 @@ uint64 SetStartProperties(uint64 inprops) {
   return outprops;
 }
 
-uint64 AddStateProperties(uint64 inprops) {
+uint64_t AddStateProperties(uint64_t inprops) {
   return inprops & kAddStateProperties;
 }
 
-uint64 DeleteStatesProperties(uint64 inprops) {
+uint64_t DeleteStatesProperties(uint64_t inprops) {
   return inprops & kDeleteStatesProperties;
 }
 
-uint64 DeleteAllStatesProperties(uint64 inprops, uint64 staticprops) {
+uint64_t DeleteAllStatesProperties(uint64_t inprops, uint64_t staticprops) {
   const auto outprops = inprops & kError;
   return outprops | kNullProperties | staticprops;
 }
 
-uint64 DeleteArcsProperties(uint64 inprops) {
+uint64_t DeleteArcsProperties(uint64_t inprops) {
   return inprops & kDeleteArcsProperties;
 }
 
 // Definitions of template functions.
 
 template <typename Weight>
-uint64 SetFinalProperties(uint64 inprops, const Weight &old_weight,
-                          const Weight &new_weight) {
+uint64_t SetFinalProperties(uint64_t inprops, const Weight &old_weight,
+                            const Weight &new_weight) {
   auto outprops = inprops;
   if (old_weight != Weight::Zero() && old_weight != Weight::One()) {
     outprops &= ~kWeighted;
@@ -437,8 +442,8 @@ uint64 SetFinalProperties(uint64 inprops, const Weight &old_weight,
 /// \param prev_arc the previously-added (or "last") arc of state s, or nullptr
 //                  if s currently has no arcs.
 template <typename Arc>
-uint64 AddArcProperties(uint64 inprops, typename Arc::StateId s, const Arc &arc,
-                        const Arc *prev_arc) {
+uint64_t AddArcProperties(uint64_t inprops, typename Arc::StateId s,
+                          const Arc &arc, const Arc *prev_arc) {
   using Weight = typename Arc::Weight;
   auto outprops = inprops;
   if (arc.ilabel != arc.olabel) {
@@ -484,30 +489,31 @@ uint64 AddArcProperties(uint64 inprops, typename Arc::StateId s, const Arc &arc,
   return outprops;
 }
 
-extern const char *PropertyNames[];
-
 namespace internal {
 
+extern const std::string_view PropertyNames[];
+
 // For a binary property, the bit is always returned set. For a trinary (i.e.,
 // two-bit) property, both bits are returned set iff either corresponding input
 // bit is set.
-inline uint64 KnownProperties(uint64 props) {
+inline uint64_t KnownProperties(uint64_t props) {
   return kBinaryProperties | (props & kTrinaryProperties) |
          ((props & kPosTrinaryProperties) << 1) |
          ((props & kNegTrinaryProperties) >> 1);
 }
 
 // Tests compatibility between two sets of properties.
-inline bool CompatProperties(uint64 props1, uint64 props2) {
+inline bool CompatProperties(uint64_t props1, uint64_t props2) {
   const auto known_props1 = KnownProperties(props1);
   const auto known_props2 = KnownProperties(props2);
   const auto known_props = known_props1 & known_props2;
   const auto incompat_props = (props1 & known_props) ^ (props2 & known_props);
   if (incompat_props) {
-    uint64 prop = 1;
+    uint64_t prop = 1;
     for (int i = 0; i < 64; ++i, prop <<= 1) {
       if (prop & incompat_props) {
-        LOG(ERROR) << "CompatProperties: Mismatch: " << PropertyNames[i]
+        LOG(ERROR) << "CompatProperties: Mismatch: "
+                   << internal::PropertyNames[i]
                    << ": props1 = " << (props1 & prop ? "true" : "false")
                    << ", props2 = " << (props2 & prop ? "true" : "false");
       }
index 6c5f856..3037249 100644 (file)
@@ -21,9 +21,9 @@
 #ifndef FST_PUSH_H_
 #define FST_PUSH_H_
 
+#include <cstdint>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/arc-map.h>
@@ -103,10 +103,10 @@ void Push(MutableFst<Arc> *fst, ReweightType type = REWEIGHT_TO_INITIAL,
   }
 }
 
-constexpr uint8 kPushWeights = 0x01;
-constexpr uint8 kPushLabels = 0x02;
-constexpr uint8 kPushRemoveTotalWeight = 0x04;
-constexpr uint8 kPushRemoveCommonAffix = 0x08;
+inline constexpr uint8_t kPushWeights = 0x01;
+inline constexpr uint8_t kPushLabels = 0x02;
+inline constexpr uint8_t kPushRemoveTotalWeight = 0x04;
+inline constexpr uint8_t kPushRemoveCommonAffix = 0x08;
 
 // Pushes the weights and/or labels of the input FST into the output mutable FST
 // by pushing weights and/or labels (as determined by the ptype argument)
@@ -115,7 +115,7 @@ constexpr uint8 kPushRemoveCommonAffix = 0x08;
 // weights towards the initial state, and right distribution when pushing
 // weights towards the final states.
 template <class Arc, ReweightType rtype>
-void Push(const Fst<Arc> &ifst, MutableFst<Arc> *ofst, uint8 ptype,
+void Push(const Fst<Arc> &ifst, MutableFst<Arc> *ofst, uint8_t ptype,
           float delta = kShortestDelta) {
   using Label = typename Arc::Label;
   using Weight = typename Arc::Weight;
@@ -132,8 +132,8 @@ void Push(const Fst<Arc> &ifst, MutableFst<Arc> *ofst, uint8 ptype,
     if (ptype & kPushWeights) {
       ShortestDistance(gfst, &gdistance, rtype == REWEIGHT_TO_INITIAL, delta);
     } else {
-      auto uwfst = MakeArcMapFst(ifst, RmWeightMapper<Arc>());
-      auto guwfst = MakeArcMapFst(uwfst, ToGallicMapper<Arc, gtype>());
+      ArcMapFst uwfst(ifst, RmWeightMapper<Arc>());
+      ArcMapFst guwfst(uwfst, ToGallicMapper<Arc, gtype>());
       ShortestDistance(guwfst, &gdistance, rtype == REWEIGHT_TO_INITIAL, delta);
     }
     auto total_weight = GallicWeight::One();
index 778df06..d71b92b 100644 (file)
 #ifndef FST_QUEUE_H_
 #define FST_QUEUE_H_
 
+#include <cstdint>
 #include <memory>
 #include <queue>
-#include <stack>
 #include <type_traits>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/arcfilter.h>
@@ -179,20 +178,20 @@ class LifoQueue : public QueueBase<S> {
 
   ~LifoQueue() override = default;
 
-  StateId Head() const final { return stack_.top(); }
+  StateId Head() const final { return stack_.back(); }
 
-  void Enqueue(StateId s) final { stack_.push(s); }
+  void Enqueue(StateId s) final { stack_.push_back(s); }
 
-  void Dequeue() final { stack_.pop(); }
+  void Dequeue() final { stack_.pop_back(); }
 
   void Update(StateId) final {}
 
   bool Empty() const final { return stack_.empty(); }
 
-  void Clear() final { stack_ = std::stack<StateId>(); }
+  void Clear() final { stack_.clear(); }
 
  private:
-  std::stack<StateId> stack_;
+  std::vector<StateId> stack_;
 };
 
 // Shortest-first queue discipline, templated on the StateId and as well as a
@@ -655,11 +654,11 @@ class AutoQueue : public QueueBase<S> {
     } else if (props & kAcyclic) {
       queue_ = std::make_unique<TopOrderQueue<StateId>>(fst, filter);
       VLOG(2) << "AutoQueue: using top-order discipline";
-    } else if ((props & kUnweighted) && (Weight::Properties() & kIdempotent)) {
+    } else if ((props & kUnweighted) && IsIdempotent<Weight>::value) {
       queue_ = std::make_unique<LifoQueue<StateId>>();
       VLOG(2) << "AutoQueue: using LIFO discipline";
     } else {
-      uint64 properties;
+      uint64_t properties;
       // Decomposes into strongly-connected components.
       SccVisitor<Arc> scc_visitor(&scc_, nullptr, nullptr, &properties);
       DfsVisit(fst, &scc_visitor, filter);
@@ -703,8 +702,8 @@ class AutoQueue : public QueueBase<S> {
             // The IsPath test is not needed for correctness. It just saves
             // instantiating a ShortestFirstQueue that can never be called.
             if constexpr (IsPath<Weight>::value) {
-              queues_[i].reset(
-                  new ShortestFirstQueue<StateId, Compare, false>(*comp));
+              queues_[i] = std::make_unique<
+                  ShortestFirstQueue<StateId, Compare, false>>(*comp);
               VLOG(3) << "AutoQueue: SCC #" << i
                       << ": using shortest-first discipline";
             } else {
@@ -789,7 +788,7 @@ void AutoQueue<StateId>::SccQueueType(const Fst<Arc> &fst,
         } else if (!less || (*less)(arc.weight, Weight::One())) {
           type = FIFO_QUEUE;
         } else if ((type == TRIVIAL_QUEUE) || (type == LIFO_QUEUE)) {
-          if (!(Weight::Properties() & kIdempotent) ||
+          if (!IsIdempotent<Weight>::value ||
               (arc.weight != Weight::Zero() && arc.weight != Weight::One())) {
             type = SHORTEST_FIRST_QUEUE;
           } else {
@@ -798,7 +797,7 @@ void AutoQueue<StateId>::SccQueueType(const Fst<Arc> &fst,
         }
         if (type != TRIVIAL_QUEUE) *all_trivial = false;
       }
-      if (!(Weight::Properties() & kIdempotent) ||
+      if (!IsIdempotent<Weight>::value ||
           (arc.weight != Weight::Zero() && arc.weight != Weight::One())) {
         *unweighted = false;
       }
@@ -832,9 +831,6 @@ class NaturalAStarEstimate {
   const std::vector<Weight> &beta_;
 };
 
-template <typename Arc, typename Weight>
-constexpr Weight NaturalAStarEstimate<Arc, Weight>::kZero;
-
 // Given a vector that maps from states to weights representing the shortest
 // distance from the initial state, a comparison function object between
 // weights, and an estimate of the shortest distance to the final states, this
@@ -897,8 +893,7 @@ struct TrivialStateEquivClass {
 // shortest distance (so far), as specified by distance, is less than (as
 // specified by comp) the shortest distance Times() the threshold to any state
 // in the same equivalence class, as specified by the functor class_func. The
-// underlying queue discipline is specified by queue. The ownership of queue is
-// given to this class.
+// underlying queue discipline is specified by queue.
 //
 // This is not a final class.
 template <typename Queue, typename Less, typename ClassFnc>
@@ -907,11 +902,11 @@ class PruneQueue : public QueueBase<typename Queue::StateId> {
   using StateId = typename Queue::StateId;
   using Weight = typename Less::Weight;
 
-  PruneQueue(const std::vector<Weight> &distance, Queue *queue,
+  PruneQueue(const std::vector<Weight> &distance, std::unique_ptr<Queue> queue,
              const Less &less, const ClassFnc &class_fnc, Weight threshold)
       : QueueBase<StateId>(OTHER_QUEUE),
         distance_(distance),
-        queue_(queue),
+        queue_(std::move(queue)),
         less_(less),
         class_fnc_(class_fnc),
         threshold_(std::move(threshold)) {}
@@ -965,25 +960,28 @@ class NaturalPruneQueue final
  public:
   using StateId = typename Queue::StateId;
 
-  NaturalPruneQueue(const std::vector<Weight> &distance, Queue *queue,
-                    const ClassFnc &class_fnc, Weight threshold)
+  NaturalPruneQueue(const std::vector<Weight> &distance,
+                    std::unique_ptr<Queue> queue, const ClassFnc &class_fnc,
+                    Weight threshold)
       : PruneQueue<Queue, NaturalLess<Weight>, ClassFnc>(
-            distance, queue, NaturalLess<Weight>(), class_fnc, threshold) {}
+            distance, std::move(queue), NaturalLess<Weight>(), class_fnc,
+            threshold) {}
 
   ~NaturalPruneQueue() override = default;
 };
 
 // Filter-based pruning queue discipline: enqueues a state only if allowed by
 // the filter, specified by the state filter functor argument. The underlying
-// queue discipline is specified by the queue argument. The ownership of the
-// queue is given to this class.
+// queue discipline is specified by the queue argument.
 template <typename Queue, typename Filter>
 class FilterQueue : public QueueBase<typename Queue::StateId> {
  public:
   using StateId = typename Queue::StateId;
 
-  FilterQueue(Queue *queue, const Filter &filter)
-      : QueueBase<StateId>(OTHER_QUEUE), queue_(queue), filter_(filter) {}
+  FilterQueue(std::unique_ptr<Queue> queue, const Filter &filter)
+      : QueueBase<StateId>(OTHER_QUEUE),
+        queue_(std::move(queue)),
+        filter_(filter) {}
 
   ~FilterQueue() override = default;
 
index f5066c3..9562b1d 100644 (file)
@@ -21,9 +21,9 @@
 #ifndef FST_RANDEQUIVALENT_H_
 #define FST_RANDEQUIVALENT_H_
 
+#include <cstdint>
 #include <random>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/arcsort.h>
@@ -32,6 +32,7 @@
 #include <fst/randgen.h>
 #include <fst/shortest-distance.h>
 #include <fst/vector-fst.h>
+#include <fst/weight.h>
 
 
 namespace fst {
@@ -45,9 +46,10 @@ namespace fst {
 // generated path and checks that these two values are within a user-specified
 // delta. Returns optional error value (when FST_FLAGS_error_fatal = false).
 template <class Arc, class ArcSelector>
-bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32 npath,
+bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32_t npath,
                     const RandGenOptions<ArcSelector> &opts,
-                    float delta = kDelta, uint64 seed = std::random_device()(),
+                    float delta = kDelta,
+                    uint64_t seed = std::random_device()(),
                     bool *error = nullptr) {
   using Weight = typename Arc::Weight;
   if (error) *error = false;
@@ -71,7 +73,7 @@ bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32 npath,
   bool result = true;
   std::mt19937 rand(seed);
   std::bernoulli_distribution coin(.5);
-  for (int32 n = 0; n < npath; ++n) {
+  for (int32_t n = 0; n < npath; ++n) {
     VectorFst<Arc> path;
     const auto &fst = coin(rand) ? sfst1 : sfst2;
     RandGen(fst, &path, opts);
@@ -84,8 +86,7 @@ bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32 npath,
     ArcSort(&cfst1, ocomp);
     Compose(cfst1, opath, &pfst1);
     // Gives up if there are epsilon cycles in a non-idempotent semiring.
-    if (!(Weight::Properties() & kIdempotent) &&
-        pfst1.Properties(kCyclic, true)) {
+    if (!IsIdempotent<Weight>::value && pfst1.Properties(kCyclic, true)) {
       continue;
     }
     const auto sum1 = ShortestDistance(pfst1);
@@ -95,8 +96,7 @@ bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32 npath,
     VectorFst<Arc> pfst2;
     Compose(cfst2, opath, &pfst2);
     // Gives up if there are epsilon cycles in a non-idempotent semiring.
-    if (!(Weight::Properties() & kIdempotent) &&
-        pfst2.Properties(kCyclic, true)) {
+    if (!IsIdempotent<Weight>::value && pfst2.Properties(kCyclic, true)) {
       continue;
     }
     const auto sum2 = ShortestDistance(pfst2);
@@ -118,9 +118,10 @@ bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32 npath,
 // (no longer than the path_length) using a user-specified seed, optionally
 // indicating an error setting an optional error argument to true.
 template <class Arc>
-bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32 npath,
-                    float delta = kDelta, uint64 seed = std::random_device()(),
-                    int32 max_length = std::numeric_limits<int32>::max(),
+bool RandEquivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2, int32_t npath,
+                    float delta = kDelta,
+                    uint64_t seed = std::random_device()(),
+                    int32_t max_length = std::numeric_limits<int32_t>::max(),
                     bool *error = nullptr) {
   const UniformArcSelector<Arc> uniform_selector(seed);
   const RandGenOptions<UniformArcSelector<Arc>> opts(uniform_selector,
index 14c4535..d847d7e 100644 (file)
@@ -23,6 +23,7 @@
 #include <algorithm>
 #include <cmath>
 #include <cstddef>
+#include <cstdint>
 #include <limits>
 #include <map>
 #include <memory>
@@ -31,7 +32,6 @@
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/accumulator.h>
@@ -69,7 +69,7 @@ class UniformArcSelector {
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
 
-  explicit UniformArcSelector(uint64 seed = std::random_device()())
+  explicit UniformArcSelector(uint64_t seed = std::random_device()())
       : rand_(seed) {}
 
   size_t operator()(const Fst<Arc> &fst, StateId s) const {
@@ -97,7 +97,7 @@ class LogProbArcSelector {
   LogProbArcSelector() : seed_(std::random_device()()), rand_(seed_) {}
 
   // Constructs a selector with a given seed.
-  explicit LogProbArcSelector(uint64 seed) : seed_(seed), rand_(seed) {}
+  explicit LogProbArcSelector(uint64_t seed) : seed_(seed), rand_(seed) {}
 
   size_t operator()(const Fst<Arc> &fst, StateId s) const {
     // Finds total weight leaving state.
@@ -119,7 +119,7 @@ class LogProbArcSelector {
     return n;
   }
 
-  uint64 Seed() const { return seed_; }
+  uint64_t Seed() const { return seed_; }
 
  protected:
   Log64Weight ToLogWeight(const Weight &weight) const {
@@ -129,7 +129,7 @@ class LogProbArcSelector {
   std::mt19937_64 &MutableRand() const { return rand_; }
 
  private:
-  const uint64 seed_;
+  const uint64_t seed_;
   mutable std::mt19937_64 rand_;
   const WeightConvert<Weight, Log64Weight> to_log_weight_{};
 };
@@ -152,7 +152,7 @@ class FastLogProbArcSelector : public LogProbArcSelector<Arc> {
   // Constructs a selector with a non-deterministic seed.
   FastLogProbArcSelector() : LogProbArcSelector<Arc>() {}
   // Constructs a selector with a given seed.
-  explicit FastLogProbArcSelector(uint64 seed)
+  explicit FastLogProbArcSelector(uint64_t seed)
       : LogProbArcSelector<Arc>(seed) {}
 
   size_t operator()(const Fst<Arc> &fst, StateId s,
@@ -209,7 +209,7 @@ class ArcSampler {
   // The max_length argument may be interpreted (or ignored) by a selector as
   // it chooses. This generic version interprets this literally.
   ArcSampler(const Fst<Arc> &fst, const Selector &selector,
-             int32 max_length = std::numeric_limits<int32>::max())
+             int32_t max_length = std::numeric_limits<int32_t>::max())
       : fst_(fst), selector_(selector), max_length_(max_length) {}
 
   // Allow updating FST argument; pass only if changed.
@@ -257,7 +257,7 @@ class ArcSampler {
  private:
   const Fst<Arc> &fst_;
   const Selector &selector_;
-  const int32 max_length_;
+  const int32_t max_length_;
 
   // Stores (N, K) as described for Value().
   std::map<size_t, size_t> sample_map_;
@@ -303,7 +303,7 @@ class ArcSampler<Arc, FastLogProbArcSelector<Arc>> {
   using Selector = FastLogProbArcSelector<Arc>;
 
   ArcSampler(const Fst<Arc> &fst, const Selector &selector,
-             int32 max_length = std::numeric_limits<int32>::max())
+             int32_t max_length = std::numeric_limits<int32_t>::max())
       : fst_(fst),
         selector_(selector),
         max_length_(max_length),
@@ -380,7 +380,7 @@ class ArcSampler<Arc, FastLogProbArcSelector<Arc>> {
 
   const Fst<Arc> &fst_;
   const Selector &selector_;
-  const int32 max_length_;
+  const int32_t max_length_;
 
   // Stores (N, K) for Value().
   std::map<size_t, size_t> sample_map_;
@@ -398,13 +398,14 @@ class ArcSampler<Arc, FastLogProbArcSelector<Arc>> {
 template <class Sampler>
 struct RandGenFstOptions : public CacheOptions {
   Sampler *sampler;          // How to sample transitions at a state.
-  int32 npath;               // Number of paths to generate.
+  int32_t npath;             // Number of paths to generate.
   bool weighted;             // Is the output tree weighted by path count, or
                              // is it just an unweighted DAG?
   bool remove_total_weight;  // Remove total weight when output is weighted.
 
-  RandGenFstOptions(const CacheOptions &opts, Sampler *sampler, int32 npath = 1,
-                    bool weighted = true, bool remove_total_weight = false)
+  RandGenFstOptions(const CacheOptions &opts, Sampler *sampler,
+                    int32_t npath = 1, bool weighted = true,
+                    bool remove_total_weight = false)
       : CacheOptions(opts),
         sampler(sampler),
         npath(npath),
@@ -498,10 +499,10 @@ class RandGenFstImpl : public CacheImpl<ToArc> {
     return CacheImpl<ToArc>::NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) &&
         (fst_->Properties(kError, false) || sampler_->Error())) {
       SetProperties(kError, kError);
@@ -565,7 +566,7 @@ class RandGenFstImpl : public CacheImpl<ToArc> {
  private:
   const std::unique_ptr<Fst<FromArc>> fst_;
   std::unique_ptr<Sampler> sampler_;
-  const int32 npath_;
+  const int32_t npath_;
   std::vector<std::unique_ptr<RandState<FromArc>>> state_table_;
   const bool weighted_;
   bool remove_total_weight_;
@@ -654,16 +655,17 @@ inline void RandGenFst<FromArc, ToArc, Sampler>::InitStateIterator(
 template <class Selector>
 struct RandGenOptions {
   const Selector &selector;  // How an arc is selected at a state.
-  int32 max_length;          // Maximum path length.
-  int32 npath;               // Number of paths to generate.
+  int32_t max_length;        // Maximum path length.
+  int32_t npath;             // Number of paths to generate.
   bool weighted;             // Is the output tree weighted by path count, or
                              // is it just an unweighted DAG?
   bool remove_total_weight;  // Remove total weight when output is weighted?
 
-  explicit RandGenOptions(const Selector &selector,
-                          int32 max_length = std::numeric_limits<int32>::max(),
-                          int32 npath = 1, bool weighted = false,
-                          bool remove_total_weight = false)
+  explicit RandGenOptions(
+      const Selector &selector,
+      int32_t max_length = std::numeric_limits<int32_t>::max(),
+      int32_t npath = 1, bool weighted = false,
+      bool remove_total_weight = false)
       : selector(selector),
         max_length(max_length),
         npath(npath),
@@ -766,7 +768,7 @@ void RandGen(const Fst<FromArc> &ifst, MutableFst<ToArc> *ofst,
 // over the transitions.
 template <class FromArc, class ToArc>
 void RandGen(const Fst<FromArc> &ifst, MutableFst<ToArc> *ofst,
-             uint64 seed = std::random_device()()) {
+             uint64_t seed = std::random_device()()) {
   const UniformArcSelector<FromArc> uniform_selector(seed);
   RandGenOptions<UniformArcSelector<ToArc>> opts(uniform_selector);
   RandGen(ifst, ofst, opts);
index 19d2e87..3bfa521 100644 (file)
 #define FST_RATIONAL_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/mutable-fst.h>
 #include <fst/replace.h>
@@ -108,10 +108,10 @@ class RationalFstImpl : public FstImpl<A> {
     return Replace()->NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && Replace()->Properties(kError, false)) {
       SetProperties(kError, kError);
     }
index 4fd9996..af1b360 100644 (file)
@@ -30,6 +30,7 @@
 
 
 #include <fst/log.h>
+#include <string_view>
 
 namespace fst {
 
@@ -61,19 +62,20 @@ class FstRegister : public GenericRegister<std::string, FstRegisterEntry<Arc>,
   using Reader = typename FstRegisterEntry<Arc>::Reader;
   using Converter = typename FstRegisterEntry<Arc>::Converter;
 
-  const Reader GetReader(const std::string &type) const {
+  const Reader GetReader(std::string_view type) const {
     return this->GetEntry(type).reader;
   }
 
-  const Converter GetConverter(const std::string &type) const {
+  const Converter GetConverter(std::string_view type) const {
     return this->GetEntry(type).converter;
   }
 
  protected:
-  std::string ConvertKeyToSoFilename(const std::string &key) const override {
+  std::string ConvertKeyToSoFilename(std::string_view key) const override {
     std::string legal_type(key);
     ConvertToLegalCSymbol(&legal_type);
-    return legal_type + "-fst.so";
+    legal_type.append("-fst.so");
+    return legal_type;
   }
 };
 
@@ -93,7 +95,7 @@ class FstRegisterer : public GenericRegisterer<FstRegister<typename FST::Arc>> {
 
  private:
   static Fst<Arc> *ReadGeneric(std::istream &strm, const FstReadOptions &opts) {
-    static_assert(std::is_base_of<Fst<Arc>, FST>::value,
+    static_assert(std::is_base_of_v<Fst<Arc>, FST>,
                   "FST class does not inherit from Fst<Arc>");
     return FST::Read(strm, opts);
   }
@@ -118,7 +120,7 @@ class FstRegisterer : public GenericRegisterer<FstRegister<typename FST::Arc>> {
 
 // Converts an FST to the specified type.
 template <class Arc>
-Fst<Arc> *Convert(const Fst<Arc> &fst, const std::string &fst_type) {
+Fst<Arc> *Convert(const Fst<Arc> &fst, std::string_view fst_type) {
   auto *reg = FstRegister<Arc>::GetRegister();
   const auto converter = reg->GetConverter(fst_type);
   if (!converter) {
index 5652f78..fcc7876 100644 (file)
 #ifndef FST_RELABEL_H_
 #define FST_RELABEL_H_
 
+#include <cstdint>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
@@ -183,7 +183,7 @@ void Relabel(MutableFst<Arc> *fst, const SymbolTable *old_isymbols,
              bool attach_new_osymbols) {
   Relabel(fst, old_isymbols, new_isymbols, "" /* no unknown isymbol */,
           attach_new_isymbols, old_osymbols, new_osymbols,
-          "" /* no unknown ioymbol */, attach_new_osymbols);
+          "" /* no unknown osymbol */, attach_new_osymbols);
 }
 
 // Relabels either the input labels or output labels. The old to
@@ -315,10 +315,10 @@ class RelabelFstImpl : public CacheImpl<Arc> {
     return CacheImpl<Arc>::NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && fst_->Properties(kError, false)) {
       SetProperties(kError, kError);
     }
index aa03c55..0c3e72b 100644 (file)
 #ifndef FST_REPLACE_UTIL_H_
 #define FST_REPLACE_UTIL_H_
 
+#include <cstdint>
 #include <map>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/connect.h>
@@ -55,23 +55,23 @@ enum ReplaceLabelType {
 // The call_label_type and return_label_type options specify how to manage
 // the labels of the call arc and the return arc of the replace FST
 struct ReplaceUtilOptions {
-  int64 root;                          // Root rule for expansion.
+  int64_t root;                        // Root rule for expansion.
   ReplaceLabelType call_label_type;    // How to label call arc.
   ReplaceLabelType return_label_type;  // How to label return arc.
-  int64 return_label;                  // Label to put on return arc.
+  int64_t return_label;                // Label to put on return arc.
 
   explicit ReplaceUtilOptions(
-      int64 root = kNoLabel,
+      int64_t root = kNoLabel,
       ReplaceLabelType call_label_type = REPLACE_LABEL_INPUT,
       ReplaceLabelType return_label_type = REPLACE_LABEL_NEITHER,
-      int64 return_label = 0)
+      int64_t return_label = 0)
       : root(root),
         call_label_type(call_label_type),
         return_label_type(return_label_type),
         return_label(return_label) {}
 
   // For backwards compatibility.
-  ReplaceUtilOptions(int64 root, bool epsilon_replace_arc)
+  ReplaceUtilOptions(int64_t root, bool epsilon_replace_arc)
       : ReplaceUtilOptions(root, epsilon_replace_arc ? REPLACE_LABEL_NEITHER
                                                      : REPLACE_LABEL_INPUT) {}
 };
@@ -79,14 +79,14 @@ struct ReplaceUtilOptions {
 // Every non-terminal on a path appears as the first label on that path in every
 // FST associated with a given SCC of the replace dependency graph. This would
 // be true if the SCC were formed from left-linear grammar rules.
-constexpr uint8 kReplaceSCCLeftLinear = 0x01;
+inline constexpr uint8_t kReplaceSCCLeftLinear = 0x01;
 // Every non-terminal on a path appears as the final label on that path in every
 // FST associated with a given SCC of the replace dependency graph. This would
 // be true if the SCC were formed from right-linear grammar rules.
-constexpr uint8 kReplaceSCCRightLinear = 0x02;
+inline constexpr uint8_t kReplaceSCCRightLinear = 0x02;
 // The SCC in the replace dependency graph has more than one state or a
 // self-loop.
-constexpr uint8 kReplaceSCCNonTrivial = 0x04;
+inline constexpr uint8_t kReplaceSCCNonTrivial = 0x04;
 
 // Defined in replace.h.
 template <class Arc>
@@ -149,7 +149,7 @@ class ReplaceUtil {
   // kReplaceSCCRightLinear, that SCC can be represented as finite-state despite
   // any cyclic dependencies, but not by the usual replacement operation (see
   // fst/extensions/pdt/replace.h).
-  uint8 SCCProperties(StateId scc_id) {
+  uint8_t SCCProperties(StateId scc_id) {
     GetSCCProperties();
     return depsccprops_[scc_id];
   }
@@ -158,7 +158,7 @@ class ReplaceUtil {
   // RTN.
   bool Connected() const {
     GetDependencies(false);
-    uint64 props = kAccessible | kCoAccessible;
+    uint64_t props = kAccessible | kCoAccessible;
     for (Label i = 0; i < fst_array_.size(); ++i) {
       if (!fst_array_[i]) continue;
       if (fst_array_[i]->Properties(props, true) != props || !depaccess_[i]) {
@@ -241,7 +241,7 @@ class ReplaceUtil {
   Label root_fst_;                                    // Root FST ID.
   ReplaceLabelType call_label_type_;                  // See Replace().
   ReplaceLabelType return_label_type_;                // See Replace().
-  int64 return_label_;                                // See Replace().
+  int64_t return_label_;                              // See Replace().
   std::vector<const Fst<Arc> *> fst_array_;           // FST per ID.
   std::vector<MutableFst<Arc> *> mutable_fst_array_;  // Mutable FST per ID.
   std::vector<Label> nonterminal_array_;              // FST ID to non-terminal.
@@ -249,10 +249,10 @@ class ReplaceUtil {
   mutable VectorFst<Arc> depfst_;                     // FST ID dependencies.
   mutable std::vector<StateId> depscc_;               // FST SCC ID.
   mutable std::vector<bool> depaccess_;               // FST ID accessibility.
-  mutable uint64 depprops_;                           // Dependency FST props.
+  mutable uint64_t depprops_;                         // Dependency FST props.
   mutable bool have_stats_;                  // Have dependency statistics?
   mutable std::vector<ReplaceStats> stats_;  // Per-FST statistics.
-  mutable std::vector<uint8> depsccprops_;   // SCC properties.
+  mutable std::vector<uint8_t> depsccprops_;  // SCC properties.
   ReplaceUtil(const ReplaceUtil &) = delete;
   ReplaceUtil &operator=(const ReplaceUtil &) = delete;
 };
@@ -613,7 +613,7 @@ void ReplaceUtil<Arc>::GetSCCProperties() const {
     }
     depscc_visited[depscc] = true;
     std::vector<StateId> fstscc;  // SCCs of the current FST.
-    uint64 fstprops;
+    uint64_t fstprops;
     SccVisitor<Arc> scc_visitor(&fstscc, nullptr, nullptr, &fstprops);
     DfsVisit(*fst, &scc_visitor);
     for (StateIterator<Fst<Arc>> siter(*fst); !siter.Done(); siter.Next()) {
index 9366bc0..af78630 100644 (file)
 #ifndef FST_REPLACE_H_
 #define FST_REPLACE_H_
 
+#include <cstdint>
 #include <set>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/cache.h>
@@ -111,23 +111,23 @@ class ReplaceRootSelector {
 template <class StateId, class PrefixId>
 class ReplaceFingerprint {
  public:
-  explicit ReplaceFingerprint(const std::vector<uint64> *size_array)
+  explicit ReplaceFingerprint(const std::vector<uint64_t> *size_array)
       : size_array_(size_array) {}
 
-  uint64 operator()(const ReplaceStateTuple<StateId, PrefixId> &tuple) const {
+  uint64_t operator()(const ReplaceStateTuple<StateId, PrefixId> &tuple) const {
     return tuple.prefix_id * size_array_->back() +
            size_array_->at(tuple.fst_id - 1) + tuple.fst_state;
   }
 
  private:
-  const std::vector<uint64> *size_array_;
+  const std::vector<uint64_t> *size_array_;
 };
 
 // Useful when the fst_state uniquely define the tuple.
 template <class StateId, class PrefixId>
 class ReplaceFstStateFingerprint {
  public:
-  uint64 operator()(const ReplaceStateTuple<StateId, PrefixId> &tuple) const {
+  uint64_t operator()(const ReplaceStateTuple<StateId, PrefixId> &tuple) const {
     return tuple.fst_state;
   }
 };
@@ -137,9 +137,30 @@ template <typename S, typename P>
 class ReplaceHash {
  public:
   size_t operator()(const ReplaceStateTuple<S, P> &t) const {
+    // TODO(189578616): Use the AbslHashValue framework.  See
+    // b/189578616#comment8 for a proposed patch and a discussion of the
+    // concerns for making such a change.
+    //
+    // We want three prime numbers that are all reasonably large and whose
+    // differences are far from each other.  (E.g., we want prime1-prime0 to be
+    // far from prime2-prime1).  It would be safer still to use large prime
+    // numbers (i.e., prime numbers that use all 64 bits on a 64-bit machine and
+    // all 32-bits on a 32-bit machine), so that all 64-bits (respectively
+    // 32-bits) of the resulting hash would look random.  However, these
+    // modest-sized prime numbers are good enough for hash tables (such as
+    // std::unordered_set and std::unordered_set) that use the low-order bits
+    // of the hash.
+    //
+    // It is important that all three components are multiplied by a prime
+    // number.  E.g., don't compute
+    //   t.prefix_id + t.fst_id * prime1 + t.fst_state * prime2
+    // which is just the identity on t.prefix_id.  Using the identity will
+    // result in long probe sequences in open-addressed hash tables (such as
+    // std::unordered_map).
     static constexpr size_t prime0 = 7853;
-    static constexpr size_t prime1 = 7867;
-    return t.prefix_id + t.fst_id * prime0 + t.fst_state * prime1;
+    static constexpr size_t prime1 = 9001;
+    static constexpr size_t prime2 = 100003;
+    return t.prefix_id * prime0 + t.fst_id * prime1 + t.fst_state * prime2;
   }
 };
 
@@ -230,20 +251,20 @@ class VectorHashReplaceStateTable {
       Label root)
       : root_size_(0) {
     size_array_.push_back(0);
-    for (const auto &fst_pair : fst_list) {
-      if (fst_pair.first == root) {
-        root_size_ = CountStates(*(fst_pair.second));
+    for (const auto &[label, fst] : fst_list) {
+      if (label == root) {
+        root_size_ = CountStates(*fst);
         size_array_.push_back(size_array_.back());
       } else {
         size_array_.push_back(size_array_.back() +
-                              CountStates(*(fst_pair.second)));
+                              CountStates(*fst));
       }
     }
-    state_table_.reset(
-        new StateTable(ReplaceRootSelector<StateId, PrefixId>(),
-                       ReplaceFstStateFingerprint<StateId, PrefixId>(),
-                       ReplaceFingerprint<StateId, PrefixId>(&size_array_),
-                       root_size_, root_size_ + size_array_.back()));
+    state_table_ = std::make_unique<StateTable>(
+        ReplaceRootSelector<StateId, PrefixId>(),
+        ReplaceFstStateFingerprint<StateId, PrefixId>(),
+        ReplaceFingerprint<StateId, PrefixId>(&size_array_), root_size_,
+        root_size_ + size_array_.back());
   }
 
   VectorHashReplaceStateTable(
@@ -251,11 +272,11 @@ class VectorHashReplaceStateTable {
       : root_size_(table.root_size_),
         size_array_(table.size_array_),
         prefix_table_(table.prefix_table_) {
-    state_table_.reset(
-        new StateTable(ReplaceRootSelector<StateId, PrefixId>(),
-                       ReplaceFstStateFingerprint<StateId, PrefixId>(),
-                       ReplaceFingerprint<StateId, PrefixId>(&size_array_),
-                       root_size_, root_size_ + size_array_.back()));
+    state_table_ = std::make_unique<StateTable>(
+        ReplaceRootSelector<StateId, PrefixId>(),
+        ReplaceFstStateFingerprint<StateId, PrefixId>(),
+        ReplaceFingerprint<StateId, PrefixId>(&size_array_), root_size_,
+        root_size_ + size_array_.back());
   }
 
   StateId FindState(const StateTuple &tuple) {
@@ -274,7 +295,7 @@ class VectorHashReplaceStateTable {
 
  private:
   StateId root_size_;
-  std::vector<uint64> size_array_;
+  std::vector<uint64_t> size_array_;
   std::unique_ptr<StateTable> state_table_;
   StackPrefixTable prefix_table_;
 };
@@ -381,7 +402,7 @@ struct ReplaceFstOptions : CacheImplOptions<CacheStore> {
   ReplaceFstOptions() : root(kNoLabel) {}
 
   // For backwards compatibility.
-  ReplaceFstOptions(int64 root, bool epsilon_replace_arc)
+  ReplaceFstOptions(int64_t root, bool epsilon_replace_arc)
       : root(root),
         call_label_type(epsilon_replace_arc ? REPLACE_LABEL_NEITHER
                                             : REPLACE_LABEL_INPUT),
@@ -421,14 +442,14 @@ bool ReplaceTransducer(ReplaceLabelType call_label_type,
 }
 
 template <class Arc>
-uint64 ReplaceFstProperties(typename Arc::Label root_label,
-                            const FstList<Arc> &fst_list,
-                            ReplaceLabelType call_label_type,
-                            ReplaceLabelType return_label_type,
-                            typename Arc::Label call_output_label,
-                            bool *sorted_and_non_empty) {
+uint64_t ReplaceFstProperties(typename Arc::Label root_label,
+                              const FstList<Arc> &fst_list,
+                              ReplaceLabelType call_label_type,
+                              ReplaceLabelType return_label_type,
+                              typename Arc::Label call_output_label,
+                              bool *sorted_and_non_empty) {
   using Label = typename Arc::Label;
-  std::vector<uint64> inprops;
+  std::vector<uint64_t> inprops;
   bool all_ilabel_sorted = true;
   bool all_olabel_sorted = true;
   bool all_non_empty = true;
@@ -717,10 +738,10 @@ class ReplaceFstImpl
     }
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if (mask & kError) {
       for (Label i = 1; i < fst_array_.size(); ++i) {
         if (fst_array_[i]->Properties(kError, false)) {
@@ -779,7 +800,7 @@ class ReplaceFstImpl
   // If acpp is null, only returns true if a final arcp is required, but does
   // not actually compute it.
   bool ComputeFinalArc(const StateTuple &tuple, Arc *arcp,
-                       uint8 flags = kArcValueFlags) {
+                       uint8_t flags = kArcValueFlags) {
     const auto fst_state = tuple.fst_state;
     if (fst_state == kNoStateId) return false;
     // If state is final, pops the stack.
@@ -810,7 +831,7 @@ class ReplaceFstImpl
   // Returns false if the underlying arc corresponds to no arc in the resulting
   // FST.
   bool ComputeArc(const StateTuple &tuple, const Arc &arc, Arc *arcp,
-                  uint8 flags = kArcValueFlags) {
+                  uint8_t flags = kArcValueFlags) {
     if (!EpsilonOnInput(call_label_type_) &&
         (flags == (flags & (kArcILabelValue | kArcWeightValue)))) {
       *arcp = arc;
@@ -864,8 +885,8 @@ class ReplaceFstImpl
   }
 
   // Returns the arc iterator flags supported by this FST.
-  uint8 ArcIteratorFlags() const {
-    uint8 flags = kArcValueFlags;
+  uint8_t ArcIteratorFlags() const {
+    uint8_t flags = kArcValueFlags;
     if (!always_cache_) flags |= kArcNoCache;
     return flags;
   }
@@ -909,8 +930,8 @@ class ReplaceFstImpl
   // Runtime options
   ReplaceLabelType call_label_type_;    // How to label call arc.
   ReplaceLabelType return_label_type_;  // How to label return arc.
-  int64 call_output_label_;  // Specifies output label to put on call arc
-  int64 return_label_;       // Specifies label to put on return arc.
+  int64_t call_output_label_;  // Specifies output label to put on call arc
+  int64_t return_label_;       // Specifies label to put on return arc.
   bool always_cache_;        // Disable optional caching of arc iterator?
 
   // State table.
@@ -1207,9 +1228,9 @@ class ArcIterator<ReplaceFst<Arc, StateTable, CacheStore>> {
 
   void Seek(size_t pos) { pos_ = pos; }
 
-  uint8 Flags() const { return flags_; }
+  uint8_t Flags() const { return flags_; }
 
-  void SetFlags(uint8 flags, uint8 mask) {
+  void SetFlags(uint8_t flags, uint8_t mask) {
     // Updates the flags taking into account what flags are supported
     // by the FST.
     flags_ &= ~mask;
@@ -1233,16 +1254,16 @@ class ArcIterator<ReplaceFst<Arc, StateTable, CacheStore>> {
   ssize_t pos_;             // Current position.
   mutable ssize_t offset_;  // Offset between position in iterator and in arcs_.
   ssize_t num_arcs_;        // Number of arcs at state_.
-  uint8 flags_;             // Behavorial flags for the arc iterator
+  uint8_t flags_;           // Behavorial flags for the arc iterator
   mutable Arc arc_;         // Memory to temporarily store computed arcs.
 
   mutable ArcIteratorData<Arc> cache_data_;  // Arc iterator data in cache.
   mutable ArcIteratorData<Arc> local_data_;  // Arc iterator data in local FST.
 
   mutable const Arc *arcs_;    // Array of arcs.
-  mutable uint8 data_flags_;   // Arc value flags valid for data in arcs_.
+  mutable uint8_t data_flags_;  // Arc value flags valid for data in arcs_.
   mutable Arc final_arc_;      // Final arc (when required).
-  mutable uint8 final_flags_;  // Arc value flags valid for final_arc_.
+  mutable uint8_t final_flags_;  // Arc value flags valid for final_arc_.
 
   ArcIterator(const ArcIterator &) = delete;
   ArcIterator &operator=(const ArcIterator &) = delete;
@@ -1318,8 +1339,8 @@ class ReplaceFstMatcher : public MatcherBase<Arc> {
     matcher_.resize(fst_array.size());
     for (Label i = 0; i < fst_array.size(); ++i) {
       if (fst_array[i]) {
-        matcher_[i].reset(
-            new LocalMatcher(*fst_array[i], match_type_, kMultiEpsList));
+        matcher_[i] = std::make_unique<LocalMatcher>(
+            *fst_array[i], match_type_, kMultiEpsList);
         auto it = impl_->nonterminal_set_.begin();
         for (; it != impl_->nonterminal_set_.end(); ++it) {
           matcher_[i]->AddMultiEpsLabel(*it);
@@ -1350,7 +1371,7 @@ class ReplaceFstMatcher : public MatcherBase<Arc> {
 
   const Fst<Arc> &GetFst() const override { return fst_; }
 
-  uint64 Properties(uint64 props) const override { return props; }
+  uint64_t Properties(uint64_t props) const override { return props; }
 
   // Sets the state from which our matching happens.
   void SetState(StateId s) final {
index de3e4e5..da5ca62 100644 (file)
@@ -21,9 +21,9 @@
 #define FST_REVERSE_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/cache.h>
 
@@ -58,8 +58,8 @@ void Reverse(const Fst<FromArc> &ifst, MutableFst<ToArc> *ofst,
   StateId istart = ifst.Start();
   StateId ostart = kNoStateId;
   StateId offset = 0;
-  uint64 dfs_iprops = 0;
-  uint64 dfs_oprops = 0;
+  uint64_t dfs_iprops = 0;
+  uint64_t dfs_oprops = 0;
   if (!require_superinitial) {
     for (StateIterator<Fst<FromArc>> siter(ifst); !siter.Done(); siter.Next()) {
       const auto s = siter.Value();
index f7a662f..c95192e 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_REWEIGHT_H_
 #define FST_REWEIGHT_H_
 
+#include <cstdint>
 #include <vector>
 
 #include <fst/log.h>
@@ -64,7 +65,7 @@ void Reweight(MutableFst<Arc> *fst,
     fst->SetProperties(kError, kError);
     return;
   }
-  const uint64 input_props = fst->Properties(kFstProperties, false);
+  const uint64_t input_props = fst->Properties(kFstProperties, false);
   StateIterator<MutableFst<Arc>> siter(*fst);
   for (; !siter.Done(); siter.Next()) {
     const auto s = siter.Value();
index 3588e73..87ecd05 100644 (file)
 #ifndef FST_RMEPSILON_H_
 #define FST_RMEPSILON_H_
 
-#include <forward_list>
+#include <cstdint>
 #include <stack>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/arcfilter.h>
@@ -133,9 +132,10 @@ class RmEpsilonState {
   // the arcs_ vector if p.first is equal to the state being expanded.
   ElementMap element_map_;
   EpsilonArcFilter<Arc> eps_filter_;
-  std::stack<StateId> eps_queue_;  // Queue used to visit the epsilon-closure.
+  std::stack<StateId, std::vector<StateId>>
+      eps_queue_;                  // Queue used to visit the epsilon-closure.
   std::vector<bool> visited_;      // True if the state has been visited.
-  std::forward_list<StateId> visited_states_;  // List of visited states.
+  std::vector<StateId> visited_states_;        // List of visited states.
   std::vector<Arc> arcs_;                      // Arcs of state being expanded.
   Weight final_weight_;  // Final weight of state being expanded.
   StateId expand_id_;    // Unique ID for each call to Expand
@@ -159,7 +159,7 @@ void RmEpsilonState<Arc, Queue>::Expand(typename Arc::StateId source) {
     }
     if (visited_[state]) continue;
     visited_[state] = true;
-    visited_states_.push_front(state);
+    visited_states_.push_back(state);
     for (ArcIterator<Fst<Arc>> aiter(fst_, state); !aiter.Done();
          aiter.Next()) {
       auto arc = aiter.Value();
@@ -170,31 +170,26 @@ void RmEpsilonState<Arc, Queue>::Expand(typename Arc::StateId source) {
           visited_.resize(arc.nextstate + 1, false);
         }
         if (!visited_[arc.nextstate]) eps_queue_.push(arc.nextstate);
+      } else if (auto [insert_it, success] = element_map_.emplace(
+                     Element(arc.ilabel, arc.olabel, arc.nextstate),
+                     std::make_pair(expand_id_, arcs_.size()));
+                 success) {
+        arcs_.push_back(std::move(arc));
+      } else if (auto &[xid, arc_idx] = insert_it->second; xid == expand_id_) {
+        auto &weight = arcs_[arc_idx].weight;
+        weight = Plus(weight, arc.weight);
       } else {
-        const Element element(arc.ilabel, arc.olabel, arc.nextstate);
-        auto insert_result = element_map_.emplace(
-            element, std::make_pair(expand_id_, arcs_.size()));
-        if (insert_result.second) {
-          arcs_.push_back(std::move(arc));
-        } else {
-          if (insert_result.first->second.first == expand_id_) {
-            auto &weight = arcs_[insert_result.first->second.second].weight;
-            weight = Plus(weight, arc.weight);
-          } else {
-            insert_result.first->second.first = expand_id_;
-            insert_result.first->second.second = arcs_.size();
-            arcs_.push_back(std::move(arc));
-          }
-        }
+        xid = expand_id_;
+        arc_idx = arcs_.size();
+        arcs_.push_back(std::move(arc));
       }
     }
     final_weight_ =
         Plus(final_weight_, Times((*distance_)[state], fst_.Final(state)));
   }
-  while (!visited_states_.empty()) {
-    visited_[visited_states_.front()] = false;
-    visited_states_.pop_front();
-  }
+
+  for (const auto state_id : visited_states_) visited_[state_id] = false;
+  visited_states_.clear();
   ++expand_id_;
 }
 
@@ -247,7 +242,7 @@ void RmEpsilon(MutableFst<Arc> *fst,
     states.resize(order.size());
     for (StateId i = 0; i < order.size(); i++) states[order[i]] = i;
   } else {
-    uint64 props;
+    uint64_t props;
     std::vector<StateId> scc;
     SccVisitor<Arc> scc_visitor(&scc, nullptr, nullptr, &props);
     DfsVisit(*fst, &scc_visitor, EpsilonArcFilter<Arc>());
@@ -436,10 +431,10 @@ class RmEpsilonFstImpl : public CacheImpl<Arc> {
     return CacheImpl<Arc>::NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found and returns other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) &&
         (fst_->Properties(kError, false) || rmeps_state_.Error())) {
       SetProperties(kError, kError);
index 1c7a71d..ae1207c 100644 (file)
@@ -20,9 +20,9 @@
 #ifndef FST_RMFINALEPSILON_H_
 #define FST_RMFINALEPSILON_H_
 
+#include <cstdint>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/connect.h>
 #include <fst/mutable-fst.h>
@@ -39,7 +39,7 @@ void RmFinalEpsilon(MutableFst<Arc> *fst) {
   // Determines the coaccesibility of states.
   std::vector<bool> access;
   std::vector<bool> coaccess;
-  uint64 props = 0;
+  uint64_t props = 0;
   SccVisitor<Arc> scc_visitor(nullptr, &access, &coaccess, &props);
   DfsVisit(*fst, &scc_visitor);
   // Finds potential list of removable final states. These are final states that
index 4f3836a..1a27704 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef FST_SCRIPT_ARC_CLASS_H_
 #define FST_SCRIPT_ARC_CLASS_H_
 
+#include <cstdint>
+
 #include <fst/script/weight-class.h>
 
 namespace fst {
@@ -34,8 +36,8 @@ struct ArcClass {
         weight(arc.weight),
         nextstate(arc.nextstate) {}
 
-  ArcClass(int64 ilabel, int64 olabel, const WeightClass &weight,
-           int64 nextstate)
+  ArcClass(int64_t ilabel, int64_t olabel, const WeightClass &weight,
+           int64_t nextstate)
       : ilabel(ilabel), olabel(olabel), weight(weight), nextstate(nextstate) {}
 
   template <class Arc>
@@ -44,10 +46,10 @@ struct ArcClass {
                nextstate);
   }
 
-  int64 ilabel;
-  int64 olabel;
+  int64_t ilabel;
+  int64_t olabel;
   WeightClass weight;
-  int64 nextstate;
+  int64_t nextstate;
 };
 
 }  // namespace script
diff --git a/src/include/fst/script/arcfilter-impl.h b/src/include/fst/script/arcfilter-impl.h
new file mode 100644 (file)
index 0000000..e8acb6f
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright 2005-2020 Google LLC
+//
+// 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.
+//
+// See www.openfst.org for extensive documentation on this weighted
+// finite-state transducer library.
+
+#ifndef FST_SCRIPT_ARCFILTER_IMPL_H_
+#define FST_SCRIPT_ARCFILTER_IMPL_H_
+
+#include <cstdint>
+
+namespace fst::script {
+
+enum class ArcFilterType : uint8_t {
+  ANY,
+  EPSILON,
+  INPUT_EPSILON,
+  OUTPUT_EPSILON
+};
+
+}  // namespace fst::script
+
+#endif  // FST_SCRIPT_ARCFILTER_IMPL_H_
index d5b538c..422780b 100644 (file)
 #ifndef FST_SCRIPT_ARCITERATOR_CLASS_H_
 #define FST_SCRIPT_ARCITERATOR_CLASS_H_
 
+#include <cstdint>
 #include <memory>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/fstlib.h>
 #include <fst/script/fst-class.h>
 
@@ -39,12 +39,12 @@ namespace script {
 class ArcIteratorImplBase {
  public:
   virtual bool Done() const = 0;
-  virtual uint8 Flags() const = 0;
+  virtual uint8_t Flags() const = 0;
   virtual void Next() = 0;
   virtual size_t Position() const = 0;
   virtual void Reset() = 0;
   virtual void Seek(size_t a) = 0;
-  virtual void SetFlags(uint8 flags, uint8 mask) = 0;
+  virtual void SetFlags(uint8_t flags, uint8_t mask) = 0;
   virtual ArcClass Value() const = 0;
   virtual ~ArcIteratorImplBase() {}
 };
@@ -53,12 +53,12 @@ class ArcIteratorImplBase {
 template <class Arc>
 class ArcIteratorClassImpl : public ArcIteratorImplBase {
  public:
-  explicit ArcIteratorClassImpl(const Fst<Arc> &fst, int64 s)
+  explicit ArcIteratorClassImpl(const Fst<Arc> &fst, int64_t s)
       : aiter_(fst, s) {}
 
   bool Done() const final { return aiter_.Done(); }
 
-  uint8 Flags() const final { return aiter_.Flags(); }
+  uint8_t Flags() const final { return aiter_.Flags(); }
 
   void Next() final { aiter_.Next(); }
 
@@ -68,13 +68,15 @@ class ArcIteratorClassImpl : public ArcIteratorImplBase {
 
   void Seek(size_t a) final { aiter_.Seek(a); }
 
-  void SetFlags(uint8 flags, uint8 mask) final { aiter_.SetFlags(flags, mask); }
+  void SetFlags(uint8_t flags, uint8_t mask) final {
+    aiter_.SetFlags(flags, mask);
+  }
 
   // This is returned by value because it has not yet been constructed, and
   // is likely to participate in return-value optimization.
   ArcClass Value() const final { return ArcClass(aiter_.Value()); }
 
-  ~ArcIteratorClassImpl() final {}
+  ~ArcIteratorClassImpl() override {}
 
  private:
   ArcIterator<Fst<Arc>> aiter_;
@@ -83,20 +85,20 @@ class ArcIteratorClassImpl : public ArcIteratorImplBase {
 class ArcIteratorClass;
 
 using InitArcIteratorClassArgs =
-    std::tuple<const FstClass &, int64, ArcIteratorClass *>;
+    std::tuple<const FstClass &, int64_t, ArcIteratorClass *>;
 
 // Untemplated user-facing class holding a templated pimpl.
 class ArcIteratorClass {
  public:
-  ArcIteratorClass(const FstClass &fst, int64 s);
+  ArcIteratorClass(const FstClass &fst, int64_t s);
 
   template <class Arc>
-  ArcIteratorClass(const Fst<Arc> &fst, int64 s)
-      : impl_(new ArcIteratorClassImpl<Arc>(fst, s)) {}
+  ArcIteratorClass(const Fst<Arc> &fst, int64_t s)
+      : impl_(std::make_unique<ArcIteratorClassImpl<Arc>>(fst, s)) {}
 
   bool Done() const { return impl_->Done(); }
 
-  uint8 Flags() const { return impl_->Flags(); }
+  uint8_t Flags() const { return impl_->Flags(); }
 
   void Next() { impl_->Next(); }
 
@@ -106,7 +108,7 @@ class ArcIteratorClass {
 
   void Seek(size_t a) { impl_->Seek(a); }
 
-  void SetFlags(uint8 flags, uint8 mask) { impl_->SetFlags(flags, mask); }
+  void SetFlags(uint8_t flags, uint8_t mask) { impl_->SetFlags(flags, mask); }
 
   ArcClass Value() const { return impl_->Value(); }
 
@@ -120,8 +122,8 @@ class ArcIteratorClass {
 template <class Arc>
 void InitArcIteratorClass(InitArcIteratorClassArgs *args) {
   const Fst<Arc> &fst = *std::get<0>(*args).GetFst<Arc>();
-  std::get<2>(*args)->impl_.reset(
-      new ArcIteratorClassImpl<Arc>(fst, std::get<1>(*args)));
+  std::get<2>(*args)->impl_ =
+      std::make_unique<ArcIteratorClassImpl<Arc>>(fst, std::get<1>(*args));
 }
 
 // Mutable arc iterators.
@@ -138,12 +140,12 @@ class MutableArcIteratorImplBase : public ArcIteratorImplBase {
 template <class Arc>
 class MutableArcIteratorClassImpl : public MutableArcIteratorImplBase {
  public:
-  explicit MutableArcIteratorClassImpl(MutableFst<Arc> *fst, int64 s)
+  explicit MutableArcIteratorClassImpl(MutableFst<Arc> *fst, int64_t s)
       : aiter_(fst, s) {}
 
   bool Done() const final { return aiter_.Done(); }
 
-  uint8 Flags() const final { return aiter_.Flags(); }
+  uint8_t Flags() const final { return aiter_.Flags(); }
 
   void Next() final { aiter_.Next(); }
 
@@ -153,7 +155,9 @@ class MutableArcIteratorClassImpl : public MutableArcIteratorImplBase {
 
   void Seek(size_t a) final { aiter_.Seek(a); }
 
-  void SetFlags(uint8 flags, uint8 mask) final { aiter_.SetFlags(flags, mask); }
+  void SetFlags(uint8_t flags, uint8_t mask) final {
+    aiter_.SetFlags(flags, mask);
+  }
 
   void SetValue(const ArcClass &ac) final { SetValue(ac.GetArc<Arc>()); }
 
@@ -172,20 +176,20 @@ class MutableArcIteratorClassImpl : public MutableArcIteratorImplBase {
 class MutableArcIteratorClass;
 
 using InitMutableArcIteratorClassArgs =
-    std::tuple<MutableFstClass *, int64, MutableArcIteratorClass *>;
+    std::tuple<MutableFstClass *, int64_t, MutableArcIteratorClass *>;
 
 // Untemplated user-facing class holding a templated pimpl.
 class MutableArcIteratorClass {
  public:
-  MutableArcIteratorClass(MutableFstClass *fst, int64 s);
+  MutableArcIteratorClass(MutableFstClass *fst, int64_t s);
 
   template <class Arc>
-  MutableArcIteratorClass(MutableFst<Arc> *fst, int64 s)
-      : impl_(new MutableArcIteratorClassImpl<Arc>(fst, s)) {}
+  MutableArcIteratorClass(MutableFst<Arc> *fst, int64_t s)
+      : impl_(std::make_unique<MutableArcIteratorClassImpl<Arc>>(fst, s)) {}
 
   bool Done() const { return impl_->Done(); }
 
-  uint8 Flags() const { return impl_->Flags(); }
+  uint8_t Flags() const { return impl_->Flags(); }
 
   void Next() { impl_->Next(); }
 
@@ -195,7 +199,7 @@ class MutableArcIteratorClass {
 
   void Seek(size_t a) { impl_->Seek(a); }
 
-  void SetFlags(uint8 flags, uint8 mask) { impl_->SetFlags(flags, mask); }
+  void SetFlags(uint8_t flags, uint8_t mask) { impl_->SetFlags(flags, mask); }
 
   void SetValue(const ArcClass &ac) { impl_->SetValue(ac); }
 
@@ -212,8 +216,9 @@ class MutableArcIteratorClass {
 template <class Arc>
 void InitMutableArcIteratorClass(InitMutableArcIteratorClassArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
-  std::get<2>(*args)->impl_.reset(
-      new MutableArcIteratorClassImpl<Arc>(fst, std::get<1>(*args)));
+  std::get<2>(*args)->impl_ =
+      std::make_unique<MutableArcIteratorClassImpl<Arc>>(fst,
+                                                          std::get<1>(*args));
 }
 
 }  // namespace script
index b7f0d52..b4fa8aa 100644 (file)
 #ifndef FST_SCRIPT_ARCSORT_H_
 #define FST_SCRIPT_ARCSORT_H_
 
+#include <cstdint>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/arcsort.h>
 #include <fst/script/fst-class.h>
 
 namespace fst {
 namespace script {
 
-enum class ArcSortType : uint8 { ILABEL, OLABEL };
+enum class ArcSortType : uint8_t { ILABEL, OLABEL };
 
-using ArcSortArgs = std::pair<MutableFstClass *, ArcSortType>;
+using FstArcSortArgs = std::pair<MutableFstClass *, ArcSortType>;
 
 template <class Arc>
-void ArcSort(ArcSortArgs *args) {
+void ArcSort(FstArcSortArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   switch (std::get<1>(*args)) {
     case ArcSortType::ILABEL: {
index f4d819f..e9b63a2 100644 (file)
@@ -37,7 +37,7 @@ namespace script {
 template <class Retval, class ArgTuple>
 struct WithReturnValue {
   // Avoid reference-to-reference if ArgTuple is a reference.
-  using Args = typename std::remove_reference<ArgTuple>::type;
+  using Args = std::remove_reference_t<ArgTuple>;
 
   Retval retval;
   const Args &args;
index 4b48077..4ec5c01 100644 (file)
 namespace fst {
 namespace script {
 
-using ClosureArgs = std::pair<MutableFstClass *, const ClosureType>;
+using FstClosureArgs = std::pair<MutableFstClass *, const ClosureType>;
 
 template <class Arc>
-void Closure(ClosureArgs *args) {
+void Closure(FstClosureArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   Closure(fst, std::get<1>(*args));
 }
index 4bb2972..5fe1b65 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 
 #include <fst/fst.h>
+#include <fst/symbol-table.h>
 #include <fst/util.h>
 #include <fst/vector-fst.h>
 #include <unordered_map>
@@ -36,7 +37,7 @@ DECLARE_string(fst_field_separator);
 
 namespace fst {
 
-// Compile a binary Fst from textual input, helper class for fstcompile.cc
+// Compile a binary FST from textual input, helper class for fstcompile.cc.
 // WARNING: Stand-alone use of this class not recommended, most code should
 // read/write using the binary format which is much more efficient.
 template <class Arc>
@@ -89,7 +90,8 @@ class FstCompiler {
         FST_FLAGS_fst_field_separator + "\n";
     while (istrm.getline(line, kLineLen)) {
       ++nline_;
-      std::vector<std::string_view> col = SplitString(line, separator, true);
+      std::vector<std::string_view> col =
+          StrSplit(line, ByAnyChar(separator), SkipEmpty());
       if (col.empty() || col[0].empty()) continue;
       if (col.size() > 5 || (col.size() > 4 && accep) ||
           (col.size() == 3 && !accep)) {
@@ -152,12 +154,12 @@ class FstCompiler {
   // Maximum line length in text file.
   static constexpr int kLineLen = 8096;
 
-  StateId StrToId(std::string_view s, SymbolTable *syms, const char *name,
-                  bool allow_negative = false) const {
+  StateId StrToId(std::string_view s, SymbolTable *syms,
+                  std::string_view name, bool allow_negative = false) const {
     StateId n = 0;
     if (syms) {
       n = (add_symbols_) ? syms->AddSymbol(s) : syms->Find(s);
-      if (n == -1 || (!allow_negative && n < 0)) {
+      if (n == kNoSymbol || (!allow_negative && n < 0)) {
         FSTERROR() << "FstCompiler: Symbol \"" << s
                    << "\" is not mapped to any integer " << name
                    << ", symbol table = " << syms->Name()
index 4f9765c..b3fbdcf 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <istream>
 #include <memory>
+#include <string>
 
 #include <fst/script/arg-packs.h>
 #include <fst/script/compile-impl.h>
@@ -37,7 +38,7 @@ namespace script {
 // this struct is only used to pass them deeper in the call graph.
 // Be sure you understand why this is so before using this struct
 // for anything else!
-struct CompileFstInnerArgs {
+struct FstCompileInnerArgs {
   std::istream &istrm;
   const std::string &source;
   const std::string &fst_type;
@@ -51,11 +52,11 @@ struct CompileFstInnerArgs {
   const bool allow_negative_labels;
 };
 
-using CompileFstArgs =
-    WithReturnValue<std::unique_ptr<FstClass>, CompileFstInnerArgs>;
+using FstCompileArgs =
+    WithReturnValue<std::unique_ptr<FstClass>, FstCompileInnerArgs>;
 
 template <class Arc>
-void CompileFstInternal(CompileFstArgs *args) {
+void CompileInternal(FstCompileArgs *args) {
   using fst::Convert;
   using fst::Fst;
   using fst::FstCompiler;
@@ -78,13 +79,13 @@ void CompileFstInternal(CompileFstArgs *args) {
   args->retval = fst ? std::make_unique<FstClass>(std::move(fst)) : nullptr;
 }
 
-void CompileFst(std::istream &istrm, const std::string &source,
-                const std::string &dest, const std::string &fst_type,
-                const std::string &arc_type, const SymbolTable *isyms,
-                const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
-                bool ikeep, bool okeep, bool nkeep, bool allow_negative_labels);
+void Compile(std::istream &istrm, const std::string &source,
+             const std::string &dest, const std::string &fst_type,
+             const std::string &arc_type, const SymbolTable *isyms,
+             const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
+             bool ikeep, bool okeep, bool nkeep, bool allow_negative_labels);
 
-std::unique_ptr<FstClass> CompileFstInternal(
+std::unique_ptr<FstClass> CompileInternal(
     std::istream &istrm, const std::string &source, const std::string &fst_type,
     const std::string &arc_type, const SymbolTable *isyms,
     const SymbolTable *osyms, const SymbolTable *ssyms, bool accep, bool ikeep,
index 3b29b3c..65a8f1a 100644 (file)
 namespace fst {
 namespace script {
 
-using ComposeArgs = std::tuple<const FstClass &, const FstClass &,
-                               MutableFstClass *, const ComposeOptions &>;
+using FstComposeArgs = std::tuple<const FstClass &, const FstClass &,
+                                  MutableFstClass *, const ComposeOptions &>;
 
 template <class Arc>
-void Compose(ComposeArgs *args) {
+void Compose(FstComposeArgs *args) {
   const Fst<Arc> &ifst1 = *std::get<0>(*args).GetFst<Arc>();
   const Fst<Arc> &ifst2 = *std::get<1>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<2>(*args)->GetMutableFst<Arc>();
index a71e5a1..845e9ea 100644 (file)
 namespace fst {
 namespace script {
 
-using ConcatArgs1 = std::pair<MutableFstClass *, const FstClass &>;
+using FstConcatArgs1 = std::pair<MutableFstClass *, const FstClass &>;
 
 template <class Arc>
-void Concat(ConcatArgs1 *args) {
+void Concat(FstConcatArgs1 *args) {
   MutableFst<Arc> *fst1 = std::get<0>(*args)->GetMutableFst<Arc>();
   const Fst<Arc> &fst2 = *std::get<1>(*args).GetFst<Arc>();
   Concat(fst1, fst2);
 }
 
-using ConcatArgs2 = std::pair<const FstClass &, MutableFstClass *>;
+using FstConcatArgs2 = std::pair<const FstClass &, MutableFstClass *>;
 
 template <class Arc>
-void Concat(ConcatArgs2 *args) {
+void Concat(FstConcatArgs2 *args) {
   const Fst<Arc> &fst1 = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *fst2 = std::get<1>(*args)->GetMutableFst<Arc>();
   Concat(fst1, fst2);
 }
 
-using ConcatArgs3 =
+using FstConcatArgs3 =
     std::pair<const std::vector<FstClass *> &, MutableFstClass *>;
 
 template <class Arc>
-void Concat(ConcatArgs3 *args) {
+void Concat(FstConcatArgs3 *args) {
   const auto &untyped_fsts1 = std::get<0>(*args);
   std::vector<const Fst<Arc> *> typed_fsts1;
   typed_fsts1.reserve(untyped_fsts1.size());
index c132cb6..abbef44 100644 (file)
 namespace fst {
 namespace script {
 
-using ConvertInnerArgs = std::pair<const FstClass &, const std::string &>;
+using FstConvertInnerArgs = std::pair<const FstClass &, const std::string &>;
 
-using ConvertArgs =
-    WithReturnValue<std::unique_ptr<FstClass>, ConvertInnerArgs>;
+using FstConvertArgs =
+    WithReturnValue<std::unique_ptr<FstClass>, FstConvertInnerArgs>;
 
 template <class Arc>
-void Convert(ConvertArgs *args) {
+void Convert(FstConvertArgs *args) {
   const Fst<Arc> &fst = *std::get<0>(args->args).GetFst<Arc>();
   const std::string &new_type = std::get<1>(args->args);
   std::unique_ptr<Fst<Arc>> result(Convert(fst, new_type));
index c3913dd..947a801 100644 (file)
 namespace fst {
 namespace script {
 
-using DecodeArgs = std::pair<MutableFstClass *, const EncodeMapperClass &>;
+using FstDecodeArgs = std::pair<MutableFstClass *, const EncodeMapperClass &>;
 
 template <class Arc>
-void Decode(DecodeArgs *args) {
+void Decode(FstDecodeArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   const EncodeMapper<Arc> &mapper = *std::get<1>(*args).GetEncodeMapper<Arc>();
   Decode(fst, mapper);
index 209ddf9..848b8af 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef FST_SCRIPT_DETERMINIZE_H_
 #define FST_SCRIPT_DETERMINIZE_H_
 
+#include <cstdint>
 #include <tuple>
 
 #include <fst/determinize.h>
@@ -30,14 +31,14 @@ namespace script {
 struct DeterminizeOptions {
   const float delta;
   const WeightClass &weight_threshold;
-  const int64 state_threshold;
-  const int64 subsequential_label;
+  const int64_t state_threshold;
+  const int64_t subsequential_label;
   const DeterminizeType det_type;
   const bool increment_subsequential_label;
 
   DeterminizeOptions(float delta, const WeightClass &weight_threshold,
-                     int64 state_threshold = kNoStateId,
-                     int64 subsequential_label = 0,
+                     int64_t state_threshold = kNoStateId,
+                     int64_t subsequential_label = 0,
                      DeterminizeType det_type = DETERMINIZE_FUNCTIONAL,
                      bool increment_subsequential_label = false)
       : delta(delta),
@@ -48,11 +49,11 @@ struct DeterminizeOptions {
         increment_subsequential_label(increment_subsequential_label) {}
 };
 
-using DeterminizeArgs =
+using FstDeterminizeArgs =
     std::tuple<const FstClass &, MutableFstClass *, const DeterminizeOptions &>;
 
 template <class Arc>
-void Determinize(DeterminizeArgs *args) {
+void Determinize(FstDeterminizeArgs *args) {
   using Weight = typename Arc::Weight;
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
index 372eff6..bd02f77 100644 (file)
 namespace fst {
 namespace script {
 
-using DifferenceArgs = std::tuple<const FstClass &, const FstClass &,
-                                  MutableFstClass *, const ComposeOptions &>;
+using FstDifferenceArgs = std::tuple<const FstClass &, const FstClass &,
+                                     MutableFstClass *, const ComposeOptions &>;
 
 template <class Arc>
-void Difference(DifferenceArgs *args) {
+void Difference(FstDifferenceArgs *args) {
   const Fst<Arc> &ifst1 = *std::get<0>(*args).GetFst<Arc>();
   const Fst<Arc> &ifst2 = *std::get<1>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<2>(*args)->GetMutableFst<Arc>();
index 6d00224..ec46baf 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef FST_SCRIPT_DISAMBIGUATE_H_
 #define FST_SCRIPT_DISAMBIGUATE_H_
 
+#include <cstdint>
 #include <tuple>
 #include <utility>
 
@@ -31,23 +32,23 @@ namespace script {
 struct DisambiguateOptions {
   const float delta;
   const WeightClass &weight_threshold;
-  const int64 state_threshold;
-  const int64 subsequential_label;
+  const int64_t state_threshold;
+  const int64_t subsequential_label;
 
   DisambiguateOptions(float delta, const WeightClass &weight_threshold,
-                      int64 state_threshold = kNoStateId,
-                      int64 subsequential_label = 0)
+                      int64_t state_threshold = kNoStateId,
+                      int64_t subsequential_label = 0)
       : delta(delta),
         weight_threshold(weight_threshold),
         state_threshold(state_threshold),
         subsequential_label(subsequential_label) {}
 };
 
-using DisambiguateArgs = std::tuple<const FstClass &, MutableFstClass *,
-                                    const DisambiguateOptions &>;
+using FstDisambiguateArgs = std::tuple<const FstClass &, MutableFstClass *,
+                                       const DisambiguateOptions &>;
 
 template <class Arc>
-void Disambiguate(DisambiguateArgs *args) {
+void Disambiguate(FstDisambiguateArgs *args) {
   using Weight = typename Arc::Weight;
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
index bd31e95..131e793 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef FST_SCRIPT_DRAW_IMPL_H_
 #define FST_SCRIPT_DRAW_IMPL_H_
 
+#include <iomanip>
 #include <ostream>
 #include <sstream>
 #include <string>
@@ -28,6 +29,7 @@
 #include <fst/fst.h>
 #include <fst/util.h>
 #include <fst/script/fst-class.h>
+#include <string_view>
 
 namespace fst {
 
@@ -42,16 +44,15 @@ class FstDrawer {
 
   FstDrawer(const Fst<Arc> &fst, const SymbolTable *isyms,
             const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
-            const std::string &title, float width, float height, bool portrait,
+            std::string_view title, float width, float height, bool portrait,
             bool vertical, float ranksep, float nodesep, int fontsize,
-            int precision, const std::string &float_format,
+            int precision, std::string_view float_format,
             bool show_weight_one)
       : fst_(fst),
         isyms_(isyms),
         osyms_(osyms),
         ssyms_(ssyms),
         accep_(accep && fst.Properties(kAcceptor, true)),
-        ostrm_(nullptr),
         title_(title),
         width_(width),
         height_(height),
@@ -65,57 +66,44 @@ class FstDrawer {
         show_weight_one_(show_weight_one) {}
 
   // Draws FST to an output buffer.
-  void Draw(std::ostream &strm, const std::string &dest) {
-    ostrm_ = &strm;
-    SetStreamState(ostrm_);
-    dest_ = dest;
+  void Draw(std::ostream &strm, std::string_view dest) {
+    SetStreamState(strm);
+    dest_ = std::string(dest);
     const auto start = fst_.Start();
     if (start == kNoStateId) return;
-    PrintString("digraph FST {\n");
+    strm << "digraph FST {\n";
     if (vertical_) {
-      PrintString("rankdir = BT;\n");
+      strm << "rankdir = BT;\n";
     } else {
-      PrintString("rankdir = LR;\n");
+      strm << "rankdir = LR;\n";
     }
-    PrintString("size = \"");
-    Print(width_);
-    PrintString(",");
-    Print(height_);
-    PrintString("\";\n");
-    if (!title_.empty()) PrintString("label = \"" + title_ + "\";\n");
-    PrintString("center = 1;\n");
+    strm << "size = \"" << width_ << "," << height_ << "\";\n";
+    if (!title_.empty()) strm << "label = \"" + title_ + "\";\n";
+    strm << "center = 1;\n";
     if (portrait_) {
-      PrintString("orientation = Portrait;\n");
+      strm << "orientation = Portrait;\n";
     } else {
-      PrintString("orientation = Landscape;\n");
+      strm << "orientation = Landscape;\n";
     }
-    PrintString("ranksep = \"");
-    Print(ranksep_);
-    PrintString("\";\n");
-    PrintString("nodesep = \"");
-    Print(nodesep_);
-    PrintString("\";\n");
+    strm << "ranksep = \"" << ranksep_ << "\";\n"
+         << "nodesep = \"" << nodesep_ << "\";\n";
     // Initial state first.
-    DrawState(start);
+    DrawState(strm, start);
     for (StateIterator<Fst<Arc>> siter(fst_); !siter.Done(); siter.Next()) {
       const auto s = siter.Value();
-      if (s != start) DrawState(s);
+      if (s != start) DrawState(strm, s);
     }
-    PrintString("}\n");
+    strm << "}\n";
   }
 
  private:
-  void SetStreamState(std::ostream *strm) const {
-    strm->precision(precision_);
-    if (float_format_ == "e")
-      strm->setf(std::ios_base::scientific, std::ios_base::floatfield);
-    if (float_format_ == "f")
-      strm->setf(std::ios_base::fixed, std::ios_base::floatfield);
+  void SetStreamState(std::ostream &strm) const {
+    strm << std::setprecision(precision_);
+    if (float_format_ == "e") strm << std::scientific;
+    if (float_format_ == "f") strm << std::fixed;
     // O.w. defaults to "g" per standard lib.
   }
 
-  void PrintString(const std::string &str) const { *ostrm_ << str; }
-
   // Escapes backslash and double quote if these occur in the string. Dot
   // will not deal gracefully with these if they are not escaped.
   static std::string Escape(const std::string &str) {
@@ -127,7 +115,7 @@ class FstDrawer {
     return ns;
   }
 
-  void PrintId(StateId id, const SymbolTable *syms, const char *name) const {
+  std::string FormatId(StateId id, const SymbolTable *syms) const {
     if (syms) {
       auto symbol = syms->Find(id);
       if (symbol.empty()) {
@@ -137,81 +125,58 @@ class FstDrawer {
                    << ", destination = " << dest_;
         symbol = "?";
       }
-      PrintString(Escape(symbol));
+      return Escape(symbol);
     } else {
-      PrintString(std::to_string(id));
+      return std::to_string(id);
     }
   }
 
-  void PrintStateId(StateId s) const { PrintId(s, ssyms_, "state ID"); }
-
-  void PrintILabel(Label label) const {
-    PrintId(label, isyms_, "arc input label");
-  }
+  std::string FormatStateId(StateId s) const { return FormatId(s, ssyms_); }
 
-  void PrintOLabel(Label label) const {
-    PrintId(label, osyms_, "arc output label");
+  std::string FormatILabel(Label label) const {
+    return FormatId(label, isyms_);
   }
 
-  void PrintWeight(Weight w) const {
-    // Weight may have double quote characters in it, so escape it.
-    PrintString(Escape(ToString(w)));
+  std::string FormatOLabel(Label label) const {
+    return FormatId(label, osyms_);
   }
 
-  template <class T>
-  void Print(T t) const {
-    *ostrm_ << t;
-  }
-
-  template <class T>
-  std::string ToString(T t) const {
+  std::string FormatWeight(Weight w) const {
     std::stringstream ss;
-    SetStreamState(&ss);
-    ss << t;
-    return ss.str();
+    SetStreamState(ss);
+    ss << w;
+    // Weight may have double quote characters in it, so escape it.
+    return Escape(ss.str());
   }
 
-  void DrawState(StateId s) const {
-    Print(s);
-    PrintString(" [label = \"");
-    PrintStateId(s);
+  void DrawState(std::ostream &strm, StateId s) const {
+    strm << s << " [label = \"" << FormatStateId(s);
     const auto weight = fst_.Final(s);
     if (weight != Weight::Zero()) {
       if (show_weight_one_ || (weight != Weight::One())) {
-        PrintString("/");
-        PrintWeight(weight);
+        strm << "/" << FormatWeight(weight);
       }
-      PrintString("\", shape = doublecircle,");
+      strm << "\", shape = doublecircle,";
     } else {
-      PrintString("\", shape = circle,");
+      strm << "\", shape = circle,";
     }
     if (s == fst_.Start()) {
-      PrintString(" style = bold,");
+      strm << " style = bold,";
     } else {
-      PrintString(" style = solid,");
+      strm << " style = solid,";
     }
-    PrintString(" fontsize = ");
-    Print(fontsize_);
-    PrintString("]\n");
+    strm << " fontsize = " << fontsize_ << "]\n";
     for (ArcIterator<Fst<Arc>> aiter(fst_, s); !aiter.Done(); aiter.Next()) {
       const auto &arc = aiter.Value();
-      PrintString("\t");
-      Print(s);
-      PrintString(" -> ");
-      Print(arc.nextstate);
-      PrintString(" [label = \"");
-      PrintILabel(arc.ilabel);
+      strm << "\t" << s << " -> " << arc.nextstate << " [label = \""
+           << FormatILabel(arc.ilabel);
       if (!accep_) {
-        PrintString(":");
-        PrintOLabel(arc.olabel);
+        strm << ":" << FormatOLabel(arc.olabel);
       }
       if (show_weight_one_ || (arc.weight != Weight::One())) {
-        PrintString("/");
-        PrintWeight(arc.weight);
+        strm << "/" << FormatWeight(arc.weight);
       }
-      PrintString("\", fontsize = ");
-      Print(fontsize_);
-      PrintString("];\n");
+      strm << "\", fontsize = " << fontsize_ << "];\n";
     }
   }
 
@@ -220,7 +185,6 @@ class FstDrawer {
   const SymbolTable *osyms_;  // olabel symbol table.
   const SymbolTable *ssyms_;  // slabel symbol table.
   bool accep_;                // Print as acceptor when possible.
-  std::ostream *ostrm_;       // Drawn FST destination.
   std::string dest_;          // Drawn FST destination name.
 
   std::string title_;
index 445c290..8eeefb9 100644 (file)
@@ -19,6 +19,7 @@
 #define FST_SCRIPT_DRAW_H_
 
 #include <ostream>
+#include <string>
 
 #include <fst/script/draw-impl.h>
 #include <fst/script/fst-class.h>
@@ -29,7 +30,7 @@ namespace script {
 // Note: it is safe to pass these strings as references because this struct is
 // only used to pass them deeper in the call graph. Be sure you understand why
 // this is so before using this struct for anything else!
-struct DrawArgs {
+struct FstDrawArgs {
   const FstClass &fst;
   const SymbolTable *isyms;
   const SymbolTable *osyms;
@@ -51,7 +52,7 @@ struct DrawArgs {
 };
 
 template <class Arc>
-void Draw(DrawArgs *args) {
+void Draw(FstDrawArgs *args) {
   const Fst<Arc> &fst = *args->fst.GetFst<Arc>();
   FstDrawer<Arc> fstdrawer(fst, args->isyms, args->osyms, args->ssyms,
                            args->accep, args->title, args->width, args->height,
index fff0ef5..9543790 100644 (file)
 namespace fst {
 namespace script {
 
-using EncodeArgs = std::tuple<MutableFstClass *, EncodeMapperClass *>;
+using FstEncodeArgs = std::tuple<MutableFstClass *, EncodeMapperClass *>;
 
 template <class Arc>
-void Encode(EncodeArgs *args) {
+void Encode(FstEncodeArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   EncodeMapper<Arc> *mapper = std::get<1>(*args)->GetEncodeMapper<Arc>();
   Encode(fst, mapper);
index 2a4e77e..0d67ec5 100644 (file)
 #ifndef FST_SCRIPT_ENCODEMAPPER_CLASS_H_
 #define FST_SCRIPT_ENCODEMAPPER_CLASS_H_
 
+#include <cstdint>
 #include <iostream>
 #include <memory>
 #include <string>
+#include <utility>
 
-#include <fst/types.h>
 #include <fst/encode.h>
 #include <fst/generic-register.h>
 #include <fst/script/arc-class.h>
 #include <fst/script/fst-class.h>
+#include <string_view>
 
 // Scripting API support for EncodeMapper.
 
@@ -41,8 +43,8 @@ class EncodeMapperImplBase {
   virtual const std::string &ArcType() const = 0;
   virtual const std::string &WeightType() const = 0;
   virtual EncodeMapperImplBase *Copy() const = 0;
-  virtual uint8 Flags() const = 0;
-  virtual uint64 Properties(uint64) = 0;
+  virtual uint8_t Flags() const = 0;
+  virtual uint64_t Properties(uint64_t) = 0;
   virtual EncodeType Type() const = 0;
   virtual bool Write(const std::string &) const = 0;
   virtual bool Write(std::ostream &, const std::string &) const = 0;
@@ -70,9 +72,9 @@ class EncodeMapperClassImpl : public EncodeMapperImplBase {
     return new EncodeMapperClassImpl<Arc>(mapper_);
   }
 
-  uint8 Flags() const final { return mapper_.Flags(); }
+  uint8_t Flags() const final { return mapper_.Flags(); }
 
-  uint64 Properties(uint64 inprops) final {
+  uint64_t Properties(uint64_t inprops) final {
     return mapper_.Properties(inprops);
   }
 
@@ -123,12 +125,12 @@ class EncodeMapperClass {
  public:
   EncodeMapperClass() : impl_(nullptr) {}
 
-  EncodeMapperClass(const std::string &arc_type, uint8 flags,
+  EncodeMapperClass(std::string_view arc_type, uint8_t flags,
                     EncodeType type = ENCODE);
 
   template <class Arc>
   explicit EncodeMapperClass(const EncodeMapper<Arc> &mapper)
-      : impl_(new EncodeMapperClassImpl<Arc>(mapper)) {}
+      : impl_(std::make_unique<EncodeMapperClassImpl<Arc>>(mapper)) {}
 
   EncodeMapperClass(const EncodeMapperClass &other)
       : impl_(other.impl_ == nullptr ? nullptr : other.impl_->Copy()) {}
@@ -144,15 +146,16 @@ class EncodeMapperClass {
 
   const std::string &WeightType() const { return impl_->WeightType(); }
 
-  uint8 Flags() const { return impl_->Flags(); }
+  uint8_t Flags() const { return impl_->Flags(); }
 
-  uint64 Properties(uint64 inprops) { return impl_->Properties(inprops); }
+  uint64_t Properties(uint64_t inprops) { return impl_->Properties(inprops); }
 
   EncodeType Type() const { return impl_->Type(); }
 
-  static EncodeMapperClass *Read(const std::string &source);
+  static std::unique_ptr<EncodeMapperClass> Read(const std::string &source);
 
-  static EncodeMapperClass *Read(std::istream &strm, const std::string &source);
+  static std::unique_ptr<EncodeMapperClass> Read(std::istream &strm,
+                                                 const std::string &source);
 
   bool Write(const std::string &source) const { return impl_->Write(source); }
 
@@ -179,7 +182,7 @@ class EncodeMapperClass {
     if (Arc::Type() != ArcType()) {
       return nullptr;
     } else {
-      auto *typed_impl = fst::down_cast<EncodeMapperClassImpl<Arc> *>(impl_.get());
+      auto *typed_impl = down_cast<EncodeMapperClassImpl<Arc> *>(impl_.get());
       return typed_impl->GetImpl();
     }
   }
@@ -189,7 +192,7 @@ class EncodeMapperClass {
     if (Arc::Type() != ArcType()) {
       return nullptr;
     } else {
-      auto *typed_impl = fst::down_cast<EncodeMapperClassImpl<Arc> *>(impl_.get());
+      auto *typed_impl = down_cast<EncodeMapperClassImpl<Arc> *>(impl_.get());
       return typed_impl->GetImpl();
     }
   }
@@ -197,20 +200,23 @@ class EncodeMapperClass {
   // Required for registration.
 
   template <class Arc>
-  static EncodeMapperClass *Read(std::istream &strm,
-                                 const std::string &source) {
+  static std::unique_ptr<EncodeMapperClass> Read(std::istream &strm,
+                                                 const std::string &source) {
     std::unique_ptr<EncodeMapper<Arc>> mapper(
         EncodeMapper<Arc>::Read(strm, source));
-    return mapper ? new EncodeMapperClass(*mapper) : nullptr;
+    return mapper ? std::make_unique<EncodeMapperClass>(*mapper) : nullptr;
   }
 
   template <class Arc>
-  static EncodeMapperImplBase *Create(uint8 flags, EncodeType type = ENCODE) {
-    return new EncodeMapperClassImpl<Arc>(EncodeMapper<Arc>(flags, type));
+  static std::unique_ptr<EncodeMapperImplBase> Create(
+      uint8_t flags, EncodeType type = ENCODE) {
+    return std::make_unique<EncodeMapperClassImpl<Arc>>(
+        EncodeMapper<Arc>(flags, type));
   }
 
  private:
-  explicit EncodeMapperClass(EncodeMapperImplBase *impl) : impl_(impl) {}
+  explicit EncodeMapperClass(std::unique_ptr<EncodeMapperImplBase> impl)
+      : impl_(std::move(impl)) {}
 
   const EncodeMapperImplBase *GetImpl() const { return impl_.get(); }
 
@@ -241,28 +247,30 @@ class EncodeMapperClassIORegister
                              EncodeMapperClassRegEntry<Reader, Creator>,
                              EncodeMapperClassIORegister<Reader, Creator>> {
  public:
-  Reader GetReader(const std::string &arc_type) const {
+  Reader GetReader(std::string_view arc_type) const {
     return this->GetEntry(arc_type).reader;
   }
 
-  Creator GetCreator(const std::string &arc_type) const {
+  Creator GetCreator(std::string_view arc_type) const {
     return this->GetEntry(arc_type).creator;
   }
 
  protected:
-  std::string ConvertKeyToSoFilename(const std::string &key) const final {
+  std::string ConvertKeyToSoFilename(std::string_view key) const final {
     std::string legal_type(key);
     ConvertToLegalCSymbol(&legal_type);
-    return legal_type + "-arc.so";
+    legal_type.append("-arc.so");
+    return legal_type;
   }
 };
 
 // Struct containing everything needed to register a particular type
 struct EncodeMapperClassIORegistration {
-  using Reader = EncodeMapperClass *(*)(std::istream &stream,
-                                        const std::string &source);
+  using Reader = std::unique_ptr<EncodeMapperClass> (*)(
+      std::istream &stream, const std::string &source);
 
-  using Creator = EncodeMapperImplBase *(*)(uint8 flags, EncodeType type);
+  using Creator = std::unique_ptr<EncodeMapperImplBase> (*)(uint8_t flags,
+                                                            EncodeType type);
 
   using Entry = EncodeMapperClassRegEntry<Reader, Creator>;
 
index e704de5..e1890c7 100644 (file)
 namespace fst {
 namespace script {
 
-using EpsNormalizeArgs =
+using FstEpsNormalizeArgs =
     std::tuple<const FstClass &, MutableFstClass *, EpsNormalizeType>;
 
 template <class Arc>
-void EpsNormalize(EpsNormalizeArgs *args) {
+void EpsNormalize(FstEpsNormalizeArgs *args) {
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
   EpsNormalize(ifst, ofst, std::get<2>(*args));
index 5236c40..a564631 100644 (file)
 namespace fst {
 namespace script {
 
-using EqualInnerArgs = std::tuple<const FstClass &, const FstClass &, float>;
+using FstEqualInnerArgs = std::tuple<const FstClass &, const FstClass &, float>;
 
-using EqualArgs = WithReturnValue<bool, EqualInnerArgs>;
+using FstEqualArgs = WithReturnValue<bool, FstEqualInnerArgs>;
 
 template <class Arc>
-void Equal(EqualArgs *args) {
+void Equal(FstEqualArgs *args) {
   const Fst<Arc> &fst1 = *std::get<0>(args->args).GetFst<Arc>();
   const Fst<Arc> &fst2 = *std::get<1>(args->args).GetFst<Arc>();
   args->retval = Equal(fst1, fst2, std::get<2>(args->args));
index ef42957..55aebe1 100644 (file)
 namespace fst {
 namespace script {
 
-using EquivalentInnerArgs =
+using FstEquivalentInnerArgs =
     std::tuple<const FstClass &, const FstClass &, float>;
 
-using EquivalentArgs = WithReturnValue<bool, EquivalentInnerArgs>;
+using FstEquivalentArgs = WithReturnValue<bool, FstEquivalentInnerArgs>;
 
 template <class Arc>
-void Equivalent(EquivalentArgs *args) {
+void Equivalent(FstEquivalentArgs *args) {
   const Fst<Arc> &fst1 = *std::get<0>(args->args).GetFst<Arc>();
   const Fst<Arc> &fst2 = *std::get<1>(args->args).GetFst<Arc>();
   args->retval = Equivalent(fst1, fst2, std::get<2>(args->args));
index e5a14a8..c0630b1 100644 (file)
 #define FST_SCRIPT_FST_CLASS_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <istream>
 #include <limits>
 #include <memory>
 #include <string>
 #include <type_traits>
+#include <utility>
 
 #include <fst/expanded-fst.h>
 #include <fst/fst.h>
@@ -32,6 +34,7 @@
 #include <fst/vector-fst.h>
 #include <fst/script/arc-class.h>
 #include <fst/script/weight-class.h>
+#include <string_view>
 
 // Classes to support "boxing" all existing types of FST arcs in a single
 // FstClass which hides the arc types. This allows clients to load
@@ -51,17 +54,17 @@ namespace script {
 class FstClassBase {
  public:
   virtual const std::string &ArcType() const = 0;
-  virtual WeightClass Final(int64) const = 0;
+  virtual WeightClass Final(int64_t) const = 0;
   virtual const std::string &FstType() const = 0;
   virtual const SymbolTable *InputSymbols() const = 0;
-  virtual size_t NumArcs(int64) const = 0;
-  virtual size_t NumInputEpsilons(int64) const = 0;
-  virtual size_t NumOutputEpsilons(int64) const = 0;
+  virtual size_t NumArcs(int64_t) const = 0;
+  virtual size_t NumInputEpsilons(int64_t) const = 0;
+  virtual size_t NumOutputEpsilons(int64_t) const = 0;
   virtual const SymbolTable *OutputSymbols() const = 0;
-  virtual uint64 Properties(uint64, bool) const = 0;
-  virtual int64 Start() const = 0;
+  virtual uint64_t Properties(uint64_t, bool) const = 0;
+  virtual int64_t Start() const = 0;
   virtual const std::string &WeightType() const = 0;
-  virtual bool ValidStateId(int64) const = 0;
+  virtual bool ValidStateId(int64_t) const = 0;
   virtual bool Write(const std::string &) const = 0;
   virtual bool Write(std::ostream &, const std::string &) const = 0;
   virtual ~FstClassBase() {}
@@ -70,24 +73,24 @@ class FstClassBase {
 // Adds all the MutableFst methods.
 class FstClassImplBase : public FstClassBase {
  public:
-  virtual bool AddArc(int64, const ArcClass &) = 0;
-  virtual int64 AddState() = 0;
+  virtual bool AddArc(int64_t, const ArcClass &) = 0;
+  virtual int64_t AddState() = 0;
   virtual void AddStates(size_t) = 0;
   virtual FstClassImplBase *Copy() = 0;
-  virtual bool DeleteArcs(int64, size_t) = 0;
-  virtual bool DeleteArcs(int64) = 0;
-  virtual bool DeleteStates(const std::vector<int64> &) = 0;
+  virtual bool DeleteArcs(int64_t, size_t) = 0;
+  virtual bool DeleteArcs(int64_t) = 0;
+  virtual bool DeleteStates(const std::vector<int64_t> &) = 0;
   virtual void DeleteStates() = 0;
   virtual SymbolTable *MutableInputSymbols() = 0;
   virtual SymbolTable *MutableOutputSymbols() = 0;
-  virtual int64 NumStates() const = 0;
-  virtual bool ReserveArcs(int64, size_t) = 0;
-  virtual void ReserveStates(int64) = 0;
+  virtual int64_t NumStates() const = 0;
+  virtual bool ReserveArcs(int64_t, size_t) = 0;
+  virtual void ReserveStates(int64_t) = 0;
   virtual void SetInputSymbols(const SymbolTable *) = 0;
-  virtual bool SetFinal(int64, const WeightClass &) = 0;
+  virtual bool SetFinal(int64_t, const WeightClass &) = 0;
   virtual void SetOutputSymbols(const SymbolTable *) = 0;
-  virtual void SetProperties(uint64, uint64) = 0;
-  virtual bool SetStart(int64) = 0;
+  virtual void SetProperties(uint64_t, uint64_t) = 0;
+  virtual bool SetStart(int64_t) = 0;
   ~FstClassImplBase() override {}
 };
 
@@ -105,25 +108,25 @@ class FstClassImpl : public FstClassImplBase {
   explicit FstClassImpl(const Fst<Arc> &impl) : impl_(impl.Copy()) {}
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool AddArc(int64 s, const ArcClass &ac) final {
+  bool AddArc(int64_t s, const ArcClass &ac) final {
     if (!ValidStateId(s)) return false;
     // Note that we do not check that the destination state is valid, so users
     // can add arcs before they add the corresponding states. Verify can be
     // used to determine whether any arc has a nonexisting destination.
     Arc arc(ac.ilabel, ac.olabel, *ac.weight.GetWeight<typename Arc::Weight>(),
             ac.nextstate);
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->AddArc(s, arc);
+    down_cast<MutableFst<Arc> *>(impl_.get())->AddArc(s, arc);
     return true;
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  int64 AddState() final {
-    return fst::down_cast<MutableFst<Arc> *>(impl_.get())->AddState();
+  int64_t AddState() final {
+    return down_cast<MutableFst<Arc> *>(impl_.get())->AddState();
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
   void AddStates(size_t n) final {
-    return fst::down_cast<MutableFst<Arc> *>(impl_.get())->AddStates(n);
+    return down_cast<MutableFst<Arc> *>(impl_.get())->AddStates(n);
   }
 
   const std::string &ArcType() const final { return Arc::Type(); }
@@ -131,37 +134,37 @@ class FstClassImpl : public FstClassImplBase {
   FstClassImpl *Copy() final { return new FstClassImpl<Arc>(*impl_); }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool DeleteArcs(int64 s, size_t n) final {
+  bool DeleteArcs(int64_t s, size_t n) final {
     if (!ValidStateId(s)) return false;
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->DeleteArcs(s, n);
+    down_cast<MutableFst<Arc> *>(impl_.get())->DeleteArcs(s, n);
     return true;
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool DeleteArcs(int64 s) final {
+  bool DeleteArcs(int64_t s) final {
     if (!ValidStateId(s)) return false;
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->DeleteArcs(s);
+    down_cast<MutableFst<Arc> *>(impl_.get())->DeleteArcs(s);
     return true;
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool DeleteStates(const std::vector<int64> &dstates) final {
+  bool DeleteStates(const std::vector<int64_t> &dstates) final {
     for (const auto &state : dstates)
       if (!ValidStateId(state)) return false;
     // Warning: calling this method with any integers beyond the precision of
     // the underlying FST will result in truncation.
     std::vector<typename Arc::StateId> typed_dstates(dstates.size());
     std::copy(dstates.begin(), dstates.end(), typed_dstates.begin());
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->DeleteStates(typed_dstates);
+    down_cast<MutableFst<Arc> *>(impl_.get())->DeleteStates(typed_dstates);
     return true;
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
   void DeleteStates() final {
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->DeleteStates();
+    down_cast<MutableFst<Arc> *>(impl_.get())->DeleteStates();
   }
 
-  WeightClass Final(int64 s) const final {
+  WeightClass Final(int64_t s) const final {
     if (!ValidStateId(s)) return WeightClass::NoWeight(WeightType());
     WeightClass w(impl_->Final(s));
     return w;
@@ -175,51 +178,51 @@ class FstClassImpl : public FstClassImplBase {
 
   // Warning: calling this method casts the FST to a mutable FST.
   SymbolTable *MutableInputSymbols() final {
-    return fst::down_cast<MutableFst<Arc> *>(impl_.get())->MutableInputSymbols();
+    return down_cast<MutableFst<Arc> *>(impl_.get())->MutableInputSymbols();
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
   SymbolTable *MutableOutputSymbols() final {
-    return fst::down_cast<MutableFst<Arc> *>(impl_.get())->MutableOutputSymbols();
+    return down_cast<MutableFst<Arc> *>(impl_.get())->MutableOutputSymbols();
   }
 
   // Signals failure by returning size_t max.
-  size_t NumArcs(int64 s) const final {
+  size_t NumArcs(int64_t s) const final {
     return ValidStateId(s) ? impl_->NumArcs(s)
                            : std::numeric_limits<size_t>::max();
   }
 
   // Signals failure by returning size_t max.
-  size_t NumInputEpsilons(int64 s) const final {
+  size_t NumInputEpsilons(int64_t s) const final {
     return ValidStateId(s) ? impl_->NumInputEpsilons(s)
                            : std::numeric_limits<size_t>::max();
   }
 
   // Signals failure by returning size_t max.
-  size_t NumOutputEpsilons(int64 s) const final {
+  size_t NumOutputEpsilons(int64_t s) const final {
     return ValidStateId(s) ? impl_->NumOutputEpsilons(s)
                            : std::numeric_limits<size_t>::max();
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  int64 NumStates() const final {
-    return fst::down_cast<MutableFst<Arc> *>(impl_.get())->NumStates();
+  int64_t NumStates() const final {
+    return down_cast<MutableFst<Arc> *>(impl_.get())->NumStates();
   }
 
-  uint64 Properties(uint64 mask, bool test) const final {
+  uint64_t Properties(uint64_t mask, bool test) const final {
     return impl_->Properties(mask, test);
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool ReserveArcs(int64 s, size_t n) final {
+  bool ReserveArcs(int64_t s, size_t n) final {
     if (!ValidStateId(s)) return false;
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->ReserveArcs(s, n);
+    down_cast<MutableFst<Arc> *>(impl_.get())->ReserveArcs(s, n);
     return true;
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  void ReserveStates(int64 n) final {
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->ReserveStates(n);
+  void ReserveStates(int64_t n) final {
+    down_cast<MutableFst<Arc> *>(impl_.get())->ReserveStates(n);
   }
 
   const SymbolTable *OutputSymbols() const final {
@@ -228,37 +231,37 @@ class FstClassImpl : public FstClassImplBase {
 
   // Warning: calling this method casts the FST to a mutable FST.
   void SetInputSymbols(const SymbolTable *isyms) final {
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->SetInputSymbols(isyms);
+    down_cast<MutableFst<Arc> *>(impl_.get())->SetInputSymbols(isyms);
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool SetFinal(int64 s, const WeightClass &weight) final {
+  bool SetFinal(int64_t s, const WeightClass &weight) final {
     if (!ValidStateId(s)) return false;
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())
+    down_cast<MutableFst<Arc> *>(impl_.get())
         ->SetFinal(s, *weight.GetWeight<typename Arc::Weight>());
     return true;
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
   void SetOutputSymbols(const SymbolTable *osyms) final {
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->SetOutputSymbols(osyms);
+    down_cast<MutableFst<Arc> *>(impl_.get())->SetOutputSymbols(osyms);
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  void SetProperties(uint64 props, uint64 mask) final {
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->SetProperties(props, mask);
+  void SetProperties(uint64_t props, uint64_t mask) final {
+    down_cast<MutableFst<Arc> *>(impl_.get())->SetProperties(props, mask);
   }
 
   // Warning: calling this method casts the FST to a mutable FST.
-  bool SetStart(int64 s) final {
+  bool SetStart(int64_t s) final {
     if (!ValidStateId(s)) return false;
-    fst::down_cast<MutableFst<Arc> *>(impl_.get())->SetStart(s);
+    down_cast<MutableFst<Arc> *>(impl_.get())->SetStart(s);
     return true;
   }
 
-  int64 Start() const final { return impl_->Start(); }
+  int64_t Start() const final { return impl_->Start(); }
 
-  bool ValidStateId(int64 s) const final {
+  bool ValidStateId(int64_t s) const final {
     // This cowardly refuses to count states if the FST is not yet expanded.
     if (!Properties(kExpanded, true)) {
       FSTERROR() << "Cannot get number of states for unexpanded FST";
@@ -315,7 +318,7 @@ class FstClass : public FstClassBase {
     return *this;
   }
 
-  WeightClass Final(int64 s) const final { return impl_->Final(s); }
+  WeightClass Final(int64_t s) const final { return impl_->Final(s); }
 
   const std::string &ArcType() const final { return impl_->ArcType(); }
 
@@ -325,13 +328,13 @@ class FstClass : public FstClassBase {
     return impl_->InputSymbols();
   }
 
-  size_t NumArcs(int64 s) const final { return impl_->NumArcs(s); }
+  size_t NumArcs(int64_t s) const final { return impl_->NumArcs(s); }
 
-  size_t NumInputEpsilons(int64 s) const final {
+  size_t NumInputEpsilons(int64_t s) const final {
     return impl_->NumInputEpsilons(s);
   }
 
-  size_t NumOutputEpsilons(int64 s) const final {
+  size_t NumOutputEpsilons(int64_t s) const final {
     return impl_->NumOutputEpsilons(s);
   }
 
@@ -339,19 +342,20 @@ class FstClass : public FstClassBase {
     return impl_->OutputSymbols();
   }
 
-  uint64 Properties(uint64 mask, bool test) const final {
+  uint64_t Properties(uint64_t mask, bool test) const final {
     // Special handling for FSTs with a null impl.
     if (!impl_) return kError & mask;
     return impl_->Properties(mask, test);
   }
 
-  static FstClass *Read(const std::string &source);
+  static std::unique_ptr<FstClass> Read(const std::string &source);
 
-  static FstClass *Read(std::istream &istrm, const std::string &source);
+  static std::unique_ptr<FstClass> Read(std::istream &istrm,
+                                        const std::string &source);
 
-  int64 Start() const final { return impl_->Start(); }
+  int64_t Start() const final { return impl_->Start(); }
 
-  bool ValidStateId(int64 s) const final { return impl_->ValidStateId(s); }
+  bool ValidStateId(int64_t s) const final { return impl_->ValidStateId(s); }
 
   const std::string &WeightType() const final { return impl_->WeightType(); }
 
@@ -359,7 +363,7 @@ class FstClass : public FstClassBase {
   // don't match.
 
   bool WeightTypesMatch(const WeightClass &weight,
-                        const std::string &op_name) const;
+                        std::string_view op_name) const;
 
   bool Write(const std::string &source) const final {
     return impl_->Write(source);
@@ -374,13 +378,13 @@ class FstClass : public FstClassBase {
   // These methods are required by IO registration.
 
   template <class Arc>
-  static FstClassImplBase *Convert(const FstClass &other) {
+  static std::unique_ptr<FstClassImplBase> Convert(const FstClass &other) {
     FSTERROR() << "Doesn't make sense to convert any class to type FstClass";
     return nullptr;
   }
 
   template <class Arc>
-  static FstClassImplBase *Create() {
+  static std::unique_ptr<FstClassImplBase> Create() {
     FSTERROR() << "Doesn't make sense to create an FstClass with a "
                << "particular arc type";
     return nullptr;
@@ -392,13 +396,14 @@ class FstClass : public FstClassBase {
       return nullptr;
     } else {
       FstClassImpl<Arc> *typed_impl =
-          fst::down_cast<FstClassImpl<Arc> *>(impl_.get());
+          down_cast<FstClassImpl<Arc> *>(impl_.get());
       return typed_impl->GetImpl();
     }
   }
 
   template <class Arc>
-  static FstClass *Read(std::istream &stream, const FstReadOptions &opts) {
+  static std::unique_ptr<FstClass> Read(std::istream &stream,
+                                        const FstReadOptions &opts) {
     if (!opts.header) {
       LOG(ERROR) << "FstClass::Read: Options header not specified";
       return nullptr;
@@ -423,10 +428,10 @@ class FstClass : public FstClassBase {
   // UnderlyingT, and returning it wrapped as FstClassT, with appropriate
   // error checking. Called from arc-templated Read() static methods.
   template <class FstClassT, class UnderlyingT>
-  static FstClassT *ReadTypedFst(std::istream &stream,
-                                 const FstReadOptions &opts) {
+  static std::unique_ptr<FstClassT> ReadTypedFst(std::istream &stream,
+                                                 const FstReadOptions &opts) {
     std::unique_ptr<UnderlyingT> u(UnderlyingT::Read(stream, opts));
-    return u ? new FstClassT(std::move(u)) : nullptr;
+    return u ? std::make_unique<FstClassT>(std::move(u)) : nullptr;
   }
 
  private:
@@ -437,20 +442,20 @@ class FstClass : public FstClassBase {
 
 class MutableFstClass : public FstClass {
  public:
-  bool AddArc(int64 s, const ArcClass &ac) {
+  bool AddArc(int64_t s, const ArcClass &ac) {
     if (!WeightTypesMatch(ac.weight, "AddArc")) return false;
     return GetImpl()->AddArc(s, ac);
   }
 
-  int64 AddState() { return GetImpl()->AddState(); }
+  int64_t AddState() { return GetImpl()->AddState(); }
 
   void AddStates(size_t n) { return GetImpl()->AddStates(n); }
 
-  bool DeleteArcs(int64 s, size_t n) { return GetImpl()->DeleteArcs(s, n); }
+  bool DeleteArcs(int64_t s, size_t n) { return GetImpl()->DeleteArcs(s, n); }
 
-  bool DeleteArcs(int64 s) { return GetImpl()->DeleteArcs(s); }
+  bool DeleteArcs(int64_t s) { return GetImpl()->DeleteArcs(s); }
 
-  bool DeleteStates(const std::vector<int64> &dstates) {
+  bool DeleteStates(const std::vector<int64_t> &dstates) {
     return GetImpl()->DeleteStates(dstates);
   }
 
@@ -464,19 +469,20 @@ class MutableFstClass : public FstClass {
     return GetImpl()->MutableOutputSymbols();
   }
 
-  int64 NumStates() const { return GetImpl()->NumStates(); }
+  int64_t NumStates() const { return GetImpl()->NumStates(); }
 
-  bool ReserveArcs(int64 s, size_t n) { return GetImpl()->ReserveArcs(s, n); }
+  bool ReserveArcs(int64_t s, size_t n) { return GetImpl()->ReserveArcs(s, n); }
 
-  void ReserveStates(int64 n) { GetImpl()->ReserveStates(n); }
+  void ReserveStates(int64_t n) { GetImpl()->ReserveStates(n); }
 
-  static MutableFstClass *Read(const std::string &source, bool convert = false);
+  static std::unique_ptr<MutableFstClass> Read(const std::string &source,
+                                               bool convert = false);
 
   void SetInputSymbols(const SymbolTable *isyms) {
     GetImpl()->SetInputSymbols(isyms);
   }
 
-  bool SetFinal(int64 s, const WeightClass &weight) {
+  bool SetFinal(int64_t s, const WeightClass &weight) {
     if (!WeightTypesMatch(weight, "SetFinal")) return false;
     return GetImpl()->SetFinal(s, weight);
   }
@@ -485,11 +491,11 @@ class MutableFstClass : public FstClass {
     GetImpl()->SetOutputSymbols(osyms);
   }
 
-  void SetProperties(uint64 props, uint64 mask) {
+  void SetProperties(uint64_t props, uint64_t mask) {
     GetImpl()->SetProperties(props, mask);
   }
 
-  bool SetStart(int64 s) { return GetImpl()->SetStart(s); }
+  bool SetStart(int64_t s) { return GetImpl()->SetStart(s); }
 
   template <class Arc>
   explicit MutableFstClass(std::unique_ptr<MutableFst<Arc>> fst)
@@ -504,14 +510,14 @@ class MutableFstClass : public FstClass {
   // These methods are required by IO registration.
 
   template <class Arc>
-  static FstClassImplBase *Convert(const FstClass &other) {
+  static std::unique_ptr<FstClassImplBase> Convert(const FstClass &other) {
     FSTERROR() << "Doesn't make sense to convert any class to type "
                << "MutableFstClass";
     return nullptr;
   }
 
   template <class Arc>
-  static FstClassImplBase *Create() {
+  static std::unique_ptr<FstClassImplBase> Create() {
     FSTERROR() << "Doesn't make sense to create a MutableFstClass with a "
                << "particular arc type";
     return nullptr;
@@ -520,15 +526,15 @@ class MutableFstClass : public FstClass {
   template <class Arc>
   MutableFst<Arc> *GetMutableFst() {
     Fst<Arc> *fst = const_cast<Fst<Arc> *>(this->GetFst<Arc>());
-    MutableFst<Arc> *mfst = fst::down_cast<MutableFst<Arc> *>(fst);
+    MutableFst<Arc> *mfst = down_cast<MutableFst<Arc> *>(fst);
     return mfst;
   }
 
   template <class Arc>
-  static MutableFstClass *Read(std::istream &stream,
-                               const FstReadOptions &opts) {
+  static std::unique_ptr<MutableFstClass> Read(std::istream &stream,
+                                               const FstReadOptions &opts) {
     std::unique_ptr<MutableFst<Arc>> mfst(MutableFst<Arc>::Read(stream, opts));
-    return mfst ? new MutableFstClass(*mfst) : nullptr;
+    return mfst ? std::make_unique<MutableFstClass>(std::move(mfst)) : nullptr;
   }
 
  protected:
@@ -543,15 +549,15 @@ class VectorFstClass : public MutableFstClass {
 
   explicit VectorFstClass(const FstClass &other);
 
-  explicit VectorFstClass(const std::string &arc_type);
+  explicit VectorFstClass(std::string_view arc_type);
 
-  static VectorFstClass *Read(const std::string &source);
+  static std::unique_ptr<VectorFstClass> Read(const std::string &source);
 
   template <class Arc>
-  static VectorFstClass *Read(std::istream &stream,
-                              const FstReadOptions &opts) {
-    std::unique_ptr<VectorFst<Arc>> mfst(VectorFst<Arc>::Read(stream, opts));
-    return mfst ? new VectorFstClass(*mfst) : nullptr;
+  static std::unique_ptr<VectorFstClass> Read(std::istream &stream,
+                                              const FstReadOptions &opts) {
+    std::unique_ptr<VectorFst<Arc>> vfst(VectorFst<Arc>::Read(stream, opts));
+    return vfst ? std::make_unique<VectorFstClass>(std::move(vfst)) : nullptr;
   }
 
   template <class Arc>
@@ -565,14 +571,15 @@ class VectorFstClass : public MutableFstClass {
   explicit VectorFstClass(const VectorFst<Arc> &fst) : MutableFstClass(fst) {}
 
   template <class Arc>
-  static FstClassImplBase *Convert(const FstClass &other) {
-    return new FstClassImpl<Arc>(
+  static std::unique_ptr<FstClassImplBase> Convert(const FstClass &other) {
+    return std::make_unique<FstClassImpl<Arc>>(
         std::make_unique<VectorFst<Arc>>(*other.GetFst<Arc>()));
   }
 
   template <class Arc>
-  static FstClassImplBase *Create() {
-    return new FstClassImpl<Arc>(std::make_unique<VectorFst<Arc>>());
+  static std::unique_ptr<FstClassImplBase> Create() {
+    return std::make_unique<FstClassImpl<Arc>>(
+        std::make_unique<VectorFst<Arc>>());
   }
 };
 
@@ -599,23 +606,24 @@ class FstClassIORegister
                              FstClassRegEntry<Reader, Creator, Converter>,
                              FstClassIORegister<Reader, Creator, Converter>> {
  public:
-  Reader GetReader(const std::string &arc_type) const {
+  Reader GetReader(std::string_view arc_type) const {
     return this->GetEntry(arc_type).reader;
   }
 
-  Creator GetCreator(const std::string &arc_type) const {
+  Creator GetCreator(std::string_view arc_type) const {
     return this->GetEntry(arc_type).creator;
   }
 
-  Converter GetConverter(const std::string &arc_type) const {
+  Converter GetConverter(std::string_view arc_type) const {
     return this->GetEntry(arc_type).converter;
   }
 
  protected:
-  std::string ConvertKeyToSoFilename(const std::string &key) const final {
+  std::string ConvertKeyToSoFilename(std::string_view key) const final {
     std::string legal_type(key);
     ConvertToLegalCSymbol(&legal_type);
-    return legal_type + "-arc.so";
+    legal_type.append("-arc.so");
+    return legal_type;
   }
 };
 
@@ -623,12 +631,13 @@ class FstClassIORegister
 // of FST class (e.g., a plain FstClass, or a MutableFstClass, etc.).
 template <class FstClassType>
 struct FstClassIORegistration {
-  using Reader = FstClassType *(*)(std::istream &stream,
-                                   const FstReadOptions &opts);
+  using Reader = std::unique_ptr<FstClassType> (*)(std::istream &stream,
+                                                   const FstReadOptions &opts);
 
-  using Creator = FstClassImplBase *(*)();
+  using Creator = std::unique_ptr<FstClassImplBase> (*)();
 
-  using Converter = FstClassImplBase *(*)(const FstClass &other);
+  using Converter =
+      std::unique_ptr<FstClassImplBase> (*)(const FstClass &other);
 
   using Entry = FstClassRegEntry<Reader, Creator, Converter>;
 
index eaf669d..6ecd6aa 100644 (file)
@@ -100,61 +100,61 @@ class AllFstOperationsRegisterer {
 
  private:
   void RegisterBatch1() {
-    REGISTER_FST_OPERATION(ArcSort, Arc, ArcSortArgs);
-    REGISTER_FST_OPERATION(Closure, Arc, ClosureArgs);
-    REGISTER_FST_OPERATION(CompileFstInternal, Arc, CompileFstArgs);
-    REGISTER_FST_OPERATION(Compose, Arc, ComposeArgs);
-    REGISTER_FST_OPERATION(Concat, Arc, ConcatArgs1);
-    REGISTER_FST_OPERATION(Concat, Arc, ConcatArgs2);
-    REGISTER_FST_OPERATION(Concat, Arc, ConcatArgs3);
+    REGISTER_FST_OPERATION(ArcSort, Arc, FstArcSortArgs);
+    REGISTER_FST_OPERATION(Closure, Arc, FstClosureArgs);
+    REGISTER_FST_OPERATION(CompileInternal, Arc, FstCompileArgs);
+    REGISTER_FST_OPERATION(Compose, Arc, FstComposeArgs);
+    REGISTER_FST_OPERATION(Concat, Arc, FstConcatArgs1);
+    REGISTER_FST_OPERATION(Concat, Arc, FstConcatArgs2);
+    REGISTER_FST_OPERATION(Concat, Arc, FstConcatArgs3);
     REGISTER_FST_OPERATION(Connect, Arc, MutableFstClass);
-    REGISTER_FST_OPERATION(Convert, Arc, ConvertArgs);
-    REGISTER_FST_OPERATION(Decode, Arc, DecodeArgs);
-    REGISTER_FST_OPERATION(Determinize, Arc, DeterminizeArgs);
-    REGISTER_FST_OPERATION(Difference, Arc, DifferenceArgs);
-    REGISTER_FST_OPERATION(Disambiguate, Arc, DisambiguateArgs);
-    REGISTER_FST_OPERATION(Draw, Arc, DrawArgs);
-    REGISTER_FST_OPERATION(Encode, Arc, EncodeArgs);
-    REGISTER_FST_OPERATION(EpsNormalize, Arc, EpsNormalizeArgs);
-    REGISTER_FST_OPERATION(Equal, Arc, EqualArgs);
-    REGISTER_FST_OPERATION(Equivalent, Arc, EquivalentArgs);
+    REGISTER_FST_OPERATION(Convert, Arc, FstConvertArgs);
+    REGISTER_FST_OPERATION(Decode, Arc, FstDecodeArgs);
+    REGISTER_FST_OPERATION(Determinize, Arc, FstDeterminizeArgs);
+    REGISTER_FST_OPERATION(Difference, Arc, FstDifferenceArgs);
+    REGISTER_FST_OPERATION(Disambiguate, Arc, FstDisambiguateArgs);
+    REGISTER_FST_OPERATION(Draw, Arc, FstDrawArgs);
+    REGISTER_FST_OPERATION(Encode, Arc, FstEncodeArgs);
+    REGISTER_FST_OPERATION(EpsNormalize, Arc, FstEpsNormalizeArgs);
+    REGISTER_FST_OPERATION(Equal, Arc, FstEqualArgs);
+    REGISTER_FST_OPERATION(Equivalent, Arc, FstEquivalentArgs);
+    REGISTER_FST_OPERATION(Info, Arc, FstInfoArgs);
     REGISTER_FST_OPERATION(InitArcIteratorClass, Arc, InitArcIteratorClassArgs);
     REGISTER_FST_OPERATION(InitMutableArcIteratorClass, Arc,
                            InitMutableArcIteratorClassArgs);
     REGISTER_FST_OPERATION(InitStateIteratorClass, Arc,
                            InitStateIteratorClassArgs);
-    REGISTER_FST_OPERATION(Info, Arc, InfoArgs);
-    REGISTER_FST_OPERATION(Intersect, Arc, IntersectArgs);
+    REGISTER_FST_OPERATION(Intersect, Arc, FstIntersectArgs);
     REGISTER_FST_OPERATION(Invert, Arc, MutableFstClass);
-    REGISTER_FST_OPERATION(Isomorphic, Arc, IsomorphicArgs);
+    REGISTER_FST_OPERATION(Isomorphic, Arc, FstIsomorphicArgs);
   }
 
   void RegisterBatch2() {
-    REGISTER_FST_OPERATION(Map, Arc, MapArgs);
-    REGISTER_FST_OPERATION(Minimize, Arc, MinimizeArgs);
-    REGISTER_FST_OPERATION(Print, Arc, PrintArgs);
-    REGISTER_FST_OPERATION(Project, Arc, ProjectArgs);
-    REGISTER_FST_OPERATION(Prune, Arc, PruneArgs1);
-    REGISTER_FST_OPERATION(Prune, Arc, PruneArgs2);
-    REGISTER_FST_OPERATION(Push, Arc, PushArgs1);
-    REGISTER_FST_OPERATION(Push, Arc, PushArgs2);
-    REGISTER_FST_OPERATION(RandEquivalent, Arc, RandEquivalentArgs);
-    REGISTER_FST_OPERATION(RandGen, Arc, RandGenArgs);
-    REGISTER_FST_OPERATION(Relabel, Arc, RelabelArgs1);
-    REGISTER_FST_OPERATION(Relabel, Arc, RelabelArgs2);
-    REGISTER_FST_OPERATION(Replace, Arc, ReplaceArgs);
-    REGISTER_FST_OPERATION(Reverse, Arc, ReverseArgs);
-    REGISTER_FST_OPERATION(Reweight, Arc, ReweightArgs);
-    REGISTER_FST_OPERATION(RmEpsilon, Arc, RmEpsilonArgs);
-    REGISTER_FST_OPERATION(ShortestDistance, Arc, ShortestDistanceArgs1);
-    REGISTER_FST_OPERATION(ShortestDistance, Arc, ShortestDistanceArgs2);
-    REGISTER_FST_OPERATION(ShortestDistance, Arc, ShortestDistanceArgs3);
-    REGISTER_FST_OPERATION(ShortestPath, Arc, ShortestPathArgs);
-    REGISTER_FST_OPERATION(Synchronize, Arc, SynchronizeArgs);
-    REGISTER_FST_OPERATION(TopSort, Arc, TopSortArgs);
-    REGISTER_FST_OPERATION(Union, Arc, UnionArgs1);
-    REGISTER_FST_OPERATION(Union, Arc, UnionArgs2);
-    REGISTER_FST_OPERATION(Verify, Arc, VerifyArgs);
+    REGISTER_FST_OPERATION(Map, Arc, FstMapArgs);
+    REGISTER_FST_OPERATION(Minimize, Arc, FstMinimizeArgs);
+    REGISTER_FST_OPERATION(Print, Arc, FstPrintArgs);
+    REGISTER_FST_OPERATION(Project, Arc, FstProjectArgs);
+    REGISTER_FST_OPERATION(Prune, Arc, FstPruneArgs1);
+    REGISTER_FST_OPERATION(Prune, Arc, FstPruneArgs2);
+    REGISTER_FST_OPERATION(Push, Arc, FstPushArgs1);
+    REGISTER_FST_OPERATION(Push, Arc, FstPushArgs2);
+    REGISTER_FST_OPERATION(RandEquivalent, Arc, FstRandEquivalentArgs);
+    REGISTER_FST_OPERATION(RandGen, Arc, FstRandGenArgs);
+    REGISTER_FST_OPERATION(Relabel, Arc, FstRelabelArgs1);
+    REGISTER_FST_OPERATION(Relabel, Arc, FstRelabelArgs2);
+    REGISTER_FST_OPERATION(Replace, Arc, FstReplaceArgs);
+    REGISTER_FST_OPERATION(Reverse, Arc, FstReverseArgs);
+    REGISTER_FST_OPERATION(Reweight, Arc, FstReweightArgs);
+    REGISTER_FST_OPERATION(RmEpsilon, Arc, FstRmEpsilonArgs);
+    REGISTER_FST_OPERATION(ShortestDistance, Arc, FstShortestDistanceArgs1);
+    REGISTER_FST_OPERATION(ShortestDistance, Arc, FstShortestDistanceArgs2);
+    REGISTER_FST_OPERATION(ShortestDistance, Arc, FstShortestDistanceArgs3);
+    REGISTER_FST_OPERATION(ShortestPath, Arc, FstShortestPathArgs);
+    REGISTER_FST_OPERATION(Synchronize, Arc, FstSynchronizeArgs);
+    REGISTER_FST_OPERATION(TopSort, Arc, FstTopSortArgs);
+    REGISTER_FST_OPERATION(Union, Arc, FstUnionArgs1);
+    REGISTER_FST_OPERATION(Union, Arc, FstUnionArgs2);
+    REGISTER_FST_OPERATION(Verify, Arc, FstVerifyArgs);
   }
 };
 
index f98f0b7..7dfa236 100644 (file)
 #ifndef FST_SCRIPT_GETTERS_H_
 #define FST_SCRIPT_GETTERS_H_
 
+#include <cstdint>
 #include <string>
 
-#include <fst/types.h>
 #include <fst/log.h>
-#include <fst/compose.h>         // For ComposeFilter.
-#include <fst/determinize.h>     // For DeterminizeType.
-#include <fst/encode.h>          // For kEncodeLabels (etc.).
-#include <fst/epsnormalize.h>    // For EpsNormalizeType.
-#include <fst/project.h>         // For ProjectType.
-#include <fst/push.h>            // For kPushWeights (etc.).
-#include <fst/queue.h>           // For QueueType.
-#include <fst/rational.h>        // For ClosureType.
-#include <fst/string.h>          // For TokenType.
-#include <fst/script/arcsort.h>      // For ArcSortType.
-#include <fst/script/map.h>          // For MapType.
-#include <fst/script/script-impl.h>  // For RandArcSelection.
+#include <fst/compose.h>            // For ComposeFilter.
+#include <fst/determinize.h>        // For DeterminizeType.
+#include <fst/encode.h>             // For kEncodeLabels (etc.).
+#include <fst/epsnormalize.h>       // For EpsNormalizeType.
+#include <fst/project.h>            // For ProjectType.
+#include <fst/push.h>               // For kPushWeights (etc.).
+#include <fst/queue.h>              // For QueueType.
+#include <fst/rational.h>           // For ClosureType.
+#include <fst/string.h>             // For TokenType.
+#include <fst/script/arcfilter-impl.h>  // For ArcFilterType.
+#include <fst/script/arcsort.h>         // For ArcSortType.
+#include <fst/script/map.h>             // For MapType.
+#include <fst/script/script-impl.h>     // For RandArcSelection.
+#include <string_view>
 
 namespace fst {
 namespace script {
 
-bool GetArcSortType(const std::string &str, ArcSortType *sort_type);
+bool GetArcFilterType(std::string_view str, ArcFilterType *arc_filter_type);
 
-inline ClosureType GetClosureType(bool closure_plus) {
-  return closure_plus ? CLOSURE_PLUS : CLOSURE_STAR;
-}
+bool GetArcSortType(std::string_view str, ArcSortType *sort_type);
+
+bool GetClosureType(std::string_view str, ClosureType *closure_type);
 
-bool GetComposeFilter(const std::string &str, ComposeFilter *compose_filter);
+bool GetComposeFilter(std::string_view str, ComposeFilter *compose_filter);
 
-bool GetDeterminizeType(const std::string &str, DeterminizeType *det_type);
+bool GetDeterminizeType(std::string_view str, DeterminizeType *det_type);
 
-inline uint8 GetEncodeFlags(bool encode_labels, bool encode_weights) {
+inline uint8_t GetEncodeFlags(bool encode_labels, bool encode_weights) {
   return (encode_labels ? kEncodeLabels : 0) |
          (encode_weights ? kEncodeWeights : 0);
 }
 
-inline EpsNormalizeType GetEpsNormalizeType(bool eps_norm_output) {
-  return eps_norm_output ? EPS_NORM_OUTPUT : EPS_NORM_INPUT;
-}
+bool GetEpsNormalizeType(std::string_view str,
+                         EpsNormalizeType *eps_norm_type);
 
-bool GetMapType(const std::string &str, MapType *map_type);
+bool GetMapType(std::string_view str, MapType *map_type);
 
-bool GetProjectType(const std::string &str, ProjectType *project_type);
+bool GetProjectType(std::string_view str, ProjectType *project_type);
 
-inline uint8 GetPushFlags(bool push_weights, bool push_labels,
-                          bool remove_total_weight, bool remove_common_affix) {
+inline uint8_t GetPushFlags(bool push_weights, bool push_labels,
+                            bool remove_total_weight,
+                            bool remove_common_affix) {
   return ((push_weights ? kPushWeights : 0) | (push_labels ? kPushLabels : 0) |
           (remove_total_weight ? kPushRemoveTotalWeight : 0) |
           (remove_common_affix ? kPushRemoveCommonAffix : 0));
 }
 
-bool GetQueueType(const std::string &str, QueueType *queue_type);
+bool GetQueueType(std::string_view str, QueueType *queue_type);
 
-bool GetRandArcSelection(const std::string &str, RandArcSelection *ras);
+bool GetRandArcSelection(std::string_view str, RandArcSelection *ras);
 
-bool GetReplaceLabelType(const std::string &str, bool epsilon_on_replace,
+bool GetReplaceLabelType(std::string_view str, bool epsilon_on_replace,
                          ReplaceLabelType *rlt);
 
-inline ReweightType GetReweightType(bool to_final) {
-  return to_final ? REWEIGHT_TO_FINAL : REWEIGHT_TO_INITIAL;
-}
+bool GetReweightType(std::string_view str, ReweightType *reweight_type);
 
-bool GetTokenType(const std::string &str, TokenType *token_type);
+bool GetTokenType(std::string_view str, TokenType *token_type);
 
 }  // namespace script
 }  // namespace fst
index 9b3428a..7e485c9 100644 (file)
 #ifndef FST_SCRIPT_INFO_IMPL_H_
 #define FST_SCRIPT_INFO_IMPL_H_
 
+#include <cstdint>
 #include <map>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/connect.h>
 #include <fst/dfs-visit.h>
 #include <fst/fst.h>
@@ -35,6 +35,8 @@
 #include <fst/test-properties.h>
 #include <fst/verify.h>
 #include <fst/visit.h>
+#include <fst/script/arcfilter-impl.h>
+#include <string_view>
 
 namespace fst {
 
@@ -48,8 +50,8 @@ class FstInfo {
   // minimal info is computed and can be requested.
   template <typename Arc>
   FstInfo(const Fst<Arc> &fst, bool test_properties,
-          const std::string &arc_filter_type = "any",
-          const std::string &info_type = "auto", bool verify = true)
+          script::ArcFilterType arc_filter_type = script::ArcFilterType::ANY,
+          std::string_view info_type = "auto", bool verify = true)
       : fst_type_(fst.Type()),
         input_symbols_(fst.InputSymbols() ? fst.InputSymbols()->Name()
                                           : "none"),
@@ -128,17 +130,23 @@ class FstInfo {
       std::vector<StateId> cc;
       CcVisitor<Arc> cc_visitor(&cc);
       FifoQueue<StateId> fifo_queue;
-      if (arc_filter_type == "any") {
-        Visit(fst, &cc_visitor, &fifo_queue);
-      } else if (arc_filter_type == "epsilon") {
-        Visit(fst, &cc_visitor, &fifo_queue, EpsilonArcFilter<Arc>());
-      } else if (arc_filter_type == "iepsilon") {
-        Visit(fst, &cc_visitor, &fifo_queue, InputEpsilonArcFilter<Arc>());
-      } else if (arc_filter_type == "oepsilon") {
-        Visit(fst, &cc_visitor, &fifo_queue, OutputEpsilonArcFilter<Arc>());
-      } else {
-        FSTERROR() << "Bad arc filter type: " << arc_filter_type;
-        return;
+      switch (arc_filter_type) {
+        case script::ArcFilterType::ANY: {
+          Visit(fst, &cc_visitor, &fifo_queue);
+          break;
+        }
+        case script::ArcFilterType::EPSILON: {
+          Visit(fst, &cc_visitor, &fifo_queue, EpsilonArcFilter<Arc>());
+          break;
+        }
+        case script::ArcFilterType::INPUT_EPSILON: {
+          Visit(fst, &cc_visitor, &fifo_queue, InputEpsilonArcFilter<Arc>());
+          break;
+        }
+        case script::ArcFilterType::OUTPUT_EPSILON: {
+          Visit(fst, &cc_visitor, &fifo_queue, OutputEpsilonArcFilter<Arc>());
+          break;
+        }
       }
       for (StateId s = 0; s < cc.size(); ++s) {
         if (cc[s] >= ncc_) ncc_ = cc[s] + 1;
@@ -147,19 +155,25 @@ class FstInfo {
     {
       std::vector<StateId> scc;
       std::vector<bool> access, coaccess;
-      uint64 props = 0;
+      uint64_t props = 0;
       SccVisitor<Arc> scc_visitor(&scc, &access, &coaccess, &props);
-      if (arc_filter_type == "any") {
-        DfsVisit(fst, &scc_visitor);
-      } else if (arc_filter_type == "epsilon") {
-        DfsVisit(fst, &scc_visitor, EpsilonArcFilter<Arc>());
-      } else if (arc_filter_type == "iepsilon") {
-        DfsVisit(fst, &scc_visitor, InputEpsilonArcFilter<Arc>());
-      } else if (arc_filter_type == "oepsilon") {
-        DfsVisit(fst, &scc_visitor, OutputEpsilonArcFilter<Arc>());
-      } else {
-        FSTERROR() << "Bad arc filter type: " << arc_filter_type;
-        return;
+      switch (arc_filter_type) {
+        case script::ArcFilterType::ANY: {
+          DfsVisit(fst, &scc_visitor);
+          break;
+        }
+        case script::ArcFilterType::EPSILON: {
+          DfsVisit(fst, &scc_visitor, EpsilonArcFilter<Arc>());
+          break;
+        }
+        case script::ArcFilterType::INPUT_EPSILON: {
+          DfsVisit(fst, &scc_visitor, InputEpsilonArcFilter<Arc>());
+          break;
+        }
+        case script::ArcFilterType::OUTPUT_EPSILON: {
+          DfsVisit(fst, &scc_visitor, OutputEpsilonArcFilter<Arc>());
+          break;
+        }
       }
       for (StateId s = 0; s < scc.size(); ++s) {
         if (access[s]) ++naccess_;
@@ -188,7 +202,7 @@ class FstInfo {
 
   bool LongInfo() const { return long_info_; }
 
-  const std::string &ArcFilterType() const { return arc_filter_type_; }
+  script::ArcFilterType ArcFilterType() const { return arc_filter_type_; }
 
   // Long info.
 
@@ -212,7 +226,7 @@ class FstInfo {
     return output_lookahead_;
   }
 
-  int64 NumStates() const {
+  int64_t NumStates() const {
     CheckLong();
     return nstates_;
   }
@@ -222,7 +236,7 @@ class FstInfo {
     return narcs_;
   }
 
-  int64 Start() const {
+  int64_t Start() const {
     CheckLong();
     return start_;
   }
@@ -282,7 +296,7 @@ class FstInfo {
     return nscc_;
   }
 
-  uint64 Properties() const {
+  uint64_t Properties() const {
     CheckLong();
     return properties_;
   }
@@ -298,9 +312,9 @@ class FstInfo {
   std::string fst_type_;
   std::string input_symbols_;
   std::string output_symbols_;
-  int64 nstates_;
+  int64_t nstates_;
   size_t narcs_;
-  int64 start_;
+  int64_t start_;
   size_t nfinal_;
   size_t nepsilons_;
   size_t niepsilons_;
@@ -316,14 +330,14 @@ class FstInfo {
   MatchType output_match_type_;
   bool input_lookahead_;
   bool output_lookahead_;
-  uint64 properties_;
-  std::string arc_filter_type_;
+  uint64_t properties_;
+  script::ArcFilterType arc_filter_type_;
   bool long_info_;
   std::string arc_type_;
 };
 
 // Prints `properties` to `ostrm` in a user-friendly multi-line format.
-void PrintProperties(std::ostream &ostrm, uint64 properties);
+void PrintProperties(std::ostream &ostrm, uint64_t properties);
 
 // Prints `header` to `ostrm` in a user-friendly multi-line format.
 void PrintHeader(std::ostream &ostrm, const FstHeader &header);
index ca8f030..0ef2e86 100644 (file)
@@ -21,6 +21,7 @@
 #include <string>
 #include <tuple>
 
+#include <fst/script/arcfilter-impl.h>
 #include <fst/script/arg-packs.h>
 #include <fst/script/fst-class.h>
 #include <fst/script/info-impl.h>
 namespace fst {
 namespace script {
 
-using InfoArgs = std::tuple<const FstClass &, bool, const std::string &,
-                            const std::string &, bool>;
+using FstInfoArgs = std::tuple<const FstClass &, bool, ArcFilterType,
+                               const std::string &, bool>;
 
 template <class Arc>
-void Info(InfoArgs *args) {
+void Info(FstInfoArgs *args) {
   const Fst<Arc> &fst = *std::get<0>(*args).GetFst<Arc>();
   const FstInfo info(fst, std::get<1>(*args), std::get<2>(*args),
                      std::get<3>(*args), std::get<4>(*args));
   info.Info();
 }
 
-void Info(const FstClass &fst, bool test_properties,
-          const std::string &arc_filter, const std::string &info_type,
-          bool verify);
+void Info(const FstClass &fst, bool test_properties, ArcFilterType arc_filter,
+          const std::string &info_type, bool verify);
 
 }  // namespace script
 }  // namespace fst
index 757d5e5..bc82f43 100644 (file)
 namespace fst {
 namespace script {
 
-using IntersectArgs = std::tuple<const FstClass &, const FstClass &,
-                                 MutableFstClass *, const ComposeOptions &>;
+using FstIntersectArgs = std::tuple<const FstClass &, const FstClass &,
+                                    MutableFstClass *, const ComposeOptions &>;
 
 template <class Arc>
-void Intersect(IntersectArgs *args) {
+void Intersect(FstIntersectArgs *args) {
   const Fst<Arc> &ifst1 = *std::get<0>(*args).GetFst<Arc>();
   const Fst<Arc> &ifst2 = *std::get<1>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<2>(*args)->GetMutableFst<Arc>();
index f217d53..601d86d 100644 (file)
 namespace fst {
 namespace script {
 
-using IsomorphicInnerArgs =
+using FstIsomorphicInnerArgs =
     std::tuple<const FstClass &, const FstClass &, float>;
 
-using IsomorphicArgs = WithReturnValue<bool, IsomorphicInnerArgs>;
+using FstIsomorphicArgs = WithReturnValue<bool, FstIsomorphicInnerArgs>;
 
 template <class Arc>
-void Isomorphic(IsomorphicArgs *args) {
+void Isomorphic(FstIsomorphicArgs *args) {
   const Fst<Arc> &fst1 = *std::get<0>(args->args).GetFst<Arc>();
   const Fst<Arc> &fst2 = *std::get<1>(args->args).GetFst<Arc>();
   args->retval = Isomorphic(fst1, fst2, std::get<2>(args->args));
index 310092f..6563f5c 100644 (file)
 #ifndef FST_SCRIPT_MAP_H_
 #define FST_SCRIPT_MAP_H_
 
+#include <cstdint>
 #include <memory>
 #include <tuple>
 
-#include <fst/types.h>
 #include <fst/arc-map.h>
 #include <fst/state-map.h>
 #include <fst/script/arg-packs.h>
@@ -49,7 +49,7 @@ std::unique_ptr<Fst<typename M::ToArc>> StateMap(
   return ofst;
 }
 
-enum class MapType : uint8 {
+enum class MapType : uint8_t {
   ARC_SUM,
   ARC_UNIQUE,
   IDENTITY,
@@ -67,13 +67,13 @@ enum class MapType : uint8 {
   TO_STD
 };
 
-using MapInnerArgs =
+using FstMapInnerArgs =
     std::tuple<const FstClass &, MapType, float, double, const WeightClass &>;
 
-using MapArgs = WithReturnValue<std::unique_ptr<FstClass>, MapInnerArgs>;
+using FstMapArgs = WithReturnValue<std::unique_ptr<FstClass>, FstMapInnerArgs>;
 
 template <class Arc>
-void Map(MapArgs *args) {
+void Map(FstMapArgs *args) {
   using Weight = typename Arc::Weight;
   const Fst<Arc> &ifst = *std::get<0>(args->args).GetFst<Arc>();
   const auto map_type = std::get<1>(args->args);
index 626ccff..9436f6c 100644 (file)
 namespace fst {
 namespace script {
 
-using MinimizeArgs =
+using FstMinimizeArgs =
     std::tuple<MutableFstClass *, MutableFstClass *, float, bool>;
 
 template <class Arc>
-void Minimize(MinimizeArgs *args) {
+void Minimize(FstMinimizeArgs *args) {
   MutableFst<Arc> *ofst1 = std::get<0>(*args)->GetMutableFst<Arc>();
   MutableFst<Arc> *ofst2 =
       std::get<1>(*args) ? std::get<1>(*args)->GetMutableFst<Arc>() : nullptr;
index c8d1d84..0d128e7 100644 (file)
@@ -50,27 +50,25 @@ class FstPrinter {
         osyms_(osyms),
         ssyms_(ssyms),
         accept_(accept && (fst.Properties(kAcceptor, true) == kAcceptor)),
-        ostrm_(nullptr),
         show_weight_one_(show_weight_one),
         sep_(field_separator),
         missing_symbol_(missing_symbol) {}
 
   // Prints FST to an output stream.
   void Print(std::ostream &ostrm, const std::string &dest) {
-    ostrm_ = &ostrm;
     dest_ = dest;
     const auto start = fst_.Start();
     if (start == kNoStateId) return;
     // Initial state first.
-    PrintState(start);
+    PrintState(ostrm, start);
     for (StateIterator<Fst<Arc>> siter(fst_); !siter.Done(); siter.Next()) {
       const auto s = siter.Value();
-      if (s != start) PrintState(s);
+      if (s != start) PrintState(ostrm, s);
     }
   }
 
  private:
-  void PrintId(StateId id, const SymbolTable *syms, const char *name) const {
+  std::string FormatId(StateId id, const SymbolTable *syms) const {
     if (syms) {
       std::string symbol = syms->Find(id);
       if (symbol.empty()) {
@@ -84,43 +82,40 @@ class FstPrinter {
           symbol = missing_symbol_;
         }
       }
-      *ostrm_ << symbol;
+      return symbol;
     } else {
-      *ostrm_ << id;
+      return std::to_string(id);
     }
   }
 
-  void PrintStateId(StateId s) const { PrintId(s, ssyms_, "state ID"); }
+  std::string FormatStateId(StateId s) const { return FormatId(s, ssyms_); }
 
-  void PrintILabel(Label l) const { PrintId(l, isyms_, "arc input label"); }
+  std::string FormatILabel(Label l) const { return FormatId(l, isyms_); }
 
-  void PrintOLabel(Label l) const { PrintId(l, osyms_, "arc output label"); }
+  std::string FormatOLabel(Label l) const { return FormatId(l, osyms_); }
 
-  void PrintState(StateId s) const {
+  void PrintState(std::ostream &ostrm, StateId s) const {
     bool output = false;
     for (ArcIterator<Fst<Arc>> aiter(fst_, s); !aiter.Done(); aiter.Next()) {
       const auto &arc = aiter.Value();
-      PrintStateId(s);
-      *ostrm_ << sep_;
-      PrintStateId(arc.nextstate);
-      *ostrm_ << sep_;
-      PrintILabel(arc.ilabel);
+      ostrm << FormatStateId(s) << sep_ << FormatStateId(arc.nextstate)
+              << sep_ << FormatILabel(arc.ilabel);
       if (!accept_) {
-        *ostrm_ << sep_;
-        PrintOLabel(arc.olabel);
+        ostrm << sep_ << FormatOLabel(arc.olabel);
       }
-      if (show_weight_one_ || arc.weight != Weight::One())
-        *ostrm_ << sep_ << arc.weight;
-      *ostrm_ << "\n";
+      if (show_weight_one_ || arc.weight != Weight::One()) {
+        ostrm << sep_ << arc.weight;
+      }
+      ostrm << "\n";
       output = true;
     }
     const auto weight = fst_.Final(s);
     if (weight != Weight::Zero() || !output) {
-      PrintStateId(s);
+      ostrm << FormatStateId(s);
       if (show_weight_one_ || weight != Weight::One()) {
-        *ostrm_ << sep_ << weight;
+        ostrm << sep_ << weight;
       }
-      *ostrm_ << "\n";
+      ostrm << "\n";
     }
   }
 
@@ -129,7 +124,6 @@ class FstPrinter {
   const SymbolTable *osyms_;    // olabel symbol table.
   const SymbolTable *ssyms_;    // slabel symbol table.
   bool accept_;                 // Print as acceptor when possible?
-  std::ostream *ostrm_;         // Text FST destination.
   std::string dest_;            // Text FST destination name.
   bool show_weight_one_;        // Print weights equal to Weight::One()?
   std::string sep_;             // Separator character between fields.
index 0366553..2d9b225 100644 (file)
@@ -19,6 +19,7 @@
 #define FST_SCRIPT_PRINT_H_
 
 #include <ostream>
+#include <string>
 
 #include <fst/flags.h>
 #include <fst/script/fst-class.h>
@@ -32,7 +33,7 @@ namespace script {
 // Note: it is safe to pass these strings as references because this struct is
 // only used to pass them deeper in the call graph. Be sure you understand why
 // this is so before using this struct for anything else!
-struct PrintArgs {
+struct FstPrintArgs {
   const FstClass &fst;
   const SymbolTable *isyms;
   const SymbolTable *osyms;
@@ -46,7 +47,7 @@ struct PrintArgs {
 };
 
 template <class Arc>
-void Print(PrintArgs *args) {
+void Print(FstPrintArgs *args) {
   const Fst<Arc> &fst = *args->fst.GetFst<Arc>();
   FstPrinter<Arc> fstprinter(fst, args->isyms, args->osyms, args->ssyms,
                              args->accept, args->show_weight_one, args->sep,
index 4ca6123..ed2891f 100644 (file)
 namespace fst {
 namespace script {
 
-using ProjectArgs = std::pair<MutableFstClass *, ProjectType>;
+using FstProjectArgs = std::pair<MutableFstClass *, ProjectType>;
 
 template <class Arc>
-void Project(ProjectArgs *args) {
+void Project(FstProjectArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   Project(fst, std::get<1>(*args));
 }
index 33e0958..a7852db 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef FST_SCRIPT_PRUNE_H_
 #define FST_SCRIPT_PRUNE_H_
 
+#include <cstdint>
 #include <tuple>
 #include <utility>
 
 namespace fst {
 namespace script {
 
-using PruneArgs1 = std::tuple<const FstClass &, MutableFstClass *,
-                              const WeightClass &, int64, float>;
+using FstPruneArgs1 = std::tuple<const FstClass &, MutableFstClass *,
+                                 const WeightClass &, int64_t, float>;
 
 template <class Arc>
-void Prune(PruneArgs1 *args) {
+void Prune(FstPruneArgs1 *args) {
   using Weight = typename Arc::Weight;
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
@@ -45,11 +46,11 @@ void Prune(PruneArgs1 *args) {
   }
 }
 
-using PruneArgs2 =
-    std::tuple<MutableFstClass *, const WeightClass &, int64, float>;
+using FstPruneArgs2 =
+    std::tuple<MutableFstClass *, const WeightClass &, int64_t, float>;
 
 template <class Arc>
-void Prune(PruneArgs2 *args) {
+void Prune(FstPruneArgs2 *args) {
   using Weight = typename Arc::Weight;
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   if constexpr (IsPath<Weight>::value) {
@@ -63,10 +64,10 @@ void Prune(PruneArgs2 *args) {
 
 void Prune(const FstClass &ifst, MutableFstClass *ofst,
            const WeightClass &weight_threshold,
-           int64 state_threshold = kNoStateId, float delta = kDelta);
+           int64_t state_threshold = kNoStateId, float delta = kDelta);
 
 void Prune(MutableFstClass *fst, const WeightClass &weight_threshold,
-           int64 state_threshold = kNoStateId, float delta = kDelta);
+           int64_t state_threshold = kNoStateId, float delta = kDelta);
 
 }  // namespace script
 }  // namespace fst
index 8d87e08..81bcb9b 100644 (file)
 #ifndef FST_SCRIPT_PUSH_H_
 #define FST_SCRIPT_PUSH_H_
 
+#include <cstdint>
 #include <tuple>
 
-#include <fst/types.h>
 #include <fst/push.h>
 #include <fst/script/fst-class.h>
 
 namespace fst {
 namespace script {
 
-using PushArgs1 = std::tuple<MutableFstClass *, ReweightType, float, bool>;
+using FstPushArgs1 = std::tuple<MutableFstClass *, ReweightType, float, bool>;
 
 template <class Arc>
-void Push(PushArgs1 *args) {
+void Push(FstPushArgs1 *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   Push(fst, std::get<1>(*args), std::get<2>(*args), std::get<3>(*args));
 }
 
-using PushArgs2 =
-    std::tuple<const FstClass &, MutableFstClass *, uint8, ReweightType, float>;
+using FstPushArgs2 = std::tuple<const FstClass &, MutableFstClass *, uint8_t,
+                                ReweightType, float>;
 
 template <class Arc>
-void Push(PushArgs2 *args) {
+void Push(FstPushArgs2 *args) {
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
   switch (std::get<3>(*args)) {
@@ -59,7 +59,7 @@ void Push(PushArgs2 *args) {
 void Push(MutableFstClass *fst, ReweightType type = REWEIGHT_TO_INITIAL,
           float delta = kShortestDelta, bool remove_total_weight = false);
 
-void Push(const FstClass &ifst, MutableFstClass *ofst, uint8 flags,
+void Push(const FstClass &ifst, MutableFstClass *ofst, uint8_t flags,
           ReweightType rew_type, float delta = kShortestDelta);
 
 }  // namespace script
index 2090cf3..182755d 100644 (file)
@@ -18,9 +18,9 @@
 #ifndef FST_SCRIPT_RANDEQUIVALENT_H_
 #define FST_SCRIPT_RANDEQUIVALENT_H_
 
+#include <cstdint>
 #include <tuple>
 
-#include <fst/types.h>
 #include <fst/randequivalent.h>
 #include <fst/script/arg-packs.h>
 #include <fst/script/fst-class.h>
 namespace fst {
 namespace script {
 
-using RandEquivalentInnerArgs =
-    std::tuple<const FstClass &, const FstClass &, int32,
-               const RandGenOptions<RandArcSelection> &, float, uint64>;
+using FstRandEquivalentInnerArgs =
+    std::tuple<const FstClass &, const FstClass &, int32_t,
+               const RandGenOptions<RandArcSelection> &, float, uint64_t>;
 
-using RandEquivalentArgs = WithReturnValue<bool, RandEquivalentInnerArgs>;
+using FstRandEquivalentArgs = WithReturnValue<bool, FstRandEquivalentInnerArgs>;
 
 template <class Arc>
-void RandEquivalent(RandEquivalentArgs *args) {
+void RandEquivalent(FstRandEquivalentArgs *args) {
   const Fst<Arc> &fst1 = *std::get<0>(args->args).GetFst<Arc>();
   const Fst<Arc> &fst2 = *std::get<1>(args->args).GetFst<Arc>();
-  const int32 npath = std::get<2>(args->args);
+  const int32_t npath = std::get<2>(args->args);
   const auto &opts = std::get<3>(args->args);
   const float delta = std::get<4>(args->args);
-  const uint64 seed = std::get<5>(args->args);
+  const uint64_t seed = std::get<5>(args->args);
   switch (opts.selector) {
     case RandArcSelection::UNIFORM: {
       const UniformArcSelector<Arc> selector(seed);
@@ -69,10 +69,10 @@ void RandEquivalent(RandEquivalentArgs *args) {
 }
 
 bool RandEquivalent(
-    const FstClass &fst1, const FstClass &fst2, int32 npath = 1,
+    const FstClass &fst1, const FstClass &fst2, int32_t npath = 1,
     const RandGenOptions<RandArcSelection> &opts =
         RandGenOptions<RandArcSelection>(RandArcSelection::UNIFORM),
-    float delta = kDelta, uint64 seed = std::random_device()());
+    float delta = kDelta, uint64_t seed = std::random_device()());
 
 }  // namespace script
 }  // namespace fst
index 91696ce..196fe5f 100644 (file)
 #ifndef FST_SCRIPT_RANDGEN_H_
 #define FST_SCRIPT_RANDGEN_H_
 
+#include <cstdint>
 #include <random>
 #include <tuple>
 
-#include <fst/types.h>
 #include <fst/randgen.h>
 #include <fst/script/fst-class.h>
 #include <fst/script/script-impl.h>
 namespace fst {
 namespace script {
 
-using RandGenArgs =
+using FstRandGenArgs =
     std::tuple<const FstClass &, MutableFstClass *,
-               const RandGenOptions<RandArcSelection> &, uint64>;
+               const RandGenOptions<RandArcSelection> &, uint64_t>;
 
 template <class Arc>
-void RandGen(RandGenArgs *args) {
+void RandGen(FstRandGenArgs *args) {
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
   const auto &opts = std::get<2>(*args);
-  const uint64 seed = std::get<3>(*args);
+  const uint64_t seed = std::get<3>(*args);
   switch (opts.selector) {
     case RandArcSelection::UNIFORM: {
       const UniformArcSelector<Arc> selector(seed);
@@ -70,7 +70,7 @@ void RandGen(RandGenArgs *args) {
 void RandGen(const FstClass &ifst, MutableFstClass *ofst,
              const RandGenOptions<RandArcSelection> &opts =
                  RandGenOptions<RandArcSelection>(RandArcSelection::UNIFORM),
-             uint64 seed = std::random_device()());
+             uint64_t seed = std::random_device()());
 
 }  // namespace script
 }  // namespace fst
index 3ac2220..bea2efa 100644 (file)
 #define FST_SCRIPT_RELABEL_H_
 
 #include <algorithm>
+#include <cstdint>
+#include <string>
 #include <tuple>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/relabel.h>
 #include <fst/script/fst-class.h>
 
 namespace fst {
 namespace script {
 
-using RelabelArgs1 =
+using FstRelabelArgs1 =
     std::tuple<MutableFstClass *, const SymbolTable *, const SymbolTable *,
                const std::string &, bool, const SymbolTable *,
                const SymbolTable *, const std::string &, bool>;
 
 template <class Arc>
-void Relabel(RelabelArgs1 *args) {
+void Relabel(FstRelabelArgs1 *args) {
   MutableFst<Arc> *ofst = std::get<0>(*args)->GetMutableFst<Arc>();
   Relabel(ofst, std::get<1>(*args), std::get<2>(*args), std::get<3>(*args),
           std::get<4>(*args), std::get<5>(*args), std::get<6>(*args),
           std::get<7>(*args), std::get<8>(*args));
 }
 
-using RelabelArgs2 =
-    std::tuple<MutableFstClass *, const std::vector<std::pair<int64, int64>> &,
-               const std::vector<std::pair<int64, int64>> &>;
+using FstRelabelArgs2 =
+    std::tuple<MutableFstClass *,
+               const std::vector<std::pair<int64_t, int64_t>> &,
+               const std::vector<std::pair<int64_t, int64_t>> &>;
 
 template <class Arc>
-void Relabel(RelabelArgs2 *args) {
+void Relabel(FstRelabelArgs2 *args) {
   MutableFst<Arc> *ofst = std::get<0>(*args)->GetMutableFst<Arc>();
   using LabelPair = std::pair<typename Arc::Label, typename Arc::Label>;
   // In case the MutableFstClass::Label is not the same as Arc::Label,
@@ -69,8 +71,8 @@ void Relabel(MutableFstClass *ofst, const SymbolTable *old_isymbols,
              const std::string &unknown_osymbol, bool attach_new_osymbols);
 
 void Relabel(MutableFstClass *ofst,
-             const std::vector<std::pair<int64, int64>> &ipairs,
-             const std::vector<std::pair<int64, int64>> &opairs);
+             const std::vector<std::pair<int64_t, int64_t>> &ipairs,
+             const std::vector<std::pair<int64_t, int64_t>> &opairs);
 
 }  // namespace script
 }  // namespace fst
index 68b3494..f433b2b 100644 (file)
 #ifndef FST_SCRIPT_REPLACE_H_
 #define FST_SCRIPT_REPLACE_H_
 
+#include <cstdint>
 #include <tuple>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/replace.h>
 #include <fst/script/fst-class.h>
 
@@ -30,27 +30,27 @@ namespace fst {
 namespace script {
 
 struct ReplaceOptions {
-  const int64 root;                          // Root rule for expansion.
+  const int64_t root;                        // Root rule for expansion.
   const ReplaceLabelType call_label_type;    // How to label call arc.
   const ReplaceLabelType return_label_type;  // How to label return arc.
-  const int64 return_label;                  // Specifies return arc label.
+  const int64_t return_label;                // Specifies return arc label.
 
   explicit ReplaceOptions(
-      int64 root, ReplaceLabelType call_label_type = REPLACE_LABEL_INPUT,
+      int64_t root, ReplaceLabelType call_label_type = REPLACE_LABEL_INPUT,
       ReplaceLabelType return_label_type = REPLACE_LABEL_NEITHER,
-      int64 return_label = 0)
+      int64_t return_label = 0)
       : root(root),
         call_label_type(call_label_type),
         return_label_type(return_label_type),
         return_label(return_label) {}
 };
 
-using ReplaceArgs =
-    std::tuple<const std::vector<std::pair<int64, const FstClass *>> &,
+using FstReplaceArgs =
+    std::tuple<const std::vector<std::pair<int64_t, const FstClass *>> &,
                MutableFstClass *, const ReplaceOptions &>;
 
 template <class Arc>
-void Replace(ReplaceArgs *args) {
+void Replace(FstReplaceArgs *args) {
   // Now that we know the arc type, we construct a vector of
   // std::pair<real label, real fst> that the real Replace will use.
   const auto &untyped_pairs = std::get<0>(*args);
@@ -76,7 +76,7 @@ void Replace(ReplaceArgs *args) {
   *ofst = rfst;
 }
 
-void Replace(const std::vector<std::pair<int64, const FstClass *>> &pairs,
+void Replace(const std::vector<std::pair<int64_t, const FstClass *>> &pairs,
              MutableFstClass *ofst, const ReplaceOptions &opts);
 
 }  // namespace script
index ff255d3..79d86a2 100644 (file)
 namespace fst {
 namespace script {
 
-using ReverseArgs = std::tuple<const FstClass &, MutableFstClass *, bool>;
+using FstReverseArgs = std::tuple<const FstClass &, MutableFstClass *, bool>;
 
 template <class Arc>
-void Reverse(ReverseArgs *args) {
+void Reverse(FstReverseArgs *args) {
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
   Reverse(ifst, ofst, std::get<2>(*args));
index 04cb07e..d474ecc 100644 (file)
 namespace fst {
 namespace script {
 
-using ReweightArgs = std::tuple<MutableFstClass *,
-                                const std::vector<WeightClass> &, ReweightType>;
+using FstReweightArgs =
+    std::tuple<MutableFstClass *, const std::vector<WeightClass> &,
+               ReweightType>;
 
 template <class Arc>
-void Reweight(ReweightArgs *args) {
+void Reweight(FstReweightArgs *args) {
   using Weight = typename Arc::Weight;
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   const std::vector<WeightClass> &potentials = std::get<1>(*args);
index 08da62d..5549145 100644 (file)
 #ifndef FST_SCRIPT_RMEPSILON_H_
 #define FST_SCRIPT_RMEPSILON_H_
 
+#include <cstdint>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/queue.h>
 #include <fst/rmepsilon.h>
+#include <fst/script/arcfilter-impl.h>
 #include <fst/script/fst-class.h>
 #include <fst/script/shortest-distance.h>
 #include <fst/script/weight-class.h>
@@ -34,11 +35,11 @@ namespace script {
 struct RmEpsilonOptions : public ShortestDistanceOptions {
   const bool connect;
   const WeightClass &weight_threshold;
-  const int64 state_threshold;
+  const int64_t state_threshold;
 
   RmEpsilonOptions(QueueType queue_type, bool connect,
                    const WeightClass &weight_threshold,
-                   int64 state_threshold = kNoStateId, float delta = kDelta)
+                   int64_t state_threshold = kNoStateId, float delta = kDelta)
       : ShortestDistanceOptions(queue_type, ArcFilterType::EPSILON, kNoStateId,
                                 delta),
         connect(connect),
@@ -113,10 +114,10 @@ void RmEpsilon(MutableFst<Arc> *fst, const RmEpsilonOptions &opts) {
 
 }  // namespace internal
 
-using RmEpsilonArgs = std::pair<MutableFstClass *, const RmEpsilonOptions &>;
+using FstRmEpsilonArgs = std::pair<MutableFstClass *, const RmEpsilonOptions &>;
 
 template <class Arc>
-void RmEpsilon(RmEpsilonArgs *args) {
+void RmEpsilon(FstRmEpsilonArgs *args) {
   MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
   const auto &opts = std::get<1>(*args);
   internal::RmEpsilon(fst, opts);
index 6164a8f..972d351 100644 (file)
 // This file contains general-purpose templates which are used in the
 // implementation of the operations.
 
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/generic-register.h>
 #include <fst/script/fst-class.h>
 namespace fst {
 namespace script {
 
-enum class RandArcSelection : uint8 { UNIFORM, LOG_PROB, FAST_LOG_PROB };
+enum class RandArcSelection : uint8_t { UNIFORM, LOG_PROB, FAST_LOG_PROB };
 
 // A generic register for operations with various kinds of signatures.
 // Needed since every function signature requires a new registration class.
@@ -132,7 +132,8 @@ class GenericOperationRegister
     // Uses the old-style FST for now.
     std::string legal_type(key.second);  // The arc type.
     ConvertToLegalCSymbol(&legal_type);
-    return legal_type + "-arc.so";
+    legal_type.append("-arc.so");
+    return legal_type;
   }
 };
 
@@ -221,10 +222,10 @@ void CopyWeights(const std::vector<Weight> &typed_weights,
 }  // namespace internal
 
 // Used for Replace operations.
-inline std::vector<std::pair<int64, const FstClass *>> BorrowPairs(
-    const std::vector<std::pair<int64, std::unique_ptr<const FstClass>>>
+inline std::vector<std::pair<int64_t, const FstClass *>> BorrowPairs(
+    const std::vector<std::pair<int64_t, std::unique_ptr<const FstClass>>>
         &pairs) {
-  std::vector<std::pair<int64, const FstClass *>> borrowed_pairs;
+  std::vector<std::pair<int64_t, const FstClass *>> borrowed_pairs;
   borrowed_pairs.reserve(pairs.size());
   for (const auto &pair : pairs) {
     borrowed_pairs.emplace_back(pair.first, pair.second.get());
index 880333f..d113882 100644 (file)
 #ifndef FST_SCRIPT_SHORTEST_DISTANCE_H_
 #define FST_SCRIPT_SHORTEST_DISTANCE_H_
 
+#include <cstdint>
 #include <tuple>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/queue.h>
 #include <fst/shortest-distance.h>
+#include <fst/script/arcfilter-impl.h>
 #include <fst/script/arg-packs.h>
 #include <fst/script/fst-class.h>
 #include <fst/script/prune.h>
 namespace fst {
 namespace script {
 
-enum class ArcFilterType : uint8 {
-  ANY,
-  EPSILON,
-  INPUT_EPSILON,
-  OUTPUT_EPSILON
-};
-
 struct ShortestDistanceOptions {
   const QueueType queue_type;
   const ArcFilterType arc_filter_type;
-  const int64 source;
+  const int64_t source;
   const float delta;
 
   ShortestDistanceOptions(QueueType queue_type, ArcFilterType arc_filter_type,
-                          int64 source, float delta)
+                          int64_t source, float delta)
       : queue_type(queue_type),
         arc_filter_type(arc_filter_type),
         source(source),
@@ -62,8 +56,9 @@ template <class Arc, class Queue, class ArcFilter>
 struct QueueConstructor {
   using Weight = typename Arc::Weight;
 
-  static Queue *Construct(const Fst<Arc> &, const std::vector<Weight> *) {
-    return new Queue();
+  static std::unique_ptr<Queue> Construct(const Fst<Arc> &,
+                                          const std::vector<Weight> *) {
+    return std::make_unique<Queue>();
   }
 };
 
@@ -75,9 +70,9 @@ struct QueueConstructor<Arc, AutoQueue<typename Arc::StateId>, ArcFilter> {
   using Weight = typename Arc::Weight;
 
   //  template<class Arc, class ArcFilter>
-  static AutoQueue<StateId> *Construct(const Fst<Arc> &fst,
-                                       const std::vector<Weight> *distance) {
-    return new AutoQueue<StateId>(fst, distance, ArcFilter());
+  static std::unique_ptr<AutoQueue<StateId>> Construct(
+      const Fst<Arc> &fst, const std::vector<Weight> *distance) {
+    return std::make_unique<AutoQueue<StateId>>(fst, distance, ArcFilter());
   }
 };
 
@@ -88,9 +83,10 @@ struct QueueConstructor<
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
 
-  static NaturalShortestFirstQueue<StateId, Weight> *Construct(
+  static std::unique_ptr<NaturalShortestFirstQueue<StateId, Weight>> Construct(
       const Fst<Arc> &, const std::vector<Weight> *distance) {
-    return new NaturalShortestFirstQueue<StateId, Weight>(*distance);
+    return std::make_unique<NaturalShortestFirstQueue<StateId, Weight>>(
+        *distance);
   }
 };
 
@@ -99,9 +95,9 @@ struct QueueConstructor<Arc, TopOrderQueue<typename Arc::StateId>, ArcFilter> {
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
 
-  static TopOrderQueue<StateId> *Construct(const Fst<Arc> &fst,
-                                           const std::vector<Weight> *) {
-    return new TopOrderQueue<StateId>(fst, ArcFilter());
+  static std::unique_ptr<TopOrderQueue<StateId>> Construct(
+      const Fst<Arc> &fst, const std::vector<Weight> *) {
+    return std::make_unique<TopOrderQueue<StateId>>(fst, ArcFilter());
   }
 };
 
@@ -141,7 +137,7 @@ void ShortestDistance(const Fst<Arc> &fst,
     }
     default: {
       FSTERROR() << "ShortestDistance: Unknown arc filter type: "
-                 << static_cast<std::underlying_type<ArcFilterType>::type>(
+                 << static_cast<std::underlying_type_t<ArcFilterType>>(
                         opts.arc_filter_type);
       distance->clear();
       distance->resize(1, Arc::Weight::NoWeight());
@@ -152,12 +148,12 @@ void ShortestDistance(const Fst<Arc> &fst,
 
 }  // namespace internal
 
-using ShortestDistanceArgs1 =
+using FstShortestDistanceArgs1 =
     std::tuple<const FstClass &, std::vector<WeightClass> *,
                const ShortestDistanceOptions &>;
 
 template <class Arc>
-void ShortestDistance(ShortestDistanceArgs1 *args) {
+void ShortestDistance(FstShortestDistanceArgs1 *args) {
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
   const Fst<Arc> &fst = *std::get<0>(*args).GetFst<Arc>();
@@ -210,11 +206,11 @@ void ShortestDistance(ShortestDistanceArgs1 *args) {
   internal::CopyWeights(typed_distance, std::get<1>(*args));
 }
 
-using ShortestDistanceArgs2 =
+using FstShortestDistanceArgs2 =
     std::tuple<const FstClass &, std::vector<WeightClass> *, bool, double>;
 
 template <class Arc>
-void ShortestDistance(ShortestDistanceArgs2 *args) {
+void ShortestDistance(FstShortestDistanceArgs2 *args) {
   using Weight = typename Arc::Weight;
   const Fst<Arc> &fst = *std::get<0>(*args).GetFst<Arc>();
   std::vector<Weight> typed_distance;
@@ -223,13 +219,13 @@ void ShortestDistance(ShortestDistanceArgs2 *args) {
   internal::CopyWeights(typed_distance, std::get<1>(*args));
 }
 
-using ShortestDistanceInnerArgs3 = std::tuple<const FstClass &, double>;
+using FstShortestDistanceInnerArgs3 = std::tuple<const FstClass &, double>;
 
-using ShortestDistanceArgs3 =
-    WithReturnValue<WeightClass, ShortestDistanceInnerArgs3>;
+using FstShortestDistanceArgs3 =
+    WithReturnValue<WeightClass, FstShortestDistanceInnerArgs3>;
 
 template <class Arc>
-void ShortestDistance(ShortestDistanceArgs3 *args) {
+void ShortestDistance(FstShortestDistanceArgs3 *args) {
   const Fst<Arc> &fst = *std::get<0>(args->args).GetFst<Arc>();
   args->retval = WeightClass(ShortestDistance(fst, std::get<1>(args->args)));
 }
index 0220068..9747f07 100644 (file)
 #ifndef FST_SCRIPT_SHORTEST_PATH_H_
 #define FST_SCRIPT_SHORTEST_PATH_H_
 
+#include <cstdint>
 #include <memory>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/shortest-path.h>
+#include <fst/script/arcfilter-impl.h>
 #include <fst/script/fst-class.h>
 #include <fst/script/shortest-distance.h>
 #include <fst/script/weight-class.h>
@@ -33,14 +34,14 @@ namespace script {
 // Slightly simplified interface: `has_distance` and `first_path` are disabled.
 
 struct ShortestPathOptions : public ShortestDistanceOptions {
-  const int32 nshortest;
+  const int32_t nshortest;
   const bool unique;
   const WeightClass &weight_threshold;
-  const int64 state_threshold;
+  const int64_t state_threshold;
 
-  ShortestPathOptions(QueueType queue_type, int32 nshortest, bool unique,
+  ShortestPathOptions(QueueType queue_type, int32_t nshortest, bool unique,
                       float delta, const WeightClass &weight_threshold,
-                      int64 state_threshold = kNoStateId)
+                      int64_t state_threshold = kNoStateId)
       : ShortestDistanceOptions(queue_type, ArcFilterType::ANY, kNoStateId,
                                 delta),
         nshortest(nshortest),
@@ -122,11 +123,11 @@ void ShortestPath(const Fst<Arc> &ifst, MutableFst<Arc> *ofst,
 
 }  // namespace internal
 
-using ShortestPathArgs = std::tuple<const FstClass &, MutableFstClass *,
-                                    const ShortestPathOptions &>;
+using FstShortestPathArgs = std::tuple<const FstClass &, MutableFstClass *,
+                                       const ShortestPathOptions &>;
 
 template <class Arc>
-void ShortestPath(ShortestPathArgs *args) {
+void ShortestPath(FstShortestPathArgs *args) {
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
   const ShortestPathOptions &opts = std::get<2>(*args);
index 1cf596d..d43ee3a 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef FST_SCRIPT_STATEITERATOR_CLASS_H_
 #define FST_SCRIPT_STATEITERATOR_CLASS_H_
 
+#include <cstdint>
 #include <memory>
 
 #include <fst/fstlib.h>
@@ -32,7 +33,7 @@ namespace script {
 class StateIteratorImplBase {
  public:
   virtual bool Done() const = 0;
-  virtual int64 Value() const = 0;
+  virtual int64_t Value() const = 0;
   virtual void Next() = 0;
   virtual void Reset() = 0;
   virtual ~StateIteratorImplBase() {}
@@ -46,7 +47,7 @@ class StateIteratorClassImpl : public StateIteratorImplBase {
 
   bool Done() const final { return siter_.Done(); }
 
-  int64 Value() const final { return siter_.Value(); }
+  int64_t Value() const final { return siter_.Value(); }
 
   void Next() final { siter_.Next(); }
 
@@ -70,11 +71,11 @@ class StateIteratorClass {
 
   template <class Arc>
   explicit StateIteratorClass(const Fst<Arc> &fst)
-      : impl_(new StateIteratorClassImpl<Arc>(fst)) {}
+      : impl_(std::make_unique<StateIteratorClassImpl<Arc>>(fst)) {}
 
   bool Done() const { return impl_->Done(); }
 
-  int64 Value() const { return impl_->Value(); }
+  int64_t Value() const { return impl_->Value(); }
 
   void Next() { impl_->Next(); }
 
@@ -90,7 +91,8 @@ class StateIteratorClass {
 template <class Arc>
 void InitStateIteratorClass(InitStateIteratorClassArgs *args) {
   const Fst<Arc> &fst = *std::get<0>(*args).GetFst<Arc>();
-  std::get<1>(*args)->impl_.reset(new StateIteratorClassImpl<Arc>(fst));
+  std::get<1>(*args)->impl_ =
+      std::make_unique<StateIteratorClassImpl<Arc>>(fst);
 }
 
 }  // namespace script
index 93a29d2..7f2851f 100644 (file)
 namespace fst {
 namespace script {
 
-using SynchronizeArgs = std::pair<const FstClass &, MutableFstClass *>;
+using FstSynchronizeArgs = std::pair<const FstClass &, MutableFstClass *>;
 
 template <class Arc>
-void Synchronize(SynchronizeArgs *args) {
+void Synchronize(FstSynchronizeArgs *args) {
   const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
   MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
   Synchronize(ifst, ofst);
index b98e9ae..a186ad8 100644 (file)
 #include <vector>
 
 #include <fst/script/weight-class.h>
+#include <string_view>
 
 namespace fst {
 namespace script {
 
-bool ReadPotentials(const std::string &weight_type, const std::string &source,
+bool ReadPotentials(std::string_view weight_type, const std::string &source,
                     std::vector<WeightClass> *potentials);
 
 bool WritePotentials(const std::string &source,
index f0167f9..f3164d9 100644 (file)
 namespace fst {
 namespace script {
 
-using TopSortArgs = WithReturnValue<bool, MutableFstClass *>;
+using FstTopSortArgs = WithReturnValue<bool, MutableFstClass *>;
 
 template <class Arc>
-void TopSort(TopSortArgs *args) {
+void TopSort(FstTopSortArgs *args) {
   args->retval = TopSort(args->args->GetMutableFst<Arc>());
 }
 
index c3a0917..8481af1 100644 (file)
 namespace fst {
 namespace script {
 
-using UnionArgs1 = std::pair<MutableFstClass *, const FstClass &>;
+using FstUnionArgs1 = std::pair<MutableFstClass *, const FstClass &>;
 
 template <class Arc>
-void Union(UnionArgs1 *args) {
+void Union(FstUnionArgs1 *args) {
   MutableFst<Arc> *fst1 = std::get<0>(*args)->GetMutableFst<Arc>();
   const Fst<Arc> &fst2 = *std::get<1>(*args).GetFst<Arc>();
   Union(fst1, fst2);
 }
 
-using UnionArgs2 =
+using FstUnionArgs2 =
     std::tuple<MutableFstClass *, const std::vector<const FstClass *> &>;
 
 template <class Arc>
-void Union(UnionArgs2 *args) {
+void Union(FstUnionArgs2 *args) {
   MutableFst<Arc> *fst1 = std::get<0>(*args)->GetMutableFst<Arc>();
   const auto &untyped_fsts2 = std::get<1>(*args);
   std::vector<const Fst<Arc> *> typed_fsts2;
index 63743f9..c7c683c 100644 (file)
 namespace fst {
 namespace script {
 
-using VerifyArgs = WithReturnValue<bool, const FstClass &>;
+using FstVerifyArgs = WithReturnValue<bool, const FstClass &>;
 
 template <class Arc>
-void Verify(VerifyArgs *args) {
+void Verify(FstVerifyArgs *args) {
   const Fst<Arc> &fst = *args->args.GetFst<Arc>();
   args->retval = Verify(fst);
 }
index 0dfc9f6..d62bbc3 100644 (file)
@@ -64,15 +64,13 @@ class WeightClassImpl : public WeightImplBase {
   void Print(std::ostream *ostrm) const final { *ostrm << weight_; }
 
   std::string ToString() const final {
-    std::string str;
-    WeightToStr(weight_, &str);
-    return str;
+    return WeightToStr(weight_);
   }
 
   bool Member() const final { return weight_.Member(); }
 
   bool operator==(const WeightImplBase &other) const final {
-    const auto *typed_other = fst::down_cast<const WeightClassImpl<W> *>(&other);
+    const auto *typed_other = down_cast<const WeightClassImpl<W> *>(&other);
     return weight_ == typed_other->weight_;
   }
 
@@ -81,19 +79,19 @@ class WeightClassImpl : public WeightImplBase {
   }
 
   WeightClassImpl<W> &PlusEq(const WeightImplBase &other) final {
-    const auto *typed_other = fst::down_cast<const WeightClassImpl<W> *>(&other);
+    const auto *typed_other = down_cast<const WeightClassImpl<W> *>(&other);
     weight_ = Plus(weight_, typed_other->weight_);
     return *this;
   }
 
   WeightClassImpl<W> &TimesEq(const WeightImplBase &other) final {
-    const auto *typed_other = fst::down_cast<const WeightClassImpl<W> *>(&other);
+    const auto *typed_other = down_cast<const WeightClassImpl<W> *>(&other);
     weight_ = Times(weight_, typed_other->weight_);
     return *this;
   }
 
   WeightClassImpl<W> &DivideEq(const WeightImplBase &other) final {
-    const auto *typed_other = fst::down_cast<const WeightClassImpl<W> *>(&other);
+    const auto *typed_other = down_cast<const WeightClassImpl<W> *>(&other);
     weight_ = Divide(weight_, typed_other->weight_);
     return *this;
   }
@@ -115,13 +113,13 @@ class WeightClass {
 
   template <class W>
   explicit WeightClass(const W &weight)
-      : impl_(new WeightClassImpl<W>(weight)) {}
+      : impl_(std::make_unique<WeightClassImpl<W>>(weight)) {}
 
   template <class W>
   explicit WeightClass(const WeightClassImpl<W> &impl)
-      : impl_(new WeightClassImpl<W>(impl)) {}
+      : impl_(std::make_unique<WeightClassImpl<W>>(impl)) {}
 
-  WeightClass(const std::string &weight_type, std::string_view weight_str);
+  WeightClass(std::string_view weight_type, std::string_view weight_str);
 
   WeightClass(const WeightClass &other)
       : impl_(other.impl_ ? other.impl_->Copy() : nullptr) {}
@@ -131,15 +129,15 @@ class WeightClass {
     return *this;
   }
 
-  static constexpr char __ZERO__[] = "__ZERO__";          // NOLINT
-  static constexpr char __ONE__[] = "__ONE__";            // NOLINT
-  static constexpr char __NOWEIGHT__[] = "__NOWEIGHT__";  // NOLINT
+  static constexpr std::string_view __ZERO__ = "__ZERO__";          // NOLINT
+  static constexpr std::string_view __ONE__ = "__ONE__";            // NOLINT
+  static constexpr std::string_view __NOWEIGHT__ = "__NOWEIGHT__";  // NOLINT
 
-  static WeightClass Zero(const std::string &weight_type);
+  static WeightClass Zero(std::string_view weight_type);
 
-  static WeightClass One(const std::string &weight_type);
+  static WeightClass One(std::string_view weight_type);
 
-  static WeightClass NoWeight(const std::string &weight_type);
+  static WeightClass NoWeight(std::string_view weight_type);
 
   template <class W>
   const W *GetWeight() const {
@@ -162,7 +160,7 @@ class WeightClass {
   bool Member() const { return impl_ && impl_->Member(); }
 
   static bool WeightTypesMatch(const WeightClass &lhs, const WeightClass &rhs,
-                               const std::string &op_name);
+                               std::string_view op_name);
 
   friend bool operator==(const WeightClass &lhs, const WeightClass &rhs);
 
@@ -200,28 +198,30 @@ std::ostream &operator<<(std::ostream &o, const WeightClass &c);
 
 // Registration for generic weight types.
 
-using StrToWeightImplBaseT = WeightImplBase *(*)(std::string_view str);
+using StrToWeightImplBaseT =
+    std::unique_ptr<WeightImplBase> (*)(std::string_view str);
 
 template <class W>
-WeightImplBase *StrToWeightImplBase(std::string_view str) {
+std::unique_ptr<WeightImplBase> StrToWeightImplBase(std::string_view str) {
   if (str == WeightClass::__ZERO__) {
-    return new WeightClassImpl<W>(W::Zero());
+    return std::make_unique<WeightClassImpl<W>>(W::Zero());
   } else if (str == WeightClass::__ONE__) {
-    return new WeightClassImpl<W>(W::One());
+    return std::make_unique<WeightClassImpl<W>>(W::One());
   } else if (str == WeightClass::__NOWEIGHT__) {
-    return new WeightClassImpl<W>(W::NoWeight());
+    return std::make_unique<WeightClassImpl<W>>(W::NoWeight());
   }
-  return new WeightClassImpl<W>(StrToWeight<W>(str));
+  return std::make_unique<WeightClassImpl<W>>(StrToWeight<W>(str));
 }
 
 class WeightClassRegister
     : public GenericRegister<std::string, StrToWeightImplBaseT,
                              WeightClassRegister> {
  protected:
-  std::string ConvertKeyToSoFilename(const std::string &key) const final {
+  std::string ConvertKeyToSoFilename(std::string_view key) const final {
     std::string legal_type(key);
     ConvertToLegalCSymbol(&legal_type);
-    return legal_type + ".so";
+    legal_type.append(".so");
+    return legal_type;
   }
 };
 
index 671e414..7d97c45 100644 (file)
 #define FST_SET_WEIGHT_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <list>
 #include <random>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
-
 #include <fst/union-weight.h>
 #include <fst/weight.h>
 #include <string_view>
 
 namespace fst {
 
-constexpr int kSetEmpty = 0;           // Label for the empty set.
-constexpr int kSetUniv = -1;           // Label for the universal set.
-constexpr int kSetBad = -2;            // Label for a non-set.
-constexpr char kSetSeparator[] = "_";  // Label separator in sets.
+inline constexpr int kSetEmpty = 0;         // Label for the empty set.
+inline constexpr int kSetUniv = -1;         // Label for the universal set.
+inline constexpr int kSetBad = -2;          // Label for a non-set.
+inline constexpr char kSetSeparator = '_';  // Label separator in sets.
 
 // Determines whether to use (intersect, union) or (union, intersect)
 // as (+, *) for the semiring. SET_INTERSECT_UNION_RESTRICTED is a
@@ -146,7 +145,7 @@ class SetWeight {
 
   ReverseWeight Reverse() const;
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kIdempotent | kLeftSemiring | kRightSemiring | kCommutative;
   }
 
@@ -247,9 +246,9 @@ class SetWeightIterator {
 template <typename Label, SetType S>
 inline std::istream &SetWeight<Label, S>::Read(std::istream &strm) {
   Clear();
-  int32 size;
+  int32_t size;
   ReadType(strm, &size);
-  for (int32 i = 0; i < size; ++i) {
+  for (int32_t i = 0; i < size; ++i) {
     Label label;
     ReadType(strm, &label);
     PushBack(label);
@@ -259,7 +258,7 @@ inline std::istream &SetWeight<Label, S>::Read(std::istream &strm) {
 
 template <typename Label, SetType S>
 inline std::ostream &SetWeight<Label, S>::Write(std::ostream &strm) const {
-  const int32 size = Size();
+  const int32_t size = Size();
   WriteType(strm, size);
   for (Iterator iter(*this); !iter.Done(); iter.Next()) {
     WriteType(strm, iter.Value());
@@ -366,7 +365,7 @@ inline std::istream &operator>>(std::istream &strm,
     weight = Weight(Label(kSetUniv));
   } else {
     weight.Clear();
-    for (std::string_view sv : SplitString(str, kSetSeparator, false)) {
+    for (std::string_view sv : StrSplit(str, kSetSeparator)) {
       auto maybe_label = ParseInt64(sv);
       if (!maybe_label.has_value()) {
         strm.clear(std::ios::badbit);
@@ -596,7 +595,7 @@ class WeightGenerate<SetWeight<Label, S>> {
  public:
   using Weight = SetWeight<Label, S>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t alphabet_size = kNumRandomWeights,
                           size_t max_set_length = kNumRandomWeights)
index 61ba91d..249a006 100644 (file)
@@ -36,7 +36,7 @@
 namespace fst {
 
 // A representable float for shortest distance and shortest path algorithms.
-constexpr float kShortestDelta = 1e-6;
+inline constexpr float kShortestDelta = 1e-6;
 
 template <class Arc, class Queue, class ArcFilter>
 struct ShortestDistanceOptions {
index 9f7a5ed..511f9f4 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_SHORTEST_PATH_H_
 #define FST_SHORTEST_PATH_H_
 
+#include <cstdint>
 #include <functional>
 #include <type_traits>
 #include <utility>
@@ -42,7 +43,7 @@ struct ShortestPathOptions
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
 
-  int32 nshortest;    // Returns n-shortest paths.
+  int32_t nshortest;  // Returns n-shortest paths.
   bool unique;        // Only returns paths with distinct input strings.
   bool has_distance;  // Distance vector already contains the
                       // shortest distance from the initial state.
@@ -57,7 +58,7 @@ struct ShortestPathOptions
   Weight weight_threshold;  // Pruning weight threshold.
   StateId state_threshold;  // Pruning state threshold.
 
-  ShortestPathOptions(Queue *queue, ArcFilter filter, int32 nshortest = 1,
+  ShortestPathOptions(Queue *queue, ArcFilter filter, int32_t nshortest = 1,
                       bool unique = false, bool has_distance = false,
                       float delta = kShortestDelta, bool first_path = false,
                       Weight weight_threshold = Weight::Zero(),
@@ -74,7 +75,7 @@ struct ShortestPathOptions
 
 namespace internal {
 
-constexpr size_t kNoArc = -1;
+inline constexpr size_t kNoArc = -1;
 
 // Helper function for SingleShortestPath building the shortest path as a left-
 // to-right machine backwards from the best final state. It takes the input
@@ -113,36 +114,6 @@ void SingleShortestPathBacktrace(
       kFstProperties);
 }
 
-// Helper function for SingleShortestPath building a tree of shortest paths to
-// every final state in the input FST. It takes the input FST and parent values
-// computed by SingleShortestPath and builds into the output mutable FST the
-// subtree of ifst that consists only of the best paths to all final states.
-// This is not normally called by users; see ShortestPath instead.
-template <class Arc>
-void SingleShortestTree(
-    const Fst<Arc> &ifst, MutableFst<Arc> *ofst,
-    const std::vector<std::pair<typename Arc::StateId, size_t>> &parent) {
-  ofst->DeleteStates();
-  ofst->SetInputSymbols(ifst.InputSymbols());
-  ofst->SetOutputSymbols(ifst.OutputSymbols());
-  ofst->SetStart(ifst.Start());
-  for (StateIterator<Fst<Arc>> siter(ifst); !siter.Done(); siter.Next()) {
-    ofst->AddState();
-    ofst->SetFinal(siter.Value(), ifst.Final(siter.Value()));
-  }
-  for (const auto &pair : parent) {
-    if (pair.first != kNoStateId && pair.second != kNoArc) {
-      ArcIterator<Fst<Arc>> aiter(ifst, pair.first);
-      aiter.Seek(pair.second);
-      ofst->AddArc(pair.first, aiter.Value());
-    }
-  }
-  if (ifst.Properties(kError, false)) ofst->SetProperties(kError, kError);
-  ofst->SetProperties(
-      ShortestPathProperties(ofst->Properties(kFstProperties, false), true),
-      kFstProperties);
-}
-
 // Implements the stopping criterion when ShortestPathOptions::first_path
 // is set to true:
 //   operator()(s, d, f) == true
@@ -340,7 +311,7 @@ class ShortestPathCompare {
 template <class Arc, class RevArc>
 void NShortestPath(const Fst<RevArc> &ifst, MutableFst<Arc> *ofst,
                    const std::vector<typename Arc::Weight> &distance,
-                   int32 nshortest, float delta = kShortestDelta,
+                   int32_t nshortest, float delta = kShortestDelta,
                    typename Arc::Weight weight_threshold = Arc::Weight::Zero(),
                    typename Arc::StateId state_threshold = kNoStateId) {
   using StateId = typename Arc::StateId;
@@ -532,7 +503,7 @@ void ShortestPath(const Fst<Arc> &ifst, MutableFst<Arc> *ofst,
 // The weights need to be right distributive and have the path (kPath) property.
 template <class Arc>
 void ShortestPath(const Fst<Arc> &ifst, MutableFst<Arc> *ofst,
-                  int32 nshortest = 1, bool unique = false,
+                  int32_t nshortest = 1, bool unique = false,
                   bool first_path = false,
                   typename Arc::Weight weight_threshold = Arc::Weight::Zero(),
                   typename Arc::StateId state_threshold = kNoStateId,
index 45f106a..cb2e7c5 100644 (file)
@@ -25,9 +25,9 @@
 #ifndef FST_SIGNED_LOG_WEIGHT_H_
 #define FST_SIGNED_LOG_WEIGHT_H_
 
+#include <cstdint>
 #include <random>
 
-#include <fst/types.h>
 
 #include <fst/float-weight.h>
 #include <fst/pair-weight.h>
@@ -90,7 +90,7 @@ class SignedLogWeightTpl : public PairWeight<TropicalWeight, LogWeightTpl<T>> {
   bool Member() const { return PairWeight<W1, W2>::Member(); }
 
   // Neither idempotent nor path.
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kLeftSemiring | kRightSemiring | kCommutative;
   }
 
@@ -585,7 +585,7 @@ class WeightGenerate<SignedLogWeightTpl<T>> {
   using W1 = typename Weight::W1;
   using W2 = typename Weight::W2;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : rand_(seed),
index 3b698e9..b61a32a 100644 (file)
 #ifndef FST_SPARSE_POWER_WEIGHT_H_
 #define FST_SPARSE_POWER_WEIGHT_H_
 
+#include <cstdint>
 #include <random>
 #include <string>
 
-#include <fst/types.h>
 
 #include <fst/sparse-tuple-weight.h>
 #include <fst/weight.h>
@@ -84,7 +84,7 @@ class SparsePowerWeight : public SparseTupleWeight<W, K> {
   static const std::string &Type() {
     static const std::string *const type = [] {
       std::string type = W::Type() + "_^n";
-      if (sizeof(K) != sizeof(uint32)) {
+      if (sizeof(K) != sizeof(uint32_t)) {
         type += "_" + std::to_string(CHAR_BIT * sizeof(K));
       }
       return new std::string(type);
@@ -92,7 +92,7 @@ class SparsePowerWeight : public SparseTupleWeight<W, K> {
     return *type;
   }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return W::Properties() &
            (kLeftSemiring | kRightSemiring | kCommutative | kIdempotent);
   }
@@ -207,7 +207,7 @@ class WeightGenerate<SparsePowerWeight<W, K>> {
   using Weight = SparsePowerWeight<W, K>;
   using Generate = WeightGenerate<W>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true, size_t sparse_power_rank = 3)
       : generate_(seed, allow_zero), sparse_power_rank_(sparse_power_rank) {}
 
index 79446c9..ca8f3ba 100644 (file)
@@ -56,7 +56,7 @@ class SparseTupleWeight {
   using Weight = W;
   using Index = K;
 
-  constexpr static K kNoKey = -1;
+  static constexpr K kNoKey = -1;
 
   SparseTupleWeight() { Init(); }
 
@@ -284,10 +284,6 @@ class SparseTupleWeight {
   friend class SparseTupleWeightIterator<W, K>;
 };
 
-// Declare storage for kNoKey since it is passed by reference.
-template <class W, class K>
-constexpr K SparseTupleWeight<W, K>::kNoKey;
-
 template <class W, class K>
 class SparseTupleWeightIterator {
  public:
index 5dc6cff..8d2fc65 100644 (file)
 #define FST_STATE_MAP_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/arc-map.h>
@@ -78,7 +78,7 @@ namespace fst {
 //
 //   // This specifies the known properties of an FST mapped by this
 //   // mapper. It takes as argument the input FST's known properties.
-//   uint64 Properties(uint64 props) const;
+//   uint64_t Properties(uint64_t props) const;
 // };
 //
 // We include a various state map versions below. One dimension of variation is
@@ -287,9 +287,9 @@ class StateMapFstImpl : public CacheImpl<B> {
     CacheImpl<B>::InitArcIterator(state, data);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && (fst_->Properties(kError, false) ||
                             (mapper_->Properties(0) & kError))) {
       SetProperties(kError, kError);
@@ -439,7 +439,7 @@ class IdentityStateMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
  private:
   const Fst<Arc> &fst_;
@@ -503,7 +503,7 @@ class ArcSumMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     return props & kArcSortProperties & kDeleteArcsProperties &
            kWeightInvariantProperties;
   }
@@ -585,7 +585,7 @@ class ArcUniqueMapper {
     return MAP_COPY_SYMBOLS;
   }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     return props & kArcSortProperties & kDeleteArcsProperties;
   }
 
index 130ce8a..f13d4c7 100644 (file)
@@ -24,7 +24,6 @@
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/bi-table.h>
index c70d73e..99e3eb4 100644 (file)
@@ -23,7 +23,6 @@
 #include <algorithm>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/mutable-fst.h>
index 114aa67..c1d976a 100644 (file)
 #ifndef FST_STRING_WEIGHT_H_
 #define FST_STRING_WEIGHT_H_
 
+#include <cstdint>
 #include <list>
 #include <random>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
-
 #include <fst/product-weight.h>
 #include <fst/union-weight.h>
 #include <fst/weight.h>
@@ -35,9 +34,9 @@
 
 namespace fst {
 
-constexpr int kStringInfinity = -1;       // Label for the infinite string.
-constexpr int kStringBad = -2;            // Label for a non-string.
-constexpr char kStringSeparator[] = "_";  // Label separator in strings.
+inline constexpr int kStringInfinity = -1;     // Label for the infinite string.
+inline constexpr int kStringBad = -2;          // Label for a non-string.
+inline constexpr char kStringSeparator = '_';  // Label separator in strings.
 
 // Determines whether to use left or right string semiring. Includes a
 // 'restricted' version that signals an error if proper prefixes/suffixes
@@ -112,7 +111,7 @@ class StringWeight {
 
   ReverseWeight Reverse() const;
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return kIdempotent |
            (S == STRING_LEFT ? kLeftSemiring
                              : (S == STRING_RIGHT
@@ -234,9 +233,9 @@ class StringWeightReverseIterator {
 template <typename Label, StringType S>
 inline std::istream &StringWeight<Label, S>::Read(std::istream &strm) {
   Clear();
-  int32 size;
+  int32_t size;
   ReadType(strm, &size);
-  for (int32 i = 0; i < size; ++i) {
+  for (int32_t i = 0; i < size; ++i) {
     Label label;
     ReadType(strm, &label);
     PushBack(label);
@@ -246,7 +245,7 @@ inline std::istream &StringWeight<Label, S>::Read(std::istream &strm) {
 
 template <typename Label, StringType S>
 inline std::ostream &StringWeight<Label, S>::Write(std::ostream &strm) const {
-  const int32 size = Size();
+  const int32_t size = Size();
   WriteType(strm, size);
   for (Iterator iter(*this); !iter.Done(); iter.Next()) {
     WriteType(strm, iter.Value());
@@ -336,7 +335,7 @@ inline std::istream &operator>>(std::istream &strm,
     weight = Weight::One();
   } else {
     weight.Clear();
-    for (std::string_view sv : SplitString(str, kStringSeparator, false)) {
+    for (std::string_view sv : StrSplit(str, kStringSeparator)) {
       auto maybe_label = ParseInt64(sv);
       if (!maybe_label.has_value()) {
         strm.clear(std::ios::badbit);
@@ -510,7 +509,7 @@ class WeightGenerate<StringWeight<Label, S>> {
  public:
   using Weight = StringWeight<Label, S>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t alphabet_size = kNumRandomWeights,
                           size_t max_string_length = kNumRandomWeights)
@@ -667,7 +666,7 @@ class WeightGenerate<GallicWeight<Label, W, G>>
   using Generate = WeightGenerate<
       ProductWeight<StringWeight<Label, GallicStringType(G)>, W>>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true)
       : generate_(seed, allow_zero) {}
 
@@ -814,7 +813,7 @@ class WeightGenerate<GallicWeight<Label, W, GALLIC>>
       WeightGenerate<UnionWeight<GallicWeight<Label, W, GALLIC_RESTRICT>,
                                  GallicUnionWeightOptions<Label, W>>>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true)
       : generate_(seed, allow_zero) {}
 
index 738834e..43dc994 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_STRING_H_
 #define FST_STRING_H_
 
+#include <cstdint>
 #include <memory>
 #include <ostream>
 #include <sstream>
@@ -27,7 +28,6 @@
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/compact-fst.h>
 #include <fst/symbol-table.h>
 #include <fst/util.h>
 
+#include <fst/compat.h>
 #include <string_view>
 
 DECLARE_string(fst_field_separator);
 
 namespace fst {
 
-enum class TokenType : uint8 { SYMBOL = 1, BYTE = 2, UTF8 = 3 };
+enum class TokenType : uint8_t { SYMBOL = 1, BYTE = 2, UTF8 = 3 };
 
 inline std::ostream &operator<<(std::ostream &strm,
                                 const TokenType &token_type) {
@@ -64,7 +65,7 @@ template <class Label>
 bool ConvertSymbolToLabel(std::string_view str, const SymbolTable *syms,
                           Label unknown_label, bool allow_negative,
                           Label *output) {
-  int64 n;
+  int64_t n;
   if (syms) {
     n = syms->Find(str);
     if ((n == kNoSymbol) && (unknown_label != kNoLabel)) n = unknown_label;
@@ -88,11 +89,10 @@ bool ConvertSymbolToLabel(std::string_view str, const SymbolTable *syms,
 }
 
 template <class Label>
-bool ConvertStringToLabels(const std::string &str, TokenType token_type,
-                           const SymbolTable *syms, Label unknown_label,
-                           bool allow_negative, std::vector<Label> *labels,
-                           const std::string &sep =
-                               FST_FLAGS_fst_field_separator) {
+bool ConvertStringToLabels(
+    std::string_view str, TokenType token_type, const SymbolTable *syms,
+    Label unknown_label, bool allow_negative, std::vector<Label> *labels,
+    const std::string &sep = FST_FLAGS_fst_field_separator) {
   labels->clear();
   switch (token_type) {
     case TokenType::BYTE: {
@@ -103,8 +103,9 @@ bool ConvertStringToLabels(const std::string &str, TokenType token_type,
       return UTF8StringToLabels(str, labels);
     }
     case TokenType::SYMBOL: {
-      const std::string separator = "\n" + sep;
-      for (std::string_view c : SplitString(str, separator, true)) {
+      const std::string separator = fst::StrCat("\n", sep);
+      for (std::string_view c :
+           StrSplit(str, ByAnyChar(separator), SkipEmpty())) {
         Label label;
         if (!ConvertSymbolToLabel(c, syms, unknown_label, allow_negative,
                                   &label)) {
@@ -122,12 +123,12 @@ bool ConvertStringToLabels(const std::string &str, TokenType token_type,
 // Additionally, epsilon symbols will be printed only if omit_epsilon
 // is false.
 template <class Label>
-bool LabelsToSymbolString(
-    const std::vector<Label> &labels, std::string *str, const SymbolTable &syms,
-    const std::string &sep = FST_FLAGS_fst_field_separator,
-    bool omit_epsilon = true) {
+bool LabelsToSymbolString(const std::vector<Label> &labels, std::string *str,
+                          const SymbolTable &syms, std::string_view sep,
+                          bool omit_epsilon) {
   std::stringstream ostrm;
-  std::string delim = "";
+  sep.remove_prefix(sep.size() - 1);  // We only respect the final char of sep.
+  std::string_view delim = "";
   for (auto label : labels) {
     if (omit_epsilon && !label) continue;
     ostrm << delim;
@@ -139,7 +140,7 @@ bool LabelsToSymbolString(
       return false;
     }
     ostrm << symbol;
-    delim = std::string(1, sep.back());
+    delim = sep;
   }
   *str = ostrm.str();
   return !!ostrm;
@@ -149,17 +150,16 @@ bool LabelsToSymbolString(
 // Additionally, epsilon symbols will be printed only if omit_epsilon
 // is false.
 template <class Label>
-bool LabelsToNumericString(
-    const std::vector<Label> &labels, std::string *str,
-    const std::string &sep = FST_FLAGS_fst_field_separator,
-    bool omit_epsilon = true) {
+bool LabelsToNumericString(const std::vector<Label> &labels, std::string *str,
+                           std::string_view sep, bool omit_epsilon) {
   std::stringstream ostrm;
-  std::string delim = "";
+  sep.remove_prefix(sep.size() - 1);  // We only respect the final char of sep.
+  std::string_view delim = "";
   for (auto label : labels) {
     if (omit_epsilon && !label) continue;
     ostrm << delim;
     ostrm << label;
-    delim = std::string(1, sep.back());
+    delim = sep;
   }
   *str = ostrm.str();
   return !!ostrm;
@@ -189,9 +189,9 @@ class StringCompiler {
   // of '\n' which is always treated as a separator.
   // Returns true on success.
   template <class FST>
-  bool operator()(const std::string &str, FST *fst,
-                  const std::string &sep =
-                      FST_FLAGS_fst_field_separator) const {
+  bool operator()(
+      std::string_view str, FST *fst,
+      const std::string &sep = FST_FLAGS_fst_field_separator) const {
     std::vector<Label> labels;
     if (!internal::ConvertStringToLabels(str, token_type_, syms_,
                                          unknown_label_, allow_negative_,
@@ -205,7 +205,7 @@ class StringCompiler {
   // Same as above but allows to specify a weight for the string.
   template <class FST>
   bool operator()(
-      const std::string &str, FST *fst, Weight weight,
+      std::string_view str, FST *fst, Weight weight,
       const std::string &sep = FST_FLAGS_fst_field_separator) const {
     std::vector<Label> labels;
     if (!internal::ConvertStringToLabels(str, token_type_, syms_,
@@ -346,9 +346,9 @@ class StringPrinter {
 
   // Converts the FST into a string. With SYMBOL token type, the last character
   // of sep is used as a separator between symbols. Returns true on success.
-  bool operator()(const Fst<Arc> &fst, std::string *str,
-                  const std::string &sep =
-                      FST_FLAGS_fst_field_separator) const {
+  bool operator()(
+      const Fst<Arc> &fst, std::string *str,
+      const std::string &sep = FST_FLAGS_fst_field_separator) const {
     std::vector<Label> labels;
     return StringFstToOutputLabels(fst, &labels) &&
            LabelsToString(labels, str, token_type_, syms_, sep, omit_epsilon_);
index cf55fff..c317cc6 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef FST_SYMBOL_TABLE_OPS_H_
 #define FST_SYMBOL_TABLE_OPS_H_
 
+#include <cstdint>
 #include <string>
 #include <vector>
 
@@ -83,8 +84,8 @@ SymbolTable *FstReadSymbols(const std::string &source, bool input);
 // Adds a contiguous range of symbols to a symbol table using a simple prefix
 // for the string, returning false if the inserted symbol string clashes with
 // any currently present.
-bool AddAuxiliarySymbols(const std::string &prefix, int64 start_label,
-                         int64 nlabels, SymbolTable *syms);
+bool AddAuxiliarySymbols(const std::string &prefix, int64_t start_label,
+                         int64_t nlabels, SymbolTable *syms);
 
 }  // namespace fst
 
index 78b2068..77728b5 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef FST_SYMBOL_TABLE_H_
 #define FST_SYMBOL_TABLE_H_
 
+#include <cstdint>
 #include <functional>
 #include <ios>
 #include <iostream>
 
 #include <fst/compat.h>
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fstream>
 #include <fst/windows_defs.inc>
 #include <map>
 #include <functional>
 #include <string_view>
+#include <fst/lock.h>
 
 DECLARE_bool(fst_compat_symbols);
 
 namespace fst {
 
-constexpr int64 kNoSymbol = -1;
+inline constexpr int64_t kNoSymbol = -1;
 
 class SymbolTable;
 
@@ -58,7 +59,8 @@ struct SymbolTableTextOptions {
 
 namespace internal {
 
-extern const int kLineLen;
+// Maximum line length in textual symbols file.
+inline constexpr int kLineLen = 8096;
 
 // List of symbols with a dense hash for looking up symbol index, rehashing at
 // 75% occupancy.
@@ -66,9 +68,9 @@ class DenseSymbolMap {
  public:
   DenseSymbolMap();
 
-  std::pair<int64, bool> InsertOrFind(std::string_view key);
+  std::pair<int64_t, bool> InsertOrFind(std::string_view key);
 
-  int64 Find(std::string_view key) const;
+  int64_t Find(std::string_view key) const;
 
   size_t Size() const { return symbols_.size(); }
 
@@ -79,7 +81,7 @@ class DenseSymbolMap {
   void ShrinkToFit();
 
  private:
-  static constexpr int64 kEmptyBucket = -1;
+  static constexpr int64_t kEmptyBucket = -1;
 
   // num_buckets must be power of 2.
   void Rehash(size_t num_buckets);
@@ -90,8 +92,8 @@ class DenseSymbolMap {
 
   const std::hash<std::string_view> str_hash_;
   std::vector<std::string> symbols_;
-  std::vector<int64> buckets_;
-  uint64 hash_mask_;
+  std::vector<int64_t> buckets_;
+  uint64_t hash_mask_;
 };
 
 // Base class for SymbolTable implementations.
@@ -110,22 +112,22 @@ class SymbolTableImplBase {
 
   virtual bool Write(std::ostream &strm) const = 0;
 
-  virtual int64 AddSymbol(std::string_view symbol, int64 key) = 0;
+  virtual int64_t AddSymbol(std::string_view symbol, int64_t key) = 0;
 
-  virtual int64 AddSymbol(std::string_view symbol) = 0;
+  virtual int64_t AddSymbol(std::string_view symbol) = 0;
 
   // Removes the symbol with the specified key. Subsequent Find() calls
   // for this key will return the empty string. Does not affect the keys
   // of other symbols.
-  virtual void RemoveSymbol(int64 key) = 0;
+  virtual void RemoveSymbol(int64_t key) = 0;
 
   // Returns the symbol for the specified key, or the empty string if not found.
-  virtual std::string Find(int64 key) const = 0;
+  virtual std::string Find(int64_t key) const = 0;
 
   // Returns the key for the specified symbol, or kNoSymbol if not found.
-  virtual int64 Find(std::string_view symbol) const = 0;
+  virtual int64_t Find(std::string_view symbol) const = 0;
 
-  virtual bool Member(int64 key) const { return !Find(key).empty(); }
+  virtual bool Member(int64_t key) const { return !Find(key).empty(); }
 
   virtual bool Member(std::string_view symbol) const {
     return Find(symbol) != kNoSymbol;
@@ -133,17 +135,17 @@ class SymbolTableImplBase {
 
   virtual void AddTable(const SymbolTable &table) = 0;
 
-  virtual int64 GetNthKey(ssize_t pos) const = 0;
+  virtual int64_t GetNthKey(ssize_t pos) const = 0;
 
   virtual const std::string &Name() const = 0;
 
-  virtual void SetName(const std::string &new_name) = 0;
+  virtual void SetName(std::string_view new_name) = 0;
 
   virtual const std::string &CheckSum() const = 0;
 
   virtual const std::string &LabeledCheckSum() const = 0;
 
-  virtual int64 AvailableKey() const = 0;
+  virtual int64_t AvailableKey() const = 0;
 
   virtual size_t NumSymbols() const = 0;
 
@@ -162,14 +164,13 @@ class ConstSymbolTableImpl : public SymbolTableImplBase {
  public:
   std::unique_ptr<SymbolTableImplBase> Copy() const final;
 
-  int64 AddSymbol(std::string_view symbol, int64 key) final;
+  int64_t AddSymbol(std::string_view symbol, int64_t key) final;
 
-  int64 AddSymbol(std::string_view symbol) final;
+  int64_t AddSymbol(std::string_view symbol) final;
 
-  void RemoveSymbol(int64 key) final;
-
-  void SetName(const std::string &new_name) final;
+  void RemoveSymbol(int64_t key) final;
 
+  void SetName(std::string_view new_name) final;
   void AddTable(const SymbolTable &table) final;
 
   bool IsMutable() const final { return false; }
@@ -179,7 +180,7 @@ class ConstSymbolTableImpl : public SymbolTableImplBase {
 // Provides the common text and binary format serialization.
 class SymbolTableImpl final : public MutableSymbolTableImpl {
  public:
-  explicit SymbolTableImpl(const std::string &name)
+  explicit SymbolTableImpl(std::string_view name)
       : name_(name),
         available_key_(0),
         dense_key_limit_(0),
@@ -198,19 +199,19 @@ class SymbolTableImpl final : public MutableSymbolTableImpl {
     return std::make_unique<SymbolTableImpl>(*this);
   }
 
-  int64 AddSymbol(std::string_view symbol, int64 key) override;
+  int64_t AddSymbol(std::string_view symbol, int64_t key) override;
 
-  int64 AddSymbol(std::string_view symbol) override {
+  int64_t AddSymbol(std::string_view symbol) override {
     return AddSymbol(symbol, available_key_);
   }
 
   // Removes the symbol with the given key. The removal is costly
   // (O(NumSymbols)) and may reduce the efficiency of Find() because of a
   // potentially reduced size of the dense key interval.
-  void RemoveSymbol(int64 key) override;
+  void RemoveSymbol(int64_t key) override;
 
   static SymbolTableImpl *ReadText(
-      std::istream &strm, const std::string &name,
+      std::istream &strm, std::string_view name,
       const SymbolTableTextOptions &opts = SymbolTableTextOptions());
 
   // Reads a binary SymbolTable from stream, using source in error messages.
@@ -220,17 +221,17 @@ class SymbolTableImpl final : public MutableSymbolTableImpl {
 
   // Returns the string associated with the key. If the key is out of
   // range (<0, >max), return an empty string.
-  std::string Find(int64 key) const override;
+  std::string Find(int64_t key) const override;
 
   // Returns the key associated with the symbol; if the symbol
   // does not exists, returns kNoSymbol.
-  int64 Find(std::string_view symbol) const override {
-    int64 idx = symbols_.Find(symbol);
+  int64_t Find(std::string_view symbol) const override {
+    int64_t idx = symbols_.Find(symbol);
     if (idx == kNoSymbol || idx < dense_key_limit_) return idx;
     return idx_key_[idx - dense_key_limit_];
   }
 
-  int64 GetNthKey(ssize_t pos) const override {
+  int64_t GetNthKey(ssize_t pos) const override {
     if (pos < 0 || static_cast<size_t>(pos) >= symbols_.Size()) {
       return kNoSymbol;
     } else if (pos < dense_key_limit_) {
@@ -241,7 +242,9 @@ class SymbolTableImpl final : public MutableSymbolTableImpl {
 
   const std::string &Name() const override { return name_; }
 
-  void SetName(const std::string &new_name) override { name_ = new_name; }
+  void SetName(std::string_view new_name) override {
+    name_ = std::string(new_name);
+  }
 
   const std::string &CheckSum() const override {
     MaybeRecomputeCheckSum();
@@ -253,7 +256,7 @@ class SymbolTableImpl final : public MutableSymbolTableImpl {
     return labeled_check_sum_string_;
   }
 
-  int64 AvailableKey() const override { return available_key_; }
+  int64_t AvailableKey() const override { return available_key_; }
 
   size_t NumSymbols() const override { return symbols_.Size(); }
 
@@ -267,16 +270,16 @@ class SymbolTableImpl final : public MutableSymbolTableImpl {
   void MaybeRecomputeCheckSum() const;
 
   std::string name_;
-  int64 available_key_;
-  int64 dense_key_limit_;
+  int64_t available_key_;
+  int64_t dense_key_limit_;
 
   DenseSymbolMap symbols_;
   // Maps index to key for index >= dense_key_limit:
   //   key = idx_key_[index - dense_key_limit]
-  std::vector<int64> idx_key_;
+  std::vector<int64_t> idx_key_;
   // Maps key to index for key >= dense_key_limit_.
   //  index = key_map_[key]
-  std::map<int64, int64> key_map_;
+  std::map<int64_t, int64_t> key_map_;
 
   mutable bool check_sum_finalized_;
   mutable std::string check_sum_string_;
@@ -307,7 +310,7 @@ class SymbolTable {
     class value_type {
      public:
       // Return the label of the current symbol.
-      int64 Label() const { return key_; }
+      int64_t Label() const { return key_; }
 
       // Return the string of the current symbol.
       // TODO(wolfsonkin): Consider adding caching.
@@ -323,7 +326,7 @@ class SymbolTable {
       friend class SymbolTable::iterator;
 
       const SymbolTable *table_;  // Does not own the underlying SymbolTable.
-      int64 key_;
+      int64_t key_;
     };
 
     using difference_type = std::ptrdiff_t;
@@ -364,7 +367,7 @@ class SymbolTable {
   using const_iterator = iterator;
 
   // Constructs symbol table with an optional name.
-  explicit SymbolTable(const std::string &name = "<unspecified>")
+  explicit SymbolTable(std::string_view name = "<unspecified>")
       : impl_(std::make_shared<internal::SymbolTableImpl>(name)) {}
 
   virtual ~SymbolTable() {}
@@ -372,7 +375,7 @@ class SymbolTable {
   // Reads a text representation of the symbol table from an istream. Pass a
   // name to give the resulting SymbolTable.
   static SymbolTable *ReadText(
-      std::istream &strm, const std::string &name,
+      std::istream &strm, std::string_view name,
       const SymbolTableTextOptions &opts = SymbolTableTextOptions()) {
     auto impl =
         fst::WrapUnique(internal::SymbolTableImpl::ReadText(strm, name, opts));
@@ -415,43 +418,43 @@ class SymbolTable {
 
   // Adds a symbol with given key to table. A symbol table also keeps track of
   // the last available key (highest key value in the symbol table).
-  int64 AddSymbol(std::string_view symbol, int64 key) {
+  int64_t AddSymbol(std::string_view symbol, int64_t key) {
     MutateCheck();
     return impl_->AddSymbol(symbol, key);
   }
 
   // Adds a symbol to the table. The associated value key is automatically
   // assigned by the symbol table.
-  int64 AddSymbol(std::string_view symbol) {
+  int64_t AddSymbol(std::string_view symbol) {
     MutateCheck();
     return impl_->AddSymbol(symbol);
   }
 
   // Returns the current available key (i.e., highest key + 1) in the symbol
   // table.
-  int64 AvailableKey() const { return impl_->AvailableKey(); }
+  int64_t AvailableKey() const { return impl_->AvailableKey(); }
 
   // Return the label-agnostic MD5 check-sum for this table. All new symbols
   // added to the table will result in an updated checksum.
   OPENFST_DEPRECATED("Use `LabeledCheckSum()` instead.")
   const std::string &CheckSum() const { return impl_->CheckSum(); }
 
-  int64 GetNthKey(ssize_t pos) const { return impl_->GetNthKey(pos); }
+  int64_t GetNthKey(ssize_t pos) const { return impl_->GetNthKey(pos); }
 
   // Returns the string associated with the key; if the key is out of
   // range (<0, >max), returns an empty string.
-  std::string Find(int64 key) const { return impl_->Find(key); }
+  std::string Find(int64_t key) const { return impl_->Find(key); }
 
   // Returns the key associated with the symbol; if the symbol does not exist,
   // kNoSymbol is returned.
-  int64 Find(std::string_view symbol) const { return impl_->Find(symbol); }
+  int64_t Find(std::string_view symbol) const { return impl_->Find(symbol); }
 
   // Same as CheckSum(), but returns an label-dependent version.
   const std::string &LabeledCheckSum() const {
     return impl_->LabeledCheckSum();
   }
 
-  bool Member(int64 key) const { return impl_->Member(key); }
+  bool Member(int64_t key) const { return impl_->Member(key); }
 
   bool Member(std::string_view symbol) const { return impl_->Member(symbol); }
 
@@ -462,13 +465,13 @@ class SymbolTable {
   // AvailableKey()).
   size_t NumSymbols() const { return impl_->NumSymbols(); }
 
-  void RemoveSymbol(int64 key) {
+  void RemoveSymbol(int64_t key) {
     MutateCheck();
     return impl_->RemoveSymbol(key);
   }
 
   // Sets the name of the symbol table.
-  void SetName(const std::string &new_name) {
+  void SetName(std::string_view new_name) {
     MutateCheck();
     impl_->SetName(new_name);
   }
@@ -498,13 +501,13 @@ class SymbolTable {
 
   template <class T = internal::SymbolTableImplBase>
   const T *Impl() const {
-    return fst::down_cast<const T *>(impl_.get());
+    return down_cast<const T *>(impl_.get());
   }
 
   template <class T = internal::SymbolTableImplBase>
   T *MutableImpl() {
     MutateCheck();
-    return fst::down_cast<T *>(impl_.get());
+    return down_cast<T *>(impl_.get());
   }
 
  private:
@@ -532,7 +535,7 @@ class OPENFST_DEPRECATED(
   bool Done() const { return (iter_ == end_); }
 
   // Return the key of the current symbol.
-  int64 Value() const { return iter_->Label(); }
+  int64_t Value() const { return iter_->Label(); }
 
   // Return the string of the current symbol.
   std::string Symbol() const { return iter_->Symbol(); }
@@ -562,8 +565,8 @@ SymbolTable *RelabelSymbolTable(
   auto *new_table = new SymbolTable(
       table->Name().empty() ? std::string()
                             : (std::string("relabeled_") + table->Name()));
-  for (const auto &pair : pairs) {
-    new_table->AddSymbol(table->Find(pair.first), pair.second);
+  for (const auto &[old_label, new_label] : pairs) {
+    new_table->AddSymbol(table->Find(old_label), new_label);
   }
   return new_table;
 }
index 14a771b..c069255 100644 (file)
 #define FST_SYNCHRONIZE_H_
 
 #include <algorithm>
+#include <cstdint>
 #include <functional>
 #include <memory>
 #include <string>
 #include <string_view>
 #include <vector>
 
-#include <fst/types.h>
-
 #include <fst/cache.h>
 #include <fst/test-properties.h>
 
@@ -139,10 +138,10 @@ class SynchronizeFstImpl : public CacheImpl<Arc> {
     return CacheImpl<Arc>::NumOutputEpsilons(s);
   }
 
-  uint64 Properties() const override { return Properties(kFstProperties); }
+  uint64_t Properties() const override { return Properties(kFstProperties); }
 
   // Sets error if found, returning other FST impl properties.
-  uint64 Properties(uint64 mask) const override {
+  uint64_t Properties(uint64_t mask) const override {
     if ((mask & kError) && fst_->Properties(kError, false)) {
       SetProperties(kError, kError);
     }
@@ -188,18 +187,19 @@ class SynchronizeFstImpl : public CacheImpl<Arc> {
   }
 
   StringView FindString(String &&str) {
-    const auto insert_result = string_set_.insert(std::forward<String>(str));
-    return *insert_result.first;
+    const auto [str_it, unused] = string_set_.insert(std::forward<String>(str));
+    return *str_it;
   }
 
   // Finds state corresponding to an element. Creates new state if element
   // is not found.
   StateId FindState(const Element &element) {
-    const auto insert_result = element_map_.emplace(element, elements_.size());
-    if (insert_result.second) {
+    const auto &[iter, inserted] =
+        element_map_.emplace(element, elements_.size());
+    if (inserted) {
       elements_.push_back(element);
     }
-    return insert_result.first->second;
+    return iter->second;
   }
 
   // Computes the outgoing transitions from a state, creating new destination
index 13e75f5..85f0941 100644 (file)
@@ -20,8 +20,9 @@
 #ifndef FST_TEST_PROPERTIES_H_
 #define FST_TEST_PROPERTIES_H_
 
+#include <cstdint>
+
 #include <fst/flags.h>
-#include <fst/types.h>
 
 #include <fst/connect.h>
 #include <fst/dfs-visit.h>
@@ -44,20 +45,21 @@ namespace internal {
 // properties can be used. This routine is seldom called directly; instead it is
 // used to implement fst.Properties(mask, /*test=*/true).
 template <class Arc>
-uint64 ComputeProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known) {
+uint64_t ComputeProperties(const Fst<Arc> &fst, uint64_t mask,
+                           uint64_t *known) {
   using Label = typename Arc::Label;
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
   const auto fst_props = fst.Properties(kFstProperties, false);  // FST-stored.
   // Computes (trinary) properties explicitly.
   // Initialize with binary properties (already known).
-  uint64 comp_props = fst_props & kBinaryProperties;
+  uint64_t comp_props = fst_props & kBinaryProperties;
   // Computes these trinary properties with a DFS. We compute only those that
   // need a DFS here, since we otherwise would like to avoid a DFS since its
   // stack could grow large.
-  constexpr uint64 kDfsProps = kCyclic | kAcyclic | kInitialCyclic |
-                               kInitialAcyclic | kAccessible | kNotAccessible |
-                               kCoAccessible | kNotCoAccessible;
+  constexpr uint64_t kDfsProps =
+      kCyclic | kAcyclic | kInitialCyclic | kInitialAcyclic | kAccessible |
+      kNotAccessible | kCoAccessible | kNotCoAccessible;
   std::vector<StateId> scc;
   if (mask & (kDfsProps | kWeightedCycles | kUnweightedCycles)) {
     SccVisitor<Arc> scc_visitor(&scc, nullptr, nullptr, &comp_props);
@@ -180,8 +182,8 @@ uint64 ComputeProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known) {
 // Similar to ComputeProperties, but uses the properties already stored
 // in the FST when possible.
 template <class Arc>
-uint64 ComputeOrUseStoredProperties(const Fst<Arc> &fst, uint64 mask,
-                                    uint64 *known) {
+uint64_t ComputeOrUseStoredProperties(const Fst<Arc> &fst, uint64_t mask,
+                                      uint64_t *known) {
   // Check stored FST properties first.
   const auto fst_props = fst.Properties(kFstProperties, /*test=*/false);
   const auto known_props = KnownProperties(fst_props);
@@ -199,7 +201,7 @@ uint64 ComputeOrUseStoredProperties(const Fst<Arc> &fst, uint64 mask,
 // FST_FLAGS_fst_verify_properties is true. This routine is seldom called directly;
 // instead it is used to implement fst.Properties(mask, /*test=*/true).
 template <class Arc>
-uint64 TestProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known) {
+uint64_t TestProperties(const Fst<Arc> &fst, uint64_t mask, uint64_t *known) {
   if (FST_FLAGS_fst_verify_properties) {
     const auto stored_props = fst.Properties(kFstProperties, false);
     const auto computed_props = ComputeProperties(fst, mask, known);
@@ -218,8 +220,8 @@ uint64 TestProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known) {
 // both 'check_mask' and 'test_mask' are computed. This is used to check for
 // newly-added properties that might not be set in old binary files.
 template <class Arc>
-uint64 CheckProperties(const Fst<Arc> &fst, uint64 check_mask,
-                       uint64 test_mask) {
+uint64_t CheckProperties(const Fst<Arc> &fst, uint64_t check_mask,
+                         uint64_t test_mask) {
   auto props = fst.Properties(kFstProperties, false);
   if (FST_FLAGS_fst_verify_properties) {
     props = TestProperties(fst, check_mask | test_mask, /*known=*/nullptr);
index fc78f0b..009e2bb 100644 (file)
 #ifndef FST_TEST_ALGO_TEST_H_
 #define FST_TEST_ALGO_TEST_H_
 
+#include <cstdint>
 #include <memory>
 #include <random>
 #include <utility>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/fstlib.h>
+#include <fst/weight.h>
 #include <fst/test/rand-fst.h>
 
 DECLARE_int32(repeat);  // defined in ./algo_test.cc
@@ -44,7 +45,7 @@ class EpsMapper {
     return A(0, 0, arc.weight, arc.nextstate);
   }
 
-  uint64 Properties(uint64 props) const {
+  uint64_t Properties(uint64_t props) const {
     props &= ~kNotAcceptor;
     props |= kAcceptor;
     props &= ~kNoIEpsilons & ~kNoOEpsilons & ~kNoEpsilons;
@@ -87,15 +88,17 @@ inline void LookAheadCompose(const Fst<StdArc> &ifst1, const Fst<StdArc> &ifst2,
 
 // This class tests a variety of identities and properties that must
 // hold for various algorithms on weighted FSTs.
-template <class Arc, class WeightGenerator>
+template <class Arc>
 class WeightedTester {
  public:
   using Label = typename Arc::Label;
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
+  using WeightGenerator = WeightGenerate<Weight>;
 
-  WeightedTester(uint64 seed, const Fst<Arc> &zero_fst, const Fst<Arc> &one_fst,
-                 const Fst<Arc> &univ_fst, WeightGenerator weight_generator)
+  WeightedTester(uint64_t seed, const Fst<Arc> &zero_fst,
+                 const Fst<Arc> &one_fst, const Fst<Arc> &univ_fst,
+                 WeightGenerator weight_generator)
       : seed_(seed),
         rand_(seed),
         zero_fst_(zero_fst),
@@ -426,7 +429,7 @@ class WeightedTester {
     {
       VLOG(1) << "Check encoding/decoding (destructive).";
       VectorFst<Arc> D(T);
-      uint8 encode_props = 0;
+      uint8_t encode_props = 0;
       if (std::bernoulli_distribution(.5)(rand_)) {
         encode_props |= kEncodeLabels;
       }
@@ -441,7 +444,7 @@ class WeightedTester {
 
     {
       VLOG(1) << "Check encoding/decoding (delayed).";
-      uint8 encode_props = 0;
+      uint8_t encode_props = 0;
       if (std::bernoulli_distribution(.5)(rand_)) {
         encode_props |= kEncodeLabels;
       }
@@ -468,8 +471,8 @@ class WeightedTester {
 
     {
       VLOG(1) << "Check gallic mappers (delayed).";
-      auto G = MakeArcMapFst(T, ToGallicMapper<Arc>());
-      auto F = MakeArcMapFst(G, FromGallicMapper<Arc>());
+      ArcMapFst G(T, ToGallicMapper<Arc>());
+      ArcMapFst F(G, FromGallicMapper<Arc>());
       CHECK(Equiv(T, F));
     }
   }
@@ -630,8 +633,8 @@ class WeightedTester {
 
   // Tests optimization operations
   void TestOptimize(const Fst<Arc> &T) {
-    uint64 tprops = T.Properties(kFstProperties, true);
-    uint64 wprops = Weight::Properties();
+    uint64_t tprops = T.Properties(kFstProperties, true);
+    uint64_t wprops = Weight::Properties();
 
     VectorFst<Arc> A(T);
     Project(&A, ProjectType::INPUT);
@@ -743,10 +746,10 @@ class WeightedTester {
         // Skip test if A is the empty machine or contains epsilons or
         // if the semiring is not idempotent (to avoid floating point
         // errors)
-        VectorFst<Arc> R;
+        VectorFst<ReverseArc<Arc>> R;
         Reverse(A, &R);
         RmEpsilon(&R);
-        DeterminizeFst<Arc> DR(R);
+        DeterminizeFst<ReverseArc<Arc>> DR(R);
         VectorFst<Arc> RD;
         Reverse(DR, &RD);
         DeterminizeFst<Arc> DRD(RD);
@@ -872,7 +875,7 @@ class WeightedTester {
   // Tests search operations
   void TestSearch(const Fst<Arc> &T) {
     if constexpr (IsPath<Weight>::value) {
-      uint64 wprops = Weight::Properties();
+      uint64_t wprops = Weight::Properties();
 
       VectorFst<Arc> A(T);
       Project(&A, ProjectType::INPUT);
@@ -941,10 +944,10 @@ class WeightedTester {
   bool Unambiguous(const Fst<Arc> &fst) {
     VectorFst<StdArc> sfst, dfst;
     VectorFst<LogArc> lfst1, lfst2;
-    Map(fst, &sfst, RmWeightMapper<Arc, StdArc>());
+    ArcMap(fst, &sfst, RmWeightMapper<Arc, StdArc>());
     Determinize(sfst, &dfst);
-    Map(fst, &lfst1, RmWeightMapper<Arc, LogArc>());
-    Map(dfst, &lfst2, RmWeightMapper<StdArc, LogArc>());
+    ArcMap(fst, &lfst1, RmWeightMapper<Arc, LogArc>());
+    ArcMap(dfst, &lfst2, RmWeightMapper<StdArc, LogArc>());
     return Equiv(lfst1, lfst2);
   }
 
@@ -971,7 +974,7 @@ class WeightedTester {
     for (ssize_t n = 0; n < kNumRandomPaths; ++n) {
       RandGen(fst1, &path, opts);
       Invert(&path);
-      Map(&path, RmWeightMapper<Arc>());
+      ArcMap(&path, RmWeightMapper<Arc>());
       Compose(path, fst2, &paths1);
       Weight sum1 = ShortestDistance(paths1);
       Compose(paths1, path, &paths2);
@@ -992,14 +995,14 @@ class WeightedTester {
     CHECK(Verify(pfst));
 
     DifferenceFst<Arc> D(fst, DeterminizeFst<Arc>(RmEpsilonFst<Arc>(
-                                  MakeArcMapFst(pfst, RmWeightMapper<Arc>()))));
+                                  ArcMapFst(pfst, RmWeightMapper<Arc>()))));
     const Weight sum1 = Times(ShortestDistance(fst), threshold);
     const Weight sum2 = ShortestDistance(D);
     return ApproxEqual(Plus(sum1, sum2), sum1, kTestDelta);
   }
 
   // Random seed.
-  uint64 seed_;
+  uint64_t seed_;
   // Random state (for randomness in this class).
   std::mt19937_64 rand_;
   // FST with no states
@@ -1011,35 +1014,20 @@ class WeightedTester {
   // Generates weights used in testing.
   WeightGenerator generate_;
   // Maximum random path length.
-  static const int kRandomPathLength;
+  static constexpr int kRandomPathLength = 25;
   // Number of random paths to explore.
-  static const int kNumRandomPaths;
+  static constexpr int kNumRandomPaths = 100;
   // Maximum number of nshortest paths.
-  static const int kNumRandomShortestPaths;
+  static constexpr int kNumRandomShortestPaths = 100;
   // Maximum number of nshortest states.
-  static const int kNumShortestStates;
+  static constexpr int kNumShortestStates = 10000;
   // Delta for equivalence tests.
-  static const float kTestDelta;
+  static constexpr float kTestDelta = .05;
 
   WeightedTester(const WeightedTester &) = delete;
   WeightedTester &operator=(const WeightedTester &) = delete;
 };
 
-template <class A, class WG>
-const int WeightedTester<A, WG>::kRandomPathLength = 25;
-
-template <class A, class WG>
-const int WeightedTester<A, WG>::kNumRandomPaths = 100;
-
-template <class A, class WG>
-const int WeightedTester<A, WG>::kNumRandomShortestPaths = 100;
-
-template <class A, class WG>
-const int WeightedTester<A, WG>::kNumShortestStates = 10000;
-
-template <class A, class WG>
-const float WeightedTester<A, WG>::kTestDelta = .05;
-
 // This class tests a variety of identities and properties that must
 // hold for various algorithms on unweighted FSAs and that are not tested
 // by WeightedTester. Only the specialization does anything interesting.
@@ -1047,7 +1035,7 @@ template <class Arc>
 class UnweightedTester {
  public:
   UnweightedTester(const Fst<Arc> &zero_fsa, const Fst<Arc> &one_fsa,
-                   const Fst<Arc> &univ_fsa, uint64 seed) {}
+                   const Fst<Arc> &univ_fsa, uint64_t seed) {}
 
   void Test(const Fst<Arc> &A1, const Fst<Arc> &A2, const Fst<Arc> &A3) {}
 };
@@ -1064,7 +1052,7 @@ class UnweightedTester<StdArc> {
   using Weight = Arc::Weight;
 
   UnweightedTester(const Fst<Arc> &zero_fsa, const Fst<Arc> &one_fsa,
-                   const Fst<Arc> &univ_fsa, uint64 seed)
+                   const Fst<Arc> &univ_fsa, uint64_t seed)
       : zero_fsa_(zero_fsa),
         one_fsa_(one_fsa),
         univ_fsa_(univ_fsa),
@@ -1111,15 +1099,12 @@ class UnweightedTester<StdArc> {
     {
       VLOG(1) << "Check if A^n c A* (delayed).";
       const int n = std::uniform_int_distribution<>(0, 4)(rand_);
-      Fst<Arc> *C = new VectorFst<Arc>(one_fsa_);
+      std::unique_ptr<Fst<Arc>> C = std::make_unique<VectorFst<Arc>>(one_fsa_);
       for (int i = 0; i < n; ++i) {
-        ConcatFst<Arc> *F = new ConcatFst<Arc>(*C, A1);
-        delete C;
-        C = F;
+        C = std::make_unique<ConcatFst<Arc>>(*C, A1);
       }
       ClosureFst<Arc> S(A1, CLOSURE_STAR);
       CHECK(Subset(*C, S));
-      delete C;
     }
   }
 
@@ -1320,14 +1305,15 @@ class UnweightedTester<StdArc> {
 // hold for various FST algorithms. It randomly generates FSTs, using
 // function object 'weight_generator' to select weights. 'WeightTester'
 // and 'UnweightedTester' are then called.
-template <class Arc, class WeightGenerator>
+template <class Arc>
 class AlgoTester {
  public:
   using Label = typename Arc::Label;
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
+  using WeightGenerator = WeightGenerate<Weight>;
 
-  AlgoTester(WeightGenerator generator, uint64 seed)
+  AlgoTester(WeightGenerator generator, uint64_t seed)
       : generate_(std::move(generator)), rand_(seed) {
     one_fst_.AddState();
     one_fst_.SetStart(0);
@@ -1338,8 +1324,8 @@ class AlgoTester {
     univ_fst_.SetFinal(0);
     for (int i = 0; i < kNumRandomLabels; ++i) univ_fst_.EmplaceArc(0, i, i, 0);
 
-    weighted_tester_.reset(new WeightedTester<Arc, WeightGenerator>(
-        seed, zero_fst_, one_fst_, univ_fst_, generate_));
+    weighted_tester_.reset(new WeightedTester<Arc>(seed, zero_fst_, one_fst_,
+                                                   univ_fst_, generate_));
 
     unweighted_tester_.reset(
         new UnweightedTester<Arc>(zero_fst_, one_fst_, univ_fst_, seed));
@@ -1389,46 +1375,27 @@ class AlgoTester {
   // FST with one state that accepts all strings.
   VectorFst<Arc> univ_fst_;
   // Tests weighted FSTs
-  std::unique_ptr<WeightedTester<Arc, WeightGenerator>> weighted_tester_;
+  std::unique_ptr<WeightedTester<Arc>> weighted_tester_;
   // Tests unweighted FSTs
   std::unique_ptr<UnweightedTester<Arc>> unweighted_tester_;
   // Mapper to remove weights from an Fst
   RmWeightMapper<Arc> rm_weight_mapper_;
   // Maximum number of states in random test Fst.
-  static const int kNumRandomStates;
+  static constexpr int kNumRandomStates = 10;
   // Maximum number of arcs in random test Fst.
-  static const int kNumRandomArcs;
+  static constexpr int kNumRandomArcs = 25;
   // Number of alternative random labels.
-  static const int kNumRandomLabels;
+  static constexpr int kNumRandomLabels = 5;
   // Probability to force an acyclic Fst
-  static const float kAcyclicProb;
+  static constexpr float kAcyclicProb = .25;
   // Maximum random path length.
-  static const int kRandomPathLength;
+  static constexpr int kRandomPathLength = 25;
   // Number of random paths to explore.
-  static const int kNumRandomPaths;
+  static constexpr int kNumRandomPaths = 100;
 
   AlgoTester(const AlgoTester &) = delete;
   AlgoTester &operator=(const AlgoTester &) = delete;
 };
-
-template <class A, class G>
-const int AlgoTester<A, G>::kNumRandomStates = 10;
-
-template <class A, class G>
-const int AlgoTester<A, G>::kNumRandomArcs = 25;
-
-template <class A, class G>
-const int AlgoTester<A, G>::kNumRandomLabels = 5;
-
-template <class A, class G>
-const float AlgoTester<A, G>::kAcyclicProb = .25;
-
-template <class A, class G>
-const int AlgoTester<A, G>::kRandomPathLength = 25;
-
-template <class A, class G>
-const int AlgoTester<A, G>::kNumRandomPaths = 100;
-
 }  // namespace fst
 
 #endif  // FST_TEST_ALGO_TEST_H_
index 4fbf8fe..9249c38 100644 (file)
 //
 // Compactors for use in tests.  See compact-fst.h.
 
+#include <cstdint>
+#include <string>
 #include <type_traits>
 
-#include <fst/types.h>
 #include <fst/arc.h>
 #include <fst/fst.h>
 #include <fst/vector-fst.h>
@@ -39,23 +40,23 @@ class TrivialArcCompactor {
   using StateId = typename A::StateId;
   using Weight = typename A::Weight;
   // We use ArcTpl, which is trivially copyable if Weight is.
-  static_assert(std::is_trivially_copyable<Weight>::value,
+  static_assert(std::is_trivially_copyable_v<Weight>,
                 "Weight must be trivially copyable.");
   using Element = ArcTpl<Weight>;
-  static_assert(std::is_trivially_copyable<Element>::value,
+  static_assert(std::is_trivially_copyable_v<Element>,
                 "ArcTpl should be trivially copyable; someone broke it.");
 
   Element Compact(StateId s, const A &arc) const {
     return Element(arc.ilabel, arc.olabel, arc.weight, arc.nextstate);
   }
 
-  Arc Expand(StateId s, const Element &e, uint32 f = kArcValueFlags) const {
+  Arc Expand(StateId s, const Element &e, uint32_t f = kArcValueFlags) const {
     return Arc(e.ilabel, e.olabel, e.weight, e.nextstate);
   }
 
   ssize_t Size() const { return -1; }
 
-  uint64 Properties() const { return 0ULL; }
+  uint64_t Properties() const { return 0ULL; }
 
   bool Compatible(const Fst<A> &fst) const { return true; }
 
@@ -110,7 +111,7 @@ class TrivialCompactor {
     StateId GetStateId() const { return s_; }
     Weight Final() const { return c_->fst_->Final(s_); }
     size_t NumArcs() const { return c_->fst_->NumArcs(s_); }
-    Arc GetArc(size_t i, uint32 f) const {
+    Arc GetArc(size_t i, uint32_t f) const {
       i_->Seek(i);
       return i_->Value();
     }
@@ -125,10 +126,10 @@ class TrivialCompactor {
 
   template <typename Arc>
   bool IsCompatible(const Fst<Arc> &fst) const {
-    return std::is_same<Arc, A>::value;
+    return std::is_same_v<Arc, A>;
   }
 
-  uint64 Properties(uint64 props) const { return props; }
+  uint64_t Properties(uint64_t props) const { return props; }
 
   static const std::string &Type() {
     static const std::string *const type =
index f39e6c4..467faa4 100644 (file)
@@ -20,6 +20,9 @@
 #ifndef FST_TEST_FST_TEST_H_
 #define FST_TEST_FST_TEST_H_
 
+#include <memory>
+#include <string>
+
 #include <fst/equal.h>
 #include <fstream>
 #include <fst/matcher.h>
@@ -49,11 +52,9 @@ class FstTester {
       : num_states_(num_states), weighted_(weighted) {
     VectorFst<Arc> vfst;
     InitFst(&vfst, num_states);
-    testfst_ = new F(vfst);
+    testfst_ = std::make_unique<F>(vfst);
   }
 
-  ~FstTester() { delete testfst_; }
-
   // This verifies the contents described in InitFst() using
   // methods defined in a generic Fst.
   template <class G>
@@ -148,12 +149,13 @@ class FstTester {
       }
     }
 
-    G *cfst1 = fst->Copy();
-    cfst1->DeleteStates();
-    CHECK_EQ(cfst1->NumStates(), 0);
-    delete cfst1;
+    {
+      std::unique_ptr<G> cfst1(fst->Copy());
+      cfst1->DeleteStates();
+      CHECK_EQ(cfst1->NumStates(), 0);
+    }
 
-    G *cfst2 = fst->Copy();
+    std::unique_ptr<G> cfst2(fst->Copy());
     for (StateIterator<G> siter(*cfst2); !siter.Done(); siter.Next()) {
       StateId s = siter.Value();
       cfst2->DeleteArcs(s);
@@ -161,10 +163,9 @@ class FstTester {
       CHECK_EQ(cfst2->NumInputEpsilons(s), 0);
       CHECK_EQ(cfst2->NumOutputEpsilons(s), 0);
     }
-    delete cfst2;
   }
 
-  void TestMutable() { TestMutable(testfst_); }
+  void TestMutable() { TestMutable(testfst_.get()); }
 
   // This verifies operator=
   template <class G>
@@ -198,9 +199,8 @@ class FstTester {
     TestBase(c2fst);
 
     // Copy from self
-    const G *c3fst = fst.Copy();
+    std::unique_ptr<const G> c3fst(fst.Copy());
     TestBase(*c3fst);
-    delete c3fst;
   }
 
   void TestCopy() const { TestCopy(*testfst_); }
@@ -214,26 +214,23 @@ class FstTester {
     {
       // write/read
       CHECK(fst.Write(filename));
-      G *ffst = G::Read(filename);
+      auto ffst = fst::WrapUnique(G::Read(filename));
       CHECK(ffst);
       TestBase(*ffst);
-      delete ffst;
     }
 
     {
       // generic read/cast/test
-      Fst<Arc> *gfst = Fst<Arc>::Read(filename);
+      auto gfst = fst::WrapUnique(Fst<Arc>::Read(filename));
       CHECK(gfst);
-      G *dfst = fst::down_cast<G *>(gfst);
+      G *dfst = down_cast<G *>(gfst.get());
       TestBase(*dfst);
 
       // generic write/read/test
       CHECK(gfst->Write(filename));
-      Fst<Arc> *hfst = Fst<Arc>::Read(filename);
+      auto hfst = fst::WrapUnique(Fst<Arc>::Read(filename));
       CHECK(hfst);
       TestBase(*hfst);
-      delete gfst;
-      delete hfst;
     }
 
     {
@@ -249,10 +246,9 @@ class FstTester {
       FstReadOptions opts;
       opts.mode = FstReadOptions::ReadMode("map");
       opts.source = aligned;
-      G *gfst = G::Read(istr, opts);
+      auto gfst = fst::WrapUnique(G::Read(istr, opts));
       CHECK(gfst);
       TestBase(*gfst);
-      delete gfst;
     }
 
     // check mmaping of unaligned files to make sure it does not fail.
@@ -268,29 +264,26 @@ class FstTester {
       FstReadOptions opts;
       opts.mode = FstReadOptions::ReadMode("map");
       opts.source = aligned;
-      G *gfst = G::Read(istr, opts);
+      auto gfst = fst::WrapUnique(G::Read(istr, opts));
       CHECK(gfst);
       TestBase(*gfst);
-      delete gfst;
     }
 
     // expanded write/read/test
     if (fst.Properties(kExpanded, false)) {
-      ExpandedFst<Arc> *efst = ExpandedFst<Arc>::Read(filename);
+      auto efst = fst::WrapUnique(ExpandedFst<Arc>::Read(filename));
       CHECK(efst);
       TestBase(*efst);
       TestExpanded(*efst);
-      delete efst;
     }
 
     // mutable write/read/test
     if (fst.Properties(kMutable, false)) {
-      MutableFst<Arc> *mfst = MutableFst<Arc>::Read(filename);
+      auto mfst = fst::WrapUnique(MutableFst<Arc>::Read(filename));
       CHECK(mfst);
       TestBase(*mfst);
       TestExpanded(*mfst);
-      TestMutable(mfst);
-      delete mfst;
+      TestMutable(mfst.get());
     }
   }
 
@@ -343,7 +336,7 @@ class FstTester {
 
   size_t num_states_ = 0;
   bool weighted_ = true;
-  F *testfst_;  // what we're testing
+  std::unique_ptr<F> testfst_;  // what we're testing
 };
 
 }  // namespace fst
index ff5dd4a..06132d8 100644 (file)
@@ -15,9 +15,9 @@
 #ifndef FST_TEST_RAND_FST_H_
 #define FST_TEST_RAND_FST_H_
 
+#include <cstdint>
 #include <random>
 
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/mutable-fst.h>
 #include <fst/verify.h>
@@ -28,7 +28,7 @@ namespace fst {
 template <class Arc, class Generate>
 void RandFst(const int num_random_states, const int num_random_arcs,
              const int num_random_labels, const float acyclic_prob,
-             Generate generate, uint64 seed, MutableFst<Arc> *fst) {
+             Generate generate, uint64_t seed, MutableFst<Arc> *fst) {
   using Label = typename Arc::Label;
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
@@ -96,10 +96,10 @@ void RandFst(const int num_random_states, const int num_random_arcs,
   CHECK(Verify(*fst));
 
   // Get/compute all properties.
-  const uint64 props = fst->Properties(kFstProperties, true);
+  const uint64_t props = fst->Properties(kFstProperties, true);
 
   // Select random set of properties to be unknown.
-  uint64 mask = 0;
+  uint64_t mask = 0;
   for (int n = 0; n < 8; ++n) {
     mask |= std::uniform_int_distribution<>(0, 0xff)(rand);
     mask <<= 8;
index 9255dc0..1695c85 100644 (file)
@@ -31,7 +31,7 @@ namespace fst {
 // This class tests a variety of identities and properties that must
 // hold for the Weight class to be well-defined. It calls function object
 // WEIGHT_GENERATOR to select weights that are used in the tests.
-template <class Weight, class WeightGenerator>
+template <class Weight, class WeightGenerator = WeightGenerate<Weight>>
 class WeightTester {
  public:
   explicit WeightTester(WeightGenerator generator)
index aafd451..45c2561 100644 (file)
 
 #include <algorithm>
 #include <array>
+#include <cstdint>
 #include <functional>
 #include <string>
 #include <vector>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/weight.h>
@@ -90,7 +90,7 @@ class TupleWeight {
   }
 
   size_t Hash() const {
-    uint64 hash = 0;
+    uint64_t hash = 0;
     for (size_t i = 0; i < n; ++i) hash = 5 * hash + values_[i].Hash();
     return size_t(hash);
   }
diff --git a/src/include/fst/types.h b/src/include/fst/types.h
deleted file mode 100644 (file)
index f207cd9..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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.
-//
-// See www.openfst.org for extensive documentation on this weighted
-// finite-state transducer library.
-//
-// Various type definitions (mostly for Google compatibility).
-
-#include <cstdlib>       // for ssize_t.
-#include <cstdint>       // for ?int*_t.
-
-#ifndef FST_LIB_TYPES_H_
-#define FST_LIB_TYPES_H_
-
-using int8 = int8_t;
-using int16 = int16_t;
-using int32 = int32_t;
-using int64 = int64_t;
-
-using uint8 = uint8_t;
-using uint16 = uint16_t;
-using uint32 = uint32_t;
-using uint64 = uint64_t;
-
-#endif  // FST_LIB_TYPES_H_
index cd3f014..078a103 100644 (file)
@@ -21,7 +21,6 @@
 #ifndef FST_UNION_FIND_H_
 #define FST_UNION_FIND_H_
 
-#include <stack>
 #include <vector>
 
 namespace fst {
@@ -41,10 +40,16 @@ class UnionFind {
     if (item >= parent_.size() || item == fail_ || parent_[item] == fail_) {
       return fail_;
     }
-    auto *p = &parent_[item];
-    for (; *p != item; item = *p, p = &parent_[item]) exec_stack_.push(p);
-    for (; !exec_stack_.empty(); exec_stack_.pop()) *exec_stack_.top() = *p;
-    return *p;
+    T root = item;
+    while (root != parent_[root]) {
+      root = parent_[root];
+    }
+    while (item != parent_[item]) {
+      T parent = parent_[item];
+      parent_[item] = root;
+      item = parent;
+    }
+    return root;
   }
 
   // Creates the (destructive) union of the sets x and y belong to.
@@ -69,6 +74,9 @@ class UnionFind {
     for (T item = 0; item < max; ++item) parent_[item] = item;
   }
 
+  // For testing only.
+  const T &Parent(const T &x) const { return parent_[x]; }
+
  private:
   // Links trees rooted in 'x' and 'y'.
   void Link(T x, T y) {
@@ -87,10 +95,9 @@ class UnionFind {
 
   UnionFind &operator=(const UnionFind &) = delete;
 
-  std::vector<T> parent_;       // Parent nodes.
-  std::vector<int> rank_;       // Rank of an element = min. depth in tree.
-  T fail_;                      // Value indicating lookup failure.
-  std::stack<T *> exec_stack_;  // Used for path compression.
+  std::vector<T> parent_;  // Parent nodes.
+  std::vector<int> rank_;  // Rank of an element = min. depth in tree.
+  T fail_;                 // Value indicating lookup failure.
 };
 
 }  // namespace fst
index 9724c1e..b310df2 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef FST_UNION_WEIGHT_H_
 #define FST_UNION_WEIGHT_H_
 
+#include <cstdint>
 #include <iostream>
 #include <list>
 #include <random>
@@ -29,7 +30,6 @@
 #include <string>
 #include <utility>
 
-#include <fst/types.h>
 
 #include <fst/weight.h>
 
@@ -124,7 +124,7 @@ class UnionWeight {
     return *type;
   }
 
-  static constexpr uint64 Properties() {
+  static constexpr uint64_t Properties() {
     return W::Properties() &
            (kLeftSemiring | kRightSemiring | kCommutative | kIdempotent);
   }
@@ -276,7 +276,7 @@ class UnionWeightReverseIterator {
 template <class W, class O>
 inline std::istream &UnionWeight<W, O>::Read(std::istream &istrm) {
   Clear();
-  int32 size;
+  int32_t size;
   ReadType(istrm, &size);
   for (int i = 0; i < size; ++i) {
     W weight;
@@ -288,7 +288,7 @@ inline std::istream &UnionWeight<W, O>::Read(std::istream &istrm) {
 
 template <class W, class O>
 inline std::ostream &UnionWeight<W, O>::Write(std::ostream &ostrm) const {
-  const int32 size = Size();
+  const int32_t size = Size();
   WriteType(ostrm, size);
   for (UnionWeightIterator<W, O> it(*this); !it.Done(); it.Next()) {
     WriteType(ostrm, it.Value());
@@ -491,7 +491,7 @@ class WeightGenerate<UnionWeight<W, O>> {
   using Weight = UnionWeight<W, O>;
   using Generate = WeightGenerate<W>;
 
-  explicit WeightGenerate(uint64 seed = std::random_device()(),
+  explicit WeightGenerate(uint64_t seed = std::random_device()(),
                           bool allow_zero = true,
                           size_t num_random_weights = kNumRandomWeights)
       : rand_(seed),
index 1357035..88414bb 100644 (file)
@@ -24,7 +24,6 @@
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 
 #include <fst/expanded-fst.h>
 #include <fst/mutable-fst.h>
index f808695..df539fd 100644 (file)
@@ -21,6 +21,7 @@
 #define FST_UTIL_H_
 
 #include <array>
+#include <cstdint>
 #include <iostream>
 #include <iterator>
 #include <list>
@@ -35,7 +36,6 @@
 #include <vector>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fstream>
 #include <fst/mapped-file.h>
@@ -50,8 +50,9 @@
 
 DECLARE_bool(fst_error_fatal);
 
-#define FSTERROR() \
-  (FST_FLAGS_fst_error_fatal ? LOG(FATAL) : LOG(ERROR))
+#define FSTERROR()                                                     \
+  LOG(LEVEL(FST_FLAGS_fst_error_fatal ? base_logging::FATAL \
+                                                 : base_logging::ERROR))
 
 namespace fst {
 
@@ -60,29 +61,33 @@ namespace fst {
 // Reads types from an input stream.
 
 // Generic case.
-template <class T,
-          typename std::enable_if<std::is_class<T>::value, T>::type * = nullptr>
+template <class T, typename std::enable_if_t<std::is_class_v<T>, T> * = nullptr>
 inline std::istream &ReadType(std::istream &strm, T *t) {
   return t->Read(strm);
 }
 
 // Numeric (boolean, integral, floating-point) case.
-template <class T, typename std::enable_if<std::is_arithmetic<T>::value,
-                                           T>::type * = nullptr>
+template <class T,
+          typename std::enable_if_t<std::is_arithmetic_v<T>, T> * = nullptr>
 inline std::istream &ReadType(std::istream &strm, T *t) {
   return strm.read(reinterpret_cast<char *>(t), sizeof(T));
 }
 
+// Numeric (boolean, integral, floating-point) case only.
+template <class T>
+inline std::istream &ReadTypeN(std::istream &strm, size_t n, T *t) {
+  static_assert(std::is_arithmetic_v<T>, "Type not supported for batch read.");
+  return strm.read(reinterpret_cast<char *>(t), sizeof(T) * n);
+}
+
 // String case.
 inline std::istream &ReadType(std::istream &strm, std::string *s) {
   s->clear();
-  int32 ns = 0;
+  int32_t ns = 0;
   ReadType(strm, &ns);
-  for (int32 i = 0; i < ns; ++i) {
-    char c;
-    strm.read(&c, 1);
-    *s += c;
-  }
+  if (ns <= 0) return strm;
+  s->resize(ns);
+  ReadTypeN(strm, ns, s->data());
   return strm;
 }
 
@@ -119,29 +124,53 @@ namespace internal {
 template <class C, class ReserveFn>
 std::istream &ReadContainerType(std::istream &strm, C *c, ReserveFn reserve) {
   c->clear();
-  int64 n = 0;
+  int64_t n = 0;
   ReadType(strm, &n);
   reserve(c, n);
   auto insert = std::inserter(*c, c->begin());
-  for (int64 i = 0; i < n; ++i) {
+  for (int64_t i = 0; i < n; ++i) {
     typename C::value_type value;
     ReadType(strm, &value);
     *insert = value;
   }
   return strm;
 }
+
+// Generic vector case.
+template <typename T, class A,
+          typename std::enable_if_t<std::is_class_v<T>, T> * = nullptr>
+inline std::istream &ReadVectorType(std::istream &strm, std::vector<T, A> *c) {
+  return internal::ReadContainerType(
+      strm, c, [](decltype(c) v, int n) { v->reserve(n); });
+}
+
+// Vector of numerics (boolean, integral, floating-point, char) case.
+template <typename T, class A,
+          typename std::enable_if_t<std::is_arithmetic_v<T>, T> * = nullptr>
+inline std::istream &ReadVectorType(std::istream &strm, std::vector<T, A> *c) {
+  c->clear();
+  int64_t n = 0;
+  ReadType(strm, &n);
+  if (n == 0) return strm;
+  c->resize(n);
+  ReadTypeN(strm, n, c->data());
+  return strm;
+}
 }  // namespace internal
 
 template <class T, size_t N>
 std::istream &ReadType(std::istream &strm, std::array<T, N> *c) {
-  for (auto &v : *c) ReadType(strm, &v);
+  if (std::is_arithmetic_v<T>) {
+    ReadTypeN(strm, c->size(), c->data());
+  } else {
+    for (auto &v : *c) ReadType(strm, &v);
+  }
   return strm;
 }
 
 template <class... T>
 std::istream &ReadType(std::istream &strm, std::vector<T...> *c) {
-  return internal::ReadContainerType(
-      strm, c, [](decltype(c) v, int n) { v->reserve(n); });
+  return internal::ReadVectorType(strm, c);
 }
 
 template <class... T>
@@ -174,23 +203,25 @@ std::istream &ReadType(std::istream &strm, std::unordered_map<T...> *c) {
 // Writes types to an output stream.
 
 // Generic case.
-template <class T,
-          typename std::enable_if<std::is_class<T>::value, T>::type * = nullptr>
+template <class T, typename std::enable_if<
+                       std::is_class<T>::value &&
+                           // `string_view` is handled separately below.
+                           !std::is_convertible<T, std::string_view>::value,
+                       T>::type * = nullptr>
 inline std::ostream &WriteType(std::ostream &strm, const T t) {
   t.Write(strm);
   return strm;
 }
 
 // Numeric (boolean, integral, floating-point) case.
-template <class T, typename std::enable_if<std::is_arithmetic<T>::value,
-                                           T>::type * = nullptr>
+template <class T,
+          typename std::enable_if_t<std::is_arithmetic_v<T>, T> * = nullptr>
 inline std::ostream &WriteType(std::ostream &strm, const T t) {
   return strm.write(reinterpret_cast<const char *>(&t), sizeof(T));
 }
 
-// String case.
-inline std::ostream &WriteType(std::ostream &strm, const std::string &s) {
-  int32 ns = s.size();
+inline std::ostream &WriteType(std::ostream &strm, std::string_view s) {
+  int32_t ns = s.size();
   WriteType(strm, ns);
   return strm.write(s.data(), ns);
 }
@@ -235,7 +266,7 @@ std::ostream &WriteSequence(std::ostream &strm, const C &c) {
 
 template <class C>
 std::ostream &WriteContainer(std::ostream &strm, const C &c) {
-  const int64 n = c.size();
+  const int64_t n = c.size();
   WriteType(strm, n);
   WriteSequence(strm, c);
   return strm;
@@ -277,15 +308,16 @@ std::ostream &WriteType(std::ostream &strm, const std::unordered_set<T...> &c) {
   return internal::WriteContainer(strm, c);
 }
 
-// Utilities for converting between int64 or Weight and string.
+// Utilities for converting between int64_t or Weight and string.
 
-// Parses a 64-bit signed integer out of an input string. Returns a value iff
-// the entirety of the string is consumed during integer parsing, otherwise
-// returning `std::nullopt`.
-std::optional<int64> ParseInt64(std::string_view s);
+// Parses a 64-bit signed integer in some base out of an input string. The
+// string should consist only of digits (no prefixes such as "0x") and an
+// optionally preceding minus. Returns a value iff the entirety of the string is
+// consumed during integer parsing, otherwise returns `std::nullopt`.
+std::optional<int64_t> ParseInt64(std::string_view s, int base = 10);
 
-int64 StrToInt64(std::string_view s, std::string_view source, size_t nline,
-                 bool allow_negative, bool *error = nullptr);
+int64_t StrToInt64(std::string_view s, std::string_view source, size_t nline,
+                   bool allow_negative, bool *error = nullptr);
 
 template <typename Weight>
 Weight StrToWeight(std::string_view s) {
@@ -300,21 +332,15 @@ Weight StrToWeight(std::string_view s) {
 }
 
 template <typename Weight>
-void WeightToStr(Weight w, std::string *s) {
+std::string WeightToStr(Weight w) {
   std::ostringstream strm;
   strm.precision(9);
   strm << w;
-  s->append(strm.str().data(), strm.str().size());
+  return strm.str();
 }
 
 // Utilities for reading/writing integer pairs (typically labels).
 
-// Splits `line` on any of the chars in `delim`, dropping empty spans if
-// `omit_empty_strings` is true.
-std::vector<std::string_view> SplitString(std::string_view line,
-                                           std::string_view delim,
-                                           bool omit_empty_strings);
-
 template <typename I>
 bool ReadIntPairs(const std::string &source,
                   std::vector<std::pair<I, I>> *pairs,
@@ -330,7 +356,8 @@ bool ReadIntPairs(const std::string &source,
   pairs->clear();
   while (strm.getline(line, kLineLen)) {
     ++nline;
-    std::vector<std::string_view> col = SplitString(line, "\n\t ", true);
+    std::vector<std::string_view> col =
+        StrSplit(line, ByAnyChar("\n\t "), SkipEmpty());
     // empty line or comment?
     if (col.empty() || col[0].empty() || col[0][0] == '#') continue;
     if (col.size() != 2) {
index 7316091..1be840f 100644 (file)
 
 #include <algorithm>
 #include <atomic>
+#include <cstdint>
+#include <memory>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/fst-decl.h>  // For optional argument declarations
@@ -50,8 +51,8 @@ class VectorState {
   using StateId = typename Arc::StateId;
   using Weight = typename Arc::Weight;
   using ArcAllocator = M;
-  using StateAllocator =
-      typename ArcAllocator::template rebind<VectorState<Arc, M>>::other;
+  using StateAllocator = typename std::allocator_traits<
+      ArcAllocator>::template rebind_alloc<VectorState<Arc, M>>;
 
   // Provide STL allocator for arcs.
   explicit VectorState(const ArcAllocator &alloc)
@@ -425,7 +426,7 @@ class VectorFstImpl : public VectorFstBaseImpl<S> {
   }
 
   // Properties always true of this FST class
-  static constexpr uint64 kStaticProperties = kExpanded | kMutable;
+  static constexpr uint64_t kStaticProperties = kExpanded | kMutable;
 
  private:
   void UpdatePropertiesAfterAddArc(StateId state) {
@@ -444,12 +445,6 @@ class VectorFstImpl : public VectorFstBaseImpl<S> {
 };
 
 template <class S>
-constexpr uint64 VectorFstImpl<S>::kStaticProperties;
-
-template <class S>
-constexpr int VectorFstImpl<S>::kMinFileVersion;
-
-template <class S>
 VectorFstImpl<S>::VectorFstImpl(const Fst<Arc> &fst) {
   SetType("vector");
   SetInputSymbols(fst.InputSymbols());
@@ -486,14 +481,14 @@ VectorFstImpl<S> *VectorFstImpl<S>::Read(std::istream &strm,
     impl->BaseImpl::AddState();
     auto *vstate = impl->GetState(state);
     vstate->SetFinal(weight);
-    int64 narcs;
+    int64_t narcs;
     ReadType(strm, &narcs);
     if (!strm) {
       LOG(ERROR) << "VectorFst::Read: Read failed: " << opts.source;
       return nullptr;
     }
     impl->ReserveArcs(state, narcs);
-    for (int64 i = 0; i < narcs; ++i) {
+    for (int64_t i = 0; i < narcs; ++i) {
       Arc arc;
       ReadType(strm, &arc.ilabel);
       ReadType(strm, &arc.olabel);
@@ -648,7 +643,7 @@ bool VectorFst<Arc, State>::WriteFst(const FST &fst, std::ostream &strm,
   for (StateIterator<FST> siter(fst); !siter.Done(); siter.Next()) {
     const auto s = siter.Value();
     fst.Final(s).Write(strm);
-    const int64 narcs = fst.NumArcs(s);
+    const int64_t narcs = fst.NumArcs(s);
     WriteType(strm, narcs);
     for (ArcIterator<FST> aiter(fst, s); !aiter.Done(); aiter.Next()) {
       const auto &arc = aiter.Value();
@@ -725,9 +720,9 @@ class ArcIterator<VectorFst<Arc, State>> {
 
   size_t Position() const { return i_; }
 
-  constexpr uint8 Flags() const { return kArcValueFlags; }
+  constexpr uint8_t Flags() const { return kArcValueFlags; }
 
-  void SetFlags(uint8, uint8) {}
+  void SetFlags(uint8_t, uint8_t) {}
 
  private:
   const Arc *arcs_;
@@ -764,7 +759,7 @@ class MutableArcIterator<VectorFst<Arc, State>>
 
   void SetValue(const Arc &arc) final {
     const auto &oarc = state_->GetArc(i_);
-    uint64 properties = properties_->load(std::memory_order_relaxed);
+    uint64_t properties = properties_->load(std::memory_order_relaxed);
     if (oarc.ilabel != oarc.olabel) properties &= ~kNotAcceptor;
     if (oarc.ilabel == 0) {
       properties &= ~kIEpsilons;
@@ -801,13 +796,13 @@ class MutableArcIterator<VectorFst<Arc, State>>
     properties_->store(properties, std::memory_order_relaxed);
   }
 
-  uint8 Flags() const final { return kArcValueFlags; }
+  uint8_t Flags() const final { return kArcValueFlags; }
 
-  void SetFlags(uint8, uint8) final {}
+  void SetFlags(uint8_t, uint8_t) final {}
 
  private:
   State *state_;
-  std::atomic<uint64> *properties_;
+  std::atomic<uint64_t> *properties_;
   size_t i_;
 };
 
index d4a7112..416d523 100644 (file)
@@ -20,7 +20,8 @@
 #ifndef FST_VERIFY_H_
 #define FST_VERIFY_H_
 
-#include <fst/types.h>
+#include <cstdint>
+
 #include <fst/log.h>
 
 #include <fst/fst.h>
@@ -95,8 +96,8 @@ bool Verify(const Fst<Arc> &fst, bool allow_negative_labels = false) {
     LOG(ERROR) << "Verify: FST error property is set";
     return false;
   }
-  uint64 known_props;
-  uint64 test_props =
+  uint64_t known_props;
+  uint64_t test_props =
       internal::ComputeProperties(fst, kFstProperties, &known_props);
   if (!internal::CompatProperties(fst_props, test_props)) {
     LOG(ERROR) << "Verify: Stored FST properties incorrect "
index 5c1911d..ad86b6e 100644 (file)
@@ -21,6 +21,8 @@
 #define FST_VISIT_H_
 
 
+#include <cstdint>
+
 #include <fst/arcfilter.h>
 #include <fst/mutable-fst.h>
 
@@ -80,12 +82,12 @@ void Visit(const FST &fst, Visitor *visitor, Queue *queue, ArcFilter filter,
     return;
   }
   // An FST's state's visit color.
-  static constexpr uint8 kWhiteState = 0x01;  // Undiscovered.
-  static constexpr uint8 kGreyState = 0x02;   // Discovered & unfinished.
-  static constexpr uint8 kBlackState = 0x04;  // Finished.
+  static constexpr uint8_t kWhiteState = 0x01;  // Undiscovered.
+  static constexpr uint8_t kGreyState = 0x02;   // Discovered & unfinished.
+  static constexpr uint8_t kBlackState = 0x04;  // Finished.
   // We destroy an iterator as soon as possible and mark it so.
-  static constexpr uint8 kArcIterDone = 0x08;
-  std::vector<uint8> state_status;
+  static constexpr uint8_t kArcIterDone = 0x08;
+  std::vector<uint8_t> state_status;
   std::vector<ArcIterator<FST> *> arc_iterator;
   MemoryPool<ArcIterator<FST>> aiter_pool;
   StateId nstates = start + 1;  // Number of known states in general case.
index a780ea3..a56868c 100644 (file)
 
 #include <cctype>
 #include <cmath>
+#include <cstdint>
 #include <iostream>
 #include <sstream>
 #include <type_traits>
 #include <utility>
 
 #include <fst/compat.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fst/util.h>
@@ -127,37 +127,36 @@ namespace fst {
 // CONSTANT DEFINITIONS
 
 // A representable float near .001.
-constexpr float kDelta = 1.0F / 1024.0F;
+inline constexpr float kDelta = 1.0F / 1024.0F;
 
 // For all a, b, c: Times(c, Plus(a, b)) = Plus(Times(c, a), Times(c, b)).
-constexpr uint64 kLeftSemiring = 0x0000000000000001ULL;
+inline constexpr uint64_t kLeftSemiring = 0x0000000000000001ULL;
 
 // For all a, b, c: Times(Plus(a, b), c) = Plus(Times(a, c), Times(b, c)).
-constexpr uint64 kRightSemiring = 0x0000000000000002ULL;
+inline constexpr uint64_t kRightSemiring = 0x0000000000000002ULL;
 
-constexpr uint64 kSemiring = kLeftSemiring | kRightSemiring;
+inline constexpr uint64_t kSemiring = kLeftSemiring | kRightSemiring;
 
 // For all a, b: Times(a, b) = Times(b, a).
-constexpr uint64 kCommutative = 0x0000000000000004ULL;
+inline constexpr uint64_t kCommutative = 0x0000000000000004ULL;
 
 // For all a: Plus(a, a) = a.
-constexpr uint64 kIdempotent = 0x0000000000000008ULL;
+inline constexpr uint64_t kIdempotent = 0x0000000000000008ULL;
 
 // For all a, b: Plus(a, b) = a or Plus(a, b) = b.
-constexpr uint64 kPath = 0x0000000000000010ULL;
+inline constexpr uint64_t kPath = 0x0000000000000010ULL;
 
 // For random weight generation: default number of distinct weights.
 // This is also used for a few other weight generation defaults.
-constexpr size_t kNumRandomWeights = 5;
+inline constexpr size_t kNumRandomWeights = 5;
 
 // Weight property boolean constants needed for SFINAE.
 
 template <class W>
-using IsIdempotent =
-    std::integral_constant<bool, (W::Properties() & kIdempotent) != 0>;
+using IsIdempotent = std::bool_constant<(W::Properties() & kIdempotent) != 0>;
 
 template <class W>
-using IsPath = std::integral_constant<bool, (W::Properties() & kPath) != 0>;
+using IsPath = std::bool_constant<(W::Properties() & kPath) != 0>;
 
 // Determines direction of division.
 enum DivideType {
@@ -251,7 +250,7 @@ struct WeightConvert<W, W> {
 //
 // class WeightGenerate<MyWeight> {
 //  public:
-//   explicit WeightGenerate(uint64 seed = std::random_device()(),
+//   explicit WeightGenerate(uint64_t seed = std::random_device()(),
 //                           bool allow_zero = true,
 //                           ...);
 //
index 43f789a..272e360 100644 (file)
@@ -4,5 +4,5 @@ lib_LTLIBRARIES = libfst.la
 libfst_la_SOURCES = compat.cc encode.cc flags.cc fst.cc fst-types.cc \
                     mapped-file.cc properties.cc symbol-table.cc \
                     symbol-table-ops.cc weight.cc util.cc
-libfst_la_LDFLAGS = -version-info 24:0:0
+libfst_la_LDFLAGS = -version-info 25:0:0
 libfst_la_LIBADD = $(DL_LIBS)
index 9ec8113..76e9ed7 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -98,8 +98,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -208,8 +207,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -223,8 +220,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -240,6 +238,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -355,7 +354,7 @@ libfst_la_SOURCES = compat.cc encode.cc flags.cc fst.cc fst-types.cc \
                     mapped-file.cc properties.cc symbol-table.cc \
                     symbol-table-ops.cc weight.cc util.cc
 
-libfst_la_LDFLAGS = -version-info 24:0:0
+libfst_la_LDFLAGS = -version-info 25:0:0
 libfst_la_LIBADD = $(DL_LIBS)
 all: all-am
 
@@ -534,7 +533,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 6695b2c..b7ea5ff 100644 (file)
@@ -1,11 +1,13 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Copyright 2005-2020 Google LLC
+//
+// 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
+//     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,
+// 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.
 #include <fst/compat.h>
 
 #include <algorithm>
-#include <cstdlib>
 #include <iostream>
-#include <numeric>
+#include <ostream>
+#include <string>
+#include <string_view>
+#include <vector>
 
 void FailedNewHandler() {
   std::cerr << "Memory allocation failed" << std::endl;
@@ -35,102 +39,76 @@ void CheckSummer::Reset() {
   for (int i = 0; i < kCheckSumLength; ++i) check_sum_[i] = '\0';
 }
 
-void CheckSummer::Update(void const *data, int size) {
-  const char *p = reinterpret_cast<const char *>(data);
-  for (int i = 0; i < size; ++i) {
-    check_sum_[(count_++) % kCheckSumLength] ^= p[i];
-  }
-}
-
-void CheckSummer::Update(std::string const &data) {
+void CheckSummer::Update(std::string_view data) {
   for (int i = 0; i < data.size(); ++i) {
     check_sum_[(count_++) % kCheckSumLength] ^= data[i];
   }
 }
 
-// String joining and splitting.
-
-namespace {
-
-// Computes size of joined string.
-size_t GetResultSize(const std::vector<std::string> &elements, size_t s_size) {
-  const auto lambda = [](size_t partial, const std::string &right) {
-    return partial + right.size();
-  };
-  return (std::accumulate(elements.begin(), elements.end(), 0, lambda) +
-          s_size * (elements.size() - 1));
+namespace internal {
+
+std::vector<std::string_view> StringSplitter::SplitToSv() {
+  std::vector<std::string_view> vec;
+  if (delim_.empty()) {
+    if (string_.empty() && !skip_empty_) {
+      vec.push_back("");
+    } else {
+      // If empty delimiter, then simply return every character separately as a
+      // single-character string_view.
+      vec.reserve(string_.size());
+      for (int i = 0; i < string_.size(); ++i) {
+        vec.push_back(string_.substr(i, 1));
+      }
+    }
+    return vec;
+  }
+  size_t prev_pos = 0, pos = 0;
+  while (pos <= string_.length()) {
+    pos = string_.find_first_of(delim_, pos);
+    if (pos == std::string_view::npos) {
+      pos = string_.length();
+    }
+    if (!skip_empty_ || pos != prev_pos) {
+      vec.push_back(string_.substr(prev_pos, pos - prev_pos));
+    }
+    prev_pos = ++pos;
+  }
+  return vec;
 }
 
-}  // namespace
+}  // namespace internal
 
-// Joins a vector of strings on a given delimiter.
-
-std::string StringJoin(const std::vector<std::string> &elements,
-                       const std::string &delim) {
-  std::string result;
-  if (elements.empty()) return result;
-  size_t s_size = delim.size();
-  result.reserve(GetResultSize(elements, s_size));
-  auto it = elements.begin();
-  result.append(it->data(), it->size());
-  for (++it; it != elements.end(); ++it) {
-    result.append(delim.data(), s_size);
-    result.append(it->data(), it->size());
-  }
-  return result;
+internal::StringSplitter StrSplit(std::string_view full, ByAnyChar delim) {
+  return internal::StringSplitter(full, std::move(delim).delimiters);
 }
 
-std::string StringJoin(const std::vector<std::string> &elements,
-                       const char *delim) {
-  const std::string str_delim(delim);
-  return StringJoin(elements, str_delim);
+internal::StringSplitter StrSplit(std::string_view full, char delim) {
+  return StrSplit(full, ByAnyChar(std::string_view(&delim, 1)));
 }
 
-std::string StringJoin(const std::vector<std::string> &elements, char delim) {
-  const std::string str_delim{delim};
-  return StringJoin(elements, str_delim);
+internal::StringSplitter StrSplit(std::string_view full, ByAnyChar delim,
+                                  SkipEmpty) {
+  return internal::StringSplitter(full, std::move(delim).delimiters,
+                                  /*skip_empty=*/true);
 }
 
-// Splits a string according to delimiter, skipping over consecutive
-// delimiters.
-
-std::vector<std::string> StringSplit(const std::string &full,
-                                     const std::string &delim) {
-  size_t prev = 0;
-  size_t found = full.find_first_of(delim);
-  size_t size = found - prev;
-  std::vector<std::string> result;
-  if (size > 0) result.push_back(full.substr(prev, size));
-  while (found != std::string::npos) {
-    prev = found + 1;
-    found = full.find_first_of(delim, prev);
-    size = found - prev;
-    if (size > 0) result.push_back(full.substr(prev, size));
-  }
-  return result;
+internal::StringSplitter StrSplit(std::string_view full, char delim,
+                                  SkipEmpty) {
+  return StrSplit(full, ByAnyChar(std::string_view(&delim, 1)), SkipEmpty());
 }
 
-std::vector<std::string> StringSplit(const std::string &full,
-                                     const char *delim) {
-  const std::string str_delim(delim);
-  return StringSplit(full, str_delim);
-}
+namespace {
+bool IsAsciiSpace(unsigned char ch) { return std::isspace(ch); }
+}  // namespace
 
-std::vector<std::string> StringSplit(const std::string &full, char delim) {
-  const std::string str_delim{delim};
-  return StringSplit(full, str_delim);
+std::string_view StripTrailingAsciiWhitespace(std::string_view full) {
+  auto it = std::find_if_not(full.rbegin(), full.rend(), IsAsciiSpace);
+  return full.substr(0, full.rend() - it);
 }
 
 void StripTrailingAsciiWhitespace(std::string *full) {
-  const auto lambda = [](char ch) { return !std::isspace(ch); };
-  const auto pos = std::find_if(full->rbegin(), full->rend(), lambda).base();
-  full->erase(pos, full->end());
-}
-
-std::string StripTrailingAsciiWhitespace(const std::string &full) {
-  std::string copy(full);
-  StripTrailingAsciiWhitespace(&copy);
-  return copy;
+  auto it = std::find_if_not(full->rbegin(), full->rend(), IsAsciiSpace);
+  full->erase(full->rend() - it);
 }
 
 }  // namespace fst
index 61a4509..143045e 100644 (file)
 
 #include <fst/encode.h>
 
+#include <cstdint>
+
 namespace fst {
 
 bool EncodeTableHeader::Read(std::istream &strm, const std::string &source) {
-  int32 magic_number;
+  int32_t magic_number;
   ReadType(strm, &magic_number);
-  if (magic_number == internal::kEncodeMagicNumber) {
-    ReadType(strm, &arctype_);
-    ReadType(strm, &flags_);
-    ReadType(strm, &size_);
-  } else if (magic_number == internal::kEncodeDeprecatedMagicNumber) {
-    // TODO(b/141172858): deprecated, remove by 2020-01-01.
-    uint32 flags;
-    ReadType(strm, &flags);
-    flags_ = flags;
-    int64 size;
-    ReadType(strm, &size);
-    size_ = size;
-  } else {
-    LOG(ERROR) << "EncodeTableHeader::Read: Bad encode table header: "
-               << source;
+  if (magic_number != internal::kEncodeMagicNumber) {
+    LOG(ERROR) << "EncodeTableHeader::Read: Bad encode table header: " << source
+               << ". Magic number not matched. Got: " << magic_number;
     return false;
   }
+  ReadType(strm, &arctype_);
+  ReadType(strm, &flags_);
+  ReadType(strm, &size_);
   if (!strm) {
     LOG(ERROR) << "EncodeTableHeader::Read: Read failed: " << source;
     return false;
index 4bf97a3..054f425 100644 (file)
@@ -1,22 +1,31 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Copyright 2005-2020 Google LLC
+//
+// 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
+//     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,
+// 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.
 //
 // Google-style flag handling definitions.
 
+#include <fst/flags.h>
+
+#include <cstdint>
 #include <cstring>
+#include <iostream>
+#include <ostream>
+#include <set>
 #include <string>
+#include <string_view>
+#include <utility>
 
-#include <fst/compat.h>
-#include <fst/flags.h>
+#include <fst/log.h>
 
 static const char *private_tmpdir = getenv("TMPDIR");
 
@@ -35,10 +44,12 @@ static void SetProgSrc(const char *src) {
   // Remove "-main" in src filename. Flags are defined in fstx.cc but SetFlags()
   // is called in fstx-main.cc, which results in a filename mismatch in
   // ShowUsageRestrict() below.
-  static constexpr char kMainSuffix[] = "-main.cc";
-  const int prefix_length = prog_src.size() - strlen(kMainSuffix);
-  if (prefix_length > 0 && prog_src.substr(prefix_length) == kMainSuffix) {
-    prog_src.erase(prefix_length, strlen("-main"));
+  static constexpr std::string_view kMainSuffix = "-main.cc";
+  const int prefix_length = prog_src.size() - kMainSuffix.size();
+  if (prefix_length > 0 &&
+      std::string_view(prog_src).substr(prefix_length) == kMainSuffix) {
+    static constexpr size_t kDashMainSize = std::string_view("-main").size();
+    prog_src.erase(prefix_length, kDashMainSize);
   }
 }
 
@@ -49,13 +60,13 @@ void SetFlags(const char *usage, int *argc, char ***argv,
 
   int index = 1;
   for (; index < *argc; ++index) {
-    std::string argval = (*argv)[index];
+    std::string_view argval = (*argv)[index];
     if (argval[0] != '-' || argval == "-") break;
-    while (argval[0] == '-') argval = argval.substr(1);  // Removes initial '-'.
-    std::string arg = argval;
-    std::string val = "";
+    while (argval[0] == '-') argval.remove_prefix(1);  // Removes initial '-'.
+    std::string arg(argval);
+    std::string val("");
     // Splits argval (arg=val) into arg and val.
-    auto pos = argval.find("=");
+    auto pos = argval.find('=');
     if (pos != std::string::npos) {
       arg = argval.substr(0, pos);
       val = argval.substr(pos + 1);
@@ -65,11 +76,11 @@ void SetFlags(const char *usage, int *argc, char ***argv,
       continue;
     auto string_register = FlagRegister<std::string>::GetRegister();
     if (string_register->SetFlag(arg, val)) continue;
-    auto int32_register = FlagRegister<int32>::GetRegister();
+    auto int32_register = FlagRegister<int32_t>::GetRegister();
     if (int32_register->SetFlag(arg, val)) continue;
-    auto int64_register = FlagRegister<int64>::GetRegister();
+    auto int64_register = FlagRegister<int64_t>::GetRegister();
     if (int64_register->SetFlag(arg, val)) continue;
-    auto uint64_register = FlagRegister<uint64>::GetRegister();
+    auto uint64_register = FlagRegister<uint64_t>::GetRegister();
     if (uint64_register->SetFlag(arg, val)) continue;
     auto double_register = FlagRegister<double>::GetRegister();
     if (double_register->SetFlag(arg, val)) continue;
@@ -106,39 +117,35 @@ static void ShowUsageRestrict(
     if ((match && !in_src) || (!match && in_src)) continue;
     if (file != old_file) {
       if (show_file) {
-        if (file_out) std::cout << std::endl;;
+        if (file_out) std::cout << std::endl;
         std::cout << "Flags from: " << file << std::endl;
         file_out = true;
       }
       old_file = file;
     }
     std::cout << usage << std::endl;
-    ;
     usage_out = true;
   }
   if (usage_out) std::cout << std::endl;
-  ;
 }
 
 void ShowUsage(bool long_usage) {
   std::set<std::pair<std::string, std::string>> usage_set;
   std::cout << flag_usage << std::endl;
-  ;
   auto bool_register = FlagRegister<bool>::GetRegister();
   bool_register->GetUsage(&usage_set);
   auto string_register = FlagRegister<std::string>::GetRegister();
   string_register->GetUsage(&usage_set);
-  auto int32_register = FlagRegister<int32>::GetRegister();
+  auto int32_register = FlagRegister<int32_t>::GetRegister();
   int32_register->GetUsage(&usage_set);
-  auto int64_register = FlagRegister<int64>::GetRegister();
+  auto int64_register = FlagRegister<int64_t>::GetRegister();
   int64_register->GetUsage(&usage_set);
-  auto uint64_register = FlagRegister<uint64>::GetRegister();
+  auto uint64_register = FlagRegister<uint64_t>::GetRegister();
   uint64_register->GetUsage(&usage_set);
   auto double_register = FlagRegister<double>::GetRegister();
   double_register->GetUsage(&usage_set);
   if (!prog_src.empty()) {
     std::cout << "PROGRAM FLAGS:" << std::endl << std::endl;
-    ;
     ShowUsageRestrict(usage_set, prog_src, true, false);
   }
   if (!long_usage) return;
index 178fcf8..9c5f165 100644 (file)
 
 #include <fst/fst.h>
 
+#include <cstdint>
 #include <sstream>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
-#include <fst/matcher-fst.h>  // declarations of *_lookahead_fst_type
 
 // FST flag definitions.
 
@@ -46,18 +45,13 @@ DEFINE_string(fst_read_mode, "read",
 
 namespace fst {
 
-// FST type definitions for lookahead FSTs.
-const char arc_lookahead_fst_type[] = "arc_lookahead";
-const char ilabel_lookahead_fst_type[] = "ilabel_lookahead";
-const char olabel_lookahead_fst_type[] = "olabel_lookahead";
-
 // Checks FST magic number and reads in the header; if rewind = true,
 // the stream is repositioned before call if possible.
 bool FstHeader::Read(std::istream &strm, const std::string &source,
                      bool rewind) {
-  int64 pos = 0;
+  int64_t pos = 0;
   if (rewind) pos = strm.tellg();
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
   if (magic_number != kFstMagicNumber) {
     LOG(ERROR) << "FstHeader::Read: Bad FST header: " << source
@@ -121,16 +115,9 @@ FstReadOptions::FstReadOptions(const std::string_view source,
 FstReadOptions::FstReadOptions(const std::string_view source,
                                const SymbolTable *isymbols,
                                const SymbolTable *osymbols)
-    : source(source),
-      header(nullptr),
-      isymbols(isymbols),
-      osymbols(osymbols),
-      read_isymbols(true),
-      read_osymbols(true) {
-  mode = ReadMode(FST_FLAGS_fst_read_mode);
-}
+    : FstReadOptions(source, /*header=*/nullptr, isymbols, osymbols) {}
 
-FstReadOptions::FileReadMode FstReadOptions::ReadMode(const std::string &mode) {
+FstReadOptions::FileReadMode FstReadOptions::ReadMode(std::string_view mode) {
   if (mode == "read") return READ;
   if (mode == "map") return MAP;
   LOG(ERROR) << "Unknown file read mode " << mode;
index de56cb6..f855422 100644 (file)
@@ -145,18 +145,23 @@ MappedFile *MappedFile::MapFromFileDescriptor(int fd, size_t pos, size_t size) {
     LOG(ERROR) << "Invalid file descriptor fd=" << fd;
     return nullptr;
   }
+  const DWORD max_size_hi =
+      sizeof(size_t) > sizeof(DWORD) ? upsize >> (CHAR_BIT * sizeof(DWORD)) : 0;
+  const DWORD max_size_lo = upsize & DWORD_MAX;
   HANDLE file_mapping = CreateFileMappingA(file, nullptr, PAGE_READONLY,
-                                           upsize >> (8 * sizeof(DWORD)),
-                                           upsize & DWORD_MAX, nullptr);
+                                           max_size_hi, max_size_lo, nullptr);
   if (file_mapping == INVALID_HANDLE_VALUE) {
     LOG(ERROR) << "Can't create mapping for fd=" << fd << " size=" << upsize
                << ": " << GetLastError();
     return nullptr;
   }
 
+  const DWORD offset_pos_hi =
+      sizeof(size_t) > sizeof(DWORD) ? offset_pos >> (CHAR_BIT * sizeof(DWORD))
+                                     : 0;
+  const DWORD offset_pos_lo = offset_pos & DWORD_MAX;
   void *map = MapViewOfFile(file_mapping, FILE_MAP_READ,
-                            offset_pos >> (8 * sizeof(DWORD)),
-                            offset_pos & DWORD_MAX, upsize);
+                            offset_pos_hi, offset_pos_lo, upsize);
   if (!map) {
     LOG(ERROR) << "mmap failed for fd=" << fd << " size=" << upsize
                << " offset=" << offset_pos << ": " << GetLastError();
@@ -208,8 +213,4 @@ MappedFile *MappedFile::Borrow(void *data) {
   return new MappedFile(region);
 }
 
-constexpr size_t MappedFile::kArchAlignment;
-
-constexpr size_t MappedFile::kMaxReadChunk;
-
 }  // namespace fst
index e486918..07460d2 100644 (file)
 #include <fst/properties.h>
 
 #include <cstddef>
+#include <cstdint>
 #include <string>
 #include <vector>
 
-#include <fst/types.h>
+#include <string_view>
 
 namespace fst {
 
@@ -35,7 +36,7 @@ namespace fst {
 // the case when a new (possibly delayed) FST is instead constructed.
 
 // Properties for a concatenatively-closed FST.
-uint64 ClosureProperties(uint64 inprops, bool, bool delayed) {
+uint64_t ClosureProperties(uint64_t inprops, bool, bool delayed) {
   auto outprops = (kError | kAcceptor | kUnweighted | kAccessible) & inprops;
   if (inprops & kUnweighted) outprops |= kUnweightedCycles;
   if (!delayed) {
@@ -57,7 +58,7 @@ uint64 ClosureProperties(uint64 inprops, bool, bool delayed) {
 }
 
 // Properties for a complemented FST.
-uint64 ComplementProperties(uint64 inprops) {
+uint64_t ComplementProperties(uint64_t inprops) {
   auto outprops = kAcceptor | kUnweighted | kUnweightedCycles | kNoEpsilons |
                   kNoIEpsilons | kNoOEpsilons | kIDeterministic |
                   kODeterministic | kAccessible;
@@ -70,7 +71,7 @@ uint64 ComplementProperties(uint64 inprops) {
 }
 
 // Properties for a composed FST.
-uint64 ComposeProperties(uint64 inprops1, uint64 inprops2) {
+uint64_t ComposeProperties(uint64_t inprops1, uint64_t inprops2) {
   auto outprops = kError & (inprops1 | inprops2);
   if (inprops1 & kAcceptor && inprops2 & kAcceptor) {
     outprops |= kAcceptor | kAccessible;
@@ -92,7 +93,7 @@ uint64 ComposeProperties(uint64 inprops1, uint64 inprops2) {
 }
 
 // Properties for a concatenated FST.
-uint64 ConcatProperties(uint64 inprops1, uint64 inprops2, bool delayed) {
+uint64_t ConcatProperties(uint64_t inprops1, uint64_t inprops2, bool delayed) {
   auto outprops = (kAcceptor | kUnweighted | kUnweightedCycles | kAcyclic) &
                   inprops1 & inprops2;
   outprops |= kError & (inprops1 | inprops2);
@@ -127,8 +128,8 @@ uint64 ConcatProperties(uint64 inprops1, uint64 inprops2, bool delayed) {
 }
 
 // Properties for a determinized FST.
-uint64 DeterminizeProperties(uint64 inprops, bool has_subsequential_label,
-                             bool distinct_psubsequential_labels) {
+uint64_t DeterminizeProperties(uint64_t inprops, bool has_subsequential_label,
+                               bool distinct_psubsequential_labels) {
   auto outprops = kAccessible;
   if ((kAcceptor & inprops) ||
       ((kNoIEpsilons & inprops) && distinct_psubsequential_labels) ||
@@ -152,7 +153,7 @@ uint64 DeterminizeProperties(uint64 inprops, bool has_subsequential_label,
 }
 
 // Properties for factored weight FST.
-uint64 FactorWeightProperties(uint64 inprops) {
+uint64_t FactorWeightProperties(uint64_t inprops) {
   auto outprops = (kExpanded | kMutable | kError | kAcceptor | kAcyclic |
                    kAccessible | kCoAccessible) &
                   inprops;
@@ -166,7 +167,7 @@ uint64 FactorWeightProperties(uint64 inprops) {
 }
 
 // Properties for an inverted FST.
-uint64 InvertProperties(uint64 inprops) {
+uint64_t InvertProperties(uint64_t inprops) {
   auto outprops = (kExpanded | kMutable | kError | kAcceptor | kNotAcceptor |
                    kEpsilons | kNoEpsilons | kWeighted | kUnweighted |
                    kWeightedCycles | kUnweightedCycles | kCyclic | kAcyclic |
@@ -192,7 +193,7 @@ uint64 InvertProperties(uint64 inprops) {
 }
 
 // Properties for a projected FST.
-uint64 ProjectProperties(uint64 inprops, bool project_input) {
+uint64_t ProjectProperties(uint64_t inprops, bool project_input) {
   auto outprops = kAcceptor;
   outprops |= (kExpanded | kMutable | kError | kWeighted | kUnweighted |
                kWeightedCycles | kUnweightedCycles | kCyclic | kAcyclic |
@@ -231,7 +232,7 @@ uint64 ProjectProperties(uint64 inprops, bool project_input) {
 }
 
 // Properties for a randgen FST.
-uint64 RandGenProperties(uint64 inprops, bool weighted) {
+uint64_t RandGenProperties(uint64_t inprops, bool weighted) {
   auto outprops = kAcyclic | kInitialAcyclic | kAccessible | kUnweightedCycles;
   outprops |= inprops & kError;
   if (weighted) {
@@ -248,23 +249,23 @@ uint64 RandGenProperties(uint64 inprops, bool weighted) {
 }
 
 // Properties for a replace FST.
-uint64 ReplaceProperties(const std::vector<uint64>& inprops, size_t root,
-                         bool epsilon_on_call, bool epsilon_on_return,
-                         bool out_epsilon_on_call, bool out_epsilon_on_return,
-                         bool replace_transducer, bool no_empty_fsts,
-                         bool all_ilabel_sorted, bool all_olabel_sorted,
-                         bool all_negative_or_dense) {
+uint64_t ReplaceProperties(const std::vector<uint64_t>& inprops, size_t root,
+                           bool epsilon_on_call, bool epsilon_on_return,
+                           bool out_epsilon_on_call, bool out_epsilon_on_return,
+                           bool replace_transducer, bool no_empty_fsts,
+                           bool all_ilabel_sorted, bool all_olabel_sorted,
+                           bool all_negative_or_dense) {
   if (inprops.empty()) return kNullProperties;
-  uint64 outprops = 0;
+  uint64_t outprops = 0;
   for (auto inprop : inprops) outprops |= kError & inprop;
-  uint64 access_props = no_empty_fsts ? kAccessible | kCoAccessible : 0;
+  uint64_t access_props = no_empty_fsts ? kAccessible | kCoAccessible : 0;
   for (auto inprop : inprops) {
     access_props &= (inprop & (kAccessible | kCoAccessible));
   }
   if (access_props == (kAccessible | kCoAccessible)) {
     outprops |= access_props;
     if (inprops[root] & kInitialCyclic) outprops |= kInitialCyclic;
-    uint64 props = 0;
+    uint64_t props = 0;
     bool string = true;
     for (auto inprop : inprops) {
       if (replace_transducer) props |= kNotAcceptor & inprop;
@@ -323,7 +324,7 @@ uint64 ReplaceProperties(const std::vector<uint64>& inprops, size_t root,
 }
 
 // Properties for a relabeled FST.
-uint64 RelabelProperties(uint64 inprops) {
+uint64_t RelabelProperties(uint64_t inprops) {
   static constexpr auto outprops =
       kExpanded | kMutable | kError | kWeighted | kUnweighted |
       kWeightedCycles | kUnweightedCycles | kCyclic | kAcyclic |
@@ -334,7 +335,7 @@ uint64 RelabelProperties(uint64 inprops) {
 }
 
 // Properties for a reversed FST (the superinitial state limits this set).
-uint64 ReverseProperties(uint64 inprops, bool has_superinitial) {
+uint64_t ReverseProperties(uint64_t inprops, bool has_superinitial) {
   auto outprops = (kExpanded | kMutable | kError | kAcceptor | kNotAcceptor |
                    kEpsilons | kIEpsilons | kOEpsilons | kUnweighted | kCyclic |
                    kAcyclic | kWeightedCycles | kUnweightedCycles) &
@@ -344,7 +345,7 @@ uint64 ReverseProperties(uint64 inprops, bool has_superinitial) {
 }
 
 // Properties for re-weighted FST.
-uint64 ReweightProperties(uint64 inprops, bool added_start_epsilon) {
+uint64_t ReweightProperties(uint64_t inprops, bool added_start_epsilon) {
   auto outprops = inprops & kWeightInvariantProperties;
   outprops = outprops & ~kCoAccessible;
   if (added_start_epsilon) {
@@ -355,7 +356,7 @@ uint64 ReweightProperties(uint64 inprops, bool added_start_epsilon) {
 }
 
 // Properties for an epsilon-removed FST.
-uint64 RmEpsilonProperties(uint64 inprops, bool delayed) {
+uint64_t RmEpsilonProperties(uint64_t inprops, bool delayed) {
   auto outprops = kNoEpsilons;
   outprops |= (kError | kAcceptor | kAcyclic | kInitialAcyclic) & inprops;
   if (inprops & kAcceptor) outprops |= kNoIEpsilons | kNoOEpsilons;
@@ -370,7 +371,7 @@ uint64 RmEpsilonProperties(uint64 inprops, bool delayed) {
 // Properties for shortest path. This function computes how the properties of
 // the output of shortest path need to be updated, given that 'props' is already
 // known.
-uint64 ShortestPathProperties(uint64 props, bool tree) {
+uint64_t ShortestPathProperties(uint64_t props, bool tree) {
   auto outprops =
       props | kAcyclic | kInitialAcyclic | kAccessible | kUnweightedCycles;
   if (!tree) outprops |= kCoAccessible;
@@ -378,7 +379,7 @@ uint64 ShortestPathProperties(uint64 props, bool tree) {
 }
 
 // Properties for a synchronized FST.
-uint64 SynchronizeProperties(uint64 inprops) {
+uint64_t SynchronizeProperties(uint64_t inprops) {
   auto outprops = (kError | kAcceptor | kAcyclic | kAccessible | kCoAccessible |
                    kUnweighted | kUnweightedCycles) &
                   inprops;
@@ -390,7 +391,7 @@ uint64 SynchronizeProperties(uint64 inprops) {
 }
 
 // Properties for a unioned FST.
-uint64 UnionProperties(uint64 inprops1, uint64 inprops2, bool delayed) {
+uint64_t UnionProperties(uint64_t inprops1, uint64_t inprops2, bool delayed) {
   auto outprops =
       (kAcceptor | kUnweighted | kUnweightedCycles | kAcyclic | kAccessible) &
       inprops1 & inprops2;
@@ -424,8 +425,9 @@ uint64 UnionProperties(uint64 inprops1, uint64 inprops2, bool delayed) {
   return outprops;
 }
 
+namespace internal {
 // Property string names (indexed by bit position).
-const char* PropertyNames[] = {
+const std::string_view PropertyNames[] = {
     // Binary.
     "expanded", "mutable", "error", "", "", "", "", "", "", "", "", "", "", "",
     "", "",
@@ -440,5 +442,5 @@ const char* PropertyNames[] = {
     "acyclic at initial state", "top sorted", "not top sorted", "accessible",
     "not accessible", "coaccessible", "not coaccessible", "string",
     "not string", "weighted cycles", "unweighted cycles"};
-
+}  // namespace internal
 }  // namespace fst
index 13bf592..845d362 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <fst/symbol-table-ops.h>
 
+#include <cstdint>
 #include <string>
 
 namespace fst {
@@ -36,8 +37,8 @@ SymbolTable *MergeSymbolTable(const SymbolTable &left, const SymbolTable &right,
   for (const auto &litem : left) {
     merged->AddSymbol(litem.Symbol(), litem.Label());
     if (right_has_all) {
-      int64 key = right.Find(litem.Symbol());
-      if (key == -1) {
+      int64_t key = right.Find(litem.Symbol());
+      if (key == kNoSymbol) {
         right_has_all = false;
       } else if (!relabel && key != litem.Label()) {
         relabel = true;
@@ -51,7 +52,7 @@ SymbolTable *MergeSymbolTable(const SymbolTable &left, const SymbolTable &right,
   // Adds all symbols we can from right symbol table.
   std::vector<std::string> conflicts;
   for (const auto &ritem : right) {
-    int64 key = merged->Find(ritem.Symbol());
+    int64_t key = merged->Find(ritem.Symbol());
     if (key != -1) {
       // Symbol already exists, maybe with different value.
       if (key != ritem.Label()) relabel = true;
@@ -75,12 +76,12 @@ SymbolTable *MergeSymbolTable(const SymbolTable &left, const SymbolTable &right,
 }
 
 SymbolTable *CompactSymbolTable(const SymbolTable &syms) {
-  std::map<int64, std::string> sorted;
+  std::map<int64_t, std::string> sorted;
   for (const auto &stitem : syms) {
     sorted[stitem.Label()] = stitem.Symbol();
   }
   auto *compact = new SymbolTable(syms.Name() + "_compact");
-  int64 newkey = 0;
+  int64_t newkey = 0;
   for (const auto &kv : sorted) compact->AddSymbol(kv.second, newkey++);
   return compact;
 }
@@ -119,9 +120,9 @@ SymbolTable *FstReadSymbols(const std::string &source, bool input_symbols) {
   return nullptr;
 }
 
-bool AddAuxiliarySymbols(const std::string &prefix, int64 start_label,
-                         int64 nlabels, SymbolTable *syms) {
-  for (int64 i = 0; i < nlabels; ++i) {
+bool AddAuxiliarySymbols(const std::string &prefix, int64_t start_label,
+                         int64_t nlabels, SymbolTable *syms) {
+  for (int64_t i = 0; i < nlabels; ++i) {
     auto index = i + start_label;
     if (index != syms->AddSymbol(prefix + std::to_string(i), index)) {
       FSTERROR() << "AddAuxiliarySymbols: Symbol table clash";
index 720b33b..10ad9b8 100644 (file)
 
 #include <fst/symbol-table.h>
 
+#include <cstdint>
+
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 
 #include <fstream>
 #include <fst/util.h>
 #include <string_view>
+#include <fst/lock.h>
 
 DEFINE_bool(fst_compat_symbols, true,
             "Require symbol tables to match when appropriate");
@@ -40,20 +42,15 @@ SymbolTableTextOptions::SymbolTableTextOptions(bool allow_negative_labels)
 
 namespace internal {
 
-// Maximum line length in textual symbols file.
-const int kLineLen = 8096;
-
 // Identifies stream data as a symbol table (and its endianity).
-static constexpr int32 kSymbolTableMagicNumber = 2125658996;
-
-constexpr int64 DenseSymbolMap::kEmptyBucket;
+static constexpr int32_t kSymbolTableMagicNumber = 2125658996;
 
 DenseSymbolMap::DenseSymbolMap()
     : str_hash_(),
       buckets_(1 << 4, kEmptyBucket),
       hash_mask_(buckets_.size() - 1) {}
 
-std::pair<int64, bool> DenseSymbolMap::InsertOrFind(std::string_view key) {
+std::pair<int64_t, bool> DenseSymbolMap::InsertOrFind(std::string_view key) {
   static constexpr float kMaxOccupancyRatio = 0.75;  // Grows when 75% full.
   if (Size() >= kMaxOccupancyRatio * buckets_.size()) {
     Rehash(buckets_.size() * 2);
@@ -70,7 +67,7 @@ std::pair<int64, bool> DenseSymbolMap::InsertOrFind(std::string_view key) {
   return {next, true};
 }
 
-int64 DenseSymbolMap::Find(std::string_view key) const {
+int64_t DenseSymbolMap::Find(std::string_view key) const {
   size_t idx = str_hash_(key) & hash_mask_;
   while (buckets_[idx] != kEmptyBucket) {
     const auto stored_value = buckets_[idx];
@@ -111,20 +108,20 @@ std::unique_ptr<SymbolTableImplBase> ConstSymbolTableImpl::Copy() const {
   return nullptr;
 }
 
-int64 ConstSymbolTableImpl::AddSymbol(std::string_view symbol, int64 key) {
+int64_t ConstSymbolTableImpl::AddSymbol(std::string_view symbol, int64_t key) {
   LOG(FATAL) << "ConstSymbolTableImpl does not support AddSymbol";
   return kNoSymbol;
 }
 
-int64 ConstSymbolTableImpl::AddSymbol(std::string_view symbol) {
+int64_t ConstSymbolTableImpl::AddSymbol(std::string_view symbol) {
   return AddSymbol(symbol, kNoSymbol);
 }
 
-void ConstSymbolTableImpl::RemoveSymbol(int64 key) {
+void ConstSymbolTableImpl::RemoveSymbol(int64_t key) {
   LOG(FATAL) << "ConstSymbolTableImpl does not support RemoveSymbol";
 }
 
-void ConstSymbolTableImpl::SetName(const std::string &new_name) {
+void ConstSymbolTableImpl::SetName(std::string_view new_name) {
   LOG(FATAL) << "ConstSymbolTableImpl does not support SetName";
 }
 
@@ -133,20 +130,21 @@ void ConstSymbolTableImpl::AddTable(const SymbolTable &table) {
 }
 
 SymbolTableImpl *SymbolTableImpl::ReadText(std::istream &strm,
-                                           const std::string &source,
+                                           std::string_view name,
                                            const SymbolTableTextOptions &opts) {
-  auto impl = std::make_unique<SymbolTableImpl>(source);
-  int64 nline = 0;
+  auto impl = std::make_unique<SymbolTableImpl>(name);
+  int64_t nline = 0;
   char line[kLineLen];
   const auto separator = opts.fst_field_separator + "\n";
   while (!strm.getline(line, kLineLen).fail()) {
     ++nline;
-    std::vector<std::string_view> col = SplitString(line, separator, true);
+    std::vector<std::string_view> col =
+        StrSplit(line, ByAnyChar(separator), SkipEmpty());
     if (col.empty()) continue;  // Empty line.
     if (col.size() != 2) {
       LOG(ERROR) << "SymbolTable::ReadText: Bad number of columns ("
                  << col.size() << "), "
-                 << "file = " << source << ", line = " << nline << ":<" << line
+                 << "file = " << name << ", line = " << nline << ":<" << line
                  << ">";
       return nullptr;
     }
@@ -158,7 +156,7 @@ SymbolTableImpl *SymbolTableImpl::ReadText(std::istream &strm,
         *maybe_key == kNoSymbol) {
       LOG(ERROR) << "SymbolTable::ReadText: Bad non-negative integer \""
                  << value << "\", "
-                 << "file = " << source << ", line = " << nline;
+                 << "file = " << name << ", line = " << nline;
       return nullptr;
     }
     impl->AddSymbol(symbol, *maybe_key);
@@ -180,33 +178,32 @@ void SymbolTableImpl::MaybeRecomputeCheckSum() const {
   // Calculates the original label-agnostic checksum.
   CheckSummer check_sum;
   for (size_t i = 0; i < symbols_.Size(); ++i) {
-    const auto &symbol = symbols_.GetSymbol(i);
-    check_sum.Update(symbol.data(), symbol.size());
-    check_sum.Update("", 1);
+    check_sum.Update(symbols_.GetSymbol(i));
+    check_sum.Update(std::string_view{"\0", 1});
   }
   check_sum_string_ = check_sum.Digest();
   // Calculates the safer, label-dependent checksum.
   CheckSummer labeled_check_sum;
-  for (int64 i = 0; i < dense_key_limit_; ++i) {
+  for (int64_t i = 0; i < dense_key_limit_; ++i) {
     std::ostringstream line;
     line << symbols_.GetSymbol(i) << '\t' << i;
-    labeled_check_sum.Update(line.str().data(), line.str().size());
+    labeled_check_sum.Update(line.str());
   }
-  using citer = std::map<int64, int64>::const_iterator;
+  using citer = std::map<int64_t, int64_t>::const_iterator;
   for (citer it = key_map_.begin(); it != key_map_.end(); ++it) {
     // TODO(tombagby, 2013-11-22) This line maintains a bug that ignores
     // negative labels in the checksum that too many tests rely on.
     if (it->first < dense_key_limit_) continue;
     std::ostringstream line;
     line << symbols_.GetSymbol(it->second) << '\t' << it->first;
-    labeled_check_sum.Update(line.str().data(), line.str().size());
+    labeled_check_sum.Update(line.str());
   }
   labeled_check_sum_string_ = labeled_check_sum.Digest();
   check_sum_finalized_ = true;
 }
 
-std::string SymbolTableImpl::Find(int64 key) const {
-  int64 idx = key;
+std::string SymbolTableImpl::Find(int64_t key) const {
+  int64_t idx = key;
   if (key < 0 || key >= dense_key_limit_) {
     const auto it = key_map_.find(key);
     if (it == key_map_.end()) return "";
@@ -216,18 +213,18 @@ std::string SymbolTableImpl::Find(int64 key) const {
   return symbols_.GetSymbol(idx);
 }
 
-int64 SymbolTableImpl::AddSymbol(std::string_view symbol, int64 key) {
+int64_t SymbolTableImpl::AddSymbol(std::string_view symbol, int64_t key) {
   if (key == kNoSymbol) return key;
-  const auto insert_key = symbols_.InsertOrFind(symbol);
-  if (!insert_key.second) {
-    const auto key_already = GetNthKey(insert_key.first);
+  if (const auto &[insert_key, inserted] = symbols_.InsertOrFind(symbol);
+      !inserted) {
+    const auto key_already = GetNthKey(insert_key);
     if (key_already == key) return key;
     VLOG(1) << "SymbolTable::AddSymbol: symbol = " << symbol
             << " already in symbol_map_ with key = " << key_already
             << " but supplied new key = " << key << " (ignoring new key)";
     return key_already;
   }
-  if (key + 1 == static_cast<int64>(symbols_.Size()) &&
+  if (key + 1 == static_cast<int64_t>(symbols_.Size()) &&
       key == dense_key_limit_) {
     ++dense_key_limit_;
   } else {
@@ -241,7 +238,7 @@ int64 SymbolTableImpl::AddSymbol(std::string_view symbol, int64 key) {
 
 // TODO(rybach): Consider a more efficient implementation which re-uses holes in
 // the dense-key range or re-arranges the dense-key range from time to time.
-void SymbolTableImpl::RemoveSymbol(const int64 key) {
+void SymbolTableImpl::RemoveSymbol(const int64_t key) {
   auto idx = key;
   if (key < 0 || key >= dense_key_limit_) {
     auto iter = key_map_.find(key);
@@ -249,7 +246,7 @@ void SymbolTableImpl::RemoveSymbol(const int64 key) {
     idx = iter->second;
     key_map_.erase(iter);
   }
-  if (idx < 0 || idx >= static_cast<int64>(symbols_.Size())) return;
+  if (idx < 0 || idx >= static_cast<int64_t>(symbols_.Size())) return;
   symbols_.RemoveSymbol(idx);
   // Removed one symbol, all indexes > idx are shifted by -1.
   for (auto &k : key_map_) {
@@ -258,16 +255,16 @@ void SymbolTableImpl::RemoveSymbol(const int64 key) {
   if (key >= 0 && key < dense_key_limit_) {
     // Removal puts a hole in the dense key range. Adjusts range to [0, key).
     const auto new_dense_key_limit = key;
-    for (int64 i = key + 1; i < dense_key_limit_; ++i) {
+    for (int64_t i = key + 1; i < dense_key_limit_; ++i) {
       key_map_[i] = i - 1;
     }
     // Moves existing values in idx_key to new place.
     idx_key_.resize(symbols_.Size() - new_dense_key_limit);
-    for (int64 i = symbols_.Size(); i >= dense_key_limit_; --i) {
+    for (int64_t i = symbols_.Size(); i >= dense_key_limit_; --i) {
       idx_key_[i - new_dense_key_limit - 1] = idx_key_[i - dense_key_limit_];
     }
     // Adds indexes for previously dense keys.
-    for (int64 i = new_dense_key_limit; i < dense_key_limit_ - 1; ++i) {
+    for (int64_t i = new_dense_key_limit; i < dense_key_limit_ - 1; ++i) {
       idx_key_[i - new_dense_key_limit] = i + 1;
     }
     dense_key_limit_ = new_dense_key_limit;
@@ -283,7 +280,7 @@ void SymbolTableImpl::RemoveSymbol(const int64 key) {
 
 SymbolTableImpl *SymbolTableImpl::Read(std::istream &strm,
                                        std::string_view source) {
-  int32 magic_number = 0;
+  int32_t magic_number = 0;
   ReadType(strm, &magic_number);
   if (strm.fail()) {
     LOG(ERROR) << "SymbolTable::Read: Read failed: " << source;
@@ -293,16 +290,16 @@ SymbolTableImpl *SymbolTableImpl::Read(std::istream &strm,
   ReadType(strm, &name);
   auto impl = std::make_unique<SymbolTableImpl>(name);
   ReadType(strm, &impl->available_key_);
-  int64 size;
+  int64_t size;
   ReadType(strm, &size);
   if (strm.fail()) {
     LOG(ERROR) << "SymbolTable::Read: Read failed: " << source;
     return nullptr;
   }
   std::string symbol;
-  int64 key;
+  int64_t key;
   impl->check_sum_finalized_ = false;
-  for (int64 i = 0; i < size; ++i) {
+  for (int64_t i = 0; i < size; ++i) {
     ReadType(strm, &symbol);
     ReadType(strm, &key);
     if (strm.fail()) {
@@ -319,9 +316,9 @@ bool SymbolTableImpl::Write(std::ostream &strm) const {
   WriteType(strm, kSymbolTableMagicNumber);
   WriteType(strm, name_);
   WriteType(strm, available_key_);
-  const int64 size = symbols_.Size();
+  const int64_t size = symbols_.Size();
   WriteType(strm, size);
-  for (int64 i = 0; i < dense_key_limit_; ++i) {
+  for (int64_t i = 0; i < dense_key_limit_; ++i) {
     WriteType(strm, symbols_.GetSymbol(i));
     WriteType(strm, i);
   }
index 5bf86a8..f489d9a 100644 (file)
 
 #include <cctype>
 #include <charconv>
+#include <cstdint>
 #include <sstream>
 #include <string>
 
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/mapped-file.h>
 #include <string_view>
@@ -39,36 +39,26 @@ DEFINE_bool(fst_error_fatal, true,
 
 namespace fst {
 
-std::vector<std::string_view> SplitString(const std::string_view line,
-                                           const std::string_view delim,
-                                           const bool omit_empty_strings) {
-  std::vector<std::string_view> vec;
-  size_t prev_pos = 0, pos = 0;
-  while (pos <= line.length()) {
-    pos = line.find_first_of(delim, pos);
-    if (pos == std::string_view::npos) {
-      pos = line.length();
-    }
-    if (!omit_empty_strings || pos != prev_pos)
-      vec.push_back(line.substr(prev_pos, pos - prev_pos));
-    prev_pos = ++pos;
-  }
-  return vec;
-}
-
-std::optional<int64> ParseInt64(std::string_view s) {
-  int64 n;
-  if (const auto [p, ec] = std::from_chars(s.begin(), s.end(), n);
-      ec != std::errc() || p != s.end()) {
+std::optional<int64_t> ParseInt64(std::string_view s, int base) {
+  // Portability note: std::from_chars does not play nicely with string_view
+  // using Microsoft Visual Studio Compiler. The string_view's begin() and end()
+  // do not return implicit char pointers on this platforms. Using data()
+  // and size() instead should be more portable.
+  //
+  // See: https://stackoverflow.com/questions/61203317/stdfrom-chars-doenst-compile-under-msvc
+  int64_t n;
+  if (const auto [p, ec] =
+          std::from_chars(s.data(), s.data() + s.size(), n, /*base=*/base);
+      ec != std::errc() || p != (s.data() + s.size())) {
     return std::nullopt;
   }
   return n;
 }
 
-int64 StrToInt64(std::string_view s, std::string_view source, size_t nline,
-                 bool allow_negative, bool *error) {
+int64_t StrToInt64(std::string_view s, std::string_view source, size_t nline,
+                   bool allow_negative, bool *error) {
   if (error) *error = false;
-  const std::optional<int64> maybe_n = ParseInt64(s);
+  const std::optional<int64_t> maybe_n = ParseInt64(s);
   if (!maybe_n.has_value() || (!allow_negative && *maybe_n < 0)) {
     FSTERROR() << "StrToInt64: Bad integer = " << s << "\", source = " << source
                << ", line = " << nline;
@@ -91,7 +81,7 @@ void ConvertToLegalCSymbol(std::string *s) {
 bool AlignInput(std::istream &strm, size_t align) {
   char c;
   for (size_t i = 0; i < align; ++i) {
-    int64 pos = strm.tellg();
+    int64_t pos = strm.tellg();
     if (pos < 0) {
       LOG(ERROR) << "AlignInput: Can't determine stream position";
       return false;
@@ -106,7 +96,7 @@ bool AlignInput(std::istream &strm, size_t align) {
 // can't align.
 bool AlignOutput(std::ostream &strm, size_t align) {
   for (size_t i = 0; i < align; ++i) {
-    int64 pos = strm.tellp();
+    int64_t pos = strm.tellp();
     if (pos < 0) {
       LOG(ERROR) << "AlignOutput: Can't determine stream position";
       return false;
index 703ec86..fa5b632 100644 (file)
@@ -13,5 +13,5 @@ shortest-distance.cc shortest-path.cc stateiterator-class.cc synchronize.cc \
 text-io.cc topsort.cc union.cc weight-class.cc verify.cc
 
 libfstscript_la_LIBADD = ../lib/libfst.la -lm $(DL_LIBS)
-libfstscript_la_LDFLAGS = -version-info 24:0:0
+libfstscript_la_LDFLAGS = -version-info 25:0:0
 endif
index 44ff108..f1ddf5c 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -98,8 +98,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -253,8 +252,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -268,8 +265,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -285,6 +283,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -407,7 +406,7 @@ AM_CPPFLAGS = -I$(srcdir)/../include $(ICU_CPPFLAGS)
 @HAVE_SCRIPT_TRUE@text-io.cc topsort.cc union.cc weight-class.cc verify.cc
 
 @HAVE_SCRIPT_TRUE@libfstscript_la_LIBADD = ../lib/libfst.la -lm $(DL_LIBS)
-@HAVE_SCRIPT_TRUE@libfstscript_la_LDFLAGS = -version-info 24:0:0
+@HAVE_SCRIPT_TRUE@libfstscript_la_LDFLAGS = -version-info 25:0:0
 all: all-am
 
 .SUFFIXES:
@@ -621,7 +620,6 @@ cscopelist-am: $(am__tagged_files)
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 62a71b8..27acc34 100644 (file)
 
 #include <fst/script/arciterator-class.h>
 
+#include <cstdint>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
-ArcIteratorClass::ArcIteratorClass(const FstClass &fst, int64 s)
+ArcIteratorClass::ArcIteratorClass(const FstClass &fst, int64_t s)
     : impl_(nullptr) {
-  InitArcIteratorClassArgs args(fst, s, this);
+  InitArcIteratorClassArgs args{fst, s, this};
   Apply<Operation<InitArcIteratorClassArgs>>("InitArcIteratorClass",
                                              fst.ArcType(), &args);
 }
 
-MutableArcIteratorClass::MutableArcIteratorClass(MutableFstClass *fst, int64 s)
+MutableArcIteratorClass::MutableArcIteratorClass(MutableFstClass *fst,
+                                                 int64_t s)
     : impl_(nullptr) {
-  InitMutableArcIteratorClassArgs args(fst, s, this);
+  InitMutableArcIteratorClassArgs args{fst, s, this};
   Apply<Operation<InitMutableArcIteratorClassArgs>>(
       "InitMutableArcIteratorClass", fst->ArcType(), &args);
 }
index 4acd109..c392c66 100644 (file)
@@ -23,11 +23,11 @@ namespace fst {
 namespace script {
 
 void ArcSort(MutableFstClass *fst, ArcSortType sort_type) {
-  ArcSortArgs args(fst, sort_type);
-  Apply<Operation<ArcSortArgs>>("ArcSort", fst->ArcType(), &args);
+  FstArcSortArgs args{fst, sort_type};
+  Apply<Operation<FstArcSortArgs>>("ArcSort", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(ArcSort, ArcSortArgs);
+REGISTER_FST_OPERATION_3ARCS(ArcSort, FstArcSortArgs);
 
 }  // namespace script
 }  // namespace fst
index 7b7a271..9a24c60 100644 (file)
@@ -23,11 +23,11 @@ namespace fst {
 namespace script {
 
 void Closure(MutableFstClass *fst, ClosureType closure_type) {
-  ClosureArgs args(fst, closure_type);
-  Apply<Operation<ClosureArgs>>("Closure", fst->ArcType(), &args);
+  FstClosureArgs args{fst, closure_type};
+  Apply<Operation<FstClosureArgs>>("Closure", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Closure, ClosureArgs);
+REGISTER_FST_OPERATION_3ARCS(Closure, FstClosureArgs);
 
 }  // namespace script
 }  // namespace fst
index 9ada9cd..ff6bb2e 100644 (file)
 
 #include <fst/script/compile.h>
 
+#include <string>
+#include <utility>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
-void CompileFst(std::istream &istrm, const std::string &source,
-                const std::string &dest, const std::string &fst_type,
-                const std::string &arc_type, const SymbolTable *isyms,
-                const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
-                bool ikeep, bool okeep, bool nkeep,
-                bool allow_negative_labels) {
+void Compile(std::istream &istrm, const std::string &source,
+             const std::string &dest, const std::string &fst_type,
+             const std::string &arc_type, const SymbolTable *isyms,
+             const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
+             bool ikeep, bool okeep, bool nkeep, bool allow_negative_labels) {
   std::unique_ptr<FstClass> fst(
-      CompileFstInternal(istrm, source, fst_type, arc_type, isyms, osyms, ssyms,
-                         accep, ikeep, okeep, nkeep, allow_negative_labels));
+      CompileInternal(istrm, source, fst_type, arc_type, isyms, osyms, ssyms,
+                      accep, ikeep, okeep, nkeep, allow_negative_labels));
   fst->Write(dest);
 }
 
-std::unique_ptr<FstClass> CompileFstInternal(
+std::unique_ptr<FstClass> CompileInternal(
     std::istream &istrm, const std::string &source, const std::string &fst_type,
     const std::string &arc_type, const SymbolTable *isyms,
     const SymbolTable *osyms, const SymbolTable *ssyms, bool accep, bool ikeep,
     bool okeep, bool nkeep, bool allow_negative_labels) {
-  CompileFstInnerArgs iargs{istrm, source, fst_type, isyms, osyms, ssyms, accep,
-                            ikeep, okeep, nkeep, allow_negative_labels};
-  CompileFstArgs args(iargs);
-  Apply<Operation<CompileFstArgs>>("CompileFstInternal", arc_type, &args);
+  FstCompileInnerArgs iargs{istrm,
+                            source,
+                            fst_type,
+                            isyms,
+                            osyms,
+                            ssyms,
+                            accep,
+                            ikeep,
+                            okeep,
+                            nkeep,
+                            allow_negative_labels};
+  FstCompileArgs args(iargs);
+  Apply<Operation<FstCompileArgs>>("CompileInternal", arc_type, &args);
   return std::move(args.retval);
 }
 
 // This registers form 2; 1 does not require registration.
-REGISTER_FST_OPERATION_3ARCS(CompileFstInternal, CompileFstArgs);
+REGISTER_FST_OPERATION_3ARCS(CompileInternal, FstCompileArgs);
 
 }  // namespace script
 }  // namespace fst
index 920b39b..39ad97c 100644 (file)
@@ -29,11 +29,11 @@ void Compose(const FstClass &ifst1, const FstClass &ifst2,
     ofst->SetProperties(kError, kError);
     return;
   }
-  ComposeArgs args(ifst1, ifst2, ofst, opts);
-  Apply<Operation<ComposeArgs>>("Compose", ifst1.ArcType(), &args);
+  FstComposeArgs args{ifst1, ifst2, ofst, opts};
+  Apply<Operation<FstComposeArgs>>("Compose", ifst1.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Compose, ComposeArgs);
+REGISTER_FST_OPERATION_3ARCS(Compose, FstComposeArgs);
 
 }  // namespace script
 }  // namespace fst
index bca10c3..1d097a1 100644 (file)
@@ -27,8 +27,8 @@ void Concat(MutableFstClass *fst1, const FstClass &fst2) {
     fst1->SetProperties(kError, kError);
     return;
   }
-  ConcatArgs1 args(fst1, fst2);
-  Apply<Operation<ConcatArgs1>>("Concat", fst1->ArcType(), &args);
+  FstConcatArgs1 args{fst1, fst2};
+  Apply<Operation<FstConcatArgs1>>("Concat", fst1->ArcType(), &args);
 }
 
 void Concat(const FstClass &fst1, MutableFstClass *fst2) {
@@ -36,8 +36,8 @@ void Concat(const FstClass &fst1, MutableFstClass *fst2) {
     fst2->SetProperties(kError, kError);
     return;
   }
-  ConcatArgs2 args(fst1, fst2);
-  Apply<Operation<ConcatArgs2>>("Concat", fst2->ArcType(), &args);
+  FstConcatArgs2 args{fst1, fst2};
+  Apply<Operation<FstConcatArgs2>>("Concat", fst2->ArcType(), &args);
 }
 
 void Concat(const std::vector<FstClass *> &fsts1, MutableFstClass *fst2) {
@@ -47,12 +47,13 @@ void Concat(const std::vector<FstClass *> &fsts1, MutableFstClass *fst2) {
       return;
     }
   }
-  ConcatArgs3 args(fsts1, fst2);
-  Apply<Operation<ConcatArgs3>>("Concat", fst2->ArcType(), &args);
+  FstConcatArgs3 args{fsts1, fst2};
+  Apply<Operation<FstConcatArgs3>>("Concat", fst2->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Concat, ConcatArgs1);
-REGISTER_FST_OPERATION_3ARCS(Concat, ConcatArgs2);
+REGISTER_FST_OPERATION_3ARCS(Concat, FstConcatArgs1);
+REGISTER_FST_OPERATION_3ARCS(Concat, FstConcatArgs2);
+REGISTER_FST_OPERATION_3ARCS(Concat, FstConcatArgs3);
 
 }  // namespace script
 }  // namespace fst
index 206abf9..01c362d 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <fst/script/convert.h>
 
+#include <string>
+#include <utility>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
@@ -24,13 +27,13 @@ namespace script {
 
 std::unique_ptr<FstClass> Convert(const FstClass &ifst,
                                   const std::string &new_type) {
-  ConvertInnerArgs iargs(ifst, new_type);
-  ConvertArgs args(iargs);
-  Apply<Operation<ConvertArgs>>("Convert", ifst.ArcType(), &args);
+  FstConvertInnerArgs iargs{ifst, new_type};
+  FstConvertArgs args(iargs);
+  Apply<Operation<FstConvertArgs>>("Convert", ifst.ArcType(), &args);
   return std::move(args.retval);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Convert, ConvertArgs);
+REGISTER_FST_OPERATION_3ARCS(Convert, FstConvertArgs);
 
 }  // namespace script
 }  // namespace fst
index 470ccc1..9459d0a 100644 (file)
@@ -27,11 +27,11 @@ void Decode(MutableFstClass *fst, const EncodeMapperClass &mapper) {
     fst->SetProperties(kError, kError);
     return;
   }
-  DecodeArgs args(fst, mapper);
-  Apply<Operation<DecodeArgs>>("Decode", fst->ArcType(), &args);
+  FstDecodeArgs args{fst, mapper};
+  Apply<Operation<FstDecodeArgs>>("Decode", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Decode, DecodeArgs);
+REGISTER_FST_OPERATION_3ARCS(Decode, FstDecodeArgs);
 
 }  // namespace script
 }  // namespace fst
index 8b8453c..0565d5d 100644 (file)
@@ -29,11 +29,11 @@ void Determinize(const FstClass &ifst, MutableFstClass *ofst,
     ofst->SetProperties(kError, kError);
     return;
   }
-  DeterminizeArgs args(ifst, ofst, opts);
-  Apply<Operation<DeterminizeArgs>>("Determinize", ifst.ArcType(), &args);
+  FstDeterminizeArgs args{ifst, ofst, opts};
+  Apply<Operation<FstDeterminizeArgs>>("Determinize", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Determinize, DeterminizeArgs);
+REGISTER_FST_OPERATION_3ARCS(Determinize, FstDeterminizeArgs);
 
 }  // namespace script
 }  // namespace fst
index f8a8568..6039233 100644 (file)
@@ -29,11 +29,11 @@ void Difference(const FstClass &ifst1, const FstClass &ifst2,
     ofst->SetProperties(kError, kError);
     return;
   }
-  DifferenceArgs args(ifst1, ifst2, ofst, opts);
-  Apply<Operation<DifferenceArgs>>("Difference", ifst1.ArcType(), &args);
+  FstDifferenceArgs args{ifst1, ifst2, ofst, opts};
+  Apply<Operation<FstDifferenceArgs>>("Difference", ifst1.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Difference, DifferenceArgs);
+REGISTER_FST_OPERATION_3ARCS(Difference, FstDifferenceArgs);
 
 }  // namespace script
 }  // namespace fst
index f09ec53..9a3c5ca 100644 (file)
@@ -29,11 +29,11 @@ void Disambiguate(const FstClass &ifst, MutableFstClass *ofst,
     ofst->SetProperties(kError, kError);
     return;
   }
-  DisambiguateArgs args(ifst, ofst, opts);
-  Apply<Operation<DisambiguateArgs>>("Disambiguate", ifst.ArcType(), &args);
+  FstDisambiguateArgs args{ifst, ofst, opts};
+  Apply<Operation<FstDisambiguateArgs>>("Disambiguate", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Disambiguate, DisambiguateArgs);
+REGISTER_FST_OPERATION_3ARCS(Disambiguate, FstDisambiguateArgs);
 
 }  // namespace script
 }  // namespace fst
index 4591aeb..35fc43b 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <fst/script/draw.h>
 
+#include <string>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
@@ -28,13 +30,14 @@ void Draw(const FstClass &fst, const SymbolTable *isyms,
           bool vertical, float ranksep, float nodesep, int fontsize,
           int precision, const std::string &float_format, bool show_weight_one,
           std::ostream &ostrm, const std::string &dest) {
-  DrawArgs args{fst, isyms, osyms, ssyms, accep, title, width, height, portrait,
-                vertical, ranksep, nodesep, fontsize, precision, float_format,
-                show_weight_one, ostrm, dest};
-  Apply<Operation<DrawArgs>>("Draw", fst.ArcType(), &args);
+  FstDrawArgs args{
+      fst,      isyms,     osyms,        ssyms,           accep,   title,
+      width,    height,    portrait,     vertical,        ranksep, nodesep,
+      fontsize, precision, float_format, show_weight_one, ostrm,   dest};
+  Apply<Operation<FstDrawArgs>>("Draw", fst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Draw, DrawArgs);
+REGISTER_FST_OPERATION_3ARCS(Draw, FstDrawArgs);
 
 }  // namespace script
 }  // namespace fst
index 103093d..63a9a44 100644 (file)
@@ -27,11 +27,11 @@ void Encode(MutableFstClass *fst, EncodeMapperClass *mapper) {
     fst->SetProperties(kError, kError);
     return;
   }
-  EncodeArgs args(fst, mapper);
-  Apply<Operation<EncodeArgs>>("Encode", fst->ArcType(), &args);
+  FstEncodeArgs args{fst, mapper};
+  Apply<Operation<FstEncodeArgs>>("Encode", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Encode, EncodeArgs);
+REGISTER_FST_OPERATION_3ARCS(Encode, FstEncodeArgs);
 
 }  // namespace script
 }  // namespace fst
index 730216e..20dc439 100644 (file)
 
 #include <fst/script/encodemapper-class.h>
 
+#include <cstdint>
+#include <memory>
+#include <string>
+
 #include <fst/script/script-impl.h>
+#include <string_view>
 
 namespace fst {
 namespace script {
@@ -25,8 +30,8 @@ namespace {
 
 // Helper methods.
 
-EncodeMapperClass *ReadEncodeMapper(std::istream &istrm,
-                                    const std::string &source) {
+std::unique_ptr<EncodeMapperClass> ReadEncodeMapper(std::istream &istrm,
+                                                    const std::string &source) {
   if (!istrm) {
     LOG(ERROR) << "ReadEncodeMapperClass: Can't open file: " << source;
     return nullptr;
@@ -51,8 +56,8 @@ EncodeMapperClass *ReadEncodeMapper(std::istream &istrm,
   return reader(istrm, source);
 }
 
-EncodeMapperImplBase *CreateEncodeMapper(const std::string &arc_type,
-                                         uint8 flags, EncodeType type) {
+std::unique_ptr<EncodeMapperImplBase> CreateEncodeMapper(
+    std::string_view arc_type, uint8_t flags, EncodeType type) {
   static const auto *reg =
       EncodeMapperClassIORegistration::Register::GetRegister();
   auto creator = reg->GetCreator(arc_type);
@@ -65,11 +70,12 @@ EncodeMapperImplBase *CreateEncodeMapper(const std::string &arc_type,
 
 }  // namespace
 
-EncodeMapperClass::EncodeMapperClass(const std::string &arc_type, uint8 flags,
+EncodeMapperClass::EncodeMapperClass(std::string_view arc_type, uint8_t flags,
                                      EncodeType type)
     : impl_(CreateEncodeMapper(arc_type, flags, type)) {}
 
-EncodeMapperClass *EncodeMapperClass::Read(const std::string &source) {
+std::unique_ptr<EncodeMapperClass> EncodeMapperClass::Read(
+    const std::string &source) {
   if (!source.empty()) {
     std::ifstream strm(source, std::ios_base::in | std::ios_base::binary);
     return ReadEncodeMapper(strm, source);
@@ -78,8 +84,8 @@ EncodeMapperClass *EncodeMapperClass::Read(const std::string &source) {
   }
 }
 
-EncodeMapperClass *EncodeMapperClass::Read(std::istream &strm,
-                                           const std::string &source) {
+std::unique_ptr<EncodeMapperClass> EncodeMapperClass::Read(
+    std::istream &strm, const std::string &source) {
   return ReadEncodeMapper(strm, source);
 }
 
index b6510cf..1118a23 100644 (file)
@@ -28,11 +28,11 @@ void EpsNormalize(const FstClass &ifst, MutableFstClass *ofst,
     ofst->SetProperties(kError, kError);
     return;
   }
-  EpsNormalizeArgs args(ifst, ofst, norm_type);
-  Apply<Operation<EpsNormalizeArgs>>("EpsNormalize", ifst.ArcType(), &args);
+  FstEpsNormalizeArgs args{ifst, ofst, norm_type};
+  Apply<Operation<FstEpsNormalizeArgs>>("EpsNormalize", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(EpsNormalize, EpsNormalizeArgs);
+REGISTER_FST_OPERATION_3ARCS(EpsNormalize, FstEpsNormalizeArgs);
 
 }  // namespace script
 }  // namespace fst
index 45f3e33..72d6ca0 100644 (file)
@@ -24,13 +24,13 @@ namespace script {
 
 bool Equal(const FstClass &fst1, const FstClass &fst2, float delta) {
   if (!internal::ArcTypesMatch(fst1, fst2, "Equal")) return false;
-  EqualInnerArgs iargs(fst1, fst2, delta);
-  EqualArgs args(iargs);
-  Apply<Operation<EqualArgs>>("Equal", fst1.ArcType(), &args);
+  FstEqualInnerArgs iargs{fst1, fst2, delta};
+  FstEqualArgs args(iargs);
+  Apply<Operation<FstEqualArgs>>("Equal", fst1.ArcType(), &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(Equal, EqualArgs);
+REGISTER_FST_OPERATION_3ARCS(Equal, FstEqualArgs);
 
 }  // namespace script
 }  // namespace fst
index ea024a1..0daed10 100644 (file)
@@ -24,13 +24,13 @@ namespace script {
 
 bool Equivalent(const FstClass &fst1, const FstClass &fst2, float delta) {
   if (!internal::ArcTypesMatch(fst1, fst2, "Equivalent")) return false;
-  EquivalentInnerArgs iargs(fst1, fst2, delta);
-  EquivalentArgs args(iargs);
-  Apply<Operation<EquivalentArgs>>("Equivalent", fst1.ArcType(), &args);
+  FstEquivalentInnerArgs iargs{fst1, fst2, delta};
+  FstEquivalentArgs args(iargs);
+  Apply<Operation<FstEquivalentArgs>>("Equivalent", fst1.ArcType(), &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(Equivalent, EquivalentArgs);
+REGISTER_FST_OPERATION_3ARCS(Equivalent, FstEquivalentArgs);
 
 }  // namespace script
 }  // namespace fst
index 268e767..8490c8e 100644 (file)
 
 #include <istream>
 #include <memory>
+#include <string>
 
 #include <fst/log.h>
 #include <fst/equal.h>
 #include <fst/fst-decl.h>
 #include <fst/reverse.h>
 #include <fst/union.h>
+#include <string_view>
 
 namespace fst {
 namespace script {
@@ -37,7 +39,8 @@ namespace {
 // Helper functions.
 
 template <class F>
-F *ReadFstClass(std::istream &istrm, const std::string &source) {
+std::unique_ptr<F> ReadFstClass(std::istream &istrm,
+                                const std::string &source) {
   if (!istrm) {
     LOG(ERROR) << "ReadFstClass: Can't open file: " << source;
     return nullptr;
@@ -56,14 +59,14 @@ F *ReadFstClass(std::istream &istrm, const std::string &source) {
 }
 
 template <class F>
-std::unique_ptr<FstClassImplBase> CreateFstClass(const std::string &arc_type) {
+std::unique_ptr<FstClassImplBase> CreateFstClass(std::string_view arc_type) {
   static const auto *reg = FstClassIORegistration<F>::Register::GetRegister();
   auto creator = reg->GetCreator(arc_type);
   if (!creator) {
     FSTERROR() << "CreateFstClass: Unknown arc type: " << arc_type;
     return nullptr;
   }
-  return fst::WrapUnique(creator());
+  return creator();
 }
 
 template <class F>
@@ -74,14 +77,14 @@ std::unique_ptr<FstClassImplBase> ConvertFstClass(const FstClass &other) {
     FSTERROR() << "ConvertFstClass: Unknown arc type: " << other.ArcType();
     return nullptr;
   }
-  return fst::WrapUnique(converter(other));
+  return converter(other);
 }
 
 }  // namespace
 
 // FstClass methods.
 
-FstClass *FstClass::Read(const std::string &source) {
+std::unique_ptr<FstClass> FstClass::Read(const std::string &source) {
   if (!source.empty()) {
     std::ifstream istrm(source, std::ios_base::in | std::ios_base::binary);
     return ReadFstClass<FstClass>(istrm, source);
@@ -90,12 +93,13 @@ FstClass *FstClass::Read(const std::string &source) {
   }
 }
 
-FstClass *FstClass::Read(std::istream &istrm, const std::string &source) {
+std::unique_ptr<FstClass> FstClass::Read(std::istream &istrm,
+                                         const std::string &source) {
   return ReadFstClass<FstClass>(istrm, source);
 }
 
 bool FstClass::WeightTypesMatch(const WeightClass &weight,
-                                const std::string &op_name) const {
+                                std::string_view op_name) const {
   if (WeightType() != weight.Type()) {
     FSTERROR() << op_name << ": FST and weight with non-matching weight types: "
                << WeightType() << " and " << weight.Type();
@@ -106,8 +110,8 @@ bool FstClass::WeightTypesMatch(const WeightClass &weight,
 
 // MutableFstClass methods.
 
-MutableFstClass *MutableFstClass::Read(const std::string &source,
-                                       bool convert) {
+std::unique_ptr<MutableFstClass> MutableFstClass::Read(
+    const std::string &source, bool convert) {
   if (convert == false) {
     if (!source.empty()) {
       std::ifstream in(source, std::ios_base::in | std::ios_base::binary);
@@ -119,16 +123,17 @@ MutableFstClass *MutableFstClass::Read(const std::string &source,
     std::unique_ptr<FstClass> ifst(FstClass::Read(source));
     if (!ifst) return nullptr;
     if (ifst->Properties(kMutable, false) == kMutable) {
-      return fst::down_cast<MutableFstClass *>(ifst.release());
+      return fst::WrapUnique(down_cast<MutableFstClass *>(ifst.release()));
     } else {
-      return new VectorFstClass(*ifst.release());
+      return std::make_unique<VectorFstClass>(*ifst.release());
     }
   }
 }
 
 // VectorFstClass methods.
 
-VectorFstClass *VectorFstClass::Read(const std::string &source) {
+std::unique_ptr<VectorFstClass> VectorFstClass::Read(
+    const std::string &source) {
   if (!source.empty()) {
     std::ifstream in(source, std::ios_base::in | std::ios_base::binary);
     return ReadFstClass<VectorFstClass>(in, source);
@@ -137,7 +142,7 @@ VectorFstClass *VectorFstClass::Read(const std::string &source) {
   }
 }
 
-VectorFstClass::VectorFstClass(const std::string &arc_type)
+VectorFstClass::VectorFstClass(std::string_view arc_type)
     : MutableFstClass(CreateFstClass<VectorFstClass>(arc_type)) {}
 
 VectorFstClass::VectorFstClass(const FstClass &other)
index c5cff74..b2e4903 100644 (file)
 
 #include <fst/script/getters.h>
 
+#include <string_view>
+
 namespace fst {
 namespace script {
 
-bool GetArcSortType(const std::string &str, ArcSortType *sort_type) {
+bool GetArcFilterType(std::string_view str, ArcFilterType *arc_filter_type) {
+  if (str == "any") {
+    *arc_filter_type = ArcFilterType::ANY;
+  } else if (str == "epsilon") {
+    *arc_filter_type = ArcFilterType::EPSILON;
+  } else if (str == "iepsilon") {
+    *arc_filter_type = ArcFilterType::INPUT_EPSILON;
+  } else if (str == "oepsilon") {
+    *arc_filter_type = ArcFilterType::OUTPUT_EPSILON;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+bool GetArcSortType(std::string_view str, ArcSortType *sort_type) {
   if (str == "ilabel") {
     *sort_type = ArcSortType::ILABEL;
   } else if (str == "olabel") {
@@ -31,7 +48,18 @@ bool GetArcSortType(const std::string &str, ArcSortType *sort_type) {
   return true;
 }
 
-bool GetComposeFilter(const std::string &str, ComposeFilter *compose_filter) {
+bool GetClosureType(std::string_view str, ClosureType *closure_type) {
+  if (str == "star") {
+    *closure_type = CLOSURE_STAR;
+  } else if (str == "plus") {
+    *closure_type = CLOSURE_PLUS;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+bool GetComposeFilter(std::string_view str, ComposeFilter *compose_filter) {
   if (str == "alt_sequence") {
     *compose_filter = ALT_SEQUENCE_FILTER;
   } else if (str == "auto") {
@@ -52,7 +80,7 @@ bool GetComposeFilter(const std::string &str, ComposeFilter *compose_filter) {
   return true;
 }
 
-bool GetDeterminizeType(const std::string &str, DeterminizeType *det_type) {
+bool GetDeterminizeType(std::string_view str, DeterminizeType *det_type) {
   if (str == "functional") {
     *det_type = DETERMINIZE_FUNCTIONAL;
   } else if (str == "nonfunctional") {
@@ -65,7 +93,19 @@ bool GetDeterminizeType(const std::string &str, DeterminizeType *det_type) {
   return true;
 }
 
-bool GetMapType(const std::string &str, MapType *map_type) {
+bool GetEpsNormalizeType(std::string_view str,
+                         EpsNormalizeType *eps_norm_type) {
+  if (str == "input") {
+    *eps_norm_type = EPS_NORM_INPUT;
+  } else if (str == "output") {
+    *eps_norm_type = EPS_NORM_OUTPUT;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+bool GetMapType(std::string_view str, MapType *map_type) {
   if (str == "arc_sum") {
     *map_type = MapType::ARC_SUM;
   } else if (str == "arc_unique") {
@@ -102,7 +142,7 @@ bool GetMapType(const std::string &str, MapType *map_type) {
   return true;
 }
 
-bool GetProjectType(const std::string &str, ProjectType *project_type) {
+bool GetProjectType(std::string_view str, ProjectType *project_type) {
   if (str == "input") {
     *project_type = ProjectType::INPUT;
   } else if (str == "output") {
@@ -113,7 +153,7 @@ bool GetProjectType(const std::string &str, ProjectType *project_type) {
   return true;
 }
 
-bool GetRandArcSelection(const std::string &str, RandArcSelection *ras) {
+bool GetRandArcSelection(std::string_view str, RandArcSelection *ras) {
   if (str == "uniform") {
     *ras = RandArcSelection::UNIFORM;
   } else if (str == "log_prob") {
@@ -126,7 +166,7 @@ bool GetRandArcSelection(const std::string &str, RandArcSelection *ras) {
   return true;
 }
 
-bool GetQueueType(const std::string &str, QueueType *queue_type) {
+bool GetQueueType(std::string_view str, QueueType *queue_type) {
   if (str == "auto") {
     *queue_type = AUTO_QUEUE;
   } else if (str == "fifo") {
@@ -145,7 +185,7 @@ bool GetQueueType(const std::string &str, QueueType *queue_type) {
   return true;
 }
 
-bool GetReplaceLabelType(const std::string &str, bool epsilon_on_replace,
+bool GetReplaceLabelType(std::string_view str, bool epsilon_on_replace,
                          ReplaceLabelType *rlt) {
   if (epsilon_on_replace || str == "neither") {
     *rlt = REPLACE_LABEL_NEITHER;
@@ -161,7 +201,18 @@ bool GetReplaceLabelType(const std::string &str, bool epsilon_on_replace,
   return true;
 }
 
-bool GetTokenType(const std::string &str, TokenType *token_type) {
+bool GetReweightType(std::string_view str, ReweightType *reweight_type) {
+  if (str == "to_initial") {
+    *reweight_type = REWEIGHT_TO_INITIAL;
+  } else if (str == "to_final") {
+    *reweight_type = REWEIGHT_TO_FINAL;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+bool GetTokenType(std::string_view str, TokenType *token_type) {
   if (str == "byte") {
     *token_type = TokenType::BYTE;
   } else if (str == "utf8") {
index c42f5a4..ce39bd1 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <fst/script/info-impl.h>
 
+#include <cstdint>
+#include <string>
+
 namespace fst {
 
 // Column width for property names.
@@ -58,12 +61,22 @@ void FstInfo::Info() const {
         << std::endl;
   ostrm.width(kWidth);
   std::string arc_type = "";
-  if (ArcFilterType() == "epsilon")
-    arc_type = "epsilon ";
-  else if (ArcFilterType() == "iepsilon")
-    arc_type = "input-epsilon ";
-  else if (ArcFilterType() == "oepsilon")
-    arc_type = "output-epsilon ";
+  switch (ArcFilterType()) {
+    case script::ArcFilterType::ANY:
+      break;
+    case script::ArcFilterType::EPSILON: {
+      arc_type = "epsilon ";
+      break;
+    }
+    case script::ArcFilterType::INPUT_EPSILON: {
+      arc_type = "input-epsilon ";
+      break;
+    }
+    case script::ArcFilterType::OUTPUT_EPSILON: {
+      arc_type = "output-epsilon ";
+      break;
+    }
+  }
   const auto accessible_label = "# of " + arc_type + "accessible states";
   ostrm.width(kWidth);
   ostrm << accessible_label << NumAccessible() << std::endl;
@@ -99,13 +112,13 @@ void FstInfo::Info() const {
   ostrm.setf(old);
 }
 
-void PrintProperties(std::ostream &ostrm, const uint64 properties) {
-  uint64 prop = 1;
+void PrintProperties(std::ostream &ostrm, const uint64_t properties) {
+  uint64_t prop = 1;
   for (auto i = 0; i < 64; ++i, prop <<= 1) {
     if (prop & kBinaryProperties) {
       const char value = properties & prop ? 'y' : 'n';
       ostrm.width(kWidth);
-      ostrm << PropertyNames[i] << value << std::endl;
+      ostrm << internal::PropertyNames[i] << value << std::endl;
     } else if (prop & kPosTrinaryProperties) {
       char value = '?';
       if (properties & prop) {
@@ -114,7 +127,7 @@ void PrintProperties(std::ostream &ostrm, const uint64 properties) {
         value = 'n';
       }
       ostrm.width(kWidth);
-      ostrm << PropertyNames[i] << value << std::endl;
+      ostrm << internal::PropertyNames[i] << value << std::endl;
     }
   }
 }
index 6f5450c..edb7d0b 100644 (file)
 
 #include <fst/script/info.h>
 
+#include <string>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
-void Info(const FstClass &fst, bool test_properties,
-          const std::string &arc_filter, const std::string &info_type,
-          bool verify) {
-  InfoArgs args(fst, test_properties, arc_filter, info_type, verify);
-  Apply<Operation<InfoArgs>>("Info", fst.ArcType(), &args);
+void Info(const FstClass &fst, bool test_properties, ArcFilterType arc_filter,
+          const std::string &info_type, bool verify) {
+  FstInfoArgs args{fst, test_properties, arc_filter, info_type, verify};
+  Apply<Operation<FstInfoArgs>>("Info", fst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Info, InfoArgs);
+REGISTER_FST_OPERATION_3ARCS(Info, FstInfoArgs);
 
 }  // namespace script
 }  // namespace fst
index adcda97..f7cb5e5 100644 (file)
@@ -29,11 +29,11 @@ void Intersect(const FstClass &ifst1, const FstClass &ifst2,
     ofst->SetProperties(kError, kError);
     return;
   }
-  IntersectArgs args(ifst1, ifst2, ofst, opts);
-  Apply<Operation<IntersectArgs>>("Intersect", ifst1.ArcType(), &args);
+  FstIntersectArgs args{ifst1, ifst2, ofst, opts};
+  Apply<Operation<FstIntersectArgs>>("Intersect", ifst1.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Intersect, IntersectArgs);
+REGISTER_FST_OPERATION_3ARCS(Intersect, FstIntersectArgs);
 
 }  // namespace script
 }  // namespace fst
index e0597f0..c6fdb01 100644 (file)
@@ -24,13 +24,13 @@ namespace script {
 
 bool Isomorphic(const FstClass &fst1, const FstClass &fst2, float delta) {
   if (!internal::ArcTypesMatch(fst1, fst2, "Isomorphic")) return false;
-  IsomorphicInnerArgs iargs(fst1, fst2, delta);
-  IsomorphicArgs args(iargs);
-  Apply<Operation<IsomorphicArgs>>("Isomorphic", fst1.ArcType(), &args);
+  FstIsomorphicInnerArgs iargs{fst1, fst2, delta};
+  FstIsomorphicArgs args(iargs);
+  Apply<Operation<FstIsomorphicArgs>>("Isomorphic", fst1.ArcType(), &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(Isomorphic, IsomorphicArgs);
+REGISTER_FST_OPERATION_3ARCS(Isomorphic, FstIsomorphicArgs);
 
 }  // namespace script
 }  // namespace fst
index 147ac72..bd9b3d9 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <fst/script/map.h>
 
+#include <utility>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
@@ -26,13 +28,13 @@ std::unique_ptr<FstClass> Map(const FstClass &ifst, MapType map_type,
                               float delta, double power,
                               const WeightClass &weight) {
   if (!ifst.WeightTypesMatch(weight, "Map")) return nullptr;
-  MapInnerArgs iargs(ifst, map_type, delta, power, weight);
-  MapArgs args(iargs);
-  Apply<Operation<MapArgs>>("Map", ifst.ArcType(), &args);
+  FstMapInnerArgs iargs{ifst, map_type, delta, power, weight};
+  FstMapArgs args(iargs);
+  Apply<Operation<FstMapArgs>>("Map", ifst.ArcType(), &args);
   return std::move(args.retval);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Map, MapArgs);
+REGISTER_FST_OPERATION_3ARCS(Map, FstMapArgs);
 
 }  // namespace script
 }  // namespace fst
index d4d46e7..dd827d0 100644 (file)
@@ -29,11 +29,11 @@ void Minimize(MutableFstClass *ofst1, MutableFstClass *ofst2, float delta,
     ofst2->SetProperties(kError, kError);
     return;
   }
-  MinimizeArgs args(ofst1, ofst2, delta, allow_nondet);
-  Apply<Operation<MinimizeArgs>>("Minimize", ofst1->ArcType(), &args);
+  FstMinimizeArgs args{ofst1, ofst2, delta, allow_nondet};
+  Apply<Operation<FstMinimizeArgs>>("Minimize", ofst1->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Minimize, MinimizeArgs);
+REGISTER_FST_OPERATION_3ARCS(Minimize, FstMinimizeArgs);
 
 }  // namespace script
 }  // namespace fst
index 342d9f4..e9f49ca 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <fst/script/print.h>
 
+#include <string>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
@@ -27,9 +29,9 @@ void Print(const FstClass &fst, std::ostream &ostrm, const std::string &dest,
            const SymbolTable *ssyms, bool accept, bool show_weight_one,
            const std::string &missing_sym) {
   const auto sep = FST_FLAGS_fst_field_separator.substr(0, 1);
-  PrintArgs args{fst, isyms, osyms, ssyms, accept, show_weight_one, ostrm, dest,
-                 sep, missing_sym};
-  Apply<Operation<PrintArgs>>("Print", fst.ArcType(), &args);
+  FstPrintArgs args{fst,   isyms, osyms, ssyms,      accept, show_weight_one,
+                    ostrm, dest,  sep,   missing_sym};
+  Apply<Operation<FstPrintArgs>>("Print", fst.ArcType(), &args);
 }
 
 // TODO(kbg,2019-09-01): Deprecated.
@@ -41,7 +43,7 @@ void PrintFst(const FstClass &fst, std::ostream &ostrm, const std::string &dest,
         missing_sym);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Print, PrintArgs);
+REGISTER_FST_OPERATION_3ARCS(Print, FstPrintArgs);
 
 }  // namespace script
 }  // namespace fst
index 74e67c4..43de764 100644 (file)
@@ -23,11 +23,11 @@ namespace fst {
 namespace script {
 
 void Project(MutableFstClass *ofst, ProjectType project_type) {
-  ProjectArgs args(ofst, project_type);
-  Apply<Operation<ProjectArgs>>("Project", ofst->ArcType(), &args);
+  FstProjectArgs args(ofst, project_type);
+  Apply<Operation<FstProjectArgs>>("Project", ofst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Project, ProjectArgs);
+REGISTER_FST_OPERATION_3ARCS(Project, FstProjectArgs);
 
 }  // namespace script
 }  // namespace fst
index c21be7b..39ad1d8 100644 (file)
 
 #include <fst/script/prune.h>
 
+#include <cstdint>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
 void Prune(const FstClass &ifst, MutableFstClass *ofst,
-           const WeightClass &weight_threshold, int64 state_threshold,
+           const WeightClass &weight_threshold, int64_t state_threshold,
            float delta) {
   if (!internal::ArcTypesMatch(ifst, *ofst, "Prune") ||
       !ofst->WeightTypesMatch(weight_threshold, "Prune")) {
     ofst->SetProperties(kError, kError);
     return;
   }
-  PruneArgs1 args(ifst, ofst, weight_threshold, state_threshold, delta);
-  Apply<Operation<PruneArgs1>>("Prune", ifst.ArcType(), &args);
+  FstPruneArgs1 args{ifst, ofst, weight_threshold, state_threshold, delta};
+  Apply<Operation<FstPruneArgs1>>("Prune", ifst.ArcType(), &args);
 }
 
 void Prune(MutableFstClass *fst, const WeightClass &weight_threshold,
-           int64 state_threshold, float delta) {
+           int64_t state_threshold, float delta) {
   if (!fst->WeightTypesMatch(weight_threshold, "Prune")) {
     fst->SetProperties(kError, kError);
     return;
   }
-  PruneArgs2 args(fst, weight_threshold, state_threshold, delta);
-  Apply<Operation<PruneArgs2>>("Prune", fst->ArcType(), &args);
+  FstPruneArgs2 args{fst, weight_threshold, state_threshold, delta};
+  Apply<Operation<FstPruneArgs2>>("Prune", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Prune, PruneArgs1);
-REGISTER_FST_OPERATION_3ARCS(Prune, PruneArgs2);
+REGISTER_FST_OPERATION_3ARCS(Prune, FstPruneArgs1);
+REGISTER_FST_OPERATION_3ARCS(Prune, FstPruneArgs2);
 
 }  // namespace script
 }  // namespace fst
index 9097a50..0885774 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <fst/script/push.h>
 
+#include <cstdint>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
@@ -24,22 +26,22 @@ namespace script {
 
 void Push(MutableFstClass *fst, ReweightType rew_type, float delta,
           bool remove_total_weight) {
-  PushArgs1 args(fst, rew_type, delta, remove_total_weight);
-  Apply<Operation<PushArgs1>>("Push", fst->ArcType(), &args);
+  FstPushArgs1 args{fst, rew_type, delta, remove_total_weight};
+  Apply<Operation<FstPushArgs1>>("Push", fst->ArcType(), &args);
 }
 
-void Push(const FstClass &ifst, MutableFstClass *ofst, uint8 flags,
+void Push(const FstClass &ifst, MutableFstClass *ofst, uint8_t flags,
           ReweightType rew_type, float delta) {
   if (!internal::ArcTypesMatch(ifst, *ofst, "Push")) {
     ofst->SetProperties(kError, kError);
     return;
   }
-  PushArgs2 args(ifst, ofst, flags, rew_type, delta);
-  Apply<Operation<PushArgs2>>("Push", ifst.ArcType(), &args);
+  FstPushArgs2 args{ifst, ofst, flags, rew_type, delta};
+  Apply<Operation<FstPushArgs2>>("Push", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Push, PushArgs1);
-REGISTER_FST_OPERATION_3ARCS(Push, PushArgs2);
+REGISTER_FST_OPERATION_3ARCS(Push, FstPushArgs1);
+REGISTER_FST_OPERATION_3ARCS(Push, FstPushArgs2);
 
 }  // namespace script
 }  // namespace fst
index e182d59..3c99b62 100644 (file)
 
 #include <fst/script/randequivalent.h>
 
+#include <cstdint>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
-bool RandEquivalent(const FstClass &fst1, const FstClass &fst2, int32 npath,
+bool RandEquivalent(const FstClass &fst1, const FstClass &fst2, int32_t npath,
                     const RandGenOptions<RandArcSelection> &opts, float delta,
-                    uint64 seed) {
+                    uint64_t seed) {
   if (!internal::ArcTypesMatch(fst1, fst2, "RandEquivalent")) return false;
-  RandEquivalentInnerArgs iargs(fst1, fst2, npath, opts, delta, seed);
-  RandEquivalentArgs args(iargs);
-  Apply<Operation<RandEquivalentArgs>>("RandEquivalent", fst1.ArcType(), &args);
+  FstRandEquivalentInnerArgs iargs{fst1, fst2, npath, opts, delta, seed};
+  FstRandEquivalentArgs args(iargs);
+  Apply<Operation<FstRandEquivalentArgs>>("RandEquivalent", fst1.ArcType(),
+                                          &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(RandEquivalent, RandEquivalentArgs);
+REGISTER_FST_OPERATION_3ARCS(RandEquivalent, FstRandEquivalentArgs);
 
 }  // namespace script
 }  // namespace fst
index 9334cfb..e9ec168 100644 (file)
 
 #include <fst/script/randgen.h>
 
+#include <cstdint>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
 void RandGen(const FstClass &ifst, MutableFstClass *ofst,
-             const RandGenOptions<RandArcSelection> &opts, uint64 seed) {
+             const RandGenOptions<RandArcSelection> &opts, uint64_t seed) {
   if (!internal::ArcTypesMatch(ifst, *ofst, "RandGen")) {
     ofst->SetProperties(kError, kError);
     return;
   }
-  RandGenArgs args(ifst, ofst, opts, seed);
-  Apply<Operation<RandGenArgs>>("RandGen", ifst.ArcType(), &args);
+  FstRandGenArgs args{ifst, ofst, opts, seed};
+  Apply<Operation<FstRandGenArgs>>("RandGen", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(RandGen, RandGenArgs);
+REGISTER_FST_OPERATION_3ARCS(RandGen, FstRandGenArgs);
 
 }  // namespace script
 }  // namespace fst
index a4e3fd9..a1b8494 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <fst/script/relabel.h>
 
+#include <cstdint>
+#include <string>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
@@ -27,21 +30,27 @@ void Relabel(MutableFstClass *ofst, const SymbolTable *old_isyms,
              const std::string &unknown_isymbol, bool attach_new_isyms,
              const SymbolTable *old_osyms, const SymbolTable *relabel_osyms,
              const std::string &unknown_osymbol, bool attach_new_osyms) {
-  RelabelArgs1 args(ofst, old_isyms, relabel_isyms, unknown_isymbol,
-                    attach_new_isyms, old_osyms, relabel_osyms, unknown_osymbol,
-                    attach_new_osyms);
-  Apply<Operation<RelabelArgs1>>("Relabel", ofst->ArcType(), &args);
+  FstRelabelArgs1 args{ofst,
+                       old_isyms,
+                       relabel_isyms,
+                       unknown_isymbol,
+                       attach_new_isyms,
+                       old_osyms,
+                       relabel_osyms,
+                       unknown_osymbol,
+                       attach_new_osyms};
+  Apply<Operation<FstRelabelArgs1>>("Relabel", ofst->ArcType(), &args);
 }
 
 void Relabel(MutableFstClass *ofst,
-             const std::vector<std::pair<int64, int64>> &ipairs,
-             const std::vector<std::pair<int64, int64>> &opairs) {
-  RelabelArgs2 args(ofst, ipairs, opairs);
-  Apply<Operation<RelabelArgs2>>("Relabel", ofst->ArcType(), &args);
+             const std::vector<std::pair<int64_t, int64_t>> &ipairs,
+             const std::vector<std::pair<int64_t, int64_t>> &opairs) {
+  FstRelabelArgs2 args{ofst, ipairs, opairs};
+  Apply<Operation<FstRelabelArgs2>>("Relabel", ofst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Relabel, RelabelArgs1);
-REGISTER_FST_OPERATION_3ARCS(Relabel, RelabelArgs2);
+REGISTER_FST_OPERATION_3ARCS(Relabel, FstRelabelArgs1);
+REGISTER_FST_OPERATION_3ARCS(Relabel, FstRelabelArgs2);
 
 }  // namespace script
 }  // namespace fst
index 52eb32d..6cc5141 100644 (file)
 
 #include <fst/script/replace.h>
 
+#include <cstdint>
+
 #include <fst/script/script-impl.h>
 
 namespace fst {
 namespace script {
 
-void Replace(const std::vector<std::pair<int64, const FstClass *>> &pairs,
+void Replace(const std::vector<std::pair<int64_t, const FstClass *>> &pairs,
              MutableFstClass *ofst, const ReplaceOptions &opts) {
   for (const auto &pair : pairs) {
     if (!internal::ArcTypesMatch(*pair.second, *ofst, "Replace")) {
@@ -30,11 +32,11 @@ void Replace(const std::vector<std::pair<int64, const FstClass *>> &pairs,
       return;
     }
   }
-  ReplaceArgs args(pairs, ofst, opts);
-  Apply<Operation<ReplaceArgs>>("Replace", ofst->ArcType(), &args);
+  FstReplaceArgs args{pairs, ofst, opts};
+  Apply<Operation<FstReplaceArgs>>("Replace", ofst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Replace, ReplaceArgs);
+REGISTER_FST_OPERATION_3ARCS(Replace, FstReplaceArgs);
 
 }  // namespace script
 }  // namespace fst
index 08cc3e9..f1fd5c9 100644 (file)
@@ -28,11 +28,11 @@ void Reverse(const FstClass &ifst, MutableFstClass *ofst,
     ofst->SetProperties(kError, kError);
     return;
   }
-  ReverseArgs args(ifst, ofst, require_superinitial);
-  Apply<Operation<ReverseArgs>>("Reverse", ifst.ArcType(), &args);
+  FstReverseArgs args{ifst, ofst, require_superinitial};
+  Apply<Operation<FstReverseArgs>>("Reverse", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Reverse, ReverseArgs);
+REGISTER_FST_OPERATION_3ARCS(Reverse, FstReverseArgs);
 
 }  // namespace script
 }  // namespace fst
index b7ccd11..d7954e5 100644 (file)
@@ -24,11 +24,11 @@ namespace script {
 
 void Reweight(MutableFstClass *fst, const std::vector<WeightClass> &potential,
               ReweightType reweight_type) {
-  ReweightArgs args(fst, potential, reweight_type);
-  Apply<Operation<ReweightArgs>>("Reweight", fst->ArcType(), &args);
+  FstReweightArgs args{fst, potential, reweight_type};
+  Apply<Operation<FstReweightArgs>>("Reweight", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Reweight, ReweightArgs);
+REGISTER_FST_OPERATION_3ARCS(Reweight, FstReweightArgs);
 
 }  // namespace script
 }  // namespace fst
index 7ebe7d0..7b8cf71 100644 (file)
@@ -27,11 +27,11 @@ void RmEpsilon(MutableFstClass *fst, const RmEpsilonOptions &opts) {
     fst->SetProperties(kError, kError);
     return;
   }
-  RmEpsilonArgs args(fst, opts);
-  Apply<Operation<RmEpsilonArgs>>("RmEpsilon", fst->ArcType(), &args);
+  FstRmEpsilonArgs args{fst, opts};
+  Apply<Operation<FstRmEpsilonArgs>>("RmEpsilon", fst->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(RmEpsilon, RmEpsilonArgs);
+REGISTER_FST_OPERATION_3ARCS(RmEpsilon, FstRmEpsilonArgs);
 
 }  // namespace script
 }  // namespace fst
index ec213b7..cca7890 100644 (file)
@@ -24,29 +24,29 @@ namespace script {
 
 void ShortestDistance(const FstClass &fst, std::vector<WeightClass> *distance,
                       const ShortestDistanceOptions &opts) {
-  ShortestDistanceArgs1 args(fst, distance, opts);
-  Apply<Operation<ShortestDistanceArgs1>>("ShortestDistance", fst.ArcType(),
-                                          &args);
+  FstShortestDistanceArgs1 args{fst, distance, opts};
+  Apply<Operation<FstShortestDistanceArgs1>>("ShortestDistance", fst.ArcType(),
+                                             &args);
 }
 
 void ShortestDistance(const FstClass &fst, std::vector<WeightClass> *distance,
                       bool reverse, double delta) {
-  ShortestDistanceArgs2 args(fst, distance, reverse, delta);
-  Apply<Operation<ShortestDistanceArgs2>>("ShortestDistance", fst.ArcType(),
-                                          &args);
+  FstShortestDistanceArgs2 args{fst, distance, reverse, delta};
+  Apply<Operation<FstShortestDistanceArgs2>>("ShortestDistance", fst.ArcType(),
+                                             &args);
 }
 
 WeightClass ShortestDistance(const FstClass &fst, double delta) {
-  ShortestDistanceInnerArgs3 iargs(fst, delta);
-  ShortestDistanceArgs3 args(iargs);
-  Apply<Operation<ShortestDistanceArgs3>>("ShortestDistance", fst.ArcType(),
-                                          &args);
+  FstShortestDistanceInnerArgs3 iargs{fst, delta};
+  FstShortestDistanceArgs3 args(iargs);
+  Apply<Operation<FstShortestDistanceArgs3>>("ShortestDistance", fst.ArcType(),
+                                             &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(ShortestDistance, ShortestDistanceArgs1);
-REGISTER_FST_OPERATION_3ARCS(ShortestDistance, ShortestDistanceArgs2);
-REGISTER_FST_OPERATION_3ARCS(ShortestDistance, ShortestDistanceArgs3);
+REGISTER_FST_OPERATION_3ARCS(ShortestDistance, FstShortestDistanceArgs1);
+REGISTER_FST_OPERATION_3ARCS(ShortestDistance, FstShortestDistanceArgs2);
+REGISTER_FST_OPERATION_3ARCS(ShortestDistance, FstShortestDistanceArgs3);
 
 }  // namespace script
 }  // namespace fst
index a7e8157..8100310 100644 (file)
@@ -28,11 +28,11 @@ void ShortestPath(const FstClass &ifst, MutableFstClass *ofst,
     ofst->SetProperties(kError, kError);
     return;
   }
-  ShortestPathArgs args(ifst, ofst, opts);
-  Apply<Operation<ShortestPathArgs>>("ShortestPath", ifst.ArcType(), &args);
+  FstShortestPathArgs args{ifst, ofst, opts};
+  Apply<Operation<FstShortestPathArgs>>("ShortestPath", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(ShortestPath, ShortestPathArgs);
+REGISTER_FST_OPERATION_3ARCS(ShortestPath, FstShortestPathArgs);
 
 }  // namespace script
 }  // namespace fst
index 2204149..74e4af6 100644 (file)
@@ -23,7 +23,7 @@ namespace fst {
 namespace script {
 
 StateIteratorClass::StateIteratorClass(const FstClass &fst) : impl_(nullptr) {
-  InitStateIteratorClassArgs args(fst, this);
+  InitStateIteratorClassArgs args{fst, this};
   Apply<Operation<InitStateIteratorClassArgs>>("InitStateIteratorClass",
                                                fst.ArcType(), &args);
 }
index d6c6833..bfc2e00 100644 (file)
@@ -27,11 +27,11 @@ void Synchronize(const FstClass &ifst, MutableFstClass *ofst) {
     ofst->SetProperties(kError, kError);
     return;
   }
-  SynchronizeArgs args(ifst, ofst);
-  Apply<Operation<SynchronizeArgs>>("Synchronize", ifst.ArcType(), &args);
+  FstSynchronizeArgs args{ifst, ofst};
+  Apply<Operation<FstSynchronizeArgs>>("Synchronize", ifst.ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Synchronize, SynchronizeArgs);
+REGISTER_FST_OPERATION_3ARCS(Synchronize, FstSynchronizeArgs);
 
 }  // namespace script
 }  // namespace fst
index 58a5e87..658a00d 100644 (file)
@@ -20,6 +20,7 @@
 #include <cstring>
 #include <ostream>
 #include <sstream>
+#include <string>
 #include <utility>
 
 #include <fst/log.h>
@@ -32,7 +33,7 @@ namespace fst {
 namespace script {
 
 // Reads vector of weights; returns true on success.
-bool ReadPotentials(const std::string &weight_type, const std::string &source,
+bool ReadPotentials(std::string_view weight_type, const std::string &source,
                     std::vector<WeightClass> *potentials) {
   std::ifstream istrm(source);
   if (!istrm) {
@@ -45,7 +46,8 @@ bool ReadPotentials(const std::string &weight_type, const std::string &source,
   potentials->clear();
   while (!istrm.getline(line, kLineLen).fail()) {
     ++nline;
-    std::vector<std::string_view> col = SplitString(line, "\n\t ", true);
+    std::vector<std::string_view> col =
+        StrSplit(line, ByAnyChar("\n\t "), SkipEmpty());
     if (col.empty() || col[0].empty()) continue;
     if (col.size() != 2) {
       FSTERROR() << "ReadPotentials: Bad number of columns, "
index da946cf..59d7ee1 100644 (file)
@@ -23,12 +23,12 @@ namespace fst {
 namespace script {
 
 bool TopSort(MutableFstClass *fst) {
-  TopSortArgs args(fst);
-  Apply<Operation<TopSortArgs>>("TopSort", fst->ArcType(), &args);
+  FstTopSortArgs args(fst);
+  Apply<Operation<FstTopSortArgs>>("TopSort", fst->ArcType(), &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(TopSort, TopSortArgs);
+REGISTER_FST_OPERATION_3ARCS(TopSort, FstTopSortArgs);
 
 }  // namespace script
 }  // namespace fst
index ca2d82d..128bec1 100644 (file)
@@ -27,8 +27,8 @@ void Union(MutableFstClass *fst1, const FstClass &fst2) {
     fst1->SetProperties(kError, kError);
     return;
   }
-  UnionArgs1 args(fst1, fst2);
-  Apply<Operation<UnionArgs1>>("Union", fst1->ArcType(), &args);
+  FstUnionArgs1 args{fst1, fst2};
+  Apply<Operation<FstUnionArgs1>>("Union", fst1->ArcType(), &args);
 }
 
 void Union(MutableFstClass *fst1, const std::vector<const FstClass *> &fsts2) {
@@ -38,12 +38,12 @@ void Union(MutableFstClass *fst1, const std::vector<const FstClass *> &fsts2) {
       return;
     }
   }
-  UnionArgs2 args(fst1, fsts2);
-  Apply<Operation<UnionArgs2>>("Union", fst1->ArcType(), &args);
+  FstUnionArgs2 args{fst1, fsts2};
+  Apply<Operation<FstUnionArgs2>>("Union", fst1->ArcType(), &args);
 }
 
-REGISTER_FST_OPERATION_3ARCS(Union, UnionArgs1);
-REGISTER_FST_OPERATION_3ARCS(Union, UnionArgs2);
+REGISTER_FST_OPERATION_3ARCS(Union, FstUnionArgs1);
+REGISTER_FST_OPERATION_3ARCS(Union, FstUnionArgs2);
 
 }  // namespace script
 }  // namespace fst
index 6393c1f..e177d9e 100644 (file)
@@ -23,12 +23,12 @@ namespace fst {
 namespace script {
 
 bool Verify(const FstClass &fst) {
-  VerifyArgs args(fst);
-  Apply<Operation<VerifyArgs>>("Verify", fst.ArcType(), &args);
+  FstVerifyArgs args(fst);
+  Apply<Operation<FstVerifyArgs>>("Verify", fst.ArcType(), &args);
   return args.retval;
 }
 
-REGISTER_FST_OPERATION_3ARCS(Verify, VerifyArgs);
+REGISTER_FST_OPERATION_3ARCS(Verify, FstVerifyArgs);
 
 }  // namespace script
 }  // namespace fst
index af495e3..b008ca4 100644 (file)
@@ -26,7 +26,7 @@ REGISTER_FST_WEIGHT(StdArc::Weight);
 REGISTER_FST_WEIGHT(LogArc::Weight);
 REGISTER_FST_WEIGHT(Log64Arc::Weight);
 
-WeightClass::WeightClass(const std::string &weight_type,
+WeightClass::WeightClass(std::string_view weight_type,
                          std::string_view weight_str) {
   static const auto *reg = WeightClassRegister::GetRegister();
   const auto stw = reg->GetEntry(weight_type);
@@ -35,28 +35,24 @@ WeightClass::WeightClass(const std::string &weight_type,
     impl_.reset();
     return;
   }
-  impl_.reset(stw(weight_str));
+  impl_ = stw(weight_str);
 }
 
-constexpr char WeightClass::__ZERO__[];
-constexpr char WeightClass::__ONE__[];
-constexpr char WeightClass::__NOWEIGHT__[];
-
-WeightClass WeightClass::Zero(const std::string &weight_type) {
+WeightClass WeightClass::Zero(std::string_view weight_type) {
   return WeightClass(weight_type, __ZERO__);
 }
 
-WeightClass WeightClass::One(const std::string &weight_type) {
+WeightClass WeightClass::One(std::string_view weight_type) {
   return WeightClass(weight_type, __ONE__);
 }
 
-WeightClass WeightClass::NoWeight(const std::string &weight_type) {
+WeightClass WeightClass::NoWeight(std::string_view weight_type) {
   return WeightClass(weight_type, __NOWEIGHT__);
 }
 
 bool WeightClass::WeightTypesMatch(const WeightClass &lhs,
                                    const WeightClass &rhs,
-                                   const std::string &op_name) {
+                                   std::string_view op_name) {
   if (lhs.Type() != rhs.Type()) {
     FSTERROR() << op_name << ": Weights with non-matching types: " << lhs.Type()
                << " and " << rhs.Type();
index de6de1c..3f6075f 100644 (file)
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -101,8 +101,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h \
-       $(top_builddir)/src/include/fst/config.h
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__objects_1 = algo_test_lexicographic-algo_test.$(OBJEXT)
@@ -217,8 +216,6 @@ am__define_uniq_tagged_files = \
   unique=`for i in $$list; do \
     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
 am__tty_colors_dummy = \
   mgn= red= grn= lgn= blu= brg= std=; \
   am__color_tests=no
@@ -438,8 +435,9 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -455,6 +453,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -1027,7 +1026,6 @@ algo_test_power.log: algo_test_power$(EXEEXT)
 @am__EXEEXT_TRUE@      --log-file $$b.log --trs-file $$b.trs \
 @am__EXEEXT_TRUE@      $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
 @am__EXEEXT_TRUE@      "$$tst" $(AM_TESTS_FD_REDIRECT)
-
 distdir: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) distdir-am
 
index 2565985..2e4f282 100644 (file)
@@ -32,23 +32,8 @@ DEFINE_int32(repeat, 25, "number of test repetitions");
 
 namespace {
 
-using ::fst::AlgoTester;
-using ::fst::ArcTpl;
-using ::fst::GallicArc;
-using ::fst::GallicWeight;
-using ::fst::LexicographicArc;
-using ::fst::LexicographicWeight;
-using ::fst::LogArc;
-using ::fst::LogWeight;
-using ::fst::MinMaxArc;
-using ::fst::MinMaxWeight;
-using ::fst::PowerWeight;
-using ::fst::StdArc;
-using ::fst::STRING_LEFT;
-using ::fst::STRING_RIGHT;
-using ::fst::StringArc;
-using ::fst::TropicalWeight;
-using ::fst::WeightGenerate;
+using fst::AlgoTester;
+using fst::WeightGenerate;
 
 }  // namespace
 
@@ -70,77 +55,34 @@ int main(int argc, char **argv) {
   VLOG(1) << "default_cache_gc:" << FST_FLAGS_fst_default_cache_gc;
   VLOG(1) << "default_cache_gc_limit:"
           << FST_FLAGS_fst_default_cache_gc_limit;
-
-#ifdef TEST_TROPICAL
-  using TropicalWeightGenerate = WeightGenerate<TropicalWeight>;
-  TropicalWeightGenerate tropical_generator(FST_FLAGS_seed, false);
-  AlgoTester<StdArc, TropicalWeightGenerate> tropical_tester(tropical_generator,
-                                                             FST_FLAGS_seed);
-  tropical_tester.Test();
-#endif  // TEST_TROPICAL
-
-#ifdef TEST_LOG
-  using LogWeightGenerate = WeightGenerate<LogWeight>;
-  LogWeightGenerate log_generator(FST_FLAGS_seed, false);
-  AlgoTester<LogArc, LogWeightGenerate> log_tester(log_generator, FST_FLAGS_seed);
-  log_tester.Test();
-#endif  // TEST_LOG
-
-#ifdef TEST_MINMAX
-  using MinMaxWeightGenerate = WeightGenerate<MinMaxWeight>;
-  MinMaxWeightGenerate minmax_generator(FST_FLAGS_seed, false);
-  AlgoTester<MinMaxArc, MinMaxWeightGenerate> minmax_tester(minmax_generator,
-                                                            FST_FLAGS_seed);
-  minmax_tester.Test();
+#if defined(TEST_TROPICAL)
+  using Arc = fst::StdArc;
+#elif defined(TEST_LOG)
+  using Arc = fst::LogArc;
+#elif defined(TEST_MINMAX)
+  using Arc = fst::MinMaxArc;
+#elif defined(TEST_LEFT_STRING)
+  using Arc = fst::StringArc<fst::STRING_LEFT>;
+#elif defined(TEST_RIGHT_STRING)
+  using Arc = fst::StringArc<fst::STRING_RIGHT>;
+#elif defined(TEST_GALLIC)
+  using Arc = fst::GallicArc<fst::StdArc>;
+#elif defined(TEST_LEXICOGRAPHIC)
+  using fst::LexicographicArc;
+  using fst::TropicalWeight;
+  using Arc = LexicographicArc<TropicalWeight, TropicalWeight>;
+#elif defined(TEST_POWER)
+  using fst::ArcTpl;
+  using fst::PowerWeight;
+  using fst::TropicalWeight;
+  using Arc = ArcTpl<PowerWeight<TropicalWeight, 3>>;
+#else
+  #error "Must have one of the TEST_* macros defined."
 #endif
-
-#ifdef TEST_LEFT_STRING
-  using StringWeightGenerate = WeightGenerate<StringWeight<int, STRING_LEFT>>;
-  StringWeightGenerate left_string_generator(FST_FLAGS_seed, false);
-  AlgoTester<StringArc<>, StringWeightGenerate> left_string_tester(
-      left_string_generator, FST_FLAGS_seed);
-  left_string_tester.Test();
-#endif  // TEST_LEFT_STRING
-
-#ifdef TEST_RIGHT_STRING
-  using StringWeightGenerate = WeightGenerate<StringWeight<int, STRING_RIGHT>>;
-  StringWeightGenerate right_string_generator(FST_FLAGS_seed, false);
-  AlgoTester<StringArc<STRING_RIGHT>, StringWeightGenerate> right_string_tester(
-      right_string_generator, FST_FLAGS_seed);
-  right_string_tester.Test();
-#endif  // TEST_RIGHT_STRING
-
-#ifdef TEST_GALLIC
-  using StdGallicArc = GallicArc<StdArc>;
-  using TropicalGallicWeightGenerate =
-      WeightGenerate<GallicWeight<int, TropicalWeight>>;
-  TropicalGallicWeightGenerate tropical_gallic_generator(FST_FLAGS_seed, false);
-  AlgoTester<StdGallicArc, TropicalGallicWeightGenerate> gallic_tester(
-      tropical_gallic_generator, FST_FLAGS_seed);
-  gallic_tester.Test();
-#endif  // TEST_GALLIC
-
-#ifdef TEST_LEXICOGRAPHIC
-  using TropicalLexicographicArc =
-      LexicographicArc<TropicalWeight, TropicalWeight>;
-  using TropicalLexicographicWeightGenerate =
-      WeightGenerate<LexicographicWeight<TropicalWeight, TropicalWeight>>;
-  TropicalLexicographicWeightGenerate lexicographic_generator(
-      FST_FLAGS_seed, false);
-  AlgoTester<TropicalLexicographicArc, TropicalLexicographicWeightGenerate>
-      lexicographic_tester(lexicographic_generator, FST_FLAGS_seed);
-  lexicographic_tester.Test();
-#endif  // TEST_LEXICOGRAPHIC
-
-#ifdef TEST_POWER
-  using TropicalCubeWeight = PowerWeight<TropicalWeight, 3>;
-  using TropicalCubeArc = ArcTpl<TropicalCubeWeight>;
-  using TropicalCubeWeightGenerate = WeightGenerate<TropicalCubeWeight>;
-  TropicalCubeWeightGenerate tropical_cube_generator(FST_FLAGS_seed, false);
-  AlgoTester<TropicalCubeArc, TropicalCubeWeightGenerate> tropical_cube_tester(
-      tropical_cube_generator, FST_FLAGS_seed);
-  tropical_cube_tester.Test();
-#endif  // TEST_POWER
+  WeightGenerate<Arc::Weight> weight_generator(FST_FLAGS_seed,
+                                               /*allow_zero=*/false);
+  AlgoTester<Arc> arc_tester(weight_generator, FST_FLAGS_seed);
+  arc_tester.Test();
 
   return 0;
 }
index b011ee7..1e92051 100644 (file)
 
 #include <fst/test/fst_test.h>
 
+#include <cstdint>
+#include <string>
+
 #include <fst/flags.h>
-#include <fst/types.h>
 #include <fst/log.h>
 #include <fst/compact-fst.h>
 #include <fst/const-fst.h>
@@ -33,9 +35,9 @@ namespace {
 
 // A user-defined arc type.
 struct CustomArc {
-  using Label = int16;
+  using Label = int16_t;
   using Weight = ProductWeight<TropicalWeight, LogWeight>;
-  using StateId = int64;
+  using StateId = int64_t;
 
   CustomArc(Label i, Label o, Weight w, StateId s)
       : ilabel(i), olabel(o), weight(w), nextstate(s) {}
@@ -60,10 +62,10 @@ static fst::FstRegisterer<
 static fst::FstRegisterer<
     CompactArcFst<CustomArc, TrivialArcCompactor<CustomArc>>>
     CompactFst_CustomArc_TrivialCompactor_registerer;
-static fst::FstRegisterer<ConstFst<StdArc, uint16>>
+static fst::FstRegisterer<ConstFst<StdArc, uint16_t>>
     ConstFst_StdArc_uint16_registerer;
 static fst::FstRegisterer<
-    CompactArcFst<StdArc, TrivialArcCompactor<StdArc>, uint16>>
+    CompactArcFst<StdArc, TrivialArcCompactor<StdArc>, uint16_t>>
     CompactFst_StdArc_TrivialCompactor_uint16_registerer;
 static fst::FstRegisterer<CompactFst<StdArc, TrivialCompactor<StdArc>>>
     CompactFst_StdArc_CustomCompactor_registerer;
@@ -219,18 +221,18 @@ int main(int argc, char **argv) {
     // TODO(jrosenstock): Add tests on default-constructed Fst.
   }
 
-  // ConstFst<StdArc, uint16> tests
+  // ConstFst<StdArc, uint16_t> tests
   {
-    FstTester<ConstFst<StdArc, uint16>> std_const_tester;
+    FstTester<ConstFst<StdArc, uint16_t>> std_const_tester;
     std_const_tester.TestBase();
     std_const_tester.TestExpanded();
     std_const_tester.TestCopy();
     std_const_tester.TestIO();
   }
 
-  // CompactArcFst<StdArc, TrivialArcCompactor<StdArc>, uint16>
+  // CompactArcFst<StdArc, TrivialArcCompactor<StdArc>, uint16_t>
   {
-    FstTester<CompactArcFst<StdArc, TrivialArcCompactor<StdArc>, uint16>>
+    FstTester<CompactArcFst<StdArc, TrivialArcCompactor<StdArc>, uint16_t>>
         std_compact_tester;
     std_compact_tester.TestBase();
     std_compact_tester.TestExpanded();
index 0666d4a..ff77402 100644 (file)
@@ -17,6 +17,8 @@
 //
 // Regression test for FST weights.
 
+#include <cstdint>
+
 #include <fst/flags.h>
 #include <fst/log.h>
 #include <fst/expectation-weight.h>
@@ -57,7 +59,6 @@ using fst::SetWeight;
 using fst::SignedLogWeight;
 using fst::SignedLogWeightTpl;
 using fst::SparsePowerWeight;
-using fst::STRING_LEFT;
 using fst::STRING_RIGHT;
 using fst::StringWeight;
 using fst::TropicalWeight;
@@ -68,33 +69,25 @@ using fst::WeightGenerate;
 using fst::WeightTester;
 
 template <class T>
-void TestTemplatedWeights(uint64 seed, int repeat) {
-  using TropicalWeightGenerate = WeightGenerate<TropicalWeightTpl<T>>;
-  TropicalWeightGenerate tropical_generate(seed);
-  WeightTester<TropicalWeightTpl<T>, TropicalWeightGenerate> tropical_tester(
-      tropical_generate);
+void TestTemplatedWeights(uint64_t seed, int repeat) {
+  WeightGenerate<TropicalWeightTpl<T>> tropical_generate(seed);
+  WeightTester<TropicalWeightTpl<T>> tropical_tester(tropical_generate);
   tropical_tester.Test(repeat);
 
-  using LogWeightGenerate = WeightGenerate<LogWeightTpl<T>>;
-  LogWeightGenerate log_generate(seed);
-  WeightTester<LogWeightTpl<T>, LogWeightGenerate> log_tester(log_generate);
+  WeightGenerate<LogWeightTpl<T>> log_generate(seed);
+  WeightTester<LogWeightTpl<T>> log_tester(log_generate);
   log_tester.Test(repeat);
 
-  using RealWeightGenerate = WeightGenerate<RealWeightTpl<T>>;
-  RealWeightGenerate real_generate(seed);
-  WeightTester<RealWeightTpl<T>, RealWeightGenerate> real_tester(real_generate);
+  WeightGenerate<RealWeightTpl<T>> real_generate(seed);
+  WeightTester<RealWeightTpl<T>> real_tester(real_generate);
   real_tester.Test(repeat);
 
-  using MinMaxWeightGenerate = WeightGenerate<MinMaxWeightTpl<T>>;
-  MinMaxWeightGenerate minmax_generate(seed, true);
-  WeightTester<MinMaxWeightTpl<T>, MinMaxWeightGenerate> minmax_tester(
-      minmax_generate);
+  WeightGenerate<MinMaxWeightTpl<T>> minmax_generate(seed, true);
+  WeightTester<MinMaxWeightTpl<T>> minmax_tester(minmax_generate);
   minmax_tester.Test(repeat);
 
-  using SignedLogWeightGenerate = WeightGenerate<SignedLogWeightTpl<T>>;
-  SignedLogWeightGenerate signedlog_generate(seed, true);
-  WeightTester<SignedLogWeightTpl<T>, SignedLogWeightGenerate> signedlog_tester(
-      signedlog_generate);
+  WeightGenerate<SignedLogWeightTpl<T>> signedlog_generate(seed, true);
+  WeightTester<SignedLogWeightTpl<T>> signedlog_tester(signedlog_generate);
   signedlog_tester.Test(repeat);
 }
 
@@ -330,42 +323,36 @@ int main(int argc, char **argv) {
   TestWeightConversion<TropicalWeight, LogWeight>(2.0);
 
   using LeftStringWeight = StringWeight<int>;
-  using LeftStringWeightGenerate = WeightGenerate<LeftStringWeight>;
-  LeftStringWeightGenerate left_string_generate(FST_FLAGS_seed);
-  WeightTester<LeftStringWeight, LeftStringWeightGenerate> left_string_tester(
-      left_string_generate);
+  WeightGenerate<LeftStringWeight> left_string_generate(
+      FST_FLAGS_seed);
+  WeightTester<LeftStringWeight> left_string_tester(left_string_generate);
   left_string_tester.Test(FST_FLAGS_repeat);
 
   using RightStringWeight = StringWeight<int, STRING_RIGHT>;
-  using RightStringWeightGenerate = WeightGenerate<RightStringWeight>;
-  RightStringWeightGenerate right_string_generate(FST_FLAGS_seed);
-  WeightTester<RightStringWeight, RightStringWeightGenerate>
-      right_string_tester(right_string_generate);
+  WeightGenerate<RightStringWeight> right_string_generate(
+      FST_FLAGS_seed);
+  WeightTester<RightStringWeight> right_string_tester(right_string_generate);
   right_string_tester.Test(FST_FLAGS_repeat);
 
   // STRING_RESTRICT not tested since it requires equal strings,
   // so would fail.
 
   using IUSetWeight = SetWeight<int, SET_INTERSECT_UNION>;
-  using IUSetWeightGenerate = WeightGenerate<IUSetWeight>;
-  IUSetWeightGenerate iu_set_generate(FST_FLAGS_seed);
-  WeightTester<IUSetWeight, IUSetWeightGenerate> iu_set_tester(iu_set_generate);
+  WeightGenerate<IUSetWeight> iu_set_generate(FST_FLAGS_seed);
+  WeightTester<IUSetWeight> iu_set_tester(iu_set_generate);
   iu_set_tester.Test(FST_FLAGS_repeat);
 
   using UISetWeight = SetWeight<int, SET_UNION_INTERSECT>;
-  using UISetWeightGenerate = WeightGenerate<UISetWeight>;
-  UISetWeightGenerate ui_set_generate(FST_FLAGS_seed);
-  WeightTester<UISetWeight, UISetWeightGenerate> ui_set_tester(ui_set_generate);
+  WeightGenerate<UISetWeight> ui_set_generate(FST_FLAGS_seed);
+  WeightTester<UISetWeight> ui_set_tester(ui_set_generate);
   ui_set_tester.Test(FST_FLAGS_repeat);
 
   // SET_INTERSECT_UNION_RESTRICT not tested since it requires equal sets,
   // so would fail.
 
   using BoolSetWeight = SetWeight<int, SET_BOOLEAN>;
-  using BoolSetWeightGenerate = WeightGenerate<BoolSetWeight>;
-  BoolSetWeightGenerate bool_set_generate(FST_FLAGS_seed);
-  WeightTester<BoolSetWeight, BoolSetWeightGenerate> bool_set_tester(
-      bool_set_generate);
+  WeightGenerate<BoolSetWeight> bool_set_generate(FST_FLAGS_seed);
+  WeightTester<BoolSetWeight> bool_set_tester(bool_set_generate);
   bool_set_tester.Test(FST_FLAGS_repeat);
 
   TestWeightConversion<IUSetWeight, UISetWeight>(iu_set_generate());
@@ -387,110 +374,86 @@ int main(int argc, char **argv) {
   // COMPOSITE WEIGHTS AND TESTERS - DEFINITIONS
 
   using TropicalGallicWeight = GallicWeight<int, TropicalWeight>;
-  using TropicalGallicWeightGenerate = WeightGenerate<TropicalGallicWeight>;
-  TropicalGallicWeightGenerate tropical_gallic_generate(
+  WeightGenerate<TropicalGallicWeight> tropical_gallic_generate(
       FST_FLAGS_seed, true);
-  WeightTester<TropicalGallicWeight, TropicalGallicWeightGenerate>
-      tropical_gallic_tester(tropical_gallic_generate);
+  WeightTester<TropicalGallicWeight> tropical_gallic_tester(
+      tropical_gallic_generate);
 
   using TropicalGenGallicWeight = GallicWeight<int, TropicalWeight, GALLIC>;
-  using TropicalGenGallicWeightGenerate =
-      WeightGenerate<TropicalGenGallicWeight>;
-  TropicalGenGallicWeightGenerate tropical_gen_gallic_generate(
+  WeightGenerate<TropicalGenGallicWeight> tropical_gen_gallic_generate(
       FST_FLAGS_seed, false);
-  WeightTester<TropicalGenGallicWeight, TropicalGenGallicWeightGenerate>
-      tropical_gen_gallic_tester(tropical_gen_gallic_generate);
+  WeightTester<TropicalGenGallicWeight> tropical_gen_gallic_tester(
+      tropical_gen_gallic_generate);
 
   using TropicalProductWeight = ProductWeight<TropicalWeight, TropicalWeight>;
-  using TropicalProductWeightGenerate = WeightGenerate<TropicalProductWeight>;
-  TropicalProductWeightGenerate tropical_product_generate(
+  WeightGenerate<TropicalProductWeight> tropical_product_generate(
       FST_FLAGS_seed);
-  WeightTester<TropicalProductWeight, TropicalProductWeightGenerate>
-      tropical_product_tester(tropical_product_generate);
+  WeightTester<TropicalProductWeight> tropical_product_tester(
+      tropical_product_generate);
 
   using TropicalLexicographicWeight =
       LexicographicWeight<TropicalWeight, TropicalWeight>;
-  using TropicalLexicographicWeightGenerate =
-      WeightGenerate<TropicalLexicographicWeight>;
-  TropicalLexicographicWeightGenerate tropical_lexicographic_generate(
+  WeightGenerate<TropicalLexicographicWeight> tropical_lexicographic_generate(
       FST_FLAGS_seed);
-  WeightTester<TropicalLexicographicWeight, TropicalLexicographicWeightGenerate>
-      tropical_lexicographic_tester(tropical_lexicographic_generate);
+  WeightTester<TropicalLexicographicWeight> tropical_lexicographic_tester(
+      tropical_lexicographic_generate);
 
   using TropicalCubeWeight = PowerWeight<TropicalWeight, 3>;
-  using TropicalCubeWeightGenerate = WeightGenerate<TropicalCubeWeight>;
-  TropicalCubeWeightGenerate tropical_cube_generate(FST_FLAGS_seed);
-  WeightTester<TropicalCubeWeight, TropicalCubeWeightGenerate>
-      tropical_cube_tester(tropical_cube_generate);
+  WeightGenerate<TropicalCubeWeight> tropical_cube_generate(
+      FST_FLAGS_seed);
+  WeightTester<TropicalCubeWeight> tropical_cube_tester(tropical_cube_generate);
 
   using FirstNestedProductWeight =
       ProductWeight<TropicalProductWeight, TropicalWeight>;
-  using FirstNestedProductWeightGenerate =
-      WeightGenerate<FirstNestedProductWeight>;
-  FirstNestedProductWeightGenerate first_nested_product_generate(
+  WeightGenerate<FirstNestedProductWeight> first_nested_product_generate(
       FST_FLAGS_seed);
-  WeightTester<FirstNestedProductWeight, FirstNestedProductWeightGenerate>
-      first_nested_product_tester(first_nested_product_generate);
+  WeightTester<FirstNestedProductWeight> first_nested_product_tester(
+      first_nested_product_generate);
 
   using SecondNestedProductWeight =
       ProductWeight<TropicalWeight, TropicalProductWeight>;
-  using SecondNestedProductWeightGenerate =
-      WeightGenerate<SecondNestedProductWeight>;
-  SecondNestedProductWeightGenerate second_nested_product_generate(
+  WeightGenerate<SecondNestedProductWeight> second_nested_product_generate(
       FST_FLAGS_seed);
-  WeightTester<SecondNestedProductWeight, SecondNestedProductWeightGenerate>
-      second_nested_product_tester(second_nested_product_generate);
+  WeightTester<SecondNestedProductWeight> second_nested_product_tester(
+      second_nested_product_generate);
 
   using NestedProductCubeWeight = PowerWeight<FirstNestedProductWeight, 3>;
-  using NestedProductCubeWeightGenerate =
-      WeightGenerate<NestedProductCubeWeight>;
-  NestedProductCubeWeightGenerate nested_product_cube_generate(
+  WeightGenerate<NestedProductCubeWeight> nested_product_cube_generate(
       FST_FLAGS_seed);
-  WeightTester<NestedProductCubeWeight, NestedProductCubeWeightGenerate>
-      nested_product_cube_tester(nested_product_cube_generate);
+  WeightTester<NestedProductCubeWeight> nested_product_cube_tester(
+      nested_product_cube_generate);
 
   using SparseNestedProductCubeWeight =
       SparsePowerWeight<NestedProductCubeWeight, size_t>;
-  using SparseNestedProductCubeWeightGenerate =
-      WeightGenerate<SparseNestedProductCubeWeight>;
-  SparseNestedProductCubeWeightGenerate sparse_nested_product_cube_generate(
-      FST_FLAGS_seed);
-  WeightTester<SparseNestedProductCubeWeight,
-               SparseNestedProductCubeWeightGenerate>
-      sparse_nested_product_cube_tester(sparse_nested_product_cube_generate);
+  WeightGenerate<SparseNestedProductCubeWeight>
+      sparse_nested_product_cube_generate(FST_FLAGS_seed);
+  WeightTester<SparseNestedProductCubeWeight> sparse_nested_product_cube_tester(
+      sparse_nested_product_cube_generate);
 
   using LogSparsePowerWeight = SparsePowerWeight<LogWeight, size_t>;
-  using LogSparsePowerWeightGenerate = WeightGenerate<LogSparsePowerWeight>;
-  LogSparsePowerWeightGenerate log_sparse_power_generate(
+  WeightGenerate<LogSparsePowerWeight> log_sparse_power_generate(
       FST_FLAGS_seed);
-  WeightTester<LogSparsePowerWeight, LogSparsePowerWeightGenerate>
-      log_sparse_power_tester(log_sparse_power_generate);
+  WeightTester<LogSparsePowerWeight> log_sparse_power_tester(
+      log_sparse_power_generate);
 
   using LogLogExpectationWeight = ExpectationWeight<LogWeight, LogWeight>;
-  using LogLogExpectationWeightGenerate =
-      WeightGenerate<LogLogExpectationWeight>;
-  LogLogExpectationWeightGenerate log_log_expectation_generate(
+  WeightGenerate<LogLogExpectationWeight> log_log_expectation_generate(
       FST_FLAGS_seed);
-  WeightTester<LogLogExpectationWeight, LogLogExpectationWeightGenerate>
-      log_log_expectation_tester(log_log_expectation_generate);
+  WeightTester<LogLogExpectationWeight> log_log_expectation_tester(
+      log_log_expectation_generate);
 
-  using RealRealExpectationWeight = ExpectationWeight<LogWeight, LogWeight>;
-  using RealRealExpectationWeightGenerate =
-      WeightGenerate<RealRealExpectationWeight>;
-  RealRealExpectationWeightGenerate real_real_expectation_generate(
+  using RealRealExpectationWeight = ExpectationWeight<RealWeight, RealWeight>;
+  WeightGenerate<RealRealExpectationWeight> real_real_expectation_generate(
       FST_FLAGS_seed);
-  WeightTester<RealRealExpectationWeight, RealRealExpectationWeightGenerate>
-      real_real_expectation_tester(real_real_expectation_generate);
+  WeightTester<RealRealExpectationWeight> real_real_expectation_tester(
+      real_real_expectation_generate);
 
   using LogLogSparseExpectationWeight =
       ExpectationWeight<LogWeight, LogSparsePowerWeight>;
-  using LogLogSparseExpectationWeightGenerate =
-      WeightGenerate<LogLogSparseExpectationWeight>;
-  LogLogSparseExpectationWeightGenerate log_log_sparse_expectation_generate(
-      FST_FLAGS_seed);
-  WeightTester<LogLogSparseExpectationWeight,
-               LogLogSparseExpectationWeightGenerate>
-      log_log_sparse_expectation_tester(log_log_sparse_expectation_generate);
+  WeightGenerate<LogLogSparseExpectationWeight>
+      log_log_sparse_expectation_generate(FST_FLAGS_seed);
+  WeightTester<LogLogSparseExpectationWeight> log_log_sparse_expectation_tester(
+      log_log_sparse_expectation_generate);
 
   struct UnionWeightOptions {
     using Compare = NaturalLess<TropicalWeight>;
@@ -506,11 +469,10 @@ int main(int argc, char **argv) {
   };
 
   using TropicalUnionWeight = UnionWeight<TropicalWeight, UnionWeightOptions>;
-  using TropicalUnionWeightGenerate = WeightGenerate<TropicalUnionWeight>;
-  TropicalUnionWeightGenerate tropical_union_generate(
+  WeightGenerate<TropicalUnionWeight> tropical_union_generate(
       FST_FLAGS_seed);
-  WeightTester<TropicalUnionWeight, TropicalUnionWeightGenerate>
-      tropical_union_tester(tropical_union_generate);
+  WeightTester<TropicalUnionWeight> tropical_union_tester(
+      tropical_union_generate);
 
   // COMPOSITE WEIGHTS AND TESTERS - TESTING
 
index 9759384..be73b80 100755 (executable)
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 2011-2020 Free Software Foundation, Inc.
+# Copyright (C) 2011-2021 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
@@ -105,8 +105,11 @@ trap "st=130; $do_exit" 2
 trap "st=141; $do_exit" 13
 trap "st=143; $do_exit" 15
 
-# Test script is run here.
-"$@" >$log_file 2>&1
+# Test script is run here. We create the file first, then append to it,
+# to ameliorate tests themselves also writing to the log file. Our tests
+# don't, but others can (automake bug#35762).
+: >"$log_file"
+"$@" >>"$log_file" 2>&1
 estatus=$?
 
 if test $enable_hard_errors = no && test $estatus -eq 99; then
@@ -128,7 +131,7 @@ esac
 # know whether the test passed or failed simply by looking at the '.log'
 # file, without the need of also peaking into the corresponding '.trs'
 # file (automake bug#11814).
-echo "$res $test_name (exit status: $estatus)" >>$log_file
+echo "$res $test_name (exit status: $estatus)" >>"$log_file"
 
 # Report outcome to console.
 echo "${col}${res}${std}: $test_name"