Address space 'z' was missing.
[fw/sdcc] / as / mcs51 / lklibr.c
index e80fe02b5b1f05965de4b971aa9f0f05c6f22a50..555adb1756ac9d689f3bfa05fb1bb001439da212 100644 (file)
  *
  */
 
+#if defined(__APPLE__) && defined(__MACH__)
+#include <sys/types.h>
+#include <sys/malloc.h>
+#else
+#include <malloc.h>
+#endif
 #include <stdio.h>
 #include <string.h>
-#include <alloc.h>
 #include "aslink.h"
 
 /*)Module      lklibr.c
@@ -182,7 +187,7 @@ char *libfil;
        if (libfil[0] == '/') { libfil++; }
 #endif
        strcat(str,libfil);
-       if(strchr(str,FSEPX) == NULL) {
+       if(strchr(libfil,FSEPX) == NULL) {
                sprintf(&str[strlen(str)], "%clib", FSEPX);
        }
        if ((fp = fopen(str, "r")) != NULL) {
@@ -202,7 +207,6 @@ char *libfil;
                lbnh->libfil = (char *) new (strlen(libfil) + 1);
                strcpy(lbnh->libfil,libfil);
                lbnh->libspc = str;
-               fprintf(stderr,"library file %s\n",str);
        } else {
                free(str);
        }
@@ -398,7 +402,7 @@ char *name;
                    } else {
                        strcat(str,relfil);
                    }
-                   if(strchr(str,FSEPX) == NULL) {
+                   if(strchr(relfil,FSEPX) == NULL) {
                        sprintf(&str[strlen(str)], "%crel", FSEPX);
                    }
 /*3*/              if ((fp = fopen(str, "r")) != NULL) {
@@ -456,8 +460,9 @@ char *name;
                        fclose(libfp);                 
                        /* if cdb information required & cdb file present */
                        if (dflag && dfp) {
-                           FILE *xfp = afile(str,"cdb",0);
+                           FILE *xfp = afile(str,"adb",0); //JCF: Nov 30, 2002
                            if (xfp) {
+                               SaveLinkedFilePath(str);
                                copyfile(dfp,xfp);
                                fclose(xfp);
                            }