OSDN Git Service

* regset.h (struct core_regset_section): Add HUMAN_NAME.
[pf3gnuchains/pf3gnuchains3x.git] / binutils / windmc.c
index 283c265..63db990 100644 (file)
@@ -1,5 +1,5 @@
 /* windmc.c -- a program to compile Windows message files.
-   Copyright 2007, 2008
+   Copyright 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Kai Tietz, Onevision.
 
@@ -51,11 +51,6 @@ typedef struct mc_msg_item
   struct bin_messagetable_item *res;
 } mc_msg_item;
 
-/* Defined in bfd/binary.c.  Used to set architecture and machine of input
-   binary files.  */
-extern enum bfd_architecture  bfd_external_binary_architecture;
-extern unsigned long          bfd_external_machine;
-
 int target_is_bigendian = 0;
 const char *def_target_arch;
 
@@ -175,7 +170,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 *
@@ -241,42 +236,12 @@ set_endianess (bfd *abfd, const char *target)
   const bfd_target *target_vec;
 
   def_target_arch = NULL;
-  target_vec = bfd_find_target (target, abfd);
+  target_vec = bfd_get_target_info (target, abfd, &target_is_bigendian, NULL,
+                                  &def_target_arch);
   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 ** arches = bfd_arch_list ();
-
-    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)
-             {
-               def_target_arch = *arch;
-               break;
-             }
-           arch++;
-         }
-      }
-
-    free (arches);
-
-    if (! def_target_arch)
-      fatal ("Can't detect architecture.");
-  }
+  if (! def_target_arch)
+    fatal ("Can't detect architecture.");
 }
 
 static int
@@ -1144,7 +1109,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)
@@ -1155,7 +1120,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)
       {