* asranlib/asranlib.c, link/lkar.h, link/lkar.c:
[fw/sdcc] / as / link / lkrel.c
index 3914acedc96b80931c6dc2f5e1f7e90b1c6ffafb..5aae61edf3d6484cb3e567c90ebd411f8fc5aa2f 100644 (file)
@@ -1,13 +1,23 @@
-/* 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 3, 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, see <http://www.gnu.org/licenses/>. */
 
 /*
- * (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 +47,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 +80,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 +110,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 +120,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;