summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2023-02-02 09:08:39 +0000
committerKen Sharp <ken.sharp@artifex.com>2023-02-04 11:17:15 +0000
commit401fc37d34b1cc31e4b014b8d5b848f2a8af1137 (patch)
tree6bfc5f7f6ce009c30b93536e63ce6eb754c4f6cb /pdf
parentc73d2f85e1de3fc1fbab25ac528da0a81d39d40b (diff)
downloadghostpdl-401fc37d34b1cc31e4b014b8d5b848f2a8af1137.tar.gz
GhotsPDF - make ishex and fromhex inline functions and expose them
We're using ishex in pdf_int.c and pdf_fontps.c, best if we only have one definition. Make them inline for performance (as was done in pdf_fontps.c and should have been in pdf_int.c)
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_fontps.c26
-rw-r--r--pdf/pdf_int.c34
-rw-r--r--pdf/pdf_int.h36
3 files changed, 36 insertions, 60 deletions
diff --git a/pdf/pdf_fontps.c b/pdf/pdf_fontps.c
index 5cfa16521..f8e0fe82b 100644
--- a/pdf/pdf_fontps.c
+++ b/pdf/pdf_fontps.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020-2022 Artifex Software, Inc.
+/* Copyright (C) 2020-2023 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -117,30 +117,6 @@ pdf_ps_end_number_object(int c)
return (c != '.' && c != 'e' && c != '-' && (c < '0' || c > '9'));
}
-static inline bool
-ishex(char c)
-{
- if (c < 0x30)
- return false;
-
- if (c > 0x39) {
- if (c > 'F') {
- if (c < 'a')
- return false;
- if (c > 'f')
- return false;
- return true;
- }
- else {
- if (c < 'A')
- return false;
- return true;
- }
- }
- else
- return true;
-}
-
static inline int
decodehex(char c)
{
diff --git a/pdf/pdf_int.c b/pdf/pdf_int.c
index dc8a76292..ba2dde339 100644
--- a/pdf/pdf_int.c
+++ b/pdf/pdf_int.c
@@ -68,40 +68,6 @@ static bool isdelimiter(char c)
return false;
}
-static bool ishex(char c)
-{
- if (c < 0x30)
- return false;
-
- if (c > 0x39) {
- if (c > 'F') {
- if (c < 'a')
- return false;
- if (c > 'f')
- return false;
- return true;
- } else {
- if (c < 'A')
- return false;
- return true;
- }
- } else
- return true;
-}
-
-/* You must ensure the character is a hex character before calling this, no error trapping here */
-static int fromhex(char c)
-{
- if (c > 0x39) {
- if (c > 'F') {
- return c - 0x57;
- } else {
- return c - 0x37;
- }
- } else
- return c - 0x30;
-}
-
/* The 'read' functions all return the newly created object on the context's stack
* which means these objects are created with a reference count of 0, and only when
* pushed onto the stack does the reference count become 1, indicating the stack is
diff --git a/pdf/pdf_int.h b/pdf/pdf_int.h
index 4cf1dcb64..bbd1c8db7 100644
--- a/pdf/pdf_int.h
+++ b/pdf/pdf_int.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018-2022 Artifex Software, Inc.
+/* Copyright (C) 2018-2023 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -20,6 +20,40 @@
#include "pdf_types.h"
+static inline bool ishex(char c)
+{
+ if (c < 0x30)
+ return false;
+
+ if (c > 0x39) {
+ if (c > 'F') {
+ if (c < 'a')
+ return false;
+ if (c > 'f')
+ return false;
+ return true;
+ } else {
+ if (c < 'A')
+ return false;
+ return true;
+ }
+ } else
+ return true;
+}
+
+/* You must ensure the character is a hex character before calling this, no error trapping here */
+static inline int fromhex(char c)
+{
+ if (c > 0x39) {
+ if (c > 'F') {
+ return c - 0x57;
+ } else {
+ return c - 0x37;
+ }
+ } else
+ return c - 0x30;
+}
+
int pdfi_skip_white(pdf_context *ctx, pdf_c_stream *s);
int pdfi_skip_eol(pdf_context *ctx, pdf_c_stream *s);
int pdfi_skip_comment(pdf_context *ctx, pdf_c_stream *s);