- Update WRC to Wine-0.9.53.

- Update and include to the build process utf8.c of unicode library.

svn path=/trunk/; revision=31829
This commit is contained in:
Aleksey Bragin 2008-01-16 17:16:34 +00:00
parent 78150156e2
commit c42936177e
26 changed files with 2977 additions and 2971 deletions

View file

@ -26,7 +26,7 @@ reactos/tools/wpp # Synced to Wine-0_9_5
reactos/tools/bin2res # Resource to binary converter
reactos/tools/winebuild # Synced to Wine-20071217
reactos/tools/wmc # Synced to Wine-20071201
reactos/tools/wrc # Synced to Wine-0_9_5
reactos/tools/wrc # Synced to Wine-0_9_53
reactos/tools/widl # Synced to Wine-20080105
The following libraries are shared with Wine.

View file

@ -89,6 +89,7 @@ UNICODE_SOURCES = $(addprefix $(UNICODE_BASE_), \
wctomb.c \
wctype.c \
$(UNICODE_CODEPAGES:%=c_%.o) \
utf8.c \
)
UNICODE_OBJECTS = \
@ -374,6 +375,10 @@ $(UNICODE_INT_)c_28606.o: $(UNICODE_BASE_)c_28606.c | $(UNICODE_INT)
$(ECHO_CC)
${host_gcc} $(UNICODE_HOST_CFLAGS) -c $< -o $@
$(UNICODE_INT_)utf8.o: $(UNICODE_BASE_)utf8.c | $(UNICODE_INT)
$(ECHO_CC)
${host_gcc} $(UNICODE_HOST_CFLAGS) -c $< -o $@
.PHONY: unicode_clean
unicode_clean:
-@$(rm) $(UNICODE_TARGET) $(UNICODE_OBJECTS) 2>$(NUL)

View file

@ -41,33 +41,63 @@ static const unsigned char utf8_mask[6] = { 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }
/* minimum Unicode value depending on UTF-8 sequence length */
static const unsigned int utf8_minval[6] = { 0x0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 };
/* get the next char value taking surrogates into account */
static inline unsigned int get_surrogate_value( const WCHAR *src, unsigned int srclen )
{
if (src[0] >= 0xd800 && src[0] <= 0xdfff) /* surrogate pair */
{
if (src[0] > 0xdbff || /* invalid high surrogate */
srclen <= 1 || /* missing low surrogate */
src[1] < 0xdc00 || src[1] > 0xdfff) /* invalid low surrogate */
return 0;
return 0x10000 + ((src[0] & 0x3ff) << 10) + (src[1] & 0x3ff);
}
return src[0];
}
/* query necessary dst length for src string */
inline static int get_length_wcs_utf8( const WCHAR *src, unsigned int srclen )
static inline int get_length_wcs_utf8( int flags, const WCHAR *src, unsigned int srclen )
{
int len;
for (len = 0; srclen; srclen--, src++, len++)
unsigned int val;
for (len = 0; srclen; srclen--, src++)
{
if (*src >= 0x80)
if (*src < 0x80) /* 0x00-0x7f: 1 byte */
{
len++;
if (*src >= 0x800) len++;
continue;
}
if (*src < 0x800) /* 0x80-0x7ff: 2 bytes */
{
len += 2;
continue;
}
if (!(val = get_surrogate_value( src, srclen )))
{
if (flags & WC_ERR_INVALID_CHARS) return -2;
continue;
}
if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
len += 3;
else /* 0x10000-0x10ffff: 4 bytes */
len += 4;
}
return len;
}
/* wide char to UTF-8 string conversion */
/* return -1 on dst buffer overflow */
int wine_utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen )
/* return -1 on dst buffer overflow, -2 on invalid input char */
int wine_utf8_wcstombs( int flags, const WCHAR *src, int srclen, char *dst, int dstlen )
{
int len;
if (!dstlen) return get_length_wcs_utf8( src, srclen );
if (!dstlen) return get_length_wcs_utf8( flags, src, srclen );
for (len = dstlen; srclen; srclen--, src++)
{
WCHAR ch = *src;
unsigned int val;
if (ch < 0x80) /* 0x00-0x7f: 1 byte */
{
@ -86,15 +116,34 @@ int wine_utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen )
continue;
}
/* 0x800-0xffff: 3 bytes */
if (!(val = get_surrogate_value( src, srclen )))
{
if (flags & WC_ERR_INVALID_CHARS) return -2;
continue;
}
if ((len -= 3) < 0) return -1; /* overflow */
dst[2] = 0x80 | (ch & 0x3f);
ch >>= 6;
dst[1] = 0x80 | (ch & 0x3f);
ch >>= 6;
dst[0] = 0xe0 | ch;
dst += 3;
if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
{
if ((len -= 3) < 0) return -1; /* overflow */
dst[2] = 0x80 | (val & 0x3f);
val >>= 6;
dst[1] = 0x80 | (val & 0x3f);
val >>= 6;
dst[0] = 0xe0 | val;
dst += 3;
}
else /* 0x10000-0x10ffff: 4 bytes */
{
if ((len -= 4) < 0) return -1; /* overflow */
dst[3] = 0x80 | (val & 0x3f);
val >>= 6;
dst[2] = 0x80 | (val & 0x3f);
val >>= 6;
dst[1] = 0x80 | (val & 0x3f);
val >>= 6;
dst[0] = 0xf0 | val;
dst += 4;
}
}
return dstlen - len;
}

View file

@ -41,6 +41,7 @@
#define WC_DISCARDNS 16
#define WC_DEFAULTCHAR 64
#define WC_NO_BEST_FIT_CHARS 1024
#define WC_ERR_INVALID_CHARS 0x0080
#ifndef WINE_UNICODE_API
#define WINE_UNICODE_API DECLSPEC_IMPORT
@ -93,7 +94,7 @@ extern int wine_cp_wcstombs( const union cptable *table, int flags,
extern int wine_cpsymbol_mbstowcs( const char *src, int srclen, WCHAR *dst, int dstlen );
extern int wine_cpsymbol_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen );
extern int wine_utf8_mbstowcs( int flags, const char *src, int srclen, WCHAR *dst, int dstlen );
extern int wine_utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen );
extern int wine_utf8_wcstombs( int flags, const WCHAR *src, int srclen, char *dst, int dstlen );
extern int wine_compare_string( int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2 );
extern int wine_get_sortkey( int flags, const WCHAR *src, int srclen, char *dst, int dstlen );

View file

@ -273,7 +273,7 @@ Bertho Stultiens <bertho@akhphd.au.dk>
- Allocate cursor and icon ordinals according to the language of the item to
decrease the amount of ordinals in use. This reduces the resource
directory size by reducing the tree size.
- Versions 1.0.5 through 1.0.7 were never commited to cvs but were available
- Versions 1.0.5 through 1.0.7 were never committed to cvs but were available
for download from an alternate site for elf-dll test generation.
---------------------------------------------------------------------------

View file

@ -13,7 +13,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"
@ -546,7 +546,7 @@ static void dump_control(const control_t *ctrl)
printf("\tExStyle: %08x\n", ctrl->exstyle->or_mask);
}
if(ctrl->gothelpid)
printf("\tHelpid: %u\n", ctrl->helpid);
printf("\tHelpid: %d\n", ctrl->helpid);
if(ctrl->extra)
{
printf("\t");
@ -636,7 +636,7 @@ static void dump_dialogex(const dialogex_t *dlgex)
printf("ExStyle: %08x\n", dlgex->exstyle->or_mask);
}
if(dlgex->gothelpid)
printf("Helpid: %u\n", dlgex->helpid);
printf("Helpid: %d\n", dlgex->helpid);
printf("Menu: %s\n", get_nameid_str(dlgex->menu));
printf("Class: %s\n", get_nameid_str(dlgex->dlgclass));
printf("Title: "); print_string(dlgex->title); printf("\n");
@ -732,7 +732,7 @@ static void dump_menuex_item(const menuex_item_t *item)
if(item->gotid)
printf(", Id=%d", item->id);
if(item->gottype)
printf(", Type=%u", item->type);
printf(", Type=%d", item->type);
if(item->gotstate)
printf(", State=%08x", item->state);
if(item->gothelpid)
@ -749,7 +749,7 @@ static void dump_menuex_item(const menuex_item_t *item)
if(item->gotid)
printf(", Id=%d", item->id);
if(item->gottype)
printf(", Type=%u", item->type);
printf(", Type=%d", item->type);
if(item->gotstate)
printf(", State=%08x", item->state);
if(item->gothelpid)

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 __WRC_DUMPRES_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
*
* History:
* 05-May-2000 BS - Added code to support endian conversions. The
@ -54,7 +54,8 @@ res_t *new_res(void)
r = (res_t *)xmalloc(sizeof(res_t));
r->allocsize = RES_BLOCKSIZE;
r->size = 0;
r->data = (char *)xmalloc(RES_BLOCKSIZE);
r->dataidx = 0;
r->data = xmalloc(RES_BLOCKSIZE);
return r;
}
@ -276,7 +277,7 @@ static void string_to_upper(string_t *str)
}
else
{
internal_error(__FILE__, __LINE__, "Invalid string type %d", str->type);
internal_error(__FILE__, __LINE__, "Invalid string type %d\n", str->type);
}
}
@ -317,7 +318,7 @@ static void put_string(res_t *res, const string_t *str, enum str_e type, int ist
{
if (!check_unicode_conversion( str, newstr, codepage ))
error( "String %s does not convert identically to Unicode and back in codepage %d. "
"Try using a Unicode string instead.", str->str.cstr, codepage );
"Try using a Unicode string instead\n", str->str.cstr, codepage );
}
if (!isterm) put_word(res, newstr->size);
for(cnt = 0; cnt < newstr->size; cnt++)
@ -370,7 +371,7 @@ static void put_name_id(res_t *res, name_id_t *nid, int upcase, const language_t
}
else
{
internal_error(__FILE__, __LINE__, "Invalid name_id type %d", nid->type);
internal_error(__FILE__, __LINE__, "Invalid name_id type %d\n", nid->type);
}
}
@ -601,7 +602,7 @@ static res_t *dialog2res(name_id_t *name, dialog_t *dlg)
if(ctrl->ctlclass)
put_name_id(res, ctrl->ctlclass, TRUE, dlg->lvc.language);
else
internal_error(__FILE__, __LINE__, "Control has no control-class");
internal_error(__FILE__, __LINE__, "Control has no control-class\n");
if(ctrl->title)
put_name_id(res, ctrl->title, FALSE, dlg->lvc.language);
else
@ -669,10 +670,10 @@ static res_t *dialog2res(name_id_t *name, dialog_t *dlg)
else if(ctrl->ctlclass->type == name_str)
put_name_id(res, ctrl->ctlclass, FALSE, NULL);
else
error("Unknown control-class %04x", ctrl->ctlclass->name.i_name);
error("Unknown control-class %04x\n", ctrl->ctlclass->name.i_name);
}
else
internal_error(__FILE__, __LINE__, "Control has no control-class");
internal_error(__FILE__, __LINE__, "Control has no control-class\n");
if(ctrl->title)
put_name_id(res, ctrl->title, FALSE, NULL);
else
@ -776,7 +777,7 @@ static res_t *dialogex2res(name_id_t *name, dialogex_t *dlgex)
if(ctrl->ctlclass)
put_name_id(res, ctrl->ctlclass, TRUE, dlgex->lvc.language);
else
internal_error(__FILE__, __LINE__, "Control has no control-class");
internal_error(__FILE__, __LINE__, "Control has no control-class\n");
if(ctrl->title)
put_name_id(res, ctrl->title, FALSE, dlgex->lvc.language);
else
@ -1412,7 +1413,7 @@ static res_t *rcdata2res(name_id_t *name, rcdata_t *rdt)
* Output : New .res format structure
* Description :
* Remarks : The data has been converted to the appropriate endian
* after is was parsed.
* after it was parsed.
*****************************************************************************
*/
static res_t *messagetable2res(name_id_t *name, messagetable_t *msg)
@ -1458,7 +1459,7 @@ static res_t *stringtable2res(stringtable_t *stt)
{
if(!stt->nentries)
{
warning("Empty internal stringtable");
warning("Empty internal stringtable\n");
continue;
}
name.type = name_ord;
@ -1595,7 +1596,7 @@ static void versionblock2res(res_t *res, ver_block_t *blk, int level, const lang
}
else
{
internal_error(__FILE__, __LINE__, "Invalid value indicator %d in VERSIONINFO", val->type);
internal_error(__FILE__, __LINE__, "Invalid value indicator %d in VERSIONINFO\n", val->type);
}
}
@ -1798,7 +1799,7 @@ char *prep_nid_for_label(const name_id_t *nid)
if((unsigned)*sptr < 0x80 && isprint(*sptr & 0xff))
buf[i] = *sptr++;
else
warning("Resourcename (str_unicode) contain unprintable characters or invalid translation, ignored");
warning("Resourcename (str_unicode) contain unprintable characters or invalid translation, ignored\n");
}
buf[i] = '\0';
}
@ -1813,7 +1814,7 @@ char *prep_nid_for_label(const name_id_t *nid)
if((unsigned)*cptr < 0x80 && isprint(*cptr & 0xff))
buf[i] = *cptr++;
else
warning("Resourcename (str_char) contain unprintable characters, ignored");
warning("Resourcename (str_char) contain unprintable characters, ignored\n");
}
buf[i] = '\0';
}
@ -1823,7 +1824,7 @@ char *prep_nid_for_label(const name_id_t *nid)
}
else
{
internal_error(__FILE__, __LINE__, "Resource name_id with invalid type %d", nid->type);
internal_error(__FILE__, __LINE__, "Resource name_id with invalid type %d\n", nid->type);
}
return buf;
}
@ -2004,7 +2005,7 @@ void resources2res(resource_t *top)
top->binres = anicurico2res(top->name, top->res.ani, top->type);
break;
default:
internal_error(__FILE__, __LINE__, "Unknown resource type encountered %d in binary res generation", top->type);
internal_error(__FILE__, __LINE__, "Unknown resource type encountered %d in binary res generation\n", top->type);
}
top->c_name = make_c_name(get_c_typename(top->type), top->name, top->lan);
top = top->next;

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 __WRC_GENRES_H

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,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"
@ -73,7 +73,8 @@ __NEW_STRUCT_FUNC(ani_any)
*/
resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan)
{
resource_t *r = (resource_t *)xmalloc(sizeof(resource_t));
resource_t *r = xmalloc(sizeof(resource_t));
memset( r, 0, sizeof(*r) );
r->type = t;
r->res.overlay = res;
r->memopt = memopt;
@ -324,10 +325,7 @@ static int convert_bitmap(char *data, int size)
type |= FL_SIZEBE | FL_OS2;
}
else
{
fprintf(stderr, "bisizel %d bosizel %d b4sizel %d\n", bisizel, bosizel, b4sizel);
yyerror("Invalid bitmap format, bih->biSize = %u", bih->biSize);
}
parser_error("Invalid bitmap format, bih->biSize = %d\n", bih->biSize);
switch(type)
{
@ -336,12 +334,12 @@ static int convert_bitmap(char *data, int size)
case FL_SIZEBE:
case FL_SIZEBE | FL_V4:
case FL_SIZEBE | FL_OS2:
yywarning("Bitmap v%c signature little-endian, but size big-endian", type & FL_V4 ? '4' : '3');
parser_warning("Bitmap v%c signature little-endian, but size big-endian\n", type & FL_V4 ? '4' : '3');
break;
case FL_SIGBE:
case FL_SIGBE | FL_V4:
case FL_SIGBE | FL_OS2:
yywarning("Bitmap v%c signature big-endian, but size little-endian", type & FL_V4 ? '4' : '3');
parser_warning("Bitmap v%c signature big-endian, but size little-endian\n", type & FL_V4 ? '4' : '3');
break;
}
@ -461,7 +459,7 @@ static void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico)
else if(BYTESWAP_WORD(ih->type) == 1)
swap = 1;
else
yyerror("Icon resource data has invalid type id %d", ih->type);
parser_error("Icon resource data has invalid type id %d\n", ih->type);
cnt = swap ? BYTESWAP_WORD(ih->count) : ih->count;
for(i = 0; i < cnt; i++)
@ -481,7 +479,7 @@ static void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico)
}
if(ide.offset > rd->size
|| ide.offset + ide.ressize > rd->size)
yyerror("Icon resource data corrupt");
parser_error("Icon resource data corrupt\n");
ico->width = ide.width;
ico->height = ide.height;
ico->nclr = ide.nclr;
@ -556,7 +554,7 @@ static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
else if(BYTESWAP_WORD(ch->type) == 2)
swap = 1;
else
yyerror("Cursor resource data has invalid type id %d", ch->type);
parser_error("Cursor resource data has invalid type id %d\n", ch->type);
cnt = swap ? BYTESWAP_WORD(ch->count) : ch->count;
for(i = 0; i < cnt; i++)
{
@ -575,7 +573,7 @@ static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
}
if(cde.offset > rd->size
|| cde.offset + cde.ressize > rd->size)
yyerror("Cursor resource data corrupt");
parser_error("Cursor resource data corrupt\n");
cur->width = cde.width;
cur->height = cde.height;
cur->nclr = cde.nclr;
@ -598,7 +596,7 @@ static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
cur->bits = info.biBitCount;
}
if(!win32 && (cur->planes != 1 || cur->bits != 1))
yywarning("Win16 cursor contains colors");
parser_warning("Win16 cursor contains colors\n");
cur->xhot = swap ? BYTESWAP_WORD(cde.xhot) : cde.xhot;
cur->yhot = swap ? BYTESWAP_WORD(cde.yhot) : cde.yhot;
cur->data = new_raw_data();
@ -745,21 +743,21 @@ static void handle_ani_icon(riff_tag_t *rtp, enum res_e type, int isswapped)
if(type == res_anicur && ctype != 2 && !once)
{
yywarning("Animated cursor contains invalid \"icon\" tag cursor-file (%d->%s)",
parser_warning("Animated cursor contains invalid \"icon\" tag cursor-file (%d->%s)",
ctype,
ctype == 1 ? "icontype" : "?");
once++;
}
else if(type == res_aniico && ctype != 1 && !once)
{
yywarning("Animated icon contains invalid \"icon\" tag icon-file (%d->%s)",
parser_warning("Animated icon contains invalid \"icon\" tag icon-file (%d->%s)",
ctype,
ctype == 2 ? "cursortype" : "?");
once++;
}
else if(ctype != 1 && ctype != 2 && !once)
{
yywarning("Animated %s contains invalid \"icon\" tag file-type (%d; neither icon nor cursor)", anistr, ctype);
parser_warning("Animated %s contains invalid \"icon\" tag file-type (%d; neither icon nor cursor)", anistr, ctype);
once++;
}
@ -768,7 +766,7 @@ static void handle_ani_icon(riff_tag_t *rtp, enum res_e type, int isswapped)
DWORD ofs = isswapped ? BYTESWAP_DWORD(cdp[i].offset) : cdp[i].offset;
DWORD sze = isswapped ? BYTESWAP_DWORD(cdp[i].ressize) : cdp[i].ressize;
if(ofs > rtp->size || ofs+sze > rtp->size)
yyerror("Animated %s's data corrupt", anistr);
parser_error("Animated %s's data corrupt", anistr);
convert_bitmap((char *)chp + ofs, 0);
cdp[i].xhot = BYTESWAP_WORD(cdp->xhot);
cdp[i].yhot = BYTESWAP_WORD(cdp->yhot);
@ -817,7 +815,7 @@ static void handle_ani_list(riff_tag_t *lst, enum res_e type, int isswapped)
isprint(rtp->tag[2]) ? rtp->tag[2] : '.',
isprint(rtp->tag[3]) ? rtp->tag[3] : '.');
if((LONG_PTR)rtp & 1)
if((UINT_PTR)rtp & 1)
rtp = SKIP_TAG(rtp,1);
}
}
@ -840,7 +838,7 @@ ani_curico_t *new_ani_curico(enum res_e type, raw_data_t *rd, int *memopt)
else if(rtp->size + 2*sizeof(DWORD) == rd->size)
isswapped = 0;
else
yyerror("Animated %s has an invalid RIFF length", anistr);
parser_error("Animated %s has an invalid RIFF length\n", anistr);
switch(byteorder)
{
@ -927,13 +925,13 @@ ani_curico_t *new_ani_curico(enum res_e type, raw_data_t *rd, int *memopt)
isprint(rtp->tag[2]) ? rtp->tag[2] : '.',
isprint(rtp->tag[3]) ? rtp->tag[3] : '.');
if((LONG_PTR)rtp & 1)
if((UINT_PTR)rtp & 1)
rtp = SKIP_TAG(rtp,1);
}
/* We must end correctly here */
if((char *)rtp != (char *)rd->data + rd->size)
yyerror("Animated %s contains invalid field size(s)", anistr);
parser_error("Animated %s contains invalid field size(s)", anistr);
}
ani->data = rd;
@ -1002,7 +1000,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
msg->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
if(rd->size < sizeof(DWORD))
yyerror("Invalid messagetable, size too small");
parser_error("Invalid messagetable, size too small\n");
nblk = *(DWORD *)rd->data;
lo = WRC_LOWORD(nblk);
@ -1017,9 +1015,9 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
* the ID, offset and length (and flag) fields to be very sure.
*/
if(hi && lo)
internal_error(__FILE__, __LINE__, "Messagetable contains more than 65535 blocks; cannot determine endian");
internal_error(__FILE__, __LINE__, "Messagetable contains more than 65535 blocks; cannot determine endian\n");
if(!hi && !lo)
yyerror("Invalid messagetable block count 0");
parser_error("Invalid messagetable block count 0\n");
if(!hi && lo) /* Messagetable byteorder == native byteorder */
{
@ -1032,7 +1030,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]);
if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
yyerror("Messagetable's blocks are outside of defined data");
parser_error("Messagetable's blocks are outside of defined data\n");
for(i = 0; i < nblk; i++)
{
msgtab_entry_t *mep, *next_mep;
@ -1043,7 +1041,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
for(id = mbp[i].idlo; id <= mbp[i].idhi; id++)
{
if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
yyerror("Messagetable's data for block %d, ID 0x%08x is outside of defined data", (int)i, id);
parser_error("Messagetable's data for block %d, ID 0x%08x is outside of defined data\n", i, id);
if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */
{
WORD *wp = (WORD *)&mep[1];
@ -1051,7 +1049,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
int n;
if(mep->length & 1)
yyerror("Message 0x%08x is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length);
parser_error("Message 0x%08x is unicode (block %d), but has odd length (%d)\n", id, i, mep->length);
for(n = 0; n < l; n++)
wp[n] = BYTESWAP_WORD(wp[n]);
@ -1079,7 +1077,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]);
nblk = BYTESWAP_DWORD(nblk);
if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
yyerror("Messagetable's blocks are outside of defined data");
parser_error("Messagetable's blocks are outside of defined data\n");
for(i = 0; i < nblk; i++)
{
msgtab_entry_t *mep;
@ -1096,7 +1094,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
mep->flags = BYTESWAP_WORD(mep->flags);
if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
yyerror("Messagetable's data for block %d, ID 0x%08x is outside of defined data", (int)i, id);
parser_error("Messagetable's data for block %d, ID 0x%08x is outside of defined data\n", i, id);
if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */
{
WORD *wp = (WORD *)&mep[1];
@ -1104,7 +1102,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
int n;
if(mep->length & 1)
yyerror("Message 0x%08x is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length);
parser_error("Message 0x%08x is unicode (block %d), but has odd length (%d)\n", id, i, mep->length);
for(n = 0; n < l; n++)
wp[n] = BYTESWAP_WORD(wp[n]);
@ -1146,6 +1144,7 @@ stringtable_t *new_stringtable(lvc_t *lvc)
{
stringtable_t *stt = (stringtable_t *)xmalloc(sizeof(stringtable_t));
memset( stt, 0, sizeof(*stt) );
if(lvc)
stt->lvc = *lvc;

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 __WRC_NEWSTRUC_H
@ -26,7 +26,9 @@
#define __NEW_STRUCT_FUNC(p) \
p##_t *new_##p(void)\
{\
return (p##_t *)xmalloc(sizeof(p##_t));\
p##_t * ret = xmalloc(sizeof(*ret)); \
memset( ret, 0, sizeof(*ret) ); \
return ret; \
}
#define __NEW_STRUCT_PROTO(p) p##_t *new_##p(void)

View file

@ -15,25 +15,25 @@
*
* 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 __WRC_PARSER_H
#define __WRC_PARSER_H
/* From parser.y */
extern int yydebug;
extern int parser_debug;
extern int want_nl; /* Set when getting line-numers */
extern int want_id; /* Set when getting the resource name */
int yyparse(void);
int parser_parse(void);
/* From parser.l */
extern FILE *yyin;
extern char *yytext;
extern FILE *parser_in;
extern char *parser_text;
extern int yy_flex_debug;
int yylex(void);
int parser_lex(void);
#endif

View file

@ -14,7 +14,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
*
* History:
* 21-May-2000 BS - Fixed the ident requirement of resource names
@ -68,18 +68,15 @@
*/
/* Exclusive string handling */
%x yystr
%x tkstr
/* Exclusive unicode string handling */
%x yylstr
%x tklstr
/* Exclusive rcdata single quoted data handling */
%x yyrcd
%x tkrcd
/* Exclusive comment eating... */
%x comment
/* Set when stripping c-junk */
%x pp_stripe
%x pp_strips
%x pp_stripp
%x pp_stripp_final
%x pp_cstrip
/* Set when scanning #line style directives */
%x pp_line
/* Set when scanning #pragma */
@ -87,8 +84,9 @@
%x pp_code_page
%option stack
%option nounput noyy_top_state
%option nounput noyy_top_state noyywrap
%option 8bit never-interactive
%option prefix="parser_"
/* Some shortcut definitions */
ws [ \f\t\r]
@ -127,9 +125,6 @@ static int cbufalloc = 0;
static WCHAR *wbuffer;
static int wbufidx;
static int wbufalloc = 0;
static int stripslevel = 0; /* Count {} during pp_strips/pp_stripe mode */
static int stripplevel = 0; /* Count () during pp_strips mode */
static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */
static int current_codepage = -1; /* use language default */
@ -320,81 +315,66 @@ static struct keyword *iskeyword(char *kw)
* because we only want to know the linenumber and
* filename.
*/
<INITIAL,pp_strips,pp_stripp>^{ws}*\#{ws}*pragma{ws}+ yy_push_state(pp_pragma);
<INITIAL,pp_strips,pp_stripp>^{ws}*\#{ws}* yy_push_state(pp_line);
<INITIAL,pp_cstrip>^{ws}*\#{ws}*pragma{ws}+ yy_push_state(pp_pragma);
<INITIAL,pp_cstrip>^{ws}*\#{ws}* yy_push_state(pp_line);
<pp_line>[^\n]* {
int lineno;
int lineno, len;
char *cptr;
char *fname;
yy_pop_state();
lineno = (int)strtol(yytext, &cptr, 10);
if(!lineno)
yyerror("Malformed '#...' line-directive; invalid linenumber");
parser_error("Malformed '#...' line-directive; invalid linenumber\n");
fname = strchr(cptr, '"');
if(!fname)
yyerror("Malformed '#...' line-directive; missing filename");
parser_error("Malformed '#...' line-directive; missing filename\n");
fname++;
cptr = strchr(fname, '"');
if(!cptr)
yyerror("Malformed '#...' line-directive; missing terminating \"");
parser_error("Malformed '#...' line-directive; missing terminating \"");
*cptr = '\0';
line_number = lineno - 1; /* We didn't read the newline */
input_name = xstrdup(fname);
/* ignore contents of C include files */
len = strlen(input_name);
if (len > 1 && !strcasecmp( input_name + len - 2, ".h" ))
BEGIN(pp_cstrip);
else
BEGIN(INITIAL);
}
<pp_pragma>code_page[^\n]* yyless(9); yy_pop_state(); yy_push_state(pp_code_page);
<pp_pragma>[^\n]* yy_pop_state(); if (pedantic) yywarning("Unrecognized #pragma directive '%s'",yytext);
<pp_pragma>[^\n]* yy_pop_state(); if (pedantic) parser_warning("Unrecognized #pragma directive '%s'\n",yytext);
<pp_code_page>\({ws}*default{ws}*\)[^\n]* current_codepage = -1; yy_pop_state();
<pp_code_page>\({ws}*utf8{ws}*\)[^\n]* current_codepage = CP_UTF8; yy_pop_state();
<pp_code_page>\({ws}*[0-9]+{ws}*\)[^\n]* {
char *p = yytext;
yy_pop_state();
while (*p < '0' || *p > '9') p++;
current_codepage = strtol( p, NULL, 10 );
if (current_codepage && !wine_cp_get_table( current_codepage ))
if (current_codepage && current_codepage != CP_UTF8 && !wine_cp_get_table( current_codepage ))
{
yyerror("Codepage %d not supported", current_codepage);
parser_error("Codepage %d not supported\n", current_codepage);
current_codepage = 0;
}
}
<pp_code_page>[^\n]* yy_pop_state(); yyerror("Malformed #pragma code_page directive");
<pp_code_page>[^\n]* yy_pop_state(); parser_error("Malformed #pragma code_page directive\n");
/*
* Strip everything until a ';' taking
* into account braces {} for structures,
* classes and enums.
*/
<pp_strips>\{ stripslevel++;
<pp_strips>\} stripslevel--;
<pp_strips>; if(!stripslevel) yy_pop_state();
<pp_strips>\/[^*\n] ; /* To catch comments */
<pp_strips>[^\{\};\n#/]* ; /* Ignore rest */
<pp_strips>\n line_number++; char_number = 1;
<pp_stripp>\( stripplevel++;
<pp_stripp>\) {
stripplevel--;
if(!stripplevel)
{
yy_pop_state();
yy_push_state(pp_stripp_final);
}
}
<pp_stripp>\/[^*\n] ; /* To catch comments */
<pp_stripp>[^\(\);\n#/]* ; /* Ignore rest */
<pp_stripp>\n line_number++; char_number = 1;
<pp_stripp_final>{ws}* ; /* Ignore */
<pp_stripp_final>; yy_pop_state(); /* Kill the semicolon */
<pp_stripp_final>\n line_number++; char_number = 1; yy_pop_state();
<pp_stripp_final>. yyless(0); yy_pop_state();
<pp_cstrip>\n line_number++; char_number = 1;
<pp_cstrip>. ; /* ignore */
\{ return tBEGIN;
\} return tEND;
[0-9]+[lL]? { yylval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { yylval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { yylval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
[0-9]+[lL]? { parser_lval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { parser_lval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
/*
* The next two rules scan identifiers and filenames.
@ -410,7 +390,7 @@ static struct keyword *iskeyword(char *kw)
{
if(wanted_id && !tok->alwayskw)
{
yylval.str = make_string(yytext);
parser_lval.str = make_string(yytext);
return tIDENT;
}
else
@ -418,137 +398,137 @@ static struct keyword *iskeyword(char *kw)
}
else
{
yylval.str = make_string(yytext);
parser_lval.str = make_string(yytext);
return tIDENT;
}
}
[A-Za-z_0-9./\\]+ yylval.str = make_string(yytext); return tFILENAME;
[A-Za-z_0-9./\\]+ parser_lval.str = make_string(yytext); return tFILENAME;
/*
* Wide string scanning
*/
L\" {
yy_push_state(yylstr);
yy_push_state(tklstr);
wbufidx = 0;
if(!win32)
yywarning("16bit resource contains unicode strings\n");
parser_warning("16bit resource contains unicode strings\n");
}
<yylstr>\"{ws}+ |
<yylstr>\" {
<tklstr>\"{ws}+ |
<tklstr>\" {
yy_pop_state();
yylval.str = get_buffered_wstring();
parser_lval.str = get_buffered_wstring();
return tSTRING;
}
<yylstr>\\[0-7]{1,6} { /* octal escape sequence */
<tklstr>\\[0-7]{1,6} { /* octal escape sequence */
unsigned int result;
result = strtoul(yytext+1, 0, 8);
if ( result > 0xffff )
yyerror("Character constant out of range");
parser_error("Character constant out of range\n");
addwchar((WCHAR)result);
}
<yylstr>\\x[0-9a-fA-F]{4} { /* hex escape sequence */
<tklstr>\\x[0-9a-fA-F]{4} { /* hex escape sequence */
unsigned int result;
result = strtoul(yytext+2, 0, 16);
addwchar((WCHAR)result);
}
<yylstr>\\x[0-9a-fA-F]{1,3} { yyerror("Invalid hex escape sequence '%s'", yytext); }
<tklstr>\\x[0-9a-fA-F]{1,3} { parser_error("Invalid hex escape sequence '%s'\n", yytext); }
<yylstr>\\[0-9]+ yyerror("Bad escape sequence");
<yylstr>\\\n{ws}* line_number++; char_number = 1; /* backslash at EOL continues string after leading whitespace on next line */
<yylstr>\\a addwchar('\a');
<yylstr>\\b addwchar('\b');
<yylstr>\\f addwchar('\f');
<yylstr>\\n addwchar('\n');
<yylstr>\\r addwchar('\r');
<yylstr>\\t addwchar('\t');
<yylstr>\\v addwchar('\v');
<yylstr>\\. addwchar(yytext[1]);
<yylstr>\\\r\n addwchar(yytext[2]); line_number++; char_number = 1;
<yylstr>\"\" addwchar('\"'); /* "bla""bla" -> "bla\"bla" */
<yylstr>\\\"\" addwchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<yylstr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */
<yylstr>[^\\\n\"]+ {
<tklstr>\\[0-9]+ parser_error("Bad escape sequence\n");
<tklstr>\\\n{ws}* line_number++; char_number = 1; /* backslash at EOL continues string after leading whitespace on next line */
<tklstr>\\a addwchar('\a');
<tklstr>\\b addwchar('\b');
<tklstr>\\f addwchar('\f');
<tklstr>\\n addwchar('\n');
<tklstr>\\r addwchar('\r');
<tklstr>\\t addwchar('\t');
<tklstr>\\v addwchar('\v');
<tklstr>\\. addwchar(yytext[1]);
<tklstr>\\\r\n addwchar(yytext[2]); line_number++; char_number = 1;
<tklstr>\"\" addwchar('\"'); /* "bla""bla" -> "bla\"bla" */
<tklstr>\\\"\" addwchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<tklstr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */
<tklstr>[^\\\n\"]+ {
char *yptr = yytext;
while(*yptr) /* FIXME: codepage translation */
addwchar(*yptr++ & 0xff);
}
<yylstr>\n yyerror("Unterminated string");
<tklstr>\n parser_error("Unterminated string\n");
/*
* Normal string scanning
*/
\" yy_push_state(yystr); cbufidx = 0;
<yystr>\"{ws}+ |
<yystr>\" {
\" yy_push_state(tkstr); cbufidx = 0;
<tkstr>\"{ws}+ |
<tkstr>\" {
yy_pop_state();
yylval.str = get_buffered_cstring();
parser_lval.str = get_buffered_cstring();
return tSTRING;
}
<yystr>\\[0-7]{1,3} { /* octal escape sequence */
<tkstr>\\[0-7]{1,3} { /* octal escape sequence */
int result;
result = strtol(yytext+1, 0, 8);
if ( result > 0xff )
yyerror("Character constant out of range");
parser_error("Character constant out of range\n");
addcchar((char)result);
}
<yystr>\\x[0-9a-fA-F]{2} { /* hex escape sequence */
<tkstr>\\x[0-9a-fA-F]{2} { /* hex escape sequence */
int result;
result = strtol(yytext+2, 0, 16);
addcchar((char)result);
}
<yystr>\\x[0-9a-fA-F] { yyerror("Invalid hex escape sequence '%s'", yytext); }
<tkstr>\\x[0-9a-fA-F] { parser_error("Invalid hex escape sequence '%s'\n", yytext); }
<yystr>\\[0-9]+ yyerror("Bad escape sequence");
<yystr>\\\n{ws}* line_number++; char_number = 1; /* backslash at EOL continues string after leading whitespace on next line */
<yystr>\\a addcchar('\a');
<yystr>\\b addcchar('\b');
<yystr>\\f addcchar('\f');
<yystr>\\n addcchar('\n');
<yystr>\\r addcchar('\r');
<yystr>\\t addcchar('\t');
<yystr>\\v addcchar('\v');
<yystr>\\. addcchar(yytext[1]);
<yystr>\\\r\n addcchar(yytext[2]); line_number++; char_number = 1;
<yystr>[^\\\n\"]+ {
<tkstr>\\[0-9]+ parser_error("Bad escape sequence\n");
<tkstr>\\\n{ws}* line_number++; char_number = 1; /* backslash at EOL continues string after leading whitespace on next line */
<tkstr>\\a addcchar('\a');
<tkstr>\\b addcchar('\b');
<tkstr>\\f addcchar('\f');
<tkstr>\\n addcchar('\n');
<tkstr>\\r addcchar('\r');
<tkstr>\\t addcchar('\t');
<tkstr>\\v addcchar('\v');
<tkstr>\\. addcchar(yytext[1]);
<tkstr>\\\r\n addcchar(yytext[2]); line_number++; char_number = 1;
<tkstr>[^\\\n\"]+ {
char *yptr = yytext;
while(*yptr)
addcchar(*yptr++);
}
<yystr>\"\" addcchar('\"'); /* "bla""bla" -> "bla\"bla" */
<yystr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<yystr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */
<yystr>\n yyerror("Unterminated string");
<tkstr>\"\" addcchar('\"'); /* "bla""bla" -> "bla\"bla" */
<tkstr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<tkstr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */
<tkstr>\n parser_error("Unterminated string\n");
/*
* Raw data scanning
*/
\' yy_push_state(yyrcd); cbufidx = 0;
<yyrcd>\' {
\' yy_push_state(tkrcd); cbufidx = 0;
<tkrcd>\' {
yy_pop_state();
yylval.raw = new_raw_data();
yylval.raw->size = cbufidx;
yylval.raw->data = xmalloc(yylval.raw->size);
memcpy(yylval.raw->data, cbuffer, yylval.raw->size);
parser_lval.raw = new_raw_data();
parser_lval.raw->size = cbufidx;
parser_lval.raw->data = xmalloc(parser_lval.raw->size);
memcpy(parser_lval.raw->data, cbuffer, parser_lval.raw->size);
return tRAWDATA;
}
<yyrcd>[0-9a-fA-F]{2} {
<tkrcd>[0-9a-fA-F]{2} {
int result;
result = strtol(yytext, 0, 16);
addcchar((char)result);
}
<yyrcd>{ws}+ ; /* Ignore space */
<yyrcd>\n line_number++; char_number = 1;
<yyrcd>. yyerror("Malformed data-line");
<tkrcd>{ws}+ ; /* Ignore space */
<tkrcd>\n line_number++; char_number = 1;
<tkrcd>. parser_error("Malformed data-line\n");
/*
* Comment stripping
* Should never occur after preprocessing
*/
<INITIAL,pp_stripp,pp_strips>"/*" {
<INITIAL,pp_cstrip>"/*" {
yy_push_state(comment);
save_wanted_id = wanted_id;
if(!no_preprocess)
yywarning("Found comments after preprocessing, please report");
parser_warning("Found comments after preprocessing, please report\n");
}
<comment>[^*\n]* ;
<comment>"*"+[^*/\n]* ;
@ -556,7 +536,7 @@ L\" {
<comment>"*"+"/" yy_pop_state(); want_id = save_wanted_id;
;[^\n]* want_id = wanted_id; /* not really comment, but left-over c-junk */
"//"[^\n]* want_id = wanted_id; if(!no_preprocess) yywarning("Found comments after preprocessing, please report");
"//"[^\n]* want_id = wanted_id; if(!no_preprocess) parser_warning("Found comments after preprocessing, please report\n");
\n {
want_id = wanted_id;
@ -572,13 +552,6 @@ L\" {
<INITIAL>. return yytext[0];
<<EOF>> {
if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final)
yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline);
else
yyterminate();
}
<*>.|\n {
/* Catch all rule to find any unmatched text */
if(*yytext == '\n')
@ -586,25 +559,12 @@ L\" {
line_number++;
char_number = 1;
}
yywarning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d",
isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START,stripslevel);
parser_warning("Unmatched text '%c' (0x%02x) YY_START=%d\n",
isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START);
}
%%
#ifndef yywrap
int yywrap(void)
{
#if 0
if(bufferstackidx > 0)
{
return 0;
}
#endif
return 1;
}
#endif
/* These dup functions copy the enclosed '\0' from
* the resource string.
*/
@ -615,7 +575,7 @@ static void addcchar(char c)
cbufalloc += 1024;
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
if(cbufalloc > 65536)
yywarning("Reallocating string buffer larger than 64kB");
parser_warning("Reallocating string buffer larger than 64kB\n");
}
cbuffer[cbufidx++] = c;
}
@ -627,7 +587,7 @@ static void addwchar(WCHAR s)
wbufalloc += 1024;
wbuffer = xrealloc(wbuffer, wbufalloc * sizeof(wbuffer[0]));
if(wbufalloc > 65536)
yywarning("Reallocating wide string buffer larger than 64kB");
parser_warning("Reallocating wide string buffer larger than 64kB\n");
}
wbuffer[wbufidx++] = s;
}
@ -638,21 +598,21 @@ static string_t *get_buffered_cstring(void)
str->size = cbufidx;
str->type = str_char;
str->str.cstr = (char *)xmalloc(cbufidx+1);
str->str.cstr = xmalloc(cbufidx+1);
memcpy(str->str.cstr, cbuffer, cbufidx);
str->str.cstr[cbufidx] = '\0';
if (!current_codepage || current_codepage == -1 || !win32) /* store as ANSI string */
{
if (!current_codepage) yyerror("Codepage set to Unicode only, cannot use ASCII string here");
if (!current_codepage) parser_error("Codepage set to Unicode only, cannot use ASCII string here\n");
return str;
}
else /* convert to Unicode before storing */
{
string_t *str_w = convert_string( str, str_unicode, current_codepage );
if (!check_unicode_conversion( str, str_w, current_codepage ))
yyerror("String %s does not convert identically to Unicode and back in codepage %d. "
"Try using a Unicode string instead.", str->str.cstr, current_codepage );
parser_error("String %s does not convert identically to Unicode and back in codepage %d. "
"Try using a Unicode string instead\n", str->str.cstr, current_codepage );
free_string( str );
return str_w;
}
@ -674,7 +634,7 @@ static string_t *make_string(char *s)
string_t *str = new_string();
str->size = strlen(s);
str->type = str_char;
str->str.cstr = (char *)xmalloc(str->size+1);
str->str.cstr = xmalloc(str->size+1);
memcpy(str->str.cstr, s, str->size+1);
return str;
}

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.
@ -114,6 +114,7 @@
pUPM = 340
};
#endif
/* Tokens. */
#define tNL 258
#define tNUMBER 259
#define tLNUMBER 260
@ -202,7 +203,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 241 "parser.y"
#line 237 "parser.y"
typedef union YYSTYPE {
string_t *str;
int num;
@ -246,14 +247,14 @@ typedef union YYSTYPE {
style_t *style;
ani_any_t *ani;
} YYSTYPE;
/* Line 1275 of yacc.c. */
#line 251 "parser.tab.h"
/* Line 1447 of yacc.c. */
#line 252 "parser.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 parser_lval;

View file

@ -16,7 +16,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
*
* History:
* 24-Jul-2000 BS - Made a fix for broken Berkeley yacc on
@ -296,7 +296,6 @@ static int rsrcid_to_token(int lookahead);
%token tFILEVERSION tPRODUCTVERSION tFILEFLAGSMASK tFILEOS tFILETYPE tFILEFLAGS tFILESUBTYPE
%token tMENUBARBREAK tMENUBREAK tMENUITEM tPOPUP tSEPARATOR
%token tHELP
%token tSTRING tIDENT tRAWDATA
%token tTOOLBAR tBUTTON
%token tBEGIN tEND
%token tDLGINIT
@ -344,7 +343,7 @@ static int rsrcid_to_token(int lookahead);
%type <lan> opt_language
%type <chars> opt_characts
%type <ver> opt_version
%type <num> expr xpr xpr_no_not
%type <num> expr xpr
%type <iptr> e_expr
%type <tlbar> toolbar
%type <tlbarItems> toolbar_items
@ -416,7 +415,7 @@ resources
&& rsc->lan->sub == head->lan->sub
&& !compare_name_id(rsc->name, head->name))
{
yyerror("Duplicate resource name '%s'", get_nameid_str(rsc->name));
parser_error("Duplicate resource name '%s'\n", get_nameid_str(rsc->name));
}
rsc = rsc->prev;
}
@ -473,11 +472,11 @@ resource
if($$)
{
if($1 > 65535 || $1 < -32768)
yyerror("Resource's ID out of range (%d)", $1);
parser_error("Resource's ID out of range (%d)\n", $1);
$$->name = new_name_id();
$$->name->type = name_ord;
$$->name->name.i_name = $1;
chat("Got %s (%d)", get_typename($3), $$->name->name.i_name);
chat("Got %s (%d)\n", get_typename($3), $$->name->name.i_name);
}
}
| tIDENT usrcvt resource_definition {
@ -487,7 +486,7 @@ resource
$$->name = new_name_id();
$$->name->type = name_str;
$$->name->name.s_name = $1;
chat("Got %s (%s)", get_typename($3), $$->name->name.s_name->str.cstr);
chat("Got %s (%s)\n", get_typename($3), $$->name->name.s_name->str.cstr);
}
}
| stringtable {
@ -496,7 +495,7 @@ resource
* the final rule of the parser is reduced (see above)
*/
$$ = NULL;
chat("Got STRINGTABLE");
chat("Got STRINGTABLE\n");
}
| tLANGUAGE {want_nl = 1; } expr ',' expr {
/* We *NEED* the newline to delimit the expression.
@ -522,19 +521,18 @@ resource
yychar = YYEMPTY; /* Could use 'yyclearin', but we already need the*/
/* direct access to yychar in rule 'usrcvt' below. */
else if(yychar == tIDENT)
yywarning("LANGUAGE statement not delimited with newline; next identifier might be wrong");
parser_warning("LANGUAGE statement not delimited with newline; next identifier might be wrong\n");
want_nl = 0; /* We don't want it anymore if we didn't get it */
if(!win32)
yywarning("LANGUAGE not supported in 16-bit mode");
if(currentlanguage)
free(currentlanguage);
parser_warning("LANGUAGE not supported in 16-bit mode\n");
free(currentlanguage);
if (get_language_codepage($3, $5) == -1)
yyerror( "Language %04x is not supported", ($5<<10) + $3);
parser_error( "Language %04x is not supported\n", ($5<<10) + $3);
currentlanguage = new_language($3, $5);
$$ = NULL;
chat("Got LANGUAGE %d,%d (0x%04x)", $3, $5, ($5<<10) + $3);
chat("Got LANGUAGE %d,%d (0x%04x)\n", $3, $5, ($5<<10) + $3);
}
;
@ -550,7 +548,7 @@ usrcvt : /* Empty */ { yychar = rsrcid_to_token(yychar); }
*/
nameid : expr {
if($1 > 65535 || $1 < -32768)
yyerror("Resource's ID out of range (%d)", $1);
parser_error("Resource's ID out of range (%d)\n", $1);
$$ = new_name_id();
$$->type = name_ord;
$$->name.i_name = $1;
@ -598,7 +596,7 @@ resource_definition
}
}
else
internal_error(__FILE__, __LINE__, "Invalid top-level type %d in cursor resource", $1->type);
internal_error(__FILE__, __LINE__, "Invalid top-level type %d in cursor resource\n", $1->type);
free($1);
}
| dialog { $$ = new_resource(res_dlg, $1, $1->memopt, $1->lvc.language); }
@ -632,7 +630,7 @@ resource_definition
}
}
else
internal_error(__FILE__, __LINE__, "Invalid top-level type %d in icon resource", $1->type);
internal_error(__FILE__, __LINE__, "Invalid top-level type %d in icon resource\n", $1->type);
free($1);
}
| menu { $$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language); }
@ -719,7 +717,7 @@ fontdir : tFONTDIR loadmemopts file_raw { $$ = new_fontdir($3, $2); }
messagetable
: tMESSAGETABLE loadmemopts file_raw {
if(!win32)
yywarning("MESSAGETABLE not supported in 16-bit mode");
parser_warning("MESSAGETABLE not supported in 16-bit mode\n");
$$ = new_messagetable($3, $2);
}
;
@ -743,7 +741,7 @@ userres : usertype loadmemopts file_raw {
#else
if(pedantic && byteorder == WRC_BO_BIG)
#endif
yywarning("Byteordering is not little-endian and type cannot be interpreted");
parser_warning("Byteordering is not little-endian and type cannot be interpreted\n");
$$ = new_user($1, $3, $2);
}
;
@ -774,7 +772,7 @@ accelerators
$$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
}
if(!$5)
yyerror("Accelerator table must have at least one entry");
parser_error("Accelerator table must have at least one entry\n");
$$->events = get_event_head($5);
if($3)
{
@ -892,11 +890,9 @@ ctrls : /* Empty */ { $$ = NULL; }
;
lab_ctrl
: tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair {
: nameid_s opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair {
$$=new_control();
$$->title = new_name_id();
$$->title->type = name_str;
$$->title->name.s_name = $1;
$$->title = $1;
$$->id = $3;
$$->x = $5;
$$->y = $7;
@ -1006,8 +1002,8 @@ optional_style_pair
style
: style '|' style { $$ = new_style($1->or_mask | $3->or_mask, $1->and_mask | $3->and_mask); free($1); free($3);}
| '(' style ')' { $$ = $2; }
| xpr_no_not { $$ = new_style($1, 0); }
| tNOT xpr_no_not { $$ = new_style(0, $2); }
| any_num { $$ = new_style($1, 0); }
| tNOT any_num { $$ = new_style(0, $2); }
;
ctlclass
@ -1027,7 +1023,7 @@ ctlclass
dialogex: tDIALOGEX loadmemopts expr ',' expr ',' expr ',' expr helpid dlgex_attribs
tBEGIN exctrls tEND {
if(!win32)
yywarning("DIALOGEX not supported in 16-bit mode");
parser_warning("DIALOGEX not supported in 16-bit mode\n");
if($2)
{
$11->memopt = *($2);
@ -1152,11 +1148,9 @@ gen_exctrl
;
lab_exctrl
: tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair helpid opt_data {
: nameid_s opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair helpid opt_data {
$$=new_control();
$$->title = new_name_id();
$$->title->type = name_str;
$$->title->name.s_name = $1;
$$->title = $1;
$$->id = $3;
$$->x = $5;
$$->y = $7;
@ -1226,7 +1220,7 @@ opt_expr: /* Empty */ { $$ = NULL; }
/* ------------------------------ Menu ------------------------------ */
menu : tMENU loadmemopts opt_lvc menu_body {
if(!$4)
yyerror("Menu must contain items");
parser_error("Menu must contain items\n");
$$ = new_menu();
if($2)
{
@ -1298,9 +1292,9 @@ item_options
/* ------------------------------ MenuEx ------------------------------ */
menuex : tMENUEX loadmemopts opt_lvc menuex_body {
if(!win32)
yywarning("MENUEX not supported in 16-bit mode");
parser_warning("MENUEX not supported in 16-bit mode\n");
if(!$4)
yyerror("MenuEx must contain items");
parser_error("MenuEx must contain items\n");
$$ = new_menuex();
if($2)
{
@ -1378,16 +1372,16 @@ itemex_options
$$->gotid = TRUE;
$$->gottype = TRUE;
$$->gotstate = TRUE;
if($2) free($2);
if($4) free($4);
free($2);
free($4);
}
| ',' e_expr ',' e_expr ',' expr {
$$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $6, 0);
$$->gotid = TRUE;
$$->gottype = TRUE;
$$->gotstate = TRUE;
if($2) free($2);
if($4) free($4);
free($2);
free($4);
}
;
@ -1399,23 +1393,23 @@ itemex_p_options
}
| ',' e_expr ',' expr {
$$ = new_itemex_opt($2 ? *($2) : 0, $4, 0, 0);
if($2) free($2);
free($2);
$$->gotid = TRUE;
$$->gottype = TRUE;
}
| ',' e_expr ',' e_expr ',' expr {
$$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $6, 0);
if($2) free($2);
if($4) free($4);
free($2);
free($4);
$$->gotid = TRUE;
$$->gottype = TRUE;
$$->gotstate = TRUE;
}
| ',' e_expr ',' e_expr ',' e_expr ',' expr {
$$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $6 ? *($6) : 0, $8);
if($2) free($2);
if($4) free($4);
if($6) free($6);
free($2);
free($4);
free($6);
$$->gotid = TRUE;
$$->gottype = TRUE;
$$->gotstate = TRUE;
@ -1434,7 +1428,7 @@ stringtable
: stt_head tBEGIN strings tEND {
if(!$3)
{
yyerror("Stringtable must have at least one entry");
parser_error("Stringtable must have at least one entry\n");
}
else
{
@ -1461,11 +1455,8 @@ stringtable
}
/* Else were done */
}
if(tagstt_memopt)
{
free(tagstt_memopt);
tagstt_memopt = NULL;
}
free(tagstt_memopt);
tagstt_memopt = NULL;
$$ = tagstt;
}
@ -1478,8 +1469,7 @@ stt_head: tSTRINGTABLE loadmemopts opt_lvc {
tagstt_memopt = $2;
tagstt_version = $3->version;
tagstt_characts = $3->characts;
if($3)
free($3);
free($3);
}
;
@ -1488,12 +1478,12 @@ strings : /* Empty */ { $$ = NULL; }
int i;
assert(tagstt != NULL);
if($2 > 65535 || $2 < -32768)
yyerror("Stringtable entry's ID out of range (%d)", $2);
parser_error("Stringtable entry's ID out of range (%d)\n", $2);
/* Search for the ID */
for(i = 0; i < tagstt->nentries; i++)
{
if(tagstt->entries[i].id == $2)
yyerror("Stringtable ID %d already in use", $2);
parser_error("Stringtable ID %d already in use\n", $2);
}
/* If we get here, then we have a new unique entry */
tagstt->nentries++;
@ -1508,11 +1498,11 @@ strings : /* Empty */ { $$ = NULL; }
tagstt->entries[tagstt->nentries-1].characts = tagstt_characts;
if(pedantic && !$4->size)
yywarning("Zero length strings make no sense");
parser_warning("Zero length strings make no sense\n");
if(!win32 && $4->size > 254)
yyerror("Stringtable entry more than 254 characters");
parser_error("Stringtable entry more than 254 characters\n");
if(win32 && $4->size > 65534) /* Hmm..., does this happen? */
yyerror("Stringtable entry more than 65534 characters (probably something else that went wrong)");
parser_error("Stringtable entry more than 65534 characters (probably something else that went wrong)\n");
$$ = tagstt;
}
;
@ -1543,7 +1533,7 @@ fix_version
: /* Empty */ { $$ = new_versioninfo(); }
| fix_version tFILEVERSION expr ',' expr ',' expr ',' expr {
if($1->gotit.fv)
yyerror("FILEVERSION already defined");
parser_error("FILEVERSION already defined\n");
$$ = $1;
$$->filever_maj1 = $3;
$$->filever_maj2 = $5;
@ -1553,7 +1543,7 @@ fix_version
}
| fix_version tPRODUCTVERSION expr ',' expr ',' expr ',' expr {
if($1->gotit.pv)
yyerror("PRODUCTVERSION already defined");
parser_error("PRODUCTVERSION already defined\n");
$$ = $1;
$$->prodver_maj1 = $3;
$$->prodver_maj2 = $5;
@ -1563,35 +1553,35 @@ fix_version
}
| fix_version tFILEFLAGS expr {
if($1->gotit.ff)
yyerror("FILEFLAGS already defined");
parser_error("FILEFLAGS already defined\n");
$$ = $1;
$$->fileflags = $3;
$$->gotit.ff = 1;
}
| fix_version tFILEFLAGSMASK expr {
if($1->gotit.ffm)
yyerror("FILEFLAGSMASK already defined");
parser_error("FILEFLAGSMASK already defined\n");
$$ = $1;
$$->fileflagsmask = $3;
$$->gotit.ffm = 1;
}
| fix_version tFILEOS expr {
if($1->gotit.fo)
yyerror("FILEOS already defined");
parser_error("FILEOS already defined\n");
$$ = $1;
$$->fileos = $3;
$$->gotit.fo = 1;
}
| fix_version tFILETYPE expr {
if($1->gotit.ft)
yyerror("FILETYPE already defined");
parser_error("FILETYPE already defined\n");
$$ = $1;
$$->filetype = $3;
$$->gotit.ft = 1;
}
| fix_version tFILESUBTYPE expr {
if($1->gotit.fst)
yyerror("FILESUBTYPE already defined");
parser_error("FILESUBTYPE already defined\n");
$$ = $1;
$$->filesubtype = $3;
$$->gotit.fst = 1;
@ -1734,25 +1724,25 @@ lama : tLOADONCALL { $$ = new_int(~WRC_MO_PRELOAD); }
opt_lvc : /* Empty */ { $$ = new_lvc(); }
| opt_lvc opt_language {
if(!win32)
yywarning("LANGUAGE not supported in 16-bit mode");
parser_warning("LANGUAGE not supported in 16-bit mode\n");
if($1->language)
yyerror("Language already defined");
parser_error("Language already defined\n");
$$ = $1;
$1->language = $2;
}
| opt_lvc opt_characts {
if(!win32)
yywarning("CHARACTERISTICS not supported in 16-bit mode");
parser_warning("CHARACTERISTICS not supported in 16-bit mode\n");
if($1->characts)
yyerror("Characteristics already defined");
parser_error("Characteristics already defined\n");
$$ = $1;
$1->characts = $2;
}
| opt_lvc opt_version {
if(!win32)
yywarning("VERSION not supported in 16-bit mode");
parser_warning("VERSION not supported in 16-bit mode\n");
if($1->version)
yyerror("Version already defined");
parser_error("Version already defined\n");
$$ = $1;
$1->version = $2;
}
@ -1768,7 +1758,7 @@ opt_lvc : /* Empty */ { $$ = new_lvc(); }
opt_language
: tLANGUAGE expr ',' expr { $$ = new_language($2, $4);
if (get_language_codepage($2, $4) == -1)
yyerror( "Language %04x is not supported", ($4<<10) + $2);
parser_error( "Language %04x is not supported\n", ($4<<10) + $2);
}
;
@ -1827,22 +1817,18 @@ e_expr : /* Empty */ { $$ = 0; }
expr : xpr { $$ = ($1); }
;
xpr_no_not : xpr '+' xpr { $$ = ($1) + ($3); }
| xpr '-' xpr { $$ = ($1) - ($3); }
| xpr '|' xpr { $$ = ($1) | ($3); }
| xpr '&' xpr { $$ = ($1) & ($3); }
| xpr '*' xpr { $$ = ($1) * ($3); }
| xpr '/' xpr { $$ = ($1) / ($3); }
| xpr '^' xpr { $$ = ($1) ^ ($3); }
| '~' xpr { $$ = ~($2); }
| '-' xpr %prec pUPM { $$ = -($2); }
| '+' xpr %prec pUPM { $$ = $2; }
| '(' xpr ')' { $$ = $2; }
| any_num { $$ = $1; }
;
xpr : xpr_no_not { $$ = ($1); }
xpr : xpr '+' xpr { $$ = ($1) + ($3); }
| xpr '-' xpr { $$ = ($1) - ($3); }
| xpr '|' xpr { $$ = ($1) | ($3); }
| xpr '&' xpr { $$ = ($1) & ($3); }
| xpr '*' xpr { $$ = ($1) * ($3); }
| xpr '/' xpr { $$ = ($1) / ($3); }
| xpr '^' xpr { $$ = ($1) ^ ($3); }
| '~' xpr { $$ = ~($2); }
| '-' xpr %prec pUPM { $$ = -($2); }
| '+' xpr %prec pUPM { $$ = $2; }
| '(' xpr ')' { $$ = $2; }
| any_num { $$ = $1; }
| tNOT any_num { $$ = ~($2); }
;
@ -1862,7 +1848,7 @@ static dialog_t *dialog_style(style_t * st, dialog_t *dlg)
if(dlg->gotstyle)
{
yywarning("Style already defined, or-ing together");
parser_warning("Style already defined, or-ing together\n");
}
else
{
@ -1886,7 +1872,7 @@ static dialog_t *dialog_exstyle(style_t *st, dialog_t *dlg)
if(dlg->gotexstyle)
{
yywarning("ExStyle already defined, or-ing together");
parser_warning("ExStyle already defined, or-ing together\n");
}
else
{
@ -1904,7 +1890,7 @@ static dialog_t *dialog_caption(string_t *s, dialog_t *dlg)
{
assert(dlg != NULL);
if(dlg->title)
yyerror("Caption already defined");
parser_error("Caption already defined\n");
dlg->title = s;
return dlg;
}
@ -1913,7 +1899,7 @@ static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg)
{
assert(dlg != NULL);
if(dlg->font)
yyerror("Font already defined");
parser_error("Font already defined\n");
dlg->font = f;
return dlg;
}
@ -1922,7 +1908,7 @@ static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg)
{
assert(dlg != NULL);
if(dlg->dlgclass)
yyerror("Class already defined");
parser_error("Class already defined\n");
dlg->dlgclass = n;
return dlg;
}
@ -2034,7 +2020,7 @@ static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control
defaultstyle |= WS_TABSTOP;
break;
default:
yywarning("Unknown default button control-style 0x%08x", special_style);
parser_warning("Unknown default button control-style 0x%08x\n", special_style);
case BS_GROUPBOX:
case BS_RADIOBUTTON:
break;
@ -2052,7 +2038,7 @@ static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control
case SS_ICON: /* Special case */
break;
default:
yywarning("Unknown default static control-style 0x%08x", special_style);
parser_warning("Unknown default static control-style 0x%08x\n", special_style);
break;
}
break;
@ -2137,7 +2123,7 @@ static dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg)
if(dlg->gotstyle)
{
yywarning("Style already defined, or-ing together");
parser_warning("Style already defined, or-ing together\n");
}
else
{
@ -2161,7 +2147,7 @@ static dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg)
if(dlg->gotexstyle)
{
yywarning("ExStyle already defined, or-ing together");
parser_warning("ExStyle already defined, or-ing together\n");
}
else
{
@ -2257,32 +2243,27 @@ static event_t *add_event(int key, int id, int flags, event_t *prev)
static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev)
{
int keycode = 0, keysym = 0;
int keycode = 0;
event_t *ev = new_event();
if(key->type == str_char)
keysym = key->str.cstr[0];
else
keysym = key->str.wstr[0];
if(key->type != str_char)
yyerror("Key code must be an ascii string");
if((flags & WRC_AF_VIRTKEY) && (!isupper(keysym & 0xff) && !isdigit(keysym & 0xff)))
if((flags & WRC_AF_VIRTKEY) && (!isupper(key->str.cstr[0] & 0xff) && !isdigit(key->str.cstr[0] & 0xff)))
yyerror("VIRTKEY code is not equal to ascii value");
if(keysym == '^' && (flags & WRC_AF_CONTROL) != 0)
if(key->str.cstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)
{
yyerror("Cannot use both '^' and CONTROL modifier");
}
else if(keysym == '^')
else if(key->str.cstr[0] == '^')
{
if(key->type == str_char)
keycode = toupper(key->str.cstr[1]) - '@';
else
keycode = toupper(key->str.wstr[1]) - '@';
keycode = toupper(key->str.cstr[1]) - '@';
if(keycode >= ' ')
yyerror("Control-code out of range");
}
else
keycode = keysym;
keycode = key->str.cstr[0];
ev->key = keycode;
ev->id = id;
ev->flags = flags & ~WRC_AF_ASCII;
@ -2295,7 +2276,8 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
/* MenuEx specific functions */
static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid)
{
itemex_opt_t *opt = (itemex_opt_t *)xmalloc(sizeof(itemex_opt_t));
itemex_opt_t *opt = xmalloc(sizeof(itemex_opt_t));
memset( opt, 0, sizeof(*opt) );
opt->id = id;
opt->type = type;
opt->state = state;
@ -2327,7 +2309,7 @@ static raw_data_t *load_file(string_t *filename, language_t *lang)
fseek(fp, 0, SEEK_SET);
if (rd->size)
{
rd->data = (char *)xmalloc(rd->size);
rd->data = xmalloc(rd->size);
fread(rd->data, rd->size, 1, fp);
}
else rd->data = NULL;
@ -2343,11 +2325,11 @@ static raw_data_t *int2raw_data(int i)
if( ( i >= 0 && (int)((unsigned short)i) != i) ||
( i < 0 && (int)((short)i) != i) )
yywarning("Integer constant out of 16bit range (%d), truncated to %d\n", i, (short)i);
parser_warning("Integer constant out of 16bit range (%d), truncated to %d\n", i, (short)i);
rd = new_raw_data();
rd->size = sizeof(short);
rd->data = (char *)xmalloc(rd->size);
rd->data = xmalloc(rd->size);
switch(byteorder)
{
#ifdef WORDS_BIGENDIAN
@ -2374,7 +2356,7 @@ static raw_data_t *long2raw_data(int i)
raw_data_t *rd;
rd = new_raw_data();
rd->size = sizeof(int);
rd->data = (char *)xmalloc(rd->size);
rd->data = xmalloc(rd->size);
switch(byteorder)
{
#ifdef WORDS_BIGENDIAN
@ -2405,7 +2387,7 @@ static raw_data_t *str2raw_data(string_t *str)
raw_data_t *rd;
rd = new_raw_data();
rd->size = str->size * (str->type == str_char ? 1 : 2);
rd->data = (char *)xmalloc(rd->size);
rd->data = xmalloc(rd->size);
if(str->type == str_char)
memcpy(rd->data, str->str.cstr, rd->size);
else if(str->type == str_unicode)
@ -2436,7 +2418,7 @@ static raw_data_t *str2raw_data(string_t *str)
}
}
else
internal_error(__FILE__, __LINE__, "Invalid stringtype");
internal_error(__FILE__, __LINE__, "Invalid stringtype\n");
return rd;
}
@ -2561,12 +2543,12 @@ static stringtable_t *find_stringtable(lvc_t *lvc)
if((stt->lvc.version && lvc->version && *(stt->lvc.version) != *(lvc->version))
|| (!stt->lvc.version && lvc->version)
|| (stt->lvc.version && !lvc->version))
yywarning("Stringtable's versions are not the same, using first definition");
parser_warning("Stringtable's versions are not the same, using first definition\n");
if((stt->lvc.characts && lvc->characts && *(stt->lvc.characts) != *(lvc->characts))
|| (!stt->lvc.characts && lvc->characts)
|| (stt->lvc.characts && !lvc->characts))
yywarning("Stringtable's characteristics are not the same, using first definition");
parser_warning("Stringtable's characteristics are not the same, using first definition\n");
*/
return stt;
}
@ -2611,7 +2593,8 @@ static resource_t *build_stt_resources(stringtable_t *stthead)
for(i = 0; i < stt->nentries; )
{
newstt = new_stringtable(&stt->lvc);
newstt->entries = (stt_entry_t *)xmalloc(16 * sizeof(stt_entry_t));
newstt->entries = xmalloc(16 * sizeof(stt_entry_t));
memset( newstt->entries, 0, 16 * sizeof(stt_entry_t) );
newstt->nentries = 16;
newstt->idbase = stt->entries[i].id & ~0xf;
for(j = 0; j < 16 && i < stt->nentries; j++)
@ -2642,7 +2625,7 @@ static resource_t *build_stt_resources(stringtable_t *stthead)
}
if(andsum != orsum)
{
warning("Stringtable's memory options are not equal (idbase: %d)", newstt->idbase);
warning("Stringtable's memory options are not equal (idbase: %d)\n", newstt->idbase);
}
/* Check version and characteristics */
for(j = 0; j < 16; j++)
@ -2650,11 +2633,11 @@ static resource_t *build_stt_resources(stringtable_t *stthead)
if(characts
&& newstt->entries[j].characts
&& *newstt->entries[j].characts != *characts)
warning("Stringtable's characteristics are not the same (idbase: %d)", newstt->idbase);
warning("Stringtable's characteristics are not the same (idbase: %d)\n", newstt->idbase);
if(version
&& newstt->entries[j].version
&& *newstt->entries[j].version != *version)
warning("Stringtable's versions are not the same (idbase: %d)", newstt->idbase);
warning("Stringtable's versions are not the same (idbase: %d)\n", newstt->idbase);
}
rsc = new_resource(res_stt, newstt, newstt->memopt, newstt->lvc.language);
rsc->name = new_name_id();
@ -2768,7 +2751,7 @@ static resource_t *build_fontdir(resource_t **fnt, int nfnt)
static int once = 0;
if(!once)
{
warning("Need to parse fonts, not yet implemented (fnt: %p, nfnt: %d)", fnt, nfnt);
warning("Need to parse fonts, not yet implemented (fnt: %p, nfnt: %d)\n", fnt, nfnt);
once++;
}
return NULL;
@ -2817,7 +2800,7 @@ static resource_t *build_fontdirs(resource_t *tail)
{
if(compare_name_id(&nid, fnd[i]->name))
{
warning("User supplied FONTDIR entry has an invalid name '%s', ignored",
warning("User supplied FONTDIR entry has an invalid name '%s', ignored\n",
get_nameid_str(fnd[i]->name));
fnd[i] = NULL;
}
@ -2827,12 +2810,13 @@ static resource_t *build_fontdirs(resource_t *tail)
if(nfnt == 0)
{
if(nfnd != 0)
warning("Found %d FONTDIR entries without any fonts present", nfnd);
warning("Found %d FONTDIR entries without any fonts present\n", nfnd);
goto clean;
}
/* Copy space */
lanfnt = xmalloc(nfnt * sizeof(*lanfnt));
memset( lanfnt, 0, nfnt * sizeof(*lanfnt));
/* Get all fonts covered by fontdirs */
for(i = 0; i < nfnd; i++)
@ -2861,7 +2845,7 @@ static resource_t *build_fontdirs(resource_t *tail)
else if(nlanfnt == BYTESWAP_WORD(cnt))
isswapped = 1;
else
error("FONTDIR for language %d,%d has wrong count (%d, expected %d)",
error("FONTDIR for language %d,%d has wrong count (%d, expected %d)\n",
fnd[i]->lan->id, fnd[i]->lan->sub, cnt, nlanfnt);
#ifdef WORDS_BIGENDIAN
if((byteorder == WRC_BO_LITTLE && !isswapped) || (byteorder != WRC_BO_LITTLE && isswapped))
@ -2869,7 +2853,7 @@ static resource_t *build_fontdirs(resource_t *tail)
if((byteorder == WRC_BO_BIG && !isswapped) || (byteorder != WRC_BO_BIG && isswapped))
#endif
{
internal_error(__FILE__, __LINE__, "User supplied FONTDIR needs byteswapping");
internal_error(__FILE__, __LINE__, "User supplied FONTDIR needs byteswapping\n");
}
}
@ -2913,10 +2897,8 @@ static resource_t *build_fontdirs(resource_t *tail)
free(lanfnt);
clean:
if(fnt)
free(fnt);
if(fnd)
free(fnd);
free(fnt);
free(fnd);
free(str.str.cstr);
return lst;
}
@ -3034,13 +3016,13 @@ static int rsrcid_to_token(int lookahead)
case WRC_RT_ANIICON:
case WRC_RT_GROUP_CURSOR:
case WRC_RT_GROUP_ICON:
yywarning("Usertype uses reserved type ID %d, which is auto-generated", yylval.num);
parser_warning("Usertype uses reserved type ID %d, which is auto-generated\n", yylval.num);
return lookahead;
case WRC_RT_DLGINCLUDE:
case WRC_RT_PLUGPLAY:
case WRC_RT_VXD:
yywarning("Usertype uses reserved type ID %d, which is not supported by wrc yet", yylval.num);
parser_warning("Usertype uses reserved type ID %d, which is not supported by wrc yet\n", yylval.num);
default:
return lookahead;
}

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 "utils.h"
#include "genres.h"
struct resheader32 {
static const struct resheader32 {
DWORD ressize; /* 0 */
DWORD hdrsize; /* 0x20 */
WORD restype1; /* 0xffff */
@ -105,7 +105,7 @@ static enum res_e res_type_from_id(const name_id_t *nid)
return res_usr;
if(nid->type != name_ord)
internal_error(__FILE__, __LINE__, "Invalid name_id descriptor %d", nid->type);
internal_error(__FILE__, __LINE__, "Invalid name_id descriptor %d\n", nid->type);
switch(nid->name.i_name)
{
@ -131,7 +131,7 @@ static enum res_e res_type_from_id(const name_id_t *nid)
case WRC_RT_VXD:
case WRC_RT_ANICURSOR:
case WRC_RT_ANIICON:
warning("Cannot be sure of resource type, using usertype settings");
warning("Cannot be sure of resource type, using usertype settings\n");
return res_usr;
}
}
@ -184,7 +184,7 @@ static resource_t *read_res32(FILE *fp)
totsize = hdrsize;
if(hdrsize & 3)
{
warning("Hu? .res header needed alignment (anything can happen now)");
warning("Hu? .res header needed alignment (anything can happen now)\n");
totsize += 4 - (hdrsize & 3);
}
totsize += ressize;
@ -216,7 +216,7 @@ static resource_t *read_res32(FILE *fp)
}
else if(get_word(idx) == 0)
{
error("ResType name has zero length (32 bit)");
error("ResType name has zero length (32 bit)\n");
}
else
{
@ -250,7 +250,7 @@ static resource_t *read_res32(FILE *fp)
}
else if(get_word(idx) == 0)
{
error("ResName name has zero length (32 bit)");
error("ResName name has zero length (32 bit)\n");
}
else
{
@ -327,7 +327,7 @@ static resource_t *read_res32(FILE *fp)
*/
static resource_t *read_res16(FILE *fp)
{
internal_error(__FILE__, __LINE__, "Can't yet read 16 bit .res files");
internal_error(__FILE__, __LINE__, "Can't yet read 16 bit .res files\n");
return NULL;
}
@ -350,7 +350,7 @@ resource_t *read_resfile(char *inname)
fp = fopen(inname, "rb");
if(!fp)
error("Could not open inputfile %s", inname);
error("Could not open inputfile %s\n", inname);
/* Determine 16 or 32 bit .res file */
if(fread(&rh, 1, sizeof(rh), fp) != sizeof(rh))
@ -360,16 +360,16 @@ resource_t *read_resfile(char *inname)
if(!memcmp(&emptyheader, &rh, sizeof(rh)))
is32bit = 1;
else if(!memcmp(&emptyheaderSWAPPED, &rh, sizeof(rh)))
error("Binary .res-file has its byteorder swapped");
error("Binary .res-file has its byteorder swapped\n");
else
is32bit = 0;
}
if(is32bit && !win32)
error("Cannot convert 32-bit .res-file into 16-bit resources (and will, hopefully never, implement it)");
error("Cannot convert 32-bit .res-file into 16-bit resources (and will, hopefully never, implement it)\n");
if(!is32bit && win32)
error("Cannot (yet) convert 16-bit .res-file into 32-bit resources");
error("Cannot (yet) convert 16-bit .res-file into 32-bit resources\n");
if(!is32bit)
{

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 __WRC_READRES_H

View file

@ -13,16 +13,18 @@
*
* 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>
#include "dumpres.h"
#include "utils.h"
#include "wrc.h"
#define MASTER_LANGUAGE LANG_ENGLISH
#define MASTER_SUBLANGUAGE SUBLANG_ENGLISH_US
#define NB_LANG 0x94
enum lang_type_e {
@ -31,77 +33,65 @@ enum lang_type_e {
lang_type_normal
};
static int present_resources[res_usr+1];
static char *res_names[res_usr+1];
static int nb_resources[res_usr+1][lang_type_normal+1];
static resource_t **list_resources[res_usr+1][lang_type_normal+1];
static int get_language_id(resource_t *resource) {
static language_t get_language(resource_t *resource) {
switch(resource->type) {
case res_acc:
return resource->res.acc->lvc.language->id;
return *resource->res.acc->lvc.language;
case res_bmp:
return resource->res.bmp->data->lvc.language->id;
return *resource->res.bmp->data->lvc.language;
case res_cur:
return resource->res.cur->lvc.language->id;
return *resource->res.cur->lvc.language;
case res_curg:
return resource->res.curg->lvc.language->id;
return *resource->res.curg->lvc.language;
case res_dlg:
return resource->res.dlg->lvc.language->id;
return *resource->res.dlg->lvc.language;
case res_dlgex:
return resource->res.dlgex->lvc.language->id;
return *resource->res.dlgex->lvc.language;
case res_fnt:
return resource->res.fnt->data->lvc.language->id;
return *resource->res.fnt->data->lvc.language;
case res_fntdir:
return resource->res.fnd->data->lvc.language->id;
return *resource->res.fnd->data->lvc.language;
case res_ico:
return resource->res.ico->lvc.language->id;
return *resource->res.ico->lvc.language;
case res_icog:
return resource->res.icog->lvc.language->id;
return *resource->res.icog->lvc.language;
case res_men:
return resource->res.men->lvc.language->id;
return *resource->res.men->lvc.language;
case res_menex:
return resource->res.menex->lvc.language->id;
return *resource->res.menex->lvc.language;
case res_rdt:
return resource->res.rdt->data->lvc.language->id;
return *resource->res.rdt->data->lvc.language;
case res_stt:
return resource->res.stt->lvc.language->id;
return *resource->res.stt->lvc.language;
case res_usr:
return resource->res.usr->data->lvc.language->id;
return *resource->res.usr->data->lvc.language;
case res_msg:
return resource->res.msg->data->lvc.language->id;
return *resource->res.msg->data->lvc.language;
case res_ver:
return resource->res.ver->lvc.language->id;
return *resource->res.ver->lvc.language;
case res_dlginit:
return resource->res.dlgi->data->lvc.language->id;
return *resource->res.dlgi->data->lvc.language;
case res_toolbar:
return resource->res.tbt->lvc.language->id;
return *resource->res.tbt->lvc.language;
case res_anicur:
case res_aniico:
return resource->res.ani->data->lvc.language->id;
return *resource->res.ani->data->lvc.language;
case res_html:
return *resource->res.html->data->lvc.language;
default:
/* Not supposed to reach here */
fprintf(stderr, "Not supposed to reach here (get_language_id())\n");
abort();
return -1;
}
}
static void add_resource(resource_t *resource) {
enum lang_type_e lang_type;
enum res_e res_type = resource->type;
int lid = get_language_id(resource);
static int get_language_id(resource_t *resource) {
return get_language(resource).id;
}
if(lid == MASTER_LANGUAGE) {
lang_type = lang_type_master;
} else if(lid == LANG_NEUTRAL) {
lang_type = lang_type_neutral;
} else {
lang_type = lang_type_normal;
}
nb_resources[res_type][lang_type]++;
list_resources[res_type][lang_type] = realloc(list_resources[res_type][lang_type], nb_resources[res_type][lang_type]*sizeof(resource_t *));
list_resources[res_type][lang_type][nb_resources[res_type][lang_type]-1] = resource;
static int compare_lang(language_t lang1, language_t lang2)
{
return memcmp(&lang1, &lang2, sizeof(language_t));
}
#if 0
@ -299,7 +289,7 @@ static int compare_control(control_t *control1, control_t *control2) {
if(!different && strcmp(nameid, get_nameid_str(control2->ctlclass)))
different = 1;
free(nameid);
if(!different &&
if(!different &&
(control1->id != control2->id))
different = 1;
if(!different && control1->gotstyle && control2->gotstyle) {
@ -614,6 +604,16 @@ static int compare_rcdata(rcdata_t *rcdata1, rcdata_t *rcdata2) {
return different;
}
static int compare_html(html_t *rcdata1, html_t *rcdata2) {
int different = 0;
if(!different &&
((rcdata1->memopt != rcdata2->memopt) ||
(rcdata1->data->lvc.version != rcdata2->data->lvc.version) ||
(rcdata1->data->lvc.characts != rcdata2->data->lvc.characts)))
different = 1;
return different;
}
static int compare_stringtable(stringtable_t *stringtable1, stringtable_t *stringtable2) {
int different = 0;
int i;
@ -831,7 +831,7 @@ static int compare_versioninfo(versioninfo_t *versioninfo1, versioninfo_t *versi
}
if(!different &&
((ver_block1 && !ver_block2) ||
(ver_block1 && !ver_block2)))
(!ver_block1 && ver_block2)))
different = 1;
}
return different;
@ -917,6 +917,8 @@ static int compare(resource_t *resource1, resource_t *resource2) {
return compare_stringtable(resource1->res.stt, resource2->res.stt);
case res_usr:
return compare_user(resource1->res.usr, resource2->res.usr);
case res_html:
return compare_html(resource1->res.html, resource2->res.html);
case res_msg:
return compare_messagetable(resource1->res.msg, resource2->res.msg);
case res_ver:
@ -936,221 +938,215 @@ static int compare(resource_t *resource1, resource_t *resource2) {
}
}
void verify_translations(resource_t *top) {
enum lang_type_e lang_type;
enum res_e res_type;
int **presence;
int i, j;
char *nameid;
char **problems;
int nb_problems, last_problem;
int complete, needs_work, partial;
resource_t *next = top;
static void dump_stringtable(resource_t *res)
{
stringtable_t *stt = res->res.stt;
int j;
for(res_type = res_0; res_type <= res_usr; res_type++) {
present_resources[res_type] = 0;
for(lang_type = lang_type_master; lang_type <= lang_type_normal; lang_type++) {
nb_resources[res_type][lang_type] = 0;
list_resources[res_type][lang_type] = NULL;
}
}
printf("DUMP ");
assert((stt->idbase%16) == 0);
assert(stt->nentries == 16);
for (j = 0; j < stt->nentries; j++)
{
stt_entry_t *entry = &stt->entries[j];
language_t *lang = stt->lvc.language;
string_t *newstr;
WCHAR *wstr;
int k;
while(next) {
switch(next->type) {
case res_acc:
case res_bmp:
case res_cur:
case res_curg:
case res_dlg:
case res_dlgex:
case res_fnt:
case res_fntdir:
case res_ico:
case res_icog:
case res_men:
case res_menex:
case res_rdt:
case res_stt:
case res_usr:
case res_msg:
case res_ver:
case res_dlginit:
case res_toolbar:
case res_anicur:
case res_aniico:
add_resource(next);
break;
default:
fprintf(stderr, "Report this: unknown resource type parsed %08x\n", next->type);
}
next = next->next;
}
present_resources[res_acc] = 1;
res_names[res_acc] = strdup("accelerator");
present_resources[res_bmp] = 1;
res_names[res_bmp] = strdup("bitmap");
present_resources[res_cur] = 1;
res_names[res_cur] = strdup("cursor");
present_resources[res_curg] = 1;
res_names[res_curg] = strdup("cursor_group");
present_resources[res_dlg] = 1;
res_names[res_dlg] = strdup("dialog");
present_resources[res_dlgex] = 1;
res_names[res_dlgex] = strdup("dialogex");
present_resources[res_fnt] = 1;
res_names[res_fnt] = strdup("font");
present_resources[res_fntdir] = 1;
res_names[res_fntdir] = strdup("fontdir");
present_resources[res_ico] = 1;
res_names[res_ico] = strdup("icon");
present_resources[res_icog] = 1;
res_names[res_icog] = strdup("icon_group");
present_resources[res_men] = 1;
res_names[res_men] = strdup("menu");
present_resources[res_menex] = 1;
res_names[res_menex] = strdup("menuex");
present_resources[res_rdt] = 1;
res_names[res_rdt] = strdup("rcdata");
present_resources[res_stt] = 1;
res_names[res_stt] = strdup("stringtable");
present_resources[res_usr] = 1;
res_names[res_usr] = strdup("user");
present_resources[res_msg] = 1;
res_names[res_msg] = strdup("messagetable");
present_resources[res_ver] = 1;
res_names[res_ver] = strdup("versioninfo");
present_resources[res_dlginit] = 1;
res_names[res_dlginit] = strdup("dlginit");
present_resources[res_toolbar] = 1;
res_names[res_toolbar] = strdup("toolbar");
present_resources[res_anicur] = 1;
res_names[res_anicur] = strdup("ani_cursor");
present_resources[res_aniico] = 1;
res_names[res_aniico] = strdup("ani_icon");
if (entry->str)
{
newstr = convert_string(entry->str, str_unicode, get_language_codepage(lang->id, lang->sub));
printf("%02x%02x", newstr->size & 0xff, (newstr->size >> 8) & 0xff);
wstr = newstr->str.wstr;
for (k = 0; k < newstr->size; k++)
printf("%02x%02x", wstr[k] & 0xff, wstr[k] >> 8);
free_string(newstr);
}
else
printf("0000");
}
putchar('\n');
}
for(res_type = res_0; res_type <= res_usr; res_type++) {
if(!present_resources[res_type]) {
continue;
}
if(nb_resources[res_type][lang_type_normal] > 0) {
if(nb_resources[res_type][lang_type_master] && nb_resources[res_type][lang_type_neutral]) {
fprintf(stderr, "Type %s:\n", res_names[res_type]);
fprintf(stderr, "There are both a NEUTRAL and a MASTER version for %s, along with additional localized versions. The NEUTRAL versions will not be checked against other versions.\n", res_names[res_type]);
} else if(nb_resources[res_type][lang_type_neutral]) {
fprintf(stderr, "Type %s:\n", res_names[res_type]);
fprintf(stderr, "There are no MASTER version, but there are some NEUTRAL versions for %s, so will use those instead of MASTER for comparison.\n", res_names[res_type]);
list_resources[res_type][lang_type_master] = list_resources[res_type][lang_type_neutral];
nb_resources[res_type][lang_type_master] = nb_resources[res_type][lang_type_neutral];
} else if(!nb_resources[res_type][lang_type_master]) {
fprintf(stderr, "Type %s:\n", res_names[res_type]);
fprintf(stderr, "There are no NEUTRAL nor MASTER versions for %s, but there are some other localized versions. No comparison will be done at all.\n", res_names[res_type]);
}
} else {
if(nb_resources[res_type][lang_type_master] && nb_resources[res_type][lang_type_neutral]) {
fprintf(stderr, "Type %s:\n", res_names[res_type]);
fprintf(stderr, "There are both a NEUTRAL and a MASTER versions for %s, but no other localized version. No comparison will be done at all.\n", res_names[res_type]);
} else if(nb_resources[res_type][lang_type_master]) {
fprintf(stderr, "Type %s:\n", res_names[res_type]);
fprintf(stderr, "There are only MASTER versions for %s. No comparison will be done at all.\n", res_names[res_type]);
} else if(nb_resources[res_type][lang_type_neutral]) {
/* fprintf(stderr, "There are only NEUTRAL versions for %s. No comparison will be done at all.\n", res_names[res_type]); */
} else {
/* fprintf(stderr, "There are no versions at all for %s. No comparison will be done at all.\n", res_names[res_type]); */
}
}
static void dump(resource_t *res)
{
switch (res->type)
{
case res_stt:
dump_stringtable(res);
return;
default:
break;
}
}
presence = malloc(nb_resources[res_type][lang_type_master]*sizeof(int *));
for(i = 0; i < nb_resources[res_type][lang_type_master]; i++) {
presence[i] = calloc(NB_LANG, sizeof(int));
presence[i][MASTER_LANGUAGE] = -1;
}
typedef struct resource_lang_node
{
language_t lang;
resource_t *res;
struct resource_lang_node *next;
} resource_lang_node_t;
for(i = 0; i < nb_resources[res_type][lang_type_normal]; i++) {
for(j = 0; j < nb_resources[res_type][lang_type_master]; j++) {
nameid = strdup(get_nameid_str(list_resources[res_type][lang_type_normal][i]->name));
if(!strcmp(nameid, get_nameid_str(list_resources[res_type][lang_type_master][j]->name))) {
if(compare(list_resources[res_type][lang_type_normal][i], list_resources[res_type][lang_type_master][j])) {
presence[j][get_language_id(list_resources[res_type][lang_type_normal][i])] = 2;
/* fprintf(stderr, "Differences in type %s, ID %s, for language %s\n", res_names[res_type], nameid, get_language_name(get_language_id(list_resources[res_type][lang_type_normal][i]))); */
} else {
presence[j][get_language_id(list_resources[res_type][lang_type_normal][i])] = 1;
}
}
free(nameid);
}
}
typedef struct resource_id_node
{
name_id_t *id;
resource_lang_node_t *langs;
struct resource_id_node *next;
} resource_id_node_t;
problems = malloc(sizeof(char *));
problems[0] = strdup("");
nb_problems = 0;
last_problem = -1;
for(i = 0; i < NB_LANG; i++) {
complete = 1;
needs_work = 0;
partial = 0;
for(j = 0; j < nb_resources[res_type][lang_type_master]; j++) {
if(presence[j][i]) {
partial = 1;
if(presence[j][i] == 2) {
needs_work = 1;
problems = realloc(problems, (++nb_problems+1)*sizeof(char *));
problems[nb_problems] = malloc(strlen(get_nameid_str(list_resources[res_type][lang_type_master][j]->name)) + 9);
sprintf(problems[nb_problems], "DIFF %s %02x", get_nameid_str(list_resources[res_type][lang_type_master][j]->name), i);
if(last_problem == i) {
problems[nb_problems-1] = realloc(problems[nb_problems-1], strlen(problems[nb_problems-1]) + 3);
strcat(problems[nb_problems-1], " \\");
} else {
last_problem = i;
}
}
} else {
complete = 0;
problems = realloc(problems, (++nb_problems+1)*sizeof(char *));
problems[nb_problems] = malloc(strlen(get_nameid_str(list_resources[res_type][lang_type_master][j]->name)) + 8);
sprintf(problems[nb_problems], "ABS %s %02x", get_nameid_str(list_resources[res_type][lang_type_master][j]->name), i);
if(last_problem == i) {
problems[nb_problems-1] = realloc(problems[nb_problems-1], strlen(problems[nb_problems-1]) + 3);
strcat(problems[nb_problems-1], " \\");
} else {
last_problem = i;
}
}
}
if(complete && partial && !needs_work) {
/* Support is complete, no need to do anything */
/* fprintf(stderr, "Support for language %s is complete for %s.\n", get_language_name(i), res_names[res_type]); */
printf(".");
} else if(complete && partial && needs_work) {
/* Support is incomplete (differing resources), needs work */
/* fprintf(stderr, "Support for language %s is incomplete (differing resources) for %s.\n", get_language_name(i), res_names[res_type]); */
printf("x");
} else if(!complete && partial && !needs_work) {
/* Support is incomplete (missing resources), needs work */
/* fprintf(stderr, "Support for language %s is incomplete (missing resources) for %s.\n", get_language_name(i), res_names[res_type]); */
printf("-");
} else if(!complete && partial && needs_work) {
/* Support is incomplete (missing and differing resources), needs work */
/* fprintf(stderr, "Support for language %s is incomplete (missing and differing resources) for %s.\n", get_language_name(i), res_names[res_type]); */
printf("+");
} else if(!complete && !partial) {
/* Support is totally absent, might be interesting to do */
/* fprintf(stderr, "Support for language %s is absent for %s.\n", get_language_name(i), res_names[res_type]); */
printf(" ");
} else {
/* Support is not relevant, no need to do anything */
/* fprintf(stderr, "Support for language %s is not relevant for %s.\n", get_language_name(i), res_names[res_type]); */
printf("n");
}
}
printf("\n");
for(i = 1; i <= nb_problems; i++) {
printf("%s\n", problems[i]);
free(problems[i]);
}
free(problems[0]);
free(problems);
for(i = 0; i < nb_resources[res_type][lang_type_master]; i++)
free(presence[i]);
free(presence);
struct
{
int enabled;
struct resource_id_node *ids;
} verify_tab[res_usr+1];
static void add_resource(resource_t *res)
{
resource_id_node_t *idnode;
resource_lang_node_t *langnode;
if (!verify_tab[res->type].enabled)
{
fprintf(stderr, "ERR: Report this: unknown resource type parsed %08x\n", res->type);
return;
}
for (idnode = verify_tab[res->type].ids; idnode; idnode = idnode->next)
if (compare_name_id(idnode->id, res->name) == 0)
break;
if (idnode == NULL)
{
idnode = xmalloc(sizeof(resource_id_node_t));
idnode->id = res->name;
idnode->langs = NULL;
idnode->next = verify_tab[res->type].ids;
verify_tab[res->type].ids = idnode;
}
for (langnode = idnode->langs; langnode; langnode = langnode->next)
if (compare_lang(langnode->lang, get_language(res)) == 0)
{
fprintf(stderr, "ERR: resource %s [type %x] language %03x:%02x duplicated!\n",
get_nameid_str(res->name), res->type, langnode->lang.id, langnode->lang.sub);
return;
}
langnode = xmalloc(sizeof(resource_lang_node_t));
langnode->res = res;
langnode->lang = get_language(res);
langnode->next = idnode->langs;
idnode->langs = langnode;
}
static void setup_tabs(void)
{
int i;
for (i = 0; i <= res_usr; i++)
switch(i) {
case res_acc:
case res_bmp:
case res_cur:
case res_curg:
case res_dlg:
case res_dlgex:
case res_fnt:
case res_fntdir:
case res_ico:
case res_icog:
case res_men:
case res_menex:
case res_rdt:
case res_stt:
case res_usr:
case res_msg:
case res_ver:
case res_dlginit:
case res_toolbar:
case res_anicur:
case res_aniico:
case res_html:
verify_tab[i].enabled = 1;
break;
}
}
static const char *get_typename_for_int(int type) {
resource_t res;
res.type = type;
return get_typename(&res);
}
static resource_t *find_main(int type, name_id_t *id, resource_lang_node_t *langnode)
{
resource_t *neutral = NULL, *en = NULL, *en_US = NULL;
for (; langnode; langnode = langnode->next)
{
if (langnode->lang.id == LANG_NEUTRAL && langnode->lang.sub == SUBLANG_NEUTRAL)
neutral = langnode->res;
if (langnode->lang.id == MASTER_LANGUAGE && langnode->lang.sub == SUBLANG_NEUTRAL)
en = langnode->res;
if (langnode->lang.id == MASTER_LANGUAGE && langnode->lang.sub == MASTER_SUBLANGUAGE)
en_US = langnode->res;
}
if (neutral != NULL && (en != NULL || en_US != NULL))
{
fprintf(stderr, "INFO: Resource %04x/%s has both NEUTRAL and MASTER language translarion\n",
type, get_nameid_str(id));
}
if (en_US != NULL) return en_US;
if (en != NULL) return en;
return neutral;
}
void verify_translations(resource_t *top) {
resource_t *curr = top;
resource_id_node_t *idnode;
resource_lang_node_t *langnode;
int type;
setup_tabs();
while (curr)
{
add_resource(curr);
curr = curr->next;
}
for (type = 0; type <= res_usr; type++)
{
printf("TYPE NEXT [%s]\n", get_typename_for_int(type));
for (idnode = verify_tab[type].ids; idnode; idnode = idnode->next)
{
resource_t *mainres;
printf("RESOURCE [%s]\n", get_nameid_str(idnode->id));
mainres = find_main(type, idnode->id, idnode->langs);
if (!mainres)
{
fprintf(stderr, "ERR: resource %04x/%s has translation(s) but not available in NEUTRAL or MASTER language\n",
type, get_nameid_str(idnode->id));
for (langnode = idnode->langs; langnode; langnode = langnode->next)
printf("EXTRA %03x:%02x\n", langnode->lang.id, langnode->lang.sub);
continue;
}
if (get_language_id(mainres) == LANG_NEUTRAL && idnode->langs->next == NULL) {
printf("NOTRANSL\n");
continue;
}
for (langnode = idnode->langs; langnode; langnode = langnode->next)
{
printf("EXIST %03x:%02x\n", langnode->lang.id, langnode->lang.sub);
dump(langnode->res);
if (compare(langnode->res, mainres))
{
printf("DIFF %03x:%02x\n", langnode->lang.id, langnode->lang.sub);
}
}
}
}
}

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"
@ -63,25 +63,24 @@ static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
}
}
#endif
fprintf(stderr, "\n");
}
int yyerror(const char *s, ...)
int parser_error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Error", yytext, ap);
generic_msg(s, "Error", parser_text, ap);
va_end(ap);
exit(1);
return 1;
}
int yywarning(const char *s, ...)
int parser_warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Warning", yytext, ap);
generic_msg(s, "Warning", parser_text, ap);
va_end(ap);
return 0;
}
@ -92,7 +91,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);
}
@ -103,7 +101,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);
}
@ -114,7 +111,6 @@ void warning(const char *s, ...)
va_start(ap, s);
fprintf(stderr, "Warning: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
}
@ -126,7 +122,6 @@ void chat(const char *s, ...)
va_start(ap, s);
fprintf(stderr, "FYI: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
}
}
@ -167,12 +162,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;
}
@ -230,7 +220,7 @@ int compare_name_id(const name_id_t *n1, const name_id_t *n2)
}
else
{
internal_error(__FILE__, __LINE__, "Can't yet compare strings of mixed type");
internal_error(__FILE__, __LINE__, "Can't yet compare strings of mixed type\n");
}
}
else if(n1->type == name_ord && n2->type == name_str)
@ -238,7 +228,7 @@ int compare_name_id(const name_id_t *n1, const name_id_t *n2)
else if(n1->type == name_str && n2->type == name_ord)
return -1;
else
internal_error(__FILE__, __LINE__, "Comparing name-ids with unknown types (%d, %d)",
internal_error(__FILE__, __LINE__, "Comparing name-ids with unknown types (%d, %d)\n",
n1->type, n2->type);
return 0; /* Keep the compiler happy */
@ -248,26 +238,38 @@ string_t *convert_string(const string_t *str, enum str_e type, int codepage)
{
const union cptable *cptable = codepage ? wine_cp_get_table( codepage ) : NULL;
string_t *ret = xmalloc(sizeof(*ret));
int res;
if (!cptable && str->type != type)
error( "Current language is Unicode only, cannot convert strings" );
if (!codepage && str->type != type)
parser_error( "Current language is Unicode only, cannot convert string\n" );
if((str->type == str_char) && (type == str_unicode))
{
ret->type = str_unicode;
ret->size = wine_cp_mbstowcs( cptable, 0, str->str.cstr, str->size, NULL, 0 );
ret->type = str_unicode;
ret->size = cptable ? wine_cp_mbstowcs( cptable, 0, str->str.cstr, str->size, NULL, 0 )
: wine_utf8_mbstowcs( 0, str->str.cstr, str->size, NULL, 0 );
ret->str.wstr = xmalloc( (ret->size+1) * sizeof(WCHAR) );
wine_cp_mbstowcs( cptable, 0, str->str.cstr, str->size, ret->str.wstr, ret->size );
if (cptable)
res = wine_cp_mbstowcs( cptable, MB_ERR_INVALID_CHARS, str->str.cstr, str->size,
ret->str.wstr, ret->size );
else
res = wine_utf8_mbstowcs( MB_ERR_INVALID_CHARS, str->str.cstr, str->size,
ret->str.wstr, ret->size );
if (res == -2)
parser_error( "Invalid character in string '%.*s' for codepage %u\n",
str->size, str->str.cstr, codepage );
ret->str.wstr[ret->size] = 0;
}
else if((str->type == str_unicode) && (type == str_char))
{
ret->type = str_char;
ret->size = wine_cp_wcstombs( cptable, 0, str->str.wstr, str->size,
NULL, 0, NULL, NULL );
ret->type = str_char;
ret->size = cptable ? wine_cp_wcstombs( cptable, 0, str->str.wstr, str->size, NULL, 0, NULL, NULL )
: wine_utf8_wcstombs( 0, str->str.wstr, str->size, NULL, 0 );
ret->str.cstr = xmalloc( ret->size + 1 );
wine_cp_wcstombs( cptable, 0, str->str.wstr, str->size, ret->str.cstr, ret->size,
NULL, NULL );
if (cptable)
wine_cp_wcstombs( cptable, 0, str->str.wstr, str->size, ret->str.cstr, ret->size, NULL, NULL );
else
wine_utf8_wcstombs( 0, str->str.wstr, str->size, ret->str.cstr, ret->size );
ret->str.cstr[ret->size] = 0;
}
else if(str->type == str_unicode)

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 __WRC_UTILS_H
@ -33,8 +33,8 @@ char *xstrdup(const char *str);
#define __attribute__(X)
#endif
int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int parser_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), noreturn));
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
*
*/
@ -53,7 +53,7 @@
#define ENDIAN "little"
#endif
static char usage[] =
static const char usage[] =
"Usage: wrc [options...] [infile[.rc|.res]] [outfile]\n"
" -D id[=val] Define preprocessor identifier id=val\n"
" -E Preprocess only\n"
@ -165,17 +165,17 @@ int char_number = 1; /* The current char pos within the line */
char *cmdline; /* The entire commandline */
time_t now; /* The time of start of wrc */
int yy_flex_debug;
int parser_debug, yy_flex_debug;
resource_t *resource_top; /* The top of the parsed resources */
int getopt (int argc, char *const *argv, const char *optstring);
static void rm_tempfile(void);
static void cleanup_files(void);
static void segvhandler(int sig);
static const char* short_options =
static const char short_options[] =
"D:Ef:F:hi:I:J:l:o:O:rU:v";
static struct option long_options[] = {
static const struct option long_options[] = {
{ "debug", 1, 0, 6 },
{ "define", 1, 0, 'D' },
{ "endianess", 1, 0, 7 },
@ -188,7 +188,7 @@ static struct option long_options[] = {
{ "nostdinc", 0, 0, 1 },
{ "output", 1, 0, 'o' },
{ "output-format", 1, 0, 'O' },
{ "pendantic", 0, 0, 8 },
{ "pedantic", 0, 0, 8 },
{ "preprocessor", 1, 0, 4 },
{ "target", 1, 0, 'F' },
{ "undefine", 1, 0, 'U' },
@ -225,6 +225,12 @@ static void set_version_defines(void)
free( version );
}
/* clean things up when aborting on a signal */
static void exit_on_signal( int sig )
{
exit(1); /* this will call the atexit functions */
}
int main(int argc,char *argv[])
{
extern char* optarg;
@ -238,6 +244,11 @@ int main(int argc,char *argv[])
int cmdlen;
signal(SIGSEGV, segvhandler);
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
now = time(NULL);
@ -390,7 +401,7 @@ int main(int argc,char *argv[])
wpp_add_include_path(INCLUDEDIR"/msvcrt");
wpp_add_include_path(INCLUDEDIR"/windows");
}
/* Check for input file on command-line */
if(optind < argc)
{
@ -412,7 +423,7 @@ int main(int argc,char *argv[])
setbuf(stderr,0);
}
yydebug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
yy_flex_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
wpp_set_debug( (debuglevel & DEBUGLEVEL_PPLEX) != 0,
@ -429,6 +440,7 @@ int main(int argc,char *argv[])
output_name = dup_basename(input_name, ".rc");
strcat(output_name, ".res");
}
atexit(cleanup_files);
/* Run the preprocessor on the input */
if(!no_preprocess)
@ -438,11 +450,10 @@ int main(int argc,char *argv[])
* no output was given.
*/
chat("Starting preprocess");
chat("Starting preprocess\n");
if (!preprocess_only)
{
atexit(rm_tempfile);
ret = wpp_parse_temp( input_name, output_name, &temp_name );
}
else if (output_name)
@ -463,20 +474,23 @@ int main(int argc,char *argv[])
exit(1); /* Error during preprocess */
if(preprocess_only)
{
output_name = NULL;
exit(0);
}
input_name = temp_name;
}
/* Go from .rc to .res */
chat("Starting parse");
chat("Starting parse\n");
if(!(yyin = fopen(input_name, "rb")))
if(!(parser_in = fopen(input_name, "rb")))
error("Could not open %s for input\n", input_name);
ret = yyparse();
ret = parser_parse();
if(input_name) fclose(yyin);
if(input_name) fclose(parser_in);
if(ret) exit(1); /* Error during parse */
@ -492,17 +506,18 @@ int main(int argc,char *argv[])
/* Convert the internal lists to binary data */
resources2res(resource_top);
chat("Writing .res-file");
chat("Writing .res-file\n");
write_resfile(output_name, resource_top);
output_name = NULL;
return 0;
}
static void rm_tempfile(void)
static void cleanup_files(void)
{
if(temp_name)
unlink(temp_name);
if (output_name) unlink(output_name);
if (temp_name) unlink(temp_name);
}
static void segvhandler(int sig)

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 __WRC_WRC_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
*/
#ifndef __WRC_WRCTYPES_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,7 +74,7 @@ void write_resfile(char *outname, resource_t *top)
if(ret != res->size)
{
fclose(fo);
error("Error writing %s", outname);
error("Error writing %s\n", outname);
}
free(res);
}
@ -88,7 +88,7 @@ void write_resfile(char *outname, resource_t *top)
if(ret != top->binres->size)
{
fclose(fo);
error("Error writing %s", outname);
error("Error writing %s\n", outname);
}
if(win32 && (top->binres->size & 0x03))
{
@ -97,7 +97,7 @@ void write_resfile(char *outname, resource_t *top)
if(ret != 4 - (top->binres->size & 0x03))
{
fclose(fo);
error("Error writing %s", outname);
error("Error writing %s\n", outname);
}
}
}