diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-14 21:08:43 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-14 21:08:43 -0500 |
commit | 1d30f6fa8413746ddc408f93710d701493af273d (patch) | |
tree | abe84e83d704e13c60c90db7ac4b9e363d8a81fc /gfx/ots/include | |
parent | 9308ec68e863e4c6e650680370a5d7baa9f0d1f3 (diff) | |
parent | 00573571a226a0c59dd744da67483864a22911aa (diff) | |
download | UXP-1d30f6fa8413746ddc408f93710d701493af273d.tar UXP-1d30f6fa8413746ddc408f93710d701493af273d.tar.gz UXP-1d30f6fa8413746ddc408f93710d701493af273d.tar.lz UXP-1d30f6fa8413746ddc408f93710d701493af273d.tar.xz UXP-1d30f6fa8413746ddc408f93710d701493af273d.zip |
Merge branch 'master' into mailnews-work
Diffstat (limited to 'gfx/ots/include')
-rw-r--r-- | gfx/ots/include/opentype-sanitiser.h | 36 | ||||
-rw-r--r-- | gfx/ots/include/ots-memory-stream.h | 2 |
2 files changed, 21 insertions, 17 deletions
diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-sanitiser.h index 87d0f3d28..52cbd3aee 100644 --- a/gfx/ots/include/opentype-sanitiser.h +++ b/gfx/ots/include/opentype-sanitiser.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2009-2017 The OTS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -35,13 +35,17 @@ typedef int int32_t; typedef unsigned int uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; -#define ntohl(x) _byteswap_ulong (x) -#define ntohs(x) _byteswap_ushort (x) -#define htonl(x) _byteswap_ulong (x) -#define htons(x) _byteswap_ushort (x) +#define ots_ntohl(x) _byteswap_ulong (x) +#define ots_ntohs(x) _byteswap_ushort (x) +#define ots_htonl(x) _byteswap_ulong (x) +#define ots_htons(x) _byteswap_ushort (x) #else #include <arpa/inet.h> #include <stdint.h> +#define ots_ntohl(x) ntohl (x) +#define ots_ntohs(x) ntohs (x) +#define ots_htonl(x) htonl (x) +#define ots_htons(x) htons (x) #endif #include <sys/types.h> @@ -52,7 +56,7 @@ typedef unsigned __int64 uint64_t; #include <cstring> #define OTS_TAG(c1,c2,c3,c4) ((uint32_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4)))) -#define OTS_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag)) +#define OTS_UNTAG(tag) ((char)((tag)>>24)), ((char)((tag)>>16)), ((char)((tag)>>8)), ((char)(tag)) namespace ots { @@ -80,7 +84,7 @@ class OTSStream { const size_t l = std::min(length, static_cast<size_t>(4) - chksum_offset); uint32_t tmp = 0; std::memcpy(reinterpret_cast<uint8_t *>(&tmp) + chksum_offset, data, l); - chksum_ += ntohl(tmp); + chksum_ += ots_ntohl(tmp); length -= l; offset += l; } @@ -89,7 +93,7 @@ class OTSStream { uint32_t tmp; std::memcpy(&tmp, reinterpret_cast<const uint8_t *>(data) + offset, sizeof(uint32_t)); - chksum_ += ntohl(tmp); + chksum_ += ots_ntohl(tmp); length -= 4; offset += 4; } @@ -99,7 +103,7 @@ class OTSStream { uint32_t tmp = 0; std::memcpy(&tmp, reinterpret_cast<const uint8_t*>(data) + offset, length); - chksum_ += ntohl(tmp); + chksum_ += ots_ntohl(tmp); } return WriteRaw(data, orig_length); @@ -127,27 +131,27 @@ class OTSStream { } bool WriteU16(uint16_t v) { - v = htons(v); + v = ots_htons(v); return Write(&v, sizeof(v)); } bool WriteS16(int16_t v) { - v = htons(v); + v = ots_htons(v); return Write(&v, sizeof(v)); } bool WriteU24(uint32_t v) { - v = htonl(v); + v = ots_htonl(v); return Write(reinterpret_cast<uint8_t*>(&v)+1, 3); } bool WriteU32(uint32_t v) { - v = htonl(v); + v = ots_htonl(v); return Write(&v, sizeof(v)); } bool WriteS32(int32_t v) { - v = htonl(v); + v = ots_htonl(v); return Write(&v, sizeof(v)); } @@ -176,7 +180,7 @@ class OTSStream { enum TableAction { TABLE_ACTION_DEFAULT, // Use OTS's default action for that table - TABLE_ACTION_SANITIZE, // Sanitize the table, potentially droping it + TABLE_ACTION_SANITIZE, // Sanitize the table, potentially dropping it TABLE_ACTION_PASSTHRU, // Serialize the table unchanged TABLE_ACTION_DROP // Drop the table }; @@ -186,7 +190,7 @@ class OTS_API OTSContext { OTSContext() {} virtual ~OTSContext() {} - // Process a given OpenType file and write out a sanitised version + // Process a given OpenType file and write out a sanitized version // output: a pointer to an object implementing the OTSStream interface. The // sanitisied output will be written to this. In the even of a failure, // partial output may have been written. diff --git a/gfx/ots/include/ots-memory-stream.h b/gfx/ots/include/ots-memory-stream.h index 579da616f..cd5b089fa 100644 --- a/gfx/ots/include/ots-memory-stream.h +++ b/gfx/ots/include/ots-memory-stream.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2009-2017 The OTS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. |