2008-02-16 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
[deliverable/binutils-gdb.git] / binutils / windres.c
index 05615c432c59a528fe61ff432259528c46a38188..e68a504cf3c2da1cf57cf5feceffb818d6942b1f 100644 (file)
@@ -8,7 +8,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -765,6 +765,12 @@ windres_add_include_dir (const char *p)
 {
   struct include_dir *n, **pp;
 
+  /* Computing paths is often complicated and error prone.
+     The easiest way to check for mistakes is at the time
+     we add them to include_dirs.  */
+  assert (p != NULL);
+  assert (*p != '\0');
+
   n = xmalloc (sizeof *n);
   n->next = NULL;
   n->dir = (char * ) p;
@@ -1056,7 +1062,8 @@ main (int argc, char **argv)
   return 0;
 }
 
-static void set_endianess (bfd *abfd, const char *target)
+static void
+set_endianess (bfd *abfd, const char *target)
 {
   const bfd_target *target_vec;
 
@@ -1065,17 +1072,22 @@ static void 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();
-    if (arch && tname)
+    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)
              {
@@ -1085,6 +1097,9 @@ static void set_endianess (bfd *abfd, const char *target)
            arch++;
          }
       }
+
+    free (arches);
+
     if (! def_target_arch)
       fatal ("Can't detect architecture.");
   }
@@ -1150,8 +1165,8 @@ set_windres_bfd (windres_bfd *wrbfd, bfd *abfd, asection *sec, rc_uint_type kind
 }
 
 void
-set_windres_bfd_content(windres_bfd *wrbfd, const void *data, rc_uint_type off,
-                       rc_uint_type length)
+set_windres_bfd_content (windres_bfd *wrbfd, const void *data, rc_uint_type off,
+                        rc_uint_type length)
 {
   if (WR_KIND(wrbfd) != WR_KIND_TARGET)
     {
@@ -1163,8 +1178,8 @@ set_windres_bfd_content(windres_bfd *wrbfd, const void *data, rc_uint_type off,
 }
 
 void
-get_windres_bfd_content(windres_bfd *wrbfd, void *data, rc_uint_type off,
-                       rc_uint_type length)
+get_windres_bfd_content (windres_bfd *wrbfd, void *data, rc_uint_type off,
+                        rc_uint_type length)
 {
   if (WR_KIND(wrbfd) != WR_KIND_TARGET)
     {
This page took 0.045584 seconds and 4 git commands to generate.