From 5f6eb1256fb6c251303d3728fc27875fe7a9ffb8 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Feb 2018 10:23:38 -0800 Subject: [PATCH 1/5] Add libharfbuzz-subset.la to linking when building api tests. --- test/api/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/Makefile.am b/test/api/Makefile.am index 99849fc99..d1d9b222b 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -14,7 +14,7 @@ EXTRA_DIST += CMakeLists.txt if HAVE_GLIB AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ -I$(top_builddir)/src/ $(GLIB_CFLAGS) -LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS) +LDADD = $(top_builddir)/src/libharfbuzz.la $(top_builddir)/src/libharfbuzz-subset.la $(GLIB_LIBS) EXTRA_DIST += hb-test.h From e428f7b1c21e0a7d6b9af507d98031b8eebcbeb5 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Feb 2018 10:24:16 -0800 Subject: [PATCH 2/5] Wrap unistd.h include in ifdef. --- util/hb-subset.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 21d0f767b..2306e66ad 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -25,7 +25,9 @@ * Google Author(s): Garret Rieger, Rod Sheeter */ +#ifdef HAVE_UNISTD_H #include +#endif #include "main-font-text.hh" #include "hb-subset.h" From fc04f11ce1999da042a39c5b271351223033292f Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Feb 2018 11:12:33 -0800 Subject: [PATCH 3/5] Rename HB_SUBSET_sources -> HB_SUBSET_CLI_sources to match what cmake is looking for. --- util/Makefile.am | 3 +-- util/Makefile.sources | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/util/Makefile.am b/util/Makefile.am index 3810e15e5..d4ab9cdc5 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -46,8 +46,7 @@ endif # HAVE_FREETYPE hb_shape_SOURCES = $(HB_SHAPE_sources) bin_PROGRAMS += hb-shape -hb_subset_SOURCES = $(HB_SUBSET_sources) -hb_subset_SOURCES = $(HB_SUBSET_sources) +hb_subset_SOURCES = $(HB_SUBSET_CLI_sources) hb_subset_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la bin_PROGRAMS += hb-subset diff --git a/util/Makefile.sources b/util/Makefile.sources index c4516ebcb..6c815d26b 100644 --- a/util/Makefile.sources +++ b/util/Makefile.sources @@ -29,7 +29,7 @@ HB_OT_SHAPE_CLOSURE_sources = \ main-font-text.hh \ $(NULL) -HB_SUBSET_sources = \ +HB_SUBSET_CLI_sources = \ hb-subset.cc \ options.cc \ options.hh \ From c25898eb54217e2a1c681233a6b9adcd7940652e Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Feb 2018 14:35:32 -0800 Subject: [PATCH 4/5] Switch to fopen() instead of open() in subset test. open wasn't compiling on windows. --- util/hb-subset.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 2306e66ad..3ae0ceeb0 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -25,9 +25,7 @@ * Google Author(s): Garret Rieger, Rod Sheeter */ -#ifdef HAVE_UNISTD_H -#include -#endif +#include #include "main-font-text.hh" #include "hb-subset.h" @@ -59,12 +57,13 @@ struct subset_consumer_t unsigned int data_length; const char* data = hb_blob_get_data (blob, &data_length); - int fd_out = open(output_file, O_CREAT | O_WRONLY, S_IRWXU); - if (fd_out == -1) { - fprintf(stderr, "Unable to open output file"); + FILE *fp_out = fopen(output_file, "w"); + if (fp_out == nullptr) { + fprintf(stderr, "Unable to open output file\n"); return false; } - ssize_t bytes_written = write(fd_out, data, data_length); + ssize_t bytes_written = fwrite(data, 1, data_length, fp_out); + if (bytes_written == -1) { fprintf(stderr, "Unable to write output file\n"); return false; From 2ea228935d41b55fed45b7423b69bc15b42e3abc Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Feb 2018 15:10:01 -0800 Subject: [PATCH 5/5] ssize_t -> size_t --- util/hb-subset.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 3ae0ceeb0..ef70a2dcb 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -62,7 +62,7 @@ struct subset_consumer_t fprintf(stderr, "Unable to open output file\n"); return false; } - ssize_t bytes_written = fwrite(data, 1, data_length, fp_out); + size_t bytes_written = fwrite(data, 1, data_length, fp_out); if (bytes_written == -1) { fprintf(stderr, "Unable to write output file\n");