mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-24 16:25:46 +01:00
WINGs: 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
fd47650717
commit
a3b6b62049
@@ -596,7 +596,7 @@ static void menu_parser_condition_ifmacro(WMenuParser parser, Bool check_exists)
|
|||||||
parser->rd++;
|
parser->rd++;
|
||||||
|
|
||||||
/* Add this condition to the stack of conditions */
|
/* Add this condition to the stack of conditions */
|
||||||
if (parser->cond.depth >= sizeof(parser->cond.stack) / sizeof(parser->cond.stack[0])) {
|
if (parser->cond.depth >= wlengthof(parser->cond.stack)) {
|
||||||
WMenuParserError(parser, _("too many nested #if sequences") );
|
WMenuParserError(parser, _("too many nested #if sequences") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ void menu_parser_define_macro(WMenuParser parser)
|
|||||||
}
|
}
|
||||||
if (*parser->rd == ')') break;
|
if (*parser->rd == ')') break;
|
||||||
|
|
||||||
if (macro->arg_count >= sizeof(arg_name) / sizeof(arg_name[0])) {
|
if (macro->arg_count >= wlengthof(arg_name)) {
|
||||||
WMenuParserError(parser, _("too many parameters for macro \"%s\" definition"), macro->name);
|
WMenuParserError(parser, _("too many parameters for macro \"%s\" definition"), macro->name);
|
||||||
wfree(macro);
|
wfree(macro);
|
||||||
*parser->rd = '\0'; // fake end-of-line to avoid warnings from remaining line content
|
*parser->rd = '\0'; // fake end-of-line to avoid warnings from remaining line content
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ static void addSizeToTypeface(Typeface * face, int size)
|
|||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < sizeof(scalableFontSizes) / sizeof(scalableFontSizes[0]); j++) {
|
for (j = 0; j < wlengthof(scalableFontSizes); j++) {
|
||||||
size = scalableFontSizes[j];
|
size = scalableFontSizes[j];
|
||||||
|
|
||||||
if (!WMCountInArray(face->sizes, (void *)(uintptr_t) size)) {
|
if (!WMCountInArray(face->sizes, (void *)(uintptr_t) size)) {
|
||||||
|
|||||||
@@ -550,7 +550,7 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
|
|||||||
"_NET_WM_ICON_NAME",
|
"_NET_WM_ICON_NAME",
|
||||||
"_NET_WM_ICON",
|
"_NET_WM_ICON",
|
||||||
};
|
};
|
||||||
Atom atoms[sizeof(atomNames) / sizeof(atomNames[0])];
|
Atom atoms[wlengthof(atomNames)];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@@ -801,9 +801,9 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XINTERNATOMS
|
#ifdef HAVE_XINTERNATOMS
|
||||||
XInternAtoms(display, atomNames, sizeof(atomNames) / sizeof(atomNames[0]), False, atoms);
|
XInternAtoms(display, atomNames, wlengthof(atomNames), False, atoms);
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < sizeof(atomNames) / sizeof(atomNames[0]); i++) {
|
for (i = 0; i < wlengthof(atomNames); i++) {
|
||||||
atoms[i] = XInternAtom(display, atomNames[i], False);
|
atoms[i] = XInternAtom(display, atomNames[i], False);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user