#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;
/* Name starts after any colon or backslash (DOS) */
p2 = strrchr( p1, '\\' );
+ if (p2 == NULL) p2 = strrchr( p1, '/' );
if (p2 == NULL) p2 = strrchr( p1, ':' );
if (p2 == NULL) p2 = p1-1;
strcpy( baseName, p2+1 );
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;
}
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;
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;
{
static int prevFile = -1;
static struct area *pPrevArea = NULL;
- static char baseName[ FILSPC ];
+ static char baseName[ PATH_MAX ];
int j;
char *p1, *p2;