* as/asranlib/Makefile.in, as/asranlib/asranlib.dsp,
[fw/sdcc] / as / link / lkrel.c
index 3914acedc96b80931c6dc2f5e1f7e90b1c6ffafb..7b5a931cfa02c68b2761a99dbaa9159a2b780498 100644 (file)
@@ -1,13 +1,24 @@
-/* lkrel.c */
+/* lkrel.c - .rel object file handling
+
+   Copyright (C) 1989-1995 Alan R. Baldwin
+   721 Berkeley St., Kent, Ohio 44240
+   Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net
+
+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, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
 
 /*
- * (C) Copyright 1989-1995
- * All Rights Reserved
- *
- * Alan R. Baldwin
- * 721 Berkeley St.
- * Kent, Ohio  44240
- *
  * With contributions for the
  * object libraries from
  * Ken Hornstein
@@ -37,22 +48,22 @@ is_rel (FILE * libfp)
   if (((c = getc (libfp)) == 'X' || c == 'D' || c == 'Q') && ((c = getc (libfp)) == 'H' || c == 'L'))
     {
       switch (getc (libfp))
-       {
-       case '\r':
-         if (getc (libfp) == '\n')
-           ret = 1;
-         break;
-
-       case '\n':
-         ret = 1;
-       }
+        {
+        case '\r':
+          if (getc (libfp) == '\n')
+            ret = 1;
+          break;
+
+        case '\n':
+          ret = 1;
+        }
     }
   else if (c == ';')
     {
       char buf[6];
 
       if (fread (buf, 1, sizeof (buf), libfp) == sizeof (buf) && memcmp (buf, "!FILE ", 6) == 0)
-       ret = 1;
+        ret = 1;
     }
   fseek (libfp, pos, SEEK_SET);
   return ret;
@@ -70,13 +81,13 @@ load_rel (FILE * libfp, long size)
       end = (size >= 0) ? ftell (libfp) + size : -1;
 
       while ((end < 0 || ftell (libfp) < end) && getline (str, sizeof (str), libfp) != NULL)
-       {
-         if (0 == strcmp (str, "</REL>"))
-           return 1;
+        {
+          if (0 == strcmp (str, "</REL>"))
+            return 1;
 
-         ip = str;
-         link_main ();
-       }
+          ip = str;
+          link_main ();
+        }
 
       return 1;
     }
@@ -100,7 +111,7 @@ enum_symbols (FILE * fp, long size, int (*func) (const char *symvoid, void *para
    * our object file and don't go into the next one.
    */
 
-  while ((end <= 0 || ftell (fp) < end) && getline (buf, sizeof (buf), fp) != NULL)
+  while ((end < 0 || ftell (fp) < end) && getline (buf, sizeof (buf), fp) != NULL)
     {
       char symname[NINPUT];
       char c;
@@ -110,22 +121,22 @@ enum_symbols (FILE * fp, long size, int (*func) (const char *symvoid, void *para
        * All 'S line's preceed 'T line's in .REL files.
        */
       if (buf[0] == 'T')
-       break;
+        break;
 
       /*
        * Skip everything that's not a symbol record.
        */
       if (buf[0] != 'S')
-       continue;
+        continue;
 
       sscanf (buf, "S %s %c", symname, &c);
 
       /* If it's an actual symbol, record it */
       if (c == 'D')
-       {
-         if ((*func) (symname, param))
-           return 1;
-       }
+        {
+          if ((*func) (symname, param))
+            return 1;
+        }
     }
 
   return 0;