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**
@ -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)

View file

@ -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 <rstuart114@gmail.com>
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com>
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

View file

@ -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 <rstuart114@gmail.com>
Copyright (C) 2009-2025 Robin Stuart <rstuart114@gmail.com>
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

View file

@ -1,7 +1,7 @@
/* filemem.c - write to file/memory abstraction */
/*
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
modification, are permitted provided that the following conditions
@ -34,7 +34,7 @@
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#ifdef _MSC_VER
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#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);
}

View file

@ -1,6 +1,6 @@
/*
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
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

View file

@ -1,6 +1,6 @@
/*
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
modification, are permitted provided that the following conditions
@ -57,8 +57,10 @@ extern "C" {
#define testutil_pclose(stream) _pclose(stream)
#else
#include <unistd.h>
# 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