Skip to content

Commit

Permalink
.clang-format: help fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Jun 15, 2024
1 parent f7637c0 commit 07c078a
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 71 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions examples/dwgfuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions examples/llvmfuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
//#include <unistd.h>
// #include <unistd.h>
#include <sys/stat.h>

#include "common.h"
Expand Down Expand Up @@ -240,29 +240,29 @@ 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 ();
if (getenv ("SEED"))
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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/unknown.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 8 additions & 4 deletions programs/dwggrep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand Down
7 changes: 4 additions & 3 deletions programs/dwgread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion programs/dxf2dwg.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ main (int argc, char *argv[])
#ifdef HAVE_VALGRIND_VALGRIND_H
|| (RUNNING_ON_VALGRIND)
#endif
)
)
dwg_free (&dwg);
continue;
}
Expand Down
12 changes: 6 additions & 6 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
82 changes: 42 additions & 40 deletions src/spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 07c078a

Please sign in to comment.