diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-02-22 22:32:26 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-02-22 22:32:26 +0000 |
commit | a70871b31f5a63adc2c0b27936ed5e01bb52d307 (patch) | |
tree | e5098789ef35cffa67cea15724ed30880b822185 /Build/source/texk/lcdf-typetools/lcdf-typetools-src/include | |
parent | 00ff1bde18fb19e295a1dff020e8783df24e7b92 (diff) |
lcdf-typetools-2.107
git-svn-id: svn://tug.org/texlive/trunk@46714 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/lcdf-typetools/lcdf-typetools-src/include')
13 files changed, 523 insertions, 503 deletions
diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/config.h b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/config.h index 18cab5cff07..a65d3d75e7b 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/config.h +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/config.h @@ -39,6 +39,11 @@ double good_strtod(const char *s, char **endptr); } /* Get rid of a possible inline macro under C++. */ # define inline inline + +/* Ignore `noexcept` if compiler is too old. */ +#if __cplusplus < 201103L +#define noexcept +#endif #endif #endif /* LCDF_TYPETOOLS_CONFIG_H */ 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 c47c1c29cf8..cdf7a58daca 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 @@ -142,23 +142,23 @@ class FeatureList { class Coverage { public: - Coverage() throw (); // empty coverage - Coverage(Glyph first, Glyph last) throw (); // range coverage - Coverage(const Vector<bool> &gmap) throw (); // used-bytemap coverage - Coverage(const String &str, ErrorHandler *errh = 0, bool check = true) throw (); + Coverage() noexcept; // empty coverage + Coverage(Glyph first, Glyph last) noexcept; // range coverage + Coverage(const Vector<bool> &gmap) noexcept; // used-bytemap coverage + Coverage(const String &str, ErrorHandler *errh = 0, bool check = true) noexcept; // default destructor - bool ok() const throw () { return _str.length() > 0; } - int size() const throw (); - bool has_fast_covers() const throw () { + bool ok() const noexcept { return _str.length() > 0; } + int size() const noexcept; + bool has_fast_covers() const noexcept { return _str.length() > 0 && _str.data()[1] == T_X_BYTEMAP; } - int coverage_index(Glyph) const throw (); - bool covers(Glyph g) const throw () { return coverage_index(g) >= 0; } + int coverage_index(Glyph) const noexcept; + bool covers(Glyph g) const noexcept { return coverage_index(g) >= 0; } - void unparse(StringAccum&) const throw (); - String unparse() const throw (); + void unparse(StringAccum&) const noexcept; + String unparse() const noexcept; class iterator { public: iterator() : _pos(0), _value(0) { } @@ -194,7 +194,7 @@ class Coverage { iterator begin() const { return iterator(_str, false); } iterator end() const { return iterator(_str, true); } - Glyph operator[](int) const throw (); + Glyph operator[](int) const noexcept; enum { T_LIST = 1, T_RANGES = 2, T_X_BYTEMAP = 3, HEADERSIZE = 4, LIST_RECSIZE = 2, RANGES_RECSIZE = 6 }; @@ -238,17 +238,17 @@ class GlyphSet { class ClassDef { public: - ClassDef(const String&, ErrorHandler* = 0) throw (); + ClassDef(const String&, ErrorHandler* = 0) noexcept; // default destructor bool ok() const { return _str.length() > 0; } - int nclass() const throw (); + int nclass() const noexcept; - int lookup(Glyph) const throw (); - int operator[](Glyph g) const throw () { return lookup(g); } + int lookup(Glyph) const noexcept; + int operator[](Glyph g) const noexcept { return lookup(g); } - void unparse(StringAccum&) const throw (); - String unparse() const throw (); + void unparse(StringAccum&) const noexcept; + String unparse() const noexcept; class class_iterator { public: 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 30e40860291..2dfe24a1c18 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 @@ -83,20 +83,20 @@ class Data { static inline int32_t s32_aligned16(const unsigned char* s); static inline int32_t s32_aligned(const unsigned char* s); - inline uint8_t operator[](unsigned offset) const throw (Bounds); - inline uint16_t u16(unsigned offset) const throw (Bounds); - inline int16_t s16(unsigned offset) const throw (Bounds); - inline uint32_t u32(unsigned offset) const throw (Bounds); - inline int32_t s32(unsigned offset) const throw (Bounds); - inline uint8_t operator[](int offset) const throw (Bounds); - inline uint16_t u16(int offset) const throw (Bounds); - inline int16_t s16(int offset) const throw (Bounds); - inline uint32_t u32(int offset) const throw (Bounds); - inline int32_t s32(int offset) const throw (Bounds); - - Data subtable(unsigned offset) const throw (Bounds); - Data offset_subtable(unsigned offset_offset) const throw (Bounds); - inline Data substring(int left, int len = -1) const throw (); + inline uint8_t operator[](unsigned offset) const; + inline uint16_t u16(unsigned offset) const; + inline int16_t s16(unsigned offset) const; + inline uint32_t u32(unsigned offset) const; + inline int32_t s32(unsigned offset) const; + inline uint8_t operator[](int offset) const; + inline uint16_t u16(int offset) const; + inline int16_t s16(int offset) const; + inline uint32_t u32(int offset) const; + inline int32_t s32(int offset) const; + + Data subtable(unsigned offset) const; + Data offset_subtable(unsigned offset_offset) const; + inline Data substring(int left, int len = -1) const noexcept; void align_long() { _str.align(4); } @@ -106,7 +106,7 @@ class Data { }; -inline uint8_t Data::operator[](unsigned offset) const throw (Bounds) { +inline uint8_t Data::operator[](unsigned offset) const { if (offset >= static_cast<unsigned>(_str.length())) throw Bounds(); else @@ -114,11 +114,7 @@ inline uint8_t Data::operator[](unsigned offset) const throw (Bounds) { } inline uint16_t Data::u16(const unsigned char* s) { -#if __x86__ || __x86_64__ || HAVE_INDIFFERENT_ALIGNMENT - return ntohs(*reinterpret_cast<const uint16_t*>(s)); -#else return (s[0] << 8) + s[1]; -#endif } inline uint16_t Data::u16_aligned(const unsigned char* s) { @@ -127,11 +123,7 @@ inline uint16_t Data::u16_aligned(const unsigned char* s) { } inline int16_t Data::s16(const unsigned char* s) { -#if __x86__ || __x86_64__ || HAVE_INDIFFERENT_ALIGNMENT - return ntohs(*reinterpret_cast<const int16_t*>(s)); -#else return (int16_t) ((s[0] << 8) + s[1]); -#endif } inline int16_t Data::s16_aligned(const unsigned char* s) { @@ -140,20 +132,12 @@ inline int16_t Data::s16_aligned(const unsigned char* s) { } inline uint32_t Data::u32(const unsigned char* s) { -#if __x86__ || __x86_64__ || HAVE_INDIFFERENT_ALIGNMENT - return ntohl(*reinterpret_cast<const uint32_t*>(s)); -#else - return (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; -#endif + return ((unsigned) s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; } inline uint32_t Data::u32_aligned16(const unsigned char* s) { -#if __x86__ || __x86_64__ || HAVE_INDIFFERENT_ALIGNMENT - return ntohl(*reinterpret_cast<const uint32_t*>(s)); -#else efont_precondition((reinterpret_cast<uintptr_t>(s) & 1) == 0); - return (u16_aligned(s) << 16) + u16_aligned(s + 2); -#endif + return ((unsigned) u16_aligned(s) << 16) + u16_aligned(s + 2); } inline uint32_t Data::u32_aligned(const unsigned char* s) { @@ -162,20 +146,12 @@ inline uint32_t Data::u32_aligned(const unsigned char* s) { } inline int32_t Data::s32(const unsigned char* s) { -#if __x86__ || __x86_64__ || HAVE_INDIFFERENT_ALIGNMENT - return ntohl(*reinterpret_cast<const int32_t*>(s)); -#else - return (int32_t) ((s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]); -#endif + return (int32_t) (((unsigned) s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]); } inline int32_t Data::s32_aligned16(const unsigned char* s) { -#if __x86__ || __x86_64__ || HAVE_INDIFFERENT_ALIGNMENT - return ntohl(*reinterpret_cast<const int32_t*>(s)); -#else efont_precondition((reinterpret_cast<uintptr_t>(s) & 1) == 0); - return (int32_t) ((u16_aligned(s) << 16) + u16_aligned(s + 2)); -#endif + return (int32_t) (((unsigned) u16_aligned(s) << 16) + u16_aligned(s + 2)); } inline int32_t Data::s32_aligned(const unsigned char* s) { @@ -183,55 +159,55 @@ inline int32_t Data::s32_aligned(const unsigned char* s) { return ntohl(*reinterpret_cast<const int32_t*>(s)); } -inline uint16_t Data::u16(unsigned offset) const throw (Bounds) { +inline uint16_t Data::u16(unsigned offset) const { if (offset + 1 >= static_cast<unsigned>(_str.length()) || offset + 1 == 0) throw Bounds(); else return u16_aligned(_str.udata() + offset); } -inline int16_t Data::s16(unsigned offset) const throw (Bounds) { +inline int16_t Data::s16(unsigned offset) const { if (offset + 1 >= static_cast<unsigned>(_str.length()) || offset + 1 == 0) throw Bounds(); else return s16_aligned(_str.udata() + offset); } -inline uint32_t Data::u32(unsigned offset) const throw (Bounds) { +inline uint32_t Data::u32(unsigned offset) const { if (offset + 3 >= static_cast<unsigned>(_str.length()) || offset + 3 < 3) throw Bounds(); else return u32_aligned16(_str.udata() + offset); } -inline int32_t Data::s32(unsigned offset) const throw (Bounds) { +inline int32_t Data::s32(unsigned offset) const { if (offset + 3 >= static_cast<unsigned>(_str.length()) || offset + 3 < 3) throw Bounds(); else return s32_aligned16(_str.udata() + offset); } -inline uint8_t Data::operator[](int offset) const throw (Bounds) { +inline uint8_t Data::operator[](int offset) const { return (*this)[unsigned(offset)]; } -inline uint16_t Data::u16(int offset) const throw (Bounds) { +inline uint16_t Data::u16(int offset) const { return u16(unsigned(offset)); } -inline int16_t Data::s16(int offset) const throw (Bounds) { +inline int16_t Data::s16(int offset) const { return s16(unsigned(offset)); } -inline uint32_t Data::u32(int offset) const throw (Bounds) { +inline uint32_t Data::u32(int offset) const { return u32(unsigned(offset)); } -inline int32_t Data::s32(int offset) const throw (Bounds) { +inline int32_t Data::s32(int offset) const { return s32(unsigned(offset)); } -inline Data Data::substring(int left, int len) const throw () { +inline Data Data::substring(int left, int len) const noexcept { return Data(_str.substring(left, len)); } 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 ec5573cb964..6d1088a97fa 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,7 +9,7 @@ class Positioning; class Gpos { public: - Gpos(const Data &, ErrorHandler * = 0) throw (Error); + Gpos(const Data &, ErrorHandler * = 0); // default destructor const ScriptList &script_list() const { return _script_list; } @@ -29,7 +29,7 @@ class Gpos { public: }; class GposLookup { public: - GposLookup(const Data &) throw (Error); + GposLookup(const Data &); int type() const { return _type; } uint16_t flags() const { return _d.u16(2); } bool unparse_automatics(Vector<Positioning> &, ErrorHandler * = 0) const; @@ -66,9 +66,9 @@ class GposValue { public: }; class GposSingle { public: - GposSingle(const Data &) throw (Error); + GposSingle(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; void unparse(Vector<Positioning> &) const; enum { F2_HEADERSIZE = 8 }; private: @@ -76,9 +76,9 @@ class GposSingle { public: }; class GposPair { public: - GposPair(const Data &) throw (Error); + GposPair(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; void unparse(Vector<Positioning> &) const; enum { F1_HEADERSIZE = 10, F1_RECSIZE = 2, PAIRSET_HEADERSIZE = 2, PAIRVALUE_HEADERSIZE = 2, diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgsub.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgsub.hh index 383389e5895..79c1e9edd89 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgsub.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/otfgsub.hh @@ -9,7 +9,7 @@ class Substitution; class Gsub { public: - Gsub(const Data &, const Font *, ErrorHandler * = 0) throw (Error); + Gsub(const Data &, const Font *, ErrorHandler * = 0); // default destructor const ScriptList &script_list() const { return _script_list; } @@ -31,7 +31,7 @@ class Gsub { public: }; class GsubLookup { public: - GsubLookup(const Data &) throw (Error); + GsubLookup(const Data &); int type() const { return _type; } uint16_t flags() const { return _d.u16(2); } void mark_out_glyphs(const Gsub &gsub, Vector<bool> &gmap) const; @@ -49,9 +49,9 @@ class GsubLookup { public: }; class GsubSingle { public: - GsubSingle(const Data &) throw (Error); + GsubSingle(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; Glyph map(Glyph) const; void mark_out_glyphs(Vector<bool> &gmap) const; void unparse(Vector<Substitution> &subs, const Coverage &limit) const; @@ -62,9 +62,9 @@ class GsubSingle { public: }; class GsubMultiple { public: - GsubMultiple(const Data &) throw (Error); + GsubMultiple(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; bool map(Glyph, Vector<Glyph> &) const; void mark_out_glyphs(Vector<bool> &gmap) const; void unparse(Vector<Substitution> &, bool alternate = false) const; @@ -76,9 +76,9 @@ class GsubMultiple { public: }; class GsubLigature { public: - GsubLigature(const Data &) throw (Error); + GsubLigature(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; bool map(const Vector<Glyph> &, Glyph &, int &) const; void mark_out_glyphs(Vector<bool> &gmap) const; void unparse(Vector<Substitution> &) const; @@ -91,9 +91,9 @@ class GsubLigature { public: }; class GsubContext { public: - GsubContext(const Data &) throw (Error); + GsubContext(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; void mark_out_glyphs(const Gsub &gsub, Vector<bool> &gmap) const; bool unparse(const Gsub &gsub, Vector<Substitution> &out_subs, const Coverage &limit) const; enum { F3_HSIZE = 6, SUBRECSIZE = 4 }; @@ -113,9 +113,9 @@ class GsubContext { public: }; class GsubChainContext { public: - GsubChainContext(const Data &) throw (Error); + GsubChainContext(const Data &); // default destructor - Coverage coverage() const throw (); + Coverage coverage() const noexcept; void mark_out_glyphs(const Gsub &gsub, Vector<bool> &gmap) const; bool unparse(const Gsub &gsub, Vector<Substitution> &subs, const Coverage &limit) const; enum { F1_HEADERSIZE = 6, F1_RECSIZE = 2, @@ -199,7 +199,7 @@ class Substitution { public: void add_outer_left(Glyph); void remove_outer_left(); Substitution in_out_append_glyph(Glyph) const; - bool out_alter(const Substitution &, int) throw (); + bool out_alter(const Substitution &, int) noexcept; void add_outer_right(Glyph); void remove_outer_right(); @@ -238,14 +238,14 @@ class Substitution { public: static bool substitute_in(const Substitute &, uint8_t, const Coverage &); static bool substitute_in(const Substitute &, uint8_t, const GlyphSet &); - static Glyph extract_glyph(const Substitute &, uint8_t) throw (); - static Glyph extract_glyph(const Substitute &, int which, uint8_t) throw (); - static bool extract_glyphs(const Substitute &, uint8_t, Vector<Glyph> &, bool coverage_ok) throw (); - static Glyph *extract_glyphptr(const Substitute &, uint8_t) throw (); - static int extract_nglyphs(const Substitute &, uint8_t, bool coverage_ok) throw (); - static bool matches(const Substitute &, uint8_t, int pos, Glyph) throw (); + static Glyph extract_glyph(const Substitute &, uint8_t) noexcept; + static Glyph extract_glyph(const Substitute &, int which, uint8_t) noexcept; + static bool extract_glyphs(const Substitute &, uint8_t, Vector<Glyph> &, bool coverage_ok) noexcept; + static Glyph *extract_glyphptr(const Substitute &, uint8_t) noexcept; + static int extract_nglyphs(const Substitute &, uint8_t, bool coverage_ok) noexcept; + static bool matches(const Substitute &, uint8_t, int pos, Glyph) noexcept; - static void unparse_glyphids(StringAccum &, const Substitute &, uint8_t, const Vector<PermString> *) throw (); + static void unparse_glyphids(StringAccum &, const Substitute &, uint8_t, const Vector<PermString> *) noexcept; }; 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 30eaaef1a83..c6bb5208aca 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 @@ -25,15 +25,15 @@ class Os2 { public: O_LOWEROPTICALPOINTSIZE = 96, O_UPPEROPTICALPOINTSIZE = 98 }; enum { HEADER_SIZE = 2 }; - inline int16_t typo_ascender() const throw (Bounds); - inline int16_t typo_descender() const throw (Bounds); - inline int16_t typo_line_gap() const throw (Bounds); - inline int16_t x_height() const throw (Bounds); - inline int16_t cap_height() const throw (Bounds); - inline double lower_optical_point_size() const throw (Bounds); - inline double upper_optical_point_size() const throw (Bounds); - inline bool has_optical_point_size() const throw (); - inline String vendor_id() const throw (); + inline int16_t typo_ascender() const; + inline int16_t typo_descender() const; + inline int16_t typo_line_gap() const; + inline int16_t x_height() const; + inline int16_t cap_height() const; + inline double lower_optical_point_size() const; + inline double upper_optical_point_size() const; + inline bool has_optical_point_size() const noexcept; + inline String vendor_id() const noexcept; private: @@ -45,47 +45,47 @@ class Os2 { public: }; -inline int16_t Os2::typo_ascender() const throw (Bounds) +inline int16_t Os2::typo_ascender() const { return _data.s16(O_TYPOASCENDER); } -inline int16_t Os2::typo_descender() const throw (Bounds) +inline int16_t Os2::typo_descender() const { return _data.s16(O_TYPODESCENDER); } -inline int16_t Os2::typo_line_gap() const throw (Bounds) +inline int16_t Os2::typo_line_gap() const { return _data.s16(O_TYPOLINEGAP); } -inline int16_t Os2::x_height() const throw (Bounds) +inline int16_t Os2::x_height() const { return _data.s16(O_XHEIGHT); } -inline int16_t Os2::cap_height() const throw (Bounds) +inline int16_t Os2::cap_height() const { return _data.s16(O_CAPHEIGHT); } -inline double Os2::lower_optical_point_size() const throw (Bounds) +inline double Os2::lower_optical_point_size() const { return _data.u16(O_LOWEROPTICALPOINTSIZE) / 20.; } -inline double Os2::upper_optical_point_size() const throw (Bounds) +inline double Os2::upper_optical_point_size() const { return _data.u16(O_UPPEROPTICALPOINTSIZE) / 20.; } -inline bool Os2::has_optical_point_size() const throw () +inline bool Os2::has_optical_point_size() const noexcept { return _data.length() >= O_UPPEROPTICALPOINTSIZE + 2; } -inline String Os2::vendor_id() const throw () +inline String Os2::vendor_id() const noexcept { return _data.substring(O_VENDORID, 4).string(); } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1bounds.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1bounds.hh index 1f1addaebc2..dff5514772a 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1bounds.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/t1bounds.hh @@ -31,8 +31,9 @@ class CharstringBounds : public CharstringInterp { public: bool char_bounds(const CharstringContext&, bool shift = true); void translate(double dx, double dy); inline Point transform(const Point& p) const; - bool output(double bb[4], double& width, bool use_cur_width = false) const; + // output: [left, bottom, right, top] + bool output(double bb[4], double& width, bool use_cur_width = false) const; static bool bounds(const CharstringContext&, double bounds[4], double& width); static bool bounds(const Transform&, const CharstringContext&, diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/ttfkern.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/ttfkern.hh index ebe35331ce6..9b46c2d58ba 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/ttfkern.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/efont/ttfkern.hh @@ -6,7 +6,7 @@ namespace Efont { namespace OpenType { class KernTable { public: - KernTable(const Data &, ErrorHandler * = 0) throw (Error); + KernTable(const Data &, ErrorHandler * = 0); // default destructor bool ok() const { return _error >= 0; } @@ -34,7 +34,7 @@ class KernTable { public: inline uint32_t first_offset() const { return _version == 0 ? 4 : 8; } - inline Data subtable(uint32_t &off) const throw (Error); + inline Data subtable(uint32_t &off) const; }; 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 ebb93ce9aea..fb1018ed0e5 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 @@ -8,30 +8,30 @@ class Bezier { public: Bezier() : _bb(-1) { } - inline Bezier(Point p[4]) throw (); - inline Bezier(const Point &, const Point &, const Point &, const Point &) throw (); + 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]; } void set_point(int i, const Point &p) { mpoint(i) = p; } - Point eval(double) const throw (); - bool is_flat(double) const throw (); - bool in_bb(const Point &, double) const throw (); - bool hit(const Point &, double) const throw (); + Point eval(double) const noexcept; + bool is_flat(double) const noexcept; + bool in_bb(const Point &, double) const noexcept; + bool hit(const Point &, double) const noexcept; - inline double bb_left() const throw (); - inline double bb_right() const throw (); - inline double bb_top() const throw (); - inline double bb_bottom() const throw (); + inline double bb_left() const noexcept; + inline double bb_right() const noexcept; + inline double bb_top() const noexcept; + inline double bb_bottom() const noexcept; - inline double bb_left_x() const throw (); - inline double bb_right_x() const throw (); - inline double bb_top_x() const throw (); - inline double bb_bottom_x() const throw (); + inline double bb_left_x() const noexcept; + inline double bb_right_x() const noexcept; + inline double bb_top_x() const noexcept; + inline double bb_bottom_x() const noexcept; - void halve(Bezier &, Bezier &) const throw (); + void halve(Bezier &, Bezier &) const noexcept; inline void segmentize(Vector<Point> &) const; void segmentize(Vector<Point> &, bool) const; @@ -43,23 +43,23 @@ class Bezier { public: Point _p[4]; mutable int _bb; - void make_bb() const throw (); - inline void ensure_bb() const throw (); + void make_bb() const noexcept; + inline void ensure_bb() const noexcept; - double hit_recurse(const Point &, double, double, double, double, double) const throw (); + double hit_recurse(const Point &, double, double, double, double, double) const noexcept; }; inline -Bezier::Bezier(Point p[4]) throw () +Bezier::Bezier(Point p[4]) noexcept : _bb(-1) { memcpy(_p, p, sizeof(Point) * 4); } inline -Bezier::Bezier(const Point &p0, const Point &p1, const Point &p2, const Point &p3) throw () +Bezier::Bezier(const Point &p0, const Point &p1, const Point &p2, const Point &p3) noexcept { _p[0] = p0; _p[1] = p1; @@ -69,59 +69,59 @@ Bezier::Bezier(const Point &p0, const Point &p1, const Point &p2, const Point &p } inline void -Bezier::ensure_bb() const throw () +Bezier::ensure_bb() const noexcept { if (_bb < 0) make_bb(); } inline double -Bezier::bb_top_x() const throw () +Bezier::bb_top_x() const noexcept { return _p[(_bb >> 4) & 3].y; } inline double -Bezier::bb_left_x() const throw () +Bezier::bb_left_x() const noexcept { return _p[(_bb >> 2) & 3].x; } inline double -Bezier::bb_bottom_x() const throw () +Bezier::bb_bottom_x() const noexcept { return _p[(_bb >> 6) & 3].y; } inline double -Bezier::bb_right_x() const throw () +Bezier::bb_right_x() const noexcept { return _p[(_bb >> 0) & 3].x; } inline double -Bezier::bb_top() const throw () +Bezier::bb_top() const noexcept { ensure_bb(); return bb_top_x(); } inline double -Bezier::bb_left() const throw () +Bezier::bb_left() const noexcept { ensure_bb(); return bb_left_x(); } inline double -Bezier::bb_bottom() const throw () +Bezier::bb_bottom() const noexcept { ensure_bb(); return bb_bottom_x(); } inline double -Bezier::bb_right() const throw () +Bezier::bb_right() const noexcept { ensure_bb(); return bb_right_x(); 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 970992379da..2fa1196616e 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,7 +8,7 @@ extern "C" { /* clp.h - Public interface to CLP. * This file is part of CLP, the command line parser package. * - * Copyright (c) 1997-2016 Eddie Kohler, ekohler@gmail.com + * Copyright (c) 1997-2018 Eddie Kohler, ekohler@gmail.com * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/point.hh b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/point.hh index aad59b53ccf..9645615d17e 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/point.hh +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/point.hh @@ -14,28 +14,28 @@ struct Point { Point(const Point &p, double dx, double dy) : x(p.x + dx), y(p.y + dy) { } // ~Point() use compiler default - inline double squared_length() const throw (); - inline double length() const throw (); - inline double magnitude() const throw (); - static inline double distance(const Point &, const Point &) throw (); - static inline double dot(const Point &, const Point &) throw (); - static Point midpoint(const Point &, const Point &) throw (); + inline double squared_length() const noexcept; + inline double length() const noexcept; + inline double magnitude() const noexcept; + static inline double distance(const Point &, const Point &) noexcept; + static inline double dot(const Point &, const Point &) noexcept; + static Point midpoint(const Point &, const Point &) noexcept; - inline double angle() const throw (); + inline double angle() const noexcept; void shift(double dx, double dy) { x += dx; y += dy; } - inline Point shifted(double dx, double dy) const throw (); - Point rotated(double) const throw (); - inline Point normal() const throw (); + inline Point shifted(double dx, double dy) const noexcept; + Point rotated(double) const noexcept; + inline Point normal() const noexcept; - bool on_line(const Point &, const Point &, double) const throw (); - bool on_segment(const Point &, const Point &, double) const throw (); + bool on_line(const Point &, const Point &, double) const noexcept; + bool on_segment(const Point &, const Point &, double) const noexcept; - inline Point &operator+=(const Point &) throw (); - inline Point &operator-=(const Point &) throw (); - inline Point &operator*=(double) throw (); - inline Point &operator/=(double) throw (); + inline Point &operator+=(const Point &) noexcept; + inline Point &operator-=(const Point &) noexcept; + inline Point &operator*=(double) noexcept; + inline Point &operator/=(double) noexcept; // Point operator+(Point, const Point &); // Point operator-(Point, const Point &); @@ -49,44 +49,44 @@ struct Point { }; inline double -Point::squared_length() const throw () +Point::squared_length() const noexcept { return x*x + y*y; } inline double -Point::length() const throw () +Point::length() const noexcept { return sqrt(x*x + y*y); } inline double -Point::magnitude() const throw () +Point::magnitude() const noexcept { return length(); } inline double -Point::angle() const throw () +Point::angle() const noexcept { return atan2(y, x); } inline Point -Point::shifted(double dx, double dy) const throw () +Point::shifted(double dx, double dy) const noexcept { return Point(x + dx, y + dy); } inline Point -Point::normal() const throw () +Point::normal() const noexcept { double l = length(); return (l ? Point(x/l, y/l) : *this); } inline Point & -Point::operator+=(const Point &p) throw () +Point::operator+=(const Point &p) noexcept { x += p.x; y += p.y; @@ -94,7 +94,7 @@ Point::operator+=(const Point &p) throw () } inline Point & -Point::operator-=(const Point &p) throw () +Point::operator-=(const Point &p) noexcept { x -= p.x; y -= p.y; @@ -102,7 +102,7 @@ Point::operator-=(const Point &p) throw () } inline Point & -Point::operator*=(double d) throw () +Point::operator*=(double d) noexcept { x *= d; y *= d; @@ -110,7 +110,7 @@ Point::operator*=(double d) throw () } inline Point & -Point::operator/=(double d) throw () +Point::operator/=(double d) noexcept { x /= d; y /= d; @@ -118,66 +118,66 @@ Point::operator/=(double d) throw () } inline bool -operator==(const Point &a, const Point &b) throw () +operator==(const Point &a, const Point &b) noexcept { return a.x == b.x && a.y == b.y; } inline bool -operator!=(const Point &a, const Point &b) throw () +operator!=(const Point &a, const Point &b) noexcept { return a.x != b.x || a.y != b.y; } inline Point -operator+(Point a, const Point &b) throw () +operator+(Point a, const Point &b) noexcept { a += b; return a; } inline Point -operator-(Point a, const Point &b) throw () +operator-(Point a, const Point &b) noexcept { a -= b; return a; } inline Point -operator-(const Point &a) throw () +operator-(const Point &a) noexcept { return Point(-a.x, -a.y); } inline Point -operator*(Point a, double scale) throw () +operator*(Point a, double scale) noexcept { a *= scale; return a; } inline Point -operator*(double scale, Point a) throw () +operator*(double scale, Point a) noexcept { a *= scale; return a; } inline Point -operator/(Point a, double scale) throw () +operator/(Point a, double scale) noexcept { a /= scale; return a; } inline double -Point::distance(const Point &a, const Point &b) throw () +Point::distance(const Point &a, const Point &b) noexcept { return (a - b).length(); } inline double -Point::dot(const Point &a, const Point &b) throw () +Point::dot(const Point &a, const Point &b) noexcept { return a.x*b.x + a.y*b.y; } 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 f62c2984978..b5756561684 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 @@ -20,143 +20,41 @@ template<typename T> class Vector; class StringAccum { public: - /** @brief Construct an empty StringAccum (with length 0). */ - StringAccum() - : _s(0), _len(0), _cap(0) { - } - - /** @brief Construct a StringAccum with room for at least @a capacity - * characters. - * @param capacity initial capacity - * - * If @a capacity <= 0, the StringAccum is created empty. If @a capacity - * is too large (so that @a capacity bytes of memory can't be allocated), - * the StringAccum falls back to a smaller capacity (possibly zero). */ - explicit inline StringAccum(int capacity); - - /** @brief Construct a StringAccum containing the characters in @a s. */ - explicit inline StringAccum(const char *cstr) - : _s(0), _len(0), _cap(0) { - append(cstr); - } - - /** @brief Construct a StringAccum containing the characters in @a s. */ - inline 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. */ - 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. */ - StringAccum(const StringAccum &x) - : _s(0), _len(0), _cap(0) { - append(x.data(), x.length()); - } - - /** @brief Destroy a StringAccum, freeing its memory. */ - ~StringAccum() { - if (_cap > 0) - delete[] (_s - MEMO_SPACE); - } - - - /** @brief Return the contents of the StringAccum. - * @return The StringAccum's contents. - * - * The return value is null if the StringAccum is empty or out-of-memory. - * The returned data() value points to writable memory (unless the - * StringAccum itself is const). */ - inline const char *data() const { - return reinterpret_cast<const char *>(_s); - } - - /** @overload */ - inline char *data() { - return reinterpret_cast<char *>(_s); - } + typedef const char* const_iterator; + typedef char* iterator; - inline const unsigned char* udata() const { - return _s; - } - - inline unsigned char* udata() { - return _s; - } - - /** @brief Return true iff the StringAccum is empty or out-of-memory. */ - bool empty() const { - return _len == 0; - } - - /** @brief Return the length of the StringAccum. */ - int length() const { - return _len; - } - - /** @brief Return the StringAccum's current capacity. - * - * The capacity is the maximum length the StringAccum can hold without - * incurring a memory allocation. Returns -1 for out-of-memory - * StringAccums. */ - int capacity() const { - return _cap; - } - - - typedef const char *const_iterator; - typedef char *iterator; + typedef int (StringAccum::*unspecified_bool_type)() const; - /** @brief Return an iterator for the first character in the StringAccum. - * - * StringAccum iterators are simply pointers into string data, so they are - * quite efficient. @sa StringAccum::data */ - inline const_iterator begin() const { - return reinterpret_cast<char *>(_s); - } + inline StringAccum(); + explicit inline StringAccum(int capacity); + explicit inline StringAccum(const char *cstr); + inline StringAccum(const char* s, int len); + inline StringAccum(const String& str); + inline StringAccum(const StringAccum& x); + inline ~StringAccum(); - /** @overload */ - inline iterator begin() { - return reinterpret_cast<char *>(_s); - } + inline const char* data() const; + inline char* data(); + inline const unsigned char* udata() const; + inline unsigned char* udata(); + inline int length() const; + inline int capacity() const; - /** @brief Return an iterator for the end of the StringAccum. - * - * The return value points one character beyond the last character in the - * StringAccum. */ - inline StringAccum::const_iterator end() const { - return reinterpret_cast<char *>(_s + _len); - } + inline bool empty() const; + inline bool operator!() const; + inline bool out_of_memory() const; - /** @overload */ - inline iterator end() { - return reinterpret_cast<char *>(_s + _len); - } + inline const_iterator begin() const; + inline iterator begin(); + inline const_iterator end() const; + inline iterator end(); - typedef int (StringAccum::*unspecified_bool_type)() const; - /** @brief Return true iff the StringAccum contains characters. * * Returns false for empty and out-of-memory StringAccums. */ - operator unspecified_bool_type() const { - return _len != 0 ? &StringAccum::capacity : 0; - } - - /** @brief Return true iff the StringAccum does not contain characters. - * - * Returns true for empty and out-of-memory StringAccums. */ - bool operator!() const { - return _len == 0; - } - - /** @brief Return true iff the StringAccum is out-of-memory. */ - bool out_of_memory() const { - return _cap < 0; + inline operator unspecified_bool_type() const { + return _len != 0 ? &StringAccum::capacity : 0; } @@ -169,182 +67,44 @@ class StringAccum { public: const char *c_str(); - /** @brief Return the <a>i</a>th character in the string. - * @param i character index - * @pre 0 <= @a i < length() */ - char operator[](int i) const { - assert((unsigned) i < (unsigned) _len); - return static_cast<char>(_s[i]); - } - - /** @brief Return a reference to the <a>i</a>th character in the string. - * @param i character index - * @pre 0 <= @a i < length() */ - char &operator[](int i) { - assert((unsigned) i < (unsigned) _len); - return reinterpret_cast<char &>(_s[i]); - } - - /** @brief Return the first character in the string. - * @pre length() > 0 */ - char front() const { - assert(_len > 0); - return static_cast<char>(_s[0]); - } - - /** @brief Return a reference to the first character in the string. - * @pre length() > 0 */ - char &front() { - assert(_len > 0); - return reinterpret_cast<char &>(_s[0]); - } - - /** @brief Return the last character in the string. - * @pre length() > 0 */ - char back() const { - assert(_len > 0); - return static_cast<char>(_s[_len - 1]); - } - - /** @brief Return a reference to the last character in the string. - * @pre length() > 0 */ - char &back() { - assert(_len > 0); - return reinterpret_cast<char &>(_s[_len - 1]); - } + inline char operator[](int i) const; + inline char& operator[](int i); + inline char front() const; + inline char& front(); + inline char back() const; + inline char& back(); + inline void clear(); - /** @brief Clear the StringAccum's comments. - * - * All characters in the StringAccum are erased. Also resets the - * StringAccum's out-of-memory status. */ - inline void clear() { - if (_cap < 0) { - _cap = 0; - _s = 0; - } - _len = 0; - } - - - /** @brief Reserve space for at least @a n characters. - * @return a pointer to at least @a n characters, or null if allocation - * fails - * @pre @a n >= 0 - * - * reserve() does not change the string's length(), only its capacity(). - * In a frequent usage pattern, code calls reserve(), passing an upper - * bound on the characters that could be written by a series of - * operations. After writing into the returned buffer, adjust_length() is - * called to account for the number of characters actually written. - * - * On failure, null is returned and errno is set to ENOMEM. */ - inline char *reserve(int n) { - assert(n >= 0); - if (_len + n <= _cap) - return reinterpret_cast<char *>(_s + _len); - else - return grow(_len + n); - } - - /** @brief Set the StringAccum's length to @a len. - * @param len new length in characters - * @pre 0 <= @a len <= capacity() - * @sa adjust_length */ - inline void set_length(int len) { - assert(len >= 0 && _len <= _cap); - _len = len; - } + inline char* reserve(int n); + inline void set_length(int len); /** @brief Set the StringAccum's length to @a len. * @pre @a len >= 0 * @return 0 on success, -ENOMEM on failure */ int resize(int len); - /** @brief Adjust the StringAccum's length. - * @param delta length adjustment - * @pre If @a delta > 0, then length() + @a delta <= capacity(). - * If @a delta < 0, then length() + delta >= 0. - * - * The StringAccum's length after adjust_length(@a delta) equals its old - * length plus @a delta. Generally adjust_length() is used after a call - * to reserve(). @sa set_length */ - inline void adjust_length(int delta) { - assert(_len + delta >= 0 && _len + delta <= _cap); - _len += delta; - } - - /** @brief Reserve space and adjust length in one operation. - * @param nadjust number of characters to reserve and adjust length - * @param nreserve additional characters to reserve - * @pre @a nadjust >= 0 and @a nreserve >= 0 - * - * This operation combines the effects of reserve(@a nadjust + @a - * nreserve) and adjust_length(@a nadjust). Returns the result of the - * reserve() call. */ - inline char *extend(int nadjust, int nreserve = 0) { - assert(nadjust >= 0 && nreserve >= 0); - if (_len + nadjust + nreserve <= _cap) { - char *x = reinterpret_cast<char *>(_s + _len); - _len += nadjust; - return x; - } else - return hard_extend(nadjust, nreserve); - } + inline void adjust_length(int delta); + inline char* extend(int nadjust, int nreserve = 0); + inline void pop_back(int n = 1); - /** @brief Remove characters from the end of the StringAccum. - * @param n number of characters to remove - * @pre @a n >= 0 and @a n <= length() - * - * Same as adjust_length(-@a n). */ - inline void pop_back(int n = 1) { - assert(n >= 0 && _len >= n); - _len -= n; - } - - - /** @brief Append character @a c to the StringAccum. - * @param c character to append */ - inline void append(char c) { - if (_len < _cap || grow(_len)) - _s[_len++] = c; - } - /** @overload */ - inline void append(unsigned char c) { - append(static_cast<char>(c)); - } + inline void append(char c); + inline void append(unsigned char c); /** @brief Append @a len copies of character @a c to the StringAccum. */ void append_fill(int c, int len); - /** @brief Append the UTF-8 encoding of Unicode character @a ch. */ - inline void append_utf8(unsigned ch) { - if (ch < 0x80) - append((unsigned char) ch); - else - append_utf8_hard(ch); - } + inline void append_utf8(unsigned ch); /** @brief Append the null-terminated C string @a s to this StringAccum. * @param s data to append */ - void append(const char *s); - /** @brief Append the first @a len characters of @a s to this StringAccum. - * @param s data to append - * @param len length of data - * @pre @a len >= 0 */ - inline void append(const char *s, int len); - /** @overload */ - inline void append(const unsigned char *s, int len); - - /** @brief Append the data from @a begin to @a end to the end of this - * StringAccum. - * - * Does nothing if @a begin >= @a end. */ - inline void append(const char *begin, const char *end); - /** @overload */ - inline void append(const unsigned char *begin, const unsigned char *end); + void append(const char* s); + inline void append(const char* s, int len); + inline void append(const unsigned char* s, int len); + inline void append(const char* begin, const char* end); + 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()); @@ -374,16 +134,7 @@ class StringAccum { public: String take_string(); - /** @brief Assign this StringAccum to @a x. */ - StringAccum &operator=(const StringAccum &x) { - if (&x != this) { - if (out_of_memory()) - _s = 0, _cap = 0; - _len = 0; - append(x.data(), x.length()); - } - return *this; - } + inline StringAccum& operator=(const StringAccum& x); /** @brief Swap this StringAccum's contents with @a x. */ void swap(StringAccum &x); @@ -393,7 +144,7 @@ class StringAccum { public: private: enum { - MEMO_SPACE = String::MEMO_SPACE + MEMO_SPACE = String::MEMO_SPACE }; unsigned char *_s; @@ -434,42 +185,329 @@ StringAccum &operator<<(StringAccum &, unsigned long); StringAccum &operator<<(StringAccum &, double); -inline -StringAccum::StringAccum(int capacity) - : _len(0) -{ +/** @brief Construct an empty StringAccum (with length 0). */ +inline StringAccum::StringAccum() + : _s(0), _len(0), _cap(0) { +} + +/** @brief Construct a StringAccum with room for at least @a capacity + * characters. + * @param capacity initial capacity + * + * If @a capacity <= 0, the StringAccum is created empty. If @a capacity + * is too large (so that @a capacity bytes of memory can't be allocated), + * the StringAccum falls back to a smaller capacity (possibly zero). */ +inline StringAccum::StringAccum(int capacity) + : _len(0) { assert(capacity >= 0); if (capacity - && (_s = new unsigned char[capacity + MEMO_SPACE])) { - _s += MEMO_SPACE; - _cap = capacity; + && (_s = new unsigned char[capacity + MEMO_SPACE])) { + _s += MEMO_SPACE; + _cap = capacity; } else { - _s = 0; - _cap = 0; + _s = 0; + _cap = 0; } } -inline void StringAccum::append(const char *s, int len) { +/** @brief Construct a StringAccum containing the characters in @a s. */ +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) + : _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) + : _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) + : _s(0), _len(0), _cap(0) { + append(x.data(), x.length()); +} + +/** @brief Destroy a StringAccum, freeing its memory. */ +inline StringAccum::~StringAccum() { + if (_cap > 0) + delete[] (_s - MEMO_SPACE); +} + +/** @brief Return the contents of the StringAccum. + * @return The StringAccum's contents. + * + * The return value is null if the StringAccum is empty or out-of-memory. + * 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); +} + +/** @overload */ +inline char* StringAccum::data() { + return reinterpret_cast<char *>(_s); +} + +inline const unsigned char* StringAccum::udata() const { + return _s; +} + +inline unsigned char* StringAccum::udata() { + return _s; +} + +/** @brief Return true iff the StringAccum is empty or out-of-memory. */ +inline bool StringAccum::empty() const { + return _len == 0; +} + +/** @brief Return the length of the StringAccum. */ +inline int StringAccum::length() const { + return _len; +} + +/** @brief Return the StringAccum's current capacity. + * + * The capacity is the maximum length the StringAccum can hold without + * incurring a memory allocation. Returns -1 for out-of-memory + * StringAccums. */ +inline int StringAccum::capacity() const { + return _cap; +} + +/** @brief Return an iterator for the first character in the StringAccum. + * + * StringAccum iterators are simply pointers into string data, so they are + * quite efficient. @sa StringAccum::data */ +inline StringAccum::const_iterator StringAccum::begin() const { + return reinterpret_cast<char*>(_s); +} + +/** @overload */ +inline StringAccum::iterator StringAccum::begin() { + return reinterpret_cast<char*>(_s); +} + +/** @brief Return an iterator for the end of the StringAccum. + * + * The return value points one character beyond the last character in the + * StringAccum. */ +inline StringAccum::const_iterator StringAccum::end() const { + return reinterpret_cast<char*>(_s + _len); +} + +/** @overload */ +inline StringAccum::iterator StringAccum::end() { + return reinterpret_cast<char*>(_s + _len); +} + +/** @brief Return true iff the StringAccum does not contain characters. + * + * Returns true for empty and out-of-memory StringAccums. */ +inline bool StringAccum::operator!() const { + return _len == 0; +} + +/** @brief Return true iff the StringAccum is out-of-memory. */ +inline bool StringAccum::out_of_memory() const { + return _cap < 0; +} + +/** @brief Return the <a>i</a>th character in the string. + * @param i character index + * @pre 0 <= @a i < length() */ +inline char StringAccum::operator[](int i) const { + assert((unsigned) i < (unsigned) _len); + return static_cast<char>(_s[i]); +} + +/** @brief Return a reference to the <a>i</a>th character in the string. + * @param i character index + * @pre 0 <= @a i < length() */ +inline char& StringAccum::operator[](int i) { + assert((unsigned) i < (unsigned) _len); + return reinterpret_cast<char &>(_s[i]); +} + +/** @brief Return the first character in the string. + * @pre length() > 0 */ +inline char StringAccum::front() const { + assert(_len > 0); + return static_cast<char>(_s[0]); +} + +/** @brief Return a reference to the first character in the string. + * @pre length() > 0 */ +inline char& StringAccum::front() { + assert(_len > 0); + return reinterpret_cast<char &>(_s[0]); +} + +/** @brief Return the last character in the string. + * @pre length() > 0 */ +inline char StringAccum::back() const { + assert(_len > 0); + return static_cast<char>(_s[_len - 1]); +} + +/** @brief Return a reference to the last character in the string. + * @pre length() > 0 */ +inline char& StringAccum::back() { + assert(_len > 0); + return reinterpret_cast<char &>(_s[_len - 1]); +} + +/** @brief Clear the StringAccum's comments. + * + * All characters in the StringAccum are erased. Also resets the + * StringAccum's out-of-memory status. */ +inline void StringAccum::clear() { + if (_cap < 0) { + _cap = 0; + _s = 0; + } + _len = 0; +} + +/** @brief Reserve space for at least @a n characters. + * @return a pointer to at least @a n characters, or null if allocation + * fails + * @pre @a n >= 0 + * + * reserve() does not change the string's length(), only its capacity(). + * In a frequent usage pattern, code calls reserve(), passing an upper + * bound on the characters that could be written by a series of + * operations. After writing into the returned buffer, adjust_length() is + * called to account for the number of characters actually written. + * + * On failure, null is returned and errno is set to ENOMEM. */ +inline char* StringAccum::reserve(int n) { + assert(n >= 0); + if (_len + n <= _cap) + return reinterpret_cast<char *>(_s + _len); + else + return grow(_len + n); +} + +/** @brief Set the StringAccum's length to @a len. + * @param len new length in characters + * @pre 0 <= @a len <= capacity() + * @sa adjust_length */ +inline void StringAccum::set_length(int len) { + assert(len >= 0 && _len <= _cap); + _len = len; +} + +/** @brief Adjust the StringAccum's length. + * @param delta length adjustment + * @pre If @a delta > 0, then length() + @a delta <= capacity(). + * If @a delta < 0, then length() + delta >= 0. + * + * The StringAccum's length after adjust_length(@a delta) equals its old + * length plus @a delta. Generally adjust_length() is used after a call + * to reserve(). @sa set_length */ +inline void StringAccum::adjust_length(int delta) { + assert(_len + delta >= 0 && _len + delta <= _cap); + _len += delta; +} + +/** @brief Reserve space and adjust length in one operation. + * @param nadjust number of characters to reserve and adjust length + * @param nreserve additional characters to reserve + * @pre @a nadjust >= 0 and @a nreserve >= 0 + * + * This operation combines the effects of reserve(@a nadjust + @a + * nreserve) and adjust_length(@a nadjust). Returns the result of the + * reserve() call. */ +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); + _len += nadjust; + return x; + } else + return hard_extend(nadjust, nreserve); +} + +/** @brief Remove characters from the end of the StringAccum. + * @param n number of characters to remove + * @pre @a n >= 0 and @a n <= length() + * + * Same as adjust_length(-@a n). */ +inline void StringAccum::pop_back(int n) { + assert(n >= 0 && _len >= n); + _len -= n; +} + +/** @brief Append character @a c to the StringAccum. + * @param c character to append */ +inline void StringAccum::append(char c) { + if (_len < _cap || grow(_len)) + _s[_len++] = c; +} + +/** @overload */ +inline void StringAccum::append(unsigned char c) { + append(static_cast<char>(c)); +} + +/** @brief Append the UTF-8 encoding of Unicode character @a ch. */ +inline void StringAccum::append_utf8(unsigned ch) { + if (ch < 0x80) + append((unsigned char) ch); + else + append_utf8_hard(ch); +} + +/** @brief Append the first @a len characters of @a s to this StringAccum. + * @param s data to append + * @param len length of data + * @pre @a len >= 0 */ +inline void StringAccum::append(const char* s, int len) { assert(len >= 0); if (_len + len <= _cap) { - memcpy(_s + _len, s, len); - _len += len; + memcpy(_s + _len, s, len); + _len += len; } else - hard_append(s, len); + hard_append(s, len); } -inline void StringAccum::append(const unsigned char *s, int len) { +/** @overload */ +inline void StringAccum::append(const unsigned char* s, int len) { append(reinterpret_cast<const char *>(s), len); } -inline void StringAccum::append(const char *begin, const char *end) { +/** @brief Append the data from @a begin to @a end to the end of this + * StringAccum. + * + * Does nothing if @a begin >= @a end. */ +inline void StringAccum::append(const char* begin, const char* end) { if (begin < end) - append(begin, end - begin); + append(begin, end - begin); } -inline void StringAccum::append(const unsigned char *begin, const unsigned char *end) { +/** @overload */ +inline void StringAccum::append(const unsigned char* begin, const unsigned char* end) { if (begin < end) - append(begin, end - begin); + append(begin, end - begin); +} + +/** @brief Assign this StringAccum to @a x. */ +inline StringAccum& StringAccum::operator=(const StringAccum& x) { + if (&x != this) { + if (out_of_memory()) + _s = 0, _cap = 0; + _len = 0; + append(x.data(), x.length()); + } + return *this; } /** @relates StringAccum @@ -513,9 +551,9 @@ operator<<(StringAccum &sa, bool b) { static const char truefalse[] = "truefalse"; if (b) - sa.append(truefalse, 4); + sa.append(truefalse, 4); else - sa.append(truefalse + 4, 5); + sa.append(truefalse + 4, 5); return sa; } @@ -562,9 +600,9 @@ inline StringAccum & operator<<(StringAccum &sa, const String &str) { if (!str.out_of_memory()) - sa.hard_append(str.begin(), str.length()); + sa.hard_append(str.begin(), str.length()); else - sa.assign_out_of_memory(); + sa.assign_out_of_memory(); return sa; } diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/vector.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/vector.cc index 9b2bc44ea84..17110b64c12 100644 --- a/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/vector.cc +++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-src/include/lcdf/vector.cc @@ -7,7 +7,7 @@ * * Copyright (c) 1999-2000 Massachusetts Institute of Technology * Copyright (c) 2001-2003 International Computer Science Institute - * Copyright (c) 1999-2016 Eddie Kohler + * Copyright (c) 1999-2018 Eddie Kohler * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), |