summaryrefslogtreecommitdiff
path: root/dviware
diff options
context:
space:
mode:
Diffstat (limited to 'dviware')
-rw-r--r--dviware/dvisvgm/ChangeLog351
-rw-r--r--dviware/dvisvgm/Makefile.am2
-rw-r--r--dviware/dvisvgm/NEWS20
-rw-r--r--dviware/dvisvgm/README2
-rwxr-xr-xdviware/dvisvgm/configure22
-rw-r--r--dviware/dvisvgm/configure.ac6
-rw-r--r--dviware/dvisvgm/doc/Makefile.am31
-rw-r--r--dviware/dvisvgm/doc/Makefile.in131
-rw-r--r--dviware/dvisvgm/doc/conf-dblatex-man.xsl2
-rw-r--r--dviware/dvisvgm/doc/conf-dblatex-pdf.xsl2
-rw-r--r--dviware/dvisvgm/doc/dvisvgm.1102
-rw-r--r--dviware/dvisvgm/doc/dvisvgm.txt.in65
-rw-r--r--dviware/dvisvgm/doc/generate-dvisvgm-sty.xsl4
-rw-r--r--dviware/dvisvgm/doc/tweak-db-refentry.xsl2
-rw-r--r--dviware/dvisvgm/doc/tweak-dblatex-pdf.xsl2
-rw-r--r--dviware/dvisvgm/libs/Makefile.am2
-rw-r--r--dviware/dvisvgm/libs/ff-woff/fontforge/tmpfile2.cpp2
-rw-r--r--dviware/dvisvgm/libs/xxHash/xxh3.h1579
-rw-r--r--dviware/dvisvgm/libs/xxHash/xxhash.c1133
-rw-r--r--dviware/dvisvgm/libs/xxHash/xxhash.h1799
-rw-r--r--dviware/dvisvgm/src/AGLTable.hpp2
-rw-r--r--dviware/dvisvgm/src/BasicDVIReader.cpp2
-rw-r--r--dviware/dvisvgm/src/BasicDVIReader.hpp2
-rw-r--r--dviware/dvisvgm/src/Bezier.cpp6
-rw-r--r--dviware/dvisvgm/src/Bezier.hpp2
-rw-r--r--dviware/dvisvgm/src/BgColorSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/BgColorSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/Bitmap.cpp2
-rw-r--r--dviware/dvisvgm/src/Bitmap.hpp2
-rw-r--r--dviware/dvisvgm/src/BoundingBox.cpp4
-rw-r--r--dviware/dvisvgm/src/BoundingBox.hpp2
-rw-r--r--dviware/dvisvgm/src/CLCommandLine.cpp2
-rw-r--r--dviware/dvisvgm/src/CLCommandLine.hpp2
-rw-r--r--dviware/dvisvgm/src/CLOption.hpp2
-rw-r--r--dviware/dvisvgm/src/CMap.cpp2
-rw-r--r--dviware/dvisvgm/src/CMap.hpp2
-rw-r--r--dviware/dvisvgm/src/CMapManager.cpp2
-rw-r--r--dviware/dvisvgm/src/CMapManager.hpp2
-rw-r--r--dviware/dvisvgm/src/CMapReader.cpp2
-rw-r--r--dviware/dvisvgm/src/CMapReader.hpp2
-rw-r--r--dviware/dvisvgm/src/Calculator.cpp2
-rw-r--r--dviware/dvisvgm/src/Calculator.hpp2
-rw-r--r--dviware/dvisvgm/src/CharMapID.cpp2
-rw-r--r--dviware/dvisvgm/src/CharMapID.hpp2
-rw-r--r--dviware/dvisvgm/src/Character.hpp2
-rw-r--r--dviware/dvisvgm/src/Color.cpp2
-rw-r--r--dviware/dvisvgm/src/Color.hpp2
-rw-r--r--dviware/dvisvgm/src/ColorSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/ColorSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/CommandLine.hpp10
-rw-r--r--dviware/dvisvgm/src/DLLoader.cpp2
-rw-r--r--dviware/dvisvgm/src/DLLoader.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIActions.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIReader.cpp2
-rw-r--r--dviware/dvisvgm/src/DVIReader.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIToSVG.cpp2
-rw-r--r--dviware/dvisvgm/src/DVIToSVG.hpp2
-rw-r--r--dviware/dvisvgm/src/DVIToSVGActions.cpp2
-rw-r--r--dviware/dvisvgm/src/DVIToSVGActions.hpp2
-rw-r--r--dviware/dvisvgm/src/Directory.cpp2
-rw-r--r--dviware/dvisvgm/src/Directory.hpp2
-rw-r--r--dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/EPSFile.cpp2
-rw-r--r--dviware/dvisvgm/src/EPSFile.hpp2
-rw-r--r--dviware/dvisvgm/src/EPSToSVG.hpp4
-rw-r--r--dviware/dvisvgm/src/EllipticalArc.cpp2
-rw-r--r--dviware/dvisvgm/src/EllipticalArc.hpp2
-rw-r--r--dviware/dvisvgm/src/EmSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/EmSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/EncFile.cpp2
-rw-r--r--dviware/dvisvgm/src/EncFile.hpp2
-rw-r--r--dviware/dvisvgm/src/FileFinder.cpp2
-rw-r--r--dviware/dvisvgm/src/FileFinder.hpp2
-rw-r--r--dviware/dvisvgm/src/FilePath.cpp12
-rw-r--r--dviware/dvisvgm/src/FilePath.hpp4
-rw-r--r--dviware/dvisvgm/src/FileSystem.cpp2
-rw-r--r--dviware/dvisvgm/src/FileSystem.hpp2
-rw-r--r--dviware/dvisvgm/src/FixWord.hpp2
-rw-r--r--dviware/dvisvgm/src/Font.cpp8
-rw-r--r--dviware/dvisvgm/src/Font.hpp2
-rw-r--r--dviware/dvisvgm/src/FontCache.cpp2
-rw-r--r--dviware/dvisvgm/src/FontCache.hpp2
-rw-r--r--dviware/dvisvgm/src/FontEncoding.cpp2
-rw-r--r--dviware/dvisvgm/src/FontEncoding.hpp2
-rw-r--r--dviware/dvisvgm/src/FontEngine.cpp2
-rw-r--r--dviware/dvisvgm/src/FontEngine.hpp2
-rw-r--r--dviware/dvisvgm/src/FontManager.cpp2
-rw-r--r--dviware/dvisvgm/src/FontManager.hpp2
-rw-r--r--dviware/dvisvgm/src/FontMap.cpp2
-rw-r--r--dviware/dvisvgm/src/FontMap.hpp2
-rw-r--r--dviware/dvisvgm/src/FontMetrics.cpp2
-rw-r--r--dviware/dvisvgm/src/FontMetrics.hpp2
-rw-r--r--dviware/dvisvgm/src/FontStyle.hpp2
-rw-r--r--dviware/dvisvgm/src/FontWriter.cpp6
-rw-r--r--dviware/dvisvgm/src/FontWriter.hpp2
-rw-r--r--dviware/dvisvgm/src/GFGlyphTracer.cpp2
-rw-r--r--dviware/dvisvgm/src/GFGlyphTracer.hpp2
-rw-r--r--dviware/dvisvgm/src/GFReader.cpp2
-rw-r--r--dviware/dvisvgm/src/GFReader.hpp2
-rw-r--r--dviware/dvisvgm/src/GFTracer.cpp2
-rw-r--r--dviware/dvisvgm/src/GFTracer.hpp2
-rw-r--r--dviware/dvisvgm/src/Ghostscript.cpp5
-rw-r--r--dviware/dvisvgm/src/Ghostscript.hpp2
-rw-r--r--dviware/dvisvgm/src/Glyph.hpp2
-rw-r--r--dviware/dvisvgm/src/GlyphTracerMessages.hpp23
-rw-r--r--dviware/dvisvgm/src/GraphicsPath.hpp8
-rw-r--r--dviware/dvisvgm/src/HashFunction.cpp2
-rw-r--r--dviware/dvisvgm/src/HashFunction.hpp2
-rw-r--r--dviware/dvisvgm/src/HtmlSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/HtmlSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/HyperlinkManager.cpp2
-rw-r--r--dviware/dvisvgm/src/HyperlinkManager.hpp2
-rw-r--r--dviware/dvisvgm/src/ImageToSVG.cpp8
-rw-r--r--dviware/dvisvgm/src/ImageToSVG.hpp11
-rw-r--r--dviware/dvisvgm/src/InputBuffer.cpp2
-rw-r--r--dviware/dvisvgm/src/InputBuffer.hpp2
-rw-r--r--dviware/dvisvgm/src/InputReader.cpp2
-rw-r--r--dviware/dvisvgm/src/InputReader.hpp2
-rw-r--r--dviware/dvisvgm/src/JFM.cpp2
-rw-r--r--dviware/dvisvgm/src/JFM.hpp2
-rw-r--r--dviware/dvisvgm/src/Length.cpp2
-rw-r--r--dviware/dvisvgm/src/Length.hpp2
-rw-r--r--dviware/dvisvgm/src/MD5HashFunction.hpp2
-rw-r--r--dviware/dvisvgm/src/Makefile.am2
-rw-r--r--dviware/dvisvgm/src/MapLine.cpp2
-rw-r--r--dviware/dvisvgm/src/MapLine.hpp2
-rw-r--r--dviware/dvisvgm/src/Matrix.cpp30
-rw-r--r--dviware/dvisvgm/src/Matrix.hpp2
-rw-r--r--dviware/dvisvgm/src/Message.cpp2
-rw-r--r--dviware/dvisvgm/src/Message.hpp2
-rw-r--r--dviware/dvisvgm/src/MessageException.hpp2
-rw-r--r--dviware/dvisvgm/src/MetafontWrapper.cpp62
-rw-r--r--dviware/dvisvgm/src/MetafontWrapper.hpp8
-rw-r--r--dviware/dvisvgm/src/MiKTeXCom.cpp2
-rw-r--r--dviware/dvisvgm/src/MiKTeXCom.hpp2
-rw-r--r--dviware/dvisvgm/src/NoPsSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/NoPsSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/NumericRanges.hpp2
-rw-r--r--dviware/dvisvgm/src/PDFParser.cpp2
-rw-r--r--dviware/dvisvgm/src/PDFParser.hpp2
-rw-r--r--dviware/dvisvgm/src/PDFToSVG.hpp4
-rw-r--r--dviware/dvisvgm/src/PSFilter.hpp2
-rw-r--r--dviware/dvisvgm/src/PSInterpreter.cpp79
-rw-r--r--dviware/dvisvgm/src/PSInterpreter.hpp13
-rw-r--r--dviware/dvisvgm/src/PSPattern.cpp11
-rw-r--r--dviware/dvisvgm/src/PSPattern.hpp2
-rw-r--r--dviware/dvisvgm/src/PSPreviewFilter.cpp2
-rw-r--r--dviware/dvisvgm/src/PSPreviewFilter.hpp2
-rw-r--r--dviware/dvisvgm/src/PageRanges.cpp2
-rw-r--r--dviware/dvisvgm/src/PageRanges.hpp2
-rw-r--r--dviware/dvisvgm/src/PageSize.cpp18
-rw-r--r--dviware/dvisvgm/src/PageSize.hpp2
-rw-r--r--dviware/dvisvgm/src/Pair.hpp2
-rw-r--r--dviware/dvisvgm/src/PapersizeSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/PapersizeSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/PathClipper.cpp2
-rw-r--r--dviware/dvisvgm/src/PathClipper.hpp2
-rw-r--r--dviware/dvisvgm/src/PdfSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/PdfSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/PreScanDVIReader.cpp2
-rw-r--r--dviware/dvisvgm/src/PreScanDVIReader.hpp2
-rw-r--r--dviware/dvisvgm/src/Process.cpp2
-rw-r--r--dviware/dvisvgm/src/Process.hpp2
-rw-r--r--dviware/dvisvgm/src/PsSpecialHandler.cpp125
-rw-r--r--dviware/dvisvgm/src/PsSpecialHandler.hpp13
-rw-r--r--dviware/dvisvgm/src/RangeMap.cpp2
-rw-r--r--dviware/dvisvgm/src/RangeMap.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharHandlerFactory.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharHandlerFactory.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharPathHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharPathHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGOutput.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGOutput.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SVGTree.cpp2
-rw-r--r--dviware/dvisvgm/src/SVGTree.hpp2
-rw-r--r--dviware/dvisvgm/src/ShadingPatch.cpp2
-rw-r--r--dviware/dvisvgm/src/ShadingPatch.hpp2
-rw-r--r--dviware/dvisvgm/src/SignalHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/SignalHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SourceInput.cpp2
-rw-r--r--dviware/dvisvgm/src/SourceInput.hpp2
-rw-r--r--dviware/dvisvgm/src/SpecialActions.hpp2
-rw-r--r--dviware/dvisvgm/src/SpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/SpecialManager.cpp2
-rw-r--r--dviware/dvisvgm/src/SpecialManager.hpp2
-rw-r--r--dviware/dvisvgm/src/StreamReader.cpp2
-rw-r--r--dviware/dvisvgm/src/StreamReader.hpp2
-rw-r--r--dviware/dvisvgm/src/StreamWriter.cpp2
-rw-r--r--dviware/dvisvgm/src/StreamWriter.hpp2
-rw-r--r--dviware/dvisvgm/src/Subfont.cpp2
-rw-r--r--dviware/dvisvgm/src/Subfont.hpp2
-rw-r--r--dviware/dvisvgm/src/System.cpp2
-rw-r--r--dviware/dvisvgm/src/System.hpp2
-rw-r--r--dviware/dvisvgm/src/TFM.cpp2
-rw-r--r--dviware/dvisvgm/src/TFM.hpp2
-rw-r--r--dviware/dvisvgm/src/TTFAutohint.cpp2
-rw-r--r--dviware/dvisvgm/src/TTFAutohint.hpp2
-rw-r--r--dviware/dvisvgm/src/TensorProductPatch.cpp6
-rw-r--r--dviware/dvisvgm/src/TensorProductPatch.hpp2
-rw-r--r--dviware/dvisvgm/src/Terminal.cpp2
-rw-r--r--dviware/dvisvgm/src/Terminal.hpp2
-rw-r--r--dviware/dvisvgm/src/ToUnicodeMap.cpp2
-rw-r--r--dviware/dvisvgm/src/ToUnicodeMap.hpp2
-rw-r--r--dviware/dvisvgm/src/TpicSpecialHandler.cpp2
-rw-r--r--dviware/dvisvgm/src/TpicSpecialHandler.hpp2
-rw-r--r--dviware/dvisvgm/src/TriangularPatch.cpp6
-rw-r--r--dviware/dvisvgm/src/TriangularPatch.hpp2
-rw-r--r--dviware/dvisvgm/src/TrueTypeFont.cpp2
-rw-r--r--dviware/dvisvgm/src/TrueTypeFont.hpp2
-rw-r--r--dviware/dvisvgm/src/Unicode.cpp2
-rw-r--r--dviware/dvisvgm/src/Unicode.hpp2
-rw-r--r--dviware/dvisvgm/src/VFActions.hpp2
-rw-r--r--dviware/dvisvgm/src/VFReader.cpp2
-rw-r--r--dviware/dvisvgm/src/VFReader.hpp2
-rw-r--r--dviware/dvisvgm/src/VectorIterator.hpp2
-rw-r--r--dviware/dvisvgm/src/VectorStream.hpp2
-rw-r--r--dviware/dvisvgm/src/XMLDocument.cpp2
-rw-r--r--dviware/dvisvgm/src/XMLDocument.hpp2
-rw-r--r--dviware/dvisvgm/src/XMLNode.cpp49
-rw-r--r--dviware/dvisvgm/src/XMLNode.hpp5
-rw-r--r--dviware/dvisvgm/src/XMLString.cpp2
-rw-r--r--dviware/dvisvgm/src/XMLString.hpp2
-rw-r--r--dviware/dvisvgm/src/XXHashFunction.hpp2
-rw-r--r--dviware/dvisvgm/src/ZLibOutputStream.hpp2
-rw-r--r--dviware/dvisvgm/src/dvisvgm.cpp10
-rw-r--r--dviware/dvisvgm/src/ffwrapper.c2
-rw-r--r--dviware/dvisvgm/src/ffwrapper.h2
-rw-r--r--dviware/dvisvgm/src/macros.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/DependencyGraph.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/GroupCollapser.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/GroupCollapser.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/OptimizerModule.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp3
-rw-r--r--dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/TextSimplifier.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/TextSimplifier.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp35
-rw-r--r--dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp2
-rw-r--r--dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp2
-rw-r--r--dviware/dvisvgm/src/options.dtd2
-rw-r--r--dviware/dvisvgm/src/options.xml10
-rw-r--r--dviware/dvisvgm/src/psdefs.cpp230
-rw-r--r--dviware/dvisvgm/src/utility.cpp2
-rw-r--r--dviware/dvisvgm/src/utility.hpp24
-rw-r--r--dviware/dvisvgm/src/version.hpp.in2
-rw-r--r--dviware/dvisvgm/src/windows.hpp2
-rw-r--r--dviware/dvisvgm/tests/BezierTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/BitmapTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/BoundingBoxTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/CMapManagerTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/CMapReaderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/CMapTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/CalculatorTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/ColorSpecialTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/ColorTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/CommandLineTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/DVIReaderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/DependencyGraphTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/DirectoryTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/DvisvgmSpecialTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/EllipticalArcTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/EmSpecialTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/FileFinderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/FilePathTest.cpp5
-rw-r--r--dviware/dvisvgm/tests/FileSystemTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/FontCacheTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/FontManagerTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/FontMapTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/GFGlyphTracerTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/GFReaderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/GhostscriptTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/GraphicsPathTest.cpp5
-rw-r--r--dviware/dvisvgm/tests/HashFunctionTest.cpp14
-rw-r--r--dviware/dvisvgm/tests/JFMReaderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/LengthTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/Makefile.am2
-rw-r--r--dviware/dvisvgm/tests/MapLineTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/MatrixTest.cpp4
-rw-r--r--dviware/dvisvgm/tests/MessageExceptionTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/PDFParserTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/PSInterpreterTest.cpp14
-rw-r--r--dviware/dvisvgm/tests/PageRagesTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/PageSizeTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/PairTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/PapersizeSpecialTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/RangeMapTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/SVGOutputTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/ShadingPatchTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/SpecialManagerTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/SplittedCharInputBufferTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/StreamInputBufferTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/StreamReaderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/StreamWriterTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/StringMatcherTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/SubfontTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/TFMReaderTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/TensorProductPatchTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/ToUnicodeMapTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/TpicSpecialTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/TriangularPatchTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/UnicodeTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/UtilityTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/VectorIteratorTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/VectorStreamTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/XMLNodeTest.cpp2
-rw-r--r--dviware/dvisvgm/tests/XMLStringTest.cpp2
-rwxr-xr-xdviware/dvisvgm/tests/check-conv2
-rw-r--r--dviware/dvisvgm/tests/data/Makefile.am2
-rwxr-xr-xdviware/dvisvgm/tests/genhashcheck.py2
-rw-r--r--dviware/dvisvgm/tests/normalize.xsl2
-rw-r--r--dviware/dvisvgm/tests/testmain.cpp2
323 files changed, 4159 insertions, 2522 deletions
diff --git a/dviware/dvisvgm/ChangeLog b/dviware/dvisvgm/ChangeLog
index c540a278c9..9b23cf074b 100644
--- a/dviware/dvisvgm/ChangeLog
+++ b/dviware/dvisvgm/ChangeLog
@@ -1,3 +1,354 @@
+2020-03-13 Martin Gieseking <martin.gieseking@uos.de>
+
+ * NEWS:
+ updated NEWS and vc/README
+
+2020-03-12 Martin Gieseking <martin.gieseking@uos.de>
+
+ * doc/dvisvgm.1:
+ added generated man page to repo
+
+2020-03-11 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/psdefs.cpp:
+ fixed xshow, yshow, and xyshow for multi-byte characters
+
+2020-03-10 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/Matrix.cpp:
+ replaced istream::ignore() with istream::get()
+to make gcc on NetBSD
+ happy
+
+ * .travis.yml:
+ travis: added packages required to build man page
+
+ * .appveyor.yml, .travis.yml, configure.ac, src/Doxyfile, src/version.hpp:
+ set version to 2.9
+
+2020-03-09 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/PsSpecialHandler.cpp:
+ create image files in tmpdir instead of cwd
+
+ * src/PsSpecialHandler.cpp:
+ fixed mime type of JPEG images
+
+ * src/utility.hpp:
+ base64_copy: added parameter to set line length
+
+ * src/XMLNode.cpp:
+ wrap lines with base64 image data (200 chars/line)
+
+ * doc/Makefile.am:
+ make install: use existing dvisvgm.1 if it can't be rebuilt
+However,
+ "make dist" and "make distcheck" should still fail if the man page
+can't
+ be built in order to ensure the tarball always contains a recent version.
+
+ * src/PsSpecialHandler.cpp, src/PsSpecialHandler.hpp:
+ some code cleanup
+
+2020-03-08 Martin Gieseking <martin.gieseking@uos.de>
+
+ * doc/dvisvgm.txt.in, src/PSInterpreter.cpp:
+ added bitmap format 'none' to disable image processing
+
+2020-03-07 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/PSInterpreter.cpp, src/PSInterpreter.hpp, src/PsSpecialHandler.cpp,
+ src/PsSpecialHandler.hpp, src/psdefs.cpp:
+ added image support for various JPEG and PNG variants
+
+ * doc/dvisvgm.txt.in, src/CommandLine.hpp, src/dvisvgm.cpp,
+ src/options.xml:
+ added command-line option --bitmap-format
+
+ * doc/generate-dvisvgm-sty.xsl:
+ manual page: reduce distance of table rows
+
+2020-03-05 Martin Gieseking <martin.gieseking@uos.de>
+
+ * libs/xxHash/xxh3.h, libs/xxHash/xxhash.c, libs/xxHash/xxhash.h,
+ tests/HashFunctionTest.cpp:
+ updated xxhash to version 0.7.3
+
+2020-03-02 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/GlyphTracerMessages.hpp:
+ suppress tracer messages if no font info available
+
+ * src/MetafontWrapper.cpp, src/MetafontWrapper.hpp:
+ added fallback method to get GF resolution applied by Metafont
+
+2020-02-29 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/PsSpecialHandler.cpp:
+ fixed potential segfault
+
+ * src/Bezier.cpp, src/BoundingBox.cpp, src/Font.cpp, src/FontWriter.cpp,
+ src/Matrix.cpp, src/TensorProductPatch.cpp, src/TriangularPatch.cpp:
+ replaced fabs() with std::abs()
+
+2020-02-26 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/XMLNode.cpp:
+ fixed copy constructor of XMLElement
+
+ * src/PSInterpreter.cpp, src/PSInterpreter.hpp, src/PsSpecialHandler.cpp,
+ src/PsSpecialHandler.hpp, src/psdefs.cpp, tests/PSInterpreterTest.cpp:
+ fixed broken handling of PS tiling patterns
+
+ * src/PSPattern.cpp:
+ simplified loop expression
+
+ * src/XMLNode.cpp, src/optimizer/RedundantElementRemover.cpp:
+ don't remove clipPath elements if referenced in patterns
+
+ * src/PsSpecialHandler.cpp:
+ don't add clip path to path elements in pattern definitions
+
+2020-02-25 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/psdefs.cpp:
+ store image counter in globaldict
+
+ * src/PsSpecialHandler.cpp, src/PsSpecialHandler.hpp, src/XMLNode.cpp,
+ src/XMLNode.hpp, src/dvisvgm.cpp:
+ don't keep encoded image data in memory
+To prevent memory issues, add
+ the base64-encoded image data when serializing
+the XML tree.
+
+ * src/PsSpecialHandler.cpp:
+ prevent access to invalid vector component
+
+ * src/XMLNode.cpp, src/XMLNode.hpp:
+ prevent deep destructor recursion of XML nodes
+
+ * src/psdefs.cpp:
+ PS handler: prevent write access to protected pattern dictionary
+
+2020-02-21 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/psdefs.cpp:
+ don't access DataSource for shading types < 4
+
+2020-02-20 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/PsSpecialHandler.cpp:
+ apply clip path to image if present
+
+ * src/optimizer/TransformSimplifier.cpp:
+ TransformSimplifier: prevent width/height from getting negative
+
+ * src/Font.cpp, src/GraphicsPath.hpp, src/PsSpecialHandler.cpp,
+ tests/GraphicsPathTest.cpp:
+ changed signature of GraphicsPath::computeBBox()
+
+2020-02-18 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/psdefs.cpp:
+ image operator: reset output device correctly
+
+2020-02-17 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/PsSpecialHandler.cpp, src/psdefs.cpp:
+ stop image processing if PNG devices are unavailable
+Handling of PS
+ operator 'image' relies on the GS output devices 'png16m' and
+'pnggray'
+ (depending on the current color space). If they are unavailable,
+ the
+image processing is stopped now instead of leaving GS with an
+ internal error.
+
+ * src/PsSpecialHandler.cpp:
+ adapt bounding box to enclose embedded bitmaps
+
+2020-02-16 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/EPSToSVG.hpp, src/ImageToSVG.cpp, src/ImageToSVG.hpp,
+ src/PDFToSVG.hpp:
+ fixed getCurrentPageNumber() for EPS and PDF files
+
+ * src/FilePath.cpp, src/FilePath.hpp, tests/FilePathTest.cpp:
+ FilePath::suffix("") now removes the suffix if present
+
+ * src/PsSpecialHandler.cpp, src/PsSpecialHandler.hpp, src/psdefs.cpp:
+ sync location and base name of temporary PNG files with SVG file
+
+ * src/PsSpecialHandler.cpp, src/PsSpecialHandler.hpp, src/dvisvgm.cpp,
+ src/psdefs.cpp:
+ remove temporary PNG files if --keep is not given
+
+2020-02-15 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/psdefs.cpp:
+ added evaluation of PS Level 1 image operators
+
+2020-02-14 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/Matrix.cpp, tests/MatrixTest.cpp:
+ fixed row/column issue in Matrix::invert()
+
+ * src/FontWriter.cpp, src/utility.hpp:
+ added wrapper function for util::base64_copy()
+
+ * src/PSInterpreter.cpp, src/PSInterpreter.hpp, src/PsSpecialHandler.cpp,
+ src/PsSpecialHandler.hpp, src/psdefs.cpp, tests/PSInterpreterTest.cpp:
+ added processing of PS image operator
+
+2020-02-12 Martin Gieseking <martin.gieseking@uos.de>
+
+ * doc/dvisvgm.txt.in:
+ manpage: added info on default values listed by --help
+
+2020-01-17 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/GraphicsPath.hpp:
+ arcto: use template type for rx and ry instead of double
+
+2020-01-14 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/PageSize.cpp:
+ replaced floor(x+0.5) with round(x)
+
+2020-01-06 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/Ghostscript.cpp:
+ added check for libgs.dylib.N (Mac only)
+
+2020-01-02 Martin Gieseking <martin.gieseking@uos.de>
+
+ * Makefile.am, README, README.md, configure.ac, doc/Makefile.am,
+ doc/conf-dblatex-man.xsl, doc/conf-dblatex-pdf.xsl, doc/db2html.xsl,
+ doc/dvisvgm.txt.in, doc/tweak-db-article.xsl, doc/tweak-db-refentry.xsl,
+ doc/tweak-dblatex-pdf.xsl, libs/Makefile.am,
+ libs/ff-woff/fontforge/tmpfile2.cpp, src/AGLTable.hpp,
+ src/BasicDVIReader.cpp, src/BasicDVIReader.hpp, src/Bezier.cpp,
+ src/Bezier.hpp, src/BgColorSpecialHandler.cpp,
+ src/BgColorSpecialHandler.hpp, src/Bitmap.cpp, src/Bitmap.hpp,
+ src/BoundingBox.cpp, src/BoundingBox.hpp, src/CLCommandLine.cpp,
+ src/CLCommandLine.hpp, src/CLOption.hpp, src/CMap.cpp, src/CMap.hpp,
+ src/CMapManager.cpp, src/CMapManager.hpp, src/CMapReader.cpp,
+ src/CMapReader.hpp, src/Calculator.cpp, src/Calculator.hpp,
+ src/CharMapID.cpp, src/CharMapID.hpp, src/Character.hpp, src/Color.cpp,
+ src/Color.hpp, src/ColorSpecialHandler.cpp, src/ColorSpecialHandler.hpp,
+ src/CommandLine.hpp, src/DLLoader.cpp, src/DLLoader.hpp,
+ src/DVIActions.hpp, src/DVIReader.cpp, src/DVIReader.hpp,
+ src/DVIToSVG.cpp, src/DVIToSVG.hpp, src/DVIToSVGActions.cpp,
+ src/DVIToSVGActions.hpp, src/Directory.cpp, src/Directory.hpp,
+ src/DvisvgmSpecialHandler.cpp, src/DvisvgmSpecialHandler.hpp,
+ src/EPSFile.cpp, src/EPSFile.hpp, src/EPSToSVG.hpp,
+ src/EllipticalArc.cpp, src/EllipticalArc.hpp, src/EmSpecialHandler.cpp,
+ src/EmSpecialHandler.hpp, src/EncFile.cpp, src/EncFile.hpp,
+ src/FileFinder.cpp, src/FileFinder.hpp, src/FilePath.cpp,
+ src/FilePath.hpp, src/FileSystem.cpp, src/FileSystem.hpp,
+ src/FixWord.hpp, src/Font.cpp, src/Font.hpp, src/FontCache.cpp,
+ src/FontCache.hpp, src/FontEncoding.cpp, src/FontEncoding.hpp,
+ src/FontEngine.cpp, src/FontEngine.hpp, src/FontManager.cpp,
+ src/FontManager.hpp, src/FontMap.cpp, src/FontMap.hpp,
+ src/FontMetrics.cpp, src/FontMetrics.hpp, src/FontStyle.hpp,
+ src/FontWriter.cpp, src/FontWriter.hpp, src/GFGlyphTracer.cpp,
+ src/GFGlyphTracer.hpp, src/GFReader.cpp, src/GFReader.hpp,
+ src/GFTracer.cpp, src/GFTracer.hpp, src/Ghostscript.cpp,
+ src/Ghostscript.hpp, src/Glyph.hpp, src/GlyphTracerMessages.hpp,
+ src/GraphicsPath.hpp, src/HashFunction.cpp, src/HashFunction.hpp,
+ src/HtmlSpecialHandler.cpp, src/HtmlSpecialHandler.hpp,
+ src/HyperlinkManager.cpp, src/HyperlinkManager.hpp, src/ImageToSVG.cpp,
+ src/ImageToSVG.hpp, src/InputBuffer.cpp, src/InputBuffer.hpp,
+ src/InputReader.cpp, src/InputReader.hpp, src/JFM.cpp, src/JFM.hpp,
+ src/Length.cpp, src/Length.hpp, src/MD5HashFunction.hpp, src/Makefile.am,
+ src/MapLine.cpp, src/MapLine.hpp, src/Matrix.cpp, src/Matrix.hpp,
+ src/Message.cpp, src/Message.hpp, src/MessageException.hpp,
+ src/MetafontWrapper.cpp, src/MetafontWrapper.hpp, src/MiKTeXCom.cpp,
+ src/MiKTeXCom.hpp, src/NoPsSpecialHandler.cpp,
+ src/NoPsSpecialHandler.hpp, src/NumericRanges.hpp, src/PDFParser.cpp,
+ src/PDFParser.hpp, src/PDFToSVG.hpp, src/PSFilter.hpp,
+ src/PSInterpreter.cpp, src/PSInterpreter.hpp, src/PSPattern.cpp,
+ src/PSPattern.hpp, src/PSPreviewFilter.cpp, src/PSPreviewFilter.hpp,
+ src/PageRanges.cpp, src/PageRanges.hpp, src/PageSize.cpp,
+ src/PageSize.hpp, src/Pair.hpp, src/PapersizeSpecialHandler.cpp,
+ src/PapersizeSpecialHandler.hpp, src/PathClipper.cpp,
+ src/PathClipper.hpp, src/PdfSpecialHandler.cpp,
+ src/PdfSpecialHandler.hpp, src/PreScanDVIReader.cpp,
+ src/PreScanDVIReader.hpp, src/Process.cpp, src/Process.hpp,
+ src/PsSpecialHandler.cpp, src/PsSpecialHandler.hpp, src/RangeMap.cpp,
+ src/RangeMap.hpp, src/SVGCharHandler.cpp, src/SVGCharHandler.hpp,
+ src/SVGCharHandlerFactory.cpp, src/SVGCharHandlerFactory.hpp,
+ src/SVGCharPathHandler.cpp, src/SVGCharPathHandler.hpp,
+ src/SVGCharTspanTextHandler.cpp, src/SVGCharTspanTextHandler.hpp,
+ src/SVGOutput.cpp, src/SVGOutput.hpp, src/SVGSingleCharTextHandler.cpp,
+ src/SVGSingleCharTextHandler.hpp, src/SVGTree.cpp, src/SVGTree.hpp,
+ src/ShadingPatch.cpp, src/ShadingPatch.hpp, src/SignalHandler.cpp,
+ src/SignalHandler.hpp, src/SourceInput.cpp, src/SourceInput.hpp,
+ src/SpecialActions.hpp, src/SpecialHandler.hpp, src/SpecialManager.cpp,
+ src/SpecialManager.hpp, src/StreamReader.cpp, src/StreamReader.hpp,
+ src/StreamWriter.cpp, src/StreamWriter.hpp, src/Subfont.cpp,
+ src/Subfont.hpp, src/System.cpp, src/System.hpp, src/TFM.cpp,
+ src/TFM.hpp, src/TTFAutohint.cpp, src/TTFAutohint.hpp,
+ src/TensorProductPatch.cpp, src/TensorProductPatch.hpp, src/Terminal.cpp,
+ src/Terminal.hpp, src/ToUnicodeMap.cpp, src/ToUnicodeMap.hpp,
+ src/TpicSpecialHandler.cpp, src/TpicSpecialHandler.hpp,
+ src/TriangularPatch.cpp, src/TriangularPatch.hpp, src/TrueTypeFont.cpp,
+ src/TrueTypeFont.hpp, src/Unicode.cpp, src/Unicode.hpp,
+ src/VFActions.hpp, src/VFReader.cpp, src/VFReader.hpp,
+ src/VectorIterator.hpp, src/VectorStream.hpp, src/XMLDocument.cpp,
+ src/XMLDocument.hpp, src/XMLNode.cpp, src/XMLNode.hpp, src/XMLString.cpp,
+ src/XMLString.hpp, src/XXHashFunction.hpp, src/ZLibOutputStream.hpp,
+ src/dvisvgm.cpp, src/ffwrapper.c, src/ffwrapper.h, src/macros.hpp,
+ src/optimizer/AttributeExtractor.cpp,
+ src/optimizer/AttributeExtractor.hpp, src/optimizer/DependencyGraph.hpp,
+ src/optimizer/GroupCollapser.cpp, src/optimizer/GroupCollapser.hpp,
+ src/optimizer/OptimizerModule.hpp,
+ src/optimizer/RedundantElementRemover.cpp,
+ src/optimizer/RedundantElementRemover.hpp,
+ src/optimizer/SVGOptimizer.cpp, src/optimizer/SVGOptimizer.hpp,
+ src/optimizer/TextSimplifier.cpp, src/optimizer/TextSimplifier.hpp,
+ src/optimizer/TransformSimplifier.cpp,
+ src/optimizer/TransformSimplifier.hpp, src/optimizer/WSNodeRemover.cpp,
+ src/optimizer/WSNodeRemover.hpp, src/options.dtd, src/options.xml,
+ src/psdefs.cpp, src/utility.cpp, src/utility.hpp, src/version.hpp,
+ src/version.hpp.in, src/windows.hpp, tests/BezierTest.cpp,
+ tests/BitmapTest.cpp, tests/BoundingBoxTest.cpp,
+ tests/CMapManagerTest.cpp, tests/CMapReaderTest.cpp, tests/CMapTest.cpp,
+ tests/CalculatorTest.cpp, tests/ColorSpecialTest.cpp,
+ tests/ColorTest.cpp, tests/CommandLineTest.cpp, tests/DVIReaderTest.cpp,
+ tests/DependencyGraphTest.cpp, tests/DirectoryTest.cpp,
+ tests/DvisvgmSpecialTest.cpp, tests/EllipticalArcTest.cpp,
+ tests/EmSpecialTest.cpp, tests/FileFinderTest.cpp,
+ tests/FilePathTest.cpp, tests/FileSystemTest.cpp,
+ tests/FontCacheTest.cpp, tests/FontManagerTest.cpp,
+ tests/FontMapTest.cpp, tests/GFGlyphTracerTest.cpp,
+ tests/GFReaderTest.cpp, tests/GhostscriptTest.cpp,
+ tests/GraphicsPathTest.cpp, tests/HashFunctionTest.cpp,
+ tests/JFMReaderTest.cpp, tests/LengthTest.cpp, tests/Makefile.am,
+ tests/MapLineTest.cpp, tests/MatrixTest.cpp,
+ tests/MessageExceptionTest.cpp, tests/PDFParserTest.cpp,
+ tests/PSInterpreterTest.cpp, tests/PageRagesTest.cpp,
+ tests/PageSizeTest.cpp, tests/PairTest.cpp,
+ tests/PapersizeSpecialTest.cpp, tests/RangeMapTest.cpp,
+ tests/SVGOutputTest.cpp, tests/ShadingPatchTest.cpp,
+ tests/SpecialManagerTest.cpp, tests/SplittedCharInputBufferTest.cpp,
+ tests/StreamInputBufferTest.cpp, tests/StreamReaderTest.cpp,
+ tests/StreamWriterTest.cpp, tests/StringMatcherTest.cpp,
+ tests/SubfontTest.cpp, tests/TFMReaderTest.cpp,
+ tests/TensorProductPatchTest.cpp, tests/ToUnicodeMapTest.cpp,
+ tests/TpicSpecialTest.cpp, tests/TriangularPatchTest.cpp,
+ tests/UnicodeTest.cpp, tests/UtilityTest.cpp,
+ tests/VectorIteratorTest.cpp, tests/VectorStreamTest.cpp,
+ tests/XMLNodeTest.cpp, tests/XMLStringTest.cpp, tests/check-conv,
+ tests/create-makefile, tests/data/Makefile.am, tests/genhashcheck.py,
+ tests/normalize.xsl, tests/testmain.cpp:
+ updated year in copyright statements to 2020
+
+2019-12-23 Martin Gieseking <martin.gieseking@uos.de>
+
+ * doc/dvisvgm.txt.in:
+ few additions to the manual page
+
2019-12-07 Martin Gieseking <martin.gieseking@uos.de>
* NEWS:
diff --git a/dviware/dvisvgm/Makefile.am b/dviware/dvisvgm/Makefile.am
index 2bb31ddd4d..7bb20a01c7 100644
--- a/dviware/dvisvgm/Makefile.am
+++ b/dviware/dvisvgm/Makefile.am
@@ -1,5 +1,5 @@
## This file is part of dvisvgm
-## Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
diff --git a/dviware/dvisvgm/NEWS b/dviware/dvisvgm/NEWS
index 3efe71b2d3..0f58739ca2 100644
--- a/dviware/dvisvgm/NEWS
+++ b/dviware/dvisvgm/NEWS
@@ -1,3 +1,23 @@
+dvisvgm-2.9 (2020-03-13)
+- added processing of PS operators 'image' and 'colorimage' to embed bitmaps
+ present in PS/PDF data into the generated SVG
+- added command-line option --bitmap-format to set the format used to embed
+ bitmaps present in EPS/PDF files
+- added fallback method to retrieve the resolution of GF files if stdout
+ of the Metafont subprocess can't be read through a pipe (GH #129)
+- fixed broken conversion of PS tiling patterns
+- fixed the functionality of PS operators 'xshow', 'yshow', and 'xyshow' for
+ multibyte characters
+- fixed a PS error triggered by unsupported shading types < 4
+- prevent negative 'height' and 'width' attributes created by optimizer
+ module 'simplify-transform'
+- fixed potential segfault caused by deep recursion in huge SVG trees
+- look for Ghostscript library name 'libgs.dylib.N' additionally to
+ 'libgs.N.dylib' (Mac only)
+- ensure that 'make install' installs the bundled manual page if it can't be
+ rebuilt due to missing build tools
+- updated bundled xxHash library to version 0.7.3
+
dvisvgm-2.8.2 (2019-12-07)
- if available, call 'mf-nowin' instead of 'mf' to process Metafont files
(GH #121)
diff --git a/dviware/dvisvgm/README b/dviware/dvisvgm/README
index dd9513702e..f880af15f8 100644
--- a/dviware/dvisvgm/README
+++ b/dviware/dvisvgm/README
@@ -130,7 +130,7 @@ ADDITIONAL INFORMATION
COPYRIGHT
- Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+ Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/dviware/dvisvgm/configure b/dviware/dvisvgm/configure
index 690013405a..c1eb843556 100755
--- a/dviware/dvisvgm/configure
+++ b/dviware/dvisvgm/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvisvgm 2.8.2.
+# Generated by GNU Autoconf 2.69 for dvisvgm 2.9.
#
# Report bugs to <martin.gieseking@uos.de>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='dvisvgm'
PACKAGE_TARNAME='dvisvgm'
-PACKAGE_VERSION='2.8.2'
-PACKAGE_STRING='dvisvgm 2.8.2'
+PACKAGE_VERSION='2.9'
+PACKAGE_STRING='dvisvgm 2.9'
PACKAGE_BUGREPORT='martin.gieseking@uos.de'
PACKAGE_URL=''
@@ -1406,7 +1406,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dvisvgm 2.8.2 to adapt to many kinds of systems.
+\`configure' configures dvisvgm 2.9 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1477,7 +1477,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dvisvgm 2.8.2:";;
+ short | recursive ) echo "Configuration of dvisvgm 2.9:";;
esac
cat <<\_ACEOF
@@ -1625,7 +1625,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dvisvgm configure 2.8.2
+dvisvgm configure 2.9
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2169,7 +2169,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dvisvgm $as_me 2.8.2, which was
+It was created by dvisvgm $as_me 2.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2527,7 +2527,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-DATE="December 2019"
+DATE="March 2020"
ac_config_headers="$ac_config_headers config.h"
@@ -3157,7 +3157,7 @@ fi
# Define the identity of the package.
PACKAGE='dvisvgm'
- VERSION='2.8.2'
+ VERSION='2.9'
cat >>confdefs.h <<_ACEOF
@@ -20138,7 +20138,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dvisvgm $as_me 2.8.2, which was
+This file was extended by dvisvgm $as_me 2.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -20204,7 +20204,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-dvisvgm config.status 2.8.2
+dvisvgm config.status 2.9
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/dviware/dvisvgm/configure.ac b/dviware/dvisvgm/configure.ac
index 3572e2d106..532bc08795 100644
--- a/dviware/dvisvgm/configure.ac
+++ b/dviware/dvisvgm/configure.ac
@@ -1,11 +1,11 @@
# This file is part of dvisvgm
-# Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+# Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
#
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([dvisvgm],[2.8.2],[martin.gieseking@uos.de])
-DATE="December 2019"
+AC_INIT([dvisvgm],[2.9],[martin.gieseking@uos.de])
+DATE="March 2020"
AC_CONFIG_SRCDIR(src)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
diff --git a/dviware/dvisvgm/doc/Makefile.am b/dviware/dvisvgm/doc/Makefile.am
index a2bc63bd2e..fdbc24e1ce 100644
--- a/dviware/dvisvgm/doc/Makefile.am
+++ b/dviware/dvisvgm/doc/Makefile.am
@@ -1,14 +1,13 @@
## This file is part of dvisvgm
-## Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
# Don't try to install the manpage file if it can't be built due to missing utilities.
# However, the distribution tarball should always contain a recent manpage. We ensure
# this by adding a dist-hook rule below.
-if BUILD_MANPAGE
+
man_MANS = dvisvgm.1
-endif
EXTRA_DIST = $(man_MANS) \
conf-dblatex-man.xsl \
@@ -18,6 +17,8 @@ EXTRA_DIST = $(man_MANS) \
tweak-dblatex-pdf.xsl \
tweak-db-refentry.xsl
+if BUILD_MANPAGE
+
CONF_DBLATEX_MAN = $(dvisvgm_srcdir)/doc/conf-dblatex-man.xsl
CONF_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/conf-dblatex-pdf.xsl
TWEAK_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/tweak-dblatex-pdf.xsl
@@ -47,6 +48,9 @@ dvisvgm.dvi: dvisvgm.1
dvisvgm.html: dvisvgm-man.xml db2html.xsl
xsltproc -o $@ db2html.xsl $<
+dvisvgm.md: dvisvgm-man.xml db2md.xsl
+ xsltproc -o $@ db2md.xsl $<
+
dvisvgm.epub: dvisvgm-article.xml
a2x -darticle -fepub -L --icons --icons-dir=. $<
mv $(basename $<).epub $@
@@ -77,21 +81,24 @@ dvisvgm.txt: dvisvgm.txt.in ../configure.ac
epub: dvisvgm.epub
html: dvisvgm.html
man: dvisvgm.1
+md: dvisvgm.md
pdf: dvisvgm.pdf
+endif
+
clean:
- rm -f dvisvgm.pdf dvisvgm.html dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub
+ rm -f dvisvgm.pdf dvisvgm.html dvisvgm.md dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub
distclean-local:
- rm -f dvisvgm.pdf dvisvgm.html dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub dvisvgm.1
+ rm -f dvisvgm.pdf dvisvgm.html dvisvgm.md dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub dvisvgm.1
+if !BUILD_MANPAGE
# Ensure that distribution tarballs always contain a recent manpage, i.e.
# let "make dist" and "make distcheck" fail if dvisvgm.1 can't be built.
dist-hook:
- @if test ! -f $(dvisvgm_srcdir)/doc/dvisvgm.1; then \
- echo "----------------------------------------------------------------"; \
- echo "manpage file dvisvgm.1 could not be built because one or more of"; \
- echo "the following utilities are missing: asciidoc, xmlto, xsltproc "; \
- echo "----------------------------------------------------------------"; \
- false; \
- fi
+ @echo "----------------------------------------------------------------"; \
+ echo "manpage file dvisvgm.1 could not be built because one or more of"; \
+ echo "the following utilities are missing: asciidoc, xmlto, xsltproc "; \
+ echo "----------------------------------------------------------------"; \
+ false;
+endif
diff --git a/dviware/dvisvgm/doc/Makefile.in b/dviware/dvisvgm/doc/Makefile.in
index b5bf93ce6b..35bceae1d1 100644
--- a/dviware/dvisvgm/doc/Makefile.in
+++ b/dviware/dvisvgm/doc/Makefile.in
@@ -13,6 +13,10 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
+
+# Don't try to install the manpage file if it can't be built due to missing utilities.
+# However, the distribution tarball should always contain a recent manpage. We ensure
+# this by adding a dist-hook rule below.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
@@ -314,11 +318,7 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-
-# Don't try to install the manpage file if it can't be built due to missing utilities.
-# However, the distribution tarball should always contain a recent manpage. We ensure
-# this by adding a dist-hook rule below.
-@BUILD_MANPAGE_TRUE@man_MANS = dvisvgm.1
+man_MANS = dvisvgm.1
EXTRA_DIST = $(man_MANS) \
conf-dblatex-man.xsl \
conf-dblatex-pdf.xsl \
@@ -327,13 +327,13 @@ EXTRA_DIST = $(man_MANS) \
tweak-dblatex-pdf.xsl \
tweak-db-refentry.xsl
-CONF_DBLATEX_MAN = $(dvisvgm_srcdir)/doc/conf-dblatex-man.xsl
-CONF_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/conf-dblatex-pdf.xsl
-TWEAK_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/tweak-dblatex-pdf.xsl
-TWEAK_DB_ARTICLE = $(dvisvgm_srcdir)/doc/tweak-db-article.xsl
-TWEAK_DB_REFENTRY = $(dvisvgm_srcdir)/doc/tweak-db-refentry.xsl
-GEN_DBLATEX_STY = $(dvisvgm_srcdir)/doc/generate-dvisvgm-sty.xsl
-DB_VARS = man.endnotes.list.enabled=0 man.endnotes.are.numbered=0 man.authors.section.enabled=0
+@BUILD_MANPAGE_TRUE@CONF_DBLATEX_MAN = $(dvisvgm_srcdir)/doc/conf-dblatex-man.xsl
+@BUILD_MANPAGE_TRUE@CONF_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/conf-dblatex-pdf.xsl
+@BUILD_MANPAGE_TRUE@TWEAK_DBLATEX_PDF = $(dvisvgm_srcdir)/doc/tweak-dblatex-pdf.xsl
+@BUILD_MANPAGE_TRUE@TWEAK_DB_ARTICLE = $(dvisvgm_srcdir)/doc/tweak-db-article.xsl
+@BUILD_MANPAGE_TRUE@TWEAK_DB_REFENTRY = $(dvisvgm_srcdir)/doc/tweak-db-refentry.xsl
+@BUILD_MANPAGE_TRUE@GEN_DBLATEX_STY = $(dvisvgm_srcdir)/doc/generate-dvisvgm-sty.xsl
+@BUILD_MANPAGE_TRUE@DB_VARS = man.endnotes.list.enabled=0 man.endnotes.are.numbered=0 man.authors.section.enabled=0
all: all-am
.SUFFIXES:
@@ -421,6 +421,7 @@ ctags CTAGS:
cscope cscopelist:
+@BUILD_MANPAGE_TRUE@dist-hook:
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
@@ -505,6 +506,8 @@ dvi: dvi-am
dvi-am:
+@BUILD_MANPAGE_FALSE@html: html-am
+
html-am:
info: info-am
@@ -547,6 +550,8 @@ mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+@BUILD_MANPAGE_FALSE@pdf: pdf-am
+
pdf-am:
ps: ps-am
@@ -575,74 +580,76 @@ uninstall-man: uninstall-man1
.PRECIOUS: Makefile
-dvisvgm.1: dvisvgm-man.xml $(CONF_DBLATEX_MAN)
- xmlto -m $(CONF_DBLATEX_MAN) $(addprefix --stringparam , $(DB_VARS)) man $<
+@BUILD_MANPAGE_TRUE@dvisvgm.1: dvisvgm-man.xml $(CONF_DBLATEX_MAN)
+@BUILD_MANPAGE_TRUE@ xmlto -m $(CONF_DBLATEX_MAN) $(addprefix --stringparam , $(DB_VARS)) man $<
-dvisvgm.pdf: dvisvgm-man.xml dvisvgm.sty $(CONF_DBLATEX_PDF) $(TWEAK_DBLATEX_PDF)
- mv $< $<.tmp
- xsltproc -o $< $(TWEAK_DBLATEX_PDF) $<.tmp
- dblatex -bxetex --texstyle=./dvisvgm.sty -p $(CONF_DBLATEX_PDF) $<
- mv $<.tmp $<
- mv $(basename $<).pdf $@
+@BUILD_MANPAGE_TRUE@dvisvgm.pdf: dvisvgm-man.xml dvisvgm.sty $(CONF_DBLATEX_PDF) $(TWEAK_DBLATEX_PDF)
+@BUILD_MANPAGE_TRUE@ mv $< $<.tmp
+@BUILD_MANPAGE_TRUE@ xsltproc -o $< $(TWEAK_DBLATEX_PDF) $<.tmp
+@BUILD_MANPAGE_TRUE@ dblatex -bxetex --texstyle=./dvisvgm.sty -p $(CONF_DBLATEX_PDF) $<
+@BUILD_MANPAGE_TRUE@ mv $<.tmp $<
+@BUILD_MANPAGE_TRUE@ mv $(basename $<).pdf $@
-dvi-pdf: dvisvgm.dvi
- dvipdfm $<
- rm -f $<
+@BUILD_MANPAGE_TRUE@dvi-pdf: dvisvgm.dvi
+@BUILD_MANPAGE_TRUE@ dvipdfm $<
+@BUILD_MANPAGE_TRUE@ rm -f $<
-dvisvgm.dvi: dvisvgm.1
- groff -Tdvi -mandoc ./$< >$@
+@BUILD_MANPAGE_TRUE@dvisvgm.dvi: dvisvgm.1
+@BUILD_MANPAGE_TRUE@ groff -Tdvi -mandoc ./$< >$@
-dvisvgm.html: dvisvgm-man.xml db2html.xsl
- xsltproc -o $@ db2html.xsl $<
+@BUILD_MANPAGE_TRUE@dvisvgm.html: dvisvgm-man.xml db2html.xsl
+@BUILD_MANPAGE_TRUE@ xsltproc -o $@ db2html.xsl $<
-dvisvgm.epub: dvisvgm-article.xml
- a2x -darticle -fepub -L --icons --icons-dir=. $<
- mv $(basename $<).epub $@
+@BUILD_MANPAGE_TRUE@dvisvgm.md: dvisvgm-man.xml db2md.xsl
+@BUILD_MANPAGE_TRUE@ xsltproc -o $@ db2md.xsl $<
-.SECONDARY: dvisvgm-article.xml dvisvgm-man.xml dvisvgm.sty
+@BUILD_MANPAGE_TRUE@dvisvgm.epub: dvisvgm-article.xml
+@BUILD_MANPAGE_TRUE@ a2x -darticle -fepub -L --icons --icons-dir=. $<
+@BUILD_MANPAGE_TRUE@ mv $(basename $<).epub $@
-dvisvgm-man.xml: dvisvgm.txt $(TWEAK_DB_REFENTRY)
- asciidoc -a icons -a 'iconsdir=.' -a badges -a 'revnumber=@VERSION@' --unsafe -bdocbook -dmanpage -o $@.tmp $<
- xsltproc -o $@ $(TWEAK_DB_REFENTRY) $@.tmp
- rm $@.tmp
+@BUILD_MANPAGE_TRUE@.SECONDARY: dvisvgm-article.xml dvisvgm-man.xml dvisvgm.sty
-dvisvgm-article.xml: dvisvgm.txt $(TWEAK_DB_ARTICLE)
- asciidoc -a icons -a 'iconsdir=.' -a badges -a 'revnumber=@VERSION@' --unsafe -bdocbook -darticle -o $@.tmp $<
- xsltproc -o $@ $(TWEAK_DB_ARTICLE) $@.tmp
- rm $@.tmp
- sed -i "s/{VERSION}/@VERSION@/" $@
+@BUILD_MANPAGE_TRUE@dvisvgm-man.xml: dvisvgm.txt $(TWEAK_DB_REFENTRY)
+@BUILD_MANPAGE_TRUE@ asciidoc -a icons -a 'iconsdir=.' -a badges -a 'revnumber=@VERSION@' --unsafe -bdocbook -dmanpage -o $@.tmp $<
+@BUILD_MANPAGE_TRUE@ xsltproc -o $@ $(TWEAK_DB_REFENTRY) $@.tmp
+@BUILD_MANPAGE_TRUE@ rm $@.tmp
-dvisvgm.sty: dvisvgm-man.xml $(GEN_DBLATEX_STY)
- xsltproc -o dvisvgm.sty $(GEN_DBLATEX_STY) $<
+@BUILD_MANPAGE_TRUE@dvisvgm-article.xml: dvisvgm.txt $(TWEAK_DB_ARTICLE)
+@BUILD_MANPAGE_TRUE@ asciidoc -a icons -a 'iconsdir=.' -a badges -a 'revnumber=@VERSION@' --unsafe -bdocbook -darticle -o $@.tmp $<
+@BUILD_MANPAGE_TRUE@ xsltproc -o $@ $(TWEAK_DB_ARTICLE) $@.tmp
+@BUILD_MANPAGE_TRUE@ rm $@.tmp
+@BUILD_MANPAGE_TRUE@ sed -i "s/{VERSION}/@VERSION@/" $@
-dvisvgm.txt: dvisvgm.txt.in ../configure.ac
- sed -e 's/@VERSION[@]/@VERSION@/g' -e 's/@PACKAGE_BUGREPORT[@]/@PACKAGE_BUGREPORT@/g' $< >$@
- if [ $< -nt ../configure.ac ]; \
- then touch -r $< $@; \
- else touch -r ../configure.ac $@; \
- fi
+@BUILD_MANPAGE_TRUE@dvisvgm.sty: dvisvgm-man.xml $(GEN_DBLATEX_STY)
+@BUILD_MANPAGE_TRUE@ xsltproc -o dvisvgm.sty $(GEN_DBLATEX_STY) $<
+
+@BUILD_MANPAGE_TRUE@dvisvgm.txt: dvisvgm.txt.in ../configure.ac
+@BUILD_MANPAGE_TRUE@ sed -e 's/@VERSION[@]/@VERSION@/g' -e 's/@PACKAGE_BUGREPORT[@]/@PACKAGE_BUGREPORT@/g' $< >$@
+@BUILD_MANPAGE_TRUE@ if [ $< -nt ../configure.ac ]; \
+@BUILD_MANPAGE_TRUE@ then touch -r $< $@; \
+@BUILD_MANPAGE_TRUE@ else touch -r ../configure.ac $@; \
+@BUILD_MANPAGE_TRUE@ fi
-epub: dvisvgm.epub
-html: dvisvgm.html
-man: dvisvgm.1
-pdf: dvisvgm.pdf
+@BUILD_MANPAGE_TRUE@epub: dvisvgm.epub
+@BUILD_MANPAGE_TRUE@html: dvisvgm.html
+@BUILD_MANPAGE_TRUE@man: dvisvgm.1
+@BUILD_MANPAGE_TRUE@md: dvisvgm.md
+@BUILD_MANPAGE_TRUE@pdf: dvisvgm.pdf
clean:
- rm -f dvisvgm.pdf dvisvgm.html dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub
+ rm -f dvisvgm.pdf dvisvgm.html dvisvgm.md dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub
distclean-local:
- rm -f dvisvgm.pdf dvisvgm.html dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub dvisvgm.1
+ rm -f dvisvgm.pdf dvisvgm.html dvisvgm.md dvisvgm-man.xml dvisvgm-article.xml dvisvgm.txt dvisvgm.sty dvisvgm.dvi dvisvgm.epub dvisvgm.1
# Ensure that distribution tarballs always contain a recent manpage, i.e.
# let "make dist" and "make distcheck" fail if dvisvgm.1 can't be built.
-dist-hook:
- @if test ! -f $(dvisvgm_srcdir)/doc/dvisvgm.1; then \
- echo "----------------------------------------------------------------"; \
- echo "manpage file dvisvgm.1 could not be built because one or more of"; \
- echo "the following utilities are missing: asciidoc, xmlto, xsltproc "; \
- echo "----------------------------------------------------------------"; \
- false; \
- fi
+@BUILD_MANPAGE_FALSE@dist-hook:
+@BUILD_MANPAGE_FALSE@ @echo "----------------------------------------------------------------"; \
+@BUILD_MANPAGE_FALSE@ echo "manpage file dvisvgm.1 could not be built because one or more of"; \
+@BUILD_MANPAGE_FALSE@ echo "the following utilities are missing: asciidoc, xmlto, xsltproc "; \
+@BUILD_MANPAGE_FALSE@ echo "----------------------------------------------------------------"; \
+@BUILD_MANPAGE_FALSE@ false;
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/dviware/dvisvgm/doc/conf-dblatex-man.xsl b/dviware/dvisvgm/doc/conf-dblatex-man.xsl
index 9802cdcdcf..2e52f9e96f 100644
--- a/dviware/dvisvgm/doc/conf-dblatex-man.xsl
+++ b/dviware/dvisvgm/doc/conf-dblatex-man.xsl
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is part of dvisvgm -->
-<!-- Copyright (C) 2015-2019 Martin Gieseking <martin.gieseking@uos.de> -->
+<!-- Copyright (C) 2015-2020 Martin Gieseking <martin.gieseking@uos.de> -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- output monospaced text in bold -->
<xsl:template match="literal">
diff --git a/dviware/dvisvgm/doc/conf-dblatex-pdf.xsl b/dviware/dvisvgm/doc/conf-dblatex-pdf.xsl
index 5b9b8c8194..321bc0f4fb 100644
--- a/dviware/dvisvgm/doc/conf-dblatex-pdf.xsl
+++ b/dviware/dvisvgm/doc/conf-dblatex-pdf.xsl
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding="iso-8859-1"?>
<!-- This file is part of dvisvgm -->
-<!-- Copyright (C) 2015-2019 Martin Gieseking <martin.gieseking@uos.de> -->
+<!-- Copyright (C) 2015-2020 Martin Gieseking <martin.gieseking@uos.de> -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="xetex.font">
<xsl:text>\setmainfont{Source Sans Pro}&#10;</xsl:text>
diff --git a/dviware/dvisvgm/doc/dvisvgm.1 b/dviware/dvisvgm/doc/dvisvgm.1
index 5c7cb95e5a..43fd7e1126 100644
--- a/dviware/dvisvgm/doc/dvisvgm.1
+++ b/dviware/dvisvgm/doc/dvisvgm.1
@@ -2,12 +2,12 @@
.\" Title: dvisvgm
.\" Author: Martin Gieseking <martin.gieseking@uos.de>
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\" Date: 2019-11-12
+.\" Date: 2020-03-08
.\" Manual: dvisvgm Manual
-.\" Source: dvisvgm 2.8.2
+.\" Source: dvisvgm 2.9
.\" Language: English
.\"
-.TH "DVISVGM" "1" "2019\-11\-12" "dvisvgm 2\&.8\&.2" "dvisvgm Manual"
+.TH "DVISVGM" "1" "2020\-03\-08" "dvisvgm 2\&.9" "dvisvgm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -46,10 +46,12 @@ SVG is a vector\-based graphics format and therefore dvisvgm tries to convert th
.sp
However, TeX\(cqs main source for font descriptions is Metafont, which produces bitmap output (GF files)\&. That\(cqs why not all obtainable TeX fonts are available in a scalable format\&. In these cases, dvisvgm tries to vectorize Metafont\(cqs output by tracing the glyph bitmaps\&. The results are not as perfect as most (manually optimized) PFB or OTF counterparts, but are nonetheless really nice in most cases\&.
.sp
-When running dvisvgm without option \fB\-\-no\-fonts\fR, it creates \fIfont\fR elements (\fB<font>\fR\&...\fB</font>\fR) to embed the font data into the SVG files\&. Unfortunately, only few SVG renderers support these elements yet\&. Most web browsers and vector graphics applications don\(cqt evaluate them properly so that the text components of the resulting graphics might look strange\&. In order to create more compatible SVG files, command\-line option \fB\-\-no\-fonts\fR can be given to replace the font elements by plain graphics paths\&.
+When running dvisvgm without option \fB\-\-no\-fonts\fR, it creates \fIfont\fR elements (\fB<font>\fR\&...\fB</font>\fR) to embed the font data into the SVG files\&. Unfortunately, only few SVG renderers support these elements yet\&. Most web browsers and vector graphics applications don\(cqt evaluate them properly so that the text components of the resulting graphics might look strange\&. In order to create more compatible SVG files, command\-line option \fB\-\-no\-fonts\fR can be given to replace the font elements by plain graphics paths\&. Most web browsers (but only few external SVG renderers) also suppport WOFF and WOFF2 fonts that can be used instead of the default SVG fonts\&. Option \fB\-\-font\-format\fR offers the functionality to change the format applied to the fonts being embedded\&.
.SH "OPTIONS"
.sp
dvisvgm provides a POSIX\-compliant command\-line interface with short and long option names\&. They may be given before and/or after the name of the file to be converted\&. Also, the order of specifying the options is not significant, i\&.e\&. you can add them in any order without changing dvisvgm\(cqs behavior\&. Certain options accept or require additional parameters which are directly appended to or separated by whitespace from a short option (e\&.g\&. \fB\-v0\fR or \fB\-v 0\fR)\&. Long options require an additional equals sign (\fB=\fR) between option name and argument but without any surrounding whitespace (e\&.g\&. \fB\-\-verbosity=0\fR)\&. Multiple short options that don\(cqt expect a further parameter can be combined after a single dash (e\&.g\&. \fB\-ejs\fR rather than \fB\-e \-j \-s\fR)\&.
+.sp
+Long option names may also be shortened by omitting trailing characters\&. As long as the shortened name is unambiguous, it\(cqs recognized and applied\&. For example, option \fB\-\-exact\-bbox\fR can be shortened to \fB\-\-exact\fR, \fB\-\-exa\fR, or \fB\-\-ex\fR\&. In case of an ambiguous abbreviation, dvisvgm prints an error message together with all matching option names\&.
.PP
\fB\-b, \-\-bbox\fR=\fIfmt\fR
.RS 4
@@ -161,6 +163,85 @@ only affects the bounding box and does not transform the page content\&. Hence,
.RE
.RE
.PP
+\fB\-B, \-\-bitmap\-format\fR=\fIfmt\fR
+.RS 4
+This option sets the image format used to embed bitmaps extracted from PostScript or PDF data\&. By default, dvisvgm embeds all bitmaps as JPEG images because it\(cqs the most compact of the two formats supported by SVG\&. To select the alternative lossless PNG format,
+\fB\-\-bitmap\-format=png\fR
+can be used\&. There are some more format variants dvisvgm currently supports even though
+\fBjpeg\fR
+and
+\fBpng\fR
+should be sufficient in most cases\&. The following list gives an overview of the known format names which correspond to names of Ghostscript output devices\&.
+.TS
+tab(:);
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt
+lt lt.
+T{
+\fBnone\fR
+T}:T{
+disable processing of bitmap images
+T}
+T{
+\fBjpeg\fR
+T}:T{
+color JPEG format
+T}
+T{
+\fBjpeggray\fR
+T}:T{
+grayscale JPEG format
+T}
+T{
+\fBpng\fR
+T}:T{
+grayscale or 24\-bit color PNG format depending on current color space
+T}
+T{
+\fBpnggray\fR
+T}:T{
+grayscale PNG format
+T}
+T{
+\fBpngmono\fR
+T}:T{
+black\-and\-white PNG format
+T}
+T{
+\fBpngmonod\fR
+T}:T{
+dithered black\-and\-white PNG format
+T}
+T{
+\fBpng16\fR
+T}:T{
+4\-bit color PNG format
+T}
+T{
+\fBpng256\fR
+T}:T{
+8\-bit color PNG format
+T}
+T{
+\fBpng16m\fR
+T}:T{
+24\-bit color PNG format
+T}
+.TE
+.sp 1
+Since the collection of supported output devices can vary among local Ghostscript installations, not all formats may be available in some environments\&. dvisvgm quits with a PostScript error message if the selected output format requires a locally unsupported output device\&.
+.sp
+The two JPEG format specifiers accept an optional parameter to set the IJG quality level which must directly follow the format specifier separated by a colon, e\&.g\&.
+\fB\-\-bitmap\-format=jpeg:50\fR\&. The quality value is an integer between 0 and 100\&. Higher values result in better image quality but lower compression rates and therefore larger files\&. The default quality level is 75 which is applied if no quality parameter is given or if it\(cqs set to 0\&.
+.RE
+.PP
\fB\-C, \-\-cache\fR[=\fIdir\fR]
.RS 4
To speed up the conversion process of bitmap fonts, dvisvgm saves intermediate conversion information in cache files\&. By default, these files are stored in
@@ -317,7 +398,7 @@ dvipdfm (\m[blue]https://ctan.org/tex-archive/dviware/dvipdfm\m[])\&.
.RS 4
Tells dvisvgm to create overlapping grid segments when approximating color gradient fills (also see option
\fB\-\-grad\-segments\fR
-below)\&. By default, adjacent segments don\(cqt overlap but only touch each other like separate tiles\&. However, this alignment can lead to visible gaps between the segments because the background color usually influences the color at the boundary of the segments if the SVG renderer uses anti\-aliasing to create smooth contours\&. One way to avoid this and to create seamlessly touching color regions is to enlarge the segments so that they extent into the area of their right and bottom neighbors\&. Since the latter are drawn on top of the overlapping parts, the visible size of all segments keeps unchanged\&. Just the former gaps disappear as the background is now completely covered by the correct colors\&. Currently, dvisvgm computes the overlapping segments separately for each patch of the mesh (a patch mesh may consist of multiple patches of the same type)\&. Therefore, there still might be visible gaps at the seam of two adjacent patches\&.
+below)\&. By default, adjacent segments don\(cqt overlap but only touch each other like separate tiles\&. However, this alignment can lead to visible gaps between the segments because the background color usually influences the color at the boundary of the segments if the SVG renderer uses anti\-aliasing to create smooth contours\&. One way to avoid this and to create seamlessly touching color regions is to enlarge the segments so that they extend into the area of their right and bottom neighbors\&. Since the latter are drawn on top of the overlapping parts, the visible size of all segments keeps unchanged\&. Just the former gaps disappear as the background is now completely covered by the correct colors\&. Currently, dvisvgm computes the overlapping segments separately for each patch of the mesh (a patch mesh may consist of multiple patches of the same type)\&. Therefore, there still might be visible gaps at the seam of two adjacent patches\&.
.RE
.PP
\fB\-\-grad\-segments\fR=\fInumber\fR
@@ -341,6 +422,15 @@ If the size of the segments created to approximate gradient color fills falls be
Prints a short summary of all available command\-line options\&. The optional
\fImode\fR
parameter is an integer value between 0 and 2\&. It selects the display variant of the help text\&. Mode 0 lists all options divided into categories with section headers\&. This is also the default if dvisvgm is called without parameters\&. Mode 1 lists all options ordered by the short option names, while mode 2 sorts the lines by the long option names\&.
+.sp
+A values in brackets after the description text indicate the default parameter of the option\&. They are applied if an option with a mandatory parameter is not used or if an optional parameter is omitted\&. For example, option
+\fB\-\-bbox\fR
+requires a size parameter which defaults to
+\fBmin\fR
+if
+\fB\-\-bbox\fR
+is not used\&. Option
+\fB\-\-zip\fR, which isn\(cqt applied by default, accepts an optional compression level parameter\&. If it\(cqs omitted, the stated default value 9 is used\&.
.RE
.PP
\fB\-\-keep\fR
@@ -1591,4 +1681,4 @@ Please report bugs using the bug tracker at GitHub (\m[blue]https://github.com/m
Written by Martin Gieseking <\m[blue]\fBmartin\&.gieseking@uos\&.de\fR\m[]>
.SH "COPYING"
.sp
-Copyright \(co 2005\-2019 Martin Gieseking\&. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 3 or, (at your option) any later version\&.
+Copyright \(co 2005\-2020 Martin Gieseking\&. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 3 or, (at your option) any later version\&.
diff --git a/dviware/dvisvgm/doc/dvisvgm.txt.in b/dviware/dvisvgm/doc/dvisvgm.txt.in
index 1b5c669252..7afc9138b9 100644
--- a/dviware/dvisvgm/doc/dvisvgm.txt.in
+++ b/dviware/dvisvgm/doc/dvisvgm.txt.in
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////
// This file is part of dvisvgm -- a fast DVI to SVG converter //
-// Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> //
+// Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> //
// //
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the GNU General Public License as //
@@ -22,7 +22,7 @@ Martin Gieseking <@PACKAGE_BUGREPORT@>
:man source: dvisvgm
:man version: @VERSION@
:man manual: dvisvgm Manual
-:revdate: 2019-11-12 20:21 +0100
+:revdate: 2020-03-08 09:20 +0100
Name
----
@@ -69,7 +69,9 @@ to embed the font data into the SVG files. Unfortunately, only few SVG renderers
elements yet. Most web browsers and vector graphics applications don't evaluate them properly so
that the text components of the resulting graphics might look strange. In order to create more
compatible SVG files, command-line option *--no-fonts* can be given to replace the font elements
-by plain graphics paths.
+by plain graphics paths. Most web browsers (but only few external SVG renderers) also suppport
+WOFF and WOFF2 fonts that can be used instead of the default SVG fonts. Option *--font-format*
+offers the functionality to change the format applied to the fonts being embedded.
Options
@@ -83,6 +85,11 @@ require an additional equals sign (+=+) between option name and argument but wit
whitespace (e.g. +--verbosity=0+). Multiple short options that don't expect a further parameter can
be combined after a single dash (e.g. +-ejs+ rather than +-e -j -s+).
+Long option names may also be shortened by omitting trailing characters. As long as the shortened
+name is unambiguous, it's recognized and applied. For example, option +--exact-bbox+ can be shortened
+to +--exact+, +--exa+, or +--ex+. In case of an ambiguous abbreviation, dvisvgm prints an error
+message together with all matching option names.
+
*-b, --bbox*='fmt'::
Sets the bounding box of the generated graphic to the specified format. The parameter 'fmt'
takes either one of the format specifiers listed below, or a sequence of four comma- or
@@ -106,11 +113,11 @@ Additionally, dvisvgm also supports the following format specifiers:
*Special bounding box sizes*;;
[horizontal]
- *dvi*::: page size stored in the DVI file
- *min*::: computes the minimal/tightest bounding box
- *none*::: no bounding box is assigned
- *papersize*::: box sizes specified by 'papersize' specials present in the DVI file
- *preview*::: bounding box data computed by the preview package (if present in the DVI file)
+ *dvi* ::: page size stored in the DVI file
+ *min* ::: computes the minimal/tightest bounding box
+ *none* ::: no bounding box is assigned
+ *papersize* ::: box sizes specified by 'papersize' specials present in the DVI file
+ *preview* ::: bounding box data computed by the preview package (if present in the DVI file)
//
*Page orientation*;;
The default page orientation for DIN/ISO and American paper sizes is 'portrait',
@@ -128,6 +135,38 @@ Hence, if you choose a landscape format, the page won't be rotated.
//
//
+*-B, --bitmap-format*='fmt'::
+This option sets the image format used to embed bitmaps extracted from PostScript or PDF data.
+By default, dvisvgm embeds all bitmaps as JPEG images because it's the most compact of the two formats
+supported by SVG. To select the alternative lossless PNG format, *--bitmap-format=png* can be used.
+There are some more format variants dvisvgm currently supports even though +jpeg+ and +png+ should be
+sufficient in most cases. The following list gives an overview of the known format names which
+correspond to names of Ghostscript output devices.
++
+--
+[horizontal]
+*none* ::: disable processing of bitmap images
+*jpeg* ::: color JPEG format
+*jpeggray* ::: grayscale JPEG format
+*png* ::: grayscale or 24-bit color PNG format depending on current color space
+*pnggray* ::: grayscale PNG format
+*pngmono* ::: black-and-white PNG format
+*pngmonod* ::: dithered black-and-white PNG format
+*png16* ::: 4-bit color PNG format
+*png256* ::: 8-bit color PNG format
+*png16m* ::: 24-bit color PNG format
+--
++
+Since the collection of supported output devices can vary among local Ghostscript installations,
+not all formats may be available in some environments. dvisvgm quits with a PostScript error message
+if the selected output format requires a locally unsupported output device.
++
+The two JPEG format specifiers accept an optional parameter to set the IJG quality level
+which must directly follow the format specifier separated by a colon, e.g. *--bitmap-format=jpeg:50*.
+The quality value is an integer between 0 and 100. Higher values result in better image quality but
+lower compression rates and therefore larger files. The default quality level is 75 which is applied
+if no quality parameter is given or if it's set to 0.
+
*-C, --cache*[='dir']::
To speed up the conversion process of bitmap fonts, dvisvgm saves intermediate conversion
information in cache files. By default, these files are stored in +$XDG_CACHE_HOME/dvisvgm/+
@@ -232,7 +271,7 @@ like separate tiles. However, this alignment can lead to visible gaps between th
because the background color usually influences the color at the boundary of the segments if the
SVG renderer uses anti-aliasing to create smooth contours.
One way to avoid this and to create seamlessly touching color regions is to enlarge the segments so
-that they extent into the area of their right and bottom neighbors. Since the latter are drawn on top
+that they extend into the area of their right and bottom neighbors. Since the latter are drawn on top
of the overlapping parts, the visible size of all segments keeps unchanged. Just the former gaps
disappear as the background is now completely covered by the correct colors.
Currently, dvisvgm computes the overlapping segments separately for each patch of the mesh (a patch mesh
@@ -265,6 +304,12 @@ an integer value between 0 and 2. It selects the display variant of the help tex
lists all options divided into categories with section headers. This is also the default if
dvisvgm is called without parameters. Mode 1 lists all options ordered by the short option names,
while mode 2 sorts the lines by the long option names.
++
+A values in brackets after the description text indicate the default parameter of the option. They
+are applied if an option with a mandatory parameter is not used or if an optional parameter is omitted.
+For example, option *--bbox* requires a size parameter which defaults to +min+ if *--bbox* is not
+used. Option *--zip*, which isn't applied by default, accepts an optional compression level parameter.
+If it's omitted, the stated default value 9 is used.
*--keep*::
Disables the removal of temporary files as created by Metafont (usually .gf, .tfm, and .log files) or
@@ -944,7 +989,7 @@ Written by {author} <{email}>
Copying
-------
-Copyright (C) 2005-2019 Martin Gieseking. Free use of this software is
+Copyright (C) 2005-2020 Martin Gieseking. Free use of this software is
granted under the terms of the GNU General Public License (GPL) version 3
or, (at your option) any later version.
diff --git a/dviware/dvisvgm/doc/generate-dvisvgm-sty.xsl b/dviware/dvisvgm/doc/generate-dvisvgm-sty.xsl
index 9ce456d1b3..bdb279da99 100644
--- a/dviware/dvisvgm/doc/generate-dvisvgm-sty.xsl
+++ b/dviware/dvisvgm/doc/generate-dvisvgm-sty.xsl
@@ -7,6 +7,8 @@
\ProvidesPackage{dvisvgm}[2015/02/04 dvisvgm DocBook style]
\RequirePackageWithOptions{docbook}
\RequirePackage[english]{babel}
+\RequirePackage{underscore}
+\renewcommand*{\arraystretch}{-0.4}
\AtBeginDocument{%
\thispagestyle{empty}
\lhead[]{\refmiscinfomanual}
@@ -16,4 +18,4 @@
\def\tableofcontents{\stdtoc} % keep TOC on current page
}
</xsl:template>
-</xsl:stylesheet> \ No newline at end of file
+</xsl:stylesheet>
diff --git a/dviware/dvisvgm/doc/tweak-db-refentry.xsl b/dviware/dvisvgm/doc/tweak-db-refentry.xsl
index 088e2ce434..1750d7a4f7 100644
--- a/dviware/dvisvgm/doc/tweak-db-refentry.xsl
+++ b/dviware/dvisvgm/doc/tweak-db-refentry.xsl
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!-- This file is part of dvisvgm -->
-<!-- Copyright (C) 2015-2019 Martin Gieseking <martin.gieseking@uos.de> -->
+<!-- Copyright (C) 2015-2020 Martin Gieseking <martin.gieseking@uos.de> -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
diff --git a/dviware/dvisvgm/doc/tweak-dblatex-pdf.xsl b/dviware/dvisvgm/doc/tweak-dblatex-pdf.xsl
index 8b07434845..d1762adecb 100644
--- a/dviware/dvisvgm/doc/tweak-dblatex-pdf.xsl
+++ b/dviware/dvisvgm/doc/tweak-dblatex-pdf.xsl
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is part of dvisvgm -->
-<!-- Copyright (C) 2015-2019 Martin Gieseking <martin.gieseking@uos.de> -->
+<!-- Copyright (C) 2015-2020 Martin Gieseking <martin.gieseking@uos.de> -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output doctype-public="-//OASIS//DTD DocBook XML V4.5//EN" doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
diff --git a/dviware/dvisvgm/libs/Makefile.am b/dviware/dvisvgm/libs/Makefile.am
index 7b6b80229d..6b6e0433e4 100644
--- a/dviware/dvisvgm/libs/Makefile.am
+++ b/dviware/dvisvgm/libs/Makefile.am
@@ -1,5 +1,5 @@
## This file is part of dvisvgm
-## Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
diff --git a/dviware/dvisvgm/libs/ff-woff/fontforge/tmpfile2.cpp b/dviware/dvisvgm/libs/ff-woff/fontforge/tmpfile2.cpp
index a3ef480662..d9e5280b2c 100644
--- a/dviware/dvisvgm/libs/ff-woff/fontforge/tmpfile2.cpp
+++ b/dviware/dvisvgm/libs/ff-woff/fontforge/tmpfile2.cpp
@@ -3,7 +3,7 @@
* works on POSIX and Windows systems.
* License: Revised BSD license used by FontForge
* https://github.com/fontforge/fontforge/blob/master/LICENSE
-* (C) 2017-2019 Martin Gieseking <martin.gieseking@uos.de> */
+* (C) 2017-2020 Martin Gieseking <martin.gieseking@uos.de> */
#include <cstdio>
#include <cstdlib>
diff --git a/dviware/dvisvgm/libs/xxHash/xxh3.h b/dviware/dvisvgm/libs/xxHash/xxh3.h
index b3a8295845..9e3e88ad61 100644
--- a/dviware/dvisvgm/libs/xxHash/xxh3.h
+++ b/dviware/dvisvgm/libs/xxHash/xxh3.h
@@ -1,50 +1,54 @@
/*
- xxHash - Extremely Fast Hash algorithm
- Development source file for `xxh3`
- Copyright (C) 2019-present, Yann Collet.
-
- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following disclaimer
- in the documentation and/or other materials provided with the
- distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- You can contact the author at :
- - xxHash source repository : https://github.com/Cyan4973/xxHash
-*/
-
-/* Note :
- This file is separated for development purposes.
- It will be integrated into `xxhash.c` when development phase is complete.
-*/
-
-#ifndef XXH3_H
-#define XXH3_H
+ * xxHash - Extremely Fast Hash algorithm
+ * Development source file for `xxh3`
+ * Copyright (C) 2019-present, Yann Collet
+ *
+ * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at:
+ * - xxHash homepage: https://www.xxhash.com
+ * - xxHash source repository: https://github.com/Cyan4973/xxHash
+ */
+/*
+ * Note: This file is separated for development purposes.
+ * It will be integrated into `xxhash.h` when development stage is completed.
+ *
+ * Credit: most of the work on vectorial and asm variants comes from @easyaspi314
+ */
-/* === Dependencies === */
+#ifndef XXH3_H_1397135465
+#define XXH3_H_1397135465
-#undef XXH_INLINE_ALL /* in case it's already defined */
-#define XXH_INLINE_ALL
+/* === Dependencies === */
+#ifndef XXHASH_H_5627135585666179
+/* special: when including `xxh3.h` directly, turn on XXH_INLINE_ALL */
+# undef XXH_INLINE_ALL /* avoid redefinition */
+# define XXH_INLINE_ALL
+#endif
#include "xxhash.h"
@@ -53,10 +57,20 @@
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* >= C99 */
# define XXH_RESTRICT restrict
#else
-/* note : it might be useful to define __restrict or __restrict__ for some C++ compilers */
+/* Note: it might be useful to define __restrict or __restrict__ for some C++ compilers */
# define XXH_RESTRICT /* disable */
#endif
+#if (defined(__GNUC__) && (__GNUC__ >= 3)) \
+ || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) \
+ || defined(__clang__)
+# define XXH_likely(x) __builtin_expect(x, 1)
+# define XXH_unlikely(x) __builtin_expect(x, 0)
+#else
+# define XXH_likely(x) (x)
+# define XXH_unlikely(x) (x)
+#endif
+
#if defined(__GNUC__)
# if defined(__AVX2__)
# include <immintrin.h>
@@ -72,17 +86,50 @@
#endif
/*
- * Sanity check.
+ * One goal of XXH3 is to make it fast on both 32-bit and 64-bit, while
+ * remaining a true 64-bit/128-bit hash function.
+ *
+ * This is done by prioritizing a subset of 64-bit operations that can be
+ * emulated without too many steps on the average 32-bit machine.
+ *
+ * For example, these two lines seem similar, and run equally fast on 64-bit:
*
- * XXH3 only requires these features to be efficient:
+ * xxh_u64 x;
+ * x ^= (x >> 47); // good
+ * x ^= (x >> 13); // bad
+ *
+ * However, to a 32-bit machine, there is a major difference.
+ *
+ * x ^= (x >> 47) looks like this:
+ *
+ * x.lo ^= (x.hi >> (47 - 32));
+ *
+ * while x ^= (x >> 13) looks like this:
+ *
+ * // note: funnel shifts are not usually cheap.
+ * x.lo ^= (x.lo >> 13) | (x.hi << (32 - 13));
+ * x.hi ^= (x.hi >> 13);
+ *
+ * The first one is significantly faster than the second, simply because the
+ * shift is larger than 32. This means:
+ * - All the bits we need are in the upper 32 bits, so we can ignore the lower
+ * 32 bits in the shift.
+ * - The shift result will always fit in the lower 32 bits, and therefore,
+ * we can ignore the upper 32 bits in the xor.
+ *
+ * Thanks to this optimization, XXH3 only requires these features to be efficient:
*
* - Usable unaligned access
* - A 32-bit or 64-bit ALU
* - If 32-bit, a decent ADC instruction
* - A 32 or 64-bit multiply with a 64-bit result
+ * - For the 128-bit variant, a decent byteswap helps short inputs.
+ *
+ * The first two are already required by XXH32, and almost all 32-bit and 64-bit
+ * platforms which can run XXH32 can run XXH3 efficiently.
*
- * Almost all 32-bit and 64-bit targets meet this, except for Thumb-1, the
- * classic 16-bit only subset of ARM's instruction set.
+ * Thumb-1, the classic 16-bit only subset of ARM's instruction set, is one
+ * notable exception.
*
* First of all, Thumb-1 lacks support for the UMULL instruction which
* performs the important long multiply. This means numerous __aeabi_lmul
@@ -93,14 +140,16 @@
* Lo registers, and this shuffling results in thousands more MOVs than A32.
*
* A32 and T32 don't have this limitation. They can access all 14 registers,
- * do a 32->64 multiply with UMULL, and the flexible operand is helpful too.
+ * do a 32->64 multiply with UMULL, and the flexible operand allowing free
+ * shifts is helpful, too.
*
- * If compiling Thumb-1 for a target which supports ARM instructions, we
- * will give a warning.
+ * Therefore, we do a quick sanity check.
*
- * Usually, if this happens, it is because of an accident and you probably
- * need to specify -march, as you probably meant to compileh for a newer
- * architecture.
+ * If compiling Thumb-1 for a target which supports ARM instructions, we will
+ * emit a warning, as it is not a "sane" platform to compile for.
+ *
+ * Usually, if this happens, it is because of an accident and you probably need
+ * to specify -march, as you likely meant to compile for a newer architecture.
*/
#if defined(__thumb__) && !defined(__thumb2__) && defined(__ARM_ARCH_ISA_ARM)
# warning "XXH3 is highly inefficient without ARM or Thumb-2."
@@ -109,11 +158,11 @@
/* ==========================================
* Vectorization detection
* ========================================== */
-#define XXH_SCALAR 0
-#define XXH_SSE2 1
-#define XXH_AVX2 2
-#define XXH_NEON 3
-#define XXH_VSX 4
+#define XXH_SCALAR 0 /* Portable scalar version */
+#define XXH_SSE2 1 /* SSE2 for Pentium 4 and all x86_64 */
+#define XXH_AVX2 2 /* AVX2 for Haswell and Bulldozer */
+#define XXH_NEON 3 /* NEON for most ARMv7-A and all AArch64 */
+#define XXH_VSX 4 /* VSX and ZVector for POWER8/z13 */
#ifndef XXH_VECTOR /* can be defined on command line */
# if defined(__AVX2__)
@@ -125,47 +174,186 @@
&& (defined(__LITTLE_ENDIAN__) /* We only support little endian NEON */ \
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
# define XXH_VECTOR XXH_NEON
-# elif defined(__PPC64__) && defined(__POWER8_VECTOR__) && defined(__GNUC__)
+# elif (defined(__PPC64__) && defined(__POWER8_VECTOR__)) \
+ || (defined(__s390x__) && defined(__VEC__)) \
+ && defined(__GNUC__) /* TODO: IBM XL */
# define XXH_VECTOR XXH_VSX
# else
# define XXH_VECTOR XXH_SCALAR
# endif
#endif
-/* control alignment of accumulator,
- * for compatibility with fast vector loads */
+/*
+ * Controls the alignment of the accumulator.
+ * This is for compatibility with aligned vector loads, which are usually faster.
+ */
#ifndef XXH_ACC_ALIGN
-# if XXH_VECTOR == 0 /* scalar */
+# if XXH_VECTOR == XXH_SCALAR /* scalar */
# define XXH_ACC_ALIGN 8
-# elif XXH_VECTOR == 1 /* sse2 */
+# elif XXH_VECTOR == XXH_SSE2 /* sse2 */
# define XXH_ACC_ALIGN 16
-# elif XXH_VECTOR == 2 /* avx2 */
+# elif XXH_VECTOR == XXH_AVX2 /* avx2 */
# define XXH_ACC_ALIGN 32
-# elif XXH_VECTOR == 3 /* neon */
+# elif XXH_VECTOR == XXH_NEON /* neon */
# define XXH_ACC_ALIGN 16
-# elif XXH_VECTOR == 4 /* vsx */
+# elif XXH_VECTOR == XXH_VSX /* vsx */
# define XXH_ACC_ALIGN 16
# endif
#endif
-/* xxh_u64 XXH_mult32to64(xxh_u32 a, xxh_u64 b) { return (xxh_u64)a * (xxh_u64)b; } */
-#if defined(_MSC_VER) && defined(_M_IX86)
-# include <intrin.h>
-# define XXH_mult32to64(x, y) __emulu(x, y)
-#else
-# define XXH_mult32to64(x, y) ((xxh_u64)((x) & 0xFFFFFFFF) * (xxh_u64)((y) & 0xFFFFFFFF))
+/*
+ * UGLY HACK:
+ * GCC usually generates the best code with -O3 for xxHash.
+ *
+ * However, when targeting AVX2, it is overzealous in its unrolling resulting
+ * in code roughly 3/4 the speed of Clang.
+ *
+ * There are other issues, such as GCC splitting _mm256_loadu_si256 into
+ * _mm_loadu_si128 + _mm256_inserti128_si256. This is an optimization which
+ * only applies to Sandy and Ivy Bridge... which don't even support AVX2.
+ *
+ * That is why when compiling the AVX2 version, it is recommended to use either
+ * -O2 -mavx2 -march=haswell
+ * or
+ * -O2 -mavx2 -mno-avx256-split-unaligned-load
+ * for decent performance, or to use Clang instead.
+ *
+ * Fortunately, we can control the first one with a pragma that forces GCC into
+ * -O2, but the other one we can't control without "failed to inline always
+ * inline function due to target mismatch" warnings.
+ */
+#if XXH_VECTOR == XXH_AVX2 /* AVX2 */ \
+ && defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \
+ && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) /* respect -O0 and -Os */
+# pragma GCC push_options
+# pragma GCC optimize("-O2")
#endif
-/* VSX stuff. It's a lot because VSX support is mediocre across compilers and
- * there is a lot of mischief with endianness. */
+
+#if XXH_VECTOR == XXH_NEON
+/*
+ * NEON's setup for vmlal_u32 is a little more complicated than it is on
+ * SSE2, AVX2, and VSX.
+ *
+ * While PMULUDQ and VMULEUW both perform a mask, VMLAL.U32 performs an upcast.
+ *
+ * To do the same operation, the 128-bit 'Q' register needs to be split into
+ * two 64-bit 'D' registers, performing this operation::
+ *
+ * [ a | b ]
+ * | '---------. .--------' |
+ * | x |
+ * | .---------' '--------. |
+ * [ a & 0xFFFFFFFF | b & 0xFFFFFFFF ],[ a >> 32 | b >> 32 ]
+ *
+ * Due to significant changes in aarch64, the fastest method for aarch64 is
+ * completely different than the fastest method for ARMv7-A.
+ *
+ * ARMv7-A treats D registers as unions overlaying Q registers, so modifying
+ * D11 will modify the high half of Q5. This is similar to how modifying AH
+ * will only affect bits 8-15 of AX on x86.
+ *
+ * VZIP takes two registers, and puts even lanes in one register and odd lanes
+ * in the other.
+ *
+ * On ARMv7-A, this strangely modifies both parameters in place instead of
+ * taking the usual 3-operand form.
+ *
+ * Therefore, if we want to do this, we can simply use a D-form VZIP.32 on the
+ * lower and upper halves of the Q register to end up with the high and low
+ * halves where we want - all in one instruction.
+ *
+ * vzip.32 d10, d11 @ d10 = { d10[0], d11[0] }; d11 = { d10[1], d11[1] }
+ *
+ * Unfortunately we need inline assembly for this: Instructions modifying two
+ * registers at once is not possible in GCC or Clang's IR, and they have to
+ * create a copy.
+ *
+ * aarch64 requires a different approach.
+ *
+ * In order to make it easier to write a decent compiler for aarch64, many
+ * quirks were removed, such as conditional execution.
+ *
+ * NEON was also affected by this.
+ *
+ * aarch64 cannot access the high bits of a Q-form register, and writes to a
+ * D-form register zero the high bits, similar to how writes to W-form scalar
+ * registers (or DWORD registers on x86_64) work.
+ *
+ * The formerly free vget_high intrinsics now require a vext (with a few
+ * exceptions)
+ *
+ * Additionally, VZIP was replaced by ZIP1 and ZIP2, which are the equivalent
+ * of PUNPCKL* and PUNPCKH* in SSE, respectively, in order to only modify one
+ * operand.
+ *
+ * The equivalent of the VZIP.32 on the lower and upper halves would be this
+ * mess:
+ *
+ * ext v2.4s, v0.4s, v0.4s, #2 // v2 = { v0[2], v0[3], v0[0], v0[1] }
+ * zip1 v1.2s, v0.2s, v2.2s // v1 = { v0[0], v2[0] }
+ * zip2 v0.2s, v0.2s, v1.2s // v0 = { v0[1], v2[1] }
+ *
+ * Instead, we use a literal downcast, vmovn_u64 (XTN), and vshrn_n_u64 (SHRN):
+ *
+ * shrn v1.2s, v0.2d, #32 // v1 = (uint32x2_t)(v0 >> 32);
+ * xtn v0.2s, v0.2d // v0 = (uint32x2_t)(v0 & 0xFFFFFFFF);
+ *
+ * This is available on ARMv7-A, but is less efficient than a single VZIP.32.
+ */
+
+/*
+ * Function-like macro:
+ * void XXH_SPLIT_IN_PLACE(uint64x2_t &in, uint32x2_t &outLo, uint32x2_t &outHi)
+ * {
+ * outLo = (uint32x2_t)(in & 0xFFFFFFFF);
+ * outHi = (uint32x2_t)(in >> 32);
+ * in = UNDEFINED;
+ * }
+ */
+# if !defined(XXH_NO_VZIP_HACK) /* define to disable */ \
+ && defined(__GNUC__) \
+ && !defined(__aarch64__) && !defined(__arm64__)
+# define XXH_SPLIT_IN_PLACE(in, outLo, outHi) \
+ do { \
+ /* Undocumented GCC/Clang operand modifier: %e0 = lower D half, %f0 = upper D half */ \
+ /* https://github.com/gcc-mirror/gcc/blob/38cf91e5/gcc/config/arm/arm.c#L22486 */ \
+ /* https://github.com/llvm-mirror/llvm/blob/2c4ca683/lib/Target/ARM/ARMAsmPrinter.cpp#L399 */ \
+ __asm__("vzip.32 %e0, %f0" : "+w" (in)); \
+ (outLo) = vget_low_u32 (vreinterpretq_u32_u64(in)); \
+ (outHi) = vget_high_u32(vreinterpretq_u32_u64(in)); \
+ } while (0)
+# else
+# define XXH_SPLIT_IN_PLACE(in, outLo, outHi) \
+ do { \
+ (outLo) = vmovn_u64 (in); \
+ (outHi) = vshrn_n_u64 ((in), 32); \
+ } while (0)
+# endif
+#endif /* XXH_VECTOR == XXH_NEON */
+
+/*
+ * VSX and Z Vector helpers.
+ *
+ * This is very messy, and any pull requests to clean this up are welcome.
+ *
+ * There are a lot of problems with supporting VSX and s390x, due to
+ * inconsistent intrinsics, spotty coverage, and multiple endiannesses.
+ */
#if XXH_VECTOR == XXH_VSX
-# include <altivec.h>
-# undef vector
-typedef __vector unsigned long long U64x2;
-typedef __vector unsigned char U8x16;
-typedef __vector unsigned U32x4;
+# if defined(__s390x__)
+# include <s390intrin.h>
+# else
+# include <altivec.h>
+# endif
-#ifndef XXH_VSX_BE
+# undef vector /* Undo the pollution */
+
+typedef __vector unsigned long long xxh_u64x2;
+typedef __vector unsigned char xxh_u8x16;
+typedef __vector unsigned xxh_u32x4;
+
+# ifndef XXH_VSX_BE
# if defined(__BIG_ENDIAN__) \
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
# define XXH_VSX_BE 1
@@ -175,67 +363,82 @@ typedef __vector unsigned U32x4;
# else
# define XXH_VSX_BE 0
# endif
-#endif
+# endif /* !defined(XXH_VSX_BE) */
-/* We need some helpers for big endian mode. */
-#if XXH_VSX_BE
+# if XXH_VSX_BE
/* A wrapper for POWER9's vec_revb. */
-# ifdef __POWER9_VECTOR__
+# if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__))
# define XXH_vec_revb vec_revb
# else
-XXH_FORCE_INLINE U64x2 XXH_vec_revb(U64x2 val)
+XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val)
{
- U8x16 const vByteSwap = { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
- 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
+ xxh_u8x16 const vByteSwap = { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
+ 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
return vec_perm(val, val, vByteSwap);
}
# endif
+# endif /* XXH_VSX_BE */
-/* Power8 Crypto gives us vpermxor which is very handy for
- * PPC64EB.
- *
- * U8x16 vpermxor(U8x16 a, U8x16 b, U8x16 mask)
- * {
- * U8x16 ret;
- * for (int i = 0; i < 16; i++) {
- * ret[i] = a[mask[i] & 0xF] ^ b[mask[i] >> 4];
- * }
- * return ret;
- * }
- *
- * Because both of the main loops load the key, swap, and xor it with input,
- * we can combine the key swap into this instruction.
+/*
+ * Performs an unaligned load and byte swaps it on big endian.
*/
-# ifdef vec_permxor
-# define XXH_vec_permxor vec_permxor
-# else
-# define XXH_vec_permxor __builtin_crypto_vpermxor
-# endif
-#endif
+XXH_FORCE_INLINE xxh_u64x2 XXH_vec_loadu(const void *ptr)
+{
+ xxh_u64x2 ret;
+ memcpy(&ret, ptr, sizeof(xxh_u64x2));
+# if XXH_VSX_BE
+ ret = XXH_vec_revb(ret);
+# endif
+ return ret;
+}
+
/*
- * Because we reinterpret the multiply, there are endian memes: vec_mulo actually becomes
- * vec_mule.
+ * vec_mulo and vec_mule are very problematic intrinsics on PowerPC
*
- * Additionally, the intrinsic wasn't added until GCC 8, despite existing for a while.
- * Clang has an easy way to control this, we can just use the builtin which doesn't swap.
- * GCC needs inline assembly. */
-#if __has_builtin(__builtin_altivec_vmuleuw)
+ * These intrinsics weren't added until GCC 8, despite existing for a while,
+ * and they are endian dependent. Also, their meaning swap depending on version.
+ * */
+# if defined(__s390x__)
+ /* s390x is always big endian, no issue on this platform */
+# define XXH_vec_mulo vec_mulo
+# define XXH_vec_mule vec_mule
+# elif defined(__clang__) && __has_builtin(__builtin_altivec_vmuleuw)
+/* Clang has a better way to control this, we can just use the builtin which doesn't swap. */
# define XXH_vec_mulo __builtin_altivec_vmulouw
# define XXH_vec_mule __builtin_altivec_vmuleuw
-#else
+# else
+/* gcc needs inline assembly */
/* Adapted from https://github.com/google/highwayhash/blob/master/highwayhash/hh_vsx.h. */
-XXH_FORCE_INLINE U64x2 XXH_vec_mulo(U32x4 a, U32x4 b) {
- U64x2 result;
+XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mulo(xxh_u32x4 a, xxh_u32x4 b)
+{
+ xxh_u64x2 result;
__asm__("vmulouw %0, %1, %2" : "=v" (result) : "v" (a), "v" (b));
return result;
}
-XXH_FORCE_INLINE U64x2 XXH_vec_mule(U32x4 a, U32x4 b) {
- U64x2 result;
+XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b)
+{
+ xxh_u64x2 result;
__asm__("vmuleuw %0, %1, %2" : "=v" (result) : "v" (a), "v" (b));
return result;
}
-#endif
-#endif
+# endif /* XXH_vec_mulo, XXH_vec_mule */
+#endif /* XXH_VECTOR == XXH_VSX */
+
+
+/* prefetch
+ * can be disabled, by declaring XXH_NO_PREFETCH build macro */
+#if defined(XXH_NO_PREFETCH)
+# define XXH_PREFETCH(ptr) (void)(ptr) /* disabled */
+#else
+# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
+# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
+# define XXH_PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
+# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
+# define XXH_PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
+# else
+# define XXH_PREFETCH(ptr) (void)(ptr) /* disabled */
+# endif
+#endif /* XXH_NO_PREFETCH */
/* ==========================================
@@ -248,6 +451,7 @@ XXH_FORCE_INLINE U64x2 XXH_vec_mule(U32x4 a, U32x4 b) {
# error "default keyset is not large enough"
#endif
+/* Pseudorandom secret taken directly from FARSH */
XXH_ALIGN(64) static const xxh_u8 kSecret[XXH_SECRET_DEFAULT_SIZE] = {
0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c,
0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f,
@@ -265,16 +469,40 @@ XXH_ALIGN(64) static const xxh_u8 kSecret[XXH_SECRET_DEFAULT_SIZE] = {
};
/*
- * GCC for x86 has a tendency to use SSE in this loop. While it
- * successfully avoids swapping (as MUL overwrites EAX and EDX), it
- * slows it down because instead of free register swap shifts, it
- * must use pshufd and punpckl/hd.
+ * Does a 32-bit to 64-bit long multiply.
*
- * To prevent this, we use this attribute to shut off SSE.
+ * Wraps __emulu on MSVC x86 because it tends to call __allmul when it doesn't
+ * need to (but it shouldn't need to anyways, it is about 7 instructions to do
+ * a 64x64 multiply...). Since we know that this will _always_ emit MULL, we
+ * use that instead of the normal method.
+ *
+ * If you are compiling for platforms like Thumb-1 and don't have a better option,
+ * you may also want to write your own long multiply routine here.
+ *
+ * XXH_FORCE_INLINE xxh_u64 XXH_mult32to64(xxh_u64 x, xxh_u64 y)
+ * {
+ * return (x & 0xFFFFFFFF) * (y & 0xFFFFFFFF);
+ * }
+ */
+#if defined(_MSC_VER) && defined(_M_IX86)
+# include <intrin.h>
+# define XXH_mult32to64(x, y) __emulu((unsigned)(x), (unsigned)(y))
+#else
+/*
+ * Downcast + upcast is usually better than masking on older compilers like
+ * GCC 4.2 (especially 32-bit ones), all without affecting newer compilers.
+ *
+ * The other method, (x & 0xFFFFFFFF) * (y & 0xFFFFFFFF), will AND both operands
+ * and perform a full 64x64 multiply -- entirely redundant on 32-bit.
*/
-#if defined(__GNUC__) && !defined(__clang__) && defined(__i386__)
-__attribute__((__target__("no-sse")))
+# define XXH_mult32to64(x, y) ((xxh_u64)(xxh_u32)(x) * (xxh_u64)(xxh_u32)(y))
#endif
+
+/*
+ * Calculates a 64->128-bit long multiply.
+ *
+ * Uses __uint128_t and _umul128 if available, otherwise uses a scalar version.
+ */
static XXH128_hash_t
XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs)
{
@@ -287,9 +515,9 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs)
*
* Usually.
*
- * Despite being a 32-bit platform, Clang (and emscripten) define this
- * type despite not having the arithmetic for it. This results in a
- * laggy compiler builtin call which calculates a full 128-bit multiply.
+ * Despite being a 32-bit platform, Clang (and emscripten) define this type
+ * despite not having the arithmetic for it. This results in a laggy
+ * compiler builtin call which calculates a full 128-bit multiply.
* In that case it is best to use the portable one.
* https://github.com/Cyan4973/xxHash/issues/211#issuecomment-515575677
*/
@@ -322,29 +550,30 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs)
/*
* Portable scalar method. Optimized for 32-bit and 64-bit ALUs.
*
- * This is a fast and simple grade school multiply, which is shown
- * below with base 10 arithmetic instead of base 0x100000000.
+ * This is a fast and simple grade school multiply, which is shown below
+ * with base 10 arithmetic instead of base 0x100000000.
*
* 9 3 // D2 lhs = 93
* x 7 5 // D2 rhs = 75
* ----------
- * 1 5 // D2 lo_lo = (93 % 10) * (75 % 10)
- * 4 5 | // D2 hi_lo = (93 / 10) * (75 % 10)
- * 2 1 | // D2 lo_hi = (93 % 10) * (75 / 10)
- * + 6 3 | | // D2 hi_hi = (93 / 10) * (75 / 10)
+ * 1 5 // D2 lo_lo = (93 % 10) * (75 % 10) = 15
+ * 4 5 | // D2 hi_lo = (93 / 10) * (75 % 10) = 45
+ * 2 1 | // D2 lo_hi = (93 % 10) * (75 / 10) = 21
+ * + 6 3 | | // D2 hi_hi = (93 / 10) * (75 / 10) = 63
* ---------
- * 2 7 | // D2 cross = (15 / 10) + (45 % 10) + 21
- * + 6 7 | | // D2 upper = (27 / 10) + (45 / 10) + 63
+ * 2 7 | // D2 cross = (15 / 10) + (45 % 10) + 21 = 27
+ * + 6 7 | | // D2 upper = (27 / 10) + (45 / 10) + 63 = 67
* ---------
- * 6 9 7 5
+ * 6 9 7 5 // D4 res = (27 * 10) + (15 % 10) + (67 * 100) = 6975
*
* The reasons for adding the products like this are:
* 1. It avoids manual carry tracking. Just like how
- * (9 * 9) + 9 + 9 = 99, the same applies with this for
- * UINT64_MAX. This avoids a lot of complexity.
+ * (9 * 9) + 9 + 9 = 99, the same applies with this for UINT64_MAX.
+ * This avoids a lot of complexity.
*
* 2. It hints for, and on Clang, compiles to, the powerful UMAAL
- * instruction available in ARMv6+ A32/T32, which is shown below:
+ * instruction available in ARM's Digital Signal Processing extension
+ * in 32-bit ARMv6 and later, which is shown below:
*
* void UMAAL(xxh_u32 *RdLo, xxh_u32 *RdHi, xxh_u32 Rn, xxh_u32 Rm)
* {
@@ -353,12 +582,12 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs)
* *RdHi = (xxh_u32)(product >> 32);
* }
*
- * This instruction was designed for efficient long multiplication,
- * and allows this to be calculated in only 4 instructions which
- * is comparable to some 64-bit ALUs.
+ * This instruction was designed for efficient long multiplication, and
+ * allows this to be calculated in only 4 instructions at speeds
+ * comparable to some 64-bit ALUs.
*
- * 3. It isn't terrible on other platforms. Usually this will be
- * a couple of 32-bit ADD/ADCs.
+ * 3. It isn't terrible on other platforms. Usually this will be a couple
+ * of 32-bit ADD/ADCs.
*/
/* First calculate all of the cross products. */
@@ -378,17 +607,11 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs)
}
/*
- * We want to keep the attribute here because a target switch
- * disables inlining.
- *
* Does a 64-bit to 128-bit multiply, then XOR folds it.
- * The reason for the separate function is to prevent passing
- * too many structs around by value. This will hopefully inline
- * the multiply, but we don't force it.
+ *
+ * The reason for the separate function is to prevent passing too many structs
+ * around by value. This will hopefully inline the multiply, but we don't force it.
*/
-#if defined(__GNUC__) && !defined(__clang__) && defined(__i386__)
-__attribute__((__target__("no-sse")))
-#endif
static xxh_u64
XXH3_mul128_fold64(xxh_u64 lhs, xxh_u64 rhs)
{
@@ -396,32 +619,78 @@ XXH3_mul128_fold64(xxh_u64 lhs, xxh_u64 rhs)
return product.low64 ^ product.high64;
}
+/* Seems to produce slightly better code on GCC for some reason. */
+XXH_FORCE_INLINE xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift)
+{
+ XXH_ASSERT(0 <= shift && shift < 64);
+ return v64 ^ (v64 >> shift);
+}
+/*
+ * We don't need to (or want to) mix as much as XXH64.
+ *
+ * Short hashes are more evenly distributed, so it isn't necessary.
+ */
static XXH64_hash_t XXH3_avalanche(xxh_u64 h64)
{
- h64 ^= h64 >> 37;
- h64 *= PRIME64_3;
- h64 ^= h64 >> 32;
+ h64 = XXH_xorshift64(h64, 37);
+ h64 *= 0x165667919E3779F9ULL;
+ h64 = XXH_xorshift64(h64, 32);
return h64;
}
/* ==========================================
* Short keys
- * ========================================== */
+ * ==========================================
+ * One of the shortcomings of XXH32 and XXH64 was that their performance was
+ * sub-optimal on short lengths. It used an iterative algorithm which strongly
+ * favored lengths that were a multiple of 4 or 8.
+ *
+ * Instead of iterating over individual inputs, we use a set of single shot
+ * functions which piece together a range of lengths and operate in constant time.
+ *
+ * Additionally, the number of multiplies has been significantly reduced. This
+ * reduces latency, especially when emulating 64-bit multiplies on 32-bit.
+ *
+ * Depending on the platform, this may or may not be faster than XXH32, but it
+ * is almost guaranteed to be faster than XXH64.
+ */
+/*
+ * At very short lengths, there isn't enough input to fully hide secrets, or use
+ * the entire secret.
+ *
+ * There is also only a limited amount of mixing we can do before significantly
+ * impacting performance.
+ *
+ * Therefore, we use different sections of the secret and always mix two secret
+ * samples with an XOR. This should have no effect on performance on the
+ * seedless or withSeed variants because everything _should_ be constant folded
+ * by modern compilers.
+ *
+ * The XOR mixing hides individual parts of the secret and increases entropy.
+ *
+ * This adds an extra layer of strength for custom secrets.
+ */
XXH_FORCE_INLINE XXH64_hash_t
XXH3_len_1to3_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed)
{
XXH_ASSERT(input != NULL);
XXH_ASSERT(1 <= len && len <= 3);
XXH_ASSERT(secret != NULL);
+ /*
+ * len = 1: combined = { input[0], 0x01, input[0], input[0] }
+ * len = 2: combined = { input[1], 0x02, input[0], input[1] }
+ * len = 3: combined = { input[2], 0x03, input[0], input[1] }
+ */
{ xxh_u8 const c1 = input[0];
xxh_u8 const c2 = input[len >> 1];
xxh_u8 const c3 = input[len - 1];
- xxh_u32 const combined = ((xxh_u32)c1) | (((xxh_u32)c2) << 8) | (((xxh_u32)c3) << 16) | (((xxh_u32)len) << 24);
- xxh_u64 const keyed = (xxh_u64)combined ^ (XXH_readLE32(secret) + seed);
- xxh_u64 const mixed = keyed * PRIME64_1;
+ xxh_u32 const combined = ((xxh_u32)c1<<16) | (((xxh_u32)c2) << 24) | (((xxh_u32)c3) << 0) | (((xxh_u32)len) << 8);
+ xxh_u64 const bitflip = (XXH_readLE32(secret) ^ XXH_readLE32(secret+4)) + seed;
+ xxh_u64 const keyed = (xxh_u64)combined ^ bitflip;
+ xxh_u64 const mixed = keyed * PRIME64_1;
return XXH3_avalanche(mixed);
}
}
@@ -431,13 +700,19 @@ XXH3_len_4to8_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h
{
XXH_ASSERT(input != NULL);
XXH_ASSERT(secret != NULL);
- XXH_ASSERT(4 <= len && len <= 8);
- { xxh_u32 const input_lo = XXH_readLE32(input);
- xxh_u32 const input_hi = XXH_readLE32(input + len - 4);
- xxh_u64 const input_64 = input_lo | ((xxh_u64)input_hi << 32);
- xxh_u64 const keyed = input_64 ^ (XXH_readLE64(secret) + seed);
- xxh_u64 const mix64 = len + ((keyed ^ (keyed >> 51)) * PRIME32_1);
- return XXH3_avalanche((mix64 ^ (mix64 >> 47)) * PRIME64_2);
+ XXH_ASSERT(4 <= len && len < 8);
+ seed ^= (xxh_u64)XXH_swap32((xxh_u32)seed) << 32;
+ { xxh_u32 const input1 = XXH_readLE32(input);
+ xxh_u32 const input2 = XXH_readLE32(input + len - 4);
+ xxh_u64 const bitflip = (XXH_readLE64(secret+8) ^ XXH_readLE64(secret+16)) - seed;
+ xxh_u64 const input64 = input2 + (((xxh_u64)input1) << 32);
+ xxh_u64 x = input64 ^ bitflip;
+ /* this mix is inspired by Pelle Evensen's rrmxmx */
+ x ^= XXH_rotl64(x, 49) ^ XXH_rotl64(x, 24);
+ x *= 0x9FB21C651E98DF25ULL;
+ x ^= (x >> 35) + len ;
+ x *= 0x9FB21C651E98DF25ULL;
+ return XXH_xorshift64(x, 28);
}
}
@@ -446,10 +721,14 @@ XXH3_len_9to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_
{
XXH_ASSERT(input != NULL);
XXH_ASSERT(secret != NULL);
- XXH_ASSERT(9 <= len && len <= 16);
- { xxh_u64 const input_lo = XXH_readLE64(input) ^ (XXH_readLE64(secret) + seed);
- xxh_u64 const input_hi = XXH_readLE64(input + len - 8) ^ (XXH_readLE64(secret + 8) - seed);
- xxh_u64 const acc = len + (input_lo + input_hi) + XXH3_mul128_fold64(input_lo, input_hi);
+ XXH_ASSERT(8 <= len && len <= 16);
+ { xxh_u64 const bitflip1 = (XXH_readLE64(secret+24) ^ XXH_readLE64(secret+32)) + seed;
+ xxh_u64 const bitflip2 = (XXH_readLE64(secret+40) ^ XXH_readLE64(secret+48)) - seed;
+ xxh_u64 const input_lo = XXH_readLE64(input) ^ bitflip1;
+ xxh_u64 const input_hi = XXH_readLE64(input + len - 8) ^ bitflip2;
+ xxh_u64 const acc = len
+ + XXH_swap64(input_lo) + input_hi
+ + XXH3_mul128_fold64(input_lo, input_hi);
return XXH3_avalanche(acc);
}
}
@@ -458,10 +737,152 @@ XXH_FORCE_INLINE XXH64_hash_t
XXH3_len_0to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed)
{
XXH_ASSERT(len <= 16);
- { if (len > 8) return XXH3_len_9to16_64b(input, len, secret, seed);
- if (len >= 4) return XXH3_len_4to8_64b(input, len, secret, seed);
+ { if (XXH_likely(len > 8)) return XXH3_len_9to16_64b(input, len, secret, seed);
+ if (XXH_likely(len >= 4)) return XXH3_len_4to8_64b(input, len, secret, seed);
if (len) return XXH3_len_1to3_64b(input, len, secret, seed);
- return 0;
+ return XXH3_avalanche((PRIME64_1 + seed) ^ (XXH_readLE64(secret+56) ^ XXH_readLE64(secret+64)));
+ }
+}
+
+/*
+ * DISCLAIMER: There are known *seed-dependent* multicollisions here due to
+ * multiplication by zero, affecting hashes of lengths 17 to 240.
+ *
+ * However, they are very unlikely.
+ *
+ * Keep this in mind when using the unseeded XXH3_64bits() variant: As with all
+ * unseeded non-cryptographic hashes, it does not attempt to defend itself
+ * against specially crafted inputs, only random inputs.
+ *
+ * Compared to classic UMAC where a 1 in 2^31 chance of 4 consecutive bytes
+ * cancelling out the secret is taken an arbitrary number of times (addressed
+ * in XXH3_accumulate_512), this collision is very unlikely with random inputs
+ * and/or proper seeding:
+ *
+ * This only has a 1 in 2^63 chance of 8 consecutive bytes cancelling out, in a
+ * function that is only called up to 16 times per hash with up to 240 bytes of
+ * input.
+ *
+ * This is not too bad for a non-cryptographic hash function, especially with
+ * only 64 bit outputs.
+ *
+ * The 128-bit variant (which trades some speed for strength) is NOT affected
+ * by this, although it is always a good idea to use a proper seed if you care
+ * about strength.
+ */
+XXH_FORCE_INLINE xxh_u64 XXH3_mix16B(const xxh_u8* XXH_RESTRICT input,
+ const xxh_u8* XXH_RESTRICT secret, xxh_u64 seed64)
+{
+#if defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \
+ && defined(__i386__) && defined(__SSE2__) /* x86 + SSE2 */ \
+ && !defined(XXH_ENABLE_AUTOVECTORIZE) /* Define to disable like XXH32 hack */
+ /*
+ * UGLY HACK:
+ * GCC for x86 tends to autovectorize the 128-bit multiply, resulting in
+ * slower code.
+ *
+ * By forcing seed64 into a register, we disrupt the cost model and
+ * cause it to scalarize. See `XXH32_round()`
+ *
+ * FIXME: Clang's output is still _much_ faster -- On an AMD Ryzen 3600,
+ * XXH3_64bits @ len=240 runs at 4.6 GB/s with Clang 9, but 3.3 GB/s on
+ * GCC 9.2, despite both emitting scalar code.
+ *
+ * GCC generates much better scalar code than Clang for the rest of XXH3,
+ * which is why finding a more optimal codepath is an interest.
+ */
+ __asm__ ("" : "+r" (seed64));
+#endif
+ { xxh_u64 const input_lo = XXH_readLE64(input);
+ xxh_u64 const input_hi = XXH_readLE64(input+8);
+ return XXH3_mul128_fold64(
+ input_lo ^ (XXH_readLE64(secret) + seed64),
+ input_hi ^ (XXH_readLE64(secret+8) - seed64)
+ );
+ }
+}
+
+/* For mid range keys, XXH3 uses a Mum-hash variant. */
+XXH_FORCE_INLINE XXH64_hash_t
+XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len,
+ const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
+ XXH64_hash_t seed)
+{
+ XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); (void)secretSize;
+ XXH_ASSERT(16 < len && len <= 128);
+
+ { xxh_u64 acc = len * PRIME64_1;
+ if (len > 32) {
+ if (len > 64) {
+ if (len > 96) {
+ acc += XXH3_mix16B(input+48, secret+96, seed);
+ acc += XXH3_mix16B(input+len-64, secret+112, seed);
+ }
+ acc += XXH3_mix16B(input+32, secret+64, seed);
+ acc += XXH3_mix16B(input+len-48, secret+80, seed);
+ }
+ acc += XXH3_mix16B(input+16, secret+32, seed);
+ acc += XXH3_mix16B(input+len-32, secret+48, seed);
+ }
+ acc += XXH3_mix16B(input+0, secret+0, seed);
+ acc += XXH3_mix16B(input+len-16, secret+16, seed);
+
+ return XXH3_avalanche(acc);
+ }
+}
+
+#define XXH3_MIDSIZE_MAX 240
+
+XXH_NO_INLINE XXH64_hash_t
+XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len,
+ const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
+ XXH64_hash_t seed)
+{
+ XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); (void)secretSize;
+ XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX);
+
+ #define XXH3_MIDSIZE_STARTOFFSET 3
+ #define XXH3_MIDSIZE_LASTOFFSET 17
+
+ { xxh_u64 acc = len * PRIME64_1;
+ int const nbRounds = (int)len / 16;
+ int i;
+ for (i=0; i<8; i++) {
+ acc += XXH3_mix16B(input+(16*i), secret+(16*i), seed);
+ }
+ acc = XXH3_avalanche(acc);
+ XXH_ASSERT(nbRounds >= 8);
+#if defined(__clang__) /* Clang */ \
+ && (defined(__ARM_NEON) || defined(__ARM_NEON__)) /* NEON */ \
+ && !defined(XXH_ENABLE_AUTOVECTORIZE) /* Define to disable */
+ /*
+ * UGLY HACK:
+ * Clang for ARMv7-A tries to vectorize this loop, similar to GCC x86.
+ * In everywhere else, it uses scalar code.
+ *
+ * For 64->128-bit multiplies, even if the NEON was 100% optimal, it
+ * would still be slower than UMAAL (see XXH_mult64to128).
+ *
+ * Unfortunately, Clang doesn't handle the long multiplies properly and
+ * converts them to the nonexistent "vmulq_u64" intrinsic, which is then
+ * scalarized into an ugly mess of VMOV.32 instructions.
+ *
+ * This mess is difficult to avoid without turning autovectorization
+ * off completely, but they are usually relatively minor and/or not
+ * worth it to fix.
+ *
+ * This loop is the easiest to fix, as unlike XXH32, this pragma
+ * _actually works_ because it is a loop vectorization instead of an
+ * SLP vectorization.
+ */
+ #pragma clang loop vectorize(disable)
+#endif
+ for (i=8 ; i < nbRounds; i++) {
+ acc += XXH3_mix16B(input+(16*i), secret+(16*(i-8)) + XXH3_MIDSIZE_STARTOFFSET, seed);
+ }
+ /* last bytes */
+ acc += XXH3_mix16B(input + len - 16, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed);
+ return XXH3_avalanche(acc);
}
}
@@ -474,6 +895,28 @@ XXH3_len_0to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_
typedef enum { XXH3_acc_64bits, XXH3_acc_128bits } XXH3_accWidth_e;
+/*
+ * XXH3_accumulate_512 is the tightest loop for long inputs, and it is the most optimized.
+ *
+ * It is a hardened version of UMAC, based off of FARSH's implementation.
+ *
+ * This was chosen because it adapts quite well to 32-bit, 64-bit, and SIMD
+ * implementations, and it is ridiculously fast.
+ *
+ * We harden it by mixing the original input to the accumulators as well as the product.
+ *
+ * This means that in the (relatively likely) case of a multiply by zero, the
+ * original input is preserved.
+ *
+ * On 128-bit inputs, we swap 64-bit pairs when we add the input to improve
+ * cross-pollination, as otherwise the upper and lower halves would be
+ * essentially independent.
+ *
+ * This doesn't matter on 64-bit hashes since they all get merged together in
+ * the end, so we skip the extra step.
+ *
+ * Both XXH3_64bits and XXH3_128bits use this subroutine.
+ */
XXH_FORCE_INLINE void
XXH3_accumulate_512( void* XXH_RESTRICT acc,
const void* XXH_RESTRICT input,
@@ -483,46 +926,75 @@ XXH3_accumulate_512( void* XXH_RESTRICT acc,
#if (XXH_VECTOR == XXH_AVX2)
XXH_ASSERT((((size_t)acc) & 31) == 0);
- { XXH_ALIGN(32) __m256i* const xacc = (__m256i *) acc;
- const __m256i* const xinput = (const __m256i *) input; /* not really aligned, just for ptr arithmetic, and because _mm256_loadu_si256() requires this type */
- const __m256i* const xsecret = (const __m256i *) secret; /* not really aligned, just for ptr arithmetic, and because _mm256_loadu_si256() requires this type */
+ { XXH_ALIGN(32) __m256i* const xacc = (__m256i *) acc;
+ /* Unaligned. This is mainly for pointer arithmetic, and because
+ * _mm256_loadu_si256 requires a const __m256i * pointer for some reason. */
+ const __m256i* const xinput = (const __m256i *) input;
+ /* Unaligned. This is mainly for pointer arithmetic, and because
+ * _mm256_loadu_si256 requires a const __m256i * pointer for some reason. */
+ const __m256i* const xsecret = (const __m256i *) secret;
size_t i;
for (i=0; i < STRIPE_LEN/sizeof(__m256i); i++) {
- __m256i const data_vec = _mm256_loadu_si256 (xinput+i);
- __m256i const key_vec = _mm256_loadu_si256 (xsecret+i);
- __m256i const data_key = _mm256_xor_si256 (data_vec, key_vec); /* uint32 dk[8] = {d0+k0, d1+k1, d2+k2, d3+k3, ...} */
- __m256i const product = _mm256_mul_epu32 (data_key, _mm256_shuffle_epi32 (data_key, 0x31)); /* uint64 mul[4] = {dk0*dk1, dk2*dk3, ...} */
+ /* data_vec = xinput[i]; */
+ __m256i const data_vec = _mm256_loadu_si256 (xinput+i);
+ /* key_vec = xsecret[i]; */
+ __m256i const key_vec = _mm256_loadu_si256 (xsecret+i);
+ /* data_key = data_vec ^ key_vec; */
+ __m256i const data_key = _mm256_xor_si256 (data_vec, key_vec);
+ /* data_key_lo = data_key >> 32; */
+ __m256i const data_key_lo = _mm256_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1));
+ /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */
+ __m256i const product = _mm256_mul_epu32 (data_key, data_key_lo);
if (accWidth == XXH3_acc_128bits) {
- __m256i const data_swap = _mm256_shuffle_epi32(data_vec, _MM_SHUFFLE(1,0,3,2));
- __m256i const sum = _mm256_add_epi64(xacc[i], data_swap);
- xacc[i] = _mm256_add_epi64(product, sum);
+ /* xacc[i] += swap(data_vec); */
+ __m256i const data_swap = _mm256_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2));
+ __m256i const sum = _mm256_add_epi64(xacc[i], data_swap);
+ /* xacc[i] += product; */
+ xacc[i] = _mm256_add_epi64(product, sum);
} else { /* XXH3_acc_64bits */
+ /* xacc[i] += data_vec; */
__m256i const sum = _mm256_add_epi64(xacc[i], data_vec);
- xacc[i] = _mm256_add_epi64(product, sum);
+ /* xacc[i] += product; */
+ xacc[i] = _mm256_add_epi64(product, sum);
}
} }
#elif (XXH_VECTOR == XXH_SSE2)
+ /* SSE2 is just a half-scale version of the AVX2 version. */
XXH_ASSERT((((size_t)acc) & 15) == 0);
- { XXH_ALIGN(16) __m128i* const xacc = (__m128i *) acc;
- const __m128i* const xinput = (const __m128i *) input; /* not really aligned, just for ptr arithmetic, and because _mm_loadu_si128() requires this type */
- const __m128i* const xsecret = (const __m128i *) secret; /* not really aligned, just for ptr arithmetic, and because _mm_loadu_si128() requires this type */
+ { XXH_ALIGN(16) __m128i* const xacc = (__m128i *) acc;
+ /* Unaligned. This is mainly for pointer arithmetic, and because
+ * _mm_loadu_si128 requires a const __m128i * pointer for some reason. */
+ const __m128i* const xinput = (const __m128i *) input;
+ /* Unaligned. This is mainly for pointer arithmetic, and because
+ * _mm_loadu_si128 requires a const __m128i * pointer for some reason. */
+ const __m128i* const xsecret = (const __m128i *) secret;
size_t i;
for (i=0; i < STRIPE_LEN/sizeof(__m128i); i++) {
- __m128i const data_vec = _mm_loadu_si128 (xinput+i);
- __m128i const key_vec = _mm_loadu_si128 (xsecret+i);
- __m128i const data_key = _mm_xor_si128 (data_vec, key_vec); /* uint32 dk[8] = {d0+k0, d1+k1, d2+k2, d3+k3, ...} */
- __m128i const product = _mm_mul_epu32 (data_key, _mm_shuffle_epi32 (data_key, 0x31)); /* uint64 mul[4] = {dk0*dk1, dk2*dk3, ...} */
+ /* data_vec = xinput[i]; */
+ __m128i const data_vec = _mm_loadu_si128 (xinput+i);
+ /* key_vec = xsecret[i]; */
+ __m128i const key_vec = _mm_loadu_si128 (xsecret+i);
+ /* data_key = data_vec ^ key_vec; */
+ __m128i const data_key = _mm_xor_si128 (data_vec, key_vec);
+ /* data_key_lo = data_key >> 32; */
+ __m128i const data_key_lo = _mm_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1));
+ /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */
+ __m128i const product = _mm_mul_epu32 (data_key, data_key_lo);
if (accWidth == XXH3_acc_128bits) {
+ /* xacc[i] += swap(data_vec); */
__m128i const data_swap = _mm_shuffle_epi32(data_vec, _MM_SHUFFLE(1,0,3,2));
- __m128i const sum = _mm_add_epi64(xacc[i], data_swap);
- xacc[i] = _mm_add_epi64(product, sum);
+ __m128i const sum = _mm_add_epi64(xacc[i], data_swap);
+ /* xacc[i] += product; */
+ xacc[i] = _mm_add_epi64(product, sum);
} else { /* XXH3_acc_64bits */
+ /* xacc[i] += data_vec; */
__m128i const sum = _mm_add_epi64(xacc[i], data_vec);
- xacc[i] = _mm_add_epi64(product, sum);
+ /* xacc[i] += product; */
+ xacc[i] = _mm_add_epi64(product, sum);
}
} }
@@ -537,117 +1009,66 @@ XXH3_accumulate_512( void* XXH_RESTRICT acc,
size_t i;
for (i=0; i < STRIPE_LEN / sizeof(uint64x2_t); i++) {
-#if !defined(__aarch64__) && !defined(__arm64__) && defined(__GNUC__) /* ARM32-specific hack */
- /* vzip on ARMv7 Clang generates a lot of vmovs (technically vorrs) without this.
- * vzip on 32-bit ARM NEON will overwrite the original register, and I think that Clang
- * assumes I don't want to destroy it and tries to make a copy. This slows down the code
- * a lot.
- * aarch64 not only uses an entirely different syntax, but it requires three
- * instructions...
- * ext v1.16B, v0.16B, #8 // select high bits because aarch64 can't address them directly
- * zip1 v3.2s, v0.2s, v1.2s // first zip
- * zip2 v2.2s, v0.2s, v1.2s // second zip
- * ...to do what ARM does in one:
- * vzip.32 d0, d1 // Interleave high and low bits and overwrite. */
-
- /* data_vec = xsecret[i]; */
- uint8x16_t const data_vec = vld1q_u8(xinput + (i * 16));
- /* key_vec = xsecret[i]; */
- uint8x16_t const key_vec = vld1q_u8(xsecret + (i * 16));
- /* data_key = data_vec ^ key_vec; */
- uint32x4_t data_key;
-
- if (accWidth == XXH3_acc_64bits) {
- /* Add first to prevent register swaps */
- /* xacc[i] += data_vec; */
- xacc[i] = vaddq_u64 (xacc[i], vreinterpretq_u64_u8(data_vec));
- } else { /* XXH3_acc_128bits */
- /* xacc[i] += swap(data_vec); */
- /* can probably be optimized better */
- uint64x2_t const data64 = vreinterpretq_u64_u8(data_vec);
- uint64x2_t const swapped= vextq_u64(data64, data64, 1);
- xacc[i] = vaddq_u64 (xacc[i], swapped);
- }
-
- data_key = vreinterpretq_u32_u8(veorq_u8(data_vec, key_vec));
-
- /* Here's the magic. We use the quirkiness of vzip to shuffle data_key in place.
- * shuffle: data_key[0, 1, 2, 3] = data_key[0, 2, 1, 3] */
- __asm__("vzip.32 %e0, %f0" : "+w" (data_key));
- /* xacc[i] += (uint64x2_t) data_key[0, 1] * (uint64x2_t) data_key[2, 3]; */
- xacc[i] = vmlal_u32(xacc[i], vget_low_u32(data_key), vget_high_u32(data_key));
-
-#else
- /* On aarch64, vshrn/vmovn seems to be equivalent to, if not faster than, the vzip method. */
-
- /* data_vec = xsecret[i]; */
- uint8x16_t const data_vec = vld1q_u8(xinput + (i * 16));
+ /* data_vec = xinput[i]; */
+ uint8x16_t data_vec = vld1q_u8(xinput + (i * 16));
/* key_vec = xsecret[i]; */
- uint8x16_t const key_vec = vld1q_u8(xsecret + (i * 16));
+ uint8x16_t key_vec = vld1q_u8(xsecret + (i * 16));
/* data_key = data_vec ^ key_vec; */
- uint64x2_t const data_key = vreinterpretq_u64_u8(veorq_u8(data_vec, key_vec));
- /* data_key_lo = (uint32x2_t) (data_key & 0xFFFFFFFF); */
- uint32x2_t const data_key_lo = vmovn_u64 (data_key);
- /* data_key_hi = (uint32x2_t) (data_key >> 32); */
- uint32x2_t const data_key_hi = vshrn_n_u64 (data_key, 32);
+ uint64x2_t data_key = vreinterpretq_u64_u8(veorq_u8(data_vec, key_vec));
+ uint32x2_t data_key_lo, data_key_hi;
if (accWidth == XXH3_acc_64bits) {
/* xacc[i] += data_vec; */
xacc[i] = vaddq_u64 (xacc[i], vreinterpretq_u64_u8(data_vec));
} else { /* XXH3_acc_128bits */
/* xacc[i] += swap(data_vec); */
- uint64x2_t const data64 = vreinterpretq_u64_u8(data_vec);
- uint64x2_t const swapped= vextq_u64(data64, data64, 1);
+ uint64x2_t const data64 = vreinterpretq_u64_u8(data_vec);
+ uint64x2_t const swapped = vextq_u64(data64, data64, 1);
xacc[i] = vaddq_u64 (xacc[i], swapped);
}
+ /* data_key_lo = (uint32x2_t) (data_key & 0xFFFFFFFF);
+ * data_key_hi = (uint32x2_t) (data_key >> 32);
+ * data_key = UNDEFINED; */
+ XXH_SPLIT_IN_PLACE(data_key, data_key_lo, data_key_hi);
/* xacc[i] += (uint64x2_t) data_key_lo * (uint64x2_t) data_key_hi; */
xacc[i] = vmlal_u32 (xacc[i], data_key_lo, data_key_hi);
-#endif
}
}
#elif (XXH_VECTOR == XXH_VSX)
- U64x2* const xacc = (U64x2*) acc; /* presumed aligned */
- U64x2 const* const xinput = (U64x2 const*) input; /* no alignment restriction */
- U64x2 const* const xsecret = (U64x2 const*) secret; /* no alignment restriction */
- U64x2 const v32 = { 32, 32 };
-#if XXH_VSX_BE
- U8x16 const vXorSwap = { 0x07, 0x16, 0x25, 0x34, 0x43, 0x52, 0x61, 0x70,
- 0x8F, 0x9E, 0xAD, 0xBC, 0xCB, 0xDA, 0xE9, 0xF8 };
-#endif
+ xxh_u64x2* const xacc = (xxh_u64x2*) acc; /* presumed aligned */
+ xxh_u64x2 const* const xinput = (xxh_u64x2 const*) input; /* no alignment restriction */
+ xxh_u64x2 const* const xsecret = (xxh_u64x2 const*) secret; /* no alignment restriction */
+ xxh_u64x2 const v32 = { 32, 32 };
size_t i;
- for (i = 0; i < STRIPE_LEN / sizeof(U64x2); i++) {
+ for (i = 0; i < STRIPE_LEN / sizeof(xxh_u64x2); i++) {
/* data_vec = xinput[i]; */
+ xxh_u64x2 const data_vec = XXH_vec_loadu(xinput + i);
/* key_vec = xsecret[i]; */
-#if XXH_VSX_BE
- /* byteswap */
- U64x2 const data_vec = XXH_vec_revb(vec_vsx_ld(0, xinput + i));
- U64x2 const key_raw = vec_vsx_ld(0, xsecret + i);
- /* See comment above. data_key = data_vec ^ swap(xsecret[i]); */
- U64x2 const data_key = (U64x2)XXH_vec_permxor((U8x16)data_vec, (U8x16)key_raw, vXorSwap);
-#else
- U64x2 const data_vec = vec_vsx_ld(0, xinput + i);
- U64x2 const key_vec = vec_vsx_ld(0, xsecret + i);
- U64x2 const data_key = data_vec ^ key_vec;
-#endif
+ xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + i);
+ xxh_u64x2 const data_key = data_vec ^ key_vec;
/* shuffled = (data_key << 32) | (data_key >> 32); */
- U32x4 const shuffled = (U32x4)vec_rl(data_key, v32);
- /* product = ((U64x2)data_key & 0xFFFFFFFF) * ((U64x2)shuffled & 0xFFFFFFFF); */
- U64x2 const product = XXH_vec_mulo((U32x4)data_key, shuffled);
+ xxh_u32x4 const shuffled = (xxh_u32x4)vec_rl(data_key, v32);
+ /* product = ((xxh_u64x2)data_key & 0xFFFFFFFF) * ((xxh_u64x2)shuffled & 0xFFFFFFFF); */
+ xxh_u64x2 const product = XXH_vec_mulo((xxh_u32x4)data_key, shuffled);
xacc[i] += product;
if (accWidth == XXH3_acc_64bits) {
xacc[i] += data_vec;
} else { /* XXH3_acc_128bits */
/* swap high and low halves */
- U64x2 const data_swapped = vec_xxpermdi(data_vec, data_vec, 2);
+#ifdef __s390x__
+ xxh_u64x2 const data_swapped = vec_permi(data_vec, data_vec, 2);
+#else
+ xxh_u64x2 const data_swapped = vec_xxpermdi(data_vec, data_vec, 2);
+#endif
xacc[i] += data_swapped;
}
}
#else /* scalar variant of Accumulator - universal */
- XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned on 32-bytes boundaries, little hint for the auto-vectorizer */
+ XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned */
const xxh_u8* const xinput = (const xxh_u8*) input; /* no alignment restriction */
const xxh_u8* const xsecret = (const xxh_u8*) secret; /* no alignment restriction */
size_t i;
@@ -666,6 +1087,26 @@ XXH3_accumulate_512( void* XXH_RESTRICT acc,
#endif
}
+/*
+ * XXH3_scrambleAcc: Scrambles the accumulators to improve mixing.
+ *
+ * Multiplication isn't perfect, as explained by Google in HighwayHash:
+ *
+ * // Multiplication mixes/scrambles bytes 0-7 of the 64-bit result to
+ * // varying degrees. In descending order of goodness, bytes
+ * // 3 4 2 5 1 6 0 7 have quality 228 224 164 160 100 96 36 32.
+ * // As expected, the upper and lower bytes are much worse.
+ *
+ * Source: https://github.com/google/highwayhash/blob/0aaf66b/highwayhash/hh_avx2.h#L291
+ *
+ * Since our algorithm uses a pseudorandom secret to add some variance into the
+ * mix, we don't need to (or want to) mix as often or as much as HighwayHash does.
+ *
+ * This isn't as tight as XXH3_accumulate, but still written in SIMD to avoid
+ * extraction.
+ *
+ * Both XXH3_64bits and XXH3_128bits use this subroutine.
+ */
XXH_FORCE_INLINE void
XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
{
@@ -673,7 +1114,9 @@ XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
XXH_ASSERT((((size_t)acc) & 31) == 0);
{ XXH_ALIGN(32) __m256i* const xacc = (__m256i*) acc;
- const __m256i* const xsecret = (const __m256i *) secret; /* not really aligned, just for ptr arithmetic, and because _mm256_loadu_si256() requires this argument type */
+ /* Unaligned. This is mainly for pointer arithmetic, and because
+ * _mm256_loadu_si256 requires a const __m256i * pointer for some reason. */
+ const __m256i* const xsecret = (const __m256i *) secret;
const __m256i prime32 = _mm256_set1_epi32((int)PRIME32_1);
size_t i;
@@ -687,7 +1130,7 @@ XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
__m256i const data_key = _mm256_xor_si256 (data_vec, key_vec);
/* xacc[i] *= PRIME32_1; */
- __m256i const data_key_hi = _mm256_shuffle_epi32 (data_key, 0x31);
+ __m256i const data_key_hi = _mm256_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1));
__m256i const prod_lo = _mm256_mul_epu32 (data_key, prime32);
__m256i const prod_hi = _mm256_mul_epu32 (data_key_hi, prime32);
xacc[i] = _mm256_add_epi64(prod_lo, _mm256_slli_epi64(prod_hi, 32));
@@ -698,7 +1141,9 @@ XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
XXH_ASSERT((((size_t)acc) & 15) == 0);
{ XXH_ALIGN(16) __m128i* const xacc = (__m128i*) acc;
- const __m128i* const xsecret = (const __m128i *) secret; /* not really aligned, just for ptr arithmetic, and because _mm_loadu_si128() requires this argument type */
+ /* Unaligned. This is mainly for pointer arithmetic, and because
+ * _mm_loadu_si128 requires a const __m128i * pointer for some reason. */
+ const __m128i* const xsecret = (const __m128i *) secret;
const __m128i prime32 = _mm_set1_epi32((int)PRIME32_1);
size_t i;
@@ -707,12 +1152,12 @@ XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
__m128i const acc_vec = xacc[i];
__m128i const shifted = _mm_srli_epi64 (acc_vec, 47);
__m128i const data_vec = _mm_xor_si128 (acc_vec, shifted);
- /* xacc[i] ^= xsecret; */
+ /* xacc[i] ^= xsecret[i]; */
__m128i const key_vec = _mm_loadu_si128 (xsecret+i);
__m128i const data_key = _mm_xor_si128 (data_vec, key_vec);
/* xacc[i] *= PRIME32_1; */
- __m128i const data_key_hi = _mm_shuffle_epi32 (data_key, 0x31);
+ __m128i const data_key_hi = _mm_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1));
__m128i const prod_lo = _mm_mul_epu32 (data_key, prime32);
__m128i const prod_hi = _mm_mul_epu32 (data_key_hi, prime32);
xacc[i] = _mm_add_epi64(prod_lo, _mm_slli_epi64(prod_hi, 32));
@@ -723,80 +1168,91 @@ XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
XXH_ASSERT((((size_t)acc) & 15) == 0);
- { uint64x2_t* const xacc = (uint64x2_t*) acc;
- uint8_t const* const xsecret = (uint8_t const*) secret;
- uint32x2_t const prime = vdup_n_u32 (PRIME32_1);
+ { uint64x2_t* xacc = (uint64x2_t*) acc;
+ uint8_t const* xsecret = (uint8_t const*) secret;
+ uint32x2_t prime = vdup_n_u32 (PRIME32_1);
size_t i;
for (i=0; i < STRIPE_LEN/sizeof(uint64x2_t); i++) {
- /* data_vec = xacc[i] ^ (xacc[i] >> 47); */
- uint64x2_t const acc_vec = xacc[i];
- uint64x2_t const shifted = vshrq_n_u64 (acc_vec, 47);
- uint64x2_t const data_vec = veorq_u64 (acc_vec, shifted);
-
- /* key_vec = xsecret[i]; */
- uint32x4_t const key_vec = vreinterpretq_u32_u8(vld1q_u8(xsecret + (i * 16)));
- /* data_key = data_vec ^ key_vec; */
- uint32x4_t const data_key = veorq_u32 (vreinterpretq_u32_u64(data_vec), key_vec);
- /* shuffled = { data_key[0, 2], data_key[1, 3] }; */
- uint32x2x2_t const shuffled = vzip_u32 (vget_low_u32(data_key), vget_high_u32(data_key));
-
- /* data_key *= PRIME32_1 */
-
- /* prod_hi = (data_key >> 32) * PRIME32_1; */
- uint64x2_t const prod_hi = vmull_u32 (shuffled.val[1], prime);
- /* xacc[i] = prod_hi << 32; */
- xacc[i] = vshlq_n_u64(prod_hi, 32);
- /* xacc[i] += (prod_hi & 0xFFFFFFFF) * PRIME32_1; */
- xacc[i] = vmlal_u32(xacc[i], shuffled.val[0], prime);
+ /* xacc[i] ^= (xacc[i] >> 47); */
+ uint64x2_t acc_vec = xacc[i];
+ uint64x2_t shifted = vshrq_n_u64 (acc_vec, 47);
+ uint64x2_t data_vec = veorq_u64 (acc_vec, shifted);
+
+ /* xacc[i] ^= xsecret[i]; */
+ uint8x16_t key_vec = vld1q_u8(xsecret + (i * 16));
+ uint64x2_t data_key = veorq_u64(data_vec, vreinterpretq_u64_u8(key_vec));
+
+ /* xacc[i] *= PRIME32_1 */
+ uint32x2_t data_key_lo, data_key_hi;
+ /* data_key_lo = (uint32x2_t) (xacc[i] & 0xFFFFFFFF);
+ * data_key_hi = (uint32x2_t) (xacc[i] >> 32);
+ * xacc[i] = UNDEFINED; */
+ XXH_SPLIT_IN_PLACE(data_key, data_key_lo, data_key_hi);
+ { /*
+ * prod_hi = (data_key >> 32) * PRIME32_1;
+ *
+ * Avoid vmul_u32 + vshll_n_u32 since Clang 6 and 7 will
+ * incorrectly "optimize" this:
+ * tmp = vmul_u32(vmovn_u64(a), vmovn_u64(b));
+ * shifted = vshll_n_u32(tmp, 32);
+ * to this:
+ * tmp = "vmulq_u64"(a, b); // no such thing!
+ * shifted = vshlq_n_u64(tmp, 32);
+ *
+ * However, unlike SSE, Clang lacks a 64-bit multiply routine
+ * for NEON, and it scalarizes two 64-bit multiplies instead.
+ *
+ * vmull_u32 has the same timing as vmul_u32, and it avoids
+ * this bug completely.
+ * See https://bugs.llvm.org/show_bug.cgi?id=39967
+ */
+ uint64x2_t prod_hi = vmull_u32 (data_key_hi, prime);
+ /* xacc[i] = prod_hi << 32; */
+ xacc[i] = vshlq_n_u64(prod_hi, 32);
+ /* xacc[i] += (prod_hi & 0xFFFFFFFF) * PRIME32_1; */
+ xacc[i] = vmlal_u32(xacc[i], data_key_lo, prime);
+ }
} }
#elif (XXH_VECTOR == XXH_VSX)
- U64x2* const xacc = (U64x2*) acc;
- const U64x2* const xsecret = (const U64x2*) secret;
- /* constants */
- U64x2 const v32 = { 32, 32 };
- U64x2 const v47 = { 47, 47 };
- U32x4 const prime = { PRIME32_1, PRIME32_1, PRIME32_1, PRIME32_1 };
- size_t i;
-#if XXH_VSX_BE
- /* endian swap */
- U8x16 const vXorSwap = { 0x07, 0x16, 0x25, 0x34, 0x43, 0x52, 0x61, 0x70,
- 0x8F, 0x9E, 0xAD, 0xBC, 0xCB, 0xDA, 0xE9, 0xF8 };
-#endif
- for (i = 0; i < STRIPE_LEN / sizeof(U64x2); i++) {
- U64x2 const acc_vec = xacc[i];
- U64x2 const data_vec = acc_vec ^ (acc_vec >> v47);
- /* key_vec = xsecret[i]; */
-#if XXH_VSX_BE
- /* swap bytes words */
- U64x2 const key_raw = vec_vsx_ld(0, xsecret + i);
- U64x2 const data_key = (U64x2)XXH_vec_permxor((U8x16)data_vec, (U8x16)key_raw, vXorSwap);
-#else
- U64x2 const key_vec = vec_vsx_ld(0, xsecret + i);
- U64x2 const data_key = data_vec ^ key_vec;
-#endif
-
- /* data_key *= PRIME32_1 */
+ XXH_ASSERT((((size_t)acc) & 15) == 0);
- /* prod_lo = ((U64x2)data_key & 0xFFFFFFFF) * ((U64x2)prime & 0xFFFFFFFF); */
- U64x2 const prod_even = XXH_vec_mule((U32x4)data_key, prime);
- /* prod_hi = ((U64x2)data_key >> 32) * ((U64x2)prime >> 32); */
- U64x2 const prod_odd = XXH_vec_mulo((U32x4)data_key, prime);
- xacc[i] = prod_odd + (prod_even << v32);
- }
+ { xxh_u64x2* const xacc = (xxh_u64x2*) acc;
+ const xxh_u64x2* const xsecret = (const xxh_u64x2*) secret;
+ /* constants */
+ xxh_u64x2 const v32 = { 32, 32 };
+ xxh_u64x2 const v47 = { 47, 47 };
+ xxh_u32x4 const prime = { PRIME32_1, PRIME32_1, PRIME32_1, PRIME32_1 };
+ size_t i;
+ for (i = 0; i < STRIPE_LEN / sizeof(xxh_u64x2); i++) {
+ /* xacc[i] ^= (xacc[i] >> 47); */
+ xxh_u64x2 const acc_vec = xacc[i];
+ xxh_u64x2 const data_vec = acc_vec ^ (acc_vec >> v47);
+
+ /* xacc[i] ^= xsecret[i]; */
+ xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + i);
+ xxh_u64x2 const data_key = data_vec ^ key_vec;
+
+ /* xacc[i] *= PRIME32_1 */
+ /* prod_lo = ((xxh_u64x2)data_key & 0xFFFFFFFF) * ((xxh_u64x2)prime & 0xFFFFFFFF); */
+ xxh_u64x2 const prod_even = XXH_vec_mule((xxh_u32x4)data_key, prime);
+ /* prod_hi = ((xxh_u64x2)data_key >> 32) * ((xxh_u64x2)prime >> 32); */
+ xxh_u64x2 const prod_odd = XXH_vec_mulo((xxh_u32x4)data_key, prime);
+ xacc[i] = prod_odd + (prod_even << v32);
+ } }
#else /* scalar variant of Scrambler - universal */
- XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned on 32-bytes boundaries, little hint for the auto-vectorizer */
+ XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned */
const xxh_u8* const xsecret = (const xxh_u8*) secret; /* no alignment restriction */
size_t i;
XXH_ASSERT((((size_t)acc) & (XXH_ACC_ALIGN-1)) == 0);
for (i=0; i < ACC_NB; i++) {
xxh_u64 const key64 = XXH_readLE64(xsecret + 8*i);
xxh_u64 acc64 = xacc[i];
- acc64 ^= acc64 >> 47;
+ acc64 = XXH_xorshift64(acc64, 47);
acc64 ^= key64;
acc64 *= PRIME32_1;
xacc[i] = acc64;
@@ -805,9 +1261,15 @@ XXH3_scrambleAcc(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret)
#endif
}
-/* assumption : nbStripes will not overflow secret size */
+#define XXH_PREFETCH_DIST 384
+
+/*
+ * XXH3_accumulate()
+ * Loops over XXH3_accumulate_512().
+ * Assumption: nbStripes will not overflow the secret size
+ */
XXH_FORCE_INLINE void
-XXH3_accumulate( xxh_u64* XXH_RESTRICT acc,
+XXH3_accumulate( xxh_u64* XXH_RESTRICT acc,
const xxh_u8* XXH_RESTRICT input,
const xxh_u8* XXH_RESTRICT secret,
size_t nbStripes,
@@ -815,24 +1277,16 @@ XXH3_accumulate( xxh_u64* XXH_RESTRICT acc,
{
size_t n;
for (n = 0; n < nbStripes; n++ ) {
+ const xxh_u8* const in = input + n*STRIPE_LEN;
+ XXH_PREFETCH(in + XXH_PREFETCH_DIST);
XXH3_accumulate_512(acc,
- input + n*STRIPE_LEN,
+ in,
secret + n*XXH_SECRET_CONSUME_RATE,
accWidth);
}
}
-/* note : clang auto-vectorizes well in SS2 mode _if_ this function is `static`,
- * and doesn't auto-vectorize it at all if it is `FORCE_INLINE`.
- * However, it auto-vectorizes better AVX2 if it is `FORCE_INLINE`
- * Pretty much every other modes and compilers prefer `FORCE_INLINE`.
- */
-
-#if defined(__clang__) && (XXH_VECTOR==0) && !defined(__AVX2__) && !defined(__arm__) && !defined(__thumb__)
-static void
-#else
XXH_FORCE_INLINE void
-#endif
XXH3_hashLong_internal_loop( xxh_u64* XXH_RESTRICT acc,
const xxh_u8* XXH_RESTRICT input, size_t len,
const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
@@ -860,7 +1314,8 @@ XXH3_hashLong_internal_loop( xxh_u64* XXH_RESTRICT acc,
/* last stripe */
if (len & (STRIPE_LEN - 1)) {
const xxh_u8* const p = input + len - STRIPE_LEN;
-#define XXH_SECRET_LASTACC_START 7 /* do not align on 8, so that secret is different from scrambler */
+ /* Do not align on 8, so that the secret is different from the scrambler */
+#define XXH_SECRET_LASTACC_START 7
XXH3_accumulate_512(acc, p, secret + secretSize - STRIPE_LEN - XXH_SECRET_LASTACC_START, accWidth);
} }
}
@@ -899,19 +1354,27 @@ XXH3_hashLong_internal(const xxh_u8* XXH_RESTRICT input, size_t len,
/* converge into final hash */
XXH_STATIC_ASSERT(sizeof(acc) == 64);
-#define XXH_SECRET_MERGEACCS_START 11 /* do not align on 8, so that secret is different from accumulator */
+ /* do not align on 8, so that the secret is different from the accumulator */
+#define XXH_SECRET_MERGEACCS_START 11
XXH_ASSERT(secretSize >= sizeof(acc) + XXH_SECRET_MERGEACCS_START);
return XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, (xxh_u64)len * PRIME64_1);
}
-
-XXH_NO_INLINE XXH64_hash_t /* It's important for performance that XXH3_hashLong is not inlined. Not sure why (uop cache maybe ?), but difference is large and easily measurable */
+/*
+ * It's important for performance that XXH3_hashLong is not inlined. Not sure
+ * why (uop cache maybe?), but the difference is large and easily measurable.
+ */
+XXH_NO_INLINE XXH64_hash_t
XXH3_hashLong_64b_defaultSecret(const xxh_u8* XXH_RESTRICT input, size_t len)
{
return XXH3_hashLong_internal(input, len, kSecret, sizeof(kSecret));
}
-XXH_NO_INLINE XXH64_hash_t /* It's important for performance that XXH3_hashLong is not inlined. Not sure why (uop cache maybe ?), but difference is large and easily measurable */
+/*
+ * It's important for performance that XXH3_hashLong is not inlined. Not sure
+ * why (uop cache maybe?), but the difference is large and easily measurable.
+ */
+XXH_NO_INLINE XXH64_hash_t
XXH3_hashLong_64b_withSecret(const xxh_u8* XXH_RESTRICT input, size_t len,
const xxh_u8* XXH_RESTRICT secret, size_t secretSize)
{
@@ -942,14 +1405,18 @@ XXH_FORCE_INLINE void XXH3_initCustomSecret(xxh_u8* customSecret, xxh_u64 seed64
}
-/* XXH3_hashLong_64b_withSeed() :
- * Generate a custom key,
- * based on alteration of default kSecret with the seed,
+/*
+ * XXH3_hashLong_64b_withSeed():
+ * Generate a custom key based on alteration of default kSecret with the seed,
* and then use this key for long mode hashing.
+ *
* This operation is decently fast but nonetheless costs a little bit of time.
* Try to avoid it whenever possible (typically when seed==0).
+ *
+ * It's important for performance that XXH3_hashLong is not inlined. Not sure
+ * why (uop cache maybe?), but the difference is large and easily measurable.
*/
-XXH_NO_INLINE XXH64_hash_t /* It's important for performance that XXH3_hashLong is not inlined. Not sure why (uop cache maybe ?), but difference is large and easily measurable */
+XXH_NO_INLINE XXH64_hash_t
XXH3_hashLong_64b_withSeed(const xxh_u8* input, size_t len, XXH64_hash_t seed)
{
XXH_ALIGN(8) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE];
@@ -958,76 +1425,6 @@ XXH3_hashLong_64b_withSeed(const xxh_u8* input, size_t len, XXH64_hash_t seed)
return XXH3_hashLong_internal(input, len, secret, sizeof(secret));
}
-
-XXH_FORCE_INLINE xxh_u64 XXH3_mix16B(const xxh_u8* XXH_RESTRICT input,
- const xxh_u8* XXH_RESTRICT secret, xxh_u64 seed64)
-{
- xxh_u64 const input_lo = XXH_readLE64(input);
- xxh_u64 const input_hi = XXH_readLE64(input+8);
- return XXH3_mul128_fold64(
- input_lo ^ (XXH_readLE64(secret) + seed64),
- input_hi ^ (XXH_readLE64(secret+8) - seed64) );
-}
-
-
-XXH_FORCE_INLINE XXH64_hash_t
-XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len,
- const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
- XXH64_hash_t seed)
-{
- XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); (void)secretSize;
- XXH_ASSERT(16 < len && len <= 128);
-
- { xxh_u64 acc = len * PRIME64_1;
- if (len > 32) {
- if (len > 64) {
- if (len > 96) {
- acc += XXH3_mix16B(input+48, secret+96, seed);
- acc += XXH3_mix16B(input+len-64, secret+112, seed);
- }
- acc += XXH3_mix16B(input+32, secret+64, seed);
- acc += XXH3_mix16B(input+len-48, secret+80, seed);
- }
- acc += XXH3_mix16B(input+16, secret+32, seed);
- acc += XXH3_mix16B(input+len-32, secret+48, seed);
- }
- acc += XXH3_mix16B(input+0, secret+0, seed);
- acc += XXH3_mix16B(input+len-16, secret+16, seed);
-
- return XXH3_avalanche(acc);
- }
-}
-
-#define XXH3_MIDSIZE_MAX 240
-
-XXH_NO_INLINE XXH64_hash_t
-XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len,
- const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
- XXH64_hash_t seed)
-{
- XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); (void)secretSize;
- XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX);
-
- #define XXH3_MIDSIZE_STARTOFFSET 3
- #define XXH3_MIDSIZE_LASTOFFSET 17
-
- { xxh_u64 acc = len * PRIME64_1;
- int const nbRounds = (int)len / 16;
- int i;
- for (i=0; i<8; i++) {
- acc += XXH3_mix16B(input+(16*i), secret+(16*i), seed);
- }
- acc = XXH3_avalanche(acc);
- XXH_ASSERT(nbRounds >= 8);
- for (i=8 ; i < nbRounds; i++) {
- acc += XXH3_mix16B(input+(16*i), secret+(16*(i-8)) + XXH3_MIDSIZE_STARTOFFSET, seed);
- }
- /* last bytes */
- acc += XXH3_mix16B(input + len - 16, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed);
- return XXH3_avalanche(acc);
- }
-}
-
/* === Public entry point === */
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* input, size_t len)
@@ -1042,14 +1439,16 @@ XXH_PUBLIC_API XXH64_hash_t
XXH3_64bits_withSecret(const void* input, size_t len, const void* secret, size_t secretSize)
{
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN);
- /* if an action must be taken should `secret` conditions not be respected,
+ /*
+ * If an action is to be taken if `secret` conditions are not respected,
* it should be done here.
* For now, it's a contract pre-condition.
- * Adding a check and a branch here would cost performance at every hash */
- if (len <= 16) return XXH3_len_0to16_64b((const xxh_u8*)input, len, (const xxh_u8*)secret, 0);
- if (len <= 128) return XXH3_len_17to128_64b((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, 0);
- if (len <= XXH3_MIDSIZE_MAX) return XXH3_len_129to240_64b((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, 0);
- return XXH3_hashLong_64b_withSecret((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize);
+ * Adding a check and a branch here would cost performance at every hash.
+ */
+ if (len <= 16) return XXH3_len_0to16_64b((const xxh_u8*)input, len, (const xxh_u8*)secret, 0);
+ if (len <= 128) return XXH3_len_17to128_64b((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, 0);
+ if (len <= XXH3_MIDSIZE_MAX) return XXH3_len_129to240_64b((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, 0);
+ return XXH3_hashLong_64b_withSecret((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize);
}
XXH_PUBLIC_API XXH64_hash_t
@@ -1152,6 +1551,9 @@ XXH3_consumeStripes( xxh_u64* acc,
}
}
+/*
+ * Both XXH3_64bits_update and XXH3_128bits_update use this routine.
+ */
XXH_FORCE_INLINE XXH_errorcode
XXH3_update(XXH3_state_t* state, const xxh_u8* input, size_t len, XXH3_accWidth_e accWidth)
{
@@ -1171,12 +1573,16 @@ XXH3_update(XXH3_state_t* state, const xxh_u8* input, size_t len, XXH3_accWidth_
state->bufferedSize += (XXH32_hash_t)len;
return XXH_OK;
}
- /* input now > XXH3_INTERNALBUFFER_SIZE */
+ /* input is now > XXH3_INTERNALBUFFER_SIZE */
#define XXH3_INTERNALBUFFER_STRIPES (XXH3_INTERNALBUFFER_SIZE / STRIPE_LEN)
XXH_STATIC_ASSERT(XXH3_INTERNALBUFFER_SIZE % STRIPE_LEN == 0); /* clean multiple */
- if (state->bufferedSize) { /* some input within internal buffer: fill then consume it */
+ /*
+ * There is some input left inside the internal buffer.
+ * Fill it, then consume it.
+ */
+ if (state->bufferedSize) {
size_t const loadSize = XXH3_INTERNALBUFFER_SIZE - state->bufferedSize;
XXH_memcpy(state->buffer + state->bufferedSize, input, loadSize);
input += loadSize;
@@ -1188,7 +1594,7 @@ XXH3_update(XXH3_state_t* state, const xxh_u8* input, size_t len, XXH3_accWidth_
state->bufferedSize = 0;
}
- /* consume input by full buffer quantities */
+ /* Consume input by full buffer quantities */
if (input+XXH3_INTERNALBUFFER_SIZE <= bEnd) {
const xxh_u8* const limit = bEnd - XXH3_INTERNALBUFFER_SIZE;
do {
@@ -1201,7 +1607,7 @@ XXH3_update(XXH3_state_t* state, const xxh_u8* input, size_t len, XXH3_accWidth_
} while (input<=limit);
}
- if (input < bEnd) { /* some remaining input input : buffer it */
+ if (input < bEnd) { /* Some remaining input: buffer it */
XXH_memcpy(state->buffer, input, (size_t)(bEnd-input));
state->bufferedSize = (XXH32_hash_t)(bEnd-input);
}
@@ -1220,7 +1626,11 @@ XXH3_64bits_update(XXH3_state_t* state, const void* input, size_t len)
XXH_FORCE_INLINE void
XXH3_digest_long (XXH64_hash_t* acc, const XXH3_state_t* state, XXH3_accWidth_e accWidth)
{
- memcpy(acc, state->acc, sizeof(state->acc)); /* digest locally, state remains unaltered, and can continue ingesting more input afterwards */
+ /*
+ * Digest on a local copy. This way, the state remains unaltered, and it can
+ * continue ingesting more input afterwards.
+ */
+ memcpy(acc, state->acc, sizeof(state->acc));
if (state->bufferedSize >= STRIPE_LEN) {
size_t const totalNbStripes = state->bufferedSize / STRIPE_LEN;
XXH32_hash_t nbStripesSoFar = state->nbStripesSoFar;
@@ -1271,40 +1681,52 @@ XXH3_len_1to3_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_
XXH_ASSERT(input != NULL);
XXH_ASSERT(1 <= len && len <= 3);
XXH_ASSERT(secret != NULL);
+ /*
+ * len = 1: combinedl = { input[0], 0x01, input[0], input[0] }
+ * len = 2: combinedl = { input[1], 0x02, input[0], input[1] }
+ * len = 3: combinedl = { input[2], 0x03, input[0], input[1] }
+ */
{ xxh_u8 const c1 = input[0];
xxh_u8 const c2 = input[len >> 1];
xxh_u8 const c3 = input[len - 1];
- xxh_u32 const combinedl = ((xxh_u32)c1) + (((xxh_u32)c2) << 8) + (((xxh_u32)c3) << 16) + (((xxh_u32)len) << 24);
- xxh_u32 const combinedh = XXH_swap32(combinedl);
- xxh_u64 const keyed_lo = (xxh_u64)combinedl ^ (XXH_readLE32(secret) + seed);
- xxh_u64 const keyed_hi = (xxh_u64)combinedh ^ (XXH_readLE32(secret+4) - seed);
- xxh_u64 const mixedl = keyed_lo * PRIME64_1;
- xxh_u64 const mixedh = keyed_hi * PRIME64_5;
+ xxh_u32 const combinedl = ((xxh_u32)c1<<16) | (((xxh_u32)c2) << 24) | (((xxh_u32)c3) << 0) | (((xxh_u32)len) << 8);
+ xxh_u32 const combinedh = XXH_rotl32(XXH_swap32(combinedl), 13);
+ xxh_u64 const bitflipl = (XXH_readLE32(secret) ^ XXH_readLE32(secret+4)) + seed;
+ xxh_u64 const bitfliph = (XXH_readLE32(secret+8) ^ XXH_readLE32(secret+12)) - seed;
+ xxh_u64 const keyed_lo = (xxh_u64)combinedl ^ bitflipl;
+ xxh_u64 const keyed_hi = (xxh_u64)combinedh ^ bitfliph;
+ xxh_u64 const mixedl = keyed_lo * PRIME64_1;
+ xxh_u64 const mixedh = keyed_hi * PRIME64_5;
XXH128_hash_t const h128 = { XXH3_avalanche(mixedl) /*low64*/, XXH3_avalanche(mixedh) /*high64*/ };
return h128;
}
}
-
XXH_FORCE_INLINE XXH128_hash_t
XXH3_len_4to8_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed)
{
XXH_ASSERT(input != NULL);
XXH_ASSERT(secret != NULL);
XXH_ASSERT(4 <= len && len <= 8);
+ seed ^= (xxh_u64)XXH_swap32((xxh_u32)seed) << 32;
{ xxh_u32 const input_lo = XXH_readLE32(input);
xxh_u32 const input_hi = XXH_readLE32(input + len - 4);
- xxh_u64 const input_64_lo = input_lo + ((xxh_u64)input_hi << 32);
- xxh_u64 const input_64_hi = XXH_swap64(input_64_lo);
- xxh_u64 const keyed_lo = input_64_lo ^ (XXH_readLE64(secret) + seed);
- xxh_u64 const keyed_hi = input_64_hi ^ (XXH_readLE64(secret + 8) - seed);
- xxh_u64 const mix64l1 = len + ((keyed_lo ^ (keyed_lo >> 51)) * PRIME32_1);
- xxh_u64 const mix64l2 = (mix64l1 ^ (mix64l1 >> 47)) * PRIME64_2;
- xxh_u64 const mix64h1 = ((keyed_hi ^ (keyed_hi >> 47)) * PRIME64_1) - len;
- xxh_u64 const mix64h2 = (mix64h1 ^ (mix64h1 >> 43)) * PRIME64_4;
- { XXH128_hash_t const h128 = { XXH3_avalanche(mix64l2) /*low64*/, XXH3_avalanche(mix64h2) /*high64*/ };
- return h128;
- } }
+ xxh_u64 const input_64 = input_lo + ((xxh_u64)input_hi << 32);
+ xxh_u64 const bitflip = (XXH_readLE64(secret+16) ^ XXH_readLE64(secret+24)) + seed;
+ xxh_u64 const keyed = input_64 ^ bitflip;
+
+ /* Shift len to the left to ensure it is even, this avoids even multiplies. */
+ XXH128_hash_t m128 = XXH_mult64to128(keyed, PRIME64_1 + (len << 2));
+
+ m128.high64 += (m128.low64 << 1);
+ m128.low64 ^= (m128.high64 >> 3);
+
+ m128.low64 = XXH_xorshift64(m128.low64, 35);
+ m128.low64 *= 0x9FB21C651E98DF25ULL;
+ m128.low64 = XXH_xorshift64(m128.low64, 28);
+ m128.high64 = XXH3_avalanche(m128.high64);
+ return m128;
+ }
}
XXH_FORCE_INLINE XXH128_hash_t
@@ -1313,15 +1735,66 @@ XXH3_len_9to16_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64
XXH_ASSERT(input != NULL);
XXH_ASSERT(secret != NULL);
XXH_ASSERT(9 <= len && len <= 16);
- { xxh_u64 const input_lo = XXH_readLE64(input) ^ (XXH_readLE64(secret) + seed);
- xxh_u64 const input_hi = XXH_readLE64(input + len - 8) ^ (XXH_readLE64(secret+8) - seed);
- XXH128_hash_t m128 = XXH_mult64to128(input_lo ^ input_hi, PRIME64_1);
- xxh_u64 const lenContrib = XXH_mult32to64(len, PRIME32_5);
- m128.low64 += lenContrib;
- m128.high64 += input_hi * PRIME64_1;
- m128.low64 ^= (m128.high64 >> 32);
- { XXH128_hash_t h128 = XXH_mult64to128(m128.low64, PRIME64_2);
+ { xxh_u64 const bitflipl = (XXH_readLE64(secret+32) ^ XXH_readLE64(secret+40)) - seed;
+ xxh_u64 const bitfliph = (XXH_readLE64(secret+48) ^ XXH_readLE64(secret+56)) + seed;
+ xxh_u64 const input_lo = XXH_readLE64(input);
+ xxh_u64 input_hi = XXH_readLE64(input + len - 8);
+ XXH128_hash_t m128 = XXH_mult64to128(input_lo ^ input_hi ^ bitflipl, PRIME64_1);
+ /*
+ * Put len in the middle of m128 to ensure that the length gets mixed to
+ * both the low and high bits in the 128x64 multiply below.
+ */
+ m128.low64 += (xxh_u64)(len - 1) << 54;
+ input_hi ^= bitfliph;
+ /*
+ * Add the high 32 bits of input_hi to the high 32 bits of m128, then
+ * add the long product of the low 32 bits of input_hi and PRIME32_2 to
+ * the high 64 bits of m128.
+ *
+ * The best approach to this operation is different on 32-bit and 64-bit.
+ */
+ if (sizeof(void *) < sizeof(xxh_u64)) { /* 32-bit */
+ /*
+ * 32-bit optimized version, which is more readable.
+ *
+ * On 32-bit, it removes an ADC and delays a dependency between the two
+ * halves of m128.high64, but it generates an extra mask on 64-bit.
+ */
+ m128.high64 += (input_hi & 0xFFFFFFFF00000000) + XXH_mult32to64((xxh_u32)input_hi, PRIME32_2);
+ } else {
+ /*
+ * 64-bit optimized (albeit more confusing) version.
+ *
+ * Uses some properties of addition and multiplication to remove the mask:
+ *
+ * Let:
+ * a = input_hi.lo = (input_hi & 0x00000000FFFFFFFF)
+ * b = input_hi.hi = (input_hi & 0xFFFFFFFF00000000)
+ * c = PRIME32_2
+ *
+ * a + (b * c)
+ * Inverse Property: x + y - x == y
+ * a + (b * (1 + c - 1))
+ * Distributive Property: x * (y + z) == (x * y) + (x * z)
+ * a + (b * 1) + (b * (c - 1))
+ * Identity Property: x * 1 == x
+ * a + b + (b * (c - 1))
+ *
+ * Substitute a, b, and c:
+ * input_hi.hi + input_hi.lo + ((xxh_u64)input_hi.lo * (PRIME32_2 - 1))
+ *
+ * Since input_hi.hi + input_hi.lo == input_hi, we get this:
+ * input_hi + ((xxh_u64)input_hi.lo * (PRIME32_2 - 1))
+ */
+ m128.high64 += input_hi + XXH_mult32to64((xxh_u32)input_hi, PRIME32_2 - 1);
+ }
+ /* m128 ^= XXH_swap64(m128 >> 64); */
+ m128.low64 ^= XXH_swap64(m128.high64);
+
+ { /* 128x64 multiply: h128 = m128 * PRIME64_2; */
+ XXH128_hash_t h128 = XXH_mult64to128(m128.low64, PRIME64_2);
h128.high64 += m128.high64 * PRIME64_2;
+
h128.low64 = XXH3_avalanche(h128.low64);
h128.high64 = XXH3_avalanche(h128.high64);
return h128;
@@ -1337,52 +1810,18 @@ XXH3_len_0to16_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64
{ if (len > 8) return XXH3_len_9to16_128b(input, len, secret, seed);
if (len >= 4) return XXH3_len_4to8_128b(input, len, secret, seed);
if (len) return XXH3_len_1to3_128b(input, len, secret, seed);
- { XXH128_hash_t const h128 = { 0, 0 };
+ { XXH128_hash_t h128;
+ xxh_u64 const bitflipl = XXH_readLE64(secret+64) ^ XXH_readLE64(secret+72);
+ xxh_u64 const bitfliph = XXH_readLE64(secret+80) ^ XXH_readLE64(secret+88);
+ h128.low64 = XXH3_avalanche((PRIME64_1 + seed) ^ bitflipl);
+ h128.high64 = XXH3_avalanche((PRIME64_2 - seed) ^ bitfliph);
return h128;
} }
}
-XXH_FORCE_INLINE XXH128_hash_t
-XXH3_hashLong_128b_internal(const xxh_u8* XXH_RESTRICT input, size_t len,
- const xxh_u8* XXH_RESTRICT secret, size_t secretSize)
-{
- XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[ACC_NB] = XXH3_INIT_ACC;
-
- XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, XXH3_acc_128bits);
-
- /* converge into final hash */
- XXH_STATIC_ASSERT(sizeof(acc) == 64);
- XXH_ASSERT(secretSize >= sizeof(acc) + XXH_SECRET_MERGEACCS_START);
- { xxh_u64 const low64 = XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, (xxh_u64)len * PRIME64_1);
- xxh_u64 const high64 = XXH3_mergeAccs(acc, secret + secretSize - sizeof(acc) - XXH_SECRET_MERGEACCS_START, ~((xxh_u64)len * PRIME64_2));
- XXH128_hash_t const h128 = { low64, high64 };
- return h128;
- }
-}
-
-XXH_NO_INLINE XXH128_hash_t /* It's important for performance that XXH3_hashLong is not inlined. Not sure why (uop cache maybe ?), but difference is large and easily measurable */
-XXH3_hashLong_128b_defaultSecret(const xxh_u8* input, size_t len)
-{
- return XXH3_hashLong_128b_internal(input, len, kSecret, sizeof(kSecret));
-}
-
-XXH_NO_INLINE XXH128_hash_t /* It's important for performance that XXH3_hashLong is not inlined. Not sure why (uop cache maybe ?), but difference is large and easily measurable */
-XXH3_hashLong_128b_withSecret(const xxh_u8* input, size_t len,
- const xxh_u8* secret, size_t secretSize)
-{
- return XXH3_hashLong_128b_internal(input, len, secret, secretSize);
-}
-
-XXH_NO_INLINE XXH128_hash_t /* It's important for performance that XXH3_hashLong is not inlined. Not sure why (uop cache maybe ?), but difference is large and easily measurable */
-XXH3_hashLong_128b_withSeed(const xxh_u8* input, size_t len, XXH64_hash_t seed)
-{
- XXH_ALIGN(8) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE];
- if (seed == 0) return XXH3_hashLong_128b_defaultSecret(input, len);
- XXH3_initCustomSecret(secret, seed);
- return XXH3_hashLong_128b_internal(input, len, secret, sizeof(secret));
-}
-
-
+/*
+ * A bit slower than XXH3_mix16B, but handles multiply by zero better.
+ */
XXH_FORCE_INLINE XXH128_hash_t
XXH128_mix32B(XXH128_hash_t acc, const xxh_u8* input_1, const xxh_u8* input_2, const xxh_u8* secret, XXH64_hash_t seed)
{
@@ -1393,6 +1832,36 @@ XXH128_mix32B(XXH128_hash_t acc, const xxh_u8* input_1, const xxh_u8* input_2, c
return acc;
}
+
+XXH_FORCE_INLINE XXH128_hash_t
+XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len,
+ const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
+ XXH64_hash_t seed)
+{
+ XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); (void)secretSize;
+ XXH_ASSERT(16 < len && len <= 128);
+
+ { XXH128_hash_t acc;
+ acc.low64 = len * PRIME64_1;
+ acc.high64 = 0;
+ if (len > 32) {
+ if (len > 64) {
+ if (len > 96) {
+ acc = XXH128_mix32B(acc, input+48, input+len-64, secret+96, seed);
+ }
+ acc = XXH128_mix32B(acc, input+32, input+len-48, secret+64, seed);
+ }
+ acc = XXH128_mix32B(acc, input+16, input+len-32, secret+32, seed);
+ }
+ acc = XXH128_mix32B(acc, input, input+len-16, secret, seed);
+ { xxh_u64 const low64 = acc.low64 + acc.high64;
+ xxh_u64 const high64 = (acc.low64 * PRIME64_1) + (acc.high64 * PRIME64_4) + ((len - seed) * PRIME64_2);
+ XXH128_hash_t const h128 = { XXH3_avalanche(low64), (XXH64_hash_t)0 - XXH3_avalanche(high64) };
+ return h128;
+ }
+ }
+}
+
XXH_NO_INLINE XXH128_hash_t
XXH3_len_129to240_128b(const xxh_u8* XXH_RESTRICT input, size_t len,
const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
@@ -1426,36 +1895,59 @@ XXH3_len_129to240_128b(const xxh_u8* XXH_RESTRICT input, size_t len,
}
}
-
XXH_FORCE_INLINE XXH128_hash_t
-XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len,
- const xxh_u8* XXH_RESTRICT secret, size_t secretSize,
- XXH64_hash_t seed)
+XXH3_hashLong_128b_internal(const xxh_u8* XXH_RESTRICT input, size_t len,
+ const xxh_u8* XXH_RESTRICT secret, size_t secretSize)
{
- XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); (void)secretSize;
- XXH_ASSERT(16 < len && len <= 128);
+ XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[ACC_NB] = XXH3_INIT_ACC;
- { XXH128_hash_t acc;
- acc.low64 = len * PRIME64_1;
- acc.high64 = 0;
- if (len > 32) {
- if (len > 64) {
- if (len > 96) {
- acc = XXH128_mix32B(acc, input+48, input+len-64, secret+96, seed);
- }
- acc = XXH128_mix32B(acc, input+32, input+len-48, secret+64, seed);
- }
- acc = XXH128_mix32B(acc, input+16, input+len-32, secret+32, seed);
- }
- acc = XXH128_mix32B(acc, input, input+len-16, secret, seed);
- { xxh_u64 const low64 = acc.low64 + acc.high64;
- xxh_u64 const high64 = (acc.low64 * PRIME64_1) + (acc.high64 * PRIME64_4) + ((len - seed) * PRIME64_2);
- XXH128_hash_t const h128 = { XXH3_avalanche(low64), (XXH64_hash_t)0 - XXH3_avalanche(high64) };
- return h128;
- }
+ XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, XXH3_acc_128bits);
+
+ /* converge into final hash */
+ XXH_STATIC_ASSERT(sizeof(acc) == 64);
+ XXH_ASSERT(secretSize >= sizeof(acc) + XXH_SECRET_MERGEACCS_START);
+ { xxh_u64 const low64 = XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, (xxh_u64)len * PRIME64_1);
+ xxh_u64 const high64 = XXH3_mergeAccs(acc, secret + secretSize - sizeof(acc) - XXH_SECRET_MERGEACCS_START, ~((xxh_u64)len * PRIME64_2));
+ XXH128_hash_t const h128 = { low64, high64 };
+ return h128;
}
}
+/*
+ * It's important for performance that XXH3_hashLong is not inlined. Not sure
+ * why (uop cache maybe?), but the difference is large and easily measurable.
+ */
+XXH_NO_INLINE XXH128_hash_t
+XXH3_hashLong_128b_defaultSecret(const xxh_u8* input, size_t len)
+{
+ return XXH3_hashLong_128b_internal(input, len, kSecret, sizeof(kSecret));
+}
+
+/*
+ * It's important for performance that XXH3_hashLong is not inlined. Not sure
+ * why (uop cache maybe?), but the difference is large and easily measurable.
+ */
+XXH_NO_INLINE XXH128_hash_t
+XXH3_hashLong_128b_withSecret(const xxh_u8* input, size_t len,
+ const xxh_u8* secret, size_t secretSize)
+{
+ return XXH3_hashLong_128b_internal(input, len, secret, secretSize);
+}
+
+/*
+ * It's important for performance that XXH3_hashLong is not inlined. Not sure
+ * why (uop cache maybe?), but the difference is large and easily measurable.
+ */
+XXH_NO_INLINE XXH128_hash_t
+XXH3_hashLong_128b_withSeed(const xxh_u8* input, size_t len, XXH64_hash_t seed)
+{
+ XXH_ALIGN(8) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE];
+ if (seed == 0) return XXH3_hashLong_128b_defaultSecret(input, len);
+ XXH3_initCustomSecret(secret, seed);
+ return XXH3_hashLong_128b_internal(input, len, secret, sizeof(secret));
+}
+
+
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(const void* input, size_t len)
{
if (len <= 16) return XXH3_len_0to16_128b((const xxh_u8*)input, len, kSecret, 0);
@@ -1468,10 +1960,12 @@ XXH_PUBLIC_API XXH128_hash_t
XXH3_128bits_withSecret(const void* input, size_t len, const void* secret, size_t secretSize)
{
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN);
- /* if an action must be taken should `secret` conditions not be respected,
+ /*
+ * If an action is to be taken if `secret` conditions are not respected,
* it should be done here.
* For now, it's a contract pre-condition.
- * Adding a check and a branch here would cost performance at every hash */
+ * Adding a check and a branch here would cost performance at every hash.
+ */
if (len <= 16) return XXH3_len_0to16_128b((const xxh_u8*)input, len, (const xxh_u8*)secret, 0);
if (len <= 128) return XXH3_len_17to128_128b((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, 0);
if (len <= XXH3_MIDSIZE_MAX) return XXH3_len_129to240_128b((const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, 0);
@@ -1562,7 +2056,7 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state)
/* 128-bit utility functions */
-#include <string.h> /* memcmp */
+#include <string.h> /* memcmp, memcpy */
/* return : 1 is equal, 0 if different */
XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2)
@@ -1608,6 +2102,11 @@ XXH128_hashFromCanonical(const XXH128_canonical_t* src)
return h;
}
+/* Pop our optimization override from above */
+#if XXH_VECTOR == XXH_AVX2 /* AVX2 */ \
+ && defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \
+ && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) /* respect -O0 and -Os */
+# pragma GCC pop_options
+#endif
-
-#endif /* XXH3_H */
+#endif /* XXH3_H_1397135465 */
diff --git a/dviware/dvisvgm/libs/xxHash/xxhash.c b/dviware/dvisvgm/libs/xxHash/xxhash.c
index 3f49b7d1d8..3e0da98f3e 100644
--- a/dviware/dvisvgm/libs/xxHash/xxhash.c
+++ b/dviware/dvisvgm/libs/xxHash/xxhash.c
@@ -1,1110 +1,43 @@
/*
-* xxHash - Fast Hash algorithm
-* Copyright (C) 2012-2016, Yann Collet
-*
-* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are
-* met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following disclaimer
-* in the documentation and/or other materials provided with the
-* distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* You can contact the author at :
-* - xxHash homepage: http://www.xxhash.com
-* - xxHash source repository : https://github.com/Cyan4973/xxHash
-*/
-
-
-/* since xxhash.c can be included (via XXH_INLINE_ALL),
- * it's good practice to protect it with guard
- * in case of multiples inclusions */
-#ifndef XXHASH_C_01393879
-#define XXHASH_C_01393879
-
-/* *************************************
-* Tuning parameters
-***************************************/
-/*!XXH_FORCE_MEMORY_ACCESS :
- * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
- * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
- * The below switch allow to select different access method for improved performance.
- * Method 0 (default) : use `memcpy()`. Safe and portable.
- * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
- * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
- * Method 2 : direct access. This method doesn't depend on compiler but violate C standard.
- * It can generate buggy code on targets which do not support unaligned memory accesses.
- * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
- * See http://stackoverflow.com/a/32095106/646947 for details.
- * Prefer these methods in priority order (0 > 1 > 2)
- */
-#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
-# if !defined(__clang__) && defined(__GNUC__) && defined(__ARM_FEATURE_UNALIGNED) && defined(__ARM_ARCH) && (__ARM_ARCH == 6)
-# define XXH_FORCE_MEMORY_ACCESS 2
-# elif !defined(__clang__) && ((defined(__INTEL_COMPILER) && !defined(_WIN32)) || \
- (defined(__GNUC__) && (defined(__ARM_ARCH) && __ARM_ARCH >= 7)))
-# define XXH_FORCE_MEMORY_ACCESS 1
-# endif
-#endif
-
-/*!XXH_ACCEPT_NULL_INPUT_POINTER :
- * If input pointer is NULL, xxHash default behavior is to dereference it, triggering a segfault.
- * When this macro is enabled, xxHash actively checks input for null pointer.
- * It it is, result for null input pointers is the same as a null-length input.
- */
-#ifndef XXH_ACCEPT_NULL_INPUT_POINTER /* can be defined externally */
-# define XXH_ACCEPT_NULL_INPUT_POINTER 0
-#endif
-
-/*!XXH_FORCE_ALIGN_CHECK :
- * This is a minor performance trick, only useful with lots of very small keys.
- * It means : check for aligned/unaligned input.
- * The check costs one initial branch per hash;
- * set it to 0 when the input is guaranteed to be aligned,
- * or when alignment doesn't matter for performance.
- */
-#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */
-# if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
-# define XXH_FORCE_ALIGN_CHECK 0
-# else
-# define XXH_FORCE_ALIGN_CHECK 1
-# endif
-#endif
-
-/*!XXH_REROLL:
- * Whether to reroll XXH32_finalize, and XXH64_finalize,
- * instead of using an unrolled jump table/if statement loop.
+ * xxHash - Extremely Fast Hash algorithm
+ * Copyright (C) 2012-present, Yann Collet
*
- * This is automatically defined on -Os/-Oz on GCC and Clang. */
-#ifndef XXH_REROLL
-# if defined(__OPTIMIZE_SIZE__)
-# define XXH_REROLL 1
-# else
-# define XXH_REROLL 0
-# endif
-#endif
-
-/* *************************************
-* Includes & Memory related functions
-***************************************/
-/*! Modify the local functions below should you wish to use some other memory routines
-* for malloc(), free() */
-#include <stdlib.h>
-static void* XXH_malloc(size_t s) { return malloc(s); }
-static void XXH_free (void* p) { free(p); }
-/*! and for memcpy() */
-#include <string.h>
-static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
-
-#include <limits.h> /* ULLONG_MAX */
-
-#define XXH_STATIC_LINKING_ONLY
-#include "xxhash.h"
-
-
-/* *************************************
-* Compiler Specific Options
-***************************************/
-#ifdef _MSC_VER /* Visual Studio */
-# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
-# define XXH_FORCE_INLINE static __forceinline
-# define XXH_NO_INLINE static __declspec(noinline)
-#else
-# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
-# ifdef __GNUC__
-# define XXH_FORCE_INLINE static inline __attribute__((always_inline))
-# define XXH_NO_INLINE static __attribute__((noinline))
-# else
-# define XXH_FORCE_INLINE static inline
-# define XXH_NO_INLINE static
-# endif
-# else
-# define XXH_FORCE_INLINE static
-# define XXH_NO_INLINE static
-# endif /* __STDC_VERSION__ */
-#endif
-
-
-
-/* *************************************
-* Debug
-***************************************/
-/* DEBUGLEVEL is expected to be defined externally,
- * typically through compiler command line.
- * Value must be a number. */
-#ifndef DEBUGLEVEL
-# define DEBUGLEVEL 0
-#endif
-
-#if (DEBUGLEVEL>=1)
-# include <assert.h> /* note : can still be disabled with NDEBUG */
-# define XXH_ASSERT(c) assert(c)
-#else
-# define XXH_ASSERT(c) ((void)0)
-#endif
-
-/* note : use after variable declarations */
-#define XXH_STATIC_ASSERT(c) { enum { XXH_sa = 1/(int)(!!(c)) }; }
-
-
-/* *************************************
-* Basic Types
-***************************************/
-#if !defined (__VMS) \
- && (defined (__cplusplus) \
- || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
-# include <stdint.h>
- typedef uint8_t xxh_u8;
-#else
- typedef unsigned char xxh_u8;
-#endif
-typedef XXH32_hash_t xxh_u32;
-
-
-/* === Memory access === */
-
-#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
-
-/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */
-static xxh_u32 XXH_read32(const void* memPtr) { return *(const xxh_u32*) memPtr; }
-
-#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
-
-/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
-/* currently only defined for gcc and icc */
-typedef union { xxh_u32 u32; } __attribute__((packed)) unalign;
-static xxh_u32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
-
-#else
-
-/* portable and safe solution. Generally efficient.
- * see : http://stackoverflow.com/a/32095106/646947
- */
-static xxh_u32 XXH_read32(const void* memPtr)
-{
- xxh_u32 val;
- memcpy(&val, memPtr, sizeof(val));
- return val;
-}
-
-#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */
-
-
-/* === Endianess === */
-typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
-
-/* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */
-#ifndef XXH_CPU_LITTLE_ENDIAN
-# if defined(_WIN32) /* Windows is always little endian */ \
- || defined(__LITTLE_ENDIAN__) \
- || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
-# define XXH_CPU_LITTLE_ENDIAN 1
-# elif defined(__BIG_ENDIAN__) \
- || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
-# define XXH_CPU_LITTLE_ENDIAN 0
-# else
-static int XXH_isLittleEndian(void)
-{
- const union { xxh_u32 u; xxh_u8 c[4]; } one = { 1 }; /* don't use static : performance detrimental */
- return one.c[0];
-}
-# define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian()
-# endif
-#endif
-
-
-
-
-/* ****************************************
-* Compiler-specific Functions and Macros
-******************************************/
-#define XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
-
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
-#if !defined(NO_CLANG_BUILTIN) && __has_builtin(__builtin_rotateleft32) && __has_builtin(__builtin_rotateleft64)
-# define XXH_rotl32 __builtin_rotateleft32
-# define XXH_rotl64 __builtin_rotateleft64
-/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */
-#elif defined(_MSC_VER)
-# define XXH_rotl32(x,r) _rotl(x,r)
-# define XXH_rotl64(x,r) _rotl64(x,r)
-#else
-# define XXH_rotl32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
-# define XXH_rotl64(x,r) (((x) << (r)) | ((x) >> (64 - (r))))
-#endif
-
-#if defined(_MSC_VER) /* Visual Studio */
-# define XXH_swap32 _byteswap_ulong
-#elif XXH_GCC_VERSION >= 403
-# define XXH_swap32 __builtin_bswap32
-#else
-static xxh_u32 XXH_swap32 (xxh_u32 x)
-{
- return ((x << 24) & 0xff000000 ) |
- ((x << 8) & 0x00ff0000 ) |
- ((x >> 8) & 0x0000ff00 ) |
- ((x >> 24) & 0x000000ff );
-}
-#endif
-
-
-/* ***************************
-* Memory reads
-*****************************/
-typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
-
-XXH_FORCE_INLINE xxh_u32 XXH_readLE32(const void* ptr)
-{
- return XXH_CPU_LITTLE_ENDIAN ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
-}
-
-static xxh_u32 XXH_readBE32(const void* ptr)
-{
- return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr);
-}
-
-XXH_FORCE_INLINE xxh_u32
-XXH_readLE32_align(const void* ptr, XXH_alignment align)
-{
- if (align==XXH_unaligned) {
- return XXH_readLE32(ptr);
- } else {
- return XXH_CPU_LITTLE_ENDIAN ? *(const xxh_u32*)ptr : XXH_swap32(*(const xxh_u32*)ptr);
- }
-}
-
-
-/* *************************************
-* Misc
-***************************************/
-XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
-
-
-/* *******************************************************************
-* 32-bit hash functions
-*********************************************************************/
-static const xxh_u32 PRIME32_1 = 0x9E3779B1U; /* 0b10011110001101110111100110110001 */
-static const xxh_u32 PRIME32_2 = 0x85EBCA77U; /* 0b10000101111010111100101001110111 */
-static const xxh_u32 PRIME32_3 = 0xC2B2AE3DU; /* 0b11000010101100101010111000111101 */
-static const xxh_u32 PRIME32_4 = 0x27D4EB2FU; /* 0b00100111110101001110101100101111 */
-static const xxh_u32 PRIME32_5 = 0x165667B1U; /* 0b00010110010101100110011110110001 */
-
-static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input)
-{
- acc += input * PRIME32_2;
- acc = XXH_rotl32(acc, 13);
- acc *= PRIME32_1;
-#if defined(__GNUC__) && defined(__SSE4_1__) && !defined(XXH_ENABLE_AUTOVECTORIZE)
- /* UGLY HACK:
- * This inline assembly hack forces acc into a normal register. This is the
- * only thing that prevents GCC and Clang from autovectorizing the XXH32 loop
- * (pragmas and attributes don't work for some resason) without globally
- * disabling SSE4.1.
- *
- * The reason we want to avoid vectorization is because despite working on
- * 4 integers at a time, there are multiple factors slowing XXH32 down on
- * SSE4:
- * - There's a ridiculous amount of lag from pmulld (10 cycles of latency on newer chips!)
- * making it slightly slower to multiply four integers at once compared to four
- * integers independently. Even when pmulld was fastest, Sandy/Ivy Bridge, it is
- * still not worth it to go into SSE just to multiply unless doing a long operation.
- *
- * - Four instructions are required to rotate,
- * movqda tmp, v // not required with VEX encoding
- * pslld tmp, 13 // tmp <<= 13
- * psrld v, 19 // x >>= 19
- * por v, tmp // x |= tmp
- * compared to one for scalar:
- * roll v, 13 // reliably fast across the board
- * shldl v, v, 13 // Sandy Bridge and later prefer this for some reason
- *
- * - Instruction level parallelism is actually more beneficial here because the
- * SIMD actually serializes this operation: While v1 is rotating, v2 can load data,
- * while v3 can multiply. SSE forces them to operate together.
- *
- * How this hack works:
- * __asm__("" // Declare an assembly block but don't declare any instructions
- * : // However, as an Input/Output Operand,
- * "+r" // constrain a read/write operand (+) as a general purpose register (r).
- * (acc) // and set acc as the operand
- * );
- *
- * Because of the 'r', the compiler has promised that seed will be in a
- * general purpose register and the '+' says that it will be 'read/write',
- * so it has to assume it has changed. It is like volatile without all the
- * loads and stores.
- *
- * Since the argument has to be in a normal register (not an SSE register),
- * each time XXH32_round is called, it is impossible to vectorize. */
- __asm__("" : "+r" (acc));
-#endif
- return acc;
-}
-
-/* mix all bits */
-static xxh_u32 XXH32_avalanche(xxh_u32 h32)
-{
- h32 ^= h32 >> 15;
- h32 *= PRIME32_2;
- h32 ^= h32 >> 13;
- h32 *= PRIME32_3;
- h32 ^= h32 >> 16;
- return(h32);
-}
-
-#define XXH_get32bits(p) XXH_readLE32_align(p, align)
-
-static xxh_u32
-XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align)
-{
-#define PROCESS1 \
- h32 += (*ptr++) * PRIME32_5; \
- h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
-
-#define PROCESS4 \
- h32 += XXH_get32bits(ptr) * PRIME32_3; \
- ptr+=4; \
- h32 = XXH_rotl32(h32, 17) * PRIME32_4 ;
-
- /* Compact rerolled version */
- if (XXH_REROLL) {
- len &= 15;
- while (len >= 4) {
- PROCESS4;
- len -= 4;
- }
- while (len > 0) {
- PROCESS1;
- --len;
- }
- return XXH32_avalanche(h32);
- } else {
- switch(len&15) /* or switch(bEnd - p) */ {
- case 12: PROCESS4;
- /* fallthrough */
- case 8: PROCESS4;
- /* fallthrough */
- case 4: PROCESS4;
- return XXH32_avalanche(h32);
-
- case 13: PROCESS4;
- /* fallthrough */
- case 9: PROCESS4;
- /* fallthrough */
- case 5: PROCESS4;
- PROCESS1;
- return XXH32_avalanche(h32);
-
- case 14: PROCESS4;
- /* fallthrough */
- case 10: PROCESS4;
- /* fallthrough */
- case 6: PROCESS4;
- PROCESS1;
- PROCESS1;
- return XXH32_avalanche(h32);
-
- case 15: PROCESS4;
- /* fallthrough */
- case 11: PROCESS4;
- /* fallthrough */
- case 7: PROCESS4;
- /* fallthrough */
- case 3: PROCESS1;
- /* fallthrough */
- case 2: PROCESS1;
- /* fallthrough */
- case 1: PROCESS1;
- /* fallthrough */
- case 0: return XXH32_avalanche(h32);
- }
- XXH_ASSERT(0);
- return h32; /* reaching this point is deemed impossible */
- }
-}
-
-XXH_FORCE_INLINE xxh_u32
-XXH32_endian_align(const xxh_u8* input, size_t len, xxh_u32 seed, XXH_alignment align)
-{
- const xxh_u8* bEnd = input + len;
- xxh_u32 h32;
-
-#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
- if (input==NULL) {
- len=0;
- bEnd=input=(const xxh_u8*)(size_t)16;
- }
-#endif
-
- if (len>=16) {
- const xxh_u8* const limit = bEnd - 15;
- xxh_u32 v1 = seed + PRIME32_1 + PRIME32_2;
- xxh_u32 v2 = seed + PRIME32_2;
- xxh_u32 v3 = seed + 0;
- xxh_u32 v4 = seed - PRIME32_1;
-
- do {
- v1 = XXH32_round(v1, XXH_get32bits(input)); input += 4;
- v2 = XXH32_round(v2, XXH_get32bits(input)); input += 4;
- v3 = XXH32_round(v3, XXH_get32bits(input)); input += 4;
- v4 = XXH32_round(v4, XXH_get32bits(input)); input += 4;
- } while (input < limit);
-
- h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7)
- + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
- } else {
- h32 = seed + PRIME32_5;
- }
-
- h32 += (xxh_u32)len;
-
- return XXH32_finalize(h32, input, len&15, align);
-}
-
-
-XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t len, XXH32_hash_t seed)
-{
-#if 0
- /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
- XXH32_state_t state;
- XXH32_reset(&state, seed);
- XXH32_update(&state, (const xxh_u8*)input, len);
- return XXH32_digest(&state);
-
-#else
-
- if (XXH_FORCE_ALIGN_CHECK) {
- if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */
- return XXH32_endian_align((const xxh_u8*)input, len, seed, XXH_aligned);
- } }
-
- return XXH32_endian_align((const xxh_u8*)input, len, seed, XXH_unaligned);
-#endif
-}
-
-
-
-/*====== Hash streaming ======*/
-
-XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void)
-{
- return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
-}
-XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr)
-{
- XXH_free(statePtr);
- return XXH_OK;
-}
-
-XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dstState, const XXH32_state_t* srcState)
-{
- memcpy(dstState, srcState, sizeof(*dstState));
-}
-
-XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, XXH32_hash_t seed)
-{
- XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
- memset(&state, 0, sizeof(state));
- state.v1 = seed + PRIME32_1 + PRIME32_2;
- state.v2 = seed + PRIME32_2;
- state.v3 = seed + 0;
- state.v4 = seed - PRIME32_1;
- /* do not write into reserved, planned to be removed in a future version */
- memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved));
- return XXH_OK;
-}
-
-
-XXH_PUBLIC_API XXH_errorcode
-XXH32_update(XXH32_state_t* state, const void* input, size_t len)
-{
- if (input==NULL)
-#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
- return XXH_OK;
-#else
- return XXH_ERROR;
-#endif
-
- { const xxh_u8* p = (const xxh_u8*)input;
- const xxh_u8* const bEnd = p + len;
-
- state->total_len_32 += (XXH32_hash_t)len;
- state->large_len |= (XXH32_hash_t)((len>=16) | (state->total_len_32>=16));
-
- if (state->memsize + len < 16) { /* fill in tmp buffer */
- XXH_memcpy((xxh_u8*)(state->mem32) + state->memsize, input, len);
- state->memsize += (XXH32_hash_t)len;
- return XXH_OK;
- }
-
- if (state->memsize) { /* some data left from previous update */
- XXH_memcpy((xxh_u8*)(state->mem32) + state->memsize, input, 16-state->memsize);
- { const xxh_u32* p32 = state->mem32;
- state->v1 = XXH32_round(state->v1, XXH_readLE32(p32)); p32++;
- state->v2 = XXH32_round(state->v2, XXH_readLE32(p32)); p32++;
- state->v3 = XXH32_round(state->v3, XXH_readLE32(p32)); p32++;
- state->v4 = XXH32_round(state->v4, XXH_readLE32(p32));
- }
- p += 16-state->memsize;
- state->memsize = 0;
- }
-
- if (p <= bEnd-16) {
- const xxh_u8* const limit = bEnd - 16;
- xxh_u32 v1 = state->v1;
- xxh_u32 v2 = state->v2;
- xxh_u32 v3 = state->v3;
- xxh_u32 v4 = state->v4;
-
- do {
- v1 = XXH32_round(v1, XXH_readLE32(p)); p+=4;
- v2 = XXH32_round(v2, XXH_readLE32(p)); p+=4;
- v3 = XXH32_round(v3, XXH_readLE32(p)); p+=4;
- v4 = XXH32_round(v4, XXH_readLE32(p)); p+=4;
- } while (p<=limit);
-
- state->v1 = v1;
- state->v2 = v2;
- state->v3 = v3;
- state->v4 = v4;
- }
-
- if (p < bEnd) {
- XXH_memcpy(state->mem32, p, (size_t)(bEnd-p));
- state->memsize = (unsigned)(bEnd-p);
- }
- }
-
- return XXH_OK;
-}
-
-
-XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* state)
-{
- xxh_u32 h32;
-
- if (state->large_len) {
- h32 = XXH_rotl32(state->v1, 1)
- + XXH_rotl32(state->v2, 7)
- + XXH_rotl32(state->v3, 12)
- + XXH_rotl32(state->v4, 18);
- } else {
- h32 = state->v3 /* == seed */ + PRIME32_5;
- }
-
- h32 += state->total_len_32;
-
- return XXH32_finalize(h32, (const xxh_u8*)state->mem32, state->memsize, XXH_aligned);
-}
-
-
-/*====== Canonical representation ======*/
-
-/*! Default XXH result types are basic unsigned 32 and 64 bits.
-* The canonical representation follows human-readable write convention, aka big-endian (large digits first).
-* These functions allow transformation of hash result into and from its canonical format.
-* This way, hash values can be written into a file or buffer, remaining comparable across different systems.
-*/
-
-XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash)
-{
- XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t));
- if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash);
- memcpy(dst, &hash, sizeof(*dst));
-}
-
-XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src)
-{
- return XXH_readBE32(src);
-}
-
-
-#ifndef XXH_NO_LONG_LONG
-
-/* *******************************************************************
-* 64-bit hash functions
-*********************************************************************/
-
-/*====== Memory access ======*/
-
-typedef XXH64_hash_t xxh_u64;
-
-
-/*! XXH_REROLL_XXH64:
- * Whether to reroll the XXH64_finalize() loop.
+ * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
*
- * Just like XXH32, we can unroll the XXH64_finalize() loop. This can be a performance gain
- * on 64-bit hosts, as only one jump is required.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * However, on 32-bit hosts, because arithmetic needs to be done with two 32-bit registers,
- * and 64-bit arithmetic needs to be simulated, it isn't beneficial to unroll. The code becomes
- * ridiculously large (the largest function in the binary on i386!), and rerolling it saves
- * anywhere from 3kB to 20kB. It is also slightly faster because it fits into cache better
- * and is more likely to be inlined by the compiler.
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
*
- * If XXH_REROLL is defined, this is ignored and the loop is always rerolled. */
-#ifndef XXH_REROLL_XXH64
-# if (defined(__ILP32__) || defined(_ILP32)) /* ILP32 is often defined on 32-bit GCC family */ \
- || !(defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) /* x86-64 */ \
- || defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) /* aarch64 */ \
- || defined(__PPC64__) || defined(__PPC64LE__) || defined(__ppc64__) || defined(__powerpc64__) /* ppc64 */ \
- || defined(__mips64__) || defined(__mips64)) /* mips64 */ \
- || (!defined(SIZE_MAX) || SIZE_MAX < ULLONG_MAX) /* check limits */
-# define XXH_REROLL_XXH64 1
-# else
-# define XXH_REROLL_XXH64 0
-# endif
-#endif /* !defined(XXH_REROLL_XXH64) */
-
-#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
-
-/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */
-static xxh_u64 XXH_read64(const void* memPtr) { return *(const xxh_u64*) memPtr; }
-
-#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
-
-/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
-/* currently only defined for gcc and icc */
-typedef union { xxh_u32 u32; xxh_u64 u64; } __attribute__((packed)) unalign64;
-static xxh_u64 XXH_read64(const void* ptr) { return ((const unalign64*)ptr)->u64; }
-
-#else
-
-/* portable and safe solution. Generally efficient.
- * see : http://stackoverflow.com/a/32095106/646947
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at:
+ * - xxHash homepage: https://www.xxhash.com
+ * - xxHash source repository: https://github.com/Cyan4973/xxHash
*/
-static xxh_u64 XXH_read64(const void* memPtr)
-{
- xxh_u64 val;
- memcpy(&val, memPtr, sizeof(val));
- return val;
-}
-
-#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */
-
-#if defined(_MSC_VER) /* Visual Studio */
-# define XXH_swap64 _byteswap_uint64
-#elif XXH_GCC_VERSION >= 403
-# define XXH_swap64 __builtin_bswap64
-#else
-static xxh_u64 XXH_swap64 (xxh_u64 x)
-{
- return ((x << 56) & 0xff00000000000000ULL) |
- ((x << 40) & 0x00ff000000000000ULL) |
- ((x << 24) & 0x0000ff0000000000ULL) |
- ((x << 8) & 0x000000ff00000000ULL) |
- ((x >> 8) & 0x00000000ff000000ULL) |
- ((x >> 24) & 0x0000000000ff0000ULL) |
- ((x >> 40) & 0x000000000000ff00ULL) |
- ((x >> 56) & 0x00000000000000ffULL);
-}
-#endif
-
-XXH_FORCE_INLINE xxh_u64 XXH_readLE64(const void* ptr)
-{
- return XXH_CPU_LITTLE_ENDIAN ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
-}
-
-static xxh_u64 XXH_readBE64(const void* ptr)
-{
- return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr);
-}
-
-XXH_FORCE_INLINE xxh_u64
-XXH_readLE64_align(const void* ptr, XXH_alignment align)
-{
- if (align==XXH_unaligned)
- return XXH_readLE64(ptr);
- else
- return XXH_CPU_LITTLE_ENDIAN ? *(const xxh_u64*)ptr : XXH_swap64(*(const xxh_u64*)ptr);
-}
-
-
-/*====== xxh64 ======*/
-
-static const xxh_u64 PRIME64_1 = 0x9E3779B185EBCA87ULL; /* 0b1001111000110111011110011011000110000101111010111100101010000111 */
-static const xxh_u64 PRIME64_2 = 0xC2B2AE3D27D4EB4FULL; /* 0b1100001010110010101011100011110100100111110101001110101101001111 */
-static const xxh_u64 PRIME64_3 = 0x165667B19E3779F9ULL; /* 0b0001011001010110011001111011000110011110001101110111100111111001 */
-static const xxh_u64 PRIME64_4 = 0x85EBCA77C2B2AE63ULL; /* 0b1000010111101011110010100111011111000010101100101010111001100011 */
-static const xxh_u64 PRIME64_5 = 0x27D4EB2F165667C5ULL; /* 0b0010011111010100111010110010111100010110010101100110011111000101 */
-
-static xxh_u64 XXH64_round(xxh_u64 acc, xxh_u64 input)
-{
- acc += input * PRIME64_2;
- acc = XXH_rotl64(acc, 31);
- acc *= PRIME64_1;
- return acc;
-}
-
-static xxh_u64 XXH64_mergeRound(xxh_u64 acc, xxh_u64 val)
-{
- val = XXH64_round(0, val);
- acc ^= val;
- acc = acc * PRIME64_1 + PRIME64_4;
- return acc;
-}
-
-static xxh_u64 XXH64_avalanche(xxh_u64 h64)
-{
- h64 ^= h64 >> 33;
- h64 *= PRIME64_2;
- h64 ^= h64 >> 29;
- h64 *= PRIME64_3;
- h64 ^= h64 >> 32;
- return h64;
-}
-
-
-#define XXH_get64bits(p) XXH_readLE64_align(p, align)
-
-static xxh_u64
-XXH64_finalize(xxh_u64 h64, const xxh_u8* ptr, size_t len, XXH_alignment align)
-{
-#define PROCESS1_64 \
- h64 ^= (*ptr++) * PRIME64_5; \
- h64 = XXH_rotl64(h64, 11) * PRIME64_1;
-
-#define PROCESS4_64 \
- h64 ^= (xxh_u64)(XXH_get32bits(ptr)) * PRIME64_1; \
- ptr+=4; \
- h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
-
-#define PROCESS8_64 { \
- xxh_u64 const k1 = XXH64_round(0, XXH_get64bits(ptr)); \
- ptr+=8; \
- h64 ^= k1; \
- h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; \
-}
-
- /* Rerolled version for 32-bit targets is faster and much smaller. */
- if (XXH_REROLL || XXH_REROLL_XXH64) {
- len &= 31;
- while (len >= 8) {
- PROCESS8_64;
- len -= 8;
- }
- if (len >= 4) {
- PROCESS4_64;
- len -= 4;
- }
- while (len > 0) {
- PROCESS1_64;
- --len;
- }
- return XXH64_avalanche(h64);
- } else {
- switch(len & 31) {
- case 24: PROCESS8_64;
- /* fallthrough */
- case 16: PROCESS8_64;
- /* fallthrough */
- case 8: PROCESS8_64;
- return XXH64_avalanche(h64);
-
- case 28: PROCESS8_64;
- /* fallthrough */
- case 20: PROCESS8_64;
- /* fallthrough */
- case 12: PROCESS8_64;
- /* fallthrough */
- case 4: PROCESS4_64;
- return XXH64_avalanche(h64);
-
- case 25: PROCESS8_64;
- /* fallthrough */
- case 17: PROCESS8_64;
- /* fallthrough */
- case 9: PROCESS8_64;
- PROCESS1_64;
- return XXH64_avalanche(h64);
-
- case 29: PROCESS8_64;
- /* fallthrough */
- case 21: PROCESS8_64;
- /* fallthrough */
- case 13: PROCESS8_64;
- /* fallthrough */
- case 5: PROCESS4_64;
- PROCESS1_64;
- return XXH64_avalanche(h64);
-
- case 26: PROCESS8_64;
- /* fallthrough */
- case 18: PROCESS8_64;
- /* fallthrough */
- case 10: PROCESS8_64;
- PROCESS1_64;
- PROCESS1_64;
- return XXH64_avalanche(h64);
-
- case 30: PROCESS8_64;
- /* fallthrough */
- case 22: PROCESS8_64;
- /* fallthrough */
- case 14: PROCESS8_64;
- /* fallthrough */
- case 6: PROCESS4_64;
- PROCESS1_64;
- PROCESS1_64;
- return XXH64_avalanche(h64);
-
- case 27: PROCESS8_64;
- /* fallthrough */
- case 19: PROCESS8_64;
- /* fallthrough */
- case 11: PROCESS8_64;
- PROCESS1_64;
- PROCESS1_64;
- PROCESS1_64;
- return XXH64_avalanche(h64);
-
- case 31: PROCESS8_64;
- /* fallthrough */
- case 23: PROCESS8_64;
- /* fallthrough */
- case 15: PROCESS8_64;
- /* fallthrough */
- case 7: PROCESS4_64;
- /* fallthrough */
- case 3: PROCESS1_64;
- /* fallthrough */
- case 2: PROCESS1_64;
- /* fallthrough */
- case 1: PROCESS1_64;
- /* fallthrough */
- case 0: return XXH64_avalanche(h64);
- }
- }
- /* impossible to reach */
- XXH_ASSERT(0);
- return 0; /* unreachable, but some compilers complain without it */
-}
-
-XXH_FORCE_INLINE xxh_u64
-XXH64_endian_align(const xxh_u8* input, size_t len, xxh_u64 seed, XXH_alignment align)
-{
- const xxh_u8* bEnd = input + len;
- xxh_u64 h64;
-
-#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
- if (input==NULL) {
- len=0;
- bEnd=input=(const xxh_u8*)(size_t)32;
- }
-#endif
-
- if (len>=32) {
- const xxh_u8* const limit = bEnd - 32;
- xxh_u64 v1 = seed + PRIME64_1 + PRIME64_2;
- xxh_u64 v2 = seed + PRIME64_2;
- xxh_u64 v3 = seed + 0;
- xxh_u64 v4 = seed - PRIME64_1;
-
- do {
- v1 = XXH64_round(v1, XXH_get64bits(input)); input+=8;
- v2 = XXH64_round(v2, XXH_get64bits(input)); input+=8;
- v3 = XXH64_round(v3, XXH_get64bits(input)); input+=8;
- v4 = XXH64_round(v4, XXH_get64bits(input)); input+=8;
- } while (input<=limit);
-
- h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
- h64 = XXH64_mergeRound(h64, v1);
- h64 = XXH64_mergeRound(h64, v2);
- h64 = XXH64_mergeRound(h64, v3);
- h64 = XXH64_mergeRound(h64, v4);
-
- } else {
- h64 = seed + PRIME64_5;
- }
-
- h64 += (xxh_u64) len;
-
- return XXH64_finalize(h64, input, len, align);
-}
-
-
-XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, XXH64_hash_t seed)
-{
-#if 0
- /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
- XXH64_state_t state;
- XXH64_reset(&state, seed);
- XXH64_update(&state, (const xxh_u8*)input, len);
- return XXH64_digest(&state);
-
-#else
-
- if (XXH_FORCE_ALIGN_CHECK) {
- if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */
- return XXH64_endian_align((const xxh_u8*)input, len, seed, XXH_aligned);
- } }
-
- return XXH64_endian_align((const xxh_u8*)input, len, seed, XXH_unaligned);
-
-#endif
-}
-
-/*====== Hash Streaming ======*/
-
-XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void)
-{
- return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t));
-}
-XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr)
-{
- XXH_free(statePtr);
- return XXH_OK;
-}
-
-XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dstState, const XXH64_state_t* srcState)
-{
- memcpy(dstState, srcState, sizeof(*dstState));
-}
-
-XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, XXH64_hash_t seed)
-{
- XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
- memset(&state, 0, sizeof(state));
- state.v1 = seed + PRIME64_1 + PRIME64_2;
- state.v2 = seed + PRIME64_2;
- state.v3 = seed + 0;
- state.v4 = seed - PRIME64_1;
- /* do not write into reserved64, might be removed in a future version */
- memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved64));
- return XXH_OK;
-}
-
-XXH_PUBLIC_API XXH_errorcode
-XXH64_update (XXH64_state_t* state, const void* input, size_t len)
-{
- if (input==NULL)
-#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
- return XXH_OK;
-#else
- return XXH_ERROR;
-#endif
-
- { const xxh_u8* p = (const xxh_u8*)input;
- const xxh_u8* const bEnd = p + len;
-
- state->total_len += len;
-
- if (state->memsize + len < 32) { /* fill in tmp buffer */
- XXH_memcpy(((xxh_u8*)state->mem64) + state->memsize, input, len);
- state->memsize += (xxh_u32)len;
- return XXH_OK;
- }
-
- if (state->memsize) { /* tmp buffer is full */
- XXH_memcpy(((xxh_u8*)state->mem64) + state->memsize, input, 32-state->memsize);
- state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0));
- state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1));
- state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2));
- state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3));
- p += 32-state->memsize;
- state->memsize = 0;
- }
-
- if (p+32 <= bEnd) {
- const xxh_u8* const limit = bEnd - 32;
- xxh_u64 v1 = state->v1;
- xxh_u64 v2 = state->v2;
- xxh_u64 v3 = state->v3;
- xxh_u64 v4 = state->v4;
-
- do {
- v1 = XXH64_round(v1, XXH_readLE64(p)); p+=8;
- v2 = XXH64_round(v2, XXH_readLE64(p)); p+=8;
- v3 = XXH64_round(v3, XXH_readLE64(p)); p+=8;
- v4 = XXH64_round(v4, XXH_readLE64(p)); p+=8;
- } while (p<=limit);
-
- state->v1 = v1;
- state->v2 = v2;
- state->v3 = v3;
- state->v4 = v4;
- }
-
- if (p < bEnd) {
- XXH_memcpy(state->mem64, p, (size_t)(bEnd-p));
- state->memsize = (unsigned)(bEnd-p);
- }
- }
-
- return XXH_OK;
-}
-
-
-XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* state)
-{
- xxh_u64 h64;
-
- if (state->total_len >= 32) {
- xxh_u64 const v1 = state->v1;
- xxh_u64 const v2 = state->v2;
- xxh_u64 const v3 = state->v3;
- xxh_u64 const v4 = state->v4;
-
- h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
- h64 = XXH64_mergeRound(h64, v1);
- h64 = XXH64_mergeRound(h64, v2);
- h64 = XXH64_mergeRound(h64, v3);
- h64 = XXH64_mergeRound(h64, v4);
- } else {
- h64 = state->v3 /*seed*/ + PRIME64_5;
- }
-
- h64 += (xxh_u64) state->total_len;
-
- return XXH64_finalize(h64, (const xxh_u8*)state->mem64, (size_t)state->total_len, XXH_aligned);
-}
-
-
-/*====== Canonical representation ======*/
-
-XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash)
-{
- XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t));
- if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash);
- memcpy(dst, &hash, sizeof(*dst));
-}
-
-XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src)
-{
- return XXH_readBE64(src);
-}
-
-
-
-/* *********************************************************************
-* XXH3
-* New generation hash designed for speed on small keys and vectorization
-************************************************************************ */
-
-#include "xxh3.h"
+/*
+ * xxhash.c instantiates functions defined in xxhash.h
+ */
-#endif /* XXH_NO_LONG_LONG */
+#define XXH_STATIC_LINKING_ONLY /* access advanced declarations */
+#define XXH_IMPLEMENTATION /* access definitions */
-#endif /* XXHASH_C_01393879 */
+#include "xxhash.h"
diff --git a/dviware/dvisvgm/libs/xxHash/xxhash.h b/dviware/dvisvgm/libs/xxHash/xxhash.h
index df1d08765d..3677f8287b 100644
--- a/dviware/dvisvgm/libs/xxHash/xxhash.h
+++ b/dviware/dvisvgm/libs/xxHash/xxhash.h
@@ -1,40 +1,42 @@
/*
- xxHash - Extremely Fast Hash algorithm
- Header File
- Copyright (C) 2012-2016, Yann Collet.
-
- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following disclaimer
- in the documentation and/or other materials provided with the
- distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- You can contact the author at :
- - xxHash source repository : https://github.com/Cyan4973/xxHash
-*/
+ * xxHash - Extremely Fast Hash algorithm
+ * Header File
+ * Copyright (C) 2012-present, Yann Collet.
+ *
+ * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at:
+ * - xxHash homepage: https://www.xxhash.com
+ * - xxHash source repository: https://github.com/Cyan4973/xxHash
+ */
-/* Notice extracted from xxHash homepage :
+/* TODO: update */
+/* Notice extracted from xxHash homepage:
-xxHash is an extremely fast Hash algorithm, running at RAM speed limits.
+xxHash is an extremely fast hash algorithm, running at RAM speed limits.
It also successfully passes all tests from the SMHasher suite.
Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz)
@@ -49,17 +51,19 @@ Lookup3 1.2 GB/s 9 Bob Jenkins
SuperFastHash 1.2 GB/s 1 Paul Hsieh
CityHash64 1.05 GB/s 10 Pike & Alakuijala
FNV 0.55 GB/s 5 Fowler, Noll, Vo
-CRC32 0.43 GB/s † 9
+CRC32 0.43 GB/s 9
MD5-32 0.33 GB/s 10 Ronald L. Rivest
SHA1-32 0.28 GB/s 10
-Note †: other CRC32 implementations can be over 40x faster than SMHasher's:
-http://fastcompression.blogspot.com/2019/03/presenting-xxh3.html?showComment=1552696407071#c3490092340461170735
-
Q.Score is a measure of quality of the hash function.
It depends on successfully passing SMHasher test set.
10 is a perfect score.
+Note: SMHasher's CRC32 implementation is not the fastest one.
+Other speed-oriented implementations can be faster,
+especially in combination with PCLMUL instruction:
+https://fastcompression.blogspot.com/2019/03/presenting-xxh3.html?showComment=1552696407071#c3490092340461170735
+
A 64-bit version, named XXH64, is available since r35.
It offers much better speed, but for 64-bit applications only.
Name Speed on 64 bits Speed on 32 bits
@@ -67,41 +71,38 @@ XXH64 13.8 GB/s 1.9 GB/s
XXH32 6.8 GB/s 6.0 GB/s
*/
-#ifndef XXHASH_H_5627135585666179
-#define XXHASH_H_5627135585666179 1
-
#if defined (__cplusplus)
extern "C" {
#endif
-
/* ****************************
-* Definitions
-******************************/
-#include <stddef.h> /* size_t */
-typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
-#define XXH_STATIC_LINKING_ONLY
-
-
-/* ****************************
- * API modifier
+ * INLINE mode
******************************/
-/** XXH_INLINE_ALL (and XXH_PRIVATE_API)
- * This build macro includes xxhash functions in `static` mode
- * in order to inline them, and remove their symbol from the public list.
- * Inlining offers great performance improvement on small keys,
- * and dramatic ones when length is expressed as a compile-time constant.
- * See https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html .
- * Methodology :
+/*!
+ * XXH_INLINE_ALL (and XXH_PRIVATE_API)
+ * Use these build macros to inline xxhash into the target unit.
+ * Inlining improves performance on small inputs, especially when the length is
+ * expressed as a compile-time constant:
+ *
+ * https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html
+ *
+ * It also keeps xxHash symbols private to the unit, so they are not exported.
+ *
+ * Usage:
* #define XXH_INLINE_ALL
* #include "xxhash.h"
- * `xxhash.c` is automatically included.
- * It's not useful to compile and link it as a separate object.
+ *
+ * Do not compile and link xxhash.o as a separate object, as it is not useful.
*/
-#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
-# ifndef XXH_STATIC_LINKING_ONLY
-# define XXH_STATIC_LINKING_ONLY
-# endif
+#if (defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)) \
+ && !defined(XXH_INLINE_ALL_31684351384)
+ /* this section should be traversed only once */
+# define XXH_INLINE_ALL_31684351384
+ /* give access to the advanced API, required to compile implementations */
+# undef XXH_STATIC_LINKING_ONLY /* avoid macro redef */
+# define XXH_STATIC_LINKING_ONLY
+ /* make all functions private */
+# undef XXH_PUBLIC_API
# if defined(__GNUC__)
# define XXH_PUBLIC_API static __inline __attribute__((unused))
# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
@@ -109,10 +110,63 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
# elif defined(_MSC_VER)
# define XXH_PUBLIC_API static __inline
# else
- /* this version may generate warnings for unused static functions */
+ /* note: this version may generate warnings for unused static functions */
# define XXH_PUBLIC_API static
# endif
-#else
+
+ /*
+ * This part deals with the special case where a unit wants to inline xxHash,
+ * but "xxhash.h" has previously been included without XXH_INLINE_ALL, such
+ * as part of some previously included *.h header file.
+ * Without further action, the new include would just be ignored,
+ * and functions would effectively _not_ be inlined (silent failure).
+ * The following macros solve this situation by prefixing all inlined names,
+ * avoiding naming collision with previous inclusions.
+ */
+# ifdef XXH_NAMESPACE
+# error "XXH_INLINE_ALL with XXH_NAMESPACE is not supported"
+ /*
+ * Note: Alternative: #undef all symbols (it's a pretty large list).
+ * Without #error: it compiles, but functions are actually not inlined.
+ */
+# endif
+# define XXH_NAMESPACE XXH_INLINE_
+ /*
+ * Some identifiers (enums, type names) are not symbols, but they must
+ * still be renamed to avoid redeclaration.
+ * Alternative solution: do not redeclare them.
+ * However, this requires some #ifdefs, and is a more dispersed action.
+ * Meanwhile, renaming can be achieved in a single block
+ */
+# define XXH_IPREF(Id) XXH_INLINE_ ## Id
+# define XXH_OK XXH_IPREF(XXH_OK)
+# define XXH_ERROR XXH_IPREF(XXH_ERROR)
+# define XXH_errorcode XXH_IPREF(XXH_errorcode)
+# define XXH32_canonical_t XXH_IPREF(XXH32_canonical_t)
+# define XXH64_canonical_t XXH_IPREF(XXH64_canonical_t)
+# define XXH128_canonical_t XXH_IPREF(XXH128_canonical_t)
+# define XXH32_state_s XXH_IPREF(XXH32_state_s)
+# define XXH32_state_t XXH_IPREF(XXH32_state_t)
+# define XXH64_state_s XXH_IPREF(XXH64_state_s)
+# define XXH64_state_t XXH_IPREF(XXH64_state_t)
+# define XXH3_state_s XXH_IPREF(XXH3_state_s)
+# define XXH3_state_t XXH_IPREF(XXH3_state_t)
+# define XXH128_hash_t XXH_IPREF(XXH128_hash_t)
+ /* Ensure the header is parsed again, even if it was previously included */
+# undef XXHASH_H_5627135585666179
+# undef XXHASH_H_STATIC_13879238742
+#endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */
+
+
+
+/* ****************************************************************
+ * Stable API
+ *****************************************************************/
+#ifndef XXHASH_H_5627135585666179
+#define XXHASH_H_5627135585666179 1
+
+/* specific declaration modes for Windows */
+#if !defined(XXH_INLINE_ALL) && !defined(XXH_PRIVATE_API)
# if defined(WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT))
# ifdef XXH_EXPORT
# define XXH_PUBLIC_API __declspec(dllexport)
@@ -122,18 +176,20 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
# else
# define XXH_PUBLIC_API /* do nothing */
# endif
-#endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */
+#endif
-/*! XXH_NAMESPACE, aka Namespace Emulation :
+/*!
+ * XXH_NAMESPACE, aka Namespace Emulation:
*
- * If you want to include _and expose_ xxHash functions from within your own library,
- * but also want to avoid symbol collisions with other libraries which may also include xxHash,
+ * If you want to include _and expose_ xxHash functions from within your own
+ * library, but also want to avoid symbol collisions with other libraries which
+ * may also include xxHash, you can use XXH_NAMESPACE to automatically prefix
+ * any public symbol from xxhash library with the value of XXH_NAMESPACE
+ * (therefore, avoid empty or numeric values).
*
- * you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
- * with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values).
- *
- * Note that no change is required within the calling program as long as it includes `xxhash.h` :
- * regular symbol name will be automatically translated by this header.
+ * Note that no change is required within the calling program as long as it
+ * includes `xxhash.h`: Regular symbol names will be automatically translated
+ * by this header.
*/
#ifdef XXH_NAMESPACE
# define XXH_CAT(A,B) A##B
@@ -165,11 +221,18 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
***************************************/
#define XXH_VERSION_MAJOR 0
#define XXH_VERSION_MINOR 7
-#define XXH_VERSION_RELEASE 2
+#define XXH_VERSION_RELEASE 3
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
XXH_PUBLIC_API unsigned XXH_versionNumber (void);
+/* ****************************
+* Definitions
+******************************/
+#include <stddef.h> /* size_t */
+typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
+
+
/*-**********************************************************************
* 32-bit hash
************************************************************************/
@@ -186,39 +249,43 @@ XXH_PUBLIC_API unsigned XXH_versionNumber (void);
# if ULONG_MAX == 0xFFFFFFFFUL
typedef unsigned long XXH32_hash_t;
# else
-# error "unsupported platform : need a 32-bit type"
+# error "unsupported platform: need a 32-bit type"
# endif
# endif
#endif
-/*! XXH32() :
- Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input".
- The memory between input & input+length must be valid (allocated and read-accessible).
- "seed" can be used to alter the result predictably.
- Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s */
+/*!
+ * XXH32():
+ * Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input".
+ * The memory between input & input+length must be valid (allocated and read-accessible).
+ * "seed" can be used to alter the result predictably.
+ * Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark): 5.4 GB/s
+ */
XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, XXH32_hash_t seed);
-/*====== Streaming ======*/
+/******* Streaming *******/
/*
* Streaming functions generate the xxHash value from an incrememtal input.
* This method is slower than single-call functions, due to state management.
* For small inputs, prefer `XXH32()` and `XXH64()`, which are better optimized.
*
- * XXH state must first be allocated, using XXH*_createState() .
+ * An XXH state must first be allocated using `XXH*_createState()`.
*
- * Start a new hash by initializing state with a seed, using XXH*_reset().
+ * Start a new hash by initializing the state with a seed using `XXH*_reset()`.
*
- * Then, feed the hash state by calling XXH*_update() as many times as necessary.
- * The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
+ * Then, feed the hash state by calling `XXH*_update()` as many times as necessary.
*
- * Finally, a hash value can be produced anytime, by using XXH*_digest().
+ * The function returns an error code, with 0 meaning OK, and any other value
+ * meaning there is an error.
+ *
+ * Finally, a hash value can be produced anytime, by using `XXH*_digest()`.
* This function returns the nn-bits hash as an int or long long.
*
- * It's still possible to continue inserting input into the hash state after a digest,
- * and generate some new hash values later on, by invoking again XXH*_digest().
+ * It's still possible to continue inserting input into the hash state after a
+ * digest, and generate new hash values later on by invoking `XXH*_digest()`.
*
- * When done, release the state, using XXH*_freeState().
+ * When done, release the state using `XXH*_freeState()`.
*/
typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */
@@ -230,21 +297,25 @@ XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, XXH32_hash_t
XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length);
XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
-/*====== Canonical representation ======*/
+/******* Canonical representation *******/
-/* Default return values from XXH functions are basic unsigned 32 and 64 bits.
+/*
+ * The default return values from XXH functions are unsigned 32 and 64 bit
+ * integers.
* This the simplest and fastest format for further post-processing.
- * However, this leaves open the question of what is the order of bytes,
- * since little and big endian conventions will write the same number differently.
*
- * The canonical representation settles this issue,
- * by mandating big-endian convention,
- * aka, the same convention as human-readable numbers (large digits first).
- * When writing hash values to storage, sending them over a network, or printing them,
- * it's highly recommended to use the canonical representation,
- * to ensure portability across a wider range of systems, present and future.
+ * However, this leaves open the question of what is the order on the byte level,
+ * since little and big endian conventions will store the same number differently.
+ *
+ * The canonical representation settles this issue by mandating big-endian
+ * convention, the same convention as human-readable numbers (large digits first).
*
- * The following functions allow transformation of hash values into and from canonical format.
+ * When writing hash values to storage, sending them over a network, or printing
+ * them, it's highly recommended to use the canonical representation to ensure
+ * portability across a wider range of systems, present and future.
+ *
+ * The following functions allow transformation of hash values to and from
+ * canonical format.
*/
typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
@@ -266,14 +337,17 @@ XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src
typedef unsigned long long XXH64_hash_t;
#endif
-/*! XXH64() :
- Calculate the 64-bit hash of sequence of length "len" stored at memory address "input".
- "seed" can be used to alter the result predictably.
- This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark).
-*/
+/*!
+ * XXH64():
+ * Returns the 64-bit hash of sequence of length @length stored at memory
+ * address @input.
+ * @seed can be used to alter the result predictably.
+ * This function usually runs faster on 64-bit systems, but slower on 32-bit
+ * systems (see benchmark).
+ */
XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, XXH64_hash_t seed);
-/*====== Streaming ======*/
+/******* Streaming *******/
typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */
XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void);
XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr);
@@ -283,7 +357,7 @@ XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, XXH64_hash_t
XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
-/*====== Canonical representation ======*/
+/******* Canonical representation *******/
typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash);
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src);
@@ -291,20 +365,25 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
#endif /* XXH_NO_LONG_LONG */
+#endif /* XXHASH_H_5627135585666179 */
+#define XXH_STATIC_LINKING_ONLY
-#ifdef XXH_STATIC_LINKING_ONLY
-
-/* ================================================================================================
- This section contains declarations which are not guaranteed to remain stable.
- They may change in future versions, becoming incompatible with a different version of the library.
- These declarations should only be used with static linking.
- Never use them in association with dynamic linking !
-=================================================================================================== */
+#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXHASH_H_STATIC_13879238742)
+#define XXHASH_H_STATIC_13879238742
+/* ****************************************************************************
+ * This section contains declarations which are not guaranteed to remain stable.
+ * They may change in future versions, becoming incompatible with a different
+ * version of the library.
+ * These declarations should only be used with static linking.
+ * Never use them in association with dynamic linking!
+ ***************************************************************************** */
-/* These definitions are only present to allow
- * static allocation of XXH state, on stack or in a struct for example.
- * Never **ever** use members directly. */
+/*
+ * These definitions are only present to allow static allocation of an XXH
+ * state, for example, on the stack or in a struct.
+ * Never **ever** access members directly.
+ */
struct XXH32_state_s {
XXH32_hash_t total_len_32;
@@ -318,7 +397,9 @@ struct XXH32_state_s {
XXH32_hash_t reserved; /* never read nor write, might be removed in a future version */
}; /* typedef'd to XXH32_state_t */
-#ifndef XXH_NO_LONG_LONG /* remove 64-bit support */
+
+#ifndef XXH_NO_LONG_LONG /* defined when there is no 64-bit support */
+
struct XXH64_state_s {
XXH64_hash_t total_len;
XXH64_hash_t v1;
@@ -330,81 +411,58 @@ struct XXH64_state_s {
XXH32_hash_t reserved32; /* required for padding anyway */
XXH64_hash_t reserved64; /* never read nor write, might be removed in a future version */
}; /* typedef'd to XXH64_state_t */
-#endif /* XXH_NO_LONG_LONG */
/*-**********************************************************************
* XXH3
* New experimental hash
************************************************************************/
-#ifndef XXH_NO_LONG_LONG
-
-/* ============================================
- * XXH3 is a new hash algorithm,
- * featuring improved speed performance for both small and large inputs.
- * See full speed analysis at : http://fastcompression.blogspot.com/2019/03/presenting-xxh3.html
- * In general, expect XXH3 to run about ~2x faster on large inputs,
- * and >3x faster on small ones, though exact differences depend on platform.
+/* ************************************************************************
+ * XXH3 is a new hash algorithm featuring:
+ * - Improved speed for both small and large inputs
+ * - True 64-bit and 128-bit outputs
+ * - SIMD acceleration
+ * - Improved 32-bit viability
+ *
+ * Speed analysis methodology is explained here:
*
- * The algorithm is portable, will generate the same hash on all platforms.
- * It benefits greatly from vectorization units, but does not require it.
+ * https://fastcompression.blogspot.com/2019/03/presenting-xxh3.html
+ *
+ * In general, expect XXH3 to run about ~2x faster on large inputs and >3x
+ * faster on small ones compared to XXH64, though exact differences depend on
+ * the platform.
+ *
+ * The algorithm is portable: Like XXH32 and XXH64, it generates the same hash
+ * on all platforms.
+ *
+ * It benefits greatly from SIMD and 64-bit arithmetic, but does not require it.
+ *
+ * Almost all 32-bit and 64-bit targets that can run XXH32 smoothly can run
+ * XXH3 at usable speeds, even if XXH64 runs slowly. Further details are
+ * explained in the implementation.
+ *
+ * Optimized implementations are provided for AVX2, SSE2, NEON, POWER8, ZVector,
+ * and scalar targets. This can be controlled with the XXH_VECTOR macro.
*
* XXH3 offers 2 variants, _64bits and _128bits.
- * When only 64 bits are needed, prefer calling the _64bits variant :
- * it reduces the amount of mixing, resulting in faster speed on small inputs.
+ * When only 64 bits are needed, prefer calling the _64bits variant, as it
+ * reduces the amount of mixing, resulting in faster speed on small inputs.
+ *
* It's also generally simpler to manipulate a scalar return type than a struct.
*
- * The XXH3 algorithm is still considered experimental.
- * Produced results can still change between versions.
- * Results produced by v0.7.x are not comparable with results from v0.7.y .
- * It's nonetheless possible to use XXH3 for ephemeral data (local sessions),
- * but avoid storing values in long-term storage for later reads.
+ * The 128-bit version adds additional strength, but it is slightly slower.
*
- * The API supports one-shot hashing, streaming mode, and custom secrets.
+ * The XXH3 algorithm is still in development.
+ * The results it produces may still change in future versions.
+ *
+ * Results produced by v0.7.x are not comparable with results from v0.7.y.
+ * However, the API is completely stable, and it can safely be used for
+ * ephemeral data (local sessions).
+ *
+ * Avoid storing values in long-term storage until the algorithm is finalized.
*
- * There are still a number of opened questions that community can influence during the experimental period.
- * I'm trying to list a few of them below, though don't consider this list as complete.
- *
- * - 128-bits output type : currently defined as a structure of two 64-bits fields.
- * That's because 128-bit values do not exist in C standard.
- * Note that it means that, at byte level, result is not identical depending on endianess.
- * However, at field level, they are identical on all platforms.
- * The canonical representation solves the issue of identical byte-level representation across platforms,
- * which is necessary for serialization.
- * Q1 : Would there be a better representation for a 128-bit hash result ?
- * Q2 : Are the names of the inner 64-bit fields important ? Should they be changed ?
- *
- * - Prototype XXH128() : XXH128() uses the same arguments as XXH64(), for consistency.
- * It means it maps to XXH3_128bits_withSeed().
- * This variant is slightly slower than XXH3_128bits(),
- * because the seed is now part of the algorithm, and can't be simplified.
- * Is that a good idea ?
- *
- * - Seed type for XXH128() : currently, it's a single 64-bit value, like the 64-bit variant.
- * It could be argued that it's more logical to offer a 128-bit seed input parameter for a 128-bit hash.
- * But 128-bit seed is more difficult to use, since it requires to pass a structure instead of a scalar value.
- * Such a variant could either replace current one, or become an additional one.
- * Farmhash, for example, offers both variants (the 128-bits seed variant is called `doubleSeed`).
- * Follow up question : if both 64-bit and 128-bit seeds are allowed, which variant should be called XXH128 ?
- *
- * - Result for len==0 : Currently, the result of hashing a zero-length input is always `0`.
- * It seems okay as a return value when using "default" secret and seed.
- * But is it still fine to return `0` when secret or seed are non-default ?
- * Are there use cases which could depend on generating a different hash result for zero-length input when the secret is different ?
- *
- * - Consistency (1) : Streaming XXH128 uses an XXH3 state, which is the same state as XXH3_64bits().
- * It means a 128bit streaming loop must invoke the following symbols :
- * XXH3_createState(), XXH3_128bits_reset(), XXH3_128bits_update() (loop), XXH3_128bits_digest(), XXH3_freeState().
- * Is that consistent enough ?
- *
- * - Consistency (2) : The canonical representation of `XXH3_64bits` is provided by existing functions
- * XXH64_canonicalFromHash(), and reverse operation XXH64_hashFromCanonical().
- * As a mirror, canonical functions for XXH128_hash_t results generated by `XXH3_128bits`
- * are XXH128_canonicalFromHash() and XXH128_hashFromCanonical().
- * Which means, `XXH3` doesn't appear in the names, because canonical functions operate on a type,
- * independently of which algorithm was used to generate that type.
- * Is that consistent enough ?
+ * The API supports one-shot hashing, streaming mode, and custom secrets.
*/
#ifdef XXH_NAMESPACE
@@ -423,28 +481,32 @@ struct XXH64_state_s {
# define XXH3_64bits_digest XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_digest)
#endif
-/* XXH3_64bits() :
+/* XXH3_64bits():
* default 64-bit variant, using default secret and default seed of 0.
* It's the fastest variant. */
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* data, size_t len);
-/* XXH3_64bits_withSecret() :
+/*
+ * XXH3_64bits_withSecret():
* It's possible to provide any blob of bytes as a "secret" to generate the hash.
- * This makes it more difficult for an external actor to prepare an intentional collision.
+ * This makes it more difficult for an external actor to prepare an intentional
+ * collision.
* The secret *must* be large enough (>= XXH3_SECRET_SIZE_MIN).
* It should consist of random bytes.
- * Avoid repeating same character, or sequences of bytes,
- * and especially avoid swathes of \0.
+ * Avoid trivial sequences, such as repeating sequences and especially '\0',
+ * as this can cancel out itself.
* Failure to respect these conditions will result in a poor quality hash.
*/
#define XXH3_SECRET_SIZE_MIN 136
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize);
-/* XXH3_64bits_withSeed() :
- * This variant generates on the fly a custom secret,
- * based on the default secret, altered using the `seed` value.
+/*
+ * XXH3_64bits_withSeed():
+ * This variant generates a custom secret on the fly based on the default
+ * secret, altered using the `seed` value.
* While this operation is decently fast, note that it's not completely free.
- * note : seed==0 produces same results as XXH3_64bits() */
+ * Note: seed==0 produces the same results as XXH3_64bits().
+ */
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, XXH64_hash_t seed);
@@ -461,14 +523,24 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, X
# define XXH_ALIGN(n) /* disabled */
#endif
+/* Old GCC versions only accept the attribute after the type in structures. */
+#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) /* C11+ */ \
+ && defined(__GNUC__)
+# define XXH_ALIGN_MEMBER(align, type) type XXH_ALIGN(align)
+#else
+# define XXH_ALIGN_MEMBER(align, type) XXH_ALIGN(align) type
+#endif
+
typedef struct XXH3_state_s XXH3_state_t;
#define XXH3_SECRET_DEFAULT_SIZE 192 /* minimum XXH3_SECRET_SIZE_MIN */
#define XXH3_INTERNALBUFFER_SIZE 256
struct XXH3_state_s {
- XXH_ALIGN(64) XXH64_hash_t acc[8];
- XXH_ALIGN(64) unsigned char customSecret[XXH3_SECRET_DEFAULT_SIZE]; /* used to store a custom secret generated from the seed. Makes state larger. Design might change */
- XXH_ALIGN(64) unsigned char buffer[XXH3_INTERNALBUFFER_SIZE];
+ XXH_ALIGN_MEMBER(64, XXH64_hash_t acc[8]);
+ /* used to store a custom secret generated from the seed. Makes state larger.
+ * Design might change */
+ XXH_ALIGN_MEMBER(64, unsigned char customSecret[XXH3_SECRET_DEFAULT_SIZE]);
+ XXH_ALIGN_MEMBER(64, unsigned char buffer[XXH3_INTERNALBUFFER_SIZE]);
XXH32_hash_t bufferedSize;
XXH32_hash_t nbStripesPerBlock;
XXH32_hash_t nbStripesSoFar;
@@ -478,30 +550,40 @@ struct XXH3_state_s {
XXH64_hash_t totalLen;
XXH64_hash_t seed;
XXH64_hash_t reserved64;
- const unsigned char* secret; /* note : there is some padding after, due to alignment on 64 bytes */
+ /* note: there is some padding after due to alignment on 64 bytes */
+ const unsigned char* secret;
}; /* typedef'd to XXH3_state_t */
-/* Streaming requires state maintenance.
- * This operation costs memory and cpu.
- * As a consequence, streaming is slower than one-shot hashing.
- * For better performance, prefer using one-shot functions whenever possible. */
+#undef XXH_ALIGN_MEMBER
+/*
+ * Streaming requires state maintenance.
+ * This operation costs memory and CPU.
+ * As a consequence, streaming is slower than one-shot hashing.
+ * For better performance, prefer one-shot functions whenever possible.
+ */
XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void);
XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t* statePtr);
XXH_PUBLIC_API void XXH3_copyState(XXH3_state_t* dst_state, const XXH3_state_t* src_state);
-/* XXH3_64bits_reset() :
- * initialize with default parameters.
- * result will be equivalent to `XXH3_64bits()`. */
+/*
+ * XXH3_64bits_reset():
+ * Initialize with the default parameters.
+ * The result will be equivalent to `XXH3_64bits()`.
+ */
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH3_state_t* statePtr);
-/* XXH3_64bits_reset_withSeed() :
- * generate a custom secret from `seed`, and store it into state.
- * digest will be equivalent to `XXH3_64bits_withSeed()`. */
+/*
+ * XXH3_64bits_reset_withSeed():
+ * Generate a custom secret from `seed`, and store it into `statePtr`.
+ * digest will be equivalent to `XXH3_64bits_withSeed()`.
+ */
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed);
-/* XXH3_64bits_reset_withSecret() :
- * `secret` is referenced, and must outlive the hash streaming session.
- * secretSize must be >= XXH3_SECRET_SIZE_MIN.
+/*
+ * XXH3_64bits_reset_withSecret():
+ * `secret` is referenced, and must outlive the hash streaming session, so
+ * be careful when using stack arrays.
+ * `secretSize` must be >= `XXH3_SECRET_SIZE_MIN`.
*/
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize);
@@ -547,20 +629,27 @@ XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update (XXH3_state_t* statePtr, const
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* statePtr);
-/* Note : for better performance, following functions can be inlined,
- * using XXH_INLINE_ALL */
+/* Note: For better performance, these functions can be inlined using XXH_INLINE_ALL */
-/* return : 1 is equal, 0 if different */
+/*!
+ * XXH128_isEqual():
+ * Return: 1 if `h1` and `h2` are equal, 0 if they are not.
+ */
XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2);
-/* This comparator is compatible with stdlib's qsort().
- * return : >0 if *h128_1 > *h128_2
- * <0 if *h128_1 < *h128_2
- * =0 if *h128_1 == *h128_2 */
+/*!
+ * XXH128_cmp():
+ *
+ * This comparator is compatible with stdlib's `qsort()`/`bsearch()`.
+ *
+ * return: >0 if *h128_1 > *h128_2
+ * <0 if *h128_1 < *h128_2
+ * =0 if *h128_1 == *h128_2
+ */
XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2);
-/*====== Canonical representation ======*/
+/******* Canonical representation *******/
typedef struct { unsigned char digest[16]; } XXH128_canonical_t;
XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash);
XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(const XXH128_canonical_t* src);
@@ -568,21 +657,1285 @@ XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(const XXH128_canonical_t*
#endif /* XXH_NO_LONG_LONG */
+#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
+# define XXH_IMPLEMENTATION
+#endif
+
+#endif /* defined(XXH_STATIC_LINKING_ONLY) && !defined(XXHASH_H_STATIC_13879238742) */
+
+
+/* ======================================================================== */
+/* ======================================================================== */
+/* ======================================================================== */
+
/*-**********************************************************************
-* XXH_INLINE_ALL
-************************************************************************/
-#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
-# include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */
+ * xxHash implementation
+ *-**********************************************************************
+ * xxHash's implementation used to be found in xxhash.c.
+ *
+ * However, code inlining requires the implementation to be visible to the
+ * compiler, usually within the header.
+ *
+ * As a workaround, xxhash.c used to be included within xxhash.h. This caused
+ * some issues with some build systems, especially ones which treat .c files
+ * as source files.
+ *
+ * Therefore, the implementation is now directly integrated within xxhash.h.
+ * Another small advantage is that xxhash.c is no longer needed in /include.
+ ************************************************************************/
+
+#if ( defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) \
+ || defined(XXH_IMPLEMENTATION) ) && !defined(XXH_IMPLEM_13a8737387)
+# define XXH_IMPLEM_13a8737387
+
+/* *************************************
+* Tuning parameters
+***************************************/
+/*!
+ * XXH_FORCE_MEMORY_ACCESS:
+ * By default, access to unaligned memory is controlled by `memcpy()`, which is
+ * safe and portable.
+ *
+ * Unfortunately, on some target/compiler combinations, the generated assembly
+ * is sub-optimal.
+ *
+ * The below switch allow to select a different access method for improved
+ * performance.
+ * Method 0 (default):
+ * Use `memcpy()`. Safe and portable.
+ * Method 1:
+ * `__attribute__((packed))` statement. It depends on compiler extensions
+ * and is therefore not portable.
+ * This method is safe if your compiler supports it, and *generally* as
+ * fast or faster than `memcpy`.
+ * Method 2:
+ * Direct access via cast. This method doesn't depend on the compiler but
+ * violates the C standard.
+ * It can generate buggy code on targets which do not support unaligned
+ * memory accesses.
+ * But in some circumstances, it's the only known way to get the most
+ * performance (ie GCC + ARMv6)
+ * Method 3:
+ * Byteshift. This can generate the best code on old compilers which don't
+ * inline small `memcpy()` calls, and it might also be faster on big-endian
+ * systems which lack a native byteswap instruction.
+ * See https://stackoverflow.com/a/32095106/646947 for details.
+ * Prefer these methods in priority order (0 > 1 > 2 > 3)
+ */
+#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
+# if !defined(__clang__) && defined(__GNUC__) && defined(__ARM_FEATURE_UNALIGNED) && defined(__ARM_ARCH) && (__ARM_ARCH == 6)
+# define XXH_FORCE_MEMORY_ACCESS 2
+# elif !defined(__clang__) && ((defined(__INTEL_COMPILER) && !defined(_WIN32)) || \
+ (defined(__GNUC__) && (defined(__ARM_ARCH) && __ARM_ARCH >= 7)))
+# define XXH_FORCE_MEMORY_ACCESS 1
+# endif
#endif
+/*!
+ *XXH_ACCEPT_NULL_INPUT_POINTER:
+ * If the input pointer is NULL, xxHash's default behavior is to dereference it,
+ * triggering a segfault.
+ * When this macro is enabled, xxHash actively checks the input for a null pointer.
+ * If it is, the result for null input pointers is the same as a zero-length input.
+ */
+#ifndef XXH_ACCEPT_NULL_INPUT_POINTER /* can be defined externally */
+# define XXH_ACCEPT_NULL_INPUT_POINTER 0
+#endif
+/*!
+ * XXH_FORCE_ALIGN_CHECK:
+ * This is a minor performance trick, only useful with lots of very small keys.
+ * It means: check for aligned/unaligned input.
+ * The check costs one initial branch per hash;
+ * Set it to 0 when the input is guaranteed to be aligned or when alignment
+ * doesn't matter for performance.
+ *
+ * This option does not affect XXH3.
+ */
+#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */
+# if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
+# define XXH_FORCE_ALIGN_CHECK 0
+# else
+# define XXH_FORCE_ALIGN_CHECK 1
+# endif
+#endif
+
+/*!
+ * XXH_NO_INLINE_HINTS:
+ *
+ * By default, xxHash tries to force the compiler to inline almost all internal
+ * functions.
+ *
+ * This can usually improve performance due to reduced jumping and improved
+ * constant folding, but significantly increases the size of the binary which
+ * might not be favorable.
+ *
+ * Additionally, sometimes the forced inlining can be detrimental to performance,
+ * depending on the architecture.
+ *
+ * XXH_NO_INLINE_HINTS marks all internal functions as static, giving the
+ * compiler full control on whether to inline or not.
+ *
+ * When not optimizing (-O0), optimizing for size (-Os, -Oz), or using
+ * -fno-inline with GCC or Clang, this will automatically be defined.
+ */
+#ifndef XXH_NO_INLINE_HINTS
+# if defined(__OPTIMIZE_SIZE__) /* -Os, -Oz */ \
+ || defined(__NO_INLINE__) /* -O0, -fno-inline */
+# define XXH_NO_INLINE_HINTS 1
+# else
+# define XXH_NO_INLINE_HINTS 0
+# endif
+#endif
-#endif /* XXH_STATIC_LINKING_ONLY */
+/*!
+ * XXH_REROLL:
+ * Whether to reroll XXH32_finalize, and XXH64_finalize,
+ * instead of using an unrolled jump table/if statement loop.
+ *
+ * This is automatically defined on -Os/-Oz on GCC and Clang.
+ */
+#ifndef XXH_REROLL
+# if defined(__OPTIMIZE_SIZE__)
+# define XXH_REROLL 1
+# else
+# define XXH_REROLL 0
+# endif
+#endif
-#if defined (__cplusplus)
+/* *************************************
+* Includes & Memory related functions
+***************************************/
+/*!
+ * Modify the local functions below should you wish to use some other memory
+ * routines for malloc() and free()
+ */
+#include <stdlib.h>
+static void* XXH_malloc(size_t s) { return malloc(s); }
+static void XXH_free (void* p) { free(p); }
+/*! and for memcpy() */
+#include <string.h>
+static void* XXH_memcpy(void* dest, const void* src, size_t size)
+{
+ return memcpy(dest,src,size);
}
+
+#include <limits.h> /* ULLONG_MAX */
+
+
+/* *************************************
+* Compiler Specific Options
+***************************************/
+#ifdef _MSC_VER /* Visual Studio warning fix */
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
#endif
-#endif /* XXHASH_H_5627135585666179 */
+#if XXH_NO_INLINE_HINTS /* disable inlining hints */
+# define XXH_FORCE_INLINE static
+# define XXH_NO_INLINE static
+#elif defined(_MSC_VER) /* Visual Studio */
+# define XXH_FORCE_INLINE static __forceinline
+# define XXH_NO_INLINE static __declspec(noinline)
+#else
+# if defined (__cplusplus) \
+ || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# ifdef __GNUC__
+# define XXH_FORCE_INLINE static inline __attribute__((always_inline))
+# define XXH_NO_INLINE static __attribute__((noinline))
+# else
+# define XXH_FORCE_INLINE static inline
+# define XXH_NO_INLINE static
+# endif
+# else
+# define XXH_FORCE_INLINE static
+# define XXH_NO_INLINE static
+# endif /* __STDC_VERSION__ */
+#endif
+
+
+
+/* *************************************
+* Debug
+***************************************/
+/*
+ * DEBUGLEVEL is expected to be defined externally, typically via the compiler's
+ * command line options. The value must be a number.
+ */
+#ifndef DEBUGLEVEL
+# define DEBUGLEVEL 0
+#endif
+
+#if (DEBUGLEVEL>=1)
+# include <assert.h> /* note: can still be disabled with NDEBUG */
+# define XXH_ASSERT(c) assert(c)
+#else
+# define XXH_ASSERT(c) ((void)0)
+#endif
+
+/* note: use after variable declarations */
+#define XXH_STATIC_ASSERT(c) { enum { XXH_sa = 1/(int)(!!(c)) }; }
+
+
+/* *************************************
+* Basic Types
+***************************************/
+#if !defined (__VMS) \
+ && (defined (__cplusplus) \
+ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# include <stdint.h>
+ typedef uint8_t xxh_u8;
+#else
+ typedef unsigned char xxh_u8;
+#endif
+typedef XXH32_hash_t xxh_u32;
+
+
+/* *** Memory access *** */
+
+#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==3))
+/*
+ * Manual byteshift. Best for old compilers which don't inline memcpy.
+ * We actually directly use XXH_readLE32 and XXH_readBE32.
+ */
+#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
+
+/*
+ * Force direct memory access. Only works on CPU which support unaligned memory
+ * access in hardware.
+ */
+static xxh_u32 XXH_read32(const void* memPtr) { return *(const xxh_u32*) memPtr; }
+
+#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
+
+/*
+ * __pack instructions are safer but compiler specific, hence potentially
+ * problematic for some compilers.
+ *
+ * Currently only defined for GCC and ICC.
+ */
+typedef union { xxh_u32 u32; } __attribute__((packed)) unalign;
+static xxh_u32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
+
+#else
+
+/*
+ * Portable and safe solution. Generally efficient.
+ * see: https://stackoverflow.com/a/32095106/646947
+ */
+static xxh_u32 XXH_read32(const void* memPtr)
+{
+ xxh_u32 val;
+ memcpy(&val, memPtr, sizeof(val));
+ return val;
+}
+
+#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */
+
+
+/* *** Endianess *** */
+typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
+
+/*!
+ * XXH_CPU_LITTLE_ENDIAN:
+ * Defined to 1 if the target is little endian, or 0 if it is big endian.
+ * It can be defined externally, for example on the compiler command line.
+ *
+ * If it is not defined, a runtime check (which is usually constant folded)
+ * is used instead.
+ */
+#ifndef XXH_CPU_LITTLE_ENDIAN
+/*
+ * Try to detect endianness automatically, to avoid the nonstandard behavior
+ * in `XXH_isLittleEndian()`
+ */
+# if defined(_WIN32) /* Windows is always little endian */ \
+ || defined(__LITTLE_ENDIAN__) \
+ || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+# define XXH_CPU_LITTLE_ENDIAN 1
+# elif defined(__BIG_ENDIAN__) \
+ || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+# define XXH_CPU_LITTLE_ENDIAN 0
+# else
+static int XXH_isLittleEndian(void)
+{
+ /*
+ * Nonstandard, but well-defined behavior in practice.
+ * Don't use static: it is detrimental to performance.
+ */
+ const union { xxh_u32 u; xxh_u8 c[4]; } one = { 1 };
+ return one.c[0];
+}
+# define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian()
+# endif
+#endif
+
+
+
+
+/* ****************************************
+* Compiler-specific Functions and Macros
+******************************************/
+#define XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+#if !defined(NO_CLANG_BUILTIN) && __has_builtin(__builtin_rotateleft32) \
+ && __has_builtin(__builtin_rotateleft64)
+# define XXH_rotl32 __builtin_rotateleft32
+# define XXH_rotl64 __builtin_rotateleft64
+/* Note: although _rotl exists for minGW (GCC under windows), performance seems poor */
+#elif defined(_MSC_VER)
+# define XXH_rotl32(x,r) _rotl(x,r)
+# define XXH_rotl64(x,r) _rotl64(x,r)
+#else
+# define XXH_rotl32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
+# define XXH_rotl64(x,r) (((x) << (r)) | ((x) >> (64 - (r))))
+#endif
+
+#if defined(_MSC_VER) /* Visual Studio */
+# define XXH_swap32 _byteswap_ulong
+#elif XXH_GCC_VERSION >= 403
+# define XXH_swap32 __builtin_bswap32
+#else
+static xxh_u32 XXH_swap32 (xxh_u32 x)
+{
+ return ((x << 24) & 0xff000000 ) |
+ ((x << 8) & 0x00ff0000 ) |
+ ((x >> 8) & 0x0000ff00 ) |
+ ((x >> 24) & 0x000000ff );
+}
+#endif
+
+
+/* ***************************
+* Memory reads
+*****************************/
+typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
+
+/*
+ * XXH_FORCE_MEMORY_ACCESS==3 is an endian-independent byteshift load.
+ *
+ * This is ideal for older compilers which don't inline memcpy.
+ */
+#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==3))
+
+XXH_FORCE_INLINE xxh_u32 XXH_readLE32(const void* memPtr)
+{
+ const xxh_u8* bytePtr = (const xxh_u8 *)memPtr;
+ return bytePtr[0]
+ | ((xxh_u32)bytePtr[1] << 8)
+ | ((xxh_u32)bytePtr[2] << 16)
+ | ((xxh_u32)bytePtr[3] << 24);
+}
+
+XXH_FORCE_INLINE xxh_u32 XXH_readBE32(const void* memPtr)
+{
+ const xxh_u8* bytePtr = (const xxh_u8 *)memPtr;
+ return bytePtr[3]
+ | ((xxh_u32)bytePtr[2] << 8)
+ | ((xxh_u32)bytePtr[1] << 16)
+ | ((xxh_u32)bytePtr[0] << 24);
+}
+
+#else
+XXH_FORCE_INLINE xxh_u32 XXH_readLE32(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
+}
+
+static xxh_u32 XXH_readBE32(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr);
+}
+#endif
+
+XXH_FORCE_INLINE xxh_u32
+XXH_readLE32_align(const void* ptr, XXH_alignment align)
+{
+ if (align==XXH_unaligned) {
+ return XXH_readLE32(ptr);
+ } else {
+ return XXH_CPU_LITTLE_ENDIAN ? *(const xxh_u32*)ptr : XXH_swap32(*(const xxh_u32*)ptr);
+ }
+}
+
+
+/* *************************************
+* Misc
+***************************************/
+XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
+
+
+/* *******************************************************************
+* 32-bit hash functions
+*********************************************************************/
+static const xxh_u32 PRIME32_1 = 0x9E3779B1U; /* 0b10011110001101110111100110110001 */
+static const xxh_u32 PRIME32_2 = 0x85EBCA77U; /* 0b10000101111010111100101001110111 */
+static const xxh_u32 PRIME32_3 = 0xC2B2AE3DU; /* 0b11000010101100101010111000111101 */
+static const xxh_u32 PRIME32_4 = 0x27D4EB2FU; /* 0b00100111110101001110101100101111 */
+static const xxh_u32 PRIME32_5 = 0x165667B1U; /* 0b00010110010101100110011110110001 */
+
+static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input)
+{
+ acc += input * PRIME32_2;
+ acc = XXH_rotl32(acc, 13);
+ acc *= PRIME32_1;
+#if defined(__GNUC__) && defined(__SSE4_1__) && !defined(XXH_ENABLE_AUTOVECTORIZE)
+ /*
+ * UGLY HACK:
+ * This inline assembly hack forces acc into a normal register. This is the
+ * only thing that prevents GCC and Clang from autovectorizing the XXH32
+ * loop (pragmas and attributes don't work for some resason) without globally
+ * disabling SSE4.1.
+ *
+ * The reason we want to avoid vectorization is because despite working on
+ * 4 integers at a time, there are multiple factors slowing XXH32 down on
+ * SSE4:
+ * - There's a ridiculous amount of lag from pmulld (10 cycles of latency on
+ * newer chips!) making it slightly slower to multiply four integers at
+ * once compared to four integers independently. Even when pmulld was
+ * fastest, Sandy/Ivy Bridge, it is still not worth it to go into SSE
+ * just to multiply unless doing a long operation.
+ *
+ * - Four instructions are required to rotate,
+ * movqda tmp, v // not required with VEX encoding
+ * pslld tmp, 13 // tmp <<= 13
+ * psrld v, 19 // x >>= 19
+ * por v, tmp // x |= tmp
+ * compared to one for scalar:
+ * roll v, 13 // reliably fast across the board
+ * shldl v, v, 13 // Sandy Bridge and later prefer this for some reason
+ *
+ * - Instruction level parallelism is actually more beneficial here because
+ * the SIMD actually serializes this operation: While v1 is rotating, v2
+ * can load data, while v3 can multiply. SSE forces them to operate
+ * together.
+ *
+ * How this hack works:
+ * __asm__("" // Declare an assembly block but don't declare any instructions
+ * : // However, as an Input/Output Operand,
+ * "+r" // constrain a read/write operand (+) as a general purpose register (r).
+ * (acc) // and set acc as the operand
+ * );
+ *
+ * Because of the 'r', the compiler has promised that seed will be in a
+ * general purpose register and the '+' says that it will be 'read/write',
+ * so it has to assume it has changed. It is like volatile without all the
+ * loads and stores.
+ *
+ * Since the argument has to be in a normal register (not an SSE register),
+ * each time XXH32_round is called, it is impossible to vectorize.
+ */
+ __asm__("" : "+r" (acc));
+#endif
+ return acc;
+}
+
+/* mix all bits */
+static xxh_u32 XXH32_avalanche(xxh_u32 h32)
+{
+ h32 ^= h32 >> 15;
+ h32 *= PRIME32_2;
+ h32 ^= h32 >> 13;
+ h32 *= PRIME32_3;
+ h32 ^= h32 >> 16;
+ return(h32);
+}
+
+#define XXH_get32bits(p) XXH_readLE32_align(p, align)
+
+static xxh_u32
+XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align)
+{
+#define PROCESS1 \
+ h32 += (*ptr++) * PRIME32_5; \
+ h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
+
+#define PROCESS4 \
+ h32 += XXH_get32bits(ptr) * PRIME32_3; \
+ ptr+=4; \
+ h32 = XXH_rotl32(h32, 17) * PRIME32_4 ;
+
+ /* Compact rerolled version */
+ if (XXH_REROLL) {
+ len &= 15;
+ while (len >= 4) {
+ PROCESS4;
+ len -= 4;
+ }
+ while (len > 0) {
+ PROCESS1;
+ --len;
+ }
+ return XXH32_avalanche(h32);
+ } else {
+ switch(len&15) /* or switch(bEnd - p) */ {
+ case 12: PROCESS4;
+ /* fallthrough */
+ case 8: PROCESS4;
+ /* fallthrough */
+ case 4: PROCESS4;
+ return XXH32_avalanche(h32);
+
+ case 13: PROCESS4;
+ /* fallthrough */
+ case 9: PROCESS4;
+ /* fallthrough */
+ case 5: PROCESS4;
+ PROCESS1;
+ return XXH32_avalanche(h32);
+
+ case 14: PROCESS4;
+ /* fallthrough */
+ case 10: PROCESS4;
+ /* fallthrough */
+ case 6: PROCESS4;
+ PROCESS1;
+ PROCESS1;
+ return XXH32_avalanche(h32);
+
+ case 15: PROCESS4;
+ /* fallthrough */
+ case 11: PROCESS4;
+ /* fallthrough */
+ case 7: PROCESS4;
+ /* fallthrough */
+ case 3: PROCESS1;
+ /* fallthrough */
+ case 2: PROCESS1;
+ /* fallthrough */
+ case 1: PROCESS1;
+ /* fallthrough */
+ case 0: return XXH32_avalanche(h32);
+ }
+ XXH_ASSERT(0);
+ return h32; /* reaching this point is deemed impossible */
+ }
+}
+
+XXH_FORCE_INLINE xxh_u32
+XXH32_endian_align(const xxh_u8* input, size_t len, xxh_u32 seed, XXH_alignment align)
+{
+ const xxh_u8* bEnd = input + len;
+ xxh_u32 h32;
+
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
+ if (input==NULL) {
+ len=0;
+ bEnd=input=(const xxh_u8*)(size_t)16;
+ }
+#endif
+
+ if (len>=16) {
+ const xxh_u8* const limit = bEnd - 15;
+ xxh_u32 v1 = seed + PRIME32_1 + PRIME32_2;
+ xxh_u32 v2 = seed + PRIME32_2;
+ xxh_u32 v3 = seed + 0;
+ xxh_u32 v4 = seed - PRIME32_1;
+
+ do {
+ v1 = XXH32_round(v1, XXH_get32bits(input)); input += 4;
+ v2 = XXH32_round(v2, XXH_get32bits(input)); input += 4;
+ v3 = XXH32_round(v3, XXH_get32bits(input)); input += 4;
+ v4 = XXH32_round(v4, XXH_get32bits(input)); input += 4;
+ } while (input < limit);
+
+ h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7)
+ + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
+ } else {
+ h32 = seed + PRIME32_5;
+ }
+
+ h32 += (xxh_u32)len;
+
+ return XXH32_finalize(h32, input, len&15, align);
+}
+
+
+XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t len, XXH32_hash_t seed)
+{
+#if 0
+ /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
+ XXH32_state_t state;
+ XXH32_reset(&state, seed);
+ XXH32_update(&state, (const xxh_u8*)input, len);
+ return XXH32_digest(&state);
+
+#else
+
+ if (XXH_FORCE_ALIGN_CHECK) {
+ if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */
+ return XXH32_endian_align((const xxh_u8*)input, len, seed, XXH_aligned);
+ } }
+
+ return XXH32_endian_align((const xxh_u8*)input, len, seed, XXH_unaligned);
+#endif
+}
+
+
+
+/******* Hash streaming *******/
+
+XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void)
+{
+ return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
+}
+XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr)
+{
+ XXH_free(statePtr);
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dstState, const XXH32_state_t* srcState)
+{
+ memcpy(dstState, srcState, sizeof(*dstState));
+}
+
+XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, XXH32_hash_t seed)
+{
+ XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
+ memset(&state, 0, sizeof(state));
+ state.v1 = seed + PRIME32_1 + PRIME32_2;
+ state.v2 = seed + PRIME32_2;
+ state.v3 = seed + 0;
+ state.v4 = seed - PRIME32_1;
+ /* do not write into reserved, planned to be removed in a future version */
+ memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved));
+ return XXH_OK;
+}
+
+
+XXH_PUBLIC_API XXH_errorcode
+XXH32_update(XXH32_state_t* state, const void* input, size_t len)
+{
+ if (input==NULL)
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
+ return XXH_OK;
+#else
+ return XXH_ERROR;
+#endif
+
+ { const xxh_u8* p = (const xxh_u8*)input;
+ const xxh_u8* const bEnd = p + len;
+
+ state->total_len_32 += (XXH32_hash_t)len;
+ state->large_len |= (XXH32_hash_t)((len>=16) | (state->total_len_32>=16));
+
+ if (state->memsize + len < 16) { /* fill in tmp buffer */
+ XXH_memcpy((xxh_u8*)(state->mem32) + state->memsize, input, len);
+ state->memsize += (XXH32_hash_t)len;
+ return XXH_OK;
+ }
+
+ if (state->memsize) { /* some data left from previous update */
+ XXH_memcpy((xxh_u8*)(state->mem32) + state->memsize, input, 16-state->memsize);
+ { const xxh_u32* p32 = state->mem32;
+ state->v1 = XXH32_round(state->v1, XXH_readLE32(p32)); p32++;
+ state->v2 = XXH32_round(state->v2, XXH_readLE32(p32)); p32++;
+ state->v3 = XXH32_round(state->v3, XXH_readLE32(p32)); p32++;
+ state->v4 = XXH32_round(state->v4, XXH_readLE32(p32));
+ }
+ p += 16-state->memsize;
+ state->memsize = 0;
+ }
+
+ if (p <= bEnd-16) {
+ const xxh_u8* const limit = bEnd - 16;
+ xxh_u32 v1 = state->v1;
+ xxh_u32 v2 = state->v2;
+ xxh_u32 v3 = state->v3;
+ xxh_u32 v4 = state->v4;
+
+ do {
+ v1 = XXH32_round(v1, XXH_readLE32(p)); p+=4;
+ v2 = XXH32_round(v2, XXH_readLE32(p)); p+=4;
+ v3 = XXH32_round(v3, XXH_readLE32(p)); p+=4;
+ v4 = XXH32_round(v4, XXH_readLE32(p)); p+=4;
+ } while (p<=limit);
+
+ state->v1 = v1;
+ state->v2 = v2;
+ state->v3 = v3;
+ state->v4 = v4;
+ }
+
+ if (p < bEnd) {
+ XXH_memcpy(state->mem32, p, (size_t)(bEnd-p));
+ state->memsize = (unsigned)(bEnd-p);
+ }
+ }
+
+ return XXH_OK;
+}
+
+
+XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* state)
+{
+ xxh_u32 h32;
+
+ if (state->large_len) {
+ h32 = XXH_rotl32(state->v1, 1)
+ + XXH_rotl32(state->v2, 7)
+ + XXH_rotl32(state->v3, 12)
+ + XXH_rotl32(state->v4, 18);
+ } else {
+ h32 = state->v3 /* == seed */ + PRIME32_5;
+ }
+
+ h32 += state->total_len_32;
+
+ return XXH32_finalize(h32, (const xxh_u8*)state->mem32, state->memsize, XXH_aligned);
+}
+
+
+/******* Canonical representation *******/
+
+/*
+ * The default return values from XXH functions are unsigned 32 and 64 bit
+ * integers.
+ *
+ * The canonical representation uses big endian convention, the same convention
+ * as human-readable numbers (large digits first).
+ *
+ * This way, hash values can be written into a file or buffer, remaining
+ * comparable across different systems.
+ *
+ * The following functions allow transformation of hash values to and from their
+ * canonical format.
+ */
+XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash)
+{
+ XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t));
+ if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash);
+ memcpy(dst, &hash, sizeof(*dst));
+}
+
+XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src)
+{
+ return XXH_readBE32(src);
+}
+
+
+#ifndef XXH_NO_LONG_LONG
+
+/* *******************************************************************
+* 64-bit hash functions
+*********************************************************************/
+
+/******* Memory access *******/
+
+typedef XXH64_hash_t xxh_u64;
+
+
+/*!
+ * XXH_REROLL_XXH64:
+ * Whether to reroll the XXH64_finalize() loop.
+ *
+ * Just like XXH32, we can unroll the XXH64_finalize() loop. This can be a
+ * performance gain on 64-bit hosts, as only one jump is required.
+ *
+ * However, on 32-bit hosts, because arithmetic needs to be done with two 32-bit
+ * registers, and 64-bit arithmetic needs to be simulated, it isn't beneficial
+ * to unroll. The code becomes ridiculously large (the largest function in the
+ * binary on i386!), and rerolling it saves anywhere from 3kB to 20kB. It is
+ * also slightly faster because it fits into cache better and is more likely
+ * to be inlined by the compiler.
+ *
+ * If XXH_REROLL is defined, this is ignored and the loop is always rerolled.
+ */
+#ifndef XXH_REROLL_XXH64
+# if (defined(__ILP32__) || defined(_ILP32)) /* ILP32 is often defined on 32-bit GCC family */ \
+ || !(defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) /* x86-64 */ \
+ || defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) /* aarch64 */ \
+ || defined(__PPC64__) || defined(__PPC64LE__) || defined(__ppc64__) || defined(__powerpc64__) /* ppc64 */ \
+ || defined(__mips64__) || defined(__mips64)) /* mips64 */ \
+ || (!defined(SIZE_MAX) || SIZE_MAX < ULLONG_MAX) /* check limits */
+# define XXH_REROLL_XXH64 1
+# else
+# define XXH_REROLL_XXH64 0
+# endif
+#endif /* !defined(XXH_REROLL_XXH64) */
+
+#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==3))
+/*
+ * Manual byteshift. Best for old compilers which don't inline memcpy.
+ * We actually directly use XXH_readLE64 and XXH_readBE64.
+ */
+#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
+
+/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */
+static xxh_u64 XXH_read64(const void* memPtr) { return *(const xxh_u64*) memPtr; }
+
+#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
+
+/*
+ * __pack instructions are safer, but compiler specific, hence potentially
+ * problematic for some compilers.
+ *
+ * Currently only defined for GCC and ICC.
+ */
+typedef union { xxh_u32 u32; xxh_u64 u64; } __attribute__((packed)) unalign64;
+static xxh_u64 XXH_read64(const void* ptr) { return ((const unalign64*)ptr)->u64; }
+
+#else
+
+/*
+ * Portable and safe solution. Generally efficient.
+ * see: https://stackoverflow.com/a/32095106/646947
+ */
+static xxh_u64 XXH_read64(const void* memPtr)
+{
+ xxh_u64 val;
+ memcpy(&val, memPtr, sizeof(val));
+ return val;
+}
+
+#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */
+
+#if defined(_MSC_VER) /* Visual Studio */
+# define XXH_swap64 _byteswap_uint64
+#elif XXH_GCC_VERSION >= 403
+# define XXH_swap64 __builtin_bswap64
+#else
+static xxh_u64 XXH_swap64 (xxh_u64 x)
+{
+ return ((x << 56) & 0xff00000000000000ULL) |
+ ((x << 40) & 0x00ff000000000000ULL) |
+ ((x << 24) & 0x0000ff0000000000ULL) |
+ ((x << 8) & 0x000000ff00000000ULL) |
+ ((x >> 8) & 0x00000000ff000000ULL) |
+ ((x >> 24) & 0x0000000000ff0000ULL) |
+ ((x >> 40) & 0x000000000000ff00ULL) |
+ ((x >> 56) & 0x00000000000000ffULL);
+}
+#endif
+
+
+/* XXH_FORCE_MEMORY_ACCESS==3 is an endian-independent byteshift load. */
+#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==3))
+
+XXH_FORCE_INLINE xxh_u64 XXH_readLE64(const void* memPtr)
+{
+ const xxh_u8* bytePtr = (const xxh_u8 *)memPtr;
+ return bytePtr[0]
+ | ((xxh_u64)bytePtr[1] << 8)
+ | ((xxh_u64)bytePtr[2] << 16)
+ | ((xxh_u64)bytePtr[3] << 24)
+ | ((xxh_u64)bytePtr[4] << 32)
+ | ((xxh_u64)bytePtr[5] << 40)
+ | ((xxh_u64)bytePtr[6] << 48)
+ | ((xxh_u64)bytePtr[7] << 56);
+}
+
+XXH_FORCE_INLINE xxh_u64 XXH_readBE64(const void* memPtr)
+{
+ const xxh_u8* bytePtr = (const xxh_u8 *)memPtr;
+ return bytePtr[7]
+ | ((xxh_u64)bytePtr[6] << 8)
+ | ((xxh_u64)bytePtr[5] << 16)
+ | ((xxh_u64)bytePtr[4] << 24)
+ | ((xxh_u64)bytePtr[3] << 32)
+ | ((xxh_u64)bytePtr[2] << 40)
+ | ((xxh_u64)bytePtr[1] << 48)
+ | ((xxh_u64)bytePtr[0] << 56);
+}
+
+#else
+XXH_FORCE_INLINE xxh_u64 XXH_readLE64(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
+}
+
+static xxh_u64 XXH_readBE64(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr);
+}
+#endif
+
+XXH_FORCE_INLINE xxh_u64
+XXH_readLE64_align(const void* ptr, XXH_alignment align)
+{
+ if (align==XXH_unaligned)
+ return XXH_readLE64(ptr);
+ else
+ return XXH_CPU_LITTLE_ENDIAN ? *(const xxh_u64*)ptr : XXH_swap64(*(const xxh_u64*)ptr);
+}
+
+
+/******* xxh64 *******/
+
+static const xxh_u64 PRIME64_1 = 0x9E3779B185EBCA87ULL; /* 0b1001111000110111011110011011000110000101111010111100101010000111 */
+static const xxh_u64 PRIME64_2 = 0xC2B2AE3D27D4EB4FULL; /* 0b1100001010110010101011100011110100100111110101001110101101001111 */
+static const xxh_u64 PRIME64_3 = 0x165667B19E3779F9ULL; /* 0b0001011001010110011001111011000110011110001101110111100111111001 */
+static const xxh_u64 PRIME64_4 = 0x85EBCA77C2B2AE63ULL; /* 0b1000010111101011110010100111011111000010101100101010111001100011 */
+static const xxh_u64 PRIME64_5 = 0x27D4EB2F165667C5ULL; /* 0b0010011111010100111010110010111100010110010101100110011111000101 */
+
+static xxh_u64 XXH64_round(xxh_u64 acc, xxh_u64 input)
+{
+ acc += input * PRIME64_2;
+ acc = XXH_rotl64(acc, 31);
+ acc *= PRIME64_1;
+ return acc;
+}
+
+static xxh_u64 XXH64_mergeRound(xxh_u64 acc, xxh_u64 val)
+{
+ val = XXH64_round(0, val);
+ acc ^= val;
+ acc = acc * PRIME64_1 + PRIME64_4;
+ return acc;
+}
+
+static xxh_u64 XXH64_avalanche(xxh_u64 h64)
+{
+ h64 ^= h64 >> 33;
+ h64 *= PRIME64_2;
+ h64 ^= h64 >> 29;
+ h64 *= PRIME64_3;
+ h64 ^= h64 >> 32;
+ return h64;
+}
+
+
+#define XXH_get64bits(p) XXH_readLE64_align(p, align)
+
+static xxh_u64
+XXH64_finalize(xxh_u64 h64, const xxh_u8* ptr, size_t len, XXH_alignment align)
+{
+#define PROCESS1_64 \
+ h64 ^= (*ptr++) * PRIME64_5; \
+ h64 = XXH_rotl64(h64, 11) * PRIME64_1;
+
+#define PROCESS4_64 \
+ h64 ^= (xxh_u64)(XXH_get32bits(ptr)) * PRIME64_1; \
+ ptr+=4; \
+ h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
+
+#define PROCESS8_64 { \
+ xxh_u64 const k1 = XXH64_round(0, XXH_get64bits(ptr)); \
+ ptr+=8; \
+ h64 ^= k1; \
+ h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; \
+}
+
+ /* Rerolled version for 32-bit targets is faster and much smaller. */
+ if (XXH_REROLL || XXH_REROLL_XXH64) {
+ len &= 31;
+ while (len >= 8) {
+ PROCESS8_64;
+ len -= 8;
+ }
+ if (len >= 4) {
+ PROCESS4_64;
+ len -= 4;
+ }
+ while (len > 0) {
+ PROCESS1_64;
+ --len;
+ }
+ return XXH64_avalanche(h64);
+ } else {
+ switch(len & 31) {
+ case 24: PROCESS8_64;
+ /* fallthrough */
+ case 16: PROCESS8_64;
+ /* fallthrough */
+ case 8: PROCESS8_64;
+ return XXH64_avalanche(h64);
+
+ case 28: PROCESS8_64;
+ /* fallthrough */
+ case 20: PROCESS8_64;
+ /* fallthrough */
+ case 12: PROCESS8_64;
+ /* fallthrough */
+ case 4: PROCESS4_64;
+ return XXH64_avalanche(h64);
+
+ case 25: PROCESS8_64;
+ /* fallthrough */
+ case 17: PROCESS8_64;
+ /* fallthrough */
+ case 9: PROCESS8_64;
+ PROCESS1_64;
+ return XXH64_avalanche(h64);
+
+ case 29: PROCESS8_64;
+ /* fallthrough */
+ case 21: PROCESS8_64;
+ /* fallthrough */
+ case 13: PROCESS8_64;
+ /* fallthrough */
+ case 5: PROCESS4_64;
+ PROCESS1_64;
+ return XXH64_avalanche(h64);
+
+ case 26: PROCESS8_64;
+ /* fallthrough */
+ case 18: PROCESS8_64;
+ /* fallthrough */
+ case 10: PROCESS8_64;
+ PROCESS1_64;
+ PROCESS1_64;
+ return XXH64_avalanche(h64);
+
+ case 30: PROCESS8_64;
+ /* fallthrough */
+ case 22: PROCESS8_64;
+ /* fallthrough */
+ case 14: PROCESS8_64;
+ /* fallthrough */
+ case 6: PROCESS4_64;
+ PROCESS1_64;
+ PROCESS1_64;
+ return XXH64_avalanche(h64);
+
+ case 27: PROCESS8_64;
+ /* fallthrough */
+ case 19: PROCESS8_64;
+ /* fallthrough */
+ case 11: PROCESS8_64;
+ PROCESS1_64;
+ PROCESS1_64;
+ PROCESS1_64;
+ return XXH64_avalanche(h64);
+
+ case 31: PROCESS8_64;
+ /* fallthrough */
+ case 23: PROCESS8_64;
+ /* fallthrough */
+ case 15: PROCESS8_64;
+ /* fallthrough */
+ case 7: PROCESS4_64;
+ /* fallthrough */
+ case 3: PROCESS1_64;
+ /* fallthrough */
+ case 2: PROCESS1_64;
+ /* fallthrough */
+ case 1: PROCESS1_64;
+ /* fallthrough */
+ case 0: return XXH64_avalanche(h64);
+ }
+ }
+ /* impossible to reach */
+ XXH_ASSERT(0);
+ return 0; /* unreachable, but some compilers complain without it */
+}
+
+XXH_FORCE_INLINE xxh_u64
+XXH64_endian_align(const xxh_u8* input, size_t len, xxh_u64 seed, XXH_alignment align)
+{
+ const xxh_u8* bEnd = input + len;
+ xxh_u64 h64;
+
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
+ if (input==NULL) {
+ len=0;
+ bEnd=input=(const xxh_u8*)(size_t)32;
+ }
+#endif
+
+ if (len>=32) {
+ const xxh_u8* const limit = bEnd - 32;
+ xxh_u64 v1 = seed + PRIME64_1 + PRIME64_2;
+ xxh_u64 v2 = seed + PRIME64_2;
+ xxh_u64 v3 = seed + 0;
+ xxh_u64 v4 = seed - PRIME64_1;
+
+ do {
+ v1 = XXH64_round(v1, XXH_get64bits(input)); input+=8;
+ v2 = XXH64_round(v2, XXH_get64bits(input)); input+=8;
+ v3 = XXH64_round(v3, XXH_get64bits(input)); input+=8;
+ v4 = XXH64_round(v4, XXH_get64bits(input)); input+=8;
+ } while (input<=limit);
+
+ h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
+ h64 = XXH64_mergeRound(h64, v1);
+ h64 = XXH64_mergeRound(h64, v2);
+ h64 = XXH64_mergeRound(h64, v3);
+ h64 = XXH64_mergeRound(h64, v4);
+
+ } else {
+ h64 = seed + PRIME64_5;
+ }
+
+ h64 += (xxh_u64) len;
+
+ return XXH64_finalize(h64, input, len, align);
+}
+
+
+XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, XXH64_hash_t seed)
+{
+#if 0
+ /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
+ XXH64_state_t state;
+ XXH64_reset(&state, seed);
+ XXH64_update(&state, (const xxh_u8*)input, len);
+ return XXH64_digest(&state);
+
+#else
+
+ if (XXH_FORCE_ALIGN_CHECK) {
+ if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */
+ return XXH64_endian_align((const xxh_u8*)input, len, seed, XXH_aligned);
+ } }
+
+ return XXH64_endian_align((const xxh_u8*)input, len, seed, XXH_unaligned);
+
+#endif
+}
+
+/******* Hash Streaming *******/
+
+XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void)
+{
+ return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t));
+}
+XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr)
+{
+ XXH_free(statePtr);
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dstState, const XXH64_state_t* srcState)
+{
+ memcpy(dstState, srcState, sizeof(*dstState));
+}
+
+XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, XXH64_hash_t seed)
+{
+ XXH64_state_t state; /* use a local state to memcpy() in order to avoid strict-aliasing warnings */
+ memset(&state, 0, sizeof(state));
+ state.v1 = seed + PRIME64_1 + PRIME64_2;
+ state.v2 = seed + PRIME64_2;
+ state.v3 = seed + 0;
+ state.v4 = seed - PRIME64_1;
+ /* do not write into reserved64, might be removed in a future version */
+ memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved64));
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH_errorcode
+XXH64_update (XXH64_state_t* state, const void* input, size_t len)
+{
+ if (input==NULL)
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
+ return XXH_OK;
+#else
+ return XXH_ERROR;
+#endif
+
+ { const xxh_u8* p = (const xxh_u8*)input;
+ const xxh_u8* const bEnd = p + len;
+
+ state->total_len += len;
+
+ if (state->memsize + len < 32) { /* fill in tmp buffer */
+ XXH_memcpy(((xxh_u8*)state->mem64) + state->memsize, input, len);
+ state->memsize += (xxh_u32)len;
+ return XXH_OK;
+ }
+
+ if (state->memsize) { /* tmp buffer is full */
+ XXH_memcpy(((xxh_u8*)state->mem64) + state->memsize, input, 32-state->memsize);
+ state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0));
+ state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1));
+ state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2));
+ state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3));
+ p += 32-state->memsize;
+ state->memsize = 0;
+ }
+
+ if (p+32 <= bEnd) {
+ const xxh_u8* const limit = bEnd - 32;
+ xxh_u64 v1 = state->v1;
+ xxh_u64 v2 = state->v2;
+ xxh_u64 v3 = state->v3;
+ xxh_u64 v4 = state->v4;
+
+ do {
+ v1 = XXH64_round(v1, XXH_readLE64(p)); p+=8;
+ v2 = XXH64_round(v2, XXH_readLE64(p)); p+=8;
+ v3 = XXH64_round(v3, XXH_readLE64(p)); p+=8;
+ v4 = XXH64_round(v4, XXH_readLE64(p)); p+=8;
+ } while (p<=limit);
+
+ state->v1 = v1;
+ state->v2 = v2;
+ state->v3 = v3;
+ state->v4 = v4;
+ }
+
+ if (p < bEnd) {
+ XXH_memcpy(state->mem64, p, (size_t)(bEnd-p));
+ state->memsize = (unsigned)(bEnd-p);
+ }
+ }
+
+ return XXH_OK;
+}
+
+
+XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* state)
+{
+ xxh_u64 h64;
+
+ if (state->total_len >= 32) {
+ xxh_u64 const v1 = state->v1;
+ xxh_u64 const v2 = state->v2;
+ xxh_u64 const v3 = state->v3;
+ xxh_u64 const v4 = state->v4;
+
+ h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
+ h64 = XXH64_mergeRound(h64, v1);
+ h64 = XXH64_mergeRound(h64, v2);
+ h64 = XXH64_mergeRound(h64, v3);
+ h64 = XXH64_mergeRound(h64, v4);
+ } else {
+ h64 = state->v3 /*seed*/ + PRIME64_5;
+ }
+
+ h64 += (xxh_u64) state->total_len;
+
+ return XXH64_finalize(h64, (const xxh_u8*)state->mem64, (size_t)state->total_len, XXH_aligned);
+}
+
+
+/******* Canonical representation *******/
+
+XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash)
+{
+ XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t));
+ if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash);
+ memcpy(dst, &hash, sizeof(*dst));
+}
+
+XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src)
+{
+ return XXH_readBE64(src);
+}
+
+
+
+/* *********************************************************************
+* XXH3
+* New generation hash designed for speed on small keys and vectorization
+************************************************************************ */
+
+#include "xxh3.h"
+
+
+#endif /* XXH_NO_LONG_LONG */
+
+
+#endif /* XXH_IMPLEMENTATION */
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/dviware/dvisvgm/src/AGLTable.hpp b/dviware/dvisvgm/src/AGLTable.hpp
index d973d1186b..c1d460273a 100644
--- a/dviware/dvisvgm/src/AGLTable.hpp
+++ b/dviware/dvisvgm/src/AGLTable.hpp
@@ -2,7 +2,7 @@
** AGLTable.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/BasicDVIReader.cpp b/dviware/dvisvgm/src/BasicDVIReader.cpp
index 272c88c3ad..bb30154e7b 100644
--- a/dviware/dvisvgm/src/BasicDVIReader.cpp
+++ b/dviware/dvisvgm/src/BasicDVIReader.cpp
@@ -2,7 +2,7 @@
** BasicDVIReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/BasicDVIReader.hpp b/dviware/dvisvgm/src/BasicDVIReader.hpp
index 14a1fb9858..7ce1f989e2 100644
--- a/dviware/dvisvgm/src/BasicDVIReader.hpp
+++ b/dviware/dvisvgm/src/BasicDVIReader.hpp
@@ -2,7 +2,7 @@
** BasicDVIReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Bezier.cpp b/dviware/dvisvgm/src/Bezier.cpp
index d2077bcfeb..87a0070621 100644
--- a/dviware/dvisvgm/src/Bezier.cpp
+++ b/dviware/dvisvgm/src/Bezier.cpp
@@ -2,7 +2,7 @@
** Bezier.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -168,7 +168,7 @@ static inline double dot_prod (const DPair &p1, const DPair &p2) {
static bool between (const DPair &p1, const DPair &p2, const DPair &p3, double delta) {
double sqr_dist = dot_prod(p2-p1, p2-p1);
double factor = sqr_dist == 0.0 ? 1.0 : sqr_dist;
- double area2 = fabs(signed_area(p1, p2, p3));
+ double area2 = abs(signed_area(p1, p2, p3));
return area2*area2/factor < delta // does p3 lay almost on the line through p1 and p2...
&& min(p1.x(), p2.x()) <= p3.x() // ...and on or inside the rectangle spanned by p1 and p2?
&& max(p1.x(), p2.x()) >= p3.x()
@@ -179,7 +179,7 @@ static bool between (const DPair &p1, const DPair &p2, const DPair &p3, double d
static inline bool near (const DPair &p1, const DPair &p2, double delta) {
DPair diff = p2-p1;
- return fabs(diff.x()) < delta && fabs(diff.y()) < delta;
+ return abs(diff.x()) < delta && abs(diff.y()) < delta;
}
diff --git a/dviware/dvisvgm/src/Bezier.hpp b/dviware/dvisvgm/src/Bezier.hpp
index 525ef23435..322dd4e72d 100644
--- a/dviware/dvisvgm/src/Bezier.hpp
+++ b/dviware/dvisvgm/src/Bezier.hpp
@@ -2,7 +2,7 @@
** Bezier.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/BgColorSpecialHandler.cpp b/dviware/dvisvgm/src/BgColorSpecialHandler.cpp
index 10c05fca05..3b315b50a3 100644
--- a/dviware/dvisvgm/src/BgColorSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/BgColorSpecialHandler.cpp
@@ -2,7 +2,7 @@
** BgColorSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/BgColorSpecialHandler.hpp b/dviware/dvisvgm/src/BgColorSpecialHandler.hpp
index e1061efc8c..9334a5c541 100644
--- a/dviware/dvisvgm/src/BgColorSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/BgColorSpecialHandler.hpp
@@ -2,7 +2,7 @@
** BgColorSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Bitmap.cpp b/dviware/dvisvgm/src/Bitmap.cpp
index 3fa554eed4..64ebd6195e 100644
--- a/dviware/dvisvgm/src/Bitmap.cpp
+++ b/dviware/dvisvgm/src/Bitmap.cpp
@@ -2,7 +2,7 @@
** Bitmap.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Bitmap.hpp b/dviware/dvisvgm/src/Bitmap.hpp
index 026edae9a2..0d04aa2a69 100644
--- a/dviware/dvisvgm/src/Bitmap.hpp
+++ b/dviware/dvisvgm/src/Bitmap.hpp
@@ -2,7 +2,7 @@
** Bitmap.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/BoundingBox.cpp b/dviware/dvisvgm/src/BoundingBox.cpp
index a076b52363..2dbcc2ebcd 100644
--- a/dviware/dvisvgm/src/BoundingBox.cpp
+++ b/dviware/dvisvgm/src/BoundingBox.cpp
@@ -2,7 +2,7 @@
** BoundingBox.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -207,7 +207,7 @@ void BoundingBox::operator += (const BoundingBox &bbox) {
static inline bool almost_equal (double v1, double v2) {
- return fabs(v1-v2) < 1e-10;
+ return abs(v1-v2) < 1e-10;
}
diff --git a/dviware/dvisvgm/src/BoundingBox.hpp b/dviware/dvisvgm/src/BoundingBox.hpp
index 8848f60f28..c52312a24a 100644
--- a/dviware/dvisvgm/src/BoundingBox.hpp
+++ b/dviware/dvisvgm/src/BoundingBox.hpp
@@ -2,7 +2,7 @@
** BoundingBox.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CLCommandLine.cpp b/dviware/dvisvgm/src/CLCommandLine.cpp
index 2b0c1b5359..1f6bb4475e 100644
--- a/dviware/dvisvgm/src/CLCommandLine.cpp
+++ b/dviware/dvisvgm/src/CLCommandLine.cpp
@@ -2,7 +2,7 @@
** CLCommandLine.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CLCommandLine.hpp b/dviware/dvisvgm/src/CLCommandLine.hpp
index a80d9b87d7..257ff4160f 100644
--- a/dviware/dvisvgm/src/CLCommandLine.hpp
+++ b/dviware/dvisvgm/src/CLCommandLine.hpp
@@ -2,7 +2,7 @@
** CLCommandLine.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CLOption.hpp b/dviware/dvisvgm/src/CLOption.hpp
index 54dff67025..d9da7ae008 100644
--- a/dviware/dvisvgm/src/CLOption.hpp
+++ b/dviware/dvisvgm/src/CLOption.hpp
@@ -2,7 +2,7 @@
** CLOption.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CMap.cpp b/dviware/dvisvgm/src/CMap.cpp
index fa92901eef..747fb5ad50 100644
--- a/dviware/dvisvgm/src/CMap.cpp
+++ b/dviware/dvisvgm/src/CMap.cpp
@@ -2,7 +2,7 @@
** CMap.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CMap.hpp b/dviware/dvisvgm/src/CMap.hpp
index 0f0259e853..63761ff2ff 100644
--- a/dviware/dvisvgm/src/CMap.hpp
+++ b/dviware/dvisvgm/src/CMap.hpp
@@ -2,7 +2,7 @@
** CMap.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CMapManager.cpp b/dviware/dvisvgm/src/CMapManager.cpp
index 779c6ee3a8..52b323ebc6 100644
--- a/dviware/dvisvgm/src/CMapManager.cpp
+++ b/dviware/dvisvgm/src/CMapManager.cpp
@@ -2,7 +2,7 @@
** CMapManager.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CMapManager.hpp b/dviware/dvisvgm/src/CMapManager.hpp
index 0635f2ec3e..aeb9156e84 100644
--- a/dviware/dvisvgm/src/CMapManager.hpp
+++ b/dviware/dvisvgm/src/CMapManager.hpp
@@ -2,7 +2,7 @@
** CMapManager.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CMapReader.cpp b/dviware/dvisvgm/src/CMapReader.cpp
index 6661afbbb1..51ba52b95d 100644
--- a/dviware/dvisvgm/src/CMapReader.cpp
+++ b/dviware/dvisvgm/src/CMapReader.cpp
@@ -2,7 +2,7 @@
** CMapReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CMapReader.hpp b/dviware/dvisvgm/src/CMapReader.hpp
index 3e5b841e0c..04ce5740c0 100644
--- a/dviware/dvisvgm/src/CMapReader.hpp
+++ b/dviware/dvisvgm/src/CMapReader.hpp
@@ -2,7 +2,7 @@
** CMapReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Calculator.cpp b/dviware/dvisvgm/src/Calculator.cpp
index 3091c9cf35..c5dc00df4d 100644
--- a/dviware/dvisvgm/src/Calculator.cpp
+++ b/dviware/dvisvgm/src/Calculator.cpp
@@ -2,7 +2,7 @@
** Calculator.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Calculator.hpp b/dviware/dvisvgm/src/Calculator.hpp
index cc3b2feb6b..92ec4e40b1 100644
--- a/dviware/dvisvgm/src/Calculator.hpp
+++ b/dviware/dvisvgm/src/Calculator.hpp
@@ -2,7 +2,7 @@
** Calculator.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CharMapID.cpp b/dviware/dvisvgm/src/CharMapID.cpp
index c04ae2ceb9..9c56afc73a 100644
--- a/dviware/dvisvgm/src/CharMapID.cpp
+++ b/dviware/dvisvgm/src/CharMapID.cpp
@@ -2,7 +2,7 @@
** CharMapID.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CharMapID.hpp b/dviware/dvisvgm/src/CharMapID.hpp
index cdc39ca94d..ed044a9cf3 100644
--- a/dviware/dvisvgm/src/CharMapID.hpp
+++ b/dviware/dvisvgm/src/CharMapID.hpp
@@ -2,7 +2,7 @@
** CharMapID.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Character.hpp b/dviware/dvisvgm/src/Character.hpp
index e232401fb8..667a583100 100644
--- a/dviware/dvisvgm/src/Character.hpp
+++ b/dviware/dvisvgm/src/Character.hpp
@@ -2,7 +2,7 @@
** Character.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Color.cpp b/dviware/dvisvgm/src/Color.cpp
index de7e9074ab..bf9a05d7a3 100644
--- a/dviware/dvisvgm/src/Color.cpp
+++ b/dviware/dvisvgm/src/Color.cpp
@@ -2,7 +2,7 @@
** Color.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Color.hpp b/dviware/dvisvgm/src/Color.hpp
index c58a97f0bb..6f6f812207 100644
--- a/dviware/dvisvgm/src/Color.hpp
+++ b/dviware/dvisvgm/src/Color.hpp
@@ -2,7 +2,7 @@
** Color.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ColorSpecialHandler.cpp b/dviware/dvisvgm/src/ColorSpecialHandler.cpp
index 4bfd494003..2cacf82992 100644
--- a/dviware/dvisvgm/src/ColorSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/ColorSpecialHandler.cpp
@@ -2,7 +2,7 @@
** ColorSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ColorSpecialHandler.hpp b/dviware/dvisvgm/src/ColorSpecialHandler.hpp
index 176253407e..eeab300f47 100644
--- a/dviware/dvisvgm/src/ColorSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/ColorSpecialHandler.hpp
@@ -2,7 +2,7 @@
** ColorSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/CommandLine.hpp b/dviware/dvisvgm/src/CommandLine.hpp
index b1f2636040..7ea6ddd76e 100644
--- a/dviware/dvisvgm/src/CommandLine.hpp
+++ b/dviware/dvisvgm/src/CommandLine.hpp
@@ -2,7 +2,7 @@
// It is part of the dvisvgm package and published under the terms
// of the GNU General Public License version 3, or (at your option) any later version.
// See file COPYING for further details.
-// Copyright (C) 2016-2019 Martin Gieseking <martin.gieseking@uos.de>
+// Copyright (C) 2016-2020 Martin Gieseking <martin.gieseking@uos.de>
#ifndef COMMANDLINE_HPP
#define COMMANDLINE_HPP
@@ -20,7 +20,7 @@ class CommandLine : public CL::CommandLine {
CommandLine () : CL::CommandLine(
"This program converts DVI files, as created by TeX/LaTeX, as well as\nEPS and PDF files to the XML-based scalable vector graphics format SVG.",
"[options] dvifile\n--eps [options] epsfile\n--pdf [options] pdffile",
- "Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>"
+ "Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>"
) {}
CommandLine (int argc, char **argv) : CommandLine() {
@@ -29,6 +29,7 @@ class CommandLine : public CL::CommandLine {
// option variables
TypedOption<std::string, Option::ArgMode::REQUIRED> bboxOpt {"bbox", 'b', "size", "min", "set size of bounding box"};
+ TypedOption<std::string, Option::ArgMode::REQUIRED> bitmapFormatOpt {"bitmap-format", 'B', "fmt", "jpeg", "set format used to embed PS/EPS bitmaps"};
TypedOption<std::string, Option::ArgMode::OPTIONAL> cacheOpt {"cache", 'C', "dir", "set/print path of cache directory"};
Option clipjoinOpt {"clipjoin", 'j', "compute intersection of clipping paths"};
Option colorOpt {"color", '\0', "colorize messages"};
@@ -36,7 +37,7 @@ class CommandLine : public CL::CommandLine {
Option commentsOpt {"comments", '\0', "add comments with additional information"};
Option epsOpt {"eps", 'E', "convert EPS file to SVG"};
Option exactBboxOpt {"exact-bbox", 'e', "compute exact glyph bounding boxes"};
- TypedOption<std::string, Option::ArgMode::REQUIRED> fontFormatOpt {"font-format", 'f', "format", "svg", "select file format of embedded fonts"};
+ TypedOption<std::string, Option::ArgMode::REQUIRED> fontFormatOpt {"font-format", 'f', "format", "svg", "set file format of embedded fonts"};
TypedOption<std::string, Option::ArgMode::REQUIRED> fontmapOpt {"fontmap", 'm', "filenames", "evaluate (additional) font map files"};
Option gradOverlapOpt {"grad-overlap", '\0', "create overlapping color gradient segments"};
TypedOption<int, Option::ArgMode::REQUIRED> gradSegmentsOpt {"grad-segments", '\0', "number", 20, "number of color gradient segments per row"};
@@ -98,6 +99,9 @@ class CommandLine : public CL::CommandLine {
{&stdinOpt, 0},
{&bboxOpt, 1},
#if !defined(DISABLE_GS)
+ {&bitmapFormatOpt, 1},
+#endif
+#if !defined(DISABLE_GS)
{&clipjoinOpt, 1},
#endif
{&colornamesOpt, 1},
diff --git a/dviware/dvisvgm/src/DLLoader.cpp b/dviware/dvisvgm/src/DLLoader.cpp
index b047203801..9a974e89d9 100644
--- a/dviware/dvisvgm/src/DLLoader.cpp
+++ b/dviware/dvisvgm/src/DLLoader.cpp
@@ -2,7 +2,7 @@
** DLLoader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DLLoader.hpp b/dviware/dvisvgm/src/DLLoader.hpp
index 6bfff573e2..469fd1c4aa 100644
--- a/dviware/dvisvgm/src/DLLoader.hpp
+++ b/dviware/dvisvgm/src/DLLoader.hpp
@@ -2,7 +2,7 @@
** DLLoader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIActions.hpp b/dviware/dvisvgm/src/DVIActions.hpp
index c42f446d9e..31ea693477 100644
--- a/dviware/dvisvgm/src/DVIActions.hpp
+++ b/dviware/dvisvgm/src/DVIActions.hpp
@@ -2,7 +2,7 @@
** DVIActions.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIReader.cpp b/dviware/dvisvgm/src/DVIReader.cpp
index b0bbabee94..417efe9304 100644
--- a/dviware/dvisvgm/src/DVIReader.cpp
+++ b/dviware/dvisvgm/src/DVIReader.cpp
@@ -2,7 +2,7 @@
** DVIReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIReader.hpp b/dviware/dvisvgm/src/DVIReader.hpp
index 972af2022a..fc1424aca3 100644
--- a/dviware/dvisvgm/src/DVIReader.hpp
+++ b/dviware/dvisvgm/src/DVIReader.hpp
@@ -2,7 +2,7 @@
** DVIReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIToSVG.cpp b/dviware/dvisvgm/src/DVIToSVG.cpp
index 4801bd80a0..7280495e83 100644
--- a/dviware/dvisvgm/src/DVIToSVG.cpp
+++ b/dviware/dvisvgm/src/DVIToSVG.cpp
@@ -2,7 +2,7 @@
** DVIToSVG.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIToSVG.hpp b/dviware/dvisvgm/src/DVIToSVG.hpp
index 40dbdc884f..1bafa7cb3d 100644
--- a/dviware/dvisvgm/src/DVIToSVG.hpp
+++ b/dviware/dvisvgm/src/DVIToSVG.hpp
@@ -2,7 +2,7 @@
** DVIToSVG.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIToSVGActions.cpp b/dviware/dvisvgm/src/DVIToSVGActions.cpp
index bb8e4d6f84..6239be3b01 100644
--- a/dviware/dvisvgm/src/DVIToSVGActions.cpp
+++ b/dviware/dvisvgm/src/DVIToSVGActions.cpp
@@ -2,7 +2,7 @@
** DVIToSVGActions.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DVIToSVGActions.hpp b/dviware/dvisvgm/src/DVIToSVGActions.hpp
index e9adc63e38..2ae3fb9a2e 100644
--- a/dviware/dvisvgm/src/DVIToSVGActions.hpp
+++ b/dviware/dvisvgm/src/DVIToSVGActions.hpp
@@ -2,7 +2,7 @@
** DVIToSVGActions.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Directory.cpp b/dviware/dvisvgm/src/Directory.cpp
index 748d1bc070..e7200a0dc3 100644
--- a/dviware/dvisvgm/src/Directory.cpp
+++ b/dviware/dvisvgm/src/Directory.cpp
@@ -2,7 +2,7 @@
** Directory.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Directory.hpp b/dviware/dvisvgm/src/Directory.hpp
index f6ec7a9602..d617b4fcbd 100644
--- a/dviware/dvisvgm/src/Directory.hpp
+++ b/dviware/dvisvgm/src/Directory.hpp
@@ -2,7 +2,7 @@
** Directory.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp b/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
index dadf196f77..b2af27d636 100644
--- a/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/DvisvgmSpecialHandler.cpp
@@ -2,7 +2,7 @@
** DvisvgmSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp b/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp
index a8bde952e6..0f73c73ecd 100644
--- a/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/DvisvgmSpecialHandler.hpp
@@ -2,7 +2,7 @@
** DvisvgmSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EPSFile.cpp b/dviware/dvisvgm/src/EPSFile.cpp
index 5a5fccc08f..1a19c07cc7 100644
--- a/dviware/dvisvgm/src/EPSFile.cpp
+++ b/dviware/dvisvgm/src/EPSFile.cpp
@@ -2,7 +2,7 @@
** EPSFile.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EPSFile.hpp b/dviware/dvisvgm/src/EPSFile.hpp
index 4fdd03ee1b..7b02db95b1 100644
--- a/dviware/dvisvgm/src/EPSFile.hpp
+++ b/dviware/dvisvgm/src/EPSFile.hpp
@@ -2,7 +2,7 @@
** EPSFile.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EPSToSVG.hpp b/dviware/dvisvgm/src/EPSToSVG.hpp
index 9b193dc9cb..64f5ac604d 100644
--- a/dviware/dvisvgm/src/EPSToSVG.hpp
+++ b/dviware/dvisvgm/src/EPSToSVG.hpp
@@ -2,7 +2,7 @@
** EPSToSVG.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -30,7 +30,7 @@ class EPSToSVG : public ImageToSVG {
public:
EPSToSVG (const std::string &fname, SVGOutputBase &out) : ImageToSVG(fname, out) {}
bool isSinglePageFormat() const override {return true;}
- int totalPageCount() override {return 1;}
+ int totalPageCount() const override {return 1;}
protected:
std::string imageFormat () const override {return "EPS";}
diff --git a/dviware/dvisvgm/src/EllipticalArc.cpp b/dviware/dvisvgm/src/EllipticalArc.cpp
index b820af0052..a151c51307 100644
--- a/dviware/dvisvgm/src/EllipticalArc.cpp
+++ b/dviware/dvisvgm/src/EllipticalArc.cpp
@@ -2,7 +2,7 @@
** EllipticalArc.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EllipticalArc.hpp b/dviware/dvisvgm/src/EllipticalArc.hpp
index 5d20558196..422a40b207 100644
--- a/dviware/dvisvgm/src/EllipticalArc.hpp
+++ b/dviware/dvisvgm/src/EllipticalArc.hpp
@@ -2,7 +2,7 @@
** EllipticalArc.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EmSpecialHandler.cpp b/dviware/dvisvgm/src/EmSpecialHandler.cpp
index c93a798fd7..efbd7abef3 100644
--- a/dviware/dvisvgm/src/EmSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/EmSpecialHandler.cpp
@@ -2,7 +2,7 @@
** EmSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EmSpecialHandler.hpp b/dviware/dvisvgm/src/EmSpecialHandler.hpp
index 242ef248ef..e20339e548 100644
--- a/dviware/dvisvgm/src/EmSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/EmSpecialHandler.hpp
@@ -2,7 +2,7 @@
** EmSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EncFile.cpp b/dviware/dvisvgm/src/EncFile.cpp
index dba0a2544a..ce0f18d81e 100644
--- a/dviware/dvisvgm/src/EncFile.cpp
+++ b/dviware/dvisvgm/src/EncFile.cpp
@@ -2,7 +2,7 @@
** EncFile.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/EncFile.hpp b/dviware/dvisvgm/src/EncFile.hpp
index fac26fd201..8f2b14c430 100644
--- a/dviware/dvisvgm/src/EncFile.hpp
+++ b/dviware/dvisvgm/src/EncFile.hpp
@@ -2,7 +2,7 @@
** EncFile.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FileFinder.cpp b/dviware/dvisvgm/src/FileFinder.cpp
index e867f648a7..a52ccd37d3 100644
--- a/dviware/dvisvgm/src/FileFinder.cpp
+++ b/dviware/dvisvgm/src/FileFinder.cpp
@@ -2,7 +2,7 @@
** FileFinder.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FileFinder.hpp b/dviware/dvisvgm/src/FileFinder.hpp
index 08c59a3372..7218bf6c0b 100644
--- a/dviware/dvisvgm/src/FileFinder.hpp
+++ b/dviware/dvisvgm/src/FileFinder.hpp
@@ -2,7 +2,7 @@
** FileFinder.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FilePath.cpp b/dviware/dvisvgm/src/FilePath.cpp
index 6f162bfab9..2150cf31f7 100644
--- a/dviware/dvisvgm/src/FilePath.cpp
+++ b/dviware/dvisvgm/src/FilePath.cpp
@@ -2,7 +2,7 @@
** FilePath.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -191,14 +191,16 @@ string FilePath::suffix () const {
/** Changes the suffix of the filename. If FilePath represents the
- * location of a directory (and not of a file) nothing happens.
- * @param[in] s new suffix */
-void FilePath::suffix (const string &s) {
+ * location of a directory (and not of a file) nothing happens. An
+ * empty new suffix leads to the removal of the current one.
+ * @param[in] newSuffix the new suffix */
+void FilePath::suffix (const string &newSuffix) {
if (!_fname.empty()) {
string current_suffix = suffix();
if (!current_suffix.empty())
_fname.erase(_fname.length()-current_suffix.length()-1);
- _fname += "."+s;
+ if (!newSuffix.empty())
+ _fname += "."+newSuffix;
}
}
diff --git a/dviware/dvisvgm/src/FilePath.hpp b/dviware/dvisvgm/src/FilePath.hpp
index 32a9be6814..e9d55562c5 100644
--- a/dviware/dvisvgm/src/FilePath.hpp
+++ b/dviware/dvisvgm/src/FilePath.hpp
@@ -2,7 +2,7 @@
** FilePath.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -52,7 +52,7 @@ class FilePath {
std::string shorterAbsoluteOrRelative (std::string reldir="", bool with_filename=true) const;
std::string basename () const;
std::string suffix () const;
- void suffix (const std::string &s);
+ void suffix (const std::string &newSuffix);
size_t depth () const {return _dirs.size();}
bool isFile () const {return !_fname.empty();}
bool empty () const {return _dirs.empty() && _fname.empty();}
diff --git a/dviware/dvisvgm/src/FileSystem.cpp b/dviware/dvisvgm/src/FileSystem.cpp
index 6a081ee24f..a1fafbdece 100644
--- a/dviware/dvisvgm/src/FileSystem.cpp
+++ b/dviware/dvisvgm/src/FileSystem.cpp
@@ -2,7 +2,7 @@
** FileSystem.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FileSystem.hpp b/dviware/dvisvgm/src/FileSystem.hpp
index b882caa9fa..f82ff1e870 100644
--- a/dviware/dvisvgm/src/FileSystem.hpp
+++ b/dviware/dvisvgm/src/FileSystem.hpp
@@ -2,7 +2,7 @@
** FileSystem.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FixWord.hpp b/dviware/dvisvgm/src/FixWord.hpp
index 94166b232c..3414e1ead4 100644
--- a/dviware/dvisvgm/src/FixWord.hpp
+++ b/dviware/dvisvgm/src/FixWord.hpp
@@ -2,7 +2,7 @@
** FixWord.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Font.cpp b/dviware/dvisvgm/src/Font.cpp
index 97520c5953..e40ad8a392 100644
--- a/dviware/dvisvgm/src/Font.cpp
+++ b/dviware/dvisvgm/src/Font.cpp
@@ -2,7 +2,7 @@
** Font.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -425,10 +425,10 @@ int PhysicalFont::traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *c
* @param[out] bbox the computed bounding box
* @param[in] cb optional calback object forwarded to the tracer
* @return true if the box could be computed successfully */
-bool PhysicalFont::getExactGlyphBox(int c, BoundingBox& bbox, GFGlyphTracer::Callback* cb) const {
+bool PhysicalFont::getExactGlyphBox (int c, BoundingBox& bbox, GFGlyphTracer::Callback* cb) const {
Glyph glyph;
if (getGlyph(c, glyph, cb)) {
- glyph.computeBBox(bbox);
+ bbox = glyph.computeBBox();
double s = scaledSize()/unitsPerEm();
bbox.scale(s, s);
return true;
@@ -608,7 +608,7 @@ double NativeFont::charWidth (int c) const {
FontEngine::instance().setFont(*this);
int upem = FontEngine::instance().getUnitsPerEM();
double w = upem ? (scaledSize()*FontEngine::instance().getAdvance(c)/upem*_style.extend) : 0;
- w += fabs(_style.slant*charHeight(c));
+ w += abs(_style.slant*charHeight(c));
return w;
}
diff --git a/dviware/dvisvgm/src/Font.hpp b/dviware/dvisvgm/src/Font.hpp
index 3273a0c14b..59556e7a81 100644
--- a/dviware/dvisvgm/src/Font.hpp
+++ b/dviware/dvisvgm/src/Font.hpp
@@ -2,7 +2,7 @@
** Font.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontCache.cpp b/dviware/dvisvgm/src/FontCache.cpp
index 34478542df..e024558913 100644
--- a/dviware/dvisvgm/src/FontCache.cpp
+++ b/dviware/dvisvgm/src/FontCache.cpp
@@ -2,7 +2,7 @@
** FontCache.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontCache.hpp b/dviware/dvisvgm/src/FontCache.hpp
index 0068b6c78b..8a6025a3d2 100644
--- a/dviware/dvisvgm/src/FontCache.hpp
+++ b/dviware/dvisvgm/src/FontCache.hpp
@@ -2,7 +2,7 @@
** FontCache.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontEncoding.cpp b/dviware/dvisvgm/src/FontEncoding.cpp
index 3b038b63c6..8f2673f123 100644
--- a/dviware/dvisvgm/src/FontEncoding.cpp
+++ b/dviware/dvisvgm/src/FontEncoding.cpp
@@ -2,7 +2,7 @@
** FontEncoding.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontEncoding.hpp b/dviware/dvisvgm/src/FontEncoding.hpp
index fffccd4224..1c4a979aa9 100644
--- a/dviware/dvisvgm/src/FontEncoding.hpp
+++ b/dviware/dvisvgm/src/FontEncoding.hpp
@@ -2,7 +2,7 @@
** FontEncoding.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontEngine.cpp b/dviware/dvisvgm/src/FontEngine.cpp
index 61efd68916..bee1ca886d 100644
--- a/dviware/dvisvgm/src/FontEngine.cpp
+++ b/dviware/dvisvgm/src/FontEngine.cpp
@@ -2,7 +2,7 @@
** FontEngine.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontEngine.hpp b/dviware/dvisvgm/src/FontEngine.hpp
index 33c9b96da2..5796c2b1b3 100644
--- a/dviware/dvisvgm/src/FontEngine.hpp
+++ b/dviware/dvisvgm/src/FontEngine.hpp
@@ -2,7 +2,7 @@
** FontEngine.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontManager.cpp b/dviware/dvisvgm/src/FontManager.cpp
index 4f236b3866..58d2dfc261 100644
--- a/dviware/dvisvgm/src/FontManager.cpp
+++ b/dviware/dvisvgm/src/FontManager.cpp
@@ -2,7 +2,7 @@
** FontManager.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontManager.hpp b/dviware/dvisvgm/src/FontManager.hpp
index 4405f67ecd..2fe88bee38 100644
--- a/dviware/dvisvgm/src/FontManager.hpp
+++ b/dviware/dvisvgm/src/FontManager.hpp
@@ -2,7 +2,7 @@
** FontManager.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontMap.cpp b/dviware/dvisvgm/src/FontMap.cpp
index cc48aef0e6..727fdd83ba 100644
--- a/dviware/dvisvgm/src/FontMap.cpp
+++ b/dviware/dvisvgm/src/FontMap.cpp
@@ -2,7 +2,7 @@
** FontMap.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontMap.hpp b/dviware/dvisvgm/src/FontMap.hpp
index cd109c1809..f4824aa7f1 100644
--- a/dviware/dvisvgm/src/FontMap.hpp
+++ b/dviware/dvisvgm/src/FontMap.hpp
@@ -2,7 +2,7 @@
** FontMap.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontMetrics.cpp b/dviware/dvisvgm/src/FontMetrics.cpp
index 003b80acad..7d858fea90 100644
--- a/dviware/dvisvgm/src/FontMetrics.cpp
+++ b/dviware/dvisvgm/src/FontMetrics.cpp
@@ -2,7 +2,7 @@
** FontMetrics.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontMetrics.hpp b/dviware/dvisvgm/src/FontMetrics.hpp
index ccba26b727..66637e3044 100644
--- a/dviware/dvisvgm/src/FontMetrics.hpp
+++ b/dviware/dvisvgm/src/FontMetrics.hpp
@@ -2,7 +2,7 @@
** FontMetrics.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontStyle.hpp b/dviware/dvisvgm/src/FontStyle.hpp
index 1088df3c4e..79a03dac36 100644
--- a/dviware/dvisvgm/src/FontStyle.hpp
+++ b/dviware/dvisvgm/src/FontStyle.hpp
@@ -2,7 +2,7 @@
** FontStyle.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/FontWriter.cpp b/dviware/dvisvgm/src/FontWriter.cpp
index d93402baf5..4dd4c5c0d8 100644
--- a/dviware/dvisvgm/src/FontWriter.cpp
+++ b/dviware/dvisvgm/src/FontWriter.cpp
@@ -2,7 +2,7 @@
** FontWriter.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -145,7 +145,7 @@ static void writeSFD (const string &sfdname, const PhysicalFont &font, const set
// ensure that the sum of the SFD's Ascent and Descent values equals the font's units per EM
double yext = font.ascent()+font.descent();
- double scale = double(font.unitsPerEm())/(yext != 0 ? yext : fabs(font.ascent()));
+ double scale = double(font.unitsPerEm())/(yext != 0 ? yext : abs(font.ascent()));
sfd <<
"Ascent: " << font.ascent()*scale << "\n"
"Descent: " << font.descent()*scale << "\n"
@@ -260,7 +260,7 @@ bool FontWriter::writeCSSFontFace (FontFormat format, const set<int> &charcodes,
os << "@font-face{"
<< "font-family:" << _font.name() << ';'
<< "src:url(data:" << info->mimetype << ";base64,";
- util::base64_copy(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>(), ostreambuf_iterator<char>(os));
+ util::base64_copy(ifs, os);
os << ") format('" << info->formatstr_long << "');}\n";
ifs.close();
if (!PhysicalFont::KEEP_TEMP_FILES)
diff --git a/dviware/dvisvgm/src/FontWriter.hpp b/dviware/dvisvgm/src/FontWriter.hpp
index 458952cad9..e6cad37e88 100644
--- a/dviware/dvisvgm/src/FontWriter.hpp
+++ b/dviware/dvisvgm/src/FontWriter.hpp
@@ -2,7 +2,7 @@
** FontWriter.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GFGlyphTracer.cpp b/dviware/dvisvgm/src/GFGlyphTracer.cpp
index 1b55afc593..db77ae1dc8 100644
--- a/dviware/dvisvgm/src/GFGlyphTracer.cpp
+++ b/dviware/dvisvgm/src/GFGlyphTracer.cpp
@@ -2,7 +2,7 @@
** GFGlyphTracer.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GFGlyphTracer.hpp b/dviware/dvisvgm/src/GFGlyphTracer.hpp
index afe1b95253..d0d45ffd61 100644
--- a/dviware/dvisvgm/src/GFGlyphTracer.hpp
+++ b/dviware/dvisvgm/src/GFGlyphTracer.hpp
@@ -2,7 +2,7 @@
** GFGlyphTracer.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GFReader.cpp b/dviware/dvisvgm/src/GFReader.cpp
index a7d314d3de..4712de41d3 100644
--- a/dviware/dvisvgm/src/GFReader.cpp
+++ b/dviware/dvisvgm/src/GFReader.cpp
@@ -2,7 +2,7 @@
** GFReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GFReader.hpp b/dviware/dvisvgm/src/GFReader.hpp
index ad1e8b2220..e829bf8ffa 100644
--- a/dviware/dvisvgm/src/GFReader.hpp
+++ b/dviware/dvisvgm/src/GFReader.hpp
@@ -2,7 +2,7 @@
** GFReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GFTracer.cpp b/dviware/dvisvgm/src/GFTracer.cpp
index e73aab12fd..4a3fa5e776 100644
--- a/dviware/dvisvgm/src/GFTracer.cpp
+++ b/dviware/dvisvgm/src/GFTracer.cpp
@@ -2,7 +2,7 @@
** GFTracer.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GFTracer.hpp b/dviware/dvisvgm/src/GFTracer.hpp
index efe9476a8f..e72848896d 100644
--- a/dviware/dvisvgm/src/GFTracer.hpp
+++ b/dviware/dvisvgm/src/GFTracer.hpp
@@ -2,7 +2,7 @@
** GFTracer.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Ghostscript.cpp b/dviware/dvisvgm/src/Ghostscript.cpp
index c097ace667..1ff82314ec 100644
--- a/dviware/dvisvgm/src/Ghostscript.cpp
+++ b/dviware/dvisvgm/src/Ghostscript.cpp
@@ -2,7 +2,7 @@
** Ghostscript.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -144,6 +144,9 @@ static string get_libgs (const string &fname) {
dlname = "libgs." + to_string(i) + ".dylib";
if (loader.loadLibrary(dlname))
return dlname;
+ dlname = "libgs.dylib." + to_string(i);
+ if (loader.loadLibrary(dlname))
+ return dlname;
#endif
}
#endif
diff --git a/dviware/dvisvgm/src/Ghostscript.hpp b/dviware/dvisvgm/src/Ghostscript.hpp
index 4ea62f775f..8c9a429798 100644
--- a/dviware/dvisvgm/src/Ghostscript.hpp
+++ b/dviware/dvisvgm/src/Ghostscript.hpp
@@ -2,7 +2,7 @@
** Ghostscript.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Glyph.hpp b/dviware/dvisvgm/src/Glyph.hpp
index 6f457a778f..dfa8cb366a 100644
--- a/dviware/dvisvgm/src/Glyph.hpp
+++ b/dviware/dvisvgm/src/Glyph.hpp
@@ -2,7 +2,7 @@
** Glyph.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/GlyphTracerMessages.hpp b/dviware/dvisvgm/src/GlyphTracerMessages.hpp
index d48fe6f1b4..f291d05ccc 100644
--- a/dviware/dvisvgm/src/GlyphTracerMessages.hpp
+++ b/dviware/dvisvgm/src/GlyphTracerMessages.hpp
@@ -2,7 +2,7 @@
** GlyphTracerMessages.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -37,17 +37,18 @@ class GlyphTracerMessages : public GFGlyphTracer::Callback {
void beginChar (uint8_t c) override {
if (!_traced) {
- if (!_fname.empty())
+ if (!_fname.empty()) {
Message::mstream() << '\n';
- // extract font name from file path
- std::string fontname = _fname;
- size_t pos;
- if ((pos = fontname.rfind('/')) != std::string::npos)
- fontname = fontname.substr(pos+1);
- if ((pos = fontname.rfind('.')) != std::string::npos)
- fontname = fontname.substr(0, pos);
- Message::mstream(false, Message::MC_STATE)
- << "tracing glyphs of " << fontname << '\n';
+ // extract font name from file path
+ std::string fontname = _fname;
+ size_t pos;
+ if ((pos = fontname.rfind('/')) != std::string::npos)
+ fontname = fontname.substr(pos+1);
+ if ((pos = fontname.rfind('.')) != std::string::npos)
+ fontname = fontname.substr(0, pos);
+ Message::mstream(false, Message::MC_STATE)
+ << "tracing glyphs of " << fontname << '\n';
+ }
_traced = true;
}
}
diff --git a/dviware/dvisvgm/src/GraphicsPath.hpp b/dviware/dvisvgm/src/GraphicsPath.hpp
index bf09a37d09..565251c0d0 100644
--- a/dviware/dvisvgm/src/GraphicsPath.hpp
+++ b/dviware/dvisvgm/src/GraphicsPath.hpp
@@ -2,7 +2,7 @@
** GraphicsPath.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -540,7 +540,7 @@ class GraphicsPath {
}
}
- void arcto (double rx, double ry, double angle, bool laf, bool sweep, const Point &p) {
+ void arcto (T rx, T ry, double angle, bool laf, bool sweep, const Point &p) {
_commands.emplace_back(ArcTo{rx, ry, angle, laf, sweep, p});
_finalPoint = p;
}
@@ -597,7 +597,8 @@ class GraphicsPath {
/** Computes the bounding box of the current path.
* @param[out] bbox the computed bounding box */
- void computeBBox (BoundingBox &bbox) const {
+ BoundingBox computeBBox () const {
+ BoundingBox bbox;
struct BBoxActions : IterationActions {
explicit BBoxActions (BoundingBox &bb) : bbox(bb) {}
void moveto (const Point &p) override {bbox.embed(p);}
@@ -610,6 +611,7 @@ class GraphicsPath {
BoundingBox &bbox;
} actions(bbox);
iterate(actions, false);
+ return bbox;
}
/** Checks whether the current path describes a dot/point only (with no extent).
diff --git a/dviware/dvisvgm/src/HashFunction.cpp b/dviware/dvisvgm/src/HashFunction.cpp
index 517cc8f3cc..7f99dacaf0 100644
--- a/dviware/dvisvgm/src/HashFunction.cpp
+++ b/dviware/dvisvgm/src/HashFunction.cpp
@@ -2,7 +2,7 @@
** HashFunction.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/HashFunction.hpp b/dviware/dvisvgm/src/HashFunction.hpp
index bba61918ed..b13ee39a50 100644
--- a/dviware/dvisvgm/src/HashFunction.hpp
+++ b/dviware/dvisvgm/src/HashFunction.hpp
@@ -2,7 +2,7 @@
** HashFunction.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/HtmlSpecialHandler.cpp b/dviware/dvisvgm/src/HtmlSpecialHandler.cpp
index 43d3dbc224..01051f9d64 100644
--- a/dviware/dvisvgm/src/HtmlSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/HtmlSpecialHandler.cpp
@@ -2,7 +2,7 @@
** HtmlSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/HtmlSpecialHandler.hpp b/dviware/dvisvgm/src/HtmlSpecialHandler.hpp
index bb85b2ad2c..e09a6d7b51 100644
--- a/dviware/dvisvgm/src/HtmlSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/HtmlSpecialHandler.hpp
@@ -2,7 +2,7 @@
** HtmlSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/HyperlinkManager.cpp b/dviware/dvisvgm/src/HyperlinkManager.cpp
index de412afcdc..ef636c5aac 100644
--- a/dviware/dvisvgm/src/HyperlinkManager.cpp
+++ b/dviware/dvisvgm/src/HyperlinkManager.cpp
@@ -2,7 +2,7 @@
** HyperlinkManager.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/HyperlinkManager.hpp b/dviware/dvisvgm/src/HyperlinkManager.hpp
index 762b4a4cca..ca8d4fd0ef 100644
--- a/dviware/dvisvgm/src/HyperlinkManager.hpp
+++ b/dviware/dvisvgm/src/HyperlinkManager.hpp
@@ -2,7 +2,7 @@
** HyperlinkManager.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ImageToSVG.cpp b/dviware/dvisvgm/src/ImageToSVG.cpp
index 26edb3c753..dfb7943a06 100644
--- a/dviware/dvisvgm/src/ImageToSVG.cpp
+++ b/dviware/dvisvgm/src/ImageToSVG.cpp
@@ -2,7 +2,7 @@
** ImageToSVG.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -67,6 +67,7 @@ void ImageToSVG::convert (int pageno) {
"lly=" << bbox.minY() << " "
"urx=" << bbox.maxX() << " "
"ury=" << bbox.maxY();
+ _currentPageNumber = pageno;
if (!isSinglePageFormat())
ss << " page=" << pageno;
try {
@@ -147,8 +148,9 @@ void ImageToSVG::convert (const std::string &rangestr, pair<int,int> *pageinfo)
FilePath ImageToSVG::getSVGFilePath (unsigned pageno) const {
FilePath path;
- if (pageno == 1)
- path = _out.filepath(1, 1);
+ unsigned numPages = totalPageCount();
+ if (pageno >= 1 && pageno <= numPages)
+ path = _out.filepath(pageno, numPages);
return path;
}
diff --git a/dviware/dvisvgm/src/ImageToSVG.hpp b/dviware/dvisvgm/src/ImageToSVG.hpp
index a4e4de223f..92a860949c 100644
--- a/dviware/dvisvgm/src/ImageToSVG.hpp
+++ b/dviware/dvisvgm/src/ImageToSVG.hpp
@@ -2,7 +2,7 @@
** ImageToSVG.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -39,9 +39,9 @@ class ImageToSVG : protected SpecialActions {
void setPageTransformation (const std::string &transCmds) {_transCmds = transCmds;}
// void setPageSize (const std::string &name);
std::string filename () const {return _fname;}
- PSInterpreter& psInterpreter () {return _psHandler.psInterpreter();}
+ PSInterpreter& psInterpreter () const {return _psHandler.psInterpreter();}
virtual bool isSinglePageFormat () const =0;
- virtual int totalPageCount () =0;
+ virtual int totalPageCount () const =0;
protected:
void checkGSAndFileFormat ();
@@ -65,7 +65,7 @@ class ImageToSVG : protected SpecialActions {
void embed (const BoundingBox &bbox) override {_bbox.embed(bbox);}
void embed (const DPair &p, double r=0) override {if (r==0) _bbox.embed(p); else _bbox.embed(p, r);}
void progress (const char *id) override;
- unsigned getCurrentPageNumber() const override {return 0;}
+ unsigned getCurrentPageNumber() const override {return _currentPageNumber;}
BoundingBox& bbox () override {return _bbox;}
BoundingBox& bbox (const std::string &name, bool reset=false) override {return _bbox;}
FilePath getSVGFilePath (unsigned pageno) const override;
@@ -76,8 +76,9 @@ class ImageToSVG : protected SpecialActions {
SVGTree _svg;
SVGOutputBase &_out;
double _x=0, _y=0;
+ unsigned _currentPageNumber=0;
BoundingBox _bbox;
- PsSpecialHandler _psHandler;
+ mutable PsSpecialHandler _psHandler;
bool _haveGS=false; ///< true if Ghostscript is available
std::string _transCmds; ///< transformation commands
};
diff --git a/dviware/dvisvgm/src/InputBuffer.cpp b/dviware/dvisvgm/src/InputBuffer.cpp
index a952369afc..b6e85f27e1 100644
--- a/dviware/dvisvgm/src/InputBuffer.cpp
+++ b/dviware/dvisvgm/src/InputBuffer.cpp
@@ -2,7 +2,7 @@
** InputBuffer.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/InputBuffer.hpp b/dviware/dvisvgm/src/InputBuffer.hpp
index 8a62b6b011..1474ce0a52 100644
--- a/dviware/dvisvgm/src/InputBuffer.hpp
+++ b/dviware/dvisvgm/src/InputBuffer.hpp
@@ -2,7 +2,7 @@
** InputBuffer.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/InputReader.cpp b/dviware/dvisvgm/src/InputReader.cpp
index 5c9b9f5c62..074c184822 100644
--- a/dviware/dvisvgm/src/InputReader.cpp
+++ b/dviware/dvisvgm/src/InputReader.cpp
@@ -2,7 +2,7 @@
** InputReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/InputReader.hpp b/dviware/dvisvgm/src/InputReader.hpp
index 0ca4f10772..9825156c09 100644
--- a/dviware/dvisvgm/src/InputReader.hpp
+++ b/dviware/dvisvgm/src/InputReader.hpp
@@ -2,7 +2,7 @@
** InputReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/JFM.cpp b/dviware/dvisvgm/src/JFM.cpp
index a79fdf0c03..7c749fd34e 100644
--- a/dviware/dvisvgm/src/JFM.cpp
+++ b/dviware/dvisvgm/src/JFM.cpp
@@ -2,7 +2,7 @@
** JFM.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/JFM.hpp b/dviware/dvisvgm/src/JFM.hpp
index c51f371a5e..8d4a1daf21 100644
--- a/dviware/dvisvgm/src/JFM.hpp
+++ b/dviware/dvisvgm/src/JFM.hpp
@@ -2,7 +2,7 @@
** JFM.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Length.cpp b/dviware/dvisvgm/src/Length.cpp
index cbee103d49..d20af5056c 100644
--- a/dviware/dvisvgm/src/Length.cpp
+++ b/dviware/dvisvgm/src/Length.cpp
@@ -2,7 +2,7 @@
** Length.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Length.hpp b/dviware/dvisvgm/src/Length.hpp
index 3c4de91fae..1b0d35d35f 100644
--- a/dviware/dvisvgm/src/Length.hpp
+++ b/dviware/dvisvgm/src/Length.hpp
@@ -2,7 +2,7 @@
** Length.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/MD5HashFunction.hpp b/dviware/dvisvgm/src/MD5HashFunction.hpp
index e233673d36..f0eda874f2 100644
--- a/dviware/dvisvgm/src/MD5HashFunction.hpp
+++ b/dviware/dvisvgm/src/MD5HashFunction.hpp
@@ -2,7 +2,7 @@
** MD5HashFunction.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Makefile.am b/dviware/dvisvgm/src/Makefile.am
index fcab2ba5cc..e7c7c27522 100644
--- a/dviware/dvisvgm/src/Makefile.am
+++ b/dviware/dvisvgm/src/Makefile.am
@@ -1,5 +1,5 @@
## This file is part of dvisvgm
-## Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
diff --git a/dviware/dvisvgm/src/MapLine.cpp b/dviware/dvisvgm/src/MapLine.cpp
index 57aa116f02..cd3d8ae7ea 100644
--- a/dviware/dvisvgm/src/MapLine.cpp
+++ b/dviware/dvisvgm/src/MapLine.cpp
@@ -2,7 +2,7 @@
** MapLine.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/MapLine.hpp b/dviware/dvisvgm/src/MapLine.hpp
index ea41fae0d0..9a6fa17648 100644
--- a/dviware/dvisvgm/src/MapLine.hpp
+++ b/dviware/dvisvgm/src/MapLine.hpp
@@ -2,7 +2,7 @@
** MapLine.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Matrix.cpp b/dviware/dvisvgm/src/Matrix.cpp
index f94e84809c..75d571877a 100644
--- a/dviware/dvisvgm/src/Matrix.cpp
+++ b/dviware/dvisvgm/src/Matrix.cpp
@@ -2,7 +2,7 @@
** Matrix.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -169,7 +169,7 @@ Matrix& Matrix::rotate (double deg) {
Matrix& Matrix::xskewByAngle (double deg) {
- if (fmod(fabs(deg)-90, 180) != 0)
+ if (fmod(abs(deg)-90, 180) != 0)
return xskewByRatio(tan(deg2rad(deg)));
return *this;
}
@@ -186,7 +186,7 @@ Matrix& Matrix::xskewByRatio (double xyratio) {
Matrix& Matrix::yskewByAngle (double deg) {
- if (fmod(fabs(deg)-90, 180) != 0)
+ if (fmod(abs(deg)-90, 180) != 0)
return yskewByRatio(tan(deg2rad(deg)));
return *this;
}
@@ -246,17 +246,17 @@ Matrix& Matrix::lmultiply (const Matrix &tm) {
Matrix& Matrix::invert () {
Matrix ret;
- if (double denom = det(*this)) {
- for (int i=0; i < 3; ++i) {
- for (int j=0; j < 3; ++j) {
- ret._values[i][j] = det(*this, i, j)/denom;
- if ((i+j)%2 != 0)
- ret._values[i][j] *= -1;
- }
+ double denom = det(*this);
+ if (abs(denom) < 1e-12)
+ throw exception();
+ for (int i=0; i < 3; ++i) {
+ for (int j=0; j < 3; ++j) {
+ ret._values[j][i] = det(*this, i, j)/denom;
+ if ((i+j)%2 != 0)
+ ret._values[j][i] *= -1;
}
- return *this = ret;
}
- throw exception();
+ return *this = ret;
}
@@ -469,7 +469,7 @@ static const char* ord_suffix (int n) {
static void skip_comma_wsp (istream &is) {
is >> ws;
- if (is.peek() == ',') is.ignore(1);
+ if (is.peek() == ',') is.get();
is >> ws;
}
@@ -494,13 +494,13 @@ static size_t parse_transform_cmd (istream &is, string cmd, size_t minparams, si
params.push_back(val);
is >> ws;
if (i == minparams && is.peek() == ')') {
- is.ignore(1);
+ is.get();
return i;
}
if (i == maxparams) {
if (is.peek() != ')')
throw ParserException("missing ')' at end of command '"+cmd+"'");
- is.ignore(1);
+ is.get();
}
skip_comma_wsp(is);
}
diff --git a/dviware/dvisvgm/src/Matrix.hpp b/dviware/dvisvgm/src/Matrix.hpp
index 733ff71fad..154ac8a37b 100644
--- a/dviware/dvisvgm/src/Matrix.hpp
+++ b/dviware/dvisvgm/src/Matrix.hpp
@@ -2,7 +2,7 @@
** Matrix.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Message.cpp b/dviware/dvisvgm/src/Message.cpp
index 85ed204cb4..caf8051f88 100644
--- a/dviware/dvisvgm/src/Message.cpp
+++ b/dviware/dvisvgm/src/Message.cpp
@@ -2,7 +2,7 @@
** Message.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Message.hpp b/dviware/dvisvgm/src/Message.hpp
index a7e6034021..fd6f048622 100644
--- a/dviware/dvisvgm/src/Message.hpp
+++ b/dviware/dvisvgm/src/Message.hpp
@@ -2,7 +2,7 @@
** Message.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/MessageException.hpp b/dviware/dvisvgm/src/MessageException.hpp
index c7aa342860..325e83e403 100644
--- a/dviware/dvisvgm/src/MessageException.hpp
+++ b/dviware/dvisvgm/src/MessageException.hpp
@@ -2,7 +2,7 @@
** MessageException.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/MetafontWrapper.cpp b/dviware/dvisvgm/src/MetafontWrapper.cpp
index 202b65d6ec..11667fb5e7 100644
--- a/dviware/dvisvgm/src/MetafontWrapper.cpp
+++ b/dviware/dvisvgm/src/MetafontWrapper.cpp
@@ -2,7 +2,7 @@
** MetafontWrapper.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -79,18 +79,8 @@ bool MetafontWrapper::call (const string &mode, double mag) {
string mf_messages;
mf_process.run(_dir, &mf_messages);
- // get resolution value from stdout created by above MF command
- char buf[256];
- istringstream iss(mf_messages);
- int resolution = 0;
- while (iss) {
- iss.getline(buf, sizeof(buf));
- string line = buf;
- if (line.substr(0, 3) == ">> ") {
- resolution = stoi(line.substr(3));
- break;
- }
- }
+ int resolution = getResolution(mf_messages);
+
// compose expected name of GF file (see Metafont Book, p. 324)
string gfname = _dir + _fontname + ".";
if (resolution > 0)
@@ -101,6 +91,52 @@ bool MetafontWrapper::call (const string &mode, double mag) {
}
+/** Returns the resolution applied to a GF file generated by Metafont. Since the resolution
+ * is part of the filename suffix, we need this value in order to address the file.
+ * @param[in] mfMessage output written to stdout by Metafont
+ * @return the resolution (>0 on success, 0 otherwise) */
+int MetafontWrapper::getResolution (const string &mfMessage) const {
+ int res = 0;
+ char buf[256];
+ if (!mfMessage.empty()) {
+ // try get resolution value written to stdout by above MF command
+ istringstream iss(mfMessage);
+ while (iss) {
+ iss.getline(buf, sizeof(buf));
+ string line = buf;
+ if (line.substr(0, 3) == ">> ") {
+ res = stoi(line.substr(3));
+ break;
+ }
+ }
+ }
+ // couldn't read resolution from stdout, try to get it from log file
+ if (res == 0) {
+ ifstream ifs(_dir+_fontname+".log");
+ while (ifs) {
+ ifs.getline(buf, sizeof(buf));
+ string line = buf;
+ if (line.substr(0, 18) == "Output written on ") {
+ line = line.substr(18);
+ size_t pos = line.find(' ');
+ line = line.substr(0, pos);
+ pos = line.rfind('.');
+ if (pos != string::npos && line.substr(line.length()-2) == "gf") {
+ line.pop_back();
+ line.pop_back();
+ try {
+ res = stoi(line.substr(pos+1));
+ }
+ catch (...) {
+ }
+ }
+ }
+ }
+ }
+ return res;
+}
+
+
/** Calls Metafont if output files (tfm and gf) don't already exist.
* @param[in] mode Metafont mode to be used (e.g. 'ljfour')
* @param[in] mag magnification factor
diff --git a/dviware/dvisvgm/src/MetafontWrapper.hpp b/dviware/dvisvgm/src/MetafontWrapper.hpp
index 031eb01ebd..582a146aee 100644
--- a/dviware/dvisvgm/src/MetafontWrapper.hpp
+++ b/dviware/dvisvgm/src/MetafontWrapper.hpp
@@ -2,7 +2,7 @@
** MetafontWrapper.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -26,14 +26,16 @@
class FileFinder;
-class MetafontWrapper
-{
+class MetafontWrapper {
public:
MetafontWrapper (std::string fname, std::string dir);
bool call (const std::string &mode, double mag);
bool make (const std::string &mode, double mag);
bool success () const;
+ protected:
+ int getResolution (const std::string &mfMessage) const;
+
private:
std::string _fontname;
std::string _dir;
diff --git a/dviware/dvisvgm/src/MiKTeXCom.cpp b/dviware/dvisvgm/src/MiKTeXCom.cpp
index 957173f126..9cd02edf41 100644
--- a/dviware/dvisvgm/src/MiKTeXCom.cpp
+++ b/dviware/dvisvgm/src/MiKTeXCom.cpp
@@ -2,7 +2,7 @@
** MiKTeXCom.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/MiKTeXCom.hpp b/dviware/dvisvgm/src/MiKTeXCom.hpp
index 5bf1981167..3da270cea1 100644
--- a/dviware/dvisvgm/src/MiKTeXCom.hpp
+++ b/dviware/dvisvgm/src/MiKTeXCom.hpp
@@ -2,7 +2,7 @@
** MiKTeXCom.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/NoPsSpecialHandler.cpp b/dviware/dvisvgm/src/NoPsSpecialHandler.cpp
index 533e5390be..f5b3d7244e 100644
--- a/dviware/dvisvgm/src/NoPsSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/NoPsSpecialHandler.cpp
@@ -2,7 +2,7 @@
** NoPsSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/NoPsSpecialHandler.hpp b/dviware/dvisvgm/src/NoPsSpecialHandler.hpp
index 027ea3fb62..9af3d47df5 100644
--- a/dviware/dvisvgm/src/NoPsSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/NoPsSpecialHandler.hpp
@@ -2,7 +2,7 @@
** NoPsSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/NumericRanges.hpp b/dviware/dvisvgm/src/NumericRanges.hpp
index c51f1eba73..a6ee109568 100644
--- a/dviware/dvisvgm/src/NumericRanges.hpp
+++ b/dviware/dvisvgm/src/NumericRanges.hpp
@@ -2,7 +2,7 @@
** NumericRanges.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PDFParser.cpp b/dviware/dvisvgm/src/PDFParser.cpp
index 1ecd40cba8..e511d4dc39 100644
--- a/dviware/dvisvgm/src/PDFParser.cpp
+++ b/dviware/dvisvgm/src/PDFParser.cpp
@@ -2,7 +2,7 @@
** PDFParser.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PDFParser.hpp b/dviware/dvisvgm/src/PDFParser.hpp
index 6471668307..b261ee9cf7 100644
--- a/dviware/dvisvgm/src/PDFParser.hpp
+++ b/dviware/dvisvgm/src/PDFParser.hpp
@@ -2,7 +2,7 @@
** PDFParser.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PDFToSVG.hpp b/dviware/dvisvgm/src/PDFToSVG.hpp
index d1871d0bb1..a6c71f964b 100644
--- a/dviware/dvisvgm/src/PDFToSVG.hpp
+++ b/dviware/dvisvgm/src/PDFToSVG.hpp
@@ -2,7 +2,7 @@
** PDFToSVG.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -32,7 +32,7 @@ class PDFToSVG : public ImageToSVG {
bool isSinglePageFormat() const override {return false;}
/** Returns the total number of pages in the PDF file. */
- int totalPageCount() override {
+ int totalPageCount() const override {
if (_totalPageCount < 0) {
_totalPageCount = psInterpreter().pdfPageCount(filename());
if (_totalPageCount < 1)
diff --git a/dviware/dvisvgm/src/PSFilter.hpp b/dviware/dvisvgm/src/PSFilter.hpp
index 2e1cac5c77..87aff89a7c 100644
--- a/dviware/dvisvgm/src/PSFilter.hpp
+++ b/dviware/dvisvgm/src/PSFilter.hpp
@@ -2,7 +2,7 @@
** PSFilter.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PSInterpreter.cpp b/dviware/dvisvgm/src/PSInterpreter.cpp
index 4b1d1fbc15..038e1326f2 100644
--- a/dviware/dvisvgm/src/PSInterpreter.cpp
+++ b/dviware/dvisvgm/src/PSInterpreter.cpp
@@ -2,7 +2,7 @@
** PSInterpreter.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -30,6 +30,7 @@
#include "PSFilter.hpp"
#include "PSInterpreter.hpp"
#include "SignalHandler.hpp"
+#include "utility.hpp"
using namespace std;
@@ -266,6 +267,7 @@ void PSInterpreter::callActions (InputReader &in) {
{"grestore", { 0, &PSActions::grestore}},
{"grestoreall", { 0, &PSActions::grestoreall}},
{"gsave", { 0, &PSActions::gsave}},
+ {"image", { 3, &PSActions::image}},
{"initclip", { 0, &PSActions::initclip}},
{"lineto", { 2, &PSActions::lineto}},
{"makepattern", {-1, &PSActions::makepattern}},
@@ -278,6 +280,7 @@ void PSInterpreter::callActions (InputReader &in) {
{"save", { 1, &PSActions::save}},
{"scale", { 2, &PSActions::scale}},
{"setblendmode", { 1, &PSActions::setblendmode}},
+ {"setcolorspace", { 1, &PSActions::setcolorspace}},
{"setcmykcolor", { 4, &PSActions::setcmykcolor}},
{"setdash", {-1, &PSActions::setdash}},
{"setgray", { 1, &PSActions::setgray}},
@@ -378,3 +381,77 @@ BoundingBox PSInterpreter::pdfPageBox (const string &fname, int pageno) {
pagebox = BoundingBox(stod(_rawData[0]), stod(_rawData[1]), stod(_rawData[2]), stod(_rawData[3]));
return pagebox;
}
+
+
+vector<PSDeviceInfo> PSInterpreter::getImageDeviceInfos () {
+ vector<PSDeviceInfo> infos {
+ {"none", "no processing of bitmap images"},
+ {"jpeg", "color JPEG format"},
+ {"jpeggray", "grayscale JPEG format"},
+ {"png", "grayscale or 24-bit color PNG format"},
+ {"pnggray", "grayscale PNG format"},
+ {"pngmono", "black-and-white PNG format"},
+ {"pngmonod", "dithered black-and-white PNG format"},
+ {"png16", "4-bit color PNG format"},
+ {"png256", "8-bit color PNG format"},
+ {"png16m", "24-bit color PNG format"},
+ };
+ return infos;
+}
+
+
+void PSInterpreter::listImageDeviceInfos (ostream &os) {
+ for (const PSDeviceInfo &info : getImageDeviceInfos())
+ os << setw(8) << left << info.name << " | " << info.description << '\n';
+}
+
+
+/** Returns true if a given PS device name is known. The function deosn't
+ * check whether the device is actually available.
+ * @param[in] deviceStr device specifier of the form <device name>[:<param>] */
+bool PSInterpreter::imageDeviceKnown (string deviceStr) {
+ if (deviceStr.empty() || !isalpha(deviceStr[0]))
+ return false;
+ deviceStr = deviceStr.substr(0, deviceStr.find(':')); // strip optional argument
+ auto infos = getImageDeviceInfos();
+ auto it = find_if(infos.begin(), infos.end(), [&](PSDeviceInfo &info) {
+ return info.name == deviceStr;
+ });
+ return it != infos.end();
+}
+
+
+/** Sets the output device used to create bitmap images.
+ * @param[in] deviceStr device specifier of the form <device name>[:<param>]
+ * @return true on success, false if device is not supported */
+bool PSInterpreter::setImageDevice (const string &deviceStr) {
+ auto params = util::split(deviceStr, ":");
+ string name = util::tolower(params[0]);
+ if (!imageDeviceKnown(name))
+ return false;
+ if (name != "jpeg" && name != "png" && name != "none") {
+ // check if image device is supported by Ghostscript
+ executeRaw("devicedict/"+name+" known{1}{0}ifelse\n", 1);
+ if (_rawData.empty() || _rawData[0] != "1")
+ throw PSException("output device '"+name+"' is not available");
+ }
+ string ps = "/@imgdevice("+name+")store ";
+ try {
+ if (params.size() > 1) {
+ // set JPEG quality level if given
+ if (name.substr(0, 4) == "jpeg") {
+ int quality = max(0, min(stoi(params[1]), 100));
+ ps += "/JPEGQ "+to_string(quality)+" def ";
+ }
+ else if (name == "pngmonod") {
+ int minFeatureSize = max(0, min(stoi(params[1]), 4));
+ ps += "/MinFeatureSize "+to_string(minFeatureSize)+" def ";
+ }
+ }
+ }
+ catch (...) {
+ throw PSException("invalid device option '"+params[1]+"' (integer expected)");
+ }
+ execute(ps);
+ return true;
+}
diff --git a/dviware/dvisvgm/src/PSInterpreter.hpp b/dviware/dvisvgm/src/PSInterpreter.hpp
index 8e75e3c5f1..138242abb7 100644
--- a/dviware/dvisvgm/src/PSInterpreter.hpp
+++ b/dviware/dvisvgm/src/PSInterpreter.hpp
@@ -2,7 +2,7 @@
** PSInterpreter.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -51,6 +51,7 @@ struct PSActions {
virtual void gsave (std::vector<double> &p) =0;
virtual void grestore (std::vector<double> &p) =0;
virtual void grestoreall (std::vector<double> &p) =0;
+ virtual void image (std::vector<double> &p) =0;
virtual void initclip (std::vector<double> &p) =0;
virtual void lineto (std::vector<double> &p) =0;
virtual void makepattern (std::vector<double> &p) =0;
@@ -62,6 +63,7 @@ struct PSActions {
virtual void save (std::vector<double> &p) =0;
virtual void scale (std::vector<double> &p) =0;
virtual void setblendmode (std::vector<double> &p) =0;
+ virtual void setcolorspace (std::vector<double> &p) =0;
virtual void setcmykcolor (std::vector<double> &cmyk) =0;
virtual void setdash (std::vector<double> &p) =0;
virtual void setgray (std::vector<double> &p) =0;
@@ -85,6 +87,11 @@ struct PSActions {
class PSFilter;
+struct PSDeviceInfo {
+ std::string name;
+ std::string description;
+};
+
/** This class provides methods to execute chunks of PostScript code and calls
* several template methods on invocation of selected PS operators (see PSActions). */
class PSInterpreter {
@@ -105,6 +112,10 @@ class PSInterpreter {
int pdfPageCount (const std::string &fname);
BoundingBox pdfPageBox (const std::string &fname, int pageno);
const std::vector<std::string>& rawData () const {return _rawData;}
+ bool setImageDevice (const std::string &deviceStr);
+ static std::vector<PSDeviceInfo> getImageDeviceInfos ();
+ static void listImageDeviceInfos (std::ostream &os);
+ static bool imageDeviceKnown (std::string deviceStr);
protected:
void init ();
diff --git a/dviware/dvisvgm/src/PSPattern.cpp b/dviware/dvisvgm/src/PSPattern.cpp
index 90ff6a5685..4659dc7a84 100644
--- a/dviware/dvisvgm/src/PSPattern.cpp
+++ b/dviware/dvisvgm/src/PSPattern.cpp
@@ -2,7 +2,7 @@
** PSPattern.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -151,12 +151,11 @@ void PSUncoloredTilingPattern::apply (SpecialActions &actions) {
setGroupNode(util::static_unique_ptr_cast<XMLElement>(getGroupNode()->clone()));
// assign current color to the pattern graphic
vector<XMLElement*> colored_elems;
- const array<const char*, 2> attribs = {{"fill", "stroke"}};
- for (const char *attrib : attribs) {
- getGroupNode()->getDescendants(nullptr, attrib, colored_elems);
+ for (const char *attrName : {"fill", "stroke"}) {
+ getGroupNode()->getDescendants(nullptr, attrName, colored_elems);
for (XMLElement *elem : colored_elems) {
- if (string(elem->getAttributeValue(attrib)) != "none")
- elem->addAttribute(attrib, _currentColor.svgColorString());
+ if (string(elem->getAttributeValue(attrName)) != "none")
+ elem->addAttribute(attrName, _currentColor.svgColorString());
}
colored_elems.clear();
}
diff --git a/dviware/dvisvgm/src/PSPattern.hpp b/dviware/dvisvgm/src/PSPattern.hpp
index 7dde27827d..2c53dd2b3e 100644
--- a/dviware/dvisvgm/src/PSPattern.hpp
+++ b/dviware/dvisvgm/src/PSPattern.hpp
@@ -2,7 +2,7 @@
** PSPattern.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PSPreviewFilter.cpp b/dviware/dvisvgm/src/PSPreviewFilter.cpp
index 6dac4945a8..20e8b53643 100644
--- a/dviware/dvisvgm/src/PSPreviewFilter.cpp
+++ b/dviware/dvisvgm/src/PSPreviewFilter.cpp
@@ -2,7 +2,7 @@
** PSPreviewFilter.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PSPreviewFilter.hpp b/dviware/dvisvgm/src/PSPreviewFilter.hpp
index 630a277b16..acadf9f39e 100644
--- a/dviware/dvisvgm/src/PSPreviewFilter.hpp
+++ b/dviware/dvisvgm/src/PSPreviewFilter.hpp
@@ -2,7 +2,7 @@
** PSPreviewFilter.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PageRanges.cpp b/dviware/dvisvgm/src/PageRanges.cpp
index e6c1a8287b..a08ad4aa54 100644
--- a/dviware/dvisvgm/src/PageRanges.cpp
+++ b/dviware/dvisvgm/src/PageRanges.cpp
@@ -2,7 +2,7 @@
** PageRanges.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PageRanges.hpp b/dviware/dvisvgm/src/PageRanges.hpp
index 5ecc7a998c..e6909b9cd1 100644
--- a/dviware/dvisvgm/src/PageRanges.hpp
+++ b/dviware/dvisvgm/src/PageRanges.hpp
@@ -2,7 +2,7 @@
** PageRanges.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PageSize.cpp b/dviware/dvisvgm/src/PageSize.cpp
index 2f0a48aeb9..ac8e1c5275 100644
--- a/dviware/dvisvgm/src/PageSize.cpp
+++ b/dviware/dvisvgm/src/PageSize.cpp
@@ -2,7 +2,7 @@
** PageSize.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -33,8 +33,8 @@ using namespace std;
* @param[out] width contains the page width when function returns
* @param[out] height contains the page height when function returns */
static void computeASize (int n, Length &width, Length &height) {
- height.set(floor(1189.0/pow(math::SQRT2, n)+0.5), Length::Unit::MM);
- width.set(floor(height.mm()/math::SQRT2+0.5), Length::Unit::MM);
+ height.set(round(1189.0/pow(math::SQRT2, n)), Length::Unit::MM);
+ width.set(round(height.mm()/math::SQRT2), Length::Unit::MM);
}
@@ -46,8 +46,8 @@ static void computeBSize (int n, Length &width, Length &height) {
Length w, h;
computeASize(n, width, height);
computeASize(n-1, w, h);
- width.set(floor(sqrt(width.mm() * w.mm())+0.5), Length::Unit::MM);
- height.set(floor(sqrt(height.mm() * h.mm())+0.5), Length::Unit::MM);
+ width.set(round(sqrt(width.mm() * w.mm())), Length::Unit::MM);
+ height.set(round(sqrt(height.mm() * h.mm())), Length::Unit::MM);
}
@@ -59,8 +59,8 @@ static void computeCSize (int n, Length &width, Length &height) {
Length w, h;
computeASize(n, width, height);
computeBSize(n, w, h);
- width.set(floor(sqrt(width.mm() * w.mm())+0.5), Length::Unit::MM);
- height.set(floor(sqrt(height.mm() * h.mm())+0.5), Length::Unit::MM);
+ width.set(round(sqrt(width.mm() * w.mm())), Length::Unit::MM);
+ height.set(round(sqrt(height.mm() * h.mm())), Length::Unit::MM);
}
@@ -72,8 +72,8 @@ static void computeDSize (int n, Length &width, Length &height) {
Length w, h;
computeASize(n, width, height);
computeBSize(n+1, w, h);
- width.set(floor(sqrt(width.mm() * w.mm())+0.5), Length::Unit::MM);
- height.set(floor(sqrt(height.mm() * h.mm())+0.5), Length::Unit::MM);
+ width.set(round(sqrt(width.mm() * w.mm())), Length::Unit::MM);
+ height.set(round(sqrt(height.mm() * h.mm())), Length::Unit::MM);
}
diff --git a/dviware/dvisvgm/src/PageSize.hpp b/dviware/dvisvgm/src/PageSize.hpp
index c785a89564..43c555b9dd 100644
--- a/dviware/dvisvgm/src/PageSize.hpp
+++ b/dviware/dvisvgm/src/PageSize.hpp
@@ -2,7 +2,7 @@
** PageSize.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Pair.hpp b/dviware/dvisvgm/src/Pair.hpp
index 5dd7c68a93..63806c5b6a 100644
--- a/dviware/dvisvgm/src/Pair.hpp
+++ b/dviware/dvisvgm/src/Pair.hpp
@@ -2,7 +2,7 @@
** Pair.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp b/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp
index 0907afc8f0..c2ab96a8a8 100644
--- a/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PapersizeSpecialHandler.cpp
@@ -2,7 +2,7 @@
** PapersizeSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp b/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp
index c7f8f26d60..ed836f37d7 100644
--- a/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/PapersizeSpecialHandler.hpp
@@ -2,7 +2,7 @@
** PapersizeSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PathClipper.cpp b/dviware/dvisvgm/src/PathClipper.cpp
index f646289d25..4aa4373f46 100644
--- a/dviware/dvisvgm/src/PathClipper.cpp
+++ b/dviware/dvisvgm/src/PathClipper.cpp
@@ -2,7 +2,7 @@
** PathClipper.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PathClipper.hpp b/dviware/dvisvgm/src/PathClipper.hpp
index fb375db35f..e3e6bd1681 100644
--- a/dviware/dvisvgm/src/PathClipper.hpp
+++ b/dviware/dvisvgm/src/PathClipper.hpp
@@ -2,7 +2,7 @@
** PathClipper.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PdfSpecialHandler.cpp b/dviware/dvisvgm/src/PdfSpecialHandler.cpp
index 70174b0fe1..3466e44f8e 100644
--- a/dviware/dvisvgm/src/PdfSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PdfSpecialHandler.cpp
@@ -2,7 +2,7 @@
** PdfSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PdfSpecialHandler.hpp b/dviware/dvisvgm/src/PdfSpecialHandler.hpp
index 389ee96b86..67512dd403 100644
--- a/dviware/dvisvgm/src/PdfSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/PdfSpecialHandler.hpp
@@ -2,7 +2,7 @@
** PdfSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PreScanDVIReader.cpp b/dviware/dvisvgm/src/PreScanDVIReader.cpp
index 7c964fae86..8e255ef088 100644
--- a/dviware/dvisvgm/src/PreScanDVIReader.cpp
+++ b/dviware/dvisvgm/src/PreScanDVIReader.cpp
@@ -2,7 +2,7 @@
** PreScanDVIReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PreScanDVIReader.hpp b/dviware/dvisvgm/src/PreScanDVIReader.hpp
index 5176f5a1f3..900fd1fc01 100644
--- a/dviware/dvisvgm/src/PreScanDVIReader.hpp
+++ b/dviware/dvisvgm/src/PreScanDVIReader.hpp
@@ -2,7 +2,7 @@
** PreScanDVIReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Process.cpp b/dviware/dvisvgm/src/Process.cpp
index de5394f1fd..2e15153b9e 100644
--- a/dviware/dvisvgm/src/Process.cpp
+++ b/dviware/dvisvgm/src/Process.cpp
@@ -2,7 +2,7 @@
** Process.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Process.hpp b/dviware/dvisvgm/src/Process.hpp
index 70eeafb9d8..53311921c9 100644
--- a/dviware/dvisvgm/src/Process.hpp
+++ b/dviware/dvisvgm/src/Process.hpp
@@ -2,7 +2,7 @@
** Process.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/PsSpecialHandler.cpp b/dviware/dvisvgm/src/PsSpecialHandler.cpp
index 31f8aa55e7..2301eeb571 100644
--- a/dviware/dvisvgm/src/PsSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/PsSpecialHandler.cpp
@@ -2,7 +2,7 @@
** PsSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -23,7 +23,6 @@
#include <fstream>
#include <memory>
#include <sstream>
-#include "EPSFile.hpp"
#include "FileFinder.hpp"
#include "FilePath.hpp"
#include "FileSystem.hpp"
@@ -36,6 +35,7 @@
#include "SVGTree.hpp"
#include "TensorProductPatch.hpp"
#include "TriangularPatch.hpp"
+#include "utility.hpp"
using namespace std;
@@ -44,10 +44,12 @@ bool PsSpecialHandler::COMPUTE_CLIPPATHS_INTERSECTIONS = false;
bool PsSpecialHandler::SHADING_SEGMENT_OVERLAP = false;
int PsSpecialHandler::SHADING_SEGMENT_SIZE = 20;
double PsSpecialHandler::SHADING_SIMPLIFY_DELTA = 0.01;
+string PsSpecialHandler::BITMAP_FORMAT;
-PsSpecialHandler::PsSpecialHandler () : _psi(this), _actions(), _previewFilter(_psi), _xmlnode(), _savenode()
+PsSpecialHandler::PsSpecialHandler () : _psi(this), _previewFilter(_psi)
{
+ _psi.setImageDevice(BITMAP_FORMAT);
}
@@ -83,6 +85,7 @@ void PsSpecialHandler::initgraphics () {
_blendmode = 0; // "normal" mode (no blending)
_sx = _sy = _cos = 1.0;
_pattern = nullptr;
+ _patternEnabled = false;
_currentcolor = Color::BLACK;
_dashoffset = 0;
_dashpattern.clear();
@@ -381,6 +384,13 @@ void PsSpecialHandler::imgfile (FileType filetype, const string &fname, const ma
}
+/** Returns path + basename of temporary bitmap images. */
+static string image_base_path (SpecialActions &actions) {
+ FilePath imgpath = actions.getSVGFilePath(actions.getCurrentPageNumber());
+ return FileSystem::tmpdir() + "/" + imgpath.basename() + "-tmp-";
+}
+
+
/** Creates an XML element containing the image data depending on the file type.
* @param[in] type file type of the image
* @param[in] fname file name/path of image file
@@ -421,14 +431,15 @@ unique_ptr<XMLElement> PsSpecialHandler::createImageNode (FileType type, const s
node = util::make_unique<XMLElement>("g"); // put SVG nodes created from the EPS/PDF file in this group
_xmlnode = node.get();
_psi.execute(
- "\n@beginspecial @setspecial" // enter special environment
- "/setpagedevice{@setpagedevice}def " // activate processing of operator "setpagedevice"
- "matrix setmatrix" // don't apply outer PS transformations
- "/FirstPage "+to_string(pageno)+" def" // set number of first page to convert (PDF only)
- "/LastPage "+to_string(pageno)+" def " // set number of last page to convert (PDF only)
- +rectclip+ // clip to bounding box (if requexted by attribute 'clip')
- "(" + pathstr + ")run " // execute file content
- "@endspecial " // leave special environment
+ "\n@beginspecial @setspecial" // enter special environment
+ "/setpagedevice{@setpagedevice}def " // activate processing of operator "setpagedevice"
+ "/@imgbase("+image_base_path(*_actions)+")store " // path and basename of image files
+ "matrix setmatrix" // don't apply outer PS transformations
+ "/FirstPage "+to_string(pageno)+" def" // set number of first page to convert (PDF only)
+ "/LastPage "+to_string(pageno)+" def " // set number of last page to convert (PDF only)
+ +rectclip+ // clip to bounding box (if requexted by attribute 'clip')
+ "(" + pathstr + ")run " // execute file content
+ "@endspecial\n" // leave special environment
);
if (node->empty())
node.reset(nullptr);
@@ -468,6 +479,11 @@ static bool transform_box_extents (const Matrix &matrix, double &w, double &h, d
}
+void PsSpecialHandler::dviBeginPage (unsigned int pageno, SpecialActions &actions) {
+ _psi.execute("/@imgbase("+image_base_path(actions)+")store\n"); // path and basename of image files
+}
+
+
void PsSpecialHandler::dviEndPage (unsigned, SpecialActions &actions) {
BoundingBox bbox;
if (_previewFilter.getBoundingBox(bbox)) { // is there any data written by preview package?
@@ -638,7 +654,7 @@ void PsSpecialHandler::stroke (vector<double> &p) {
}
else {
// compute bounding box
- _path.computeBBox(bbox);
+ bbox = _path.computeBBox();
bbox.expand(_linewidth/2);
ostringstream oss;
@@ -669,12 +685,10 @@ void PsSpecialHandler::stroke (vector<double> &p) {
path->addAttribute("stroke-dashoffset", _dashoffset);
}
}
- if (path && _clipStack.path()) {
+ if (path && _clipStack.path() && !_savenode) {
// assign clipping path and clip bounding box
path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
- BoundingBox clipbox;
- _clipStack.path()->computeBBox(clipbox);
- bbox.intersect(clipbox);
+ bbox.intersect(_clipStack.path()->computeBBox());
_clipStack.removePrependedPath();
}
if (_xmlnode)
@@ -696,8 +710,7 @@ void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
return;
// compute bounding box
- BoundingBox bbox;
- _path.computeBBox(bbox);
+ BoundingBox bbox = _path.computeBBox();
if (!_actions->getMatrix().isIdentity()) {
_path.transform(_actions->getMatrix());
if (!_xmlnode)
@@ -714,12 +727,10 @@ void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
path->addAttribute("fill", XMLString("url(#")+_pattern->svgID()+")");
else if (_actions->getColor() != Color::BLACK || _savenode)
path->addAttribute("fill", _actions->getColor().svgColorString());
- if (_clipStack.path()) {
+ if (_clipStack.path() && !_savenode) { // clip path active and not inside pattern definition?
// assign clipping path and clip bounding box
path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
- BoundingBox clipbox;
- _clipStack.path()->computeBBox(clipbox);
- bbox.intersect(clipbox);
+ bbox.intersect(_clipStack.path()->computeBBox());
_clipStack.removePrependedPath();
}
if (evenodd) // SVG default fill rule is "nonzero" algorithm
@@ -738,6 +749,62 @@ void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
}
+/** Postprocesses the 'image' operation performed by the PS interpreter. If
+ * the PS image operator succeeded, there's now a PNG file that must be embedded
+ * into the SVG file. */
+void PsSpecialHandler::image (std::vector<double> &p) {
+ int imgID = static_cast<int>(p[0]); // ID of PNG file written
+ if (imgID < 0) // no bitmap file written?
+ return;
+
+ double width = p[1];
+ double height = p[2];
+ string suffix = (BITMAP_FORMAT.substr(0, 3) == "png" ? ".png" : ".jpg");
+ string fname = image_base_path(*_actions)+to_string(imgID)+suffix;
+ ifstream ifs(fname, ios::binary);
+ if (ifs) {
+ ifs.close();
+ auto image = util::make_unique<XMLElement>("image");
+ double x = _actions->getX();
+ double y = _actions->getY();
+ image->addAttribute("x", x);
+ image->addAttribute("y", y);
+ image->addAttribute("width", util::to_string(width));
+ image->addAttribute("height", util::to_string(height));
+
+ // The current transformation matrix (CTM) maps the unit square to the rectangular region
+ // of the target canvas showing the bitmap (see PS Reference Manual, 4.10.3). Therefore,
+ // the local pixel coordinates of the original bitmap must be transformed by CTM*inv(M) to
+ // get the target coordinates. M is the matrix that maps the unit square to the bitmap rectangle.
+ Matrix matrix{width, 0, 0, 0, -height, height}; // maps unit square to bitmap rectangle
+ matrix = matrix.invert().lmultiply(_actions->getMatrix());
+ image->addAttribute("transform", matrix.toSVG());
+
+ // To prevent memory issues, only add the filename to the href attribute and tag it by '@'
+ // for later base64 encoding.
+ image->addAttribute("@xlink:href", string("data:image/")+(suffix == ".png" ? "png" : "jpeg")+";base64,"+fname);
+
+ // if set, assign clipping path to image
+ if (_clipStack.path()) {
+ auto group = util::make_unique<XMLElement>("g");
+ group->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
+ group->append(std::move(image));
+ image = std::move(group); // handle the entire group as image to add
+ }
+ if (_xmlnode)
+ _xmlnode->append(std::move(image));
+ else {
+ _actions->svgTree().appendToPage(std::move(image));
+ BoundingBox bbox(x, y, x+width, y+height);
+ bbox.transform(matrix);
+ if (_clipStack.path())
+ bbox.intersect(_clipStack.path()->computeBBox());
+ _actions->embed(bbox);
+ }
+ }
+}
+
+
/** Creates a Matrix object from a given sequence of 6 double values.
* The given values must be arranged in PostScript matrix order.
* @param[in] v vector containing the matrix values
@@ -774,7 +841,6 @@ static void create_matrix (vector<double> &v, int startindex, Matrix &matrix) {
* 9-14: pattern matrix */
void PsSpecialHandler::makepattern (vector<double> &p) {
int pattern_type = static_cast<int>(p[0]);
- int id = static_cast<int>(p[1]);
switch (pattern_type) {
case 0:
// pattern definition completed
@@ -784,6 +850,7 @@ void PsSpecialHandler::makepattern (vector<double> &p) {
}
break;
case 1: { // tiling pattern
+ int id = static_cast<int>(p[1]);
BoundingBox bbox(p[2], p[3], p[4], p[5]);
const double &xstep=p[6], &ystep=p[7]; // horizontal and vertical distance of adjacent tiles
int paint_type = static_cast<int>(p[8]);
@@ -1184,7 +1251,8 @@ void PsSpecialHandler::rotate (vector<double> &p) {
void PsSpecialHandler::setgray (vector<double> &p) {
- _pattern = nullptr;
+ if (!_patternEnabled)
+ _pattern = nullptr;
_currentcolor.setGray(p[0]);
if (_actions)
_actions->setColor(_currentcolor);
@@ -1192,7 +1260,8 @@ void PsSpecialHandler::setgray (vector<double> &p) {
void PsSpecialHandler::setrgbcolor (vector<double> &p) {
- _pattern= nullptr;
+ if (!_patternEnabled)
+ _pattern= nullptr;
_currentcolor.setRGB(p[0], p[1], p[2]);
if (_actions)
_actions->setColor(_currentcolor);
@@ -1200,7 +1269,8 @@ void PsSpecialHandler::setrgbcolor (vector<double> &p) {
void PsSpecialHandler::setcmykcolor (vector<double> &p) {
- _pattern = nullptr;
+ if (!_patternEnabled)
+ _pattern = nullptr;
_currentcolor.setCMYK(p[0], p[1], p[2], p[3]);
if (_actions)
_actions->setColor(_currentcolor);
@@ -1208,7 +1278,8 @@ void PsSpecialHandler::setcmykcolor (vector<double> &p) {
void PsSpecialHandler::sethsbcolor (vector<double> &p) {
- _pattern = nullptr;
+ if (!_patternEnabled)
+ _pattern = nullptr;
_currentcolor.setHSB(p[0], p[1], p[2]);
if (_actions)
_actions->setColor(_currentcolor);
diff --git a/dviware/dvisvgm/src/PsSpecialHandler.hpp b/dviware/dvisvgm/src/PsSpecialHandler.hpp
index 6251e20a47..9dcbc2d4ce 100644
--- a/dviware/dvisvgm/src/PsSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/PsSpecialHandler.hpp
@@ -2,7 +2,7 @@
** PsSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -95,6 +95,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
static bool SHADING_SEGMENT_OVERLAP;
static int SHADING_SEGMENT_SIZE;
static double SHADING_SIMPLIFY_DELTA;
+ static std::string BITMAP_FORMAT;
protected:
void initialize ();
@@ -104,6 +105,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void processHeaderFile (const char *fname);
void imgfile (FileType type, const std::string &fname, const std::map<std::string,std::string> &attr);
std::unique_ptr<XMLElement> createImageNode (FileType type, const std::string &fname, int pageno, BoundingBox bbox, bool clip);
+ void dviBeginPage (unsigned int pageno, SpecialActions &actions) override;
void dviEndPage (unsigned pageno, SpecialActions &actions) override;
void clip (Path path, bool evenodd);
void processSequentialPatchMesh (int shadingTypeID, ColorSpace cspace, VectorIterator<double> &it);
@@ -125,6 +127,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void grestore (std::vector<double> &p) override;
void grestoreall (std::vector<double> &p) override;
void gsave (std::vector<double> &p) override;
+ void image (std::vector<double> &p) override;
void initclip (std::vector<double> &p) override;
void lineto (std::vector<double> &p) override;
void makepattern (std::vector<double> &p) override;
@@ -136,6 +139,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void save (std::vector<double> &p) override;
void scale (std::vector<double> &p) override;
void setblendmode (std::vector<double> &p) override {_blendmode = int(p[0]);}
+ void setcolorspace (std::vector<double> &p) override {_patternEnabled = bool(p[0]);}
void setcmykcolor (std::vector<double> &cmyk) override;
void setdash (std::vector<double> &p) override;
void setgray (std::vector<double> &p) override;
@@ -158,11 +162,11 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
private:
PSInterpreter _psi;
- SpecialActions *_actions;
+ SpecialActions *_actions=nullptr;
PSPreviewFilter _previewFilter; ///< filter to extract information generated by the preview package
PsSection _psSection=PS_NONE; ///< current section processed (nothing yet, headers, or body specials)
- XMLElement *_xmlnode; ///< if != 0, created SVG elements are appended to this node
- XMLElement *_savenode; ///< pointer to temporaryly store _xmlnode
+ XMLElement *_xmlnode=nullptr; ///< if != 0, created SVG elements are appended to this node
+ XMLElement *_savenode=nullptr; ///< pointer to temporaryly store _xmlnode
std::string _headerCode; ///< collected literal PS header code
Path _path;
DPair _currentpoint; ///< current PS position in bp units
@@ -181,6 +185,7 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
ClippingStack _clipStack;
std::map<int, std::unique_ptr<PSPattern>> _patterns;
PSTilingPattern *_pattern; ///< current pattern
+ bool _patternEnabled; ///< true if active color space is a pattern
};
#endif
diff --git a/dviware/dvisvgm/src/RangeMap.cpp b/dviware/dvisvgm/src/RangeMap.cpp
index 5fa2bb10ab..86190cacf9 100644
--- a/dviware/dvisvgm/src/RangeMap.cpp
+++ b/dviware/dvisvgm/src/RangeMap.cpp
@@ -2,7 +2,7 @@
** RangeMap.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/RangeMap.hpp b/dviware/dvisvgm/src/RangeMap.hpp
index 9d3f2c2d95..3e3bff9d4b 100644
--- a/dviware/dvisvgm/src/RangeMap.hpp
+++ b/dviware/dvisvgm/src/RangeMap.hpp
@@ -2,7 +2,7 @@
** RangeMap.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharHandler.cpp b/dviware/dvisvgm/src/SVGCharHandler.cpp
index 3733053e4d..f8d75a28d3 100644
--- a/dviware/dvisvgm/src/SVGCharHandler.cpp
+++ b/dviware/dvisvgm/src/SVGCharHandler.cpp
@@ -2,7 +2,7 @@
** SVGCharHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharHandler.hpp b/dviware/dvisvgm/src/SVGCharHandler.hpp
index 48d24496fa..f75df47215 100644
--- a/dviware/dvisvgm/src/SVGCharHandler.hpp
+++ b/dviware/dvisvgm/src/SVGCharHandler.hpp
@@ -2,7 +2,7 @@
** SVGCharHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp b/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp
index 613f7e7d8b..397943ace0 100644
--- a/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp
+++ b/dviware/dvisvgm/src/SVGCharHandlerFactory.cpp
@@ -2,7 +2,7 @@
** SVGCharHandlerFactory.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp b/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp
index 92a08dc196..f37b9977c2 100644
--- a/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp
+++ b/dviware/dvisvgm/src/SVGCharHandlerFactory.hpp
@@ -2,7 +2,7 @@
** SVGCharHandlerFactory.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharPathHandler.cpp b/dviware/dvisvgm/src/SVGCharPathHandler.cpp
index 3962168ae2..7a766bae49 100644
--- a/dviware/dvisvgm/src/SVGCharPathHandler.cpp
+++ b/dviware/dvisvgm/src/SVGCharPathHandler.cpp
@@ -2,7 +2,7 @@
** SVGCharPathHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharPathHandler.hpp b/dviware/dvisvgm/src/SVGCharPathHandler.hpp
index ba172de340..c404cbcd5a 100644
--- a/dviware/dvisvgm/src/SVGCharPathHandler.hpp
+++ b/dviware/dvisvgm/src/SVGCharPathHandler.hpp
@@ -2,7 +2,7 @@
** SVGCharPathHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp b/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp
index a48f5f9a93..6b89348dc1 100644
--- a/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp
+++ b/dviware/dvisvgm/src/SVGCharTspanTextHandler.cpp
@@ -2,7 +2,7 @@
** SVGCharTspanTextHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp b/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp
index 01567997b6..b847965a1a 100644
--- a/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp
+++ b/dviware/dvisvgm/src/SVGCharTspanTextHandler.hpp
@@ -2,7 +2,7 @@
** SVGCharTspanTextHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGOutput.cpp b/dviware/dvisvgm/src/SVGOutput.cpp
index 1f9e244883..18702be776 100644
--- a/dviware/dvisvgm/src/SVGOutput.cpp
+++ b/dviware/dvisvgm/src/SVGOutput.cpp
@@ -2,7 +2,7 @@
** SVGOutput.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGOutput.hpp b/dviware/dvisvgm/src/SVGOutput.hpp
index 1f4da20ee8..f29a032674 100644
--- a/dviware/dvisvgm/src/SVGOutput.hpp
+++ b/dviware/dvisvgm/src/SVGOutput.hpp
@@ -2,7 +2,7 @@
** SVGOutput.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp b/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp
index 0d36b5a8b8..89d1c548b0 100644
--- a/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp
+++ b/dviware/dvisvgm/src/SVGSingleCharTextHandler.cpp
@@ -2,7 +2,7 @@
** SVGSingleCharTextHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp b/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp
index 7fd2174f12..67fcabd44c 100644
--- a/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp
+++ b/dviware/dvisvgm/src/SVGSingleCharTextHandler.hpp
@@ -2,7 +2,7 @@
** SVGSingleCharTextHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGTree.cpp b/dviware/dvisvgm/src/SVGTree.cpp
index 57b5fd5a4f..e35a14d9b3 100644
--- a/dviware/dvisvgm/src/SVGTree.cpp
+++ b/dviware/dvisvgm/src/SVGTree.cpp
@@ -2,7 +2,7 @@
** SVGTree.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SVGTree.hpp b/dviware/dvisvgm/src/SVGTree.hpp
index d351ec9799..a441a314a5 100644
--- a/dviware/dvisvgm/src/SVGTree.hpp
+++ b/dviware/dvisvgm/src/SVGTree.hpp
@@ -2,7 +2,7 @@
** SVGTree.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ShadingPatch.cpp b/dviware/dvisvgm/src/ShadingPatch.cpp
index 1ad0011daf..847dc3aa0c 100644
--- a/dviware/dvisvgm/src/ShadingPatch.cpp
+++ b/dviware/dvisvgm/src/ShadingPatch.cpp
@@ -2,7 +2,7 @@
** ShadingPatch.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ShadingPatch.hpp b/dviware/dvisvgm/src/ShadingPatch.hpp
index 4346301e7b..573188b77b 100644
--- a/dviware/dvisvgm/src/ShadingPatch.hpp
+++ b/dviware/dvisvgm/src/ShadingPatch.hpp
@@ -2,7 +2,7 @@
** ShadingPatch.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SignalHandler.cpp b/dviware/dvisvgm/src/SignalHandler.cpp
index 5af70be2e4..14badba085 100644
--- a/dviware/dvisvgm/src/SignalHandler.cpp
+++ b/dviware/dvisvgm/src/SignalHandler.cpp
@@ -2,7 +2,7 @@
** SignalHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SignalHandler.hpp b/dviware/dvisvgm/src/SignalHandler.hpp
index b97449399e..647a3650fc 100644
--- a/dviware/dvisvgm/src/SignalHandler.hpp
+++ b/dviware/dvisvgm/src/SignalHandler.hpp
@@ -2,7 +2,7 @@
** SignalHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SourceInput.cpp b/dviware/dvisvgm/src/SourceInput.cpp
index 35cdd24af9..5cd2e22749 100644
--- a/dviware/dvisvgm/src/SourceInput.cpp
+++ b/dviware/dvisvgm/src/SourceInput.cpp
@@ -2,7 +2,7 @@
** SourceInput.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SourceInput.hpp b/dviware/dvisvgm/src/SourceInput.hpp
index 3b0f7b3c62..63f4af9b7a 100644
--- a/dviware/dvisvgm/src/SourceInput.hpp
+++ b/dviware/dvisvgm/src/SourceInput.hpp
@@ -2,7 +2,7 @@
** SourceInput.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SpecialActions.hpp b/dviware/dvisvgm/src/SpecialActions.hpp
index 7e53303792..f8eba3fd12 100644
--- a/dviware/dvisvgm/src/SpecialActions.hpp
+++ b/dviware/dvisvgm/src/SpecialActions.hpp
@@ -2,7 +2,7 @@
** SpecialActions.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SpecialHandler.hpp b/dviware/dvisvgm/src/SpecialHandler.hpp
index 4a3439bb24..6c676a6ba0 100644
--- a/dviware/dvisvgm/src/SpecialHandler.hpp
+++ b/dviware/dvisvgm/src/SpecialHandler.hpp
@@ -2,7 +2,7 @@
** SpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SpecialManager.cpp b/dviware/dvisvgm/src/SpecialManager.cpp
index 4838cbdf47..f3b2f3aa50 100644
--- a/dviware/dvisvgm/src/SpecialManager.cpp
+++ b/dviware/dvisvgm/src/SpecialManager.cpp
@@ -2,7 +2,7 @@
** SpecialManager.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/SpecialManager.hpp b/dviware/dvisvgm/src/SpecialManager.hpp
index fe88eaf58e..4c4ccae281 100644
--- a/dviware/dvisvgm/src/SpecialManager.hpp
+++ b/dviware/dvisvgm/src/SpecialManager.hpp
@@ -2,7 +2,7 @@
** SpecialManager.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/StreamReader.cpp b/dviware/dvisvgm/src/StreamReader.cpp
index ccfb176abe..200b6592d9 100644
--- a/dviware/dvisvgm/src/StreamReader.cpp
+++ b/dviware/dvisvgm/src/StreamReader.cpp
@@ -2,7 +2,7 @@
** StreamReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/StreamReader.hpp b/dviware/dvisvgm/src/StreamReader.hpp
index 05c4e1e701..653b451b69 100644
--- a/dviware/dvisvgm/src/StreamReader.hpp
+++ b/dviware/dvisvgm/src/StreamReader.hpp
@@ -2,7 +2,7 @@
** StreamReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/StreamWriter.cpp b/dviware/dvisvgm/src/StreamWriter.cpp
index 6216468695..c0885c31b1 100644
--- a/dviware/dvisvgm/src/StreamWriter.cpp
+++ b/dviware/dvisvgm/src/StreamWriter.cpp
@@ -2,7 +2,7 @@
** StreamWriter.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/StreamWriter.hpp b/dviware/dvisvgm/src/StreamWriter.hpp
index 441a9a7e7f..16a54b1050 100644
--- a/dviware/dvisvgm/src/StreamWriter.hpp
+++ b/dviware/dvisvgm/src/StreamWriter.hpp
@@ -2,7 +2,7 @@
** StreamWriter.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Subfont.cpp b/dviware/dvisvgm/src/Subfont.cpp
index e0b2570d8c..eb7f244cdb 100644
--- a/dviware/dvisvgm/src/Subfont.cpp
+++ b/dviware/dvisvgm/src/Subfont.cpp
@@ -2,7 +2,7 @@
** Subfont.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Subfont.hpp b/dviware/dvisvgm/src/Subfont.hpp
index ca88520ea2..5125194e9d 100644
--- a/dviware/dvisvgm/src/Subfont.hpp
+++ b/dviware/dvisvgm/src/Subfont.hpp
@@ -2,7 +2,7 @@
** Subfont.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/System.cpp b/dviware/dvisvgm/src/System.cpp
index b2724bdcab..ed14df6821 100644
--- a/dviware/dvisvgm/src/System.cpp
+++ b/dviware/dvisvgm/src/System.cpp
@@ -2,7 +2,7 @@
** System.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/System.hpp b/dviware/dvisvgm/src/System.hpp
index fa29325252..72a0cb3da8 100644
--- a/dviware/dvisvgm/src/System.hpp
+++ b/dviware/dvisvgm/src/System.hpp
@@ -2,7 +2,7 @@
** System.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TFM.cpp b/dviware/dvisvgm/src/TFM.cpp
index 005081533e..ea6f2ecbe4 100644
--- a/dviware/dvisvgm/src/TFM.cpp
+++ b/dviware/dvisvgm/src/TFM.cpp
@@ -2,7 +2,7 @@
** TFM.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TFM.hpp b/dviware/dvisvgm/src/TFM.hpp
index f2fd3027eb..261a5ce736 100644
--- a/dviware/dvisvgm/src/TFM.hpp
+++ b/dviware/dvisvgm/src/TFM.hpp
@@ -2,7 +2,7 @@
** TFM.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TTFAutohint.cpp b/dviware/dvisvgm/src/TTFAutohint.cpp
index a7aef2a5ec..ad1b03f21a 100644
--- a/dviware/dvisvgm/src/TTFAutohint.cpp
+++ b/dviware/dvisvgm/src/TTFAutohint.cpp
@@ -2,7 +2,7 @@
** TTFAutohint.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TTFAutohint.hpp b/dviware/dvisvgm/src/TTFAutohint.hpp
index 417661d3bb..d23ceb2be0 100644
--- a/dviware/dvisvgm/src/TTFAutohint.hpp
+++ b/dviware/dvisvgm/src/TTFAutohint.hpp
@@ -2,7 +2,7 @@
** TTFAutohint.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TensorProductPatch.cpp b/dviware/dvisvgm/src/TensorProductPatch.cpp
index 52acd63179..dcd31e275d 100644
--- a/dviware/dvisvgm/src/TensorProductPatch.cpp
+++ b/dviware/dvisvgm/src/TensorProductPatch.cpp
@@ -2,7 +2,7 @@
** TensorProductPatch.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -300,9 +300,9 @@ DPair TensorProductPatch::blossomValue (double u1, double u2, double u3, double
/** Snaps value x to the interval [0,1]. Values lesser than or near 0 are mapped to 0, values
* greater than or near 1 are mapped to 1. */
static inline double snap (double x) {
- if (fabs(x) < 0.001)
+ if (abs(x) < 0.001)
return 0;
- if (fabs(1-x) < 0.001)
+ if (abs(1-x) < 0.001)
return 1;
return x;
}
diff --git a/dviware/dvisvgm/src/TensorProductPatch.hpp b/dviware/dvisvgm/src/TensorProductPatch.hpp
index 711feefc2d..e53604cf52 100644
--- a/dviware/dvisvgm/src/TensorProductPatch.hpp
+++ b/dviware/dvisvgm/src/TensorProductPatch.hpp
@@ -2,7 +2,7 @@
** TensorProductPatch.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Terminal.cpp b/dviware/dvisvgm/src/Terminal.cpp
index 0e46874895..3b2ff2b871 100644
--- a/dviware/dvisvgm/src/Terminal.cpp
+++ b/dviware/dvisvgm/src/Terminal.cpp
@@ -2,7 +2,7 @@
** Terminal.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Terminal.hpp b/dviware/dvisvgm/src/Terminal.hpp
index e452aa042f..fd7a920c16 100644
--- a/dviware/dvisvgm/src/Terminal.hpp
+++ b/dviware/dvisvgm/src/Terminal.hpp
@@ -2,7 +2,7 @@
** Terminal.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ToUnicodeMap.cpp b/dviware/dvisvgm/src/ToUnicodeMap.cpp
index f002038aec..6ab99a248e 100644
--- a/dviware/dvisvgm/src/ToUnicodeMap.cpp
+++ b/dviware/dvisvgm/src/ToUnicodeMap.cpp
@@ -2,7 +2,7 @@
** ToUnicodeMap.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ToUnicodeMap.hpp b/dviware/dvisvgm/src/ToUnicodeMap.hpp
index 8ab3474e65..74d6dcb648 100644
--- a/dviware/dvisvgm/src/ToUnicodeMap.hpp
+++ b/dviware/dvisvgm/src/ToUnicodeMap.hpp
@@ -2,7 +2,7 @@
** ToUnicodeMap.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TpicSpecialHandler.cpp b/dviware/dvisvgm/src/TpicSpecialHandler.cpp
index b97fa439af..47d3e46988 100644
--- a/dviware/dvisvgm/src/TpicSpecialHandler.cpp
+++ b/dviware/dvisvgm/src/TpicSpecialHandler.cpp
@@ -2,7 +2,7 @@
** TpicSpecialHandler.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TpicSpecialHandler.hpp b/dviware/dvisvgm/src/TpicSpecialHandler.hpp
index fa8ba706fd..f6ec271994 100644
--- a/dviware/dvisvgm/src/TpicSpecialHandler.hpp
+++ b/dviware/dvisvgm/src/TpicSpecialHandler.hpp
@@ -2,7 +2,7 @@
** TpicSpecialHandler.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TriangularPatch.cpp b/dviware/dvisvgm/src/TriangularPatch.cpp
index 01efe2e8f0..fadeb725ff 100644
--- a/dviware/dvisvgm/src/TriangularPatch.cpp
+++ b/dviware/dvisvgm/src/TriangularPatch.cpp
@@ -2,7 +2,7 @@
** TriangularPatch.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -142,9 +142,9 @@ Color TriangularPatch::averageColor (const Color &c1, const Color &c2, const Col
/** Snaps value x to the interval [0,1]. Values lesser than or near 0 are mapped to 0, values
* greater than or near 1 are mapped to 1. */
static inline double snap (double x) {
- if (fabs(x) < 0.001)
+ if (abs(x) < 0.001)
return 0;
- if (fabs(1-x) < 0.001)
+ if (abs(1-x) < 0.001)
return 1;
return x;
}
diff --git a/dviware/dvisvgm/src/TriangularPatch.hpp b/dviware/dvisvgm/src/TriangularPatch.hpp
index d329e43fa1..797068bacd 100644
--- a/dviware/dvisvgm/src/TriangularPatch.hpp
+++ b/dviware/dvisvgm/src/TriangularPatch.hpp
@@ -2,7 +2,7 @@
** TriangularPatch.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TrueTypeFont.cpp b/dviware/dvisvgm/src/TrueTypeFont.cpp
index 408a00eede..2921af59ea 100644
--- a/dviware/dvisvgm/src/TrueTypeFont.cpp
+++ b/dviware/dvisvgm/src/TrueTypeFont.cpp
@@ -2,7 +2,7 @@
** TrueTypeFont.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/TrueTypeFont.hpp b/dviware/dvisvgm/src/TrueTypeFont.hpp
index d2e5b6e98d..0ae155c52c 100644
--- a/dviware/dvisvgm/src/TrueTypeFont.hpp
+++ b/dviware/dvisvgm/src/TrueTypeFont.hpp
@@ -2,7 +2,7 @@
** TrueTypeFont.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Unicode.cpp b/dviware/dvisvgm/src/Unicode.cpp
index d4a18a7bb9..950209bda0 100644
--- a/dviware/dvisvgm/src/Unicode.cpp
+++ b/dviware/dvisvgm/src/Unicode.cpp
@@ -2,7 +2,7 @@
** Unicode.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/Unicode.hpp b/dviware/dvisvgm/src/Unicode.hpp
index e281edc791..bc9db7e731 100644
--- a/dviware/dvisvgm/src/Unicode.hpp
+++ b/dviware/dvisvgm/src/Unicode.hpp
@@ -2,7 +2,7 @@
** Unicode.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/VFActions.hpp b/dviware/dvisvgm/src/VFActions.hpp
index 73567109f7..2d4a2a2c5f 100644
--- a/dviware/dvisvgm/src/VFActions.hpp
+++ b/dviware/dvisvgm/src/VFActions.hpp
@@ -2,7 +2,7 @@
** VFActions.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/VFReader.cpp b/dviware/dvisvgm/src/VFReader.cpp
index 47f5e3f7b6..eb1193ddaa 100644
--- a/dviware/dvisvgm/src/VFReader.cpp
+++ b/dviware/dvisvgm/src/VFReader.cpp
@@ -2,7 +2,7 @@
** VFReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/VFReader.hpp b/dviware/dvisvgm/src/VFReader.hpp
index bd42289039..bbf4986d7f 100644
--- a/dviware/dvisvgm/src/VFReader.hpp
+++ b/dviware/dvisvgm/src/VFReader.hpp
@@ -2,7 +2,7 @@
** VFReader.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/VectorIterator.hpp b/dviware/dvisvgm/src/VectorIterator.hpp
index 17707fbc96..0fb53d78e4 100644
--- a/dviware/dvisvgm/src/VectorIterator.hpp
+++ b/dviware/dvisvgm/src/VectorIterator.hpp
@@ -2,7 +2,7 @@
** VectorIterator.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/VectorStream.hpp b/dviware/dvisvgm/src/VectorStream.hpp
index 9672e67435..0372d368d0 100644
--- a/dviware/dvisvgm/src/VectorStream.hpp
+++ b/dviware/dvisvgm/src/VectorStream.hpp
@@ -2,7 +2,7 @@
** VectorStream.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/XMLDocument.cpp b/dviware/dvisvgm/src/XMLDocument.cpp
index be14eaf678..ffe23b1f80 100644
--- a/dviware/dvisvgm/src/XMLDocument.cpp
+++ b/dviware/dvisvgm/src/XMLDocument.cpp
@@ -2,7 +2,7 @@
** XMLDocument.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/XMLDocument.hpp b/dviware/dvisvgm/src/XMLDocument.hpp
index e9132c44d8..2eaaee4a28 100644
--- a/dviware/dvisvgm/src/XMLDocument.hpp
+++ b/dviware/dvisvgm/src/XMLDocument.hpp
@@ -2,7 +2,7 @@
** XMLDocument.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/XMLNode.cpp b/dviware/dvisvgm/src/XMLNode.cpp
index 128be5b9e5..db07d95dd2 100644
--- a/dviware/dvisvgm/src/XMLNode.cpp
+++ b/dviware/dvisvgm/src/XMLNode.cpp
@@ -2,7 +2,7 @@
** XMLNode.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -19,15 +19,18 @@
*************************************************************************/
#include <algorithm>
-#include <map>
+#include <fstream>
#include <list>
+#include <map>
#include <sstream>
+#include "FileSystem.hpp"
#include "utility.hpp"
#include "XMLNode.hpp"
#include "XMLString.hpp"
using namespace std;
+bool XMLNode::KEEP_ENCODED_FILES=false;
bool XMLElement::WRITE_NEWLINES=true;
@@ -69,7 +72,7 @@ XMLElement::XMLElement (string name) : _name(std::move(name)) {
XMLElement::XMLElement (const XMLElement &node)
: XMLNode(node), _name(node._name), _attributes(node._attributes)
{
- for (XMLNode *child=_firstChild.get(); child; child = child->next())
+ for (XMLNode *child=node._firstChild.get(); child; child = child->next())
insertLast(child->clone());
}
@@ -84,6 +87,14 @@ XMLElement::XMLElement (XMLElement &&node) noexcept
}
+XMLElement::~XMLElement () {
+ // explicitly remove child nodes by iteration to prevent deep recursion
+ unique_ptr<XMLNode> child = std::move(_firstChild);
+ while (child && child->next())
+ child->removeNext();
+}
+
+
/** Removes all attributes and children. */
void XMLElement::clear () {
_attributes.clear();
@@ -315,8 +326,10 @@ unique_ptr<XMLNode> XMLElement::remove (XMLNode *child) {
bool XMLElement::getDescendants (const char *name, const char *attrName, vector<XMLElement*> &descendants) const {
for (XMLNode *child = _firstChild.get(); child; child = child->next()) {
if (XMLElement *elem = child->toElement()) {
- if ((!name || elem->name() == name) && (!attrName || elem->hasAttribute(attrName)))
- descendants.push_back(elem);
+ if (!name || !name[0] || (name[0] != '!' && elem->name() == name) || (name[0] == '!' && elem->name() != name+1)) {
+ if (!attrName || elem->hasAttribute(attrName))
+ descendants.push_back(elem);
+ }
elem->getDescendants(name, attrName, descendants);
}
}
@@ -347,8 +360,30 @@ XMLElement* XMLElement::getFirstDescendant (const char *name, const char *attrNa
ostream& XMLElement::write (ostream &os) const {
os << '<' << _name;
- for (const auto &attrib : _attributes)
- os << ' ' << attrib.name << "='" << attrib.value << '\'';
+ for (const auto &attrib : _attributes) {
+ os << ' ';
+ if (attrib.name.front() != '@')
+ os << attrib.name << "='" << attrib.value << '\'';
+ else {
+ os << attrib.name.substr(1) << "='";
+ size_t pos = attrib.value.find("base64,");
+ if (pos == string::npos)
+ os << attrib.value;
+ else {
+ os << attrib.value.substr(0, pos+7);
+ string fname = attrib.value.substr(pos+7);
+ ifstream ifs(fname, ios::binary);
+ if (ifs) {
+ os << '\n';
+ util::base64_copy(ifs, os, 200);
+ ifs.close();
+ if (!KEEP_ENCODED_FILES)
+ FileSystem::remove(fname);
+ }
+ }
+ os << "'";
+ }
+ }
if (empty())
os << "/>";
else {
diff --git a/dviware/dvisvgm/src/XMLNode.hpp b/dviware/dvisvgm/src/XMLNode.hpp
index b4e5ed6f2b..534ae87bd7 100644
--- a/dviware/dvisvgm/src/XMLNode.hpp
+++ b/dviware/dvisvgm/src/XMLNode.hpp
@@ -2,7 +2,7 @@
** XMLNode.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -63,6 +63,8 @@ class XMLNode {
XMLNode* prev () const {return _prev;}
XMLNode* next () const {return _next.get();}
+ static bool KEEP_ENCODED_FILES;
+
protected:
XMLNode* insertNext (std::unique_ptr<XMLNode> node);
std::unique_ptr<XMLNode> removeNext ();
@@ -126,6 +128,7 @@ class XMLElement : public XMLNode {
explicit XMLElement (std::string name);
XMLElement (const XMLElement &node);
XMLElement (XMLElement &&node) noexcept;
+ ~XMLElement ();
std::unique_ptr<XMLNode> clone () const override {return util::make_unique<XMLElement>(*this);}
void clear () override;
void addAttribute (const std::string &name, const std::string &value);
diff --git a/dviware/dvisvgm/src/XMLString.cpp b/dviware/dvisvgm/src/XMLString.cpp
index fcafb8d1ee..31de6a7b33 100644
--- a/dviware/dvisvgm/src/XMLString.cpp
+++ b/dviware/dvisvgm/src/XMLString.cpp
@@ -2,7 +2,7 @@
** XMLString.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/XMLString.hpp b/dviware/dvisvgm/src/XMLString.hpp
index fa9cf15f9e..52c227ae8a 100644
--- a/dviware/dvisvgm/src/XMLString.hpp
+++ b/dviware/dvisvgm/src/XMLString.hpp
@@ -2,7 +2,7 @@
** XMLString.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/XXHashFunction.hpp b/dviware/dvisvgm/src/XXHashFunction.hpp
index f81deddbd4..e44083f182 100644
--- a/dviware/dvisvgm/src/XXHashFunction.hpp
+++ b/dviware/dvisvgm/src/XXHashFunction.hpp
@@ -2,7 +2,7 @@
** XXHashFunction.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ZLibOutputStream.hpp b/dviware/dvisvgm/src/ZLibOutputStream.hpp
index 8331cb9eed..c1c065e357 100644
--- a/dviware/dvisvgm/src/ZLibOutputStream.hpp
+++ b/dviware/dvisvgm/src/ZLibOutputStream.hpp
@@ -2,7 +2,7 @@
** ZLibOutputStream.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/dvisvgm.cpp b/dviware/dvisvgm/src/dvisvgm.cpp
index 5828299fce..74a8e83abc 100644
--- a/dviware/dvisvgm/src/dvisvgm.cpp
+++ b/dviware/dvisvgm/src/dvisvgm.cpp
@@ -2,7 +2,7 @@
** dvisvgm.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -363,10 +363,18 @@ static void set_variables (const CommandLine &cmdline) {
PhysicalFont::KEEP_TEMP_FILES = cmdline.keepOpt.given();
PhysicalFont::METAFONT_MAG = max(1.0, cmdline.magOpt.value());
XMLString::DECIMAL_PLACES = max(0, min(6, cmdline.precisionOpt.value()));
+ XMLNode::KEEP_ENCODED_FILES = cmdline.keepOpt.given();
PsSpecialHandler::COMPUTE_CLIPPATHS_INTERSECTIONS = cmdline.clipjoinOpt.given();
PsSpecialHandler::SHADING_SEGMENT_OVERLAP = cmdline.gradOverlapOpt.given();
PsSpecialHandler::SHADING_SEGMENT_SIZE = max(1, cmdline.gradSegmentsOpt.value());
PsSpecialHandler::SHADING_SIMPLIFY_DELTA = cmdline.gradSimplifyOpt.value();
+ PsSpecialHandler::BITMAP_FORMAT = util::tolower(cmdline.bitmapFormatOpt.value());
+ if (!PSInterpreter::imageDeviceKnown(PsSpecialHandler::BITMAP_FORMAT)) {
+ ostringstream oss;
+ oss << "unknown image format '" << PsSpecialHandler::BITMAP_FORMAT << "'\nknown formats:\n";
+ PSInterpreter::listImageDeviceInfos(oss);
+ throw CL::CommandLineException(oss.str());
+ }
if (cmdline.optimizeOpt.given()) {
SVGOptimizer::MODULE_SEQUENCE = cmdline.optimizeOpt.value();
vector<string> modnames;
diff --git a/dviware/dvisvgm/src/ffwrapper.c b/dviware/dvisvgm/src/ffwrapper.c
index 68377f0762..61f17fdc6d 100644
--- a/dviware/dvisvgm/src/ffwrapper.c
+++ b/dviware/dvisvgm/src/ffwrapper.c
@@ -2,7 +2,7 @@
** ffwrapper.c **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/ffwrapper.h b/dviware/dvisvgm/src/ffwrapper.h
index f652a97f9a..e3e2f98832 100644
--- a/dviware/dvisvgm/src/ffwrapper.h
+++ b/dviware/dvisvgm/src/ffwrapper.h
@@ -2,7 +2,7 @@
** ffwrapper.h **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/macros.hpp b/dviware/dvisvgm/src/macros.hpp
index beeb54f04b..0a03776057 100644
--- a/dviware/dvisvgm/src/macros.hpp
+++ b/dviware/dvisvgm/src/macros.hpp
@@ -2,7 +2,7 @@
** macros.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp b/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp
index e26018253d..28046e45a2 100644
--- a/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp
+++ b/dviware/dvisvgm/src/optimizer/AttributeExtractor.cpp
@@ -2,7 +2,7 @@
** AttributeExtractor.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp b/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp
index c882e8b4c8..b4c6f2775c 100644
--- a/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp
+++ b/dviware/dvisvgm/src/optimizer/AttributeExtractor.hpp
@@ -2,7 +2,7 @@
** AttributeExtractor.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp b/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp
index c9111b43d5..98d2a8d699 100644
--- a/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp
+++ b/dviware/dvisvgm/src/optimizer/DependencyGraph.hpp
@@ -2,7 +2,7 @@
** DependencyGraph.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp b/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp
index 36bf3a8cd5..b8a32786c1 100644
--- a/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp
+++ b/dviware/dvisvgm/src/optimizer/GroupCollapser.cpp
@@ -2,7 +2,7 @@
** GroupCollapser.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp b/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp
index 9b5eb01829..08db518a90 100644
--- a/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp
+++ b/dviware/dvisvgm/src/optimizer/GroupCollapser.hpp
@@ -2,7 +2,7 @@
** GroupCollapser.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp b/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp
index ff4fec1b4d..276cfa5578 100644
--- a/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp
+++ b/dviware/dvisvgm/src/optimizer/OptimizerModule.hpp
@@ -2,7 +2,7 @@
** OptimizerModule.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp
index 85d8e5b1fa..906ccc2d14 100644
--- a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp
+++ b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.cpp
@@ -2,7 +2,7 @@
** RedundantElementRemover.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -54,6 +54,7 @@ void RedundantElementRemover::execute (XMLElement *defs, XMLElement *context) {
}
// collect elements that reference a clipPath, i.e. have a clip-path attribute
vector<XMLElement*> descendants;
+ defs->getDescendants("!clipPath", "clip-path", descendants);
context->getDescendants(nullptr, "clip-path", descendants);
// remove referenced IDs and their dependencies from the dependency graph
for (const XMLElement *elem : descendants) {
diff --git a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp
index dd46cfeba5..8d5a6b689f 100644
--- a/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp
+++ b/dviware/dvisvgm/src/optimizer/RedundantElementRemover.hpp
@@ -2,7 +2,7 @@
** RedundantElementRemover.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp b/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp
index 0320f8b565..b2d45176e7 100644
--- a/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp
+++ b/dviware/dvisvgm/src/optimizer/SVGOptimizer.cpp
@@ -2,7 +2,7 @@
** SVGOptimizer.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp b/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp
index 809f1f497c..0da157fbbb 100644
--- a/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp
+++ b/dviware/dvisvgm/src/optimizer/SVGOptimizer.hpp
@@ -2,7 +2,7 @@
** SVGOptimizer.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp b/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp
index 23e0e386df..b94ab9458e 100644
--- a/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp
+++ b/dviware/dvisvgm/src/optimizer/TextSimplifier.cpp
@@ -2,7 +2,7 @@
** TextSimplifier.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp b/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp
index 86f44e5051..cfdd548e87 100644
--- a/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp
+++ b/dviware/dvisvgm/src/optimizer/TextSimplifier.hpp
@@ -2,7 +2,7 @@
** TextSimplifier.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp b/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp
index b9d4c3db59..461698b62a 100644
--- a/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp
+++ b/dviware/dvisvgm/src/optimizer/TransformSimplifier.cpp
@@ -2,7 +2,7 @@
** TransformSimplifier.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -61,7 +61,7 @@ void TransformSimplifier::execute (XMLElement *context) {
/** Tries to incorporate the translation and scaling components of the 'transform' attribute
* of a given element into the positional and/or size attributes of that element. If successful,
- * the 'transform' attribute is removed.
+ * the 'transform' attribute is either removed or simplified to a scale() matrix.
* Currently, only 'image' and 'rect' elements are considered.
* @param[in] elem element to check
* @param[in] matrix matrix representing the 'transform' attribute of the element
@@ -72,17 +72,30 @@ bool TransformSimplifier::incorporateTransform (XMLElement *elem, const Matrix &
double ty = matrix.get(1, 2);
double sx = matrix.get(0, 0);
double sy = matrix.get(1, 1);
+ double x=0, y=0;
+
if (const char *xstr = elem->getAttributeValue("x"))
- tx += sx*strtod(xstr, nullptr);
+ x = strtod(xstr, nullptr);
if (const char *ystr = elem->getAttributeValue("y"))
- ty += sy*strtod(ystr, nullptr);
- if (const char *wstr = elem->getAttributeValue("width"))
- elem->addAttribute("width", sx*strtod(wstr, nullptr));
- if (const char *hstr = elem->getAttributeValue("height"))
- elem->addAttribute("height", sy*strtod(hstr, nullptr));
- elem->addAttribute("x", tx); // update x attribute
- elem->addAttribute("y", ty); // update x attribute
- elem->removeAttribute("transform");
+ y = strtod(ystr, nullptr);
+ // width and height attributes must not become negative. Hence, only apply the scaling
+ // values if they are non-negative. Otherwise, keep a scaling matrix
+ if (sx < 0 || sy < 0) {
+ x += (sx == 0 ? 0 : tx/sx);
+ y += (sy == 0 ? 0 : ty/sy);
+ elem->addAttribute("transform", "scale("+XMLString(sx)+","+XMLString(sy)+")");
+ }
+ else {
+ x = x*sx + tx;
+ y = y*sy + ty;
+ if (const char *wstr = elem->getAttributeValue("width"))
+ elem->addAttribute("width", sx*strtod(wstr, nullptr));
+ if (const char *hstr = elem->getAttributeValue("height"))
+ elem->addAttribute("height", sy*strtod(hstr, nullptr));
+ elem->removeAttribute("transform");
+ }
+ elem->addAttribute("x", x); // update x attribute
+ elem->addAttribute("y", y); // update y attribute
return true;
}
return false;
diff --git a/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp b/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp
index c4b6d9ee16..5d503635ba 100644
--- a/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp
+++ b/dviware/dvisvgm/src/optimizer/TransformSimplifier.hpp
@@ -2,7 +2,7 @@
** TransformSimplifier.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp b/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp
index 2135e285bb..be58bf70fd 100644
--- a/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp
+++ b/dviware/dvisvgm/src/optimizer/WSNodeRemover.cpp
@@ -2,7 +2,7 @@
** WSNodeRemover.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp b/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp
index c4fe7f989e..8c21ce2b6e 100644
--- a/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp
+++ b/dviware/dvisvgm/src/optimizer/WSNodeRemover.hpp
@@ -2,7 +2,7 @@
** WSNodeRemover.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/options.dtd b/dviware/dvisvgm/src/options.dtd
index 7e29babc43..d2806badce 100644
--- a/dviware/dvisvgm/src/options.dtd
+++ b/dviware/dvisvgm/src/options.dtd
@@ -3,7 +3,7 @@
** options.dtd **
** **
** This file is part of dvisvgm - a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/options.xml b/dviware/dvisvgm/src/options.xml
index 27975f1591..b1911694dd 100644
--- a/dviware/dvisvgm/src/options.xml
+++ b/dviware/dvisvgm/src/options.xml
@@ -3,7 +3,7 @@
** options.xml **
** **
** This file is part of dvisvgm - a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -26,7 +26,7 @@
<usage>--eps [options] epsfile</usage>
<usage>--pdf [options] pdffile</usage>
<description>This program converts DVI files, as created by TeX/LaTeX, as well as\nEPS and PDF files to the XML-based scalable vector graphics format SVG.</description>
- <copyright>Copyright (C) 2005-2019 Martin Gieseking &lt;martin.gieseking@uos.de></copyright>
+ <copyright>Copyright (C) 2005-2020 Martin Gieseking &lt;martin.gieseking@uos.de></copyright>
</program>
<options>
<section title="Input options">
@@ -53,6 +53,10 @@
<arg type="string" name="size" default="min"/>
<description>set size of bounding box</description>
</option>
+ <option long="bitmap-format" short="B" if="!defined(DISABLE_GS)">
+ <arg type="string" name="fmt" default="jpeg"/>
+ <description>set format used to embed PS/EPS bitmaps</description>
+ </option>
<option long="clipjoin" short="j" if="!defined(DISABLE_GS)">
<description>compute intersection of clipping paths</description>
</option>
@@ -64,7 +68,7 @@
</option>
<option long="font-format" short="f" if="!defined(DISABLE_WOFF)">
<arg type="string" name="format" default="svg"/>
- <description>select file format of embedded fonts</description>
+ <description>set file format of embedded fonts</description>
</option>
<option long="grad-overlap" if="!defined(DISABLE_GS)">
<description>create overlapping color gradient segments</description>
diff --git a/dviware/dvisvgm/src/psdefs.cpp b/dviware/dvisvgm/src/psdefs.cpp
index 04abb6227d..9c5991217d 100644
--- a/dviware/dvisvgm/src/psdefs.cpp
+++ b/dviware/dvisvgm/src/psdefs.cpp
@@ -2,7 +2,7 @@
** psdefs.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -22,104 +22,132 @@
const char *PSInterpreter::PSDEFS =
"<</Install{matrix setmatrix}/HWResolution[72 72]/PageSize[10000 10000]/Imaging"
-"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 ";
+"BBox null>>setpagedevice/@dodraw true store/@GD globaldict def/@SD systemdict "
+"def/@UD userdict def @GD/@nulldev false put @GD/@patcnt 0 put true setglobal @"
+"SD/:save @SD/save get put @SD/:restore @SD/restore get put @SD/:gsave @SD/gsav"
+"e get put @SD/:grestore @SD/grestore get put @SD/:grestoreall @SD/grestoreall "
+"get put @SD/:newpath @SD/newpath get put @SD/:stroke @SD/stroke get put @SD/:f"
+"ill @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/n"
+"ulldevice get put @SD/:image @SD/image get put @SD/:colorimage @SD/colorimage "
+"get put @SD/.setopacityalpha known not{@SD/.setopacityalpha{pop}put}if @SD/.se"
+"tshapealpha known not{@SD/.setshapealpha{pop}put}if @SD/.setblendmode known no"
+"t{@SD/.setblendmode{pop}put}if @SD/prseq{-1 1{-1 roll =only( )print}for(\\n)pr"
+"int}put @SD/prcmd{( )exch(\\ndvi.)3{print}repeat prseq}put @SD/cvxall{{cvx}for"
+"all}put @SD/defpr{[exch[/copy @SD]cvxall 5 -1 roll dup 6 1 roll[/get/exec]cvxa"
+"ll 6 -1 roll dup 7 1 roll 4 -1 roll dup 5 1 roll dup length string cvs/prcmd c"
+"vx]cvx def}put @SD/querypos{{currentpoint}stopped{$error/newerror false 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 dtrans"
+"form dup mul exch dup dup mul 3 -1 roll add dup 0 eq{pop}{sqrt div}ifelse 3(ap"
+"plyscalevals)prcmd}put @SD/prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(curveto)p"
+"rcmd}{0(closepath)prcmd}pathforall}put @SD/nulldevice{@GD/@nulldev true put :n"
+"ulldevice 1 1(setnulldevice)prcmd}put @SD/charpath{/@dodraw false store :charp"
+"ath/@dodraw true store}put @SD/stringwidth{/@dodraw false store :stringwidth/@"
+"dodraw true store}put @SD/show{@dodraw @GD/@nulldev get not and{dup :gsave cur"
+"rentpoint 2{50 mul exch}repeat :newpath moveto 50 50/scale sysexec true charpa"
+"th fill :grestore/@dodraw false store :show/@dodraw true store}{:show}ifelse}p"
+"ut @SD/varxyshow{dup 0 ge{<</chr 3 -1 roll string/prc 5 -1 roll/arr 7 -1 roll/"
+"str 9 -1 roll/idx 0>>begin 0 chr length str length 1 sub{str exch chr length g"
+"etinterval/chr exch store :gsave chr show :grestore currentpoint prc moveto/id"
+"x idx 1 add store}for end}{pop pop show}ifelse}put @SD/xyshow{dup dup type/arr"
+"aytype eq exch length 0 gt and{dup length 2 idiv 2 index length exch idiv}{-1}"
+"ifelse{exch arr idx 2 mul get add exch arr idx 2 mul 1 add get add}exch varxys"
+"how}put @SD/xshow{dup dup type/arraytype eq exch length 0 gt and{dup length 2 "
+"index length exch idiv}{-1}ifelse{exch arr idx get add exch}exch varxyshow}put"
+" @SD/yshow{dup dup type/arraytype eq exch length 0 gt and{dup length 2 index l"
+"ength exch idiv}{-1}ifelse{arr idx get add}exch varxyshow}put @SD/awidthshow{{"
+"1 string dup 0 5 index put :gsave show :grestore pop 0 rmoveto 3 index eq{4 in"
+"dex 4 index rmoveto}if 1 index 1 index rmoveto}exch cshow 5{pop}repeat}put @SD"
+"/widthshow{0 0 3 -1 roll awidthshow}put @SD/ashow{0 0 0 6 3 roll awidthshow}pu"
+"t @SD/newpath{:newpath 1 1(newpath)prcmd}put @SD/stroke{@dodraw @GD/@nulldev g"
+"et not and{prcolor 0 1(newpath)prcmd prpath 0(stroke)prcmd :newpath}{:stroke}i"
+"felse}put @SD/fill{@dodraw @GD/@nulldev 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)prcmd prpath 0(eofill)prcmd :newpath}{:eofill"
+"}ifelse}put @SD/clip{:clip @GD/@nulldev get not{0 1(newpath)prcmd prpath 0(cli"
+"p)prcmd}if}put @SD/eoclip{:eoclip @GD/@nulldev get not{0 1(newpath)prcmd prpat"
+"h 0(eoclip)prcmd}}put @SD/shfill{begin currentdict/ShadingType known currentdi"
+"ct/ColorSpace known and currentdict/DataSource known and currentdict/Function "
+"known not and ShadingType 4 ge{DataSource type/arraytype eq{<</DeviceGray 1/De"
+"viceRGB 3/DeviceCMYK 4/bgknown currentdict/Background known/bbknown currentdic"
+"t/BBox known>>begin currentdict ColorSpace known{ShadingType ColorSpace load b"
+"gknown{1 Background aload pop}{0}ifelse bbknown{1 BBox aload pop}{0}ifelse Sha"
+"dingType 5 eq{VerticesPerRow}if DataSource aload length 4 add bgknown{ColorSpa"
+"ce load add}if bbknown{4 add}if ShadingType 5 eq{1 add}if(shfill)prcmd}if end}"
+"if}if end}put @SD/image{dup type/dicttype eq{dup}{<</Width 6 index/Height 7 in"
+"dex/colorimg false>>}ifelse @execimg}put @SD/colorimage{<<2 index{/Width 2 ind"
+"ex 8 add index/Height 4 index 9 add index}{/Width 8 index/Height 9 index}ifels"
+"e/colorimg true>>@execimg}put/@imgbase(./)def/@imgdevice(jpeg)def/@execimg{@GD"
+"/@imgcnt 2 copy .knownget{1 add}{1}ifelse put begin<</imgdev null/imgid @GD/@i"
+"mgcnt get/ispng @imgdevice 0 3 getinterval(png)eq dup/suffix exch{(.png)}{(.jp"
+"g)}ifelse/colorimg currentdict/colorimg .knownget dup{pop}if/colordev 1 index "
+"currentcolorspace dup length 1 ne exch 0 get/DeviceGray ne or or>>begin @imgde"
+"vice(png)ne @imgdevice(jpeg)ne and{@imgdevice cvn}{colordev{ispng{/png16m}{/jp"
+"eg}ifelse}{ispng{/pnggray}{/jpeggray}ifelse}ifelse}ifelse dup devicedict exch "
+"known{:gsave/imgdev exch finddevice def mark/OutputFile @imgbase imgid 20 stri"
+"ng cvs strconcat suffix strconcat/PageSize[Width Height]/UseFastColor true isp"
+"ng{@imgdevice(pngmonod)eq{/MinFeatureSize where{pop/MinFeatureSize MinFeatureS"
+"ize}if}if}{/JPEGQ where{pop/JPEGQ JPEGQ}if}ifelse imgdev putdeviceprops setdev"
+"ice[Width 0 0 Height neg 0 Height]/setmatrix sysexec colorimg{:colorimage}{:im"
+"age}ifelse/copypage sysexec mark/OutputFile()imgdev putdeviceprops pop :gresto"
+"re imgid Width Height 3(image)prcmd}{pop colorimg{:colorimage}{:image}ifelse}i"
+"felse end end}def/@rect{4 -2 roll moveto exch dup 0 rlineto exch 0 exch rlinet"
+"o 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 rlineto neg 0 exch rlineto}{exch dup 0 rline"
+"to exch 0 exch rlineto neg 0 rlineto}ifelse closepath}bind def @SD/rectclip{:n"
+"ewpath dup type/arraytype eq{aload length 4 idiv{@rectcc}repeat}{@rectcc}ifels"
+"e clip :newpath}put @SD/rectfill{:gsave :newpath dup type/arraytype eq{aload l"
+"ength 4 idiv{@rectcc}repeat}{@rectcc}ifelse fill :grestore}put @SD/rectstroke{"
+"gsave :newpath dup type/arraytype eq{aload length 4 idiv{@rect}repeat}{@rect}i"
+"felse stroke grestore}put false setglobal @SD readonly pop/initclip 0 defpr/cl"
+"ippath 0 defpr/sysexec{@SD exch get exec}def/adddot{dup length 1 add string du"
+"p 0 46 put dup 3 -1 roll 1 exch putinterval}def/setlinewidth{dup/setlinewidth "
+"sysexec 1(setlinewidth)prcmd}def/setlinecap 1 defpr/setlinejoin 1 defpr/setmit"
+"erlimit 1 defpr/setdash{mark 3 1 roll 2 copy/setdash sysexec exch aload length"
+" 1 add -1 roll counttomark(setdash)prcmd pop}def/@setpagedevice{pop<<>>/setpag"
+"edevice sysexec matrix setmatrix newpath 0(setpagedevice)prcmd}def/@checknulld"
+"ev{@GD/@nulldev get{currentpagedevice maxlength 0 ne{@GD/@nulldev false put 0 "
+"1(setnulldevice)prcmd}if}if}def/prcolor{currentcolorspace @setcolorspace curre"
+"ntrgbcolor 3(setrgbcolor)prcmd}def/printgstate{@dodraw @GD/@nulldev get not an"
+"d{matrix currentmatrix aload pop 6(setmatrix)prcmd applyscalevals currentlinew"
+"idth 1(setlinewidth)prcmd currentlinecap 1(setlinecap)prcmd currentlinejoin 1("
+"setlinejoin)prcmd currentmiterlimit 1(setmiterlimit)prcmd prcolor currentdash "
+"mark 3 1 roll exch aload length 1 add -1 roll counttomark(setdash)prcmd pop}if"
+"}def/strconcat{exch dup length 2 index length add string dup dup 4 2 roll copy"
+" length 4 -1 roll putinterval}def/setgstate{/setgstate sysexec printgstate}def"
+"/save{@UD begin/@saveID vmstatus pop pop def end :save @saveID 1(save)prcmd}de"
+"f/restore{:restore @checknulldev printgstate @UD/@saveID known{@UD begin @save"
+"ID end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/grestore{:grestore @checknu"
+"lldev printgstate 0(grestore)prcmd}def/grestoreall{:grestoreall @checknulldev "
+"setstate 0(grestoreall)prcmd}def/rotate{dup type/arraytype ne @dodraw and{dup "
+"1(rotate)prcmd}if/rotate sysexec applyscalevals}def/scale{dup type/arraytype n"
+"e @dodraw and{2 copy 2(scale)prcmd}if/scale sysexec applyscalevals}def/transla"
+"te{dup type/arraytype ne @dodraw and{2 copy 2(translate)prcmd}if/translate sys"
+"exec}def/setmatrix{dup/setmatrix sysexec @dodraw{aload pop 6(setmatrix)prcmd a"
+"pplyscalevals}{pop}ifelse}def/initmatrix{matrix setmatrix}def/concat{matrix cu"
+"rrentmatrix matrix concatmatrix setmatrix}def/makepattern{gsave<</mx 3 -1 roll"
+">>begin<</XUID[1000000 @patcnt]>>copy mx/makepattern sysexec dup begin Pattern"
+"Type 2 lt{PatternType @patcnt BBox aload pop XStep YStep PaintType mx aload po"
+"p 15(makepattern)prcmd :newpath matrix setmatrix dup PaintProc 0 1(makepattern"
+")prcmd @GD/@patcnt @patcnt 1 add put}if end end grestore}def/setpattern{begin "
+"PatternType 1 eq{PaintType 1 eq{XUID aload pop exch pop 1}{:gsave[currentcolor"
+"space aload length -1 roll pop]/setcolorspace sysexec/setcolor sysexec XUID al"
+"oad pop exch pop currentrgbcolor :grestore 4}ifelse(setpattern)prcmd currentco"
+"lorspace 0 get/Pattern ne{[/Pattern currentcolorspace]/setcolorspace sysexec}i"
+"f currentcolorspace @setcolorspace}{/setpattern sysexec}ifelse end}def/setcolo"
+"r{dup type/dicttype eq{setpattern}{/setcolor sysexec/currentrgbcolor sysexec s"
+"etrgbcolor}ifelse}def/setcolorspace{dup/setcolorspace sysexec @setcolorspace}d"
+"ef/@setcolorspace{dup type/arraytype eq{0 get}if/Pattern eq{1}{0}ifelse 1(setc"
+"olorspace)prcmd}def/setgray 1 defpr/setcmykcolor 4 defpr/sethsbcolor 3 defpr/s"
+"etrgbcolor 3 defpr/.setopacityalpha{dup/.setopacityalpha sysexec 1(setopacitya"
+"lpha)prcmd}def/.setshapealpha{dup/.setshapealpha sysexec 1(setshapealpha)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/@pdfpagecount{(r"
+")file runpdfbegin pdfpagecount runpdfend}def/@pdfpagebox{(r)file runpdfbegin d"
+"up dup 1 lt exch pdfpagecount gt or{pop}{pdfgetpage/MediaBox pget pop aload po"
+"p}ifelse runpdfend}def DELAYBIND{.bindnow}if ";
diff --git a/dviware/dvisvgm/src/utility.cpp b/dviware/dvisvgm/src/utility.cpp
index f1ae59ec08..8fe31fcf2d 100644
--- a/dviware/dvisvgm/src/utility.cpp
+++ b/dviware/dvisvgm/src/utility.cpp
@@ -2,7 +2,7 @@
** utility.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/utility.hpp b/dviware/dvisvgm/src/utility.hpp
index 7127280284..7ad3bc8d69 100644
--- a/dviware/dvisvgm/src/utility.hpp
+++ b/dviware/dvisvgm/src/utility.hpp
@@ -2,7 +2,7 @@
** utility.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -88,10 +88,12 @@ std::vector<uint8_t> bytes (T val, int n=0) {
* the result to the range starting at 'dest'.
* @param[in] first initial position of the range to be encoded
* @param[in] last final position of the range to be encoded
- * @param[in] dest first position of the destination range */
+ * @param[in] dest first position of the destination range
+ * @param[in] wrap if > 0, add a newline after the given number of characters written */
template <typename InputIterator, typename OutputIterator>
-void base64_copy (InputIterator first, InputIterator last, OutputIterator dest) {
+void base64_copy (InputIterator first, InputIterator last, OutputIterator dest, int wrap=0) {
static const char *base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ int count=0;
while (first != last) {
int padding = 0;
unsigned char c0 = *first++, c1=0, c2=0;
@@ -106,15 +108,29 @@ void base64_copy (InputIterator first, InputIterator last, OutputIterator dest)
}
uint32_t n = (c0 << 16) | (c1 << 8) | c2;
for (int i=0; i <= 3-padding; i++) {
+ if (wrap > 0 && ++count > wrap) {
+ count = 1;
+ *dest++ = '\n';
+ }
*dest++ = base64_chars[(n >> 18) & 0x3f];
n <<= 6;
}
- while (padding--)
+ while (padding--) {
+ if (wrap > 0 && ++count > wrap) {
+ count = 1;
+ *dest++ = '\n';
+ }
*dest++ = '=';
+ }
}
}
+inline void base64_copy (std::istream &is, std::ostream &os, int wrap=0) {
+ base64_copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::ostreambuf_iterator<char>(os), wrap);
+}
+
+
/** Simple implementation mimicking std::make_unique introduced in C++14.
* Constructs an object of class T on the heap and returns a unique_ptr<T> to it.
* @param[in] args arguments forwarded to an constructor of T */
diff --git a/dviware/dvisvgm/src/version.hpp.in b/dviware/dvisvgm/src/version.hpp.in
index efbe631d5b..20ba32bbd5 100644
--- a/dviware/dvisvgm/src/version.hpp.in
+++ b/dviware/dvisvgm/src/version.hpp.in
@@ -2,7 +2,7 @@
** version.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/src/windows.hpp b/dviware/dvisvgm/src/windows.hpp
index e548ee099a..114420c3d5 100644
--- a/dviware/dvisvgm/src/windows.hpp
+++ b/dviware/dvisvgm/src/windows.hpp
@@ -2,7 +2,7 @@
** windows.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/BezierTest.cpp b/dviware/dvisvgm/tests/BezierTest.cpp
index 0c6ae70074..e03e4670fe 100644
--- a/dviware/dvisvgm/tests/BezierTest.cpp
+++ b/dviware/dvisvgm/tests/BezierTest.cpp
@@ -2,7 +2,7 @@
** BezierTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/BitmapTest.cpp b/dviware/dvisvgm/tests/BitmapTest.cpp
index 8a93519186..7c12d80b35 100644
--- a/dviware/dvisvgm/tests/BitmapTest.cpp
+++ b/dviware/dvisvgm/tests/BitmapTest.cpp
@@ -2,7 +2,7 @@
** BitmapTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/BoundingBoxTest.cpp b/dviware/dvisvgm/tests/BoundingBoxTest.cpp
index 31d23fe571..417080b5be 100644
--- a/dviware/dvisvgm/tests/BoundingBoxTest.cpp
+++ b/dviware/dvisvgm/tests/BoundingBoxTest.cpp
@@ -2,7 +2,7 @@
** BoundingBoxTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/CMapManagerTest.cpp b/dviware/dvisvgm/tests/CMapManagerTest.cpp
index 980eb70d91..5e4a98b9e7 100644
--- a/dviware/dvisvgm/tests/CMapManagerTest.cpp
+++ b/dviware/dvisvgm/tests/CMapManagerTest.cpp
@@ -2,7 +2,7 @@
** CMapManagerTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/CMapReaderTest.cpp b/dviware/dvisvgm/tests/CMapReaderTest.cpp
index 7e64d6d4e5..28df86bb41 100644
--- a/dviware/dvisvgm/tests/CMapReaderTest.cpp
+++ b/dviware/dvisvgm/tests/CMapReaderTest.cpp
@@ -2,7 +2,7 @@
** CMapReaderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/CMapTest.cpp b/dviware/dvisvgm/tests/CMapTest.cpp
index e18431f648..68a216a898 100644
--- a/dviware/dvisvgm/tests/CMapTest.cpp
+++ b/dviware/dvisvgm/tests/CMapTest.cpp
@@ -2,7 +2,7 @@
** CMapTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/CalculatorTest.cpp b/dviware/dvisvgm/tests/CalculatorTest.cpp
index a82b8c6955..28ebf342b8 100644
--- a/dviware/dvisvgm/tests/CalculatorTest.cpp
+++ b/dviware/dvisvgm/tests/CalculatorTest.cpp
@@ -2,7 +2,7 @@
** CalculatorTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/ColorSpecialTest.cpp b/dviware/dvisvgm/tests/ColorSpecialTest.cpp
index a7c2369afc..f05393a61a 100644
--- a/dviware/dvisvgm/tests/ColorSpecialTest.cpp
+++ b/dviware/dvisvgm/tests/ColorSpecialTest.cpp
@@ -2,7 +2,7 @@
** ColorSpecialTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/ColorTest.cpp b/dviware/dvisvgm/tests/ColorTest.cpp
index 36acfe4a16..c82d384fae 100644
--- a/dviware/dvisvgm/tests/ColorTest.cpp
+++ b/dviware/dvisvgm/tests/ColorTest.cpp
@@ -2,7 +2,7 @@
** ColorTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/CommandLineTest.cpp b/dviware/dvisvgm/tests/CommandLineTest.cpp
index 5e10af8432..ad7b0768c2 100644
--- a/dviware/dvisvgm/tests/CommandLineTest.cpp
+++ b/dviware/dvisvgm/tests/CommandLineTest.cpp
@@ -2,7 +2,7 @@
** CommandLineTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/DVIReaderTest.cpp b/dviware/dvisvgm/tests/DVIReaderTest.cpp
index 572c1f8397..e5b0ef8dc0 100644
--- a/dviware/dvisvgm/tests/DVIReaderTest.cpp
+++ b/dviware/dvisvgm/tests/DVIReaderTest.cpp
@@ -2,7 +2,7 @@
** DVIReaderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/DependencyGraphTest.cpp b/dviware/dvisvgm/tests/DependencyGraphTest.cpp
index fdf788e9d6..866d505864 100644
--- a/dviware/dvisvgm/tests/DependencyGraphTest.cpp
+++ b/dviware/dvisvgm/tests/DependencyGraphTest.cpp
@@ -2,7 +2,7 @@
** DependencyGraphTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/DirectoryTest.cpp b/dviware/dvisvgm/tests/DirectoryTest.cpp
index 848b3b710f..b610737930 100644
--- a/dviware/dvisvgm/tests/DirectoryTest.cpp
+++ b/dviware/dvisvgm/tests/DirectoryTest.cpp
@@ -2,7 +2,7 @@
** DirectoryTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/DvisvgmSpecialTest.cpp b/dviware/dvisvgm/tests/DvisvgmSpecialTest.cpp
index 4b4cdb6d42..829b4ca5ad 100644
--- a/dviware/dvisvgm/tests/DvisvgmSpecialTest.cpp
+++ b/dviware/dvisvgm/tests/DvisvgmSpecialTest.cpp
@@ -2,7 +2,7 @@
** DvisvgmSpecialTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/EllipticalArcTest.cpp b/dviware/dvisvgm/tests/EllipticalArcTest.cpp
index 127f7b08e3..4bf4977cca 100644
--- a/dviware/dvisvgm/tests/EllipticalArcTest.cpp
+++ b/dviware/dvisvgm/tests/EllipticalArcTest.cpp
@@ -2,7 +2,7 @@
** EllipticalArcTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/EmSpecialTest.cpp b/dviware/dvisvgm/tests/EmSpecialTest.cpp
index 1a14e9e5f6..00cc10f73c 100644
--- a/dviware/dvisvgm/tests/EmSpecialTest.cpp
+++ b/dviware/dvisvgm/tests/EmSpecialTest.cpp
@@ -2,7 +2,7 @@
** EmSpecialTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/FileFinderTest.cpp b/dviware/dvisvgm/tests/FileFinderTest.cpp
index 0ce1085fbc..7ea9bce627 100644
--- a/dviware/dvisvgm/tests/FileFinderTest.cpp
+++ b/dviware/dvisvgm/tests/FileFinderTest.cpp
@@ -2,7 +2,7 @@
** FileFinderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/FilePathTest.cpp b/dviware/dvisvgm/tests/FilePathTest.cpp
index 6cce81ef43..d5b6f67d4b 100644
--- a/dviware/dvisvgm/tests/FilePathTest.cpp
+++ b/dviware/dvisvgm/tests/FilePathTest.cpp
@@ -2,7 +2,7 @@
** FilePathTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -77,6 +77,9 @@ TEST(FilePathTest, file1) {
fp.suffix("new");
ASSERT_EQ(fp.suffix(), "new");
ASSERT_EQ(fp.relative("/a/b/x/y"), "../../c/d/f.new");
+ fp.suffix("");
+ ASSERT_EQ(fp.suffix(), "");
+ ASSERT_EQ(fp.relative("/a/b/x/y"), "../../c/d/f");
}
diff --git a/dviware/dvisvgm/tests/FileSystemTest.cpp b/dviware/dvisvgm/tests/FileSystemTest.cpp
index 0c8597f02c..e5acd22b73 100644
--- a/dviware/dvisvgm/tests/FileSystemTest.cpp
+++ b/dviware/dvisvgm/tests/FileSystemTest.cpp
@@ -2,7 +2,7 @@
** FileSystemTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/FontCacheTest.cpp b/dviware/dvisvgm/tests/FontCacheTest.cpp
index d7928b5bb8..d0e05be49a 100644
--- a/dviware/dvisvgm/tests/FontCacheTest.cpp
+++ b/dviware/dvisvgm/tests/FontCacheTest.cpp
@@ -2,7 +2,7 @@
** FontCacheTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/FontManagerTest.cpp b/dviware/dvisvgm/tests/FontManagerTest.cpp
index 869b7b7305..2ddb5b1064 100644
--- a/dviware/dvisvgm/tests/FontManagerTest.cpp
+++ b/dviware/dvisvgm/tests/FontManagerTest.cpp
@@ -2,7 +2,7 @@
** FontManagerTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/FontMapTest.cpp b/dviware/dvisvgm/tests/FontMapTest.cpp
index 5d4158c554..f73dfe39bd 100644
--- a/dviware/dvisvgm/tests/FontMapTest.cpp
+++ b/dviware/dvisvgm/tests/FontMapTest.cpp
@@ -2,7 +2,7 @@
** FontMapTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/GFGlyphTracerTest.cpp b/dviware/dvisvgm/tests/GFGlyphTracerTest.cpp
index 060e7cc824..71c08ee8e5 100644
--- a/dviware/dvisvgm/tests/GFGlyphTracerTest.cpp
+++ b/dviware/dvisvgm/tests/GFGlyphTracerTest.cpp
@@ -2,7 +2,7 @@
** GFGlyphTracerTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/GFReaderTest.cpp b/dviware/dvisvgm/tests/GFReaderTest.cpp
index 2387d28c3a..ac582dcb29 100644
--- a/dviware/dvisvgm/tests/GFReaderTest.cpp
+++ b/dviware/dvisvgm/tests/GFReaderTest.cpp
@@ -2,7 +2,7 @@
** GFReaderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/GhostscriptTest.cpp b/dviware/dvisvgm/tests/GhostscriptTest.cpp
index 180dbd558a..909fc80f6a 100644
--- a/dviware/dvisvgm/tests/GhostscriptTest.cpp
+++ b/dviware/dvisvgm/tests/GhostscriptTest.cpp
@@ -2,7 +2,7 @@
** GhostscriptTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/GraphicsPathTest.cpp b/dviware/dvisvgm/tests/GraphicsPathTest.cpp
index 92420f653e..a6af6cdc77 100644
--- a/dviware/dvisvgm/tests/GraphicsPathTest.cpp
+++ b/dviware/dvisvgm/tests/GraphicsPathTest.cpp
@@ -2,7 +2,7 @@
** GraphicsPathTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -109,8 +109,7 @@ TEST(GraphicsPathTest, computeBBox) {
path.cubicto(5,5,30,10,90,70);
path.lineto(20,30);
path.closepath();
- BoundingBox bbox;
- path.computeBBox(bbox);
+ BoundingBox bbox = path.computeBBox();
EXPECT_EQ(bbox, BoundingBox(5, 5, 100, 100));
}
diff --git a/dviware/dvisvgm/tests/HashFunctionTest.cpp b/dviware/dvisvgm/tests/HashFunctionTest.cpp
index 64559c5aab..6b287014df 100644
--- a/dviware/dvisvgm/tests/HashFunctionTest.cpp
+++ b/dviware/dvisvgm/tests/HashFunctionTest.cpp
@@ -2,7 +2,7 @@
** HashFunctionTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -75,13 +75,13 @@ TEST(HashFunctionTest, xxh128) {
XXH128HashFunction xxh128;
ASSERT_EQ(xxh128.digestSize(), 16);
xxh128.update("0123456789");
- EXPECT_EQ(xxh128.digestString(), "942eb242912d99ecb1844fcc57198e3a");
+ EXPECT_EQ(xxh128.digestString(), "e353667619ec664b49655fc9692165fb");
xxh128.update("abcdefghij");
- EXPECT_EQ(xxh128.digestString(), "f37bc26b7087c656f0345fdf02a75bc4");
+ EXPECT_EQ(xxh128.digestString(), "5f64782bdc987c162389e97fd11aed64");
xxh128.reset();
xxh128.update("0123456789");
- EXPECT_EQ(xxh128.digestString(), "942eb242912d99ecb1844fcc57198e3a");
- vector<uint8_t> bytes = {0x94, 0x2e, 0xb2, 0x42, 0x91, 0x2d, 0x99, 0xec, 0xb1, 0x84, 0x4f, 0xcc, 0x57, 0x19, 0x8e, 0x3a};
+ EXPECT_EQ(xxh128.digestString(), "e353667619ec664b49655fc9692165fb");
+ vector<uint8_t> bytes = {0xe3, 0x53, 0x66, 0x76, 0x19, 0xec, 0x66, 0x4b, 0x49, 0x65, 0x5F, 0xc9, 0x69, 0x21, 0x65, 0xfb};
EXPECT_EQ(xxh128.digestValue(), bytes);
}
#endif
@@ -128,11 +128,11 @@ TEST(HashFunctionTest, createXXH128) {
auto hashfunc = HashFunction::create("xxh128");
ASSERT_TRUE(dynamic_cast<XXH128HashFunction*>(hashfunc.get()) != nullptr);
hashfunc->update("0123456789");
- EXPECT_EQ(hashfunc->digestString(), "942eb242912d99ecb1844fcc57198e3a");
+ EXPECT_EQ(hashfunc->digestString(), "e353667619ec664b49655fc9692165fb");
hashfunc = HashFunction::create("xxh128", "0123456789");
ASSERT_TRUE(dynamic_cast<XXH128HashFunction*>(hashfunc.get()) != nullptr);
- EXPECT_EQ(hashfunc->digestString(), "942eb242912d99ecb1844fcc57198e3a");
+ EXPECT_EQ(hashfunc->digestString(), "e353667619ec664b49655fc9692165fb");
}
#endif
diff --git a/dviware/dvisvgm/tests/JFMReaderTest.cpp b/dviware/dvisvgm/tests/JFMReaderTest.cpp
index 6259325f54..b82d00febf 100644
--- a/dviware/dvisvgm/tests/JFMReaderTest.cpp
+++ b/dviware/dvisvgm/tests/JFMReaderTest.cpp
@@ -2,7 +2,7 @@
** JFMReaderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/LengthTest.cpp b/dviware/dvisvgm/tests/LengthTest.cpp
index 83da5d4766..f6a5bca573 100644
--- a/dviware/dvisvgm/tests/LengthTest.cpp
+++ b/dviware/dvisvgm/tests/LengthTest.cpp
@@ -2,7 +2,7 @@
** LengthTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/Makefile.am b/dviware/dvisvgm/tests/Makefile.am
index 002e7e82bf..438a06b02b 100644
--- a/dviware/dvisvgm/tests/Makefile.am
+++ b/dviware/dvisvgm/tests/Makefile.am
@@ -1,5 +1,5 @@
## This file is part of dvisvgm
-## Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
diff --git a/dviware/dvisvgm/tests/MapLineTest.cpp b/dviware/dvisvgm/tests/MapLineTest.cpp
index 7364f495b8..2d25c914f6 100644
--- a/dviware/dvisvgm/tests/MapLineTest.cpp
+++ b/dviware/dvisvgm/tests/MapLineTest.cpp
@@ -2,7 +2,7 @@
** MapLineTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/MatrixTest.cpp b/dviware/dvisvgm/tests/MatrixTest.cpp
index 62eb6a1805..2858c66aa6 100644
--- a/dviware/dvisvgm/tests/MatrixTest.cpp
+++ b/dviware/dvisvgm/tests/MatrixTest.cpp
@@ -2,7 +2,7 @@
** MatrixTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -207,6 +207,8 @@ TEST(MatrixTest, invert) {
for (int i=0; i < 3; ++i)
for (int j=0; j < 3; ++j)
EXPECT_DOUBLE_EQ(m2.get(i,j), m3.get(i,j));
+ Matrix m4{0};
+ EXPECT_THROW(m4.invert(), exception);
}
diff --git a/dviware/dvisvgm/tests/MessageExceptionTest.cpp b/dviware/dvisvgm/tests/MessageExceptionTest.cpp
index bff72088a2..706921c223 100644
--- a/dviware/dvisvgm/tests/MessageExceptionTest.cpp
+++ b/dviware/dvisvgm/tests/MessageExceptionTest.cpp
@@ -2,7 +2,7 @@
** MessageExceptionTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/PDFParserTest.cpp b/dviware/dvisvgm/tests/PDFParserTest.cpp
index 58e879c7e0..868b04de97 100644
--- a/dviware/dvisvgm/tests/PDFParserTest.cpp
+++ b/dviware/dvisvgm/tests/PDFParserTest.cpp
@@ -2,7 +2,7 @@
** PDFParserTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/PSInterpreterTest.cpp b/dviware/dvisvgm/tests/PSInterpreterTest.cpp
index 629f8d753b..cf8f772e06 100644
--- a/dviware/dvisvgm/tests/PSInterpreterTest.cpp
+++ b/dviware/dvisvgm/tests/PSInterpreterTest.cpp
@@ -2,7 +2,7 @@
** PSInterpreterTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -38,7 +38,8 @@ class PSTestActions : public PSActions {
void fill (vector<double> &p) override {print("fill", p);}
void gsave (vector<double> &p) override {print("gsave", p);}
void grestore (vector<double> &p) override {print("grestore", p);}
- void grestoreall(std::vector<double> &p) override {print("grestoreall", p);}
+ void grestoreall (std::vector<double> &p) override{print("grestoreall", p);}
+ void image (std::vector<double> &p) override {print("image", p);}
void initclip (vector<double> &p) override {print("initclip", p);}
void lineto (vector<double> &p) override {print("lineto", p);}
void moveto (vector<double> &p) override {print("moveto", p);}
@@ -52,6 +53,7 @@ class PSTestActions : public PSActions {
void save(std::vector<double> &p) override {print("save", p);}
void scale (vector<double> &p) override {print("scale", p);}
void setblendmode (vector<double> &p) override {print("setblendmode", p);}
+ void setcolorspace (vector<double> &p) override {print("setcolorspace", p);}
void setcmykcolor (vector<double> &p) override {print("setcmykcolor", p);}
void setdash (vector<double> &p) override {print("setdash", p);}
void setgray (vector<double> &p) override {print("setgray", p);}
@@ -102,7 +104,7 @@ TEST(PSInterpreterTest, gsave_grestore) {
actions.clear();
psi.execute("grestore ");
- EXPECT_EQ(actions.result(), "setmatrix 1 0 0 1 0 0;applyscalevals 1 1 1;setlinewidth 1;setlinecap 0;setlinejoin 0;setmiterlimit 10;setrgbcolor 0 0 0;setdash 0;grestore;");
+ EXPECT_EQ(actions.result(), "setmatrix 1 0 0 1 0 0;applyscalevals 1 1 1;setlinewidth 1;setlinecap 0;setlinejoin 0;setmiterlimit 10;setcolorspace 0;setrgbcolor 0 0 0;setdash 0;grestore;");
actions.clear();
psi.execute("1 setlinecap 5 setmiterlimit 0 1 0 setrgbcolor gsave 0 setlinecap 10 setmiterlimit ");
@@ -110,7 +112,7 @@ TEST(PSInterpreterTest, gsave_grestore) {
actions.clear();
psi.execute("grestore ");
- EXPECT_EQ(actions.result(), "setmatrix 1 0 0 1 0 0;applyscalevals 1 1 1;setlinewidth 1;setlinecap 1;setlinejoin 0;setmiterlimit 5;setrgbcolor 0 1 0;setdash 0;grestore;");
+ EXPECT_EQ(actions.result(), "setmatrix 1 0 0 1 0 0;applyscalevals 1 1 1;setlinewidth 1;setlinecap 1;setlinejoin 0;setmiterlimit 5;setcolorspace 0;setrgbcolor 0 1 0;setdash 0;grestore;");
}
@@ -118,11 +120,11 @@ TEST(PSInterpreterTest, stroke_fill) {
PSTestActions actions;
PSInterpreter psi(&actions);
psi.execute("0 0 moveto 10 10 lineto 0 10 lineto closepath stroke ");
- EXPECT_EQ(actions.result(), "setrgbcolor 0 0 0;newpath 0;moveto 0 0;lineto 10 10;lineto 0 10;closepath;stroke;");
+ EXPECT_EQ(actions.result(), "setcolorspace 0;setrgbcolor 0 0 0;newpath 0;moveto 0 0;lineto 10 10;lineto 0 10;closepath;stroke;");
actions.clear();
psi.execute("0 0 moveto 10 10 lineto 0 10 lineto closepath fill ");
- EXPECT_EQ(actions.result(), "setrgbcolor 0 0 0;newpath 0;moveto 0 0;lineto 10 10;lineto 0 10;closepath;fill;");
+ EXPECT_EQ(actions.result(), "setcolorspace 0;setrgbcolor 0 0 0;newpath 0;moveto 0 0;lineto 10 10;lineto 0 10;closepath;fill;");
}
diff --git a/dviware/dvisvgm/tests/PageRagesTest.cpp b/dviware/dvisvgm/tests/PageRagesTest.cpp
index 7be21c6e40..60b6eb77ab 100644
--- a/dviware/dvisvgm/tests/PageRagesTest.cpp
+++ b/dviware/dvisvgm/tests/PageRagesTest.cpp
@@ -2,7 +2,7 @@
** PageRagesTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/PageSizeTest.cpp b/dviware/dvisvgm/tests/PageSizeTest.cpp
index 9b7aa2c2dc..be9a25ec16 100644
--- a/dviware/dvisvgm/tests/PageSizeTest.cpp
+++ b/dviware/dvisvgm/tests/PageSizeTest.cpp
@@ -2,7 +2,7 @@
** PageSizeTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/PairTest.cpp b/dviware/dvisvgm/tests/PairTest.cpp
index 5e6d6a1e2b..bbff66b2f7 100644
--- a/dviware/dvisvgm/tests/PairTest.cpp
+++ b/dviware/dvisvgm/tests/PairTest.cpp
@@ -2,7 +2,7 @@
** PairTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/PapersizeSpecialTest.cpp b/dviware/dvisvgm/tests/PapersizeSpecialTest.cpp
index 9960af3906..a4a155e8bc 100644
--- a/dviware/dvisvgm/tests/PapersizeSpecialTest.cpp
+++ b/dviware/dvisvgm/tests/PapersizeSpecialTest.cpp
@@ -2,7 +2,7 @@
** PapersizeSpecialTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/RangeMapTest.cpp b/dviware/dvisvgm/tests/RangeMapTest.cpp
index 63f31ff1bb..1d9f46b82f 100644
--- a/dviware/dvisvgm/tests/RangeMapTest.cpp
+++ b/dviware/dvisvgm/tests/RangeMapTest.cpp
@@ -2,7 +2,7 @@
** RangeMapTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/SVGOutputTest.cpp b/dviware/dvisvgm/tests/SVGOutputTest.cpp
index 60e3beefd9..a20dfd63cb 100644
--- a/dviware/dvisvgm/tests/SVGOutputTest.cpp
+++ b/dviware/dvisvgm/tests/SVGOutputTest.cpp
@@ -2,7 +2,7 @@
** SVGOutputTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/ShadingPatchTest.cpp b/dviware/dvisvgm/tests/ShadingPatchTest.cpp
index 17eefc287f..3cf6b1096b 100644
--- a/dviware/dvisvgm/tests/ShadingPatchTest.cpp
+++ b/dviware/dvisvgm/tests/ShadingPatchTest.cpp
@@ -2,7 +2,7 @@
** ShadingPatchTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/SpecialManagerTest.cpp b/dviware/dvisvgm/tests/SpecialManagerTest.cpp
index 38635634af..156dd14f2f 100644
--- a/dviware/dvisvgm/tests/SpecialManagerTest.cpp
+++ b/dviware/dvisvgm/tests/SpecialManagerTest.cpp
@@ -2,7 +2,7 @@
** SpecialManagerTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/SplittedCharInputBufferTest.cpp b/dviware/dvisvgm/tests/SplittedCharInputBufferTest.cpp
index c29a33c15a..6ca61d53ed 100644
--- a/dviware/dvisvgm/tests/SplittedCharInputBufferTest.cpp
+++ b/dviware/dvisvgm/tests/SplittedCharInputBufferTest.cpp
@@ -2,7 +2,7 @@
** SplittedCharInputBufferTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/StreamInputBufferTest.cpp b/dviware/dvisvgm/tests/StreamInputBufferTest.cpp
index e5bf646ec9..10124341e8 100644
--- a/dviware/dvisvgm/tests/StreamInputBufferTest.cpp
+++ b/dviware/dvisvgm/tests/StreamInputBufferTest.cpp
@@ -2,7 +2,7 @@
** StreamInputBufferTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/StreamReaderTest.cpp b/dviware/dvisvgm/tests/StreamReaderTest.cpp
index e769ab0f44..864efab3b4 100644
--- a/dviware/dvisvgm/tests/StreamReaderTest.cpp
+++ b/dviware/dvisvgm/tests/StreamReaderTest.cpp
@@ -2,7 +2,7 @@
** StreamReaderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/StreamWriterTest.cpp b/dviware/dvisvgm/tests/StreamWriterTest.cpp
index aa2cadb9c9..05d5da2e3f 100644
--- a/dviware/dvisvgm/tests/StreamWriterTest.cpp
+++ b/dviware/dvisvgm/tests/StreamWriterTest.cpp
@@ -2,7 +2,7 @@
** StreamWriterTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/StringMatcherTest.cpp b/dviware/dvisvgm/tests/StringMatcherTest.cpp
index df2bb81cdb..89ee78fa8b 100644
--- a/dviware/dvisvgm/tests/StringMatcherTest.cpp
+++ b/dviware/dvisvgm/tests/StringMatcherTest.cpp
@@ -2,7 +2,7 @@
** StringMatcherTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/SubfontTest.cpp b/dviware/dvisvgm/tests/SubfontTest.cpp
index c3a6c2466f..609a0efe99 100644
--- a/dviware/dvisvgm/tests/SubfontTest.cpp
+++ b/dviware/dvisvgm/tests/SubfontTest.cpp
@@ -2,7 +2,7 @@
** SubfontTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/TFMReaderTest.cpp b/dviware/dvisvgm/tests/TFMReaderTest.cpp
index ce950e92fe..fa701f036d 100644
--- a/dviware/dvisvgm/tests/TFMReaderTest.cpp
+++ b/dviware/dvisvgm/tests/TFMReaderTest.cpp
@@ -2,7 +2,7 @@
** TFMReaderTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/TensorProductPatchTest.cpp b/dviware/dvisvgm/tests/TensorProductPatchTest.cpp
index a051f7d70d..576ce581a8 100644
--- a/dviware/dvisvgm/tests/TensorProductPatchTest.cpp
+++ b/dviware/dvisvgm/tests/TensorProductPatchTest.cpp
@@ -2,7 +2,7 @@
** TensorProductPatchTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/ToUnicodeMapTest.cpp b/dviware/dvisvgm/tests/ToUnicodeMapTest.cpp
index 1aea8b9b87..a0a5ee9868 100644
--- a/dviware/dvisvgm/tests/ToUnicodeMapTest.cpp
+++ b/dviware/dvisvgm/tests/ToUnicodeMapTest.cpp
@@ -2,7 +2,7 @@
** ToUnicodeMapTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/TpicSpecialTest.cpp b/dviware/dvisvgm/tests/TpicSpecialTest.cpp
index afc92d54be..9f88b13412 100644
--- a/dviware/dvisvgm/tests/TpicSpecialTest.cpp
+++ b/dviware/dvisvgm/tests/TpicSpecialTest.cpp
@@ -2,7 +2,7 @@
** TpicSpecialTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/TriangularPatchTest.cpp b/dviware/dvisvgm/tests/TriangularPatchTest.cpp
index 07c8819e2c..86ef13fb36 100644
--- a/dviware/dvisvgm/tests/TriangularPatchTest.cpp
+++ b/dviware/dvisvgm/tests/TriangularPatchTest.cpp
@@ -2,7 +2,7 @@
** TriangularPatchTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/UnicodeTest.cpp b/dviware/dvisvgm/tests/UnicodeTest.cpp
index 11a0b2fac1..dc4e77d165 100644
--- a/dviware/dvisvgm/tests/UnicodeTest.cpp
+++ b/dviware/dvisvgm/tests/UnicodeTest.cpp
@@ -2,7 +2,7 @@
** UnicodeTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/UtilityTest.cpp b/dviware/dvisvgm/tests/UtilityTest.cpp
index 2faa4c2a96..4ca490379f 100644
--- a/dviware/dvisvgm/tests/UtilityTest.cpp
+++ b/dviware/dvisvgm/tests/UtilityTest.cpp
@@ -2,7 +2,7 @@
** UtilityTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/VectorIteratorTest.cpp b/dviware/dvisvgm/tests/VectorIteratorTest.cpp
index 0f705596e2..905a6fa743 100644
--- a/dviware/dvisvgm/tests/VectorIteratorTest.cpp
+++ b/dviware/dvisvgm/tests/VectorIteratorTest.cpp
@@ -2,7 +2,7 @@
** VectorIteratorTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/VectorStreamTest.cpp b/dviware/dvisvgm/tests/VectorStreamTest.cpp
index 4b0263185c..022b1c1fdc 100644
--- a/dviware/dvisvgm/tests/VectorStreamTest.cpp
+++ b/dviware/dvisvgm/tests/VectorStreamTest.cpp
@@ -2,7 +2,7 @@
** VectorStreamTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/XMLNodeTest.cpp b/dviware/dvisvgm/tests/XMLNodeTest.cpp
index eb3a37c434..8108d88db8 100644
--- a/dviware/dvisvgm/tests/XMLNodeTest.cpp
+++ b/dviware/dvisvgm/tests/XMLNodeTest.cpp
@@ -2,7 +2,7 @@
** XMLNodeTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/XMLStringTest.cpp b/dviware/dvisvgm/tests/XMLStringTest.cpp
index 1c74c03c4c..18c129c4cc 100644
--- a/dviware/dvisvgm/tests/XMLStringTest.cpp
+++ b/dviware/dvisvgm/tests/XMLStringTest.cpp
@@ -2,7 +2,7 @@
** XMLStringTest.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/check-conv b/dviware/dvisvgm/tests/check-conv
index a43800b9a4..f87496762c 100755
--- a/dviware/dvisvgm/tests/check-conv
+++ b/dviware/dvisvgm/tests/check-conv
@@ -2,7 +2,7 @@
# This file is part of the dvisvgm package and published under the
# terms of the GNU General Public License version 3 or later.
# See file COPYING for further details.
-# Copyright (C) 2009-2019 Martin Gieseking <martin.gieseking@uos.de>
+# Copyright (C) 2009-2020 Martin Gieseking <martin.gieseking@uos.de>
files=(sample frktest)
diff --git a/dviware/dvisvgm/tests/data/Makefile.am b/dviware/dvisvgm/tests/data/Makefile.am
index 27632f3299..55818cc0c6 100644
--- a/dviware/dvisvgm/tests/data/Makefile.am
+++ b/dviware/dvisvgm/tests/data/Makefile.am
@@ -1,5 +1,5 @@
## This file is part of dvisvgm
-## Copyright (C) 2016-2019 Martin Gieseking <martin.gieseking@uos.de>
+## Copyright (C) 2016-2020 Martin Gieseking <martin.gieseking@uos.de>
##
## Process this file with automake.
diff --git a/dviware/dvisvgm/tests/genhashcheck.py b/dviware/dvisvgm/tests/genhashcheck.py
index f7ac46c488..5f3495128c 100755
--- a/dviware/dvisvgm/tests/genhashcheck.py
+++ b/dviware/dvisvgm/tests/genhashcheck.py
@@ -2,7 +2,7 @@
# This file is part of the dvisvgm package and published under the
# terms of the GNU General Public License version 3 or later.
# See file COPYING for further details.
-# Copyright (C) 2016-2019 Martin Gieseking <martin.gieseking@uos.de>
+# Copyright (C) 2016-2020 Martin Gieseking <martin.gieseking@uos.de>
import re
import sys
diff --git a/dviware/dvisvgm/tests/normalize.xsl b/dviware/dvisvgm/tests/normalize.xsl
index cc568c3aec..2b39eba9f7 100644
--- a/dviware/dvisvgm/tests/normalize.xsl
+++ b/dviware/dvisvgm/tests/normalize.xsl
@@ -2,7 +2,7 @@
<!-- *********************************************************************
** Stylesheet to rearrange font-/path-elements in an SVG file. **
** It's part of the dvisvgm package. **
-** Copyright (C) 2009-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2009-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
diff --git a/dviware/dvisvgm/tests/testmain.cpp b/dviware/dvisvgm/tests/testmain.cpp
index 8336939079..ce75cb5664 100644
--- a/dviware/dvisvgm/tests/testmain.cpp
+++ b/dviware/dvisvgm/tests/testmain.cpp
@@ -2,7 +2,7 @@
** testmain.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **