diff --git a/.clang-format b/.clang-format index 53e055abd..b12d83895 100644 --- a/.clang-format +++ b/.clang-format @@ -13,6 +13,7 @@ StatementMacros: ['SET_ENT', 'CAST_DWG_OBJECT_TO_OBJECT', 'DISABLE_NODSTYLE', 'ENCODE_CTRL_TO_TABLE', + 'DECODER_OR_ENCODER', 'FIELD_TFv', 'PRE', 'LATER_VERSIONS', diff --git a/examples/dwgfuzz.c b/examples/dwgfuzz.c index 6b4ff9436..a64279022 100644 --- a/examples/dwgfuzz.c +++ b/examples/dwgfuzz.c @@ -62,8 +62,8 @@ // debugging #ifndef FUZZ_MODE # define FUZZ_MODE FUZZ_INMEM -//#define FUZZ_MODE FUZZ_STDIN -//#define FUZZ_MODE FUZZ_FILE +// #define FUZZ_MODE FUZZ_STDIN +// #define FUZZ_MODE FUZZ_FILE #endif int dwg_fuzz_dat (Dwg_Data **restrict dwgp, Bit_Chain *restrict dat); diff --git a/examples/llvmfuzz.c b/examples/llvmfuzz.c index d1c562104..7530680f2 100644 --- a/examples/llvmfuzz.c +++ b/examples/llvmfuzz.c @@ -18,7 +18,7 @@ #include #include #include -//#include +// #include #include #include "common.h" @@ -240,15 +240,15 @@ main (int argc, char *argv[]) { unsigned seed; const unsigned int possible_outputformats = -#ifdef DISABLE_DXF -# ifdef DISABLE_JSON +# ifdef DISABLE_DXF +# ifdef DISABLE_JSON 1; -# else +# else 3; -# endif -#else +# endif +# else 5; -#endif +# endif if (argc <= 1 || !*argv[1]) return usage (); @@ -256,13 +256,13 @@ main (int argc, char *argv[]) seed = (unsigned)strtol (getenv ("SEED"), NULL, 10) % 9999; else { -#ifdef HAVE_GETTIMEOFDAY +# ifdef HAVE_GETTIMEOFDAY struct timeval tval; gettimeofday (&tval, NULL); seed = (unsigned)(tval.tv_sec * 1000 + tval.tv_usec) % 9999; -#else +# else seed = (unsigned)time (NULL) % 9999; -#endif +# endif } srand (seed); /* works only on linux @@ -305,22 +305,22 @@ main (int argc, char *argv[]) assert ((long)n_read == len); out = rand () % possible_outputformats; -#ifdef STANDALONE +# ifdef STANDALONE if (getenv ("OUT")) out = strtol (getenv ("OUT"), NULL, 10); // print SEED onlyu when needed (no env vars given) if (!(out || getenv ("VER"))) fprintf (stderr, "SEED=%04u ", seed); fprintf (stderr, "OUT=%d ", out); -#endif +# endif if (out == 0) { ver = rand () % 20; -#ifdef STANDALONE +# ifdef STANDALONE if (getenv ("VER")) ver = strtol (getenv ("VER"), NULL, 10); fprintf (stderr, "VER=%d ", ver); -#endif +# endif } fprintf (stderr, "examples/llvmfuzz_standalone %s [%" PRIuSIZE "]\n", argv[i], len); diff --git a/examples/unknown.c b/examples/unknown.c index 859e1f8a2..233b3eb6b 100644 --- a/examples/unknown.c +++ b/examples/unknown.c @@ -675,7 +675,7 @@ set_possible(struct _dxf *dxf, const struct _unknown_field *g, const int i) // The i-th bit of a string. See bit_read_B() // 0x1: 10000000,0 >> 8 = 1 #define BIT(b, i) (((b)[(i) / 8] & (0x80 >> (i) % 8)) >> (7 - (i) % 8)) -//#define BIT(b,i) (((b)[(i)/8] >> (8-((i)%8))) & 1) +// #define BIT(b,i) (((b)[(i)/8] >> (8-((i)%8))) & 1) // like memmem but for bits, not bytes. // search for the bits of small in big. returns the bit offset in big or -1. diff --git a/programs/dwggrep.c b/programs/dwggrep.c index a832ed6be..c4ecb754f 100644 --- a/programs/dwggrep.c +++ b/programs/dwggrep.c @@ -106,7 +106,8 @@ static pcre2_compile_context_16 *compile_context16 = NULL; static int usage (void) { - printf ("\nUsage: dwggrep [-bcihntx] [--type TYPE] [--dxf NUM] [--help] pattern *.dwg\n"); + printf ("\nUsage: dwggrep [-bcihntx] [--type TYPE] [--dxf NUM] [--help] " + "pattern *.dwg\n"); return 1; } static int @@ -128,15 +129,18 @@ help (void) #ifdef HAVE_PCRE2_H printf (" -x Extended regex pattern\n"); #endif - printf (" -c, --count Print only the count of matched elements.\n"); + printf (" -c, --count Print only the count of matched " + "elements.\n"); printf (" -h, --no-filename Print no filename.\n"); #if 0 printf(" -R, -r, --recursive Recursively search subdirectories listed.\n"); #endif - printf (" -y, --type NAME Search only NAME entities or objects.\n"); + printf ( + " -y, --type NAME Search only NAME entities or objects.\n"); printf (" -d, --dxf NUM Search only DXF group NUM fields.\n"); printf (" -t, --text Search only in TEXT-like entities.\n"); - printf (" -b, --blocks Search also in all block definitions.\n"); + printf ( + " -b, --blocks Search also in all block definitions.\n"); printf (" -n, --tables Search only in table names.\n"); #ifdef HAVE_GETOPT_LONG printf (" --help Display this help and exit\n"); diff --git a/programs/dwgread.c b/programs/dwgread.c index 786a26dc7..1a6656c8c 100644 --- a/programs/dwgread.c +++ b/programs/dwgread.c @@ -78,7 +78,8 @@ help (void) printf (" -v[0-9], --verbose [0-9] verbosity\n"); # ifndef DISABLE_DXF # ifndef DISABLE_JSON - printf (" -O fmt, --format fmt fmt: DXF, DXFB, JSON, minJSON, GeoJSON\n"); + printf ( + " -O fmt, --format fmt fmt: DXF, DXFB, JSON, minJSON, GeoJSON\n"); # else printf (" -O fmt, --format fmt fmt: DXF, DXFB\n"); # endif @@ -198,8 +199,8 @@ main (int argc, char *argv[]) else #endif #ifndef DISABLE_JSON - if (strstr (outfile, ".min.json") - || strstr (outfile, ".MIN.JSON")) + if (strstr (outfile, ".min.json") + || strstr (outfile, ".MIN.JSON")) { fmt = strdup ("json"); opts |= DWG_OPTS_MINIMAL; diff --git a/programs/dxf2dwg.c b/programs/dxf2dwg.c index 47671b6f8..c580cf4d9 100644 --- a/programs/dxf2dwg.c +++ b/programs/dxf2dwg.c @@ -330,7 +330,7 @@ main (int argc, char *argv[]) #ifdef HAVE_VALGRIND_VALGRIND_H || (RUNNING_ON_VALGRIND) #endif - ) + ) dwg_free (&dwg); continue; } diff --git a/src/encode.c b/src/encode.c index 6369a6294..3d01ccfa9 100644 --- a/src/encode.c +++ b/src/encode.c @@ -6412,12 +6412,12 @@ encode_preR13_header_variables (Bit_Chain *dat, Dwg_Data *restrict dwg) Bit_Chain *hdl_dat = dat; int error = 0; -// PRE (R_13b1) -// { -// if (dat->from_version >= R_13b1) -// downgrade_preR13_header_variables (dat, dwg); -// } -// clang-format off + // PRE (R_13b1) + // { + // if (dat->from_version >= R_13b1) + // downgrade_preR13_header_variables (dat, dwg); + // } + // clang-format off #include "header_variables_r11.spec" // clang-format on diff --git a/src/spec.h b/src/spec.h index 26be978b8..6def2b98f 100644 --- a/src/spec.h +++ b/src/spec.h @@ -722,46 +722,48 @@ #endif #ifndef COMMON_TABLE_FLAGS -# define COMMON_TABLE_FLAGS(acdbname) \ - assert (obj->supertype == DWG_SUPERTYPE_OBJECT); \ - PRE (R_13b1) \ - { \ - if (strcmp (#acdbname, "Layer") == 0) \ - { \ - FIELD_CAST (flag, RC, RS, 70); \ - } \ - else \ - { \ - FIELD_CAST (flag, RC, RC, 70); \ - } \ - DECODER_OR_ENCODER \ - { \ - LOG_FLAG_##acdbname \ - } \ - FIELD_TFv (name, 32, 2); \ - VERSION (R_11) \ - FIELD_RSd (used, 0); \ - } \ - LATER_VERSIONS \ - { \ - FIELD_T (name, 2); \ - UNTIL (R_2004) \ - { \ - FIELD_B (is_xref_ref, 0); /* always 1, 70 bit 6 */ \ - FIELD_BS (is_xref_resolved, 0); /* 0 or 256 */ \ - FIELD_B (is_xref_dep, 0); /* 70 bit 4 */ \ - } \ - LATER_VERSIONS \ - { \ - FIELD_VALUE (is_xref_ref) = 1; \ - FIELD_BS (is_xref_resolved, 0); /* 0 or 256 */ \ - if (FIELD_VALUE (is_xref_resolved) == 256) \ - FIELD_VALUE (is_xref_dep) = 1; \ - } \ - FIELD_HANDLE (xref, 5, 0); /* NULLHDL without is_xref_dep */ \ - FIELD_VALUE (flag) \ - |= FIELD_VALUE (is_xref_dep) << 4 | FIELD_VALUE (is_xref_ref) << 6; \ - } \ +# define COMMON_TABLE_FLAGS(acdbname) \ + assert (obj->supertype == DWG_SUPERTYPE_OBJECT); \ + PRE (R_13b1) \ + { \ + if (strcmp (#acdbname, "Layer") == 0) \ + { \ + FIELD_CAST (flag, RC, RS, 70); \ + } \ + else \ + { \ + FIELD_CAST (flag, RC, RC, 70); \ + } \ + /* clang-format off */ \ + DECODER_OR_ENCODER \ + { \ + LOG_FLAG_##acdbname \ + } \ + FIELD_TFv (name, 32, 2); \ + VERSION (R_11) \ + FIELD_RSd (used, 0); \ + /* clang-format on */ \ + } \ + LATER_VERSIONS \ + { \ + FIELD_T (name, 2); \ + UNTIL (R_2004) \ + { \ + FIELD_B (is_xref_ref, 0); /* always 1, 70 bit 6 */ \ + FIELD_BS (is_xref_resolved, 0); /* 0 or 256 */ \ + FIELD_B (is_xref_dep, 0); /* 70 bit 4 */ \ + } \ + LATER_VERSIONS \ + { \ + FIELD_VALUE (is_xref_ref) = 1; \ + FIELD_BS (is_xref_resolved, 0); /* 0 or 256 */ \ + if (FIELD_VALUE (is_xref_resolved) == 256) \ + FIELD_VALUE (is_xref_dep) = 1; \ + } \ + FIELD_HANDLE (xref, 5, 0); /* NULLHDL without is_xref_dep */ \ + FIELD_VALUE (flag) \ + |= FIELD_VALUE (is_xref_dep) << 4 | FIELD_VALUE (is_xref_ref) << 6; \ + } \ RESET_VER #endif