From 10ac28a71ee401c1e271a5f3db653c42ef7273fe Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Sat, 19 Jan 2008 15:42:51 +0000 Subject: [PATCH] * device/include/asm/ds390/features.h: fixed bug with ds390 & stack-auto * as/link/lklex.c, * as/link/mcs51/lkmain.c: used LKDIRSEP, LKDIRSEPSTR and LKOBJEXT, cosmetic changes, brought more in sync, changed old K&R to ANSI git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4995 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 ++ as/link/lklex.c | 16 +++----- as/link/mcs51/lkmain.c | 60 +++++++++++++++-------------- device/include/asm/ds390/features.h | 2 + 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 089faa18..b973a16b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ * as/mcs51/asx8051.dsp: removed define SDK * as/mcs51/i51mch.c (machine): fixed bug 1865114 + * device/include/asm/ds390/features.h: fixed bug with ds390 & stack-auto + * as/link/lklex.c, + * as/link/mcs51/lkmain.c: used LKDIRSEP, LKDIRSEPSTR and LKOBJEXT, + cosmetic changes, brought more in sync, changed old K&R to ANSI 2008-01-13 Borut Razem diff --git a/as/link/lklex.c b/as/link/lklex.c index c29066ed..67c297a1 100644 --- a/as/link/lklex.c +++ b/as/link/lklex.c @@ -162,7 +162,7 @@ getSid (char *id) * The function getfid() scans the current input text line from * the current position copying the next string into the external * string buffer (str). The string ends when end of line is found. - * Trailing spacers are removed. The maximum number of characters + * Trailing spaces are removed. The maximum number of characters * copied is PATH_MAX. If the input string is larger than PATH_MAX * characters then the string is truncated. The string is NULL * terminated. @@ -186,9 +186,7 @@ getSid (char *id) */ VOID -getfid(str, c) -register int c; -char *str; +getfid(char *str, register int c) { register char *p; @@ -261,8 +259,7 @@ getnb() */ VOID -skip(c) -register int c; +skip(register int c) { if (c < 0) c = getnb(); @@ -332,7 +329,7 @@ get() */ VOID -unget(c) +unget(int c) { if (c != 0) --ip; @@ -370,7 +367,7 @@ unget(c) */ int -getmap(d) +getmap(int d) { register int c, n, v; @@ -628,8 +625,7 @@ endline() */ VOID -chop_crlf(str) -char *str; +chop_crlf(char *str) { register int i; diff --git a/as/link/mcs51/lkmain.c b/as/link/mcs51/lkmain.c index e470adb0..89ce6a18 100644 --- a/as/link/mcs51/lkmain.c +++ b/as/link/mcs51/lkmain.c @@ -9,7 +9,7 @@ * Kent, Ohio 44240 * * 31-Oct-97 JLH: - * - add jflag and jfp to control NoICE output file genration + * - add jflag and jfp to control NoICE output file generation * 3-Nov-97 JLH: * - use a_type == 0 as "virgin area" flag: set == 1 if -b */ @@ -421,6 +421,8 @@ main(int argc, char *argv[]) #endif lkexit(lkerr); + + /* Never get here. */ return 0; } @@ -459,14 +461,6 @@ lkexit(int i) if (sfp != NULL) fclose(sfp); if (tfp != NULL) fclose(tfp); if (dfp != NULL) fclose(dfp); - /*if (dfp != NULL) - FILE *xfp = afile(linkp->f_idp,"cdb",1); - dfp = freopen("temp.cdb","r",dfp); - copyfile(xfp,dfp); - fclose(xfp); - fclose(dfp); - remove("temp.cdb"); - }*/ exit(i); } @@ -603,7 +597,6 @@ link_main() } } - /*)Function VOID map() * * The function map() opens the output map file and calls the various @@ -853,6 +846,7 @@ parse() case 'R': rflag = 1; break; + case 'x': case 'X': xflag = 0; @@ -928,10 +922,10 @@ parse() if ( c == ';') return(0); } else - if (ctype[c] & ILL) { - fprintf(stderr, "Invalid input"); - lkexit(1); - } else { + if (ctype[c] & ILL) { + fprintf(stderr, "Invalid input"); + lkexit(1); + } else { if (linkp == NULL) { linkp = (struct lfile *) new (sizeof (struct lfile)); @@ -1152,13 +1146,11 @@ setgbl() v = expr(0); sp = lkpsym(id, 0); if (sp == NULL) { - fprintf(stderr, - "No definition of symbol %s\n", id); + fprintf(stderr, "No definition of symbol %s\n", id); lkerr++; } else { if (sp->s_flag & S_DEF) { - fprintf(stderr, - "Redefinition of symbol %s\n", id); + fprintf(stderr, "Redefinition of symbol %s\n", id); lkerr++; sp->s_axp = NULL; } @@ -1173,7 +1165,7 @@ setgbl() } } -/*)Function FILE * afile(fn,, ft, wf) +/*)Function FILE * afile(fn, ft, wf) * * char * fn file specification string * char * ft file type string @@ -1213,13 +1205,23 @@ afile(char *fn, char *ft, int wf) { FILE *fp; char fb[PATH_MAX]; - char *omode = (wf ? (wf == 2 ? "a" : "w") : "r"); + char *omode; int i; + switch (wf) { + case 0: omode = "r"; break; + case 1: omode = "w"; break; + case 2: omode = "a"; break; + case 3: omode = "rb"; break; + case 4: omode = "wb"; break; + case 5: omode = "ab"; break; + default: omode = "r"; break; + } + /*Look backward the name path and get rid of the extension, if any*/ i=strlen(fn); - for(; (fn[i]!='.')&&(fn[i]!='\\')&&(fn[i]!='/')&&(i>0); i--); - if( (fn[i]=='.') && strcmp(ft, "lnk") ) + for(; (fn[i]!=FSEPX)&&(fn[i]!=LKDIRSEP)&&(fn[i]!='/')&&(i>0); i--); + if( (fn[i]==FSEPX) && strcmp(ft, "lnk") ) { strncpy(fb, fn, i); fb[i]=0; @@ -1230,18 +1232,19 @@ afile(char *fn, char *ft, int wf) } /*Add the extension*/ - if (fb[i] != '.') + if (fb[i] != FSEPX) { - strcat(fb, "."); - strcat(fb, strlen(ft)?ft:"rel"); + fb[i] = FSEPX; + fb[i+1] = 0; + strcat(fb, strlen(ft)?ft:LKOBJEXT); } fp = fopen(fb, omode); if (fp==NULL) { - if (strcmp(ft,"adb"))/*Do not complaint for optional adb files*/ + if (strcmp(ft,"adb"))/*Do not complain for optional adb files*/ { - fprintf(stderr, "%s: cannot %s.\n", fb, wf?"create":"open"); + fprintf(stderr, "%s: cannot %s.\n", fb, (wf%3)==1?"create":"open"); lkerr++; } } @@ -1433,8 +1436,7 @@ usage() * side effects: * none */ -VOID copyfile (dest,src) -FILE *src,*dest ; +VOID copyfile (FILE *dest, FILE *src) { int ch; diff --git a/device/include/asm/ds390/features.h b/device/include/asm/ds390/features.h index 2d84124b..6d4f4dad 100644 --- a/device/include/asm/ds390/features.h +++ b/device/include/asm/ds390/features.h @@ -19,6 +19,8 @@ #if defined(SDCC_STACK_AUTO) #if defined(SDCC_USE_XSTACK) #define _AUTOMEM __pdata + #elif defined(SDCC_STACK_TENBIT) + #define _AUTOMEM __xdata #else #define _AUTOMEM __idata #endif -- 2.39.5