diff options
author | Norbert Preining <norbert@preining.info> | 2019-12-10 03:01:52 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-12-10 03:01:52 +0000 |
commit | 0174af21196c197a5b3672c87bc6f7a614fddd7d (patch) | |
tree | 00b155441be0755336593a3a2170f7531a055e99 /dviware/dvisvgm/src | |
parent | d1cebb67c836ee110bdbd3aeb622675df479c993 (diff) |
CTAN sync 201912100301
Diffstat (limited to 'dviware/dvisvgm/src')
46 files changed, 275 insertions, 315 deletions
diff --git a/dviware/dvisvgm/src/Calculator.hpp b/dviware/dvisvgm/src/Calculator.hpp index f498365e54..cc3b2feb6b 100644 --- a/dviware/dvisvgm/src/Calculator.hpp +++ b/dviware/dvisvgm/src/Calculator.hpp @@ -33,7 +33,6 @@ struct CalculatorException : public MessageException { class Calculator { public: - Calculator () : _numValue(0) {} double eval (std::istream &is); double eval (const std::string &expr); void setVariable (const std::string &name, double value) {_variables[name] = value;} @@ -48,7 +47,7 @@ class Calculator { private: std::map<std::string,double> _variables; - double _numValue; + double _numValue=0; std::string _strValue; }; diff --git a/dviware/dvisvgm/src/CharMapID.hpp b/dviware/dvisvgm/src/CharMapID.hpp index e79c64b24f..cdc39ca94d 100644 --- a/dviware/dvisvgm/src/CharMapID.hpp +++ b/dviware/dvisvgm/src/CharMapID.hpp @@ -25,7 +25,7 @@ /** Represents a character map of a font. */ struct CharMapID { - CharMapID () noexcept : platform_id(0), encoding_id(0) {} + CharMapID () noexcept =default; CharMapID (uint8_t plf_id, uint8_t enc_id) noexcept : platform_id(plf_id), encoding_id(enc_id) {} bool operator == (const CharMapID &ids) const { @@ -52,8 +52,8 @@ struct CharMapID { static const CharMapID MAC_SIMPLCHINESE; static const CharMapID MAC_KOREAN; - uint8_t platform_id; - uint8_t encoding_id; + uint8_t platform_id=0; + uint8_t encoding_id=0; }; #endif diff --git a/dviware/dvisvgm/src/Color.hpp b/dviware/dvisvgm/src/Color.hpp index f522bded55..c58a97f0bb 100644 --- a/dviware/dvisvgm/src/Color.hpp +++ b/dviware/dvisvgm/src/Color.hpp @@ -40,7 +40,7 @@ class Color { enum class ColorSpace {GRAY, RGB, CMYK, LAB}; public: - Color () noexcept : _rgb(0) {} + Color () noexcept =default; explicit Color (uint32_t rgb) noexcept : _rgb(rgb) {} Color (uint8_t r, uint8_t g, uint8_t b) noexcept {setRGB(r,g,b);} Color (double r, double g, double b) noexcept {setRGB(r,g,b);} @@ -90,7 +90,7 @@ class Color { static int numComponents (ColorSpace colorSpace); private: - uint32_t _rgb; + uint32_t _rgb=0; }; #endif diff --git a/dviware/dvisvgm/src/Directory.cpp b/dviware/dvisvgm/src/Directory.cpp index ccc05a2e92..748d1bc070 100644 --- a/dviware/dvisvgm/src/Directory.cpp +++ b/dviware/dvisvgm/src/Directory.cpp @@ -22,35 +22,20 @@ using namespace std; -#ifdef _WIN32 - #include "windows.hpp" -#else +#ifndef _WIN32 #include <cerrno> #include <sys/stat.h> #endif Directory::Directory () { -#if _WIN32 - _handle = INVALID_HANDLE_VALUE; - _firstread = true; +#ifdef _WIN32 memset(&_fileData, 0, sizeof(WIN32_FIND_DATA)); -#else - _dir = nullptr; - _dirent = nullptr; #endif } -Directory::Directory (const string &dirname) { -#if _WIN32 - _handle = INVALID_HANDLE_VALUE; - _firstread = true; - memset(&_fileData, 0, sizeof(WIN32_FIND_DATA)); -#else - _dir = nullptr; - _dirent = nullptr; -#endif +Directory::Directory (const string &dirname) : Directory() { open(dirname); } diff --git a/dviware/dvisvgm/src/Directory.hpp b/dviware/dvisvgm/src/Directory.hpp index a703c18977..f6ec7a9602 100644 --- a/dviware/dvisvgm/src/Directory.hpp +++ b/dviware/dvisvgm/src/Directory.hpp @@ -43,12 +43,12 @@ class Directory { private: std::string _dirname; #ifdef _WIN32 - bool _firstread; - HANDLE _handle; + bool _firstread=true; + HANDLE _handle=INVALID_HANDLE_VALUE; WIN32_FIND_DATA _fileData; #else - DIR *_dir; - struct dirent *_dirent; + DIR *_dir=nullptr; + struct dirent *_dirent=nullptr; #endif }; diff --git a/dviware/dvisvgm/src/FileFinder.cpp b/dviware/dvisvgm/src/FileFinder.cpp index dfd60412cb..e867f648a7 100644 --- a/dviware/dvisvgm/src/FileFinder.cpp +++ b/dviware/dvisvgm/src/FileFinder.cpp @@ -46,6 +46,7 @@ std::string FileFinder::_argv0; std::string FileFinder::_progname; +std::string FileFinder::_pathbuf; bool FileFinder::_enableMktex = false; @@ -109,12 +110,11 @@ const char* FileFinder::findFile (const std::string &fname, const char *ftype) c if (fname.empty()) return nullptr; - static std::string buf; // try to lookup the file in the additionally specified directories for (const std::string &dir : _additionalDirs) { - buf = dir + "/" + fname; - if (FileSystem::exists(buf)) - return buf.c_str(); + _pathbuf = dir+"/"+fname; + if (FileSystem::exists(_pathbuf)) + return _pathbuf.c_str(); } std::string ext; if (ftype) @@ -126,21 +126,18 @@ const char* FileFinder::findFile (const std::string &fname, const char *ftype) c ext = fname.substr(pos+1); } +#ifdef _WIN32 + if (ext == "dll" || ext == "exe") + return lookupExecutable(fname); #ifdef MIKTEX - if (ext == "dll" || ext == "exe") { - // lookup dll and exe files in the MiKTeX bin directory first - buf = _miktex->getBinDir() + "/" + fname; - if (FileSystem::exists(buf)) - return buf.c_str(); - } else if (ext == "cmap") { // The MiKTeX SDK doesn't support the lookup of files without suffix (yet), thus // it's not possible to find cmap files which usually don't have a suffix. In order // to work around this, we try to lookup the files by calling kpsewhich. Process process("kpsewhich", "-format=cmap "+fname); - process.run(&buf); - buf = util::trim(buf); - return buf.empty() ? nullptr : buf.c_str(); + process.run(&_pathbuf); + _pathbuf = util::trim(_pathbuf); + return _pathbuf.empty() ? nullptr : _pathbuf.c_str(); } try { return _miktex->findFile(fname.c_str()); @@ -148,17 +145,9 @@ const char* FileFinder::findFile (const std::string &fname, const char *ftype) c catch (const MessageException &e) { return nullptr; } -#else -#ifdef TEXLIVEWIN32 - if (ext == "exe") { - // lookup exe files in directory where dvisvgm is located - if (const char *path = kpse_var_value("SELFAUTOLOC")) { - buf = std::string(path) + "/" + fname; - return FileSystem::exists(buf) ? buf.c_str() : nullptr; - } - return nullptr; - } -#endif +#endif // MIKTEX +#endif // _WIN32 +#ifndef MIKTEX static std::map<std::string, kpse_file_format_type> types = { {"tfm", kpse_tfm_format}, {"pfb", kpse_type1_format}, @@ -188,12 +177,12 @@ const char* FileFinder::findFile (const std::string &fname, const char *ftype) c // In the current version of libkpathsea, each call of kpse_find_file produces // a memory leak since the path buffer is not freed. I don't think we can do // anything against it here... - buf = path; + _pathbuf = path; std::free(path); - return buf.c_str(); + return _pathbuf.c_str(); } return nullptr; -#endif +#endif // !MIKTEX } @@ -264,3 +253,35 @@ const char* FileFinder::lookup (const std::string &fname, const char *ftype, boo return path; return nullptr; } + + +/** Looks up the location of an executable file. + * @param[in] fname name of file to look up + * @param[in] addSuffix if true, ".exe" is appended to the given filename (Windows only) + * @return absolute path of file or nullptr if not found */ +const char* FileFinder::lookupExecutable (const std::string &fname, bool addSuffix) const { +#ifdef MIKTEX + _pathbuf = _miktex->getBinDir() + "/" + fname; + if (addSuffix) + _pathbuf += ".exe"; + if (FileSystem::exists(_pathbuf)) + return _pathbuf.c_str(); + try { + return _miktex->findFile(fname.c_str()); + } + catch (...) { + } +#else + // lookup executables in directory where dvisvgm is located + if (const char *path = kpse_var_value("SELFAUTOLOC")) { + _pathbuf = std::string(path) + "/" + fname; +#ifdef _WIN32 + if (addSuffix) + _pathbuf += ".exe"; +#endif + if (FileSystem::exists(_pathbuf)) + return _pathbuf.c_str(); + } +#endif // !MIKTEX + return nullptr; +} diff --git a/dviware/dvisvgm/src/FileFinder.hpp b/dviware/dvisvgm/src/FileFinder.hpp index b01c26b10c..08c59a3372 100644 --- a/dviware/dvisvgm/src/FileFinder.hpp +++ b/dviware/dvisvgm/src/FileFinder.hpp @@ -35,6 +35,7 @@ class FileFinder { void addLookupDir (const std::string &path); const char* lookup (const std::string &fname, const char *ftype, bool extended=true) const; const char* lookup (const std::string &fname, bool extended=true) const {return lookup(fname, nullptr, extended);} + const char* lookupExecutable (const std::string &fname, bool addSuffix=false) const; protected: FileFinder (); @@ -45,6 +46,7 @@ class FileFinder { private: static std::string _argv0; static std::string _progname; + static std::string _pathbuf; ///< buffer holding the path of the last search static bool _enableMktex; std::set<std::string> _additionalDirs; #ifdef MIKTEX diff --git a/dviware/dvisvgm/src/FilePath.cpp b/dviware/dvisvgm/src/FilePath.cpp index c859d30469..6f162bfab9 100644 --- a/dviware/dvisvgm/src/FilePath.cpp +++ b/dviware/dvisvgm/src/FilePath.cpp @@ -122,7 +122,7 @@ void FilePath::init (string path, bool isfile, string current_dir) { single_slashes(path); single_slashes(current_dir); #ifdef _WIN32 - path = FileSystem::adaptPathSeperators(path); + path = FileSystem::ensureForwardSlashes(path); _drive = strip_drive_letter(path); #endif if (isfile) { @@ -303,7 +303,7 @@ bool FilePath::exists () const { bool FilePath::isAbsolute (string path) { path = util::trim(path); #ifdef _WIN32 - path = FileSystem::adaptPathSeperators(path); + path = FileSystem::ensureForwardSlashes(path); if (path.length() >= 2 && path[1] == ':' && isalpha(path[0])) path.erase(0, 2); // remove drive letter and colon #endif diff --git a/dviware/dvisvgm/src/FileSystem.cpp b/dviware/dvisvgm/src/FileSystem.cpp index 35621465a5..6a081ee24f 100644 --- a/dviware/dvisvgm/src/FileSystem.cpp +++ b/dviware/dvisvgm/src/FileSystem.cpp @@ -50,7 +50,6 @@ using namespace std; #endif -FileSystem FileSystem::_fs; string FileSystem::TMPDIR; const char *FileSystem::TMPSUBDIR = nullptr; @@ -133,8 +132,10 @@ uint64_t FileSystem::filesize (const string &fname) { } -string FileSystem::adaptPathSeperators (string path) { +string FileSystem::ensureForwardSlashes (string path) { +#ifdef _WIN32 std::replace(path.begin(), path.end(), PATHSEP, '/'); +#endif return path; } @@ -142,7 +143,7 @@ string FileSystem::adaptPathSeperators (string path) { string FileSystem::getcwd () { char buf[1024]; #ifdef _WIN32 - return adaptPathSeperators(_getcwd(buf, 1024)); + return ensureForwardSlashes(_getcwd(buf, 1024)); #else return ::getcwd(buf, 1024); #endif @@ -198,7 +199,7 @@ string FileSystem::tmpdir () { #ifdef _WIN32 char buf[MAX_PATH]; if (GetTempPath(MAX_PATH, buf)) - ret = adaptPathSeperators(buf); + ret = ensureForwardSlashes(buf); else ret = "."; #else @@ -232,7 +233,7 @@ bool FileSystem::mkdir (const string &dirname) { bool success = false; if (const char *cdirname = dirname.c_str()) { success = true; - const string dirstr = adaptPathSeperators(util::trim(cdirname)); + const string dirstr = ensureForwardSlashes(util::trim(cdirname)); for (size_t pos=1; success && (pos = dirstr.find('/', pos)) != string::npos; pos++) success &= s_mkdir(dirstr.substr(0, pos)); success &= s_mkdir(dirstr); diff --git a/dviware/dvisvgm/src/FileSystem.hpp b/dviware/dvisvgm/src/FileSystem.hpp index 9a1b80067d..b882caa9fa 100644 --- a/dviware/dvisvgm/src/FileSystem.hpp +++ b/dviware/dvisvgm/src/FileSystem.hpp @@ -24,15 +24,14 @@ #include <string> #include <vector> -class FileSystem -{ +class FileSystem { public: ~FileSystem (); static bool remove (const std::string &fname); static bool rename (const std::string &oldname, const std::string &newname); static bool copy (const std::string &src, const std::string &dest, bool remove_src=false); static uint64_t filesize (const std::string &fname); - static std::string adaptPathSeperators (std::string path); + static std::string ensureForwardSlashes (std::string path); static std::string getcwd (); static std::string tmpdir (); static bool chdir (const std::string &dir); @@ -51,9 +50,6 @@ class FileSystem FileSystem () =default; bool system_tmpdir_available (); static const char* TMPSUBDIR; ///< subdirectory of the system's temporary folder - - private: - static FileSystem _fs; }; #endif diff --git a/dviware/dvisvgm/src/FixWord.hpp b/dviware/dvisvgm/src/FixWord.hpp index 41a09f1120..94166b232c 100644 --- a/dviware/dvisvgm/src/FixWord.hpp +++ b/dviware/dvisvgm/src/FixWord.hpp @@ -25,14 +25,14 @@ class FixWord { public: - FixWord () : _value(0) {} + FixWord () =default; FixWord (int32_t fw) : _value(fw) {} explicit operator double () const {return double(_value)/(1 << 20);} bool operator < (FixWord fw) const {return _value < fw._value;} bool operator == (FixWord fw) const {return _value == fw._value;} private: - int32_t _value; + int32_t _value=0; }; #endif diff --git a/dviware/dvisvgm/src/FontStyle.hpp b/dviware/dvisvgm/src/FontStyle.hpp index 40c5d3e45e..1088df3c4e 100644 --- a/dviware/dvisvgm/src/FontStyle.hpp +++ b/dviware/dvisvgm/src/FontStyle.hpp @@ -22,11 +22,11 @@ #define FONTSTYLE struct FontStyle { - FontStyle () : bold(0), extend(1), slant(0) {} + FontStyle () =default; FontStyle (float b, float e, float s) : bold(b), extend(e), slant(s) {} - double bold; ///< stroke width in pt used to draw the glyph outlines - double extend; ///< factor to strech/shrink the glyphs horizontally - double slant; ///< horizontal slanting/skewing value (= tan(phi)) + double bold=0; ///< stroke width in pt used to draw the glyph outlines + double extend=1; ///< factor to strech/shrink the glyphs horizontally + double slant=0; ///< horizontal slanting/skewing value (= tan(phi)) }; #endif diff --git a/dviware/dvisvgm/src/GFGlyphTracer.cpp b/dviware/dvisvgm/src/GFGlyphTracer.cpp index 85f7c2cab5..1b55afc593 100644 --- a/dviware/dvisvgm/src/GFGlyphTracer.cpp +++ b/dviware/dvisvgm/src/GFGlyphTracer.cpp @@ -22,10 +22,6 @@ using namespace std; -GFGlyphTracer::GFGlyphTracer () : GFTracer(_ifs, 0) -{ -} - /** Constructs a new glyph tracer. * @param[in] is GF input stream * @param[in] upp target units per PS point */ diff --git a/dviware/dvisvgm/src/GFGlyphTracer.hpp b/dviware/dvisvgm/src/GFGlyphTracer.hpp index 49f69b69ec..afe1b95253 100644 --- a/dviware/dvisvgm/src/GFGlyphTracer.hpp +++ b/dviware/dvisvgm/src/GFGlyphTracer.hpp @@ -26,8 +26,7 @@ #include "GFTracer.hpp" #include "Glyph.hpp" -class GFGlyphTracer : public GFTracer -{ +class GFGlyphTracer : public GFTracer { public: struct Callback { virtual ~Callback () =default; @@ -38,7 +37,7 @@ class GFGlyphTracer : public GFTracer }; public: - GFGlyphTracer (); + GFGlyphTracer () : GFTracer(_ifs, 0) {} GFGlyphTracer (std::string &fname, double upp, Callback *cb=nullptr); void reset (std::string &fname, double upp); void setCallback (Callback *cb) {_callback = cb;} diff --git a/dviware/dvisvgm/src/GFReader.cpp b/dviware/dvisvgm/src/GFReader.cpp index 32ba354443..a7d314d3de 100644 --- a/dviware/dvisvgm/src/GFReader.cpp +++ b/dviware/dvisvgm/src/GFReader.cpp @@ -40,16 +40,6 @@ static inline double scaled2double (int32_t scaled) { } -GFReader::GFReader (istream &is) : _in(is), _insideCharDef(false), _penDown(false) -{ - _minX = _maxX = _minY = _maxY = _x = _y = 0; - _currentChar = 0; - _designSize = 0; - _hppp = _vppp = 0; - _checksum = 0; -} - - uint32_t GFReader::readUnsigned (int bytes) { uint32_t ret = 0; for (int i=bytes-1; i >= 0 && !_in.eof(); i--) { diff --git a/dviware/dvisvgm/src/GFReader.hpp b/dviware/dvisvgm/src/GFReader.hpp index 3dfceb98cd..ad1e8b2220 100644 --- a/dviware/dvisvgm/src/GFReader.hpp +++ b/dviware/dvisvgm/src/GFReader.hpp @@ -47,7 +47,7 @@ class GFReader { }; public: - explicit GFReader (std::istream &is); + explicit GFReader (std::istream &is) : _in(is) {} virtual ~GFReader () =default; virtual bool executeChar (uint8_t c); virtual bool executeAllChars (); @@ -91,16 +91,16 @@ class GFReader { private: std::istream &_in; - int32_t _minX, _maxX, _minY, _maxY; - int32_t _x, _y; ///< current pen location (pixel units) - int32_t _currentChar; - Bitmap _bitmap; ///< bitmap of current char - double _designSize; ///< designSize in PS points - double _hppp, _vppp; ///< horizontal and vertical pixel per point - uint32_t _checksum; + int32_t _minX=0, _maxX=0, _minY=0, _maxY=0; + int32_t _x=0, _y=0; ///< current pen location (pixel units) + int32_t _currentChar=0; + Bitmap _bitmap; ///< bitmap of current char + double _designSize=0; ///< designSize in PS points + double _hppp=0, _vppp=0; ///< horizontal and vertical pixel per point + uint32_t _checksum=0; std::unordered_map<uint8_t,CharInfo> _charInfoMap; - bool _insideCharDef; ///< true if inside a character definition (between BOC and EOC) - bool _penDown; + bool _insideCharDef=false; ///< true if inside a character definition (between BOC and EOC) + bool _penDown=false; }; #endif diff --git a/dviware/dvisvgm/src/GFTracer.cpp b/dviware/dvisvgm/src/GFTracer.cpp index 61d297d982..e73aab12fd 100644 --- a/dviware/dvisvgm/src/GFTracer.cpp +++ b/dviware/dvisvgm/src/GFTracer.cpp @@ -27,12 +27,6 @@ using namespace std; -GFTracer::GFTracer (istream &is) - : GFReader(is), _unitsPerPoint(0.0) -{ -} - - /** Constructs a new GFTracer. * @param[in] is GF file is read from this stream * @param[in] upp target units per PS point */ diff --git a/dviware/dvisvgm/src/GFTracer.hpp b/dviware/dvisvgm/src/GFTracer.hpp index 8fe746cc05..efe9476a8f 100644 --- a/dviware/dvisvgm/src/GFTracer.hpp +++ b/dviware/dvisvgm/src/GFTracer.hpp @@ -26,7 +26,7 @@ class GFTracer : public GFReader { public: - explicit GFTracer (std::istream &is); + explicit GFTracer (std::istream &is) : GFReader(is) {} GFTracer (std::istream &is, double upp); virtual void moveTo (double x, double y) =0; virtual void lineTo (double x, double y) =0; @@ -39,7 +39,7 @@ class GFTracer : public GFReader { void unitsPerPoint(double upp) {_unitsPerPoint = upp;} private: - double _unitsPerPoint; ///< target units per PS point + double _unitsPerPoint=0; ///< target units per PS point }; #endif diff --git a/dviware/dvisvgm/src/GlyphTracerMessages.hpp b/dviware/dvisvgm/src/GlyphTracerMessages.hpp index 8a41b811d9..d48fe6f1b4 100644 --- a/dviware/dvisvgm/src/GlyphTracerMessages.hpp +++ b/dviware/dvisvgm/src/GlyphTracerMessages.hpp @@ -27,7 +27,8 @@ class GlyphTracerMessages : public GFGlyphTracer::Callback { public: - explicit GlyphTracerMessages (bool sfmsg=true, bool autonl=true) : _sfmsg(sfmsg), _autonl(autonl), _traced(false) {} + GlyphTracerMessages () =default; + explicit GlyphTracerMessages (bool sfmsg, bool autonl) : _sfmsg(sfmsg), _autonl(autonl) {} ~GlyphTracerMessages () override { if (_autonl) @@ -71,8 +72,8 @@ class GlyphTracerMessages : public GFGlyphTracer::Callback { private: std::string _fname; - bool _sfmsg, _autonl; - bool _traced; ///< true if a glyph of the current font has already been traced? + bool _sfmsg=true, _autonl=true; + bool _traced=false; ///< true if a glyph of the current font has already been traced? }; #endif diff --git a/dviware/dvisvgm/src/GraphicsPath.hpp b/dviware/dvisvgm/src/GraphicsPath.hpp index 78b29d4630..bf09a37d09 100644 --- a/dviware/dvisvgm/src/GraphicsPath.hpp +++ b/dviware/dvisvgm/src/GraphicsPath.hpp @@ -22,6 +22,7 @@ #include <array> #include <cctype> +#include <cmath> #include <deque> #include <ostream> #include <type_traits> @@ -687,7 +688,7 @@ class GraphicsPath { * @param[in] actions template methods called by each iteration step * @param[in] optimize if true, shorthand drawing commands (hlineto, vlineto,...) are considered */ void iterate (IterationActions &actions, bool optimize) const { - double eps = XMLString::DECIMAL_PLACES > 0 ? pow(10, -XMLString::DECIMAL_PLACES) : 1e-7; + double eps = XMLString::DECIMAL_PLACES > 0 ? std::pow(10, -XMLString::DECIMAL_PLACES) : 1e-7; IterationVisitor visitor(actions, optimize, eps); for (const CommandVariant &cmd : _commands) { if (actions.quit()) diff --git a/dviware/dvisvgm/src/HtmlSpecialHandler.hpp b/dviware/dvisvgm/src/HtmlSpecialHandler.hpp index 0d4e3e4e11..bb85b2ad2c 100644 --- a/dviware/dvisvgm/src/HtmlSpecialHandler.hpp +++ b/dviware/dvisvgm/src/HtmlSpecialHandler.hpp @@ -29,7 +29,6 @@ class SpecialActions; class HtmlSpecialHandler : public SpecialHandler { public: - HtmlSpecialHandler () : _active(false) {} void preprocess (const std::string &prefix, std::istream &is, SpecialActions &actions) override; bool process (const std::string &prefix, std::istream &is, SpecialActions &actions) override; const char* name () const override {return "html";} @@ -41,7 +40,7 @@ class HtmlSpecialHandler : public SpecialHandler { void dviMovedTo (double x, double y, SpecialActions &actions) override; private: - bool _active; + bool _active=false; }; #endif diff --git a/dviware/dvisvgm/src/HyperlinkManager.hpp b/dviware/dvisvgm/src/HyperlinkManager.hpp index 7f5a460bdb..762b4a4cca 100644 --- a/dviware/dvisvgm/src/HyperlinkManager.hpp +++ b/dviware/dvisvgm/src/HyperlinkManager.hpp @@ -59,7 +59,7 @@ class HyperlinkManager { static void setDefaultLinkColor (Color color); protected: - HyperlinkManager () : _anchorType(AnchorType::NONE), _depthThreshold(0), _linewidth(-1) {} + HyperlinkManager () =default; void markLinkedBox (SpecialActions &actions); enum class MarkerType {NONE, LINE, BOX, BGCOLOR}; @@ -69,9 +69,9 @@ class HyperlinkManager { static ColorSource COLORSOURCE; ///< if true, LINK_LINECOLOR is applied private: - AnchorType _anchorType; ///< type of active anchor - int _depthThreshold; ///< break anchor box if the DVI stack depth underruns this threshold - double _linewidth; ///< line width of link marker (-1 => compute individual value per link) + AnchorType _anchorType=AnchorType::NONE; ///< type of active anchor + int _depthThreshold=0; ///< break anchor box if the DVI stack depth underruns this threshold + double _linewidth=-1; ///< line width of link marker (-1 => compute individual value per link) std::string _base; ///< base URL that is prepended to all relative targets NamedAnchors _namedAnchors; ///< information about all named anchors processed }; diff --git a/dviware/dvisvgm/src/Length.hpp b/dviware/dvisvgm/src/Length.hpp index 4454eec168..3c4de91fae 100644 --- a/dviware/dvisvgm/src/Length.hpp +++ b/dviware/dvisvgm/src/Length.hpp @@ -39,7 +39,7 @@ class Length { enum class Unit {PT, BP, CM, MM, IN, PC, DD, CC, SP}; public: - constexpr Length () : _pt(0) {} + constexpr Length () =default; explicit constexpr Length (long double pt) : _pt(static_cast<double>(pt)) {} Length (double val, Unit unit) {set(val, unit);} Length (double val, const std::string &unitstr) {set(val, unitstr);} @@ -76,7 +76,7 @@ class Length { static constexpr double pt2sp = 65536.0; private: - double _pt; // length in TeX point units (72.27pt = 1in) + double _pt=0; // length in TeX point units (72.27pt = 1in) }; diff --git a/dviware/dvisvgm/src/MetafontWrapper.cpp b/dviware/dvisvgm/src/MetafontWrapper.cpp index 5807d7254e..202b65d6ec 100644 --- a/dviware/dvisvgm/src/MetafontWrapper.cpp +++ b/dviware/dvisvgm/src/MetafontWrapper.cpp @@ -53,19 +53,19 @@ bool MetafontWrapper::call (const string &mode, double mag) { return false; // mf file not available => no need to call the "slow" Metafont FileSystem::remove(_fontname+".gf"); -#ifdef _WIN32 -#ifdef TEXLIVEWIN32 - const char *mfname = "mf-nowin.exe"; -#else - const char *mfname = "mf.exe"; + string mfName = "mf"; // file name of Metafont executable +#ifndef MIKTEX + if (const char *mfnowinPath = FileFinder::instance().lookupExecutable("mf-nowin", true)) + mfName = mfnowinPath; + else #endif - const char *cmd = FileFinder::instance().lookup(mfname, false); - if (!cmd) { - Message::estream(true) << "can't run Metafont (" << mfname << " not found)\n"; - return false; - } -#else - const char *cmd = "mf"; + if (const char *mfPath = FileFinder::instance().lookupExecutable(mfName, true)) + mfName = mfPath; +#ifdef _WIN32 + else { + Message::estream(true) << "can't run Metafont (mf.exe and mf-nowin.exe not found)\n"; + return false; + } #endif ostringstream oss; oss << "\"\\mode=" << mode << ";" // set MF mode, e.g. 'proof', 'ljfour' or 'localfont' @@ -75,7 +75,7 @@ bool MetafontWrapper::call (const string &mode, double mag) { "batchmode;" // don't halt on errors and don't print informational messages "input " << _fontname << "\""; // load font description Message::mstream(false, Message::MC_STATE) << "\nrunning Metafont for " << _fontname << '\n'; - Process mf_process(cmd, oss.str()); + Process mf_process(mfName, oss.str()); string mf_messages; mf_process.run(_dir, &mf_messages); diff --git a/dviware/dvisvgm/src/MiKTeXCom.cpp b/dviware/dvisvgm/src/MiKTeXCom.cpp index 72c2af7f0e..957173f126 100644 --- a/dviware/dvisvgm/src/MiKTeXCom.cpp +++ b/dviware/dvisvgm/src/MiKTeXCom.cpp @@ -92,8 +92,7 @@ const char* MiKTeXCom::findFile (const char *fname) { _bstr_t path; static string ret; #ifdef _MSC_VER - HRESULT hres = _session->FindFile(fname, path.GetAddress()); - bool found = (hres != 0); + bool found = (_session->FindFile(fname, path.GetAddress()) == VARIANT_TRUE); #else VARIANT_BOOL found_var; _session->FindFile(_bstr_t(fname), path.GetAddress(), &found_var); diff --git a/dviware/dvisvgm/src/NoPsSpecialHandler.hpp b/dviware/dvisvgm/src/NoPsSpecialHandler.hpp index f4f0421885..027ea3fb62 100644 --- a/dviware/dvisvgm/src/NoPsSpecialHandler.hpp +++ b/dviware/dvisvgm/src/NoPsSpecialHandler.hpp @@ -25,7 +25,6 @@ class NoPsSpecialHandler : public SpecialHandler { public: - NoPsSpecialHandler () : _count(0) {} bool process (const std::string &prefix, std::istream &is, SpecialActions &actions) override; const char* name () const override {return nullptr;} const char* info () const override {return nullptr;} @@ -35,7 +34,7 @@ class NoPsSpecialHandler : public SpecialHandler { void dviEndPage (unsigned pageno, SpecialActions &actions) override; private: - unsigned _count; // number of PS specials skipped + size_t _count=0; // number of PS specials skipped }; #endif diff --git a/dviware/dvisvgm/src/PSInterpreter.cpp b/dviware/dvisvgm/src/PSInterpreter.cpp index aa9cab2107..4b1d1fbc15 100644 --- a/dviware/dvisvgm/src/PSInterpreter.cpp +++ b/dviware/dvisvgm/src/PSInterpreter.cpp @@ -24,6 +24,7 @@ #include <sstream> #include <unordered_map> #include "FileFinder.hpp" +#include "FileSystem.hpp" #include "InputReader.hpp" #include "Message.hpp" #include "PSFilter.hpp" @@ -352,7 +353,7 @@ int GSDLLCALL PSInterpreter::error (void *inst, const char *buf, int len) { /** Returns the total number of pages of a PDF file. * @param[in] fname name/path of the PDF file */ int PSInterpreter::pdfPageCount (const string &fname) { - executeRaw("\n("+fname+")@pdfpagecount ", 1); + executeRaw("\n("+FileSystem::ensureForwardSlashes(fname)+")@pdfpagecount ", 1); if (!_rawData.empty()) { size_t index; int ret = stoi(_rawData[0], &index, 10); @@ -370,7 +371,7 @@ int PSInterpreter::pdfPageCount (const string &fname) { * @return the bounding box of the given page */ BoundingBox PSInterpreter::pdfPageBox (const string &fname, int pageno) { BoundingBox pagebox; - executeRaw("\n"+to_string(pageno)+"("+fname+")@pdfpagebox ", 4); + executeRaw("\n"+to_string(pageno)+"("+FileSystem::ensureForwardSlashes(fname)+")@pdfpagebox ", 4); if (_rawData.size() < 4) pagebox.invalidate(); else diff --git a/dviware/dvisvgm/src/PSPreviewFilter.cpp b/dviware/dvisvgm/src/PSPreviewFilter.cpp index 36f0303e0f..6dac4945a8 100644 --- a/dviware/dvisvgm/src/PSPreviewFilter.cpp +++ b/dviware/dvisvgm/src/PSPreviewFilter.cpp @@ -28,12 +28,6 @@ using namespace std; -PSPreviewFilter::PSPreviewFilter (PSInterpreter &psi) - : PSFilter(psi), _active(false), _tightpage(false), _dvi2bp(1.0/65536.0) -{ -} - - /** Activates this filter so that the PS code will be redirected through it if * it's hooked into the PSInterpreter. */ void PSPreviewFilter::activate () { diff --git a/dviware/dvisvgm/src/PSPreviewFilter.hpp b/dviware/dvisvgm/src/PSPreviewFilter.hpp index 7de5a2e2a8..630a277b16 100644 --- a/dviware/dvisvgm/src/PSPreviewFilter.hpp +++ b/dviware/dvisvgm/src/PSPreviewFilter.hpp @@ -30,7 +30,7 @@ class SpecialActions; class PSPreviewFilter : public PSFilter { public: - explicit PSPreviewFilter (PSInterpreter &psi); + explicit PSPreviewFilter (PSInterpreter &psi) : PSFilter(psi) {} void activate (); void execute (const char *code, size_t len) override; bool active () const override {return _active;} @@ -44,11 +44,11 @@ class PSPreviewFilter : public PSFilter { double width () const; private: - std::string _version; ///< version string of preview package - bool _active; ///< true if filter is active - bool _tightpage; ///< true if tightpage option was given - double _dvi2bp; ///< factor to convert dvi units to PS points - std::vector<int> _boxExtents; ///< bounding box data set by the preview package (in DVI units) + std::string _version; ///< version string of preview package + bool _active=false; ///< true if filter is active + bool _tightpage=false; ///< true if tightpage option was given + double _dvi2bp=1.0/65536.0; ///< factor to convert dvi units to PS points + std::vector<int> _boxExtents; ///< bounding box data set by the preview package (in DVI units) }; #endif diff --git a/dviware/dvisvgm/src/PathClipper.hpp b/dviware/dvisvgm/src/PathClipper.hpp index 09c904bfd4..fb375db35f 100644 --- a/dviware/dvisvgm/src/PathClipper.hpp +++ b/dviware/dvisvgm/src/PathClipper.hpp @@ -31,25 +31,22 @@ using ClipperLib::IntPoint; -class PathClipper -{ +class PathClipper { public: using CurvedPath = GraphicsPath<double>; public: - PathClipper () : _numLines(0) {} void intersect (const CurvedPath &p1, const CurvedPath &p2, CurvedPath &result); protected: void flatten (const CurvedPath &gp, ClipperLib::Paths &polygons); -// void divide (IntPoint &p1, IntPoint &p2, IntPoint &ip); void reconstruct (const ClipperLib::Path &polygon, CurvedPath &path); void reconstruct (const ClipperLib::Paths &polygons, CurvedPath &path); static void callback (IntPoint &e1bot, IntPoint &e1top, IntPoint &e2bot, IntPoint &e2top, IntPoint &ip); private: std::vector<Bezier> _curves; - int _numLines; ///< negative number of straight line segments in path been processed + int _numLines=0; ///< negative number of straight line segments in path been processed }; #endif diff --git a/dviware/dvisvgm/src/PreScanDVIReader.cpp b/dviware/dvisvgm/src/PreScanDVIReader.cpp index 415eadbb73..7c964fae86 100644 --- a/dviware/dvisvgm/src/PreScanDVIReader.cpp +++ b/dviware/dvisvgm/src/PreScanDVIReader.cpp @@ -25,7 +25,7 @@ using namespace std; PreScanDVIReader::PreScanDVIReader (std::istream &is, DVIActions *actions) - : BasicDVIReader(is), _actions(actions), _currentPageNumber(0) + : BasicDVIReader(is), _actions(actions) { } diff --git a/dviware/dvisvgm/src/PreScanDVIReader.hpp b/dviware/dvisvgm/src/PreScanDVIReader.hpp index 614beac66e..5176f5a1f3 100644 --- a/dviware/dvisvgm/src/PreScanDVIReader.hpp +++ b/dviware/dvisvgm/src/PreScanDVIReader.hpp @@ -25,8 +25,7 @@ struct DVIActions; -class PreScanDVIReader : public BasicDVIReader -{ +class PreScanDVIReader : public BasicDVIReader { public: PreScanDVIReader (std::istream &is, DVIActions *actions); unsigned currentPageNumber () const override {return _currentPageNumber;} @@ -37,7 +36,7 @@ class PreScanDVIReader : public BasicDVIReader private: DVIActions *_actions; - unsigned _currentPageNumber; + unsigned _currentPageNumber=0; }; #endif diff --git a/dviware/dvisvgm/src/Process.cpp b/dviware/dvisvgm/src/Process.cpp index ff73cb5336..de5394f1fd 100644 --- a/dviware/dvisvgm/src/Process.cpp +++ b/dviware/dvisvgm/src/Process.cpp @@ -22,6 +22,7 @@ #include "windows.hpp" #else #include <csignal> + #include <cstring> #include <fcntl.h> #include <sys/wait.h> #include <unistd.h> @@ -42,7 +43,7 @@ class Subprocess { enum class State {RUNNING, FINISHED, FAILED}; public: - Subprocess (); + Subprocess () =default; Subprocess (const Subprocess&) =delete; Subprocess (Subprocess&&) =delete; ~Subprocess (); @@ -52,11 +53,11 @@ class Subprocess { private: #ifdef _WIN32 - HANDLE _pipeReadHandle; ///< handle of read end of pipe - HANDLE _childProcHandle; ///< handle of child process + HANDLE _pipeReadHandle=NULL; ///< handle of read end of pipe + HANDLE _childProcHandle=NULL; ///< handle of child process #else - int _readfd; ///< file descriptor of read end of pipe - pid_t _pid; ///< PID of the subprocess + int _readfd=-1; ///< file descriptor of read end of pipe + pid_t _pid=-1; ///< PID of the subprocess #endif }; @@ -113,10 +114,6 @@ static inline void close_and_zero_handle (HANDLE &handle) { } -Subprocess::Subprocess() : _pipeReadHandle(NULL), _childProcHandle(NULL) { -} - - Subprocess::~Subprocess () { if (_pipeReadHandle != NULL) CloseHandle(_pipeReadHandle); @@ -214,10 +211,6 @@ Subprocess::State Subprocess::state () { #else // !_WIN32 -Subprocess::Subprocess () : _readfd(-1), _pid(-1) { -} - - Subprocess::~Subprocess () { if (_readfd >= 0) close(_readfd); @@ -276,12 +269,12 @@ static void split_paramstr (string ¶mstr, vector<const char*> ¶ms) { /** Starts a child process. - * @param[in] cmd name of command to execute - * @param[in] paramstr parameters required by command + * @param[in] cmd name of command to execute or absolute path to executable + * @param[in] paramstr parameters required by the command * @returns true if child process started properly */ bool Subprocess::run (const string &cmd, string paramstr) { int pipefd[2]; - if (pipe(pipefd) < 0) + if (cmd.empty() || pipe(pipefd) < 0) return false; _pid = fork(); @@ -299,9 +292,11 @@ bool Subprocess::run (const string &cmd, string paramstr) { vector<const char*> params; params.push_back(cmd.c_str()); split_paramstr(paramstr, params); - params.push_back(nullptr); // trailing null pointer marks end of parameter list - signal(SIGINT, SIG_IGN); // child process is supposed to ignore ctrl-c events - execvp(cmd.c_str(), const_cast<char* const*>(¶ms[0])); + params.push_back(nullptr); // trailing null pointer marks end of parameter list + signal(SIGINT, SIG_IGN); // child process is supposed to ignore ctrl-c events + if (params[0][0] == '/') // absolute path to executable? + params[0] = strrchr(params[0], '/')+1; // filename of executable + execvp(cmd.c_str(), const_cast<char* const*>(params.data())); exit(1); } _readfd = pipefd[0]; diff --git a/dviware/dvisvgm/src/PsSpecialHandler.cpp b/dviware/dvisvgm/src/PsSpecialHandler.cpp index 405da48434..31f8aa55e7 100644 --- a/dviware/dvisvgm/src/PsSpecialHandler.cpp +++ b/dviware/dvisvgm/src/PsSpecialHandler.cpp @@ -214,7 +214,7 @@ bool PsSpecialHandler::process (const string &prefix, istream &is, SpecialAction if (_actions) { StreamInputReader in(is); string fname = in.getQuotedString(in.peek() == '"' ? "\"" : nullptr); - fname = FileSystem::adaptPathSeperators(fname); + fname = FileSystem::ensureForwardSlashes(fname); FileType fileType = FileType::EPS; if (prefix == "pdffile") fileType = FileType::PDF; @@ -392,7 +392,7 @@ unique_ptr<XMLElement> PsSpecialHandler::createImageNode (FileType type, const s unique_ptr<XMLElement> node; string pathstr; if (const char *path = FileFinder::instance().lookup(fname, false)) - pathstr = FileSystem::adaptPathSeperators(path); + pathstr = FileSystem::ensureForwardSlashes(path); if ((pathstr.empty() || !FileSystem::exists(pathstr)) && FileSystem::exists(fname)) pathstr = fname; if (pathstr.empty()) diff --git a/dviware/dvisvgm/src/PsSpecialHandler.hpp b/dviware/dvisvgm/src/PsSpecialHandler.hpp index c7a8a97815..6251e20a47 100644 --- a/dviware/dvisvgm/src/PsSpecialHandler.hpp +++ b/dviware/dvisvgm/src/PsSpecialHandler.hpp @@ -46,7 +46,6 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions { * clipping paths and compute their intersections locally if necessary. */ class ClippingStack { public: - ClippingStack () : _maxID(0) {} void pushEmptyPath (); void push (const Path &path, int saveID=-1); bool replace (const Path &path); @@ -72,7 +71,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions { Entry (const Entry &entry) =default; Entry (Entry &&entry) =default; }; - size_t _maxID; + size_t _maxID=0; std::stack<Entry> _stack; ///< stack holding the clipping information of the current graphics context }; diff --git a/dviware/dvisvgm/src/RangeMap.hpp b/dviware/dvisvgm/src/RangeMap.hpp index 128d37c038..9d3f2c2d95 100644 --- a/dviware/dvisvgm/src/RangeMap.hpp +++ b/dviware/dvisvgm/src/RangeMap.hpp @@ -30,7 +30,7 @@ class RangeMap { class Range { friend class RangeMap; public: - Range () : _min(0), _max(0), _minval(0) {} + Range () =default; Range (uint32_t min, uint32_t max, uint32_t minval) : _min(min), _max(max), _minval(minval) { if (_min > _max) @@ -53,8 +53,8 @@ class RangeMap { bool join (const Range &r); private: - uint32_t _min, _max; - uint32_t _minval; + uint32_t _min=0, _max=0; + uint32_t _minval=0; }; using Ranges = std::vector<Range>; diff --git a/dviware/dvisvgm/src/SVGOutput.cpp b/dviware/dvisvgm/src/SVGOutput.cpp index 7c4108c876..1f9e244883 100644 --- a/dviware/dvisvgm/src/SVGOutput.cpp +++ b/dviware/dvisvgm/src/SVGOutput.cpp @@ -35,7 +35,7 @@ using namespace std; SVGOutput::SVGOutput (const string &base, string pattern, int zipLevel) - : _path(base), _pattern(std::move(pattern)), _stdout(base.empty()), _zipLevel(zipLevel), _page(-1) + : _path(base), _pattern(std::move(pattern)), _stdout(base.empty()), _zipLevel(zipLevel) { } diff --git a/dviware/dvisvgm/src/SVGOutput.hpp b/dviware/dvisvgm/src/SVGOutput.hpp index 3c382f0b7f..1f4da20ee8 100644 --- a/dviware/dvisvgm/src/SVGOutput.hpp +++ b/dviware/dvisvgm/src/SVGOutput.hpp @@ -53,7 +53,7 @@ struct SVGOutputBase { class SVGOutput : public SVGOutputBase { public: - SVGOutput () : SVGOutput("", "", 0) {} + SVGOutput () =default; explicit SVGOutput (const std::string &base) : SVGOutput(base, "", 0) {} SVGOutput (const std::string &base, const std::string &pattern) : SVGOutput(base, pattern, 0) {} SVGOutput (const std::string &base, std::string pattern, int zipLevel); @@ -67,9 +67,9 @@ class SVGOutput : public SVGOutputBase { private: FilePath _path; std::string _pattern; - bool _stdout; ///< write to STDOUT? - int _zipLevel; ///< compression level - mutable int _page; ///< number of current page being written + bool _stdout=true; ///< write to STDOUT? + int _zipLevel=0; ///< compression level + mutable int _page=-1; ///< number of current page being written mutable std::unique_ptr<std::ostream> _osptr; }; diff --git a/dviware/dvisvgm/src/SignalHandler.cpp b/dviware/dvisvgm/src/SignalHandler.cpp index 886c9281bb..5af70be2e4 100644 --- a/dviware/dvisvgm/src/SignalHandler.cpp +++ b/dviware/dvisvgm/src/SignalHandler.cpp @@ -49,7 +49,7 @@ class SignalHandler::Impl { SignalHandler::SignalHandler () - : _active(false), _impl(util::make_unique<SignalHandler::Impl>()) + : _impl(util::make_unique<SignalHandler::Impl>()) { } @@ -89,7 +89,7 @@ void SignalHandler::stop () { /** Checks for incoming signals and throws an exception if CTRL-C was caught. * @throw SignalException */ -void SignalHandler::check() { +void SignalHandler::check () { if (_break) throw SignalException(); } diff --git a/dviware/dvisvgm/src/SignalHandler.hpp b/dviware/dvisvgm/src/SignalHandler.hpp index 827f9e0962..b97449399e 100644 --- a/dviware/dvisvgm/src/SignalHandler.hpp +++ b/dviware/dvisvgm/src/SignalHandler.hpp @@ -45,7 +45,7 @@ class SignalHandler { static void callback (int signal); private: - bool _active; ///< true if listening for signals + bool _active=false; ///< true if listening for signals static volatile bool _break; ///< true if signal has been caught class Impl; std::unique_ptr<Impl> _impl; ///< system-specific data/functions diff --git a/dviware/dvisvgm/src/TFM.hpp b/dviware/dvisvgm/src/TFM.hpp index 668ff39083..f2fd3027eb 100644 --- a/dviware/dvisvgm/src/TFM.hpp +++ b/dviware/dvisvgm/src/TFM.hpp @@ -30,8 +30,7 @@ class StreamReader; -class TFM : public FontMetrics -{ +class TFM : public FontMetrics { public: explicit TFM (std::istream &is); double getCharWidth (int c) const override; @@ -51,7 +50,7 @@ class TFM : public FontMetrics uint16_t lastChar () const override {return _lastChar;} protected: - TFM () : _checksum(0), _firstChar(0), _lastChar(0), _designSize(0), _params(7) {} + TFM () : _params(7) {} void readHeader (StreamReader &reader); void readTables (StreamReader &reader, int nw, int nh, int nd, int ni); void readParameters (StreamReader &reader, int np); @@ -59,9 +58,9 @@ class TFM : public FontMetrics void setCharRange (int firstchar, int lastchar) {_firstChar=firstchar; _lastChar=lastchar;} private: - uint32_t _checksum; - uint16_t _firstChar, _lastChar; - double _designSize; ///< design size of the font in PS points (72bp = 1in) + uint32_t _checksum=0; + uint16_t _firstChar=0, _lastChar=0; + double _designSize=0; ///< design size of the font in PS points (72bp = 1in) std::vector<uint32_t> _charInfoTable; std::vector<FixWord> _widthTable; ///< character widths in design size units std::vector<FixWord> _heightTable; ///< character height in design size units diff --git a/dviware/dvisvgm/src/VFReader.cpp b/dviware/dvisvgm/src/VFReader.cpp index cff67c919c..47f5e3f7b6 100644 --- a/dviware/dvisvgm/src/VFReader.cpp +++ b/dviware/dvisvgm/src/VFReader.cpp @@ -28,11 +28,6 @@ using namespace std; -VFReader::VFReader (istream &is) : StreamReader(is) -{ -} - - VFActions* VFReader::replaceActions (VFActions *a) { VFActions *ret = _actions; _actions = a; diff --git a/dviware/dvisvgm/src/VFReader.hpp b/dviware/dvisvgm/src/VFReader.hpp index 8ddba805e8..bd42289039 100644 --- a/dviware/dvisvgm/src/VFReader.hpp +++ b/dviware/dvisvgm/src/VFReader.hpp @@ -31,10 +31,10 @@ struct VFException : public MessageException { struct VFActions; -class VFReader : public StreamReader{ +class VFReader : public StreamReader { using ApproveAction = bool (*)(int); public: - explicit VFReader (std::istream &is); + explicit VFReader (std::istream &is) : StreamReader(is) {} VFActions* replaceActions (VFActions *a); bool executeAll (); bool executePreambleAndFontDefs (); diff --git a/dviware/dvisvgm/src/VectorStream.hpp b/dviware/dvisvgm/src/VectorStream.hpp index c74388e076..9672e67435 100644 --- a/dviware/dvisvgm/src/VectorStream.hpp +++ b/dviware/dvisvgm/src/VectorStream.hpp @@ -28,9 +28,7 @@ template <typename T> class VectorStreamBuffer : public std::streambuf { public: explicit VectorStreamBuffer (const std::vector<T> &v) { - if (v.empty()) - _begin = _end = _curr = nullptr; - else { + if (!v.empty()) { _begin = _curr = &v[0]; _end = &v[0]+v.size(); } @@ -68,9 +66,9 @@ class VectorStreamBuffer : public std::streambuf { } private: - const T *_begin; - const T *_end; - const T *_curr; + const T *_begin=nullptr; + const T *_end=nullptr; + const T *_curr=nullptr; }; diff --git a/dviware/dvisvgm/src/dvisvgm.cpp b/dviware/dvisvgm/src/dvisvgm.cpp index 37584d5ddb..5828299fce 100644 --- a/dviware/dvisvgm/src/dvisvgm.cpp +++ b/dviware/dvisvgm/src/dvisvgm.cpp @@ -64,7 +64,7 @@ using namespace std; //////////////////////////////////////////////////////////////////////////////// static string remove_path (string fname) { - fname = FileSystem::adaptPathSeperators(fname); + fname = FileSystem::ensureForwardSlashes(fname); size_t slashpos = fname.rfind('/'); if (slashpos == string::npos) return fname; diff --git a/dviware/dvisvgm/src/psdefs.cpp b/dviware/dvisvgm/src/psdefs.cpp index d38e2354e0..04abb6227d 100644 --- a/dviware/dvisvgm/src/psdefs.cpp +++ b/dviware/dvisvgm/src/psdefs.cpp @@ -22,103 +22,104 @@ const char *PSInterpreter::PSDEFS = "<</Install{matrix setmatrix}/HWResolution[72 72]/PageSize[10000 10000]/Imaging" -"BBox null>>setpagedevice/@dodraw true store/@nulldev false store/@patcnt 0 sto" -"re/@SD systemdict def/@UD userdict def true setglobal @SD/:save @SD/save get p" -"ut @SD/:restore @SD/restore get put @SD/:gsave @SD/gsave get put @SD/:grestore" -" @SD/grestore get put @SD/:grestoreall @SD/grestoreall get put @SD/:newpath @S" -"D/newpath get put @SD/:stroke @SD/stroke get put @SD/:fill @SD/fill get put @S" -"D/:eofill @SD/eofill get put @SD/:clip @SD/clip get put @SD/:eoclip @SD/eoclip" -" get put @SD/:charpath @SD/charpath get put @SD/:show @SD/show get put @SD/:st" -"ringwidth @SD/stringwidth get put @SD/:nulldevice @SD/nulldevice get put @SD/." -"setopacityalpha known not{@SD/.setopacityalpha{pop}put}if @SD/.setshapealpha k" -"nown not{@SD/.setshapealpha{pop}put}if @SD/.setblendmode known not{@SD/.setble" -"ndmode{pop}put}if @SD/prseq{-1 1{-1 roll =only( )print}for(\\n)print}put @SD/p" -"rcmd{( )exch(\\ndvi.)3{print}repeat prseq}put @SD/cvxall{{cvx}forall}put @SD/d" -"efpr{[exch[/copy @SD]cvxall 5 -1 roll dup 6 1 roll[/get/exec]cvxall 6 -1 roll " -"dup 7 1 roll 4 -1 roll dup 5 1 roll dup length string cvs/prcmd cvx]cvx def}pu" -"t @SD/querypos{{currentpoint}stopped{$error/newerror false put}{2(querypos)prc" -"md}ifelse}put @SD/applyscalevals{1 0 dtransform exch dup mul exch dup mul add " -"sqrt 0 1 dtransform exch dup mul exch dup mul add sqrt 1 0 dtransform dup mul " -"exch dup dup mul 3 -1 roll add dup 0 eq{pop}{sqrt div}ifelse 3(applyscalevals)" -"prcmd}put @SD/prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(curveto)prcmd}{0(close" -"path)prcmd}pathforall}put @SD/nulldevice{/@nulldev true store :nulldevice 1 1(" -"setnulldevice)prcmd}put @SD/charpath{/@dodraw false store :charpath/@dodraw tr" -"ue store}put @SD/stringwidth{/@dodraw false store :stringwidth/@dodraw true st" -"ore}put @SD/show{@dodraw @nulldev not and{dup :gsave currentpoint 2{50 mul exc" -"h}repeat :newpath moveto 50 50/scale sysexec true charpath fill :grestore/@dod" -"raw false store :show/@dodraw true store}{:show}ifelse}put @SD/varxyshow{exch " -"dup type/arraytype eq{<</arr 3 -1 roll/prc 5 -1 roll/chr 1 string/idx 0>>begin" -"{chr 0 3 -1 roll put :gsave chr show :grestore currentpoint prc moveto/idx idx" -" 1 add store}forall end}{pop show}ifelse}put @SD/xyshow{{exch arr idx 2 mul ge" -"t add exch arr idx 2 mul 1 add get add}varxyshow}put @SD/xshow{{exch arr idx g" -"et add exch}varxyshow}put @SD/yshow{{arr idx get add}varxyshow}put @SD/awidths" -"how{{1 string dup 0 5 index put :gsave show :grestore pop 0 rmoveto 3 index eq" -"{4 index 4 index rmoveto}if 1 index 1 index rmoveto}exch cshow 5{pop}repeat}pu" -"t @SD/widthshow{0 0 3 -1 roll pstack awidthshow}put @SD/ashow{0 0 0 6 3 roll a" -"widthshow}put @SD/newpath{:newpath 1 1(newpath)prcmd}put @SD/stroke{@dodraw @n" -"ulldev not and{prcolor 0 1(newpath)prcmd prpath 0(stroke)prcmd :newpath}{:stro" -"ke}ifelse}put @SD/fill{@dodraw @nulldev not and{prcolor 0 1(newpath)prcmd prpa" -"th 0(fill)prcmd :newpath}{:fill}ifelse}put @SD/eofill{@dodraw @nulldev not and" -"{prcolor 0 1(newpath)prcmd prpath 0(eofill)prcmd :newpath}{:eofill}ifelse}put " -"@SD/clip{:clip @nulldev not{0 1(newpath)prcmd prpath 0(clip)prcmd}if}put @SD/e" -"oclip{:eoclip @nulldev not{0 1(newpath)prcmd prpath 0(eoclip)prcmd}}put @SD/sh" -"fill{begin currentdict/ShadingType known currentdict/ColorSpace known and curr" -"entdict/DataSource known and currentdict/Function known not and ShadingType 4 " -"ge and DataSource type/arraytype eq and{<</DeviceGray 1/DeviceRGB 3/DeviceCMYK" -" 4/bgknown currentdict/Background known/bbknown currentdict/BBox known>>begin " -"currentdict ColorSpace known{ShadingType ColorSpace load bgknown{1 Background " -"aload pop}{0}ifelse bbknown{1 BBox aload pop}{0}ifelse ShadingType 5 eq{Vertic" -"esPerRow}if DataSource aload length 4 add bgknown{ColorSpace load add}if bbkno" -"wn{4 add}if ShadingType 5 eq{1 add}if(shfill)prcmd}if end}if end}put/@rect{4 -" -"2 roll moveto exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}b" -"ind def/@rectcc{4 -2 roll moveto 2 copy 0 lt exch 0 lt xor{dup 0 exch rlineto " -"exch 0 rlineto neg 0 exch rlineto}{exch dup 0 rlineto exch 0 exch rlineto neg " -"0 rlineto}ifelse closepath}bind def @SD/rectclip{:newpath dup type/arraytype e" -"q{aload length 4 idiv{@rectcc}repeat}{@rectcc}ifelse clip :newpath}put @SD/rec" -"tfill{gsave :newpath dup type/arraytype eq{aload length 4 idiv{@rectcc}repeat}" -"{@rectcc}ifelse fill grestore}put @SD/rectstroke{gsave :newpath dup type/array" -"type eq{aload length 4 idiv{@rect}repeat}{@rect}ifelse stroke grestore}put fal" -"se setglobal @SD readonly pop/initclip 0 defpr/clippath 0 defpr/sysexec{@SD ex" -"ch get exec}def/adddot{dup length 1 add string dup 0 46 put dup 3 -1 roll 1 ex" -"ch putinterval}def/setlinewidth{dup/setlinewidth sysexec 1(setlinewidth)prcmd}" -"def/setlinecap 1 defpr/setlinejoin 1 defpr/setmiterlimit 1 defpr/setdash{mark " -"3 1 roll 2 copy/setdash sysexec exch aload length 1 add -1 roll counttomark(se" -"tdash)prcmd pop}def/@setpagedevice{pop<<>>/setpagedevice sysexec matrix setmat" -"rix newpath 0(setpagedevice)prcmd}def/@checknulldev{@nulldev{currentpagedevice" -" maxlength 0 ne{/@nulldev false store 0 1(setnulldevice)prcmd}if}if}def/prcolo" -"r{currentrgbcolor 3(setrgbcolor)prcmd}def/printgstate{@dodraw @nulldev not and" -"{matrix currentmatrix aload pop 6(setmatrix)prcmd applyscalevals currentlinewi" -"dth 1(setlinewidth)prcmd currentlinecap 1(setlinecap)prcmd currentlinejoin 1(s" -"etlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd currentrgbcolor 3(set" -"rgbcolor)prcmd currentdash mark 3 1 roll exch aload length 1 add -1 roll count" -"tomark(setdash)prcmd pop}if}def/setgstate{/setgstate sysexec printgstate}def/s" -"ave{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)prcmd}def/" -"restore{:restore @checknulldev printgstate @UD/@saveID known{@UD begin @saveID" -" end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore @checknull" -"dev printgstate 0(grestore)prcmd}def/grestoreall{:grestoreall @checknulldev se" -"tstate 0(grestoreall)prcmd}def/rotate{dup type/arraytype ne @dodraw and{dup 1(" -"rotate)prcmd}if/rotate sysexec applyscalevals}def/scale{dup type/arraytype ne " -"@dodraw and{2 copy 2(scale)prcmd}if/scale sysexec applyscalevals}def/translate" -"{dup type/arraytype ne @dodraw and{2 copy 2(translate)prcmd}if/translate sysex" -"ec}def/setmatrix{dup/setmatrix sysexec @dodraw{aload pop 6(setmatrix)prcmd app" -"lyscalevals}{pop}ifelse}def/initmatrix{matrix setmatrix}def/concat{matrix curr" -"entmatrix matrix concatmatrix setmatrix}def/makepattern{gsave<</mx 3 -1 roll>>" -"begin dup/XUID[1000000 @patcnt]put mx/makepattern sysexec dup dup begin Patter" -"nType @patcnt BBox aload pop XStep YStep PaintType mx aload pop 15(makepattern" -")prcmd :newpath matrix setmatrix PaintProc 0 1(makepattern)prcmd end/@patcnt @" -"patcnt 1 add store end grestore}def/setpattern{begin PatternType 1 eq{PaintTyp" -"e 1 eq{XUID aload pop exch pop 1}{:gsave[currentcolorspace aload length -1 rol" -"l pop]setcolorspace/setcolor sysexec XUID aload pop exch pop currentrgbcolor :" -"grestore 4}ifelse(setpattern)prcmd}{/setpattern sysexec}ifelse end}def/setcolo" -"r{dup type/dicttype eq{setpattern}{/setcolor sysexec/currentrgbcolor sysexec s" -"etrgbcolor}ifelse}def/setgray 1 defpr/setcmykcolor 4 defpr/sethsbcolor 3 defpr" -"/setrgbcolor 3 defpr/.setopacityalpha{dup/.setopacityalpha sysexec 1(setopacit" -"yalpha)prcmd}def/.setshapealpha{dup/.setshapealpha sysexec 1(setshapealpha)prc" -"md}def/.setblendmode{dup/.setblendmode sysexec<</Normal 0/Compatible 0/Multipl" -"y 1/Screen 2/Overlay 3/SoftLight 4/HardLight 5/ColorDodge 6/ColorBurn 7/Darken" -" 8/Lighten 9/Difference 10/Exclusion 11/Hue 12/Saturation 13/Color 14/Luminosi" -"ty 15/CompatibleOverprint 16>>exch get 1(setblendmode)prcmd}def/@pdfpagecount{" -"(r)file runpdfbegin pdfpagecount runpdfend}def/@pdfpagebox{(r)file runpdfbegin" -" dup dup 1 lt exch pdfpagecount gt or{pop}{pdfgetpage/MediaBox pget pop aload " -"pop}ifelse runpdfend}def DELAYBIND{.bindnow}if "; +"BBox null>>setpagedevice/@dodraw true store/@patcnt 0 store/@GD globaldict def" +"/@SD systemdict def/@UD userdict def @GD/@nulldev false put true setglobal @SD" +"/:save @SD/save get put @SD/:restore @SD/restore get put @SD/:gsave @SD/gsave " +"get put @SD/:grestore @SD/grestore get put @SD/:grestoreall @SD/grestoreall ge" +"t put @SD/:newpath @SD/newpath get put @SD/:stroke @SD/stroke get put @SD/:fil" +"l @SD/fill get put @SD/:eofill @SD/eofill get put @SD/:clip @SD/clip get put @" +"SD/:eoclip @SD/eoclip get put @SD/:charpath @SD/charpath get put @SD/:show @SD" +"/show get put @SD/:stringwidth @SD/stringwidth get put @SD/:nulldevice @SD/nul" +"ldevice get put @SD/.setopacityalpha known not{@SD/.setopacityalpha{pop}put}if" +" @SD/.setshapealpha known not{@SD/.setshapealpha{pop}put}if @SD/.setblendmode " +"known not{@SD/.setblendmode{pop}put}if @SD/prseq{-1 1{-1 roll =only( )print}fo" +"r(\\n)print}put @SD/prcmd{( )exch(\\ndvi.)3{print}repeat prseq}put @SD/cvxall{" +"{cvx}forall}put @SD/defpr{[exch[/copy @SD]cvxall 5 -1 roll dup 6 1 roll[/get/e" +"xec]cvxall 6 -1 roll dup 7 1 roll 4 -1 roll dup 5 1 roll dup length string cvs" +"/prcmd cvx]cvx def}put @SD/querypos{{currentpoint}stopped{$error/newerror fals" +"e put}{2(querypos)prcmd}ifelse}put @SD/applyscalevals{1 0 dtransform exch dup " +"mul exch dup mul add sqrt 0 1 dtransform exch dup mul exch dup mul add sqrt 1 " +"0 dtransform dup mul exch dup dup mul 3 -1 roll add dup 0 eq{pop}{sqrt div}ife" +"lse 3(applyscalevals)prcmd}put @SD/prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(c" +"urveto)prcmd}{0(closepath)prcmd}pathforall}put @SD/nulldevice{@GD/@nulldev tru" +"e put :nulldevice 1 1(setnulldevice)prcmd}put @SD/charpath{/@dodraw false stor" +"e :charpath/@dodraw true store}put @SD/stringwidth{/@dodraw false store :strin" +"gwidth/@dodraw true store}put @SD/show{@dodraw @GD/@nulldev get not and{dup :g" +"save currentpoint 2{50 mul exch}repeat :newpath moveto 50 50/scale sysexec tru" +"e charpath fill :grestore/@dodraw false store :show/@dodraw true store}{:show}" +"ifelse}put @SD/varxyshow{exch dup type/arraytype eq{<</arr 3 -1 roll/prc 5 -1 " +"roll/chr 1 string/idx 0>>begin{chr 0 3 -1 roll put :gsave chr show :grestore c" +"urrentpoint prc moveto/idx idx 1 add store}forall end}{pop show}ifelse}put @SD" +"/xyshow{{exch arr idx 2 mul get add exch arr idx 2 mul 1 add get add}varxyshow" +"}put @SD/xshow{{exch arr idx get add exch}varxyshow}put @SD/yshow{{arr idx get" +" add}varxyshow}put @SD/awidthshow{{1 string dup 0 5 index put :gsave show :gre" +"store pop 0 rmoveto 3 index eq{4 index 4 index rmoveto}if 1 index 1 index rmov" +"eto}exch cshow 5{pop}repeat}put @SD/widthshow{0 0 3 -1 roll pstack awidthshow}" +"put @SD/ashow{0 0 0 6 3 roll awidthshow}put @SD/newpath{:newpath 1 1(newpath)p" +"rcmd}put @SD/stroke{@dodraw @GD/@nulldev get not and{prcolor 0 1(newpath)prcmd" +" prpath 0(stroke)prcmd :newpath}{:stroke}ifelse}put @SD/fill{@dodraw @GD/@null" +"dev get not and{prcolor 0 1(newpath)prcmd prpath 0(fill)prcmd :newpath}{:fill}" +"ifelse}put @SD/eofill{@dodraw @GD/@nulldev get not and{prcolor 0 1(newpath)prc" +"md prpath 0(eofill)prcmd :newpath}{:eofill}ifelse}put @SD/clip{:clip @GD/@null" +"dev get not{0 1(newpath)prcmd prpath 0(clip)prcmd}if}put @SD/eoclip{:eoclip @G" +"D/@nulldev get not{0 1(newpath)prcmd prpath 0(eoclip)prcmd}}put @SD/shfill{beg" +"in currentdict/ShadingType known currentdict/ColorSpace known and currentdict/" +"DataSource known and currentdict/Function known not and ShadingType 4 ge and D" +"ataSource type/arraytype eq and{<</DeviceGray 1/DeviceRGB 3/DeviceCMYK 4/bgkno" +"wn currentdict/Background known/bbknown currentdict/BBox known>>begin currentd" +"ict ColorSpace known{ShadingType ColorSpace load bgknown{1 Background aload po" +"p}{0}ifelse bbknown{1 BBox aload pop}{0}ifelse ShadingType 5 eq{VerticesPerRow" +"}if DataSource aload length 4 add bgknown{ColorSpace load add}if bbknown{4 add" +"}if ShadingType 5 eq{1 add}if(shfill)prcmd}if end}if end}put/@rect{4 -2 roll m" +"oveto exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def/" +"@rectcc{4 -2 roll moveto 2 copy 0 lt exch 0 lt xor{dup 0 exch rlineto exch 0 r" +"lineto neg 0 exch rlineto}{exch dup 0 rlineto exch 0 exch rlineto neg 0 rlinet" +"o}ifelse closepath}bind def @SD/rectclip{:newpath dup type/arraytype eq{aload " +"length 4 idiv{@rectcc}repeat}{@rectcc}ifelse clip :newpath}put @SD/rectfill{gs" +"ave :newpath dup type/arraytype eq{aload length 4 idiv{@rectcc}repeat}{@rectcc" +"}ifelse fill grestore}put @SD/rectstroke{gsave :newpath dup type/arraytype eq{" +"aload length 4 idiv{@rect}repeat}{@rect}ifelse stroke grestore}put false setgl" +"obal @SD readonly pop/initclip 0 defpr/clippath 0 defpr/sysexec{@SD exch get e" +"xec}def/adddot{dup length 1 add string dup 0 46 put dup 3 -1 roll 1 exch putin" +"terval}def/setlinewidth{dup/setlinewidth sysexec 1(setlinewidth)prcmd}def/setl" +"inecap 1 defpr/setlinejoin 1 defpr/setmiterlimit 1 defpr/setdash{mark 3 1 roll" +" 2 copy/setdash sysexec exch aload length 1 add -1 roll counttomark(setdash)pr" +"cmd pop}def/@setpagedevice{pop<<>>/setpagedevice sysexec matrix setmatrix newp" +"ath 0(setpagedevice)prcmd}def/@checknulldev{@GD/@nulldev get{currentpagedevice" +" maxlength 0 ne{@GD/@nulldev false put 0 1(setnulldevice)prcmd}if}if}def/prcol" +"or{currentrgbcolor 3(setrgbcolor)prcmd}def/printgstate{@dodraw @GD/@nulldev ge" +"t not and{matrix currentmatrix aload pop 6(setmatrix)prcmd applyscalevals curr" +"entlinewidth 1(setlinewidth)prcmd currentlinecap 1(setlinecap)prcmd currentlin" +"ejoin 1(setlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd currentrgbco" +"lor 3(setrgbcolor)prcmd currentdash mark 3 1 roll exch aload length 1 add -1 r" +"oll counttomark(setdash)prcmd pop}if}def/setgstate{/setgstate sysexec printgst" +"ate}def/save{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)p" +"rcmd}def/restore{:restore @checknulldev printgstate @UD/@saveID known{@UD begi" +"n @saveID end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore @" +"checknulldev printgstate 0(grestore)prcmd}def/grestoreall{:grestoreall @checkn" +"ulldev setstate 0(grestoreall)prcmd}def/rotate{dup type/arraytype ne @dodraw a" +"nd{dup 1(rotate)prcmd}if/rotate sysexec applyscalevals}def/scale{dup type/arra" +"ytype ne @dodraw and{2 copy 2(scale)prcmd}if/scale sysexec applyscalevals}def/" +"translate{dup type/arraytype ne @dodraw and{2 copy 2(translate)prcmd}if/transl" +"ate sysexec}def/setmatrix{dup/setmatrix sysexec @dodraw{aload pop 6(setmatrix)" +"prcmd applyscalevals}{pop}ifelse}def/initmatrix{matrix setmatrix}def/concat{ma" +"trix currentmatrix matrix concatmatrix setmatrix}def/makepattern{gsave<</mx 3 " +"-1 roll>>begin dup/XUID[1000000 @patcnt]put mx/makepattern sysexec dup dup beg" +"in PatternType @patcnt BBox aload pop XStep YStep PaintType mx aload pop 15(ma" +"kepattern)prcmd :newpath matrix setmatrix PaintProc 0 1(makepattern)prcmd end/" +"@patcnt @patcnt 1 add store end grestore}def/setpattern{begin PatternType 1 eq" +"{PaintType 1 eq{XUID aload pop exch pop 1}{:gsave[currentcolorspace aload leng" +"th -1 roll pop]setcolorspace/setcolor sysexec XUID aload pop exch pop currentr" +"gbcolor :grestore 4}ifelse(setpattern)prcmd}{/setpattern sysexec}ifelse end}de" +"f/setcolor{dup type/dicttype eq{setpattern}{/setcolor sysexec/currentrgbcolor " +"sysexec setrgbcolor}ifelse}def/setgray 1 defpr/setcmykcolor 4 defpr/sethsbcolo" +"r 3 defpr/setrgbcolor 3 defpr/.setopacityalpha{dup/.setopacityalpha sysexec 1(" +"setopacityalpha)prcmd}def/.setshapealpha{dup/.setshapealpha sysexec 1(setshape" +"alpha)prcmd}def/.setblendmode{dup/.setblendmode sysexec<</Normal 0/Compatible " +"0/Multiply 1/Screen 2/Overlay 3/SoftLight 4/HardLight 5/ColorDodge 6/ColorBurn" +" 7/Darken 8/Lighten 9/Difference 10/Exclusion 11/Hue 12/Saturation 13/Color 14" +"/Luminosity 15/CompatibleOverprint 16>>exch get 1(setblendmode)prcmd}def/@pdfp" +"agecount{(r)file runpdfbegin pdfpagecount runpdfend}def/@pdfpagebox{(r)file ru" +"npdfbegin dup dup 1 lt exch pdfpagecount gt or{pop}{pdfgetpage/MediaBox pget p" +"op aload pop}ifelse runpdfend}def DELAYBIND{.bindnow}if "; |