+1999-09-19 Ian Lance Taylor <ian@zembu.com>
+
+ * resrc.c (write_rc_rcdata): Fix local variable shadowing
+ problem. If RCDATA_BUFFER data can be read as strings, modify
+ code to print the strings as comments.
+ * resres.c: Add casts to avoid warnings.
+ (write_res_data, read_res_data): Don't put the program name in the
+ error message; fatal already puts it there.
+
1999-09-14 Michael Meissner <meissner@cygnus.com>
* configure.in (Canonicalization of target names): Remove adding
for (i = 0; i + 3 < ri->u.buffer.length; i += 4)
{
unsigned long l;
+ int j;
+ if (! first)
+ indent (e, ind + 2);
l = ((((((ri->u.buffer.data[i + 3] << 8)
| ri->u.buffer.data[i + 2]) << 8)
| ri->u.buffer.data[i + 1]) << 8)
| ri->u.buffer.data[i]);
- if (first)
- first = 0;
- else
+ fprintf (e, "%luL", l);
+ if (i + 4 < ri->u.buffer.length || ri->next != NULL)
+ fprintf (e, ",");
+ for (j = 0; j < 4; ++j)
+ if (! isprint (ri->u.buffer.data[i + j])
+ && ri->u.buffer.data[i + j] != 0)
+ break;
+ if (j >= 4)
{
- fprintf (e, ",\n");
- indent (e, ind + 2);
+ fprintf (e, "\t// ");
+ for (j = 0; j < 4; ++j)
+ {
+ if (! isprint (ri->u.buffer.data[i + j]))
+ fprintf (e, "\\%03o", ri->u.buffer.data[i + j]);
+ else
+ {
+ if (ri->u.buffer.data[i + j] == '\\')
+ fprintf (e, "\\");
+ fprintf (e, "%c", ri->u.buffer.data[i + j]);
+ }
+ }
}
- fprintf (e, "%luL", l);
+ fprintf (e, "\n");
+ first = 0;
}
if (i + 1 < ri->u.buffer.length)
{
- int i;
-
- i = (ri->u.buffer.data[i + 1] << 8) | ri->u.buffer.data[i];
- if (first)
- first = 0;
- else
+ int s;
+ int j;
+
+ if (! first)
+ indent (e, ind + 2);
+ s = (ri->u.buffer.data[i + 1] << 8) | ri->u.buffer.data[i];
+ fprintf (e, "%d", s);
+ if (i + 2 < ri->u.buffer.length || ri->next != NULL)
+ fprintf (e, ",");
+ for (j = 0; j < 2; ++j)
+ if (! isprint (ri->u.buffer.data[i + j])
+ && ri->u.buffer.data[i + j] != 0)
+ break;
+ if (j >= 2)
{
- fprintf (e, ",\n");
- indent (e, ind + 2);
+ fprintf (e, "\t// ");
+ for (j = 0; j < 2; ++j)
+ {
+ if (! isprint (ri->u.buffer.data[i + j]))
+ fprintf (e, "\\%03o", ri->u.buffer.data[i + j]);
+ else
+ {
+ if (ri->u.buffer.data[i + j] == '\\')
+ fprintf (e, "\\");
+ fprintf (e, "%c", ri->u.buffer.data[i + j]);
+ }
+ }
}
- fprintf (e, "%d", i);
+ fprintf (e, "\n");
i += 2;
+ first = 0;
}
if (i < ri->u.buffer.length)
{
- if (first)
- first = 0;
- else
- {
- fprintf (e, ",\n");
- indent (e, ind + 2);
- }
+ if (! first)
+ indent (e, ind + 2);
if ((ri->u.buffer.data[i] & 0x7f) == ri->u.buffer.data[i]
&& isprint (ri->u.buffer.data[i]))
fprintf (e, "\"%c\"", ri->u.buffer.data[i]);
else
- fprintf (e, "\"\%03o\"", ri->u.buffer.data[i]);
+ fprintf (e, "\"\\%03o\"", ri->u.buffer.data[i]);
+ if (ri->next != NULL)
+ fprintf (e, ",");
+ fprintf (e, "\n");
+ first = 0;
}
break;
}
}
- if (ri->next != NULL)
- fprintf (e, ",");
- fprintf (e, "\n");
+ if (ri->type != RCDATA_BUFFER)
+ {
+ if (ri->next != NULL)
+ fprintf (e, ",");
+ fprintf (e, "\n");
+ }
}
indent (e, ind);
/* resres.c: read_res_file and write_res_file implementation for windres.
-
Copyright 1998, 1999 Free Software Foundation, Inc.
Written by Anders Norlander <anorland@hem2.passagen.se>.
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
+/* FIXME: This file does not work correctly in a cross configuration.
+ It assumes that it can use fread and fwrite to read and write
+ integers. It does no swapping. */
+
#include "bfd.h"
#include "bucomm.h"
#include "libiberty.h"
/* If we're at level 3, then this key represents a language.
Use it to update the current language. */
if (!re->id.named
- && re->id.u.id != *language
+ && re->id.u.id != (unsigned long) *language
&& (re->id.u.id & 0xffff) == re->id.u.id)
{
*language = re->id.u.id;
const struct res_id *type;
const struct res_id *name;
const struct res_resource *res;
- int *language;
+ int *language ATTRIBUTE_UNUSED;
{
int rt;
if (rt != 0
&& type != NULL
- && (type->named || type->u.id != rt))
+ && (type->named || type->u.id != (unsigned long) rt))
{
fprintf (stderr, "// Unexpected resource type mismatch: ");
res_id_print (stderr, *type, 1);
size_t size;
int count;
{
- if (fwrite (data, size, count, fres) != count)
- fatal ("%s: %s: could not write to file", program_name, filename);
+ if (fwrite (data, size, count, fres) != (size_t) count)
+ fatal ("%s: could not write to file", filename);
}
/* Read data from file, abort on failure */
size_t size;
int count;
{
- if (fread (data, size, count, fres) != count)
- fatal ("%s: %s: unexpected end of file", program_name, filename);
+ if (fread (data, size, count, fres) != (size_t) count)
+ fatal ("%s: unexpected end of file", filename);
}
/* Write a resource id */