Michael Stefaniuc : wmc: Use the ARRAY_SIZE() macro.
Alexandre Julliard
julliard at winehq.org
Tue Oct 23 16:10:01 CDT 2018
Module: wine
Branch: master
Commit: 86ebd6dc0d30eef5ffa1a1e354fb6cdb1ee9c7d3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=86ebd6dc0d30eef5ffa1a1e354fb6cdb1ee9c7d3
Author: Michael Stefaniuc <mstefani at winehq.org>
Date: Mon Oct 22 22:39:03 2018 +0200
wmc: Use the ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/wmc/lang.c | 7 +++----
tools/wmc/po.c | 4 ++--
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/tools/wmc/lang.c b/tools/wmc/lang.c
index b045612..07022f7 100644
--- a/tools/wmc/lang.c
+++ b/tools/wmc/lang.c
@@ -162,14 +162,12 @@ static const language_t languages[] = {
{0x500A, 850, 1252, "Spanish", "Puerto Rico"}
};
-#define NLAN (sizeof(languages)/sizeof(languages[0]))
-
void show_languages(void)
{
unsigned int i;
printf(" Code | DOS-cp | WIN-cp | Language | Country\n");
printf("-------+--------+--------+--------------+---------\n");
- for(i = 0; i < NLAN; i++)
+ for(i = 0; i < ARRAY_SIZE(languages); i++)
printf("0x%04x | %5d | %5d | %-12s | %s\n",
languages[i].id,
languages[i].doscp,
@@ -185,7 +183,8 @@ static int langcmp(const void *p1, const void *p2)
const language_t *find_language(unsigned id)
{
- return (const language_t *)bsearch(&id, languages, NLAN, sizeof(languages[0]), langcmp);
+ return (const language_t *)bsearch(&id, languages, ARRAY_SIZE(languages),
+ sizeof(languages[0]), langcmp);
}
void show_codepages(void)
diff --git a/tools/wmc/po.c b/tools/wmc/po.c
index 6db02c8..3529a5b 100644
--- a/tools/wmc/po.c
+++ b/tools/wmc/po.c
@@ -666,10 +666,10 @@ void add_translations( const char *po_dir )
if ((p = strchr( buffer, '#' ))) *p = 0;
for (tok = strtok( buffer, " \t\r\n" ); tok; tok = strtok( NULL, " \t\r\n" ))
{
- for (i = 0; i < sizeof(languages)/sizeof(languages[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(languages); i++)
if (!strcmp( tok, languages[i].name )) break;
- if (i == sizeof(languages)/sizeof(languages[0]))
+ if (i == ARRAY_SIZE(languages))
error( "unknown language '%s'\n", tok );
name = strmake( "%s/%s.mo", po_dir, tok );
More information about the wine-cvs
mailing list