diff options
author | Ian Lance Taylor <ian@airs.com> | 1999-09-19 23:59:35 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1999-09-19 23:59:35 +0000 |
commit | 34ca6cf879e70a8b02c4743c6e7586e9dd09bd7c (patch) | |
tree | dd7bf8b2f89c3ddfac089eff82bd7f5dc0ff8295 /binutils/resrc.c | |
parent | 4cc782b5919b187ce44ea9d4a66793105aeb07da (diff) | |
download | gdb-34ca6cf879e70a8b02c4743c6e7586e9dd09bd7c.zip gdb-34ca6cf879e70a8b02c4743c6e7586e9dd09bd7c.tar.gz gdb-34ca6cf879e70a8b02c4743c6e7586e9dd09bd7c.tar.bz2 |
* 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.c | 92 |
1 files changed, 66 insertions, 26 deletions
diff --git a/binutils/resrc.c b/binutils/resrc.c index c633c2a..8ed6a5d 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); |