Changeset 1503 for trunk/src/kmk/kbuild.c
- Timestamp:
- Apr 9, 2008, 1:16:53 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kbuild.c
r1484 r1503 205 205 206 206 /** 207 * Determin the PATH_KBUILDvalue.207 * Determin the KBUILD_PATH value. 208 208 * 209 209 * @returns Pointer to static a buffer containing the value (consider it read-only). 210 210 */ 211 const char *get_ path_kbuild(void)211 const char *get_kbuild_path(void) 212 212 { 213 213 static const char *s_pszPath = NULL; … … 215 215 { 216 216 PATH_VAR(szTmpPath); 217 const char *pszEnvVar = getenv(" PATH_KBUILD");217 const char *pszEnvVar = getenv("KBUILD_PATH"); 218 218 if ( !pszEnvVar 219 219 || !my_abspath(pszEnvVar, szTmpPath)) 220 220 { 221 #ifdef PATH_KBUILD 222 return s_pszPath = PATH_KBUILD; 221 const char *pszEnvVar = getenv("PATH_KBUILD"); 222 if ( !pszEnvVar 223 || !my_abspath(pszEnvVar, szTmpPath)) 224 { 225 #ifdef KBUILD_PATH 226 return s_pszPath = KBUILD_PATH; 223 227 #else 224 /* $(abspath $(PATH_KBUILD_BIN)/../..)*/ 225 size_t cch = strlen(get_path_kbuild_bin()); 226 char *pszTmp2 = alloca(cch + sizeof("/../..")); 227 strcat(strcpy(pszTmp2, get_path_kbuild_bin()), "/../.."); 228 if (!my_abspath(pszTmp2, szTmpPath)) 229 fatal(NILF, _("failed to determin PATH_KBUILD")); 230 #endif 228 /* $(abspath $(KBUILD_BIN_PATH)/../..)*/ 229 size_t cch = strlen(get_kbuild_bin_path()); 230 char *pszTmp2 = alloca(cch + sizeof("/../..")); 231 strcat(strcpy(pszTmp2, get_kbuild_bin_path()), "/../.."); 232 if (!my_abspath(pszTmp2, szTmpPath)) 233 fatal(NILF, _("failed to determin KBUILD_PATH")); 234 #endif 235 } 231 236 } 232 237 s_pszPath = xstrdup(szTmpPath); … … 237 242 238 243 /** 239 * Determin the PATH_KBUILD_BINvalue.244 * Determin the KBUILD_BIN_PATH value. 240 245 * 241 246 * @returns Pointer to static a buffer containing the value (consider it read-only). 242 247 */ 243 const char *get_ path_kbuild_bin(void)248 const char *get_kbuild_bin_path(void) 244 249 { 245 250 static const char *s_pszPath = NULL; … … 247 252 { 248 253 PATH_VAR(szTmpPath); 249 const char *pszEnvVar = getenv("PATH_KBUILD_BIN"); 254 255 const char *pszEnvVar = getenv("KBUILD_BIN_PATH"); 250 256 if ( !pszEnvVar 251 257 || !my_abspath(pszEnvVar, szTmpPath)) 252 258 { 253 #ifdef PATH_KBUILD 254 return s_pszPath = PATH_KBUILD_BIN; 259 const char *pszEnvVar = getenv("PATH_KBUILD_BIN"); 260 if ( !pszEnvVar 261 || !my_abspath(pszEnvVar, szTmpPath)) 262 { 263 #ifdef KBUILD_PATH 264 return s_pszPath = KBUILD_BIN_PATH; 255 265 #else 256 /* $(abspath $(dir $(ARGV0)).) */ 257 size_t cch = strlen(g_pszExeName); 258 char *pszTmp2 = alloca(cch + sizeof(".")); 259 char *pszSep = pszTmp2 + cch - 1; 260 memcpy(pszTmp2, g_pszExeName, cch); 261 #ifdef HAVE_DOS_PATHS 262 while (pszSep >= pszTmp2 && *pszSep != '/' && *pszSep != '\\' && *pszSep != ':') 263 #else 264 while (pszSep >= pszTmp2 && *pszSep != '/') 265 #endif 266 pszSep--; 267 if (pszSep >= pszTmp2) 268 strcpy(pszSep + 1, "."); 269 else 270 strcpy(pszTmp2, "."); 271 272 if (!my_abspath(pszTmp2, szTmpPath)) 273 fatal(NILF, _("failed to determin PATH_KBUILD_BIN (pszTmp2=%s szTmpPath=%s)"), pszTmp2, szTmpPath); 274 #endif 266 /* $(abspath $(dir $(ARGV0)).) */ 267 size_t cch = strlen(g_pszExeName); 268 char *pszTmp2 = alloca(cch + sizeof(".")); 269 char *pszSep = pszTmp2 + cch - 1; 270 memcpy(pszTmp2, g_pszExeName, cch); 271 # ifdef HAVE_DOS_PATHS 272 while (pszSep >= pszTmp2 && *pszSep != '/' && *pszSep != '\\' && *pszSep != ':') 273 # else 274 while (pszSep >= pszTmp2 && *pszSep != '/') 275 # endif 276 pszSep--; 277 if (pszSep >= pszTmp2) 278 strcpy(pszSep + 1, "."); 279 else 280 strcpy(pszTmp2, "."); 281 282 if (!my_abspath(pszTmp2, szTmpPath)) 283 fatal(NILF, _("failed to determin KBUILD_BIN_PATH (pszTmp2=%s szTmpPath=%s)"), pszTmp2, szTmpPath); 284 #endif /* !KBUILD_PATH */ 285 } 275 286 } 276 287 s_pszPath = xstrdup(szTmpPath); … … 289 300 static char *s_pszDefaultShell = NULL; 290 301 if (!s_pszDefaultShell) 291 302 { 292 303 #if defined(__OS2__) || defined(_WIN32) || defined(WINDOWS32) 293 304 static const char s_szShellName[] = "/kmk_ash.exe"; … … 295 306 static const char s_szShellName[] = "/kmk_ash"; 296 307 #endif 297 const char *pszBin = get_ path_kbuild_bin();308 const char *pszBin = get_kbuild_bin_path(); 298 309 size_t cchBin = strlen(pszBin); 299 310 s_pszDefaultShell = xmalloc(cchBin + sizeof(s_szShellName)); 300 311 memcpy(s_pszDefaultShell, pszBin, cchBin); 301 312 memcpy(&s_pszDefaultShell[cchBin], s_szShellName, sizeof(s_szShellName)); 302 313 } 303 314 return s_pszDefaultShell; 304 315 }
Note:
See TracChangeset
for help on using the changeset viewer.