Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ endif()
if (WCHAR_T EQUAL 2)
set(HAVE_PCRE2_16 1)
endif()

if (NOT HAVE_MIMALLOC_OVERRIDE_H)
if (ENABLE_MIMALLOC)
message(WARNING "Should not ENABLE_MIMALLOC without mimalloc-override.h")
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ if test x$enable_shared = xyes && \
then
AX_COMPILER_FLAGS([WARN_CFLAGS],[AM_LDFLAGS],[$ax_is_release],
[-fno-semantic-interposition -fwrapv -fno-common -fvisibility=hidden \
-fno-strict-aliasing -ftrivial-auto-var-init=zero \
-fno-strict-aliasing -ftrivial-auto-var-init=zero -fstrict-flex-arrays=3 \
-fstack-protector-strong -fstack-clash-protection \
-fcf-protection=full -fno-delete-null-pointer-checks \
-Wno-alloc-size])
Expand Down Expand Up @@ -283,6 +283,7 @@ AX_GCC_FUNC_ATTRIBUTE(malloc)
AX_GCC_FUNC_ATTRIBUTE(returns_nonnull)
AX_GCC_FUNC_ATTRIBUTE(noreturn)
AX_GCC_FUNC_ATTRIBUTE(aligned)
AX_GCC_FUNC_ATTRIBUTE(counted_by)
if test x$ax_cv_check_cflags__Wformat_y2k = xyes || \
test x$ax_cv_check_cflags__Wformat_2__Wformat_y2k = xyes
then
Expand Down
20 changes: 9 additions & 11 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -13796,10 +13796,10 @@ BD*
struct _dwg_object_BLOCKSTRETCHACTION*
@item bl95
BL, DXF 95
@item bs76
@item num_indexes
BS, DXF 76
@item bl94
BL, DXF 94
@item indexes
BL*, DXF 94

@end vtable
@end indentedblock
Expand All @@ -13814,12 +13814,10 @@ BL, DXF 94
struct _dwg_object_BLOCKSTRETCHACTION*
@item hdl
H, DXF 331
@item shrt
@item num_indexes
BS, DXF 74
@item long1
BL, DXF 94
@item long2
BL, DXF 94
@item indexes
BL*, DXF 94

@end vtable
@end indentedblock
Expand Down Expand Up @@ -14481,7 +14479,7 @@ BD, DXF 53
@item num_dashes
BS, DXF 79
@item dashes
BD*
BD*, DXF 49

@end vtable
@end indentedblock
Expand Down Expand Up @@ -14561,9 +14559,9 @@ BL, DXF 97
@item fitpts
2RD*
@item start_tangent
2RD
2RD, DXF 12
@item end_tangent
2RD
2RD, DXF 13

@end vtable
@end indentedblock
Expand Down
48 changes: 36 additions & 12 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@
# endif
#endif

#ifndef __counted_by
# if (defined(__clang__) && (__clang_major__ >= 18)) || \
(defined( __GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 1500)
# define __counted_by(x) __attribute__((__counted_by__(x)))
# ifdef __cplusplus
# undef __counted_by
# define __counted_by(x)
# endif
# else
# define __counted_by(x)
# endif
#endif

#ifdef __cplusplus
extern "C" {
# ifndef restrict
Expand Down Expand Up @@ -7799,17 +7812,16 @@ typedef struct _dwg_object_BLOCKSCALEACTION

typedef struct _dwg_BLOCKSTRETCHACTION_handles {
struct _dwg_object_BLOCKSTRETCHACTION *parent;
BITCODE_H hdl; // 331
BITCODE_BS shrt; // 74
BITCODE_BL long1; // 94
BITCODE_BL long2; // 94
BITCODE_H hdl; // 331
BITCODE_BS num_indexes; // 74
BITCODE_BL *indexes; // 94
} Dwg_BLOCKSTRETCHACTION_handles;

typedef struct _dwg_BLOCKSTRETCHACTION_codes {
struct _dwg_object_BLOCKSTRETCHACTION *parent;
BITCODE_BL bl95; // 95
BITCODE_BS bs76; // 76
BITCODE_BL bl94; // 94
BITCODE_BL bl95; // 95
BITCODE_BS num_indexes; // 76
BITCODE_BL *indexes; // 94
} Dwg_BLOCKSTRETCHACTION_codes;

typedef struct _dwg_object_BLOCKSTRETCHACTION
Expand All @@ -7820,7 +7832,7 @@ typedef struct _dwg_object_BLOCKSTRETCHACTION
BITCODE_BL num_pts; // 72
BITCODE_2RD *pts; // 10
BITCODE_BL num_hdls; // 72
Dwg_BLOCKSTRETCHACTION_handles *hdls; /*!< DXF 331, 74, 94, 94 */
Dwg_BLOCKSTRETCHACTION_handles *hdls; /*!< DXF 331, 74, 94 */
BITCODE_BL num_codes; // 75
Dwg_BLOCKSTRETCHACTION_codes *codes; /*!< DXF 95, 76, 94 */
BLOCKACTION_doubles_fields;
Expand Down Expand Up @@ -8144,17 +8156,29 @@ typedef struct _dwg_entity_eed_data
BITCODE_RS length; /* RC */
unsigned short codepage:15; /* RS_LE */
unsigned short is_tu:1;
char string[1]; /* inlined */
#ifndef SWIG
char string[] __counted_by(length); /* inlined */
#else
char string[0]; // swig limitation https://github.com/swig/swig/issues/1699
#endif
} eed_0;
struct { /* R2007+ 0 (1000) string */
BITCODE_RS length;
unsigned short _padding:15;
unsigned short is_tu:1;
DWGCHAR string[1]; /* inlined */
#ifndef SWIG
DWGCHAR string[] __counted_by(length); /* inlined */
#else
DWGCHAR string[0];
#endif
} eed_0_r2007;
struct { /* 1 (1001) handle, not in data */
char invalid[1]; // set the eed[0].handle to the used APPID instead
BITCODE_RS appid_index;
#ifndef SWIG
char invalid[]; // set the eed[0].handle to the used APPID instead
#else
char invalid[0];
#endif
} eed_1;
struct { /* 2 (1002) "{" => 0 open, or "}" => 1 close */
BITCODE_RC close;
Expand All @@ -8164,7 +8188,7 @@ typedef struct _dwg_entity_eed_data
} eed_3;
struct { /* 4 (1004) binary */
BITCODE_RC length;
unsigned char data[1]; // inlined
unsigned char data[] __counted_by(length); // inlined
} eed_4;
struct { /* 5 (1005) entity */
BITCODE_RLL entity;
Expand Down
6 changes: 5 additions & 1 deletion m4/ax_gcc_func_attribute.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# const
# constructor
# constructor_priority for constructor attribute with priority
# counted_by
# deprecated
# destructor
# dllexport
Expand All @@ -48,7 +49,6 @@
# ifunc
# leaf
# malloc
# ms_format
# noclone
# noinline
# nonnull
Expand Down Expand Up @@ -95,6 +95,7 @@ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
CFLAGS="$CFLAGS -Werror"
fi
fi

AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
m4_case([$1],
Expand Down Expand Up @@ -126,6 +127,9 @@ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
[constructor], [
int foo( void ) __attribute__(($1));
],
[counted_by], [
struct { int size; int flex[[]] __attribute__((__counted_by__(size))); } x;
],
[deprecated], [
int foo( void ) __attribute__(($1("")));
],
Expand Down
2 changes: 1 addition & 1 deletion m4/ax_printf_size_t.m4
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ save_CFLAGS="$CFLAGS"
if test "_$GCC" = _yes
then
# Take advantage of GCC's format-string checking
CFLAGS="$CFLAGS -Wformat -pedantic -Werror"
CFLAGS="$CFLAGS -Wformat -pedantic -Werror -Wno-deprecated"
fi

result=unknown
Expand Down
3 changes: 3 additions & 0 deletions programs/my_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ int _access (const char *path, int mode);
# ifndef S_ISREG
# define S_ISREG(m) ((m & 0170000) == _S_IFREG)
# endif
# ifndef S_ISDIR
# define S_ISDIR(m) ((m & 0170000) == _S_IFDIR)
# endif
# ifndef W_OK
# define W_OK 0
# endif
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ clang-tidy: ../compile_commands.json
# emacs flymake-mode
check-syntax:
test -n "$(CHK_SOURCES)" && \
nice $(COMPILE) -O0 -o /dev/null -S $(CHK_SOURCES)
nice $(COMPILE) -I. -O0 -o /dev/null -S $(CHK_SOURCES)
.PHONY: check-syntax cppcheck clang-tidy

if ENABLE_GCOV
Expand Down
6 changes: 3 additions & 3 deletions src/bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ bit_wcs2dup (const BITCODE_TU restrict src)
return NULL;
len = bit_wcs2len (src);
blen = (len + 1) * 2; // include the zero
d = malloc (blen);
d = (BITCODE_TU)malloc (blen);
if (d)
memcpy (d, src, blen);
return d;
Expand Down Expand Up @@ -2173,12 +2173,12 @@ bit_write_TV (Bit_Chain *restrict dat, BITCODE_TV restrict chain)
if (length && dat->opts & DWG_OPTS_INJSON)
{
size_t destlen = length * 2;
char *dest = malloc (destlen);
char *dest = (char*)malloc (destlen);
while (!bit_utf8_to_TV (dest, (unsigned char *)chain, destlen, length, 0,
dat->codepage))
{
destlen *= 2;
dest = realloc (dest, destlen);
dest = (char*)realloc (dest, destlen);
}
need_free = true;
chain = dest;
Expand Down
4 changes: 2 additions & 2 deletions src/codepages.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ dwg_codepage_isalnum (const Dwg_Codepage cp, const wchar_t c)
const uint8_t key = c & 0xff;
const uint8_t sz8 = fntbl[0];
const size_t sz = (size_t)sz8;
uint8_t *found = bsearch (&key, &fntbl[1], sz, 1, b8_cmp);
uint8_t *found = (uint8_t *)bsearch (&key, &fntbl[1], sz, 1, b8_cmp);
if (!found || found == &fntbl[0])
return false;
else
Expand All @@ -463,7 +463,7 @@ dwg_codepage_isalnum (const Dwg_Codepage cp, const wchar_t c)
const uint16_t *fntbl16 = cp_alnum16tbl[cp];
const uint16_t sz16 = fntbl16[0];
const size_t sz = (size_t)sz16;
uint16_t *found = bsearch (&key, &fntbl16[1], sz, 2, b16_cmp);
uint16_t *found = (uint16_t *)bsearch (&key, &fntbl16[1], sz, 2, b16_cmp);
if (!found || found == &fntbl16[0])
return false;
else
Expand Down
10 changes: 10 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ EXPORT int strcasecmp (const char *a, const char *b);
# define ATTRIBUTE_NORETURN
#endif

#ifndef __counted_by
# ifdef HAVE_FUNC_ATTRIBUTE_COUNTED_BY
# define __counted_by(x) __attribute__ ((__counted_by__(x)))
# elif defined(_MSC_VER)
# define __counted_by(x)
# else
# define __counted_by(x)
# endif
#endif

#if defined(_WIN32) && defined(HAVE_FUNC_ATTRIBUTE_MS_FORMAT) \
&& !defined(__USE_MINGW_ANSI_STDIO)
# define ATTRIBUTE_FORMAT(x, y) __attribute__ ((format (ms_printf, x, y)))
Expand Down
Loading
Loading