Changeset 927 in kBuild for trunk/src/gmakenew
- Timestamp:
- May 25, 2007 9:30:31 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmakenew/kbuild.c
r917 r927 57 57 /** The argv[0] passed to main. */ 58 58 static const char *g_argv0 = ""; 59 /** The initial working directory. */ 60 static const char *g_pszInitialCwd = "."; 59 61 60 62 … … 67 69 void init_kbuild(int argc, char **argv) 68 70 { 71 PATH_VAR(szCwd); 72 69 73 g_argv0 = argv[0]; 74 #ifdef WINDOWS32 75 if (getcwd_fs(szCwd, GET_PATH_MAX) != 0) 76 #else 77 if (getcwd(szCwd, GET_PATH_MAX) != 0) 78 #endif 79 g_pszInitialCwd = xstrdup(szCwd); 80 else 81 fatal(NILF, _("getcwd failed")); 82 } 83 84 85 /** 86 * Wrapper that ensures correct starting_directory. 87 */ 88 static char *my_abspath(const char *pszIn, char *pszOut) 89 { 90 char *pszSaved, *pszRet; 91 92 pszSaved = starting_directory; 93 starting_directory = g_pszInitialCwd; 94 pszRet = abspath(pszIn, pszOut); 95 starting_directory = pszSaved; 96 97 return pszRet; 70 98 } 71 99 … … 84 112 const char *pszEnvVar = getenv("PATH_KBUILD"); 85 113 if ( !pszEnvVar 86 || ! abspath(pszEnvVar, szTmpPath))114 || !my_abspath(pszEnvVar, szTmpPath)) 87 115 { 88 116 #ifdef PATH_KBUILD … … 93 121 char *pszTmp2 = alloca(cch + sizeof("/../..")); 94 122 strcat(strcpy(pszTmp2, get_path_kbuild_bin()), "/../.."); 95 if (! abspath(pszTmp2, szTmpPath))123 if (!my_abspath(pszTmp2, szTmpPath)) 96 124 fatal(NILF, _("failed to determin PATH_KBUILD")); 97 125 #endif … … 116 144 const char *pszEnvVar = getenv("PATH_KBUILD_BIN"); 117 145 if ( !pszEnvVar 118 || ! abspath(pszEnvVar, szTmpPath))146 || !my_abspath(pszEnvVar, szTmpPath)) 119 147 { 120 148 #ifdef PATH_KBUILD 121 149 return s_pszPath = PATH_KBUILD_BIN; 122 150 #else 123 /* $(abspath $( ARGV0)/../../..) - the filename shouldn't cause trouble...*/151 /* $(abspath $(dir $(ARGV0)).) */ 124 152 size_t cch = strlen(g_argv0); 125 char *pszTmp2 = alloca(cch + sizeof("/../../..")); 126 strcat(strcpy(pszTmp2, g_argv0), "/../../.."); 127 if (!abspath(pszTmp2, szTmpPath)) 128 fatal(NILF, _("failed to determin PATH_KBUILD_BIN")); 153 char *pszTmp2 = alloca(cch + sizeof(".")); 154 char *pszSep = pszTmp2 + cch - 1; 155 memcpy(pszTmp2, g_argv0, cch); 156 #ifdef HAVE_DOS_PATHS 157 while (pszSep >= pszTmp2 && *pszSep != '/' && *pszSep != '\\' && pszSep != ':') 158 #else 159 while (pszSep >= pszTmp2 && *pszSep != '/') 160 #endif 161 pszSep--; 162 if (pszSep >= pszTmp2) 163 strcpy(pszSep + 1, "."); 164 else 165 strcpy(pszTmp2, "."); 166 167 if (!my_abspath(pszTmp2, szTmpPath)) 168 fatal(NILF, _("failed to determin PATH_KBUILD_BIN (pszTmp2=%s szTmpPath=%s)"), pszTmp2, szTmpPath); 129 169 #endif 130 170 }
Note:
See TracChangeset
for help on using the changeset viewer.