CMakeLists.txt | 1 poppler/UTF.cc | 2 - poppler/UnicodeMapFuncs.cc | 88 +++++++++++++++++++++++++++++++++++++++++++++ poppler/UnicodeMapFuncs.h | 64 ++------------------------------ 4 files changed, 94 insertions(+), 61 deletions(-)
New commits: commit 00c1566e8cc0dacd899ec6dd267265f4b714eae4 Author: Albert Astals Cid <[email protected]> Date: Wed Jan 10 00:49:51 2018 +0100 UnicodeMapFuncs: Move implementation to .cpp With that the last warning i got on poppler core is gone \o/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 399260c1..5e3d6a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -378,6 +378,7 @@ set(poppler_SRCS poppler/StructTreeRoot.cc poppler/StructElement.cc poppler/UnicodeMap.cc + poppler/UnicodeMapFuncs.cc poppler/UnicodeTypeTable.cc poppler/UTF.cc poppler/XRef.cc diff --git a/poppler/UnicodeMapFuncs.cc b/poppler/UnicodeMapFuncs.cc new file mode 100644 index 00000000..3eb82d50 --- /dev/null +++ b/poppler/UnicodeMapFuncs.cc @@ -0,0 +1,88 @@ +//======================================================================== +// +// UnicodeMapFuncs.cc +// +// Copyright 2001-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2008 Koji Otani <[email protected]> +// Copyright (C) 2017 Adrian Johnson <[email protected]> +// Copyright (C) 2018 Albert Astals Cid <[email protected]> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include "UnicodeMapFuncs.h" + +int mapUTF8(Unicode u, char *buf, int bufSize) { + if (u <= 0x0000007f) { + if (bufSize < 1) { + return 0; + } + buf[0] = (char)u; + return 1; + } else if (u <= 0x000007ff) { + if (bufSize < 2) { + return 0; + } + buf[0] = (char)(0xc0 + (u >> 6)); + buf[1] = (char)(0x80 + (u & 0x3f)); + return 2; + } else if (u <= 0x0000ffff) { + if (bufSize < 3) { + return 0; + } + buf[0] = (char)(0xe0 + (u >> 12)); + buf[1] = (char)(0x80 + ((u >> 6) & 0x3f)); + buf[2] = (char)(0x80 + (u & 0x3f)); + return 3; + } else if (u <= 0x0010ffff) { + if (bufSize < 4) { + return 0; + } + buf[0] = (char)(0xf0 + (u >> 18)); + buf[1] = (char)(0x80 + ((u >> 12) & 0x3f)); + buf[2] = (char)(0x80 + ((u >> 6) & 0x3f)); + buf[3] = (char)(0x80 + (u & 0x3f)); + return 4; + } else { + return 0; + } +} + +int mapUTF16(Unicode u, char *buf, int bufSize) { + if (u <= 0xffff) { + if (bufSize < 2) { + return 0; + } + buf[0] = (char)((u >> 8) & 0xff); + buf[1] = (char)(u & 0xff); + return 2; + } else if (u < 0x110000) { + Unicode uu; + + /* using surrogate pair */ + if (bufSize < 4) { + return 0; + } + uu = ((u - 0x10000) >> 10) + 0xd800; + buf[0] = (char)((uu >> 8) & 0xff); + buf[1] = (char)(uu & 0xff); + uu = (u & 0x3ff)+0xdc00; + buf[2] = (char)((uu >> 8) & 0xff); + buf[3] = (char)(uu & 0xff); + return 4; + } else { + return 0; + } +} diff --git a/poppler/UnicodeMapFuncs.h b/poppler/UnicodeMapFuncs.h index b89ee6eb..61336396 100644 --- a/poppler/UnicodeMapFuncs.h +++ b/poppler/UnicodeMapFuncs.h @@ -15,71 +15,15 @@ // // Copyright (C) 2008 Koji Otani <[email protected]> // Copyright (C) 2017 Adrian Johnson <[email protected]> +// Copyright (C) 2018 Albert Astals Cid <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git // //======================================================================== -static int mapUTF8(Unicode u, char *buf, int bufSize) { - if (u <= 0x0000007f) { - if (bufSize < 1) { - return 0; - } - buf[0] = (char)u; - return 1; - } else if (u <= 0x000007ff) { - if (bufSize < 2) { - return 0; - } - buf[0] = (char)(0xc0 + (u >> 6)); - buf[1] = (char)(0x80 + (u & 0x3f)); - return 2; - } else if (u <= 0x0000ffff) { - if (bufSize < 3) { - return 0; - } - buf[0] = (char)(0xe0 + (u >> 12)); - buf[1] = (char)(0x80 + ((u >> 6) & 0x3f)); - buf[2] = (char)(0x80 + (u & 0x3f)); - return 3; - } else if (u <= 0x0010ffff) { - if (bufSize < 4) { - return 0; - } - buf[0] = (char)(0xf0 + (u >> 18)); - buf[1] = (char)(0x80 + ((u >> 12) & 0x3f)); - buf[2] = (char)(0x80 + ((u >> 6) & 0x3f)); - buf[3] = (char)(0x80 + (u & 0x3f)); - return 4; - } else { - return 0; - } -} +#include "UTF.h" -static int mapUTF16(Unicode u, char *buf, int bufSize) { - if (u <= 0xffff) { - if (bufSize < 2) { - return 0; - } - buf[0] = (char)((u >> 8) & 0xff); - buf[1] = (char)(u & 0xff); - return 2; - } else if (u < 0x110000) { - Unicode uu; +int mapUTF8(Unicode u, char *buf, int bufSize); - /* using surrogate pair */ - if (bufSize < 4) { - return 0; - } - uu = ((u - 0x10000) >> 10) + 0xd800; - buf[0] = (char)((uu >> 8) & 0xff); - buf[1] = (char)(uu & 0xff); - uu = (u & 0x3ff)+0xdc00; - buf[2] = (char)((uu >> 8) & 0xff); - buf[3] = (char)(uu & 0xff); - return 4; - } else { - return 0; - } -} +int mapUTF16(Unicode u, char *buf, int bufSize); commit bf6d79b5c6b5bdcc0d79b4eebd85840e8f2e30ef Author: Albert Astals Cid <[email protected]> Date: Wed Jan 10 00:49:33 2018 +0100 Forgot C for last commit diff --git a/poppler/UTF.cc b/poppler/UTF.cc index c00ddc51..da2faad1 100644 --- a/poppler/UTF.cc +++ b/poppler/UTF.cc @@ -16,7 +16,7 @@ // Copyright (C) 2008 Koji Otani <[email protected]> // Copyright (C) 2012, 2017 Adrian Johnson <[email protected]> // Copyright (C) 2012 Hib Eris <[email protected]> -// Copyright (C) 2016 Albert Astals Cid <[email protected]> +// Copyright (C) 2016, 2018 Albert Astals Cid <[email protected]> // Copyright (C) 2016 Jason Crain <[email protected]> // // To see a description of the changes please see the Changelog file that _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
