X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=binutils%2Fwindmc.c;fp=binutils%2Fwindmc.c;h=c7aa8f8e4e9704b237e6655251cd0adc6173059c;hp=14a2f86a1de7c9407417db2bcd69ca751010feb3;hb=88750007d7869f178f0ba528f41efd3b74c424cf;hpb=6df9443a374e2b81278c61b8afc0a1eef7db280b diff --git a/binutils/windmc.c b/binutils/windmc.c index 14a2f86..c7aa8f8 100644 --- a/binutils/windmc.c +++ b/binutils/windmc.c @@ -1,5 +1,5 @@ /* windmc.c -- a program to compile Windows message files. - Copyright 2007 + Copyright 2007, 2008 Free Software Foundation, Inc. Written by Kai Tietz, Onevision. @@ -175,7 +175,7 @@ res_init (void) void * res_alloc (rc_uint_type bytes) { - return (void *) obstack_alloc (&res_obstack, (size_t) bytes); + return obstack_alloc (&res_obstack, (size_t) bytes); } static FILE * @@ -245,18 +245,23 @@ set_endianess (bfd *abfd, const char *target) if (! target_vec) fatal ("Can't detect target endianess and architecture."); target_is_bigendian = ((target_vec->byteorder == BFD_ENDIAN_BIG) ? 1 : 0); + { - const char *tname = target_vec->name; - const char **arch = bfd_arch_list (); + const char * tname = target_vec->name; + const char ** arches = bfd_arch_list (); - if (arch && tname) + if (arches && tname) { + const char ** arch = arches; + if (strchr (tname, '-') != NULL) tname = strchr (tname, '-') + 1; + while (*arch != NULL) { const char *in_a = strstr (*arch, tname); char end_ch = (in_a ? in_a[strlen (tname)] : 0); + if (in_a && (in_a == *arch || in_a[-1] == ':') && end_ch == 0) { @@ -266,6 +271,9 @@ set_endianess (bfd *abfd, const char *target) arch++; } } + + free (arches); + if (! def_target_arch) fatal ("Can't detect architecture."); } @@ -373,7 +381,8 @@ convert_unicode_to_ACP (const unichar *usz) return NULL; codepage_from_unicode (&l, usz, &s, mcset_codepage_out); if (! s) - fatal ("unicode string not mappable to ASCII codepage 0x%lx.\n", (long) mcset_codepage_out); + fatal ("unicode string not mappable to ASCII codepage 0x%lx.\n", + (unsigned long) mcset_codepage_out); return s; } @@ -699,13 +708,11 @@ windmc_write_bin (const char *filename, mc_node_lang **nl, int elems) if (elems <= 0) return; mc_bfd.abfd = windmc_open_as_binary (filename); - mc_bfd.sec = bfd_make_section (mc_bfd.abfd, ".data"); + mc_bfd.sec = bfd_make_section_with_flags (mc_bfd.abfd, ".data", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); if (mc_bfd.sec == NULL) bfd_fatal ("bfd_make_section"); - if (! bfd_set_section_flags (mc_bfd.abfd, mc_bfd.sec, - (SEC_HAS_CONTENTS | SEC_ALLOC - | SEC_LOAD | SEC_DATA))) - bfd_fatal ("bfd_set_section_flags"); /* Requiring this is probably a bug in BFD. */ mc_bfd.sec->output_section = mc_bfd.sec; @@ -797,8 +804,8 @@ write_rc (FILE *fp) int i, l; fprintf (fp, - "/* Do not edit this file manually.\n" - " This file is autogenerated by windmc. */\n\n"); + "/* Do not edit this file manually.\n" + " This file is autogenerated by windmc. */\n\n"); if (! mc_nodes_lang_count) return; n = NULL; @@ -810,10 +817,11 @@ write_rc (FILE *fp) ++i; n = mc_nodes_lang[l]; fprintf (fp, "\n// Country: %s\n// Language: %s\n#pragma code_page(%u)\n", - n->lang->lang_info.country, n->lang->lang_info.name, - (unsigned) n->lang->lang_info.wincp); - fprintf (fp, "LANGUAGE 0x%lx, 0x%lx\n", (long) (n->lang->nval & 0x3ff), - (long) ((n->lang->nval & 0xffff) >> 10)); + n->lang->lang_info.country, n->lang->lang_info.name, + (unsigned) n->lang->lang_info.wincp); + fprintf (fp, "LANGUAGE 0x%lx, 0x%lx\n", + (unsigned long) (n->lang->nval & 0x3ff), + (unsigned long) ((n->lang->nval & 0xffff) >> 10)); fprintf (fp, "1 MESSAGETABLE \""); if (mcset_prefix_bin) fprintf (fp, "%s_", mcset_mc_basename); @@ -1136,7 +1144,7 @@ main (int argc, char **argv) unichar *u; rc_uint_type ul; char *buff; - long flen; + bfd_size_type flen; FILE *fp = fopen (input_filename, "rb"); if (!fp) @@ -1147,7 +1155,8 @@ main (int argc, char **argv) fseek (fp, 0, SEEK_SET); buff = malloc (flen + 3); memset (buff, 0, flen + 3); - fread (buff, 1, flen, fp); + if (fread (buff, 1, flen, fp) < flen) + fatal (_("unable to read contents of %s"), input_filename); fclose (fp); if (mcset_text_in_is_unicode != 1) {