From fef00f8b9251edba56d37a74c312a728a0384a86 Mon Sep 17 00:00:00 2001 From: gitlost Date: Wed, 15 Jan 2025 23:47:40 +0000 Subject: [PATCH] filemem: fix stdout input under MSYS2, mailing list, props Frank https://sourceforge.net/p/zint/mailman/message/59113804/ also fix some warnings and suppress "-Wlong-long" --- ChangeLog | 3 ++- backend/common.c | 8 ++++---- backend/common.h | 4 +++- backend/filemem.c | 6 +++--- backend/tests/test_large.c | 4 ++-- backend/tests/testcommon.h | 4 +++- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9991dedd..deb9ac34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Version 2.13.0.9 (dev) not released yet (2024-12-23) +Version 2.13.0.9 (dev) not released yet (2025-01-15) ==================================================== **Incompatible changes** @@ -71,6 +71,7 @@ Bugs - CODE128: fix extended char latching when exactly 3 extended chars at end - library: need to check for valid UTF-8 after de-escaping - MAXICODE: maintain current set between segments +- MSYS2: fix stdout output on Windows under MSYS2 (mailing list, props Frank) Version 2.13.0 (2023-12-18) diff --git a/backend/common.c b/backend/common.c index ceb6f560..7b2f6d0d 100644 --- a/backend/common.c +++ b/backend/common.c @@ -1,7 +1,7 @@ /* common.c - Contains functions needed for a number of barcodes */ /* libzint - the open source barcode library - Copyright (C) 2008-2024 Robin Stuart + Copyright (C) 2008-2025 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -503,15 +503,15 @@ INTERNAL int errtxt_adj(const int error_number, struct zint_symbol *symbol, cons err_buf[0] = '\0'; -/* Suppress gcc 14 warning output may be truncated */ -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 14 +/* Suppress gcc 8+ warning output may be truncated */ +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" #endif strncat(err_buf, symbol->errtxt, sizeof(symbol->errtxt) - 1); -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 14 +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8 #pragma GCC diagnostic pop #endif diff --git a/backend/common.h b/backend/common.h index 6017dbb2..092f452f 100644 --- a/backend/common.h +++ b/backend/common.h @@ -1,7 +1,7 @@ /* common.h - Header for all common functions in common.c */ /* libzint - the open source barcode library - Copyright (C) 2009-2024 Robin Stuart + Copyright (C) 2009-2025 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -84,6 +84,8 @@ typedef unsigned __int64 uint64_t; # if _MSC_VER > 1200 /* VC6 */ # pragma warning(disable: 4996) /* function or variable may be unsafe */ # endif +#elif defined(__MINGW64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 3 +# pragma GCC diagnostic ignored "-Wlong-long" #endif #if defined(__GNUC__) && __GNUC__ >= 3 diff --git a/backend/filemem.c b/backend/filemem.c index 0ea982f1..7b752cb6 100644 --- a/backend/filemem.c +++ b/backend/filemem.c @@ -1,7 +1,7 @@ /* filemem.c - write to file/memory abstraction */ /* libzint - the open source barcode library - Copyright (C) 2023-2024 Robin Stuart + Copyright (C) 2023-2025 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -34,7 +34,7 @@ #include #include #include -#ifdef _MSC_VER +#ifdef _WIN32 #include #include #endif @@ -117,7 +117,7 @@ INTERNAL int fm_open(struct filemem *restrict const fmp, struct zint_symbol *sym return 1; } if (fmp->flags & BARCODE_STDOUT) { -#ifdef _MSC_VER +#ifdef _WIN32 if (strchr(mode, 'b') != NULL && _setmode(_fileno(stdout), _O_BINARY) == -1) { return fm_seterr(fmp, errno); } diff --git a/backend/tests/test_large.c b/backend/tests/test_large.c index 5deb77d7..472d5000 100644 --- a/backend/tests/test_large.c +++ b/backend/tests/test_large.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2024 Robin Stuart + Copyright (C) 2020-2025 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -34,7 +34,7 @@ #include "testcommon.h" #include "../large.h" -#if defined(__MINGW32__) +#if defined(__MINGW32__) && !defined(__MINGW64__) # if __WORDSIZE == 32 # define LX_FMT "I32" # else diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index 83653f13..bf6652a9 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2024 Robin Stuart + Copyright (C) 2019-2025 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -57,8 +57,10 @@ extern "C" { #define testutil_pclose(stream) _pclose(stream) #else #include +# ifndef _WIN32 extern FILE *popen(const char *command, const char *type); extern int pclose(FILE *stream); +# endif #define testutil_popen(command, mode) popen(command, mode) #define testutil_pclose(stream) pclose(stream) #endif