[PATCH v2] wmc: Remove struct and enum typedefs.
Huw Davies
huw at codeweavers.com
Tue Oct 26 02:17:08 CDT 2021
This has the side effect of fixing the build on macOS after
commit 2c1b8153630.
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
tools/wmc/lang.c | 8 ++--
tools/wmc/lang.h | 6 +--
tools/wmc/mcl.c | 16 +++----
tools/wmc/mcy.y | 103 +++++++++++++++++++++----------------------
tools/wmc/po.c | 14 +++---
tools/wmc/wmc.h | 10 ++---
tools/wmc/wmctypes.h | 52 +++++++++++-----------
tools/wmc/write.c | 24 +++++-----
8 files changed, 116 insertions(+), 117 deletions(-)
diff --git a/tools/wmc/lang.c b/tools/wmc/lang.c
index b5ab3be7225..7dd80d840e6 100644
--- a/tools/wmc/lang.c
+++ b/tools/wmc/lang.c
@@ -31,7 +31,7 @@
*
* MUST be sorting ascending on language ID
*/
-static const language_t languages[] = {
+static const struct language languages[] = {
{0x0000, 437, "Neutral", NULL},
{0x0002, 866, "Bulgarian", NULL},
@@ -177,11 +177,11 @@ void show_languages(void)
static int langcmp(const void *p1, const void *p2)
{
- return *(const unsigned *)p1 - ((const language_t *)p2)->id;
+ return *(const unsigned *)p1 - ((const struct language *)p2)->id;
}
-const language_t *find_language(unsigned id)
+const struct language *find_language(unsigned id)
{
- return (const language_t *)bsearch(&id, languages, ARRAY_SIZE(languages),
+ return (const struct language *)bsearch(&id, languages, ARRAY_SIZE(languages),
sizeof(languages[0]), langcmp);
}
diff --git a/tools/wmc/lang.h b/tools/wmc/lang.h
index 365aacdd766..f8798f142eb 100644
--- a/tools/wmc/lang.h
+++ b/tools/wmc/lang.h
@@ -23,14 +23,14 @@
#include "winnls.h"
-typedef struct language {
+struct language {
unsigned id;
unsigned doscp;
const char *name;
const char *country;
-} language_t;
+};
void show_languages(void);
-const language_t *find_language(unsigned id);
+const struct language *find_language(unsigned id);
#endif
diff --git a/tools/wmc/mcl.c b/tools/wmc/mcl.c
index c0ca4eeba5c..0d7b50027c5 100644
--- a/tools/wmc/mcl.c
+++ b/tools/wmc/mcl.c
@@ -486,21 +486,21 @@ static void newline(void)
static int unisort(const void *p1, const void *p2)
{
- return unistricmp(((const token_t *)p1)->name, ((const token_t *)p2)->name);
+ return unistricmp(((const struct token *)p1)->name, ((const struct token *)p2)->name);
}
-static token_t *tokentable = NULL;
+static struct token *tokentable = NULL;
static int ntokentable = 0;
-token_t *lookup_token(const WCHAR *s)
+struct token *lookup_token(const WCHAR *s)
{
- token_t tok;
+ struct token tok;
tok.name = s;
- return (token_t *)bsearch(&tok, tokentable, ntokentable, sizeof(*tokentable), unisort);
+ return (struct token *)bsearch(&tok, tokentable, ntokentable, sizeof(*tokentable), unisort);
}
-void add_token(tok_e type, const WCHAR *name, int tok, int cp, const WCHAR *alias, int fix)
+void add_token(enum tok_enum type, const WCHAR *name, int tok, int cp, const WCHAR *alias, int fix)
{
ntokentable++;
tokentable = xrealloc(tokentable, ntokentable * sizeof(*tokentable));
@@ -513,7 +513,7 @@ void add_token(tok_e type, const WCHAR *name, int tok, int cp, const WCHAR *alia
qsort(tokentable, ntokentable, sizeof(*tokentable), unisort);
}
-void get_tokentable(token_t **tab, int *len)
+void get_tokentable(struct token **tab, int *len)
{
assert(tab != NULL);
assert(len != NULL);
@@ -624,7 +624,7 @@ int mcy_lex(void)
if(char_table[ch] & CH_IDENT)
{
- token_t *tok;
+ struct token *tok;
while(isisochar(ch) && (char_table[ch] & (CH_IDENT|CH_NUMBER)))
{
push_unichar(ch);
diff --git a/tools/wmc/mcy.y b/tools/wmc/mcy.y
index 879c46ffc77..79d3679afdf 100644
--- a/tools/wmc/mcy.y
+++ b/tools/wmc/mcy.y
@@ -62,9 +62,9 @@ int want_nl = 0; /* Request next newlinw */
int want_line = 0; /* Request next complete line */
int want_file = 0; /* Request next ident as filename */
-node_t *nodehead = NULL; /* The list of all parsed elements */
-static node_t *nodetail = NULL;
-lan_blk_t *lanblockhead; /* List of parsed elements transposed */
+struct node *nodehead = NULL; /* The list of all parsed elements */
+static struct node *nodetail;
+struct lan_blk *lanblockhead; /* List of parsed elements transposed */
static int base = 16; /* Current printout base to use (8, 10 or 16) */
static WCHAR *cast = NULL; /* Current typecast to use */
@@ -77,31 +77,31 @@ static int have_sev; /* Set if severity parsed for current message */
static int have_fac; /* Set if facility parsed for current message */
static int have_sym; /* Set is symbol parsed for current message */
-static cp_xlat_t *cpxlattab = NULL; /* Codepage translation table */
+static struct cp_xlat *cpxlattab = NULL; /* Codepage translation table */
static int ncpxlattab = 0;
/* Prototypes */
static WCHAR *merge(WCHAR *s1, WCHAR *s2);
-static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg);
-static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg);
-static msg_t *complete_msg(msg_t *msg, int id);
-static void add_node(node_e type, void *p);
-static void do_add_token(tok_e type, token_t *tok, const char *code);
+static struct lanmsg *new_lanmsg(struct lan_cp *lcp, WCHAR *msg);
+static struct msg *add_lanmsg(struct msg *msg, struct lanmsg *lanmsg);
+static struct msg *complete_msg(struct msg *msg, int id);
+static void add_node(enum node_type type, void *p);
+static void do_add_token(enum tok_enum type, struct token *tok, const char *code);
static void test_id(int id);
-static int check_languages(node_t *head);
-static lan_blk_t *block_messages(node_t *head);
+static int check_languages(struct node *head);
+static struct lan_blk *block_messages(struct node *head);
static void add_cpxlat(int lan, int cpin, int cpout);
-static cp_xlat_t *find_cpxlat(int lan);
+static struct cp_xlat *find_cpxlat(int lan);
%}
%union {
WCHAR *str;
unsigned num;
- token_t *tok;
- lanmsg_t *lmp;
- msg_t *msg;
- lan_cp_t lcp;
+ struct token *tok;
+ struct lanmsg *lmp;
+ struct msg *msg;
+ struct lan_cp lcp;
}
@@ -306,7 +306,7 @@ sym : tSYMNAME '=' tIDENT { last_sym = $3; }
;
sev : tSEVERITY '=' token {
- token_t *tok = lookup_token($3->name);
+ struct token *tok = lookup_token($3->name);
if(!tok)
xyyerror("Undefined severityname\n");
if(tok->type != tok_severity)
@@ -318,7 +318,7 @@ sev : tSEVERITY '=' token {
;
fac : tFACILITY '=' token {
- token_t *tok = lookup_token($3->name);
+ struct token *tok = lookup_token($3->name);
if(!tok)
xyyerror("Undefined facilityname\n");
if(tok->type != tok_facility)
@@ -346,8 +346,8 @@ body : lang setline lines tMSGEND { $$ = new_lanmsg(&$1, $3); }
* message to be parsed.
*/
lang : tLANGUAGE setnl '=' token tNL {
- token_t *tok = lookup_token($4->name);
- cp_xlat_t *cpx;
+ struct token *tok = lookup_token($4->name);
+ struct cp_xlat *cpx;
if(!tok)
xyyerror("Undefined language\n");
if(tok->type != tok_language)
@@ -358,7 +358,7 @@ lang : tLANGUAGE setnl '=' token tNL {
}
else if(!tok->codepage)
{
- const language_t *lan = find_language(tok->token);
+ const struct language *lan = find_language(tok->token);
if(!lan)
{
/* Just set default; warning was given while parsing languagenames */
@@ -388,7 +388,7 @@ lines : tLINE { $$ = $1; }
/*----------------------------------------------------------------------
* Helper rules
*/
-token : tIDENT { $$ = xmalloc(sizeof(token_t)); memset($$,0,sizeof(*$$)); $$->name = $1; }
+token : tIDENT { $$ = xmalloc(sizeof(struct token)); memset($$,0,sizeof(*$$)); $$->name = $1; }
| tTOKEN { $$ = $1; }
;
@@ -413,9 +413,9 @@ static WCHAR *merge(WCHAR *s1, WCHAR *s2)
return s1;
}
-static void do_add_token(tok_e type, token_t *tok, const char *code)
+static void do_add_token(enum tok_enum type, struct token *tok, const char *code)
{
- token_t *tp = lookup_token(tok->name);
+ struct token *tp = lookup_token(tok->name);
if(tp)
{
if(tok->type != type)
@@ -434,9 +434,9 @@ static void do_add_token(tok_e type, token_t *tok, const char *code)
}
}
-static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg)
+static struct lanmsg *new_lanmsg(struct lan_cp *lcp, WCHAR *msg)
{
- lanmsg_t *lmp = xmalloc(sizeof(lanmsg_t));
+ struct lanmsg *lmp = xmalloc(sizeof(*lmp));
lmp->lan = lcp->language;
lmp->cp = lcp->codepage;
lmp->msg = msg;
@@ -448,12 +448,12 @@ static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg)
return lmp;
}
-static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
+static struct msg *add_lanmsg(struct msg *msg, struct lanmsg *lanmsg)
{
int i;
if(!msg)
{
- msg = xmalloc(sizeof(msg_t));
+ msg = xmalloc(sizeof(*msg));
memset( msg, 0, sizeof(*msg) );
}
msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
@@ -469,10 +469,10 @@ static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
static int sort_lanmsg(const void *p1, const void *p2)
{
- return (*(const lanmsg_t * const *)p1)->lan - (*(const lanmsg_t * const*)p2)->lan;
+ return (*(const struct lanmsg * const *)p1)->lan - (*(const struct lanmsg * const*)p2)->lan;
}
-static msg_t *complete_msg(msg_t *mp, int id)
+static struct msg *complete_msg(struct msg *mp, int id)
{
assert(mp != NULL);
mp->id = id;
@@ -491,9 +491,9 @@ static msg_t *complete_msg(msg_t *mp, int id)
return mp;
}
-static void add_node(node_e type, void *p)
+static void add_node(enum node_type type, void *p)
{
- node_t *ndp = xmalloc(sizeof(node_t));
+ struct node *ndp = xmalloc(sizeof(*ndp));
memset( ndp, 0, sizeof(*ndp) );
ndp->type = type;
ndp->u.all = p;
@@ -512,7 +512,7 @@ static void add_node(node_e type, void *p)
static void test_id(int id)
{
- node_t *ndp;
+ struct node *ndp;
for(ndp = nodehead; ndp; ndp = ndp->next)
{
if(ndp->type != nd_msg)
@@ -522,12 +522,12 @@ static void test_id(int id)
}
}
-static int check_languages(node_t *head)
+static int check_languages(struct node *head)
{
static const char err_missing[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x\n";
- node_t *ndp;
+ struct node *ndp;
int nm = 0;
- msg_t *msg = NULL;
+ struct msg *msg = NULL;
for(ndp = head; ndp; ndp = ndp->next)
{
@@ -540,8 +540,8 @@ static int check_languages(node_t *head)
else
{
int i;
- msg_t *m1;
- msg_t *m2;
+ struct msg *m1;
+ struct msg *m2;
if(ndp->u.msg->nmsgs > msg->nmsgs)
{
m1 = ndp->u.msg;
@@ -568,11 +568,10 @@ static int check_languages(node_t *head)
return nm;
}
-#define MSGRID(x) ((*(const msg_t * const*)(x))->realid)
+#define MSGRID(x) ((*(const struct msg * const*)(x))->realid)
static int sort_msg(const void *p1, const void *p2)
{
return MSGRID(p1) > MSGRID(p2) ? 1 : (MSGRID(p1) == MSGRID(p2) ? 0 : -1);
- /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
}
/*
@@ -580,13 +579,13 @@ static int sort_msg(const void *p1, const void *p2)
* from ID/language based list to a language/ID
* based list.
*/
-static lan_blk_t *block_messages(node_t *head)
+static struct lan_blk *block_messages(struct node *head)
{
- lan_blk_t *lbp;
- lan_blk_t *lblktail = NULL;
- lan_blk_t *lblkhead = NULL;
- msg_t **msgtab = NULL;
- node_t *ndp;
+ struct lan_blk *lbp;
+ struct lan_blk *lblktail = NULL;
+ struct lan_blk *lblkhead = NULL;
+ struct msg **msgtab = NULL;
+ struct node *ndp;
int nmsg = 0;
int i;
int nl;
@@ -605,7 +604,7 @@ static lan_blk_t *block_messages(node_t *head)
for(nl = 0; nl < msgtab[0]->nmsgs; nl++) /* This should be equal for all after check_languages() */
{
- lbp = xmalloc(sizeof(lan_blk_t));
+ lbp = xmalloc(sizeof(*lbp));
memset( lbp, 0, sizeof(*lbp) );
if(!lblktail)
{
@@ -630,7 +629,7 @@ static lan_blk_t *block_messages(node_t *head)
for(i = 1; i < nmsg; i++)
{
- block_t *blk = &(lbp->blks[lbp->nblk-1]);
+ struct block *blk = &(lbp->blks[lbp->nblk-1]);
if(msgtab[i]->realid == blk->idhi+1)
{
blk->size += ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
@@ -658,7 +657,7 @@ static lan_blk_t *block_messages(node_t *head)
static int sc_xlat(const void *p1, const void *p2)
{
- return ((const cp_xlat_t *)p1)->lan - ((const cp_xlat_t *)p2)->lan;
+ return ((const struct cp_xlat *)p1)->lan - ((const struct cp_xlat *)p2)->lan;
}
static void add_cpxlat(int lan, int cpin, int cpout)
@@ -671,12 +670,12 @@ static void add_cpxlat(int lan, int cpin, int cpout)
qsort(cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
}
-static cp_xlat_t *find_cpxlat(int lan)
+static struct cp_xlat *find_cpxlat(int lan)
{
- cp_xlat_t t;
+ struct cp_xlat t;
if(!cpxlattab) return NULL;
t.lan = lan;
- return (cp_xlat_t *)bsearch(&t, cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
+ return (struct cp_xlat *)bsearch(&t, cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
}
diff --git a/tools/wmc/po.c b/tools/wmc/po.c
index 28bcea91f59..87ebc072df1 100644
--- a/tools/wmc/po.c
+++ b/tools/wmc/po.c
@@ -46,7 +46,7 @@ struct mo_file
/* ... rest of file data here */
};
-static lan_blk_t *new_top, *new_tail;
+static struct lan_blk *new_top, *new_tail;
static const struct
{
@@ -365,7 +365,7 @@ static BOOL is_english( int lan )
return lan == MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
}
-static char *convert_msgid_ascii( const lanmsg_t *msg, int error_on_invalid_char )
+static char *convert_msgid_ascii( const struct lanmsg *msg, int error_on_invalid_char )
{
int i;
char *buffer = xmalloc( msg->len * 4 + 1 );
@@ -632,9 +632,9 @@ static const char *get_msgstr( const char *msgid, const char *context, int *foun
return ret;
}
-static lanmsg_t *translate_string( lanmsg_t *str, int lang, int *found )
+static struct lanmsg *translate_string( struct lanmsg *str, int lang, int *found )
{
- lanmsg_t *new;
+ struct lanmsg *new;
const char *transl;
char *buffer, *msgid, *context;
@@ -654,7 +654,7 @@ static lanmsg_t *translate_string( lanmsg_t *str, int lang, int *found )
return new;
}
-static void translate_block( block_t *blk, block_t *new, int lang, int *found )
+static void translate_block( struct block *blk, struct block *new, int lang, int *found )
{
int i;
@@ -673,7 +673,7 @@ static void translate_block( block_t *blk, block_t *new, int lang, int *found )
static void translate_messages( int lang )
{
int i, found;
- lan_blk_t *lbp, *new;
+ struct lan_blk *lbp, *new;
for (lbp = lanblockhead; lbp; lbp = lbp->next)
{
@@ -705,7 +705,7 @@ static void translate_messages( int lang )
void add_translations( const char *po_dir )
{
- lan_blk_t *lbp;
+ struct lan_blk *lbp;
char buffer[256];
char *p, *tok, *name;
unsigned int i;
diff --git a/tools/wmc/wmc.h b/tools/wmc/wmc.h
index 913c2a9443e..e9736103fe3 100644
--- a/tools/wmc/wmc.h
+++ b/tools/wmc/wmc.h
@@ -60,15 +60,15 @@ extern int mcy_debug;
extern int want_nl;
extern int want_line;
extern int want_file;
-extern node_t *nodehead;
-extern lan_blk_t *lanblockhead;
+extern struct node *nodehead;
+extern struct lan_blk *lanblockhead;
int mcy_lex(void);
extern FILE *yyin;
void set_codepage(int cp);
-void add_token(tok_e type, const WCHAR *name, int tok, int cp, const WCHAR *alias, int fix);
-token_t *lookup_token(const WCHAR *s);
-void get_tokentable(token_t **tab, int *len);
+void add_token(enum tok_enum type, const WCHAR *name, int tok, int cp, const WCHAR *alias, int fix);
+struct token *lookup_token(const WCHAR *s);
+void get_tokentable(struct token **tab, int *len);
#endif
diff --git a/tools/wmc/wmctypes.h b/tools/wmc/wmctypes.h
index 6c9a97c5e68..116ace20545 100644
--- a/tools/wmc/wmctypes.h
+++ b/tools/wmc/wmctypes.h
@@ -40,86 +40,86 @@
/*
* Tokenizer types
*/
-typedef enum tok_enum {
+enum tok_enum {
tok_null = 0,
tok_keyword,
tok_severity,
tok_facility,
tok_language
-} tok_e;
+};
-typedef struct token {
- tok_e type;
+struct token {
+ enum tok_enum type;
const WCHAR *name; /* Parsed name of token */
int token; /* Tokenvalue or language code */
int codepage;
const WCHAR *alias; /* Alias or filename */
int fixed; /* Cleared if token may change */
-} token_t;
+};
-typedef struct lan_cp {
+struct lan_cp {
int language;
int codepage;
-} lan_cp_t;
+};
-typedef struct cp_xlat {
+struct cp_xlat {
int lan;
int cpin;
int cpout;
-} cp_xlat_t;
+};
-typedef struct lanmsg {
+struct lanmsg {
int lan; /* Language code of message */
int cp; /* Codepage of message */
WCHAR *msg; /* Message text */
int len; /* Message length including trailing '\0' */
const char *file; /* File location for definition */
int line;
-} lanmsg_t;
+};
-typedef struct msg {
+struct msg {
int id; /* Message ID */
unsigned realid; /* Combined message ID */
WCHAR *sym; /* Symbolic name */
int sev; /* Severity code */
int fac; /* Facility code */
- lanmsg_t **msgs; /* Array message texts */
+ struct lanmsg **msgs; /* Array message texts */
int nmsgs; /* Number of message texts in array */
int base; /* Base of number to print */
WCHAR *cast; /* Typecase to use */
-} msg_t;
+};
-typedef enum {
+enum node_type {
nd_msg,
nd_comment
-} node_e;
+};
-typedef struct node {
+struct node {
struct node *next;
struct node *prev;
- node_e type;
+ enum node_type type;
union {
void *all;
WCHAR *comment;
- msg_t *msg;
+ struct msg *msg;
} u;
-} node_t;
+};
-typedef struct block {
+struct block {
unsigned idlo; /* Lowest ID in this set */
unsigned idhi; /* Highest ID in this set */
int size; /* Size of this set */
- lanmsg_t **msgs; /* Array of messages in this set */
+ struct lanmsg **msgs; /* Array of messages in this set */
int nmsg; /* Number of array entries */
-} block_t;
+};
-typedef struct lan_blk {
+struct lan_blk {
struct lan_blk *next; /* Linkage for languages */
struct lan_blk *prev;
int lan; /* The language of this block */
int version; /* The resource version for auto-translated resources */
- block_t *blks; /* Array of blocks for this language */
+ struct block *blks; /* Array of blocks for this language */
int nblk; /* Nr of blocks in array */
-} lan_blk_t;
+};
#endif
diff --git a/tools/wmc/write.c b/tools/wmc/write.c
index 69ebf24b6b9..353a503f674 100644
--- a/tools/wmc/write.c
+++ b/tools/wmc/write.c
@@ -150,11 +150,11 @@ static int killcomment(char *s)
void write_h_file(const char *fname)
{
- node_t *ndp;
+ struct node *ndp;
char *cptr;
char *cast;
FILE *fp;
- token_t *ttab;
+ struct token *ttab;
int ntab;
int i;
int once = 0;
@@ -278,8 +278,8 @@ void write_h_file(const char *fname)
static void write_rcbin(FILE *fp)
{
- lan_blk_t *lbp;
- token_t *ttab;
+ struct lan_blk *lbp;
+ struct token *ttab;
int ntab;
int i;
@@ -370,7 +370,7 @@ static char *make_string(WCHAR *uc, int len)
static void write_rcinline(FILE *fp)
{
- lan_blk_t *lbp;
+ struct lan_blk *lbp;
int i;
int j;
@@ -391,7 +391,7 @@ static void write_rcinline(FILE *fp)
}
for(i = 0; i < lbp->nblk; i++)
{
- block_t *blk = &lbp->blks[i];
+ struct block *blk = &lbp->blks[i];
for(j = 0; j < blk->nmsg; j++)
{
char *cptr;
@@ -426,7 +426,7 @@ void write_rc_file(const char *fname)
fclose(fp);
}
-static void output_bin_data( lan_blk_t *lbp )
+static void output_bin_data( struct lan_blk *lbp )
{
unsigned int offs = 4 * (lbp->nblk * 3 + 1);
int i, j, k;
@@ -441,7 +441,7 @@ static void output_bin_data( lan_blk_t *lbp )
}
for (i = 0; i < lbp->nblk; i++)
{
- block_t *blk = &lbp->blks[i];
+ struct block *blk = &lbp->blks[i];
for (j = 0; j < blk->nmsg; j++)
{
int len = (2 * blk->msgs[j]->len + 3) & ~3;
@@ -455,8 +455,8 @@ static void output_bin_data( lan_blk_t *lbp )
void write_bin_files(void)
{
- lan_blk_t *lbp;
- token_t *ttab;
+ struct lan_blk *lbp;
+ struct token *ttab;
int ntab;
int i;
@@ -487,7 +487,7 @@ void write_bin_files(void)
void write_res_file( const char *name )
{
- lan_blk_t *lbp;
+ struct lan_blk *lbp;
int i, j;
init_output_buffer();
@@ -511,7 +511,7 @@ void write_res_file( const char *name )
for (i = 0; i < lbp->nblk; i++)
{
- block_t *blk = &lbp->blks[i];
+ struct block *blk = &lbp->blks[i];
for (j = 0; j < blk->nmsg; j++) data_size += 4 + ((blk->msgs[j]->len * 2 + 3) & ~3);
}
--
2.23.0
More information about the wine-devel
mailing list