* .version,
[fw/sdcc] / as / mcs51 / asnoice.c
index acf86b46194adb9a44f1c6e8b020cce2bca13723..2220d3a65ed7465e65a532a5d8432ce3521577e6 100644 (file)
@@ -9,18 +9,16 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-//#if !defined(_MSC_VER)
-//#include <alloc.h>
-//#endif
+#include <ctype.h>
 #include "asm.h"
 
-/* Return basic file name without path or extension */
-static char* BaseFileName( int fileNumber );
+/* Return basic file name without path or extension.
+   If spacesToUnderscores != 0 then spaces are converted to underscores */
 
-char* BaseFileName( int fileNumber )
+char* BaseFileName( int fileNumber, int spacesToUnderscores )
 {
        static int prevFile = -1;
-        static char baseName[ FILSPC ];
+        static char baseName[ PATH_MAX ];
 
         char *p1, *p2;
 
@@ -45,6 +43,14 @@ char* BaseFileName( int fileNumber )
                if (p2 != NULL) *p2 = 0;
                /* SD comment this out since not a ANSI Function */
                 /* strupr( baseName ); */
+
+                if (spacesToUnderscores)
+                {
+                  /* Convert spaces to underscores */
+                  for (p1 = baseName; *p1; ++p1)
+                    if (isspace(*p1))
+                      *p1 = '_';
+                }
        }
        return baseName;
 }
@@ -56,7 +62,7 @@ void DefineNoICE_Line()
         struct sym *pSym;
 
        /* symbol is FILE.nnn */
-        sprintf( name, "%s.%u", BaseFileName( cfile ), srcline[ cfile ] );
+        sprintf( name, "%s.%u", BaseFileName( cfile, 0 ), srcline[ cfile ] );
 
         pSym = lookup( name );
         pSym->s_type = S_USER;
@@ -72,7 +78,7 @@ void DefineCDB_Line()
         struct sym *pSym;
 
        /* symbol is FILE.nnn */
-        sprintf( name, "A$%s$%u", BaseFileName( cfile ), srcline[ cfile ] );
+        sprintf( name, "A$%s$%u", BaseFileName( cfile, 1 ), srcline[ cfile ] );
 
         pSym = lookup( name );
         pSym->s_type = S_USER;
@@ -88,7 +94,7 @@ void DefineNoICE_Line()
 {
         static int prevFile = -1;
         static struct area *pPrevArea = NULL;
-        static char baseName[ FILSPC ];
+        static char baseName[ PATH_MAX ];
 
         int j;
         char *p1, *p2;