Skip to content

Commit

Permalink
format code with clang-format-15
Browse files Browse the repository at this point in the history
  • Loading branch information
jason authored and nosracd committed Jul 19, 2024
1 parent e2180e2 commit 4fbd67e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 44 deletions.
2 changes: 1 addition & 1 deletion lcm-logger/glib_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifdef WIN32
#define SIGKILL 2
#include "../lcm/windows/WinPorting.h"
//#include <Winsock2.h>
// #include <Winsock2.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion lcm-python/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "pylcm_subscription.h"

//#define dbg(...) fprintf (stderr, __VA_ARGS__)
// #define dbg(...) fprintf (stderr, __VA_ARGS__)
#define dbg(...)

// to support python 2.5 and earlier
Expand Down
4 changes: 2 additions & 2 deletions lcm-python/pylcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
} while (0)
#endif

//#define dbg(...) fprintf (stderr, __VA_ARGS__)
//#define dbg(...)
// #define dbg(...) fprintf (stderr, __VA_ARGS__)
// #define dbg(...)

// to support python 2.5 and earlier
#ifndef Py_TYPE
Expand Down
73 changes: 33 additions & 40 deletions lcm/dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ extern "C" {
{ DBG_14, _BBLUE_ }, \
{ DBG_15, _BMAGENTA_ }, \
{ DBG_16, _BWHITE_ } \
// clang-format on

#define DBG_ENV "LCM_DBG"
// clang-format on

#define DBG_ENV "LCM_DBG"

// =================== do not modify after this line ==================

Expand All @@ -124,30 +123,22 @@ typedef struct dbg_mode_color {
const char *color;
} dbg_mode_color_t;

static dbg_mode_color_t dbg_colortab[] = {DBG_COLORTAB};

static dbg_mode_color_t dbg_colortab[] = {
DBG_COLORTAB
};
static dbg_mode_t dbg_nametab[] = {DBG_NAMETAB};

static dbg_mode_t dbg_nametab[] = {
DBG_NAMETAB
};

static inline
const char* DCOLOR(unsigned long long d_mode)
static inline const char *DCOLOR(unsigned long long d_mode)
{
dbg_mode_color_t *mode;

for (mode = dbg_colortab; mode->d_mode != 0; mode++)
{
for (mode = dbg_colortab; mode->d_mode != 0; mode++) {
if (mode->d_mode & d_mode)
return mode->color;
}

return _BWHITE_;
}


static void dbg_init()
{
const char *dbg_env;
Expand All @@ -162,62 +153,64 @@ static void dbg_init()
char env[256];
strncpy(env, dbg_env, sizeof(env));
env[sizeof(env) - 1] = '\0';
for (char *name = strtok(env,","); name; name = strtok(NULL, ",")) {
for (char *name = strtok(env, ","); name; name = strtok(NULL, ",")) {
int cancel;
dbg_mode_t *mode;

if (*name == '-') {
cancel = 1;
name++;
}
else
} else
cancel = 0;

for (mode = dbg_nametab; mode->d_name != NULL; mode++)
if (strcmp(name, mode->d_name) == 0)
break;
if (mode->d_name == NULL) {
fprintf(stderr, "Warning: Unknown debug option: "
"\"%s\"\n", name);
fprintf(stderr,
"Warning: Unknown debug option: "
"\"%s\"\n",
name);
return;
}

if (cancel)
{
if (cancel) {
dbg_modes &= ~mode->d_mode;
}
else
{
dbg_modes = dbg_modes | mode->d_mode;
} else {
dbg_modes = dbg_modes | mode->d_mode;
}
}
}
}

#ifndef NO_DBG

#define dbg(mode, ...) { \
if( !dbg_initiated) dbg_init(); \
if( dbg_modes & (mode) ) { \
printf("%s", DCOLOR(mode)); \
printf(__VA_ARGS__); \
printf(_NORMAL_); \
} \
}
#define dbg(mode, ...) \
{ \
if (!dbg_initiated) \
dbg_init(); \
if (dbg_modes & (mode)) { \
printf("%s", DCOLOR(mode)); \
printf(__VA_ARGS__); \
printf(_NORMAL_); \
} \
}
#define dbg_active(mode) (dbg_modes & (mode))

#else

#define dbg(mode, ...)
#define dbg(mode, ...)
#define dbg_active(mode) false
#define cdbg(mode,color,dtag,arg)
#define cdbg(mode, color, dtag, arg)

#endif

#define cprintf(color, ...) { printf(color); printf(__VA_ARGS__); \
printf(_NORMAL_); }


#define cprintf(color, ...) \
{ \
printf(color); \
printf(__VA_ARGS__); \
printf(_NORMAL_); \
}

#ifdef __cplusplus
}
Expand Down

0 comments on commit 4fbd67e

Please sign in to comment.