diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2023-08-31 23:02:37 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2023-08-31 23:02:37 +0000 |
commit | ccd166583d2b4e9b5f14a0be92620c03cc97227e (patch) | |
tree | cd34c73bf7ada7cbb9d38d228454e7e8dd296250 | |
parent | c6a5821a086bfbfaac58c9991cf6dcbe34a33526 (diff) |
lcdf-typetools 2.110
git-svn-id: svn://tug.org/texlive/trunk@68131 c570f23f-e606-0410-a88d-b1316a301751
98 files changed, 5655 insertions, 4959 deletions
diff --git a/Build/source/texk/README b/Build/source/texk/README index dc01bd69314..56bd268a3c0 100644 --- a/Build/source/texk/README +++ b/Build/source/texk/README @@ -75,7 +75,7 @@ gsftopk - from Paul Vojta's xdvi. kpathsea - maintained here, by us -lcdf-typetools 2.108 - checked 31may22 +lcdf-typetools 2.110 - checked 01sep23 https://www.lcdf.org/type/ makeindexk - maintained here, by us diff --git a/Build/source/texk/lcdf-typetools/ChangeLog b/Build/source/texk/lcdf-typetools/ChangeLog index b846e857844..84de5fb94a7 100644 --- a/Build/source/texk/lcdf-typetools/ChangeLog +++ b/Build/source/texk/lcdf-typetools/ChangeLog @@ -1,3 +1,8 @@ +2023-09-01 Akira Kakuto <kakuto@jcom.zaq.ne.jp> + + Import lcdf-typetools-2.110. + * version.ac: Adapted. + 2019-01-28 Akira Kakuto <kakuto@w32tex.org> Import lcdf-typetools-2.108. diff --git a/Build/source/texk/lcdf-typetools/TLpatches/ChangeLog b/Build/source/texk/lcdf-typetools/TLpatches/ChangeLog index a626ca3bda3..f9721eeb7f5 100644 --- a/Build/source/texk/lcdf-typetools/TLpatches/ChangeLog +++ b/Build/source/texk/lcdf-typetools/TLpatches/ChangeLog @@ -1,3 +1,9 @@ +2023-09-01 Akira Kakuto <kakuto@jcom.zaq.ne.jp> + + Import lcdf-typetools-2.110. + * patch-02-mingw64: Remove. + * patch-03-w32: Adapted. + 2019-01-30 Akira Kakuto <kakuto@w32tex.org> * patch-03-w32: Remove wrong changes. diff --git a/Build/source/texk/lcdf-typetools/TLpatches/TL-Changes b/Build/source/texk/lcdf-typetools/TLpatches/TL-Changes index 8de5cfa9857..c275a6e35eb 100644 --- a/Build/source/texk/lcdf-typetools/TLpatches/TL-Changes +++ b/Build/source/texk/lcdf-typetools/TLpatches/TL-Changes @@ -1,8 +1,9 @@ Changes applied to the lcdf-typetools tree as obtained from: - http://www.lcdf.org/type/lcdf-typetools-2.108.tar.gz + http://www.lcdf.org/type/lcdf-typetools-2.110.tar.gz Removed: aclocal.m4 + ar-lib compile configure depcomp diff --git a/Build/source/texk/lcdf-typetools/TLpatches/patch-02-mingw64 b/Build/source/texk/lcdf-typetools/TLpatches/patch-02-mingw64 deleted file mode 100644 index 401b55ace58..00000000000 --- a/Build/source/texk/lcdf-typetools/TLpatches/patch-02-mingw64 +++ /dev/null @@ -1,11 +0,0 @@ -diff -ur lcdf-typetools-2.108/include/config.h lcdf-typetools-src/include/config.h ---- lcdf-typetools-2.108/include/config.h Mon Jan 28 03:39:19 2019 -+++ lcdf-typetools-src/include/config.h Mon Jan 28 07:59:03 2019 -@@ -7,6 +7,7 @@ - #ifdef WIN32 - # ifdef __MINGW32__ - # include <winsock2.h> -+# include <windows.h> - # else - # include <win32lib.h> - # endif diff --git a/Build/source/texk/lcdf-typetools/TLpatches/patch-03-w32 b/Build/source/texk/lcdf-typetools/TLpatches/patch-03-w32 index e01b835b9db..83d0a477314 100644 --- a/Build/source/texk/lcdf-typetools/TLpatches/patch-03-w32 +++ b/Build/source/texk/lcdf-typetools/TLpatches/patch-03-w32 @@ -1,6 +1,6 @@ -diff -ur lcdf-typetools-2.108/liblcdf/filename.cc lcdf-typetools-src/liblcdf/filename.cc ---- lcdf-typetools-2.108/liblcdf/filename.cc Mon Jan 28 03:39:19 2019 -+++ lcdf-typetools-src/liblcdf/filename.cc Thu Jan 31 06:16:24 2019 +diff -ur lcdf-typetools-2.110/liblcdf/filename.cc lcdf-typetools-src/liblcdf/filename.cc +--- lcdf-typetools-2.110/liblcdf/filename.cc Fri Apr 08 02:43:00 2022 ++++ lcdf-typetools-src/liblcdf/filename.cc Fri Sep 01 07:11:55 2023 @@ -126,5 +126,5 @@ if (_actual || !_path) return _actual; @@ -8,193 +8,3 @@ diff -ur lcdf-typetools-2.108/liblcdf/filename.cc lcdf-typetools-src/liblcdf/fil - return fopen(_path.c_str(), binary ? "wb" : "w"); + return fopen(_path.c_str(), "wb"); } -diff -ur lcdf-typetools-2.108/otftotfm/automatic.cc lcdf-typetools-src/otftotfm/automatic.cc ---- lcdf-typetools-2.108/otftotfm/automatic.cc Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/otftotfm/automatic.cc Thu Jan 31 06:35:14 2019 -@@ -39,7 +39,9 @@ - #include <algorithm> - - #ifdef WIN32 --# define mkdir(dir, access) mkdir(dir) -+# include <io.h> -+# include <direct.h> -+# define mkdir(dir, access) _mkdir(dir) - # define COPY_CMD "copy" - # define CMD_SEP "&" - #else -@@ -124,7 +126,18 @@ - static void - find_writable_texdir(ErrorHandler *errh, const char *) - { -+#if defined(W32TEX) -+// W32TeX does not have TEXMFVAR -+ char *p = kpsei_var_value("TEXMFVAR"); -+ if (p == NULL) // W32TeX -+ look_for_writable_texdir("$TEXMFLOCAL", true); -+ else { // TeXLive -+ free (p); -+ look_for_writable_texdir("$TEXMFVAR", true); -+ } -+#else - look_for_writable_texdir("$TEXMFVAR", true); -+#endif - if (!writable_texdir) - look_for_writable_texdir("$VARTEXMF", false); - if (!writable_texdir) -@@ -313,7 +326,7 @@ - String ls_r = writable_texdir + "ls-R"; - bool success = false; - if (access(ls_r.c_str(), R_OK) >= 0) // make sure it already exists -- if (FILE *f = fopen(ls_r.c_str(), "a")) { -+ if (FILE *f = fopen(ls_r.c_str(), "ab")) { - fprintf(f, "./%s:\n%s\n", directory.c_str(), file.c_str()); - success = true; - fclose(f); -@@ -323,7 +336,11 @@ - if (!success && writable_texdir.find_left('\'') < 0 && directory.find_left('\'') < 0 && file.find_left('\'') < 0) { - // look for mktexupd script - if (!mktexupd_tried) { -+#ifdef _WIN32 -+ mktexupd = "mktexupd.exe"; -+#else - mktexupd = kpsei_string(kpsei_find_file("mktexupd", KPSEI_FMT_WEB2C)); -+#endif - mktexupd_tried = true; - } - -@@ -677,7 +694,7 @@ - #endif - { - fclose(f); -- f = fopen(map_file.c_str(), "w"); -+ f = fopen(map_file.c_str(), "wb"); - fd = fileno(f); - } - -diff -ur lcdf-typetools-2.108/otftotfm/kpseinterface.c lcdf-typetools-src/otftotfm/kpseinterface.c ---- lcdf-typetools-2.108/otftotfm/kpseinterface.c Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/otftotfm/kpseinterface.c Thu Jan 31 06:37:34 2019 -@@ -21,6 +21,9 @@ - #include <kpathsea/expand.h> - #include <kpathsea/c-pathch.h> - #include <kpathsea/tex-file.h> -+#ifdef W32TEX -+#include <kpathsea/variable.h> -+#endif - #include "kpseinterface.h" - - int kpsei_env_sep_char = ENV_SEP; -@@ -86,3 +89,11 @@ - { - kpathsea_debug = flags; - } -+ -+#ifdef W32TEX -+char* -+kpsei_var_value(const char *name) -+{ -+ return kpse_var_value(name); -+} -+#endif -diff -ur lcdf-typetools-2.108/otftotfm/kpseinterface.h lcdf-typetools-src/otftotfm/kpseinterface.h ---- lcdf-typetools-2.108/otftotfm/kpseinterface.h Thu Jun 23 21:25:52 2016 -+++ lcdf-typetools-src/otftotfm/kpseinterface.h Thu Jan 31 06:38:40 2019 -@@ -13,6 +13,10 @@ - char* kpsei_find_file(const char* name, int format); - void kpsei_set_debug_flags(unsigned flags); - -+#ifdef W32TEX -+char* kpsei_var_value(const char *name); -+#endif -+ - #ifdef __cplusplus - } - #endif -diff -ur lcdf-typetools-2.108/otftotfm/otftotfm.cc lcdf-typetools-src/otftotfm/otftotfm.cc ---- lcdf-typetools-2.108/otftotfm/otftotfm.cc Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/otftotfm/otftotfm.cc Thu Jan 31 06:40:59 2019 -@@ -63,6 +63,9 @@ - #ifdef HAVE_FCNTL_H - # include <fcntl.h> - #endif -+#ifdef _MSC_VER -+# include <io.h> -+#endif - - using namespace Efont; - -@@ -590,7 +593,7 @@ - - if (verbose) - errh->message("creating %s", filename.c_str()); -- FILE *f = fopen(filename.c_str(), "w"); -+ FILE *f = fopen(filename.c_str(), "wb"); - if (!f) { - errh->error("%s: %s", filename.c_str(), strerror(errno)); - return; -@@ -1048,7 +1051,7 @@ - #endif - { - fclose(f); -- f = fopen(filename.c_str(), "w"); -+ f = fopen(filename.c_str(), "wb"); - fd = fileno(f); - } - -diff -ur lcdf-typetools-2.108/t1dotlessj/t1dotlessj.cc lcdf-typetools-src/t1dotlessj/t1dotlessj.cc ---- lcdf-typetools-2.108/t1dotlessj/t1dotlessj.cc Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/t1dotlessj/t1dotlessj.cc Thu Jan 31 06:43:35 2019 -@@ -410,10 +410,10 @@ - // write it to output - if (!outputf) - outputf = stdout; -- if (binary) { - #if defined(_MSDOS) || defined(_WIN32) -- _setmode(_fileno(outputf), _O_BINARY); -+ _setmode(_fileno(outputf), _O_BINARY); - #endif -+ if (binary) { - Type1PFBWriter w(outputf); - dotless_font->write(w); - } else { -diff -ur lcdf-typetools-2.108/t1rawafm/t1rawafm.cc lcdf-typetools-src/t1rawafm/t1rawafm.cc ---- lcdf-typetools-2.108/t1rawafm/t1rawafm.cc Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/t1rawafm/t1rawafm.cc Thu Jan 31 06:44:47 2019 -@@ -359,6 +359,9 @@ - if (!outf) - errh->fatal("%s: %s", output_file, strerror(errno)); - } -+#if defined(_MSDOS) || defined(_WIN32) -+ _setmode(_fileno(outf), _O_BINARY); -+#endif - - write_afm(outf, font); - -diff -ur lcdf-typetools-2.108/t1reencode/t1reencode.cc lcdf-typetools-src/t1reencode/t1reencode.cc ---- lcdf-typetools-2.108/t1reencode/t1reencode.cc Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/t1reencode/t1reencode.cc Thu Jan 31 06:46:38 2019 -@@ -1094,10 +1094,10 @@ - if (!outf) - errh->fatal("%s: %s", output_file, strerror(errno)); - } -- if (binary) { - #if defined(_MSDOS) || defined(_WIN32) -- _setmode(_fileno(outf), _O_BINARY); -+ _setmode(_fileno(outf), _O_BINARY); - #endif -+ if (binary) { - Type1PFBWriter w(outf); - font->write(w); - } else { -diff -ur lcdf-typetools-2.108/t1testpage/t1testpage.cc lcdf-typetools-src/t1testpage/t1testpage.cc ---- lcdf-typetools-2.108/t1testpage/t1testpage.cc Mon Jan 28 03:39:20 2019 -+++ lcdf-typetools-src/t1testpage/t1testpage.cc Thu Jan 31 06:47:51 2019 -@@ -665,6 +665,9 @@ - if (!outf) - errh->fatal("%s: %s", output_file, strerror(errno)); - } -+#if defined(_MSDOS) || defined(_WIN32) -+ _setmode(_fileno(outf), _O_BINARY); -+#endif - - //font->undo_synthetic(); diff --git a/Build/source/texk/lcdf-typetools/configure b/Build/source/texk/lcdf-typetools/configure index 19bc60df083..eb64e47b3e5 100755 --- a/Build/source/texk/lcdf-typetools/configure +++ b/Build/source/texk/lcdf-typetools/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for LCDF typetools (TeX Live) 2.108. +# Generated by GNU Autoconf 2.71 for LCDF typetools (TeX Live) 2.110. # # Report bugs to <tex-k@tug.org>. # @@ -629,8 +629,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='LCDF typetools (TeX Live)' PACKAGE_TARNAME='lcdf-typetools--tex-live-' -PACKAGE_VERSION='2.108' -PACKAGE_STRING='LCDF typetools (TeX Live) 2.108' +PACKAGE_VERSION='2.110' +PACKAGE_STRING='LCDF typetools (TeX Live) 2.110' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1417,7 +1417,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 LCDF typetools (TeX Live) 2.108 to adapt to many kinds of systems. +\`configure' configures LCDF typetools (TeX Live) 2.110 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1489,7 +1489,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of LCDF typetools (TeX Live) 2.108:";; + short | recursive ) echo "Configuration of LCDF typetools (TeX Live) 2.110:";; esac cat <<\_ACEOF @@ -1635,7 +1635,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -LCDF typetools (TeX Live) configure 2.108 +LCDF typetools (TeX Live) configure 2.110 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2691,7 +2691,7 @@ 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 LCDF typetools (TeX Live) $as_me 2.108, which was +It was created by LCDF typetools (TeX Live) $as_me 2.110, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -9348,7 +9348,7 @@ fi # Define the identity of the package. PACKAGE='lcdf-typetools--tex-live-' - VERSION='2.108' + VERSION='2.110' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -15252,7 +15252,7 @@ fi -LCDF_TYPETOOLS_VERSION=2.108 +LCDF_TYPETOOLS_VERSION=2.110 ac_config_headers="$ac_config_headers autoconf.h" @@ -21548,7 +21548,7 @@ Usage: $0 [OPTIONS] Report bugs to <bug-libtool@gnu.org>." lt_cl_version="\ -LCDF typetools (TeX Live) config.lt 2.108 +LCDF typetools (TeX Live) config.lt 2.110 configured by $0, generated by GNU Autoconf 2.71. Copyright (C) 2011 Free Software Foundation, Inc. @@ -23624,7 +23624,7 @@ 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 LCDF typetools (TeX Live) $as_me 2.108, which was +This file was extended by LCDF typetools (TeX Live) $as_me 2.110, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -23692,7 +23692,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -LCDF typetools (TeX Live) config.status 2.108 +LCDF typetools (TeX Live) config.status 2.110 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.am b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.am index 0bb3d977ad2..d59afbc8308 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.am +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.am @@ -38,6 +38,7 @@ EXTRA_DIST = \ include/efont/otf.hh \ include/efont/otfcmap.hh \ include/efont/otfdata.hh \ + include/efont/otffvar.hh \ include/efont/otfgpos.hh \ include/efont/otfgsub.hh \ include/efont/otfname.hh \ diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.in b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.in index 563e9a30875..808ac3998ef 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.in +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/Makefile.in @@ -396,6 +396,7 @@ EXTRA_DIST = \ include/efont/otf.hh \ include/efont/otfcmap.hh \ include/efont/otfdata.hh \ + include/efont/otffvar.hh \ include/efont/otfgpos.hh \ include/efont/otfgsub.hh \ include/efont/otfname.hh \ diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/NEWS.md b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/NEWS.md index 68382c0e911..80458c2fea4 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/NEWS.md +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/NEWS.md @@ -1,6 +1,22 @@ LCDF Typetools NEWS =================== +## Version 2.110 – 30.Aug.2023 + +* Support `otfinfo --var`, which prints information about variable fonts. + +* `otfinfo -u` reports all Unicode code positions, not just the BMP. + +* `otfinfo -i` reports embedding permissions. + +* Update feature, language, and script descriptions. + + +## Version 2.109 – 29.Aug.2023 + +* Change output to avoid triggering pdftex bug. + + ## Version 2.108 – 27.Jan.2019 * Handle more fonts. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/README.md b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/README.md index 8666241a121..d1577d22450 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/README.md +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/README.md @@ -99,7 +99,7 @@ named `FONTNAME.afm` -- `MyriadMM-LightCn.afm`, for example. Copyright and license --------------------- -All source code is Copyright (c) 1997-2019 Eddie Kohler. +All source code is Copyright (c) 1997-2023 Eddie Kohler. This code is distributed under the GNU General Public License, Version 2 (and only Version 2). The GNU General Public License is available via the diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/autoconf.h.in b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/autoconf.h.in index 178587ae6d4..c31ee8b09fb 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/autoconf.h.in +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/autoconf.h.in @@ -73,9 +73,6 @@ /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the `mkstemp' function. */ #undef HAVE_MKSTEMP @@ -103,6 +100,9 @@ /* 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 @@ -211,7 +211,9 @@ /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P -/* 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 */ diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.1 index 43057e099eb..1a35b5da3d7 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.cc index c77ddd2f512..c4eb938bc32 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/cfftot1.cc @@ -1,6 +1,6 @@ /* cfftot1.cc -- driver for translating CFF fonts to Type 1 fonts * - * Copyright (c) 2002-2019 Eddie Kohler + * Copyright (c) 2002-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -38,13 +38,13 @@ using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define QUIET_OPT 303 -#define PFB_OPT 304 -#define PFA_OPT 305 -#define OUTPUT_OPT 306 -#define NAME_OPT 307 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define QUIET_OPT 303 +#define PFB_OPT 304 +#define PFA_OPT 305 +#define OUTPUT_OPT 306 +#define NAME_OPT 307 const Clp_Option options[] = { { "ascii", 'a', PFA_OPT, 0, 0 }, @@ -69,11 +69,12 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) va_list val; va_start(val, error_message); if (!error_message) - errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name); + errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name); else - errh->xmessage(ErrorHandler::e_error, error_message, val); + errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -108,13 +109,13 @@ do_file(const char *infn, const char *outfn, PermString name, ErrorHandler *errh { FILE *f; if (!infn || strcmp(infn, "-") == 0) { - f = stdin; - infn = "<stdin>"; + f = stdin; + infn = "<stdin>"; #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif } else if (!(f = fopen(infn, "rb"))) - errh->fatal("%s: %s", infn, strerror(errno)); + errh->fatal("%s: %s", infn, strerror(errno)); int c = getc(f); ungetc(c, f); @@ -122,23 +123,23 @@ do_file(const char *infn, const char *outfn, PermString name, ErrorHandler *errh Cff::Font *font = 0; if (c == EOF) - errh->fatal("%s: empty file", infn); + errh->fatal("%s: empty file", infn); if (c != 1 && c != 'O') - errh->fatal("%s: not a CFF or OpenType/CFF font", infn); + errh->fatal("%s: not a CFF or OpenType/CFF font", infn); StringAccum sa(150000); int amt; do { - if (char *x = sa.reserve(32768)) { - amt = fread(x, 1, 32768, f); - sa.adjust_length(amt); - } else - amt = 0; + if (char *x = sa.reserve(32768)) { + amt = fread(x, 1, 32768, f); + sa.adjust_length(amt); + } else + amt = 0; } while (amt != 0); if (!feof(f) || ferror(f)) - errh->lerror(infn, "%s", strerror(errno)); + errh->lerror(infn, "%s", strerror(errno)); if (f != stdin) - fclose(f); + fclose(f); ContextErrorHandler cerrh(errh, "While processing %s:", infn); cerrh.set_indent(0); @@ -146,47 +147,47 @@ do_file(const char *infn, const char *outfn, PermString name, ErrorHandler *errh unsigned units_per_em = 0; if (c == 'O') { Efont::OpenType::Font font(data, &cerrh); - data = font.table("CFF"); + data = font.table("CFF"); units_per_em = font.units_per_em(); } Cff *cff = new Cff(data, units_per_em, &cerrh); Cff::FontParent *fp = cff->font(name, &cerrh); if (errh->nerrors() == 0 - && !(font = dynamic_cast<Cff::Font *>(fp))) - errh->fatal("%s: CID-keyed fonts not supported", infn); + && !(font = dynamic_cast<Cff::Font *>(fp))) + errh->fatal("%s: CID-keyed fonts not supported", infn); if (errh->nerrors() > 0) - return; + return; Type1Font *font1 = create_type1_font(font, &cerrh); if (!outfn || strcmp(outfn, "-") == 0) { - f = stdout; - outfn = "<stdout>"; + f = stdout; + outfn = "<stdout>"; } else if (!(f = fopen(outfn, "wb"))) - errh->fatal("%s: %s", outfn, strerror(errno)); + errh->fatal("%s: %s", outfn, strerror(errno)); if (binary) { #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif - Type1PFBWriter t1w(f); - font1->write(t1w); + Type1PFBWriter t1w(f); + font1->write(t1w); } else { - Type1PFAWriter t1w(f); - font1->write(t1w); + Type1PFAWriter t1w(f); + font1->write(t1w); } if (f != stdout) - fclose(f); + fclose(f); } int main(int argc, char *argv[]) { Clp_Parser *clp = - Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); + Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); program_name = Clp_ProgramName(clp); ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr, String(program_name) + ": ")); @@ -195,71 +196,71 @@ main(int argc, char *argv[]) const char *font_name = 0; while (1) { - int opt = Clp_Next(clp); - switch (opt) { - - case PFA_OPT: - binary = false; - break; - - case PFB_OPT: - binary = true; - break; - - case NAME_OPT: - if (font_name) - usage_error(errh, "font name specified twice"); - font_name = clp->vstr; - break; - - case QUIET_OPT: - if (clp->negated) - errh = ErrorHandler::default_handler(); - else - errh = new SilentErrorHandler; - break; - - case VERSION_OPT: - printf("cfftot1 (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 2002-2019 Eddie Kohler\n\ + int opt = Clp_Next(clp); + switch (opt) { + + case PFA_OPT: + binary = false; + break; + + case PFB_OPT: + binary = true; + break; + + case NAME_OPT: + if (font_name) + usage_error(errh, "font name specified twice"); + font_name = clp->vstr; + break; + + case QUIET_OPT: + if (clp->negated) + errh = ErrorHandler::default_handler(); + else + errh = new SilentErrorHandler; + break; + + case VERSION_OPT: + printf("cfftot1 (LCDF typetools) %s\n", VERSION); + printf("Copyright (C) 2002-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); - exit(0); - break; - - case HELP_OPT: - usage(); - exit(0); - break; - - case OUTPUT_OPT: - output_file: - if (output_file) - usage_error(errh, "output file specified twice"); - output_file = clp->vstr; - break; - - case Clp_NotOption: - if (input_file && output_file) - usage_error(errh, "too many arguments"); - else if (input_file) - goto output_file; - else - input_file = clp->vstr; - break; - - case Clp_Done: - goto done; - - case Clp_BadOption: - usage_error(errh, 0); - break; - - default: - break; - - } + exit(0); + break; + + case HELP_OPT: + usage(); + exit(0); + break; + + case OUTPUT_OPT: + output_file: + if (output_file) + usage_error(errh, "output file specified twice"); + output_file = clp->vstr; + break; + + case Clp_NotOption: + if (input_file && output_file) + usage_error(errh, "too many arguments"); + else if (input_file) + goto output_file; + else + input_file = clp->vstr; + break; + + case Clp_Done: + goto done; + + case Clp_BadOption: + usage_error(errh, 0); + break; + + default: + break; + + } } done: diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/maket1font.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/maket1font.cc index 54a4000b9bd..f12fc283201 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/maket1font.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/cfftot1/maket1font.cc @@ -1,6 +1,6 @@ /* maket1font.{cc,hh} -- translate CFF fonts to Type 1 fonts * - * Copyright (c) 2002-2019 Eddie Kohler + * Copyright (c) 2002-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -35,7 +35,7 @@ class MakeType1CharstringInterp : public Type1CharstringGenInterp { public: MakeType1CharstringInterp(int precision = 5); ~MakeType1CharstringInterp(); - Type1Font *output() const { return _output; } + Type1Font *output() const { return _output; } void run(const CharstringProgram *, Type1Font *, PermString glyph_definer, ErrorHandler *); void run(const CharstringContext &, Type1Charstring &, ErrorHandler *); @@ -69,40 +69,40 @@ class MakeType1CharstringInterp : public Type1CharstringGenInterp { public: class MakeType1CharstringInterp::Subr { public: - Subr(CsRef csr) : _csr(csr), _output_subrno(-1), _stamp(0) { } + Subr(CsRef csr) : _csr(csr), _output_subrno(-1), _stamp(0) { } - bool up_to_date() const { return _stamp == max_stamp; } - void update() { _stamp = max_stamp; } - static void bump_date() { max_stamp++; } + bool up_to_date() const { return _stamp == max_stamp; } + void update() { _stamp = max_stamp; } + static void bump_date() { max_stamp++; } //String name(const MakeType1CharstringInterp *) const; Type1Charstring *charstring(const MakeType1CharstringInterp *) const; - int ncalls() const { return _calls.size(); } - Subr *call(int i) const { return _calls[i]; } + int ncalls() const { return _calls.size(); } + Subr *call(int i) const { return _calls[i]; } bool has_call(Subr *) const; struct Caller { - Subr *subr; - int pos; - int len; - Caller(Subr *s, int p, int l) + Subr *subr; + int pos; + int len; + Caller(Subr *s, int p, int l) : subr(s), pos(p), len(l) { } - String charstring(MakeType1CharstringInterp *mcsi) const { - Type1Charstring *t1cs = subr->charstring(mcsi); - return t1cs->substring(pos, len); - } + String charstring(MakeType1CharstringInterp *mcsi) const { + Type1Charstring *t1cs = subr->charstring(mcsi); + return t1cs->substring(pos, len); + } }; - int ncallers() const { return _callers.size(); } - const Caller &caller(int i) const { return _callers[i]; } + int ncallers() const { return _callers.size(); } + const Caller &caller(int i) const { return _callers[i]; } - void add_call(Subr *s) { _calls.push_back(s); } + void add_call(Subr *s) { _calls.push_back(s); } void add_caller(Subr *s, int pos, int len); - int output_subrno() const { return _output_subrno; } - void set_output_subrno(int n) { _output_subrno = n; } + int output_subrno() const { return _output_subrno; } + void set_output_subrno(int n) { _output_subrno = n; } void transfer_nested_calls(int pos, int length, Subr *new_caller) const; void change_callers(Subr *, int pos, int length, int new_length); @@ -135,8 +135,8 @@ bool MakeType1CharstringInterp::Subr::has_call(Subr *s) const { for (int i = 0; i < _calls.size(); i++) - if (_calls[i] == s) - return true; + if (_calls[i] == s) + return true; return false; } @@ -153,20 +153,20 @@ MakeType1CharstringInterp::MakeType1CharstringInterp(int precision) MakeType1CharstringInterp::~MakeType1CharstringInterp() { for (int i = 0; i < _glyphs.size(); i++) - delete _glyphs[i]; + delete _glyphs[i]; for (int i = 0; i < _subrs.size(); i++) - delete _subrs[i]; + delete _subrs[i]; for (int i = 0; i < _gsubrs.size(); i++) - delete _gsubrs[i]; + delete _gsubrs[i]; } String MakeType1CharstringInterp::landmark(ErrorHandler *errh) const { if (_cur_glyph >= 0 && _cur_glyph < program()->nglyphs()) - return errh->format("glyph %<%s%>", program()->glyph_name(_cur_glyph).c_str()); + return errh->format("glyph %<%s%>", program()->glyph_name(_cur_glyph).c_str()); else - return String(); + return String(); } @@ -177,21 +177,21 @@ MakeType1CharstringInterp::csr_subr(CsRef csr, bool force) const { Vector<Subr *> *vp; if ((csr & CSR_TYPE) == CSR_SUBR) - vp = &_subrs; + vp = &_subrs; else if ((csr & CSR_TYPE) == CSR_GSUBR) - vp = &_gsubrs; + vp = &_gsubrs; else if ((csr & CSR_TYPE) == CSR_GLYPH) - vp = &_glyphs; + vp = &_glyphs; else - return 0; + return 0; int n = (csr & CSR_NUM); if (n >= vp->size()) - return 0; + return 0; Subr *&what = (*vp)[n]; if (!what && force) - what = new Subr(csr); + what = new Subr(csr); return what; } @@ -202,16 +202,16 @@ MakeType1CharstringInterp::Subr::name(const MakeType1CharstringInterp *mcsi) con int n = (_csr & CSR_NUM); switch (_csr & CSR_TYPE) { case CSR_SUBR: - return "subr" + String(n); + return "subr" + String(n); case CSR_GSUBR: - return "gsubr" + String(n); + return "gsubr" + String(n); case CSR_GLYPH: - if (String name = mcsi->output()->glyph_name(n)) - return name; - else - return "??glyph" + String(n) + "??"; + if (String name = mcsi->output()->glyph_name(n)) + return name; + else + return "??glyph" + String(n) + "??"; default: - return ""; + return ""; } } #endif @@ -223,13 +223,13 @@ MakeType1CharstringInterp::Subr::charstring(const MakeType1CharstringInterp *mcs switch (_csr & CSR_TYPE) { case CSR_SUBR: case CSR_GSUBR: - if (_output_subrno >= 0) - return static_cast<Type1Charstring *>(mcsi->output()->subr(_output_subrno)); - return 0; + if (_output_subrno >= 0) + return static_cast<Type1Charstring *>(mcsi->output()->subr(_output_subrno)); + return 0; case CSR_GLYPH: - return static_cast<Type1Charstring *>(mcsi->output()->glyph(n)); + return static_cast<Type1Charstring *>(mcsi->output()->glyph(n)); default: - return 0; + return 0; } } @@ -238,18 +238,18 @@ MakeType1CharstringInterp::Subr::transfer_nested_calls(int pos, int length, Subr { int right = pos + length; for (int i = 0; i < _calls.size(); i++) { - Subr *cs = _calls[i]; - // 11.Jul.2006 - remember not to shift the new caller's records! (Michael Zedler) - if (cs != new_caller) - for (int j = 0; j < cs->_callers.size(); j++) { - Caller &c = cs->_callers[j]; - if (c.subr == this && pos <= c.pos && c.pos + c.len <= right) { - // shift caller to point at the subroutine - c.subr = new_caller; - c.pos -= pos; - new_caller->add_call(cs); - } - } + Subr *cs = _calls[i]; + // 11.Jul.2006 - remember not to shift the new caller's records! (Michael Zedler) + if (cs != new_caller) + for (int j = 0; j < cs->_callers.size(); j++) { + Caller &c = cs->_callers[j]; + if (c.subr == this && pos <= c.pos && c.pos + c.len <= right) { + // shift caller to point at the subroutine + c.subr = new_caller; + c.pos -= pos; + new_caller->add_call(cs); + } + } } } @@ -257,27 +257,27 @@ void MakeType1CharstringInterp::Subr::change_callers(Subr *caller, int pos, int length, int new_length) { if (up_to_date()) - return; + return; update(); int right = pos + length; int delta = new_length - length; for (int i = 0; i < _callers.size(); i++) { - Caller &c = _callers[i]; - if (c.subr != caller) - /* nada */; - else if (pos <= c.pos && c.pos + c.len <= right) { - // erase - //if (c.debug) fprintf(stderr, " ERASE caller %08x:%d+%d [%d+%d]\n", c.subr->_csr, c.pos, c.len, pos, length); - c.subr = 0; - } else if (right <= c.pos) { - //if (c.debug) fprintf(stderr, " ADJUST caller %08x:%d+%d -> %d+%d [%d+%d]\n", c.subr->_csr, c.pos, c.len, c.pos+delta, c.len, pos, length); - c.pos += delta; - } else if (c.pos <= pos && right <= c.pos + c.len) { + Caller &c = _callers[i]; + if (c.subr != caller) + /* nada */; + else if (pos <= c.pos && c.pos + c.len <= right) { + // erase + //if (c.debug) fprintf(stderr, " ERASE caller %08x:%d+%d [%d+%d]\n", c.subr->_csr, c.pos, c.len, pos, length); + c.subr = 0; + } else if (right <= c.pos) { + //if (c.debug) fprintf(stderr, " ADJUST caller %08x:%d+%d -> %d+%d [%d+%d]\n", c.subr->_csr, c.pos, c.len, c.pos+delta, c.len, pos, length); + c.pos += delta; + } else if (c.pos <= pos && right <= c.pos + c.len) { //if (c.debug) fprintf(stderr, " ADJUST caller %08x:%d+%d -> %d+%d [%d+%d]\n", c.subr->_csr, c.pos, c.len, c.pos, c.len+delta, pos, length); - c.len += delta; - } else - c.subr = 0; + c.len += delta; + } else + c.subr = 0; } } @@ -286,25 +286,25 @@ MakeType1CharstringInterp::Subr::unify(MakeType1CharstringInterp *mcsi) { // clean up caller list for (int i = 0; i < _callers.size(); i++) - if (!_callers[i].subr) { - _callers[i] = _callers.back(); - _callers.pop_back(); - i--; - } + if (!_callers[i].subr) { + _callers[i] = _callers.back(); + _callers.pop_back(); + i--; + } if (!_callers.size()) - return false; - assert(!_calls.size()); // because this hasn't been unified yet + return false; + assert(!_calls.size()); // because this hasn't been unified yet // Find the smallest shared complete charstring. String substr = _callers[0].charstring(mcsi); int suboff = 0; for (int i = 1; i < _callers.size(); i++) { - String substr1 = _callers[i].charstring(mcsi); - const char *d = substr.data() + suboff, *d1 = substr1.data(); - const char *dx = substr.data() + substr.length(), *d1x = d1 + substr1.length(); - while (dx > d && d1x > d1 && dx[-1] == d1x[-1]) - dx--, d1x--; + String substr1 = _callers[i].charstring(mcsi); + const char *d = substr.data() + suboff, *d1 = substr1.data(); + const char *dx = substr.data() + substr.length(), *d1x = d1 + substr1.length(); + while (dx > d && d1x > d1 && dx[-1] == d1x[-1]) + dx--, d1x--; if (d1x != d1) { // 8.13.2013 -- We might have stopped in the middle of a number // or command in d1 -- even if we absorbed all of d! For @@ -320,14 +320,14 @@ MakeType1CharstringInterp::Subr::unify(MakeType1CharstringInterp *mcsi) } substr = substr.substring(Type1Charstring(substr).first_caret_after(suboff)); if (!substr.length()) - return false; + return false; for (int i = 0; i < _callers.size(); i++) { - Caller &c = _callers[i]; - if (int delta = c.len - substr.length()) { + Caller &c = _callers[i]; + if (int delta = c.len - substr.length()) { //if (c.debug) fprintf(stderr, " PREFIX caller %08x:%d+%d -> %d+%d [%s]\n", c.subr->_csr, c.pos, c.len, c.pos+delta, c.len+delta, CharstringUnparser::unparse(Type1Charstring(substr)).c_str()); - c.pos += delta; - c.len -= delta; - } + c.pos += delta; + c.len -= delta; + } } // otherwise, success @@ -343,17 +343,17 @@ MakeType1CharstringInterp::Subr::unify(MakeType1CharstringInterp *mcsi) String callsubr_string = Type1CharstringGen::callsubr_string(_output_subrno); for (int i = 0; i < _callers.size(); i++) - // 13.Jun.2003 - must check whether _callers[i].subr exists: if we - // called a subroutine more than once, change_callers() might have - // zeroed it out. - if (_callers[i].subr && _callers[i].subr != this) { - Subr::Caller c = _callers[i]; - c.subr->charstring(mcsi)->assign_substring(c.pos, c.len, callsubr_string); - Subr::bump_date(); - for (int j = 0; j < c.subr->ncalls(); j++) - c.subr->call(j)->change_callers(c.subr, c.pos, c.len, callsubr_string.length()); - assert(!_callers[i].subr); - } + // 13.Jun.2003 - must check whether _callers[i].subr exists: if we + // called a subroutine more than once, change_callers() might have + // zeroed it out. + if (_callers[i].subr && _callers[i].subr != this) { + Subr::Caller c = _callers[i]; + c.subr->charstring(mcsi)->assign_substring(c.pos, c.len, callsubr_string); + Subr::bump_date(); + for (int j = 0; j < c.subr->ncalls(); j++) + c.subr->call(j)->change_callers(c.subr, c.pos, c.len, callsubr_string.length()); + assert(!_callers[i].subr); + } // this subr is no longer "called"/interpolated from anywhere _callers.clear(); @@ -372,30 +372,30 @@ MakeType1CharstringInterp::type2_command(int cmd, const uint8_t *data, int *left case Cs::cCallsubr: case Cs::cCallgsubr: - if (subr_depth() < MAX_SUBR_DEPTH && size() == 1) { - //fprintf(stderr, "succeeded %d\n", (int) top()); - bool g = (cmd == Cs::cCallgsubr); - CsRef csref = ((int)top() + program()->xsubr_bias(g)) | (g ? CSR_GSUBR : CSR_SUBR); - Subr *callee = csr_subr(csref, true); - if (callee) - _cur_subr->add_call(callee); - - int left = csgen().length(); - - bool more = callxsubr_command(g); - - int right = csgen().length(); - if (error() >= 0 && callee) - callee->add_caller(_cur_subr, left, right - left); - return more; - } else { - //fprintf(stderr, "failed %d\n", (int) top()); - goto normal; - } + if (subr_depth() < MAX_SUBR_DEPTH && size() == 1) { + //fprintf(stderr, "succeeded %d\n", (int) top()); + bool g = (cmd == Cs::cCallgsubr); + CsRef csref = ((int)top() + program()->xsubr_bias(g)) | (g ? CSR_GSUBR : CSR_SUBR); + Subr *callee = csr_subr(csref, true); + if (callee) + _cur_subr->add_call(callee); + + int left = csgen().length(); + + bool more = callxsubr_command(g); + + int right = csgen().length(); + if (error() >= 0 && callee) + callee->add_caller(_cur_subr, left, right - left); + return more; + } else { + //fprintf(stderr, "failed %d\n", (int) top()); + goto normal; + } normal: default: - return CharstringInterp::type2_command(cmd, data, left); + return CharstringInterp::type2_command(cmd, data, left); } } @@ -406,9 +406,9 @@ MakeType1CharstringInterp::run(const CharstringContext &g, Type1Charstring &out, Type1CharstringGenInterp::run(g, out); if (Type1CharstringGenInterp::had_bad_flex() && !(_flex_message & 1)) { - errh->lwarning(landmark(errh), "complex flex hint replaced with curves"); - errh->message("(This font contains flex hints prohibited by Type 1. They%,ve been\nreplaced by ordinary curves.)"); - _flex_message |= 1; + errh->lwarning(landmark(errh), "complex flex hint replaced with curves"); + errh->message("(This font contains flex hints prohibited by Type 1. They%,ve been\nreplaced by ordinary curves.)"); + _flex_message |= 1; } #if !HAVE_ADOBE_CODE if (Type1CharstringGenInterp::had_flex() && !(_flex_message & 2)) { @@ -440,37 +440,37 @@ MakeType1CharstringInterp::run(const CharstringProgram *program, Type1Font *outp int nglyphs = program->nglyphs(); Type1Charstring receptacle; for (int i = 0; i < nglyphs; i++) { - _cur_subr = _glyphs[i] = new Subr(CSR_GLYPH | i); - _cur_glyph = i; - run(program->glyph_context(i), receptacle, errh); + _cur_subr = _glyphs[i] = new Subr(CSR_GLYPH | i); + _cur_glyph = i; + run(program->glyph_context(i), receptacle, errh); #if 0 - PermString n = program->glyph_name(i); - if (i == 408 || i == 20) { - fprintf(stderr, "%d: %s was %s\n", i, n.c_str(), CharstringUnparser::unparse(*program->glyph(i)).c_str()); - fprintf(stderr, " now %s\n", CharstringUnparser::unparse(receptacle).c_str()); + PermString n = program->glyph_name(i); + if (i == 408 || i == 20) { + fprintf(stderr, "%d: %s was %s\n", i, n.c_str(), CharstringUnparser::unparse(*program->glyph(i)).c_str()); + fprintf(stderr, " now %s\n", CharstringUnparser::unparse(receptacle).c_str()); fprintf(stderr, " *** %d.%d: %s\n", 134, 30, CharstringUnparser::unparse(Type1Charstring(receptacle.data_string().substring(134, 30))).c_str()); - } + } #endif - PermString name = program->glyph_name(i); - if (output->glyph(name)) { - errh->warning("glyph %<%s%> defined more than once", name.c_str()); - int i = 1; - do { - name = program->glyph_name(i) + String(".") + String(i); - ++i; - } while (output->glyph(name)); - } - output->add_glyph(Type1Subr::make_glyph(name, receptacle, glyph_definer)); + PermString name = program->glyph_name(i); + if (output->glyph(name)) { + errh->warning("glyph %<%s%> defined more than once", name.c_str()); + int i = 1; + do { + name = program->glyph_name(i) + String(".") + String(i); + ++i; + } while (output->glyph(name)); + } + output->add_glyph(Type1Subr::make_glyph(name, receptacle, glyph_definer)); } // unify Subrs for (int i = 0; i < _subrs.size(); i++) - if (_subrs[i]) - _subrs[i]->unify(this); + if (_subrs[i]) + _subrs[i]->unify(this); for (int i = 0; i < _gsubrs.size(); i++) - if (_gsubrs[i]) - _gsubrs[i]->unify(this); + if (_gsubrs[i]) + _gsubrs[i]->unify(this); } @@ -479,25 +479,33 @@ MakeType1CharstringInterp::run(const CharstringProgram *program, Type1Font *outp **/ static void -add_number_def(Type1Font *output, int dict, PermString name, const Cff::Font *font, Cff::DictOperator op) +add_number_def(Type1Font* output, int dict, PermString name, const Cff::Font* font, Cff::DictOperator op) { double v; if (font->dict_value(op, &v)) - output->add_definition(dict, Type1Definition::make(name, v, "def")); + output->add_definition(dict, Type1Definition::make(name, v, "def")); } static void -add_delta_def(Type1Font *output, int dict, PermString name, const Cff::Font *font, Cff::DictOperator op) +add_number_def(Type1Font* output, int dict, PermString name, const Cff::Font* font, Cff::DictOperator op, double default_value) +{ + double v; + if (font->dict_value(op, &v) && v != default_value) + output->add_definition(dict, Type1Definition::make(name, v, "def")); +} + +static void +add_delta_def(Type1Font* output, int dict, PermString name, const Cff::Font* font, Cff::DictOperator op) { Vector<double> vec; if (font->dict_value(op, vec)) { - for (int i = 1; i < vec.size(); i++) - vec[i] += vec[i - 1]; - StringAccum sa; - for (int i = 0; i < vec.size(); i++) - sa << (i ? ' ' : '[') << vec[i]; - sa << ']'; - output->add_definition(dict, Type1Definition::make_literal(name, sa.take_string(), (dict == Type1Font::dP ? "|-" : "readonly def"))); + for (int i = 1; i < vec.size(); i++) + vec[i] += vec[i - 1]; + StringAccum sa; + for (int i = 0; i < vec.size(); i++) + sa << (i ? ' ' : '[') << vec[i]; + sa << ']'; + output->add_definition(dict, Type1Definition::make_literal(name, sa.take_string(), (dict == Type1Font::dP ? "|-" : "readonly def"))); } } @@ -506,25 +514,38 @@ create_type1_font(Cff::Font *font, ErrorHandler *errh) { String version = font->dict_string(Cff::oVersion); Type1Font *output = Type1Font::skeleton_make(font->font_name(), version); - output->skeleton_comments_end(); StringAccum sa; + double v; + Vector<double> vec; + const char* old_double_format = StringAccum::double_format; + StringAccum::double_format = "%.9g"; + + output->add_definition(Type1Font::dF, Type1Definition::make("FontType", 1.0, "def")); + output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontName", "/" + font->font_name(), "def")); + font->dict_value(Cff::oPaintType, &v); + output->add_definition(Type1Font::dF, Type1Definition::make("PaintType", v, "def")); + if (font->dict_value(Cff::oFontMatrix, vec) && vec.size() == 6) { + sa << '[' << vec[0] << ' ' << vec[1] << ' ' << vec[2] << ' ' << vec[3] << ' ' << vec[4] << ' ' << vec[5] << ']'; + output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontMatrix", sa.take_string(), "readonly def")); + } else { + output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontMatrix", "[0.001 0 0 0.001 0 0]", "readonly def")); + } // FontInfo dictionary if (version) - output->add_definition(Type1Font::dFI, Type1Definition::make_string("version", version, "readonly def")); + output->add_definition(Type1Font::dFI, Type1Definition::make_string("version", version, "readonly def")); if (String s = font->dict_string(Cff::oNotice)) - output->add_definition(Type1Font::dFI, Type1Definition::make_string("Notice", s, "readonly def")); + output->add_definition(Type1Font::dFI, Type1Definition::make_string("Notice", s, "readonly def")); if (String s = font->dict_string(Cff::oCopyright)) - output->add_definition(Type1Font::dFI, Type1Definition::make_string("Copyright", s, "readonly def")); + output->add_definition(Type1Font::dFI, Type1Definition::make_string("Copyright", s, "readonly def")); if (String s = font->dict_string(Cff::oFullName)) - output->add_definition(Type1Font::dFI, Type1Definition::make_string("FullName", s, "readonly def")); + output->add_definition(Type1Font::dFI, Type1Definition::make_string("FullName", s, "readonly def")); if (String s = font->dict_string(Cff::oFamilyName)) - output->add_definition(Type1Font::dFI, Type1Definition::make_string("FamilyName", s, "readonly def")); + output->add_definition(Type1Font::dFI, Type1Definition::make_string("FamilyName", s, "readonly def")); if (String s = font->dict_string(Cff::oWeight)) - output->add_definition(Type1Font::dFI, Type1Definition::make_string("Weight", s, "readonly def")); - double v; + output->add_definition(Type1Font::dFI, Type1Definition::make_string("Weight", s, "readonly def")); if (font->dict_value(Cff::oIsFixedPitch, &v)) - output->add_definition(Type1Font::dFI, Type1Definition::make_literal("isFixedPitch", (v ? "true" : "false"), "def")); + output->add_definition(Type1Font::dFI, Type1Definition::make_literal("isFixedPitch", (v ? "true" : "false"), "def")); add_number_def(output, Type1Font::dFI, "ItalicAngle", font, Cff::oItalicAngle); add_number_def(output, Type1Font::dFI, "UnderlinePosition", font, Cff::oUnderlinePosition); add_number_def(output, Type1Font::dFI, "UnderlineThickness", font, Cff::oUnderlineThickness); @@ -532,48 +553,42 @@ create_type1_font(Cff::Font *font, ErrorHandler *errh) // Encoding, other font dictionary entries output->add_item(font->type1_encoding_copy()); - font->dict_value(Cff::oPaintType, &v); - output->add_definition(Type1Font::dF, Type1Definition::make("PaintType", v, "def")); - output->add_definition(Type1Font::dF, Type1Definition::make("FontType", 1.0, "def")); - Vector<double> vec; - if (font->dict_value(Cff::oFontMatrix, vec) && vec.size() == 6) { - sa << '[' << vec[0] << ' ' << vec[1] << ' ' << vec[2] << ' ' << vec[3] << ' ' << vec[4] << ' ' << vec[5] << ']'; - output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontMatrix", sa.take_string(), "readonly def")); - } else - output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontMatrix", "[0.001 0 0 0.001 0 0]", "readonly def")); add_number_def(output, Type1Font::dF, "StrokeWidth", font, Cff::oStrokeWidth); add_number_def(output, Type1Font::dF, "UniqueID", font, Cff::oUniqueID); if (font->dict_value(Cff::oXUID, vec) && vec.size()) { - for (int i = 0; i < vec.size(); i++) - sa << (i ? ' ' : '[') << vec[i]; - sa << ']'; - output->add_definition(Type1Font::dF, Type1Definition::make_literal("XUID", sa.take_string(), "readonly def")); + for (int i = 0; i < vec.size(); i++) + sa << (i ? ' ' : '[') << vec[i]; + sa << ']'; + output->add_definition(Type1Font::dF, Type1Definition::make_literal("XUID", sa.take_string(), "readonly def")); } if (font->dict_value(Cff::oFontBBox, vec) && vec.size() == 4) { - sa << '{' << vec[0] << ' ' << vec[1] << ' ' << vec[2] << ' ' << vec[3] << '}'; - output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontBBox", sa.take_string(), "readonly def")); + sa << '{' << vec[0] << ' ' << vec[1] << ' ' << vec[2] << ' ' << vec[3] << '}'; + output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontBBox", sa.take_string(), "readonly def")); } else - output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontBBox", "{0 0 0 0}", "readonly def")); + output->add_definition(Type1Font::dF, Type1Definition::make_literal("FontBBox", "{0 0 0 0}", "readonly def")); output->skeleton_fontdict_end(); // Private dictionary - add_delta_def(output, Type1Font::dP, "BlueValues", font, Cff::oBlueValues); + if (font->dict_has(Cff::oBlueValues)) + add_delta_def(output, Type1Font::dP, "BlueValues", font, Cff::oBlueValues); + else + output->add_definition(Type1Font::dP, Type1Definition::make_literal("BlueValues", "[]", "|-")); add_delta_def(output, Type1Font::dP, "OtherBlues", font, Cff::oOtherBlues); add_delta_def(output, Type1Font::dP, "FamilyBlues", font, Cff::oFamilyBlues); add_delta_def(output, Type1Font::dP, "FamilyOtherBlues", font, Cff::oFamilyOtherBlues); - add_number_def(output, Type1Font::dP, "BlueScale", font, Cff::oBlueScale); - add_number_def(output, Type1Font::dP, "BlueShift", font, Cff::oBlueShift); - add_number_def(output, Type1Font::dP, "BlueFuzz", font, Cff::oBlueFuzz); + add_number_def(output, Type1Font::dP, "BlueScale", font, Cff::oBlueScale, 0.039625); + add_number_def(output, Type1Font::dP, "BlueShift", font, Cff::oBlueShift, 7); + add_number_def(output, Type1Font::dP, "BlueFuzz", font, Cff::oBlueFuzz, 1); if (font->dict_value(Cff::oStdHW, &v)) - output->add_definition(Type1Font::dP, Type1Definition::make_literal("StdHW", String("[") + String(v) + "]", "|-")); + output->add_definition(Type1Font::dP, Type1Definition::make_literal("StdHW", String("[") + String(v) + "]", "|-")); if (font->dict_value(Cff::oStdVW, &v)) - output->add_definition(Type1Font::dP, Type1Definition::make_literal("StdVW", String("[") + String(v) + "]", "|-")); + output->add_definition(Type1Font::dP, Type1Definition::make_literal("StdVW", String("[") + String(v) + "]", "|-")); add_delta_def(output, Type1Font::dP, "StemSnapH", font, Cff::oStemSnapH); add_delta_def(output, Type1Font::dP, "StemSnapV", font, Cff::oStemSnapV); if (font->dict_value(Cff::oForceBold, &v)) - output->add_definition(Type1Font::dP, Type1Definition::make_literal("ForceBold", (v ? "true" : "false"), "def")); - add_number_def(output, Type1Font::dP, "LanguageGroup", font, Cff::oLanguageGroup); - add_number_def(output, Type1Font::dP, "ExpansionFactor", font, Cff::oExpansionFactor); + output->add_definition(Type1Font::dP, Type1Definition::make_literal("ForceBold", (v ? "true" : "false"), "def")); + add_number_def(output, Type1Font::dP, "LanguageGroup", font, Cff::oLanguageGroup, 0); + add_number_def(output, Type1Font::dP, "ExpansionFactor", font, Cff::oExpansionFactor, 0.06); add_number_def(output, Type1Font::dP, "UniqueID", font, Cff::oUniqueID); output->add_definition(Type1Font::dP, Type1Definition::make_literal("MinFeature", "{16 16}", "|-")); output->add_definition(Type1Font::dP, Type1Definition::make_literal("password", "5839", "def")); @@ -585,6 +600,7 @@ create_type1_font(Cff::Font *font, ErrorHandler *errh) MakeType1CharstringInterp maker(5); maker.run(font, output, " |-", errh); + StringAccum::double_format = old_double_format; return output; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/configure.ac b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/configure.ac index a18a8979d5b..99001bcb1cb 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/configure.ac +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([lcdf-typetools], [2.108]) +AC_INIT([lcdf-typetools],[2.110]) AC_CONFIG_SRCDIR([NEWS.md]) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS([autoconf.h]) @@ -32,11 +32,7 @@ if test "$enable_adobe_code" = yes; then fi -dnl AN_MAKEVAR([AR], [AC_PROG_AR]) -dnl AN_PROGRAM([ar], [AC_PROG_AR]) -dnl AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) -dnl AC_PROG_AR - +AM_PROG_AR AC_PROG_RANLIB @@ -115,8 +111,9 @@ dnl standard headers dnl (Though obsolete, AC_HEADER_STC changes the standard includes.) dnl -AC_LANG_C -AC_HEADER_STDC +AC_LANG([C]) +AC_CHECK_INCLUDES_DEFAULT +AC_PROG_EGREP AC_HEADER_DIRENT AC_CHECK_HEADERS([fcntl.h unistd.h sys/time.h sys/wait.h]) @@ -125,13 +122,13 @@ dnl dnl <new> and/or <new.h> dnl -AC_LANG_CPLUSPLUS +AC_LANG([C++]) AC_CACHE_CHECK([whether <new> works], ac_cv_good_new_hdr, -[AC_TRY_LINK([#include <new>], [ +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <new>]], [[ int a; int *b = new(&a) int; return 0; -], ac_cv_good_new_hdr=yes, ac_cv_good_new_hdr=no)]) +]])],[ac_cv_good_new_hdr=yes],[ac_cv_good_new_hdr=no])]) if test "$ac_cv_good_new_hdr" = yes; then AC_DEFINE([HAVE_NEW_HDR], [1], [Define if <new> exists and works.]) fi @@ -151,43 +148,41 @@ dnl functions such as strerror, working strtod, working strnlen, strtoul, dnl time headers such as unistd.h dnl -AC_LANG_C +AC_LANG([C]) need_fixlibc=0 AC_CHECK_FUNCS([strerror], [], [need_fixlibc=1]) AC_CACHE_CHECK([for broken strtod], [ac_cv_broken_strtod], -[AC_TRY_RUN([#include <stdio.h> +[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> #include <stdlib.h> int main(int c, char **v) { char s[] = "12 "; char *endp; double d = strtod(s, &endp); return (s + 2) == endp; -}], [ac_cv_broken_strtod=yes], [ac_cv_broken_strtod=no], -[ac_cv_broken_strtod=no])]) +}]])],[ac_cv_broken_strtod=yes],[ac_cv_broken_strtod=no],[ac_cv_broken_strtod=no])]) if test "x$ac_cv_broken_strtod" = xyes; then need_fixlibc=1 AC_DEFINE([HAVE_BROKEN_STRTOD], [1], [Define if strtod is broken.]) fi -AC_LANG_CPLUSPLUS +AC_LANG([C++]) AC_CHECK_DECLS([strnlen], [], [], [#include <string.h>]) AC_CHECK_FUNCS([strnlen], [have_strnlen=1], [need_fixlibc=1]) if test "x$have_strnlen" = x1; then AC_CACHE_CHECK([for broken strnlen], [ac_cv_broken_strnlen], - [AC_TRY_RUN([#include <string.h> + [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <string.h> #include <stdio.h> int main(int c, char **v) { char s[] = "01234567891"; return strnlen(s, 10) == 10; -}], [ac_cv_broken_strnlen=yes], [ac_cv_broken_strnlen=no], -[ac_cv_broken_strnlen=no])]) +}]])],[ac_cv_broken_strnlen=yes],[ac_cv_broken_strnlen=no],[ac_cv_broken_strnlen=no])]) if test "x$ac_cv_broken_strnlen" = xyes; then need_fixlibc=1 AC_DEFINE([HAVE_BROKEN_STRNLEN], [1], [Define if strnlen is broken.]) fi fi -AC_LANG_C +AC_LANG([C]) AC_CHECK_FUNCS([ctime ftruncate mkstemp sigaction strdup strtoul vsnprintf waitpid]) AC_CHECK_FUNC([floor], [], [AC_CHECK_LIB([m], [floor])]) @@ -247,7 +242,7 @@ dnl dnl ntohs, ntohl (need them in C++ code) dnl -AC_LANG_CPLUSPLUS +AC_LANG([C]) AC_CHECK_HEADERS([byteorder.h netinet/in.h sys/param.h]) AC_MSG_CHECKING([whether ntohs and ntohl are defined]) ac_ntoh_defined=no @@ -296,7 +291,7 @@ Cannot find a definition for ntohs and/or ntohl! =========================================]) fi -AC_LANG_C +AC_LANG([C]) AC_SEARCH_LIBS([ntohs], [-lnet -lwinsock32]) @@ -304,10 +299,10 @@ dnl dnl is va_list addressable? dnl -AC_LANG_CPLUSPLUS +AC_LANG([C++]) AC_CACHE_CHECK([for addressable va_list type], ac_cv_va_list_addr, - [AC_TRY_COMPILE([#include <stdarg.h> + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> void f(va_list *) { } void g(va_list val) { @@ -318,7 +313,7 @@ void h(int a, ...) { va_start(val, a); g(val); va_end(val); -}], [h(2, 3, 4);], ac_cv_va_list_addr=yes, ac_cv_va_list_addr=no)]) +}]], [[h(2, 3, 4);]])],[ac_cv_va_list_addr=yes],[ac_cv_va_list_addr=no])]) if test "x$ac_cv_va_list_addr" = xyes; then AC_DEFINE(HAVE_ADDRESSABLE_VA_LIST, 1, [Define if the va_list type is addressable.]) fi @@ -331,13 +326,11 @@ dnl m4_include([m4/lcdf-typetools.m4]) SELECTED_SUBDIRS= -AC_FOREACH([Kpse_Prog], kpse_lcdf_typetools_progs, - [test "x$enable_[]Kpse_Prog" = xno || SELECTED_SUBDIRS="$SELECTED_SUBDIRS Kpse_Prog" +m4_foreach_w([Kpse_Prog],kpse_lcdf_typetools_progs,[test "x$enable_[]Kpse_Prog" = xno || SELECTED_SUBDIRS="$SELECTED_SUBDIRS Kpse_Prog" ]) AC_SUBST(SELECTED_SUBDIRS) -AC_FOREACH([Kpse_Opt], kpse_otftotfm_auto_opts, - [AS_IF([test "x$enable_auto_]Kpse_Opt[" != xno], +m4_foreach_w([Kpse_Opt],kpse_otftotfm_auto_opts,[AS_IF([test "x$enable_auto_]Kpse_Opt[" != xno], [AC_DEFINE([HAVE_AUTO_]AS_TR_CPP(Kpse_Opt), 1, [Define to run ]Kpse_Opt[ from otftotfm.])]) ]) @@ -511,4 +504,5 @@ dnl dnl Output dnl -AC_OUTPUT(Makefile liblcdf/Makefile libefont/Makefile cfftot1/Makefile mmafm/Makefile mmpfb/Makefile otfinfo/Makefile otftotfm/Makefile t1dotlessj/Makefile t1lint/Makefile t1rawafm/Makefile t1reencode/Makefile t1testpage/Makefile ttftotype42/Makefile) +AC_CONFIG_FILES([Makefile liblcdf/Makefile libefont/Makefile cfftot1/Makefile mmafm/Makefile mmpfb/Makefile otfinfo/Makefile otftotfm/Makefile t1dotlessj/Makefile t1lint/Makefile t1rawafm/Makefile t1reencode/Makefile t1testpage/Makefile ttftotype42/Makefile]) +AC_OUTPUT diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/afmparse.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/afmparse.hh index c97c4949b0c..2b7404a87d4 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/afmparse.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/afmparse.hh @@ -37,7 +37,6 @@ class AfmParser { public: private: Slurper &_slurper; - bool _save_line; unsigned char *_line; unsigned char *_pos; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/amfm.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/amfm.hh index 55cf1909546..ca0a14137e8 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/amfm.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/amfm.hh @@ -117,7 +117,6 @@ class AmfmReader { public: typedef Vector<double> NumVector; AmfmMetrics *_amfm; - MetricsFinder *_finder; AfmParser &_l; MultipleMasterSpace *_mmspace; ErrorHandler *_errh; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/cff.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/cff.hh index 494d93dcbfc..794bb54501a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/cff.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/cff.hh @@ -25,8 +25,8 @@ class Cff { public: bool ok() const { return _error >= 0; } int error() const { return _error; } - const String &data_string() const { return _data_string; } - const uint8_t *data() const { return _data; } + const String& data_string() const { return _data_string; } + const uint8_t* data() const { return _data; } int length() const { return _len; } int nfonts() const { return _name_index.size(); } @@ -40,7 +40,7 @@ class Cff { public: PermString sid_permstring(int sid) const; int ngsubrs() const { return _gsubrs_index.nitems(); } - Charstring *gsubr(int i); + Charstring* gsubr(int i); unsigned units_per_em() const { return _units_per_em; } @@ -72,14 +72,14 @@ class Cff { public: tTypeMask = 0x7F, tPrivate = 0x80, tP = tPrivate }; - static const char * const operator_names[]; + static const char* const operator_names[]; static const int operator_types[]; class IndexIterator { public: IndexIterator() : _offset(0), _last_offset(0), _offsize(-1) { } - IndexIterator(const uint8_t *, int, int, ErrorHandler * = 0, const char *index_name = "INDEX"); + IndexIterator(const uint8_t*, int, int, ErrorHandler* = 0, const char* index_name = "INDEX"); int error() const { return (_offsize < 0 ? _offsize : 0); } @@ -90,28 +90,28 @@ class Cff { public: } int nitems() const; - inline const uint8_t *operator*() const; - inline const uint8_t *operator[](int) const; - const uint8_t *index_end() const; + inline const uint8_t* operator*() const; + inline const uint8_t* operator[](int) const; + const uint8_t* index_end() const; void operator++() { _offset += _offsize; } void operator++(int) { ++(*this); } private: - const uint8_t *_contents; - const uint8_t *_offset; - const uint8_t *_last_offset; + const uint8_t* _contents; + const uint8_t* _offset; + const uint8_t* _last_offset; int _offsize; - inline uint32_t offset_at(const uint8_t *) const; + inline uint32_t offset_at(const uint8_t*) const; }; private: String _data_string; - const uint8_t *_data; + const uint8_t* _data; int _len; int _error; @@ -130,7 +130,7 @@ class Cff { public: unsigned _units_per_em; - int parse_header(ErrorHandler *); + int parse_header(ErrorHandler*); enum { HEADER_SIZE = 4 }; @@ -140,28 +140,28 @@ class Cff { public: class Cff::Dict { public: Dict(); - Dict(Cff *, int pos, int dict_len, ErrorHandler * = 0, const char *dict_name = "DICT"); - int assign(Cff *, int pos, int dict_len, ErrorHandler * = 0, const char *dict_name = "DICT"); + Dict(Cff*, int pos, int dict_len, ErrorHandler* = 0, const char* dict_name = "DICT"); + int assign(Cff*, int pos, int dict_len, ErrorHandler* = 0, const char* dict_name = "DICT"); bool ok() const { return _error >= 0; } int error() const { return _error; } - int check(bool is_private, ErrorHandler * = 0, const char *dict_name = "DICT") const; + int check(bool is_private, ErrorHandler* = 0, const char* dict_name = "DICT") const; bool has(DictOperator) const; inline bool has_first(DictOperator) const; - bool xvalue(DictOperator, Vector<double> &) const; - bool xvalue(DictOperator, int *) const; - bool xvalue(DictOperator, double *) const; - bool value(DictOperator, Vector<double> &) const; - bool value(DictOperator, int *) const; - bool value(DictOperator, double *) const; + bool xvalue(DictOperator, Vector<double>&) const; + bool xvalue(DictOperator, int*) const; + bool xvalue(DictOperator, double*) const; + bool value(DictOperator, Vector<double>&) const; + bool value(DictOperator, int*) const; + bool value(DictOperator, double*) const; - void unparse(ErrorHandler *, const char *) const; + void unparse(ErrorHandler*, const char*) const; private: - Cff *_cff; + Cff* _cff; int _pos; Vector<int> _operators; Vector<int> _pointers; @@ -173,8 +173,8 @@ class Cff::Dict { public: class Cff::Charset { public: Charset() : _error(-1) { } - Charset(const Cff *, int pos, int nglyphs, int max_sid, ErrorHandler * = 0); - void assign(const Cff *, int pos, int nglyphs, int max_sid, ErrorHandler * = 0); + Charset(const Cff*, int pos, int nglyphs, int max_sid, ErrorHandler* = 0); + void assign(const Cff*, int pos, int nglyphs, int max_sid, ErrorHandler* = 0); int error() const { return _error; } @@ -190,8 +190,8 @@ class Cff::Charset { public: Vector<int> _gids; int _error; - void assign(const int *, int, int); - int parse(const Cff *, int pos, int nglyphs, int max_sid, ErrorHandler *); + void assign(const int*, int, int); + int parse(const Cff*, int pos, int nglyphs, int max_sid, ErrorHandler*); }; @@ -199,7 +199,7 @@ class Cff::FDSelect { public: FDSelect() : _fds(0), _my_fds(false), _nglyphs(0), _error(-1) { } ~FDSelect(); - void assign(const Cff *, int pos, int nglyphs, ErrorHandler * = 0); + void assign(const Cff*, int pos, int nglyphs, ErrorHandler* = 0); int error() const { return _error; } @@ -208,14 +208,14 @@ class Cff::FDSelect { public: private: - const uint8_t *_fds; + const uint8_t* _fds; bool _my_fds; int _nglyphs; int _error; - FDSelect(const FDSelect &); - FDSelect &operator=(const FDSelect &); - int parse(const Cff *, int pos, int nglyphs, ErrorHandler *); + FDSelect(const FDSelect&); + FDSelect& operator=(const FDSelect&); + int parse(const Cff*, int pos, int nglyphs, ErrorHandler*); }; @@ -229,7 +229,7 @@ class Cff::FontParent : public CharstringProgram { public: int ngsubrs_x() const { return _cff->ngsubrs(); } int ngsubrs() const { return ngsubrs_x(); } - Charstring *gsubr(int) const; + Charstring* gsubr(int) const; int gsubr_bias() const; private: @@ -239,10 +239,10 @@ class Cff::FontParent : public CharstringProgram { public: int _error; int _font_index; - FontParent(const FontParent &); - FontParent &operator=(const FontParent &); + FontParent(const FontParent&); + FontParent& operator=(const FontParent&); - Charstring *charstring(const IndexIterator &, int) const; + Charstring* charstring(const IndexIterator&, int) const; friend class Cff; friend class Cff::Font; @@ -253,7 +253,7 @@ class Cff::FontParent : public CharstringProgram { public: class Cff::CIDFont : public Cff::FontParent { public: - CIDFont(Cff* cff, PermString, const Dict &, ErrorHandler *); + CIDFont(Cff* cff, PermString, const Dict&, ErrorHandler*); ~CIDFont(); PermString font_name() const { return _font_name; } @@ -261,17 +261,17 @@ class Cff::CIDFont : public Cff::FontParent { public: int nglyphs() const { return _charstrings_index.nitems(); } PermString glyph_name(int) const; - void glyph_names(Vector<PermString> &) const; - Charstring *glyph(int) const; - Charstring *glyph(PermString) const; + void glyph_names(Vector<PermString>&) const; + Charstring* glyph(int) const; + Charstring* glyph(PermString) const; int glyphid(PermString) const; - const CharstringProgram *child_program(int) const; + const CharstringProgram* child_program(int) const; bool dict_has(DictOperator) const; String dict_string(DictOperator) const; - bool dict_value(DictOperator, double *) const; - bool dict_xvalue(DictOperator, double, double *) const; - bool dict_value(DictOperator, Vector<double> &) const; + bool dict_value(DictOperator, double*) const; + bool dict_xvalue(DictOperator, double, double*) const; + bool dict_value(DictOperator, Vector<double>&) const; private: @@ -283,18 +283,18 @@ class Cff::CIDFont : public Cff::FontParent { public: Cff::Charset _charset; IndexIterator _charstrings_index; - mutable Vector<Charstring *> _charstrings_cs; + mutable Vector<Charstring*> _charstrings_cs; - Vector<ChildFont *> _child_fonts; + Vector<ChildFont*> _child_fonts; Cff::FDSelect _fdselect; - const Dict &dict_of(DictOperator) const; + const Dict& dict_of(DictOperator) const; }; class Cff::ChildFont : public Cff::FontParent { public: - ChildFont(Cff* cff, Cff::CIDFont *, int charstring_type, const Dict &, ErrorHandler * = 0); + ChildFont(Cff* cff, Cff::CIDFont*, int charstring_type, const Dict&, ErrorHandler* = 0); ~ChildFont(); bool ok() const { return _error >= 0; } @@ -307,34 +307,34 @@ class Cff::ChildFont : public Cff::FontParent { public: int nsubrs_x() const { return _subrs_index.nitems(); } int nsubrs() const { return nsubrs_x(); } - Charstring *subr(int) const; + Charstring* subr(int) const; int subr_bias() const; int nglyphs() const { return _parent->nglyphs(); } PermString glyph_name(int gi) const { return _parent->glyph_name(gi); } - void glyph_names(Vector<PermString> &v) const { _parent->glyph_names(v); } - Charstring *glyph(int gi) const { return _parent->glyph(gi); } - Charstring *glyph(PermString n) const { return _parent->glyph(n); } + void glyph_names(Vector<PermString>& v) const { _parent->glyph_names(v); } + Charstring* glyph(int gi) const { return _parent->glyph(gi); } + Charstring* glyph(PermString n) const { return _parent->glyph(n); } double global_width_x(bool) const; private: - Cff::CIDFont *_parent; + Cff::CIDFont* _parent; Dict _top_dict; Dict _private_dict; IndexIterator _subrs_index; - mutable Vector<Charstring *> _subrs_cs; + mutable Vector<Charstring*> _subrs_cs; double _default_width_x; double _nominal_width_x; - ChildFont(const ChildFont &); // does not exist - ChildFont &operator=(const ChildFont &); // does not exist + ChildFont(const ChildFont&); // does not exist + ChildFont& operator=(const ChildFont&); // does not exist - Charstring *charstring(const IndexIterator &, int) const; + Charstring* charstring(const IndexIterator&, int) const; friend class Cff::Font; @@ -342,7 +342,7 @@ class Cff::ChildFont : public Cff::FontParent { public: class Cff::Font : public Cff::ChildFont { public: - Font(Cff* cff, PermString, const Dict &, ErrorHandler *); + Font(Cff* cff, PermString, const Dict&, ErrorHandler*); ~Font(); PermString font_name() const { return _font_name; } @@ -350,19 +350,19 @@ class Cff::Font : public Cff::ChildFont { public: int nglyphs() const { return _charstrings_index.nitems(); } PermString glyph_name(int) const; - void glyph_names(Vector<PermString> &) const; - Charstring *glyph(int) const; - Charstring *glyph(PermString) const; + void glyph_names(Vector<PermString>&) const; + Charstring* glyph(int) const; + Charstring* glyph(PermString) const; int glyphid(PermString) const; - Type1Encoding *type1_encoding() const; - Type1Encoding *type1_encoding_copy() const; + Type1Encoding* type1_encoding() const; + Type1Encoding* type1_encoding_copy() const; bool dict_has(DictOperator) const; String dict_string(DictOperator) const; - inline bool dict_value(DictOperator, double *) const; - inline bool dict_value(DictOperator, Vector<double> &) const; - const Dict &top_dict() const { return _top_dict; } + inline bool dict_value(DictOperator, double*) const; + inline bool dict_value(DictOperator, Vector<double>&) const; + const Dict& top_dict() const { return _top_dict; } private: @@ -371,21 +371,21 @@ class Cff::Font : public Cff::ChildFont { public: Cff::Charset _charset; IndexIterator _charstrings_index; - mutable Vector<Charstring *> _charstrings_cs; + mutable Vector<Charstring*> _charstrings_cs; int _encoding_pos; int _encoding[256]; - mutable Type1Encoding *_t1encoding; + mutable Type1Encoding* _t1encoding; - int parse_encoding(int pos, ErrorHandler *); - int assign_standard_encoding(const int *standard_encoding); + int parse_encoding(int pos, ErrorHandler*); + int assign_standard_encoding(const int* standard_encoding); - inline const Dict &dict_of(DictOperator) const; + inline const Dict& dict_of(DictOperator) const; }; -inline uint32_t Cff::IndexIterator::offset_at(const uint8_t *x) const +inline uint32_t Cff::IndexIterator::offset_at(const uint8_t* x) const { switch (_offsize) { case 0: @@ -401,13 +401,13 @@ inline uint32_t Cff::IndexIterator::offset_at(const uint8_t *x) const } } -inline const uint8_t *Cff::IndexIterator::operator*() const +inline const uint8_t* Cff::IndexIterator::operator*() const { assert(live()); return _contents + offset_at(_offset); } -inline const uint8_t *Cff::IndexIterator::operator[](int which) const +inline const uint8_t* Cff::IndexIterator::operator[](int which) const { assert(live() && _offset + which * _offsize <= _last_offset); return _contents + offset_at(_offset + which * _offsize); @@ -442,17 +442,17 @@ inline bool Cff::Dict::has_first(DictOperator op) const return _operators.size() && _operators[0] == op; } -inline const Cff::Dict &Cff::Font::dict_of(DictOperator op) const +inline const Cff::Dict& Cff::Font::dict_of(DictOperator op) const { return (op >= 0 && op <= oLastOperator && (operator_types[op] & tP) ? _private_dict : _top_dict); } -inline bool Cff::Font::dict_value(DictOperator op, double *val) const +inline bool Cff::Font::dict_value(DictOperator op, double* val) const { return dict_of(op).value(op, val); } -inline bool Cff::Font::dict_value(DictOperator op, Vector<double> &val) const +inline bool Cff::Font::dict_value(DictOperator op, Vector<double>& val) const { return dict_of(op).value(op, val); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otf.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otf.hh index cdf7a58daca..cb9059b270f 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otf.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otf.hh @@ -14,8 +14,8 @@ class Tag { public: Tag() : _tag(0U) { } explicit Tag(uint32_t tag) : _tag(tag) { } - Tag(const char *name); - Tag(const String &name); + Tag(const char* name); + Tag(const String& name); // default destructor static Tag head_tag() { return Tag(0x68656164U); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfcmap.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfcmap.hh index 1fdce99802d..bf468046cf3 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfcmap.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfcmap.hh @@ -23,17 +23,18 @@ class Cmap { public: String _str; int _error; int _ntables; - mutable int _first_unicode_table; + mutable int _best_unicode_table; mutable Vector<int> _table_error; enum { HEADER_SIZE = 4, ENCODING_SIZE = 8, HIBYTE_SUBHEADERS = 524 }; enum Format { F_BYTE = 0, F_HIBYTE = 2, F_SEGMENTED = 4, F_TRIMMED = 6, - F_HIBYTE32 = 8, F_TRIMMED32 = 10, F_SEGMENTED32 = 12 }; - enum { USE_FIRST_UNICODE_TABLE = -2 }; + F_HIBYTE32 = 8, F_TRIMMED32 = 10, F_SEGMENTED32 = 12, + F_MANYTOONE = 13 }; + enum { USE_BEST_UNICODE_TABLE = -2 }; int parse_header(ErrorHandler *); - int first_unicode_table() const { return _first_unicode_table; } + int best_unicode_table() const { return _best_unicode_table; } int first_table(int platform, int encoding) const; int check_table(int t, ErrorHandler * = 0) const; Glyph map_table(int t, uint32_t, ErrorHandler * = 0) const; @@ -44,11 +45,11 @@ class Cmap { public: inline Glyph Cmap::map_uni(uint32_t c) const { - return map_table(USE_FIRST_UNICODE_TABLE, c, ErrorHandler::default_handler()); + return map_table(USE_BEST_UNICODE_TABLE, c, ErrorHandler::default_handler()); } inline void Cmap::unmap_all(Vector<std::pair<uint32_t, Glyph> > &ugp) const { - dump_table(USE_FIRST_UNICODE_TABLE, ugp, ErrorHandler::default_handler()); + dump_table(USE_BEST_UNICODE_TABLE, ugp, ErrorHandler::default_handler()); } inline const uint8_t* Cmap::table_data(int t) const { diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfdata.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfdata.hh index 2dfe24a1c18..1be41da0e5f 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfdata.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfdata.hh @@ -82,6 +82,8 @@ class Data { static inline int32_t s32(const unsigned char* s); static inline int32_t s32_aligned16(const unsigned char* s); static inline int32_t s32_aligned(const unsigned char* s); + static inline double fixed_aligned16(const unsigned char* s); + static inline double fixed_aligned(const unsigned char* s); inline uint8_t operator[](unsigned offset) const; inline uint16_t u16(unsigned offset) const; @@ -159,6 +161,14 @@ inline int32_t Data::s32_aligned(const unsigned char* s) { return ntohl(*reinterpret_cast<const int32_t*>(s)); } +inline double Data::fixed_aligned16(const unsigned char* s) { + return s32_aligned16(s) / 65536.; +} + +inline double Data::fixed_aligned(const unsigned char* s) { + return s32_aligned(s) / 65536.; +} + inline uint16_t Data::u16(unsigned offset) const { if (offset + 1 >= static_cast<unsigned>(_str.length()) || offset + 1 == 0) throw Bounds(); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otffvar.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otffvar.hh new file mode 100644 index 00000000000..680863f1f31 --- /dev/null +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otffvar.hh @@ -0,0 +1,110 @@ +// -*- related-file-name: "../../libefont/otffvar.cc" -*- +#ifndef EFONT_OTFFVAR_HH +#define EFONT_OTFFVAR_HH +#include <efont/otf.hh> +#include <lcdf/error.hh> +#include <utility> +namespace Efont { namespace OpenType { +class Axis; +class FvarInstance; + +class Fvar { public: + Fvar(Data); + // default destructor + + inline int naxes() const; + inline Axis axis(int i) const; + inline int ninstances() const; + inline FvarInstance instance(int i) const; + + private: + const unsigned char* _d; + const unsigned char* _id; + + enum { HEADER_SIZE = 16, AXIS_SIZE = 20, + X_AXISOFF = 4, X_AXISCOUNT = 8, X_AXISSIZE = 10, + X_INSTANCECOUNT = 12, X_INSTANCESIZE = 14 }; + +}; + +class Axis { public: + inline Axis(const unsigned char* d) : _d(d) {} + + inline Tag tag() const; + inline double min_value() const; + inline double default_value() const; + inline double max_value() const; + inline uint16_t flags() const; + inline int nameid() const; + + private: + const unsigned char* _d; +}; + +class FvarInstance { public: + inline FvarInstance(const unsigned char* d, int naxes) : _d(d), _naxes(naxes) {} + + inline int nameid() const; + inline double coord(int) const; + + private: + const unsigned char* _d; + const int _naxes; +}; + + +inline int Fvar::naxes() const { + return Data::u16_aligned(_d + X_AXISCOUNT); +} + +inline Axis Fvar::axis(int i) const { + assert(i >= 0 && i < naxes()); + return Axis(_d + Data::u16_aligned(_d + X_AXISOFF) + i * Data::u16_aligned(_d + X_AXISSIZE)); +} + +inline int Fvar::ninstances() const { + return _id ? Data::u16_aligned(_d + X_INSTANCECOUNT) : 0; +} + +inline FvarInstance Fvar::instance(int i) const { + assert(i >= 0 && i < ninstances()); + return FvarInstance(_id + i * Data::u16_aligned(_d + X_INSTANCESIZE), naxes()); +} + + +inline Tag Axis::tag() const { + return Tag(Data::u32_aligned16(_d)); +} + +inline double Axis::min_value() const { + return Data::fixed_aligned16(_d + 4); +} + +inline double Axis::default_value() const { + return Data::fixed_aligned16(_d + 8); +} + +inline double Axis::max_value() const { + return Data::fixed_aligned16(_d + 12); +} + +inline uint16_t Axis::flags() const { + return Data::u16_aligned(_d + 16); +} + +inline int Axis::nameid() const { + return Data::u16_aligned(_d + 18); +} + + +inline int FvarInstance::nameid() const { + return Data::u16_aligned(_d); +} + +inline double FvarInstance::coord(int ax) const { + assert(ax >= 0 && ax < _naxes); + return Data::fixed_aligned16(_d + 4 + ax * 4); +} + +}} +#endif diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgpos.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgpos.hh index 6d1088a97fa..0cd4d4a9342 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgpos.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgpos.hh @@ -9,11 +9,11 @@ class Positioning; class Gpos { public: - Gpos(const Data &, ErrorHandler * = 0); + Gpos(const Data&, ErrorHandler* = 0); // default destructor - const ScriptList &script_list() const { return _script_list; } - const FeatureList &feature_list() const { return _feature_list; } + const ScriptList& script_list() const { return _script_list; } + const FeatureList& feature_list() const { return _feature_list; } int nlookups() const; GposLookup lookup(unsigned) const; @@ -29,10 +29,10 @@ class Gpos { public: }; class GposLookup { public: - GposLookup(const Data &); + GposLookup(const Data&); int type() const { return _type; } uint16_t flags() const { return _d.u16(2); } - bool unparse_automatics(Vector<Positioning> &, ErrorHandler * = 0) const; + bool unparse_automatics(Vector<Positioning>&, ErrorHandler* = 0) const; enum { HEADERSIZE = 6, RECSIZE = 2, L_SINGLE = 1, L_PAIR = 2, L_CURSIVE = 3, L_MARKTOBASE = 4, @@ -47,10 +47,10 @@ class GposLookup { public: class GposValue { public: static inline int size(uint16_t format); - static inline int16_t xplacement(uint16_t format, const Data &); - static inline int16_t yplacement(uint16_t format, const Data &); - static inline int16_t xadvance(uint16_t format, const Data &); - static inline int16_t yadvance(uint16_t format, const Data &); + static inline int16_t xplacement(uint16_t format, const Data&); + static inline int16_t yplacement(uint16_t format, const Data&); + static inline int16_t xadvance(uint16_t format, const Data&); + static inline int16_t yadvance(uint16_t format, const Data&); enum { F_XPLACEMENT = 0x0001, F_YPLACEMENT = 0x0002, @@ -66,20 +66,20 @@ class GposValue { public: }; class GposSingle { public: - GposSingle(const Data &); + GposSingle(const Data&); // default destructor Coverage coverage() const noexcept; - void unparse(Vector<Positioning> &) const; + void unparse(Vector<Positioning>&) const; enum { F2_HEADERSIZE = 8 }; private: Data _d; }; class GposPair { public: - GposPair(const Data &); + GposPair(const Data&); // default destructor Coverage coverage() const noexcept; - void unparse(Vector<Positioning> &) const; + void unparse(Vector<Positioning>&) const; enum { F1_HEADERSIZE = 10, F1_RECSIZE = 2, PAIRSET_HEADERSIZE = 2, PAIRVALUE_HEADERSIZE = 2, F2_HEADERSIZE = 16 }; @@ -92,16 +92,16 @@ struct Position { int pdx, pdy; // placement int adx, ady; // advance inline Position(); - inline Position(Glyph, uint16_t format, const Data &); - inline Position(uint16_t format, const Data &); - inline Position(Glyph, const Position &); + inline Position(Glyph, uint16_t format, const Data&); + inline Position(uint16_t format, const Data&); + inline Position(Glyph, const Position&); inline Position(Glyph g, int pdx, int pdy, int adx, int ady); bool empty() const { return pdx == 0 && pdy == 0 && adx == 0 && ady == 0; } operator bool() const { return !empty(); } bool h_empty() const { return pdx == 0 && pdy == 0 && adx == 0; } bool placed() const { return pdx != 0 || pdy != 0; } - void unparse(StringAccum &, const Vector<PermString> * = 0) const; - String unparse(const Vector<PermString> * = 0) const; + void unparse(StringAccum&, const Vector<PermString>* = 0) const; + String unparse(const Vector<PermString>* = 0) const; }; class Positioning { public: @@ -109,13 +109,13 @@ class Positioning { public: Positioning(); // single positioning - inline Positioning(const Position &); + inline Positioning(const Position&); // pair positioning - inline Positioning(const Position &, const Position &); + inline Positioning(const Position&, const Position&); - bool context_in(const Coverage &) const; - bool context_in(const GlyphSet &) const; + bool context_in(const Coverage&) const; + bool context_in(const GlyphSet&) const; // types inline operator bool() const; @@ -124,14 +124,14 @@ class Positioning { public: inline bool is_pairkern() const; // extract data - const Position &left() const { return _left; } + const Position& left() const { return _left; } Glyph left_glyph() const { return _left.g; } - const Position &right() const { return _right; } + const Position& right() const { return _right; } Glyph right_glyph() const { return _right.g; } - inline void all_in_glyphs(Vector<Glyph> &gs) const; + inline void all_in_glyphs(Vector<Glyph>& gs) const; - void unparse(StringAccum &, const Vector<PermString> * = 0) const; - String unparse(const Vector<PermString> * = 0) const; + void unparse(StringAccum&, const Vector<PermString>* = 0) const; + String unparse(const Vector<PermString>* = 0) const; private: @@ -145,7 +145,7 @@ inline int GposValue::size(uint16_t format) return (nibble_bitcount_x2[format & 15] + nibble_bitcount_x2[(format>>4) & 15]); } -inline int16_t GposValue::xplacement(uint16_t format, const Data &d) +inline int16_t GposValue::xplacement(uint16_t format, const Data& d) { if (format & F_XPLACEMENT) return d.s16(0); @@ -153,7 +153,7 @@ inline int16_t GposValue::xplacement(uint16_t format, const Data &d) return 0; } -inline int16_t GposValue::yplacement(uint16_t format, const Data &d) +inline int16_t GposValue::yplacement(uint16_t format, const Data& d) { if (format & F_YPLACEMENT) return d.s16((format & F_XPLACEMENT ? 2 : 0)); @@ -161,7 +161,7 @@ inline int16_t GposValue::yplacement(uint16_t format, const Data &d) return 0; } -inline int16_t GposValue::xadvance(uint16_t format, const Data &d) +inline int16_t GposValue::xadvance(uint16_t format, const Data& d) { if (format & F_XADVANCE) return d.s16(nibble_bitcount_x2[format & (F_XADVANCE - 1)]); @@ -169,7 +169,7 @@ inline int16_t GposValue::xadvance(uint16_t format, const Data &d) return 0; } -inline int16_t GposValue::yadvance(uint16_t format, const Data &d) +inline int16_t GposValue::yadvance(uint16_t format, const Data& d) { if (format & F_YADVANCE) return d.s16(nibble_bitcount_x2[format & (F_YADVANCE - 1)]); @@ -182,21 +182,21 @@ inline Position::Position() { } -inline Position::Position(Glyph g_, uint16_t format, const Data &value) +inline Position::Position(Glyph g_, uint16_t format, const Data& value) : g(g_), pdx(GposValue::xplacement(format, value)), pdy(GposValue::yplacement(format, value)), adx(GposValue::xadvance(format, value)), ady(GposValue::yadvance(format, value)) { } -inline Position::Position(uint16_t format, const Data &value) +inline Position::Position(uint16_t format, const Data& value) : g(0), pdx(GposValue::xplacement(format, value)), pdy(GposValue::yplacement(format, value)), adx(GposValue::xadvance(format, value)), ady(GposValue::yadvance(format, value)) { } -inline Position::Position(Glyph g_, const Position &p) +inline Position::Position(Glyph g_, const Position& p) : g(g_), pdx(p.pdx), pdy(p.pdy), adx(p.adx), ady(p.ady) { } @@ -206,12 +206,12 @@ inline Position::Position(Glyph g_, int pdx_, int pdy_, int adx_, int ady_) { } -inline Positioning::Positioning(const Position &left) +inline Positioning::Positioning(const Position& left) : _left(left) { } -inline Positioning::Positioning(const Position &left, const Position &right) +inline Positioning::Positioning(const Position& left, const Position& right) : _left(left), _right(right) { } @@ -236,7 +236,7 @@ inline bool Positioning::is_pairkern() const return _left.g != 0 && !_left.placed() && _right.g != 0 && _right.h_empty(); } -inline void Positioning::all_in_glyphs(Vector<Glyph> &gs) const +inline void Positioning::all_in_glyphs(Vector<Glyph>& gs) const { gs.clear(); if (_left.g != 0) diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfname.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfname.hh index 692354f0f97..d060cb9beec 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfname.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfname.hh @@ -23,17 +23,18 @@ class Name { public: N_PREF_SUBFAMILY = 17, N_MAC_COMPAT_FULLNAME = 18, N_SAMPLE_TEXT = 19, N_POSTSCRIPT_CID = 20 }; enum Platform { P_UNICODE = 0, P_MACINTOSH = 1, P_MICROSOFT = 3, - E_MS_UNICODE_BMP = 1, E_MAC_ROMAN = 0, + E_MS_UNICODE_BMP = 1, E_MS_UNICODE_FULL = 10, + E_MAC_ROMAN = 0, L_MS_ENGLISH_AMERICAN = 0x409 }; enum { HEADER_SIZE = 6, NAMEREC_SIZE = 12 }; typedef uint8_t namerecord_t[NAMEREC_SIZE]; typedef const namerecord_t *const_iterator; - inline static int nameid(const namerecord_t &); - inline static int platform(const namerecord_t &); - inline static int encoding(const namerecord_t &); - inline static int language(const namerecord_t &); + inline static int nameid(const namerecord_t&); + inline static int platform(const namerecord_t&); + inline static int encoding(const namerecord_t&); + inline static int language(const namerecord_t&); inline const_iterator begin() const; inline const_iterator end() const; @@ -46,14 +47,14 @@ class Name { public: struct PlatformPred { inline PlatformPred(int nameid, int platform = -1, int encoding = -1, int language = -1); - inline bool operator()(const namerecord_t &) const; + inline bool operator()(const namerecord_t&) const; private: int _nameid, _platform, _encoding, _language; }; struct EnglishPlatformPred { EnglishPlatformPred(int nameid) : _nameid(nameid) { } - inline bool operator()(const namerecord_t &) const; + inline bool operator()(const namerecord_t&) const; private: int _nameid; }; @@ -68,19 +69,19 @@ class Name { public: }; -inline int Name::nameid(const namerecord_t &nr) { +inline int Name::nameid(const namerecord_t& nr) { return Data::u16_aligned(reinterpret_cast<const unsigned char*>(&nr) + 6); } -inline int Name::platform(const namerecord_t &nr) { +inline int Name::platform(const namerecord_t& nr) { return Data::u16_aligned(reinterpret_cast<const unsigned char*>(&nr)); } -inline int Name::encoding(const namerecord_t &nr) { +inline int Name::encoding(const namerecord_t& nr) { return Data::u16_aligned(reinterpret_cast<const unsigned char*>(&nr) + 2); } -inline int Name::language(const namerecord_t &nr) { +inline int Name::language(const namerecord_t& nr) { return Data::u16_aligned(reinterpret_cast<const unsigned char*>(&nr) + 4); } @@ -101,18 +102,19 @@ inline Name::PlatformPred::PlatformPred(int nid, int p, int e, int l) : _nameid(nid), _platform(p), _encoding(e), _language(l) { } -inline bool Name::PlatformPred::operator()(const namerecord_t &i) const { +inline bool Name::PlatformPred::operator()(const namerecord_t& i) const { return (_nameid == nameid(i)) && (_platform < 0 || _platform == platform(i)) && (_encoding < 0 || _encoding == encoding(i)) && (_language < 0 || _language == language(i)); } -inline bool Name::EnglishPlatformPred::operator()(const namerecord_t &i) const { +inline bool Name::EnglishPlatformPred::operator()(const namerecord_t& i) const { if (_nameid == nameid(i)) { int p = platform(i), e = encoding(i), l = language(i); return (p == P_MACINTOSH && e == E_MAC_ROMAN && l == 0) - || (p == P_MICROSOFT && e == E_MS_UNICODE_BMP && l == L_MS_ENGLISH_AMERICAN); + || (p == P_MICROSOFT && e == E_MS_UNICODE_BMP && l == L_MS_ENGLISH_AMERICAN) + || (p == P_MICROSOFT && e == E_MS_UNICODE_FULL && l == L_MS_ENGLISH_AMERICAN); } else return false; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfos2.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfos2.hh index c6bb5208aca..88262c97c5a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfos2.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfos2.hh @@ -14,17 +14,19 @@ class Os2 { public: bool ok() const { return _error >= 0; } int error() const { return _error; } - enum Offsets { O_AVGCHARWIDTH = 2, O_SUBSCRIPTXSIZE = 10, - O_SUBSCRIPTYSIZE = 12, O_SUBSCRIPTXOFFSET = 14, - O_SUBSCRIPTYOFFSET = 16, O_SUPERSCRIPTXSIZE = 18, - O_SUPERSCRIPTYSIZE = 20, O_SUPERSCRIPTXOFFSET = 22, - O_SUPERSCRIPTYOFFSET = 24, O_STRIKEOUTSIZE = 26, - O_STRIKEOUTPOSITION = 28, O_VENDORID = 58, + enum Offsets { O_AVGCHARWIDTH = 2, O_FSTYPE = 8, + O_SUBSCRIPTXSIZE = 10, O_SUBSCRIPTYSIZE = 12, + O_SUBSCRIPTXOFFSET = 14, O_SUBSCRIPTYOFFSET = 16, + O_SUPERSCRIPTXSIZE = 18, O_SUPERSCRIPTYSIZE = 20, + O_SUPERSCRIPTXOFFSET = 22, O_SUPERSCRIPTYOFFSET = 24, + O_STRIKEOUTSIZE = 26, O_STRIKEOUTPOSITION = 28, + O_VENDORID = 58, O_TYPOASCENDER = 68, O_TYPODESCENDER = 70, O_TYPOLINEGAP = 72, O_XHEIGHT = 86, O_CAPHEIGHT = 88, O_LOWEROPTICALPOINTSIZE = 96, O_UPPEROPTICALPOINTSIZE = 98 }; enum { HEADER_SIZE = 2 }; + inline uint16_t type_flags() const; inline int16_t typo_ascender() const; inline int16_t typo_descender() const; inline int16_t typo_line_gap() const; @@ -45,6 +47,11 @@ class Os2 { public: }; +inline uint16_t Os2::type_flags() const +{ + return _data.u16(O_FSTYPE); +} + inline int16_t Os2::typo_ascender() const { return _data.s16(O_TYPOASCENDER); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1cs.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1cs.hh index d9f36db6cd9..7be78e53664 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1cs.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1cs.hh @@ -25,7 +25,7 @@ class Charstring { public: Charstring() { } virtual ~Charstring(); - virtual bool process(CharstringInterp &) const = 0; + virtual bool process(CharstringInterp&) const = 0; enum Commands { cError = 0, @@ -122,9 +122,9 @@ class Charstring { public: }; static String command_name(int); - static const char * const command_names[]; + static const char* const command_names[]; - static const char * const standard_encoding[256]; + static const char* const standard_encoding[256]; }; @@ -132,25 +132,25 @@ class Charstring { public: class Type1Charstring : public Charstring { public: Type1Charstring() { } - inline Type1Charstring(const String &); // unencrypted - Type1Charstring(int lenIV, const String &); // encrypted + inline Type1Charstring(const String&); // unencrypted + Type1Charstring(int lenIV, const String&); // encrypted // default copy constructor // default destructor // default assignment operator - inline const uint8_t *data() const; + inline const uint8_t* data() const; int length() const { return _s.length(); } operator String::unspecified_bool_type() const { return _s; } - inline const String &data_string() const; + inline const String& data_string() const; inline String substring(int pos, int len) const; int first_caret_after(int pos) const; - inline void assign(const String &); - void prepend(const Type1Charstring &); - void assign_substring(int pos, int len, const String &); + inline void assign(const String&); + void prepend(const Type1Charstring&); + void assign_substring(int pos, int len, const String&); - bool process(CharstringInterp &) const; + bool process(CharstringInterp&) const; private: @@ -165,15 +165,15 @@ class Type1Charstring : public Charstring { public: class Type2Charstring : public Charstring { public: Type2Charstring() { } - inline Type2Charstring(const String &); + inline Type2Charstring(const String&); // default copy constructor // default destructor // default assignment operator - inline const uint8_t *data() const; + inline const uint8_t* data() const; int length() const { return _s.length(); } - bool process(CharstringInterp &) const; + bool process(CharstringInterp&) const; private: @@ -184,14 +184,14 @@ class Type2Charstring : public Charstring { public: struct CharstringContext { - CharstringContext(const CharstringProgram *program_, const Charstring *cs_) : program(program_), cs(cs_) { } + CharstringContext(const CharstringProgram* program_, const Charstring* cs_) : program(program_), cs(cs_) { } operator String::unspecified_bool_type() const { return cs != 0 ? &String::length : 0; } - const CharstringProgram *program; - const Charstring *cs; + const CharstringProgram* program; + const Charstring* cs; }; @@ -205,38 +205,38 @@ class CharstringProgram { public: virtual void font_matrix(double[6]) const; unsigned units_per_em() const { return _units_per_em; } - inline const CharstringProgram *program(int) const; - virtual const CharstringProgram *child_program(int) const; + inline const CharstringProgram* program(int) const; + virtual const CharstringProgram* child_program(int) const; bool parent_program() const { return _parent_program; } void set_parent_program(bool pp) { _parent_program = pp; } virtual int nsubrs() const { return 0; } - virtual Charstring *subr(int) const { return 0; } + virtual Charstring* subr(int) const { return 0; } virtual int subr_bias() const { return 0; } virtual int ngsubrs() const { return 0; } - virtual Charstring *gsubr(int) const { return 0; } + virtual Charstring* gsubr(int) const { return 0; } virtual int gsubr_bias() const { return 0; } inline int nxsubrs(bool g) const; - inline Charstring *xsubr(bool g, int) const; + inline Charstring* xsubr(bool g, int) const; inline int xsubr_bias(bool g) const; virtual int nglyphs() const { return 0; } virtual PermString glyph_name(int) const { return PermString(); } - virtual void glyph_names(Vector<PermString> &) const; - virtual Charstring *glyph(int) const { return 0; } - virtual Charstring *glyph(PermString) const { return 0; } + virtual void glyph_names(Vector<PermString>&) const; + virtual Charstring* glyph(int) const { return 0; } + virtual Charstring* glyph(PermString) const { return 0; } inline CharstringContext glyph_context(int) const; inline CharstringContext glyph_context(PermString) const; virtual bool is_mm() const { return mmspace() != 0; } - virtual MultipleMasterSpace *mmspace() const { return 0; } + virtual MultipleMasterSpace* mmspace() const { return 0; } enum VectorType { VEC_WEIGHT = 0, VEC_NORM_DESIGN = 1, VEC_DESIGN = 2 }; - virtual Vector<double> *mm_vector(VectorType, bool writable) const; + virtual Vector<double>* mm_vector(VectorType, bool writable) const; - virtual Type1Encoding *type1_encoding() const { return 0; } + virtual Type1Encoding* type1_encoding() const { return 0; } virtual double global_width_x(bool is_nominal) const; @@ -257,25 +257,25 @@ enum Type1Defs { }; -inline Type1Charstring::Type1Charstring(const String &s) +inline Type1Charstring::Type1Charstring(const String& s) : Charstring(), _s(s), _key(-1) { } -inline void Type1Charstring::assign(const String &s) +inline void Type1Charstring::assign(const String& s) { _s = s; _key = -1; } -inline const uint8_t *Type1Charstring::data() const +inline const uint8_t* Type1Charstring::data() const { if (_key >= 0) decrypt(); - return reinterpret_cast<const uint8_t *>(_s.data()); + return reinterpret_cast<const uint8_t*>(_s.data()); } -inline const String &Type1Charstring::data_string() const +inline const String& Type1Charstring::data_string() const { if (_key >= 0) decrypt(); @@ -289,20 +289,20 @@ inline String Type1Charstring::substring(int pos, int len) const return _s.substring(pos, len); } -inline bool operator==(const Type1Charstring &a, const Type1Charstring &b) +inline bool operator==(const Type1Charstring& a, const Type1Charstring& b) { return a.data_string() == b.data_string(); } -inline Type2Charstring::Type2Charstring(const String &s) +inline Type2Charstring::Type2Charstring(const String& s) : _s(s) { } -inline const uint8_t *Type2Charstring::data() const +inline const uint8_t* Type2Charstring::data() const { - return reinterpret_cast<const uint8_t *>(_s.data()); + return reinterpret_cast<const uint8_t*>(_s.data()); } @@ -311,7 +311,7 @@ inline int CharstringProgram::nxsubrs(bool g) const return (g ? ngsubrs() : nsubrs()); } -inline Charstring *CharstringProgram::xsubr(bool g, int i) const +inline Charstring* CharstringProgram::xsubr(bool g, int i) const { return (g ? gsubr(i) : subr(i)); } @@ -321,7 +321,7 @@ inline int CharstringProgram::xsubr_bias(bool g) const return (g ? gsubr_bias() : subr_bias()); } -inline const CharstringProgram *CharstringProgram::program(int gi) const +inline const CharstringProgram* CharstringProgram::program(int gi) const { return (_parent_program ? child_program(gi) : this); } @@ -330,7 +330,7 @@ inline CharstringContext CharstringProgram::glyph_context(int gi) const { if (!_parent_program) return CharstringContext(this, glyph(gi)); - else if (const CharstringProgram *p = child_program(gi)) + else if (const CharstringProgram* p = child_program(gi)) return CharstringContext(p, p->glyph(gi)); else return CharstringContext(0, 0); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1font.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1font.hh index a879a11e9ab..31eae7040be 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1font.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1font.hh @@ -17,10 +17,10 @@ class MultipleMasterSpace; class Type1Font : public CharstringProgram { public: - Type1Font(Type1Reader &); + Type1Font(Type1Reader&); ~Type1Font(); - int read(Type1Reader &); + int read(Type1Reader&); bool ok() const; @@ -28,29 +28,29 @@ class Type1Font : public CharstringProgram { public: void font_matrix(double[6]) const; int nitems() const { return _items.size(); } - Type1Item *item(int i) const { return _items[i]; } - void add_item(Type1Item *it) { _items.push_back(it); } - void add_definition(int dict, Type1Definition *); - void add_type1_encoding(Type1Encoding *); + Type1Item* item(int i) const { return _items[i]; } + void add_item(Type1Item* it) { _items.push_back(it); } + void add_definition(int dict, Type1Definition*); + void add_type1_encoding(Type1Encoding*); int nsubrs() const { return _subrs.size(); } - Type1Charstring *subr(int) const; + Type1Charstring* subr(int) const; int nglyphs() const { return _glyphs.size(); } PermString glyph_name(int) const; - Type1Charstring *glyph(int) const; - Type1Charstring *glyph(PermString) const; - void add_glyph(Type1Subr *); + Type1Charstring* glyph(int) const; + Type1Charstring* glyph(PermString) const; + void add_glyph(Type1Subr*); - Type1Subr *subr_x(int i) const { return _subrs[i]; } - bool set_subr(int, const Type1Charstring &, PermString definer = PermString()); + Type1Subr* subr_x(int i) const { return _subrs[i]; } + bool set_subr(int, const Type1Charstring&, PermString definer = PermString()); bool remove_subr(int); void fill_in_subrs(); - void renumber_subrs(const Vector<int> &); // dangerous! + void renumber_subrs(const Vector<int>&); // dangerous! - Type1Subr *glyph_x(int i) const { return _glyphs[i]; } + Type1Subr* glyph_x(int i) const { return _glyphs[i]; } - Type1Encoding *type1_encoding() const { return _encoding; } + Type1Encoding* type1_encoding() const { return _encoding; } // note: the order is relevant enum Dict { @@ -63,42 +63,41 @@ class Type1Font : public CharstringProgram { public: dLast }; - Type1Definition *dict(int d, PermString s) const { return _dict[d][s]; } - Type1Definition *dict(PermString s) const { return _dict[dF][s]; } - Type1Definition *p_dict(PermString s) const { return _dict[dP][s]; } - Type1Definition *b_dict(PermString s) const { return _dict[dB][s]; } - Type1Definition *bp_dict(PermString s) const { return _dict[dBP][s];} - Type1Definition *fi_dict(PermString s) const { return _dict[dFI][s];} + Type1Definition* dict(int d, PermString s) const { return _dict[d][s]; } + Type1Definition* dict(PermString s) const { return _dict[dF][s]; } + Type1Definition* p_dict(PermString s) const { return _dict[dP][s]; } + Type1Definition* b_dict(PermString s) const { return _dict[dB][s]; } + Type1Definition* bp_dict(PermString s) const { return _dict[dBP][s];} + Type1Definition* fi_dict(PermString s) const { return _dict[dFI][s];} - typedef HashMap<PermString, Type1Definition *> DictHashMap; + typedef HashMap<PermString, Type1Definition*> DictHashMap; inline DictHashMap::const_iterator dict_begin(int dict) const; inline DictHashMap::iterator dict_begin(int dict); int first_dict_item(int d) const { return _index[d]; } - Type1Definition *ensure(Dict, PermString); - void add_header_comment(const String &); + Type1Definition* ensure(Dict, PermString); + void add_header_comment(const String&); - MultipleMasterSpace *create_mmspace(ErrorHandler * = 0) const; - MultipleMasterSpace *mmspace() const; + MultipleMasterSpace* create_mmspace(ErrorHandler* = 0) const; + MultipleMasterSpace* mmspace() const; void undo_synthetic(); void set_charstring_definer(PermString d) { _charstring_definer = d; } - void write(Type1Writer &); + void write(Type1Writer&); // font skeletons - static Type1Font *skeleton_make(PermString, const String &version = String()); - static Type1Font *skeleton_make_copy(const Type1Font *, PermString, const Vector<double> *xuid_extension); - void skeleton_comments_end(); + static Type1Font* skeleton_make(PermString, const String& version = String()); + static Type1Font* skeleton_make_copy(const Type1Font*, PermString, const Vector<double>*xuid_extension); void skeleton_fontinfo_end(); void skeleton_fontdict_end(); void skeleton_private_end(); void skeleton_common_subrs(); // for experts only - void set_item(int, Type1Item *); - inline void set_dict(int dict, PermString, Type1Definition *); + void set_item(int, Type1Item*); + inline void set_dict(int dict, PermString, Type1Definition*); void uncache_defs(); private: @@ -107,34 +106,34 @@ class Type1Font : public CharstringProgram { public: bool _built; mutable PermString _font_name; - Vector<Type1Item *> _items; + Vector<Type1Item*> _items; - HashMap<PermString, Type1Definition *> *_dict; + HashMap<PermString, Type1Definition*>* _dict; int _index[dLast]; int _dict_deltas[dLast]; - Vector<Type1Subr *> _subrs; - Vector<Type1Subr *> _glyphs; + Vector<Type1Subr*> _subrs; + Vector<Type1Subr*> _glyphs; HashMap<PermString, int> _glyph_map; PermString _charstring_definer; - Type1Encoding *_encoding; + Type1Encoding* _encoding; mutable bool _cached_mmspace; - mutable MultipleMasterSpace *_mmspace; + mutable MultipleMasterSpace* _mmspace; - Type1IncludedFont *_synthetic_item; + Type1IncludedFont* _synthetic_item; Type1Font(PermString); - Type1Font(const Type1Font &); - Type1Font &operator=(const Type1Font &); + Type1Font(const Type1Font&); + Type1Font& operator=(const Type1Font&); - void read_encoding(Type1Reader &, const char *); - bool read_synthetic_font(Type1Reader &, const char *, StringAccum &); + void read_encoding(Type1Reader&, const char*); + bool read_synthetic_font(Type1Reader&, const char*, StringAccum&); void cache_defs() const; void shift_indices(int, int); - Type1Item *dict_size_item(int) const; + Type1Item* dict_size_item(int) const; int get_dict_size(int) const; void set_dict_size(int, int); @@ -151,7 +150,7 @@ inline Type1Font::DictHashMap::iterator Type1Font::dict_begin(int dict) return _dict[dict].begin(); } -inline void Type1Font::set_dict(int dict, PermString name, Type1Definition *t1d) +inline void Type1Font::set_dict(int dict, PermString name, Type1Definition* t1d) { _dict[dict].insert(name, t1d); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/bezier.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/bezier.hh index fb1018ed0e5..02f3a0f3291 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/bezier.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/bezier.hh @@ -7,13 +7,13 @@ class Bezier { public: - Bezier() : _bb(-1) { } + Bezier() : _bb(-1) { } inline Bezier(Point p[4]) noexcept; inline Bezier(const Point &, const Point &, const Point &, const Point &) noexcept; - const Point *points() const { return _p; } - const Point &point(int i) const { assert(i>=0&&i<4); return _p[i]; } - Point &mpoint(int i) { assert(i>=0&&i<4); _bb = -1; return _p[i]; } + const Point *points() const { return _p; } + const Point &point(int i) const { assert(i>=0&&i<4); return _p[i]; } + Point &mpoint(int i) { assert(i>=0&&i<4); _bb = -1; return _p[i]; } void set_point(int i, const Point &p) { mpoint(i) = p; } Point eval(double) const noexcept; @@ -72,7 +72,7 @@ inline void Bezier::ensure_bb() const noexcept { if (_bb < 0) - make_bb(); + make_bb(); } inline double diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/clp.h b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/clp.h index 3174a06e596..a3126b780e9 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/clp.h +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/clp.h @@ -8,18 +8,25 @@ extern "C" { /* clp.h - Public interface to CLP. * This file is part of CLP, the command line parser package. * - * Copyright (c) 1997-2019 Eddie Kohler, ekohler@gmail.com + * Copyright (c) 1997-2021 Eddie Kohler, ekohler@gmail.com + * + * CLP is free software. It is distributed under the GNU General Public + * License, Version 2, or, alternatively and at your discretion, under the + * more permissive (BSD-like) Click LICENSE file as described below. * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, subject to the conditions - * listed in the Click LICENSE file, which is available in full at - * http://www.pdos.lcs.mit.edu/click/license.html. The conditions include: you - * must preserve this copyright notice, and you cannot mention the copyright - * holders in advertising related to the Software without their permission. - * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This - * notice is a summary of the Click LICENSE file; the license in that file is - * legally binding. */ + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, subject to the + * conditions listed in the Click LICENSE file, which is available in full at + * http://github.com/kohler/click/blob/master/LICENSE. The conditions + * include: you must preserve this copyright notice, and you cannot mention + * the copyright holders in advertising related to the Software without + * their permission. The Software is provided WITHOUT ANY WARRANTY, EXPRESS + * OR IMPLIED. This notice is a summary of the Click LICENSE file; the + * license in that file is binding. */ + +#include <stdio.h> +#include <stdarg.h> typedef struct Clp_Option Clp_Option; typedef struct Clp_Parser Clp_Parser; @@ -32,15 +39,15 @@ typedef struct Clp_ParserState Clp_ParserState; * should be parsed. * @sa Clp_NewParser, Clp_SetOptions */ struct Clp_Option { - const char *long_name; /**< Name of long option, or NULL if the option - has no long name. */ - int short_name; /**< Character defining short option, or 0 if - the option has no short name. */ - int option_id; /**< User-specified ID defining option, - returned by Clp_Next. */ - int val_type; /**< ID of option's value type, or 0 if option - takes no value. */ - int flags; /**< Option parsing flags. */ + const char *long_name; /**< Name of long option, or NULL if the option + has no long name. */ + int short_name; /**< Character defining short option, or 0 if + the option has no short name. */ + int option_id; /**< User-specified ID defining option, + returned by Clp_Next. */ + int val_type; /**< ID of option's value type, or 0 if option + takes no value. */ + int flags; /**< Option parsing flags. */ }; /** @name Value types @@ -48,98 +55,102 @@ struct Clp_Option { * the Clp_Option val_type field. For example, if an option took integers, its * Clp_Option structure would have val_type set to Clp_ValInt. */ /**@{*/ -#define Clp_NoVal 0 /**< @brief Option takes no value. */ -#define Clp_ValString 1 /**< @brief Option value is an - arbitrary string. */ -#define Clp_ValStringNotOption 2 /**< @brief Option value is a - non-option string. - - See Clp_DisallowOptions. */ -#define Clp_ValBool 3 /**< @brief Option value is a - boolean. - - Accepts "true", "false", "yes", "no", "1", and "0", or any - prefixes thereof. The match is case-insensitive. */ -#define Clp_ValInt 4 /**< @brief Option value is a - signed int. - - Accepts an optional "+" or "-" sign, followed by one or more - digits. The digits may be include a "0x" or "0X" prefix, for - a hexidecimal number, or a "0" prefix, for an octal number; - otherwise it is decimal. */ -#define Clp_ValUnsigned 5 /**< @brief Option value is an - unsigned int. - - Accepts an optional "+" sign, followed by one or more - digits. The digits may be include a "0x" or "0X" prefix, for - a hexidecimal number, or a "0" prefix, for an octal number; - otherwise it is decimal. */ -#define Clp_ValDouble 6 /**< @brief Option value is a - double. - Accepts a real number as defined by strtod(). */ -#define Clp_ValFirstUser 10 /**< @brief Value types >= - Clp_ValFirstUser are available - for user types. */ +#define Clp_NoVal 0 /**< @brief Option takes no value. */ +#define Clp_ValString 1 /**< @brief Option value is an + arbitrary string. */ +#define Clp_ValStringNotOption 2 /**< @brief Option value is a + non-option string. + + See Clp_DisallowOptions. */ +#define Clp_ValBool 3 /**< @brief Option value is a + boolean. + + Accepts "true", "false", "yes", "no", "1", and "0", or any + prefixes thereof. The match is case-insensitive. */ +#define Clp_ValInt 4 /**< @brief Option value is a + signed int. + + Accepts an optional "+" or "-" sign, followed by one or more + digits. The digits may be include a "0x" or "0X" prefix, for + a hexadecimal number, or a "0" prefix, for an octal number; + otherwise it is decimal. */ +#define Clp_ValUnsigned 5 /**< @brief Option value is an + unsigned int. + + Accepts an optional "+" sign, followed by one or more + digits. The digits may be include a "0x" or "0X" prefix, for + a hexadecimal number, or a "0" prefix, for an octal number; + otherwise it is decimal. */ +#define Clp_ValLong 6 /**< @brief Option value is a + signed long. */ +#define Clp_ValUnsignedLong 7 /**< @brief Option value is an + unsigned long. */ +#define Clp_ValDouble 8 /**< @brief Option value is a + double. + Accepts a real number as defined by strtod(). */ +#define Clp_ValFirstUser 10 /**< @brief Value types >= + Clp_ValFirstUser are available + for user types. */ /**@}*/ /** @name Option flags * These flags are used in the Clp_Option flags field. */ /**@{*/ -#define Clp_Mandatory (1<<0) /**< @brief Option flag: value - is mandatory. - - It is an error if the option has no value. This is the - default if an option has arg_type != 0 and the Clp_Optional - flag is not provided. */ -#define Clp_Optional (1<<1) /**< @brief Option flag: value - is optional. */ -#define Clp_Negate (1<<2) /**< @brief Option flag: option - may be negated. - - --no-[long_name] will be accepted in argument lists. */ -#define Clp_OnlyNegated (1<<3) /**< @brief Option flag: option - <em>must</em> be negated. - - --no-[long_name] will be accepted in argument lists, but - --[long_name] will not. This is the default if long_name - begins with "no-". */ -#define Clp_PreferredMatch (1<<4) /**< @brief Option flag: prefer this - option when matching. - - Prefixes of --[long_name] should map to this option, even if - other options begin with --[long_name]. */ +#define Clp_Mandatory (1<<0) /**< @brief Option flag: value + is mandatory. + + It is an error if the option has no value. This is the + default if an option has arg_type != 0 and the Clp_Optional + flag is not provided. */ +#define Clp_Optional (1<<1) /**< @brief Option flag: value + is optional. */ +#define Clp_Negate (1<<2) /**< @brief Option flag: option + may be negated. + + --no-[long_name] will be accepted in argument lists. */ +#define Clp_OnlyNegated (1<<3) /**< @brief Option flag: option + <em>must</em> be negated. + + --no-[long_name] will be accepted in argument lists, but + --[long_name] will not. This is the default if long_name + begins with "no-". */ +#define Clp_PreferredMatch (1<<4) /**< @brief Option flag: prefer this + option when matching. + + Prefixes of --[long_name] should map to this option, even if + other options begin with --[long_name]. */ /**@}*/ /** @name Option character types * These flags are used in to define character types in Clp_SetOptionChar(). */ /**@{*/ -/* Clp_NotOption 0 */ -#define Clp_Short (1<<0) /**< @brief Option character begins - a set of short options. */ -#define Clp_Long (1<<1) /**< @brief Option character begins - a long option. */ -#define Clp_ShortNegated (1<<2) /**< @brief Option character begins - a set of negated short options. */ -#define Clp_LongNegated (1<<3) /**< @brief Option character begins - a negated long option. */ -#define Clp_LongImplicit (1<<4) /**< @brief Option character can begin - a long option, and is part of that - long option. */ +/* Clp_NotOption 0 */ +#define Clp_Short (1<<0) /**< @brief Option character begins + a set of short options. */ +#define Clp_Long (1<<1) /**< @brief Option character begins + a long option. */ +#define Clp_ShortNegated (1<<2) /**< @brief Option character begins + a set of negated short options. */ +#define Clp_LongNegated (1<<3) /**< @brief Option character begins + a negated long option. */ +#define Clp_LongImplicit (1<<4) /**< @brief Option character can begin + a long option, and is part of that + long option. */ /**@}*/ -#define Clp_NotOption 0 /**< @brief Clp_Next value: argument - was not an option. */ -#define Clp_Done -1 /**< @brief Clp_Next value: there are - no more arguments. */ -#define Clp_BadOption -2 /**< @brief Clp_Next value: argument - was an erroneous option. */ -#define Clp_Error -3 /**< @brief Clp_Next value: internal - CLP error. */ +#define Clp_NotOption 0 /**< @brief Clp_Next value: argument + was not an option. */ +#define Clp_Done -1 /**< @brief Clp_Next value: there are + no more arguments. */ +#define Clp_BadOption -2 /**< @brief Clp_Next value: argument + was an erroneous option. */ +#define Clp_Error -3 /**< @brief Clp_Next value: internal + CLP error. */ -#define Clp_ValSize 40 /**< @brief Minimum size of the - Clp_Parser val.cs field. */ -#define Clp_ValIntSize 10 /**< @brief Minimum size of the - Clp_Parser val.is field. */ +#define Clp_ValSize 40 /**< @brief Minimum size of the + Clp_Parser val.cs field. */ +#define Clp_ValIntSize 10 /**< @brief Minimum size of the + Clp_Parser val.is field. */ /** @brief A value parsing function. @@ -150,7 +161,7 @@ struct Clp_Option { * @return 1 if parsing succeeded, 0 otherwise */ typedef int (*Clp_ValParseFunc)(Clp_Parser *clp, const char *vstr, - int complain, void *user_data); + int complain, void *user_data); /** @brief A function for reporting option errors. * @param clp the parser @@ -165,49 +176,51 @@ typedef void (*Clp_ErrorHandler)(Clp_Parser *clp, const char *message); * value types, and current arguments. * @sa Clp_NewParser, Clp_SetOptions, Clp_SetArguments */ struct Clp_Parser { - const Clp_Option *option; /**< The last option. */ + const Clp_Option *option; /**< The last option. */ - int negated; /**< Whether the last option was negated. */ + int negated; /**< Whether the last option was negated. */ - int have_val; /**< Whether the last option had a value. */ - const char *vstr; /**< The string value provided with the last - option. */ + int have_val; /**< Whether the last option had a value. */ + const char *vstr; /**< The string value provided with the last + option. */ union { - int i; - unsigned u; - double d; - const char *s; - void *pv; + int i; + unsigned u; + long l; + unsigned long ul; + double d; + const char *s; + void *pv; #ifdef HAVE_INT64_TYPES - int64_t i64; - uint64_t u64; + int64_t i64; + uint64_t u64; #endif - char cs[Clp_ValSize]; - unsigned char ucs[Clp_ValSize]; - int is[Clp_ValIntSize]; - unsigned us[Clp_ValIntSize]; - } val; /**< The parsed value provided with the last - option. */ + char cs[Clp_ValSize]; + unsigned char ucs[Clp_ValSize]; + int is[Clp_ValIntSize]; + unsigned us[Clp_ValIntSize]; + } val; /**< The parsed value provided with the last + option. */ - void *user_data; /**< Uninterpreted by CLP; users can set - arbitrarily. */ + void *user_data; /**< Uninterpreted by CLP; users can set + arbitrarily. */ struct Clp_Internal *internal; }; /** @cond never */ #if __GNUC__ >= 4 -# define CLP_SENTINEL __attribute__((sentinel)) +# define CLP_SENTINEL __attribute__((sentinel)) #else -# define CLP_SENTINEL /* nothing */ +# define CLP_SENTINEL /* nothing */ #endif /** @endcond never */ /** @brief Create a new Clp_Parser. */ Clp_Parser *Clp_NewParser(int argc, const char * const *argv, - int nopt, const Clp_Option *opt); + int nopt, const Clp_Option *opt); /** @brief Destroy a Clp_Parser object. */ void Clp_DeleteParser(Clp_Parser *clp); @@ -242,29 +255,31 @@ void Clp_SetArguments(Clp_Parser *clp, int argc, const char * const *argv); int Clp_SetOptionProcessing(Clp_Parser *clp, int on); -#define Clp_DisallowOptions (1<<0) /**< @brief Value type flag: value - can't be an option string. +#define Clp_DisallowOptions (1<<0) /**< @brief Value type flag: value + can't be an option string. - See Clp_AddType(). */ + See Clp_AddType(). */ /** @brief Define a new value type for @a clp. */ int Clp_AddType(Clp_Parser *clp, int val_type, int flags, - Clp_ValParseFunc parser, void *user_data); + Clp_ValParseFunc parser, void *user_data); -#define Clp_AllowNumbers (1<<0) /**< @brief String list flag: allow - explicit numbers. +#define Clp_AllowNumbers (1<<0) /**< @brief String list flag: allow + explicit numbers. - See Clp_AddStringListType() and Clp_AddStringListTypeVec(). */ + See Clp_AddStringListType() and Clp_AddStringListTypeVec(). */ +#define Clp_StringListLong (1<<1) /**< @brief String list flag: values + have long type. */ /** @brief Define a new string list value type for @a clp. */ int Clp_AddStringListTypeVec(Clp_Parser *clp, int val_type, int flags, - int nstrs, const char * const *strs, - const int *vals); + int nstrs, const char * const *strs, + const int *vals); /** @brief Define a new string list value type for @a clp. */ int Clp_AddStringListType(Clp_Parser *clp, int val_type, int flags, ...) - CLP_SENTINEL; + CLP_SENTINEL; /** @brief Parse and return the next argument from @a clp. */ @@ -290,12 +305,28 @@ void Clp_RestoreParser(Clp_Parser *clp, const Clp_ParserState *state); /** @brief Report a parser error. */ int Clp_OptionError(Clp_Parser *clp, const char *format, ...); +/** @brief Format a message. */ +int Clp_vsnprintf(Clp_Parser* clp, char* str, size_t size, + const char* format, va_list val); + +/** @brief Print a message. */ +int Clp_fprintf(Clp_Parser* clp, FILE* f, const char* format, ...); + +/** @brief Print a message. */ +int Clp_vfprintf(Clp_Parser* clp, FILE* f, const char* format, va_list val); + /** @brief Extract the current option as a string. */ int Clp_CurOptionNameBuf(Clp_Parser *clp, char *buf, int len); /** @brief Extract the current option as a string. */ const char *Clp_CurOptionName(Clp_Parser *clp); +/** @brief Test if the current option had long name @a name. */ +int Clp_IsLong(Clp_Parser *clp, const char *long_name); + +/** @brief Test if the current option had short name @a name. */ +int Clp_IsShort(Clp_Parser *clp, int short_name); + #undef CLP_SENTINEL #ifdef __cplusplus } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/error.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/error.hh index 36b3e728a63..3b473f9ce0a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/error.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/error.hh @@ -7,13 +7,13 @@ #endif #include <stdarg.h> #if HAVE_ADDRESSABLE_VA_LIST -# define VA_LIST_REF_T va_list * -# define VA_LIST_DEREF(val) (*(val)) -# define VA_LIST_REF(val) (&(val)) +# define VA_LIST_REF_T va_list * +# define VA_LIST_DEREF(val) (*(val)) +# define VA_LIST_REF(val) (&(val)) #else -# define VA_LIST_REF_T va_list -# define VA_LIST_DEREF(val) (val) -# define VA_LIST_REF(val) (val) +# define VA_LIST_REF_T va_list +# define VA_LIST_DEREF(val) (val) +# define VA_LIST_REF(val) (val) #endif #if __GNUC__ <= 3 # define ERRH_SENTINEL @@ -92,36 +92,36 @@ class ErrorHandler { public: * level, the exit status is the absolute value of the * error level. */ enum Level { - el_abort = -999, ///< Error level that triggers abort(). - el_fatal = -1, ///< Fatal exit error level. - /// Exit status equals -(level). - el_emergency = 0, ///< Emergency error level: system is unusable. - el_alert = 1, ///< Alert error level: action must be taken. - el_critical = 2, ///< Error level for critical conditions. - el_error = 3, ///< Error level for normal error conditions. - el_warning = 4, ///< Error level for warning conditions. - el_notice = 5, ///< Error level for normal, but significant - /// conditions. - el_info = 6, ///< Error level for informational messages. - el_debug = 7 ///< Error level for debug messages. + el_abort = -999, ///< Error level that triggers abort(). + el_fatal = -1, ///< Fatal exit error level. + /// Exit status equals -(level). + el_emergency = 0, ///< Emergency error level: system is unusable. + el_alert = 1, ///< Alert error level: action must be taken. + el_critical = 2, ///< Error level for critical conditions. + el_error = 3, ///< Error level for normal error conditions. + el_warning = 4, ///< Error level for warning conditions. + el_notice = 5, ///< Error level for normal, but significant + /// conditions. + el_info = 6, ///< Error level for informational messages. + el_debug = 7 ///< Error level for debug messages. }; /** @brief Error level indicators. */ static const char e_abort[], - e_fatal[], - e_emergency[], - e_alert[], - e_critical[], - e_error[], - e_warning[], - e_warning_annotated[], - e_notice[], - e_info[], - e_debug[]; + e_fatal[], + e_emergency[], + e_alert[], + e_critical[], + e_error[], + e_warning[], + e_warning_annotated[], + e_notice[], + e_info[], + e_debug[]; /** @brief Construct an ErrorHandler. */ ErrorHandler() - : _nerrors(0) { + : _nerrors(0) { } virtual ~ErrorHandler() { @@ -153,7 +153,7 @@ class ErrorHandler { public: /** @brief Return the default ErrorHandler. * @sa static_initialize() */ static ErrorHandler *default_handler() { - return the_default_handler; + return the_default_handler; } /** @brief Set the default ErrorHandler to @a errh. @@ -165,14 +165,14 @@ class ErrorHandler { public: /** @brief Return the global silent ErrorHandler. */ static ErrorHandler *silent_handler() { - return the_silent_handler; + return the_silent_handler; } - static const int ok_result; ///< Equals 0, used for error levels - /// <5> and above - static const int error_result; ///< Equals -EINVAL, used for error - /// levels <4> and below + static const int ok_result; ///< Equals 0, used for error levels + /// <5> and above + static const int error_result; ///< Equals -EINVAL, used for error + /// levels <4> and below /** @brief Print a debug message (level el_debug). @@ -226,7 +226,7 @@ class ErrorHandler { public: * * Shorthand for xmessage(combine_anno(@a str, @a anno)). */ int xmessage(const String &anno, const String &str) { - return xmessage(combine_anno(str, anno)); + return xmessage(combine_anno(str, anno)); } /** @brief Format and print an error message, adding annotations. * @param anno annotations @@ -235,7 +235,7 @@ class ErrorHandler { public: * * Shorthand for xmessage(@a anno, vformat(@a fmt, @a val)). */ int xmessage(const String &anno, const char *fmt, va_list val) { - return xmessage(anno, vformat(fmt, val)); + return xmessage(anno, vformat(fmt, val)); } /** @brief Print an error message, adding landmark and other annotations. * @param landmark landmark annotation @@ -245,8 +245,8 @@ class ErrorHandler { public: * Shorthand for xmessage(combine_anno(@a anno, make_landmark_anno(@a * landmark)), @a str). */ int xmessage(const String &landmark, const String &anno, - const String &str) { - return xmessage(combine_anno(anno, make_landmark_anno(landmark)), str); + const String &str) { + return xmessage(combine_anno(anno, make_landmark_anno(landmark)), str); } /** @brief Format and print an error message, adding landmark and other * annotations. @@ -258,8 +258,8 @@ class ErrorHandler { public: * Shorthand for xmessage(@a landmark, @a anno, vformat(@a fmt, @a * val)). */ int xmessage(const String &landmark, const String &anno, - const char *fmt, va_list val) { - return xmessage(landmark, anno, vformat(fmt, val)); + const char *fmt, va_list val) { + return xmessage(landmark, anno, vformat(fmt, val)); } @@ -280,7 +280,7 @@ class ErrorHandler { public: * * @sa account, clear */ int nerrors() const { - return _nerrors; + return _nerrors; } @@ -349,7 +349,7 @@ class ErrorHandler { public: static String xformat(const char *fmt, ...); /** @overload */ static String vxformat(const char *fmt, va_list val) { - return vxformat(0, fmt, val); + return vxformat(0, fmt, val); } @@ -436,7 +436,7 @@ class ErrorHandler { public: * * The default implementation sets the nerrors() counter to zero. */ virtual void clear() { - _nerrors = 0; + _nerrors = 0; } @@ -506,7 +506,7 @@ class ErrorHandler { public: * // Results: s points to "error message\n", level_str == 4 * @endcode */ static const char *parse_anno(const String &str, - const char *begin, const char *end, ...) ERRH_SENTINEL; + const char *begin, const char *end, ...) ERRH_SENTINEL; /** @brief Skip a string's error annotations. * @param begin pointer to start of string @@ -517,12 +517,12 @@ class ErrorHandler { public: * Use this function to skip an error line's annotation area. The error * line is defined as a pair of iterators. */ static const char *skip_anno(const char *begin, const char *end) { - String name, value; - const char *x = begin; - do { - x = skip_anno(String(), x, end, &name, &value, false); - } while (name); - return x; + String name, value; + const char *x = begin; + do { + x = skip_anno(String(), x, end, &name, &value, false); + } while (name); + return x; } @@ -533,12 +533,12 @@ class ErrorHandler { public: * like a formatted annotation (it starts with an open brace), returns @a * x unchanged. Otherwise, returns make_anno("l", @a x). */ static String make_landmark_anno(const String &x) { - if (x && x[0] == '{') - return x; - else if (x) - return make_anno("l", x); - else - return String(); + if (x && x[0] == '{') + return x; + else if (x) + return make_anno("l", x); + else + return String(); } /** @brief Clean the @a landmark. @@ -555,16 +555,16 @@ class ErrorHandler { public: struct Conversion; typedef String (*ConversionFunction)(int flags, VA_LIST_REF_T); enum ConversionFlags { - cf_zero_pad = 1, ///< Set for conversions using the '0' flag. - cf_plus_positive = 2, ///< Set for conversions using the '+' flag. - cf_space_positive = 4, ///< Set for conversions using the ' ' flag. - cf_left_just = 8, ///< Set for conversions using the '-' flag. - cf_alternate_form = 16, ///< Set for conversions using the '#' flag. - cf_singlequote = 32, ///< Set for conversions using the '\'' flag. - cf_uppercase = 64, ///< Set for 'X' conversions (not 'x'). - cf_signed = 128, ///< Set for conversions of signed numbers. - cf_negative = 256, ///< Set for conversions of negative numbers. - cf_utf8 = 1024 ///< Set to use UTF-8 characters on output. + cf_zero_pad = 1, ///< Set for conversions using the '0' flag. + cf_plus_positive = 2, ///< Set for conversions using the '+' flag. + cf_space_positive = 4, ///< Set for conversions using the ' ' flag. + cf_left_just = 8, ///< Set for conversions using the '-' flag. + cf_alternate_form = 16, ///< Set for conversions using the '#' flag. + cf_singlequote = 32, ///< Set for conversions using the '\'' flag. + cf_uppercase = 64, ///< Set for 'X' conversions (not 'x'). + cf_signed = 128, ///< Set for conversions of signed numbers. + cf_negative = 256, ///< Set for conversions of negative numbers. + cf_utf8 = 1024 ///< Set to use UTF-8 characters on output. }; static Conversion *add_conversion(const String &name, ConversionFunction func); static int remove_conversion(Conversion *conversion); @@ -577,9 +577,9 @@ class ErrorHandler { public: static ErrorHandler *the_silent_handler; static const char *skip_anno(const String &str, - const char *begin, const char *end, - String *name_result, String *value_result, - bool raw); + const char *begin, const char *end, + String *name_result, String *value_result, + bool raw); }; @@ -615,7 +615,7 @@ class ErrorVeneer : public ErrorHandler { public: * If @a errh is 0, then the ErrorVeneer acts like a * SilentErrorHandler. */ ErrorVeneer(ErrorHandler *errh) - : _errh(errh) { + : _errh(errh) { } String vformat(const char *fmt, va_list val); @@ -645,7 +645,7 @@ class FileErrorHandler : public ErrorHandler { public: FileErrorHandler(FILE *f, const String &prefix = String()); void set_default_flags(int default_flags) { - _default_flags = default_flags; + _default_flags = default_flags; } String vformat(const char *fmt, va_list val); @@ -679,7 +679,7 @@ class LocalErrorHandler : public ErrorVeneer { public: /** @brief Construct a LocalErrorHandler. */ LocalErrorHandler(ErrorHandler *errh) - : ErrorVeneer(errh) { + : ErrorVeneer(errh) { } }; @@ -737,17 +737,17 @@ class ContextErrorHandler : public ErrorVeneer { public: /** @brief Return true iff the context has already been printed. */ bool context_printed() const { - return _context_printed; + return _context_printed; } /** @brief Set whether the context has been printed. */ void set_context_printed(bool x) { - _context_printed = x; + _context_printed = x; } /** @brief Set the context string to @a str. */ void set_context(const String &str) { - _context = str; + _context = str; } /** @brief Set the indent string to @a str. @@ -756,7 +756,7 @@ class ContextErrorHandler : public ErrorVeneer { public: * contain landmarks as well as non-landmark text. The default indent * string is " " (two spaces). */ void set_indent(const String &str) { - _indent = str; + _indent = str; } /** @brief Set the context landmark to @a str. @@ -768,7 +768,7 @@ class ContextErrorHandler : public ErrorVeneer { public: * @note The input @a str is passed to * ErrorHandler::make_landmark_anno(). */ void set_context_landmark(const String &str) { - _context_landmark = make_landmark_anno(str); + _context_landmark = make_landmark_anno(str); } String decorate(const String &str); @@ -836,7 +836,7 @@ class LandmarkErrorHandler : public ErrorVeneer { public: /** @brief Set the default landmark applied to error messages. */ void set_landmark(const String &landmark) { - _landmark = make_landmark_anno(landmark); + _landmark = make_landmark_anno(landmark); } String decorate(const String &str); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/straccum.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/straccum.hh index b5756561684..c2496417716 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/straccum.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/straccum.hh @@ -27,7 +27,7 @@ class StringAccum { public: inline StringAccum(); explicit inline StringAccum(int capacity); - explicit inline StringAccum(const char *cstr); + explicit inline StringAccum(const char* cstr); inline StringAccum(const char* s, int len); inline StringAccum(const String& str); inline StringAccum(const StringAccum& x); @@ -64,7 +64,7 @@ class StringAccum { public: * length(), and later append() and similar operations can overwrite it. * If appending the null character fails, the StringAccum becomes * out-of-memory and the returned value is a null string. */ - const char *c_str(); + const char* c_str(); inline char operator[](int i) const; @@ -107,7 +107,7 @@ class StringAccum { public: inline void append(const unsigned char* begin, const unsigned char* end); // word joining - void append_break_lines(const String &text, int linelen, const String &leftmargin = String()); + void append_break_lines(const String& text, int linelen, const String& leftmargin = String()); /** @brief Append result of snprintf() to this StringAccum. * @param n maximum number of characters to print @@ -121,7 +121,7 @@ class StringAccum { public: * should make sure that the printf() invocation represented by your * arguments will never write more than @a n characters, not including the * terminating null. */ - StringAccum &snprintf(int n, const char *format, ...) LCDF_SNPRINTF_ATTR; + StringAccum& snprintf(int n, const char* format, ...) LCDF_SNPRINTF_ATTR; /** @brief Return a String object with this StringAccum's contents. @@ -137,52 +137,54 @@ class StringAccum { public: inline StringAccum& operator=(const StringAccum& x); /** @brief Swap this StringAccum's contents with @a x. */ - void swap(StringAccum &x); + void swap(StringAccum& x); // see also operator<< declarations below + static const char* double_format; + private: enum { MEMO_SPACE = String::MEMO_SPACE }; - unsigned char *_s; + unsigned char* _s; int _len; int _cap; - char *grow(int); + char* grow(int); void assign_out_of_memory(); - char *hard_extend(int nadjust, int nreserve); - void hard_append(const char *s, int len); + char* hard_extend(int nadjust, int nreserve); + void hard_append(const char* s, int len); void append_utf8_hard(unsigned ch); - friend StringAccum &operator<<(StringAccum &sa, const char *s); - friend StringAccum &operator<<(StringAccum &sa, const String &str); + friend StringAccum& operator<<(StringAccum& sa, const char* s); + friend StringAccum& operator<<(StringAccum& sa, const String& str); #if HAVE_PERMSTRING - friend StringAccum &operator<<(StringAccum &sa, PermString s); + friend StringAccum& operator<<(StringAccum& sa, PermString s); #endif }; -inline StringAccum &operator<<(StringAccum &, char); -inline StringAccum &operator<<(StringAccum &, unsigned char); -inline StringAccum &operator<<(StringAccum &, const char *); -inline StringAccum &operator<<(StringAccum &, const String &); -inline StringAccum &operator<<(StringAccum &, const StringAccum &); +inline StringAccum& operator<<(StringAccum&, char); +inline StringAccum& operator<<(StringAccum&, unsigned char); +inline StringAccum& operator<<(StringAccum&, const char*); +inline StringAccum& operator<<(StringAccum&, const String&); +inline StringAccum& operator<<(StringAccum&, const StringAccum&); #ifdef HAVE_PERMSTRING -inline StringAccum &operator<<(StringAccum &, PermString); +inline StringAccum& operator<<(StringAccum&, PermString); #endif -inline StringAccum &operator<<(StringAccum &, bool); -inline StringAccum &operator<<(StringAccum &, short); -inline StringAccum &operator<<(StringAccum &, unsigned short); -inline StringAccum &operator<<(StringAccum &, int); -inline StringAccum &operator<<(StringAccum &, unsigned); -StringAccum &operator<<(StringAccum &, long); -StringAccum &operator<<(StringAccum &, unsigned long); -StringAccum &operator<<(StringAccum &, double); +inline StringAccum& operator<<(StringAccum&, bool); +inline StringAccum& operator<<(StringAccum&, short); +inline StringAccum& operator<<(StringAccum&, unsigned short); +inline StringAccum& operator<<(StringAccum&, int); +inline StringAccum& operator<<(StringAccum&, unsigned); +StringAccum& operator<<(StringAccum&, long); +StringAccum& operator<<(StringAccum&, unsigned long); +StringAccum& operator<<(StringAccum&, double); /** @brief Construct an empty StringAccum (with length 0). */ @@ -211,25 +213,25 @@ inline StringAccum::StringAccum(int capacity) } /** @brief Construct a StringAccum containing the characters in @a s. */ -inline StringAccum::StringAccum(const char *cstr) +inline StringAccum::StringAccum(const char* cstr) : _s(0), _len(0), _cap(0) { append(cstr); } /** @brief Construct a StringAccum containing the characters in @a s. */ -inline StringAccum::StringAccum(const char *s, int len) +inline StringAccum::StringAccum(const char* s, int len) : _s(0), _len(0), _cap(0) { append(s, len); } /** @brief Construct a StringAccum containing the characters in @a str. */ -inline StringAccum::StringAccum(const String &str) +inline StringAccum::StringAccum(const String& str) : _s(0), _len(0), _cap(0) { append(str.begin(), str.end()); } /** @brief Construct a StringAccum containing a copy of @a x. */ -inline StringAccum::StringAccum(const StringAccum &x) +inline StringAccum::StringAccum(const StringAccum& x) : _s(0), _len(0), _cap(0) { append(x.data(), x.length()); } @@ -247,12 +249,12 @@ inline StringAccum::~StringAccum() { * The returned data() value points to writable memory (unless the * StringAccum itself is const). */ inline const char* StringAccum::data() const { - return reinterpret_cast<const char *>(_s); + return reinterpret_cast<const char*>(_s); } /** @overload */ inline char* StringAccum::data() { - return reinterpret_cast<char *>(_s); + return reinterpret_cast<char*>(_s); } inline const unsigned char* StringAccum::udata() const { @@ -333,7 +335,7 @@ inline char StringAccum::operator[](int i) const { * @pre 0 <= @a i < length() */ inline char& StringAccum::operator[](int i) { assert((unsigned) i < (unsigned) _len); - return reinterpret_cast<char &>(_s[i]); + return reinterpret_cast<char&>(_s[i]); } /** @brief Return the first character in the string. @@ -347,7 +349,7 @@ inline char StringAccum::front() const { * @pre length() > 0 */ inline char& StringAccum::front() { assert(_len > 0); - return reinterpret_cast<char &>(_s[0]); + return reinterpret_cast<char&>(_s[0]); } /** @brief Return the last character in the string. @@ -361,7 +363,7 @@ inline char StringAccum::back() const { * @pre length() > 0 */ inline char& StringAccum::back() { assert(_len > 0); - return reinterpret_cast<char &>(_s[_len - 1]); + return reinterpret_cast<char&>(_s[_len - 1]); } /** @brief Clear the StringAccum's comments. @@ -391,7 +393,7 @@ inline void StringAccum::clear() { inline char* StringAccum::reserve(int n) { assert(n >= 0); if (_len + n <= _cap) - return reinterpret_cast<char *>(_s + _len); + return reinterpret_cast<char*>(_s + _len); else return grow(_len + n); } @@ -429,7 +431,7 @@ inline void StringAccum::adjust_length(int delta) { inline char* StringAccum::extend(int nadjust, int nreserve) { assert(nadjust >= 0 && nreserve >= 0); if (_len + nadjust + nreserve <= _cap) { - char *x = reinterpret_cast<char *>(_s + _len); + char* x = reinterpret_cast<char*>(_s + _len); _len += nadjust; return x; } else @@ -481,7 +483,7 @@ inline void StringAccum::append(const char* s, int len) { /** @overload */ inline void StringAccum::append(const unsigned char* s, int len) { - append(reinterpret_cast<const char *>(s), len); + append(reinterpret_cast<const char*>(s), len); } /** @brief Append the data from @a begin to @a end to the end of this @@ -514,8 +516,8 @@ inline StringAccum& StringAccum::operator=(const StringAccum& x) { @brief Append character @a c to StringAccum @a sa. @return @a sa @note Same as @a sa.append(@a c). */ -inline StringAccum & -operator<<(StringAccum &sa, char c) +inline StringAccum& +operator<<(StringAccum& sa, char c) { sa.append(c); return sa; @@ -525,8 +527,8 @@ operator<<(StringAccum &sa, char c) @brief Append character @a c to StringAccum @a sa. @return @a sa @note Same as @a sa.append(@a c). */ -inline StringAccum & -operator<<(StringAccum &sa, unsigned char c) +inline StringAccum& +operator<<(StringAccum& sa, unsigned char c) { sa.append(c); return sa; @@ -536,8 +538,8 @@ operator<<(StringAccum &sa, unsigned char c) @brief Append null-terminated C string @a cstr to StringAccum @a sa. @return @a sa @note Same as @a sa.append(@a cstr). */ -inline StringAccum & -operator<<(StringAccum &sa, const char *cstr) +inline StringAccum& +operator<<(StringAccum& sa, const char* cstr) { sa.append(cstr); return sa; @@ -546,8 +548,8 @@ operator<<(StringAccum &sa, const char *cstr) /** @relates StringAccum @brief Append "true" or "false" to @a sa, depending on @a b. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, bool b) +inline StringAccum& +operator<<(StringAccum& sa, bool b) { static const char truefalse[] = "truefalse"; if (b) @@ -560,8 +562,8 @@ operator<<(StringAccum &sa, bool b) /** @relates StringAccum @brief Append decimal representation of @a i to @a sa. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, short i) +inline StringAccum& +operator<<(StringAccum& sa, short i) { return sa << static_cast<long>(i); } @@ -569,8 +571,8 @@ operator<<(StringAccum &sa, short i) /** @relates StringAccum @brief Append decimal representation of @a u to @a sa. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, unsigned short u) +inline StringAccum& +operator<<(StringAccum& sa, unsigned short u) { return sa << static_cast<unsigned long>(u); } @@ -578,8 +580,8 @@ operator<<(StringAccum &sa, unsigned short u) /** @relates StringAccum @brief Append decimal representation of @a i to @a sa. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, int i) +inline StringAccum& +operator<<(StringAccum& sa, int i) { return sa << static_cast<long>(i); } @@ -587,8 +589,8 @@ operator<<(StringAccum &sa, int i) /** @relates StringAccum @brief Append decimal representation of @a u to @a sa. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, unsigned u) +inline StringAccum& +operator<<(StringAccum& sa, unsigned u) { return sa << static_cast<unsigned long>(u); } @@ -596,8 +598,8 @@ operator<<(StringAccum &sa, unsigned u) /** @relates StringAccum @brief Append the contents of @a str to @a sa. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, const String &str) +inline StringAccum& +operator<<(StringAccum& sa, const String& str) { if (!str.out_of_memory()) sa.hard_append(str.begin(), str.length()); @@ -607,8 +609,8 @@ operator<<(StringAccum &sa, const String &str) } #ifdef HAVE_PERMSTRING -inline StringAccum & -operator<<(StringAccum &sa, PermString s) +inline StringAccum& +operator<<(StringAccum& sa, PermString s) { sa.append(s.c_str(), s.length()); return sa; @@ -618,21 +620,21 @@ operator<<(StringAccum &sa, PermString s) /** @relates StringAccum @brief Append the contents of @a sb to @a sa. @return @a sa */ -inline StringAccum & -operator<<(StringAccum &sa, const StringAccum &sb) +inline StringAccum& +operator<<(StringAccum& sa, const StringAccum& sb) { sa.append(sb.begin(), sb.end()); return sa; } inline bool -operator==(StringAccum &sa, const char *s) +operator==(StringAccum& sa, const char* s) { return strcmp(sa.c_str(), s) == 0; } inline bool -operator!=(StringAccum &sa, const char *s) +operator!=(StringAccum& sa, const char* s) { return strcmp(sa.c_str(), s) != 0; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/lcdf-typetools.spec b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/lcdf-typetools.spec index d9eedba6dd3..cbbf4379ce1 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/lcdf-typetools.spec +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/lcdf-typetools.spec @@ -1,6 +1,6 @@ Summary: Programs to manipulate OpenType and multiple-master fonts Name: lcdf-typetools -Version: 2.108 +Version: 2.110 Copyright: GPL Vendor: Little Cambridgeport Design Factory <http://www.lcdf.org/> Group: Utilities/Printing diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.am b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.am index a783e28e640..a4a90074801 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.am +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.am @@ -16,6 +16,7 @@ libefont_a_SOURCES = \ otfcmap.cc \ otfdata.cc \ otfdescrip.cc \ + otffvar.cc \ otfgpos.cc \ otfgsub.cc \ otfname.cc \ diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.in b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.in index 88041f45ea4..0274193f441 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.in +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/Makefile.in @@ -121,13 +121,13 @@ am_libefont_a_OBJECTS = afm.$(OBJEXT) afmparse.$(OBJEXT) \ afmw.$(OBJEXT) amfm.$(OBJEXT) cff.$(OBJEXT) encoding.$(OBJEXT) \ findmet.$(OBJEXT) metrics.$(OBJEXT) otf.$(OBJEXT) \ otfcmap.$(OBJEXT) otfdata.$(OBJEXT) otfdescrip.$(OBJEXT) \ - otfgpos.$(OBJEXT) otfgsub.$(OBJEXT) otfname.$(OBJEXT) \ - otfos2.$(OBJEXT) otfpost.$(OBJEXT) pairop.$(OBJEXT) \ - psres.$(OBJEXT) t1bounds.$(OBJEXT) t1cs.$(OBJEXT) \ - t1csgen.$(OBJEXT) t1interp.$(OBJEXT) t1item.$(OBJEXT) \ - t1font.$(OBJEXT) t1fontskel.$(OBJEXT) t1mm.$(OBJEXT) \ - t1rw.$(OBJEXT) t1unparser.$(OBJEXT) ttfcs.$(OBJEXT) \ - ttfhead.$(OBJEXT) ttfkern.$(OBJEXT) + otffvar.$(OBJEXT) otfgpos.$(OBJEXT) otfgsub.$(OBJEXT) \ + otfname.$(OBJEXT) otfos2.$(OBJEXT) otfpost.$(OBJEXT) \ + pairop.$(OBJEXT) psres.$(OBJEXT) t1bounds.$(OBJEXT) \ + t1cs.$(OBJEXT) t1csgen.$(OBJEXT) t1interp.$(OBJEXT) \ + t1item.$(OBJEXT) t1font.$(OBJEXT) t1fontskel.$(OBJEXT) \ + t1mm.$(OBJEXT) t1rw.$(OBJEXT) t1unparser.$(OBJEXT) \ + ttfcs.$(OBJEXT) ttfhead.$(OBJEXT) ttfkern.$(OBJEXT) libefont_a_OBJECTS = $(am_libefont_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -149,14 +149,15 @@ am__depfiles_remade = ./$(DEPDIR)/afm.Po ./$(DEPDIR)/afmparse.Po \ ./$(DEPDIR)/encoding.Po ./$(DEPDIR)/findmet.Po \ ./$(DEPDIR)/metrics.Po ./$(DEPDIR)/otf.Po \ ./$(DEPDIR)/otfcmap.Po ./$(DEPDIR)/otfdata.Po \ - ./$(DEPDIR)/otfdescrip.Po ./$(DEPDIR)/otfgpos.Po \ - ./$(DEPDIR)/otfgsub.Po ./$(DEPDIR)/otfname.Po \ - ./$(DEPDIR)/otfos2.Po ./$(DEPDIR)/otfpost.Po \ - ./$(DEPDIR)/pairop.Po ./$(DEPDIR)/psres.Po \ - ./$(DEPDIR)/t1bounds.Po ./$(DEPDIR)/t1cs.Po \ - ./$(DEPDIR)/t1csgen.Po ./$(DEPDIR)/t1font.Po \ - ./$(DEPDIR)/t1fontskel.Po ./$(DEPDIR)/t1interp.Po \ - ./$(DEPDIR)/t1item.Po ./$(DEPDIR)/t1mm.Po ./$(DEPDIR)/t1rw.Po \ + ./$(DEPDIR)/otfdescrip.Po ./$(DEPDIR)/otffvar.Po \ + ./$(DEPDIR)/otfgpos.Po ./$(DEPDIR)/otfgsub.Po \ + ./$(DEPDIR)/otfname.Po ./$(DEPDIR)/otfos2.Po \ + ./$(DEPDIR)/otfpost.Po ./$(DEPDIR)/pairop.Po \ + ./$(DEPDIR)/psres.Po ./$(DEPDIR)/t1bounds.Po \ + ./$(DEPDIR)/t1cs.Po ./$(DEPDIR)/t1csgen.Po \ + ./$(DEPDIR)/t1font.Po ./$(DEPDIR)/t1fontskel.Po \ + ./$(DEPDIR)/t1interp.Po ./$(DEPDIR)/t1item.Po \ + ./$(DEPDIR)/t1mm.Po ./$(DEPDIR)/t1rw.Po \ ./$(DEPDIR)/t1unparser.Po ./$(DEPDIR)/ttfcs.Po \ ./$(DEPDIR)/ttfhead.Po ./$(DEPDIR)/ttfkern.Po am__mv = mv -f @@ -363,6 +364,7 @@ libefont_a_SOURCES = \ otfcmap.cc \ otfdata.cc \ otfdescrip.cc \ + otffvar.cc \ otfgpos.cc \ otfgsub.cc \ otfname.cc \ @@ -447,6 +449,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otfcmap.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otfdata.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otfdescrip.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otffvar.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otfgpos.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otfgsub.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otfname.Po@am__quote@ # am--include-marker @@ -641,6 +644,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/otfcmap.Po -rm -f ./$(DEPDIR)/otfdata.Po -rm -f ./$(DEPDIR)/otfdescrip.Po + -rm -f ./$(DEPDIR)/otffvar.Po -rm -f ./$(DEPDIR)/otfgpos.Po -rm -f ./$(DEPDIR)/otfgsub.Po -rm -f ./$(DEPDIR)/otfname.Po @@ -718,6 +722,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/otfcmap.Po -rm -f ./$(DEPDIR)/otfdata.Po -rm -f ./$(DEPDIR)/otfdescrip.Po + -rm -f ./$(DEPDIR)/otffvar.Po -rm -f ./$(DEPDIR)/otfgpos.Po -rm -f ./$(DEPDIR)/otfgsub.Po -rm -f ./$(DEPDIR)/otfname.Po diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/amfm.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/amfm.cc index 0ee4f66e6b0..f7c5dbc455d 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/amfm.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/amfm.cc @@ -108,7 +108,7 @@ AmfmMetrics::master(int m, ErrorHandler *errh) if (!afm) { if (errh) - errh->error("%s: can't find AFM file for master `%s'", + errh->error("%s: can%,t find AFM file for master %<%s%>", _font_name.c_str(), master.font_name.c_str()); } else if (!strcompat(afm->font_name(), master.font_name) @@ -116,7 +116,7 @@ AmfmMetrics::master(int m, ErrorHandler *errh) || !strcompat(afm->full_name(), master.full_name) || !strcompat(afm->version(), master.version)) { if (errh) - errh->error("%s: AFM for master `%s' doesn't match AMFM", + errh->error("%s: AFM for master %<%s%> doesn%,t match AMFM", _font_name.c_str(), master.font_name.c_str()); } else if (!_sanity_afm) { @@ -131,19 +131,19 @@ AmfmMetrics::master(int m, ErrorHandler *errh) buf[0] = 0; if (afm->nglyphs() != _sanity_afm->nglyphs()) - sprintf(buf, "glyph count (%d vs. %d)", afm->nglyphs(), _sanity_afm->nglyphs()); - if (afm->nfd() != _sanity_afm->nfd()) - sprintf(buf, "fd count (%d vs. %d)", afm->nfd(), _sanity_afm->nfd()); - if (afm->nkv() != _sanity_afm->nkv()) - sprintf(buf, "kv count (%d vs. %d)", afm->nkv(), _sanity_afm->nkv()); - if (pairp->op_count() != sanity_pairp->op_count()) - sprintf(buf, "pair op count (%d vs. %d)", pairp->op_count(), sanity_pairp->op_count()); + snprintf(buf, sizeof(buf), "glyph count (%d vs. %d)", afm->nglyphs(), _sanity_afm->nglyphs()); + else if (afm->nfd() != _sanity_afm->nfd()) + snprintf(buf, sizeof(buf), "fd count (%d vs. %d)", afm->nfd(), _sanity_afm->nfd()); + else if (afm->nkv() != _sanity_afm->nkv()) + snprintf(buf, sizeof(buf), "kv count (%d vs. %d)", afm->nkv(), _sanity_afm->nkv()); + else if (pairp->op_count() != sanity_pairp->op_count()) + snprintf(buf, sizeof(buf), "pair op count (%d vs. %d)", pairp->op_count(), sanity_pairp->op_count()); if (!buf[0]) { master.afm = afm; afm->use(); } else if (errh) - errh->error("%s: AFM for master `%s' failed sanity checks (%s)", _font_name.c_str(), master.font_name.c_str(), buf); + errh->error("%s: AFM for master %<%s%> failed sanity checks (%s)", _font_name.c_str(), master.font_name.c_str(), buf); } } @@ -243,8 +243,7 @@ AmfmMetrics::interpolate(const Vector<double> &design_vector, **/ AmfmReader::AmfmReader(AfmParser &afmp, AmfmMetrics *amfm, ErrorHandler *errh) - : _amfm(amfm), _finder(amfm->_finder), _l(afmp), - _mmspace(amfm->_mmspace) + : _amfm(amfm), _l(afmp), _mmspace(amfm->_mmspace) { _errh = errh ? errh : ErrorHandler::silent_handler(); } @@ -306,12 +305,12 @@ AmfmReader::no_match_warning(const char *context) const PermString keyword = _l.keyword(); if (!keyword) return; if (_l.key_matched()) { - lwarning(context ? "bad `%s' command in %s:" - : "bad `%s' command:", keyword.c_str(), context); + lwarning(context ? "bad %<%s%> command in %s:" + : "bad %<%s%> command:", keyword.c_str(), context); lwarning("field %d %s", _l.fail_field(), _l.message().c_str()); } else - lwarning(context ? "unknown command `%s' in %s" - : "unknown command `%s'", keyword.c_str(), context); + lwarning(context ? "unknown command %<%s%> in %s" + : "unknown command %<%s%>", keyword.c_str(), context); _l.clear_message(); } @@ -491,7 +490,7 @@ AmfmReader::read() done: if (!_mmspace) { - _errh->error("`%s' is not an AMFM file", String(_l.landmark().file()).c_str()); + _errh->error("%<%s%> is not an AMFM file", String(_l.landmark().file()).c_str()); return false; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/cff.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/cff.cc index 74af65d7cd2..1498f450deb 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/cff.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/cff.cc @@ -1320,6 +1320,8 @@ Cff::Font::parse_encoding(int pos, ErrorHandler *errh) for (int i = 0; i < n; i++, p += 2) { int first = p[0]; int nLeft = p[1]; + if (first + nLeft > 255) + return errh->error("Encoding[1] has out-of-range component"), -EINVAL; for (int e = first; e <= first + nLeft; e++) { if (_encoding[e]) retval = 1; @@ -1327,11 +1329,13 @@ Cff::Font::parse_encoding(int pos, ErrorHandler *errh) } } - } else + } else { return errh->error("unknown Encoding format %d", format), -EINVAL; + } - if (g > _charset.nglyphs()) + if (g > _charset.nglyphs()) { return errh->error("Encoding glyph %d out of range", g), -EINVAL; + } // check supplements if (supplemented) { diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/findmet.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/findmet.cc index ceea7992c43..f776c5d32b4 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/findmet.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/findmet.cc @@ -211,8 +211,9 @@ InstanceMetricsFinder::find_metrics_instance(PermString name, MultipleMasterSpace *mmspace = amfm->mmspace(); if (!mmspace->check_intermediate() && _call_mmpfb) { - char *buf = new char[amfm->font_name().length() + 30]; - sprintf(buf, "mmpfb -q --amcp-info '%s'", amfm->font_name().c_str()); + size_t bufsz = amfm->font_name().length() + 30; + char *buf = new char[bufsz]; + snprintf(buf, bufsz, "mmpfb -q --amcp-info '%s'", amfm->font_name().c_str()); FILE *f = popen(buf, "r"); if (f) { diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfcmap.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfcmap.cc index b91970c9600..b0a6ec3d12b 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfcmap.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfcmap.cc @@ -62,7 +62,8 @@ Cmap::parse_header(ErrorHandler *errh) int last_platform = -1; int last_encoding = -1; int last_language = -1; - _first_unicode_table = -1; + _best_unicode_table = -1; + int best_unicode_priority = 0; for (int i = 0; i < _ntables; i++) { int loc = HEADER_SIZE + ENCODING_SIZE * i; int platform = USHORT_AT(data + loc); @@ -92,10 +93,24 @@ Cmap::parse_header(ErrorHandler *errh) || (encoding == last_encoding && language > last_language))))) errh->warning("unsorted cmap encoding records at entry %d (%d,%d,%d follows %d,%d,%d)", i, platform, encoding, language, last_platform, last_encoding, last_language); - if ((platform == 0 || (platform == 3 && encoding == 1)) - && _first_unicode_table < 0) - _first_unicode_table = i; - last_platform = platform, last_encoding = encoding, last_language = language; + int unicode_priority = -1; + if (platform == 0 && encoding == 4) + unicode_priority = 5; + else if (platform == 3 && encoding == 10) + unicode_priority = 4; + else if (platform == 0 && encoding == 6) + unicode_priority = 1; + else if ((platform == 0 && encoding != 5) || (platform == 3 && encoding == 1)) + unicode_priority = 3; + else + unicode_priority = 0; + if (unicode_priority > best_unicode_priority) { + _best_unicode_table = i; + best_unicode_priority = unicode_priority; + } + last_platform = platform; + last_encoding = encoding; + last_language = language; } _table_error.assign(_ntables, -2); @@ -122,12 +137,12 @@ Cmap::check_table(int t, ErrorHandler *errh) const { if (!errh) errh = ErrorHandler::silent_handler(); - if (t == USE_FIRST_UNICODE_TABLE && _first_unicode_table == -1) { + if (t == USE_BEST_UNICODE_TABLE && _best_unicode_table == -1) { errh->warning("font appears not to support Unicode"); - _first_unicode_table = 0; + _best_unicode_table = 0; } - if (t == USE_FIRST_UNICODE_TABLE) - t = _first_unicode_table; + if (t == USE_BEST_UNICODE_TABLE) + t = _best_unicode_table; if (_error < 0 || t < 0 || t >= _ntables) return errh->error("no such table"); if (_table_error[t] != -2) @@ -224,7 +239,8 @@ Cmap::check_table(int t, ErrorHandler *errh) const break; } - case F_SEGMENTED32: { + case F_SEGMENTED32: + case F_MANYTOONE: { if (left < 8 || (length = ULONG_AT(data + 4)) > left || length < 16) @@ -349,6 +365,24 @@ Cmap::map_table(int t, uint32_t uni, ErrorHandler *errh) const return 0; } + case F_MANYTOONE: { + uint32_t nGroups = ULONG_AT2(data + 12); + uint32_t l = 0, r = nGroups; + const uint8_t *groups = data + 16; + while (l < r) { + uint32_t m = l + (r - l) / 2; + uint32_t startCharCode = ULONG_AT2(groups + m * 12); + uint32_t endCharCode = ULONG_AT2(groups + m * 12 + 4); + if (uni < startCharCode) + r = m; + else if (uni <= endCharCode) + return ULONG_AT2(groups + m * 12 + 8); + else + l = m + 1; + } + return 0; + } + default: return 0; @@ -441,6 +475,19 @@ Cmap::dump_table(int t, Vector<std::pair<uint32_t, Glyph> > &ugp, ErrorHandler * break; } + case F_MANYTOONE: { + uint32_t nGroups = ULONG_AT2(data + 12); + const uint8_t *groups = data + 16; + for (uint32_t i = 0; i < nGroups; i++, groups += 12) { + uint32_t startCharCode = ULONG_AT2(groups); + uint32_t nCharCodes = ULONG_AT2(groups + 4) - startCharCode; + Glyph glyphID = ULONG_AT2(groups + 8); + for (uint32_t i = 0; i <= nCharCodes; i++) + ugp.push_back(std::make_pair(startCharCode + i, glyphID)); + } + break; + } + default: break; @@ -451,7 +498,7 @@ int Cmap::map_uni(const Vector<uint32_t> &vin, Vector<Glyph> &vout) const { int t; - if ((t = check_table(USE_FIRST_UNICODE_TABLE)) < 0) + if ((t = check_table(USE_BEST_UNICODE_TABLE)) < 0) return -1; vout.resize(vin.size(), 0); for (int i = 0; i < vin.size(); i++) diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfdescrip.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfdescrip.cc index 6046ade2fb0..a2ad2d0289c 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfdescrip.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfdescrip.cc @@ -1,6 +1,6 @@ /* otfdescrip.cc -- descriptions for OpenType tags * - * Copyright (c) 2002-2019 Eddie Kohler + * Copyright (c) 2002-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -25,14 +25,19 @@ struct Mapping { static const Mapping scripts[] = { { T("DFLT"), "Default" }, + { T("adlm"), "Adlam" }, + { T("aghb"), "Caucasian Albanian" }, + { T("ahom"), "Ahom" }, { T("arab"), "Arabic" }, { T("armi"), "Imperial Aramaic" }, { T("armn"), "Armenian" }, { T("avst"), "Avestan" }, { T("bali"), "Balinese" }, { T("bamu"), "Bamum" }, + { T("bass"), "Bassa Vah" }, { T("batk"), "Batak" }, { T("beng"), "Bengali" }, + { T("bhks"), "Bhaiksuki" }, { T("bng2"), "Bengali v.2" }, { T("bopo"), "Bopomofo" }, { T("brah"), "Brahmi" }, @@ -45,18 +50,28 @@ static const Mapping scripts[] = { { T("cari"), "Carian" }, { T("cham"), "Cham" }, { T("cher"), "Cherokee" }, + { T("chrs"), "Chorasmian" }, { T("copt"), "Coptic" }, + { T("cpmn"), "Cypro-Minoan" }, { T("cprt"), "Cypriot Syllabary" }, { T("cyrl"), "Cyrillic" }, { T("dev2"), "Devanagari v.2" }, { T("deva"), "Devanagari" }, + { T("diak"), "Dives Akuru" }, + { T("dogr"), "Dogra" }, { T("dsrt"), "Deseret" }, - { T("egyp"), "Egyptian heiroglyphs" }, + { T("dupl"), "Duployan" }, + { T("egyp"), "Egyptian Hieroglyphs" }, + { T("elba"), "Elbasan" }, + { T("elym"), "Elymaic" }, { T("ethi"), "Ethiopic" }, { T("geor"), "Georgian" }, { T("gjr2"), "Gujarati v.2" }, { T("glag"), "Glagolitic" }, + { T("gong"), "Gunjala Gondi" }, + { T("gonm"), "Masaram Gondi" }, { T("goth"), "Gothic" }, + { T("gran"), "Grantha" }, { T("grek"), "Greek" }, { T("gujr"), "Gujarati" }, { T("gur2"), "Gurmukhi v.2" }, @@ -64,14 +79,21 @@ static const Mapping scripts[] = { { T("hang"), "Hangul" }, { T("hani"), "CJK Ideographic" }, { T("hano"), "Hanunoo" }, + { T("hatr"), "Hatran" }, { T("hebr"), "Hebrew" }, + { T("hluw"), "Anatolian Hieroglyphs" }, + { T("hmng"), "Pahawh Hmong" }, + { T("hmnp"), "Nyiakeng Puachue Hmong" }, + { T("hung"), "Old Hungarian" }, { T("ital"), "Old Italic" }, - { T("jamo"), "Hangul Jamo" }, + { T("jamo"), "Hangul Jamo" }, // not recommended -- prefer `hang` { T("java"), "Javanese" }, { T("kali"), "Kayah Li" }, { T("kana"), "Hiragana/Katakana" }, { T("khar"), "Kharosthi" }, { T("khmr"), "Khmer" }, + { T("khoj"), "Khojki" }, + { T("kits"), "Khitan Small Script" }, { T("knd2"), "Kannada v.2" }, { T("knda"), "Kannada" }, { T("kthi"), "Kaithi" }, @@ -80,40 +102,70 @@ static const Mapping scripts[] = { { T("latn"), "Latin" }, { T("lepc"), "Lepcha" }, { T("limb"), "Limbu" }, + { T("lina"), "Linear A" }, { T("linb"), "Linear B" }, { T("lisu"), "Lisu (Fraser)" }, { T("lyci"), "Lycian" }, { T("lydi"), "Lydian" }, + { T("mahj"), "Mahajani" }, + { T("maka"), "Makasar" }, { T("mand"), "Mandaic, Mandaean" }, + { T("mani"), "Manichaean" }, + { T("marc"), "Marchen" }, { T("math"), "Mathematical Alphanumeric Symbols" }, + { T("medf"), "Medefaidrin (Oberi Okaime, Oberi ƆkaimÉ›)" }, + { T("mend"), "Mende Kikakui" }, { T("merc"), "Meroitic Cursive" }, { T("mero"), "Meroitic Hieroglyphs" }, { T("mlm2"), "Malayalam v.2" }, { T("mlym"), "Malayalam" }, + { T("modi"), "Modi" }, { T("mong"), "Mongolian" }, + { T("mroo"), "Mro" }, { T("mtei"), "Meitei Mayek (Meithei, Meetei)" }, + { T("mult"), "Multani" }, { T("musc"), "Musical Symbols" }, - { T("mymr"), "Myanmar" }, + { T("mym2"), "Myanmar v.2" }, + { T("mymr"), "Myanmar" }, // not recommended -- prefer `mym2` + { T("nand"), "Nandinagari" }, + { T("narb"), "Old North Arabian" }, + { T("nbat"), "Nabataean" }, + { T("newa"), "Newa" }, { T("nko "), "N'Ko" }, + { T("nshu"), "Nüshu" }, { T("ogam"), "Ogham" }, { T("olck"), "Ol Chiki" }, { T("orkh"), "Old Turkic, Orkhon Runic" }, { T("ory2"), "Odia v.2 (formerly Oriya v.2)" }, { T("orya"), "Odia (formerly Oriya)" }, + { T("osge"), "Osage" }, { T("osma"), "Osmanya" }, + { T("ougr"), "Old Uyghur" }, + { T("palm"), "Palmyrene" }, + { T("pauc"), "Pau Cin Hau" }, + { T("perm"), "Old Permic" }, { T("phag"), "Phags-pa" }, { T("phli"), "Inscriptional Pahlavi" }, + { T("phlp"), "Psalter Pahlavi" }, { T("phnx"), "Phoenician" }, + { T("plrd"), "Miao" }, { T("prti"), "Inscriptional Parthian" }, { T("rjng"), "Rejang" }, + { T("rohg"), "Hanifi Rohingya" }, { T("runr"), "Runic" }, { T("samr"), "Samaritan" }, { T("sarb"), "Old South Arabian" }, { T("saur"), "Saurashtra" }, + { T("sgnw"), "Sign Writing" }, { T("shaw"), "Shavian" }, { T("shrd"), "Sharada" }, + { T("sidd"), "Siddham" }, + { T("sind"), "Khudawadi" }, { T("sinh"), "Sinhala" }, + { T("sogd"), "Sogdian" }, + { T("sogo"), "Old Sogdian" }, { T("sora"), "Sora Sompeng" }, + { T("soyo"), "Soyombo" }, { T("sund"), "Sundanese" }, { T("sylo"), "Syloti Nagri" }, { T("syrc"), "Syriac" }, @@ -122,6 +174,7 @@ static const Mapping scripts[] = { { T("tale"), "Tai Le" }, { T("talu"), "New Tai Lue" }, { T("taml"), "Tamil" }, + { T("tang"), "Tangut" }, { T("tavt"), "Tai Viet" }, { T("tel2"), "Telugu v.2" }, { T("telu"), "Telugu" }, @@ -130,91 +183,154 @@ static const Mapping scripts[] = { { T("thaa"), "Thaana" }, { T("thai"), "Thai" }, { T("tibt"), "Tibetan" }, + { T("tirh"), "Tirhuta" }, { T("tml2"), "Tamil v.2" }, + { T("tnsa"), "Tangsa" }, + { T("toto"), "Toto" }, { T("ugar"), "Ugaritic Cuneiform" }, { T("vai "), "Vai" }, + { T("vith"), "Vithkuqi" }, + { T("wara"), "Warang Citi" }, + { T("wcho"), "Wancho" }, { T("xpeo"), "Old Persian Cuneiform" }, { T("xsux"), "Sumero-Akkadian Cuneiform" }, - { T("yi "), "Yi" } + { T("yezi"), "Yezidi" }, + { T("yi "), "Yi" }, + { T("zanb"), "Zanabazar Square (Zanabazarin Dörböljin Useg, Xewtee Dörböljin Bicig, Horizontal Square Script)" } }; static const Mapping languages[] = { { T("ABA "), "Abaza" }, { T("ABK "), "Abkhazian" }, + { T("ACH "), "Acholi" }, + { T("ACR "), "Achi" }, { T("ADY "), "Adyghe" }, { T("AFK "), "Afrikaans" }, { T("AFR "), "Afar" }, { T("AGW "), "Agaw" }, + { T("AIO "), "Aiton" }, + { T("AKA "), "Akan" }, + { T("AKB "), "Batak Angkola" }, { T("ALS "), "Alsatian" }, { T("ALT "), "Altai" }, { T("AMH "), "Amharic" }, + { T("ANG "), "Anglo-Saxon" }, { T("APPH"), "Phonetic transcription—Americanist conventions" }, { T("ARA "), "Arabic" }, + { T("ARG "), "Aragonese" }, { T("ARI "), "Aari" }, - { T("ARK "), "Arakanese" }, + { T("ARK "), "Rakhine" }, { T("ASM "), "Assamese" }, - { T("ATH "), "Athapaskan" }, + { T("AST "), "Asturian" }, + { T("ATH "), "Athapaskan languages" }, + { T("AVN "), "Avatime" }, { T("AVR "), "Avar" }, { T("AWA "), "Awadhi" }, { T("AYM "), "Aymara" }, - { T("AZE "), "Azeri" }, + { T("AZB "), "Torki" }, + { T("AZE "), "Azerbaijani" }, { T("BAD "), "Badaga" }, + { T("BAD0"), "Banda" }, { T("BAG "), "Baghelkhandi" }, { T("BAL "), "Balkar" }, - { T("BAU "), "Baule" }, + { T("BAN "), "Balinese" }, + { T("BAR "), "Bavarian" }, + { T("BAU "), "Baulé" }, + { T("BBC "), "Batak Toba" }, { T("BBR "), "Berber" }, { T("BCH "), "Bench" }, { T("BCR "), "Bible Cree" }, + { T("BDY "), "Bandjalang" }, { T("BEL "), "Belarussian" }, { T("BEM "), "Bemba" }, { T("BEN "), "Bengali" }, + { T("BGC "), "Haryanvi" }, + { T("BGQ "), "Bagri" }, { T("BGR "), "Bulgarian" }, { T("BHI "), "Bhili" }, { T("BHO "), "Bhojpuri" }, { T("BIK "), "Bikol" }, { T("BIL "), "Bilen" }, + { T("BIS "), "Bislama" }, + { T("BJJ "), "Kanauji" }, { T("BKF "), "Blackfoot" }, - { T("BLI "), "Balochi" }, + { T("BLI "), "Baluchi" }, + { T("BLK "), "Pa’o Karen" }, { T("BLN "), "Balante" }, { T("BLT "), "Balti" }, - { T("BMB "), "Bambara" }, + { T("BMB "), "Bambara (Bamanankan)" }, { T("BML "), "Bamileke" }, { T("BOS "), "Bosnian" }, + { T("BPY "), "Bishnupriya Manipuri" }, { T("BRE "), "Breton" }, { T("BRH "), "Brahui" }, { T("BRI "), "Braj Bhasha" }, { T("BRM "), "Burmese" }, + { T("BRX "), "Bodo" }, { T("BSH "), "Bashkir" }, + { T("BSK "), "Burushaski" }, + { T("BTD "), "Batak Dairi (Pakpak)" }, { T("BTI "), "Beti" }, + { T("BTK "), "Batak languages" }, + { T("BTM "), "Batak Mandailing" }, + { T("BTS "), "Batak Simalungun" }, + { T("BTX "), "Batak Karo" }, + { T("BTZ "), "Batak Alas-Kluet" }, + { T("BUG "), "Bugis" }, + { T("BYV "), "Medumba" }, + { T("CAK "), "Kaqchikel" }, { T("CAT "), "Catalan" }, + { T("CBK "), "Zamboanga Chavacano" }, + { T("CCHN"), "Chinantec" }, { T("CEB "), "Cebuano" }, + { T("CGG "), "Chiga" }, + { T("CHA "), "Chamorro" }, { T("CHE "), "Chechen" }, { T("CHG "), "Chaha Gurage" }, { T("CHH "), "Chattisgarhi" }, - { T("CHI "), "Chichewa" }, + { T("CHI "), "Chichewa (Chewa, Nyanja)" }, { T("CHK "), "Chukchi" }, + { T("CHK0"), "Chuukese" }, + { T("CHO "), "Choctaw" }, { T("CHP "), "Chipewyan" }, { T("CHR "), "Cherokee" }, { T("CHU "), "Chuvash" }, + { T("CHY "), "Cheyenne" }, + { T("CJA "), "Western Cham" }, + { T("CJM "), "Eastern Cham" }, { T("CMR "), "Comorian" }, { T("COP "), "Coptic" }, + { T("COR "), "Cornish" }, { T("COS "), "Corsican" }, + { T("CPP "), "Creoles" }, { T("CRE "), "Cree" }, { T("CRR "), "Carrier" }, { T("CRT "), "Crimean Tatar" }, + { T("CSB "), "Kashubian" }, { T("CSL "), "Church Slavonic" }, { T("CSY "), "Czech" }, + { T("CTG "), "Chittagonian" }, + { T("CTT "), "Wayanad Chetti" }, + { T("CUK "), "San Blas Kuna" }, + { T("DAG "), "Dagbani" }, { T("DAN "), "Danish" }, { T("DAR "), "Dargwa" }, + { T("DAX "), "Dayi" }, { T("DCR "), "Woods Cree" }, { T("DEU "), "German" }, - { T("DGR "), "Dogri" }, - { T("DHV "), "Dhivehi" }, // deprecated - { T("DIV "), "Dhivehi" }, - { T("DJR "), "Djerma" }, + { T("DGO "), "Dogri (individual language)" }, + { T("DGR "), "Dogri (macrolanguage)" }, + { T("DHG "), "Dhangu" }, + { T("DHV "), "Divehi (Dhivehi, Maldivian)" }, // deprecated + { T("DIQ "), "Dimli" }, + { T("DIV "), "Divehi (Dhivehi, Maldivian)" }, + { T("DJR "), "Zarma" }, + { T("DJR0"), "Djambarrpuyngu" }, { T("DNG "), "Dangme" }, + { T("DNJ "), "Dan" }, { T("DNK "), "Dinka" }, { T("DRI "), "Dari" }, + { T("DUJ "), "Dhuwal" }, { T("DUN "), "Dungan" }, { T("DZN "), "Dzongkha" }, { T("EBI "), "Ebira" }, @@ -222,105 +338,157 @@ static const Mapping languages[] = { { T("EDO "), "Edo" }, { T("EFI "), "Efik" }, { T("ELL "), "Greek" }, + { T("EMK "), "Eastern Maninkakan" }, { T("ENG "), "English" }, { T("ERZ "), "Erzya" }, { T("ESP "), "Spanish" }, + { T("ESU "), "Central Yupik" }, { T("ETI "), "Estonian" }, { T("EUQ "), "Basque" }, { T("EVK "), "Evenki" }, { T("EVN "), "Even" }, { T("EWE "), "Ewe" }, { T("FAN "), "French Antillean" }, - { T("FAR "), "Farsi" }, + { T("FAN0"), "Fang" }, + { T("FAR "), "Persian" }, + { T("FAT "), "Fanti" }, { T("FIN "), "Finnish" }, { T("FJI "), "Fijian" }, - { T("FLE "), "Flemish" }, - { T("FNE "), "Forest Nenets" }, + { T("FLE "), "Dutch (Flemish)" }, + { T("FMP "), "Fe’fe’" }, + { T("FNE "), "Forest Enets" }, { T("FON "), "Fon" }, { T("FOS "), "Faroese" }, { T("FRA "), "French" }, + { T("FRC "), "Cajun French" }, { T("FRI "), "Frisian" }, { T("FRL "), "Friulian" }, + { T("FRP "), "Arpitan" }, { T("FTA "), "Futa" }, - { T("FUL "), "Fulani" }, + { T("FUL "), "Fulah" }, + { T("FUV "), "Nigerian Fulfulde" }, { T("GAD "), "Ga" }, - { T("GAE "), "Gaelic" }, + { T("GAE "), "Scottish Gaelic (Gaelic)" }, { T("GAG "), "Gagauz" }, { T("GAL "), "Galician" }, { T("GAR "), "Garshuni" }, { T("GAW "), "Garhwali" }, - { T("GEZ "), "Ge'ez" }, + { T("GEZ "), "Geez" }, + { T("GIH "), "Githabul" }, { T("GIL "), "Gilyak" }, + { T("GIL0"), "Kiribati (Gilbertese)" }, + { T("GKP "), "Kpelle (Guinea)" }, + { T("GLK "), "Gilaki" }, { T("GMZ "), "Gumuz" }, + { T("GNN "), "Gumatj" }, + { T("GOG "), "Gogo" }, { T("GON "), "Gondi" }, { T("GRN "), "Greenlandic" }, { T("GRO "), "Garo" }, { T("GUA "), "Guarani" }, + { T("GUC "), "Wayuu" }, + { T("GUF "), "Gupapuyngu" }, { T("GUJ "), "Gujarati" }, - { T("HAI "), "Haitian" }, - { T("HAL "), "Halam" }, + { T("GUZ "), "Gusii" }, + { T("HAI "), "Haitian (Haitian Creole)" }, + { T("HAI0"), "Haida" }, + { T("HAL "), "Halam (Falam Chin)" }, { T("HAR "), "Harauti" }, { T("HAU "), "Hausa" }, { T("HAW "), "Hawaiian" }, + { T("HAY "), "Haya" }, + { T("HAZ "), "Hazaragi" }, { T("HBN "), "Hammer-Banna" }, + { T("HEI "), "Heiltsuk" }, + { T("HER "), "Herero" }, { T("HIL "), "Hiligaynon" }, { T("HIN "), "Hindi" }, { T("HMA "), "High Mari" }, + { T("HMD "), "A-Hmao" }, + { T("HMN "), "Hmong" }, + { T("HMO "), "Hiri Motu" }, + { T("HMZ "), "Hmong Shuat" }, { T("HND "), "Hindko" }, { T("HO "), "Ho" }, { T("HRI "), "Harari" }, { T("HRV "), "Croatian" }, { T("HUN "), "Hungarian" }, { T("HYE "), "Armenian" }, + { T("HYE0"), "Armenian East" }, + { T("IBA "), "Iban" }, + { T("IBB "), "Ibibio" }, { T("IBO "), "Igbo" }, - { T("IJO "), "Ijo" }, + { T("IDO "), "Ido" }, + { T("IJO "), "Ijo languages" }, + { T("ILE "), "Interlingue" }, { T("ILO "), "Ilokano" }, + { T("INA "), "Interlingua" }, { T("IND "), "Indonesian" }, { T("ING "), "Ingush" }, { T("INU "), "Inuktitut" }, + { T("INUK"), "Nunavik Inuktitut" }, + { T("IPK "), "Inupiat" }, { T("IPPH"), "Phonetic transcription—IPA conventions" }, { T("IRI "), "Irish" }, { T("IRT "), "Irish Traditional" }, + { T("IRU "), "Irula" }, { T("ISL "), "Icelandic" }, { T("ISM "), "Inari Sami" }, { T("ITA "), "Italian" }, { T("IWR "), "Hebrew" }, + { T("JAM "), "Jamaican Creole" }, { T("JAN "), "Japanese" }, { T("JAV "), "Javanese" }, + { T("JBO "), "Lojban" }, + { T("JCT "), "Krymchak" }, { T("JII "), "Yiddish" }, - { T("JUD "), "Judezmo" }, + { T("JUD "), "Ladino" }, { T("JUL "), "Jula" }, { T("KAB "), "Kabardian" }, + { T("KAB0"), "Kabyle" }, { T("KAC "), "Kachchi" }, { T("KAL "), "Kalenjin" }, { T("KAN "), "Kannada" }, { T("KAR "), "Karachay" }, { T("KAT "), "Georgian" }, + { T("KAW "), "Kawi (Old Javanese)" }, { T("KAZ "), "Kazakh" }, + { T("KDE "), "Makonde" }, + { T("KEA "), "Kabuverdianu (Crioulo)" }, { T("KEB "), "Kebena" }, + { T("KEK "), "Kekchi" }, { T("KGE "), "Khutsuri Georgian" }, { T("KHA "), "Khakass" }, { T("KHK "), "Khanty-Kazim" }, { T("KHM "), "Khmer" }, { T("KHS "), "Khanty-Shurishkar" }, + { T("KHT "), "Khamti Shan" }, { T("KHV "), "Khanty-Vakhi" }, { T("KHW "), "Khowar" }, - { T("KIK "), "Kikuyu" }, - { T("KIR "), "Kirghiz" }, + { T("KIK "), "Kikuyu (Gikuyu)" }, + { T("KIR "), "Kirghiz (Kyrgyz)" }, { T("KIS "), "Kisii" }, + { T("KIU "), "Kirmanjki" }, + { T("KJD "), "Southern Kiwai" }, + { T("KJP "), "Eastern Pwo Karen" }, + { T("KJZ "), "Bumthangkha" }, { T("KKN "), "Kokni" }, { T("KLM "), "Kalmyk" }, { T("KMB "), "Kamba" }, { T("KMN "), "Kumaoni" }, { T("KMO "), "Komo" }, { T("KMS "), "Komso" }, + { T("KMZ "), "Khorasani Turkic" }, { T("KNR "), "Kanuri" }, { T("KOD "), "Kodagu" }, { T("KOH "), "Korean Old Hangul" }, { T("KOK "), "Konkani" }, + { T("KOM "), "Komi" }, { T("KON "), "Kikongo" }, + { T("KON0"), "Kongo" }, { T("KOP "), "Komi-Permyak" }, { T("KOR "), "Korean" }, + { T("KOS "), "Kosraean" }, { T("KOZ "), "Komi-Zyrian" }, { T("KPL "), "Kpelle" }, { T("KRI "), "Krio" }, @@ -330,15 +498,20 @@ static const Mapping languages[] = { { T("KRN "), "Karen" }, { T("KRT "), "Koorete" }, { T("KSH "), "Kashmiri" }, + { T("KSH0"), "Ripuarian" }, { T("KSI "), "Khasi" }, { T("KSM "), "Kildin Sami" }, + { T("KSW "), "S’gaw Karen" }, + { T("KUA "), "Kuanyama" }, { T("KUI "), "Kui" }, { T("KUL "), "Kulvi" }, { T("KUM "), "Kumyk" }, { T("KUR "), "Kurdish" }, { T("KUU "), "Kurukh" }, { T("KUY "), "Kuy" }, + { T("KWK "), "Kwakʼwala" }, { T("KYK "), "Koryak" }, + { T("KYU "), "Western Kayah" }, { T("LAD "), "Ladin" }, { T("LAH "), "Lahuli" }, { T("LAK "), "Lak" }, @@ -348,34 +521,57 @@ static const Mapping languages[] = { { T("LAZ "), "Laz" }, { T("LCR "), "L-Cree" }, { T("LDK "), "Ladakhi" }, + { T("LEF "), "Lelemi" }, { T("LEZ "), "Lezgi" }, + { T("LIJ "), "Ligurian" }, + { T("LIM "), "Limburgish" }, { T("LIN "), "Lingala" }, + { T("LIS "), "Lisu" }, + { T("LJP "), "Lampung" }, + { T("LKI "), "Laki" }, { T("LMA "), "Low Mari" }, { T("LMB "), "Limbu" }, + { T("LMO "), "Lombard" }, { T("LMW "), "Lomwe" }, + { T("LOM "), "Loma" }, + { T("LPO "), "Lipo" }, + { T("LRC "), "Luri" }, { T("LSB "), "Lower Sorbian" }, { T("LSM "), "Lule Sami" }, { T("LTH "), "Lithuanian" }, { T("LTZ "), "Luxembourgish" }, - { T("LUB "), "Luba" }, - { T("LUG "), "Luganda" }, - { T("LUH "), "Luhya" }, + { T("LUA "), "Luba-Lulua" }, + { T("LUB "), "Luba-Katanga" }, + { T("LUG "), "Ganda" }, + { T("LUH "), "Luyia" }, { T("LUO "), "Luo" }, { T("LVI "), "Latvian" }, + { T("MAD "), "Madura" }, + { T("MAG "), "Magahi" }, + { T("MAH "), "Marshallese" }, { T("MAJ "), "Majang" }, - { T("MAK "), "Makua" }, - { T("MAL "), "Malayalam Traditional" }, + { T("MAK "), "Makhuwa" }, + { T("MAL "), "Malayalam" }, + { T("MAM "), "Mam" }, { T("MAN "), "Mansi" }, { T("MAP "), "Mapudungun" }, { T("MAR "), "Marathi" }, { T("MAW "), "Marwari" }, { T("MBN "), "Mbundu" }, + { T("MBO "), "Mbo" }, { T("MCH "), "Manchu" }, { T("MCR "), "Moose Cree" }, { T("MDE "), "Mende" }, - { T("MEN "), "Me'en" }, + { T("MDR "), "Mandar" }, + { T("MEN "), "Me’en" }, + { T("MER "), "Meru" }, + { T("MFA "), "Pattani Malay" }, + { T("MFE "), "Morisyen" }, + { T("MIN "), "Minangkabau" }, { T("MIZ "), "Mizo" }, { T("MKD "), "Macedonian" }, + { T("MKR "), "Makasar" }, + { T("MKW "), "Kituba" }, { T("MLE "), "Male" }, { T("MLG "), "Malagasy" }, { T("MLN "), "Malinke" }, @@ -385,37 +581,56 @@ static const Mapping languages[] = { { T("MNG "), "Mongolian" }, { T("MNI "), "Manipuri" }, { T("MNK "), "Maninka" }, - { T("MNX "), "Manx Gaelic" }, + { T("MNX "), "Manx" }, { T("MOH "), "Mohawk" }, { T("MOK "), "Moksha" }, { T("MOL "), "Moldavian" }, { T("MON "), "Mon" }, + { T("MONT"), "Thailand Mon" }, { T("MOR "), "Moroccan" }, + { T("MOS "), "Mossi" }, { T("MRI "), "Maori" }, { T("MTH "), "Maithili" }, { T("MTS "), "Maltese" }, { T("MUN "), "Mundari" }, + { T("MUS "), "Muscogee" }, + { T("MWL "), "Mirandese" }, + { T("MWW "), "Hmong Daw" }, + { T("MYN "), "Mayan" }, + { T("MZN "), "Mazanderani" }, { T("NAG "), "Naga-Assamese" }, + { T("NAH "), "Nahuatl" }, { T("NAN "), "Nanai" }, + { T("NAP "), "Neapolitan" }, { T("NAS "), "Naskapi" }, + { T("NAU "), "Nauruan" }, + { T("NAV "), "Navajo" }, { T("NCR "), "N-Cree" }, { T("NDB "), "Ndebele" }, + { T("NDC "), "Ndau" }, { T("NDG "), "Ndonga" }, + { T("NDS "), "Low Saxon" }, { T("NEP "), "Nepali" }, { T("NEW "), "Newari" }, + { T("NGA "), "Ngbaka" }, { T("NGR "), "Nagari" }, { T("NHC "), "Norway House Cree" }, { T("NIS "), "Nisi" }, { T("NIU "), "Niuean" }, - { T("NKL "), "Nkole" }, - { T("NKO "), "N'Ko" }, + { T("NKL "), "Nyankole" }, + { T("NKO "), "N’Ko" }, { T("NLD "), "Dutch" }, + { T("NOE "), "Nimadi" }, { T("NOG "), "Nogai" }, { T("NOR "), "Norwegian" }, + { T("NOV "), "Novial" }, { T("NSM "), "Northern Sami" }, + { T("NSO "), "Northern Sotho" }, { T("NTA "), "Northern Tai" }, { T("NTO "), "Esperanto" }, - { T("NYN "), "Nynorsk" }, + { T("NYM "), "Nyamwezi" }, + { T("NYN "), "Norwegian Nynorsk (Nynorsk, Norwegian)" }, + { T("NZA "), "Mbembe Tigon" }, { T("OCI "), "Occitan" }, { T("OCR "), "Oji-Cree" }, { T("OJB "), "Ojibway" }, @@ -423,34 +638,71 @@ static const Mapping languages[] = { { T("ORO "), "Oromo" }, { T("OSS "), "Ossetian" }, { T("PAA "), "Palestinian Aramaic" }, + { T("PAG "), "Pangasinan" }, { T("PAL "), "Pali" }, + { T("PAM "), "Pampangan" }, { T("PAN "), "Punjabi" }, { T("PAP "), "Palpa" }, + { T("PAP0"), "Papiamentu" }, { T("PAS "), "Pashto" }, + { T("PAU "), "Palauan" }, + { T("PCC "), "Bouyei" }, + { T("PCD "), "Picard" }, + { T("PDC "), "Pennsylvania German" }, { T("PGR "), "Polytonic Greek" }, + { T("PHK "), "Phake" }, + { T("PIH "), "Norfolk" }, { T("PIL "), "Filipino" }, { T("PLG "), "Palaung" }, { T("PLK "), "Polish" }, - { T("PRO "), "Provencal" }, + { T("PMS "), "Piemontese" }, + { T("PNB "), "Western Panjabi" }, + { T("POH "), "Pocomchi" }, + { T("PON "), "Pohnpeian" }, + { T("PRO "), "Provençal / Old Provençal" }, { T("PTG "), "Portuguese" }, + { T("PWO "), "Western Pwo Karen" }, { T("QIN "), "Chin" }, + { T("QUC "), "K’iche’" }, + { T("QUH "), "Quechua (Bolivia)" }, + { T("QUZ "), "Quechua" }, + { T("QVI "), "Quechua (Ecuador)" }, + { T("QWH "), "Quechua (Peru)" }, { T("RAJ "), "Rajasthani" }, + { T("RAR "), "Rarotongan" }, { T("RBU "), "Russian Buriat" }, { T("RCR "), "R-Cree" }, + { T("REJ "), "Rejang" }, { T("RIA "), "Riang" }, - { T("RMS "), "Rhaeto-Romanic" }, + { T("RHG "), "Rohingya" }, + { T("RIF "), "Tarifit" }, + { T("RIT "), "Ritarungo" }, + { T("RKW "), "Arakwal" }, + { T("RMS "), "Romansh" }, + { T("RMY "), "Vlax Romani" }, { T("ROM "), "Romanian" }, { T("ROY "), "Romany" }, { T("RSY "), "Rusyn" }, - { T("RUA "), "Ruanda" }, + { T("RTM "), "Rotuman" }, + { T("RUA "), "Kinyarwanda" }, + { T("RUN "), "Rundi" }, + { T("RUP "), "Aromanian" }, { T("RUS "), "Russian" }, { T("SAD "), "Sadri" }, { T("SAN "), "Sanskrit" }, + { T("SAS "), "Sasak" }, { T("SAT "), "Santali" }, { T("SAY "), "Sayisi" }, + { T("SCN "), "Sicilian" }, + { T("SCO "), "Scots" }, + { T("SCS "), "North Slavey" }, { T("SEK "), "Sekota" }, { T("SEL "), "Selkup" }, + { T("SFM "), "Small Flowery Miao" }, + { T("SGA "), "Old Irish" }, { T("SGO "), "Sango" }, + { T("SGS "), "Samogitian" }, + { T("SHI "), "Tachelhit" }, { T("SHN "), "Shan" }, { T("SIB "), "Sibe" }, { T("SID "), "Sidamo" }, @@ -462,76 +714,127 @@ static const Mapping languages[] = { { T("SML "), "Somali" }, { T("SMO "), "Samoan" }, { T("SNA "), "Sena" }, + { T("SNA0"), "Shona" }, { T("SND "), "Sindhi" }, - { T("SNH "), "Sinhalese" }, + { T("SNH "), "Sinhala (Sinhalese)" }, { T("SNK "), "Soninke" }, { T("SOG "), "Sodo Gurage" }, - { T("SOT "), "Sotho" }, + { T("SOP "), "Songe" }, + { T("SOT "), "Southern Sotho" }, { T("SQI "), "Albanian" }, { T("SRB "), "Serbian" }, + { T("SRD "), "Sardinian" }, { T("SRK "), "Saraiki" }, { T("SRR "), "Serer" }, { T("SSL "), "South Slavey" }, { T("SSM "), "Southern Sami" }, + { T("STQ "), "Saterland Frisian" }, + { T("SUK "), "Sukuma" }, + { T("SUN "), "Sundanese" }, { T("SUR "), "Suri" }, { T("SVA "), "Svan" }, { T("SVE "), "Swedish" }, { T("SWA "), "Swadaya Aramaic" }, { T("SWK "), "Swahili" }, - { T("SWZ "), "Swazi" }, + { T("SWZ "), "Swati" }, { T("SXT "), "Sutu" }, + { T("SXU "), "Upper Saxon" }, + { T("SYL "), "Sylheti" }, { T("SYR "), "Syriac" }, + { T("SYRE"), "Syriac, Estrangela script-variant (equivalent to ISO 15924 'Syre')" }, + { T("SYRJ"), "Syriac, Western script-variant (equivalent to ISO 15924 'Syrj')" }, + { T("SYRN"), "Syriac, Eastern script-variant (equivalent to ISO 15924 'Syrn')" }, + { T("SZL "), "Silesian" }, { T("TAB "), "Tabasaran" }, { T("TAJ "), "Tajiki" }, { T("TAM "), "Tamil" }, { T("TAT "), "Tatar" }, { T("TCR "), "TH-Cree" }, + { T("TDD "), "Dehong Dai" }, { T("TEL "), "Telugu" }, + { T("TET "), "Tetum" }, + { T("TGL "), "Tagalog" }, { T("TGN "), "Tongan" }, { T("TGR "), "Tigre" }, { T("TGY "), "Tigrinya" }, { T("THA "), "Thai" }, { T("THT "), "Tahitian" }, { T("TIB "), "Tibetan" }, + { T("TIV "), "Tiv" }, + { T("TJL "), "Tai Laing" }, { T("TKM "), "Turkmen" }, + { T("TLI "), "Tlingit" }, + { T("TMH "), "Tamashek" }, { T("TMN "), "Temne" }, { T("TNA "), "Tswana" }, - { T("TNE "), "Tundra Nenets" }, + { T("TNE "), "Tundra Enets" }, { T("TNG "), "Tonga" }, { T("TOD "), "Todo" }, + { T("TOD0"), "Toma" }, + { T("TPI "), "Tok Pisin" }, { T("TRK "), "Turkish" }, { T("TSG "), "Tsonga" }, + { T("TSJ "), "Tshangla" }, { T("TUA "), "Turoyo Aramaic" }, { T("TUL "), "Tulu" }, + { T("TUM "), "Tumbuka" }, { T("TUR "), "Turkish" }, // deprecated? { T("TUV "), "Tuvin" }, + { T("TVL "), "Tuvalu" }, { T("TWI "), "Twi" }, + { T("TYZ "), "Tà y" }, + { T("TZM "), "Tamazight" }, + { T("TZO "), "Tzotzil" }, { T("UDM "), "Udmurt" }, { T("UKR "), "Ukrainian" }, + { T("UMB "), "Umbundu" }, { T("URD "), "Urdu" }, { T("USB "), "Upper Sorbian" }, { T("UYG "), "Uyghur" }, { T("UZB "), "Uzbek" }, + { T("VEC "), "Venetian" }, { T("VEN "), "Venda" }, { T("VIT "), "Vietnamese" }, + { T("VOL "), "Volapük" }, + { T("VRO "), "Võro" }, { T("WA "), "Wa" }, { T("WAG "), "Wagdi" }, + { T("WAR "), "Waray-Waray" }, + { T("WCI "), "Waci Gbe" }, { T("WCR "), "West-Cree" }, { T("WEL "), "Welsh" }, { T("WLF "), "Wolof" }, - { T("XBD "), "Tai Lue" }, + { T("WLN "), "Walloon" }, + { T("WTM "), "Mewati" }, + { T("XBD "), "Lü" }, { T("XHS "), "Xhosa" }, + { T("XJB "), "Minjangbal" }, + { T("XKF "), "Khengkha" }, + { T("XOG "), "Soga" }, + { T("XPE "), "Kpelle (Liberia)" }, + { T("XUB "), "Bette Kuruma" }, + { T("XUJ "), "Jennu Kuruma" }, { T("YAK "), "Sakha" }, + { T("YAO "), "Yao" }, + { T("YAP "), "Yapese" }, { T("YBA "), "Yoruba" }, { T("YCR "), "Y-Cree" }, + { T("YGP "), "Gepo" }, { T("YIC "), "Yi Classic" }, { T("YIM "), "Yi Modern" }, - { T("ZHH "), "Chinese, Hong Kong SAR" }, - { T("ZHP "), "Chinese Phonetic" }, - { T("ZHS "), "Chinese Simplified" }, - { T("ZHT "), "Chinese Traditional" }, + { T("YNA "), "Aluo" }, + { T("YWQ "), "Wuding-Luquan Yi" }, + { T("ZEA "), "Zealandic" }, + { T("ZGH "), "Standard Moroccan Tamazight" }, + { T("ZHA "), "Zhuang" }, + { T("ZHH "), "Chinese, Traditional, Hong Kong SAR" }, + { T("ZHP "), "Chinese, Phonetic" }, + { T("ZHS "), "Chinese, Simplified" }, + { T("ZHT "), "Chinese, Traditional" }, + { T("ZHTM"), "Chinese, Traditional, Macao SAR" }, { T("ZND "), "Zande" }, - { T("ZUL "), "Zulu" } + { T("ZUL "), "Zulu" }, + { T("ZZA "), "Zazaki" } }; static const Mapping features[] = { @@ -540,7 +843,7 @@ static const Mapping features[] = { { T("abvm"), "Above-base Mark Positioning" }, { T("abvs"), "Above-base Substitutions" }, { T("afrc"), "Alternative Fractions" }, - { T("akhn"), "Akhands" }, + { T("akhn"), "Akhand" }, { T("blwf"), "Below-base Forms" }, { T("blwm"), "Below-base Mark Positioning" }, { T("blws"), "Below-base Substitutions" }, @@ -550,6 +853,7 @@ static const Mapping features[] = { { T("case"), "Case-Sensitive Forms" }, { T("ccmp"), "Glyph Composition/Decomposition" }, { T("cfar"), "Conjunct Form After Ro" }, + { T("chws"), "Contextual Half-width Spacing" }, { T("cjct"), "Conjunct Forms" }, { T("clig"), "Contextual Ligatures" }, { T("cpct"), "Centered CJK Punctuation" }, @@ -566,11 +870,13 @@ static const Mapping features[] = { { T("dist"), "Distances" }, { T("dlig"), "Discretionary Ligatures" }, { T("dnom"), "Denominators" }, + { T("dtls"), "Dotless Forms" }, { T("expt"), "Expert Forms" }, { T("falt"), "Final Glyph on Line Alternates" }, { T("fin2"), "Terminal Forms #2" }, { T("fin3"), "Terminal Forms #3" }, { T("fina"), "Terminal Forms" }, + { T("flac"), "Flattened Accent Forms" }, { T("frac"), "Fractions" }, { T("fwid"), "Full Widths" }, { T("half"), "Half Forms" }, @@ -623,6 +929,7 @@ static const Mapping features[] = { { T("pwid"), "Proportional Widths" }, { T("qwid"), "Quarter Widths" }, { T("rand"), "Randomize" }, + { T("rclt"), "Required Contextual Alternates" }, { T("rkrf"), "Rakar Forms" }, { T("rlig"), "Required Ligatures" }, { T("rphf"), "Reph Forms" }, @@ -655,6 +962,8 @@ static const Mapping features[] = { { T("ss18"), "Stylistic Set 18" }, { T("ss19"), "Stylistic Set 19" }, { T("ss20"), "Stylistic Set 20" }, + { T("ssty"), "Math Script Style Alternates" }, + { T("stch"), "Stretching Glyph Decomposition" }, { T("subs"), "Subscript" }, { T("sups"), "Superscript" }, { T("swsh"), "Swash" }, @@ -667,6 +976,7 @@ static const Mapping features[] = { { T("unic"), "Unicase" }, { T("valt"), "Alternate Vertical Metrics" }, { T("vatu"), "Vattu Variants" }, + { T("vchw"), "Vertical Contextual Half-width Spacing" }, { T("vert"), "Vertical Writing" }, { T("vhal"), "Alternate Vertical Half Metrics" }, { T("vjmo"), "Vowel Jamo Forms" }, diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otffvar.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otffvar.cc new file mode 100644 index 00000000000..ff5204e55de --- /dev/null +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otffvar.cc @@ -0,0 +1,62 @@ +// -*- related-file-name: "../include/efont/otffvar.hh" -*- + +/* otffvar.{cc,hh} -- OpenType fvar table + * + * Copyright (c) 2002-2023 Eddie Kohler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include <efont/otffvar.hh> +#include <lcdf/error.hh> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <efont/otfdata.hh> // for ntohl() + +namespace Efont { namespace OpenType { + +Fvar::Fvar(Data d) + : _id(nullptr) +{ + d.align_long(); + _d = d.udata(); + // USHORT majorVersion + // USHORT minorVersion + // OFFSET16 axesArrayOffset + // USHORT reserved + // USHORT axisCount + // USHORT axisSize + // USHORT instanceCount + // USHORT instanceSize + if (d.length() == 0) + throw BlankTable("fvar"); + if (d.length() < HEADER_SIZE + || d.u16(0) != 1) + throw Format("fvar"); + int axoff = d.u16(X_AXISOFF), nax = d.u16(X_AXISCOUNT), + axsz = d.u16(X_AXISSIZE); + if (axoff < HEADER_SIZE + || (axoff % 2) != 0 + || nax == 0 + || axsz < AXIS_SIZE + || (axsz % 2) != 0 + || axoff + nax * axsz > d.length()) + throw Format("fvar"); + int nin = d.u16(X_INSTANCECOUNT), insz = d.u16(X_INSTANCESIZE); + if (insz >= 4 + nax * 4 + && (insz % 2) == 0 + && axoff + axsz * nax + insz * nin <= d.length()) + _id = _d + axoff + axsz * nax; +} + +}} diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfname.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfname.cc index 0e8e4e4f6b2..0ff7fc68a1e 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfname.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfname.cc @@ -114,7 +114,7 @@ Name::name(const_iterator i) const String Name::utf8_name(const_iterator i) const { - // This code can handle Microsoft Unicode BMP and Mac Roman encodings, + // This code can handle Microsoft Unicode and Mac Roman encodings, // but that's it if (!(i < end())) return String(); @@ -125,10 +125,22 @@ Name::utf8_name(const_iterator i) const return String(); const unsigned char *begins = _str.udata() + stringOffset + offset; const unsigned char *ends = begins + length; - if (platform(*i) == P_MICROSOFT && encoding(*i) == E_MS_UNICODE_BMP) { + if (platform(*i) == P_MICROSOFT + && (encoding(*i) == E_MS_UNICODE_BMP || encoding(*i) == E_MS_UNICODE_FULL)) { StringAccum sa; - for (const unsigned char *s = begins; s + 1 < ends; s += 2) - sa.append_utf8(Data::u16(s)); + for (const unsigned char *s = begins; s + 1 < ends; s += 2) { + unsigned d = Data::u16(s), d2; + if (d >= 0xD800 && d < 0xE000) { + if (d < 0xDC00 && s + 3 < ends + && (d2 = Data::u16(s + 2)) >= 0xDC00 && d2 < 0xE000) { + d = 0x10000 + ((d - 0xD800) << 10) + (d2 - 0xDC00); + s += 2; + } else { + d = 0xFFFD; // REPLACEMENT CHARACTER + } + } + sa.append_utf8(d); + } return sa.take_string(); } else if (platform(*i) == P_MACINTOSH && encoding(*i) == E_MAC_ROMAN) { StringAccum sa; @@ -154,6 +166,8 @@ Name::english_name(int nameid) const const_iterator end = this->end(); const_iterator it = std::find_if(begin(), end, PlatformPred(nameid, P_MICROSOFT, E_MS_UNICODE_BMP, L_MS_ENGLISH_AMERICAN)); if (it == end) + it = std::find_if(begin(), end, PlatformPred(nameid, P_MICROSOFT, E_MS_UNICODE_FULL, L_MS_ENGLISH_AMERICAN)); + if (it == end) it = std::find_if(begin(), end, PlatformPred(nameid, P_MACINTOSH, E_MAC_ROMAN, 0)); return utf8_name(it); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfpost.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfpost.cc index af04b19edcb..791e7e7a22c 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfpost.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/otfpost.cc @@ -27,6 +27,7 @@ #define SHORT_AT(d) (Data::s16_aligned(d)) #define ULONG_AT(d) (Data::u32_aligned(d)) #define LONG_AT(d) (Data::s32_aligned(d)) +#define FIXED_AT(d) (Data::fixed_aligned(d)) namespace Efont { namespace OpenType { @@ -159,7 +160,7 @@ Post::italic_angle() const { if (error() < 0) return -1; - return (double) LONG_AT(_str.udata() + 4) / 65536.; + return FIXED_AT(_str.udata() + 4); } bool diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1font.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1font.cc index 82ab06e0389..fad22c33914 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1font.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1font.cc @@ -2,7 +2,7 @@ /* t1font.{cc,hh} -- Type 1 font * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -78,7 +78,7 @@ Type1Font::set_item(int i, Type1Item *it) } static const char * const dict_starters[] = { - "0 dict begin", "/FontInfo 0 dict dup begin", "dup /Private 0 dict dup begin", "/Blend 0 dict dup begin", 0, 0 + "0 dict dup begin", "/FontInfo 0 dict dup begin", "dup /Private 0 dict dup begin", "/Blend 0 dict dup begin", 0, 0 }; void @@ -850,7 +850,8 @@ Type1Font::create_mmspace(ErrorHandler *errh) const int nmasters = master_positions.size(); if (nmasters <= 0) { - errh->error("bad BlendDesignPositions"); + if (errh) + errh->error("bad BlendDesignPositions"); return 0; } int naxes = master_positions[0].size(); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1fontskel.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1fontskel.cc index c62e25a392a..c34e44ed1ee 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1fontskel.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1fontskel.cc @@ -1,6 +1,6 @@ /* t1fontskel.cc -- Type 1 font skeleton * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -28,10 +28,10 @@ namespace Efont { static const char* othersubrs_code = // This version of the OtherSubrs code for old PostScript interpreters comes from -// https://github.com/adobe-type-tools/afdko/blob/master/FDK/Tools/Programs/public/lib/source/t1write/t1write_flexothers.txt -// (commit 3f4eeec). The Adobe Font Development Kit is licensed by the Apache +// https://github.com/adobe-type-tools/afdko:c/shared/source/t1write/t1write_flexothers.h +// (commit 26761e9). The Adobe Font Development Kit is licensed by the Apache // License, 2.0, which permits this embedding. -"% Copyright 1987-1990 Adobe Systems Incorporated. All rights reserved.\n" +"% Copyright 2014 Adobe Systems Incorporated. All rights reserved.\n" "/OtherSubrs[systemdict/internaldict known{1183615869 systemdict/internaldict\n" "get exec/FlxProc known{save true}{false}ifelse}{userdict/internaldict known\n" "not{userdict/internaldict{count 0 eq{/internaldict errordict/invalidaccess get\n" @@ -113,27 +113,22 @@ Type1Font::skeleton_make(PermString font_name, const String &version) { Type1Font *output = new Type1Font(font_name); - // %!PS-Adobe-Font comment + // %!PS-AdobeFont comment StringAccum sa; - sa << "%!PS-AdobeFont-1.0: " << font_name; - if (version) + sa << "%!FontType1-1.1: " << font_name; + if (version) { sa << ' ' << version; + } output->add_item(new Type1CopyItem(sa.take_string())); + // XXX %%BeginResource: font FontName - output->_dict_deltas[dF] = 3; // Private, FontInfo, Encoding + output->_dict_deltas[dF] = 4; // Private, FontInfo, Encoding, FID output->_dict_deltas[dP] = 3; // OtherSubrs, Subrs, CharStrings return output; } void -Type1Font::skeleton_comments_end() -{ - // count members of font dictionary - add_definition(dF, new Type1Definition("FontName", "/" + String(_font_name), "def")); -} - -void Type1Font::skeleton_fontinfo_end() { if (first_dict_item(Type1Font::dFI) >= 0) @@ -146,7 +141,7 @@ void Type1Font::skeleton_fontdict_end() { // switch to eexec - add_item(new Type1CopyItem("currentdict end")); + add_item(new Type1CopyItem("end")); add_item(new Type1EexecItem(true)); // Private dictionary @@ -238,7 +233,7 @@ Type1Font::skeleton_make_copy(const Type1Font *font, PermString font_name, const Type1Font *output = skeleton_make(font_name, version); // other comments from font header - for (int i = 0; i < font->nitems(); i++) + for (int i = 0; i < font->nitems(); i++) { if (Type1CopyItem *c = font->item(i)->cast_copy()) { if (c->length() > 1 && c->value()[0] == '%') { if (c->value()[1] != '!') @@ -247,8 +242,12 @@ Type1Font::skeleton_make_copy(const Type1Font *font, PermString font_name, const break; } else break; + } - output->skeleton_comments_end(); + add_number_def(output, dF, "FontType", font); + output->add_definition(dF, new Type1Definition("FontName", "/" + String(font_name), "def")); + add_number_def(output, dF, "PaintType", font); + add_copy_def(output, dF, "FontMatrix", font, "readonly def"); // FontInfo dictionary if (version) @@ -275,9 +274,6 @@ Type1Font::skeleton_make_copy(const Type1Font *font, PermString font_name, const // Encoding, other font dictionary entries output->add_type1_encoding(new Type1Encoding(*font->type1_encoding())); - add_number_def(output, dF, "PaintType", font); - add_number_def(output, dF, "FontType", font); - add_copy_def(output, dF, "FontMatrix", font, "readonly def"); add_number_def(output, dF, "StrokeWidth", font); if (!xuid_extension) add_number_def(output, dF, "UniqueID", font); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1item.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1item.cc index d9e2b614ef4..f25f63bfb22 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1item.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1item.cc @@ -2,7 +2,7 @@ /* t1item.{cc,hh} -- items in a Type 1 font * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -37,7 +37,7 @@ namespace Efont { **/ void -Type1NullItem::gen(Type1Writer &) +Type1NullItem::gen(Type1Writer&) { } @@ -46,7 +46,7 @@ Type1NullItem::gen(Type1Writer &) **/ void -Type1CopyItem::gen(Type1Writer &w) +Type1CopyItem::gen(Type1Writer& w) { w << _value << '\n'; } @@ -57,7 +57,7 @@ Type1CopyItem::gen(Type1Writer &w) **/ void -Type1EexecItem::gen(Type1Writer &w) +Type1EexecItem::gen(Type1Writer& w) { if (_eexec_on) w << "currentfile eexec\n"; @@ -72,25 +72,25 @@ Type1EexecItem::gen(Type1Writer &w) typedef Vector<double> NumVector; -Type1Definition::Type1Definition(PermString n, const String &v, PermString d) +Type1Definition::Type1Definition(PermString n, const String& v, PermString d) : _name(n), _val(v), _definer(d) { _val.c_str(); // ensure it ends with '\0' } -Type1Definition * -Type1Definition::make_string(PermString n, const String &v, PermString d) +Type1Definition* +Type1Definition::make_string(PermString n, const String& v, PermString d) { - Type1Definition *t1d = new Type1Definition(n, "", d); + Type1Definition* t1d = new Type1Definition(n, "", d); t1d->set_string(v); return t1d; } int -Type1Definition::slurp_string(StringAccum &accum, int pos, Type1Reader *reader) +Type1Definition::slurp_string(StringAccum& accum, int pos, Type1Reader* reader) { int paren_level = 0; - char *s = accum.data() + pos; + char* s = accum.data() + pos; do { switch (*s++) { @@ -112,11 +112,11 @@ Type1Definition::slurp_string(StringAccum &accum, int pos, Type1Reader *reader) } int -Type1Definition::slurp_proc(StringAccum &accum, int pos, Type1Reader *reader) +Type1Definition::slurp_proc(StringAccum& accum, int pos, Type1Reader* reader) { int paren_level = 0; int brace_level = 0; - char *s = accum.data() + pos; + char* s = accum.data() + pos; do { switch (*s++) { @@ -144,11 +144,11 @@ Type1Definition::slurp_proc(StringAccum &accum, int pos, Type1Reader *reader) return s - accum.data(); } -Type1Definition * -Type1Definition::make(StringAccum &accum, Type1Reader *reader, +Type1Definition* +Type1Definition::make(StringAccum& accum, Type1Reader* reader, bool force_definition) { - char *s = accum.data(); + char* s = accum.data(); while (isspace((unsigned char) *s)) s++; if (*s != '/') @@ -213,20 +213,20 @@ Type1Definition::make(StringAccum &accum, Type1Reader *reader, } void -Type1Definition::gen(Type1Writer &w) +Type1Definition::gen(Type1Writer& w) { w << '/' << _name << ' ' << _val << ' ' << _definer << '\n'; } void -Type1Definition::gen(StringAccum &sa) +Type1Definition::gen(StringAccum& sa) { sa << '/' << _name << ' ' << _val << ' ' << _definer; } bool -Type1Definition::value_bool(bool &b) const +Type1Definition::value_bool(bool& b) const { if (_val == "true") { b = true; @@ -239,23 +239,23 @@ Type1Definition::value_bool(bool &b) const } bool -Type1Definition::value_int(int &i) const +Type1Definition::value_int(int& i) const { - char *s; + char* s; i = strtol(_val.data(), &s, 10); return (*s == 0); } bool -Type1Definition::value_num(double &d) const +Type1Definition::value_num(double& d) const { - char *s; + char* s; d = strtonumber(_val.data(), &s); return (*s == 0); } bool -Type1Definition::value_string(String &str) const +Type1Definition::value_string(String& str) const { if (_val.length() == 0 || _val[0] != '(' || _val.back() != ')') return false; @@ -315,7 +315,7 @@ Type1Definition::value_string(String &str) const } bool -Type1Definition::value_name(PermString &str) const +Type1Definition::value_name(PermString& str) const { if (_val.length() == 0 || _val[0] != '/') return false; @@ -328,10 +328,10 @@ Type1Definition::value_name(PermString &str) const } static bool -strtonumvec(const char *f, const char **endf, NumVector &v) +strtonumvec(const char* f, const char** endf, NumVector& v) { v.clear(); - char *s = (char *)f; + char* s = (char*) f; if (*s != '[' && *s != '{') return false; s++; @@ -349,16 +349,16 @@ strtonumvec(const char *f, const char **endf, NumVector &v) } bool -Type1Definition::value_numvec(NumVector &v) const +Type1Definition::value_numvec(NumVector& v) const { return strtonumvec(_val.data(), 0, v); } static bool -strtonumvec_vec(const char *f, const char **endf, Vector<NumVector> &v) +strtonumvec_vec(const char* f, const char** endf, Vector<NumVector>& v) { v.clear(); - const char *s = f; + const char* s = f; if (*s != '[' && *s != '{') return false; s++; @@ -379,18 +379,18 @@ strtonumvec_vec(const char *f, const char **endf, Vector<NumVector> &v) } bool -Type1Definition::value_numvec_vec(Vector<NumVector> &v) const +Type1Definition::value_numvec_vec(Vector<NumVector>& v) const { return strtonumvec_vec(_val.data(), 0, v); } bool -Type1Definition::value_normalize(Vector<NumVector> &in, - Vector<NumVector> &out) const +Type1Definition::value_normalize(Vector<NumVector>& in, + Vector<NumVector>& out) const { in.clear(); out.clear(); - const char *s = _val.data(); + const char* s = _val.data(); if (*s++ != '[') return false; while (1) { @@ -417,10 +417,10 @@ Type1Definition::value_normalize(Vector<NumVector> &in, } bool -Type1Definition::value_namevec(Vector<PermString> &v) const +Type1Definition::value_namevec(Vector<PermString>& v) const { v.clear(); - const char *s = _val.data(); + const char* s = _val.data(); if (*s++ != '[') return false; while (1) { @@ -429,7 +429,7 @@ Type1Definition::value_namevec(Vector<PermString> &v) const if (*s == '/') s++; if (isalnum((unsigned char) *s)) { - const char *start = s; + const char* start = s; while (*s && !isspace((unsigned char) *s) && *s != ']' && *s != '/') s++; v.push_back(PermString(start, s - start)); @@ -458,9 +458,9 @@ Type1Definition::set_num(double n) } void -Type1Definition::set_string(const String &v) +Type1Definition::set_string(const String& v) { - const char *s = v.data(); + const char* s = v.data(); int len = v.length(); int left = 0; StringAccum sa; @@ -471,7 +471,7 @@ Type1Definition::set_string(const String &v) if (s[pos] == '(' || s[pos] == ')' || s[pos] == '\\') sa << s[pos]; else - sprintf(sa.reserve(8), "%03o", (unsigned char) (s[pos])); + snprintf(sa.extend(3, 1), 4, "%03o", (unsigned char) (s[pos])); left = pos + 1; } sa << v.substring(left) << ')'; @@ -489,7 +489,7 @@ Type1Definition::set_name(PermString str, bool name) } static void -accum_numvec(StringAccum &sa, const NumVector &nv, bool executable) +accum_numvec(StringAccum& sa, const NumVector& nv, bool executable) { char open = (executable ? '{' : '['); for (int i = 0; i < nv.size(); i++) @@ -498,7 +498,7 @@ accum_numvec(StringAccum &sa, const NumVector &nv, bool executable) } void -Type1Definition::set_numvec(const NumVector &nv, bool executable) +Type1Definition::set_numvec(const NumVector& nv, bool executable) { StringAccum sa; accum_numvec(sa, nv, executable); @@ -506,7 +506,7 @@ Type1Definition::set_numvec(const NumVector &nv, bool executable) } void -Type1Definition::set_numvec_vec(const Vector<NumVector> &nv) +Type1Definition::set_numvec_vec(const Vector<NumVector>& nv) { StringAccum sa; sa << '['; @@ -517,14 +517,14 @@ Type1Definition::set_numvec_vec(const Vector<NumVector> &nv) } void -Type1Definition::set_normalize(const Vector<NumVector> &vin, - const Vector<NumVector> &vout) +Type1Definition::set_normalize(const Vector<NumVector>& vin, + const Vector<NumVector>& vout) { StringAccum sa; sa << '['; for (int i = 0; i < vin.size(); i++) { - const NumVector &vini = vin[i]; - const NumVector &vouti = vout[i]; + const NumVector& vini = vin[i]; + const NumVector& vouti = vout[i]; sa << '['; for (int j = 0; j < vini.size(); j++) sa << '[' << vini[j] << ' ' << vouti[j] << ']'; @@ -535,7 +535,7 @@ Type1Definition::set_normalize(const Vector<NumVector> &vin, } void -Type1Definition::set_namevec(const Vector<PermString> &v, bool executable) +Type1Definition::set_namevec(const Vector<PermString>& v, bool executable) { StringAccum sa; sa << '['; @@ -564,7 +564,7 @@ Type1Encoding::Type1Encoding() _v[i] = dot_notdef; } -Type1Encoding::Type1Encoding(const Type1Encoding &o) +Type1Encoding::Type1Encoding(const Type1Encoding& o) : Type1Item(), _definer(o._definer) { if (o._copy_of) { @@ -578,7 +578,7 @@ Type1Encoding::Type1Encoding(const Type1Encoding &o) } } -Type1Encoding::Type1Encoding(Type1Encoding *copy_of) +Type1Encoding::Type1Encoding(Type1Encoding* copy_of) : _v(copy_of->_v), _copy_of(copy_of), _definer(copy_of->_definer) { } @@ -593,7 +593,7 @@ void Type1Encoding::unshare() { if (_copy_of) { - PermString *new_v = new PermString[256]; + PermString* new_v = new PermString[256]; memcpy(new_v, _v, sizeof(PermString) * 256); _v = new_v; _copy_of = 0; @@ -609,9 +609,9 @@ Type1Encoding::clear() } -static Type1Encoding *canonical_standard_encoding; +static Type1Encoding* canonical_standard_encoding; -Type1Encoding * +Type1Encoding* Type1Encoding::standard_encoding() { if (!canonical_standard_encoding) { @@ -626,7 +626,7 @@ Type1Encoding::standard_encoding() void -Type1Encoding::gen(Type1Writer &w) +Type1Encoding::gen(Type1Writer& w) { if (_copy_of && _copy_of == canonical_standard_encoding) w << "/Encoding StandardEncoding def\n"; @@ -645,19 +645,19 @@ Type1Encoding::gen(Type1Writer &w) **/ Type1Subr::Type1Subr(PermString n, int num, PermString definer, - int lenIV, const String &s) + int lenIV, const String& s) : _name(n), _subrno(num), _definer(definer), _cs(lenIV, s) { } Type1Subr::Type1Subr(PermString n, int num, PermString definer, - const Type1Charstring &t1cs) + const Type1Charstring& t1cs) : _name(n), _subrno(num), _definer(definer), _cs(t1cs) { } -Type1Subr * -Type1Subr::make(const char *s_in, int s_len, int cs_pos, int cs_len, int lenIV) +Type1Subr* +Type1Subr::make(const char* s_in, int s_len, int cs_pos, int cs_len, int lenIV) { /* USAGE NOTE: You must ensure that s_in contains a valid subroutine string before calling Type1Subr::make. Type1Reader::was_charstring() is a good @@ -666,13 +666,13 @@ Type1Subr::make(const char *s_in, int s_len, int cs_pos, int cs_len, int lenIV) /[char_name] ### charstring_start ........ dup [subrno] ### charstring_start .... */ - const char *s = s_in; + const char* s = s_in; PermString name; int subrno = 0; // Force literal spaces rather than isspace(). if (*s == '/') { - const char *nstart = ++s; + const char* nstart = ++s; while (!isspace((unsigned char) *s) && *s) s++; name = PermString(nstart, s - nstart); @@ -692,24 +692,24 @@ Type1Subr::make(const char *s_in, int s_len, int cs_pos, int cs_len, int lenIV) return new Type1Subr(name, subrno, definer, lenIV, String(s, cs_len)); } -Type1Subr * -Type1Subr::make_subr(int subrno, const Type1Charstring &cs, PermString definer) +Type1Subr* +Type1Subr::make_subr(int subrno, const Type1Charstring& cs, PermString definer) { return new Type1Subr(PermString(), subrno, definer, cs); } -Type1Subr * -Type1Subr::make_glyph(PermString glyph, const Type1Charstring &cs, PermString definer) +Type1Subr* +Type1Subr::make_glyph(PermString glyph, const Type1Charstring& cs, PermString definer) { return new Type1Subr(glyph, -1, definer, cs); } void -Type1Subr::gen(Type1Writer &w) +Type1Subr::gen(Type1Writer& w) { int len = _cs.length(); - const unsigned char *data = _cs.data(); + const unsigned char* data = _cs.data(); if (is_subr()) w << "dup " << _subrno << ' ' << len + w.lenIV() << w.charstring_start(); @@ -724,8 +724,8 @@ Type1Subr::gen(Type1Writer &w) // PERFORMANCE NOTE: Putting the charstring in a buffer of known length // and printing that buffer rather than one char at a time is an OK // optimization. (around 10%) - unsigned char *buf = new unsigned char[len + w.lenIV()]; - unsigned char *t = buf; + unsigned char* buf = new unsigned char[len + w.lenIV()]; + unsigned char* t = buf; int r = t1R_cs; for (int i = 0; i < w.lenIV(); i++) { @@ -750,27 +750,27 @@ Type1Subr::gen(Type1Writer &w) * Type1SubrGroupItem **/ -Type1SubrGroupItem::Type1SubrGroupItem(Type1Font *font, bool is_subrs, const String &value) +Type1SubrGroupItem::Type1SubrGroupItem(Type1Font* font, bool is_subrs, const String& value) : _font(font), _is_subrs(is_subrs), _value(value) { } -Type1SubrGroupItem::Type1SubrGroupItem(const Type1SubrGroupItem &from, Type1Font *font) +Type1SubrGroupItem::Type1SubrGroupItem(const Type1SubrGroupItem& from, Type1Font* font) : _font(font), _is_subrs(from._is_subrs), _value(from._value), _end_text(from._end_text) { } void -Type1SubrGroupItem::add_end_text(const String &s) +Type1SubrGroupItem::add_end_text(const String& s) { _end_text += s + "\n"; } void -Type1SubrGroupItem::gen(Type1Writer &w) +Type1SubrGroupItem::gen(Type1Writer& w) { - Type1Font *font = _font; + Type1Font* font = _font; int pos = _value.find_left(_is_subrs ? " array" : " dict"); if (pos >= 1 && isdigit((unsigned char) _value[pos - 1])) { @@ -795,12 +795,12 @@ Type1SubrGroupItem::gen(Type1Writer &w) if (_is_subrs) { int count = font->nsubrs(); for (int i = 0; i < count; i++) - if (Type1Subr *g = font->subr_x(i)) + if (Type1Subr* g = font->subr_x(i)) g->gen(w); } else { int count = font->nglyphs(); for (int i = 0; i < count; i++) - if (Type1Subr *g = font->glyph_x(i)) + if (Type1Subr* g = font->glyph_x(i)) g->gen(w); } @@ -811,7 +811,7 @@ Type1SubrGroupItem::gen(Type1Writer &w) * Type1IncludedFont **/ -Type1IncludedFont::Type1IncludedFont(Type1Font *font, int unique_id) +Type1IncludedFont::Type1IncludedFont(Type1Font* font, int unique_id) : _included_font(font), _unique_id(unique_id) { } @@ -822,9 +822,9 @@ Type1IncludedFont::~Type1IncludedFont() } void -Type1IncludedFont::gen(Type1Writer &w) +Type1IncludedFont::gen(Type1Writer& w) { - FILE *f = tmpfile(); + FILE* f = tmpfile(); if (!f) return; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1mm.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1mm.cc index c49eafa6e87..7b749eec87a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1mm.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1mm.cc @@ -96,8 +96,8 @@ MultipleMasterSpace::error(ErrorHandler *errh, const char *s, ...) const va_list val; va_start(val, s); assert(strlen(s) < 800); - sprintf(buf, (s[0] == ' ' ? "%.200s%s" : "%.200s: %s"), - _font_name.c_str(), s); + snprintf(buf, sizeof(buf), (s[0] == ' ' ? "%.200s%s" : "%.200s: %s"), + _font_name.c_str(), s); errh->xmessage(ErrorHandler::e_error, buf, val); va_end(val); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1rw.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1rw.cc index 35e9f57a72c..90605378f12 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1rw.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1rw.cc @@ -30,16 +30,31 @@ unsigned char *Type1Reader::xvalue = &Type1Reader::xvalue_store[1]; void Type1Reader::static_initialize() { - if (xvalue['A']) - return; // rely on static data being initialized to 0 - xvalue['0'] = 0; xvalue['1'] = 1; xvalue['2'] = 2; xvalue['3'] = 3; - xvalue['4'] = 4; xvalue['5'] = 5; xvalue['6'] = 6; xvalue['7'] = 7; - xvalue['8'] = 8; xvalue['9'] = 9; - xvalue['A'] = 10; xvalue['B'] = 11; xvalue['C'] = 12; xvalue['D'] = 13; - xvalue['E'] = 14; xvalue['F'] = 15; - xvalue['a'] = 10; xvalue['b'] = 11; xvalue['c'] = 12; xvalue['d'] = 13; - xvalue['e'] = 14; xvalue['f'] = 15; + if (!xvalue[(unsigned char) 'A']) { + xvalue[(unsigned char) '0'] = 0; + xvalue[(unsigned char) '1'] = 1; + xvalue[(unsigned char) '2'] = 2; + xvalue[(unsigned char) '3'] = 3; + xvalue[(unsigned char) '4'] = 4; + xvalue[(unsigned char) '5'] = 5; + xvalue[(unsigned char) '6'] = 6; + xvalue[(unsigned char) '7'] = 7; + xvalue[(unsigned char) '8'] = 8; + xvalue[(unsigned char) '9'] = 9; + xvalue[(unsigned char) 'A'] = 10; + xvalue[(unsigned char) 'B'] = 11; + xvalue[(unsigned char) 'C'] = 12; + xvalue[(unsigned char) 'D'] = 13; + xvalue[(unsigned char) 'E'] = 14; + xvalue[(unsigned char) 'F'] = 15; + xvalue[(unsigned char) 'a'] = 10; + xvalue[(unsigned char) 'b'] = 11; + xvalue[(unsigned char) 'c'] = 12; + xvalue[(unsigned char) 'd'] = 13; + xvalue[(unsigned char) 'e'] = 14; + xvalue[(unsigned char) 'f'] = 15; + } } @@ -489,8 +504,8 @@ Type1Writer & Type1Writer::operator<<(int x) { char str[128]; - sprintf(str, "%d", x); - print(str, strlen(str)); + size_t len = snprintf(str, sizeof(str), "%d", x); + print(str, len); return *this; } @@ -499,8 +514,8 @@ Type1Writer & Type1Writer::operator<<(double x) { char str[256]; - sprintf(str, "%g", x); - print(str, strlen(str)); + size_t len = snprintf(str, sizeof(str), "%g", x); + print(str, len); return *this; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1unparser.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1unparser.cc index e38aa37a9d7..8e50d285e67 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1unparser.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/t1unparser.cc @@ -102,9 +102,11 @@ CharstringUnparser::type2_command(int cmd, const unsigned char *data, int *left) void CharstringUnparser::act_hintmask(int, const unsigned char *data, int nhints) { + static const char hexdig[] = "0123456789ABCDEF"; _sa << '['; - for (int i = 0; i < nhints; i++, data++) - sprintf(_sa.extend(2), "%02X", *data); + for (int i = 0; i < nhints; i++, data++) { + _sa << hexdig[(unsigned) ((*data >> 4) & 15)] << hexdig[(unsigned) (*data & 15)]; + } _sa << ']'; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/ttfcs.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/ttfcs.cc index eef06084ced..b9936b4965d 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/ttfcs.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/libefont/ttfcs.cc @@ -144,7 +144,7 @@ TrueTypeBoundsCharstringProgram::glyph_name(int gi) const if (gi >= 0 && gi < _unicodes.size() && _unicodes[gi] > 0 && _unicodes[gi] <= 0xFFFF) { char buf[10]; - sprintf(buf, "uni%04X", _unicodes[gi]); + snprintf(buf, sizeof(buf), "uni%04X", _unicodes[gi]); return PermString(buf); } else return permprintf("index%d", gi); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/bezier.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/bezier.cc index c296a4b4aa3..eb1ea73dc9a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/bezier.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/bezier.cc @@ -2,7 +2,7 @@ /* bezier.{cc,hh} -- cubic Bezier curves * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -27,14 +27,14 @@ Bezier::make_bb() const noexcept { _bb = 0; for (int i = 1; i < 4; i++) { - if (_p[i].x > bb_right_x()) - _bb = (_bb & ~0x03) | (i << 0); - else if (_p[i].x < bb_left_x()) - _bb = (_bb & ~0x0C) | (i << 2); - if (_p[i].y > bb_top_x()) - _bb = (_bb & ~0x30) | (i << 4); - else if (_p[i].y < bb_bottom_x()) - _bb = (_bb & ~0xC0) | (i << 6); + if (_p[i].x > bb_right_x()) + _bb = (_bb & ~0x03) | (i << 0); + else if (_p[i].x < bb_left_x()) + _bb = (_bb & ~0x0C) | (i << 2); + if (_p[i].y > bb_top_x()) + _bb = (_bb & ~0x30) | (i << 4); + else if (_p[i].y < bb_bottom_x()) + _bb = (_bb & ~0xC0) | (i << 6); } } @@ -47,7 +47,7 @@ bool Bezier::is_flat(double t) const noexcept { return (_p[2].on_segment(_p[0], _p[3], t) - && _p[1].on_segment(_p[0], _p[3], t)); + && _p[1].on_segment(_p[0], _p[3], t)); } static Point @@ -56,12 +56,12 @@ eval_bezier(Point *b_in, int degree, double u) assert(degree < 4); Point b[4]; for (int i = 0; i <= degree; i++) - b[i] = b_in[i]; + b[i] = b_in[i]; double m = 1.0 - u; for (int i = 1; i <= degree; i++) - for (int j = 0; j <= degree - i; j++) - b[j] = b[j]*m + b[j+1]*u; + for (int j = 0; j <= degree - i; j++) + b[j] = b[j]*m + b[j+1]*u; return b[0]; } @@ -71,8 +71,8 @@ Bezier::eval(double u) const noexcept Bezier b = *this; double m = 1.0 - u; for (int i = 1; i < 4; i++) - for (int j = 0; j < 4 - i; j++) - b._p[j] = m * b._p[j] + u * b._p[j+1]; + for (int j = 0; j < 4 - i; j++) + b._p[j] = m * b._p[j] + u * b._p[j+1]; return b._p[0]; } @@ -104,45 +104,45 @@ Bezier::in_bb(const Point &p, double tolerance) const noexcept { ensure_bb(); if (bb_right() + tolerance < p.x - || bb_left() - tolerance > p.x - || bb_top() + tolerance < p.y - || bb_bottom() - tolerance > p.y) - return false; + || bb_left() - tolerance > p.x + || bb_top() + tolerance < p.y + || bb_bottom() - tolerance > p.y) + return false; else - return true; + return true; } double Bezier::hit_recurse(const Point &p, double tolerance, double leftd, - double rightd, double leftt, double rightt) const noexcept + double rightd, double leftt, double rightt) const noexcept { Bezier left, right; double middled, resultt; if (is_flat(tolerance)) { - if (p.on_segment(_p[0], _p[3], tolerance)) - return (leftt + rightt) / 2; - else - return -1; + if (p.on_segment(_p[0], _p[3], tolerance)) + return (leftt + rightt) / 2; + else + return -1; } if (leftd < tolerance * tolerance) - return leftt; + return leftt; if (rightd < tolerance * tolerance) - return rightt; + return rightt; if (!in_bb(p, tolerance)) - return -1; + return -1; halve(left, right); middled = (right._p[0] - p).squared_length(); resultt = left.hit_recurse - (p, tolerance, leftd, middled, leftt, (leftt + rightt) / 2); + (p, tolerance, leftd, middled, leftt, (leftt + rightt) / 2); if (resultt >= 0) - return resultt; + return resultt; return right.hit_recurse - (p, tolerance, middled, rightd, (leftt + rightt) / 2, rightt); + (p, tolerance, middled, rightd, (leftt + rightt) / 2, rightt); } bool @@ -165,14 +165,14 @@ void Bezier::segmentize(Vector<Point> &v, bool first) const { if (is_flat(0.5)) { - if (first) - v.push_back(_p[0]); - v.push_back(_p[3]); + if (first) + v.push_back(_p[0]); + v.push_back(_p[3]); } else { - Bezier left, right; - halve(left, right); - left.segmentize(v, first); - right.segmentize(v, false); + Bezier left, right; + halve(left, right); + left.segmentize(v, first); + right.segmentize(v, false); } } @@ -191,10 +191,10 @@ chord_length_parameterize(const Point *d, int nd, Vector<double> &result) result.reserve(nd); result.push_back(0); for (int i = 1; i < nd; i++) - result.push_back(result.back() + Point::distance(d[i-1], d[i])); + result.push_back(result.back() + Point::distance(d[i-1], d[i])); double last_dist = result.back(); for (int i = 1; i < nd; i++) - result[i] /= last_dist; + result[i] /= last_dist; } static inline double @@ -226,14 +226,14 @@ B3(double u) static Bezier generate_bezier(const Point *d, int nd, const Vector<double> ¶meters, - const Point &left_tangent, const Point &right_tangent) + const Point &left_tangent, const Point &right_tangent) { Point *a0 = new Point[nd]; Point *a1 = new Point[nd]; for (int i = 0; i < nd; i++) { - a0[i] = left_tangent * B1(parameters[i]); - a1[i] = right_tangent * B2(parameters[i]); + a0[i] = left_tangent * B1(parameters[i]); + a1[i] = right_tangent * B2(parameters[i]); } double c[2][2], x[2]; @@ -241,14 +241,14 @@ generate_bezier(const Point *d, int nd, const Vector<double> ¶meters, int last = nd - 1; for (int i = 0; i < nd; i++) { - c[0][0] += Point::dot(a0[i], a0[i]); - c[0][1] += Point::dot(a0[i], a1[i]); - c[1][1] += Point::dot(a1[i], a1[i]); - - Point tmp = d[i] - (d[0] * (B0(parameters[i]) + B1(parameters[i])) - + d[last] * (B2(parameters[i]) + B3(parameters[i]))); - x[0] += Point::dot(a0[i], tmp); - x[1] += Point::dot(a1[i], tmp); + c[0][0] += Point::dot(a0[i], a0[i]); + c[0][1] += Point::dot(a0[i], a1[i]); + c[1][1] += Point::dot(a1[i], a1[i]); + + Point tmp = d[i] - (d[0] * (B0(parameters[i]) + B1(parameters[i])) + + d[last] * (B2(parameters[i]) + B3(parameters[i]))); + x[0] += Point::dot(a0[i], tmp); + x[1] += Point::dot(a1[i], tmp); } c[1][0] = c[0][1]; @@ -259,18 +259,18 @@ generate_bezier(const Point *d, int nd, const Vector<double> ¶meters, // finally, derive alpha values if (det_c0_c1 == 0.0) - det_c0_c1 = c[0][0]*c[1][1] * 10e-12; + det_c0_c1 = c[0][0]*c[1][1] * 10e-12; double alpha_l = det_x_c1 / det_c0_c1; double alpha_r = det_c0_x / det_c0_c1; // if alpha negative, use the Wu/Barsky heuristic if (alpha_l < 0.0 || alpha_r < 0.0) { - double distance = Point::distance(d[0], d[last]) / 3; - return Bezier(d[0], d[0] + left_tangent*distance, - d[last] + right_tangent*distance, d[last]); + double distance = Point::distance(d[0], d[last]) / 3; + return Bezier(d[0], d[0] + left_tangent*distance, + d[last] + right_tangent*distance, d[last]); } else - return Bezier(d[0], d[0] + left_tangent*alpha_l, - d[last] + right_tangent*alpha_r, d[last]); + return Bezier(d[0], d[0] + left_tangent*alpha_l, + d[last] + right_tangent*alpha_r, d[last]); } static double @@ -280,11 +280,11 @@ newton_raphson_root_find(const Bezier &b, const Point &p, double u) Point b_det[3]; for (int i = 0; i < 3; i++) - b_det[i] = (b_pts[i+1] - b_pts[i]) * 3; + b_det[i] = (b_pts[i+1] - b_pts[i]) * 3; Point b_det_det[2]; for (int i = 0; i < 2; i++) - b_det_det[i] = (b_det[i+1] - b_det[i]) * 2; + b_det_det[i] = (b_det[i+1] - b_det[i]) * 2; Point b_u = b.eval(u); Point b_det_u = eval_bezier(b_det, 2, u); @@ -292,31 +292,31 @@ newton_raphson_root_find(const Bezier &b, const Point &p, double u) double numerator = Point::dot(b_u - p, b_det_u); double denominator = Point::dot(b_det_u, b_det_u) + - Point::dot(b_u - p, b_det_det_u); + Point::dot(b_u - p, b_det_det_u); return u - numerator/denominator; } static void reparameterize(const Point *d, int nd, Vector<double> ¶meters, - const Bezier &b) + const Bezier &b) { for (int i = 0; i < nd; i++) - parameters[i] = newton_raphson_root_find(b, d[i], parameters[i]); + parameters[i] = newton_raphson_root_find(b, d[i], parameters[i]); } static double compute_max_error(const Point *d, int nd, const Bezier &b, - const Vector<double> ¶meters, int *split_point) + const Vector<double> ¶meters, int *split_point) { *split_point = nd/2; double max_dist = 0.0; for (int i = 1; i < nd - 1; i++) { - double dist = (b.eval(parameters[i]) - d[i]).squared_length(); - if (dist >= max_dist) { - max_dist = dist; - *split_point = i; - } + double dist = (b.eval(parameters[i]) - d[i]).squared_length(); + if (dist >= max_dist) { + max_dist = dist; + *split_point = i; + } } return max_dist; } @@ -327,12 +327,12 @@ fit0(const Point *d, int nd, Point left_tangent, Point right_tangent, { // Use a heuristic for small regions (only two points) if (nd == 2) { - double dist = Point::distance(d[0], d[1]) / 3; - result.push_back(Bezier(d[0], - d[0] + dist*left_tangent, - d[1] + dist*right_tangent, - d[1])); - return; + double dist = Point::distance(d[0], d[1]) / 3; + result.push_back(Bezier(d[0], + d[0] + dist*left_tangent, + d[1] + dist*right_tangent, + d[1])); + return; } // Parameterize points and attempt to fit curve @@ -344,21 +344,21 @@ fit0(const Point *d, int nd, Point left_tangent, Point right_tangent, int split_point; double max_error = compute_max_error(d, nd, b, parameters, &split_point); if (max_error < error) { - result.push_back(b); - return; + result.push_back(b); + return; } // if error not too large, try iteration and reparameterization if (max_error < error*error) - for (int i = 0; i < 4; i++) { - reparameterize(d, nd, parameters, b); - b = generate_bezier(d, nd, parameters, left_tangent, right_tangent); - max_error = compute_max_error(d, nd, b, parameters, &split_point); - if (max_error < error) { - result.push_back(b); - return; - } - } + for (int i = 0; i < 4; i++) { + reparameterize(d, nd, parameters, b); + b = generate_bezier(d, nd, parameters, left_tangent, right_tangent); + max_error = compute_max_error(d, nd, b, parameters, &split_point); + if (max_error < error) { + result.push_back(b); + return; + } + } // fitting failed -- split at max error point and fit again Point center_tangent = ((d[split_point-1] - d[split_point+1])/2).normal(); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/clp.c b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/clp.c index 1555f2298d4..e5e763692c8 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/clp.c +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/clp.c @@ -2,20 +2,24 @@ /* clp.c - Complete source code for CLP. * This file is part of CLP, the command line parser package. * - * Copyright (c) 1997-2019 Eddie Kohler, ekohler@gmail.com + * Copyright (c) 1997-2023 Eddie Kohler, ekohler@gmail.com + * + * CLP is free software. It is distributed under the GNU General Public + * License, Version 2, or, alternatively and at your discretion, under the + * more permissive (BSD-like) Click LICENSE file as described below. * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, subject to the conditions - * listed in the Click LICENSE file, which is available in full at - * http://www.pdos.lcs.mit.edu/click/license.html. The conditions include: you - * must preserve this copyright notice, and you cannot mention the copyright - * holders in advertising related to the Software without their permission. - * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This - * notice is a summary of the Click LICENSE file; the license in that file is - * legally binding. */ - -#ifdef HAVE_CONFIG_H + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, subject to the + * conditions listed in the Click LICENSE file, which is available in full at + * http://github.com/kohler/click/blob/master/LICENSE. The conditions + * include: you must preserve this copyright notice, and you cannot mention + * the copyright holders in advertising related to the Software without + * their permission. The Software is provided WITHOUT ANY WARRANTY, EXPRESS + * OR IMPLIED. This notice is a summary of the Click LICENSE file; the + * license in that file is binding. */ + +#if HAVE_CONFIG_H # include <config.h> #endif #include <lcdf/clp.h> @@ -25,11 +29,23 @@ #include <assert.h> #include <stdarg.h> #include <ctype.h> +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_INTTYPES_H || !defined(HAVE_CONFIG_H) +# include <inttypes.h> +#endif -/* By default, assume we have strtoul. */ +/* By default, assume we have inttypes.h, strtoul, and uintptr_t. */ #if !defined(HAVE_STRTOUL) && !defined(HAVE_CONFIG_H) # define HAVE_STRTOUL 1 #endif +#if defined(HAVE_INTTYPES_H) || !defined(HAVE_CONFIG_H) +# include <inttypes.h> +#endif +#if !defined(HAVE_UINTPTR_T) && defined(HAVE_CONFIG_H) +typedef unsigned long uintptr_t; +#endif #ifdef __cplusplus extern "C" { @@ -39,7 +55,7 @@ extern "C" { /** @file clp.h * @brief Functions for parsing command line options. * - * The CLP functions are used to parse command line arugments into options. + * The CLP functions are used to parse command line arguments into options. * It automatically handles value parsing, error messages, long options with * minimum prefix matching, short options, and negated options. * @@ -129,10 +145,10 @@ extern "C" { /* Option types for Clp_SetOptionChar */ -#define Clp_DoubledLong (Clp_LongImplicit * 2) +#define Clp_DoubledLong (Clp_LongImplicit * 2) -#define Clp_InitialValType 8 -#define MAX_AMBIGUOUS_VALUES 4 +#define Clp_InitialValType 8 +#define MAX_AMBIGUOUS_VALUES 4 typedef struct { int val_type; @@ -157,13 +173,13 @@ typedef struct { } Clp_InternOption; -#define Clp_OptionCharsSize 5 +#define Clp_OptionCharsSize 5 typedef struct { int c; int type; } Clp_Oclass; -#define Clp_OclassSize 10 +#define Clp_OclassSize 10 typedef struct Clp_Internal { const Clp_Option *opt; @@ -222,14 +238,13 @@ struct Clp_ParserState { typedef struct Clp_StringList { - Clp_Option *items; Clp_InternOption *iopt; int nitems; - int allow_int; + unsigned char allow_int; + unsigned char val_long; int nitems_invalid_report; - } Clp_StringList; @@ -248,8 +263,8 @@ static int parse_double(Clp_Parser *, const char *, int, void *); static int parse_string_list(Clp_Parser *, const char *, int, void *); static int ambiguity_error(Clp_Parser *, int, int *, const Clp_Option *, - const Clp_InternOption *, const char *, const char *, - ...); + const Clp_InternOption *, const char *, const char *, + ...); /******* @@ -262,22 +277,22 @@ static char * encode_utf8(char *s, int n, int c) { if (c < 0 || c >= 0x110000 || (c >= 0xD800 && c <= 0xDFFF)) - c = U_REPLACEMENT; + c = U_REPLACEMENT; if (c <= 0x7F && n >= 1) - *s++ = c; + *s++ = c; else if (c <= 0x7FF && n >= 2) { - *s++ = 0xC0 | (c >> 6); - goto char1; + *s++ = 0xC0 | (c >> 6); + goto char1; } else if (c <= 0xFFFF && n >= 3) { - *s++ = 0xE0 | (c >> 12); - goto char2; + *s++ = 0xE0 | (c >> 12); + goto char2; } else if (n >= 4) { - *s++ = 0xF0 | (c >> 18); - *s++ = 0x80 | ((c >> 12) & 0x3F); + *s++ = 0xF0 | (c >> 18); + *s++ = 0x80 | ((c >> 12) & 0x3F); char2: - *s++ = 0x80 | ((c >> 6) & 0x3F); + *s++ = 0x80 | ((c >> 6) & 0x3F); char1: - *s++ = 0x80 | (c & 0x3F); + *s++ = 0x80 | (c & 0x3F); } return s; } @@ -286,48 +301,48 @@ static int decode_utf8(const char *s, const char **cp) { int c; - if ((unsigned char) *s <= 0x7F) /* 1 byte: 0x000000-0x00007F */ - c = *s++; - else if ((unsigned char) *s <= 0xC1) /* bad/overlong encoding */ - goto replacement; - else if ((unsigned char) *s <= 0xDF) { /* 2 bytes: 0x000080-0x0007FF */ - if ((s[1] & 0xC0) != 0x80) /* bad encoding */ - goto replacement; - c = (*s++ & 0x1F) << 6; - goto char1; - } else if ((unsigned char) *s <= 0xEF) { /* 3 bytes: 0x000800-0x00FFFF */ - if ((s[1] & 0xC0) != 0x80 /* bad encoding */ - || (s[2] & 0xC0) != 0x80 /* bad encoding */ - || ((unsigned char) *s == 0xE0 /* overlong encoding */ - && (s[1] & 0xE0) == 0x80) - || ((unsigned char) *s == 0xED /* encoded surrogate */ - && (s[1] & 0xE0) == 0xA0)) - goto replacement; - c = (*s++ & 0x0F) << 12; - goto char2; - } else if ((unsigned char) *s <= 0xF4) { /* 4 bytes: 0x010000-0x10FFFF */ - if ((s[1] & 0xC0) != 0x80 /* bad encoding */ - || (s[2] & 0xC0) != 0x80 /* bad encoding */ - || (s[3] & 0xC0) != 0x80 /* bad encoding */ - || ((unsigned char) *s == 0xF0 /* overlong encoding */ - && (s[1] & 0xF0) == 0x80) - || ((unsigned char) *s == 0xF4 /* encoded value > 0x10FFFF */ - && (unsigned char) s[1] >= 0x90)) - goto replacement; - c = (*s++ & 0x07) << 18; - c += (*s++ & 0x3F) << 12; + if ((unsigned char) *s <= 0x7F) /* 1 byte: 0x000000-0x00007F */ + c = *s++; + else if ((unsigned char) *s <= 0xC1) /* bad/overlong encoding */ + goto replacement; + else if ((unsigned char) *s <= 0xDF) { /* 2 bytes: 0x000080-0x0007FF */ + if ((s[1] & 0xC0) != 0x80) /* bad encoding */ + goto replacement; + c = (*s++ & 0x1F) << 6; + goto char1; + } else if ((unsigned char) *s <= 0xEF) { /* 3 bytes: 0x000800-0x00FFFF */ + if ((s[1] & 0xC0) != 0x80 /* bad encoding */ + || (s[2] & 0xC0) != 0x80 /* bad encoding */ + || ((unsigned char) *s == 0xE0 /* overlong encoding */ + && (s[1] & 0xE0) == 0x80) + || ((unsigned char) *s == 0xED /* encoded surrogate */ + && (s[1] & 0xE0) == 0xA0)) + goto replacement; + c = (*s++ & 0x0F) << 12; + goto char2; + } else if ((unsigned char) *s <= 0xF4) { /* 4 bytes: 0x010000-0x10FFFF */ + if ((s[1] & 0xC0) != 0x80 /* bad encoding */ + || (s[2] & 0xC0) != 0x80 /* bad encoding */ + || (s[3] & 0xC0) != 0x80 /* bad encoding */ + || ((unsigned char) *s == 0xF0 /* overlong encoding */ + && (s[1] & 0xF0) == 0x80) + || ((unsigned char) *s == 0xF4 /* encoded value > 0x10FFFF */ + && (unsigned char) s[1] >= 0x90)) + goto replacement; + c = (*s++ & 0x07) << 18; + c += (*s++ & 0x3F) << 12; char2: - c += (*s++ & 0x3F) << 6; + c += (*s++ & 0x3F) << 6; char1: - c += (*s++ & 0x3F); + c += (*s++ & 0x3F); } else { replacement: - c = U_REPLACEMENT; - for (s++; (*s & 0xC0) == 0x80; s++) - /* nothing */; + c = U_REPLACEMENT; + for (s++; (*s & 0xC0) == 0x80; s++) + /* nothing */; } if (cp) - *cp = s; + *cp = s; return c; } @@ -353,88 +368,88 @@ clp_utf8_charlen(const Clp_Internal *cli, const char *s) static int min_different_chars(const char *s, const char *t) /* Returns the minimum number of bytes required to distinguish - s from t. - If s is shorter than t, returns strlen(s). */ + s from t. + If s is shorter than t, returns strlen(s). */ { const char *sfirst = s; while (*s && *t && *s == *t) - s++, t++; + s++, t++; if (!*s) - return s - sfirst; + return s - sfirst; else - return s - sfirst + 1; + return s - sfirst + 1; } static int long_as_short(const Clp_Internal *cli, const Clp_Option *o, - Clp_InternOption *io, int failure) + Clp_InternOption *io, int failure) { if ((cli->long1pos || cli->long1neg) && io->ilong) { - const char *name = o->long_name + io->ilongoff; - if (cli->utf8) { - int c = decode_utf8(name, &name); - if (!*name && c && c != U_REPLACEMENT) - return c; - } else if (name[0] && !name[1]) - return (unsigned char) name[0]; + const char *name = o->long_name + io->ilongoff; + if (cli->utf8) { + int c = decode_utf8(name, &name); + if (!*name && c && c != U_REPLACEMENT) + return c; + } else if (name[0] && !name[1]) + return (unsigned char) name[0]; } return failure; } static void compare_options(Clp_Parser *clp, const Clp_Option *o1, Clp_InternOption *io1, - const Clp_Option *o2, Clp_InternOption *io2) + const Clp_Option *o2, Clp_InternOption *io2) { Clp_Internal *cli = clp->internal; int short1, shortx1; /* ignore meaningless combinations */ if ((!io1->ishort && !io1->ilong) || (!io2->ishort && !io2->ilong) - || !((io1->ipos && io2->ipos) || (io1->ineg && io2->ineg)) - || o1->option_id == o2->option_id) - return; + || !((io1->ipos && io2->ipos) || (io1->ineg && io2->ineg)) + || o1->option_id == o2->option_id) + return; /* look for duplication of short options */ short1 = (io1->ishort ? o1->short_name : -1); shortx1 = long_as_short(cli, o1, io1, -2); if (short1 >= 0 || shortx1 >= 0) { - int short2 = (io2->ishort ? o2->short_name : -3); - int shortx2 = long_as_short(cli, o2, io2, -4); - if (short1 == short2) - Clp_OptionError(clp, "CLP internal error: more than 1 option has short name %<%c%>", short1); - else if ((short1 == shortx2 || shortx1 == short2 || shortx1 == shortx2) - && ((io1->ipos && io2->ipos && cli->long1pos) - || (io1->ineg && io2->ineg && cli->long1neg))) - Clp_OptionError(clp, "CLP internal error: 1-char long name conflicts with short name %<%c%>", (short1 == shortx2 ? shortx2 : shortx1)); + int short2 = (io2->ishort ? o2->short_name : -3); + int shortx2 = long_as_short(cli, o2, io2, -4); + if (short1 == short2) + Clp_OptionError(clp, "CLP internal error: more than 1 option has short name %<%c%>", short1); + else if ((short1 == shortx2 || shortx1 == short2 || shortx1 == shortx2) + && ((io1->ipos && io2->ipos && cli->long1pos) + || (io1->ineg && io2->ineg && cli->long1neg))) + Clp_OptionError(clp, "CLP internal error: 1-char long name conflicts with short name %<%c%>", (short1 == shortx2 ? shortx2 : shortx1)); } /* analyze longest minimum match */ if (io1->ilong) { - const char *name1 = o1->long_name + io1->ilongoff; - - /* long name's first character matches short name */ - if (io2->ishort && !io1->iprefmatch) { - int name1char = (cli->utf8 ? decode_utf8(name1, 0) : (unsigned char) *name1); - if (name1char == o2->short_name) { - if (io1->ipos && io2->ipos) - io1->lmmpos_short = 1; - if (io1->ineg && io2->ineg) - io1->lmmneg_short = 1; - } - } - - /* match long name to long name */ - if (io2->ilong) { - const char *name2 = o2->long_name + io2->ilongoff; - if (strcmp(name1, name2) == 0) - Clp_OptionError(clp, "CLP internal error: duplicate long name %<%s%>", name1); - if (io1->ipos && io2->ipos && !strncmp(name1, name2, io1->lmmpos) - && (!io1->iprefmatch || strncmp(name1, name2, strlen(name1)))) - io1->lmmpos = min_different_chars(name1, name2); - if (io1->ineg && io2->ineg && !strncmp(name1, name2, io1->lmmneg) - && (!io1->iprefmatch || strncmp(name1, name2, strlen(name1)))) - io1->lmmneg = min_different_chars(name1, name2); - } + const char *name1 = o1->long_name + io1->ilongoff; + + /* long name's first character matches short name */ + if (io2->ishort && !io1->iprefmatch) { + int name1char = (cli->utf8 ? decode_utf8(name1, 0) : (unsigned char) *name1); + if (name1char == o2->short_name) { + if (io1->ipos && io2->ipos) + io1->lmmpos_short = 1; + if (io1->ineg && io2->ineg) + io1->lmmneg_short = 1; + } + } + + /* match long name to long name */ + if (io2->ilong) { + const char *name2 = o2->long_name + io2->ilongoff; + if (strcmp(name1, name2) == 0) + Clp_OptionError(clp, "CLP internal error: duplicate long name %<%s%>", name1); + if (io1->ipos && io2->ipos && !strncmp(name1, name2, io1->lmmpos) + && (!io1->iprefmatch || strncmp(name1, name2, strlen(name1)))) + io1->lmmpos = min_different_chars(name1, name2); + if (io1->ineg && io2->ineg && !strncmp(name1, name2, io1->lmmneg) + && (!io1->iprefmatch || strncmp(name1, name2, strlen(name1)))) + io1->lmmneg = min_different_chars(name1, name2); + } } } @@ -443,10 +458,10 @@ calculate_lmm(Clp_Parser *clp, const Clp_Option *opt, Clp_InternOption *iopt, in { int i, j; for (i = 0; i < nopt; ++i) { - iopt[i].lmmpos = iopt[i].lmmneg = 1; - iopt[i].lmmpos_short = iopt[i].lmmneg_short = 0; - for (j = 0; j < nopt; ++j) - compare_options(clp, &opt[i], &iopt[i], &opt[j], &iopt[j]); + iopt[i].lmmpos = iopt[i].lmmneg = 1; + iopt[i].lmmpos_short = iopt[i].lmmneg_short = 0; + for (j = 0; j < nopt; ++j) + compare_options(clp, &opt[i], &iopt[i], &opt[j], &iopt[j]); } } @@ -471,7 +486,8 @@ calculate_lmm(Clp_Parser *clp, const Clp_Option *opt, Clp_InternOption *iopt, in * one of the substrings "UTF-8", "UTF8", or "utf8". Override this with * Clp_SetUTF8().</li> * <li>The Clp_ValString, Clp_ValStringNotOption, Clp_ValInt, Clp_ValUnsigned, - * Clp_ValBool, and Clp_ValDouble types are installed.</li> + * Clp_ValLong, Clp_ValUnsignedLong, Clp_ValBool, and Clp_ValDouble types are + * installed.</li> * <li>Errors are reported to standard error.</li> * </ul> * @@ -492,9 +508,9 @@ Clp_NewParser(int argc, const char * const *argv, int nopt, const Clp_Option *op Clp_Internal *cli = (Clp_Internal *)malloc(sizeof(Clp_Internal)); Clp_InternOption *iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * nopt); if (cli) - cli->valtype = (Clp_ValType *)malloc(sizeof(Clp_ValType) * Clp_InitialValType); + cli->valtype = (Clp_ValType *)malloc(sizeof(Clp_ValType) * Clp_InitialValType); if (!clp || !cli || !iopt || !cli->valtype) - goto failed; + goto failed; clp->option = &clp_option_sentinel[-Clp_Done]; clp->negated = 0; @@ -511,19 +527,19 @@ Clp_NewParser(int argc, const char * const *argv, int nopt, const Clp_Option *op /* Assign program name (now so we can call Clp_OptionError) */ if (argc > 0) { - const char *slash = strrchr(argv[0], '/'); - cli->program_name = slash ? slash + 1 : argv[0]; + const char *slash = strrchr(argv[0], '/'); + cli->program_name = slash ? slash + 1 : argv[0]; } else - cli->program_name = 0; + cli->program_name = 0; /* Assign arguments, skipping program name */ Clp_SetArguments(clp, argc - 1, argv + 1); /* Initialize UTF-8 status and option classes */ { - char *s = getenv("LANG"); - cli->utf8 = (s && (strstr(s, "UTF-8") != 0 || strstr(s, "UTF8") != 0 - || strstr(s, "utf8") != 0)); + char *s = getenv("LANG"); + cli->utf8 = (s && (strstr(s, "UTF-8") != 0 || strstr(s, "UTF8") != 0 + || strstr(s, "utf8") != 0)); } cli->oclass[0].c = '-'; cli->oclass[0].type = Clp_Short; @@ -534,8 +550,10 @@ Clp_NewParser(int argc, const char * const *argv, int nopt, const Clp_Option *op cli->nvaltype = 0; Clp_AddType(clp, Clp_ValString, 0, parse_string, 0); Clp_AddType(clp, Clp_ValStringNotOption, Clp_DisallowOptions, parse_string, 0); - Clp_AddType(clp, Clp_ValInt, 0, parse_int, 0); - Clp_AddType(clp, Clp_ValUnsigned, 0, parse_int, (void *)cli); + Clp_AddType(clp, Clp_ValInt, 0, parse_int, (void*) (uintptr_t) 0); + Clp_AddType(clp, Clp_ValUnsigned, 0, parse_int, (void*) (uintptr_t) 1); + Clp_AddType(clp, Clp_ValLong, 0, parse_int, (void*) (uintptr_t) 2); + Clp_AddType(clp, Clp_ValUnsignedLong, 0, parse_int, (void*) (uintptr_t) 3); Clp_AddType(clp, Clp_ValBool, 0, parse_bool, 0); Clp_AddType(clp, Clp_ValDouble, 0, parse_double, 0); @@ -546,13 +564,13 @@ Clp_NewParser(int argc, const char * const *argv, int nopt, const Clp_Option *op failed: if (cli && cli->valtype) - free(cli->valtype); + free(cli->valtype); if (cli) - free(cli); + free(cli); if (clp) - free(clp); + free(clp); if (iopt) - free(iopt); + free(iopt); return 0; } @@ -565,18 +583,18 @@ Clp_DeleteParser(Clp_Parser *clp) int i; Clp_Internal *cli; if (!clp) - return; + return; cli = clp->internal; /* get rid of any string list types */ for (i = 0; i < cli->nvaltype; i++) - if (cli->valtype[i].func == parse_string_list) { - Clp_StringList *clsl = (Clp_StringList *)cli->valtype[i].user_data; - free(clsl->items); - free(clsl->iopt); - free(clsl); - } + if (cli->valtype[i].func == parse_string_list) { + Clp_StringList *clsl = (Clp_StringList *)cli->valtype[i].user_data; + free(clsl->items); + free(clsl->iopt); + free(clsl); + } free(cli->valtype); free(cli->iopt); @@ -638,10 +656,10 @@ Clp_OptionChar(Clp_Parser *clp, int c) Clp_Internal *cli = clp->internal; int i, oclass = 0; if (cli->noclass > 0 && cli->oclass[0].c == 0) - oclass = cli->oclass[0].type; + oclass = cli->oclass[0].type; for (i = 0; i < cli->noclass; ++i) - if (cli->oclass[i].c == c) - oclass = cli->oclass[i].type; + if (cli->oclass[i].c == c) + oclass = cli->oclass[i].type; return oclass; } @@ -698,41 +716,41 @@ Clp_SetOptionChar(Clp_Parser *clp, int c, int type) Clp_Internal *cli = clp->internal; if (type != Clp_NotOption && type != Clp_Short && type != Clp_Long - && type != Clp_ShortNegated && type != Clp_LongNegated - && type != Clp_LongImplicit && type != (Clp_Short | Clp_Long) - && type != (Clp_ShortNegated | Clp_LongNegated)) - return -1; + && type != Clp_ShortNegated && type != Clp_LongNegated + && type != Clp_LongImplicit && type != (Clp_Short | Clp_Long) + && type != (Clp_ShortNegated | Clp_LongNegated)) + return -1; if (c < 0 || c >= (cli->utf8 ? 0x110000 : 256)) - return -1; + return -1; if (c == 0) - cli->noclass = 0; + cli->noclass = 0; for (i = 0; i < cli->noclass; ++i) - if (cli->oclass[i].c == c) - break; + if (cli->oclass[i].c == c) + break; if (i == Clp_OclassSize) - return -1; + return -1; cli->oclass[i].c = c; cli->oclass[i].type = type; if (cli->noclass == i) - cli->noclass = i + 1; + cli->noclass = i + 1; long1pos = long1neg = 0; for (i = 0; i < cli->noclass; ++i) { - if ((cli->oclass[i].type & Clp_Short) - && (cli->oclass[i].type & Clp_Long)) - long1pos = 1; - if ((cli->oclass[i].type & Clp_ShortNegated) - && (cli->oclass[i].type & Clp_LongNegated)) - long1neg = 1; + if ((cli->oclass[i].type & Clp_Short) + && (cli->oclass[i].type & Clp_Long)) + long1pos = 1; + if ((cli->oclass[i].type & Clp_ShortNegated) + && (cli->oclass[i].type & Clp_LongNegated)) + long1neg = 1; } if (long1pos != cli->long1pos || long1neg != cli->long1neg) { - /* Must recheck option set */ - cli->long1pos = long1pos; - cli->long1neg = long1neg; - calculate_lmm(clp, cli->opt, cli->iopt, cli->nopt); + /* Must recheck option set */ + cli->long1pos = long1pos; + cli->long1neg = long1neg; + calculate_lmm(clp, cli->opt, cli->iopt, cli->nopt); } return old; @@ -774,11 +792,11 @@ Clp_SetOptions(Clp_Parser *clp, int nopt, const Clp_Option *opt) static unsigned opt_generation = 0; if (nopt > cli->nopt) { - iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * nopt); - if (!iopt) - return -1; - free(cli->iopt); - cli->iopt = iopt; + iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * nopt); + if (!iopt) + return -1; + free(cli->iopt); + cli->iopt = iopt; } cli->opt = opt; @@ -788,42 +806,44 @@ Clp_SetOptions(Clp_Parser *clp, int nopt, const Clp_Option *opt) cli->current_option = -1; /* Massage the options to make them usable */ - for (i = 0; i < nopt; i++) { - /* Ignore negative option_ids, which are internal to CLP */ - if (opt[i].option_id < 0) { - Clp_OptionError(clp, "CLP internal error: option %d has negative option_id", i); - iopt[i].ilong = iopt[i].ishort = iopt[i].ipos = iopt[i].ineg = 0; - continue; - } - - /* Set flags based on input flags */ - iopt[i].ilong = (opt[i].long_name != 0 && opt[i].long_name[0] != 0); - iopt[i].ishort = (opt[i].short_name > 0 - && opt[i].short_name < (cli->utf8 ? 0x110000 : 256)); - iopt[i].ipos = 1; - iopt[i].ineg = (opt[i].flags & Clp_Negate) != 0; - iopt[i].imandatory = (opt[i].flags & Clp_Mandatory) != 0; - iopt[i].ioptional = (opt[i].flags & Clp_Optional) != 0; - iopt[i].iprefmatch = (opt[i].flags & Clp_PreferredMatch) != 0; - iopt[i].ilongoff = 0; - - /* Enforce invariants */ - if (opt[i].val_type <= 0) - iopt[i].imandatory = iopt[i].ioptional = 0; - if (opt[i].val_type > 0 && !iopt[i].ioptional) - iopt[i].imandatory = 1; - - /* Options that start with 'no-' should be changed to OnlyNegated */ - if (iopt[i].ilong && strncmp(opt[i].long_name, "no-", 3) == 0) { - iopt[i].ipos = 0; - iopt[i].ineg = 1; - iopt[i].ilongoff = 3; - if (strncmp(opt[i].long_name + 3, "no-", 3) == 0) - Clp_OptionError(clp, "CLP internal error: option %d begins with \"no-no-\"", i); - } else if (opt[i].flags & Clp_OnlyNegated) { - iopt[i].ipos = 0; - iopt[i].ineg = 1; - } + for (i = 0; i < nopt; ++i) { + memset(&iopt[i], 0, sizeof(iopt[i])); + + /* Ignore negative option_ids, which are internal to CLP */ + if (opt[i].option_id < 0) { + Clp_OptionError(clp, "CLP internal error: option %d has negative option_id", i); + iopt[i].ilong = iopt[i].ishort = iopt[i].ipos = iopt[i].ineg = 0; + continue; + } + + /* Set flags based on input flags */ + iopt[i].ilong = (opt[i].long_name != 0 && opt[i].long_name[0] != 0); + iopt[i].ishort = (opt[i].short_name > 0 + && opt[i].short_name < (cli->utf8 ? 0x110000 : 256)); + iopt[i].ipos = 1; + iopt[i].ineg = (opt[i].flags & Clp_Negate) != 0; + iopt[i].imandatory = (opt[i].flags & Clp_Mandatory) != 0; + iopt[i].ioptional = (opt[i].flags & Clp_Optional) != 0; + iopt[i].iprefmatch = (opt[i].flags & Clp_PreferredMatch) != 0; + iopt[i].ilongoff = 0; + + /* Enforce invariants */ + if (opt[i].val_type <= 0) + iopt[i].imandatory = iopt[i].ioptional = 0; + if (opt[i].val_type > 0 && !iopt[i].ioptional) + iopt[i].imandatory = 1; + + /* Options that start with 'no-' should be changed to OnlyNegated */ + if (iopt[i].ilong && strncmp(opt[i].long_name, "no-", 3) == 0) { + iopt[i].ipos = 0; + iopt[i].ineg = 1; + iopt[i].ilongoff = 3; + if (strncmp(opt[i].long_name + 3, "no-", 3) == 0) + Clp_OptionError(clp, "CLP internal error: option %d begins with \"no-no-\"", i); + } else if (opt[i].flags & Clp_OnlyNegated) { + iopt[i].ipos = 0; + iopt[i].ineg = 1; + } } /* Check option set */ @@ -891,18 +911,18 @@ Clp_SetOptionProcessing(Clp_Parser *clp, int on) static int argcmp(const char *ref, const char *arg, int min_match, int fewer_dashes) /* Returns 0 if ref and arg don't match. - Returns -1 if ref and arg match, but fewer than min_match characters. - Returns len if ref and arg match min_match or more characters; - len is the number of characters that matched in arg. - Allows arg to contain fewer dashes than ref iff fewer_dashes != 0. - - Examples: - argcmp("x", "y", 1, 0) --> 0 / just plain wrong - argcmp("a", "ax", 1, 0) --> 0 / ...even though min_match == 1 - and the 1st chars match - argcmp("box", "bo", 3, 0) --> -1 / ambiguous - argcmp("cat", "c=3", 1, 0) --> 1 / handles = arguments - */ + Returns -1 if ref and arg match, but fewer than min_match characters. + Returns len if ref and arg match min_match or more characters; + len is the number of characters that matched in arg. + Allows arg to contain fewer dashes than ref iff fewer_dashes != 0. + + Examples: + argcmp("x", "y", 1, 0) --> 0 / just plain wrong + argcmp("a", "ax", 1, 0) --> 0 / ...even though min_match == 1 + and the 1st chars match + argcmp("box", "bo", 3, 0) --> -1 / ambiguous + argcmp("cat", "c=3", 1, 0) --> 1 / handles = arguments + */ { const char *refstart = ref; const char *argstart = arg; @@ -910,27 +930,27 @@ argcmp(const char *ref, const char *arg, int min_match, int fewer_dashes) compare: while (*ref && *arg && *arg != '=' && *ref == *arg) - ref++, arg++; + ref++, arg++; /* Allow arg to contain fewer dashes than ref */ if (fewer_dashes && *ref == '-' && ref[1] && ref[1] == *arg) { - ref++; - goto compare; + ref++; + goto compare; } if (*arg && *arg != '=') - return 0; + return 0; else if (ref - refstart < min_match) - return -1; + return -1; else - return arg - argstart; + return arg - argstart; } static int find_prefix_opt(Clp_Parser *clp, const char *arg, - int nopt, const Clp_Option *opt, - const Clp_InternOption *iopt, - int *ambiguous, int *ambiguous_values) + int nopt, const Clp_Option *opt, + const Clp_InternOption *iopt, + int *ambiguous, int *ambiguous_values) /* Looks for an unambiguous match of 'arg' against one of the long options in 'opt'. Returns positive if it finds one; otherwise, returns -1 and possibly changes 'ambiguous' and 'ambiguous_values' to keep @@ -942,28 +962,28 @@ find_prefix_opt(Clp_Parser *clp, const char *arg, retry: for (i = 0; i < nopt; i++) { - int len, lmm; - if (!iopt[i].ilong || (negated ? !iopt[i].ineg : !iopt[i].ipos)) - continue; - - lmm = (negated ? iopt[i].lmmneg : iopt[i].lmmpos); - if (clp && clp->internal->could_be_short - && (negated ? iopt[i].lmmneg_short : iopt[i].lmmpos_short)) - lmm = (first_charlen >= lmm ? first_charlen + 1 : lmm); - len = argcmp(opt[i].long_name + iopt[i].ilongoff, arg, lmm, fewer_dashes); - if (len > 0) - return i; - else if (len < 0) { - if (*ambiguous < MAX_AMBIGUOUS_VALUES) - ambiguous_values[*ambiguous] = i; - (*ambiguous)++; - } + int len, lmm; + if (!iopt[i].ilong || (negated ? !iopt[i].ineg : !iopt[i].ipos)) + continue; + + lmm = (negated ? iopt[i].lmmneg : iopt[i].lmmpos); + if (clp && clp->internal->could_be_short + && (negated ? iopt[i].lmmneg_short : iopt[i].lmmpos_short)) + lmm = (first_charlen >= lmm ? first_charlen + 1 : lmm); + len = argcmp(opt[i].long_name + iopt[i].ilongoff, arg, lmm, fewer_dashes); + if (len > 0) + return i; + else if (len < 0) { + if (*ambiguous < MAX_AMBIGUOUS_VALUES) + ambiguous_values[*ambiguous] = i; + (*ambiguous)++; + } } /* If there were no partial matches, try again with fewer_dashes true */ if (*ambiguous == first_ambiguous && !fewer_dashes) { - fewer_dashes = 1; - goto retry; + fewer_dashes = 1; + goto retry; } return -1; @@ -979,13 +999,13 @@ val_type_binsearch(Clp_Internal *cli, int val_type) { unsigned l = 0, r = cli->nvaltype; while (l < r) { - unsigned m = l + (r - l) / 2; - if (cli->valtype[m].val_type == val_type) - return m; - else if (cli->valtype[m].val_type < val_type) - l = m + 1; - else - r = m; + unsigned m = l + (r - l) / 2; + if (cli->valtype[m].val_type == val_type) + return m; + else if (cli->valtype[m].val_type < val_type) + l = m + 1; + else + r = m; } return l; } @@ -1023,35 +1043,35 @@ val_type_binsearch(Clp_Internal *cli, int val_type) */ int Clp_AddType(Clp_Parser *clp, int val_type, int flags, - Clp_ValParseFunc parser, void *user_data) + Clp_ValParseFunc parser, void *user_data) { Clp_Internal *cli = clp->internal; int vtpos; if (val_type <= 0 || !parser) - return -1; + return -1; vtpos = val_type_binsearch(cli, val_type); if (vtpos == cli->nvaltype || cli->valtype[vtpos].val_type != val_type) { - if (cli->nvaltype != 0 && (cli->nvaltype % Clp_InitialValType) == 0) { - Clp_ValType *new_valtype = - (Clp_ValType *) realloc(cli->valtype, sizeof(Clp_ValType) * (cli->nvaltype + Clp_InitialValType)); - if (!new_valtype) - return -1; - cli->valtype = new_valtype; - } - memmove(&cli->valtype[vtpos + 1], &cli->valtype[vtpos], - sizeof(Clp_ValType) * (cli->nvaltype - vtpos)); - cli->nvaltype++; - cli->valtype[vtpos].func = 0; + if (cli->nvaltype != 0 && (cli->nvaltype % Clp_InitialValType) == 0) { + Clp_ValType *new_valtype = + (Clp_ValType *) realloc(cli->valtype, sizeof(Clp_ValType) * (cli->nvaltype + Clp_InitialValType)); + if (!new_valtype) + return -1; + cli->valtype = new_valtype; + } + memmove(&cli->valtype[vtpos + 1], &cli->valtype[vtpos], + sizeof(Clp_ValType) * (cli->nvaltype - vtpos)); + cli->nvaltype++; + cli->valtype[vtpos].func = 0; } if (cli->valtype[vtpos].func == parse_string_list) { - Clp_StringList *clsl = (Clp_StringList *) cli->valtype[vtpos].user_data; - free(clsl->items); - free(clsl->iopt); - free(clsl); + Clp_StringList *clsl = (Clp_StringList *) cli->valtype[vtpos].user_data; + free(clsl->items); + free(clsl->iopt); + free(clsl); } cli->valtype[vtpos].val_type = val_type; @@ -1075,33 +1095,38 @@ parse_string(Clp_Parser *clp, const char *arg, int complain, void *user_data) } static int -parse_int(Clp_Parser *clp, const char *arg, int complain, void *user_data) +parse_int(Clp_Parser* clp, const char* arg, int complain, void* user_data) { const char *val; + uintptr_t type = (uintptr_t) user_data; if (*arg == 0 || isspace((unsigned char) *arg) - || (user_data != 0 && *arg == '-')) - val = arg; - else if (user_data != 0) { /* unsigned */ + || ((type & 1) && *arg == '-')) + val = arg; + else if (type & 1) { /* unsigned */ #if HAVE_STRTOUL - clp->val.u = strtoul(arg, (char **) &val, 0); + clp->val.ul = strtoul(arg, (char **) &val, 0); #else - /* don't bother really trying to do it right */ - if (arg[0] == '-') - val = arg; - else - clp->val.u = strtol(arg, (char **) &val, 0); + /* don't bother really trying to do it right */ + if (arg[0] == '-') + val = arg; + else + clp->val.l = strtol(arg, (char **) &val, 0); #endif } else - clp->val.i = strtol(arg, (char **) &val, 0); + clp->val.l = strtol(arg, (char **) &val, 0); + if (type <= 1) + clp->val.u = (unsigned) clp->val.ul; if (*arg != 0 && *val == 0) - return 1; - else if (complain) { - const char *message = user_data != 0 - ? "%<%O%> expects a nonnegative integer, not %<%s%>" - : "%<%O%> expects an integer, not %<%s%>"; - return Clp_OptionError(clp, message, arg); - } else - return 0; + return 1; + else { + if (complain) { + const char *message = (type & 1) + ? "%<%O%> expects a nonnegative integer, not %<%s%>" + : "%<%O%> expects an integer, not %<%s%>"; + Clp_OptionError(clp, message, arg); + } + return 0; + } } static int @@ -1110,15 +1135,16 @@ parse_double(Clp_Parser *clp, const char *arg, int complain, void *user_data) const char *val; (void)user_data; if (*arg == 0 || isspace((unsigned char) *arg)) - val = arg; + val = arg; else - clp->val.d = strtod(arg, (char **) &val); + clp->val.d = strtod(arg, (char **) &val); if (*arg != 0 && *val == 0) - return 1; - else if (complain) - return Clp_OptionError(clp, "%<%O%> expects a real number, not %<%s%>", arg); - else - return 0; + return 1; + else { + if (complain) + Clp_OptionError(clp, "%<%O%> expects a real number, not %<%s%>", arg); + return 0; + } } static int @@ -1128,27 +1154,27 @@ parse_bool(Clp_Parser *clp, const char *arg, int complain, void *user_data) char lcarg[6]; (void)user_data; if (strlen(arg) > 5 || strchr(arg, '=') != 0) - goto error; + goto error; for (i = 0; arg[i] != 0; i++) - lcarg[i] = tolower((unsigned char) arg[i]); + lcarg[i] = tolower((unsigned char) arg[i]); lcarg[i] = 0; if (argcmp("yes", lcarg, 1, 0) > 0 - || argcmp("true", lcarg, 1, 0) > 0 - || argcmp("1", lcarg, 1, 0) > 0) { - clp->val.i = 1; - return 1; + || argcmp("true", lcarg, 1, 0) > 0 + || argcmp("1", lcarg, 1, 0) > 0) { + clp->val.i = 1; + return 1; } else if (argcmp("no", lcarg, 1, 0) > 0 - || argcmp("false", lcarg, 1, 0) > 0 - || argcmp("1", lcarg, 1, 0) > 0) { - clp->val.i = 0; - return 1; + || argcmp("false", lcarg, 1, 0) > 0 + || argcmp("1", lcarg, 1, 0) > 0) { + clp->val.i = 0; + return 1; } error: if (complain) - Clp_OptionError(clp, "%<%O%> expects a true-or-false value, not %<%s%>", arg); + Clp_OptionError(clp, "%<%O%> expects a true-or-false value, not %<%s%>", arg); return 0; } @@ -1166,70 +1192,73 @@ parse_string_list(Clp_Parser *clp, const char *arg, int complain, void *user_dat /* actually look for a string value */ idx = find_prefix_opt - (0, arg, sl->nitems, sl->items, sl->iopt, - &ambiguous, ambiguous_values); + (0, arg, sl->nitems, sl->items, sl->iopt, + &ambiguous, ambiguous_values); if (idx >= 0) { - clp->val.i = sl->items[idx].option_id; - return 1; + clp->val.i = sl->items[idx].option_id; + if (sl->val_long) + clp->val.l = clp->val.i; + return 1; } if (sl->allow_int) { - if (parse_int(clp, arg, 0, 0)) - return 1; + if (parse_int(clp, arg, 0, (void*) (uintptr_t) (sl->val_long ? 2 : 0))) + return 1; } if (complain) { - const char *complaint = (ambiguous ? "ambiguous" : "invalid"); - if (!ambiguous) { - ambiguous = sl->nitems_invalid_report; - for (idx = 0; idx < ambiguous; idx++) - ambiguous_values[idx] = idx; - } - return ambiguity_error - (clp, ambiguous, ambiguous_values, sl->items, sl->iopt, - "", "option %<%O%> value %<%s%> is %s", arg, complaint); + const char *complaint = (ambiguous ? "ambiguous" : "invalid"); + if (!ambiguous) { + ambiguous = sl->nitems_invalid_report; + for (idx = 0; idx < ambiguous; idx++) + ambiguous_values[idx] = idx; + } + return ambiguity_error + (clp, ambiguous, ambiguous_values, sl->items, sl->iopt, + "", "option %<%V%> is %s", complaint); } else - return 0; + return 0; } static int finish_string_list(Clp_Parser *clp, int val_type, int flags, - Clp_Option *items, int nitems, int itemscap) + Clp_Option *items, int nitems, int itemscap) { int i; Clp_StringList *clsl = (Clp_StringList *)malloc(sizeof(Clp_StringList)); Clp_InternOption *iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * nitems); if (!clsl || !iopt) - goto error; + goto error; clsl->items = items; clsl->iopt = iopt; clsl->nitems = nitems; clsl->allow_int = (flags & Clp_AllowNumbers) != 0; + clsl->val_long = (flags & Clp_StringListLong) != 0; if (nitems < MAX_AMBIGUOUS_VALUES && nitems < itemscap && clsl->allow_int) { - items[nitems].long_name = "any integer"; - clsl->nitems_invalid_report = nitems + 1; + items[nitems].long_name = "any integer"; + clsl->nitems_invalid_report = nitems + 1; } else if (nitems > MAX_AMBIGUOUS_VALUES + 1) - clsl->nitems_invalid_report = MAX_AMBIGUOUS_VALUES + 1; + clsl->nitems_invalid_report = MAX_AMBIGUOUS_VALUES + 1; else - clsl->nitems_invalid_report = nitems; + clsl->nitems_invalid_report = nitems; for (i = 0; i < nitems; i++) { - iopt[i].ilong = iopt[i].ipos = 1; - iopt[i].ishort = iopt[i].ineg = iopt[i].ilongoff = iopt[i].iprefmatch = 0; + iopt[i].ilong = iopt[i].ipos = 1; + iopt[i].ishort = iopt[i].ineg = iopt[i].ilongoff = iopt[i].iprefmatch = 0; } calculate_lmm(clp, items, iopt, nitems); if (Clp_AddType(clp, val_type, 0, parse_string_list, clsl) >= 0) - return 0; + return 0; error: if (clsl) - free(clsl); + free(clsl); if (iopt) - free(iopt); + free(iopt); return -1; } @@ -1269,39 +1298,44 @@ Clp_AddStringListType(Clp_Parser *clp, int val_type, int flags, ...) va_start(val, flags); if (!items) - goto error; + goto error; /* slurp up the arguments */ while (1) { - int value; - char *name = va_arg(val, char *); - if (!name) - break; - value = va_arg(val, int); - - if (nitems >= itemscap) { - Clp_Option *new_items; - itemscap *= 2; - new_items = (Clp_Option *)realloc(items, sizeof(Clp_Option) * itemscap); - if (!new_items) - goto error; - items = new_items; - } - - items[nitems].long_name = name; - items[nitems].option_id = value; - items[nitems].flags = 0; - nitems++; + int value; + char *name = va_arg(val, char *); + if (!name) + break; + if (flags & Clp_StringListLong) { + long lvalue = va_arg(val, long); + value = (int) lvalue; + assert(value == lvalue); + } else + value = va_arg(val, int); + + if (nitems >= itemscap) { + Clp_Option *new_items; + itemscap *= 2; + new_items = (Clp_Option *)realloc(items, sizeof(Clp_Option) * itemscap); + if (!new_items) + goto error; + items = new_items; + } + + items[nitems].long_name = name; + items[nitems].option_id = value; + items[nitems].flags = 0; + nitems++; } va_end(val); if (finish_string_list(clp, val_type, flags, items, nitems, itemscap) >= 0) - return 0; + return 0; error: va_end(val); if (items) - free(items); + free(items); return -1; } @@ -1344,30 +1378,30 @@ Clp_AddStringListType(Clp_Parser *clp, int val_type, int flags, ...) */ int Clp_AddStringListTypeVec(Clp_Parser *clp, int val_type, int flags, - int nstrs, const char * const *strs, - const int *vals) + int nstrs, const char * const *strs, + const int *vals) /* An alternate way to make a string list type. See Clp_AddStringListType - for the basics; this coalesces the strings and values into two arrays, - rather than spreading them out into a variable argument list. */ + for the basics; this coalesces the strings and values into two arrays, + rather than spreading them out into a variable argument list. */ { int i; int itemscap = (nstrs < 5 ? 5 : nstrs); Clp_Option *items = (Clp_Option *)malloc(sizeof(Clp_Option) * itemscap); if (!items) - return -1; + return -1; /* copy over items */ for (i = 0; i < nstrs; i++) { - items[i].long_name = strs[i]; - items[i].option_id = vals[i]; - items[i].flags = 0; + items[i].long_name = strs[i]; + items[i].option_id = vals[i]; + items[i].flags = 0; } if (finish_string_list(clp, val_type, flags, items, nstrs, itemscap) >= 0) - return 0; + return 0; else { - free(items); - return -1; + free(items); + return -1; } } @@ -1421,17 +1455,17 @@ Clp_NewParserState(void) { Clp_ParserState *state = (Clp_ParserState *)malloc(sizeof(Clp_ParserState)); if (state) { - state->argv = 0; - state->argc = 0; - state->option_chars[0] = 0; - state->xtext = 0; - state->option_processing = 0; - state->opt_generation = 0; - state->current_option = -1; - state->is_short = 0; - state->whole_negated = 0; - state->current_short = 0; - state->negated_by_no = 0; + state->argv = 0; + state->argc = 0; + state->option_chars[0] = 0; + state->xtext = 0; + state->option_processing = 0; + state->opt_generation = 0; + state->current_option = -1; + state->is_short = 0; + state->whole_negated = 0; + state->current_short = 0; + state->negated_by_no = 0; } return state; } @@ -1497,9 +1531,9 @@ Clp_RestoreParser(Clp_Parser *clp, const Clp_ParserState *state) cli->current_short = state->current_short; cli->negated_by_no = state->negated_by_no; if (cli->opt_generation == state->opt_generation) - cli->current_option = state->current_option; + cli->current_option = state->current_option; else - cli->current_option = -1; + cli->current_option = -1; } @@ -1521,12 +1555,12 @@ get_oclass(Clp_Parser *clp, const char *text, int *ocharskip) { int c; if (clp->internal->utf8) { - const char *s; - c = decode_utf8(text, &s); - *ocharskip = s - text; + const char *s; + c = decode_utf8(text, &s); + *ocharskip = s - text; } else { - c = (unsigned char) text[0]; - *ocharskip = 1; + c = (unsigned char) text[0]; + *ocharskip = 1; } return Clp_OptionChar(clp, c); } @@ -1534,22 +1568,22 @@ get_oclass(Clp_Parser *clp, const char *text, int *ocharskip) static int next_argument(Clp_Parser *clp, int want_argument) /* Moves clp to the next argument. - Returns 1 if it finds another option. - Returns 0 if there aren't any more arguments. - Returns 0, sets clp->have_val = 1, and sets clp->vstr to the argument - if the next argument isn't an option. - If want_argument > 0, it'll look for an argument. - want_argument == 1: Accept arguments that start with Clp_NotOption - or Clp_LongImplicit. - want_argument == 2: Accept ALL arguments. - - Where is the option stored when this returns? - Well, cli->argv[0] holds the whole of the next command line argument. - cli->option_chars holds a string: what characters began the option? - It is generally "-" or "--". - cli->text holds the text of the option: - for short options, cli->text[0] is the relevant character; - for long options, cli->text holds the rest of the option. */ + Returns 1 if it finds another option. + Returns 0 if there aren't any more arguments. + Returns 0, sets clp->have_val = 1, and sets clp->vstr to the argument + if the next argument isn't an option. + If want_argument > 0, it'll look for an argument. + want_argument == 1: Accept arguments that start with Clp_NotOption + or Clp_LongImplicit. + want_argument == 2: Accept ALL arguments. + + Where is the option stored when this returns? + Well, cli->argv[0] holds the whole of the next command line argument. + cli->option_chars holds a string: what characters began the option? + It is generally "-" or "--". + cli->text holds the text of the option: + for short options, cli->text[0] is the relevant character; + for long options, cli->text holds the rest of the option. */ { Clp_Internal *cli = clp->internal; const char *text; @@ -1562,102 +1596,102 @@ next_argument(Clp_Parser *clp, int want_argument) /* if we're in a string of short options, move up one char in the string */ if (cli->is_short) { - cli->xtext += clp_utf8_charlen(cli, cli->xtext); - if (cli->xtext[0] == 0) - cli->is_short = 0; - else if (want_argument > 0) { - /* handle -O[=]argument case */ - clp->have_val = 1; - if (cli->xtext[0] == '=') - clp->vstr = cli->xtext + 1; - else - clp->vstr = cli->xtext; - cli->is_short = 0; - return 0; - } + cli->xtext += clp_utf8_charlen(cli, cli->xtext); + if (cli->xtext[0] == 0) + cli->is_short = 0; + else if (want_argument > 0) { + /* handle -O[=]argument case */ + clp->have_val = 1; + if (cli->xtext[0] == '=') + clp->vstr = cli->xtext + 1; + else + clp->vstr = cli->xtext; + cli->is_short = 0; + return 0; + } } /* if in short options, we're all set */ if (cli->is_short) - return 1; + return 1; /** if not in short options, move to the next argument **/ cli->whole_negated = 0; cli->xtext = 0; if (cli->argc <= 1) - return 0; + return 0; cli->argc--; cli->argv++; text = cli->argv[0]; if (want_argument > 1) - goto not_option; + goto not_option; if (text[0] == '-' && text[1] == '-') { - oclass = Clp_DoubledLong; - ocharskip = 2; + oclass = Clp_DoubledLong; + ocharskip = 2; } else - oclass = get_oclass(clp, text, &ocharskip); + oclass = get_oclass(clp, text, &ocharskip); /* If this character could introduce either a short or a long option, try a long option first, but remember that short's a possibility for later. */ if ((oclass & (Clp_Short | Clp_ShortNegated)) - && (oclass & (Clp_Long | Clp_LongNegated))) { - oclass &= ~(Clp_Short | Clp_ShortNegated); - if (text[ocharskip]) - cli->could_be_short = 1; + && (oclass & (Clp_Long | Clp_LongNegated))) { + oclass &= ~(Clp_Short | Clp_ShortNegated); + if (text[ocharskip]) + cli->could_be_short = 1; } switch (oclass) { case Clp_Short: - cli->is_short = 1; - goto check_singleton; + cli->is_short = 1; + goto check_singleton; case Clp_ShortNegated: - cli->is_short = 1; - cli->whole_negated = 1; - goto check_singleton; + cli->is_short = 1; + cli->whole_negated = 1; + goto check_singleton; case Clp_Long: - goto check_singleton; + goto check_singleton; case Clp_LongNegated: - cli->whole_negated = 1; - goto check_singleton; + cli->whole_negated = 1; + goto check_singleton; check_singleton: - /* For options introduced with one character, option-char, - '[option-char]' alone is NOT an option. */ - if (!text[ocharskip]) - goto not_option; - set_option_text(cli, text, ocharskip); - break; + /* For options introduced with one character, option-char, + '[option-char]' alone is NOT an option. */ + if (!text[ocharskip]) + goto not_option; + set_option_text(cli, text, ocharskip); + break; case Clp_LongImplicit: - /* LongImplict: option_chars == "" (since all chars are part of the - option); restore head -> text of option */ - if (want_argument > 0) - goto not_option; - set_option_text(cli, text, 0); - break; + /* LongImplict: option_chars == "" (since all chars are part of the + option); restore head -> text of option */ + if (want_argument > 0) + goto not_option; + set_option_text(cli, text, 0); + break; case Clp_DoubledLong: - set_option_text(cli, text, ocharskip); - break; + set_option_text(cli, text, ocharskip); + break; not_option: case Clp_NotOption: - cli->is_short = 0; - clp->have_val = 1; - clp->vstr = text; - return 0; + cli->is_short = 0; + clp->have_val = 1; + clp->vstr = text; + return 0; default: - assert(0 /* CLP misconfiguration: bad option type */); + assert(0 /* CLP misconfiguration: bad option type */); } @@ -1673,7 +1707,7 @@ switch_to_short_argument(Clp_Parser *clp) int ocharskip, oclass = get_oclass(clp, text, &ocharskip); assert(cli->could_be_short); cli->is_short = 1; - cli->whole_negated = (oclass & Clp_ShortNegated ? 1 : 0); + cli->whole_negated = !!(oclass & Clp_ShortNegated); set_option_text(cli, cli->argv[0], ocharskip); } @@ -1681,9 +1715,9 @@ switch_to_short_argument(Clp_Parser *clp) static int find_long(Clp_Parser *clp, const char *arg) /* If arg corresponds to one of clp's options, finds that option & - returns it. If any argument is given after an = sign in arg, sets - clp->have_val = 1 and clp->vstr to that argument. Sets cli->ambiguous - to 1 iff there was no match because the argument was ambiguous. */ + returns it. If any argument is given after an = sign in arg, sets + clp->have_val = 1 and clp->vstr to that argument. Sets cli->ambiguous + to 1 iff there was no match because the argument was ambiguous. */ { Clp_Internal *cli = clp->internal; int optno, len, lmm; @@ -1693,32 +1727,32 @@ find_long(Clp_Parser *clp, const char *arg) /* Look for a normal option. */ optno = find_prefix_opt - (clp, arg, cli->nopt, opt, cli->iopt, - &cli->ambiguous, cli->ambiguous_values); + (clp, arg, cli->nopt, opt, cli->iopt, + &cli->ambiguous, cli->ambiguous_values); if (optno >= 0) - goto worked; + goto worked; /* If we can't find it, look for a negated option. */ /* I know this is silly, but it makes me happy to accept --no-no-option as a double negative synonym for --option. :) */ first_negative_ambiguous = cli->ambiguous; while (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-') { - arg += 3; - clp->negated = !clp->negated; - optno = find_prefix_opt - (clp, arg, cli->nopt, opt, cli->iopt, - &cli->ambiguous, cli->ambiguous_values); - if (optno >= 0) - goto worked; + arg += 3; + clp->negated = !clp->negated; + optno = find_prefix_opt + (clp, arg, cli->nopt, opt, cli->iopt, + &cli->ambiguous, cli->ambiguous_values); + if (optno >= 0) + goto worked; } /* No valid option was found; return 0. Mark the ambiguous values found through '--no' by making them negative. */ { - int i, max = cli->ambiguous; - if (max > MAX_AMBIGUOUS_VALUES) max = MAX_AMBIGUOUS_VALUES; - for (i = first_negative_ambiguous; i < max; i++) - cli->ambiguous_values[i] = -cli->ambiguous_values[i] - 1; + int i, max = cli->ambiguous; + if (max > MAX_AMBIGUOUS_VALUES) max = MAX_AMBIGUOUS_VALUES; + for (i = first_negative_ambiguous; i < max; i++) + cli->ambiguous_values[i] = -cli->ambiguous_values[i] - 1; } return -1; @@ -1726,15 +1760,15 @@ find_long(Clp_Parser *clp, const char *arg) iopt = &cli->iopt[optno]; lmm = (clp->negated ? iopt->lmmneg : iopt->lmmpos); if (cli->could_be_short - && (clp->negated ? iopt->lmmneg_short : iopt->lmmpos_short)) { - int first_charlen = clp_utf8_charlen(cli, arg); - lmm = (first_charlen >= lmm ? first_charlen + 1 : lmm); + && (clp->negated ? iopt->lmmneg_short : iopt->lmmpos_short)) { + int first_charlen = clp_utf8_charlen(cli, arg); + lmm = (first_charlen >= lmm ? first_charlen + 1 : lmm); } len = argcmp(opt[optno].long_name + iopt->ilongoff, arg, lmm, 1); assert(len > 0); if (arg[len] == '=') { - clp->have_val = 1; - clp->vstr = arg + len + 1; + clp->have_val = 1; + clp->vstr = arg + len + 1; } return optno; } @@ -1749,15 +1783,15 @@ find_short(Clp_Parser *clp, const char *text) const Clp_InternOption *iopt = cli->iopt; int i, c; if (clp->internal->utf8) - c = decode_utf8(text, 0); + c = decode_utf8(text, 0); else - c = (unsigned char) *text; + c = (unsigned char) *text; for (i = 0; i < cli->nopt; i++) - if (iopt[i].ishort && opt[i].short_name == c + if (iopt[i].ishort && opt[i].short_name == c && (!clp->negated || iopt[i].ineg)) { clp->negated = clp->negated || !iopt[i].ipos; - return i; + return i; } return -1; @@ -1804,7 +1838,7 @@ find_short(Clp_Parser *clp, const char *text) * </dl> * * The parsed argument is shifted off the argument list, so that sequential - * calls to Clp_Next() step through the arugment list. + * calls to Clp_Next() step through the argument list. */ int Clp_Next(Clp_Parser *clp) @@ -1821,49 +1855,49 @@ Clp_Next(Clp_Parser *clp) /* Get the next argument or option */ if (!next_argument(clp, cli->option_processing ? 0 : 2)) { - clp->val.s = clp->vstr; - optno = clp->have_val ? Clp_NotOption : Clp_Done; - clp->option = &clp_option_sentinel[-optno]; - return optno; + clp->val.s = clp->vstr; + optno = clp->have_val ? Clp_NotOption : Clp_Done; + clp->option = &clp_option_sentinel[-optno]; + return optno; } clp->negated = cli->whole_negated; if (cli->is_short) - optno = find_short(clp, cli->xtext); + optno = find_short(clp, cli->xtext); else - optno = find_long(clp, cli->xtext); + optno = find_long(clp, cli->xtext); /* If there's ambiguity between long & short options, and we couldn't find a long option, look for a short option */ if (optno < 0 && cli->could_be_short) { - switch_to_short_argument(clp); - optno = find_short(clp, cli->xtext); + switch_to_short_argument(clp); + optno = find_short(clp, cli->xtext); } /* If we didn't find an option... */ if (optno < 0 || (clp->negated && !cli->iopt[optno].ineg)) { - /* default processing for the "--" option: turn off option processing - and return the next argument */ - if (strcmp(cli->argv[0], "--") == 0) { - Clp_SetOptionProcessing(clp, 0); - return Clp_Next(clp); - } - - /* otherwise, report some error or other */ - if (cli->ambiguous) - ambiguity_error(clp, cli->ambiguous, cli->ambiguous_values, - cli->opt, cli->iopt, cli->option_chars, - "option %<%s%s%> is ambiguous", - cli->option_chars, cli->xtext); - else if (cli->is_short && !cli->could_be_short) - Clp_OptionError(clp, "unrecognized option %<%s%C%>", - cli->option_chars, cli->xtext); - else - Clp_OptionError(clp, "unrecognized option %<%s%s%>", - cli->option_chars, cli->xtext); - - clp->option = &clp_option_sentinel[-Clp_BadOption]; - return Clp_BadOption; + /* default processing for the "--" option: turn off option processing + and return the next argument */ + if (strcmp(cli->argv[0], "--") == 0) { + Clp_SetOptionProcessing(clp, 0); + return Clp_Next(clp); + } + + /* otherwise, report some error or other */ + if (cli->ambiguous) + ambiguity_error(clp, cli->ambiguous, cli->ambiguous_values, + cli->opt, cli->iopt, cli->option_chars, + "option %<%s%s%> is ambiguous", + cli->option_chars, cli->xtext); + else if (cli->is_short && !cli->could_be_short) + Clp_OptionError(clp, "unrecognized option %<%s%C%>", + cli->option_chars, cli->xtext); + else + Clp_OptionError(clp, "unrecognized option %<%s%s%>", + cli->option_chars, cli->xtext); + + clp->option = &clp_option_sentinel[-Clp_BadOption]; + return Clp_BadOption; } /* Set the current option */ @@ -1873,29 +1907,29 @@ Clp_Next(Clp_Parser *clp) /* The no-argument (or should-have-no-argument) case */ if (clp->negated - || (!cli->iopt[optno].imandatory && !cli->iopt[optno].ioptional)) { - if (clp->have_val) { - Clp_OptionError(clp, "%<%O%> can%,t take an argument"); - clp->option = &clp_option_sentinel[-Clp_BadOption]; - return Clp_BadOption; - } else { - clp->option = &cli->opt[optno]; - return cli->opt[optno].option_id; - } + || (!cli->iopt[optno].imandatory && !cli->iopt[optno].ioptional)) { + if (clp->have_val) { + Clp_OptionError(clp, "%<%O%> can%,t take an argument"); + clp->option = &clp_option_sentinel[-Clp_BadOption]; + return Clp_BadOption; + } else { + clp->option = &cli->opt[optno]; + return cli->opt[optno].option_id; + } } /* Get an argument if we need one, or if it's optional */ /* Sanity-check the argument type. */ opt = &cli->opt[optno]; if (opt->val_type <= 0) { - clp->option = &clp_option_sentinel[-Clp_Error]; - return Clp_Error; + clp->option = &clp_option_sentinel[-Clp_Error]; + return Clp_Error; } vtpos = val_type_binsearch(cli, opt->val_type); if (vtpos == cli->nvaltype - || cli->valtype[vtpos].val_type != opt->val_type) { - clp->option = &clp_option_sentinel[-Clp_Error]; - return Clp_Error; + || cli->valtype[vtpos].val_type != opt->val_type) { + clp->option = &clp_option_sentinel[-Clp_Error]; + return Clp_Error; } /* complain == 1 only if the argument was explicitly given, @@ -1904,43 +1938,45 @@ Clp_Next(Clp_Parser *clp) Clp_SaveParser(clp, &clpsave); if (cli->iopt[optno].imandatory && !clp->have_val) { - /* Mandatory argument case */ - /* Allow arguments to options to start with a dash, but only if the - argument type allows it by not setting Clp_DisallowOptions */ - int disallow = (cli->valtype[vtpos].flags & Clp_DisallowOptions) != 0; - next_argument(clp, disallow ? 1 : 2); - if (!clp->have_val) { - int got_option = cli->xtext != 0; - Clp_RestoreParser(clp, &clpsave); - if (got_option) - Clp_OptionError(clp, "%<%O%> requires a non-option argument"); - else - Clp_OptionError(clp, "%<%O%> requires an argument"); - clp->option = &clp_option_sentinel[-Clp_BadOption]; - return Clp_BadOption; - } + /* Mandatory argument case */ + /* Allow arguments to options to start with a dash, but only if the + argument type allows it by not setting Clp_DisallowOptions */ + int disallow = (cli->valtype[vtpos].flags & Clp_DisallowOptions) != 0; + next_argument(clp, disallow ? 1 : 2); + if (!clp->have_val) { + int got_option = cli->xtext != 0; + Clp_RestoreParser(clp, &clpsave); + if (got_option) + Clp_OptionError(clp, "%<%O%> requires a non-option argument"); + else + Clp_OptionError(clp, "%<%O%> requires an argument"); + clp->option = &clp_option_sentinel[-Clp_BadOption]; + return Clp_BadOption; + } } else if (cli->is_short && !clp->have_val - && cli->xtext[clp_utf8_charlen(cli, cli->xtext)]) - /* The -[option]argument case: - Assume that the rest of the current string is the argument. */ - next_argument(clp, 1); + && cli->xtext[clp_utf8_charlen(cli, cli->xtext)]) + /* The -[option]argument case: + Assume that the rest of the current string is the argument. */ + next_argument(clp, 1); /* Parse the argument */ + clp->option = opt; if (clp->have_val) { - Clp_ValType *atr = &cli->valtype[vtpos]; - if (atr->func(clp, clp->vstr, complain, atr->user_data) <= 0) { - /* parser failed */ - clp->have_val = 0; - if (cli->iopt[optno].imandatory) { - clp->option = &clp_option_sentinel[-Clp_BadOption]; - return Clp_BadOption; - } else - Clp_RestoreParser(clp, &clpsave); - } + Clp_ValType *atr = &cli->valtype[vtpos]; + if (atr->func(clp, clp->vstr, complain, atr->user_data) <= 0) { + /* parser failed */ + clp->have_val = 0; + if (complain) { + clp->option = &clp_option_sentinel[-Clp_BadOption]; + return Clp_BadOption; + } else { + Clp_RestoreParser(clp, &clpsave); + clp->option = opt; + } + } } - clp->option = opt; return opt->option_id; } @@ -1961,7 +1997,7 @@ Clp_Shift(Clp_Parser *clp, int allow_options) Clp_SaveParser(clp, &clpsave); next_argument(clp, allow_options ? 2 : 1); if (!clp->have_val) - Clp_RestoreParser(clp, &clpsave); + Clp_RestoreParser(clp, &clpsave); return clp->vstr; } @@ -1971,222 +2007,224 @@ Clp_Shift(Clp_Parser *clp, int allow_options) **/ typedef struct Clp_BuildString { - char *text; - char *pos; - int capacity; - int bad; + char* data; + char* pos; + char* end_data; + char buf[256]; } Clp_BuildString; -static Clp_BuildString * -new_build_string(void) -{ - Clp_BuildString *bs = (Clp_BuildString *)malloc(sizeof(Clp_BuildString)); - if (!bs) goto bad; - bs->text = (char *)malloc(256); - if (!bs->text) goto bad; - bs->pos = bs->text; - bs->capacity = 256; - bs->bad = 0; - return bs; - - bad: - if (bs) free(bs); - return 0; +static void build_string_program_prefix(Clp_BuildString* bs, + const Clp_Parser* clp); + +static void build_string_init(Clp_BuildString* bs, Clp_Parser* clp) { + bs->data = bs->pos = bs->buf; + bs->end_data = &bs->buf[sizeof(bs->buf)]; + if (clp) + build_string_program_prefix(bs, clp); } -static void -free_build_string(Clp_BuildString *bs) -{ - if (bs) free(bs->text); - free(bs); +static void build_string_cleanup(Clp_BuildString* bs) { + if (bs->data != bs->buf) + free(bs->data); } -static int -grow_build_string(Clp_BuildString *bs, int want) -{ - char *new_text; - int ipos = bs->pos - bs->text; - int new_capacity = bs->capacity; - while (want >= new_capacity) - new_capacity *= 2; - new_text = (char *)realloc(bs->text, new_capacity); - if (!new_text) { - bs->bad = 1; - return 0; +static int build_string_grow(Clp_BuildString* bs, size_t want) { + size_t ipos = bs->pos - bs->data, ncap; + if (!bs->pos) + return 0; + for (ncap = (bs->end_data - bs->data) << 1; ncap < want; ncap *= 2) + /* nada */; + if (bs->data == bs->buf) { + if ((bs->data = (char*) malloc(ncap))) + memcpy(bs->data, bs->buf, bs->pos - bs->buf); + } else + bs->data = (char*) realloc(bs->data, ncap); + if (!bs->data) { + bs->pos = bs->end_data = bs->data; + return 0; } else { - bs->text = new_text; - bs->pos = bs->text + ipos; - bs->capacity = new_capacity; - return 1; + bs->pos = bs->data + ipos; + bs->end_data = bs->data + ncap; + return 1; } } -#define ENSURE_BUILD_STRING(bs, space) \ - ((((bs)->pos - (bs)->text) + (space) >= (bs)->capacity) \ - || grow_build_string((bs), ((bs)->pos - (bs)->text) + (space))) +#define ENSURE_BUILD_STRING(bs, space) \ + ((((bs)->end_data - (bs)->pos) >= (space)) \ + || build_string_grow((bs), (bs)->pos - (bs)->data + (space))) static void append_build_string(Clp_BuildString *bs, const char *s, int l) { if (l < 0) - l = strlen(s); + l = strlen(s); if (ENSURE_BUILD_STRING(bs, l)) { - memcpy(bs->pos, s, l); - bs->pos += l; + memcpy(bs->pos, s, l); + bs->pos += l; + } +} + +static void +build_string_program_prefix(Clp_BuildString* bs, const Clp_Parser* clp) +{ + const Clp_Internal* cli = clp->internal; + if (cli->program_name && cli->program_name[0]) { + append_build_string(bs, cli->program_name, -1); + append_build_string(bs, ": ", 2); } } -static Clp_BuildString * -Clp_VaOptionError(Clp_Parser *clp, Clp_BuildString *bs, - const char *fmt, va_list val) +static void +Clp_vbsprintf(Clp_Parser *clp, Clp_BuildString *bs, + const char *fmt, va_list val) { Clp_Internal *cli = clp->internal; const char *percent; int c; - if (!bs) - bs = new_build_string(); - if (!bs) - return 0; - if (cli->program_name && cli->program_name[0]) { - append_build_string(bs, cli->program_name, -1); - append_build_string(bs, ": ", 2); - } - for (percent = strchr(fmt, '%'); percent; percent = strchr(fmt, '%')) { - append_build_string(bs, fmt, percent - fmt); - switch (*++percent) { - - case 's': { - const char *s = va_arg(val, const char *); - if (s) - append_build_string(bs, s, -1); - else - append_build_string(bs, "(null)", 6); - break; - } - - case 'C': { - const char *s = va_arg(val, const char *); - if (cli->utf8) - c = decode_utf8(s, 0); - else - c = (unsigned char) *s; - goto char_c; - } - - case 'c': - c = va_arg(val, int); - goto char_c; - - char_c: - if (ENSURE_BUILD_STRING(bs, 4)) { - if (c >= 32 && c <= 126) - *bs->pos++ = c; - else if (c < 32) { - *bs->pos++ = '^'; - *bs->pos++ = c + 64; - } else if (cli->utf8 && c >= 127 && c < 0x110000) { - bs->pos = encode_utf8(bs->pos, 4, c); - } else if (c >= 127 && c <= 255) { - sprintf(bs->pos, "\\%03o", c & 0xFF); - bs->pos += 4; - } else { - *bs->pos++ = '\\'; - *bs->pos++ = '?'; - } - } - break; - - case 'd': { - int d = va_arg(val, int); - if (ENSURE_BUILD_STRING(bs, 32)) { - sprintf(bs->pos, "%d", d); - bs->pos = strchr(bs->pos, 0); - } - break; - } - - case 'O': { - int optno = cli->current_option; - const Clp_Option *opt = &cli->opt[optno]; - if (optno < 0) - append_build_string(bs, "(no current option!)", -1); - else if (cli->current_short) { - append_build_string(bs, cli->option_chars, -1); - if (ENSURE_BUILD_STRING(bs, 5)) { - if (cli->utf8) - bs->pos = encode_utf8(bs->pos, 5, opt->short_name); - else - *bs->pos++ = opt->short_name; - } - } else if (cli->negated_by_no) { - append_build_string(bs, cli->option_chars, -1); - append_build_string(bs, "no-", 3); - append_build_string(bs, opt->long_name + cli->iopt[optno].ilongoff, -1); - } else { - append_build_string(bs, cli->option_chars, -1); - append_build_string(bs, opt->long_name + cli->iopt[optno].ilongoff, -1); - } - break; - } - - case '%': - if (ENSURE_BUILD_STRING(bs, 1)) - *bs->pos++ = '%'; - break; - - case '`': /* backwards compatibility */ - case '<': - append_build_string(bs, (cli->utf8 ? "\342\200\230" : "'"), -1); - break; - - case '\'': /* backwards compatibility */ - case ',': - case '>': - append_build_string(bs, (cli->utf8 ? "\342\200\231" : "'"), -1); - break; - - default: - if (ENSURE_BUILD_STRING(bs, 2)) { - *bs->pos++ = '%'; - *bs->pos++ = *percent; - } - break; - - } - fmt = ++percent; + append_build_string(bs, fmt, percent - fmt); + switch (*++percent) { + + case 's': { + const char *s = va_arg(val, const char *); + append_build_string(bs, s ? s : "(null)", -1); + break; + } + + case 'C': { + const char *s = va_arg(val, const char *); + if (cli->utf8) + c = decode_utf8(s, 0); + else + c = (unsigned char) *s; + goto char_c; + } + + case 'c': + c = va_arg(val, int); + goto char_c; + + char_c: + if (ENSURE_BUILD_STRING(bs, 5)) { + if (c >= 32 && c <= 126) + *bs->pos++ = c; + else if (c < 32) { + *bs->pos++ = '^'; + *bs->pos++ = c + 64; + } else if (cli->utf8 && c >= 127 && c < 0x110000) { + bs->pos = encode_utf8(bs->pos, 4, c); + } else if (c >= 127 && c <= 255) { + snprintf(bs->pos, 5, "\\%03o", c & 0xFF); + bs->pos += 4; + } else { + *bs->pos++ = '\\'; + *bs->pos++ = '?'; + } + } + break; + + case 'd': { + int d = va_arg(val, int); + if (ENSURE_BUILD_STRING(bs, 32)) { + bs->pos += snprintf(bs->pos, 32, "%d", d); + } + break; + } + + case 'O': + case 'V': { + int optno = cli->current_option; + const Clp_Option *opt = &cli->opt[optno]; + if (optno < 0) + append_build_string(bs, "(no current option!)", -1); + else if (cli->current_short) { + append_build_string(bs, cli->option_chars, -1); + if (ENSURE_BUILD_STRING(bs, 5)) { + if (cli->utf8) + bs->pos = encode_utf8(bs->pos, 5, opt->short_name); + else + *bs->pos++ = opt->short_name; + } + } else if (cli->negated_by_no) { + append_build_string(bs, cli->option_chars, -1); + append_build_string(bs, "no-", 3); + append_build_string(bs, opt->long_name + cli->iopt[optno].ilongoff, -1); + } else { + append_build_string(bs, cli->option_chars, -1); + append_build_string(bs, opt->long_name + cli->iopt[optno].ilongoff, -1); + } + if (optno >= 0 && clp->have_val && *percent == 'V') { + if (cli->current_short && !cli->iopt[optno].ioptional) + append_build_string(bs, " ", 1); + else if (!cli->current_short) + append_build_string(bs, "=", 1); + append_build_string(bs, clp->vstr, -1); + } + break; + } + + case '%': + if (ENSURE_BUILD_STRING(bs, 1)) + *bs->pos++ = '%'; + break; + + case '<': + append_build_string(bs, (cli->utf8 ? "\342\200\230" : "'"), -1); + break; + + case ',': + case '>': + append_build_string(bs, (cli->utf8 ? "\342\200\231" : "'"), -1); + break; + + case 0: + append_build_string(bs, "%", 1); + goto done; + + default: + if (ENSURE_BUILD_STRING(bs, 2)) { + *bs->pos++ = '%'; + *bs->pos++ = *percent; + } + break; + + } + fmt = ++percent; } + done: append_build_string(bs, fmt, -1); - append_build_string(bs, "\n", 1); +} - return bs; +static const char* build_string_text(Clp_BuildString* bs, int report_oom) { + if (bs->pos) { + *bs->pos = 0; + return bs->data; + } else if (report_oom) + return "out of memory\n"; + else + return NULL; } static void do_error(Clp_Parser *clp, Clp_BuildString *bs) { - const char *text; - if (bs && !bs->bad) { - *bs->pos = 0; - text = bs->text; - } else - text = "out of memory\n"; - + const char *text = build_string_text(bs, 1); if (clp->internal->error_handler != 0) - (*clp->internal->error_handler)(clp, text); + (*clp->internal->error_handler)(clp, text); else - fputs(text, stderr); + fputs(text, stderr); } /** @param clp the parser * @param format error format * - * Format an error message from @a format and any additional arguments in the - * ellipsis. The resulting error string by printing it to standard error or - * passing it to Clp_SetErrorHandler. + * Format an error message from @a format and any additional arguments in + * the ellipsis. The resulting error string is then printed to standard + * error (or passed to the error handler specified by Clp_SetErrorHandler). + * Returns the number of characters printed. * * The following format characters are accepted: * @@ -2207,6 +2245,9 @@ do_error(Clp_Parser *clp, Clp_BuildString *bs) * <dt><tt>%</tt><tt>O</tt></dt> * <dd>The current option. No values are read from the argument list; the * current option is defined in the Clp_Parser object itself.</dd> + * <dt><tt>%</tt><tt>V</tt></dt> + * <dd>Like <tt>%</tt><tt>O</tt>, but also includes the current value, + * if any.</dd> * <dt><tt>%%</tt></dt> * <dd>Prints a percent character.</dd> * <dt><tt>%</tt><tt><</tt></dt> @@ -2228,61 +2269,139 @@ do_error(Clp_Parser *clp, Clp_BuildString *bs) int Clp_OptionError(Clp_Parser *clp, const char *format, ...) { - Clp_BuildString *bs; + Clp_BuildString bs; va_list val; va_start(val, format); - bs = Clp_VaOptionError(clp, 0, format, val); + build_string_init(&bs, clp); + Clp_vbsprintf(clp, &bs, format, val); + append_build_string(&bs, "\n", 1); va_end(val); - do_error(clp, bs); - free_build_string(bs); - return 0; + do_error(clp, &bs); + build_string_cleanup(&bs); + return bs.pos - bs.data; +} + +/** @param clp the parser + * @param f output file + * @param format error format + * + * Format an error message using @a format and additional arguments in the + * ellipsis, according to the Clp_OptionError formatting conventions. The + * resulting message is written to @a f. + * + * @sa Clp_OptionError */ +int +Clp_fprintf(Clp_Parser* clp, FILE* f, const char* format, ...) +{ + Clp_BuildString bs; + va_list val; + va_start(val, format); + build_string_init(&bs, NULL); + Clp_vbsprintf(clp, &bs, format, val); + va_end(val); + if (bs.pos != bs.data) + fwrite(bs.data, 1, bs.pos - bs.data, f); + build_string_cleanup(&bs); + return bs.pos - bs.data; +} + +/** @param clp the parser + * @param f output file + * @param format error format + * @param val arguments + * + * Format an error message using @a format and @a val, according to the + * Clp_OptionError formatting conventions. The resulting message is written + * to @a f. + * + * @sa Clp_OptionError */ +int +Clp_vfprintf(Clp_Parser* clp, FILE* f, const char* format, va_list val) +{ + Clp_BuildString bs; + build_string_init(&bs, NULL); + Clp_vbsprintf(clp, &bs, format, val); + if (bs.pos != bs.data) + fwrite(bs.data, 1, bs.pos - bs.data, f); + build_string_cleanup(&bs); + return bs.pos - bs.data; +} + +/** @param clp the parser + * @param str output string + * @param size size of output string + * @param format error format + * + * Format an error message from @a format and any additional arguments in + * the ellipsis, according to the Clp_OptionError formatting conventions. + * The resulting string is written to @a str. At most @a size characters are + * written to @a str, including a terminating null byte. The return value is + * the number of characters that would have been written (excluding the + * terminating null byte) if @a size were large enough to contain the entire + * string. + * + * @sa Clp_OptionError */ +int +Clp_vsnprintf(Clp_Parser* clp, char* str, size_t size, + const char* format, va_list val) +{ + Clp_BuildString bs; + build_string_init(&bs, NULL); + Clp_vbsprintf(clp, &bs, format, val); + if ((size_t) (bs.pos - bs.data) < size) { + memcpy(str, bs.data, bs.pos - bs.data); + str[bs.pos - bs.data] = 0; + } else { + memcpy(str, bs.data, size - 1); + str[size - 1] = 0; + } + build_string_cleanup(&bs); + return bs.pos - bs.data; } static int ambiguity_error(Clp_Parser *clp, int ambiguous, int *ambiguous_values, - const Clp_Option *opt, const Clp_InternOption *iopt, - const char *prefix, const char *fmt, ...) + const Clp_Option *opt, const Clp_InternOption *iopt, + const char *prefix, const char *fmt, ...) { Clp_Internal *cli = clp->internal; - Clp_BuildString *bs; + Clp_BuildString bs; int i; va_list val; + va_start(val, fmt); - bs = Clp_VaOptionError(clp, 0, fmt, val); - if (!bs) goto done; + build_string_init(&bs, clp); + Clp_vbsprintf(clp, &bs, fmt, val); + append_build_string(&bs, "\n", 1); - if (clp->internal->program_name && clp->internal->program_name[0]) { - append_build_string(bs, clp->internal->program_name, -1); - append_build_string(bs, ": ", 2); - } - append_build_string(bs, "(Possibilities are", -1); + build_string_program_prefix(&bs, clp); + append_build_string(&bs, "(Possibilities are", -1); for (i = 0; i < ambiguous && i < MAX_AMBIGUOUS_VALUES; i++) { - int value = ambiguous_values[i]; - const char *no_dash = ""; - if (value < 0) - value = -(value + 1), no_dash = "no-"; - if (i == 0) - append_build_string(bs, " ", 1); - else if (i == ambiguous - 1) - append_build_string(bs, (i == 1 ? " and " : ", and "), -1); - else - append_build_string(bs, ", ", 2); - append_build_string(bs, (cli->utf8 ? "\342\200\230" : "'"), -1); - append_build_string(bs, prefix, -1); - append_build_string(bs, no_dash, -1); - append_build_string(bs, opt[value].long_name + iopt[value].ilongoff, -1); - append_build_string(bs, (cli->utf8 ? "\342\200\231" : "'"), -1); + int value = ambiguous_values[i]; + const char *no_dash = ""; + if (value < 0) + value = -(value + 1), no_dash = "no-"; + if (i == 0) + append_build_string(&bs, " ", 1); + else if (i == ambiguous - 1) + append_build_string(&bs, (i == 1 ? " and " : ", and "), -1); + else + append_build_string(&bs, ", ", 2); + append_build_string(&bs, (cli->utf8 ? "\342\200\230" : "'"), -1); + append_build_string(&bs, prefix, -1); + append_build_string(&bs, no_dash, -1); + append_build_string(&bs, opt[value].long_name + iopt[value].ilongoff, -1); + append_build_string(&bs, (cli->utf8 ? "\342\200\231" : "'"), -1); } if (ambiguous > MAX_AMBIGUOUS_VALUES) - append_build_string(bs, ", and others", -1); - append_build_string(bs, ".)\n", -1); + append_build_string(&bs, ", and others", -1); + append_build_string(&bs, ".)\n", -1); va_end(val); - done: - do_error(clp, bs); - free_build_string(bs); + do_error(clp, &bs); + build_string_cleanup(&bs); return 0; } @@ -2291,7 +2410,7 @@ copy_string(char *buf, int buflen, int bufpos, const char *what) { int l = strlen(what); if (l > buflen - bufpos - 1) - l = buflen - bufpos - 1; + l = buflen - bufpos - 1; memcpy(buf + bufpos, what, l); return l; } @@ -2315,23 +2434,23 @@ Clp_CurOptionNameBuf(Clp_Parser *clp, char *buf, int len) int optno = cli->current_option; int pos = 0; if (optno < 0) - pos += copy_string(buf, len, pos, "(no current option!)"); + pos += copy_string(buf, len, pos, "(no current option!)"); else if (cli->current_short) { - pos += copy_string(buf, len, pos, cli->option_chars); - if (cli->utf8) - pos = (encode_utf8(buf + pos, len - pos - 1, cli->opt[optno].short_name) - buf); - else if (pos < len - 1) - buf[pos++] = cli->opt[optno].short_name; + pos += copy_string(buf, len, pos, cli->option_chars); + if (cli->utf8) + pos = (encode_utf8(buf + pos, len - pos - 1, cli->opt[optno].short_name) - buf); + else if (pos < len - 1) + buf[pos++] = cli->opt[optno].short_name; } else if (cli->negated_by_no) { - pos += copy_string(buf, len, pos, cli->option_chars); - pos += copy_string(buf, len, pos, "no-"); - pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff); + pos += copy_string(buf, len, pos, cli->option_chars); + pos += copy_string(buf, len, pos, "no-"); + pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff); } else { - pos += copy_string(buf, len, pos, cli->option_chars); - pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff); + pos += copy_string(buf, len, pos, cli->option_chars); + pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff); } if (pos < len) - buf[pos] = 0; + buf[pos] = 0; return pos; } @@ -2354,6 +2473,22 @@ Clp_CurOptionName(Clp_Parser *clp) return buf; } +int +Clp_IsLong(Clp_Parser *clp, const char *long_name) +{ + Clp_Internal *cli = clp->internal; + int optno = cli->current_option; + return optno >= 0 && strcmp(cli->opt[optno].long_name, long_name) == 0; +} + +int +Clp_IsShort(Clp_Parser *clp, int short_name) +{ + Clp_Internal *cli = clp->internal; + int optno = cli->current_option; + return optno >= 0 && cli->opt[optno].short_name == short_name; +} + #ifdef __cplusplus } #endif diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/error.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/error.cc index 2c41f3f2e79..6e9d757522e 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/error.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/error.cc @@ -4,7 +4,7 @@ * Eddie Kohler * * Copyright (c) 1999-2000 Massachusetts Institute of Technology - * Copyright (c) 2001-2019 Eddie Kohler + * Copyright (c) 2001-2023 Eddie Kohler * Copyright (c) 2008 Meraki, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -74,23 +74,23 @@ parse_level(const char *begin, const char *end, int *result) bool negative = false; if (s != end && *s == '-') { - negative = true; - ++s; + negative = true; + ++s; } else if (s != end && *s == '+') - ++s; + ++s; const char *digits = s; for (; s != end && *s >= '0' && *s <= '9'; ++s) - x = x * 10 + *s - '0'; + x = x * 10 + *s - '0'; if (s != end && *s == '.') - for (++s; s != end && *s >= '0' && *s <= '9'; ++s) - /* nada */; + for (++s; s != end && *s >= '0' && *s <= '9'; ++s) + /* nada */; if (s == digits || (s == digits + 1 && s[-1] == '.')) - return begin; + return begin; if (result) - *result = (negative ? -x : x); + *result = (negative ? -x : x); return s; } @@ -102,25 +102,25 @@ ErrorHandler::make_anno(const char *name, const String &value) // level annotation requires special handling if (name[0] == '<' && name[1] == '>' && name[2] == 0) { - if (parse_level(value.begin(), value.end(), 0) == value.end()) { - sa << '<' << value << '>'; - return sa.take_string(); - } else - return String(); + if (parse_level(value.begin(), value.end(), 0) == value.end()) { + sa << '<' << value << '>'; + return sa.take_string(); + } else + return String(); } sa << '{' << name << ':'; const char *last = value.begin(), *end = value.end(); for (const char *s = value.begin(); s != end; ++s) - if (*s == '\\' || *s == '}') { - sa.append(last, s); - sa << '\\' << *s; - last = s + 1; - } else if (*s == '\n') { - sa.append(last, s); - sa << '\\' << 'n'; - last = s + 1; - } + if (*s == '\\' || *s == '}') { + sa.append(last, s); + sa << '\\' << *s; + last = s + 1; + } else if (*s == '\n') { + sa.append(last, s); + sa << '\\' << 'n'; + last = s + 1; + } sa.append(last, end); sa << '}'; return sa.take_string(); @@ -128,77 +128,77 @@ ErrorHandler::make_anno(const char *name, const String &value) const char * ErrorHandler::skip_anno(const String &str, const char *begin, const char *end, - String *name_result, String *value_result, bool raw) + String *name_result, String *value_result, bool raw) { String name, value; const char *s = begin; if (s + 3 <= end && *s == '<') { - const char *x = parse_level(s + 1, end, 0); - if (x != s + 1 && x != end && *x == '>') { - name = String::make_stable("<>", 2); - if (str) - value = str.substring(begin + 1, x); - begin = x + 1; - } + const char *x = parse_level(s + 1, end, 0); + if (x != s + 1 && x != end && *x == '>') { + name = String::make_stable("<>", 2); + if (str) + value = str.substring(begin + 1, x); + begin = x + 1; + } } else if (s + 2 <= end && *s == '{' && s[1] == '}') - begin = s + 2; + begin = s + 2; else if (s + 3 <= end && *s == '{' && str) { - for (++s; s != end && isalnum((unsigned char) *s); ++s) - /* nada */; - if (s == end || s == begin + 1 || (*s != '}' && *s != ':')) - /* not an annotation */; - else if (*s == '}' && str) { - name = str.substring(begin + 1, s); - begin = s + 1; - } else if (*s == '}') { - name = String::make_stable("{}", 2); - begin = s + 1; - } else if (str) { - const char *x, *last = s + 1; - StringAccum sa; - for (x = s + 1; x != end && *x != '\n' && *x != '}'; ++x) - if (*x == '\\' && x + 1 != end && x[1] != '\n') { - if (!raw) { - sa.append(last, x); - sa << (x[1] == 'n' ? '\n' : x[1]); - last = x + 2; - } - ++x; - } - if (x != end && *x == '}') { - name = str.substring(begin + 1, s); - if (sa) { - sa.append(last, x); - value = sa.take_string(); - } else - value = str.substring(s + 1, x); - begin = x + 1; - } - } else { - const char *x; - for (x = s + 1; x != end && *x != '\n' && *x != '}'; ++x) - if (*x == '\\' && x + 1 != end && x[1] != '\n') - ++x; - if (x != end && *x == '}') { - name = String::make_stable("{}", 2); - begin = x + 1; - } - } + for (++s; s != end && isalnum((unsigned char) *s); ++s) + /* nada */; + if (s == end || s == begin + 1 || (*s != '}' && *s != ':')) + /* not an annotation */; + else if (*s == '}' && str) { + name = str.substring(begin + 1, s); + begin = s + 1; + } else if (*s == '}') { + name = String::make_stable("{}", 2); + begin = s + 1; + } else if (str) { + const char *x, *last = s + 1; + StringAccum sa; + for (x = s + 1; x != end && *x != '\n' && *x != '}'; ++x) + if (*x == '\\' && x + 1 != end && x[1] != '\n') { + if (!raw) { + sa.append(last, x); + sa << (x[1] == 'n' ? '\n' : x[1]); + last = x + 2; + } + ++x; + } + if (x != end && *x == '}') { + name = str.substring(begin + 1, s); + if (sa) { + sa.append(last, x); + value = sa.take_string(); + } else + value = str.substring(s + 1, x); + begin = x + 1; + } + } else { + const char *x; + for (x = s + 1; x != end && *x != '\n' && *x != '}'; ++x) + if (*x == '\\' && x + 1 != end && x[1] != '\n') + ++x; + if (x != end && *x == '}') { + name = String::make_stable("{}", 2); + begin = x + 1; + } + } } if (name_result) - *name_result = name; + *name_result = name; if (value_result) - *value_result = value; + *value_result = value; return begin; } const char * ErrorHandler::parse_anno(const String &str, const char *begin, const char *end, - ...) + ...) { const char *names[8]; void *values[8]; @@ -207,28 +207,28 @@ ErrorHandler::parse_anno(const String &str, const char *begin, const char *end, va_list val; va_start(val, end); while (const char *n = va_arg(val, const char *)) { - assert(nanno < 8); - names[nanno] = n; - if (n[0] == '#') - values[nanno] = va_arg(val, int *); - else - values[nanno] = va_arg(val, String *); - ++nanno; + assert(nanno < 8); + names[nanno] = n; + if (n[0] == '#') + values[nanno] = va_arg(val, int *); + else + values[nanno] = va_arg(val, String *); + ++nanno; } String name, value; while (1) { - begin = skip_anno(str, begin, end, &name, &value, false); - if (!name) - break; - for (int i = 0; i < nanno; ++i) - if (names[i][0] == '#') { - if (name == (names[i] + 1)) - parse_level(value.begin(), value.end(), (int *) values[i]); - } else { - if (name == names[i]) - *(String *) values[i] = value; - } + begin = skip_anno(str, begin, end, &name, &value, false); + if (!name) + break; + for (int i = 0; i < nanno; ++i) + if (names[i][0] == '#') { + if (name == (names[i] + 1)) + parse_level(value.begin(), value.end(), (int *) values[i]); + } else { + if (name == names[i]) + *(String *) values[i] = value; + } } return begin; @@ -238,63 +238,63 @@ String ErrorHandler::combine_anno(const String &text, const String &anno) { if (!anno) - return text; + return text; String names[8], values[8]; int nanno = 0; const char *abegin = anno.begin(); while (abegin != anno.end()) { - assert(nanno < 8); - abegin = skip_anno(anno, abegin, anno.end(), &names[nanno], &values[nanno], true); - if (names[nanno]) - ++nanno; - else - break; + assert(nanno < 8); + abegin = skip_anno(anno, abegin, anno.end(), &names[nanno], &values[nanno], true); + if (names[nanno]) + ++nanno; + else + break; } const char *last = text.begin(), *s = last; String name; StringAccum sa; while (s != text.end()) { - const char *line = s; - uint32_t mask = (1U << nanno) - 1; - while (1) { - s = skip_anno(text, s, text.end(), &name, 0, false); - if (!name) - break; - for (int i = 0; i < nanno; ++i) - if (name == names[i]) - mask &= ~(1U << i); - } - - if (mask) { - sa.append(last, line); - for (int i = 0; i < nanno; ++i) - if (mask & (1U << i)) { - if (names[i].equals("<>", 2)) - sa << '<' << values[i] << '>'; - else - sa << '{' << names[i] << ':' << values[i] << '}'; - } - last = line; - } - if (abegin != anno.end()) { - sa.append(last, s); - sa.append(abegin, anno.end()); - last = s; - } - - while (s != text.end() && *s != '\n') - ++s; - if (s != text.end()) - ++s; + const char *line = s; + uint32_t mask = (1U << nanno) - 1; + while (1) { + s = skip_anno(text, s, text.end(), &name, 0, false); + if (!name) + break; + for (int i = 0; i < nanno; ++i) + if (name == names[i]) + mask &= ~(1U << i); + } + + if (mask) { + sa.append(last, line); + for (int i = 0; i < nanno; ++i) + if (mask & (1U << i)) { + if (names[i].equals("<>", 2)) + sa << '<' << values[i] << '>'; + else + sa << '{' << names[i] << ':' << values[i] << '}'; + } + last = line; + } + if (abegin != anno.end()) { + sa.append(last, s); + sa.append(abegin, anno.end()); + last = s; + } + + while (s != text.end() && *s != '\n') + ++s; + if (s != text.end()) + ++s; } if (sa) { - sa.append(last, text.end()); - return sa.take_string(); + sa.append(last, text.end()); + return sa.take_string(); } else - return text; + return text; } String @@ -302,22 +302,22 @@ ErrorHandler::clean_landmark(const String &landmark, bool with_colon) { const char *end = landmark.end(); while (end != landmark.begin() && isspace((unsigned char) end[-1])) - --end; + --end; if (end != landmark.begin() && end[-1] == ':') - --end; + --end; if (end == landmark.begin()) - return String(); + return String(); else if (with_colon) - return landmark.substring(landmark.begin(), end) + ": "; + return landmark.substring(landmark.begin(), end) + ": "; else - return landmark.substring(landmark.begin(), end); + return landmark.substring(landmark.begin(), end); } // FORMATTING -#define NUMBUF_SIZE 128 -#define ErrH ErrorHandler +#define NUMBUF_SIZE 128 +#define ErrH ErrorHandler #if SIZEOF_UNSIGNED_LONG >= SIZEOF_VOID_P typedef unsigned long do_number_t; @@ -329,54 +329,54 @@ static char* do_number(do_number_t num, char *after_last, int base, int flags) { const char *digits = - ((flags & ErrH::cf_uppercase) ? "0123456789ABCDEF" : "0123456789abcdef"); + ((flags & ErrH::cf_uppercase) ? "0123456789ABCDEF" : "0123456789abcdef"); char *pos = after_last; while (num) { - *--pos = digits[num % base]; - num /= base; + *--pos = digits[num % base]; + num /= base; } if (pos == after_last) - *--pos = '0'; + *--pos = '0'; return pos; } static char * do_number_flags(char *pos, char *after_last, int base, int flags, - int precision, int field_width) + int precision, int field_width) { // remove cf_alternate_form for zero results in base 16 if ((flags & ErrH::cf_alternate_form) && base == 16 && *pos == '0') - flags &= ~ErrH::cf_alternate_form; + flags &= ~ErrH::cf_alternate_form; // account for zero padding if (precision >= 0) - while (after_last - pos < precision) - *--pos = '0'; + while (after_last - pos < precision) + *--pos = '0'; else if (flags & ErrH::cf_zero_pad) { - if ((flags & ErrH::cf_alternate_form) && base == 16) - field_width -= 2; - if ((flags & ErrH::cf_negative) - || (flags & (ErrH::cf_plus_positive | ErrH::cf_space_positive))) - field_width--; - while (after_last - pos < field_width) - *--pos = '0'; + if ((flags & ErrH::cf_alternate_form) && base == 16) + field_width -= 2; + if ((flags & ErrH::cf_negative) + || (flags & (ErrH::cf_plus_positive | ErrH::cf_space_positive))) + field_width--; + while (after_last - pos < field_width) + *--pos = '0'; } // alternate forms if ((flags & ErrH::cf_alternate_form) && base == 8 && pos[1] != '0') - *--pos = '0'; + *--pos = '0'; else if ((flags & ErrH::cf_alternate_form) && base == 16) { - *--pos = ((flags & ErrH::cf_uppercase) ? 'X' : 'x'); - *--pos = '0'; + *--pos = ((flags & ErrH::cf_uppercase) ? 'X' : 'x'); + *--pos = '0'; } // sign if (flags & ErrH::cf_negative) - *--pos = '-'; + *--pos = '-'; else if (flags & ErrH::cf_plus_positive) - *--pos = '+'; + *--pos = '+'; else if (flags & ErrH::cf_space_positive) - *--pos = ' '; + *--pos = ' '; return pos; } @@ -386,10 +386,10 @@ ErrorHandler::vxformat(int default_flags, const char *s, va_list val) { StringAccum msg; - char numbuf[NUMBUF_SIZE]; // for numerics + char numbuf[NUMBUF_SIZE]; // for numerics numbuf[NUMBUF_SIZE-1] = 0; - String strstore; // to ensure temporaries aren't destroyed + String strstore; // to ensure temporaries aren't destroyed // declare and initialize these here to make gcc shut up about possible // use before initialization @@ -400,354 +400,354 @@ ErrorHandler::vxformat(int default_flags, const char *s, va_list val) int base = 10; while (1) { - const char *pct = strchr(s, '%'); - if (!pct) { - if (*s) - msg << s; - break; - } - if (pct != s) { - msg.append(s, pct - s); - s = pct; - } - - // parse flags - flags = default_flags; + const char *pct = strchr(s, '%'); + if (!pct) { + if (*s) + msg << s; + break; + } + if (pct != s) { + msg.append(s, pct - s); + s = pct; + } + + // parse flags + flags = default_flags; flags: - switch (*++s) { - case '#': flags |= cf_alternate_form; goto flags; - case '0': flags |= cf_zero_pad; goto flags; - case '-': flags |= cf_left_just; goto flags; - case ' ': flags |= cf_space_positive; goto flags; - case '+': flags |= cf_plus_positive; goto flags; - case '\'': flags |= cf_singlequote; goto flags; - case '_': flags &= ~cf_utf8; goto flags; - } - - // parse field width - field_width = -1; - if (*s == '*') { - field_width = va_arg(val, int); - if (field_width < 0) { - field_width = -field_width; - flags |= cf_left_just; - } - s++; - } else if (*s >= '0' && *s <= '9') - for (field_width = 0; *s >= '0' && *s <= '9'; s++) - field_width = 10*field_width + *s - '0'; - - // parse precision - precision = -1; - if (*s == '.') { - s++; - precision = 0; - if (*s == '*') { - precision = va_arg(val, int); - s++; - } else if (*s >= '0' && *s <= '9') - for (; *s >= '0' && *s <= '9'; s++) - precision = 10*precision + *s - '0'; - } - - // parse width flags - width_flag = 0; + switch (*++s) { + case '#': flags |= cf_alternate_form; goto flags; + case '0': flags |= cf_zero_pad; goto flags; + case '-': flags |= cf_left_just; goto flags; + case ' ': flags |= cf_space_positive; goto flags; + case '+': flags |= cf_plus_positive; goto flags; + case '\'': flags |= cf_singlequote; goto flags; + case '_': flags &= ~cf_utf8; goto flags; + } + + // parse field width + field_width = -1; + if (*s == '*') { + field_width = va_arg(val, int); + if (field_width < 0) { + field_width = -field_width; + flags |= cf_left_just; + } + s++; + } else if (*s >= '0' && *s <= '9') + for (field_width = 0; *s >= '0' && *s <= '9'; s++) + field_width = 10*field_width + *s - '0'; + + // parse precision + precision = -1; + if (*s == '.') { + s++; + precision = 0; + if (*s == '*') { + precision = va_arg(val, int); + s++; + } else if (*s >= '0' && *s <= '9') + for (; *s >= '0' && *s <= '9'; s++) + precision = 10*precision + *s - '0'; + } + + // parse width flags + width_flag = 0; width_flags: - switch (*s) { - case 'h': case 'l': - if (width_flag == *s) - width_flag = *s + 'A' - 'a'; - else if (width_flag) - break; - else - width_flag = *s; - s++; - goto width_flags; - case 'z': - case 't': - if (width_flag) - break; - width_flag = *s++; - break; - case '^': - if (!isdigit((unsigned char) s[1]) || width_flag) - break; - for (s++; isdigit((unsigned char) *s); s++) - width_flag = width_flag * 10 + *s - '0'; - width_flag = -width_flag; - break; - } - - // conversion character - // after switch, data lies between `s1' and `s2' - const char *s1 = 0, *s2 = 0; - base = 10; - switch (*s++) { - - case 's': { - s1 = va_arg(val, const char *); - if (!s1) - s1 = "(null)"; - - // fetch length - int len; - if (precision < 0) - len = strlen(s1); - else - len = strnlen(s1, precision); - - // transform string if alternate form - if (flags & cf_alternate_form) { - strstore = String(s1, len).printable(); - if (precision < 0 || strstore.length() < precision) - len = strstore.length(); - } - - // quote characters that look like annotations, readjusting length - if (flags & (cf_singlequote | cf_alternate_form)) { - if (!(flags & cf_alternate_form)) - strstore = String(s1, len); - - // check first line, considering trailing part of 'msg' - const char *mbegin = msg.end(); - while (mbegin != msg.begin() && mbegin[-1] != '\n') - --mbegin; - if (skip_anno(strstore.begin(), strstore.end()) != strstore.begin() - && skip_anno(mbegin, msg.end()) == msg.end()) { - strstore = String::make_stable("{}", 2) + strstore; - len += 2; - } - - // check subsequent lines - const char *s = std::find(strstore.begin(), strstore.end(), '\n'); - while (s != strstore.end() && s + 1 != strstore.end()) { - size_t nextpos = (s + 1) - strstore.begin(); - if (skip_anno(s + 1, strstore.end()) != s + 1) { - strstore = strstore.substring(strstore.begin(), s + 1) - + String::make_stable("{}", 2) - + strstore.substring(s + 1, strstore.end()); - len += 2; - } - s = std::find(strstore.begin() + nextpos, strstore.end(), '\n'); - } - } - - // obtain begin and end pointers - if (flags & (cf_singlequote | cf_alternate_form)) - s1 = strstore.begin(); - s2 = s1 + len; - break; - } - - case 'c': { - int c = va_arg(val, int); - // check for extension of 'signed char' to 'int' - if (c < 0) - c += 256; - // assume ASCII - if (c == '\n') - strcpy(numbuf, "\\n"); - else if (c == '\t') - strcpy(numbuf, "\\t"); - else if (c == '\r') - strcpy(numbuf, "\\r"); - else if (c == '\0') - strcpy(numbuf, "\\0"); - else if (c < 0 || c >= 256) - strcpy(numbuf, "(bad char)"); - else if (c < 32 || c >= 0177) - sprintf(numbuf, "\\%03o", c); - else - sprintf(numbuf, "%c", c); - s1 = numbuf; - s2 = strchr(numbuf, 0); - break; - } - - case '%': { - numbuf[0] = '%'; - s1 = numbuf; - s2 = s1 + 1; - break; - } - - case '<': - s1 = (flags & cf_utf8 ? "\342\200\230" : "\'"); - s2 = s1 + strlen(s1); - break; - - case '>': - case ',': - s1 = (flags & cf_utf8 ? "\342\200\231" : "\'"); - s2 = s1 + strlen(s1); - break; - - case 'd': - case 'i': - flags |= cf_signed; + switch (*s) { + case 'h': case 'l': + if (width_flag == *s) + width_flag = *s + 'A' - 'a'; + else if (width_flag) + break; + else + width_flag = *s; + s++; + goto width_flags; + case 'z': + case 't': + if (width_flag) + break; + width_flag = *s++; + break; + case '^': + if (!isdigit((unsigned char) s[1]) || width_flag) + break; + for (s++; isdigit((unsigned char) *s); s++) + width_flag = width_flag * 10 + *s - '0'; + width_flag = -width_flag; + break; + } + + // conversion character + // after switch, data lies between `s1' and `s2' + const char *s1 = 0, *s2 = 0; + base = 10; + switch (*s++) { + + case 's': { + s1 = va_arg(val, const char *); + if (!s1) + s1 = "(null)"; + + // fetch length + int len; + if (precision < 0) + len = strlen(s1); + else + len = strnlen(s1, precision); + + // transform string if alternate form + if (flags & cf_alternate_form) { + strstore = String(s1, len).printable(); + if (precision < 0 || strstore.length() < precision) + len = strstore.length(); + } + + // quote characters that look like annotations, readjusting length + if (flags & (cf_singlequote | cf_alternate_form)) { + if (!(flags & cf_alternate_form)) + strstore = String(s1, len); + + // check first line, considering trailing part of 'msg' + const char *mbegin = msg.end(); + while (mbegin != msg.begin() && mbegin[-1] != '\n') + --mbegin; + if (skip_anno(strstore.begin(), strstore.end()) != strstore.begin() + && skip_anno(mbegin, msg.end()) == msg.end()) { + strstore = String::make_stable("{}", 2) + strstore; + len += 2; + } + + // check subsequent lines + const char *s = std::find(strstore.begin(), strstore.end(), '\n'); + while (s != strstore.end() && s + 1 != strstore.end()) { + size_t nextpos = (s + 1) - strstore.begin(); + if (skip_anno(s + 1, strstore.end()) != s + 1) { + strstore = strstore.substring(strstore.begin(), s + 1) + + String::make_stable("{}", 2) + + strstore.substring(s + 1, strstore.end()); + len += 2; + } + s = std::find(strstore.begin() + nextpos, strstore.end(), '\n'); + } + } + + // obtain begin and end pointers + if (flags & (cf_singlequote | cf_alternate_form)) + s1 = strstore.begin(); + s2 = s1 + len; + break; + } + + case 'c': { + int c = va_arg(val, int); + // check for extension of 'signed char' to 'int' + if (c < 0) + c += 256; + // assume ASCII + if (c == '\n') + strcpy(numbuf, "\\n"); + else if (c == '\t') + strcpy(numbuf, "\\t"); + else if (c == '\r') + strcpy(numbuf, "\\r"); + else if (c == '\0') + strcpy(numbuf, "\\0"); + else if (c < 0 || c >= 256) + strcpy(numbuf, "(bad char)"); + else if (c < 32 || c >= 0177) + snprintf(numbuf, sizeof(numbuf), "\\%03o", c); + else + snprintf(numbuf, sizeof(numbuf), "%c", c); + s1 = numbuf; + s2 = strchr(numbuf, 0); + break; + } + + case '%': { + numbuf[0] = '%'; + s1 = numbuf; + s2 = s1 + 1; + break; + } + + case '<': + s1 = (flags & cf_utf8 ? "\342\200\230" : "\'"); + s2 = s1 + strlen(s1); + break; + + case '>': + case ',': + s1 = (flags & cf_utf8 ? "\342\200\231" : "\'"); + s2 = s1 + strlen(s1); + break; + + case 'd': + case 'i': + flags |= cf_signed; /* fallthru */ - case 'u': - number: { - // protect numbuf from overflow - if (field_width > NUMBUF_SIZE) - field_width = NUMBUF_SIZE; - if (precision > NUMBUF_SIZE - 4) - precision = NUMBUF_SIZE - 4; - - s2 = numbuf + NUMBUF_SIZE; - - do_number_t num; - switch (width_flag) { - case 'H': - case -8: - num = (unsigned char) va_arg(val, int); - if ((flags & cf_signed) && (signed char) num < 0) - num = -(signed char) num, flags |= cf_negative; - break; - case 'h': - case -16: - num = (unsigned short) va_arg(val, int); - if ((flags & cf_signed) && (short) num < 0) - num = -(short) num, flags |= cf_negative; - break; - case 0: - case -32: + case 'u': + number: { + // protect numbuf from overflow + if (field_width > NUMBUF_SIZE) + field_width = NUMBUF_SIZE; + if (precision > NUMBUF_SIZE - 4) + precision = NUMBUF_SIZE - 4; + + s2 = numbuf + NUMBUF_SIZE; + + do_number_t num; + switch (width_flag) { + case 'H': + case -8: + num = (unsigned char) va_arg(val, int); + if ((flags & cf_signed) && (signed char) num < 0) + num = -(signed char) num, flags |= cf_negative; + break; + case 'h': + case -16: + num = (unsigned short) va_arg(val, int); + if ((flags & cf_signed) && (short) num < 0) + num = -(short) num, flags |= cf_negative; + break; + case 0: + case -32: #if SIZEOF_LONG == 4 - case 'l': + case 'l': #endif #if SIZEOF_SIZE_T == 4 - case 'z': + case 'z': #endif #if SIZEOF_PTRDIFF_T == 4 - case 't': + case 't': #endif - num = va_arg(val, unsigned); - if ((flags & cf_signed) && (int) num < 0) - num = -(int) num, flags |= cf_negative; - break; + num = va_arg(val, unsigned); + if ((flags & cf_signed) && (int) num < 0) + num = -(int) num, flags |= cf_negative; + break; #if HAVE_INT64_TYPES # if SIZEOF_LONG == 8 - case 'l': + case 'l': # endif # if SIZEOF_LONG_LONG == 8 - case 'L': + case 'L': # endif # if SIZEOF_SIZE_T == 8 - case 'z': + case 'z': # endif # if SIZEOF_PTRDIFF_T == 8 - case 't': + case 't': # endif - case -64: { - uint64_t qnum = va_arg(val, uint64_t); - if ((flags & cf_signed) && (int64_t)qnum < 0) - qnum = -(int64_t) qnum, flags |= cf_negative; - StringAccum sa; - sa.append_numeric(static_cast<String::uintmax_t>(qnum), base, (flags & cf_uppercase)); - s1 = s2 - sa.length(); - memcpy(const_cast<char*>(s1), sa.data(), s2 - s1); - goto got_number; - } + case -64: { + uint64_t qnum = va_arg(val, uint64_t); + if ((flags & cf_signed) && (int64_t)qnum < 0) + qnum = -(int64_t) qnum, flags |= cf_negative; + StringAccum sa; + sa.append_numeric(static_cast<String::uintmax_t>(qnum), base, (flags & cf_uppercase)); + s1 = s2 - sa.length(); + memcpy(const_cast<char*>(s1), sa.data(), s2 - s1); + goto got_number; + } #endif - default: - goto error; - } - s1 = do_number(num, (char*) s2, base, flags); + default: + goto error; + } + s1 = do_number(num, (char*) s2, base, flags); #if HAVE_INT64_TYPES - got_number: + got_number: #endif - s1 = do_number_flags((char*)s1, (char*) s2, base, flags, precision, field_width); - break; - } + s1 = do_number_flags((char*)s1, (char*) s2, base, flags, precision, field_width); + break; + } - case 'o': - base = 8; - goto number; + case 'o': + base = 8; + goto number; - case 'X': - flags |= cf_uppercase; + case 'X': + flags |= cf_uppercase; /* fallthru */ - case 'x': - base = 16; - goto number; - - case 'p': { - if (*s == '{') { - s1 = s2 = s + 1; - while (*s2 && *s2 != '}' && !isspace((unsigned char) *s2)) - ++s2; - if (*s2 == '}') - goto braces; - } - void* v = va_arg(val, void*); - s2 = numbuf + NUMBUF_SIZE; - s1 = do_number((do_number_t) v, (char*) s2, 16, flags); - s1 = do_number_flags((char*) s1, (char*) s2, 16, flags | cf_alternate_form, precision, field_width); - break; - } + case 'x': + base = 16; + goto number; + + case 'p': { + if (*s == '{') { + s1 = s2 = s + 1; + while (*s2 && *s2 != '}' && !isspace((unsigned char) *s2)) + ++s2; + if (*s2 == '}') + goto braces; + } + void* v = va_arg(val, void*); + s2 = numbuf + NUMBUF_SIZE; + s1 = do_number((do_number_t) v, (char*) s2, 16, flags); + s1 = do_number_flags((char*) s1, (char*) s2, 16, flags | cf_alternate_form, precision, field_width); + break; + } #ifndef __KERNEL__ - case 'e': case 'f': case 'g': - case 'E': case 'F': case 'G': { - char format[80], *f = format, new_numbuf[NUMBUF_SIZE]; - *f++ = '%'; - if (flags & cf_alternate_form) - *f++ = '#'; - if (precision >= 0) - f += sprintf(f, ".%d", precision); - *f++ = s[-1]; - *f++ = 0; - - int len = sprintf(new_numbuf, format, va_arg(val, double)); - - s2 = numbuf + NUMBUF_SIZE; - s1 = s2 - len; - memcpy((char *)s1, new_numbuf, len); // note: no terminating \0 - s1 = do_number_flags((char *)s1, (char *)s2, 10, flags & ~cf_alternate_form, -1, field_width); - break; - } + case 'e': case 'f': case 'g': + case 'E': case 'F': case 'G': { + char format[80], *f = format, new_numbuf[NUMBUF_SIZE]; + *f++ = '%'; + if (flags & cf_alternate_form) + *f++ = '#'; + if (precision >= 0) + f += snprintf(f, 72, ".%d", precision); + *f++ = s[-1]; + *f++ = 0; + + int len = snprintf(new_numbuf, sizeof(new_numbuf), format, va_arg(val, double)); + + s2 = numbuf + NUMBUF_SIZE; + s1 = s2 - len; + memcpy((char *)s1, new_numbuf, len); // note: no terminating \0 + s1 = do_number_flags((char *)s1, (char *)s2, 10, flags & ~cf_alternate_form, -1, field_width); + break; + } #endif - case '{': - s1 = s2 = s; - while (*s2 && *s2 != '}' && !isspace((unsigned char) *s2)) - ++s2; - if (*s2 != '}') - goto error; - goto braces; - - braces: - s = s2 + 1; - for (Conversion *item = error_items; item; item = item->next) - if (item->name.equals(s1, s2 - s1)) { - strstore = item->hook(flags, VA_LIST_REF(val)); - s1 = strstore.begin(); - s2 = strstore.end(); - goto got_result; - } - goto error; - - error: - default: - assert(0 /* Bad % in error */); - break; - - } - - // add result of conversion + case '{': + s1 = s2 = s; + while (*s2 && *s2 != '}' && !isspace((unsigned char) *s2)) + ++s2; + if (*s2 != '}') + goto error; + goto braces; + + braces: + s = s2 + 1; + for (Conversion *item = error_items; item; item = item->next) + if (item->name.equals(s1, s2 - s1)) { + strstore = item->hook(flags, VA_LIST_REF(val)); + s1 = strstore.begin(); + s2 = strstore.end(); + goto got_result; + } + goto error; + + error: + default: + assert(0 /* Bad % in error */); + break; + + } + + // add result of conversion got_result: - int slen = s2 - s1; - if (slen > field_width) - field_width = slen; - char *dest = msg.extend(field_width); - if (flags & cf_left_just) { - memcpy(dest, s1, slen); - memset(dest + slen, ' ', field_width - slen); - } else { - memcpy(dest + field_width - slen, s1, slen); - memset(dest, (flags & cf_zero_pad ? '0' : ' '), field_width - slen); - } + int slen = s2 - s1; + if (slen > field_width) + field_width = slen; + char *dest = msg.extend(field_width); + if (flags & cf_left_just) { + memcpy(dest, s1, slen); + memset(dest + slen, ' ', field_width - slen); + } else { + memcpy(dest + field_width - slen, s1, slen); + memset(dest, (flags & cf_zero_pad ? '0' : ' '), field_width - slen); + } } return msg.take_string(); @@ -896,13 +896,13 @@ ErrorHandler::xmessage(const String &str) const char *s = xstr.begin(), *end = xstr.end(); void *user_data = 0; while (s != end) { - const char *l = parse_anno(xstr, s, end, "#<>", &xlevel, - (const char *) 0); - const char *nl = std::find(l, end, '\n'); - String line = xstr.substring(s, nl); - s = nl + (nl != end); - user_data = emit(line, user_data, s != end); - min_level = (xlevel < min_level ? xlevel : min_level); + const char *l = parse_anno(xstr, s, end, "#<>", &xlevel, + (const char *) 0); + const char *nl = std::find(l, end, '\n'); + String line = xstr.substring(s, nl); + s = nl + (nl != end); + user_data = emit(line, user_data, s != end); + min_level = (xlevel < min_level ? xlevel : min_level); } account(min_level); @@ -953,10 +953,10 @@ FileErrorHandler::FileErrorHandler(FILE *f, const String &context) # if HAVE_UNISTD_H if (isatty(fileno(_f))) { # endif - char *s = getenv("LANG"); - if (s && (strstr(s, "UTF-8") != 0 || strstr(s, "UTF8") != 0 - || strstr(s, "utf8") != 0)) - _default_flags |= cf_utf8; + char *s = getenv("LANG"); + if (s && (strstr(s, "UTF-8") != 0 || strstr(s, "UTF8") != 0 + || strstr(s, "utf8") != 0)) + _default_flags |= cf_utf8; # if HAVE_UNISTD_H } # endif @@ -973,7 +973,7 @@ FileErrorHandler::emit(const String &str, void *, bool) { String landmark; const char *s = parse_anno(str, str.begin(), str.end(), - "l", &landmark, (const char *) 0); + "l", &landmark, (const char *) 0); StringAccum sa; sa << _context << clean_landmark(landmark, true) << str.substring(s, str.end()) << '\n'; @@ -993,13 +993,13 @@ ErrorHandler::Conversion * ErrorHandler::add_conversion(const String &name, ConversionFunction function) { if (Conversion *c = new Conversion) { - c->name = name; - c->hook = function; - c->next = error_items; - error_items = c; - return c; + c->name = name; + c->hook = function; + c->next = error_items; + error_items = c; + return c; } else - return 0; + return 0; } int @@ -1007,11 +1007,11 @@ ErrorHandler::remove_conversion(ErrorHandler::Conversion *conv) { Conversion **pprev = &error_items; for (Conversion *c = error_items; c; pprev = &c->next, c = *pprev) - if (c == conv) { - *pprev = c->next; - delete c; - return 0; - } + if (c == conv) { + *pprev = c->next; + delete c; + return 0; + } return -1; } @@ -1019,8 +1019,8 @@ ErrorHandler * ErrorHandler::static_initialize(ErrorHandler *default_handler) { if (!the_silent_handler) { - the_default_handler = default_handler; - the_silent_handler = new SilentErrorHandler; + the_default_handler = default_handler; + the_silent_handler = new SilentErrorHandler; } return default_handler; } @@ -1032,9 +1032,9 @@ ErrorHandler::static_cleanup() delete the_silent_handler; the_default_handler = the_silent_handler = 0; while (error_items) { - Conversion *next = error_items->next; - delete error_items; - error_items = next; + Conversion *next = error_items->next; + delete error_items; + error_items = next; } } @@ -1053,27 +1053,27 @@ String ErrorVeneer::vformat(const char *fmt, va_list val) { if (_errh) - return _errh->vformat(fmt, val); + return _errh->vformat(fmt, val); else - return ErrorHandler::vformat(fmt, val); + return ErrorHandler::vformat(fmt, val); } String ErrorVeneer::decorate(const String &str) { if (_errh) - return _errh->decorate(str); + return _errh->decorate(str); else - return ErrorHandler::decorate(str); + return ErrorHandler::decorate(str); } void * ErrorVeneer::emit(const String &str, void *user_data, bool more) { if (_errh) - return _errh->emit(str, user_data, more); + return _errh->emit(str, user_data, more); else - return ErrorHandler::emit(str, user_data, more); + return ErrorHandler::emit(str, user_data, more); } void @@ -1081,7 +1081,7 @@ ErrorVeneer::account(int level) { ErrorHandler::account(level); if (_errh) - _errh->account(level); + _errh->account(level); } @@ -1090,7 +1090,7 @@ ErrorVeneer::account(int level) // ContextErrorHandler::ContextErrorHandler(ErrorHandler *errh, const char *fmt, - ...) + ...) : ErrorVeneer(errh), _indent(String::make_stable(" ", 2)), _context_landmark("{l:}"), _context_printed(false) { @@ -1099,7 +1099,7 @@ ContextErrorHandler::ContextErrorHandler(ErrorHandler *errh, const char *fmt, _context = ErrorVeneer::vformat(fmt, val); va_end(val); if (_context) - _context = combine_anno(_context, String::make_stable("{context:context}", 17)); + _context = combine_anno(_context, String::make_stable("{context:context}", 17)); } String @@ -1107,26 +1107,26 @@ ContextErrorHandler::decorate(const String &str) { String context_anno; const char *str_endanno = parse_anno(str, str.begin(), str.end(), - "context", &context_anno, - (const char *) 0); + "context", &context_anno, + (const char *) 0); if (context_anno.equals("no", 2)) - return ErrorVeneer::decorate(str); + return ErrorVeneer::decorate(str); String istr; if (context_anno.equals("noindent", 8)) - istr = combine_anno(str, _context_landmark); + istr = combine_anno(str, _context_landmark); else - istr = combine_anno(str, _context_landmark + _indent); + istr = combine_anno(str, _context_landmark + _indent); if (!_context_printed && !context_anno.equals("nocontext", 9)) { - String astr = combine_anno(combine_anno(_context, _context_landmark), - str.substring(str.begin(), str_endanno)); - if (astr && astr.back() != '\n') - astr += '\n'; - _context_printed = true; - return ErrorVeneer::decorate(astr + istr); + String astr = combine_anno(combine_anno(_context, _context_landmark), + str.substring(str.begin(), str_endanno)); + if (astr && astr.back() != '\n') + astr += '\n'; + _context_printed = true; + return ErrorVeneer::decorate(astr + istr); } else - return ErrorVeneer::decorate(istr); + return ErrorVeneer::decorate(istr); } @@ -1135,7 +1135,7 @@ ContextErrorHandler::decorate(const String &str) // PrefixErrorHandler::PrefixErrorHandler(ErrorHandler *errh, - const String &prefix) + const String &prefix) : ErrorVeneer(errh), _prefix(prefix) { } @@ -1179,7 +1179,7 @@ BailErrorHandler::account(int level) { ErrorVeneer::account(level); if (level <= _level) - exit(1); + exit(1); } #endif diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/globmatch.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/globmatch.cc index 891c9b09955..d42f138e256 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/globmatch.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/globmatch.cc @@ -2,7 +2,7 @@ /* globmatch.{cc,hh} -- glob_match() function for shell globbing * - * Copyright (c) 2000-2019 Eddie Kohler + * Copyright (c) 2000-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -31,86 +31,86 @@ glob_match(const String& str, const String& pattern) Vector<int> glob_ppos, glob_spos1, glob_spos2; while (1) { - while (ppos < plen) - switch (pdata[ppos]) { + while (ppos < plen) + switch (pdata[ppos]) { - case '?': - if (spos >= slen) - goto done; - spos++; - ppos++; - break; + case '?': + if (spos >= slen) + goto done; + spos++; + ppos++; + break; - case '*': - glob_ppos.push_back(ppos + 1); - glob_spos1.push_back(spos); - glob_spos2.push_back(slen); - spos = slen; - ppos++; - break; + case '*': + glob_ppos.push_back(ppos + 1); + glob_spos1.push_back(spos); + glob_spos2.push_back(slen); + spos = slen; + ppos++; + break; - case '[': { - if (spos >= slen) - goto done; + case '[': { + if (spos >= slen) + goto done; - // find end of character class - int p = ppos + 1; - bool negated = false; - if (p < plen && pdata[p] == '^') { - negated = true; - p++; - } - int first = p; - if (p < plen && pdata[p] == ']') - p++; - while (p < plen && pdata[p] != ']') - p++; - if (p >= plen) // not a character class at all - goto ordinary; + // find end of character class + int p = ppos + 1; + bool negated = false; + if (p < plen && pdata[p] == '^') { + negated = true; + p++; + } + int first = p; + if (p < plen && pdata[p] == ']') + p++; + while (p < plen && pdata[p] != ']') + p++; + if (p >= plen) // not a character class at all + goto ordinary; - // parse character class - bool in = false; - for (int i = first; i < p && !in; i++) { - int c1 = pdata[i]; - int c2 = c1; - if (i < p - 2 && pdata[i+1] == '-') { - c2 = pdata[i+2]; - i += 2; - } - if (sdata[spos] >= c1 && sdata[spos] <= c2) - in = true; - } + // parse character class + bool in = false; + for (int i = first; i < p && !in; i++) { + int c1 = pdata[i]; + int c2 = c1; + if (i < p - 2 && pdata[i+1] == '-') { + c2 = pdata[i+2]; + i += 2; + } + if (sdata[spos] >= c1 && sdata[spos] <= c2) + in = true; + } - if ((negated && in) || (!negated && !in)) - goto done; - ppos = p + 1; - spos++; - break; - } + if ((negated && in) || (!negated && !in)) + goto done; + ppos = p + 1; + spos++; + break; + } - default: - ordinary: - if (spos >= slen || sdata[spos] != pdata[ppos]) - goto done; - spos++; - ppos++; - break; + default: + ordinary: + if (spos >= slen || sdata[spos] != pdata[ppos]) + goto done; + spos++; + ppos++; + break; - } + } done: - if (spos == slen && ppos == plen) - return true; - while (glob_ppos.size() && glob_spos1.back() == glob_spos2.back()) { - glob_ppos.pop_back(); - glob_spos1.pop_back(); - glob_spos2.pop_back(); - } - if (glob_ppos.size()) { - glob_spos2.back()--; - spos = glob_spos2.back(); - ppos = glob_ppos.back(); - } else - return false; + if (spos == slen && ppos == plen) + return true; + while (glob_ppos.size() && glob_spos1.back() == glob_spos2.back()) { + glob_ppos.pop_back(); + glob_spos1.pop_back(); + glob_spos2.pop_back(); + } + if (glob_ppos.size()) { + glob_spos2.back()--; + spos = glob_spos2.back(); + ppos = glob_ppos.back(); + } else + return false; } } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/landmark.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/landmark.cc index 3d4252e5d19..ce0975d3aff 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/landmark.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/landmark.cc @@ -2,7 +2,7 @@ /* landmark.{cc,hh} -- FILE:LINE type landmarks * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -22,15 +22,15 @@ Landmark operator+(const Landmark &landmark, int offset) { if (landmark.has_line()) - return Landmark(landmark.file(), landmark.line() + offset); + return Landmark(landmark.file(), landmark.line() + offset); else - return landmark; + return landmark; } Landmark::operator String() const { if (_file && has_line()) - return _file + ":" + String(_line); + return _file + ":" + String(_line); else - return _file; + return _file; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/permstr.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/permstr.cc index 55d4b30fd0e..0b016cdb583 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/permstr.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/permstr.cc @@ -2,7 +2,7 @@ /* permstr.{cc,hh} -- permanent strings * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -33,8 +33,8 @@ PermString::Initializer::Initializer() { static int initialized = 0; if (!initialized) { - PermString::static_initialize(); - initialized = 1; + PermString::static_initialize(); + initialized = 1; } } @@ -42,10 +42,10 @@ void PermString::static_initialize() { for (int i = 0; i < 256; i++) { - one_char_doodad[i].next = 0; - one_char_doodad[i].length = 1; - one_char_doodad[i].data[0] = i; - one_char_doodad[i].data[1] = 0; + one_char_doodad[i].next = 0; + one_char_doodad[i].length = 1; + one_char_doodad[i].data[0] = i; + one_char_doodad[i].data[1] = 0; } } @@ -114,28 +114,28 @@ PermString::initialize(const char* s, int length) const unsigned char* mm; if (length < 0) - length = (s ? strlen(s) : 0); + length = (s ? strlen(s) : 0); if (length == 0) { - _rep = zero_char_doodad.data; - return; + _rep = zero_char_doodad.data; + return; } else if (length == 1) { - _rep = one_char_doodad[m[0]].data; - return; + _rep = one_char_doodad[m[0]].data; + return; } unsigned hash; int l; for (hash = 0, l = length, mm = m; l; mm++, l--) - hash = (hash << 1) + scatter[*mm]; + hash = (hash << 1) + scatter[*mm]; hash &= (NHASH - 1); Doodad *buck; for (buck = buckets[hash]; buck; buck = buck->next) - if (length == buck->length && memcmp(s, buck->data, length) == 0) { - _rep = buck->data; - return; - } + if (length == buck->length && memcmp(s, buck->data, length) == 0) { + _rep = buck->data; + return; + } // CANNOT USE new because the structure has variable size. buck = (Doodad *)malloc(sizeof(Doodad) + length - 1); @@ -156,8 +156,8 @@ static void append(const char *s, int len) { if (pspos + len >= pscap) { - pscap *= 2; - psc = (char *)realloc(psc, pscap); + pscap *= 2; + psc = (char *)realloc(psc, pscap); } memcpy(psc + pspos, s, len); pspos += len; @@ -167,8 +167,8 @@ inline static void extend(int len) { while (pspos + len >= pscap) { - pscap *= 2; - psc = (char *)realloc(psc, pscap); + pscap *= 2; + psc = (char *)realloc(psc, pscap); } } @@ -178,118 +178,117 @@ vpermprintf(const char *s, va_list val) pspos = 0; while (1) { - const char *pct = strchr(s, '%'); - if (!pct) { - if (*s) - append(s, strlen(s)); - break; - } - if (pct != s) { - append(s, pct - s); - s = pct; - } - - int iflag = -1; - while (1) - switch (*++s) { - - case '0': - /* zeroflag = 1; */ - break; - - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - assert(iflag == -1 /* Too many decimal flags in permprintf */); - iflag = 0; - while (*s >= '0' && *s <= '9') { - iflag = iflag * 10 + *s - '0'; - s++; - } - break; - - case '*': - assert(iflag == -1 /* iflag given */); - iflag = va_arg(val, int); - break; - - case 's': { - const char *x = va_arg(val, const char *); - if (x) { - if (iflag < 0) - append(x, strlen(x)); - else - append(x, iflag); - } - goto pctdone; - } - - case 'c': { - char c = (char)(va_arg(val, int) & 0xFF); - append(&c, 1); - goto pctdone; - } - - case 'p': { - PermString::Capsule x = va_arg(val, PermString::Capsule); - PermString px; - if (x) - px = PermString::decapsule(x); - if (iflag < 0 || iflag > px.length()) - append(px.c_str(), px.length()); - else - append(px.c_str(), iflag); - goto pctdone; - } - - case 'd': { - // FIXME FIXME rewrite for sense - int x = va_arg(val, int); - if (pspos == pscap) - extend(1); - - // FIXME -2^31 - unsigned int ux = x; - if (x < 0) { - psc[pspos++] = '-'; - ux = -x; - } - - int numdigits = 0; - for (unsigned digcountx = ux; digcountx > 9; digcountx /= 10) - numdigits++; - - extend(numdigits + 1); - int digit = numdigits; - do { - psc[pspos + digit] = (ux % 10) + '0'; - ux /= 10; - digit--; - } while (ux); - pspos += numdigits + 1; - - goto pctdone; - } - - case 'g': { - // FIXME FIXME rewrite for sense - double x = va_arg(val, double); - char buffer[1000]; - int len; - sprintf(buffer, "%.10g%n", x, &len); - extend(len); - strcpy(psc + pspos, buffer); - pspos += len; - goto pctdone; - } - - default: - assert(0 /* Bad % in permprintf */); - goto pctdone; - - } + const char *pct = strchr(s, '%'); + if (!pct) { + if (*s) + append(s, strlen(s)); + break; + } + if (pct != s) { + append(s, pct - s); + s = pct; + } + + int iflag = -1; + while (1) + switch (*++s) { + + case '0': + /* zeroflag = 1; */ + break; + + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + assert(iflag == -1 /* Too many decimal flags in permprintf */); + iflag = 0; + while (*s >= '0' && *s <= '9') { + iflag = iflag * 10 + *s - '0'; + s++; + } + break; + + case '*': + assert(iflag == -1 /* iflag given */); + iflag = va_arg(val, int); + break; + + case 's': { + const char *x = va_arg(val, const char *); + if (x) { + if (iflag < 0) + append(x, strlen(x)); + else + append(x, iflag); + } + goto pctdone; + } + + case 'c': { + char c = (char)(va_arg(val, int) & 0xFF); + append(&c, 1); + goto pctdone; + } + + case 'p': { + PermString::Capsule x = va_arg(val, PermString::Capsule); + PermString px; + if (x) + px = PermString::decapsule(x); + if (iflag < 0 || iflag > px.length()) + append(px.c_str(), px.length()); + else + append(px.c_str(), iflag); + goto pctdone; + } + + case 'd': { + // FIXME FIXME rewrite for sense + int x = va_arg(val, int); + if (pspos == pscap) + extend(1); + + // FIXME -2^31 + unsigned int ux = x; + if (x < 0) { + psc[pspos++] = '-'; + ux = -x; + } + + int numdigits = 0; + for (unsigned digcountx = ux; digcountx > 9; digcountx /= 10) + numdigits++; + + extend(numdigits + 1); + int digit = numdigits; + do { + psc[pspos + digit] = (ux % 10) + '0'; + ux /= 10; + digit--; + } while (ux); + pspos += numdigits + 1; + + goto pctdone; + } + + case 'g': { + // FIXME FIXME rewrite for sense + double x = va_arg(val, double); + char buffer[1000]; + int len = snprintf(buffer, sizeof(buffer), "%.10g", x); + extend(len); + strcpy(psc + pspos, buffer); + pspos += len; + goto pctdone; + } + + default: + assert(0 /* Bad % in permprintf */); + goto pctdone; + + } pctdone: - s++; + s++; } return PermString(psc, pspos); @@ -307,7 +306,7 @@ PermString permprintf(const char *s, ...) PermString permcat(PermString a, PermString b) { if (!a || !b) - return a ? a : b; + return a ? a : b; unsigned al = a.length(); unsigned bl = b.length(); char *s = new char[al + bl]; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/point.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/point.cc index 9fd881e9612..6e17c4c90fa 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/point.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/point.cc @@ -2,7 +2,7 @@ /* point.{cc,hh} -- 2D points * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -46,12 +46,12 @@ Point::on_segment(const Point &a, const Point &b, double t) const noexcept double tt; Point c = b - a; if (fabs(c.x) > fabs(c.y)) - tt = (x - a.x) / c.x; + tt = (x - a.x) / c.x; else if (c.y) - tt = (y - a.y) / c.y; + tt = (y - a.y) / c.y; else - tt = 0; + tt = 0; if (tt < 0 || tt > 1) - return 0; + return 0; return on_line(a, b, t); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/slurper.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/slurper.cc index 0755059e825..4d0d2347540 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/slurper.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/slurper.cc @@ -2,7 +2,7 @@ /* slurper.{cc,hh} -- reading from files a line at a time * - * Copyright (c) 1998-2019 Eddie Kohler + * Copyright (c) 1998-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -19,8 +19,8 @@ #include <lcdf/slurper.hh> #include <string.h> -static const int DefChunkCap = 2048; -static const int WorthMoving = 256; +static const int DefChunkCap = 2048; +static const int WorthMoving = 256; Slurper::Slurper(const Filename &filename, FILE *f) @@ -88,7 +88,7 @@ Slurper::get_line_at(unsigned pos) while (1) { for (; pos < _len; pos++) if (_data[pos] == '\n' || _data[pos] == '\r') - goto line_ends_at_pos; + goto line_ends_at_pos; // no line end? look for more data. save and reset `pos', since _pos // may change. @@ -107,10 +107,10 @@ Slurper::get_line_at(unsigned pos) unsigned next_pos; // Find beginning of next line. 3 cases: - // 1. line ends in \r\n -> _pos = pos + 2; - // 2. line ends in \r OR \n -> _pos = pos + 1; - // 3. neither -> must be last line in file; _pos = pos, - // since pos == _len + // 1. line ends in \r\n -> _pos = pos + 2; + // 2. line ends in \r OR \n -> _pos = pos + 1; + // 3. neither -> must be last line in file; _pos = pos, + // since pos == _len if (pos == _len) { // last line in file didn't end in `\n': must have no data left // ensure we have enough space for terminating nul diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/straccum.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/straccum.cc index 6ee6b62f22b..ce034d35857 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/straccum.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/straccum.cc @@ -4,7 +4,7 @@ * Eddie Kohler * * Copyright (c) 1999-2000 Massachusetts Institute of Technology - * Copyright (c) 2001-2019 Eddie Kohler + * Copyright (c) 2001-2023 Eddie Kohler * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -55,6 +55,7 @@ * Out-of-memory StringAccum objects have length zero. */ +const char* StringAccum::double_format = "%.12g"; void StringAccum::assign_out_of_memory() @@ -62,12 +63,12 @@ StringAccum::assign_out_of_memory() assert(_cap >= 0); if (_cap > 0) delete[] (_s - MEMO_SPACE); - _s = reinterpret_cast<unsigned char *>(const_cast<char *>(String::out_of_memory_data())); + _s = reinterpret_cast<unsigned char*>(const_cast<char*>(String::out_of_memory_data())); _cap = -1; _len = 0; } -char * +char* StringAccum::grow(int want) { // can't append to out-of-memory strings @@ -80,7 +81,7 @@ StringAccum::grow(int want) while (ncap <= want) ncap = (ncap + MEMO_SPACE) * 2 - MEMO_SPACE; - unsigned char *n = new unsigned char[ncap + MEMO_SPACE]; + unsigned char* n = new unsigned char[ncap + MEMO_SPACE]; if (!n) { assign_out_of_memory(); errno = ENOMEM; @@ -94,7 +95,7 @@ StringAccum::grow(int want) } _s = n; _cap = ncap; - return reinterpret_cast<char *>(_s + _len); + return reinterpret_cast<char*>(_s + _len); } int @@ -109,27 +110,27 @@ StringAccum::resize(int len) } } -char * +char* StringAccum::hard_extend(int nadjust, int nreserve) { - char *x = grow(_len + nadjust + nreserve); + char* x = grow(_len + nadjust + nreserve); if (x) _len += nadjust; return x; } -const char * +const char* StringAccum::c_str() { if (_len < _cap || grow(_len)) _s[_len] = '\0'; - return reinterpret_cast<char *>(_s); + return reinterpret_cast<char*>(_s); } void StringAccum::append_fill(int c, int len) { - if (char *s = extend(len)) + if (char* s = extend(len)) memset(s, c, len); } @@ -155,11 +156,11 @@ StringAccum::append_utf8_hard(unsigned ch) } void -StringAccum::hard_append(const char *s, int len) +StringAccum::hard_append(const char* s, int len) { // We must be careful about calls like "sa.append(sa.begin(), sa.end())"; // a naive implementation might use sa's data after freeing it. - const char *my_s = reinterpret_cast<char *>(_s); + const char* my_s = reinterpret_cast<char*>(_s); if (len <= 0) { // do nothing @@ -171,14 +172,14 @@ StringAccum::hard_append(const char *s, int len) if (grow(_len + len)) goto success; } else { - unsigned char *old_s = _s; + unsigned char* old_s = _s; int old_len = _len; _s = 0; _len = 0; _cap = 0; - if (char *new_s = extend(old_len + len)) { + if (char* new_s = extend(old_len + len)) { memcpy(new_s, old_s, old_len); memcpy(new_s + old_len, s, len); } @@ -188,7 +189,7 @@ StringAccum::hard_append(const char *s, int len) } void -StringAccum::append(const char *s) +StringAccum::append(const char* s) { hard_append(s, strlen(s)); } @@ -198,7 +199,7 @@ StringAccum::take_string() { int len = length(); int cap = _cap; - char *str = reinterpret_cast<char *>(_s); + char* str = reinterpret_cast<char*>(_s); if (len > 0) { _s = 0; _len = _cap = 0; @@ -212,9 +213,9 @@ StringAccum::take_string() } void -StringAccum::swap(StringAccum &o) +StringAccum::swap(StringAccum& o) { - unsigned char *os = o._s; + unsigned char* os = o._s; int olen = o._len, ocap = o._cap; o._s = _s; o._len = _len, o._cap = _cap; @@ -225,11 +226,11 @@ StringAccum::swap(StringAccum &o) /** @relates StringAccum @brief Append decimal representation of @a i to @a sa. @return @a sa */ -StringAccum & -operator<<(StringAccum &sa, long i) +StringAccum& +operator<<(StringAccum& sa, long i) { - if (char *x = sa.reserve(24)) { - int len = sprintf(x, "%ld", i); + if (char* x = sa.reserve(24)) { + int len = snprintf(x, 24, "%ld", i); sa.adjust_length(len); } return sa; @@ -238,32 +239,32 @@ operator<<(StringAccum &sa, long i) /** @relates StringAccum @brief Append decimal representation of @a u to @a sa. @return @a sa */ -StringAccum & -operator<<(StringAccum &sa, unsigned long u) +StringAccum& +operator<<(StringAccum& sa, unsigned long u) { - if (char *x = sa.reserve(24)) { - int len = sprintf(x, "%lu", u); + if (char* x = sa.reserve(24)) { + int len = snprintf(x, 24, "%lu", u); sa.adjust_length(len); } return sa; } -StringAccum & -operator<<(StringAccum &sa, double d) +StringAccum& +operator<<(StringAccum& sa, double d) { - if (char *x = sa.reserve(256)) { - int len = sprintf(x, "%.12g", d); + if (char* x = sa.reserve(256)) { + int len = snprintf(x, 256, StringAccum::double_format, d); sa.adjust_length(len); } return sa; } -StringAccum & -StringAccum::snprintf(int n, const char *format, ...) +StringAccum& +StringAccum::snprintf(int n, const char* format, ...) { va_list val; va_start(val, format); - if (char *x = reserve(n + 1)) { + if (char* x = reserve(n + 1)) { #if HAVE_VSNPRINTF int len = vsnprintf(x, n + 1, format, val); #else @@ -277,7 +278,7 @@ StringAccum::snprintf(int n, const char *format, ...) } void -StringAccum::append_break_lines(const String& text, int linelen, const String &leftmargin) +StringAccum::append_break_lines(const String& text, int linelen, const String& leftmargin) { if (text.length() == 0) return; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/string.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/string.cc index 41e7ae0d602..399482557e7 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/string.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/string.cc @@ -4,7 +4,7 @@ * Eddie Kohler * * Copyright (c) 1999-2000 Massachusetts Institute of Technology - * Copyright (c) 2001-2019 Eddie Kohler + * Copyright (c) 2001-2023 Eddie Kohler * Copyright (c) 2008-2009 Meraki, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -103,24 +103,24 @@ String::create_memo(char *space, int dirty, int capacity) assert(capacity > 0 && capacity >= dirty); memo_t *memo; if (space) - memo = reinterpret_cast<memo_t *>(space); + memo = reinterpret_cast<memo_t *>(space); else - memo = reinterpret_cast<memo_t *>(new char[MEMO_SPACE + capacity]); + memo = reinterpret_cast<memo_t *>(new char[MEMO_SPACE + capacity]); if (memo) { - memo->capacity = capacity; - memo->dirty = dirty; - memo->refcount = (space ? 0 : 1); + memo->capacity = capacity; + memo->dirty = dirty; + memo->refcount = (space ? 0 : 1); #if HAVE_STRING_PROFILING - int bucket = profile_memo_size_bucket(dirty, capacity); - ++memo_sizes[bucket]; - ++live_memo_sizes[bucket]; - live_memo_bytes[bucket] += capacity; - ++live_memo_count; + int bucket = profile_memo_size_bucket(dirty, capacity); + ++memo_sizes[bucket]; + ++live_memo_sizes[bucket]; + live_memo_bytes[bucket] += capacity; + ++live_memo_count; # if HAVE_STRING_PROFILING > 1 - memo->pprev = &live_memos[bucket]; - if ((memo->next = *memo->pprev)) - memo->next->pprev = &memo->next; - *memo->pprev = memo; + memo->pprev = &live_memos[bucket]; + if ((memo->next = *memo->pprev)) + memo->next->pprev = &memo->next; + *memo->pprev = memo; # endif #endif } @@ -139,7 +139,7 @@ String::delete_memo(memo_t *memo) --live_memo_count; # if HAVE_STRING_PROFILING > 1 if ((*memo->pprev = memo->next)) - memo->next->pprev = memo->pprev; + memo->next->pprev = memo->pprev; # endif #endif delete[] reinterpret_cast<char *>(memo); @@ -151,29 +151,29 @@ void String::one_profile_report(StringAccum &sa, int i, int examples) { if (i <= 16) - sa << "memo_dirty_" << i; + sa << "memo_dirty_" << i; else if (i < 25) { - uint32_t s = (i - 17) * 2 + 17; - sa << "memo_cap_" << s << '_' << (s + 1); + uint32_t s = (i - 17) * 2 + 17; + sa << "memo_cap_" << s << '_' << (s + 1); } else if (i < 29) { - uint32_t s = (i - 25) * 8 + 33; - sa << "memo_cap_" << s << '_' << (s + 7); + uint32_t s = (i - 25) * 8 + 33; + sa << "memo_cap_" << s << '_' << (s + 7); } else { - uint32_t s1 = (1U << (i - 23)) + 1; - uint32_t s2 = (s1 - 1) << 1; - sa << "memo_cap_" << s1 << '_' << s2; + uint32_t s1 = (1U << (i - 23)) + 1; + uint32_t s2 = (s1 - 1) << 1; + sa << "memo_cap_" << s1 << '_' << s2; } sa << '\t' << live_memo_sizes[i] << '\t' << memo_sizes[i] << '\t' << live_memo_bytes[i] << '\n'; if (examples) { # if HAVE_STRING_PROFILING > 1 - for (memo_t *m = live_memos[i]; m; m = m->next) { - sa << " [" << m->dirty << "] "; - uint32_t dirty = m->dirty; - if (dirty > 0 && m->real_data[dirty - 1] == '\0') - --dirty; - sa.append(m->real_data, dirty > 128 ? 128 : dirty); - sa << '\n'; - } + for (memo_t *m = live_memos[i]; m; m = m->next) { + sa << " [" << m->dirty << "] "; + uint32_t dirty = m->dirty; + if (dirty > 0 && m->real_data[dirty - 1] == '\0') + --dirty; + sa.append(m->real_data, dirty > 128 ? 128 : dirty); + sa << '\n'; + } # endif } } @@ -183,11 +183,11 @@ String::profile_report(StringAccum &sa, int examples) { uint64_t all_live_sizes = 0, all_sizes = 0, all_live_bytes = 0; for (int i = 0; i < 55; ++i) { - if (memo_sizes[i]) - one_profile_report(sa, i, examples); - all_live_sizes += live_memo_sizes[i]; - all_sizes += memo_sizes[i]; - all_live_bytes += live_memo_bytes[i]; + if (memo_sizes[i]) + one_profile_report(sa, i, examples); + all_live_sizes += live_memo_sizes[i]; + all_sizes += memo_sizes[i]; + all_live_bytes += live_memo_bytes[i]; } sa << "memo_total\t" << all_live_sizes << '\t' << all_sizes << '\t' << all_live_bytes << '\n'; } @@ -200,11 +200,11 @@ String::profile_report(StringAccum &sa, int examples) String::String(int x) { if (x >= 0 && x < 10) - assign_memo(int_data + 2 * x, 1, 0); + assign_memo(int_data + 2 * x, 1, 0); else { - char buf[128]; - sprintf(buf, "%d", x); - assign(buf, -1, false); + char buf[128]; + int len = snprintf(buf, sizeof(buf), "%d", x); + assign(buf, len, false); } } @@ -212,11 +212,11 @@ String::String(int x) String::String(unsigned x) { if (x < 10) - assign_memo(int_data + 2 * x, 1, 0); + assign_memo(int_data + 2 * x, 1, 0); else { - char buf[128]; - sprintf(buf, "%u", x); - assign(buf, -1, false); + char buf[128]; + int len = snprintf(buf, sizeof(buf), "%u", x); + assign(buf, len, false); } } @@ -224,11 +224,11 @@ String::String(unsigned x) String::String(long x) { if (x >= 0 && x < 10) - assign_memo(int_data + 2 * x, 1, 0); + assign_memo(int_data + 2 * x, 1, 0); else { - char buf[128]; - sprintf(buf, "%ld", x); - assign(buf, -1, false); + char buf[128]; + int len = snprintf(buf, sizeof(buf), "%ld", x); + assign(buf, len, false); } } @@ -236,18 +236,18 @@ String::String(long x) String::String(unsigned long x) { if (x < 10) - assign_memo(int_data + 2 * x, 1, 0); + assign_memo(int_data + 2 * x, 1, 0); else { - char buf[128]; - sprintf(buf, "%lu", x); - assign(buf, -1, false); + char buf[128]; + int len = snprintf(buf, sizeof(buf), "%lu", x); + assign(buf, len, false); } } String::String(double x) { char buf[128]; - int len = sprintf(buf, "%.12g", x); + int len = snprintf(buf, sizeof(buf), "%.12g", x); assign(buf, len, false); } @@ -263,7 +263,7 @@ String String::make_stable(const char *s, int len) { if (len < 0) - len = (s ? strlen(s) : 0); + len = (s ? strlen(s) : 0); return String(s, len, 0); } @@ -279,7 +279,7 @@ void String::assign_out_of_memory() { if (_r.memo) - deref(); + deref(); _r.memo = 0; _r.data = &oom_data; _r.length = 0; @@ -289,38 +289,38 @@ void String::assign(const char *s, int len, bool need_deref) { if (!s) { - assert(len <= 0); - len = 0; + assert(len <= 0); + len = 0; } else if (len < 0) - len = strlen(s); + len = strlen(s); // need to start with dereference if (need_deref) { - if (unlikely(_r.memo - && s >= _r.memo->real_data - && s + len <= _r.memo->real_data + _r.memo->capacity)) { - // Be careful about "String s = ...; s = s.c_str();" - _r.data = s; - _r.length = len; - return; - } else - deref(); + if (unlikely(_r.memo + && s >= _r.memo->real_data + && s + len <= _r.memo->real_data + _r.memo->capacity)) { + // Be careful about "String s = ...; s = s.c_str();" + _r.data = s; + _r.length = len; + return; + } else + deref(); } if (len == 0) { - _r.memo = 0; - _r.data = (s == &oom_data ? s : &null_data); + _r.memo = 0; + _r.data = (s == &oom_data ? s : &null_data); } else { - // Make the memo a multiple of 16 characters and bigger than 'len'. - int memo_capacity = (len + 15 + MEMO_SPACE) & ~15; - _r.memo = create_memo(0, len, memo_capacity - MEMO_SPACE); - if (!_r.memo) { - assign_out_of_memory(); - return; - } - memcpy(_r.memo->real_data, s, len); - _r.data = _r.memo->real_data; + // Make the memo a multiple of 16 characters and bigger than 'len'. + int memo_capacity = (len + 15 + MEMO_SPACE) & ~15; + _r.memo = create_memo(0, len, memo_capacity - MEMO_SPACE); + if (!_r.memo) { + assign_out_of_memory(); + return; + } + memcpy(_r.memo->real_data, s, len); + _r.data = _r.memo->real_data; } _r.length = len; @@ -336,24 +336,24 @@ String::append_uninitialized(int len) { // Appending anything to "out of memory" leaves it as "out of memory" if (unlikely(len <= 0) || out_of_memory()) - return 0; + return 0; // If we can, append into unused space. First, we check that there's // enough unused space for 'len' characters to fit; then, we check // that the unused space immediately follows the data in '*this'. uint32_t dirty; if (_r.memo - && ((dirty = _r.memo->dirty), _r.memo->capacity > dirty + len)) { - char *real_dirty = _r.memo->real_data + dirty; - if (real_dirty == _r.data + _r.length) { - _r.memo->dirty = dirty + len; - _r.length += len; - assert(_r.memo->dirty < _r.memo->capacity); + && ((dirty = _r.memo->dirty), _r.memo->capacity > dirty + len)) { + char *real_dirty = _r.memo->real_data + dirty; + if (real_dirty == _r.data + _r.length) { + _r.memo->dirty = dirty + len; + _r.length += len; + assert(_r.memo->dirty < _r.memo->capacity); #if HAVE_STRING_PROFILING - profile_update_memo_dirty(_r.memo, dirty, dirty + len, _r.memo->capacity); + profile_update_memo_dirty(_r.memo, dirty, dirty + len, _r.memo->capacity); #endif - return real_dirty; - } + return real_dirty; + } } // Now we have to make new space. Make sure the memo is a multiple of 16 @@ -363,15 +363,15 @@ String::append_uninitialized(int len) int want_memo_len = _r.length + len + MEMO_SPACE; int memo_capacity; if (want_memo_len <= 1024) - memo_capacity = (want_memo_len + 15) & ~15; + memo_capacity = (want_memo_len + 15) & ~15; else - for (memo_capacity = 2048; memo_capacity < want_memo_len; ) - memo_capacity *= 2; + for (memo_capacity = 2048; memo_capacity < want_memo_len; ) + memo_capacity *= 2; memo_t *new_memo = create_memo(0, _r.length + len, memo_capacity - MEMO_SPACE); if (!new_memo) { - assign_out_of_memory(); - return 0; + assign_out_of_memory(); + return 0; } char *new_data = new_memo->real_data; @@ -379,7 +379,7 @@ String::append_uninitialized(int len) deref(); _r.data = new_data; - new_data += _r.length; // now new_data points to the garbage + new_data += _r.length; // now new_data points to the garbage _r.length += len; _r.memo = new_memo; return new_data; @@ -389,29 +389,29 @@ void String::append(const char *s, int len, memo_t *memo) { if (!s) { - assert(len <= 0); - len = 0; + assert(len <= 0); + len = 0; } else if (len < 0) - len = strlen(s); + len = strlen(s); if (s == &oom_data) - // Appending "out of memory" to a regular string makes it "out of - // memory" - assign_out_of_memory(); + // Appending "out of memory" to a regular string makes it "out of + // memory" + assign_out_of_memory(); else if (len == 0) - /* do nothing */; + /* do nothing */; else if (_r.length == 0 && memo && !out_of_memory()) { - deref(); - assign_memo(s, len, memo); + deref(); + assign_memo(s, len, memo); } else if (likely(!(_r.memo - && s >= _r.memo->real_data - && s + len <= _r.memo->real_data + _r.memo->capacity))) { - if (char *space = append_uninitialized(len)) - memcpy(space, s, len); + && s >= _r.memo->real_data + && s + len <= _r.memo->real_data + _r.memo->capacity))) { + if (char *space = append_uninitialized(len)) + memcpy(space, s, len); } else { - String preserve_s(*this); - if (char *space = append_uninitialized(len)) - memcpy(space, s, len); + String preserve_s(*this); + if (char *space = append_uninitialized(len)) + memcpy(space, s, len); } } @@ -421,7 +421,7 @@ String::append_fill(int c, int len) { assert(len >= 0); if (char *space = append_uninitialized(len)) - memset(space, c, len); + memset(space, c, len); } /** @brief Ensure the string's data is unshared and return a mutable @@ -432,7 +432,7 @@ String::mutable_data() // If _memo has a capacity (it's not one of the special strings) and it's // uniquely referenced, return _data right away. if (_r.memo && _r.memo->refcount == 1) - return const_cast<char *>(_r.data); + return const_cast<char *>(_r.data); // Otherwise, make a copy of it. Rely on: deref() doesn't change _data or // _length; and if _capacity == 0, then deref() doesn't free _real_data. @@ -470,35 +470,35 @@ String String::substring(int pos, int len) const { if (pos < 0) - pos += _r.length; + pos += _r.length; int pos2; if (len < 0) - pos2 = _r.length + len; + pos2 = _r.length + len; else if (pos >= 0 && len >= _r.length) // avoid integer overflow - pos2 = _r.length; + pos2 = _r.length; else - pos2 = pos + len; + pos2 = pos + len; if (pos < 0) - pos = 0; + pos = 0; if (pos2 > _r.length) - pos2 = _r.length; + pos2 = _r.length; if (pos >= pos2) - return String(); + return String(); else - return String(_r.data + pos, pos2 - pos, _r.memo); + return String(_r.data + pos, pos2 - pos, _r.memo); } int String::find_left(char c, int start) const { if (start < 0) - start = 0; + start = 0; for (int i = start; i < _r.length; i++) - if (_r.data[i] == c) - return i; + if (_r.data[i] == c) + return i; return -1; } @@ -506,11 +506,11 @@ int String::find_left(const String &str, int start) const { if (start < 0) - start = 0; + start = 0; int max_pos = length() - str.length(); for (int i = start; i <= max_pos; ++i) - if (memcmp(_r.data + i, str.data(), str.length()) == 0) - return i; + if (memcmp(_r.data + i, str.data(), str.length()) == 0) + return i; return -1; } @@ -518,10 +518,10 @@ int String::find_right(char c, int start) const { if (start >= _r.length) - start = _r.length - 1; + start = _r.length - 1; for (int i = start; i >= 0; i--) - if (_r.data[i] == c) - return i; + if (_r.data[i] == c) + return i; return -1; } @@ -532,7 +532,7 @@ hard_lower(const String &s, int pos) char *x = const_cast<char *>(new_s.data()); // know it's mutable int len = s.length(); for (; pos < len; pos++) - x[pos] = tolower((unsigned char) x[pos]); + x[pos] = tolower((unsigned char) x[pos]); return new_s; } @@ -545,9 +545,9 @@ String::lower() const { // avoid copies if (!out_of_memory()) - for (int i = 0; i < _r.length; i++) - if (_r.data[i] >= 'A' && _r.data[i] <= 'Z') - return hard_lower(*this, i); + for (int i = 0; i < _r.length; i++) + if (_r.data[i] >= 'A' && _r.data[i] <= 'Z') + return hard_lower(*this, i); return *this; } @@ -558,7 +558,7 @@ hard_upper(const String &s, int pos) char *x = const_cast<char *>(new_s.data()); // know it's mutable int len = s.length(); for (; pos < len; pos++) - x[pos] = toupper((unsigned char) x[pos]); + x[pos] = toupper((unsigned char) x[pos]); return new_s; } @@ -571,8 +571,8 @@ String::upper() const { // avoid copies for (int i = 0; i < _r.length; i++) - if (_r.data[i] >= 'a' && _r.data[i] <= 'z') - return hard_upper(*this, i); + if (_r.data[i] >= 'a' && _r.data[i] <= 'z') + return hard_upper(*this, i); return *this; } @@ -584,12 +584,12 @@ hard_printable(const String &s, int pos, int type) const unsigned char *x = reinterpret_cast<const unsigned char *>(s.data()); int len = s.length(); for (; pos < len; pos++) { - if (x[pos] >= 32 && x[pos] < 127) - sa << x[pos]; - else if (x[pos] < 32 && type != 1) - sa << '^' << (unsigned char)(x[pos] + 64); - else if (char *buf = sa.extend(4, 1)) - sprintf(buf, "\\%03o", x[pos]); + if (x[pos] >= 32 && x[pos] < 127) + sa << x[pos]; + else if (x[pos] < 32 && type != 1) + sa << '^' << (unsigned char)(x[pos] + 64); + else if (char *buf = sa.extend(4, 1)) + snprintf(buf, 5, "\\%03o", x[pos]); } return sa.take_string(); } @@ -607,9 +607,9 @@ String::printable(int type) const { // avoid copies if (!out_of_memory()) - for (int i = 0; i < _r.length; i++) - if (_r.data[i] < 32 || _r.data[i] > 126) - return hard_printable(*this, i, type); + for (int i = 0; i < _r.length; i++) + if (_r.data[i] < 32 || _r.data[i] > 126) + return hard_printable(*this, i, type); return *this; } @@ -617,7 +617,7 @@ hashcode_t String::hashcode(const char *begin, const char *end) { if (end <= begin) - return 0; + return 0; uint32_t hash = end - begin; int rem = hash & 3; @@ -628,16 +628,16 @@ String::hashcode(const char *begin, const char *end) if (!(reinterpret_cast<uintptr_t>(begin) & 1)) { #endif #define get16(p) (*reinterpret_cast<const uint16_t *>((p))) - for (; begin != end; begin += 4) { - hash += get16(begin); - uint32_t tmp = (get16(begin + 2) << 11) ^ hash; - hash = (hash << 16) ^ tmp; - hash += hash >> 11; - } - if (rem >= 2) { - last16 = get16(begin); - goto rem2; - } + for (; begin != end; begin += 4) { + hash += get16(begin); + uint32_t tmp = (get16(begin + 2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + hash += hash >> 11; + } + if (rem >= 2) { + last16 = get16(begin); + goto rem2; + } #undef get16 #if !HAVE_INDIFFERENT_ALIGNMENT } else { @@ -648,38 +648,38 @@ String::hashcode(const char *begin, const char *end) # else # error "unknown byte order" # endif - // should be exactly the same as the code above - for (; begin != end; begin += 4) { - hash += get16(begin); - uint32_t tmp = (get16(begin + 2) << 11) ^ hash; - hash = (hash << 16) ^ tmp; - hash += hash >> 11; - } - if (rem >= 2) { - last16 = get16(begin); - goto rem2; - } + // should be exactly the same as the code above + for (; begin != end; begin += 4) { + hash += get16(begin); + uint32_t tmp = (get16(begin + 2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + hash += hash >> 11; + } + if (rem >= 2) { + last16 = get16(begin); + goto rem2; + } # undef get16 } #endif /* Handle end cases */ - if (0) { // weird organization avoids uninitialized - rem2: // variable warnings - if (rem == 3) { - hash += last16; - hash ^= hash << 16; - hash ^= ((unsigned char) begin[2]) << 18; - hash += hash >> 11; - } else { - hash += last16; - hash ^= hash << 11; - hash += hash >> 17; - } + if (0) { // weird organization avoids uninitialized + rem2: // variable warnings + if (rem == 3) { + hash += last16; + hash ^= hash << 16; + hash ^= ((unsigned char) begin[2]) << 18; + hash += hash >> 11; + } else { + hash += last16; + hash ^= hash << 11; + hash += hash >> 17; + } } else if (rem == 1) { - hash += (unsigned char) *begin; - hash ^= hash << 10; - hash += hash >> 1; + hash += (unsigned char) *begin; + hash ^= hash << 10; + hash += hash >> 1; } /* Force "avalanching" of final 127 bits */ @@ -702,14 +702,14 @@ String::hashcode() const int l = length(); const char *d = data(); if (!l) - return 0; + return 0; else if (l == 1) - return d[0] | (d[0] << 8); + return d[0] | (d[0] << 8); else if (l < 4) - return d[0] + (d[1] << 3) + (l << 12); + return d[0] + (d[1] << 3) + (l << 12); else - return d[0] + (d[1] << 8) + (d[2] << 16) + (d[3] << 24) - + (l << 12) + (d[l-1] << 10); + return d[0] + (d[1] << 8) + (d[2] << 16) + (d[3] << 24) + + (l << 12) + (d[l-1] << 10); } #endif @@ -721,15 +721,15 @@ String::equals(const char *s, int len) const // used as (for example) keys in hashtables. Instead, "out-of-memory" // strings compare unequal to other null strings, but equal to each other. if (len < 0) - len = strlen(s); + len = strlen(s); if (_r.length != len) - return false; + return false; else if (_r.data == s) - return true; + return true; else if (len == 0) - return (s != &oom_data && _r.data != &oom_data); + return (s != &oom_data && _r.data != &oom_data); else - return memcmp(_r.data, s, len) == 0; + return memcmp(_r.data, s, len) == 0; } bool @@ -737,36 +737,36 @@ String::starts_with(const char *s, int len) const { // See note on equals() re: "out-of-memory" strings. if (len < 0) - len = strlen(s); + len = strlen(s); if (_r.length < len) - return false; + return false; else if (_r.data == s) - return true; + return true; else if (len == 0) - return (s != &oom_data && _r.data != &oom_data); + return (s != &oom_data && _r.data != &oom_data); else - return memcmp(_r.data, s, len) == 0; + return memcmp(_r.data, s, len) == 0; } int String::compare(const char *s, int len) const { if (len < 0) - len = strlen(s); + len = strlen(s); if (_r.data == s) - return _r.length - len; + return _r.length - len; else if (_r.data == &oom_data) - return 1; + return 1; else if (s == &oom_data) - return -1; + return -1; else if (_r.length == len) - return memcmp(_r.data, s, len); + return memcmp(_r.data, s, len); else if (_r.length < len) { - int v = memcmp(_r.data, s, _r.length); - return (v ? v : -1); + int v = memcmp(_r.data, s, _r.length); + return (v ? v : -1); } else { - int v = memcmp(_r.data, s, len); - return (v ? v : 1); + int v = memcmp(_r.data, s, len); + return (v ? v : 1); } } @@ -775,12 +775,12 @@ String::align(int n) { int offset = reinterpret_cast<uintptr_t>(_r.data) % n; if (offset) { - String s; - s.append_uninitialized(_r.length + n + 1); - offset = reinterpret_cast<uintptr_t>(s._r.data) % n; - memcpy((char *)s._r.data + n - offset, _r.data, _r.length); - s._r.data += n - offset; - s._r.length = _r.length; - *this = s; + String s; + s.append_uninitialized(_r.length + n + 1); + offset = reinterpret_cast<uintptr_t>(s._r.data) % n; + memcpy((char *)s._r.data + n - offset, _r.data, _r.length); + s._r.data += n - offset; + s._r.length = _r.length; + *this = s; } } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/transform.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/transform.cc index 8f92dfeba83..f16726b7c03 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/transform.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/transform.cc @@ -2,7 +2,7 @@ /* transform.{cc,hh} -- planar affine transformations * - * Copyright (c) 2000-2019 Eddie Kohler + * Copyright (c) 2000-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -39,7 +39,7 @@ Transform::Transform(const double m[6]) } Transform::Transform(double m0, double m1, double m2, - double m3, double m4, double m5) + double m3, double m4, double m5) { _m[0] = m0; _m[1] = m1; @@ -54,8 +54,8 @@ void Transform::check_null(double tolerance) { _null = (fabs(_m[0] - 1) < tolerance && fabs(_m[1]) < tolerance - && fabs(_m[2]) < tolerance && fabs(_m[3] - 1) < tolerance - && fabs(_m[4]) < tolerance && fabs(_m[5]) < tolerance); + && fabs(_m[2]) < tolerance && fabs(_m[3] - 1) < tolerance + && fabs(_m[4]) < tolerance && fabs(_m[5]) < tolerance); } @@ -68,7 +68,7 @@ Transform::scale(double x, double y) _m[3] *= y; if (x != 1 || y != 1) - _null = false; + _null = false; } void @@ -86,7 +86,7 @@ Transform::rotate(double r) _m[3] = b*c - a*s; if (r != 0) - _null = false; + _null = false; } void @@ -96,7 +96,7 @@ Transform::translate(double x, double y) _m[5] += _m[1]*x + _m[3]*y; if (x != 0 || y != 0) - _null = false; + _null = false; } void Transform::raw_translate(double x, double y) { @@ -144,17 +144,17 @@ Point Transform::real_apply(const Point &p) const { return Point(p.x*_m[0] + p.y*_m[2] + _m[4], - p.x*_m[1] + p.y*_m[3] + _m[5]); + p.x*_m[1] + p.y*_m[3] + _m[5]); } Bezier & operator*=(Bezier &b, const Transform &t) { if (!t.null()) { - b.mpoint(0) *= t; - b.mpoint(1) *= t; - b.mpoint(2) *= t; - b.mpoint(3) *= t; + b.mpoint(0) *= t; + b.mpoint(1) *= t; + b.mpoint(2) *= t; + b.mpoint(3) *= t; } return b; } @@ -163,8 +163,8 @@ Bezier operator*(const Bezier &b, const Transform &t) { return (t.null() - ? b - : Bezier(b.point(0) * t, b.point(1) * t, b.point(2) * t, b.point(3) * t)); + ? b + : Bezier(b.point(0) * t, b.point(1) * t, b.point(2) * t, b.point(3) * t)); } String @@ -173,9 +173,9 @@ Transform::unparse() const StringAccum sa; sa << '['; for (int i = 0; i < 6; i++) { - if (i) - sa << ',' << ' '; - sa << _m[i]; + if (i) + sa << ',' << ' '; + sa << _m[i]; } sa << ']'; return sa.take_string(); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/vectorv.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/vectorv.cc index eee30630f9f..bd695ff7963 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/vectorv.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/liblcdf/vectorv.cc @@ -37,7 +37,7 @@ Vector<void*>::operator=(const Vector<void*> &o) { if (&o != this) { _n = 0; - if (reserve(o._n)) { + if (reserve(o._n) && o._n) { _n = o._n; memcpy(_l, o._l, sizeof(void *) * _n); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/m4/lcdf-typetools.m4 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/m4/lcdf-typetools.m4 index 7aaff4c33af..6f96a8421dc 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/m4/lcdf-typetools.m4 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/m4/lcdf-typetools.m4 @@ -1,15 +1,13 @@ ## Define configure options for lcdf-typetools. Extracted from configure.ac ## for ease of building TeX Live. -m4_define_default([kpse_indent_26], [26])[]dnl -m4_define([kpse_lcdf_typetools_progs], [cfftot1 mmafm mmpfb otfinfo otftotfm t1dotlessj t1lint t1rawafm t1reencode t1testpage ttftotype42])[]dnl -AC_FOREACH([Kpse_Prog], kpse_lcdf_typetools_progs, - [AC_ARG_ENABLE(Kpse_Prog, +m4_define_default([kpse_indent_26],[26])[]dnl +m4_define([kpse_lcdf_typetools_progs],[cfftot1 mmafm mmpfb otfinfo otftotfm t1dotlessj t1lint t1rawafm t1reencode t1testpage ttftotype42])[]dnl +m4_foreach_w([Kpse_Prog],kpse_lcdf_typetools_progs,[AC_ARG_ENABLE(Kpse_Prog, AS_HELP_STRING([--disable-]Kpse_Prog, [do not build the ]Kpse_Prog[ program], kpse_indent_26))]) -m4_define([kpse_otftotfm_auto_opts], [cfftot1 t1dotlessj ttftotype42 updmap])[]dnl -AC_FOREACH([Kpse_Opt], kpse_otftotfm_auto_opts, - [AC_ARG_ENABLE(Kpse_Opt, +m4_define([kpse_otftotfm_auto_opts],[cfftot1 t1dotlessj ttftotype42 updmap])[]dnl +m4_foreach_w([Kpse_Opt],kpse_otftotfm_auto_opts,[AC_ARG_ENABLE(Kpse_Opt, AS_HELP_STRING([--disable-auto-]Kpse_Opt, [disable running ]Kpse_Opt[ from otftotfm], kpse_indent_26))]) diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/main.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/main.cc index 67e635f662a..67d403d3d2b 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/main.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/main.cc @@ -1,6 +1,6 @@ /* main.cc -- driver for mmafm program * - * Copyright (c) 1997-2019 Eddie Kohler + * Copyright (c) 1997-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -30,19 +30,19 @@ # include <time.h> #endif -#define WEIGHT_OPT 300 -#define WIDTH_OPT 301 -#define OPSIZE_OPT 302 -#define STYLE_OPT 303 -#define N1_OPT 304 -#define N2_OPT 305 -#define N3_OPT 306 -#define N4_OPT 307 -#define VERSION_OPT 308 -#define HELP_OPT 309 -#define OUTPUT_OPT 310 -#define PRECISION_OPT 311 -#define KERN_PREC_OPT 312 +#define WEIGHT_OPT 300 +#define WIDTH_OPT 301 +#define OPSIZE_OPT 302 +#define STYLE_OPT 303 +#define N1_OPT 304 +#define N2_OPT 305 +#define N3_OPT 306 +#define N4_OPT 307 +#define VERSION_OPT 308 +#define HELP_OPT 309 +#define OUTPUT_OPT 310 +#define PRECISION_OPT 311 +#define KERN_PREC_OPT 312 const Clp_Option options[] = { { "1", '1', N1_OPT, Clp_ValDouble, 0 }, @@ -216,6 +216,7 @@ usage_error(const char *error_message, ...) errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } static void @@ -307,11 +308,11 @@ main(int argc, char *argv[]) case OUTPUT_OPT: if (output_file) errh->fatal("output file already specified"); if (strcmp(clp->vstr, "-") == 0) - output_file = stdout; + output_file = stdout; else { - output_file = fopen(clp->vstr, "wb"); - if (!output_file) - errh->fatal("%s: %s", clp->vstr, strerror(errno)); + output_file = fopen(clp->vstr, "wb"); + if (!output_file) + errh->fatal("%s: %s", clp->vstr, strerror(errno)); } break; @@ -322,7 +323,7 @@ main(int argc, char *argv[]) case VERSION_OPT: printf("mmafm (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 1997-2019 Eddie Kohler\n\ + printf("Copyright (C) 1997-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); @@ -349,8 +350,9 @@ particular purpose.\n"); MultipleMasterSpace *mmspace = amfm->mmspace(); #if MMAFM_RUN_MMPFB if (!mmspace->check_intermediate()) { - char *buf = new char[amfm->font_name().length() + 30]; - sprintf(buf, "mmpfb -q --amcp-info '%s'", amfm->font_name().c_str()); + size_t bufsz = amfm->font_name().length() + 30; + char *buf = new char[bufsz]; + snprintf(buf, bufsz, "mmpfb -q --amcp-info '%s'", amfm->font_name().c_str()); FILE *f = popen(buf, "r"); if (f) { @@ -391,7 +393,7 @@ particular purpose.\n"); // components are unknown. if (!KNOWN(design[0])) errh->fatal("must specify %s%,s %s coordinate", amfm->font_name().c_str(), - mmspace->axis_type(0).c_str()); + mmspace->axis_type(0).c_str()); Metrics *m = amfm->interpolate(design, weight, errh); if (m) { @@ -404,12 +406,13 @@ particular purpose.\n"); time_t cur_time = time(0); char *time_str = ctime(&cur_time); int time_len = strlen(time_str) - 1; - char *buf = new char[strlen(VERSION) + time_len + 100]; - sprintf(buf, "Interpolated by mmafm-%s on %.*s.", VERSION, - time_len, time_str); + size_t bufsz = strlen(VERSION) + time_len + 100; + char* buf = new char[bufsz]; + snprintf(buf, bufsz, "Interpolated by mmafm-%s on %.*s.", VERSION, + time_len, time_str); #else - char *buf = new char[strlen(VERSION) + 100]; - sprintf(buf, "Interpolated by mmafm-%s.", VERSION); + char* buf = new char[strlen(VERSION) + 100]; + snprintf(buf, strlen(VERSION) + 100, "Interpolated by mmafm-%s.", VERSION); #endif afm_xt->opening_comments.push_back(buf); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/mmafm.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/mmafm.1 index 58be625b366..a4f924d3bd8 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/mmafm.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmafm/mmafm.1 @@ -1,5 +1,5 @@ .\" -*-nroff-*- -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/main.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/main.cc index 8b742f77c55..dc737ca99fa 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/main.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/main.cc @@ -1,6 +1,6 @@ /* main.cc -- driver for mmpfb program * - * Copyright (c) 1997-2019 Eddie Kohler + * Copyright (c) 1997-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -36,24 +36,24 @@ # include <io.h> #endif -#define WEIGHT_OPT 300 -#define WIDTH_OPT 301 -#define OPSIZE_OPT 302 -#define STYLE_OPT 303 -#define N1_OPT 304 -#define N2_OPT 305 -#define N3_OPT 306 -#define N4_OPT 307 -#define VERSION_OPT 308 -#define AMCP_INFO_OPT 309 -#define HELP_OPT 310 -#define PFA_OPT 311 -#define PFB_OPT 312 -#define OUTPUT_OPT 313 -#define QUIET_OPT 314 -#define PRECISION_OPT 315 -#define SUBRS_OPT 316 -#define MINIMIZE_OPT 317 +#define WEIGHT_OPT 300 +#define WIDTH_OPT 301 +#define OPSIZE_OPT 302 +#define STYLE_OPT 303 +#define N1_OPT 304 +#define N2_OPT 305 +#define N3_OPT 306 +#define N4_OPT 307 +#define VERSION_OPT 308 +#define AMCP_INFO_OPT 309 +#define HELP_OPT 310 +#define PFA_OPT 311 +#define PFB_OPT 312 +#define OUTPUT_OPT 313 +#define QUIET_OPT 314 +#define PRECISION_OPT 315 +#define SUBRS_OPT 316 +#define MINIMIZE_OPT 317 const Clp_Option options[] = { { "1", '1', N1_OPT, Clp_ValDouble, 0 }, @@ -101,6 +101,7 @@ usage_error(const char *error_message, ...) errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -176,12 +177,12 @@ do_file(const char *filename, PsresDatabase *psres) const char *underscore = strchr(filename, '_'); if (!fn && underscore) { fn = psres->filename_value - ("FontOutline", PermString(filename, underscore - filename)); + ("FontOutline", PermString(filename, underscore - filename)); int i = 0; while (underscore[0] == '_' && underscore[1]) { - double x = strtod(underscore + 1, const_cast<char **>(&underscore)); - set_design(i, x); - i++; + double x = strtod(underscore + 1, const_cast<char **>(&underscore)); + set_design(i, x); + i++; } } f = fn.open_read(); @@ -219,18 +220,18 @@ static void print_conversion_program(FILE *f, const Type1Charstring &cs, PermString name) { if (cs) { - const unsigned char *data = cs.data(); - for (int i = 0; i < cs.length(); ) { - int l = cs.length() - i; - if (l > 32) - l = 32; - fprintf(f, "%s <", name.c_str()); - for (int j = 0; j < l; j++) - fprintf(f, "%02X", data[j]); - fprintf(f, ">\n"); - data += l; - i += l; - } + const unsigned char *data = cs.data(); + for (int i = 0; i < cs.length(); ) { + int l = cs.length() - i; + if (l > 32) + l = 32; + fprintf(f, "%s <", name.c_str()); + for (int j = 0; j < l; j++) + fprintf(f, "%02X", data[j]); + fprintf(f, ">\n"); + data += l; + i += l; + } } } @@ -242,10 +243,10 @@ print_amcp_info(MultipleMasterSpace *mmspace, FILE *f) const Type1Charstring &cdv = mmspace->cdv(); if (!ndv && !cdv) fprintf(stderr, "%s does not have conversion programs.\n", - mmspace->font_name().c_str()); + mmspace->font_name().c_str()); else { fprintf(f, "StartConversionPrograms %d %d\n", ndv.length(), - cdv.length()); + cdv.length()); print_conversion_program(f, ndv, "NDV"); print_conversion_program(f, cdv, "CDV"); fprintf(f, "EndConversionPrograms\n"); @@ -313,49 +314,49 @@ main(int argc, char *argv[]) case PRECISION_OPT: if (clp->val.i > 107) { - errh->warning("precision lowered to 107"); - precision = 107; + errh->warning("precision lowered to 107"); + precision = 107; } else if (clp->val.i < 1) { - errh->warning("precision raised to 1"); - precision = 1; + errh->warning("precision raised to 1"); + precision = 1; } else - precision = clp->val.i; + precision = clp->val.i; break; case SUBRS_OPT: if (clp->negated) - subr_count = -1; + subr_count = -1; else if (clp->val.i <= 0) - errh->warning("subr count too small"); + errh->warning("subr count too small"); else - subr_count = clp->val.i; + subr_count = clp->val.i; break; case MINIMIZE_OPT: - minimize = !clp->negated; - break; + minimize = !clp->negated; + break; case QUIET_OPT: if (clp->negated) - errh = ErrorHandler::default_handler(); + errh = ErrorHandler::default_handler(); else - errh = new SilentErrorHandler; + errh = new SilentErrorHandler; break; case OUTPUT_OPT: if (outfile) errh->fatal("output file already specified"); if (strcmp(clp->vstr, "-") == 0) - outfile = stdout; + outfile = stdout; else { - outfile = fopen(clp->vstr, "wb"); - if (!outfile) - errh->fatal("%s: %s", clp->vstr, strerror(errno)); + outfile = fopen(clp->vstr, "wb"); + if (!outfile) + errh->fatal("%s: %s", clp->vstr, strerror(errno)); } break; case VERSION_OPT: printf("mmpfb (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 1997-2019 Eddie Kohler\n\ + printf("Copyright (C) 1997-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); @@ -373,7 +374,7 @@ particular purpose.\n"); case Clp_Done: if (!font) - usage_error("missing font argument"); + usage_error("missing font argument"); goto done; case Clp_BadOption: @@ -406,7 +407,7 @@ particular purpose.\n"); for (int i = 0; i < mmspace->naxes(); i++) if (!KNOWN(design[i]) && KNOWN(default_design[i])) { errh->warning("using default value %g for %s%,s %s", default_design[i], - font->font_name().c_str(), mmspace->axis_type(i).c_str()); + font->font_name().c_str(), mmspace->axis_type(i).c_str()); design[i] = default_design[i]; } @@ -435,12 +436,13 @@ particular purpose.\n"); time_t cur_time = time(0); char *time_str = ctime(&cur_time); int time_len = strlen(time_str) - 1; - char *buf = new char[strlen(VERSION) + time_len + 100]; - sprintf(buf, "%%%% Interpolated by mmpfb-%s on %.*s.", VERSION, - time_len, time_str); + size_t bufsz = strlen(VERSION) + time_len + 100; + char* buf = new char[bufsz]; + snprintf(buf, bufsz, "%%%% Interpolated by mmpfb-%s on %.*s.", VERSION, + time_len, time_str); #else - char *buf = new char[strlen(VERSION) + 100]; - sprintf(buf, "%%%% Interpolated by mmpfb-%s.", VERSION); + char* buf = new char[strlen(VERSION) + 100]; + snprintf(buf, strlen(VERSION) + 100, "%%%% Interpolated by mmpfb-%s.", VERSION); #endif t1font->add_header_comment(buf); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/mmpfb.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/mmpfb.1 index 42dadb72bf5..9a9a8787e8e 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/mmpfb.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/mmpfb.1 @@ -1,5 +1,5 @@ .\" -*-nroff-*- -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/myfont.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/myfont.cc index 7a58a32d170..3ae03bf1ddb 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/myfont.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/myfont.cc @@ -1,6 +1,6 @@ /* myfont.cc -- general multiple- to single-master conversion * - * Copyright (c) 1997-2019 Eddie Kohler + * Copyright (c) 1997-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -44,7 +44,7 @@ MyFont::kill_def(Type1Definition *t1d, int whichd) if (whichd < 0) for (whichd = dFont; whichd < dLast; whichd = (Dict)(whichd + 1)) if (dict(whichd, t1d->name()) == t1d) - break; + break; if (whichd < 0 || whichd >= dLast || dict(whichd, t1d->name()) != t1d) return; @@ -69,20 +69,20 @@ MyFont::set_design_vector(MultipleMasterSpace *mmspace, const Vector<double> &de { Type1Definition *t1d = dict("DesignVector"); if (t1d) { - t1d->set_numvec(design); - kill_def(t1d, dFont); + t1d->set_numvec(design); + kill_def(t1d, dFont); } t1d = dict("NormDesignVector"); if (t1d) { - NumVector norm_design; - if (mmspace->design_to_norm_design(design, norm_design)) - t1d->set_numvec(norm_design); - kill_def(t1d, dFont); + NumVector norm_design; + if (mmspace->design_to_norm_design(design, norm_design)) + t1d->set_numvec(norm_design); + kill_def(t1d, dFont); } if (!mmspace->design_to_weight(design, _weight_vector, errh)) - return false; + return false; // Need to check for case when all design coordinates are unspecified. The // font file contains a default WeightVector, but possibly NOT a default @@ -90,15 +90,15 @@ MyFont::set_design_vector(MultipleMasterSpace *mmspace, const Vector<double> &de // `MyriadMM_-9.79797979e97_-9.79797979e97_' because the DesignVector // components are unknown. if (!KNOWN(design[0])) { - errh->error("must specify %s%,s %s coordinate", font_name().c_str(), - mmspace->axis_type(0).c_str()); - return false; + errh->error("must specify %s%,s %s coordinate", font_name().c_str(), + mmspace->axis_type(0).c_str()); + return false; } t1d = dict("WeightVector"); if (t1d) { - t1d->set_numvec(_weight_vector); - kill_def(t1d, dFont); + t1d->set_numvec(_weight_vector); + kill_def(t1d, dFont); } int naxes = design.size(); @@ -107,27 +107,27 @@ MyFont::set_design_vector(MultipleMasterSpace *mmspace, const Vector<double> &de PermString name; t1d = dict("FontName"); if (t1d && t1d->value_name(name)) { - StringAccum sa(name); - for (int a = 0; a < naxes; a++) - sa << '_' << design[a]; - // Multiple masters require an underscore AFTER the font name - sa << '_'; - t1d->set_name(sa.c_str()); - uncache_defs(); // remove cached font name + StringAccum sa(name); + for (int a = 0; a < naxes; a++) + sa << '_' << design[a]; + // Multiple masters require an underscore AFTER the font name + sa << '_'; + t1d->set_name(sa.c_str()); + uncache_defs(); // remove cached font name } // add a FullName too String full_name; t1d = fi_dict("FullName"); if (t1d && t1d->value_string(full_name)) { - StringAccum sa(full_name); - for (int a = 0; a < naxes; a++) { - sa << (a ? ' ' : '_') << design[a]; - PermString label = mmspace->axis_abbreviation(a); - if (label) - sa << ' ' << label; - } - t1d->set_string(sa.c_str()); + StringAccum sa(full_name); + for (int a = 0; a < naxes; a++) { + sa << (a ? ' ' : '_') << design[a]; + PermString label = mmspace->axis_abbreviation(a); + if (label) + sa << ' ' << label; + } + t1d->set_string(sa.c_str()); } // save UniqueID, then kill its definition @@ -140,21 +140,21 @@ MyFont::set_design_vector(MultipleMasterSpace *mmspace, const Vector<double> &de t1d = dict("XUID"); NumVector xuid; if (!t1d || !t1d->value_numvec(xuid)) { - if (have_uniqueid) { - t1d = ensure(dFont, "XUID"); - xuid.clear(); - xuid.push_back(1); - xuid.push_back(uniqueid); - } else if (t1d) { - kill_def(t1d, dFont); - t1d = 0; - } + if (have_uniqueid) { + t1d = ensure(dFont, "XUID"); + xuid.clear(); + xuid.push_back(1); + xuid.push_back(uniqueid); + } else if (t1d) { + kill_def(t1d, dFont); + t1d = 0; + } } if (t1d) { - // Append design vector values to the XUID to prevent cache pollution. - for (int a = 0; a < naxes; a++) - xuid.push_back((int)(design[a] * 100)); - t1d->set_numvec(xuid); + // Append design vector values to the XUID to prevent cache pollution. + for (int a = 0; a < naxes; a++) + xuid.push_back((int)(design[a] * 100)); + t1d->set_numvec(xuid); } return true; @@ -168,15 +168,15 @@ MyFont::interpolate_dict_int(PermString name, Dict the_dict, ErrorHandler *errh) NumVector blend; if (def && blend_def && blend_def->value_numvec(blend)) { - int n = _nmasters; - double val = 0; - for (int m = 0; m < n; m++) - val += blend[m] * _weight_vector[m]; - int ival = (int)floor(val + 0.50001); - if (fabs(val - ival) >= 0.001) - errh->warning("interpolated %s should be an integer (it is %g)", name.c_str(), val); - def->set_num(ival); - kill_def(blend_def, the_dict + dBlend); + int n = _nmasters; + double val = 0; + for (int m = 0; m < n; m++) + val += blend[m] * _weight_vector[m]; + int ival = (int)floor(val + 0.50001); + if (fabs(val - ival) >= 0.001) + errh->warning("interpolated %s should be an integer (it is %g)", name.c_str(), val); + def->set_num(ival); + kill_def(blend_def, the_dict + dBlend); } } @@ -188,18 +188,18 @@ MyFont::interpolate_dict_num(PermString name, Dict the_dict, bool force_integer) NumVector blend; if (def && blend_def && blend_def->value_numvec(blend)) { - int n = _nmasters; - double val = 0; - for (int m = 0; m < n; m++) - val += blend[m] * _weight_vector[m]; - if (force_integer) - val = floor(val + 0.50001); - def->set_num(val); - kill_def(blend_def, the_dict + dBlend); + int n = _nmasters; + double val = 0; + for (int m = 0; m < n; m++) + val += blend[m] * _weight_vector[m]; + if (force_integer) + val = floor(val + 0.50001); + def->set_num(val); + kill_def(blend_def, the_dict + dBlend); } else if (def && !blend_def && force_integer) { - double val; - if (def->value_num(val)) - def->set_num(floor(val + 0.50001)); + double val; + if (def->value_num(val)) + def->set_num(floor(val + 0.50001)); } } @@ -211,20 +211,20 @@ MyFont::interpolate_dict_numvec(PermString name, Dict the_dict, int round_mode, Vector<NumVector> blend; if (def && blend_def && blend_def->value_numvec_vec(blend)) { - int n = blend.size(); - NumVector val; - for (int i = 0; i < n; i++) { - double d = 0; - for (int m = 0; m < _nmasters; m++) - d += blend[i][m] * _weight_vector[m]; - if (round_mode == 2 && i < 2) - d = floor(d - 0.50001); - else if (round_mode) - d = floor(d + 0.50001); - val.push_back(d); - } - def->set_numvec(val, executable); - kill_def(blend_def, the_dict + dBlend); + int n = blend.size(); + NumVector val; + for (int i = 0; i < n; i++) { + double d = 0; + for (int m = 0; m < _nmasters; m++) + d += blend[i][m] * _weight_vector[m]; + if (round_mode == 2 && i < 2) + d = floor(d - 0.50001); + else if (round_mode) + d = floor(d + 0.50001); + val.push_back(d); + } + def->set_numvec(val, executable); + kill_def(blend_def, the_dict + dBlend); } } @@ -256,11 +256,11 @@ MyFont::interpolate_dicts(bool force_integer, ErrorHandler *errh) Vector<PermString> namevec; double thresh_val; if (def && blend_def && thresh && blend_def->value_namevec(namevec) - && thresh->value_num(thresh_val) && namevec.size() == _nmasters) { + && thresh->value_num(thresh_val) && namevec.size() == _nmasters) { double v = 0; for (int m = 0; m < _nmasters; m++) - if (namevec[m] == "true") - v += _weight_vector[m]; + if (namevec[m] == "true") + v += _weight_vector[m]; def->set_code(v >= thresh_val ? "true" : "false"); kill_def(blend_def, dBlendPrivate); } @@ -276,13 +276,13 @@ MyFont::interpolate_dicts(bool force_integer, ErrorHandler *errh) for (DictHashMap::const_iterator i = dict_begin(dBlend); i; i++) { PermString name = i.key(); if (i.value() && name != "Private" && name != "FontInfo" - && name != "ConvertDesignVector" && name != "NormalizeDesignVector") - errh->warning("didn%,t interpolate %s in Blend", name.c_str()); + && name != "ConvertDesignVector" && name != "NormalizeDesignVector") + errh->warning("didn%,t interpolate %s in Blend", name.c_str()); } for (DictHashMap::const_iterator i = dict_begin(dBlendPrivate); i; i++) if (i.value() && i.key() != "Erode") - errh->warning("didn%,t interpolate %s in BlendPrivate", i.key().c_str()); + errh->warning("didn%,t interpolate %s in BlendPrivate", i.key().c_str()); kill_def(p_dict("NDV"), dPrivate); kill_def(p_dict("CDV"), dPrivate); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1minimize.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1minimize.cc index da7fee98cc3..99c184cb29b 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1minimize.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1minimize.cc @@ -1,6 +1,6 @@ /* t1minimize.cc -- make minimal copy of a Type 1 font * - * Copyright (c) 2003-2019 Eddie Kohler + * Copyright (c) 2003-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -29,13 +29,13 @@ minimize(Type1Font *font) // Subrs for (int i = 0; i < font->nsubrs(); i++) - if (Type1Subr *s = font->subr_x(i)) - output->set_subr(s->subrno(), s->t1cs(), s->definer()); + if (Type1Subr *s = font->subr_x(i)) + output->set_subr(s->subrno(), s->t1cs(), s->definer()); // CharStrings for (int i = 0; i < font->nglyphs(); i++) - if (Type1Subr *g = font->glyph_x(i)) - output->add_glyph(Type1Subr::make_glyph(g->name(), g->t1cs(), g->definer())); + if (Type1Subr *g = font->glyph_x(i)) + output->add_glyph(Type1Subr::make_glyph(g->name(), g->t1cs(), g->definer())); return output; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.cc index c8a4f507f03..5a01baa276d 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.cc @@ -1,6 +1,6 @@ /* t1rewrit.cc -- routines for multiple- to single-master charstring conversion * - * Copyright (c) 1997-2019 Eddie Kohler + * Copyright (c) 1997-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -45,7 +45,7 @@ class HintReplacementDetector : public CharstringInterp { public: HintReplacementDetector(Type1Font *, const Vector<double> &, int); bool is_hint_replacement(int i) const { return _hint_replacements[i] != 0; } - int call_count(int i) const { return _call_counts[i]; } + int call_count(int i) const { return _call_counts[i]; } bool type1_command(int); @@ -80,50 +80,50 @@ HintReplacementDetector::type1_command(int cmd) switch (cmd) { case Cs::cCallothersubr: { - if (size() < 2) - goto unknown; - int command = (int)top(0); - int n = (int)top(1); - if (command == Cs::othcReplacehints && n == 1) { - pop(2); - _hint_replacements[(int)top()] = 1; - ps_clear(); - ps_push(top()); - pop(); - break; - } else if (command >= Cs::othcMM1 && command <= Cs::othcMM6) { - pop(2); - return mm_command(command, n); - } else if (command >= Cs::othcITC_load && command <= Cs::othcITC_random) { - pop(2); - return itc_command(command, n); - } else - goto unknown; + if (size() < 2) + goto unknown; + int command = (int)top(0); + int n = (int)top(1); + if (command == Cs::othcReplacehints && n == 1) { + pop(2); + _hint_replacements[(int)top()] = 1; + ps_clear(); + ps_push(top()); + pop(); + break; + } else if (command >= Cs::othcMM1 && command <= Cs::othcMM6) { + pop(2); + return mm_command(command, n); + } else if (command >= Cs::othcITC_load && command <= Cs::othcITC_random) { + pop(2); + return itc_command(command, n); + } else + goto unknown; } case Cs::cCallsubr: { - if (size() < 1) - return error(errUnderflow, cmd); - int which = (int)pop(); - if (!_count_calls_below || _subr_level < _count_calls_below) - _call_counts[which]++; - - Charstring *subr_cs = get_subr(which); - if (!subr_cs) - return error(errSubr, which); - - _subr_level++; - subr_cs->process(*this); - _subr_level--; - - if (error() != errOK) - return false; - return !done(); + if (size() < 1) + return error(errUnderflow, cmd); + int which = (int)pop(); + if (!_count_calls_below || _subr_level < _count_calls_below) + _call_counts[which]++; + + Charstring *subr_cs = get_subr(which); + if (!subr_cs) + return error(errSubr, which); + + _subr_level++; + subr_cs->process(*this); + _subr_level--; + + if (error() != errOK) + return false; + return !done(); } case Cs::cEndchar: case Cs::cReturn: - return CharstringInterp::type1_command(cmd); + return CharstringInterp::type1_command(cmd); case Cs::cBlend: case Cs::cAbs: @@ -144,17 +144,17 @@ HintReplacementDetector::type1_command(int cmd) case Cs::cNot: case Cs::cEq: case Cs::cIfelse: - return arith_command(cmd); + return arith_command(cmd); case Cs::cPop: - if (ps_size() >= 1) - push(ps_pop()); - break; + if (ps_size() >= 1) + push(ps_pop()); + break; default: unknown: - clear(); - break; + clear(); + break; } return true; @@ -253,98 +253,98 @@ Type1OneMMRemover::itc_command(int command, int on_stack) assert(weight.size()); Vector<double> *scratch = scratch_vector(); Type1CharstringGen *gen = - (_in_prefix ? &_prefix_gen : (_in_subr ? &_main_gen : 0)); + (_in_prefix ? &_prefix_gen : (_in_subr ? &_main_gen : 0)); int base = size() - on_stack - 2; switch (command) { case Cs::othcITC_load: { - if (on_stack != 1) - return false; - int offset = (int)at(base); - for (int i = 0; i < weight.size(); i++) - vec(scratch, offset+i) = weight.at_u(i); - // save load command, so we expand its effects into the scratch - // vector - if (gen) { - gen->gen_number(offset); - gen->gen_number(1); - gen->gen_number(Cs::othcITC_load); - gen->gen_command(Cs::cCallothersubr); - } - break; + if (on_stack != 1) + return false; + int offset = (int)at(base); + for (int i = 0; i < weight.size(); i++) + vec(scratch, offset+i) = weight.at_u(i); + // save load command, so we expand its effects into the scratch + // vector + if (gen) { + gen->gen_number(offset); + gen->gen_number(1); + gen->gen_number(Cs::othcITC_load); + gen->gen_command(Cs::cCallothersubr); + } + break; } case Cs::othcITC_put: { - if (on_stack != 2) - return false; - int offset = (int)at(base+1); - vec(scratch, offset) = at(base); - // save put command, so we expand its effects into the scratch - // vector - if (gen) { - gen->gen_number(at(base)); - gen->gen_number(offset); - gen->gen_number(2); - gen->gen_number(Cs::othcITC_put); - gen->gen_command(Cs::cCallothersubr); - } - break; + if (on_stack != 2) + return false; + int offset = (int)at(base+1); + vec(scratch, offset) = at(base); + // save put command, so we expand its effects into the scratch + // vector + if (gen) { + gen->gen_number(at(base)); + gen->gen_number(offset); + gen->gen_number(2); + gen->gen_number(Cs::othcITC_put); + gen->gen_command(Cs::cCallothersubr); + } + break; } case Cs::othcITC_get: { - if (on_stack != 1) - return false; - int offset = (int)at(base); - double d = vec(scratch, offset); - if (!KNOWN(d)) { - _must_expand = true; - return false; - } - ps_push(d); - break; + if (on_stack != 1) + return false; + int offset = (int)at(base); + double d = vec(scratch, offset); + if (!KNOWN(d)) { + _must_expand = true; + return false; + } + ps_push(d); + break; } case Cs::othcITC_add: { - if (on_stack != 2) - return false; - ps_push(at(base) + at(base+1)); - break; + if (on_stack != 2) + return false; + ps_push(at(base) + at(base+1)); + break; } case Cs::othcITC_sub: { - if (on_stack != 2) - return false; - ps_push(at(base) - at(base+1)); - break; + if (on_stack != 2) + return false; + ps_push(at(base) - at(base+1)); + break; } case Cs::othcITC_mul: { - if (on_stack != 2) - return false; - ps_push(at(base) * at(base+1)); - break; + if (on_stack != 2) + return false; + ps_push(at(base) * at(base+1)); + break; } case Cs::othcITC_div: { - if (on_stack != 2) - return false; - ps_push(at(base) / at(base+1)); - break; + if (on_stack != 2) + return false; + ps_push(at(base) / at(base+1)); + break; } case Cs::othcITC_ifelse: { - if (on_stack != 4) - return false; - if (at(base+2) <= at(base+3)) - ps_push(at(base)); - else - ps_push(at(base+1)); - break; + if (on_stack != 4) + return false; + if (at(base+2) <= at(base+3)) + ps_push(at(base)); + else + ps_push(at(base+1)); + break; } default: - return false; + return false; } @@ -358,81 +358,81 @@ Type1OneMMRemover::type1_command(int cmd) switch (cmd) { case Cs::cCallothersubr: { - // Expand known othersubr calls. If we cannot expand the othersubr - // call completely, then write it to the expander. - if (size() < 2) - goto partial_othersubr; - int command = (int)top(0); - int n = (int)top(1); - if (command >= Cs::othcITC_load && command <= Cs::othcITC_random) { - if (!itc_complained) - itc_complain(); - if (size() < 2 + n || !itc_command(command, n)) - goto partial_othersubr; - } else if (command >= Cs::othcMM1 && command <= Cs::othcMM6) { - if (size() < 2 + n) - goto partial_othersubr; - pop(2); - mm_command(command, n); - } else - goto normal; - break; + // Expand known othersubr calls. If we cannot expand the othersubr + // call completely, then write it to the expander. + if (size() < 2) + goto partial_othersubr; + int command = (int)top(0); + int n = (int)top(1); + if (command >= Cs::othcITC_load && command <= Cs::othcITC_random) { + if (!itc_complained) + itc_complain(); + if (size() < 2 + n || !itc_command(command, n)) + goto partial_othersubr; + } else if (command >= Cs::othcMM1 && command <= Cs::othcMM6) { + if (size() < 2 + n) + goto partial_othersubr; + pop(2); + mm_command(command, n); + } else + goto normal; + break; } partial_othersubr: { - if (!_in_prefix) { - _must_expand = true; - goto normal; - } - _prefix_gen.gen_stack(*this, 0); - _prefix_gen.gen_command(Cs::cCallothersubr); - break; + if (!_in_prefix) { + _must_expand = true; + goto normal; + } + _prefix_gen.gen_stack(*this, 0); + _prefix_gen.gen_command(Cs::cCallothersubr); + break; } case Cs::cCallsubr: { - // expand subroutines in line if necessary - if (size() < 1) - goto normal; - int subrno = (int)pop(); - if (_subr_level < 1) { // otherwise, have already included prefix - if (Type1Charstring *cs = _remover->subr_prefix(subrno)) - run_subr(cs); - } - if (Type1Charstring *cs = _remover->subr_expander(subrno)) - run_subr(cs); - else { - push(subrno); - goto normal; - } - break; + // expand subroutines in line if necessary + if (size() < 1) + goto normal; + int subrno = (int)pop(); + if (_subr_level < 1) { // otherwise, have already included prefix + if (Type1Charstring *cs = _remover->subr_prefix(subrno)) + run_subr(cs); + } + if (Type1Charstring *cs = _remover->subr_expander(subrno)) + run_subr(cs); + else { + push(subrno); + goto normal; + } + break; } case Cs::cPop: - if (ps_size() >= 1) - push(ps_pop()); - else if (_in_prefix && ps_size() == 0) { - _prefix_gen.gen_stack(*this, 0); - _prefix_gen.gen_command(Cs::cPop); - } else - goto normal; - break; + if (ps_size() >= 1) + push(ps_pop()); + else if (_in_prefix && ps_size() == 0) { + _prefix_gen.gen_stack(*this, 0); + _prefix_gen.gen_command(Cs::cPop); + } else + goto normal; + break; case Cs::cDiv: - if (size() < 2) - goto normal; - top(1) /= top(0); - pop(); - break; + if (size() < 2) + goto normal; + top(1) /= top(0); + pop(); + break; case Cs::cReturn: - return false; + return false; normal: default: - _main_gen.gen_stack(*this, cmd); - _main_gen.gen_command(cmd); - _in_prefix = 0; - return (cmd != Cs::cEndchar); + _main_gen.gen_stack(*this, cmd); + _main_gen.gen_command(cmd); + _in_prefix = 0; + return (cmd != Cs::cEndchar); } return true; @@ -441,7 +441,7 @@ Type1OneMMRemover::type1_command(int cmd) bool Type1OneMMRemover::run(const Type1Charstring &cs, - bool in_subr, bool do_prefix, bool fresh) + bool in_subr, bool do_prefix, bool fresh) { _prefix_gen.clear(); _main_gen.clear(); @@ -455,15 +455,15 @@ Type1OneMMRemover::run(const Type1Charstring &cs, CharstringInterp::interpret(_remover->program(), &cs); if (in_subr) { - _main_gen.gen_stack(*this, Cs::cReturn); - _main_gen.gen_command(Cs::cReturn); + _main_gen.gen_stack(*this, Cs::cReturn); + _main_gen.gen_command(Cs::cReturn); } if (_must_expand) - return true; + return true; if (fresh && in_subr) { - if (_main_gen.length() == 0 - || (_main_gen.length() == 1 && _main_gen.data()[0] == Cs::cReturn)) - return true; + if (_main_gen.length() == 0 + || (_main_gen.length() == 1 && _main_gen.data()[0] == Cs::cReturn)) + return true; } return false; } @@ -490,10 +490,10 @@ Type1Charstring * Type1OneMMRemover::output_prefix() { if (_prefix_gen.length() > 0) { - _prefix_gen.gen_command(Cs::cReturn); - return _prefix_gen.output(); + _prefix_gen.gen_command(Cs::cReturn); + return _prefix_gen.output(); } else - return 0; + return 0; } void @@ -535,21 +535,21 @@ Type1BadCallRemover::type1_command(int cmd) switch (cmd) { case Cs::cCallsubr: { - if (size() < 1) - goto normal; - int subrno = (int)top(); - if (!get_subr(subrno)) { - pop(); - return false; - } else - goto normal; + if (size() < 1) + goto normal; + int subrno = (int)top(); + if (!get_subr(subrno)) { + pop(); + return false; + } else + goto normal; } normal: default: - _gen.gen_stack(*this, 0); - _gen.gen_command(cmd); - return (cmd != Cs::cEndchar || _is_subr) && cmd != Cs::cReturn; + _gen.gen_stack(*this, 0); + _gen.gen_command(cmd); + return (cmd != Cs::cEndchar || _is_subr) && cmd != Cs::cReturn; } } @@ -570,7 +570,7 @@ Type1BadCallRemover::run(Type1Charstring &cs, bool is_subr) **/ Type1MMRemover::Type1MMRemover(Type1Font *font, const Vector<double> &wv, - int precision, ErrorHandler *errh) + int precision, ErrorHandler *errh) : _font(font), _weight_vector(wv), _precision(precision), _nsubrs(font->nsubrs()), _subr_done(_nsubrs, 0), @@ -584,22 +584,22 @@ Type1MMRemover::Type1MMRemover(Type1Font *font, const Vector<double> &wv, // find subroutines needed for hint replacement HintReplacementDetector hr(font, wv, 0); for (int i = 0; i < _font->nglyphs(); i++) - if (Type1Subr *g = _font->glyph_x(i)) - hr.run(font, g->t1cs()); + if (Type1Subr *g = _font->glyph_x(i)) + hr.run(font, g->t1cs()); for (int i = 0; i < _nsubrs; i++) - if (hr.is_hint_replacement(i)) - _hint_replacement_subr[i] = 1; + if (hr.is_hint_replacement(i)) + _hint_replacement_subr[i] = 1; // don't get rid of first 4 subrs for (int i = 0; i < _nsubrs && i < 4; i++) - _subr_done[i] = 1; + _subr_done[i] = 1; } Type1MMRemover::~Type1MMRemover() { for (int i = 0; i < _nsubrs; i++) - if (_subr_prefix[i]) - delete _subr_prefix[i]; + if (_subr_prefix[i]) + delete _subr_prefix[i]; } @@ -607,20 +607,20 @@ Type1Charstring * Type1MMRemover::subr_prefix(int subrno) { if (subrno < 0 || subrno >= _nsubrs) - return 0; + return 0; if (!_subr_done[subrno]) { - _subr_done[subrno] = 1; + _subr_done[subrno] = 1; - Type1Charstring *subr = _font->subr(subrno); - if (!subr) - return 0; + Type1Charstring *subr = _font->subr(subrno); + if (!subr) + return 0; - Type1OneMMRemover one(this); - if (one.run_fresh_subr(*subr, !_hint_replacement_subr[subrno])) - _must_expand_subr[subrno] = true; - _subr_prefix[subrno] = one.output_prefix(); - one.output_main(*subr); + Type1OneMMRemover one(this); + if (one.run_fresh_subr(*subr, !_hint_replacement_subr[subrno])) + _must_expand_subr[subrno] = true; + _subr_prefix[subrno] = one.output_prefix(); + one.output_main(*subr); } return _subr_prefix[subrno]; @@ -630,11 +630,11 @@ Type1Charstring * Type1MMRemover::subr_expander(int subrno) { if (subrno < 0 || subrno >= _nsubrs) - return 0; + return 0; if (!_subr_done[subrno]) - (void)subr_prefix(subrno); + (void)subr_prefix(subrno); if (!_expand_all_subrs && !_must_expand_subr[subrno]) - return 0; + return 0; return _font->subr(subrno); } @@ -655,73 +655,73 @@ Type1MMRemover::run() // check subroutines for (int subrno = 0; subrno < _nsubrs; subrno++) - (void)subr_prefix(subrno); + (void)subr_prefix(subrno); // expand glyphs Vector<PermString> bad_glyphs; for (int i = 0; i < _font->nglyphs(); i++) { - Type1Subr *g = _font->glyph_x(i); - if (g) { - if (one.run_fresh_glyph(g->t1cs())) { - // Every glyph should be fully expandable without encountering - // a MM command. If we fail the first time, try again, - // expanding ALL subroutines. This catches, for example, SUBR - // 1 { 1 0 return }; GLYPH g { 1 callsubr 2 blend }; This will - // fail the first time, because `1 callsubr' will be left as a - // subroutine call, so `1 0' (required arguments to `blend') - // won't be visible. - _expand_all_subrs = true; - if (one.run_fresh_glyph(g->t1cs())) - bad_glyphs.push_back(g->name()); - _expand_all_subrs = false; - } - one.output_main(g->t1cs()); - } + Type1Subr *g = _font->glyph_x(i); + if (g) { + if (one.run_fresh_glyph(g->t1cs())) { + // Every glyph should be fully expandable without encountering + // a MM command. If we fail the first time, try again, + // expanding ALL subroutines. This catches, for example, SUBR + // 1 { 1 0 return }; GLYPH g { 1 callsubr 2 blend }; This will + // fail the first time, because `1 callsubr' will be left as a + // subroutine call, so `1 0' (required arguments to `blend') + // won't be visible. + _expand_all_subrs = true; + if (one.run_fresh_glyph(g->t1cs())) + bad_glyphs.push_back(g->name()); + _expand_all_subrs = false; + } + one.output_main(g->t1cs()); + } } // remove uncalled subroutines, expand hint replacement subroutines HintReplacementDetector hr(_font, _weight_vector, 0); for (int i = 0; i < _font->nglyphs(); i++) - if (Type1Subr *g = _font->glyph_x(i)) - hr.run(_font, g->t1cs()); + if (Type1Subr *g = _font->glyph_x(i)) + hr.run(_font, g->t1cs()); // don't remove first four subroutines! for (int subrno = 4; subrno < _nsubrs; subrno++) - if (hr.call_count(subrno) || _hint_replacement_subr[subrno]) { - Type1Charstring *cs = _font->subr(subrno); - if (one.rerun_subr(*cs)) { - _expand_all_subrs = true; - if (one.rerun_subr(*cs)) - bad_glyphs.push_back(permprintf("subr %d", subrno)); - _expand_all_subrs = false; - } - one.output_main(*cs); - } else - _font->remove_subr(subrno); + if (hr.call_count(subrno) || _hint_replacement_subr[subrno]) { + Type1Charstring *cs = _font->subr(subrno); + if (one.rerun_subr(*cs)) { + _expand_all_subrs = true; + if (one.rerun_subr(*cs)) + bad_glyphs.push_back(permprintf("subr %d", subrno)); + _expand_all_subrs = false; + } + one.output_main(*cs); + } else + _font->remove_subr(subrno); // remove calls to removed subroutines Type1BadCallRemover bcr(this); for (int i = 0; i < _font->nglyphs(); i++) - if (Type1Subr *g = _font->glyph_x(i)) - bcr.run(g->t1cs(), false); + if (Type1Subr *g = _font->glyph_x(i)) + bcr.run(g->t1cs(), false); for (int subrno = 4; subrno < _nsubrs; subrno++) - if (Type1Charstring *cs = _font->subr(subrno)) - bcr.run(*cs, true); + if (Type1Charstring *cs = _font->subr(subrno)) + bcr.run(*cs, true); // report warnings if (bad_glyphs.size()) { - qsort(&bad_glyphs[0], bad_glyphs.size(), sizeof(PermString), sort_permstring_compare); - _errh->error("could not fully interpolate the following glyphs:"); - StringAccum sa; - for (int i = 0; i < bad_glyphs.size(); i++) { - PermString n = bad_glyphs[i]; - bool comma = (i < bad_glyphs.size() - 1); - if (sa.length() && sa.length() + 1 + n.length() + comma > 70) { - _errh->message(" %s", sa.c_str()); - sa.clear(); - } - sa << (sa.length() ? " " : "") << n << (comma ? "," : ""); - } - _errh->message(" %s", sa.c_str()); + qsort(&bad_glyphs[0], bad_glyphs.size(), sizeof(PermString), sort_permstring_compare); + _errh->error("could not fully interpolate the following glyphs:"); + StringAccum sa; + for (int i = 0; i < bad_glyphs.size(); i++) { + PermString n = bad_glyphs[i]; + bool comma = (i < bad_glyphs.size() - 1); + if (sa.length() && sa.length() + 1 + n.length() + comma > 70) { + _errh->message(" %s", sa.c_str()); + sa.clear(); + } + sa << (sa.length() ? " " : "") << n << (comma ? "," : ""); + } + _errh->message(" %s", sa.c_str()); } } @@ -759,42 +759,42 @@ SubrExpander::type1_command(int cmd) switch (cmd) { case Cs::cCallsubr: { - if (size() < 1) - goto unknown; - int subrno = (int)top(0); - int renumber_subrno = (subrno >= 0 && subrno < _renumbering->size() ? (*_renumbering)[subrno] : subrno); - if (renumber_subrno >= 0) { - top(0) = renumber_subrno; - goto unknown; - } - pop(); - if (Charstring *subr_cs = get_subr(subrno)) { - _subr_level++; - subr_cs->process(*this); - _subr_level--; - } - return !done(); + if (size() < 1) + goto unknown; + int subrno = (int)top(0); + int renumber_subrno = (subrno >= 0 && subrno < _renumbering->size() ? (*_renumbering)[subrno] : subrno); + if (renumber_subrno >= 0) { + top(0) = renumber_subrno; + goto unknown; + } + pop(); + if (Charstring *subr_cs = get_subr(subrno)) { + _subr_level++; + subr_cs->process(*this); + _subr_level--; + } + return !done(); } case Cs::cEndchar: - set_done(); - goto end_cs; + set_done(); + goto end_cs; case Cs::cReturn: - if (_subr_level) - return false; - goto end_cs; + if (_subr_level) + return false; + goto end_cs; end_cs: - _gen.gen_stack(*this, cmd); - _gen.gen_command(cmd); - return false; + _gen.gen_stack(*this, cmd); + _gen.gen_command(cmd); + return false; default: unknown: - _gen.gen_stack(*this, cmd); - _gen.gen_command(cmd); - break; + _gen.gen_stack(*this, cmd); + _gen.gen_command(cmd); + break; } return true; @@ -823,27 +823,27 @@ Type1SubrRemover::Type1SubrRemover(Type1Font *font, ErrorHandler *errh) // find subroutines needed for hint replacement HintReplacementDetector hr(font, 2); for (int i = 0; i < _font->nglyphs(); i++) { - Type1Subr *g = _font->glyph_x(i); - if (g) - hr.run(_font, g->t1cs()); + Type1Subr *g = _font->glyph_x(i); + if (g) + hr.run(_font, g->t1cs()); } // save necessary subroutines for (int i = 0; i < 4; i++) { - _renumbering[i] = i; - _save_count++; + _renumbering[i] = i; + _save_count++; } // save hint-replacement subroutines for (int i = 0; i < _nsubrs; i++) { - Type1Subr *cs = _font->subr_x(i); - if (!cs) { - _renumbering[i] = DEAD; - _nonexist_count++; - } else if (hr.is_hint_replacement(i)) { - _renumbering[i] = i; - _save_count++; - } else - _cost[i] = hr.call_count(i) * (cs->t1cs().length() - (i <= 107 ? 2 : 3)); + Type1Subr *cs = _font->subr_x(i); + if (!cs) { + _renumbering[i] = DEAD; + _nonexist_count++; + } else if (hr.is_hint_replacement(i)) { + _renumbering[i] = i; + _save_count++; + } else + _cost[i] = hr.call_count(i) * (cs->t1cs().length() - (i <= 107 ? 2 : 3)); } } @@ -867,20 +867,20 @@ bool Type1SubrRemover::run(int lower_to) { if (lower_to < 0) - lower_to = _nsubrs; + lower_to = _nsubrs; if (lower_to < _save_count) { - _errh->warning("reducing %s to minimum number of subroutines (%d)", - _font->font_name().c_str(), _save_count - _nonexist_count); - lower_to = _save_count; + _errh->warning("reducing %s to minimum number of subroutines (%d)", + _font->font_name().c_str(), _save_count - _nonexist_count); + lower_to = _save_count; } int to_remove = _nsubrs - _nonexist_count - lower_to; if (to_remove < 0) - to_remove = 0; + to_remove = 0; // multiply by lost bytes per call Vector<int> permute; for (int i = 0; i < _nsubrs; i++) - permute.push_back(i); + permute.push_back(i); // sort them by least frequent use -> most frequent use sort_keys = &_cost; @@ -889,33 +889,33 @@ Type1SubrRemover::run(int lower_to) // mark first portion of `permute' to be removed int removed = 0; for (int i = 0; i < _nsubrs; i++) { - int p = permute[i]; - if (_renumbering[p] == REMOVABLE && removed < to_remove) { - _renumbering[p] = DEAD; - removed++; - } + int p = permute[i]; + if (_renumbering[p] == REMOVABLE && removed < to_remove) { + _renumbering[p] = DEAD; + removed++; + } } // renumber the rest int renumber_pos = 0; for (int i = 0; i < _nsubrs; i++) - if (_renumbering[i] == REMOVABLE) { // save it - while (_renumbering[renumber_pos] >= 0) - renumber_pos++; - _renumbering[i] = renumber_pos++; - } + if (_renumbering[i] == REMOVABLE) { // save it + while (_renumbering[renumber_pos] >= 0) + renumber_pos++; + _renumbering[i] = renumber_pos++; + } SubrExpander rem0; rem0.set_renumbering(&_renumbering); // go through and change them all for (int i = 0; i < _nsubrs; i++) { - Type1Subr *s = _font->subr_x(i); - if (s && _renumbering[i] >= 0) - rem0.run(_font, s->t1cs()); + Type1Subr *s = _font->subr_x(i); + if (s && _renumbering[i] >= 0) + rem0.run(_font, s->t1cs()); } for (int i = 0; i < _font->nglyphs(); i++) - if (Type1Subr *g = _font->glyph_x(i)) - rem0.run(_font, g->t1cs()); + if (Type1Subr *g = _font->glyph_x(i)) + rem0.run(_font, g->t1cs()); // actually remove subroutines _font->renumber_subrs(_renumbering); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.hh index eac9d75beeb..53f78b773ab 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/mmpfb/t1rewrit.hh @@ -9,10 +9,10 @@ class Type1MMRemover { public: Type1MMRemover(Efont::Type1Font *, const Vector<double> &weight_vec, int, ErrorHandler *); ~Type1MMRemover(); - Efont::CharstringProgram *program() const { return _font; } + Efont::CharstringProgram *program() const { return _font; } const Vector<double> &weight_vector() const { return _weight_vector; } - int nmasters() const { return _weight_vector.size(); } - int precision() const { return _precision; } + int nmasters() const { return _weight_vector.size(); } + int precision() const { return _precision; } Efont::Type1Charstring *subr_prefix(int); Efont::Type1Charstring *subr_expander(int); @@ -42,10 +42,10 @@ class Type1SubrRemover { public: Type1SubrRemover(Efont::Type1Font *, ErrorHandler *); ~Type1SubrRemover(); - Efont::CharstringProgram *program() const { return _font; } - ErrorHandler *errh() const { return _errh; } + Efont::CharstringProgram *program() const { return _font; } + ErrorHandler *errh() const { return _errh; } - int save_count() const { return _save_count; } + int save_count() const { return _save_count; } bool run(int); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.1 index 558d5e144f3..a09995cbe3f 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.1 @@ -1,5 +1,5 @@ '\"t -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. @@ -132,6 +132,25 @@ Print each Unicode code point supported by the font, followed by the glyph numbe representing that code point (and, if present, the name of the corresponding glyph). .Sp .TP 5 +.BR \-\-variable +Print information about a variable font's variation axes, including their +names and parameter ranges. For example: +.nf + Axis 0: wght + Axis 0 name: Weight + Axis 0 range: 300 800 + Axis 0 default: 400 + Axis 1: wdth + Axis 1 name: Width + Axis 1 range: 75 100 + Axis 1 default: 100 + Instance 0 name: Light + Instance 0 position: 300 100 + Instance 1 name: Regular + Instance 1 position: 400 100 +.fi +.Sp +.TP 5 .BR \-t ", " \-\-tables Print the size and name of every OpenType table in the font. For example: .nf diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.cc index ea917b6a073..12f6c330ea8 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otfinfo/otfinfo.cc @@ -1,6 +1,6 @@ /* otfinfo.cc -- driver for reporting information about OpenType fonts * - * Copyright (c) 2003-2019 Eddie Kohler + * Copyright (c) 2003-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -16,6 +16,7 @@ #endif #include <efont/psres.hh> #include <efont/otfcmap.hh> +#include <efont/otffvar.hh> #include <efont/otfgsub.hh> #include <efont/otfgpos.hh> #include <efont/otfname.hh> @@ -43,23 +44,24 @@ using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define QUIET_OPT 303 -#define VERBOSE_OPT 304 -#define SCRIPT_OPT 305 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define QUIET_OPT 303 +#define VERBOSE_OPT 304 +#define SCRIPT_OPT 305 -#define QUERY_SCRIPTS_OPT 320 -#define QUERY_FEATURES_OPT 321 -#define QUERY_OPTICAL_SIZE_OPT 322 +#define QUERY_SCRIPTS_OPT 320 +#define QUERY_FEATURES_OPT 321 +#define QUERY_OPTICAL_SIZE_OPT 322 #define QUERY_POSTSCRIPT_NAME_OPT 323 -#define QUERY_GLYPHS_OPT 324 -#define QUERY_FVERSION_OPT 325 -#define TABLES_OPT 326 -#define QUERY_FAMILY_OPT 327 -#define INFO_OPT 328 -#define DUMP_TABLE_OPT 329 -#define QUERY_UNICODE_OPT 330 +#define QUERY_GLYPHS_OPT 324 +#define QUERY_FVERSION_OPT 325 +#define TABLES_OPT 326 +#define QUERY_FAMILY_OPT 327 +#define INFO_OPT 328 +#define DUMP_TABLE_OPT 329 +#define QUERY_UNICODE_OPT 330 +#define QUERY_VARIABLE_OPT 331 const Clp_Option options[] = { { "script", 0, SCRIPT_OPT, Clp_ValString, 0 }, @@ -77,6 +79,8 @@ const Clp_Option options[] = { { "tables", 't', TABLES_OPT, 0, 0 }, { "dump-table", 'T', DUMP_TABLE_OPT, Clp_ValString, 0 }, { "unicode", 'u', QUERY_UNICODE_OPT, 0, 0 }, + { "variable", 0, QUERY_VARIABLE_OPT, 0, 0 }, + { "variations", 0, QUERY_VARIABLE_OPT, 0, 0 }, { "help", 'h', HELP_OPT, 0, 0 }, { "version", 0, VERSION_OPT, 0, 0 }, }; @@ -96,11 +100,12 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) va_list val; va_start(val, error_message); if (!error_message) - errh->message("Usage: %s [OPTION]... FONT", program_name); + errh->message("Usage: %s [OPTION]... FONT", program_name); else - errh->xmessage(ErrorHandler::e_error, error_message, val); + errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -112,7 +117,7 @@ usage() Options specify what information to print.\n\ \n\ Usage: %s [-sfzpg | OPTIONS] [OTFFILES...]\n\n", - program_name); + program_name); uerrh.message("\ Query options:\n\ -s, --scripts Report font%,s supported scripts.\n\ @@ -124,6 +129,8 @@ Query options:\n\ -i, --info Report font%,s names and designer/vendor info.\n\ -g, --glyphs Report font%,s glyph names.\n\ -t, --tables Report font%,s OpenType tables.\n\ + -u, --unicode Report font%,s supported Unicode code points.\n\ + --variable Report variable font information.\n\ -T, --dump-table NAME Output font%,s %<NAME%> table.\n\ \n\ Other options:\n\ @@ -142,36 +149,36 @@ read_file(String filename, ErrorHandler *errh, bool warning = false) FILE *f; int f_errno = 0; if (!filename || filename == "-") { - filename = "<stdin>"; - f = stdin; + filename = "<stdin>"; + f = stdin; #if defined(_MSDOS) || defined(_WIN32) - // Set the file mode to binary - _setmode(_fileno(f), _O_BINARY); + // Set the file mode to binary + _setmode(_fileno(f), _O_BINARY); #endif } else { - f = fopen(filename.c_str(), "rb"); - f_errno = errno; + f = fopen(filename.c_str(), "rb"); + f_errno = errno; } String error_anno = (warning ? errh->e_warning : errh->e_error) + ErrorHandler::make_landmark_anno(filename); if (!f) { - errh->xmessage(error_anno, strerror(f_errno)); - return String(); + errh->xmessage(error_anno, strerror(f_errno)); + return String(); } StringAccum sa; int amt; do { - if (char *x = sa.reserve(8192)) { - amt = fread(x, 1, 8192, f); - sa.adjust_length(amt); - } else - amt = 0; + if (char *x = sa.reserve(8192)) { + amt = fread(x, 1, 8192, f); + sa.adjust_length(amt); + } else + amt = 0; } while (amt != 0); if (!feof(f) || ferror(f)) - errh->xmessage(error_anno, strerror(errno)); + errh->xmessage(error_anno, strerror(errno)); if (f != stdin) - fclose(f); + fclose(f); return sa.take_string(); } @@ -179,9 +186,9 @@ String printable_filename(const String &s) { if (!s || s == "-") - return String::make_stable("<stdin>"); + return String::make_stable("<stdin>"); else - return s; + return s; } static void @@ -190,18 +197,18 @@ collect_script_descriptions(const OpenType::ScriptList &script_list, Vector<Stri Vector<OpenType::Tag> script, langsys; script_list.language_systems(script, langsys, errh); for (int i = 0; i < script.size(); i++) { - String what = script[i].text(); - const char *s = script[i].script_description(); - String where = (s ? s : "<unknown script>"); - if (!langsys[i].null()) { - what += String(".") + langsys[i].text(); - s = langsys[i].language_description(); - where += String("/") + (s ? s : "<unknown language>"); - } - if (what.length() < 8) - output.push_back(what + String("\t\t") + where); - else - output.push_back(what + String("\t") + where); + String what = script[i].text(); + const char *s = script[i].script_description(); + String where = (s ? s : "<unknown script>"); + if (!langsys[i].null()) { + what += String(".") + langsys[i].text(); + s = langsys[i].language_description(); + where += String("/") + (s ? s : "<unknown language>"); + } + if (what.length() < 8) + output.push_back(what + String("\t\t") + where); + else + output.push_back(what + String("\t") + where); } } @@ -210,19 +217,19 @@ do_query_scripts(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandler *re { Vector<String> results; if (String gsub_table = otf.table("GSUB")) { - OpenType::Gsub gsub(gsub_table, &otf, errh); - collect_script_descriptions(gsub.script_list(), results, errh); + OpenType::Gsub gsub(gsub_table, &otf, errh); + collect_script_descriptions(gsub.script_list(), results, errh); } if (String gpos_table = otf.table("GPOS")) { - OpenType::Gpos gpos(gpos_table, errh); - collect_script_descriptions(gpos.script_list(), results, errh); + OpenType::Gpos gpos(gpos_table, errh); + collect_script_descriptions(gpos.script_list(), results, errh); } if (results.size()) { - std::sort(results.begin(), results.end()); - String *unique_result = std::unique(results.begin(), results.end()); - for (String *sp = results.begin(); sp < unique_result; sp++) - result_errh->message("%s", sp->c_str()); + std::sort(results.begin(), results.end()); + String *unique_result = std::unique(results.begin(), results.end()); + for (String *sp = results.begin(); sp < unique_result; sp++) + result_errh->message("%s", sp->c_str()); } } @@ -234,12 +241,12 @@ collect_feature_descriptions(const OpenType::ScriptList &script_list, const Open // collect features applying to this script script_list.features(script, langsys, required_fid, fids, errh); for (int i = -1; i < fids.size(); i++) { - int fid = (i < 0 ? required_fid : fids[i]); - if (fid >= 0) { - OpenType::Tag tag = feature_list.tag(fid); - const char *s = tag.feature_description(); - output.push_back(tag.text() + String("\t") + (s ? s : "<unknown feature>")); - } + int fid = (i < 0 ? required_fid : fids[i]); + if (fid >= 0) { + OpenType::Tag tag = feature_list.tag(fid); + const char *s = tag.feature_description(); + output.push_back(tag.text() + String("\t") + (s ? s : "<unknown feature>")); + } } } @@ -248,19 +255,19 @@ do_query_features(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandler *r { Vector<String> results; if (String gsub_table = otf.table("GSUB")) { - OpenType::Gsub gsub(gsub_table, &otf, errh); - collect_feature_descriptions(gsub.script_list(), gsub.feature_list(), results, errh); + OpenType::Gsub gsub(gsub_table, &otf, errh); + collect_feature_descriptions(gsub.script_list(), gsub.feature_list(), results, errh); } if (String gpos_table = otf.table("GPOS")) { - OpenType::Gpos gpos(gpos_table, errh); - collect_feature_descriptions(gpos.script_list(), gpos.feature_list(), results, errh); + OpenType::Gpos gpos(gpos_table, errh); + collect_feature_descriptions(gpos.script_list(), gpos.feature_list(), results, errh); } if (results.size()) { - std::sort(results.begin(), results.end()); - String *unique_result = std::unique(results.begin(), results.end()); - for (String *sp = results.begin(); sp < unique_result; sp++) - result_errh->message("%s", sp->c_str()); + std::sort(results.begin(), results.end()); + String *unique_result = std::unique(results.begin(), results.end()); + for (String *sp = results.begin(); sp < unique_result; sp++) + result_errh->message("%s", sp->c_str()); } } @@ -269,43 +276,43 @@ do_query_optical_size_size(const OpenType::Font &otf, ErrorHandler *errh, ErrorH { int before_nerrors = errh->nerrors(); try { - String gpos_table = otf.table("GPOS"); - if (!gpos_table) - return false; - - OpenType::Gpos gpos(gpos_table, errh); - OpenType::Name name(otf.table("name"), errh); - - // extract 'size' feature - int required_fid; - Vector<int> fids; - gpos.script_list().features(script, langsys, required_fid, fids, errh); - - int size_fid = gpos.feature_list().find(OpenType::Tag("size"), fids); - if (size_fid < 0) - return false; - - // old Adobe fonts implement an old, incorrect idea - // of what the FeatureParams offset means. - OpenType::Data size_data = gpos.feature_list().size_params(size_fid, name, errh); - if (!size_data.length()) - return false; - - StringAccum sa; - sa << "design size " << (size_data.u16(0) / 10.) << " pt"; - if (size_data.u16(2) != 0) { - sa << ", size range (" << (size_data.u16(6) / 10.) << " pt, " - << (size_data.u16(8) / 10.) << " pt], " - << "subfamily ID " << size_data.u16(2); - if (String n = name.english_name(size_data.u16(4))) - sa << ", subfamily name " << n; - } - - result_errh->message("%s", sa.c_str()); + String gpos_table = otf.table("GPOS"); + if (!gpos_table) + return false; + + OpenType::Gpos gpos(gpos_table, errh); + OpenType::Name name(otf.table("name"), errh); + + // extract 'size' feature + int required_fid; + Vector<int> fids; + gpos.script_list().features(script, langsys, required_fid, fids, errh); + + int size_fid = gpos.feature_list().find(OpenType::Tag("size"), fids); + if (size_fid < 0) + return false; + + // old Adobe fonts implement an old, incorrect idea + // of what the FeatureParams offset means. + OpenType::Data size_data = gpos.feature_list().size_params(size_fid, name, errh); + if (!size_data.length()) + return false; + + StringAccum sa; + sa << "design size " << (size_data.u16(0) / 10.) << " pt"; + if (size_data.u16(2) != 0) { + sa << ", size range (" << (size_data.u16(6) / 10.) << " pt, " + << (size_data.u16(8) / 10.) << " pt], " + << "subfamily ID " << size_data.u16(2); + if (String n = name.english_name(size_data.u16(4))) + sa << ", subfamily name " << n; + } + + result_errh->message("%s", sa.c_str()); return true; } catch (OpenType::Error) { - return errh->nerrors() != before_nerrors; + return errh->nerrors() != before_nerrors; } } @@ -321,8 +328,8 @@ do_query_optical_size(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandle if (!os2_table) throw OpenType::Error(); - OpenType::Os2 os2(os2_table, errh); - if (!os2.ok() || !os2.has_optical_point_size()) + OpenType::Os2 os2(os2_table, errh); + if (!os2.ok() || !os2.has_optical_point_size()) throw OpenType::Error(); StringAccum sa; @@ -330,8 +337,8 @@ do_query_optical_size(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandle result_errh->message("%s", sa.c_str()); } catch (OpenType::Error) { - if (errh->nerrors() == before_nerrors) - result_errh->message("no optical size information"); + if (errh->nerrors() == before_nerrors) + result_errh->message("no optical size information"); } } @@ -342,13 +349,13 @@ do_query_family_name(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandler String family_name = "no family name information"; if (String name_table = otf.table("name")) { - OpenType::Name name(name_table, errh); - if (name.ok()) - family_name = name.english_name(OpenType::Name::N_FAMILY); + OpenType::Name name(name_table, errh); + if (name.ok()) + family_name = name.english_name(OpenType::Name::N_FAMILY); } if (errh->nerrors() == before_nerrors) - result_errh->message("%s", family_name.c_str()); + result_errh->message("%s", family_name.c_str()); } static void @@ -358,13 +365,13 @@ do_query_postscript_name(const OpenType::Font &otf, ErrorHandler *errh, ErrorHan String postscript_name = "no PostScript name information"; if (String name_table = otf.table("name")) { - OpenType::Name name(name_table, errh); - if (name.ok()) - postscript_name = name.english_name(OpenType::Name::N_POSTSCRIPT); + OpenType::Name name(name_table, errh); + if (name.ok()) + postscript_name = name.english_name(OpenType::Name::N_POSTSCRIPT); } if (errh->nerrors() == before_nerrors) - result_errh->message("%s", postscript_name.c_str()); + result_errh->message("%s", postscript_name.c_str()); } static void @@ -374,13 +381,13 @@ do_query_font_version(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandle String version = "no version information"; if (String name_table = otf.table("name")) { - OpenType::Name name(name_table, errh); - if (name.ok()) - version = name.english_name(OpenType::Name::N_VERSION); + OpenType::Name name(name_table, errh); + if (name.ok()) + version = name.english_name(OpenType::Name::N_VERSION); } if (errh->nerrors() == before_nerrors) - result_errh->message("%s", version.c_str()); + result_errh->message("%s", version.c_str()); } static void @@ -390,87 +397,106 @@ do_info(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandler *result_errh StringAccum sa; if (String name_table = otf.table("name")) { - OpenType::Name name(name_table, errh); - if (name.ok()) { - if (String s = name.english_name(OpenType::Name::N_FAMILY)) - sa << "Family: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_SUBFAMILY)) - sa << "Subfamily: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_FULLNAME)) - sa << "Full name: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_POSTSCRIPT)) - sa << "PostScript name: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_POSTSCRIPT_CID)) - sa << "PostScript CID name: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_PREF_FAMILY)) - sa << "Preferred family: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_PREF_SUBFAMILY)) - sa << "Preferred subfamily: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_MAC_COMPAT_FULLNAME)) - sa << "Mac font menu name: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_VERSION)) - sa << "Version: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_UNIQUEID)) - sa << "Unique ID: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_DESCRIPTION)) - sa << "Description: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_DESIGNER)) - sa << "Designer: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_DESIGNER_URL)) - sa << "Designer URL: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_MANUFACTURER)) - sa << "Manufacturer: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_VENDOR_URL)) - sa << "Vendor URL: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_TRADEMARK)) - sa << "Trademark: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_COPYRIGHT)) - sa << "Copyright: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_LICENSE_URL)) - sa << "License URL: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_LICENSE_DESCRIPTION)) - sa << "License Description: " << s << "\n"; - if (String s = name.english_name(OpenType::Name::N_SAMPLE_TEXT)) - sa << "Sample text: " << s << "\n"; - } + OpenType::Name name(name_table, errh); + if (name.ok()) { + if (String s = name.english_name(OpenType::Name::N_FAMILY)) + sa << "Family: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_SUBFAMILY)) + sa << "Subfamily: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_FULLNAME)) + sa << "Full name: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_POSTSCRIPT)) + sa << "PostScript name: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_POSTSCRIPT_CID)) + sa << "PostScript CID name: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_PREF_FAMILY)) + sa << "Preferred family: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_PREF_SUBFAMILY)) + sa << "Preferred subfamily: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_MAC_COMPAT_FULLNAME)) + sa << "Mac font menu name: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_VERSION)) + sa << "Version: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_UNIQUEID)) + sa << "Unique ID: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_DESCRIPTION)) + sa << "Description: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_DESIGNER)) + sa << "Designer: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_DESIGNER_URL)) + sa << "Designer URL: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_MANUFACTURER)) + sa << "Manufacturer: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_VENDOR_URL)) + sa << "Vendor URL: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_TRADEMARK)) + sa << "Trademark: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_COPYRIGHT)) + sa << "Copyright: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_LICENSE_URL)) + sa << "License URL: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_LICENSE_DESCRIPTION)) + sa << "License Description: " << s << "\n"; + if (String s = name.english_name(OpenType::Name::N_SAMPLE_TEXT)) + sa << "Sample text: " << s << "\n"; + } } if (String os2_table = otf.table("OS/2")) { - OpenType::Os2 os2(os2_table, errh); - if (os2.ok()) { - if (String s = os2.vendor_id()) { - while (s.length() && (s.back() == ' ' || s.back() == 0)) - s = s.substring(s.begin(), s.end() - 1); - if (s) - sa << "Vendor ID: " << s << "\n"; - } - } + OpenType::Os2 os2(os2_table, errh); + if (os2.ok()) { + if (String s = os2.vendor_id()) { + while (s.length() && (s.back() == ' ' || s.back() == 0)) + s = s.substring(s.begin(), s.end() - 1); + if (s) + sa << "Vendor ID: " << s << "\n"; + } + uint16_t emb = os2.type_flags(); + sa << "Permissions: "; + if ((emb & 15) == 0) { + sa << "Installable"; + } else if ((emb & 15) == 2) { + sa << "Restricted License"; + } else if ((emb & 15) == 4) { + sa << "Preview & Print"; + } else if ((emb & 15) == 8) { + sa << "Editable"; + } else { + sa << "Unknown (" << (emb & 15) << ")"; + } + if ((emb & 0x100) != 0) { + sa << ", No subsetting"; + } + if ((emb & 0x200) != 0) { + sa << ", Bitmap only"; + } + } } if (sa || errh->nerrors() == before_nerrors) - result_errh->message("%s", (sa ? sa.c_str() : "no information")); + result_errh->message("%s", (sa ? sa.c_str() : "no information")); } static void do_query_glyphs_cff(const OpenType::Font& otf, ErrorHandler* errh, Vector<PermString>& glyph_names) { try { - // get font - Cff cff(otf.table("CFF"), otf.units_per_em(), errh); - if (!cff.ok()) - return; - - Cff::FontParent *fp = cff.font(PermString(), errh); - if (!fp || !fp->ok()) - return; - Cff::Font *font = dynamic_cast<Cff::Font *>(fp); - if (!font) { - errh->error("CID-keyed fonts not supported"); - return; - } - - // save glyph names - font->glyph_names(glyph_names); + // get font + Cff cff(otf.table("CFF"), otf.units_per_em(), errh); + if (!cff.ok()) + return; + + Cff::FontParent *fp = cff.font(PermString(), errh); + if (!fp || !fp->ok()) + return; + Cff::Font *font = dynamic_cast<Cff::Font *>(fp); + if (!font) { + errh->error("CID-keyed fonts not supported"); + return; + } + + // save glyph names + font->glyph_names(glyph_names); } catch (OpenType::Error) { } } @@ -479,13 +505,13 @@ static void do_query_glyphs_post(const OpenType::Font& otf, ErrorHandler* errh, Vector<PermString>& glyph_names) { try { - // get font + // get font OpenType::Post post(otf.table("post"), errh); - if (!post.ok()) + if (!post.ok()) return; - // save glyph names - post.glyph_names(glyph_names); + // save glyph names + post.glyph_names(glyph_names); } catch (OpenType::Error) { } } @@ -514,6 +540,7 @@ do_query_unicode(const OpenType::Font& otf, ErrorHandler* errh, ErrorHandler* re else if (otf.table("post")) do_query_glyphs_post(otf, errh, glyph_names); + int before_nerrors = errh->nerrors(); try { OpenType::Cmap cmap(otf.table("cmap"), errh); if (!cmap.ok()) @@ -525,15 +552,65 @@ do_query_unicode(const OpenType::Font& otf, ErrorHandler* errh, ErrorHandler* re for (std::pair<uint32_t, int>* it = u2g.begin(); it != u2g.end(); ++it) { char name[10]; if (it->first < 0x10000) - sprintf(name, "uni%04X", it->first); + snprintf(name, sizeof(name), "uni%04X", it->first); else - sprintf(name, "u%X", it->first); + snprintf(name, sizeof(name), "u%X", it->first); if (it->second < glyph_names.size()) result_errh->message("%s %d %s\n", name, it->second, glyph_names[it->second].c_str()); else result_errh->message("%s %d\n", name, it->second); } } catch (OpenType::Error) { + if (errh->nerrors() == before_nerrors) + errh->message("corrupted tables"); + } +} + +static void +do_query_variable(const OpenType::Font& otf, ErrorHandler* errh, ErrorHandler* result_errh) +{ + if (!otf.table("fvar")) { + result_errh->message("Not a variable font\n"); + return; + } + + int before_nerrors = errh->nerrors(); + try { + OpenType::Fvar fvar(otf.table("fvar")); + int naxes = fvar.naxes(); + if (naxes == 0) { + result_errh->message("Not a variable font\n"); + return; + } + + OpenType::Name name(otf.table("name")); + String s; + StringAccum sa; + for (int i = 0; i != naxes; ++i) { + OpenType::Axis ax = fvar.axis(i); + sa << "Axis " << i << ": " << ax.tag().text() << "\n"; + if (name.ok() && ax.nameid() && (s = name.english_name(ax.nameid()))) { + sa << "Axis " << i << " name: " << s << "\n"; + } + sa << "Axis " << i << " range: " << ax.min_value() << " " << ax.max_value() << "\n"; + sa << "Axis " << i << " default: " << ax.default_value() << "\n"; + } + + int ninstances = fvar.ninstances(); + for (int i = 0; i != ninstances; ++i) { + OpenType::FvarInstance in = fvar.instance(i); + const char* sp = i < 10 ? " " : " "; + if (name.ok() && in.nameid() && (s = name.english_name(in.nameid()))) { + sa << "Instance " << i << " name: " << sp << s << "\n"; + } + sa << "Instance " << i << " position: " << sp; + for (int j = 0; j != naxes; ++j) + sa << " " << in.coord(j); + sa << "\n"; + } + + result_errh->message("%s", sa.c_str()); + } catch (OpenType::Error) { } } @@ -542,16 +619,16 @@ do_tables(const OpenType::Font &otf, ErrorHandler *errh, ErrorHandler *result_er { int before_nerrors = errh->nerrors(); try { - int n = otf.ntables(); + int n = otf.ntables(); - for (int i = 0; i < n; i++) - if (OpenType::Tag tag = otf.table_tag(i)) { - String s = otf.table(tag); - result_errh->message("%7u %s\n", s.length(), tag.text().c_str()); - } + for (int i = 0; i < n; i++) + if (OpenType::Tag tag = otf.table_tag(i)) { + String s = otf.table(tag); + result_errh->message("%7u %s\n", s.length(), tag.text().c_str()); + } } catch (OpenType::Error) { - if (errh->nerrors() == before_nerrors) - result_errh->message("corrupted tables"); + if (errh->nerrors() == before_nerrors) + errh->message("corrupted tables"); } } @@ -560,16 +637,16 @@ do_dump_table(const OpenType::Font &otf, OpenType::Tag tag, ErrorHandler *errh) { int before_nerrors = errh->nerrors(); try { - if (otf.has_table(tag)) { - String s = otf.table(tag); - int written = fwrite(s.data(), 1, s.length(), stdout); - if (written != s.length()) - errh->error("%s", strerror(errno)); - } else - errh->message("no %<%s%> table", tag.text().c_str()); + if (otf.has_table(tag)) { + String s = otf.table(tag); + int written = fwrite(s.data(), 1, s.length(), stdout); + if (written != s.length()) + errh->error("%s", strerror(errno)); + } else + errh->message("no %<%s%> table", tag.text().c_str()); } catch (OpenType::Error) { - if (errh->nerrors() == before_nerrors) - errh->message("corrupted tables"); + if (errh->nerrors() == before_nerrors) + errh->message("corrupted tables"); } } @@ -577,7 +654,7 @@ int main(int argc, char *argv[]) { Clp_Parser *clp = - Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); + Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); program_name = Clp_ProgramName(clp); ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr, String(program_name) + ": ")); @@ -586,139 +663,142 @@ main(int argc, char *argv[]) int query = 0; while (1) { - int opt = Clp_Next(clp); - switch (opt) { - - case SCRIPT_OPT: { - if (!script.null()) - usage_error(errh, "--script already specified"); - String arg = clp->vstr; - int period = arg.find_left('.'); - OpenType::Tag scr(period <= 0 ? arg : arg.substring(0, period)); - if (scr.valid() && period > 0) { - OpenType::Tag lang(arg.substring(period + 1)); - if (lang.valid()) { - script = scr; - langsys = lang; - } else - usage_error(errh, "bad language tag"); - } else if (scr.valid()) - script = scr; - else - usage_error(errh, "bad script tag"); - break; - } - - case QUERY_SCRIPTS_OPT: - case QUERY_FEATURES_OPT: - case QUERY_OPTICAL_SIZE_OPT: - case QUERY_POSTSCRIPT_NAME_OPT: - case QUERY_GLYPHS_OPT: - case QUERY_FAMILY_OPT: - case QUERY_FVERSION_OPT: + int opt = Clp_Next(clp); + switch (opt) { + + case SCRIPT_OPT: { + if (!script.null()) + usage_error(errh, "--script already specified"); + String arg = clp->vstr; + int period = arg.find_left('.'); + OpenType::Tag scr(period <= 0 ? arg : arg.substring(0, period)); + if (scr.valid() && period > 0) { + OpenType::Tag lang(arg.substring(period + 1)); + if (lang.valid()) { + script = scr; + langsys = lang; + } else + usage_error(errh, "bad language tag"); + } else if (scr.valid()) + script = scr; + else + usage_error(errh, "bad script tag"); + break; + } + + case QUERY_SCRIPTS_OPT: + case QUERY_FEATURES_OPT: + case QUERY_OPTICAL_SIZE_OPT: + case QUERY_POSTSCRIPT_NAME_OPT: + case QUERY_GLYPHS_OPT: + case QUERY_FAMILY_OPT: + case QUERY_FVERSION_OPT: case QUERY_UNICODE_OPT: - case TABLES_OPT: - case INFO_OPT: - if (query) - usage_error(errh, "supply exactly one query type option"); - query = opt; - break; - - case DUMP_TABLE_OPT: - if (query) - usage_error(errh, "supply exactly one query type option"); - if (!(dump_table = OpenType::Tag(clp->vstr))) - usage_error(errh, "bad table name"); - query = opt; - break; - - case QUIET_OPT: - if (clp->negated) - errh = ErrorHandler::default_handler(); - else - errh = new SilentErrorHandler; - break; - - case VERBOSE_OPT: - verbose = !clp->negated; - break; - - case VERSION_OPT: - printf("otfinfo (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 2003-2019 Eddie Kohler\n\ + case QUERY_VARIABLE_OPT: + case TABLES_OPT: + case INFO_OPT: + if (query) + usage_error(errh, "supply exactly one query type option"); + query = opt; + break; + + case DUMP_TABLE_OPT: + if (query) + usage_error(errh, "supply exactly one query type option"); + if (!(dump_table = OpenType::Tag(clp->vstr))) + usage_error(errh, "bad table name"); + query = opt; + break; + + case QUIET_OPT: + if (clp->negated) + errh = ErrorHandler::default_handler(); + else + errh = new SilentErrorHandler; + break; + + case VERBOSE_OPT: + verbose = !clp->negated; + break; + + case VERSION_OPT: + printf("otfinfo (LCDF typetools) %s\n", VERSION); + printf("Copyright (C) 2003-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); - exit(0); - break; + exit(0); + break; - case HELP_OPT: - usage(); - exit(0); - break; + case HELP_OPT: + usage(); + exit(0); + break; - case Clp_NotOption: - input_files.push_back(clp->vstr); - break; + case Clp_NotOption: + input_files.push_back(clp->vstr); + break; - case Clp_Done: - goto done; + case Clp_Done: + goto done; - case Clp_BadOption: - usage_error(errh, 0); - break; + case Clp_BadOption: + usage_error(errh, 0); + break; - default: - break; + default: + break; - } + } } done: if (!query) - usage_error(errh, "supply exactly one query option"); + usage_error(errh, "supply exactly one query option"); if (!input_files.size()) - input_files.push_back("-"); + input_files.push_back("-"); if (script.null()) - script = Efont::OpenType::Tag("latn"); + script = Efont::OpenType::Tag("latn"); FileErrorHandler stdout_errh(stdout); for (const char **input_filep = input_files.begin(); input_filep != input_files.end(); input_filep++) { - int before_nerrors = errh->nerrors(); - String font_data = read_file(*input_filep, errh); - if (errh->nerrors() != before_nerrors) - continue; - - String input_file = printable_filename(*input_filep); - LandmarkErrorHandler cerrh(errh, input_file); - OpenType::Font otf(font_data, &cerrh); - if (!otf.ok()) - continue; - - PrefixErrorHandler stdout_cerrh(&stdout_errh, input_file + ":"); - ErrorHandler *result_errh = (input_files.size() > 1 ? static_cast<ErrorHandler *>(&stdout_cerrh) : static_cast<ErrorHandler *>(&stdout_errh)); - if (query == QUERY_SCRIPTS_OPT) - do_query_scripts(otf, &cerrh, result_errh); - else if (query == QUERY_FEATURES_OPT) - do_query_features(otf, &cerrh, result_errh); - else if (query == QUERY_OPTICAL_SIZE_OPT) - do_query_optical_size(otf, &cerrh, result_errh); - else if (query == QUERY_POSTSCRIPT_NAME_OPT) - do_query_postscript_name(otf, &cerrh, result_errh); - else if (query == QUERY_GLYPHS_OPT) - do_query_glyphs(otf, &cerrh, result_errh); - else if (query == QUERY_UNICODE_OPT) - do_query_unicode(otf, &cerrh, result_errh); - else if (query == QUERY_FAMILY_OPT) - do_query_family_name(otf, &cerrh, result_errh); - else if (query == QUERY_FVERSION_OPT) - do_query_font_version(otf, &cerrh, result_errh); - else if (query == TABLES_OPT) - do_tables(otf, &cerrh, result_errh); - else if (query == DUMP_TABLE_OPT) - do_dump_table(otf, dump_table, &cerrh); - else if (query == INFO_OPT) - do_info(otf, &cerrh, result_errh); + int before_nerrors = errh->nerrors(); + String font_data = read_file(*input_filep, errh); + if (errh->nerrors() != before_nerrors) + continue; + + String input_file = printable_filename(*input_filep); + LandmarkErrorHandler cerrh(errh, input_file); + OpenType::Font otf(font_data, &cerrh); + if (!otf.ok()) + continue; + + PrefixErrorHandler stdout_cerrh(&stdout_errh, input_file + ":"); + ErrorHandler *result_errh = (input_files.size() > 1 ? static_cast<ErrorHandler *>(&stdout_cerrh) : static_cast<ErrorHandler *>(&stdout_errh)); + if (query == QUERY_SCRIPTS_OPT) + do_query_scripts(otf, &cerrh, result_errh); + else if (query == QUERY_FEATURES_OPT) + do_query_features(otf, &cerrh, result_errh); + else if (query == QUERY_OPTICAL_SIZE_OPT) + do_query_optical_size(otf, &cerrh, result_errh); + else if (query == QUERY_POSTSCRIPT_NAME_OPT) + do_query_postscript_name(otf, &cerrh, result_errh); + else if (query == QUERY_GLYPHS_OPT) + do_query_glyphs(otf, &cerrh, result_errh); + else if (query == QUERY_UNICODE_OPT) + do_query_unicode(otf, &cerrh, result_errh); + else if (query == QUERY_FAMILY_OPT) + do_query_family_name(otf, &cerrh, result_errh); + else if (query == QUERY_FVERSION_OPT) + do_query_font_version(otf, &cerrh, result_errh); + else if (query == QUERY_VARIABLE_OPT) + do_query_variable(otf, &cerrh, result_errh); + else if (query == TABLES_OPT) + do_tables(otf, &cerrh, result_errh); + else if (query == DUMP_TABLE_OPT) + do_dump_table(otf, dump_table, &cerrh); + else if (query == INFO_OPT) + do_info(otf, &cerrh, result_errh); } Clp_DeleteParser(clp); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/automatic.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/automatic.cc index 0567de51e2c..87c10bb15f5 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/automatic.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/automatic.cc @@ -126,18 +126,16 @@ look_for_writable_texdir(const char *path_variable, bool create) static void find_writable_texdir(ErrorHandler *errh, const char *) { -#if defined(W32TEX) -// W32TeX does not have TEXMFVAR + // Check if TEXMFVAR is writable. + // Some distributions like W32TeX do not have TEXMFVAR defined, + // in which case we check TEXMFLOCAL. char *p = kpsei_var_value("TEXMFVAR"); - if (p == NULL) // W32TeX + if (p == NULL) look_for_writable_texdir("$TEXMFLOCAL", true); - else { // TeXLive + else { free (p); look_for_writable_texdir("$TEXMFVAR", true); } -#else - look_for_writable_texdir("$TEXMFVAR", true); -#endif if (!writable_texdir) look_for_writable_texdir("$VARTEXMF", false); if (!writable_texdir) diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.cc index 6a30b9d17fd..b9660442bfb 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.cc @@ -395,9 +395,10 @@ DvipsEncoding::parse_ligkern_words(Vector<String> &v, int override, ErrorHandler // boundary char setting if (v[0] == "||" && v[1] == "=") { char *endptr; + long boundary_char = strtol(v[2].c_str(), &endptr, 10); if (override > 0 || _boundary_char < 0) - _boundary_char = strtol(v[2].c_str(), &endptr, 10); - if (*endptr == 0 && _boundary_char < _e.size()) + _boundary_char = boundary_char; + if (*endptr == 0 && boundary_char < _e.size()) return 0; else return errh->error("parse error in boundary character assignment"); @@ -405,9 +406,10 @@ DvipsEncoding::parse_ligkern_words(Vector<String> &v, int override, ErrorHandler // altselector char setting if (v[0] == "^^" && v[1] == "=") { char *endptr; + long altselector_char = strtol(v[2].c_str(), &endptr, 10); if (override > 0 || _altselector_char < 0) - _altselector_char = strtol(v[2].c_str(), &endptr, 10); - if (*endptr == 0 && _altselector_char < _e.size()) + _altselector_char = altselector_char; + if (*endptr == 0 && altselector_char < _e.size()) return 0; else return errh->error("parse error in altselector character assignment"); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.hh index 67181b2d654..c3a2cb36d81 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/dvipsencoding.hh @@ -5,7 +5,7 @@ #include <lcdf/hashmap.hh> class Metrics; class Secondary; -class FontInfo; +struct FontInfo; class DvipsEncoding { public: diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.c b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.c index 68eecbcc56d..419e961ee74 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.c +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.c @@ -1,6 +1,6 @@ /* kpseinterface.{c,h} -- interface with the kpathsea library * - * Copyright (c) 2003-2019 Eddie Kohler + * Copyright (c) 2003-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,9 +21,7 @@ #include <kpathsea/expand.h> #include <kpathsea/c-pathch.h> #include <kpathsea/tex-file.h> -#ifdef W32TEX #include <kpathsea/variable.h> -#endif #include "kpseinterface.h" int kpsei_env_sep_char = ENV_SEP; @@ -53,34 +51,40 @@ kpsei_path_expand(const char* path) } char* +kpsei_var_value(const char *name) +{ + return kpse_var_value(name); +} + +char* kpsei_find_file(const char* name, int format) { char *result; switch (format) { case KPSEI_FMT_WEB2C: - return kpse_find_file(name, kpse_web2c_format, true); + return kpse_find_file(name, kpse_web2c_format, true); case KPSEI_FMT_ENCODING: #if HAVE_DECL_KPSE_ENC_FORMAT - if ((result = kpse_find_file(name, kpse_enc_format, true))) - return result; + if ((result = kpse_find_file(name, kpse_enc_format, true))) + return result; #endif - return kpse_find_file(name, kpse_tex_ps_header_format, true); + return kpse_find_file(name, kpse_tex_ps_header_format, true); case KPSEI_FMT_TYPE1: - return kpse_find_file(name, kpse_type1_format, false); + return kpse_find_file(name, kpse_type1_format, false); case KPSEI_FMT_TYPE42: - return kpse_find_file(name, kpse_type42_format, false); + return kpse_find_file(name, kpse_type42_format, false); case KPSEI_FMT_TRUETYPE: - return kpse_find_file(name, kpse_truetype_format, false); + return kpse_find_file(name, kpse_truetype_format, false); #if HAVE_DECL_KPSE_OPENTYPE_FORMAT case KPSEI_FMT_OPENTYPE: - return kpse_find_file(name, kpse_opentype_format, false); + return kpse_find_file(name, kpse_opentype_format, false); #endif case KPSEI_FMT_OTHER_TEXT: - return kpse_find_file(name, kpse_program_text_format, true); + return kpse_find_file(name, kpse_program_text_format, true); case KPSEI_FMT_MAP: - return kpse_find_file(name, kpse_fontmap_format, true); + return kpse_find_file(name, kpse_fontmap_format, true); default: - return 0; + return 0; } } @@ -89,11 +93,3 @@ kpsei_set_debug_flags(unsigned flags) { kpathsea_debug = flags; } - -#ifdef W32TEX -char* -kpsei_var_value(const char *name) -{ - return kpse_var_value(name); -} -#endif diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.h b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.h index 413e06e6572..1758981db7c 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.h +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.h @@ -7,16 +7,13 @@ extern "C" { void kpsei_init(const char* argv0, const char* progname); extern int kpsei_env_sep_char; char* kpsei_path_expand(const char* path); /* free() result */ +char* kpsei_var_value(const char *name); enum { KPSEI_FMT_WEB2C, KPSEI_FMT_ENCODING, KPSEI_FMT_TYPE1, KPSEI_FMT_OTHER_TEXT, KPSEI_FMT_MAP, KPSEI_FMT_TRUETYPE, KPSEI_FMT_OPENTYPE, KPSEI_FMT_TYPE42 }; char* kpsei_find_file(const char* name, int format); void kpsei_set_debug_flags(unsigned flags); -#ifdef W32TEX -char* kpsei_var_value(const char *name); -#endif - #ifdef __cplusplus } #endif diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.1 index 6ecb0a7591f..da704e7d21f 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.1 @@ -1,5 +1,5 @@ '\"t -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.cc index 913e4cb68e4..2638de66c08 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.cc @@ -16,6 +16,7 @@ #endif #ifdef WIN32 # define _USE_MATH_DEFINES +# include <io.h> #endif #include <efont/psres.hh> #include <efont/t1rw.hh> @@ -63,9 +64,6 @@ #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif -#ifdef _MSC_VER -# include <io.h> -#endif using namespace Efont; @@ -314,6 +312,7 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -567,7 +566,7 @@ String Printer::render(double value) const { return String(value); else { char buf[128]; - sprintf(buf, "%.4f", value); + snprintf(buf, sizeof(buf), "%.4f", value); return String(buf); } } @@ -2267,7 +2266,7 @@ main(int argc, char *argv[]) case VERSION_OPT: printf("otftotfm (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 2002-2019 Eddie Kohler\n\ + printf("Copyright (C) 2002-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.hh index 368a7b8135d..7e0df68ca06 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/otftotfm.hh @@ -2,7 +2,7 @@ #define OTFTOTFM_OTFTOTFM_HH #include <lcdf/string.hh> class Metrics; -class FontInfo; +struct FontInfo; class StringAccum; class ErrorHandler; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/secondary.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/secondary.cc index 64343f7db21..ad372732f6d 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/secondary.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/otftotfm/secondary.cc @@ -1,6 +1,6 @@ /* secondary.{cc,hh} -- code for generating fake glyphs * - * Copyright (c) 2003-2019 Eddie Kohler + * Copyright (c) 2003-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -238,7 +238,7 @@ double FontInfo::x_height(const Transform& font_xform) const { if (!warned) { ErrorHandler* errh = ErrorHandler::default_handler(); errh->warning("font x-height and height of %<x%> differ by %d%%", (int) (fabs(x1 - x2) * 100 / units_per_em())); - errh->message("(The height of %<x%> is usually more reliable than the x-height, so I%,m\nusing that. Or try --use-x-height or --no-use-x-height.)\n"); + errh->message("(The height of %<x%> is usually more reliable than the x-height, so I%,m\nusing that. Or try `--x-height=font` or `--x-height=x`.)\n"); warned = true; } return x1; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.1 index a839fca3492..c145995d809 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.cc index 9a70c4183a1..edbad431f4d 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1dotlessj/t1dotlessj.cc @@ -1,6 +1,6 @@ /* t1dotlessj.cc -- driver for creating dotlessj characters from Type 1 fonts * - * Copyright (c) 2003-2019 Eddie Kohler + * Copyright (c) 2003-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -43,13 +43,13 @@ enum { EXIT_NORMAL = 0, EXIT_DOTLESSJ_EXISTS = 1, EXIT_J_NODOT = 2, using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define QUIET_OPT 303 -#define PFA_OPT 304 -#define PFB_OPT 305 -#define OUTPUT_OPT 306 -#define NAME_OPT 307 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define QUIET_OPT 303 +#define PFA_OPT 304 +#define PFB_OPT 305 +#define OUTPUT_OPT 306 +#define NAME_OPT 307 const Clp_Option options[] = { { "help", 'h', HELP_OPT, 0, 0 }, @@ -71,11 +71,12 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) va_list val; va_start(val, error_message); if (!error_message) - errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name); + errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name); else - errh->xmessage(ErrorHandler::e_error, error_message, val); + errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(EXIT_ERROR); + va_end(val); } void @@ -192,17 +193,17 @@ Sectioner::undot(PermString font_name, ErrorHandler *errh) // fprintf(stderr, "%d %s\n", s - _sections.begin(), CharstringUnparser::unparse(Type1Charstring(*s)).c_str()); if (_sections.size() < 3) - errh->fatal("<%d>%s: %<j%> is already dotless", -EXIT_J_NODOT, font_name.c_str()); + errh->fatal("<%d>%s: %<j%> is already dotless", -EXIT_J_NODOT, font_name.c_str()); int topmost = -1; for (int i = 0; i < _sections.size() - 1; i++) - if (topmost < 0 || _bounds[i*4 + 1] > _bounds[topmost*4 + 1]) - topmost = i; + if (topmost < 0 || _bounds[i*4 + 1] > _bounds[topmost*4 + 1]) + topmost = i; // check if any sections are below this for (int i = 0; i < _sections.size() - 1; i++) - if (_bounds[i*4 + 1] < _bounds[topmost*4 + 1]) - goto found_below; + if (_bounds[i*4 + 1] < _bounds[topmost*4 + 1]) + goto found_below; errh->fatal("<%d>%s: %<j%> is already dotless", -EXIT_J_NODOT, font_name.c_str()); found_below: @@ -214,7 +215,7 @@ Sectioner::gen(Type1Font *font) { StringAccum sa; for (String *s = _sections.begin(); s < _sections.end(); s++) - sa << *s; + sa << *s; Type1Charstring in(sa.take_string()), out; Type1CharstringGenInterp gen(precision()); gen.set_hint_replacement_storage(font); @@ -230,36 +231,36 @@ do_file(const char *filename, PsresDatabase *psres, ErrorHandler *errh) { FILE *f; if (!filename || strcmp(filename, "-") == 0) { - f = stdin; - filename = "<stdin>"; + f = stdin; + filename = "<stdin>"; #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif } else - f = fopen(filename, "rb"); + f = fopen(filename, "rb"); if (!f) { - // check for PostScript name - Filename fn = psres->filename_value("FontOutline", filename); - f = fn.open_read(); + // check for PostScript name + Filename fn = psres->filename_value("FontOutline", filename); + f = fn.open_read(); } if (!f) - errh->fatal("<%d>%s: %s", -EXIT_ERROR, filename, strerror(errno)); + errh->fatal("<%d>%s: %s", -EXIT_ERROR, filename, strerror(errno)); Type1Reader *reader; int c = getc(f); ungetc(c, f); if (c == EOF) - errh->fatal("<%d>%s: empty file", -EXIT_ERROR, filename); + errh->fatal("<%d>%s: empty file", -EXIT_ERROR, filename); if (c == 128) - reader = new Type1PFBReader(f); + reader = new Type1PFBReader(f); else - reader = new Type1PFAReader(f); + reader = new Type1PFAReader(f); Type1Font *font = new Type1Font(*reader); if (!font->ok()) - errh->fatal("<%d>%s: no glyphs in font", -EXIT_ERROR, filename); + errh->fatal("<%d>%s: no glyphs in font", -EXIT_ERROR, filename); delete reader; return font; @@ -272,7 +273,7 @@ main(int argc, char *argv[]) psres->add_psres_path(getenv("PSRESOURCEPATH"), 0, false); Clp_Parser *clp = - Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); + Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); program_name = Clp_ProgramName(clp); ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr)); @@ -283,103 +284,103 @@ main(int argc, char *argv[]) const char *font_name = 0; while (1) { - int opt = Clp_Next(clp); - switch (opt) { - - case QUIET_OPT: - if (clp->negated) - errh = ErrorHandler::default_handler(); - else - errh = new SilentErrorHandler; - break; - - case NAME_OPT: - font_name = clp->vstr; - break; - - case PFA_OPT: - binary = false; - break; - - case PFB_OPT: - binary = true; - break; - - case OUTPUT_OPT: - output_file: - if (outputf) - usage_error(errh, "output file specified twice"); - if (strcmp(clp->vstr, "-") == 0) - outputf = stdout; - else if (!(outputf = fopen(clp->vstr, "wb"))) - errh->fatal("<%d>%s: %s", -EXIT_ERROR, clp->vstr, strerror(errno)); - break; - - case VERSION_OPT: - printf("t1dotlessj (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 2003-2019 Eddie Kohler\n\ + int opt = Clp_Next(clp); + switch (opt) { + + case QUIET_OPT: + if (clp->negated) + errh = ErrorHandler::default_handler(); + else + errh = new SilentErrorHandler; + break; + + case NAME_OPT: + font_name = clp->vstr; + break; + + case PFA_OPT: + binary = false; + break; + + case PFB_OPT: + binary = true; + break; + + case OUTPUT_OPT: + output_file: + if (outputf) + usage_error(errh, "output file specified twice"); + if (strcmp(clp->vstr, "-") == 0) + outputf = stdout; + else if (!(outputf = fopen(clp->vstr, "wb"))) + errh->fatal("<%d>%s: %s", -EXIT_ERROR, clp->vstr, strerror(errno)); + break; + + case VERSION_OPT: + printf("t1dotlessj (LCDF typetools) %s\n", VERSION); + printf("Copyright (C) 2003-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); - exit(0); - break; - - case HELP_OPT: - usage(); - exit(0); - break; - - case Clp_NotOption: - if (input_file && outputf) - usage_error(errh, "too many arguments"); - else if (input_file) - goto output_file; - else - input_file = clp->vstr; - break; - - case Clp_Done: - goto done; - - case Clp_BadOption: - usage_error(errh, 0); - break; - - default: - break; - - } + exit(0); + break; + + case HELP_OPT: + usage(); + exit(0); + break; + + case Clp_NotOption: + if (input_file && outputf) + usage_error(errh, "too many arguments"); + else if (input_file) + goto output_file; + else + input_file = clp->vstr; + break; + + case Clp_Done: + goto done; + + case Clp_BadOption: + usage_error(errh, 0); + break; + + default: + break; + + } } done: Type1Font *font = do_file(input_file, psres, errh); if (!input_file || strcmp(input_file, "-") == 0) - input_file = "<stdin>"; + input_file = "<stdin>"; // check for existing dotlessj if (font->glyph("dotlessj")) - errh->fatal("<%d>%s: already has a %<dotlessj%> glyph", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str()); + errh->fatal("<%d>%s: already has a %<dotlessj%> glyph", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str()); else if (font->glyph("uni0237")) - errh->fatal("<%d>%s: already has a dotlessj glyph at %<uni0237%>", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str()); + errh->fatal("<%d>%s: already has a dotlessj glyph at %<uni0237%>", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str()); else if (font->glyph("u0237")) - errh->fatal("<%d>%s: already has a dotlessj glyph at %<u0237%>", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str()); + errh->fatal("<%d>%s: already has a dotlessj glyph at %<u0237%>", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str()); else if (private_use_dotlessj && font->glyph(private_use_dotlessj)) - errh->fatal("<%d>%s: already has a dotlessj glyph at %<%s%>", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str(), private_use_dotlessj); + errh->fatal("<%d>%s: already has a dotlessj glyph at %<%s%>", -EXIT_DOTLESSJ_EXISTS, font->font_name().c_str(), private_use_dotlessj); // check for j Type1Charstring *j_cs = font->glyph("j"); if (!j_cs) - j_cs = font->glyph("uni006A"); + j_cs = font->glyph("uni006A"); if (!j_cs) - j_cs = font->glyph("u006A"); + j_cs = font->glyph("u006A"); if (!j_cs) - errh->fatal("<%d>%s: has no %<j%> glyph to make dotless", -EXIT_NO_J, font->font_name().c_str()); + errh->fatal("<%d>%s: has no %<j%> glyph to make dotless", -EXIT_NO_J, font->font_name().c_str()); // make new font String actual_font_name = (font_name ? String(font_name) : font->font_name() + String("LCDFJ")); if (actual_font_name.length() > 29 && !font_name) { - errh->warning("derived font name %<%s%> longer than 29 characters", actual_font_name.c_str()); - errh->message("(Use the %<--name%> option to supply your own name.)"); + errh->warning("derived font name %<%s%> longer than 29 characters", actual_font_name.c_str()); + errh->message("(Use the %<--name%> option to supply your own name.)"); } Vector<double> xuid_extension; @@ -389,10 +390,10 @@ particular purpose.\n"); // copy space and .notdef if (Type1Charstring *notdef = font->glyph(".notdef")) - dotless_font->add_glyph(Type1Subr::make_glyph(".notdef", *notdef, " |-")); + dotless_font->add_glyph(Type1Subr::make_glyph(".notdef", *notdef, " |-")); if (Type1Charstring *space = font->glyph("space")) { - dotless_font->add_glyph(Type1Subr::make_glyph("space", *space, " |-")); - dotless_font->type1_encoding()->put(' ', "space"); + dotless_font->add_glyph(Type1Subr::make_glyph("space", *space, " |-")); + dotless_font->type1_encoding()->put(' ', "space"); } // create dotless j @@ -409,16 +410,16 @@ particular purpose.\n"); // write it to output if (!outputf) - outputf = stdout; + outputf = stdout; #if defined(_MSDOS) || defined(_WIN32) _setmode(_fileno(outputf), _O_BINARY); #endif if (binary) { - Type1PFBWriter w(outputf); - dotless_font->write(w); + Type1PFBWriter w(outputf); + dotless_font->write(w); } else { - Type1PFAWriter w(outputf); - dotless_font->write(w); + Type1PFAWriter w(outputf); + dotless_font->write(w); } return (errh->nerrors() == 0 ? EXIT_NORMAL : EXIT_ERROR); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.cc index e6b4eaab848..ca4a517853a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.cc @@ -1,6 +1,6 @@ /* cscheck.{cc,hh} -- checking Type 1 charstrings for validity * - * Copyright (c) 1999-2019 Eddie Kohler + * Copyright (c) 1999-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,8 +21,8 @@ using namespace Efont; -#define CHECK_STACK_GE(numargs) do { if (size() < numargs) return error(errUnderflow, cmd); } while (0) -#define CHECK_STACK_EQ(numargs) do { CHECK_STACK_GE(numargs); if (size() > numargs) _errh->warning("too many arguments to %<%s%> (have %d, expected %d)", Charstring::command_name(cmd).c_str(), size(), numargs); } while (0) +#define CHECK_STACK_GE(numargs) do { if (size() < numargs) return error(errUnderflow, cmd); } while (0) +#define CHECK_STACK_EQ(numargs) do { CHECK_STACK_GE(numargs); if (size() > numargs) _errh->warning("too many arguments to %<%s%> (have %d, expected %d)", Charstring::command_name(cmd).c_str(), size(), numargs); } while (0) #define CHECK_STACK_CPEQ(numargs) do { CHECK_STACK_EQ(numargs); if (!_cp_exists) return error(errCurrentPoint, cmd); } while (0) @@ -46,15 +46,15 @@ CharstringChecker::stem(double y, double dy, const char *cmd_name) Vector<double> &hints = (is_v ? _h_vstem : _h_hstem); const char *dimen_name = (is_v ? "x" : "y"); if (dy < 0) { - y += dy; - dy = -dy; + y += dy; + dy = -dy; } if (dy < 0.5) - _errh->warning("small delta-%s in %<%s%> (%g)", dimen_name, cmd_name, dy); + _errh->warning("small delta-%s in %<%s%> (%g)", dimen_name, cmd_name, dy); for (int i = 0; i < hints.size(); i += 2) - if ((hints[i] >= y && hints[i+1] <= y) - || (hints[i] >= y+dy && hints[i+1] <= y+dy)) - _errh->warning("overlapping %<%s%> hints", cmd_name); + if ((hints[i] >= y && hints[i+1] <= y) + || (hints[i] >= y+dy && hints[i+1] <= y+dy)) + _errh->warning("overlapping %<%s%> hints", cmd_name); hints.push_back(y); hints.push_back(y+dy); } @@ -70,35 +70,35 @@ CharstringChecker::check_stem3(const char *cmd_name) // sort hints int i0, i1, i2; if (hints[0] > hints[2]) - i0 = 2, i1 = 0; + i0 = 2, i1 = 0; else - i0 = 0, i1 = 2; + i0 = 0, i1 = 2; if (hints[4] < hints[i0]) - i2 = i1, i1 = i0, i0 = 4; + i2 = i1, i1 = i0, i0 = 4; else if (hints[4] < hints[i1]) - i2 = i1, i1 = 4; + i2 = i1, i1 = 4; else - i2 = 4; + i2 = 4; // check constraints. count "almost equal" as equal double stemw0 = hints[i0+1] - hints[i0]; double stemw2 = hints[i2+1] - hints[i2]; if ((int)(1024*(stemw0 - stemw2) + .5) != 0) - _errh->error("bad %<%s%>: extreme stem widths unequal (%g, %g)", cmd_name, stemw0, stemw2); + _errh->error("bad %<%s%>: extreme stem widths unequal (%g, %g)", cmd_name, stemw0, stemw2); double c0 = (hints[i0] + hints[i0+1])/2; double c1 = (hints[i1] + hints[i1+1])/2; double c2 = (hints[i2] + hints[i2+1])/2; if ((int)(1024*((c1 - c0) - (c2 - c1)) + .5) != 0) - _errh->error("bad %<%s%>: stem gaps unequal (%g, %g)", cmd_name, c1-c0, c2-c1); + _errh->error("bad %<%s%>: stem gaps unequal (%g, %g)", cmd_name, c1-c0, c2-c1); // compare to old hints if (old_hints.size()) { - for (int i = 0; i < old_hints.size(); i++) - if (hints[i] != old_hints[i]) { - _errh->warning("%<%s%> conflicts with old %<%s%>", cmd_name, cmd_name); - break; - } + for (int i = 0; i < old_hints.size(); i++) + if (hints[i] != old_hints[i]) { + _errh->warning("%<%s%> conflicts with old %<%s%>", cmd_name, cmd_name); + break; + } } old_hints = hints; } @@ -240,7 +240,7 @@ CharstringChecker::callothersubr() retval = mm_command(othersubrnum, n); goto skip_pop; - default: // unknown + default: // unknown unknown: _errh->warning("unknown callothersubr %<%d%>", othersubrnum); ps_clear(); @@ -266,20 +266,20 @@ bool CharstringChecker::type1_command(int cmd) { if (_subrno < 0) - ++_ncommand; + ++_ncommand; if (cmd == Cs::cCallsubr) { - int old_subrno = _subrno; - _subrno = (size() > 1 ? (int) top(0) : -300); - bool result = callsubr_command(); - _subrno = old_subrno; - return result; + int old_subrno = _subrno; + _subrno = (size() > 1 ? (int) top(0) : -300); + bool result = callsubr_command(); + _subrno = old_subrno; + return result; } else if (cmd == Cs::cCallothersubr) { - CHECK_STACK_GE(2); - return callothersubr(); + CHECK_STACK_GE(2); + return callothersubr(); } else if (cmd == Cs::cReturn) { - return false; + return false; } else if (cmd == Cs::cPop || cmd == Cs::cDiv) { - return arith_command(cmd); + return arith_command(cmd); } if (cmd != Cs::cHsbw && cmd != Cs::cSbw) { @@ -528,11 +528,11 @@ CharstringSubrChecker::type1_command(int cmd) { switch (cmd) { case Cs::cReturn: - _returned = true; - return false; + _returned = true; + return false; default: - clear(); - return true; + clear(); + return true; } } @@ -548,6 +548,6 @@ CharstringSubrChecker::check(const CharstringContext &g, ErrorHandler *errh) CharstringInterp::interpret(g); if (!_returned) - _errh->error("subroutine does not return"); + _errh->error("subroutine does not return"); return errh->nerrors() == old_errors; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.hh index d9de5134109..b73cfcaa3f0 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/cscheck.hh @@ -11,7 +11,7 @@ template <typename T> class CharstringCheckerErrorHandler : public ErrorVeneer { public: CharstringCheckerErrorHandler(ErrorHandler *errh, T *checker) - : ErrorVeneer(errh), _checker(checker) { + : ErrorVeneer(errh), _checker(checker) { } String decorate(const String &str); @@ -34,10 +34,10 @@ class CharstringChecker : public Efont::CharstringInterp { public: bool check(const Efont::CharstringContext &, ErrorHandler *); int ncommand() const { - return _ncommand; + return _ncommand; } int subrno() const { - return _subrno; + return _subrno; } private: @@ -88,10 +88,10 @@ class CharstringSubrChecker : public Efont::CharstringInterp { public: bool check(const Efont::CharstringContext &, ErrorHandler *); int ncommand() const { - return -1; + return -1; } int subrno() const { - return -1; + return -1; } private: @@ -109,27 +109,27 @@ CharstringCheckerErrorHandler<T>::decorate(const String &str) StringAccum sa; const char *s = skip_anno(str.begin(), str.end()); while (s < str.end() && isspace((unsigned char) *s)) - ++s; + ++s; sa.append(str.begin(), s); if (_checker->subrno() >= 0) - sa << "called from "; + sa << "called from "; if (_checker->ncommand() >= 0) - sa << "command " << (_checker->ncommand() - 1) << ':'; + sa << "command " << (_checker->ncommand() - 1) << ':'; if (sa) - sa << ' '; + sa << ' '; if (s + 11 < str.end() && memcmp(s, "charstring ", 11) == 0) { - bool quote_parity = 0; - const char *last = s + 11; - for (const char *x = last; x != str.end(); ++x) - if (*x == '\'') { - sa.append(last, x); - sa << format(quote_parity ? "%>" : "%<"); - quote_parity = !quote_parity; - last = x + 1; - } - sa.append(last, str.end()); + bool quote_parity = 0; + const char *last = s + 11; + for (const char *x = last; x != str.end(); ++x) + if (*x == '\'') { + sa.append(last, x); + sa << format(quote_parity ? "%>" : "%<"); + quote_parity = !quote_parity; + last = x + 1; + } + sa.append(last, str.end()); } else - sa.append(s, str.end()); + sa.append(s, str.end()); return ErrorVeneer::decorate(sa.take_string()); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.1 index 5ab620b81a3..a21796729d9 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.cc index 1d5c6363f65..0f3ed55f3d3 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1lint/t1lint.cc @@ -1,6 +1,6 @@ /* t1lint.cc -- driver for checking Type 1 fonts for validity * - * Copyright (c) 1999-2019 Eddie Kohler + * Copyright (c) 1999-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -38,9 +38,9 @@ using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define QUIET_OPT 303 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define QUIET_OPT 303 const Clp_Option options[] = { { "help", 'h', HELP_OPT, 0, 0 }, @@ -63,6 +63,7 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -94,34 +95,34 @@ Report bugs to <ekohler@gmail.com>.\n", program_name); static bool get_num_array(Type1Font *font, int dictionary, const char *name, - Vector<double> &v, ErrorHandler *errh, bool mandatory = false) + Vector<double> &v, ErrorHandler *errh, bool mandatory = false) { if (Type1Definition *d = font->dict(dictionary, name)) { - if (d->value_numvec(v)) - return true; - errh->error("%s not an array of numbers", name); - v.clear(); + if (d->value_numvec(v)) + return true; + errh->error("%s not an array of numbers", name); + v.clear(); } else if (mandatory) - errh->error("%s not defined", name); + errh->error("%s not defined", name); return false; } static bool get_integer(Type1Font *font, int dictionary, const char *name, - int &v, ErrorHandler *errh, bool mandatory = false) + int &v, ErrorHandler *errh, bool mandatory = false) { Type1Definition *d = font->dict(dictionary, name); double scratch; if (d && d->value_int(v)) - return true; + return true; else if (d && d->value_num(scratch)) { - errh->warning("%s not an integer", name); - v = (int)scratch; - return true; + errh->warning("%s not an integer", name); + v = (int)scratch; + return true; } else if (d) - errh->error("%s not a number", name); + errh->error("%s not a number", name); else if (mandatory) - errh->error("%s not defined", name); + errh->error("%s not defined", name); return false; } @@ -129,7 +130,7 @@ get_integer(Type1Font *font, int dictionary, const char *name, static void check_blue_array(Vector<double> &blues, const char *name, double BlueScale, - ErrorHandler *errh) + ErrorHandler *errh) { if (blues.size() % 2 != 0) { errh->error("%s has an odd number of entries", name); @@ -147,27 +148,27 @@ check_blue_array(Vector<double> &blues, const char *name, double BlueScale, if (blues[i] > blues[i+1]) errh->error("%s zone %d in the wrong order", name, i/2); else if (blues[i+1] - blues[i] >= max_diff) - errh->error("%s zone %d too large in relation to BlueScale (size %g, max %g [%g])", name, i/2, blues[i+1] - blues[i], max_diff, BlueScale); + errh->error("%s zone %d too large in relation to BlueScale (size %g, max %g [%g])", name, i/2, blues[i+1] - blues[i], max_diff, BlueScale); } } static void check_blue_overlap(Vector<double> &bl1, const char *name1, - Vector<double> &bl2, const char *name2, int BlueFuzz, - ErrorHandler *errh) + Vector<double> &bl2, const char *name2, int BlueFuzz, + ErrorHandler *errh) { int min_fuzz = 2*BlueFuzz + 1; for (int i = 2; i < bl1.size(); i += 2) { int thresh = (&bl1 == &bl2 ? i : bl2.size()); for (int j = 0; j < thresh; j += 2) { if ((bl2[j] >= bl1[i] && bl2[j] <= bl1[i+1]) - || (bl2[j+1] >= bl1[i] && bl2[j+1] <= bl1[i+1])) - errh->error("%s zone %d and %s zone %d overlap", - name1, i/2, name2, j/2); + || (bl2[j+1] >= bl1[i] && bl2[j+1] <= bl1[i+1])) + errh->error("%s zone %d and %s zone %d overlap", + name1, i/2, name2, j/2); else if ((bl2[j] >= bl1[i+1] && bl2[j] < bl1[i+1]+min_fuzz) - || (bl2[j+1] <= bl1[i] && bl2[j+1]+min_fuzz > bl1[i])) - errh->error("%s zone %d and %s zone %d overlap within BlueFuzz", - name1, i/2, name2, j/2); + || (bl2[j+1] <= bl1[i] && bl2[j+1]+min_fuzz > bl1[i])) + errh->error("%s zone %d and %s zone %d overlap within BlueFuzz", + name1, i/2, name2, j/2); } } } @@ -187,7 +188,7 @@ check_blues(Type1Font *font, ErrorHandler *errh) errh->error("BlueScale less than or equal to 0"); else { if (BlueScale > 0.5) - errh->error("suspiciously large BlueScale (%g)", BlueScale); + errh->error("suspiciously large BlueScale (%g)", BlueScale); ok = true; } } @@ -249,7 +250,7 @@ check_blues(Type1Font *font, ErrorHandler *errh) void check_stem_snap(Vector<double> &stem_snap, double main, bool is_v, - ErrorHandler *errh) + ErrorHandler *errh) { const char *name = (is_v ? "V" : "H"); if (stem_snap.size() > 12) @@ -294,7 +295,7 @@ check_stems(Type1Font *font, ErrorHandler *errh) static void do_file(const char *filename, PsresDatabase *psres, ErrorHandler *errh, - ErrorHandler *err_errh) + ErrorHandler *err_errh) { FILE *f; if (strcmp(filename, "-") == 0) { @@ -333,25 +334,25 @@ do_file(const char *filename, PsresDatabase *psres, ErrorHandler *errh, // check UniqueID values int UniqueID = -1, UniqueID2 = -1; if (get_integer(font, Type1Font::dF, "UniqueID", UniqueID, errh) - && (UniqueID < 0 || UniqueID > 0xFFFFFF)) - cerrh.error("UniqueID not in the range 0-16777215"); + && (UniqueID < 0 || UniqueID > 0xFFFFFF)) + cerrh.error("UniqueID not in the range 0-16777215"); if (get_integer(font, Type1Font::dP, "UniqueID", UniqueID2, errh) - && (UniqueID2 < 0 || UniqueID2 > 0xFFFFFF)) - cerrh.error("Private UniqueID not in the range 0-16777215"); + && (UniqueID2 < 0 || UniqueID2 > 0xFFFFFF)) + cerrh.error("Private UniqueID not in the range 0-16777215"); if (UniqueID >= 0 && UniqueID2 >= 0 && UniqueID != UniqueID2) - cerrh.error("Private UniqueID does not equal font UniqueID"); + cerrh.error("Private UniqueID does not equal font UniqueID"); // check XUID values Vector<double> XUID; if (get_num_array(font, Type1Font::dF, "XUID", XUID, errh)) { - if (XUID.size() == 0) - cerrh.error("empty XUID"); - for (int i = 0; i < XUID.size(); i++) { - if (floor(XUID[i]) != XUID[i] || XUID[i] < 0 || XUID[i] > 0xFFFFFF) { - cerrh.error("element of XUID not an integer in the range 0-16777215"); - break; - } - } + if (XUID.size() == 0) + cerrh.error("empty XUID"); + for (int i = 0; i < XUID.size(); i++) { + if (floor(XUID[i]) != XUID[i] || XUID[i] < 0 || XUID[i] > 0xFFFFFF) { + cerrh.error("element of XUID not an integer in the range 0-16777215"); + break; + } + } } check_blues(font, &cerrh); @@ -360,24 +361,24 @@ do_file(const char *filename, PsresDatabase *psres, ErrorHandler *errh, MultipleMasterSpace *mmspace = font->create_mmspace(&cerrh); Vector<double> weight_vector; if (mmspace) - weight_vector = mmspace->default_weight_vector(); + weight_vector = mmspace->default_weight_vector(); int gc = font->nglyphs(); CharstringChecker cc(weight_vector); for (int i = 0; i < gc; i++) { ContextErrorHandler derrh - (&cerrh, "While interpreting %<%s%>:", font->glyph_name(i).c_str()); + (&cerrh, "While interpreting %<%s%>:", font->glyph_name(i).c_str()); cc.check(font->glyph_context(i), &derrh); } int ns = font->nsubrs(); CharstringSubrChecker csc(weight_vector); for (int i = 0; i < ns; ++i) - if (Type1Charstring *cs = font->subr(i)) { - ContextErrorHandler derrh(&cerrh, "While interpreting subr %d:", i); - CharstringContext cctx(font, cs); - csc.check(cctx, &derrh); - } + if (Type1Charstring *cs = font->subr(i)) { + ContextErrorHandler derrh(&cerrh, "While interpreting subr %d:", i); + CharstringContext cctx(font, cs); + csc.check(cctx, &derrh); + } } delete font; @@ -405,14 +406,14 @@ main(int argc, char *argv[]) case QUIET_OPT: if (clp->negated) - errh = out_errh; + errh = out_errh; else - errh = new SilentErrorHandler; + errh = new SilentErrorHandler; break; case VERSION_OPT: printf("t1lint (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 1999-2019 Eddie Kohler\n\ + printf("Copyright (C) 1999-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.1 index 9a367a31a52..f555882cea7 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.cc index eaf919d1e28..d4cc31667c5 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1rawafm/t1rawafm.cc @@ -69,6 +69,7 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -315,7 +316,7 @@ main(int argc, char *argv[]) case VERSION_OPT: printf("t1rawafm (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 2008-2019 Eddie Kohler\n\ + printf("Copyright (C) 2008-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.1 index 8ded8a4e5b7..a44060d4b2a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.cc index ff428b5ce5d..91ab828821e 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/t1reencode.cc @@ -1,6 +1,6 @@ /* t1reencode.cc -- driver for reencoding Type 1 fonts * - * Copyright (c) 2005-2019 Eddie Kohler + * Copyright (c) 2005-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -34,15 +34,15 @@ using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define OUTPUT_OPT 303 -#define ENCODING_OPT 304 -#define ENCODING_TEXT_OPT 305 -#define PFA_OPT 306 -#define PFB_OPT 307 -#define FONTNAME_OPT 308 -#define FULLNAME_OPT 309 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define OUTPUT_OPT 303 +#define ENCODING_OPT 304 +#define ENCODING_TEXT_OPT 305 +#define PFA_OPT 306 +#define PFB_OPT 307 +#define FONTNAME_OPT 308 +#define FULLNAME_OPT 309 const Clp_Option options[] = { { "help", 'h', HELP_OPT, 0, 0 }, @@ -629,11 +629,12 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) va_list val; va_start(val, error_message); if (!error_message) - errh->message("Usage: %s [OPTION]... FONT", program_name); + errh->message("Usage: %s [OPTION]... FONT", program_name); else - errh->xmessage(ErrorHandler::e_error, error_message, val); + errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -667,20 +668,20 @@ static void kill_def(Type1Font* font, Type1Definition *t1d, int whichd) { if (!t1d || font->dict(whichd, t1d->name()) != t1d) - return; + return; int icount = font->nitems(); for (int i = font->first_dict_item(whichd); i < icount; i++) - if (font->item(i) == t1d) { - StringAccum sa; - sa << '%'; - t1d->gen(sa); - PermString name = t1d->name(); - Type1CopyItem *t1ci = new Type1CopyItem(sa.take_string()); - font->set_item(i, t1ci); - font->set_dict(whichd, name, 0); - return; - } + if (font->item(i) == t1d) { + StringAccum sa; + sa << '%'; + t1d->gen(sa); + PermString name = t1d->name(); + Type1CopyItem *t1ci = new Type1CopyItem(sa.take_string()); + font->set_item(i, t1ci); + font->set_dict(whichd, name, 0); + return; + } assert(0); } @@ -691,7 +692,7 @@ adjust_font_definitions(Type1Font* font, Type1Encoding* encoding, String new_nam // prepare an MD5 digest over the encoding StringAccum etext; for (int i = 0; i < 256; i++) - etext << encoding->elt(i) << ' '; + etext << encoding->elt(i) << ' '; MD5_CONTEXT md5; md5_init(&md5); md5_update(&md5, (const unsigned char*) etext.data(), etext.length() - 1); @@ -707,66 +708,66 @@ adjust_font_definitions(Type1Font* font, Type1Encoding* encoding, String new_nam t1d = font->dict("XUID"); Vector<double> xuid; if (!t1d || !t1d->value_numvec(xuid)) { - if (have_uniqueid) { - t1d = font->ensure(Type1Font::dFont, "XUID"); - xuid.clear(); - xuid.push_back(1); - xuid.push_back(uniqueid); - } else if (t1d) { - kill_def(font, t1d, Type1Font::dFont); - t1d = 0; - } + if (have_uniqueid) { + t1d = font->ensure(Type1Font::dFont, "XUID"); + xuid.clear(); + xuid.push_back(1); + xuid.push_back(uniqueid); + } else if (t1d) { + kill_def(font, t1d, Type1Font::dFont); + t1d = 0; + } } if (t1d) { - uint8_t digest[MD5_DIGEST_SIZE + 2]; // leave 2 bytes of space - md5_final((unsigned char *) digest, &md5); - digest[MD5_DIGEST_SIZE] = digest[MD5_DIGEST_SIZE + 1] = 0; - - // append digest to XUID; each element must be less than 2^24 - for (int i = 0; i < MD5_DIGEST_SIZE; i += 3) - xuid.push_back((digest[i] << 16) | (digest[i+1] << 8) | digest[i+2]); - t1d->set_numvec(xuid); + uint8_t digest[MD5_DIGEST_SIZE + 2]; // leave 2 bytes of space + md5_final((unsigned char *) digest, &md5); + digest[MD5_DIGEST_SIZE] = digest[MD5_DIGEST_SIZE + 1] = 0; + + // append digest to XUID; each element must be less than 2^24 + for (int i = 0; i < MD5_DIGEST_SIZE; i += 3) + xuid.push_back((digest[i] << 16) | (digest[i+1] << 8) | digest[i+2]); + t1d->set_numvec(xuid); } // prepare new font name if (!encoding_name) { - char text_digest[MD5_TEXT_DIGEST_SIZE + 1]; - md5_final_text(text_digest, &md5); - encoding_name = "AutoEnc_" + String(text_digest); + char text_digest[MD5_TEXT_DIGEST_SIZE + 1]; + md5_final_text(text_digest, &md5); + encoding_name = "AutoEnc_" + String(text_digest); } t1d = font->dict("FontName"); PermString name; if (t1d && t1d->value_name(name)) { - if (!new_name) - new_name = name + encoding_name; - t1d->set_name(new_name.c_str()); - font->uncache_defs(); // remove cached font name + if (!new_name) + new_name = name + encoding_name; + t1d->set_name(new_name.c_str()); + font->uncache_defs(); // remove cached font name } // add a FullName too String full_name; t1d = font->fi_dict("FullName"); if (t1d && t1d->value_string(full_name)) { - if (!new_full_name) - new_full_name = full_name + "_" + encoding_name + " Enc"; - t1d->set_string(new_full_name.c_str()); + if (!new_full_name) + new_full_name = full_name + "_" + encoding_name + " Enc"; + t1d->set_string(new_full_name.c_str()); } // add header comments { - StringAccum sa; + StringAccum sa; #if HAVE_CTIME - time_t cur_time = time(0); - char *time_str = ctime(&cur_time); - sa << "%% Created by t1reencode-" VERSION " on " << time_str; - sa.pop_back(); + time_t cur_time = time(0); + char *time_str = ctime(&cur_time); + sa << "%% Created by t1reencode-" VERSION " on " << time_str; + sa.pop_back(); #else - sa << "%% Created by t1reencode-" VERSION "."; + sa << "%% Created by t1reencode-" VERSION "."; #endif - font->add_header_comment(sa.take_string().c_str()); - font->add_header_comment("%% T1reencode is free software. See <http://www.lcdf.org/type/>."); + font->add_header_comment(sa.take_string().c_str()); + font->add_header_comment("%% T1reencode is free software. See <http://www.lcdf.org/type/>."); } } @@ -780,51 +781,51 @@ tokenize(const String &s, int &pos_in, int &line) int len = s.length(); int pos = pos_in; while (1) { - // skip whitespace - while (pos < len && isspace((unsigned char) data[pos])) { - if (data[pos] == '\n') - line++; - else if (data[pos] == '\r' && (pos + 1 == len || data[pos+1] != '\n')) - line++; - pos++; - } - - if (pos >= len) { - pos_in = len; - return String(); - } else if (data[pos] == '%') { - for (pos++; pos < len && data[pos] != '\n' && data[pos] != '\r'; pos++) - /* nada */; - } else if (data[pos] == '[' || data[pos] == ']' || data[pos] == '{' || data[pos] == '}') { - pos_in = pos + 1; - return s.substring(pos, 1); - } else if (data[pos] == '(') { - int first = pos, nest = 0; - for (pos++; pos < len && (data[pos] != ')' || nest); pos++) - switch (data[pos]) { - case '(': nest++; break; - case ')': nest--; break; - case '\\': - if (pos + 1 < len) - pos++; - break; - case '\n': line++; break; - case '\r': - if (pos + 1 == len || data[pos+1] != '\n') - line++; - break; - } - pos_in = (pos < len ? pos + 1 : len); - return s.substring(first, pos_in - first); - } else { - int first = pos; - while (pos < len && data[pos] == '/') - pos++; - while (pos < len && data[pos] != '/' && !isspace((unsigned char) data[pos]) && data[pos] != '[' && data[pos] != ']' && data[pos] != '%' && data[pos] != '(' && data[pos] != '{' && data[pos] != '}') - pos++; - pos_in = pos; - return s.substring(first, pos - first); - } + // skip whitespace + while (pos < len && isspace((unsigned char) data[pos])) { + if (data[pos] == '\n') + line++; + else if (data[pos] == '\r' && (pos + 1 == len || data[pos+1] != '\n')) + line++; + pos++; + } + + if (pos >= len) { + pos_in = len; + return String(); + } else if (data[pos] == '%') { + for (pos++; pos < len && data[pos] != '\n' && data[pos] != '\r'; pos++) + /* nada */; + } else if (data[pos] == '[' || data[pos] == ']' || data[pos] == '{' || data[pos] == '}') { + pos_in = pos + 1; + return s.substring(pos, 1); + } else if (data[pos] == '(') { + int first = pos, nest = 0; + for (pos++; pos < len && (data[pos] != ')' || nest); pos++) + switch (data[pos]) { + case '(': nest++; break; + case ')': nest--; break; + case '\\': + if (pos + 1 < len) + pos++; + break; + case '\n': line++; break; + case '\r': + if (pos + 1 == len || data[pos+1] != '\n') + line++; + break; + } + pos_in = (pos < len ? pos + 1 : len); + return s.substring(first, pos_in - first); + } else { + int first = pos; + while (pos < len && data[pos] == '/') + pos++; + while (pos < len && data[pos] != '/' && !isspace((unsigned char) data[pos]) && data[pos] != '[' && data[pos] != ']' && data[pos] != '%' && data[pos] != '(' && data[pos] != '{' && data[pos] != '}') + pos++; + pos_in = pos; + return s.substring(first, pos - first); + } } } @@ -843,25 +844,25 @@ parse_encoding(String s, String filename, ErrorHandler *errh) // parse text String token = tokenize(s, pos, line); if (!token || token[0] != '/') { - errh->lerror(landmark(filename, line), "parse error, expected name"); - return 0; + errh->lerror(landmark(filename, line), "parse error, expected name"); + return 0; } encoding_name = token.substring(1); if (tokenize(s, pos, line) != "[") { - errh->lerror(landmark(filename, line), "parse error, expected ["); - return 0; + errh->lerror(landmark(filename, line), "parse error, expected ["); + return 0; } Type1Encoding *t1e = new Type1Encoding; int e = 0; while ((token = tokenize(s, pos, line)) && token[0] == '/') { - if (e > 255) { - errh->lwarning(landmark(filename, line), "more than 256 characters in encoding"); - break; - } - t1e->put(e, token.substring(1)); - e++; + if (e > 255) { + errh->lwarning(landmark(filename, line), "more than 256 characters in encoding"); + break; + } + t1e->put(e, token.substring(1)); + e++; } return t1e; } @@ -879,36 +880,36 @@ do_file(const char *filename, PsresDatabase *psres, ErrorHandler *errh) { FILE *f; if (!filename || strcmp(filename, "-") == 0) { - f = stdin; - filename = "<stdin>"; + f = stdin; + filename = "<stdin>"; #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif } else - f = fopen(filename, "rb"); + f = fopen(filename, "rb"); if (!f) { - // check for PostScript name - Filename fn = psres->filename_value("FontOutline", filename); - f = fn.open_read(); + // check for PostScript name + Filename fn = psres->filename_value("FontOutline", filename); + f = fn.open_read(); } if (!f) - errh->fatal("%s: %s", filename, strerror(errno)); + errh->fatal("%s: %s", filename, strerror(errno)); Type1Reader *reader; int c = getc(f); ungetc(c, f); if (c == EOF) - errh->fatal("%s: empty file", filename); + errh->fatal("%s: empty file", filename); if (c == 128) - reader = new Type1PFBReader(f); + reader = new Type1PFBReader(f); else - reader = new Type1PFAReader(f); + reader = new Type1PFAReader(f); Type1Font *font = new Type1Font(*reader); if (!font->ok()) - errh->fatal("%s: no glyphs in font", filename); + errh->fatal("%s: no glyphs in font", filename); delete reader; return font; @@ -921,7 +922,7 @@ main(int argc, char *argv[]) psres->add_psres_path(getenv("PSRESOURCEPATH"), 0, false); Clp_Parser *clp = - Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); + Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); program_name = Clp_ProgramName(clp); ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr)); @@ -935,148 +936,150 @@ main(int argc, char *argv[]) Vector<String> glyph_patterns; while (1) { - int opt = Clp_Next(clp); - switch (opt) { - - case ENCODING_OPT: - if (encoding_file || encoding_text) - errh->fatal("encoding already specified"); - encoding_file = clp->vstr; - break; - - case ENCODING_TEXT_OPT: - if (encoding_file || encoding_text) - errh->fatal("encoding already specified"); - encoding_text = clp->vstr; - break; - - case FONTNAME_OPT: - if (new_font_name) - errh->fatal("font name already specified"); - new_font_name = clp->vstr; - break; - - case FULLNAME_OPT: - if (new_full_name) - errh->fatal("full name already specified"); - new_full_name = clp->vstr; - break; - - case OUTPUT_OPT: - if (output_file) - errh->fatal("output file already specified"); - output_file = clp->vstr; - break; - - case PFA_OPT: - binary = false; - break; - - case PFB_OPT: - binary = true; - break; - - case VERSION_OPT: - printf("t1reencode (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 1999-2019 Eddie Kohler\n\ + int opt = Clp_Next(clp); + switch (opt) { + + case ENCODING_OPT: + if (encoding_file || encoding_text) + errh->fatal("encoding already specified"); + encoding_file = clp->vstr; + break; + + case ENCODING_TEXT_OPT: + if (encoding_file || encoding_text) + errh->fatal("encoding already specified"); + encoding_text = clp->vstr; + break; + + case FONTNAME_OPT: + if (new_font_name) + errh->fatal("font name already specified"); + new_font_name = clp->vstr; + break; + + case FULLNAME_OPT: + if (new_full_name) + errh->fatal("full name already specified"); + new_full_name = clp->vstr; + break; + + case OUTPUT_OPT: + if (output_file) + errh->fatal("output file already specified"); + output_file = clp->vstr; + break; + + case PFA_OPT: + binary = false; + break; + + case PFB_OPT: + binary = true; + break; + + case VERSION_OPT: + printf("t1reencode (LCDF typetools) %s\n", VERSION); + printf("Copyright (C) 1999-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); - exit(0); - break; - - case HELP_OPT: - usage(); - exit(0); - break; - - case Clp_NotOption: - if (input_file && output_file) - errh->fatal("too many arguments"); - else if (input_file) - output_file = clp->vstr; - else - input_file = clp->vstr; - break; - - case Clp_Done: - goto done; - - case Clp_BadOption: - usage_error(errh, 0); - break; - - default: - break; - - } + exit(0); + break; + + case HELP_OPT: + usage(); + exit(0); + break; + + case Clp_NotOption: + if (input_file && output_file) + errh->fatal("too many arguments"); + else if (input_file) + output_file = clp->vstr; + else + input_file = clp->vstr; + break; + + case Clp_Done: + goto done; + + case Clp_BadOption: + usage_error(errh, 0); + break; + + default: + break; + + } } done: // read the font Type1Font *font = do_file(input_file, psres, errh); if (!input_file || strcmp(input_file, "-") == 0) - input_file = "<stdin>"; + input_file = "<stdin>"; // read the encoding - if (!encoding_file && !encoding_text) - errh->fatal("missing %<-e ENCODING%> argument"); + if (encoding_text) + encoding_file = "<argument>"; + if (!encoding_file) + errh->fatal("missing %<-e ENCODING%> argument"); Type1Encoding *t1e = 0; if (strcmp(encoding_file, "StandardEncoding") == 0) { - t1e = Type1Encoding::standard_encoding(); - encoding_name = encoding_file; + t1e = Type1Encoding::standard_encoding(); + encoding_name = encoding_file; } else { - String text; - if (strcmp(encoding_file, "ISOLatin1Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_1_Encoding") == 0) - text = String::make_stable(ISOLatin1Encoding); - else if (strcmp(encoding_file, "ISOLatin2Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_2_Encoding") == 0) - text = String::make_stable(ISOLatin2Encoding); - else if (strcmp(encoding_file, "ISOLatin3Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_3_Encoding") == 0) - text = String::make_stable(ISOLatin3Encoding); - else if (strcmp(encoding_file, "ISOLatin4Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_4_Encoding") == 0) - text = String::make_stable(ISOLatin4Encoding); - else if (strcmp(encoding_file, "ISOCyrillicEncoding") == 0 - || strcmp(encoding_file, "ISO_8859_5_Encoding") == 0) - text = String::make_stable(ISOCyrillicEncoding); - else if (strcmp(encoding_file, "ISOGreekEncoding") == 0 - || strcmp(encoding_file, "ISO_8859_7_Encoding") == 0) - text = String::make_stable(ISOGreekEncoding); - else if (strcmp(encoding_file, "ISO_8859_9_Encoding") == 0 - || strcmp(encoding_file, "ISOLatin5Encoding") == 0) - text = String::make_stable(ISOLatin5Encoding); - else if (strcmp(encoding_file, "ISOLatin6Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_10_Encoding") == 0) - text = String::make_stable(ISOLatin6Encoding); - else if (strcmp(encoding_file, "ISOThaiEncoding") == 0 - || strcmp(encoding_file, "ISO_8859_11_Encoding") == 0) - text = String::make_stable(ISOThaiEncoding); - else if (strcmp(encoding_file, "ISOLatin7Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_13_Encoding") == 0) - text = String::make_stable(ISOLatin7Encoding); - else if (strcmp(encoding_file, "ISOLatin8Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_14_Encoding") == 0) - text = String::make_stable(ISOLatin8Encoding); - else if (strcmp(encoding_file, "ISOLatin9Encoding") == 0 - || strcmp(encoding_file, "ISO_8859_15_Encoding") == 0) - text = String::make_stable(ISOLatin9Encoding); - else if (strcmp(encoding_file, "KOI8REncoding") == 0) - text = String::make_stable(KOI8REncoding); - else if (strcmp(encoding_file, "ExpertEncoding") == 0) - text = String::make_stable(ExpertEncoding); - else if (strcmp(encoding_file, "ExpertSubsetEncoding") == 0) - text = String::make_stable(ExpertSubsetEncoding); - else if (strcmp(encoding_file, "SymbolEncoding") == 0) - text = String::make_stable(SymbolEncoding); - else if (encoding_text) - text = String::make_stable(encoding_text), encoding_file = "<argument>"; - else if ((text = read_file(encoding_file, errh)), errh->nerrors() > 0) - exit(1); - if (!(t1e = parse_encoding(text, encoding_file, errh))) - exit(1); + String text; + if (strcmp(encoding_file, "ISOLatin1Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_1_Encoding") == 0) + text = String::make_stable(ISOLatin1Encoding); + else if (strcmp(encoding_file, "ISOLatin2Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_2_Encoding") == 0) + text = String::make_stable(ISOLatin2Encoding); + else if (strcmp(encoding_file, "ISOLatin3Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_3_Encoding") == 0) + text = String::make_stable(ISOLatin3Encoding); + else if (strcmp(encoding_file, "ISOLatin4Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_4_Encoding") == 0) + text = String::make_stable(ISOLatin4Encoding); + else if (strcmp(encoding_file, "ISOCyrillicEncoding") == 0 + || strcmp(encoding_file, "ISO_8859_5_Encoding") == 0) + text = String::make_stable(ISOCyrillicEncoding); + else if (strcmp(encoding_file, "ISOGreekEncoding") == 0 + || strcmp(encoding_file, "ISO_8859_7_Encoding") == 0) + text = String::make_stable(ISOGreekEncoding); + else if (strcmp(encoding_file, "ISO_8859_9_Encoding") == 0 + || strcmp(encoding_file, "ISOLatin5Encoding") == 0) + text = String::make_stable(ISOLatin5Encoding); + else if (strcmp(encoding_file, "ISOLatin6Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_10_Encoding") == 0) + text = String::make_stable(ISOLatin6Encoding); + else if (strcmp(encoding_file, "ISOThaiEncoding") == 0 + || strcmp(encoding_file, "ISO_8859_11_Encoding") == 0) + text = String::make_stable(ISOThaiEncoding); + else if (strcmp(encoding_file, "ISOLatin7Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_13_Encoding") == 0) + text = String::make_stable(ISOLatin7Encoding); + else if (strcmp(encoding_file, "ISOLatin8Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_14_Encoding") == 0) + text = String::make_stable(ISOLatin8Encoding); + else if (strcmp(encoding_file, "ISOLatin9Encoding") == 0 + || strcmp(encoding_file, "ISO_8859_15_Encoding") == 0) + text = String::make_stable(ISOLatin9Encoding); + else if (strcmp(encoding_file, "KOI8REncoding") == 0) + text = String::make_stable(KOI8REncoding); + else if (strcmp(encoding_file, "ExpertEncoding") == 0) + text = String::make_stable(ExpertEncoding); + else if (strcmp(encoding_file, "ExpertSubsetEncoding") == 0) + text = String::make_stable(ExpertSubsetEncoding); + else if (strcmp(encoding_file, "SymbolEncoding") == 0) + text = String::make_stable(SymbolEncoding); + else if (encoding_text) + text = String::make_stable(encoding_text); + else if ((text = read_file(encoding_file, errh)), errh->nerrors() > 0) + exit(1); + if (!(t1e = parse_encoding(text, encoding_file, errh))) + exit(1); } // set the encoding @@ -1088,21 +1091,21 @@ particular purpose.\n"); // write it to output FILE *outf; if (!output_file || strcmp(output_file, "-") == 0) - outf = stdout; + outf = stdout; else { - outf = fopen(output_file, "w"); - if (!outf) - errh->fatal("%s: %s", output_file, strerror(errno)); + outf = fopen(output_file, binary ? "wb" : "w"); + if (!outf) + errh->fatal("%s: %s", output_file, strerror(errno)); } #if defined(_MSDOS) || defined(_WIN32) _setmode(_fileno(outf), _O_BINARY); #endif if (binary) { - Type1PFBWriter w(outf); - font->write(w); + Type1PFBWriter w(outf); + font->write(w); } else { - Type1PFAWriter w(outf); - font->write(w); + Type1PFAWriter w(outf); + font->write(w); } return (errh->nerrors() == 0 ? 0 : 1); diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/util.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/util.cc index 2e3495cf963..d77dd615ec4 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/util.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1reencode/util.cc @@ -1,6 +1,6 @@ /* util.{cc,hh} -- various bits * - * Copyright (c) 2003-2019 Eddie Kohler + * Copyright (c) 2003-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -31,30 +31,30 @@ read_file(String filename, ErrorHandler *errh, bool warning) { FILE *f; if (!filename || filename == "-") { - filename = "<stdin>"; - f = stdin; + filename = "<stdin>"; + f = stdin; #if defined(_MSDOS) || defined(_WIN32) - // Set the file mode to binary - _setmode(_fileno(f), _O_BINARY); + // Set the file mode to binary + _setmode(_fileno(f), _O_BINARY); #endif } else if (!(f = fopen(filename.c_str(), "rb"))) { - errh->xmessage((warning ? errh->e_warning : errh->e_error) + ErrorHandler::make_landmark_anno(filename), strerror(errno)); - return String(); + errh->xmessage((warning ? errh->e_warning : errh->e_error) + ErrorHandler::make_landmark_anno(filename), strerror(errno)); + return String(); } StringAccum sa; int amt; do { - if (char *x = sa.reserve(8192)) { - amt = fread(x, 1, 8192, f); - sa.adjust_length(amt); - } else - amt = 0; + if (char *x = sa.reserve(8192)) { + amt = fread(x, 1, 8192, f); + sa.adjust_length(amt); + } else + amt = 0; } while (amt != 0); if (!feof(f) || ferror(f)) - errh->xmessage((warning ? errh->e_warning : errh->e_error) + ErrorHandler::make_landmark_anno(filename), strerror(errno)); + errh->xmessage((warning ? errh->e_warning : errh->e_error) + ErrorHandler::make_landmark_anno(filename), strerror(errno)); if (f != stdin) - fclose(f); + fclose(f); return sa.take_string(); } @@ -62,9 +62,9 @@ String printable_filename(const String &s) { if (!s || s == "-") - return String::make_stable("<stdin>"); + return String::make_stable("<stdin>"); else - return s; + return s; } String @@ -72,7 +72,7 @@ pathname_filename(const String &path) { int slash = path.find_right('/'); if (slash >= 0 && slash != path.length() - 1) - return path.substring(slash + 1); + return path.substring(slash + 1); else - return path; + return path; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.1 index d46e48538eb..42e5ea2d732 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.cc index 7931b45087b..35719dfb81c 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/t1testpage/t1testpage.cc @@ -1,6 +1,6 @@ /* t1testpage.cc -- driver for generating Type 1 fonts' test pages * - * Copyright (c) 1999-2019 Eddie Kohler + * Copyright (c) 1999-2023 Eddie Kohler * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -42,11 +42,11 @@ using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define OUTPUT_OPT 303 -#define GLYPH_OPT 304 -#define SMOKE_OPT 305 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define OUTPUT_OPT 303 +#define GLYPH_OPT 304 +#define SMOKE_OPT 305 const Clp_Option options[] = { { "help", 'h', HELP_OPT, 0, 0 }, @@ -68,11 +68,12 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) va_list val; va_start(val, error_message); if (!error_message) - errh->message("Usage: %s [OPTION]... FONT", program_name); + errh->message("Usage: %s [OPTION]... FONT", program_name); else - errh->xmessage(ErrorHandler::e_error, error_message, val); + errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -106,19 +107,19 @@ namespace { class Testpager { public: Testpager(FILE *f) - : _f(f), _pageno(1) { + : _f(f), _pageno(1) { } virtual ~Testpager() { - fclose(_f); + fclose(_f); } virtual void prolog(const Vector<Type1Font *> &fonts) = 0; void newpage() { - fprintf(_f, "%%%%Page: %d %d\n", _pageno, _pageno); - ++_pageno; + fprintf(_f, "%%%%Page: %d %d\n", _pageno, _pageno); + ++_pageno; } virtual void font(Type1Font *font, const Vector<PermString>& glyph_names) = 0; virtual void epilog() { - fprintf(_f, "%%%%EOF\n"); + fprintf(_f, "%%%%EOF\n"); } protected: FILE *_f; @@ -127,7 +128,7 @@ class Testpager { public: class GridTestpager : public Testpager { public: GridTestpager(FILE *f) - : Testpager(f) { + : Testpager(f) { } void prolog(const Vector<Type1Font *> &fonts); void font(Type1Font *font, const Vector<PermString>& glyph_names); @@ -135,7 +136,7 @@ class GridTestpager : public Testpager { public: class SmokeTestpager : public Testpager { public: SmokeTestpager(FILE *f) - : Testpager(f) { + : Testpager(f) { } void prolog(const Vector<Type1Font *> &fonts); void font(Type1Font *font, const Vector<PermString>& glyph_names); @@ -151,32 +152,32 @@ do_file(const char *filename, PsresDatabase *psres, ErrorHandler *errh) { FILE *f; if (!filename || strcmp(filename, "-") == 0) { - f = stdin; - filename = "<stdin>"; + f = stdin; + filename = "<stdin>"; #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif } else - f = fopen(filename, "rb"); + f = fopen(filename, "rb"); if (!f) { - // check for PostScript name - Filename fn = psres->filename_value("FontOutline", filename); - f = fn.open_read(); + // check for PostScript name + Filename fn = psres->filename_value("FontOutline", filename); + f = fn.open_read(); } if (!f) - errh->fatal("%s: %s", filename, strerror(errno)); + errh->fatal("%s: %s", filename, strerror(errno)); Type1Reader *reader; int c = getc(f); ungetc(c, f); if (c == EOF) - errh->fatal("%s: empty file", filename); + errh->fatal("%s: empty file", filename); if (c == 128) - reader = new Type1PFBReader(f); + reader = new Type1PFBReader(f); else - reader = new Type1PFAReader(f); + reader = new Type1PFAReader(f); Type1Font *font = new Type1Font(*reader); @@ -203,8 +204,8 @@ GridTestpager::prolog(const Vector<Type1Font *> &fonts) } bind def\n"); Type1PFAWriter w(_f); for (Vector<Type1Font *>::const_iterator it = fonts.begin(); - it != fonts.end(); ++it) - (*it)->write(w); + it != fonts.end(); ++it) + (*it)->write(w); fprintf(_f, "%%%%EndProlog\n"); } @@ -213,9 +214,9 @@ GridTestpager::font(Type1Font* font, const Vector<PermString>& glyph_names) { HashMap<PermString, int> encodings(-1); if (Type1Encoding *encoding = font->type1_encoding()) - for (int i = 255; i >= 0; i--) - if (encoding->elt(i)) - encodings.insert(encoding->elt(i), i); + for (int i = 255; i >= 0; i--) + if (encoding->elt(i)) + encodings.insert(encoding->elt(i), i); int per_row = 10; int nrows = 13; @@ -223,59 +224,59 @@ GridTestpager::font(Type1Font* font, const Vector<PermString>& glyph_names) int page = 0, gi = -1; for (Vector<PermString>::const_iterator it = glyph_names.begin(); - it != glyph_names.end(); ++it) { - // allow font that doesn't have all glyphs - if (!font->glyph(*it)) - continue; - - ++gi; - if (gi % per_page == 0) { - if (page) - fprintf(_f, "showpage restore\n"); - ++page; - newpage(); - fprintf(_f, "save\n"); - // make new font - fprintf(_f, "/%s findfont dup length dict begin\n\ + it != glyph_names.end(); ++it) { + // allow font that doesn't have all glyphs + if (!font->glyph(*it)) + continue; + + ++gi; + if (gi % per_page == 0) { + if (page) + fprintf(_f, "showpage restore\n"); + ++page; + newpage(); + fprintf(_f, "save\n"); + // make new font + fprintf(_f, "/%s findfont dup length dict begin\n\ { 1 index /FID ne {def} {pop pop} ifelse } forall\n /Encoding [", - font->font_name().c_str()); - int gx = 0; - for (Vector<PermString>::const_iterator xit = it; - xit != glyph_names.end() && gx < per_page; ++xit) - if (font->glyph(*xit)) { - ++gx; - fprintf(_f, " /%s", xit->c_str()); - if (gx % 10 == 9) - fprintf(_f, "\n"); - } - fprintf(_f, " ] def\n currentdict end /X exch definefont pop\n\ + font->font_name().c_str()); + int gx = 0; + for (Vector<PermString>::const_iterator xit = it; + xit != glyph_names.end() && gx < per_page; ++xit) + if (font->glyph(*xit)) { + ++gx; + fprintf(_f, " /%s", xit->c_str()); + if (gx % 10 == 9) + fprintf(_f, "\n"); + } + fprintf(_f, " ] def\n currentdict end /X exch definefont pop\n\ /Helvetica-Bold 16 selectfont 36 742 moveto (%s) show\n\ /X 24 selectfont\n", font->font_name().c_str()); - } - - int row = (gi % per_page) / per_row; - int col = gi % per_row; - - fprintf(_f, "%d %d %d (%s)", row, col, gi % per_page, it->c_str()); - if (encodings[*it] >= 0) { - int e = encodings[*it]; - if (e == '\\') - fprintf(_f, " ('\\\\\\\\')"); - else if (e == '\'') - fprintf(_f, " ('\\\\'')"); - else if (e == '(' || e == ')') - fprintf(_f, " ('\\%c')", e); - else if (e >= 32 && e < 127) - fprintf(_f, " ('%c')", e); - else - fprintf(_f, " ('\\\\%03o')", e); - } else - fprintf(_f, " ()"); - fprintf(_f, " magicbox\n"); + } + + int row = (gi % per_page) / per_row; + int col = gi % per_row; + + fprintf(_f, "%d %d %d (%s)", row, col, gi % per_page, it->c_str()); + if (encodings[*it] >= 0) { + int e = encodings[*it]; + if (e == '\\') + fprintf(_f, " ('\\\\\\\\')"); + else if (e == '\'') + fprintf(_f, " ('\\\\'')"); + else if (e == '(' || e == ')') + fprintf(_f, " ('\\%c')", e); + else if (e >= 32 && e < 127) + fprintf(_f, " ('%c')", e); + else + fprintf(_f, " ('\\\\%03o')", e); + } else + fprintf(_f, " ()"); + fprintf(_f, " magicbox\n"); } if (page) - fprintf(_f, "showpage restore\n"); + fprintf(_f, "showpage restore\n"); } @@ -298,8 +299,8 @@ class Smoker : public CharstringInterp { public: void act_curve(int, const Point &, const Point &, const Point &, const Point &); void act_closepath(int); - String char_postscript() { return _char_sa.take_string(); } - String points_postscript() { return _points_sa.take_string(); } + String char_postscript() { return _char_sa.take_string(); } + String points_postscript() { return _points_sa.take_string(); } bool run(const CharstringContext&); @@ -323,8 +324,8 @@ void Smoker::maybe_move(const Point& p) { if (_char_cp.x < -100000 || _char_cp != p) { - _char_sa << (p * _xform) << " moveto\n"; - _points_sa << (p * _xform) << " pA\n"; + _char_sa << (p * _xform) << " moveto\n"; + _points_sa << (p * _xform) << " pA\n"; } } @@ -336,9 +337,9 @@ Smoker::act_line(int cmd, const Point& p0, const Point& p1) maybe_move(p0); _char_sa << xp1 << " lineto\n"; if (cmd == Charstring::cRlineto - || cmd == Charstring::cHlineto - || cmd == Charstring::cVlineto) - _points_sa << xp1 << " pA\n"; + || cmd == Charstring::cHlineto + || cmd == Charstring::cVlineto) + _points_sa << xp1 << " pA\n"; _char_cp = p1; } @@ -379,8 +380,8 @@ static Transform bounds2xform(CharstringBounds& bounds, bool expand = false) { if (expand) { - Point vec = bounds.bb_top_right() - bounds.bb_bottom_left(); - bounds.act_line(0, bounds.bb_bottom_left() - 0.1 * vec, bounds.bb_top_right() + 0.1 * vec); + Point vec = bounds.bb_top_right() - bounds.bb_bottom_left(); + bounds.act_line(0, bounds.bb_bottom_left() - 0.1 * vec, bounds.bb_top_right() + 0.1 * vec); } bounds.act_line(0, Point(0, 0), bounds.width()); bounds.act_line(0, Point(0, 0), Point(1, 1)); @@ -392,10 +393,10 @@ bounds2xform(CharstringBounds& bounds, bool expand = false) double scale = std::min(x_scale, y_scale); double origin_x = LEFT_BOUND; if (bounds.bb_left() < 0) - origin_x += -bounds.bb_left() * scale; + origin_x += -bounds.bb_left() * scale; double origin_y = BOTTOM_BOUND; if (bounds.bb_bottom() < 0) - origin_y += -bounds.bb_bottom() * scale; + origin_y += -bounds.bb_bottom() * scale; return Transform(scale, 0, 0, scale, origin_x, origin_y); } @@ -425,51 +426,51 @@ SmokeTestpager::font(Type1Font* font, const Vector<PermString>& glyph_names) { HashMap<PermString, int> encodings(-1); if (Type1Encoding *encoding = font->type1_encoding()) - for (int i = 255; i >= 0; i--) - encodings.insert(encoding->elt(i), i); + for (int i = 255; i >= 0; i--) + encodings.insert(encoding->elt(i), i); // First, calculate font bounds, and from there, the transform. CharstringBounds bounds; for (const char* const* bg = bounds_glyphs; *bg; bg++) - if (CharstringContext cc = font->glyph_context(*bg)) - bounds.char_bounds(cc, false); + if (CharstringContext cc = font->glyph_context(*bg)) + bounds.char_bounds(cc, false); if (bounds.bb_left() == bounds.bb_right()) - for (int gi = 0; gi < glyph_names.size(); gi++) - bounds.char_bounds(font->glyph_context(glyph_names[gi]), false); + for (int gi = 0; gi < glyph_names.size(); gi++) + bounds.char_bounds(font->glyph_context(glyph_names[gi]), false); Transform font_xform = bounds2xform(bounds, true); for (int gi = 0; gi < glyph_names.size(); gi++) { - // allow font that doesn't have all glyphs - if (!font->glyph(glyph_names[gi])) - continue; - - newpage(); - fprintf(_f, "save\n"); - - CharstringContext cc = font->glyph_context(glyph_names[gi]); - bounds.clear(); - bounds.char_bounds(cc, false); - - Transform xform(font_xform); - if (bounds.bb_known()) { - Point lb = bounds.bb_bottom_left() * xform; - Point rt = bounds.bb_top_right() * xform; - Point wd = bounds.width() * xform; - if (lb.x < LEFT_BOUND || lb.y < BOTTOM_BOUND - || rt.x > RIGHT_BOUND || rt.y > TOP_BOUND - || wd.x < LEFT_BOUND || wd.x > RIGHT_BOUND - || wd.y < BOTTOM_BOUND || wd.y > TOP_BOUND) - xform = bounds2xform(bounds); - } - - Smoker smoker(xform); - smoker.run(font->glyph_context(glyph_names[gi])); - fprintf(_f, "%g %g moveto 0 %g rlineto %g %g moveto 0 %g rlineto %g %g moveto %g 0 rlineto 0 setgray stroke\n", - (Point(0, 0) * xform).x, BOTTOM_BOUND - 36, TOP_BOUND - BOTTOM_BOUND + 72, - (bounds.width() * xform).x, BOTTOM_BOUND - 36, TOP_BOUND - BOTTOM_BOUND + 72, - LEFT_BOUND - 36, (Point(0, 0) * xform).y, RIGHT_BOUND - LEFT_BOUND + 72); - - fprintf(_f, "%s\n0.5 setgray fill\n\n1 setlinewidth\n%s\nshowpage\nrestore\n", smoker.char_postscript().c_str(), smoker.points_postscript().c_str()); + // allow font that doesn't have all glyphs + if (!font->glyph(glyph_names[gi])) + continue; + + newpage(); + fprintf(_f, "save\n"); + + CharstringContext cc = font->glyph_context(glyph_names[gi]); + bounds.clear(); + bounds.char_bounds(cc, false); + + Transform xform(font_xform); + if (bounds.bb_known()) { + Point lb = bounds.bb_bottom_left() * xform; + Point rt = bounds.bb_top_right() * xform; + Point wd = bounds.width() * xform; + if (lb.x < LEFT_BOUND || lb.y < BOTTOM_BOUND + || rt.x > RIGHT_BOUND || rt.y > TOP_BOUND + || wd.x < LEFT_BOUND || wd.x > RIGHT_BOUND + || wd.y < BOTTOM_BOUND || wd.y > TOP_BOUND) + xform = bounds2xform(bounds); + } + + Smoker smoker(xform); + smoker.run(font->glyph_context(glyph_names[gi])); + fprintf(_f, "%g %g moveto 0 %g rlineto %g %g moveto 0 %g rlineto %g %g moveto %g 0 rlineto 0 setgray stroke\n", + (Point(0, 0) * xform).x, BOTTOM_BOUND - 36, TOP_BOUND - BOTTOM_BOUND + 72, + (bounds.width() * xform).x, BOTTOM_BOUND - 36, TOP_BOUND - BOTTOM_BOUND + 72, + LEFT_BOUND - 36, (Point(0, 0) * xform).y, RIGHT_BOUND - LEFT_BOUND + 72); + + fprintf(_f, "%s\n0.5 setgray fill\n\n1 setlinewidth\n%s\nshowpage\nrestore\n", smoker.char_postscript().c_str(), smoker.points_postscript().c_str()); } } @@ -485,50 +486,50 @@ click_strcmp(PermString a, PermString b) const char *bd = b.c_str(), *be = b.c_str() + b.length(); while (ad < ae && bd < be) { - if (isdigit((unsigned char) *ad) && isdigit((unsigned char) *bd)) { - // compare the two numbers, but don't treat them as numbers in - // case of overflow - // first, skip initial '0's - const char *iad = ad, *ibd = bd; - while (ad < ae && *ad == '0') - ad++; - while (bd < be && *bd == '0') - bd++; - int longer_zeros = (ad - iad) - (bd - ibd); - // skip to end of number - const char *nad = ad, *nbd = bd; - while (ad < ae && isdigit((unsigned char) *ad)) - ad++; - while (bd < be && isdigit((unsigned char) *bd)) - bd++; - // longer number must be larger - if ((ad - nad) != (bd - nbd)) - return (ad - nad) - (bd - nbd); - // otherwise, compare numbers with the same length - for (; nad < ad && nbd < bd; nad++, nbd++) - if (*nad != *nbd) - return *nad - *nbd; - // finally, longer string of initial '0's wins - if (longer_zeros != 0) - return longer_zeros; - } else if (isdigit((unsigned char) *ad)) - return (isalpha((unsigned char) *bd) ? -1 : 1); - else if (isdigit((unsigned char) *bd)) - return (isalpha((unsigned char) *ad) ? 1 : -1); - else { - int d = tolower((unsigned char) *ad) - tolower((unsigned char) *bd); - if (d != 0) - return d; - ad++; - bd++; - } + if (isdigit((unsigned char) *ad) && isdigit((unsigned char) *bd)) { + // compare the two numbers, but don't treat them as numbers in + // case of overflow + // first, skip initial '0's + const char *iad = ad, *ibd = bd; + while (ad < ae && *ad == '0') + ad++; + while (bd < be && *bd == '0') + bd++; + int longer_zeros = (ad - iad) - (bd - ibd); + // skip to end of number + const char *nad = ad, *nbd = bd; + while (ad < ae && isdigit((unsigned char) *ad)) + ad++; + while (bd < be && isdigit((unsigned char) *bd)) + bd++; + // longer number must be larger + if ((ad - nad) != (bd - nbd)) + return (ad - nad) - (bd - nbd); + // otherwise, compare numbers with the same length + for (; nad < ad && nbd < bd; nad++, nbd++) + if (*nad != *nbd) + return *nad - *nbd; + // finally, longer string of initial '0's wins + if (longer_zeros != 0) + return longer_zeros; + } else if (isdigit((unsigned char) *ad)) + return (isalpha((unsigned char) *bd) ? -1 : 1); + else if (isdigit((unsigned char) *bd)) + return (isalpha((unsigned char) *ad) ? 1 : -1); + else { + int d = tolower((unsigned char) *ad) - tolower((unsigned char) *bd); + if (d != 0) + return d; + ad++; + bd++; + } } if ((ae - ad) != (be - bd)) - return (ae - ad) - (be - bd); + return (ae - ad) - (be - bd); else { - assert(a.length() == b.length()); - return memcmp(a.c_str(), b.c_str(), a.length()); + assert(a.length() == b.length()); + return memcmp(a.c_str(), b.c_str(), a.length()); } } @@ -543,27 +544,27 @@ glyphcompare(const void *lv, const void *rv) const char* ldot = strchr(ln->c_str(), '.'); const char* rdot = strchr(rn->c_str(), '.'); if (ldot == ln->begin()) - ldot = 0; + ldot = 0; if (rdot == rn->begin()) - rdot = 0; + rdot = 0; if (ldot || rdot) { - PermString l(ln->begin(), ldot ? ldot : ln->end()); - PermString r(rn->begin(), rdot ? rdot : rn->end()); - int diff = glyphcompare(&l, &r); - if (diff != 0) - return diff; + PermString l(ln->begin(), ldot ? ldot : ln->end()); + PermString r(rn->begin(), rdot ? rdot : rn->end()); + int diff = glyphcompare(&l, &r); + if (diff != 0) + return diff; } int lorder = glyph_order[*ln]; int rorder = glyph_order[*rn]; if (lorder >= 0 && rorder >= 0) - return lorder - rorder; + return lorder - rorder; else if (lorder >= 0) - return -1; + return -1; else if (rorder >= 0) - return 1; + return 1; else - return click_strcmp(*ln, *rn); + return click_strcmp(*ln, *rn); } } @@ -571,10 +572,10 @@ static bool glyph_matches(const String& glyph_name, const String* pattern_begin, const String* pattern_end) { if (pattern_begin >= pattern_end) - return true; + return true; for (; pattern_begin < pattern_end; pattern_begin++) - if (glob_match(glyph_name, *pattern_begin)) - return true; + if (glob_match(glyph_name, *pattern_begin)) + return true; return false; } @@ -585,7 +586,7 @@ main(int argc, char *argv[]) psres->add_psres_path(getenv("PSRESOURCEPATH"), 0, false); Clp_Parser *clp = - Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); + Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); program_name = Clp_ProgramName(clp); ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr)); @@ -595,75 +596,75 @@ main(int argc, char *argv[]) Vector<Type1Font *> fonts; while (1) { - int opt = Clp_Next(clp); - switch (opt) { - - case GLYPH_OPT: { - const char* s = clp->vstr, *end = s + strlen(s); - while (s < end) { - while (s < end && isspace((unsigned char) *s)) - s++; - const char* word = s; - while (s < end && !isspace((unsigned char) *s)) - s++; - if (word < s) - glyph_patterns.push_back(String(word, s - word)); - } - break; - } - - case SMOKE_OPT: - smoke = !clp->negated; - break; - - case OUTPUT_OPT: - if (output_file) - errh->fatal("output file already specified"); - output_file = clp->vstr; - break; - - case VERSION_OPT: - printf("t1testpage (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 1999-2019 Eddie Kohler\n\ + int opt = Clp_Next(clp); + switch (opt) { + + case GLYPH_OPT: { + const char* s = clp->vstr, *end = s + strlen(s); + while (s < end) { + while (s < end && isspace((unsigned char) *s)) + s++; + const char* word = s; + while (s < end && !isspace((unsigned char) *s)) + s++; + if (word < s) + glyph_patterns.push_back(String(word, s - word)); + } + break; + } + + case SMOKE_OPT: + smoke = !clp->negated; + break; + + case OUTPUT_OPT: + if (output_file) + errh->fatal("output file already specified"); + output_file = clp->vstr; + break; + + case VERSION_OPT: + printf("t1testpage (LCDF typetools) %s\n", VERSION); + printf("Copyright (C) 1999-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); - exit(0); - break; + exit(0); + break; - case HELP_OPT: - usage(); - exit(0); - break; + case HELP_OPT: + usage(); + exit(0); + break; - case Clp_NotOption: - fonts.push_back(do_file(clp->vstr, psres, errh)); - break; + case Clp_NotOption: + fonts.push_back(do_file(clp->vstr, psres, errh)); + break; - case Clp_Done: - goto done; + case Clp_Done: + goto done; - case Clp_BadOption: - usage_error(errh, 0); - break; + case Clp_BadOption: + usage_error(errh, 0); + break; - default: - break; + default: + break; - } + } } done: if (!fonts.size()) - fonts.push_back(do_file(0, psres, errh)); + fonts.push_back(do_file(0, psres, errh)); FILE *outf; if (!output_file || strcmp(output_file, "-") == 0) - outf = stdout; + outf = stdout; else { - outf = fopen(output_file, "w"); - if (!outf) - errh->fatal("%s: %s", output_file, strerror(errno)); + outf = fopen(output_file, "w"); + if (!outf) + errh->fatal("%s: %s", output_file, strerror(errno)); } #if defined(_MSDOS) || defined(_WIN32) _setmode(_fileno(outf), _O_BINARY); @@ -675,10 +676,10 @@ particular purpose.\n"); int gindex = 0; char buf[7] = "Asmall"; for (int c = 0; c < 26; c++) { - buf[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[c]; - glyph_order.insert(PermString(buf[0]), gindex++); - glyph_order.insert(PermString("abcdefghijklmnopqrstuvwxyz"[c]), gindex++); - glyph_order.insert(PermString(buf), gindex++); + buf[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[c]; + glyph_order.insert(PermString(buf[0]), gindex++); + glyph_order.insert(PermString("abcdefghijklmnopqrstuvwxyz"[c]), gindex++); + glyph_order.insert(PermString(buf), gindex++); } glyph_order.insert("parenleft", gindex++); glyph_order.insert("period", gindex++); @@ -715,32 +716,32 @@ particular purpose.\n"); // Get glyph names. HashMap<PermString, int> glyph_hash(0); for (Vector<Type1Font *>::iterator it = fonts.begin(); it != fonts.end(); - ++it) - for (int i = 0; i < (*it)->nglyphs(); i++) { - if (glyph_matches((*it)->glyph_name(i), - glyph_patterns.begin(), glyph_patterns.end())) - glyph_hash.insert((*it)->glyph_name(i), 1); - } + ++it) + for (int i = 0; i < (*it)->nglyphs(); i++) { + if (glyph_matches((*it)->glyph_name(i), + glyph_patterns.begin(), glyph_patterns.end())) + glyph_hash.insert((*it)->glyph_name(i), 1); + } Vector<PermString> glyph_names; for (HashMap<PermString, int>::iterator it = glyph_hash.begin(); - it != glyph_hash.end(); ++it) - glyph_names.push_back(it.key()); + it != glyph_hash.end(); ++it) + glyph_names.push_back(it.key()); if (glyph_names.size() == 0) - errh->fatal("no glyphs to print"); + errh->fatal("no glyphs to print"); qsort(glyph_names.begin(), glyph_names.size(), sizeof(PermString), glyphcompare); // outputs Testpager *tp; if (smoke) - tp = new SmokeTestpager(outf); + tp = new SmokeTestpager(outf); else - tp = new GridTestpager(outf); + tp = new GridTestpager(outf); tp->prolog(fonts); for (Vector<Type1Font *>::iterator it = fonts.begin(); it != fonts.end(); - ++it) - tp->font(*it, glyph_names); + ++it) + tp->font(*it, glyph_names); tp->epilog(); delete tp; diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.1 b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.1 index a212bd1a79c..1427ee9bd12 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.1 +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.1 @@ -1,4 +1,4 @@ -.ds V 2.108 +.ds V 2.110 .de M .BR "\\$1" "(\\$2)\\$3" .. diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.cc index d1e88706cd1..d0b84e48cb8 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/ttftotype42/ttftotype42.cc @@ -43,10 +43,10 @@ using namespace Efont; -#define VERSION_OPT 301 -#define HELP_OPT 302 -#define QUIET_OPT 303 -#define OUTPUT_OPT 306 +#define VERSION_OPT 301 +#define HELP_OPT 302 +#define QUIET_OPT 303 +#define OUTPUT_OPT 306 const Clp_Option options[] = { { "help", 'h', HELP_OPT, 0, 0 }, @@ -65,11 +65,12 @@ usage_error(ErrorHandler *errh, const char *error_message, ...) va_list val; va_start(val, error_message); if (!error_message) - errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name); + errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name); else - errh->xmessage(ErrorHandler::e_error, error_message, val); + errh->xmessage(ErrorHandler::e_error, error_message, val); errh->message("Type %s --help for more information.", program_name); exit(1); + va_end(val); } void @@ -120,44 +121,43 @@ static const NameId fontinfo_names[] = { static void fprint_sfnts(FILE *f, const String &data, bool glyf, const OpenType::Font &font) { - if (glyf && data.length() >= 65535) { - OpenType::Data head = font.table("head"); - OpenType::Data loca = font.table("loca"); - bool loca_long = (head.length() >= 52 && head.u16(50) != 0); - int loca_size = (loca_long ? 4 : 2); - uint32_t first_offset = 0; - for (int i = 1; i * loca_size < loca.length(); i++) { - uint32_t next_offset = (loca_long ? loca.u32(4*i) : loca.u16(2*i) * 2); - if (next_offset - first_offset >= 65535) { - uint32_t prev_offset = (loca_long ? loca.u32(4*i - 4) : loca.u16(2*i - 2) * 2); - fprint_sfnts(f, data.substring(first_offset, prev_offset - first_offset), false, font); - first_offset = prev_offset; - } - } - fprint_sfnts(f, data.substring(first_offset), false, font); - return; + OpenType::Data head = font.table("head"); + bool loca_long = (head.length() >= 52 && head.u16(50) != 0); + // Do not split fonts with long offsets -- Werner Lemberg + if (glyf && data.length() >= 65535 && !loca_long) { + OpenType::Data loca = font.table("loca"); + int loca_size = (loca_long ? 4 : 2); + uint32_t first_offset = 0; + for (int i = 1; i * loca_size < loca.length(); i++) { + uint32_t next_offset = (loca_long ? loca.u32(4*i) : loca.u16(2*i) * 2); + if (next_offset - first_offset >= 65535) { + uint32_t prev_offset = (loca_long ? loca.u32(4*i - 4) : loca.u16(2*i - 2) * 2); + fprint_sfnts(f, data.substring(first_offset, prev_offset - first_offset), false, font); + first_offset = prev_offset; + } + } + fprint_sfnts(f, data.substring(first_offset), false, font); } else if (data.length() >= 65535) { - for (int offset = 0; offset < data.length(); ) { - int next_offset = offset + 65534; - if (next_offset > data.length()) - next_offset = data.length(); - fprint_sfnts(f, data.substring(offset, next_offset - offset), false, font); - offset = next_offset; - } - return; + for (int offset = 0; offset < data.length(); ) { + int next_offset = offset + 65534; + if (next_offset > data.length()) + next_offset = data.length(); + fprint_sfnts(f, data.substring(offset, next_offset - offset), false, font); + offset = next_offset; + } + } else { + fputc('<', f); + const uint8_t *s = data.udata(); + for (int i = 0; i < data.length(); i++) { + if (i && (i % 38) == 0) + fputc('\n', f); + fputc("0123456789ABCDEF"[(s[i] >> 4) & 0xF], f); + fputc("0123456789ABCDEF"[s[i] & 0xF], f); + } + if ((data.length() % 38) == 0) + fputc('\n', f); + fputs("00>\n", f); } - - fputc('<', f); - const uint8_t *s = data.udata(); - for (int i = 0; i < data.length(); i++) { - if (i && (i % 38) == 0) - fputc('\n', f); - fputc("0123456789ABCDEF"[(s[i] >> 4) & 0xF], f); - fputc("0123456789ABCDEF"[s[i] & 0xF], f); - } - if ((data.length() % 38) == 0) - fputc('\n', f); - fputs("00>\n", f); } static void @@ -165,65 +165,65 @@ do_file(const char *infn, const char *outfn, ErrorHandler *errh) { FILE *f; if (!infn || strcmp(infn, "-") == 0) { - f = stdin; - infn = "<stdin>"; + f = stdin; + infn = "<stdin>"; #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif } else if (!(f = fopen(infn, "rb"))) - errh->fatal("%s: %s", infn, strerror(errno)); + errh->fatal("%s: %s", infn, strerror(errno)); int c = getc(f); ungetc(c, f); if (c == EOF) - errh->fatal("%s: empty file", infn); + errh->fatal("%s: empty file", infn); StringAccum sa(150000); int amt; do { - if (char *x = sa.reserve(32768)) { - amt = fread(x, 1, 32768, f); - sa.adjust_length(amt); - } else - amt = 0; + if (char *x = sa.reserve(32768)) { + amt = fread(x, 1, 32768, f); + sa.adjust_length(amt); + } else + amt = 0; } while (amt != 0); if (!feof(f) || ferror(f)) - errh->error("%s: %s", infn, strerror(errno)); + errh->error("%s: %s", infn, strerror(errno)); if (f != stdin) - fclose(f); + fclose(f); LandmarkErrorHandler cerrh(errh, infn); OpenType::Font otf(sa.take_string(), &cerrh); if (!otf.ok() || !otf.check_checksums(&cerrh)) - return; + return; if (otf.table("CFF")) - cerrh.fatal("CFF-flavored OpenType font not suitable for Type 42"); + cerrh.fatal("CFF-flavored OpenType font not suitable for Type 42"); OpenType::Name name(otf.table("name"), &cerrh); OpenType::Data head_data = otf.table("head"); if (!otf.table("glyf") || head_data.length() <= 52 || !name.ok()) - cerrh.fatal("font appears to lack required tables"); + cerrh.fatal("font appears to lack required tables"); // create reduced font Vector<OpenType::Tag> tags; Vector<String> tables; for (const char * const *table = t42_tables; *table; table++) - if (String s = otf.table(*table)) { - tags.push_back(*table); - tables.push_back(s); - } + if (String s = otf.table(*table)) { + tags.push_back(*table); + tables.push_back(s); + } OpenType::Font reduced_font = OpenType::Font::make(true, tags, tables); // output file if (!outfn || strcmp(outfn, "-") == 0) { - f = stdout; - outfn = "<stdout>"; + f = stdout; + outfn = "<stdout>"; #if defined(_MSDOS) || defined(_WIN32) - _setmode(_fileno(f), _O_BINARY); + _setmode(_fileno(f), _O_BINARY); #endif } else if (!(f = fopen(outfn, "wb"))) - errh->fatal("%s: %s", outfn, strerror(errno)); + errh->fatal("%s: %s", outfn, strerror(errno)); // fprintf(f, "%%!\n"); @@ -238,59 +238,59 @@ do_file(const char *infn, const char *outfn, ErrorHandler *errh) // font opener fprintf(f, "%%!PS-TrueTypeFont-65536-%u-1\n", head_data.u32(4)); if (post.ok()) - fprintf(f, "%%%%VMusage: %u %u\n", post.mem_type42(false), post.mem_type42(true)); + fprintf(f, "%%%%VMusage: %u %u\n", post.mem_type42(false), post.mem_type42(true)); fprintf(f, "11 dict begin\n"); fprintf(f, "/FontName /%s def\n", name.english_name(OpenType::Name::N_POSTSCRIPT).c_str()); fprintf(f, "/FontType 42 def\n"); fprintf(f, "/FontMatrix [1 0 0 1 0 0] def\n"); fprintf(f, "/FontBBox [%g %g %g %g] readonly def\n", - /* head_data.s16(36), head_data.s16(38), - head_data.s16(40), head_data.s16(42)); */ - head_data.s16(36) / emunits, head_data.s16(38) / emunits, - head_data.s16(40) / emunits, head_data.s16(42) / emunits); + /* head_data.s16(36), head_data.s16(38), + head_data.s16(40), head_data.s16(42)); */ + head_data.s16(36) / emunits, head_data.s16(38) / emunits, + head_data.s16(40) / emunits, head_data.s16(42) / emunits); fprintf(f, "/PaintType 0 def\n"); // XUID (MD5 sum of font data) { - MD5_CONTEXT md5; - md5_init(&md5); - md5_update(&md5, (const unsigned char *) reduced_font.data(), reduced_font.length()); - unsigned char result[MD5_DIGEST_SIZE + 3]; - memset(result, 0, sizeof(result)); - md5_final(result, &md5); - fprintf(f, "/XUID [42"); - for (int i = 0; i < MD5_DIGEST_SIZE; i += 3) - fprintf(f, " 16#%X", result[i] + result[i+1]*256 + result[i+2]*256*256); - fprintf(f, "] def\n"); + MD5_CONTEXT md5; + md5_init(&md5); + md5_update(&md5, (const unsigned char *) reduced_font.data(), reduced_font.length()); + unsigned char result[MD5_DIGEST_SIZE + 3]; + memset(result, 0, sizeof(result)); + md5_final(result, &md5); + fprintf(f, "/XUID [42"); + for (int i = 0; i < MD5_DIGEST_SIZE; i += 3) + fprintf(f, " 16#%X", result[i] + result[i+1]*256 + result[i+2]*256*256); + fprintf(f, "] def\n"); } // FontInfo dictionary fprintf(f, "/FontInfo 10 dict dup begin\n"); for (const NameId *n = fontinfo_names; n->name; n++) - if (String s = name.english_name(n->nameid)) { - fprintf(f, "/%s (", n->name); - for (const char *x = s.begin(); x < s.end(); x++) - if (*x == '(' || *x == '\\' || *x == ')') - fprintf(f, "\\%c", *x); - else if (*x == '\n' || (*x >= ' ' && *x <= '~')) - fputc(*x, f); - else - fprintf(f, "\\%03o", (unsigned char) *x); - fprintf(f, ") readonly def\n"); - } + if (String s = name.english_name(n->nameid)) { + fprintf(f, "/%s (", n->name); + for (const char *x = s.begin(); x < s.end(); x++) + if (*x == '(' || *x == '\\' || *x == ')') + fprintf(f, "\\%c", *x); + else if (*x == '\n' || (*x >= ' ' && *x <= '~')) + fputc(*x, f); + else + fprintf(f, "\\%03o", (unsigned char) *x); + fprintf(f, ") readonly def\n"); + } if (post.ok()) { - fprintf(f, "/isFixedPitch %s def\n", (post.is_fixed_pitch() ? "true" : "false")); - fprintf(f, "/ItalicAngle %g def\n", post.italic_angle()); - fprintf(f, "/UnderlinePosition %g def\n", (post.underline_position() - (post.underline_thickness() / 2)) / emunits); - fprintf(f, "/UnderlineThickness %g def\n", post.underline_thickness() / emunits); + fprintf(f, "/isFixedPitch %s def\n", (post.is_fixed_pitch() ? "true" : "false")); + fprintf(f, "/ItalicAngle %g def\n", post.italic_angle()); + fprintf(f, "/UnderlinePosition %g def\n", (post.underline_position() - (post.underline_thickness() / 2)) / emunits); + fprintf(f, "/UnderlineThickness %g def\n", post.underline_thickness() / emunits); } fprintf(f, "end readonly def\n"); // encoding fprintf(f, "/Encoding 256 array\n0 1 255{1 index exch/.notdef put}for\n"); for (int i = 0; i < 256; i++) - if (OpenType::Glyph g = cmap.map_uni(i)) - fprintf(f, "dup %d /%s put\n", i, gn[g].c_str()); + if (OpenType::Glyph g = cmap.map_uni(i)) + fprintf(f, "dup %d /%s put\n", i, gn[g].c_str()); fprintf(f, "readonly def\n"); // print 'sfnts' array @@ -298,17 +298,17 @@ do_file(const char *infn, const char *outfn, ErrorHandler *errh) fprintf(f, "/sfnts[\n"); fprint_sfnts(f, sfnts.substring(0, OpenType::Font::HEADER_SIZE + OpenType::Font::TABLE_DIR_ENTRY_SIZE * reduced_font.ntables()), false, reduced_font); for (int i = 0; i < reduced_font.ntables(); i++) { - int off = OpenType::Font::HEADER_SIZE + OpenType::Font::TABLE_DIR_ENTRY_SIZE * i; - uint32_t offset = sfnts.u32(off + 8); - uint32_t length = (sfnts.u32(off + 12) + 3) & ~3; - fprint_sfnts(f, sfnts.substring(offset, length), sfnts.u32(off) == 0x676C7966 /*glyf*/, reduced_font); + int off = OpenType::Font::HEADER_SIZE + OpenType::Font::TABLE_DIR_ENTRY_SIZE * i; + uint32_t offset = sfnts.u32(off + 8); + uint32_t length = (sfnts.u32(off + 12) + 3) & ~3; + fprint_sfnts(f, sfnts.substring(offset, length), sfnts.u32(off) == 0x676C7966 /*glyf*/, reduced_font); } fprintf(f, "] def\n"); // print CharStrings data fprintf(f, "/CharStrings %d dict dup begin\n", ttbprog.nglyphs()); for (int i = 0; i < gn.size(); i++) - fprintf(f, "/%s %d def\n", gn[i].c_str(), i); + fprintf(f, "/%s %d def\n", gn[i].c_str(), i); fprintf(f, "end readonly def\n"); // complete font @@ -317,7 +317,7 @@ do_file(const char *infn, const char *outfn, ErrorHandler *errh) // fprintf(f, "/%s 100 selectfont 30 30 moveto (Hello! 9) show showpage\n", name.english_name(OpenType::Name::N_POSTSCRIPT).c_str()); if (f != stdout) - fclose(f); + fclose(f); } #if 0 @@ -335,7 +335,7 @@ int main(int argc, char *argv[]) { Clp_Parser *clp = - Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); + Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options); program_name = Clp_ProgramName(clp); ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr, String(program_name) + ": ")); @@ -343,57 +343,57 @@ main(int argc, char *argv[]) const char *output_file = 0; while (1) { - int opt = Clp_Next(clp); - switch (opt) { - - case QUIET_OPT: - if (clp->negated) - errh = ErrorHandler::default_handler(); - else - errh = new SilentErrorHandler; - break; - - case VERSION_OPT: - printf("ttftotype42 (LCDF typetools) %s\n", VERSION); - printf("Copyright (C) 2006-2019 Eddie Kohler\n\ + int opt = Clp_Next(clp); + switch (opt) { + + case QUIET_OPT: + if (clp->negated) + errh = ErrorHandler::default_handler(); + else + errh = new SilentErrorHandler; + break; + + case VERSION_OPT: + printf("ttftotype42 (LCDF typetools) %s\n", VERSION); + printf("Copyright (C) 2006-2023 Eddie Kohler\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty, not even for merchantability or fitness for a\n\ particular purpose.\n"); - exit(0); - break; - - case HELP_OPT: - usage(); - exit(0); - break; - - case OUTPUT_OPT: - output_file: - if (output_file) - usage_error(errh, "output file specified twice"); - output_file = clp->vstr; - break; - - case Clp_NotOption: - if (input_file && output_file) - usage_error(errh, "too many arguments"); - else if (input_file) - goto output_file; - else - input_file = clp->vstr; - break; - - case Clp_Done: - goto done; - - case Clp_BadOption: - usage_error(errh, 0); - break; - - default: - break; - - } + exit(0); + break; + + case HELP_OPT: + usage(); + exit(0); + break; + + case OUTPUT_OPT: + output_file: + if (output_file) + usage_error(errh, "output file specified twice"); + output_file = clp->vstr; + break; + + case Clp_NotOption: + if (input_file && output_file) + usage_error(errh, "too many arguments"); + else if (input_file) + goto output_file; + else + input_file = clp->vstr; + break; + + case Clp_Done: + goto done; + + case Clp_BadOption: + usage_error(errh, 0); + break; + + default: + break; + + } } done: diff --git a/Build/source/texk/lcdf-typetools/version.ac b/Build/source/texk/lcdf-typetools/version.ac index bc82b32931e..2a1adceb8cb 100644 --- a/Build/source/texk/lcdf-typetools/version.ac +++ b/Build/source/texk/lcdf-typetools/version.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current lcdf-typetools version -m4_define([lcdf_typetools_version], [2.108]) +m4_define([lcdf_typetools_version], [2.110]) |