Message412894
The venv launcher can quote the executable path either always or only when it contains spaces. The following is a suggestion for implementing the latter.
Before allocating `executable`, use memchr() (include <memory.h>) to search the UTF-8 source for a space. If found, increment the character count by two. After allocating `executable`, add the initial quote character, and increment the pointer.
BOOL add_quotes = FALSE;
if (memchr(start, ' ', (size_t)len) != NULL) {
add_quotes = TRUE;
cch += 2;
}
executable = (wchar_t *)malloc(cch * sizeof(wchar_t));
if (executable == NULL) {
error(RC_NO_MEMORY, L"A memory allocation failed");
}
if (add_quotes) {
*executable++ = L'\"';
}
Later, after checking the existence via GetFileAttributesW(), add the trailing quote and null, and decrement the pointer:
if (GetFileAttributesW(executable) == INVALID_FILE_ATTRIBUTES) {
error(RC_NO_PYTHON, L"No Python at '%ls'", executable);
}
if (add_quotes) {
size_t n = wcslen(executable);
executable[n] = L'\"';
executable[n + 1] = L'\0';
executable--;
} |
|
Date |
User |
Action |
Args |
2022-02-09 06:28:54 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower, hokiedsp |
2022-02-09 06:28:54 | eryksun | set | messageid: <1644388134.4.0.337532353418.issue46686@roundup.psfhosted.org> |
2022-02-09 06:28:54 | eryksun | link | issue46686 messages |
2022-02-09 06:28:53 | eryksun | create | |
|