Skip to content

Commit dcfe615

Browse files
Drop gotlandmark().
1 parent 8876b27 commit dcfe615

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

PC/getpathp.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -270,32 +270,24 @@ canonicalize(wchar_t *buffer, const wchar_t *path)
270270
}
271271

272272

273-
/* gotlandmark only called by search_for_prefix, which ensures
274-
'prefix' is null terminated in bounds. join() ensures
275-
'landmark' can not overflow prefix if too long. */
273+
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
274+
assumption provided by only caller, calculate_path() */
276275
static int
277-
gotlandmark(const wchar_t *prefix)
276+
search_for_prefix(wchar_t *prefix, const wchar_t *argv0_path)
278277
{
279278
wchar_t filename[MAXPATHLEN+1];
280279
memset(filename, 0, sizeof(filename));
281-
wcscpy_s(filename, Py_ARRAY_LENGTH(filename), prefix);
280+
/* Search from argv0_path, until LANDMARK is found.
281+
We guarantee 'prefix' is null terminated in bounds. */
282+
wcscpy_s(prefix, MAXPATHLEN+1, argv0_path);
283+
do {
284+
wcscpy_s(filename, Py_ARRAY_LENGTH(filename), prefix);
282285
#ifndef LANDMARK
283286
# define LANDMARK L"lib\\os.py"
284287
#endif
285-
join(filename, LANDMARK);
286-
return ismodule(filename);
287-
}
288-
289-
290-
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
291-
assumption provided by only caller, calculate_path() */
292-
static int
293-
search_for_prefix(wchar_t *prefix, const wchar_t *argv0_path)
294-
{
295-
/* Search from argv0_path, until landmark is found */
296-
wcscpy_s(prefix, MAXPATHLEN + 1, argv0_path);
297-
do {
298-
if (gotlandmark(prefix)) {
288+
/* join() ensures 'landmark' can not overflow prefix if too long. */
289+
join(filename, LANDMARK);
290+
if (ismodule(filename)) {
299291
return 1;
300292
}
301293
reduce(prefix);

0 commit comments

Comments
 (0)