forked from e16/e16
1
0
Fork 0

Introduce E_ARRAY_SIZE() and MOD_ITEMS()

Just a bit tidier.
This commit is contained in:
Kim Woelders 2021-03-18 06:17:47 +01:00
parent 136f37f0b9
commit 358b60baf9
35 changed files with 88 additions and 134 deletions

View File

@ -1243,7 +1243,6 @@ static const IpcItem AclassIpcArray[] = {
" aclass list [name/all] List action class[es]\n"
" aclass load [name] Reload action classes (default is bindings.cfg)\n"}
};
#define N_IPC_FUNCS (sizeof(AclassIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -1253,7 +1252,7 @@ extern const EModule ModAclass;
const EModule ModAclass = {
"aclass", "ac",
AclassSighan,
{N_IPC_FUNCS, AclassIpcArray},
MOD_ITEMS(AclassIpcArray),
{0, NULL}
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -2542,7 +2542,6 @@ static const IpcItem BackgroundsIpcArray[] = {
IPC_BackgroundUse, "use_bg", NULL, "Deprecated - do not use", NULL}
,
};
#define N_IPC_FUNCS (sizeof(BackgroundsIpcArray)/sizeof(IpcItem))
/*
* Configuration items
@ -2553,7 +2552,6 @@ static const CfgItem BackgroundsCfgItems[] = {
CFG_ITEM_BOOL(Conf.backgrounds, no_scan, 0),
CFG_ITEM_INT(Conf.backgrounds, timeout, 240),
};
#define N_CFG_ITEMS (sizeof(BackgroundsCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -2563,6 +2561,6 @@ extern const EModule ModBackgrounds;
const EModule ModBackgrounds = {
"backgrounds", "bg",
BackgroundsSighan,
{N_IPC_FUNCS, BackgroundsIpcArray},
{N_CFG_ITEMS, BackgroundsCfgItems}
MOD_ITEMS(BackgroundsIpcArray),
MOD_ITEMS(BackgroundsCfgItems)
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2018 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -1082,13 +1082,11 @@ static const IpcItem ButtonsIpcArray[] = {
"(removes all buttons)\n \"button_show buttons CONFIG*\" "
"(removes all buttons with CONFIG in the start)\n"},
};
#define N_IPC_FUNCS (sizeof(ButtonsIpcArray)/sizeof(IpcItem))
#if 0
static const CfgItem ButtonsCfgItems[] = {
CFG_ITEM_BOOL(Conf.buttons, enable, 1),
};
#define N_CFG_ITEMS (sizeof(ButtonsCfgItems)/sizeof(CfgItem))
#endif
/*
@ -1099,6 +1097,6 @@ extern const EModule ModButtons;
const EModule ModButtons = {
"buttons", "btn",
ButtonsSighan,
{N_IPC_FUNCS, ButtonsIpcArray},
MOD_ITEMS(ButtonsIpcArray),
{0, NULL}
};

View File

@ -591,12 +591,12 @@ ThemeConfigLoad(void)
"menustyles.cfg",
};
Progressbar *p = NULL;
int i;
unsigned int i;
/* Font mappings */
FontConfigLoad();
for (i = 0; i < (int)(sizeof(config_files) / sizeof(char *)); i++)
for (i = 0; i < E_ARRAY_SIZE(config_files); i++)
{
if (!Mode.wm.restart && Conf.startup.animate)
@ -616,8 +616,7 @@ ThemeConfigLoad(void)
ConfigFileLoad(config_files[i], Mode.theme.path, ConfigFileRead, 1);
if (p)
ProgressbarSet(p, (i * 100) /
(int)(sizeof(config_files) / sizeof(char *)));
ProgressbarSet(p, (i * 100) / E_ARRAY_SIZE(config_files));
/* Hack - We are not running in the event loop here */
EobjsRepaint();

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2018 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -1995,7 +1995,6 @@ static const IpcItem ContainersIpcArray[] = {
" iconbox new <name> Create new iconbox\n"
" iconbox cfg Configure iconboxes\n"}
};
#define N_IPC_FUNCS (sizeof(ContainersIpcArray)/sizeof(IpcItem))
/*
* Configuration items
@ -2003,7 +2002,6 @@ static const IpcItem ContainersIpcArray[] = {
static const CfgItem ContainersCfgItems[] = {
CFG_ITEM_INT(Conf_containers, anim_time, 250),
};
#define N_CFG_ITEMS (sizeof(ContainersCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -2013,6 +2011,6 @@ extern const EModule ModIconboxes;
const EModule ModIconboxes = {
"iconboxes", "ibox",
ContainersSighan,
{N_IPC_FUNCS, ContainersIpcArray},
{N_CFG_ITEMS, ContainersCfgItems}
MOD_ITEMS(ContainersIpcArray),
MOD_ITEMS(ContainersCfgItems)
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2018 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -421,7 +421,6 @@ static const IpcItem CursorIpcArray[] = {
"Cursor functions",
" cursor list Show all cursors\n"}
};
#define N_IPC_FUNCS (sizeof(CursorIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -431,7 +430,6 @@ extern const EModule ModCursors;
const EModule ModCursors = {
"cursor", "csr",
NULL,
{N_IPC_FUNCS, CursorIpcArray}
,
MOD_ITEMS(CursorIpcArray),
{0, NULL}
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2019 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -2984,7 +2984,6 @@ static const IpcItem DesksIpcArray[] = {
" area lmove <dl> Move relative to current linear area\n"}
,
};
#define N_IPC_FUNCS (sizeof(DesksIpcArray)/sizeof(IpcItem))
static void
DesksCfgFuncCount(void *item __UNUSED__, const char *value)
@ -3039,7 +3038,6 @@ static const CfgItem DesksCfgItems[] = {
CFG_ITEM_INT(Conf.desks, edge_flip_mode, EDGE_FLIP_ON),
CFG_ITEM_INT(Conf.desks, edge_flip_resistance, 25),
};
#define N_CFG_ITEMS (sizeof(DesksCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -3049,6 +3047,6 @@ extern const EModule ModDesktops;
const EModule ModDesktops = {
"desktops", "desk",
DesksSighan,
{N_IPC_FUNCS, DesksIpcArray},
{N_CFG_ITEMS, DesksCfgItems}
MOD_ITEMS(DesksIpcArray),
MOD_ITEMS(DesksCfgItems)
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -2622,7 +2622,6 @@ static const IpcItem CompMgrIpcArray[] = {
" cm stop Stop composite manager\n"}
,
};
#define N_IPC_FUNCS (sizeof(CompMgrIpcArray)/sizeof(IpcItem))
static const CfgItem CompMgrCfgItems[] = {
CFG_ITEM_BOOL(Conf_compmgr, enable, 0),
@ -2643,7 +2642,6 @@ static const CfgItem CompMgrCfgItems[] = {
CFG_ITEM_INT(Conf_compmgr, override_redirect.mode, 1),
CFG_ITEM_INT(Conf_compmgr, override_redirect.opacity, 90),
};
#define N_CFG_ITEMS (sizeof(CompMgrCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -2653,8 +2651,8 @@ extern const EModule ModCompMgr;
const EModule ModCompMgr = {
"compmgr", "cm",
ECompMgrSighan,
{N_IPC_FUNCS, CompMgrIpcArray},
{N_CFG_ITEMS, CompMgrCfgItems}
MOD_ITEMS(CompMgrIpcArray),
MOD_ITEMS(CompMgrCfgItems)
};
#endif /* USE_COMPOSITE */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2010 Kim Woelders
* Copyright (C) 2003-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -34,6 +34,8 @@ typedef struct {
CfgItemList cfg;
} EModule;
#define MOD_ITEMS(x) { E_ARRAY_SIZE(x), x }
typedef enum {
ESIGNAL_NONE,
ESIGNAL_INIT,

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -409,7 +409,7 @@ EventsInit(void)
Mode.screen.fps = 60; /* If not randr or weirdness */
for (i = 0; i < sizeof(Extensions) / sizeof(EServerExt); i++)
for (i = 0; i < E_ARRAY_SIZE(Extensions); i++)
ExtQuery(Extensions + i);
#if USE_COMPOSITE
@ -429,7 +429,7 @@ EventsGetExtensionName(int req)
unsigned int i;
EServerExtData *exd;
for (i = 0; i < sizeof(Extensions) / sizeof(EServerExt); i++)
for (i = 0; i < E_ARRAY_SIZE(Extensions); i++)
{
exd = ExtData + Extensions[i].ix;
if (req == exd->major_op)
@ -1247,14 +1247,13 @@ static const char *const TxtEventNames[] = {
"SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage",
"MappingNotify"
};
#define N_EVENT_NAMES (sizeof(TxtEventNames)/sizeof(char*))
static const char *
EventName(unsigned int type)
{
static char buf[16];
if (type < N_EVENT_NAMES)
if (type < E_ARRAY_SIZE(TxtEventNames))
return TxtEventNames[type];
switch (type)
@ -1292,12 +1291,11 @@ EventName(unsigned int type)
static const char *const TxtEventNotifyModeNames[] = {
"NotifyNormal", "NotifyGrab", "NotifyUngrab", "NotifyWhileGrabbed"
};
#define N_EVENT_NOTIFY_MODE_NAMES (sizeof(TxtEventNotifyModeNames)/sizeof(char*))
static const char *
EventNotifyModeName(unsigned int mode)
{
if (mode < N_EVENT_NOTIFY_MODE_NAMES)
if (mode < E_ARRAY_SIZE(TxtEventNotifyModeNames))
return TxtEventNotifyModeNames[mode];
return "Unknown";
@ -1308,12 +1306,11 @@ static const char *const TxtEventNotifyDetailNames[] = {
"NotifyNonlinearVirtual", "NotifyPointer", "NotifyPointerRoot",
"NotifyDetailNone"
};
#define N_EVENT_NOTIFY_DETAIL_NAMES (sizeof(TxtEventNotifyDetailNames)/sizeof(char*))
static const char *
EventNotifyDetailName(unsigned int detail)
{
if (detail < N_EVENT_NOTIFY_DETAIL_NAMES)
if (detail < E_ARRAY_SIZE(TxtEventNotifyDetailNames))
return TxtEventNotifyDetailNames[detail];
return "Unknown";

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2020 Kim Woelders
* Copyright (C) 2003-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -386,7 +386,7 @@ void
EWMH_SetWindowState(const EWin * ewin)
{
EX_Atom atom_list[64];
int len = sizeof(atom_list) / sizeof(EX_Atom);
int len = E_ARRAY_SIZE(atom_list);
int atom_count;
atom_count = 0;

View File

@ -1207,7 +1207,6 @@ static const IpcItem FocusIpcArray[] = {
" the last window does not lose the focus\n"}
,
};
#define N_IPC_FUNCS (sizeof(FocusIpcArray)/sizeof(IpcItem))
static const CfgItem FocusCfgItems[] = {
CFG_ITEM_INT(Conf.focus, mode, MODE_FOCUS_SLOPPY),
@ -1225,7 +1224,6 @@ static const CfgItem FocusCfgItems[] = {
CFG_ITEM_BOOL(Conf, autoraise.enable, 0),
CFG_ITEM_INT(Conf, autoraise.delay, 500),
};
#define N_CFG_ITEMS (sizeof(FocusCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -1235,6 +1233,6 @@ extern const EModule ModFocus;
const EModule ModFocus = {
"focus", NULL,
FocusSighan,
{N_IPC_FUNCS, FocusIpcArray},
{N_CFG_ITEMS, FocusCfgItems}
MOD_ITEMS(FocusIpcArray),
MOD_ITEMS(FocusCfgItems)
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2015 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -333,7 +333,6 @@ static FXHandler fx_handlers[] = {
{"ripples", FX_Ripple_Init, FX_Ripple_Ops, 0, 0},
{"waves", FX_Waves_Init, FX_Waves_Ops, 0, 0},
};
#define N_FX_HANDLERS (sizeof(fx_handlers)/sizeof(FXHandler))
/****************************** Effect handlers *****************************/
@ -387,7 +386,7 @@ FX_OpForEach(int op)
{
unsigned int i;
for (i = 0; i < N_FX_HANDLERS; i++)
for (i = 0; i < E_ARRAY_SIZE(fx_handlers); i++)
FX_Op(&fx_handlers[i], op);
}
@ -487,7 +486,6 @@ static const CfgItem FxCfgItems[] = {
CFR_FUNC_BOOL(fx_handlers[0].enabled, ripples.enabled, 0, FxCfgFunc),
CFR_FUNC_BOOL(fx_handlers[1].enabled, waves.enabled, 0, FxCfgFunc),
};
#define N_CFG_ITEMS (sizeof(FxCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -498,5 +496,5 @@ const EModule ModEffects = {
"effects", "fx",
FxSighan,
{0, NULL},
{N_CFG_ITEMS, FxCfgItems}
MOD_ITEMS(FxCfgItems)
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2020 Kim Woelders
* Copyright (C) 2007-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -760,12 +760,10 @@ static const IpcItem GlwinIpcArray[] = {
" glwin\n"}
,
};
#define N_IPC_FUNCS (sizeof(GlwinIpcArray)/sizeof(IpcItem))
static const CfgItem GlwinCfgItems[] = {
CFG_ITEM_INT(Conf_glwin, mode, 0),
};
#define N_CFG_ITEMS (sizeof(GlwinCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -775,6 +773,6 @@ extern const EModule ModGlwin;
const EModule ModGlwin = {
"glwin", NULL,
GlwinSighan,
{N_IPC_FUNCS, GlwinIpcArray},
{N_CFG_ITEMS, GlwinCfgItems}
MOD_ITEMS(GlwinIpcArray),
MOD_ITEMS(GlwinCfgItems)
};

View File

@ -1430,7 +1430,6 @@ static const IpcItem GroupsIpcArray[] = {
" group <groupid> shade <on/off/?>\n"}
,
};
#define N_IPC_FUNCS (sizeof(GroupsIpcArray)/sizeof(IpcItem))
/*
* Configuration items
@ -1445,13 +1444,12 @@ static const CfgItem GroupsCfgItems[] = {
CFG_ITEM_BOOL(Conf_groups, dflt.shade, 1),
CFG_ITEM_BOOL(Conf_groups, swapmove, 1),
};
#define N_CFG_ITEMS (sizeof(GroupsCfgItems)/sizeof(CfgItem))
extern const EModule ModGroups;
const EModule ModGroups = {
"groups", "grp",
NULL,
{N_IPC_FUNCS, GroupsIpcArray},
{N_CFG_ITEMS, GroupsCfgItems}
MOD_ITEMS(GroupsIpcArray),
MOD_ITEMS(GroupsCfgItems)
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2019 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -142,7 +142,7 @@ doSignalsSetup(int setup)
sigemptyset(&sa.sa_mask);
sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) NULL);
for (i = 0; i < sizeof(signals) / sizeof(int); i++)
for (i = 0; i < E_ARRAY_SIZE(signals); i++)
{
sig = signals[i];
if (Mode.wm.coredump &&

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2020 Kim Woelders
* Copyright (C) 2003-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -40,8 +40,6 @@
static void EHintsSetDeskInfo(void);
static void EHintsSetAreaInfo(void);
#define N_ITEMS(x) (sizeof(x)/sizeof(x[0]))
static const char *const atoms_misc_names[] = {
/* Misc atoms */
"MANAGER",
@ -71,7 +69,7 @@ HintsInit(void)
{
EX_Window win;
ex_atoms_get(atoms_misc_names, N_ITEMS(atoms_misc_names), atoms_misc);
ex_atoms_get(atoms_misc_names, E_ARRAY_SIZE(atoms_misc_names), atoms_misc);
win = XCreateSimpleWindow(disp, WinGetXwin(VROOT), -200, -200, 5, 5,
0, 0, 0);

View File

@ -1305,7 +1305,6 @@ static const IpcItem ImageclassIpcArray[] = {
NULL}
,
};
#define N_IPC_FUNCS (sizeof(ImageclassIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -1315,7 +1314,6 @@ extern const EModule ModImageclass;
const EModule ModImageclass = {
"imageclass", "ic",
NULL,
{N_IPC_FUNCS, ImageclassIpcArray}
,
MOD_ITEMS(ImageclassIpcArray),
{0, NULL}
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -1446,13 +1446,13 @@ IPC_InsertKeys(const char *params, Client * c __UNUSED__)
ev.window = win;
for (i = 0; i < (int)strlen(s); i++)
{
int j;
unsigned int j;
ev.x = Mode.events.cx;
ev.y = Mode.events.cy;
ev.x_root = Mode.events.cx;
ev.y_root = Mode.events.cy;
for (j = 0; j < (int)(sizeof(ks) / sizeof(struct _keyset)); j++)
for (j = 0; j < E_ARRAY_SIZE(ks); j++)
{
if (strncmp(ks[j].ch, &(s[i]), strlen(ks[j].ch)))
continue;
@ -1723,7 +1723,7 @@ IPC_GetList(int *pnum)
return ipc_item_list;
}
num = sizeof(IPCArray) / sizeof(IpcItem);
num = E_ARRAY_SIZE(IPCArray);
lst = EMALLOC(const IpcItem *, num);
for (i = 0; i < num; i++)

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2018 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -447,7 +447,6 @@ static const CfgItem LocaleCfgItems[] = {
CFG_FUNC_STR(Conf_locale, internal, LangCfgChange),
CFG_ITEM_STR(Conf_locale, exported),
};
#define N_CFG_ITEMS (sizeof(LocaleCfgItems)/sizeof(CfgItem))
extern const EModule ModLocale;
@ -455,5 +454,5 @@ const EModule ModLocale = {
"locale", NULL,
NULL,
{0, NULL},
{N_CFG_ITEMS, LocaleCfgItems}
MOD_ITEMS(LocaleCfgItems)
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2015 Kim Woelders
* Copyright (C) 2007-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -569,7 +569,6 @@ static const IpcItem MagwinIpcArray[] = {
" mag [show|hide]\n"}
,
};
#define N_IPC_FUNCS (sizeof(MagwinIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -579,6 +578,6 @@ extern const EModule ModMagwin;
const EModule ModMagwin = {
"magwin", NULL,
NULL,
{N_IPC_FUNCS, MagwinIpcArray},
MOD_ITEMS(MagwinIpcArray),
{0, NULL}
};

View File

@ -385,7 +385,7 @@ EoptGet(int argc, char **argv)
eoptarg = NULL;
eopt = NULL;
for (i = 0; i < sizeof(Eopts) / sizeof(EOpt); i++)
for (i = 0; i < E_ARRAY_SIZE(Eopts); i++)
{
eopt = &Eopts[i];
@ -447,7 +447,7 @@ EoptHelp(void)
char buf[256];
printf("e16 options:\n");
for (i = 0; i < sizeof(Eopts) / sizeof(EOpt); i++)
for (i = 0; i < E_ARRAY_SIZE(Eopts); i++)
{
eopt = &Eopts[i];
if (!eopt->desc)

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -1123,7 +1123,7 @@ static const char *const menu_aliases[] = {
"ROOT_2", "enlightenment.menu",
"WINOPS_MENU", "winops.menu",
};
#define N_MENU_ALIASES (sizeof(menu_aliases)/sizeof(char*)/2)
#define N_MENU_ALIASES (E_ARRAY_SIZE(menu_aliases)/2)
static const char *
_MenuCheckAlias(const char *name)
@ -2089,7 +2089,6 @@ static const IpcItem MenusIpcArray[] = {
" menus show <name> Show named menu\n"}
,
};
#define N_IPC_FUNCS (sizeof(MenusIpcArray)/sizeof(IpcItem))
static const CfgItem MenusCfgItems[] = {
CFG_ITEM_BOOL(Conf.menus, animate, 0),
@ -2104,7 +2103,6 @@ static const CfgItem MenusCfgItems[] = {
CFG_ITEM_HEX(Conf.menus, key.escape, XK_Escape),
CFG_ITEM_HEX(Conf.menus, key.ret, XK_Return),
};
#define N_CFG_ITEMS (sizeof(MenusCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -2114,6 +2112,6 @@ extern const EModule ModMenus;
const EModule ModMenus = {
"menus", "menu",
MenusSighan,
{N_IPC_FUNCS, MenusIpcArray},
{N_CFG_ITEMS, MenusCfgItems}
MOD_ITEMS(MenusIpcArray),
MOD_ITEMS(MenusCfgItems)
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2020 Kim Woelders
* Copyright (C) 2003-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -100,7 +100,7 @@ const EModule *const p_modules[] = {
&ModWarplist,
&ModWindowMatch,
};
int n_modules = sizeof(p_modules) / sizeof(EModule *);
int n_modules = E_ARRAY_SIZE(p_modules);
#if 0
static void
@ -219,14 +219,13 @@ static const CfgItem MiscCfgItems[] = {
CFG_ITEM_BOOL(Conf, memory_paranoia, 1),
CFG_ITEM_BOOL(Conf, save_under, 0),
};
#define N_CFG_ITEMS ((int)(sizeof(MiscCfgItems)/sizeof(CfgItem)))
/* Stuff not elsewhere */
const EModule ModMisc = {
"misc", NULL,
NULL,
{0, NULL},
{N_CFG_ITEMS, MiscCfgItems}
MOD_ITEMS(MiscCfgItems)
};
void

View File

@ -2123,7 +2123,6 @@ static const IpcItem PagersIpcArray[] = {
" pager zoom <on/off> Toggle zooming in the pager\n"}
,
};
#define N_IPC_FUNCS (sizeof(PagersIpcArray)/sizeof(IpcItem))
/*
* Configuration items
@ -2139,7 +2138,6 @@ static const CfgItem PagersCfgItems[] = {
CFG_ITEM_INT(Conf_pagers, win_button, 1),
CFG_ITEM_INT(Conf_pagers, menu_button, 3),
};
#define N_CFG_ITEMS (sizeof(PagersCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -2149,6 +2147,6 @@ extern const EModule ModPagers;
const EModule ModPagers = {
"pagers", "pg",
PagersSighan,
{N_IPC_FUNCS, PagersIpcArray},
{N_CFG_ITEMS, PagersCfgItems}
MOD_ITEMS(PagersIpcArray),
MOD_ITEMS(PagersCfgItems)
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -711,7 +711,6 @@ static const DialogDef *const dialogs[] = {
&DlgSession,
&DlgMisc,
};
#define N_CFG_DLGS (sizeof(dialogs)/sizeof(DialogDef*))
static void
CB_DlgSelect(Dialog * d, int val, void *data)
@ -746,7 +745,7 @@ _DlgFillConfiguration(Dialog * d, DItem * table, void *data __UNUSED__)
buttons = DialogAddItem(table, DITEM_TABLE);
content = DialogAddItem(table, DITEM_TABLE);
for (i = 0; i < N_CFG_DLGS; i++)
for (i = 0; i < E_ARRAY_SIZE(dialogs); i++)
{
di = DialogAddItem(buttons, DITEM_BUTTON);
DialogItemSetPadding(di, 2, 2, 0, 0);
@ -780,7 +779,7 @@ IPC_Cfg(const char *params)
return;
}
for (i = 0; i < N_CFG_DLGS; i++)
for (i = 0; i < E_ARRAY_SIZE(dialogs); i++)
{
name = dialogs[i]->label;
if (Estrcasecmp(params, name))

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -500,7 +500,6 @@ static const IpcItem SlideoutsIpcArray[] = {
{
IPC_Slideout, "slideout", NULL, "Show slideout", NULL},
};
#define N_IPC_FUNCS (sizeof(SlideoutsIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -510,6 +509,6 @@ extern const EModule ModSlideouts;
const EModule ModSlideouts = {
"slideouts", "slideout",
SlideoutsSighan,
{N_IPC_FUNCS, SlideoutsIpcArray},
MOD_ITEMS(SlideoutsIpcArray),
{0, NULL}
};

View File

@ -562,7 +562,6 @@ static const IpcItem SoundIpcArray[] = {
" sound on Enable sounds\n"
" sound play <classname> Play sounds\n"}
};
#define N_IPC_FUNCS (sizeof(SoundIpcArray)/sizeof(IpcItem))
static const CfgItem SoundCfgItems[] = {
CFG_FUNC_BOOL(Conf_sound, enable, 0, _SoundEnableChange),
@ -570,7 +569,6 @@ static const CfgItem SoundCfgItems[] = {
CFG_ITEM_HEX(Conf_sound, mask1, 0),
CFG_ITEM_HEX(Conf_sound, mask2, 0),
};
#define N_CFG_ITEMS (sizeof(SoundCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -580,8 +578,8 @@ extern const EModule ModSound;
const EModule ModSound = {
"sound", "audio",
_SoundSighan,
{N_IPC_FUNCS, SoundIpcArray},
{N_CFG_ITEMS, SoundCfgItems}
MOD_ITEMS(SoundIpcArray),
MOD_ITEMS(SoundCfgItems)
};
#endif /* ENABLE_SOUND */

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2014 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -486,7 +486,6 @@ static const IpcItem TextclassIpcArray[] = {
NULL}
,
};
#define N_IPC_FUNCS (sizeof(TextclassIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -496,7 +495,6 @@ extern const EModule ModTextclass;
const EModule ModTextclass = {
"textclass", "tc",
NULL,
{N_IPC_FUNCS, TextclassIpcArray}
,
MOD_ITEMS(TextclassIpcArray),
{0, NULL}
};

View File

@ -507,7 +507,6 @@ static const IpcItem ThemeIpcArray[] = {
" theme use <name> Switch to theme <name>\n"}
,
};
#define N_IPC_FUNCS (sizeof(ThemeIpcArray)/sizeof(IpcItem))
static const CfgItem ThemeCfgItems[] = {
CFG_ITEM_STR(Conf.theme, name),
@ -516,7 +515,6 @@ static const CfgItem ThemeCfgItems[] = {
CFG_ITEM_BOOL(Conf.theme, use_alt_font_cfg, 0),
CFG_ITEM_STR(Conf.theme, font_cfg),
};
#define N_CFG_ITEMS (sizeof(ThemeCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -526,6 +524,6 @@ extern const EModule ModTheme;
const EModule ModTheme = {
"theme", "th",
NULL,
{N_IPC_FUNCS, ThemeIpcArray},
{N_CFG_ITEMS, ThemeCfgItems}
MOD_ITEMS(ThemeIpcArray),
MOD_ITEMS(ThemeCfgItems)
};

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -883,7 +883,6 @@ static const CfgItem TooltipsCfgItems[] = {
CFG_ITEM_BOOL(Conf_tooltips, showroottooltip, 1),
CFG_ITEM_INT(Conf_tooltips, delay, 1500),
};
#define N_CFG_ITEMS (sizeof(TooltipsCfgItems)/sizeof(CfgItem))
/*
* Module descriptor
@ -894,5 +893,5 @@ const EModule ModTooltips = {
"tooltips", "tt",
TooltipsSighan,
{0, NULL},
{N_CFG_ITEMS, TooltipsCfgItems}
MOD_ITEMS(TooltipsCfgItems)
};

View File

@ -136,4 +136,6 @@ unsigned int GetTimeUs(void);
void SleepUs(unsigned int tus);
#define E_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif /* _UTIL_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2020 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -552,7 +552,6 @@ static const CfgItem WarplistCfgItems[] = {
CFG_ITEM_BOOL(Conf.warplist, show_shape, 0),
CFG_ITEM_INT(Conf.warplist, icon_mode, EWIN_ICON_MODE_APP_IMG),
};
#define N_CFG_ITEMS (sizeof(WarplistCfgItems)/sizeof(CfgItem))
extern const EModule ModWarplist;
@ -560,5 +559,5 @@ const EModule ModWarplist = {
"warplist", "warp",
NULL,
{0, NULL},
{N_CFG_ITEMS, WarplistCfgItems}
MOD_ITEMS(WarplistCfgItems)
};

View File

@ -977,7 +977,6 @@ static const IpcItem WindowMatchIpcArray[] = {
" wmatch list List window matches\n"}
,
};
#define N_IPC_FUNCS (sizeof(WindowMatchIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
@ -987,7 +986,6 @@ extern const EModule ModWindowMatch;
const EModule ModWindowMatch = {
"winmatch", NULL,
WindowMatchSighan,
{N_IPC_FUNCS, WindowMatchIpcArray}
,
MOD_ITEMS(WindowMatchIpcArray),
{0, NULL}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2019 Kim Woelders
* Copyright (C) 2004-2021 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -43,8 +43,6 @@
#define _ex_disp disp
#define N_ITEMS(x) (sizeof(x)/sizeof(x[0]))
/*
* General stuff
*/
@ -600,9 +598,9 @@ void
ex_icccm_init(void)
{
#if DEBUG_CHECK
assert(CHECK_COUNT_ICCCM == N_ITEMS(atoms_icccm));
assert(CHECK_COUNT_ICCCM == E_ARRAY_SIZE(atoms_icccm));
#endif
ex_atoms_get(atoms_icccm_names, N_ITEMS(atoms_icccm), atoms_icccm);
ex_atoms_get(atoms_icccm_names, E_ARRAY_SIZE(atoms_icccm), atoms_icccm);
}
static void
@ -822,9 +820,9 @@ void
ex_netwm_init(void)
{
#if DEBUG_CHECK
assert(CHECK_COUNT_NETWM == N_ITEMS(atoms_netwm));
assert(CHECK_COUNT_NETWM == E_ARRAY_SIZE(atoms_netwm));
#endif
ex_atoms_get(atoms_netwm_names, N_ITEMS(atoms_netwm), atoms_netwm);
ex_atoms_get(atoms_netwm_names, E_ARRAY_SIZE(atoms_netwm), atoms_netwm);
}
/*