mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
wmaker: Use the macro 'wlengthof' to get the number of element in an array
The new macro 'wlengthof' from WUtil makes code easier to read than the previous [sizeof() / sizeof([0]) ] construct. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
a3b6b62049
commit
be022d9623
@@ -772,7 +772,7 @@ static void initDefaults(void)
|
|||||||
|
|
||||||
WMPLSetCaseSensitive(False);
|
WMPLSetCaseSensitive(False);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
|
for (i = 0; i < wlengthof(optionList); i++) {
|
||||||
entry = &optionList[i];
|
entry = &optionList[i];
|
||||||
|
|
||||||
entry->plkey = WMCreatePLString(entry->key);
|
entry->plkey = WMCreatePLString(entry->key);
|
||||||
@@ -782,7 +782,7 @@ static void initDefaults(void)
|
|||||||
entry->plvalue = NULL;
|
entry->plvalue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
|
for (i = 0; i < wlengthof(staticOptionList); i++) {
|
||||||
entry = &staticOptionList[i];
|
entry = &staticOptionList[i];
|
||||||
|
|
||||||
entry->plkey = WMCreatePLString(entry->key);
|
entry->plkey = WMCreatePLString(entry->key);
|
||||||
@@ -937,7 +937,7 @@ void wReadStaticDefaults(WMPropList * dict)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
void *tdata;
|
void *tdata;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
|
for (i = 0; i < wlengthof(staticOptionList); i++) {
|
||||||
entry = &staticOptionList[i];
|
entry = &staticOptionList[i];
|
||||||
|
|
||||||
if (dict)
|
if (dict)
|
||||||
@@ -1094,7 +1094,7 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict)
|
|||||||
|
|
||||||
needs_refresh = 0;
|
needs_refresh = 0;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
|
for (i = 0; i < wlengthof(optionList); i++) {
|
||||||
entry = &optionList[i];
|
entry = &optionList[i];
|
||||||
|
|
||||||
if (new_dict)
|
if (new_dict)
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ void StartUp(Bool defaultScreenOnly)
|
|||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
int dummy;
|
int dummy;
|
||||||
#endif
|
#endif
|
||||||
Atom atom[sizeof(atomNames) / sizeof(atomNames[0])];
|
Atom atom[wlengthof(atomNames)];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore CapsLock in modifiers
|
* Ignore CapsLock in modifiers
|
||||||
@@ -437,12 +437,12 @@ void StartUp(Bool defaultScreenOnly)
|
|||||||
/* _XA_VERSION = XInternAtom(dpy, "VERSION", False); */
|
/* _XA_VERSION = XInternAtom(dpy, "VERSION", False); */
|
||||||
|
|
||||||
#ifdef HAVE_XINTERNATOMS
|
#ifdef HAVE_XINTERNATOMS
|
||||||
XInternAtoms(dpy, atomNames, sizeof(atomNames) / sizeof(atomNames[0]), False, atom);
|
XInternAtoms(dpy, atomNames, wlengthof(atomNames), False, atom);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < sizeof(atomNames) / sizeof(atomNames[0]); i++)
|
for (i = 0; i < wlengthof(atomNames); i++)
|
||||||
atom[i] = XInternAtom(dpy, atomNames[i], False);
|
atom[i] = XInternAtom(dpy, atomNames[i], False);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -831,7 +831,7 @@ static void revertSettings(WMWidget *button, void *client_data)
|
|||||||
|
|
||||||
wWindowSetupInitialAttributes(wwin, &level, &workspace);
|
wWindowSetupInitialAttributes(wwin, &level, &workspace);
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(panel->attrChk) / sizeof(panel->attrChk[0])); i++) {
|
for (i = 0; i < wlengthof(panel->attrChk); i++) {
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
@@ -872,7 +872,7 @@ static void revertSettings(WMWidget *button, void *client_data)
|
|||||||
WMSetButtonSelected(panel->attrChk[i], flag);
|
WMSetButtonSelected(panel->attrChk[i], flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(panel->moreChk) / sizeof(panel->moreChk[0])); i++) {
|
for (i = 0; i < wlengthof(panel->moreChk); i++) {
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
@@ -918,7 +918,7 @@ static void revertSettings(WMWidget *button, void *client_data)
|
|||||||
WMSetButtonSelected(panel->moreChk[i], flag);
|
WMSetButtonSelected(panel->moreChk[i], flag);
|
||||||
}
|
}
|
||||||
if (panel->appFrm && wapp) {
|
if (panel->appFrm && wapp) {
|
||||||
for (i = 0; i < (sizeof(panel->appChk) / sizeof(panel->appChk[0])); i++) {
|
for (i = 0; i < wlengthof(panel->appChk); i++) {
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
@@ -1318,7 +1318,7 @@ static void create_tab_window_attributes(WWindow *wwin, InspectorPanel *panel, i
|
|||||||
WMMoveWidget(panel->attrFrm, 15, 45);
|
WMMoveWidget(panel->attrFrm, 15, 45);
|
||||||
WMResizeWidget(panel->attrFrm, frame_width, 250);
|
WMResizeWidget(panel->attrFrm, frame_width, 250);
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(panel->attrChk) / sizeof(panel->attrChk[0])); i++) {
|
for (i = 0; i < wlengthof(panel->attrChk); i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
caption = _("Disable titlebar");
|
caption = _("Disable titlebar");
|
||||||
@@ -1402,7 +1402,7 @@ static void create_tab_window_advanced(WWindow *wwin, InspectorPanel *panel, int
|
|||||||
WMMoveWidget(panel->moreFrm, 15, 45);
|
WMMoveWidget(panel->moreFrm, 15, 45);
|
||||||
WMResizeWidget(panel->moreFrm, frame_width, 265);
|
WMResizeWidget(panel->moreFrm, frame_width, 265);
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(panel->moreChk) / sizeof(panel->moreChk[0])); i++) {
|
for (i = 0; i < wlengthof(panel->moreChk); i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
caption = _("Do not bind keyboard shortcuts");
|
caption = _("Do not bind keyboard shortcuts");
|
||||||
@@ -1565,7 +1565,7 @@ static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int fr
|
|||||||
WMMoveWidget(panel->appFrm, 15, 50);
|
WMMoveWidget(panel->appFrm, 15, 50);
|
||||||
WMResizeWidget(panel->appFrm, frame_width, 240);
|
WMResizeWidget(panel->appFrm, frame_width, 240);
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(panel->appChk) / sizeof(panel->appChk[0])); i++) {
|
for (i = 0; i < wlengthof(panel->appChk); i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
caption = _("Start hidden");
|
caption = _("Start hidden");
|
||||||
|
|||||||
18
src/wmspec.c
18
src/wmspec.c
@@ -198,8 +198,6 @@ static atomitem_t atomNames[] = {
|
|||||||
{"UTF8_STRING", &utf8_string},
|
{"UTF8_STRING", &utf8_string},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define atomNr (sizeof(atomNames)/sizeof(atomNames[0]))
|
|
||||||
|
|
||||||
#define _NET_WM_STATE_REMOVE 0
|
#define _NET_WM_STATE_REMOVE 0
|
||||||
#define _NET_WM_STATE_ADD 1
|
#define _NET_WM_STATE_ADD 1
|
||||||
#define _NET_WM_STATE_TOGGLE 2
|
#define _NET_WM_STATE_TOGGLE 2
|
||||||
@@ -235,7 +233,7 @@ typedef struct NetData {
|
|||||||
|
|
||||||
static void setSupportedHints(WScreen *scr)
|
static void setSupportedHints(WScreen *scr)
|
||||||
{
|
{
|
||||||
Atom atom[atomNr];
|
Atom atom[wlengthof(atomNames)];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
/* set supported hints list */
|
/* set supported hints list */
|
||||||
@@ -534,19 +532,19 @@ void wNETWMInitStuff(WScreen *scr)
|
|||||||
|
|
||||||
#ifdef HAVE_XINTERNATOMS
|
#ifdef HAVE_XINTERNATOMS
|
||||||
{
|
{
|
||||||
Atom atoms[atomNr];
|
Atom atoms[wlengthof(atomNames)];
|
||||||
char *names[atomNr];
|
char *names[wlengthof(atomNames)];
|
||||||
|
|
||||||
for (i = 0; i < atomNr; ++i)
|
for (i = 0; i < wlengthof(atomNames); ++i)
|
||||||
names[i] = atomNames[i].name;
|
names[i] = atomNames[i].name;
|
||||||
|
|
||||||
XInternAtoms(dpy, &names[0], atomNr, False, atoms);
|
XInternAtoms(dpy, &names[0], wlengthof(atomNames), False, atoms);
|
||||||
for (i = 0; i < atomNr; ++i)
|
for (i = 0; i < wlengthof(atomNames); ++i)
|
||||||
*atomNames[i].atom = atoms[i];
|
*atomNames[i].atom = atoms[i];
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < atomNr; i++)
|
for (i = 0; i < wlengthof(atomNames); i++)
|
||||||
*atomNames[i].atom = XInternAtom(dpy, atomNames[i].name, False);
|
*atomNames[i].atom = XInternAtom(dpy, atomNames[i].name, False);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -585,7 +583,7 @@ void wNETWMCleanup(WScreen *scr)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < atomNr; i++)
|
for (i = 0; i < wlengthof(atomNames); i++)
|
||||||
XDeleteProperty(dpy, scr->root_win, *atomNames[i].atom);
|
XDeleteProperty(dpy, scr->root_win, *atomNames[i].atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ void FormatXError(Display * dpy, XErrorEvent * error, char *buffer, int size)
|
|||||||
if (i > size - 100)
|
if (i > size - 100)
|
||||||
return;
|
return;
|
||||||
buffer += i;
|
buffer += i;
|
||||||
if (error->request_code >= sizeof(requestCodes) / sizeof(requestCodes[0])) {
|
if (error->request_code >= wlengthof(requestCodes)) {
|
||||||
sprintf(buffer, "\n Request code: %i\n", error->request_code);
|
sprintf(buffer, "\n Request code: %i\n", error->request_code);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "\n Request code: %i %s\n", error->request_code,
|
sprintf(buffer, "\n Request code: %i %s\n", error->request_code,
|
||||||
|
|||||||
Reference in New Issue
Block a user