mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
CMake: check for getopt_long_only()
instead of just getopt()
so behaviour of CLI same general: AIX compat, suppress some warnings
This commit is contained in:
parent
bead450f38
commit
1449866d18
@ -1,5 +1,5 @@
|
||||
# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
|
||||
# Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
# Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
# vim: set ts=4 sw=4 et :
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
@ -139,8 +139,8 @@ if(APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_function_exists(getopt HAVE_GETOPT)
|
||||
if(NOT HAVE_GETOPT)
|
||||
check_function_exists(getopt_long_only HAVE_GETOPT_LONG_ONLY)
|
||||
if(NOT HAVE_GETOPT_LONG_ONLY)
|
||||
add_subdirectory(getopt)
|
||||
endif()
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* common.c - Contains functions needed for a number of barcodes */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2008-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -607,7 +607,7 @@ INTERNAL char *debug_print_escape(const unsigned char *source, const int first_l
|
||||
|
||||
#ifdef ZINT_TEST
|
||||
/* Suppress gcc warning null destination pointer [-Wformat-overflow=] false-positive */
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-overflow="
|
||||
#endif
|
||||
@ -660,7 +660,7 @@ INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int
|
||||
}
|
||||
symbol->errtxt[strlen(symbol->errtxt) - 1] = '\0'; /* Zap last space */
|
||||
}
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif /*ZINT_TEST*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* common.h - Header for all common functions in common.c */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -54,7 +54,7 @@ extern "C" {
|
||||
# include <malloc.h>
|
||||
# define z_alloca(nmemb) _alloca(nmemb)
|
||||
#else
|
||||
# if defined(ZINT_IS_C89) || defined(ZINT_IS_C99) || defined(__NuttX__) /* C89 or C99 or NuttX RTOS */
|
||||
# if defined(ZINT_IS_C89) || defined(ZINT_IS_C99) || defined(__NuttX__) || defined(_AIX)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
# define z_alloca(nmemb) alloca(nmemb)
|
||||
|
@ -105,8 +105,8 @@ INTERNAL FILE *out_win_fopen(const char *filename, const char *mode);
|
||||
|
||||
#define out_le_float(b, n) do { \
|
||||
unsigned char *bp = (unsigned char *) &(b); \
|
||||
float f = n; \
|
||||
uint32_t *p_u32 = (uint32_t *) &(f); \
|
||||
float f = (float) (n); \
|
||||
uint32_t *p_u32 = (uint32_t *) &f; \
|
||||
bp[0] = (unsigned char) (*p_u32 & 0xFF); \
|
||||
bp[1] = (unsigned char) ((*p_u32 >> 8) & 0xFF); \
|
||||
bp[2] = (unsigned char) ((*p_u32 >> 16) & 0xFF); \
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -29,6 +29,8 @@
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "../large.h"
|
||||
|
||||
@ -43,7 +45,7 @@
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Wformat" /* Unfortunately doesn't seem to be way to only avoid non-ISO warnings */
|
||||
# endif
|
||||
#elif defined(_MSC_VER) || defined(__APPLE__) || defined(__OpenBSD__) || __WORDSIZE == 32
|
||||
#elif (defined(__WORDSIZE) && __WORDSIZE == 32) || (defined(ULONG_MAX) && ULONG_MAX <= 0xFFFFFFFF)
|
||||
# define LX_FMT "ll"
|
||||
#else
|
||||
# define LX_FMT "l"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -945,19 +945,18 @@ static void test_encode_file_unreadable(const testCtx *const p_ctx) {
|
||||
|
||||
/* #181 Nico Gunkel OSS-Fuzz (buffer not freed on fread() error) Note: unable to reproduce fread() error using this method */
|
||||
static void test_encode_file_directory(const testCtx *const p_ctx) {
|
||||
#ifndef __NetBSD__
|
||||
int ret;
|
||||
struct zint_symbol *symbol;
|
||||
char dirname[] = "in_dir";
|
||||
#endif
|
||||
|
||||
(void)p_ctx;
|
||||
|
||||
testStart("test_encode_file_directory");
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#if defined(__NetBSD__) || defined(_AIX)
|
||||
/* Reading a directory works on NetBSD, and get `code128()` ZINT_ERROR_TOO_LONG instead */
|
||||
testSkip("Test not implemented on NetBSD");
|
||||
(void)ret; (void)symbol; (void)dirname;
|
||||
testSkip("Test not implemented on NetBSD or AIX");
|
||||
#else
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -1590,7 +1590,7 @@ int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||
int width1, height1, width2, height2;
|
||||
png_byte color_type1, color_type2;
|
||||
png_byte bit_depth1, bit_depth2;
|
||||
png_bytep row1 = NULL, row2 = NULL;
|
||||
png_bytep row1, row2;
|
||||
size_t rowbytes1, rowbytes2;
|
||||
int r;
|
||||
|
||||
@ -1634,6 +1634,7 @@ int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
row1 = row2 = NULL; /* Init here to avoid potential "clobbered" warning */
|
||||
if (setjmp(png_jmpbuf(png_ptr1))) {
|
||||
if (row1) {
|
||||
free(row1);
|
||||
@ -4007,12 +4008,12 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
int maxi_len = 0;
|
||||
if (symbol->option_2 >= 1 && symbol->option_2 <= 100) {
|
||||
/* Suppress gcc warning null destination pointer [-Wformat-overflow=] false-positive */
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-overflow="
|
||||
#endif
|
||||
sprintf(maxi, "[)>\03601\035%02d", symbol->option_2 - 1);
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
maxi_len = (int) strlen(maxi);
|
||||
|
@ -25,19 +25,20 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#if !defined(_MSC_VER) && !defined(__NetBSD__) && !defined(_AIX)
|
||||
# include <getopt.h>
|
||||
# if defined(__NetBSD__) && !defined(getopt_long_only) /* `getopt_long_only()` not available */
|
||||
# define getopt_long_only getopt_long
|
||||
# endif
|
||||
# include <zint.h>
|
||||
#else
|
||||
# include "../getopt/getopt.h"
|
||||
# ifdef _MSC_VER
|
||||
# include "zint.h"
|
||||
# if _MSC_VER != 1200 /* VC6 */
|
||||
# pragma warning(disable: 4996) /* function or variable may be unsafe */
|
||||
# endif
|
||||
#endif /* _MSC_VER */
|
||||
# else
|
||||
# include <zint.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Following copied from "backend/library.c" */
|
||||
|
||||
@ -64,7 +65,7 @@ typedef char static_assert_int_at_least_32bits[sizeof(int) * CHAR_BIT < 32 ? -1
|
||||
# include <malloc.h>
|
||||
# define z_alloca(nmemb) _alloca(nmemb)
|
||||
#else
|
||||
# if defined(ZINT_IS_C89) || defined(ZINT_IS_C99) || defined(__NuttX__) /* C89 or C99 or NuttX RTOS */
|
||||
# if defined(ZINT_IS_C89) || defined(ZINT_IS_C99) || defined(__NuttX__) || defined(_AIX)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
# define z_alloca(nmemb) alloca(nmemb)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -1245,9 +1245,6 @@ static void test_other_opts(const testCtx *const p_ctx) {
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
#ifdef __NetBSD__
|
||||
if (strcmp(data[i].opt, " -bg=") == 0) continue; /* `getopt_long_only()` not available on NetBSD */
|
||||
#endif
|
||||
|
||||
strcpy(cmd, "zint");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user