- Made DefaultExePath work for VC6 also
authorjtvolpe <jtvolpe@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 13 Feb 2001 04:04:18 +0000 (04:04 +0000)
committerjtvolpe <jtvolpe@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 13 Feb 2001 04:04:18 +0000 (04:04 +0000)
- 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

src/SDCCglobl.h
src/SDCCmain.c

index 59ac9a1cf7aea5e1515ab785cfa47a1ac83d970d..2339f7fef1d4e12274b1f4dc4f2385dc57adc89c 100644 (file)
@@ -7,25 +7,43 @@
 #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.
+ */
 
-#include "SDCCerr.h"
+# 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
index f575a84e1da3f8c76c1770a2c0499f32f6d325f1..fa42f4f728a888f2b81211408a0f86e34fd12070 100644 (file)
@@ -362,9 +362,13 @@ printVersionInfo ()
 #else
 #ifdef __DJGPP__
           " (DJGPP) \n"
+#else
+#if defined(_MSC_VER)
+          " (WIN32) \n"
 #else
           " (UNIX) \n"
 #endif
+#endif
 #endif
 
           ,VersionString
@@ -1260,18 +1264,13 @@ parseCmdLine (int argc, char **argv)
 /* my_system - will call a program with arguments                  */
 /*-----------------------------------------------------------------*/
 
-#if defined(_MSC_VER)
 
-char *try_dir[] =
-{DefaultExePath, NULL};                // TODO : Fill in some default search list
 
-#else
 
 //char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL};
 char *try_dir[] =
 {NULL, NULL}; /* First entry may be overwritten, so use two. */
 
-#endif
 
 #ifdef USE_SYSTEM_SYSTEM_CALLS
 int 
@@ -1285,13 +1284,16 @@ my_system (const char *cmd)
   // 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
 
-      strcat (cmdLine, "/");
+      strcat (cmdLine, DIR_SEPARATOR_STRING);
       strncat (cmdLine, cmd, argsStart);       // the command
+
 #if NATIVE_WIN32
       strcat (cmdLine, ".exe");
+
+#if 0
       /* Mung slashes into backslashes to keep WIndoze happy. */
       {
        char *r = cmdLine;
@@ -1305,6 +1307,8 @@ my_system (const char *cmd)
          }
       }
 #endif
+#endif
+
       if (access (cmdLine, X_OK) == 0)
        {
          // the arguments
@@ -1723,35 +1727,17 @@ main (int argc, char **argv, char **envp)
   if (port->init)
     port->init ();
 
-#if defined(_MSC_VER)
-
-  {
-    int i;
-
     // 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]);
-      *(strrchr(DefaultExePath, '/')) = 0;
+      *(strrchr(DefaultExePath, DIR_SEPARATOR_CHAR)) = 0;
       try_dir[0] = DefaultExePath;
   }
 
-#endif
 
   setDefaultOptions ();
   parseCmdLine (argc, argv);