- Sync with Wine.

svn path=/trunk/; revision=30932
This commit is contained in:
Aleksey Bragin 2007-12-01 15:56:03 +00:00
parent d660a25834
commit ff325e041a
13 changed files with 732 additions and 508 deletions

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <stdlib.h>
@ -33,7 +33,47 @@
*/
static const language_t languages[] = {
{0x0000, 437, 1252, "Neutral", "Neutral"},
{0x0000, 437, 1252, "Neutral", NULL},
{0x0002, 866, 1251, "Bulgarian", NULL},
{0x0003, 850, 1252, "Catalan", NULL},
{0x0005, 852, 1250, "Czech", NULL},
{0x0006, 850, 1252, "Danish", NULL},
{0x0007, 850, 1252, "German", NULL},
{0x0008, 737, 1253, "Greek", NULL},
{0x0009, 437, 1252, "English", NULL},
{0x000A, 850, 1252, "Spanish - Traditional Sort", NULL},
{0x000B, 850, 1252, "Finnish", NULL},
{0x000C, 850, 1252, "French", NULL},
{0x000E, 852, 1250, "Hungarian", NULL},
{0x000F, 850, 1252, "Icelandic", NULL},
{0x0010, 850, 1252, "Italian", NULL},
{0x0011, 932, 932, "Japanese", NULL},
{0x0012, 949, 949, "Korean", NULL},
{0x0013, 850, 1252, "Dutch", NULL},
{0x0014, 850, 1252, "Norwegian (Bokmål)", NULL},
{0x0015, 852, 1250, "Polish", NULL},
{0x0016, 850, 1252, "Portuguese", NULL},
{0x0018, 852, 1250, "Romanian", NULL},
{0x0019, 866, 1251, "Russian", NULL},
{0x001A, 852, 1250, "Serbian", NULL},
{0x001B, 852, 1250, "Slovak", NULL},
{0x001C, 852, 1250, "Albanian", NULL},
{0x001D, 850, 1252, "Swedish", NULL},
{0x001F, 857, 1254, "Turkish", NULL},
{0x0021, 850, 1252, "Indonesian", NULL},
{0x0022, 866, 1251, "Ukrainian", NULL},
{0x0023, 866, 1251, "Belarusian", NULL},
{0x0024, 852, 1250, "Slovene", NULL},
{0x0025, 775, 1257, "Estonian", NULL},
{0x0026, 775, 1257, "Latvian", NULL},
{0x0027, 775, 1257, "Lithuanian", NULL},
{0x002A,1258, 1258, "Vietnamese", NULL},
{0x002D, 850, 1252, "Basque", NULL},
{0x002F, 866, 1251, "Macedonian", NULL},
{0x0036, 850, 1252, "Afrikaans", NULL},
{0x0038, 852, 1252, "Faroese", NULL},
{0x003C, 437, 1252, "Irish", NULL},
{0x003E, 850, 1252, "Malay", NULL},
{0x0402, 866, 1251, "Bulgarian", "Bulgaria"},
{0x0403, 850, 1252, "Catalan", "Spain"},
{0x0405, 852, 1250, "Czech", "Czech Republic"},
@ -67,11 +107,11 @@ static const language_t languages[] = {
{0x0425, 775, 1257, "Estonian", "Estonia"},
{0x0426, 775, 1257, "Latvian", "Latvia"},
{0x0427, 775, 1257, "Lithuanian", "Lithuania"},
/* {0x042A, ?, ?, "Vietnamese", "Vietnam"},*/
{0x042A,1258, 1258, "Vietnamese", "Vietnam"},
{0x042D, 850, 1252, "Basque", "Spain"},
{0x042F, 866, 1251, "Macedonian", "Former Yugoslav Republic of Macedonia"},
{0x0436, 850, 1252, "Afrikaans", "South Africa"},
/* {0x0438, 852, 1252, "Faroese", "Faroe Islands"}, FIXME: Not sure about codepages */
{0x0438, 852, 1252, "Faroese", "Faroe Islands"},
{0x043C, 437, 1252, "Irish", "Ireland"},
{0x043E, 850, 1252, "Malay", "Malaysia"},
/* {0x048F, ?, ?, "Esperanto", "<none>"},*/
@ -84,7 +124,7 @@ static const language_t languages[] = {
{0x0813, 850, 1252, "Dutch", "Belgium"},
{0x0814, 850, 1252, "Norwegian (Nynorsk)", "Norway"},
{0x0816, 850, 1252, "Portuguese", "Portugal"},
/* {0x081A, ?, ?, "Serbian (latin)", "Yugoslavia"},*/
{0x081A, 852, 1250, "Serbian (latin)", "Yugoslavia"},
{0x081D, 850, 1252, "Swedish (Finland)", "Finland"},
{0x0C07, 850, 1252, "German", "Austria"},
{0x0C09, 850, 1252, "English", "Australia"},
@ -135,7 +175,7 @@ void show_languages(void)
languages[i].doscp,
languages[i].wincp,
languages[i].name,
languages[i].country);
languages[i].country ? languages[i].country : "Neutral");
}
static int langcmp(const void *p1, const void *p2)

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WMC_LANG_H

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -74,25 +74,25 @@
* The 'Codepages' keyword is a wmc extension.
*/
static WCHAR ustr_application[] = { 'A', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o', 'n', 0 };
static WCHAR ustr_codepages[] = { 'C', 'o', 'd', 'e', 'p', 'a', 'g', 'e', 's', 0 };
static WCHAR ustr_english[] = { 'E', 'n', 'g', 'l', 'i', 's', 'h', 0 };
static WCHAR ustr_error[] = { 'E', 'r', 'r', 'o', 'r', 0 };
static WCHAR ustr_facility[] = { 'F', 'a', 'c', 'i', 'l', 'i', 't', 'y', 0 };
static WCHAR ustr_facilitynames[] = { 'F', 'a', 'c', 'i', 'l', 'i', 't', 'y', 'N', 'a', 'm', 'e', 's', 0 };
static WCHAR ustr_informational[] = { 'I', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', 'a', 'l', 0 };
static WCHAR ustr_language[] = { 'L', 'a', 'n', 'g', 'u', 'a', 'g', 'e', 0};
static WCHAR ustr_languagenames[] = { 'L', 'a', 'n', 'g', 'u', 'a', 'g', 'e', 'N', 'a', 'm', 'e', 's', 0};
static WCHAR ustr_messageid[] = { 'M', 'e', 's', 's', 'a', 'g', 'e', 'I', 'd', 0 };
static WCHAR ustr_messageidtypedef[] = { 'M', 'e', 's', 's', 'a', 'g', 'e', 'I', 'd', 'T', 'y', 'p', 'e', 'd', 'e', 'f', 0 };
static WCHAR ustr_outputbase[] = { 'O', 'u', 't', 'p', 'u', 't', 'B', 'a', 's', 'e', 0 };
static WCHAR ustr_severity[] = { 'S', 'e', 'v', 'e', 'r', 'i', 't', 'y', 0 };
static WCHAR ustr_severitynames[] = { 'S', 'e', 'v', 'e', 'r', 'i', 't', 'y', 'N', 'a', 'm', 'e', 's', 0 };
static WCHAR ustr_success[] = { 'S', 'u', 'c', 'c', 'e', 's', 's', 0 };
static WCHAR ustr_symbolicname[] = { 'S', 'y', 'm', 'b', 'o', 'l', 'i', 'c', 'N', 'a', 'm', 'e', 0 };
static WCHAR ustr_system[] = { 'S', 'y', 's', 't', 'e', 'm', 0 };
static WCHAR ustr_warning[] = { 'W', 'a', 'r', 'n', 'i', 'n', 'g', 0 };
static WCHAR ustr_msg00001[] = { 'm', 's', 'g', '0', '0', '0', '0', '1', 0 };
static const WCHAR ustr_application[] = { 'A', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o', 'n', 0 };
static const WCHAR ustr_codepages[] = { 'C', 'o', 'd', 'e', 'p', 'a', 'g', 'e', 's', 0 };
static const WCHAR ustr_english[] = { 'E', 'n', 'g', 'l', 'i', 's', 'h', 0 };
static const WCHAR ustr_error[] = { 'E', 'r', 'r', 'o', 'r', 0 };
static const WCHAR ustr_facility[] = { 'F', 'a', 'c', 'i', 'l', 'i', 't', 'y', 0 };
static const WCHAR ustr_facilitynames[] = { 'F', 'a', 'c', 'i', 'l', 'i', 't', 'y', 'N', 'a', 'm', 'e', 's', 0 };
static const WCHAR ustr_informational[] = { 'I', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', 'a', 'l', 0 };
static const WCHAR ustr_language[] = { 'L', 'a', 'n', 'g', 'u', 'a', 'g', 'e', 0};
static const WCHAR ustr_languagenames[] = { 'L', 'a', 'n', 'g', 'u', 'a', 'g', 'e', 'N', 'a', 'm', 'e', 's', 0};
static const WCHAR ustr_messageid[] = { 'M', 'e', 's', 's', 'a', 'g', 'e', 'I', 'd', 0 };
static const WCHAR ustr_messageidtypedef[] = { 'M', 'e', 's', 's', 'a', 'g', 'e', 'I', 'd', 'T', 'y', 'p', 'e', 'd', 'e', 'f', 0 };
static const WCHAR ustr_outputbase[] = { 'O', 'u', 't', 'p', 'u', 't', 'B', 'a', 's', 'e', 0 };
static const WCHAR ustr_severity[] = { 'S', 'e', 'v', 'e', 'r', 'i', 't', 'y', 0 };
static const WCHAR ustr_severitynames[] = { 'S', 'e', 'v', 'e', 'r', 'i', 't', 'y', 'N', 'a', 'm', 'e', 's', 0 };
static const WCHAR ustr_success[] = { 'S', 'u', 'c', 'c', 'e', 's', 's', 0 };
static const WCHAR ustr_symbolicname[] = { 'S', 'y', 'm', 'b', 'o', 'l', 'i', 'c', 'N', 'a', 'm', 'e', 0 };
static const WCHAR ustr_system[] = { 'S', 'y', 's', 't', 'e', 'm', 0 };
static const WCHAR ustr_warning[] = { 'W', 'a', 'r', 'n', 'i', 'n', 'g', 0 };
static const WCHAR ustr_msg00001[] = { 'm', 's', 'g', '0', '0', '0', '0', '1', 0 };
/*
* This table is to beat any form of "expression building" to check for
* correct filename characters. It is also used for ident checks.
@ -156,7 +156,7 @@ void set_codepage(int cp)
codepage = cp;
codepage_def = find_codepage(codepage);
if(!codepage_def)
xyyerror("Codepage %d not found; cannot process", codepage);
xyyerror("Codepage %d not found; cannot process\n", codepage);
}
/*
@ -187,7 +187,7 @@ static int fill_inputbuffer(void)
if(!inputbuffer)
{
inputbuffer = xmalloc(INPUTBUFFER_SIZE);
inputbuffer = xmalloc(INPUTBUFFER_SIZE*sizeof(WCHAR));
xlatebuffer = xmalloc(INPUTBUFFER_SIZE);
}
@ -203,7 +203,7 @@ try_again:
assert(codepage_def != NULL);
n = wine_cp_mbstowcs(codepage_def, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE);
if(n < 0)
internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)", n);
internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)\n", n);
if(n <= 1)
goto try_again; /* Should not hapen */
n--; /* Strip added conversion '\0' from input length */
@ -224,7 +224,7 @@ try_again:
if(!n && ferror(yyin))
xyyerror(err_fatalread);
else
xyyerror("Fatal: file to short to determine byteorder (should never happen)");
xyyerror("Fatal: file to short to determine byteorder (should never happen)\n");
}
if(isisochar(inputbuffer[0]) &&
isisochar(inputbuffer[1]) &&
@ -249,7 +249,7 @@ try_again:
#endif
}
else
xyyerror("Fatal: cannot determine file's byteorder");
xyyerror("Fatal: cannot determine file's byteorder\n");
/* FIXME:
* Determine the file-endian with the leader-bytes
* "FF FE..."; can't remember the exact sequence.
@ -302,7 +302,7 @@ try_again:
if(!n)
{
yywarning("Re-read line (input was or converted to zilch)");
mcy_warning("Re-read line (input was or converted to zilch)\n");
goto try_again; /* Should not happen, but could be due to stdin reading and a signal */
}
@ -458,7 +458,7 @@ static int scan_number(int ch)
while(1)
{
if(!isisochar(ch))
xyyerror("Invalid digit");
xyyerror("Invalid digit\n");
switch(state)
{
@ -472,7 +472,7 @@ static int scan_number(int ch)
state = 4;
}
else
internal_error(__FILE__, __LINE__, "Non-digit in first number-scanner state");
internal_error(__FILE__, __LINE__, "Non-digit in first number-scanner state\n");
break;
case 1:
if(ch == 'x' || ch == 'X')
@ -486,11 +486,11 @@ static int scan_number(int ch)
state = 3;
}
else if(isalpha(ch) || ch == '_')
xyyerror("Invalid number digit");
xyyerror("Invalid number digit\n");
else
{
unget_unichar(ch);
yylval.num = 0;
mcy_lval.num = 0;
return tNUMBER;
}
break;
@ -498,7 +498,7 @@ static int scan_number(int ch)
if(isxdigit(ch))
push_char(ch);
else if(isalpha(ch) || ch == '_' || !isxdigit(tos_char_stack()))
xyyerror("Invalid hex digit");
xyyerror("Invalid hex digit\n");
else
{
base = 16;
@ -509,7 +509,7 @@ static int scan_number(int ch)
if(ch >= '0' && ch <= '7')
push_char(ch);
else if(isalnum(ch) || ch == '_')
xyyerror("Invalid octal digit");
xyyerror("Invalid octal digit\n");
else
{
base = 8;
@ -520,7 +520,7 @@ static int scan_number(int ch)
if(isdigit(ch))
push_char(ch);
else if(isalnum(ch) || ch == '_')
xyyerror("Invalid decimal digit");
xyyerror("Invalid decimal digit\n");
else
{
base = 10;
@ -528,14 +528,14 @@ static int scan_number(int ch)
}
break;
default:
internal_error(__FILE__, __LINE__, "Invalid state in number-scanner");
internal_error(__FILE__, __LINE__, "Invalid state in number-scanner\n");
}
ch = get_unichar();
}
finish:
unget_unichar(ch);
push_char(0);
yylval.num = strtoul(get_char_stack(), NULL, base);
mcy_lval.num = strtoul(get_char_stack(), NULL, base);
return tNUMBER;
}
@ -586,7 +586,7 @@ void get_tokentable(token_t **tab, int *len)
* The scanner
*
*/
int yylex(void)
int mcy_lex(void)
{
static const WCHAR ustr_dot1[] = { '.', '\n', 0 };
static const WCHAR ustr_dot2[] = { '.', '\r', '\n', 0 };
@ -626,7 +626,7 @@ int yylex(void)
while((ch = get_unichar()) != '\n')
{
if(ch == EOF)
xyyerror("Unexpected EOF");
xyyerror("Unexpected EOF\n");
push_unichar(ch);
}
newline();
@ -639,7 +639,7 @@ int yylex(void)
set_codepage(WMC_DEFAULT_CODEPAGE);
return tMSGEND;
}
yylval.str = xunistrdup(get_unichar_stack());
mcy_lval.str = xunistrdup(get_unichar_stack());
return tLINE;
}
@ -677,7 +677,7 @@ int yylex(void)
unget_unichar(ch);
push_unichar(0);
want_file = 0;
yylval.str = xunistrdup(get_unichar_stack());
mcy_lval.str = xunistrdup(get_unichar_stack());
return tFILE;
}
@ -693,7 +693,7 @@ int yylex(void)
push_unichar(0);
if(!(tok = lookup_token(get_unichar_stack())))
{
yylval.str = xunistrdup(get_unichar_stack());
mcy_lval.str = xunistrdup(get_unichar_stack());
return tIDENT;
}
switch(tok->type)
@ -706,11 +706,11 @@ int yylex(void)
/* Fall through */
case tok_severity:
case tok_facility:
yylval.tok = tok;
mcy_lval.tok = tok;
return tTOKEN;
default:
internal_error(__FILE__, __LINE__, "Invalid token type encountered");
internal_error(__FILE__, __LINE__, "Invalid token type encountered\n");
}
}
@ -738,10 +738,10 @@ int yylex(void)
newline();
push_unichar(ch); /* Include the newline */
push_unichar(0);
yylval.str = xunistrdup(get_unichar_stack());
mcy_lval.str = xunistrdup(get_unichar_stack());
return tCOMMENT;
default:
xyyerror("Invalid character '%c' (0x%04x)", isisochar(ch) && isprint(ch) ? ch : '.', ch);
xyyerror("Invalid character '%c' (0x%04x)\n", isisochar(ch) && isprint(ch) ? ch : '.', ch);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/* A Bison parser, made by GNU Bison 1.875c. */
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@ -50,6 +50,7 @@
tTOKEN = 276
};
#endif
/* Tokens. */
#define tSEVNAMES 258
#define tFACNAMES 259
#define tLANNAMES 260
@ -74,7 +75,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 99 "tools/wmc/mcy.y"
#line 98 "tools/wmc/mcy.y"
typedef union YYSTYPE {
WCHAR *str;
unsigned num;
@ -83,14 +84,14 @@ typedef union YYSTYPE {
msg_t *msg;
lan_cp_t lcp;
} YYSTYPE;
/* Line 1275 of yacc.c. */
#line 88 "tools/wmc/mcy.tab.h"
/* Line 1447 of yacc.c. */
#line 89 "tools/wmc/mcy.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
extern YYSTYPE mcy_lval;

View file

@ -15,12 +15,12 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTES:
*
* The basic grammar of the file is yet another example of, humpf,
* design. There is is mix of context-insensitive and -sentitive
* design. There is a mix of context-insensitive and -sensitive
* stuff, which makes it rather complicated.
* The header definitions are all context-insensitive because they have
* delimited arguments, whereas the message headers are (semi-) context-
@ -95,7 +95,6 @@ static cp_xlat_t *find_cpxlat(int lan);
%}
%union {
WCHAR *str;
unsigned num;
@ -123,7 +122,7 @@ static cp_xlat_t *find_cpxlat(int lan);
%%
file : items {
if(!check_languages(nodehead))
xyyerror("No messages defined");
xyyerror("No messages defined\n");
lanblockhead = block_messages(nodehead);
}
;
@ -166,7 +165,7 @@ global : tSEVNAMES '=' '(' smaps ')'
base = $3;
break;
default:
xyyerror("Numberbase must be 8, 10 or 16");
xyyerror("Numberbase must be 8, 10 or 16\n");
}
}
| tBASE '=' error { xyyerror(err_number); }
@ -185,7 +184,7 @@ smap : token '=' tNUMBER alias {
$1->token = $3;
$1->alias = $4;
if($3 & (~0x3))
xyyerror("Severity value out of range (0x%08x > 0x3)", $3);
xyyerror("Severity value out of range (0x%08x > 0x3)\n", $3);
do_add_token(tok_severity, $1, "severity");
}
| token '=' error { xyyerror(err_number); }
@ -204,7 +203,7 @@ fmap : token '=' tNUMBER alias {
$1->token = $3;
$1->alias = $4;
if($3 & (~0xfff))
xyyerror("Facility value out of range (0x%08x > 0xfff)", $3);
xyyerror("Facility value out of range (0x%08x > 0xfff)\n", $3);
do_add_token(tok_facility, $1, "facility");
}
| token '=' error { xyyerror(err_number); }
@ -230,9 +229,9 @@ lmap : token '=' tNUMBER setfile ':' tFILE optcp {
$1->codepage = $7;
do_add_token(tok_language, $1, "language");
if(!find_language($3) && !find_cpxlat($3))
yywarning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override", $3, WMC_DEFAULT_CODEPAGE);
mcy_warning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override\n", $3, WMC_DEFAULT_CODEPAGE);
}
| token '=' tNUMBER setfile ':' error { xyyerror("Filename expected"); }
| token '=' tNUMBER setfile ':' error { xyyerror("Filename expected\n"); }
| token '=' tNUMBER error { xyyerror(err_colon); }
| token '=' error { xyyerror(err_number); }
| token error { xyyerror(err_assign); }
@ -240,7 +239,7 @@ lmap : token '=' tNUMBER setfile ':' tFILE optcp {
optcp : /* Empty */ { $$ = 0; }
| ':' tNUMBER { $$ = $2; }
| ':' error { xyyerror("Codepage-number expected"); }
| ':' error { xyyerror("Codepage-number expected\n"); }
;
/*----------------------------------------------------------------------
@ -254,7 +253,7 @@ cmaps : cmap
cmap : clan '=' tNUMBER ':' tNUMBER {
static const char err_nocp[] = "Codepage %d not builtin; cannot convert";
if(find_cpxlat($1))
xyyerror("Codepage translation already defined for language 0x%x", $1);
xyyerror("Codepage translation already defined for language 0x%x\n", $1);
if($3 && !find_codepage($3))
xyyerror(err_nocp, $3);
if($5 && !find_codepage($5))
@ -270,7 +269,7 @@ cmap : clan '=' tNUMBER ':' tNUMBER {
clan : tNUMBER { $$ = $1; }
| tTOKEN {
if($1->type != tok_language)
xyyerror("Language name or code expected");
xyyerror("Language name or code expected\n");
$$ = $1->token;
}
;
@ -283,7 +282,7 @@ msg : msgid sevfacsym { test_id($1); } bodies { $$ = complete_msg($4, $1); }
msgid : tMSGID '=' id {
if($3 & (~0xffff))
xyyerror("Message ID value out of range (0x%08x > 0xffff)", $3);
xyyerror("Message ID value out of range (0x%08x > 0xffff)\n", $3);
$$ = $3;
}
| tMSGID error { xyyerror(err_assign); }
@ -296,9 +295,9 @@ id : /* Empty */ { $$ = ++last_id; }
;
sevfacsym: /* Empty */ { have_sev = have_fac = have_sym = 0; }
| sevfacsym sev { if(have_sev) xyyerror("Severity already defined"); have_sev = 1; }
| sevfacsym fac { if(have_fac) xyyerror("Facility already defined"); have_fac = 1; }
| sevfacsym sym { if(have_sym) xyyerror("Symbolname already defined"); have_sym = 1; }
| sevfacsym sev { if(have_sev) xyyerror("Severity already defined\n"); have_sev = 1; }
| sevfacsym fac { if(have_fac) xyyerror("Facility already defined\n"); have_fac = 1; }
| sevfacsym sym { if(have_sym) xyyerror("Symbolname already defined\n"); have_sym = 1; }
;
sym : tSYMNAME '=' tIDENT { last_sym = $3; }
@ -309,9 +308,9 @@ sym : tSYMNAME '=' tIDENT { last_sym = $3; }
sev : tSEVERITY '=' token {
token_t *tok = lookup_token($3->name);
if(!tok)
xyyerror("Undefined severityname");
xyyerror("Undefined severityname\n");
if(tok->type != tok_severity)
xyyerror("Identifier is not of class 'severity'");
xyyerror("Identifier is not of class 'severity'\n");
last_sev = tok->token;
}
| tSEVERITY '=' error { xyyerror(err_ident); }
@ -321,9 +320,9 @@ sev : tSEVERITY '=' token {
fac : tFACILITY '=' token {
token_t *tok = lookup_token($3->name);
if(!tok)
xyyerror("Undefined facilityname");
xyyerror("Undefined facilityname\n");
if(tok->type != tok_facility)
xyyerror("Identifier is not of class 'facility'");
xyyerror("Identifier is not of class 'facility'\n");
last_fac = tok->token;
}
| tFACILITY '=' error { xyyerror(err_ident); }
@ -335,7 +334,7 @@ fac : tFACILITY '=' token {
*/
bodies : body { $$ = add_lanmsg(NULL, $1); }
| bodies body { $$ = add_lanmsg($1, $2); }
| error { xyyerror("'Language=...' (start of message text-definition) expected"); }
| error { xyyerror("'Language=...' (start of message text-definition) expected\n"); }
;
body : lang setline lines tMSGEND { $$ = new_lanmsg(&$1, $3); }
@ -350,9 +349,9 @@ lang : tLANGUAGE setnl '=' token tNL {
token_t *tok = lookup_token($4->name);
cp_xlat_t *cpx;
if(!tok)
xyyerror("Undefined language");
xyyerror("Undefined language\n");
if(tok->type != tok_language)
xyyerror("Identifier is not of class 'language'");
xyyerror("Identifier is not of class 'language'\n");
if((cpx = find_cpxlat(tok->token)))
{
set_codepage($$.codepage = cpx->cpin);
@ -375,7 +374,7 @@ lang : tLANGUAGE setnl '=' token tNL {
set_codepage($$.codepage = tok->codepage);
$$.language = tok->token;
}
| tLANGUAGE setnl '=' token error { xyyerror("Missing newline"); }
| tLANGUAGE setnl '=' token error { xyyerror("Missing newline\n"); }
| tLANGUAGE setnl '=' error { xyyerror(err_ident); }
| tLANGUAGE error { xyyerror(err_assign); }
;
@ -389,7 +388,7 @@ lines : tLINE { $$ = $1; }
/*----------------------------------------------------------------------
* Helper rules
*/
token : tIDENT { $$ = xmalloc(sizeof(token_t)); $$->name = $1; }
token : tIDENT { $$ = xmalloc(sizeof(token_t)); memset($$,0,sizeof(*$$)); $$->name = $1; }
| tTOKEN { $$ = $1; }
;
@ -420,12 +419,12 @@ static void do_add_token(tok_e type, token_t *tok, const char *code)
if(tp)
{
if(tok->type != type)
yywarning("Type change in token");
mcy_warning("Type change in token\n");
if(tp != tok)
xyyerror("Overlapping token not the same");
xyyerror("Overlapping token not the same\n");
/* else its already defined and changed */
if(tok->fixed)
xyyerror("Redefinition of %s", code);
xyyerror("Redefinition of %s\n", code);
tok->fixed = 1;
}
else
@ -437,13 +436,13 @@ 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)
{
lanmsg_t *lmp = (lanmsg_t *)xmalloc(sizeof(lanmsg_t));
lanmsg_t *lmp = xmalloc(sizeof(lanmsg_t));
lmp->lan = lcp->language;
lmp->cp = lcp->codepage;
lmp->msg = msg;
lmp->len = unistrlen(msg) + 1; /* Include termination */
if(lmp->len > 4096)
yywarning("Message exceptionally long; might be a missing termination");
mcy_warning("Message exceptionally long; might be a missing termination\n");
return lmp;
}
@ -451,21 +450,24 @@ static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
{
int i;
if(!msg)
{
msg = xmalloc(sizeof(msg_t));
memset( msg, 0, sizeof(*msg) );
}
msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
msg->msgs[msg->nmsgs] = lanmsg;
msg->nmsgs++;
for(i = 0; i < msg->nmsgs-1; i++)
{
if(msg->msgs[i]->lan == lanmsg->lan)
xyyerror("Message for language 0x%x already defined", lanmsg->lan);
xyyerror("Message for language 0x%x already defined\n", lanmsg->lan);
}
return msg;
}
static int sort_lanmsg(const void *p1, const void *p2)
{
return (*(lanmsg_t **)p1)->lan - (*(lanmsg_t **)p2)->lan;
return (*(const lanmsg_t * const *)p1)->lan - (*(const lanmsg_t * const*)p2)->lan;
}
static msg_t *complete_msg(msg_t *mp, int id)
@ -475,7 +477,7 @@ static msg_t *complete_msg(msg_t *mp, int id)
if(have_sym)
mp->sym = last_sym;
else
xyyerror("No symbolic name defined for message id %d", id);
xyyerror("No symbolic name defined for message id %d\n", id);
mp->sev = last_sev;
mp->fac = last_fac;
qsort(mp->msgs, mp->nmsgs, sizeof(*(mp->msgs)), sort_lanmsg);
@ -489,7 +491,8 @@ static msg_t *complete_msg(msg_t *mp, int id)
static void add_node(node_e type, void *p)
{
node_t *ndp = (node_t *)xmalloc(sizeof(node_t));
node_t *ndp = xmalloc(sizeof(node_t));
memset( ndp, 0, sizeof(*ndp) );
ndp->type = type;
ndp->u.all = p;
@ -513,7 +516,7 @@ static void test_id(int id)
if(ndp->type != nd_msg)
continue;
if(ndp->u.msg->id == id && ndp->u.msg->sev == last_sev && ndp->u.msg->fac == last_fac)
xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined", id, last_fac, last_sev);
xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined\n", id, last_fac, last_sev);
}
}
@ -563,7 +566,7 @@ static int check_languages(node_t *head)
return nm;
}
#define MSGRID(x) ((*(msg_t **)(x))->realid)
#define MSGRID(x) ((*(const msg_t * 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);
@ -601,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));
memset( lbp, 0, sizeof(*lbp) );
if(!lblktail)
{
lblkhead = lblktail = lbp;
@ -653,7 +656,7 @@ static lan_blk_t *block_messages(node_t *head)
static int sc_xlat(const void *p1, const void *p2)
{
return ((cp_xlat_t *)p1)->lan - ((cp_xlat_t *)p2)->lan;
return ((const cp_xlat_t *)p1)->lan - ((const cp_xlat_t *)p2)->lan;
}
static void add_cpxlat(int lan, int cpin, int cpout)

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -36,9 +36,8 @@
static void generic_msg(const char *s, const char *t, va_list ap)
{
fprintf(stderr, "%s %s: %d, %d: ", t, input_name ? input_name : "stdin", line_number, char_number);
fprintf(stderr, "%s:%d:%d: %s: ", input_name ? input_name : "stdin", line_number, char_number, t);
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
}
/*
@ -49,7 +48,7 @@ static void generic_msg(const char *s, const char *t, va_list ap)
* The extra routine 'xyyerror' is used to exit after giving a real
* message.
*/
int yyerror(const char *s, ...)
int mcy_error(const char *s, ...)
{
#ifndef SUPPRESS_YACC_ERROR_MESSAGE
va_list ap;
@ -70,7 +69,7 @@ int xyyerror(const char *s, ...)
return 1;
}
int yywarning(const char *s, ...)
int mcy_warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
@ -85,7 +84,6 @@ void internal_error(const char *file, int line, const char *s, ...)
va_start(ap, s);
fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(3);
}
@ -96,7 +94,6 @@ void error(const char *s, ...)
va_start(ap, s);
fprintf(stderr, "Error: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(2);
}
@ -107,7 +104,6 @@ void warning(const char *s, ...)
va_start(ap, s);
fprintf(stderr, "Warning: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
}
@ -128,7 +124,7 @@ char *dup_basename(const char *name, const char *ext)
namelen = strlen(name);
/* +4 for later extension and +1 for '\0' */
base = (char *)xmalloc(namelen +4 +1);
base = xmalloc(namelen +4 +1);
strcpy(base, name);
if(!strcasecmp(name + namelen-extlen, ext))
{
@ -148,12 +144,7 @@ void *xmalloc(size_t size)
{
error("Virtual memory exhausted.\n");
}
/*
* We set it to 0.
* This is *paramount* because we depend on it
* just about everywhere in the rest of the code.
*/
memset(res, 0, size);
memset(res, 0x55, size);
return res;
}
@ -177,7 +168,7 @@ char *xstrdup(const char *str)
char *s;
assert(str != NULL);
s = (char *)xmalloc(strlen(str)+1);
s = xmalloc(strlen(str)+1);
return strcpy(s, str);
}
@ -203,7 +194,7 @@ WCHAR *xunistrdup(const WCHAR * str)
WCHAR *s;
assert(str != NULL);
s = (WCHAR *)xmalloc((unistrlen(str)+1) * sizeof(WCHAR));
s = xmalloc((unistrlen(str)+1) * sizeof(WCHAR));
return unistrcpy(s, str);
}
@ -220,7 +211,7 @@ int unistricmp(const WCHAR *s1, const WCHAR *s2)
if(!once)
{
once++;
yywarning(warn);
mcy_warning(warn);
}
i = *s1++ - *s2++;
}
@ -233,7 +224,7 @@ int unistricmp(const WCHAR *s1, const WCHAR *s2)
if((*s1 & 0xffff) > 0x7f || (*s2 & 0xffff) > 0x7f)
{
if(!once)
yywarning(warn);
mcy_warning(warn);
return *s1 - *s2;
}
else

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WMC_UTILS_H
@ -33,9 +33,9 @@ char *xstrdup(const char *str);
#define __attribute__(X)
#endif
int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int mcy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int xyyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
int mcy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -31,7 +31,7 @@
#include "lang.h"
#include "write.h"
static char usage[] =
static const char usage[] =
"Usage: wmc [options...] [inputfile.mc]\n"
" -B x Set output byte-order x={n[ative], l[ittle], b[ig]}\n"
" (default is n[ative] which equals "
@ -58,7 +58,7 @@ static char usage[] =
"bytes read, which should be 0x0000..0x00ff.\n"
;
static char version_string[] =
static const char version_string[] =
"Wine Message Compiler version " PACKAGE_VERSION "\n"
"Copyright 2000 Bertho A. Stultiens\n"
;
@ -113,9 +113,22 @@ int char_number = 1; /* The current char pos within the line */
char *cmdline; /* The entire commandline */
time_t now; /* The time of start of wmc */
int mcy_debug;
int getopt (int argc, char *const *argv, const char *optstring);
static void segvhandler(int sig);
static void cleanup_files(void)
{
if (output_name) unlink( output_name );
if (header_name) unlink( header_name );
}
static void exit_on_signal( int sig )
{
exit(1); /* this will call the atexit functions */
}
int main(int argc,char *argv[])
{
extern char* optarg;
@ -126,7 +139,13 @@ int main(int argc,char *argv[])
int i;
int cmdlen;
atexit( cleanup_files );
signal(SIGSEGV, segvhandler);
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
now = time(NULL);
@ -220,7 +239,7 @@ int main(int argc,char *argv[])
return 1;
}
yydebug = dodebug;
mcy_debug = dodebug;
if(dodebug)
{
setbuf(stdout, 0);
@ -254,7 +273,7 @@ int main(int argc,char *argv[])
else
yyin = stdin;
ret = yyparse();
ret = mcy_parse();
if(input_name)
fclose(yyin);
@ -269,7 +288,8 @@ int main(int argc,char *argv[])
write_rc_file(output_name);
if(!rcinline)
write_bin_files();
output_name = NULL;
header_name = NULL;
return 0;
}

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WMC_WMC_H
@ -56,15 +56,15 @@ extern time_t now;
extern int line_number;
extern int char_number;
int yyparse(void);
extern int yydebug;
int mcy_parse(void);
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;
int yylex(void);
int mcy_lex(void);
FILE *yyin;
void set_codepage(int cp);

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WMC_WMCTYPES_H

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -87,7 +87,7 @@
* for normal character strings and 1 for unicode strings.
*/
static char str_header[] =
static const char str_header[] =
"/* This file is generated with wmc version " PACKAGE_VERSION ". Do not edit! */\n"
"/* Source : %s */\n"
"/* Cmdline: %s */\n"
@ -101,11 +101,11 @@ static char *dup_u2c(int cp, const WCHAR *uc)
char *cptr;
const union cptable *cpdef = find_codepage(cp);
if(!cpdef)
internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)", cp);
internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)\n", cp);
len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
cptr = xmalloc(len);
if((len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len, NULL, NULL)) < 0)
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", len);
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", len);
return cptr;
}
@ -271,14 +271,14 @@ void write_h_file(const char *fname)
fprintf(fp, "#define %s\t0x%08xL\n\n", cptr, ndp->u.msg->realid);
break;
default:
internal_error(__FILE__, __LINE__, "Invalid base for number print");
internal_error(__FILE__, __LINE__, "Invalid base for number print\n");
}
free(cptr);
if(cast)
free(cast);
break;
default:
internal_error(__FILE__, __LINE__, "Invalid node type %d", ndp->type);
internal_error(__FILE__, __LINE__, "Invalid node type %d\n", ndp->type);
}
}
fprintf(fp, "\n#endif\n");
@ -308,7 +308,7 @@ static void write_rcbin(FILE *fp)
}
}
if(!cptr)
internal_error(__FILE__, __LINE__, "Filename vanished for language 0x%0x", lbp->lan);
internal_error(__FILE__, __LINE__, "Filename vanished for language 0x%0x\n", lbp->lan);
fprintf(fp, "1 MESSAGETABLE \"%s.bin\"\n", cptr);
free(cptr);
}
@ -390,7 +390,7 @@ static char *make_string(WCHAR *uc, int len, int codepage)
mlen = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
cc = tmp = xmalloc(mlen);
if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0)
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", i);
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
*cptr++ = ' ';
*cptr++ = '"';
for(i = b = 0; i < len; i++, cc++)

View file

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WMC_WRITE_H
#define __WMC_WRITE_H