From 1b938a5aed15c13cd3e4d5d4a6e2da7c08e87c9d Mon Sep 17 00:00:00 2001 From: vav Date: Tue, 17 Oct 2000 14:44:52 +0000 Subject: [PATCH] fixed assemblers & linker: now works with CygWin's option 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 | 37 ++++++++++++++++++++++++++++++++----- as/mcs51/aslink.h | 1 + as/mcs51/asm.h | 1 + as/mcs51/lklex.c | 37 +++++++++++++++++++++++++++++++++---- as/mcs51/lklibr.c | 9 +++------ as/z80/aslex.c | 2 ++ 6 files changed, 72 insertions(+), 15 deletions(-) diff --git a/as/mcs51/aslex.c b/as/mcs51/aslex.c index 4cbcda62..12dade5f 100644 --- a/as/mcs51/aslex.c +++ b/as/mcs51/aslex.c @@ -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; +} diff --git a/as/mcs51/aslink.h b/as/mcs51/aslink.h index ba85dcb7..f42aa092 100644 --- a/as/mcs51/aslink.h +++ b/as/mcs51/aslink.h @@ -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(); diff --git a/as/mcs51/asm.h b/as/mcs51/asm.h index a7a8131a..c85a11d1 100644 --- a/as/mcs51/asm.h +++ b/as/mcs51/asm.h @@ -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(); diff --git a/as/mcs51/lklex.c b/as/mcs51/lklex.c index 15e6c5ab..55765c61 100644 --- a/as/mcs51/lklex.c +++ b/as/mcs51/lklex.c @@ -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; +} diff --git a/as/mcs51/lklibr.c b/as/mcs51/lklibr.c index a6a549a7..e80fe02b 100644 --- a/as/mcs51/lklibr.c +++ b/as/mcs51/lklibr.c @@ -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(); } diff --git a/as/z80/aslex.c b/as/z80/aslex.c index 49a395f9..c6cbbd7a 100644 --- a/as/z80/aslex.c +++ b/as/z80/aslex.c @@ -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); } -- 2.47.2