From 0e7df3f92424f34b25de6615e79b5b5b413a120a Mon Sep 17 00:00:00 2001 From: jtvolpe Date: Tue, 13 Feb 2001 04:04:18 +0000 Subject: [PATCH] - Made DefaultExePath work for VC6 also - 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 | 48 +++++++++++++++++++++++++++++++++--------------- src/SDCCmain.c | 40 +++++++++++++--------------------------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 59ac9a1c..2339f7fe 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -7,25 +7,43 @@ #include #include -#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 diff --git a/src/SDCCmain.c b/src/SDCCmain.c index f575a84e..fa42f4f7 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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); -- 2.39.5