diff --git a/CHANGES.md b/CHANGES.md index 855cb89..a3303e9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,9 @@ v1.6.1 - YYYY-MM-DD ------------------- - Added missing input checking to `pdfioFileCreateFontObjFromBase` function. +- Updated Xcode project to use installed PNG library. +- Fixed some clang warnings. + v1.6.0 - 2025-10-06 diff --git a/pdfio-content.c b/pdfio-content.c index 45cf293..f71277d 100644 --- a/pdfio-content.c +++ b/pdfio-content.c @@ -2702,7 +2702,8 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary png_infop info = NULL; // PNG info pointers png_bytep *rows = NULL; // PNG row pointers unsigned char *pixels = NULL; // PNG image data - unsigned i, // Looping var + int i; // Looping var + unsigned y, // Row color_type, // PNG color mode width, // Width in columns height, // Height in lines @@ -2800,8 +2801,8 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary goto finish_png; } - for (i = 0; i < height; i ++) - rows[i] = pixels + i * linesize; + for (y = 0; y < height; y ++) + rows[y] = pixels + y * linesize; // Read the image... for (i = png_set_interlace_handling(pp); i > 0; i --) @@ -2815,7 +2816,7 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary // Grab any color space/palette information... if (png_get_PLTE(pp, info, &palette, &num_palette)) { - pdfioDictSetArray(dict, "ColorSpace", pdfioArrayCreateColorFromPalette(dict->pdf, num_palette, (unsigned char *)palette)); + pdfioDictSetArray(dict, "ColorSpace", pdfioArrayCreateColorFromPalette(dict->pdf, (size_t)num_palette, (unsigned char *)palette)); } else if (png_get_iCCP(pp, info, &icc_name, /*compression_type*/NULL, &icc_data, &icc_datalen)) { @@ -3845,14 +3846,12 @@ png_read_func(png_structp pp, // I - PNG pointer png_bytep data, // I - Read buffer size_t length) // I - Number of bytes to read { - int *fd = (int *)png_get_io_ptr(pp); - // Pointer to file descriptor - ssize_t bytes; // Bytes read + int *fd = (int *)png_get_io_ptr(pp);// Pointer to file descriptor PDFIO_DEBUG("png_read_func(pp=%p, data=%p, length=%lu)\n", (void *)pp, (void *)data, (unsigned long)length); - if ((bytes = read(*fd, data, length)) < (ssize_t)length) + if (read(*fd, data, length) < (ssize_t)length) png_error(pp, "Unable to read from PNG file."); } #endif // HAVE_LIBPNG diff --git a/pdfio.xcodeproj/project.pbxproj b/pdfio.xcodeproj/project.pbxproj index 52bef57..b3fe035 100644 --- a/pdfio.xcodeproj/project.pbxproj +++ b/pdfio.xcodeproj/project.pbxproj @@ -379,7 +379,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "Apple Development"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1.1.2; + CURRENT_PROJECT_VERSION = 1.6.1; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -390,6 +390,9 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "DEBUG=1", + "HAVE_LIBPNG=1", + "HAVE_TM_GMTOFF=1", + "HAVE_TIMEGM=1", ); GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; @@ -409,10 +412,21 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + /usr/local/include, + /opt/local/include, + /opt/homebrew/include, + ); MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-L/usr/local/lib", + "-L/opt/local/lib", + "-L/opt/homebrew/lib", + "-lpng16", + ); RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -465,7 +479,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "Apple Development"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1.1.2; + CURRENT_PROJECT_VERSION = 1.6.1; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_HARDENED_RUNTIME = YES; @@ -474,7 +488,12 @@ ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; - GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "HAVE_LIBPNG=1", + "HAVE_TM_GMTOFF=1", + "HAVE_TIMEGM=1", + ); GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -492,9 +511,20 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + /usr/local/include, + /opt/local/include, + /opt/homebrew/include, + ); MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "-L/usr/local/lib", + "-L/opt/local/lib", + "-L/opt/homebrew/lib", + "-lpng16", + ); RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx; STRING_CATALOG_GENERATE_SYMBOLS = YES; diff --git a/testpdfio.c b/testpdfio.c index 8726643..4916366 100644 --- a/testpdfio.c +++ b/testpdfio.c @@ -3486,7 +3486,7 @@ write_pdfa_file( // Embed a base font, which are not allowed for PDF/A testBegin("pdfioFileCreateFontObjFromBase(Helvetica)"); - if ((font = pdfioFileCreateFontObjFromBase(pdf, "Helvetica")) != NULL) + if (pdfioFileCreateFontObjFromBase(pdf, "Helvetica") != NULL) { testEnd(false); goto done;