- Timestamp:
- Jul 15, 2007 4:25:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kbuild.c
r961 r1071 140 140 141 141 #endif 142 143 #if !defined(__OS2__) && !defined(WINDOWS32) 144 /* fallback, try use the path to locate the binary. */ 145 if ( rc < 0 146 && access(argv[0], X_OK)) 147 { 148 size_t cchArgv0 = strlen(argv[0]); 149 const char *pszPath = getenv("PATH"); 150 char *pszCopy = xstrdup(pszPath ? pszPath : "."); 151 char *psz = pszCopy; 152 while (*psz) 153 { 154 size_t cch; 155 char *pszEnd = strchr(psz, PATH_SEPARATOR_CHAR); 156 if (!pszEnd) 157 pszEnd = strchr(psz, '\0'); 158 cch = pszEnd - psz; 159 if (cch + cchArgv0 + 2 <= GET_PATH_MAX) 160 { 161 memcpy(szTmp, psz, cch); 162 szTmp[cch] = '/'; 163 memcpy(&szTmp[cch + 1], argv[0], cchArgv0 + 1); 164 if (!access(szTmp, X_OK)) 165 { 166 rc = 0; 167 break; 168 } 169 } 170 171 /* next */ 172 psz = pszEnd; 173 while (*psz == PATH_SEPARATOR_CHAR) 174 psz++; 175 } 176 free(pszCopy); 177 } 178 #endif 179 142 180 if (rc < 0) 143 181 g_pszExeName = argv[0];
Note:
See TracChangeset
for help on using the changeset viewer.