From 768cb33c4760bc65c6a854b2acaeb16a3971f4fb Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Wed, 29 Sep 2021 11:05:40 -0400
Subject: [PATCH 01/15] Bump NuGet versions.
---
pdfio_native.nuspec | 4 ++--
pdfio_native.redist.nuspec | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pdfio_native.nuspec b/pdfio_native.nuspec
index 7bf9655..3af4526 100644
--- a/pdfio_native.nuspec
+++ b/pdfio_native.nuspec
@@ -3,7 +3,7 @@
pdfio_native
PDFio Library for VS2019+
- 1.0.0-b4
+ 1.0.0-b5
Michael R Sweet
michaelrsweet
https://github.com/michaelrsweet/pappl
@@ -16,7 +16,7 @@
Copyright © 2019-2021 by Michael R Sweet
pdf file native
-
+
diff --git a/pdfio_native.redist.nuspec b/pdfio_native.redist.nuspec
index ef184e1..2b617e3 100644
--- a/pdfio_native.redist.nuspec
+++ b/pdfio_native.redist.nuspec
@@ -3,7 +3,7 @@
pdfio_native
PDFio Library for VS2019+
- 1.0.0-b4
+ 1.0.0-b5
Michael R Sweet
michaelrsweet
https://github.com/michaelrsweet/pappl
From 85bfab49ab258fe5509397a68d1b8b991713eee8 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Wed, 29 Sep 2021 11:48:50 -0400
Subject: [PATCH 02/15] Fix pdfio_native.redist package name.
---
pdfio_native.nuspec | 4 ++--
pdfio_native.redist.nuspec | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pdfio_native.nuspec b/pdfio_native.nuspec
index 3af4526..117e8ac 100644
--- a/pdfio_native.nuspec
+++ b/pdfio_native.nuspec
@@ -3,7 +3,7 @@
pdfio_native
PDFio Library for VS2019+
- 1.0.0-b5
+ 1.0.0-b6
Michael R Sweet
michaelrsweet
https://github.com/michaelrsweet/pappl
@@ -16,7 +16,7 @@
Copyright © 2019-2021 by Michael R Sweet
pdf file native
-
+
diff --git a/pdfio_native.redist.nuspec b/pdfio_native.redist.nuspec
index 2b617e3..c8f4133 100644
--- a/pdfio_native.redist.nuspec
+++ b/pdfio_native.redist.nuspec
@@ -1,9 +1,9 @@
- pdfio_native
+ pdfio_native.redist
PDFio Library for VS2019+
- 1.0.0-b5
+ 1.0.0-b6
Michael R Sweet
michaelrsweet
https://github.com/michaelrsweet/pappl
From d1e8c966ed38ac00c06c2d4398db3067a1235c1b Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Fri, 1 Oct 2021 11:38:04 -0400
Subject: [PATCH 03/15] Fix some Coverity-detected issues.
---
CHANGES.md | 1 +
pdfio-array.c | 3 ++-
pdfio-content.c | 2 +-
pdfio-file.c | 6 +++++-
pdfio-value.c | 2 ++
ttf.c | 3 ++-
6 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 0f62462..7023a4c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@ v1.0.0 (TBD)
- Added `pdfioFileCreateOutput` API to support streaming output of PDF
(Issue #21)
+- Fixed some issues identified by a Coverity scan.
v1.0b1 (August 30, 2021)
diff --git a/pdfio-array.c b/pdfio-array.c
index 088ba8c..defe3f7 100644
--- a/pdfio-array.c
+++ b/pdfio-array.c
@@ -568,7 +568,8 @@ _pdfioArrayRead(pdfio_file_t *pdf, // I - PDF file
PDFIO_DEBUG("_pdfioArrayRead(pdf=%p, tb=%p)\n", pdf, tb);
// Create an array...
- array = pdfioArrayCreate(pdf);
+ if ((array = pdfioArrayCreate(pdf)) == NULL)
+ return (NULL);
// Read until we get "]" to end the array...
while (_pdfioTokenGet(tb, token, sizeof(token)))
diff --git a/pdfio-content.c b/pdfio-content.c
index 6c7ff14..c020960 100644
--- a/pdfio-content.c
+++ b/pdfio-content.c
@@ -2358,7 +2358,7 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary
PDFIO_DEBUG("copy_png: Adding %s ColorSpace value.\n", color_type == _PDFIO_PNG_TYPE_GRAY ? "CalGray" : "CalRGB");
if (wx != 0.0)
- pdfioDictSetArray(dict, "ColorSpace", pdfioArrayCreateColorFromPrimaries(dict->pdf, color_type == _PDFIO_PNG_TYPE_GRAY ? 1 : 3, gamma, wx, wy, rx, ry, bx, by, gx, gy));
+ pdfioDictSetArray(dict, "ColorSpace", pdfioArrayCreateColorFromPrimaries(dict->pdf, color_type == _PDFIO_PNG_TYPE_GRAY ? 1 : 3, gamma, wx, wy, rx, ry, gx, gy, bx, by));
else
pdfioDictSetArray(dict, "ColorSpace", pdfioArrayCreateColorFromStandard(dict->pdf, color_type == _PDFIO_PNG_TYPE_GRAY ? 1 : 3, PDFIO_CS_SRGB));
}
diff --git a/pdfio-file.c b/pdfio-file.c
index 45aaf8a..0dc9adb 100644
--- a/pdfio-file.c
+++ b/pdfio-file.c
@@ -1388,7 +1388,11 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
return (false);
}
- _pdfioFileSeek(pdf, xref_offset + ptr + 3 - line, SEEK_SET);
+ if (_pdfioFileSeek(pdf, xref_offset + ptr + 3 - line, SEEK_SET) < 0)
+ {
+ _pdfioFileError(pdf, "Unable to seek to xref object %lu %u.", (unsigned long)number, (unsigned)generation);
+ return (false);
+ }
PDFIO_DEBUG("load_xref: Loading object %lu %u.\n", (unsigned long)number, (unsigned)generation);
diff --git a/pdfio-value.c b/pdfio-value.c
index f896c3f..784aa61 100644
--- a/pdfio-value.c
+++ b/pdfio-value.c
@@ -278,6 +278,8 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file
else
{
// Date value...
+ memset(&dateval, 0, sizeof(dateval));
+
dateval.tm_year = (token[3] - '0') * 1000 + (token[4] - '0') * 100 + (token[5] - '0') * 10 + token[6] - '0' - 1900;
dateval.tm_mon = (token[7] - '0') * 10 + token[8] - '0' - 1;
dateval.tm_mday = (token[9] - '0') * 10 + token[10] - '0';
diff --git a/ttf.c b/ttf.c
index 6279697..0517565 100644
--- a/ttf.c
+++ b/ttf.c
@@ -513,7 +513,8 @@ ttfDelete(ttf_t *font) // I - Font
return;
// Close the font file...
- close(font->fd);
+ if (font->fd >= 0)
+ close(font->fd);
// Free all memory used...
free(font->copyright);
From 00fb962e84258629a7eacfb3d221b0a460886582 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:08:07 -0400
Subject: [PATCH 04/15] Add prototype coverity Github Actions integration.
---
.github/workflows/coverity.yml | 38 ++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 .github/workflows/coverity.yml
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
new file mode 100644
index 0000000..2d4f78a
--- /dev/null
+++ b/.github/workflows/coverity.yml
@@ -0,0 +1,38 @@
+name: Coverity Scan
+
+on: workflow_dispatch
+
+jobs:
+ latest:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: update build environment
+ run: sudo apt-get update --fix-missing -y
+ - name: install prerequisites
+ run: sudo apt-get install -y zlib1g-dev
+ - name: Download Coverity Build Tool
+ run: |
+ wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=michaelrsweet/pdfio" -O cov-analysis-linux64.tar.gz
+ mkdir cov-analysis-linux64
+ tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
+ env:
+ TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
+
+ - name: Build with cov-build
+ run: |
+ export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
+ cov-build --dir cov-int make
+ - name: Submit the result to Coverity Scan
+ run: |
+ tar czvf pdfio-cov.tgz cov-int
+ curl \
+ --form project=ruby \
+ --form token=$TOKEN \
+ --form email=michael.r.sweet@gmail.com \
+ --form file=@pdfio-cov.tgz \
+ --form version="Master" \
+ --form description="Snapshot" \
+ "https://scan.coverity.com/builds?project=michaelrsweet%2Fpdfio"
+ env:
+ TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
From 89d9a7c471e5b4a31ca1d71569c960782b3d0fcb Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:13:14 -0400
Subject: [PATCH 05/15] Add prototype coverity Github Actions integration.
---
.github/workflows/coverity.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 2d4f78a..5b6e847 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -13,7 +13,7 @@ jobs:
run: sudo apt-get install -y zlib1g-dev
- name: Download Coverity Build Tool
run: |
- wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=michaelrsweet/pdfio" -O cov-analysis-linux64.tar.gz
+ wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=michaelrsweet%2Fpdfio" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
From e67866e29d7fe122ad21c8f15d089871bf6ff4fb Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:17:49 -0400
Subject: [PATCH 06/15] Tweak coverity Github Actions.
---
.github/workflows/coverity.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 5b6e847..00ba54e 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -13,7 +13,7 @@ jobs:
run: sudo apt-get install -y zlib1g-dev
- name: Download Coverity Build Tool
run: |
- wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=michaelrsweet%2Fpdfio" -O cov-analysis-linux64.tar.gz
+ wget -q https://scan.coverity.com/download/linux64 --post-data "token=$TOKEN&project=michaelrsweet%2Fpdfio" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
From 3c702096b732e19308c51e4a90fefcc0efa20e70 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:19:58 -0400
Subject: [PATCH 07/15] Tweak coverity Github Actions.
---
.github/workflows/coverity.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 00ba54e..0352fd5 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -13,7 +13,7 @@ jobs:
run: sudo apt-get install -y zlib1g-dev
- name: Download Coverity Build Tool
run: |
- wget -q https://scan.coverity.com/download/linux64 --post-data "token=$TOKEN&project=michaelrsweet%2Fpdfio" -O cov-analysis-linux64.tar.gz
+ wget -q https://scan.coverity.com/download/linux64 --post-data token=$TOKEN&project=michaelrsweet\%2Fpdfio -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
From f23fd8de59d3ee9cdc24e81139afee722f9a3fa0 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:21:37 -0400
Subject: [PATCH 08/15] Tweak coverity Github Actions.
---
.github/workflows/coverity.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 0352fd5..778f5f5 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -13,7 +13,7 @@ jobs:
run: sudo apt-get install -y zlib1g-dev
- name: Download Coverity Build Tool
run: |
- wget -q https://scan.coverity.com/download/linux64 --post-data token=$TOKEN&project=michaelrsweet\%2Fpdfio -O cov-analysis-linux64.tar.gz
+ wget -q https://scan.coverity.com/download/linux64 --post-data token=$TOKEN\&project=michaelrsweet\%2Fpdfio -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
From 494924a78c6262c044f81f8b1ffea05c9fd40655 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:26:51 -0400
Subject: [PATCH 09/15] Tweak coverity Github Actions.
---
.github/workflows/coverity.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 778f5f5..0f8bf31 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -3,8 +3,9 @@ name: Coverity Scan
on: workflow_dispatch
jobs:
- latest:
+ coverity-scan:
runs-on: ubuntu-latest
+ environment: Coverity
steps:
- uses: actions/checkout@v2
- name: update build environment
From 835fbda363aa5e9c2f6e4bbe787b0f99f417cb96 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Tue, 5 Oct 2021 18:37:16 -0400
Subject: [PATCH 10/15] Tweak coverity Github Actions.
---
.github/workflows/coverity.yml | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 0f8bf31..e7e7972 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -14,7 +14,7 @@ jobs:
run: sudo apt-get install -y zlib1g-dev
- name: Download Coverity Build Tool
run: |
- wget -q https://scan.coverity.com/download/linux64 --post-data token=$TOKEN\&project=michaelrsweet\%2Fpdfio -O cov-analysis-linux64.tar.gz
+ wget -q https://scan.coverity.com/download/linux64 --post-data token="$TOKEN&project=$GITHUB_REPOSITORY" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
@@ -26,14 +26,13 @@ jobs:
cov-build --dir cov-int make
- name: Submit the result to Coverity Scan
run: |
- tar czvf pdfio-cov.tgz cov-int
+ tar czvf cov.tgz cov-int
curl \
- --form project=ruby \
--form token=$TOKEN \
--form email=michael.r.sweet@gmail.com \
- --form file=@pdfio-cov.tgz \
- --form version="Master" \
- --form description="Snapshot" \
- "https://scan.coverity.com/builds?project=michaelrsweet%2Fpdfio"
+ --form file=@cov.tgz \
+ --form version="$GITHUB_REF" \
+ --form description="$GITHUB_SHA" \
+ "https://scan.coverity.com/builds?project=$GITHUB_REPOSITORY"
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
From e0312545317ddde5edd71ac4752ab130547c8925 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Wed, 13 Oct 2021 17:15:59 -0400
Subject: [PATCH 11/15] Fix 'all-shared' target.
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 467b55a..c2adba2 100644
--- a/Makefile
+++ b/Makefile
@@ -69,8 +69,8 @@ all: $(TARGETS)
all-shared:
if test `uname` = Darwin; then \
$(MAKE) DSONAME="libpdfio.1.dylib" -$(MAKEFLAGS) all; \
- else
- $(MAKE) DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \
+ else \
+ $(MAKE) COMMONFLAGS="-g -Os -fPIC" DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \
fi
debug:
From f3689d6b3d85d12bb60b8897c5571b176df5c108 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Fri, 15 Oct 2021 19:32:08 -0400
Subject: [PATCH 12/15] Fix all-shared on Linux (Issue #22)
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index c2adba2..ff50bce 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,7 @@ libpdfio.a: $(LIBOBJS)
$(RANLIB) $@
libpdfio.so.1: $(LIBOBJS)
- $(CC) $(DSOFLAGS) $(COMMONFLAGS) -shared -o $@ -Wl,soname,$@ $(LIBOBJS) $(LIBS)
+ $(CC) $(DSOFLAGS) $(COMMONFLAGS) -shared -o $@ -Wl,-soname,$@ $(LIBOBJS) $(LIBS)
libpdfio.1.dylib: $(LIBOBJS)
$(CC) $(DSOFLAGS) $(COMMONFLAGS) -dynamiclib -o $@ -install_name $(prefix)/lib/$@ -current_version $(VERSION) -compatibility_version 1.0 $(LIBOBJS) $(LIBS)
From 095a4c10d4690d5f99f81cd159d1df2738b3e7c5 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Sat, 16 Oct 2021 00:02:31 -0400
Subject: [PATCH 13/15] Fix some memory leaks (Issue #23)
---
CHANGES.md | 4 +++-
Makefile | 3 +++
pdfio-array.c | 9 +++++++++
pdfio-stream.c | 2 ++
testpdfio.c | 26 +++++++++++++++++---------
5 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 7023a4c..0a89de8 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,10 +7,12 @@ v1.0.0 (TBD)
- Added `pdfioFileCreateOutput` API to support streaming output of PDF
(Issue #21)
+- Fixed `all-shared` target (Issue #22)
+- Fixed memory leaks (Issue #23)
- Fixed some issues identified by a Coverity scan.
v1.0b1 (August 30, 2021)
------------------------
-- Initial release
\ No newline at end of file
+- Initial release
diff --git a/Makefile b/Makefile
index ff50bce..816632d 100644
--- a/Makefile
+++ b/Makefile
@@ -118,6 +118,9 @@ install-shared:
test: testpdfio
./testpdfio
+valgrind: testpdfio
+ valgrind --leak-check=full ./testpdfio
+
# pdfio library
libpdfio.a: $(LIBOBJS)
diff --git a/pdfio-array.c b/pdfio-array.c
index defe3f7..336a08e 100644
--- a/pdfio-array.c
+++ b/pdfio-array.c
@@ -357,6 +357,15 @@ _pdfioArrayDebug(pdfio_array_t *a, // I - Array
void
_pdfioArrayDelete(pdfio_array_t *a) // I - Array
{
+ size_t i; // Looping var
+
+
+ for (i = 0; i < a->num_values; i ++)
+ {
+ if (a->values[i].type == PDFIO_VALTYPE_BINARY)
+ free(a->values[i].value.binary.data);
+ }
+
if (a)
free(a->values);
diff --git a/pdfio-stream.c b/pdfio-stream.c
index bd6f832..395abc7 100644
--- a/pdfio-stream.c
+++ b/pdfio-stream.c
@@ -80,6 +80,8 @@ pdfioStreamClose(pdfio_stream_t *st) // I - Stream
goto done;
}
}
+
+ deflateEnd(&st->flate);
}
// Save the length of this stream...
diff --git a/testpdfio.c b/testpdfio.c
index 42bbc70..4569cac 100644
--- a/testpdfio.c
+++ b/testpdfio.c
@@ -734,7 +734,7 @@ do_unit_tests(void)
puts("\n");
}
else
- return (1);
+ goto fail;
// Test the value parsers for edge cases...
fputs("_pdfioValueRead(cid_dict): ", stdout);
@@ -748,43 +748,51 @@ do_unit_tests(void)
puts("\n");
}
else
- return (1);
+ goto fail;
// Create a new PDF file...
fputs("pdfioFileCreate(\"testpdfio-out.pdf\", ...): ", stdout);
if ((outpdf = pdfioFileCreate("testpdfio-out.pdf", NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
puts("PASS");
else
- return (1);
+ goto fail;
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
- return (1);
+ goto fail;
if (read_unit_file("testpdfio-out.pdf", num_pages, first_image, false))
- return (1);
+ goto fail;
// Create a new PDF file...
if ((outfd = open("testpdfio-out2.pdf", O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0)
{
perror("Unable to open \"testpdfio-out2.pdf\"");
- return (1);
+ goto fail;
}
fputs("pdfioFileCreateOutput(...): ", stdout);
if ((outpdf = pdfioFileCreateOutput((pdfio_output_cb_t)output_cb, &outfd, NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
puts("PASS");
else
- return (1);
+ goto fail;
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
- return (1);
+ goto fail;
close(outfd);
if (read_unit_file("testpdfio-out2.pdf", num_pages, first_image, true))
- return (1);
+ goto fail;
+
+ pdfioFileClose(inpdf);
return (0);
+
+ fail:
+
+ pdfioFileClose(inpdf);
+
+ return (1);
}
From 22c245ffd11a6ed7d1eae940c6d44ea09f37d92e Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Sat, 16 Oct 2021 09:41:19 -0400
Subject: [PATCH 14/15] Update pdfioContentSetDashPattern to accept doubles
(Issue #25)
---
CHANGES.md | 1 +
pdfio-content.c | 8 ++++----
pdfio-content.h | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 0a89de8..2ed842c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,7 @@ v1.0.0 (TBD)
(Issue #21)
- Fixed `all-shared` target (Issue #22)
- Fixed memory leaks (Issue #23)
+- Updated `pdfioContentSetDashPattern` to accept `double` values (Issue #25)
- Fixed some issues identified by a Coverity scan.
diff --git a/pdfio-content.c b/pdfio-content.c
index c020960..0d27241 100644
--- a/pdfio-content.c
+++ b/pdfio-content.c
@@ -660,11 +660,11 @@ pdfioContentSave(pdfio_stream_t *st) // I - Stream
bool // O - `true` on success, `false` on failure
pdfioContentSetDashPattern(
pdfio_stream_t *st, // I - Stream
- int phase, // I - Phase (offset within pattern)
- int on, // I - On length
- int off) // I - Off length
+ double phase, // I - Phase (offset within pattern)
+ double on, // I - On length
+ double off) // I - Off length
{
- return (pdfioStreamPrintf(st, "[%d %d] %d d\n", on, off, phase));
+ return (pdfioStreamPrintf(st, "[%g %g] %g d\n", on, off, phase));
}
diff --git a/pdfio-content.h b/pdfio-content.h
index 004b620..412b62f 100644
--- a/pdfio-content.h
+++ b/pdfio-content.h
@@ -96,7 +96,7 @@ extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, double x, double y) _PDF
extern bool pdfioContentPathRect(pdfio_stream_t *st, double x, double y, double width, double height) _PDFIO_PUBLIC;
extern bool pdfioContentRestore(pdfio_stream_t *st) _PDFIO_PUBLIC;
extern bool pdfioContentSave(pdfio_stream_t *st) _PDFIO_PUBLIC;
-extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off) _PDFIO_PUBLIC;
+extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, double phase, double on, double off) _PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) _PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) _PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) _PDFIO_PUBLIC;
From af13376e6df25098cd8f4fbd44a4e4dec9dddde5 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Mon, 18 Oct 2021 23:08:13 -0400
Subject: [PATCH 15/15] Update docos.
---
doc/pdfio.3 | 12 ++++++------
doc/pdfio.html | 6 +++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/doc/pdfio.3 b/doc/pdfio.3
index af77926..25e7fc0 100644
--- a/doc/pdfio.3
+++ b/doc/pdfio.3
@@ -1,4 +1,4 @@
-.TH pdfio 3 "pdf read/write library" "2021-09-27" "pdf read/write library"
+.TH pdfio 3 "pdf read/write library" "2021-10-18" "pdf read/write library"
.SH NAME
pdfio \- pdf read/write library
.SH Introduction
@@ -152,7 +152,7 @@ There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which ge
You can reproduce this with the makefile using:
.nf
- sudo make 'COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64"' install
+ sudo make COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64" install
.fi
.SS Detecting PDFio
.PP
@@ -160,7 +160,7 @@ PDFio can be detected using the pkg\-config command, for example:
.nf
if pkg\-config \-\-exists pdfio; then
- ...
+ ...
fi
.fi
.PP
@@ -1406,9 +1406,9 @@ Set the stroke pattern.
.nf
bool pdfioContentSetDashPattern (
pdfio_stream_t *st,
- int phase,
- int on,
- int off
+ double phase,
+ double on,
+ double off
);
.fi
.SS pdfioContentSetFillColorDeviceCMYK
diff --git a/doc/pdfio.html b/doc/pdfio.html
index 84a484a..b32cfd7 100644
--- a/doc/pdfio.html
+++ b/doc/pdfio.html
@@ -548,12 +548,12 @@ make install-shared
sudo xcodebuild install
You can reproduce this with the makefile using:
-sudo make 'COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"' install
+sudo make COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64" install
Detecting PDFio
PDFio can be detected using the pkg-config
command, for example:
if pkg-config --exists pdfio; then
- ...
+ ...
fi
In a makefile you can add the necessary compiler and linker options with:
@@ -1563,7 +1563,7 @@ bool pdfioContentSave(pdfio_stream_t *st);
Set the stroke pattern.
-bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off);
+bool pdfioContentSetDashPattern(pdfio_stream_t *st, double phase, double on, double off);
Parameters