filemem: fix stdout input under MSYS2, mailing list, props Frank

59113804/
  also fix some warnings and suppress "-Wlong-long"
This commit is contained in:
gitlost 2025-01-15 23:47:40 +00:00
parent 7a9fdd6cd0
commit fef00f8b92
6 changed files with 17 additions and 12 deletions

View file

@ -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** **Incompatible changes**
@ -71,6 +71,7 @@ Bugs
- CODE128: fix extended char latching when exactly 3 extended chars at end - CODE128: fix extended char latching when exactly 3 extended chars at end
- library: need to check for valid UTF-8 after de-escaping - library: need to check for valid UTF-8 after de-escaping
- MAXICODE: maintain current set between segments - 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) Version 2.13.0 (2023-12-18)

View file

@ -1,7 +1,7 @@
/* common.c - Contains functions needed for a number of barcodes */ /* common.c - Contains functions needed for a number of barcodes */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2024 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions 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'; err_buf[0] = '\0';
/* Suppress gcc 14 warning output may be truncated */ /* Suppress gcc 8+ warning output may be truncated */
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 14 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation" #pragma GCC diagnostic ignored "-Wstringop-truncation"
#endif #endif
strncat(err_buf, symbol->errtxt, sizeof(symbol->errtxt) - 1); 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 #pragma GCC diagnostic pop
#endif #endif

View file

@ -1,7 +1,7 @@
/* common.h - Header for all common functions in common.c */ /* common.h - Header for all common functions in common.c */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -84,6 +84,8 @@ typedef unsigned __int64 uint64_t;
# if _MSC_VER > 1200 /* VC6 */ # if _MSC_VER > 1200 /* VC6 */
# pragma warning(disable: 4996) /* function or variable may be unsafe */ # pragma warning(disable: 4996) /* function or variable may be unsafe */
# endif # endif
#elif defined(__MINGW64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 3
# pragma GCC diagnostic ignored "-Wlong-long"
#endif #endif
#if defined(__GNUC__) && __GNUC__ >= 3 #if defined(__GNUC__) && __GNUC__ >= 3

View file

@ -1,7 +1,7 @@
/* filemem.c - write to file/memory abstraction */ /* filemem.c - write to file/memory abstraction */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2023-2024 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2023-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -34,7 +34,7 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef _MSC_VER #ifdef _WIN32
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#endif #endif
@ -117,7 +117,7 @@ INTERNAL int fm_open(struct filemem *restrict const fmp, struct zint_symbol *sym
return 1; return 1;
} }
if (fmp->flags & BARCODE_STDOUT) { if (fmp->flags & BARCODE_STDOUT) {
#ifdef _MSC_VER #ifdef _WIN32
if (strchr(mode, 'b') != NULL && _setmode(_fileno(stdout), _O_BINARY) == -1) { if (strchr(mode, 'b') != NULL && _setmode(_fileno(stdout), _O_BINARY) == -1) {
return fm_seterr(fmp, errno); return fm_seterr(fmp, errno);
} }

View file

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -34,7 +34,7 @@
#include "testcommon.h" #include "testcommon.h"
#include "../large.h" #include "../large.h"
#if defined(__MINGW32__) #if defined(__MINGW32__) && !defined(__MINGW64__)
# if __WORDSIZE == 32 # if __WORDSIZE == 32
# define LX_FMT "I32" # define LX_FMT "I32"
# else # else

View file

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -57,8 +57,10 @@ extern "C" {
#define testutil_pclose(stream) _pclose(stream) #define testutil_pclose(stream) _pclose(stream)
#else #else
#include <unistd.h> #include <unistd.h>
# ifndef _WIN32
extern FILE *popen(const char *command, const char *type); extern FILE *popen(const char *command, const char *type);
extern int pclose(FILE *stream); extern int pclose(FILE *stream);
# endif
#define testutil_popen(command, mode) popen(command, mode) #define testutil_popen(command, mode) popen(command, mode)
#define testutil_pclose(stream) pclose(stream) #define testutil_pclose(stream) pclose(stream)
#endif #endif