Added support to generate aomf51 file. (Basic Intel support, no Keil
[fw/sdcc] / as / mcs51 / lklex.c
index d7e4271bc94faed6e010008f6aec6a64926e3464..c6f5cd81ddf8244620d5aacec29fa0fcff3be58a 100644 (file)
@@ -23,6 +23,7 @@
  *             char    get()
  *             VOID    getfid()
  *             VOID    getid()
+ *             VOID    getSid()
  *             int     getline()
  *             int     getmap()
  *             char    getnb()
@@ -94,10 +95,68 @@ 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
  *
@@ -105,9 +164,9 @@ char *id;
  *     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.
+ *     characters copied is PATH_MAX. If the input string is larger than
+ *     PATH_MAX characters then the string is truncated, if the input string
+ *     is shorter than PATH_MAX characters then the string is NULL filled.
  *
  *     local variables:
  *             char *  p               pointer to external string buffer
@@ -136,11 +195,11 @@ char *str;
 
        p = str;
        do {
-               if (p < &str[FILSPC-1])
+               if (p < &str[PATH_MAX-1])
                        *p++ = c;
                c = get();
        } while (c && ((ctype[c] != SPACE)||(c == ':')||(c == '\\')));
-       while (p < &str[FILSPC])
+       while (p < &str[PATH_MAX])
                *p++ = 0;
 }
 
@@ -444,13 +503,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);