summaryrefslogtreecommitdiff
path: root/binutils/resrc.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1999-09-19 23:59:35 +0000
committerIan Lance Taylor <ian@airs.com>1999-09-19 23:59:35 +0000
commit172e807837e14bc58255242ab7093d84a95b6a5c (patch)
tree8523c23483e5f71423ecff4b2680aaa524b1e1a7 /binutils/resrc.c
parentb780da7309626440afd27a253502af22051730de (diff)
downloadbinutils-redhat-172e807837e14bc58255242ab7093d84a95b6a5c.tar.gz
* 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.
Diffstat (limited to 'binutils/resrc.c')
-rw-r--r--binutils/resrc.c92
1 files changed, 66 insertions, 26 deletions
diff --git a/binutils/resrc.c b/binutils/resrc.c
index c633c2a0b1..8ed6a5d158 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -2155,60 +2155,100 @@ write_rc_rcdata (e, rcdata, ind)
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);