PR binutils/647

* rcparse.y (RCDATA): Allow a filename to be supplied as the parameter.
  Parse it with define_rcdata_file().
* resrc.c (define_rcdata_file): New function.
* windres.h: Provide a prototype for the new function.

* resrc.c (define_user_file): Fix typo by replacing "font file" with "file".
This commit is contained in:
Nick Clifton
2005-01-17 16:24:12 +00:00
parent 637537d07b
commit b09a777222
4 changed files with 63 additions and 7 deletions

View File

@@ -1,3 +1,14 @@
2005-01-17 Eugene Kotlyarov <ekot@narod.ru>
PR binutils/647
* rcparse.y (RCDATA): Allow a filename to be supplied as the
parameter. Parse it with define_rcdata_file().
* resrc.c (define_rcdata_file): New function.
* windres.h: Provide a prototype for the new function.
* resrc.c (define_user_file): Fix typo by replacing "font file"
with "file".
2005-01-16 Jason Thorpe <thorpej@netbsd.org> 2005-01-16 Jason Thorpe <thorpej@netbsd.org>
* MAINTAINERS: Update my email address. * MAINTAINERS: Update my email address.

View File

@@ -1,5 +1,6 @@
%{ /* rcparse.y -- parser for Windows rc files %{ /* rcparse.y -- parser for Windows rc files
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support. Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -1152,6 +1153,13 @@ rcdata:
YYERROR; YYERROR;
rcparse_discard_strings (); rcparse_discard_strings ();
} }
| id RCDATA suboptions file_name
{
define_rcdata_file ($1, &$3, $4);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
; ;
/* We use a different lexing algorithm, because rcdata strings may /* We use a different lexing algorithm, because rcdata strings may

View File

@@ -1,5 +1,6 @@
/* resrc.c -- read and write Windows rc files. /* resrc.c -- read and write Windows rc files.
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support. Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -857,7 +858,7 @@ define_font (struct res_id id, const struct res_res_info *resinfo,
e = open_file_search (filename, FOPEN_RB, "font file", &real_filename); e = open_file_search (filename, FOPEN_RB, "font file", &real_filename);
if (stat (real_filename, &s) < 0) if (stat (real_filename, &s) < 0)
fatal (_("stat failed on bitmap file `%s': %s"), real_filename, fatal (_("stat failed on font file `%s': %s"), real_filename,
strerror (errno)); strerror (errno));
data = (unsigned char *) res_alloc (s.st_size); data = (unsigned char *) res_alloc (s.st_size);
@@ -1255,6 +1256,39 @@ define_user_data (struct res_id id, struct res_id type,
r->res_info = *resinfo; r->res_info = *resinfo;
} }
void
define_rcdata_file (struct res_id id, const struct res_res_info *resinfo,
const char *filename)
{
struct rcdata_item *ri;
FILE *e;
char *real_filename;
struct stat s;
unsigned char *data;
e = open_file_search (filename, FOPEN_RB, "file", &real_filename);
if (stat (real_filename, &s) < 0)
fatal (_("stat failed on file `%s': %s"), real_filename,
strerror (errno));
data = (unsigned char *) res_alloc (s.st_size);
get_data (e, data, s.st_size, real_filename);
fclose (e);
free (real_filename);
ri = (struct rcdata_item *) res_alloc (sizeof *ri);
ri->next = NULL;
ri->type = RCDATA_BUFFER;
ri->u.buffer.length = s.st_size;
ri->u.buffer.data = data;
define_rcdata (id, resinfo, ri);
}
/* Define a user data resource where the data is in a file. */ /* Define a user data resource where the data is in a file. */
void void
@@ -1268,10 +1302,10 @@ define_user_file (struct res_id id, struct res_id type,
struct res_id ids[3]; struct res_id ids[3];
struct res_resource *r; struct res_resource *r;
e = open_file_search (filename, FOPEN_RB, "font file", &real_filename); e = open_file_search (filename, FOPEN_RB, "file", &real_filename);
if (stat (real_filename, &s) < 0) if (stat (real_filename, &s) < 0)
fatal (_("stat failed on bitmap file `%s': %s"), real_filename, fatal (_("stat failed on file `%s': %s"), real_filename,
strerror (errno)); strerror (errno));
data = (unsigned char *) res_alloc (s.st_size); data = (unsigned char *) res_alloc (s.st_size);

View File

@@ -1,5 +1,6 @@
/* windres.h -- header file for windres program. /* windres.h -- header file for windres program.
Copyright 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc. Copyright 1997, 1998, 2000, 2002, 2003, 2005
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support. Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -829,6 +830,8 @@ extern void define_messagetable
(struct res_id, const struct res_res_info *, const char *); (struct res_id, const struct res_res_info *, const char *);
extern void define_rcdata extern void define_rcdata
(struct res_id, const struct res_res_info *, struct rcdata_item *); (struct res_id, const struct res_res_info *, struct rcdata_item *);
extern void define_rcdata_file
(struct res_id, const struct res_res_info *, const char *);
extern struct rcdata_item *define_rcdata_string extern struct rcdata_item *define_rcdata_string
(const char *, unsigned long); (const char *, unsigned long);
extern struct rcdata_item *define_rcdata_number (unsigned long, int); extern struct rcdata_item *define_rcdata_number (unsigned long, int);