]> git.gag.com Git - fw/sdcc/commitdiff
fixed assemblers & linker: now works with CygWin's option
authorvav <vav@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 17 Oct 2000 14:44:52 +0000 (14:44 +0000)
committervav <vav@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 17 Oct 2000 14:44:52 +0000 (14:44 +0000)
Default Text File Type = Unix

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@473 4a8a32a2-be11-0410-ad9d-d568d2c75423

as/mcs51/aslex.c
as/mcs51/aslink.h
as/mcs51/asm.h
as/mcs51/lklex.c
as/mcs51/lklibr.c
as/z80/aslex.c

index 4cbcda629e67b43a96508ec7f485a551b6b651dd..12dade5f97aa93fecbc03a02ad82ed059a54904a 100644 (file)
@@ -402,8 +402,6 @@ getmap(d)
 int
 getline()
 {
-register int i;
-
 loop:  if (incfil >= 0) {
                if (fgets(ib, sizeof ib, ifp[incfil]) == NULL) {
                        fclose(ifp[incfil--]);
@@ -423,9 +421,7 @@ loop:       if (incfil >= 0) {
                        ++srcline[cfile];
                }
        }
-       i = strlen(ib) - 1;
-       if (ib[i] == '\n')
-               ib[i] = 0;
+       chop_crlf(ib);
        return (1);
 }
 
@@ -492,3 +488,34 @@ endline()
        c = getnb();
        return( (c == '\0' || c == ';') ? 0 : c );
 }
+
+/*)Function    VOID    chop_crlf(str)
+ *
+ *             char    *str            string to chop
+ *
+ *     The function chop_crlf() removes trailing LF or CR/LF from
+ *     str, if present.
+ *
+ *     local variables:
+ *             int     i               string length
+ *
+ *     global variables:
+ *             none
+ *
+ *     functions called:
+ *             none
+ *
+ *     side effects:
+ *             none
+ */
+
+VOID
+chop_crlf(str)
+char *str;
+{
+       register int i;
+
+       i = strlen(str);
+       if (i >= 1 && str[i-1] == '\n') str[i-1] = 0;
+       if (i >= 2 && str[i-2] == '\r') str[i-2] = 0;
+}
index ba85dcb750a974cb19a67146809767fc1fb768f4..f42aa092b35c600ca5aced87799f9994d46a5b0f 100644 (file)
@@ -654,6 +654,7 @@ extern      char            getnb();
 extern int             more();
 extern VOID            skip();
 extern VOID            unget();
+extern VOID            chop_crlf();
 
 /* lkarea.c */
 extern VOID            lkparea();
index a7a8131a0ec61e7f058eaf4814ab658475e7761d..c85a11d16ee6a0575a439c397b837570b2f4e056 100644 (file)
@@ -575,6 +575,7 @@ extern      char            getnb();
 extern VOID            getst();
 extern int             more();
 extern VOID            unget();
+extern VOID            chop_crlf();
 
 /* assym.c */
 extern struct  area *  alookup();
index 15e6c5abefcf95c8a888339be849331ae225bb87..55765c6186d64f4b53c4752925a8e70fbbe95bd8 100644 (file)
@@ -415,7 +415,7 @@ getmap(d)
 int
 getline()
 {
-       register int i, ftype;
+       register int ftype;
        register char *fid;
 
 loop:  if (pflag && cfp && cfp->f_type == F_STD)
@@ -473,9 +473,7 @@ loop:       if (pflag && cfp && cfp->f_type == F_STD)
                        return(0);
                }
        }
-       i = strlen(ib) - 1;
-       if (ib[i] == '\n')
-               ib[i] = 0;
+       chop_crlf(ib);
        return (1);
 }
 
@@ -542,3 +540,34 @@ endline()
        c = getnb();
        return( (c == '\0' || c == ';') ? 0 : c );
 }
+
+/*)Function    VOID    chop_crlf(str)
+ *
+ *             char    *str            string to chop
+ *
+ *     The function chop_crlf() removes trailing LF or CR/LF from
+ *     str, if present.
+ *
+ *     local variables:
+ *             int     i               string length
+ *
+ *     global variables:
+ *             none
+ *
+ *     functions called:
+ *             none
+ *
+ *     side effects:
+ *             none
+ */
+
+VOID
+chop_crlf(str)
+char *str;
+{
+       register int i;
+
+       i = strlen(str);
+       if (i >= 1 && str[i-1] == '\n') str[i-1] = 0;
+       if (i >= 2 && str[i-2] == '\r') str[i-2] = 0;
+}
index a6a549a78d201287d229ccb94a745a653c172972..e80fe02b5b1f05965de4b971aa9f0f05c6f22a50 100644 (file)
@@ -381,7 +381,7 @@ char *name;
 
 /*2*/          while (fgets(relfil, NINPUT, libfp) != NULL) {
                    relfil[NINPUT+1] = '\0';
-                   relfil[strlen(relfil) - 1] = '\0';
+                   chop_crlf(relfil);
                    if (path != NULL) {
                        str = (char *) new (strlen(path)+strlen(relfil)+6);
                        strcpy(str,path);
@@ -414,7 +414,7 @@ char *name;
 /*4*/                  while (fgets(buf, NINPUT, fp) != NULL) {
 
                        buf[NINPUT+1] = '\0';
-                       buf[strlen(buf) - 1] = '\0';
+                       chop_crlf(buf);
 
                        /*
                         * Skip everything that's not a symbol record.
@@ -537,14 +537,11 @@ char *filspc;
 {
        FILE *fp;
        char str[NINPUT+2];
-       int i;
 
        if ((fp = fopen(filspc,"r")) != NULL) {
                while (fgets(str, NINPUT, fp) != NULL) {
                        str[NINPUT+1] = '\0';
-                       i = strlen(str) - 1;
-                       if (str[i] == '\n')
-                               str[i] = '\0';
+                       chop_crlf(str);
                        ip = str;
                        link_main();
                }
index 49a395f913f0397116bf2e1901212e22d1275231..c6cbbd7a85d2093d6e3218102eca05e94985307e 100644 (file)
@@ -432,6 +432,8 @@ loop:       if (incfil >= 0) {
        i = strlen(ib) - 1;
        if (ib[i] == '\n')
                ib[i] = 0;
+       if (i >= 1 && ib[i-1] == '\r')
+               ib[i-1] = 0;
        return (1);
 }