X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=as%2Fmcs51%2Flklex.c;h=7c481300bbd6c595a0f7e1dc4592c82f4b0d0ac3;hb=90bdb43b342189fcb94a398855d43f3f47f96738;hp=7466cabe74ce35f9d70354f49dc529197d4570e7;hpb=3895c1378eea714f02cff7961e6f4ddcae1cfcd2;p=fw%2Fsdcc diff --git a/as/mcs51/lklex.c b/as/mcs51/lklex.c index 7466cabe..7c481300 100644 --- a/as/mcs51/lklex.c +++ b/as/mcs51/lklex.c @@ -11,9 +11,6 @@ #include #include -//#if !defined(_MSC_VER) -//#include -//#endif #include "aslink.h" /*)Module lklex.c @@ -26,7 +23,8 @@ * char get() * VOID getfid() * VOID getid() - * int getline() + * VOID getSid() + * int as_getline() * int getmap() * char getnb() * int more() @@ -97,20 +95,78 @@ char *id; *p++ = 0; } +/*)Function VOID getSid (char *id) + * + * char * id a pointer to a string of + * maximum length NCPS + * + * getSid is derived from getid. It is called from newsym() + * in lksym.c, when an S-record has to be scanned. getSid accepts + * much more characters than getid, which is necessary for SDCC. + * + * The function getSid() scans the current input text line + * from the current position copying the next string + * into the external string buffer (id). The string ends when a space + * character (space, tab, \0) is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * Intervening white space (SPACES and TABS) are skipped. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip the position in the current + * input text line. + */ + +VOID +getSid (id) +char *id; +{ + register int c; + register char *p; + + c = getnb(); + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + c = get(); + } while (c != '\0' && c != ' ' && c != '\t'); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + /*)Function VOID getfid(fid,c) * * char * str a pointer to a string of - * maximum length FILSPC + * maximum length PATH_MAX * int c this is first character to * copy to the string buffer * - * 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 a - * non SPACE type character is found. The maximum number of - * characters copied is FILSPC. If the input string is larger than - * FILSPC characters then the string is truncated, if the input string - * is shorter than FILSPC characters then the string is NULL filled. + * 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 + * copied is PATH_MAX. If the input string is larger than PATH_MAX + * characters then the string is truncated. The string is NULL + * terminated. * * local variables: * char * p pointer to external string buffer @@ -138,13 +194,21 @@ char *str; register char *p; p = str; - do { - if (p < &str[FILSPC-1]) + do + { + if (p < &str[PATH_MAX-1]) *p++ = c; c = get(); - } while (c && ((ctype[c] != SPACE)||(c == ':')||(c == '\\'))); - while (p < &str[FILSPC]) - *p++ = 0; + if (c == ';') + while (c) + c = get(); + } while (c); + /* trim trailing spaces */ + --p; + while (p >= str && ctype[(int)*p] == SPACE) + --p; + /* terminate the string */ + *(++p) = '\0'; } /*)Function char getnb() @@ -361,15 +425,15 @@ getmap(d) return (c); } -/*)Function int getline() +/*)Function int as_getline() * - * The function getline() reads a line of input text from a + * The function as_getline() reads a line of input text from a * .rel source text file, a .lnk command file or from stdin. * Lines of text are processed from a single .lnk file or * multiple .rel files until all files have been read. * The input text line is copied into the global string ib[] * and converted to a NULL terminated string. The function - * getline() returns a (1) after succesfully reading a line + * as_getline() returns a (1) after succesfully reading a line * or a (0) if all files have been read. * This function also opens each input .lst file and output * .rst file as each .rel file is processed. @@ -415,7 +479,7 @@ getmap(d) */ int -getline() +as_getline() { register int ftype; register char *fid; @@ -447,13 +511,14 @@ loop: if (pflag && cfp && cfp->f_type == F_STD) sfp = afile(fid, "rel", 0); /* if a .cdb file exists then copy it over */ if (dflag && sfp && dfp && pass == 0) { - FILE *xfp = afile(fid,"cdb",0); + FILE *xfp = afile(fid,"adb",0); //JCF: Nov 30, 2002 if (xfp) { copyfile(dfp,xfp); fclose(xfp); } } if (uflag && pass != 0) { + SaveLinkedFilePath(fid); //Save the linked path for aomf51 if ((tfp = afile(fid, "lst", 0)) != NULL) { if ((rfp = afile(fid, "rst", 1)) == NULL) { fclose(tfp);