- Added some host port constants to SDCCglobl.h
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@614
4a8a32a2-be11-0410-ad9d-
d568d2c75423
#include <setjmp.h>
#include <stdio.h>
#include <setjmp.h>
#include <stdio.h>
-#if defined(_MSC_VER)
-# include "sdcc_vc.h"
-#else
-# include "sdccconf.h"
-#endif // _MSC_VER
+/*
+ * Define host port dependant constants etc.
+ */
+# define DOS_DIR_SEPARATOR_CHAR '\\'
+# define DOS_DIR_SEPARATOR_STRING "\\"
+# define UNIX_DIR_SEPARATOR_CHAR '/'
+# define UNIX_DIR_SEPARATOR_STRING "/"
-#if defined(_MSC_VER)
-# define NATIVE_WIN32 1
-#endif
+#if defined(__BORLANDC__) /* Borland Turbo C/Win32 Host */
-#ifdef __BORLANDC__
-#define NATIVE_WIN32 1
-#endif
+# define NATIVE_WIN32 1
+# define DIR_SEPARATOR_CHAR DOS_DIR_SEPARATOR_CHAR
+# define DIR_SEPARATOR_STRING DOS_DIR_SEPARATOR_STRING
-#ifdef __MINGW32__
-#define NATIVE_WIN32 1
-#endif
+#elif defined(_MSC_VER) /* Miscosoft VC6/Win32 Host */
+
+# define NATIVE_WIN32 1
+# include "sdcc_vc.h"
+# define DIR_SEPARATOR_CHAR DOS_DIR_SEPARATOR_CHAR
+# define DIR_SEPARATOR_STRING DOS_DIR_SEPARATOR_STRING
+
+#elif defined(__MINGW32__) /* MINGW32 DOS Host */
+
+# define NATIVE_WIN32 1
+# define DIR_SEPARATOR_CHAR DOS_DIR_SEPARATOR_CHAR
+# define DIR_SEPARATOR_STRING DOS_DIR_SEPARATOR_STRING
+
+#else /* Assume Un*x style system */
+
+# include "sdccconf.h"
+# define DIR_SEPARATOR_CHAR UNIX_DIR_SEPARATOR_CHAR
+# define DIR_SEPARATOR_STRING UNIX_DIR_SEPARATOR_STRING
+
+#endif // _MSC_VER
+
+#include "SDCCerr.h"
#define SPACE ' '
#define ZERO 0
#define SPACE ' '
#define ZERO 0
#else
#ifdef __DJGPP__
" (DJGPP) \n"
#else
#ifdef __DJGPP__
" (DJGPP) \n"
+#else
+#if defined(_MSC_VER)
+ " (WIN32) \n"
#else
" (UNIX) \n"
#endif
#else
" (UNIX) \n"
#endif
/* my_system - will call a program with arguments */
/*-----------------------------------------------------------------*/
/* my_system - will call a program with arguments */
/*-----------------------------------------------------------------*/
-char *try_dir[] =
-{DefaultExePath, NULL}; // TODO : Fill in some default search list
//char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL};
char *try_dir[] =
{NULL, NULL}; /* First entry may be overwritten, so use two. */
//char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL};
char *try_dir[] =
{NULL, NULL}; /* First entry may be overwritten, so use two. */
#ifdef USE_SYSTEM_SYSTEM_CALLS
int
#ifdef USE_SYSTEM_SYSTEM_CALLS
int
// try to find the command in predefined path's
while (try_dir[i])
{
// try to find the command in predefined path's
while (try_dir[i])
{
- cmdLine = (char *) malloc (strlen (try_dir[i]) + strlen (cmd) + 10);
+ cmdLine = (char *) Safe_malloc (strlen (try_dir[i]) + strlen (cmd) + 10);
strcpy (cmdLine, try_dir[i]); // the path
strcpy (cmdLine, try_dir[i]); // the path
+ strcat (cmdLine, DIR_SEPARATOR_STRING);
strncat (cmdLine, cmd, argsStart); // the command
strncat (cmdLine, cmd, argsStart); // the command
#if NATIVE_WIN32
strcat (cmdLine, ".exe");
#if NATIVE_WIN32
strcat (cmdLine, ".exe");
/* Mung slashes into backslashes to keep WIndoze happy. */
{
char *r = cmdLine;
/* Mung slashes into backslashes to keep WIndoze happy. */
{
char *r = cmdLine;
if (access (cmdLine, X_OK) == 0)
{
// the arguments
if (access (cmdLine, X_OK) == 0)
{
// the arguments
if (port->init)
port->init ();
if (port->init)
port->init ();
-#if defined(_MSC_VER)
-
- {
- int i;
-
// Create a default exe search path from the path to the sdcc command
// Create a default exe search path from the path to the sdcc command
- strcpy (DefaultExePath, argv[0]);
- for (i = strlen (DefaultExePath); i > 0; i--)
- if (DefaultExePath[i] == '\\')
- {
- DefaultExePath[i] = '\0';
- break;
- }
- if (i == 0)
- DefaultExePath[0] = '\0';
- }
-#else
-
- if (strchr(argv[0], '/'))
+ if (strchr(argv[0], DIR_SEPARATOR_CHAR))
{
strcpy(DefaultExePath, argv[0]);
{
strcpy(DefaultExePath, argv[0]);
- *(strrchr(DefaultExePath, '/')) = 0;
+ *(strrchr(DefaultExePath, DIR_SEPARATOR_CHAR)) = 0;
try_dir[0] = DefaultExePath;
}
try_dir[0] = DefaultExePath;
}
setDefaultOptions ();
parseCmdLine (argc, argv);
setDefaultOptions ();
parseCmdLine (argc, argv);