diff options
author | Karl Berry <karl@freefriends.org> | 2012-10-26 21:36:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-10-26 21:36:14 +0000 |
commit | 4147899f17a6e0b0dde20f309845c4fc0032bce9 (patch) | |
tree | 3609a0dc99736d7a2081187b9e12e9bac63c6bb6 /Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots.lua | |
parent | 3d12d871ae8a0e941fb2521bdc99ce436aeb17c6 (diff) |
pgfplots (26oct12)
git-svn-id: svn://tug.org/texlive/trunk@28094 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots.lua')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots.lua new file mode 100644 index 00000000000..8242222e8d6 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots.lua @@ -0,0 +1,30 @@ + +pgfplotsGetLuaBinaryStringFromCharIndicesChunkSize = 7000; + +-- Takes a table containing an arbitrary number of integers in the range 0..255 and converts it +-- into a binary stream of the corresponding binary chars. +-- +-- @param charIndices a table containing 0...N arguments; each in the range 0..255 +-- +-- @return a string containing binary content, one byte for each input integer. +function pgfplotsGetLuaBinaryStringFromCharIndices(charIndices) + -- unpack extracts only the indices (we can't provide a table to string.char). + -- note that pdf.immediateobj has been designed to avoid sanity checking for invalid UTF strings - + -- in other words: it accepts binary strings. + -- + -- unfortunately, this here fails for huge input tables: + -- pgfplotsretval=string.char(unpack(charIndices)); + -- we have to create it incrementally using chunks: + local len = #charIndices; + local chunkSize = pgfplotsGetLuaBinaryStringFromCharIndicesChunkSize; + local buf = {}; + -- ok, append all full chunks of chunkSize first: + local numFullChunks = math.floor(len/chunkSize); + for i = 0, numFullChunks-1, 1 do + table.insert(buf, string.char(unpack(charIndices, 1+i*chunkSize, (i+1)*chunkSize))); + end + -- append the rest: + table.insert(buf, string.char(unpack(charIndices, 1+numFullChunks*chunkSize))); + return table.concat(buf); +end + |