• Home
  • Raw
  • Download

Lines Matching +full:bom +full:- +full:path

2  * Copyright (C) 2011-2013 Vinay Sajip.
38 * which builds the setuptools-style launcher.
45 * one-level-higher pyvenv.cfg, and uses its "home" property to locate and
53 /* Just for now - static definition */
101 _snwprintf_s(&message[len], MSGSIZE - len, _TRUNCATE, L": %ls", in error()
121 /* This is not thread-safe, just like getenv */ in get_env()
217 find_existing_python(const wchar_t * path) in find_existing_python() argument
224 if (_wcsicmp(path, ip->executable) == 0) { in find_existing_python()
240 if (bits == ip->bits && _wcsicmp(version, ip->version) == 0) { in find_existing_python2()
283 wcsncpy_s(ip->version, MAX_VERSION_SIZE, ip_version, in _locate_pythons_for_key()
284 MAX_VERSION_SIZE-1); in _locate_pythons_for_key()
289 check = wcsrchr(ip->version, L'-'); in _locate_pythons_for_key()
290 if (check && !wcscmp(check, L"-32")) { in _locate_pythons_for_key()
302 data_size = sizeof(ip->executable) - 1; in _locate_pythons_for_key()
306 (LPBYTE)ip->executable, &data_size); in _locate_pythons_for_key()
312 data_size = sizeof(ip->executable) - 1; in _locate_pythons_for_key()
314 (LPBYTE)ip->executable, &data_size); in _locate_pythons_for_key()
327 data_size = data_size / sizeof(wchar_t) - 1; /* for NUL */ in _locate_pythons_for_key()
328 if (ip->executable[data_size - 1] == L'\\') in _locate_pythons_for_key()
329 --data_size; /* reg value ended in a backslash */ in _locate_pythons_for_key()
330 /* ip->executable is data_size long */ in _locate_pythons_for_key()
334 _snwprintf_s(&ip->executable[data_size], in _locate_pythons_for_key()
335 MAX_PATH - data_size, in _locate_pythons_for_key()
336 MAX_PATH - data_size, in _locate_pythons_for_key()
339 attrs = GetFileAttributesW(ip->executable); in _locate_pythons_for_key()
343 ip->executable, message); in _locate_pythons_for_key()
347 ip->executable); in _locate_pythons_for_key()
349 else if (find_existing_python(ip->executable)) { in _locate_pythons_for_key()
351 ip->executable); in _locate_pythons_for_key()
356 ip->bits = bits; in _locate_pythons_for_key()
358 ok = GetBinaryTypeW(ip->executable, &attrs); in _locate_pythons_for_key()
361 ip->executable); in _locate_pythons_for_key()
365 ip->bits = 64; in _locate_pythons_for_key()
367 ip->bits = 32; in _locate_pythons_for_key()
369 ip->bits = 0; in _locate_pythons_for_key()
372 if (ip->bits == 0) { in _locate_pythons_for_key()
375 ip->executable, attrs); in _locate_pythons_for_key()
381 const wchar_t *name = wcsrchr(ip->executable, L'\\'); in _locate_pythons_for_key()
383 wcscpy_s(ip->exe_display, MAX_PATH, name+1); in _locate_pythons_for_key()
386 if (wcschr(ip->executable, L' ') != NULL) { in _locate_pythons_for_key()
389 if (!ip->exe_display[0]) { in _locate_pythons_for_key()
390 wcscpy_s(ip->exe_display, MAX_PATH, ip->executable); in _locate_pythons_for_key()
392 n = wcslen(ip->executable); in _locate_pythons_for_key()
393 memmove(&ip->executable[1], in _locate_pythons_for_key()
394 ip->executable, n * sizeof(wchar_t)); in _locate_pythons_for_key()
395 ip->executable[0] = L'\"'; in _locate_pythons_for_key()
396 ip->executable[n + 1] = L'\"'; in _locate_pythons_for_key()
397 ip->executable[n + 2] = L'\0'; in _locate_pythons_for_key()
401 ip->executable, ip->bits); in _locate_pythons_for_key()
402 if (find_existing_python2(ip->bits, ip->version)) { in _locate_pythons_for_key()
403 debug(L"locate_pythons_for_key: %ls-%i: already \ in _locate_pythons_for_key()
404 found\n", ip->version, ip->bits); in _locate_pythons_for_key()
429 ip2->version, -1, ip1->version, -1); in compare_pythons()
435 return -1; in compare_pythons()
437 return ip2->bits - ip1->bits; /* 64 before 32 */ in compare_pythons()
492 wcscpy_s(ip->executable, MAX_PATH, venv_python); in locate_venv_python()
493 ip->bits = 0; in locate_venv_python()
494 wcscpy_s(ip->version, MAX_VERSION_SIZE, L"venv"); in locate_venv_python()
520 /* Store-installed Python is lowest priority */ in locate_all_pythons()
535 if (wcsstr(wanted_ver, L"-32")) { in find_python_by_version()
537 wlen -= wcslen(L"-32"); in find_python_by_version()
539 else if (wcsstr(wanted_ver, L"-64")) { /* Added option to select 64 bit explicitly */ in find_python_by_version()
541 wlen -= wcslen(L"-64"); in find_python_by_version()
544 n = wcslen(ip->version); in find_python_by_version()
556 if ((wcsncmp(ip->version, wanted_ver, n) == 0) && in find_python_by_version()
558 ((bits == 0) || (ip->bits == bits))) { in find_python_by_version()
624 sizeof(wchar_t) - 2]; in locate_python()
642 debug(L"'%ls'\n", result->executable); in locate_python()
655 /* Not found a value yet - try by major version. in locate_python()
669 result->version, result->executable); in locate_python()
683 #define SCRIPT_SUFFIX L"-script.pyw"
685 #define SCRIPT_SUFFIX L"-script.py"
711 wcsncpy_s(p, MAX_PATH - (p - wrapped_script_path) + 1, SCRIPT_SUFFIX, _TRUNCATE); in locate_wrapped_script()
714 debug(L"File '%ls' non-existent\n", wrapped_script_path); in locate_wrapped_script()
769 of seconds, or until the app does something UI-ish (eg, creating a in run_child()
850 child_command_size - 1, L"%ls %ls", in invoke_child()
854 child_command_size - 1, L"%ls %ls %ls", in invoke_child()
910 if (p[n - 1] == L' ') /* No empty strings in table, so n > 1 */ in skip_prefix()
943 /* No extension - search using registered extensions. */ in find_on_path()
970 if (_wcsicmp(cp->key, name) == 0) { in find_command()
985 wcsncpy_s(cp->key, MAX_PATH, name, _TRUNCATE); in update_command()
986 wcsncpy_s(cp->value, MSGSIZE, cmdline, _TRUNCATE); in update_command()
1014 if (read == MSGSIZE - 1) { in read_config_file()
1021 if (read == MSGSIZE - 1) { in read_config_file()
1054 wchar_t * endp = shebang_line + nchars - 1; in parse_shebang()
1066 for (vpp = builtin_virtual_paths; vpp->shebang; ++vpp) { in parse_shebang()
1067 plen = wcslen(vpp->shebang); in parse_shebang()
1068 if (wcsncmp(shebang_line, vpp->shebang, plen) == 0) { in parse_shebang()
1070 *search = vpp->search; in parse_shebang()
1078 if (vpp->shebang == NULL) { in parse_shebang()
1080 * Not found in builtins - look in customized commands. in parse_shebang()
1101 *command = cp->value; in parse_shebang()
1108 --endp; in parse_shebang()
1126 } BOM; typedef
1129 * Strictly, we don't need to handle UTF-16 and UTF-32, since Python itself
1130 * doesn't. Never mind, one day it might - there's no harm leaving it in.
1132 static BOM BOMs[] = {
1133 { 3, { 0xEF, 0xBB, 0xBF }, CP_UTF8 }, /* UTF-8 - keep first */
1134 /* Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix
1135 * of UTF-32LE BOM. */
1136 { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */
1137 { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */
1138 { 2, { 0xFF, 0xFE }, CP_UTF16LE }, /* UTF-16LE */
1139 { 2, { 0xFE, 0xFF }, CP_UTF16BE }, /* UTF-16BE */
1143 static BOM *
1147 * Look for a BOM in the input and return a pointer to the in find_BOM()
1150 BOM * result = NULL; in find_BOM()
1151 BOM *bom; in find_BOM() local
1153 for (bom = BOMs; bom->length; bom++) { in find_BOM()
1154 if (strncmp(bom->sequence, buffer, bom->length) == 0) { in find_BOM()
1155 result = bom; in find_BOM()
1163 find_terminator(char * buffer, int len, BOM *bom) in find_terminator() argument
1183 cp = bom->code_page; in find_terminator()
1186 /* no adjustment needed for UTF-8 or big endian */ in find_terminator()
1208 2.7-32 in validate_version()
1211 3-32 in validate_version()
1212 3.6-64 in validate_version()
1213 3-64 in validate_version()
1226 if (result && (*p == L'-')) { /* Allow - for Bits Separator */ in validate_version()
1283 for (mp = magic_values; mp->min; mp++) { in find_by_magic()
1284 if ((magic >= mp->min) && (magic <= mp->max)) { in find_by_magic()
1285 result = locate_python(mp->version, FALSE); in find_by_magic()
1311 BOM* bom; in maybe_handle_shebang() local
1331 ip->version); in maybe_handle_shebang()
1332 invoke_child(ip->executable, NULL, cmdline); in maybe_handle_shebang()
1335 /* Look for BOM */ in maybe_handle_shebang()
1336 bom = find_BOM(buffer); in maybe_handle_shebang()
1337 if (bom == NULL) { in maybe_handle_shebang()
1339 debug(L"maybe_handle_shebang: BOM not found, using UTF-8\n"); in maybe_handle_shebang()
1340 bom = BOMs; /* points to UTF-8 entry - the default */ in maybe_handle_shebang()
1343 debug(L"maybe_handle_shebang: BOM found, code page %u\n", in maybe_handle_shebang()
1344 bom->code_page); in maybe_handle_shebang()
1345 start = &buffer[bom->length]; in maybe_handle_shebang()
1347 p = find_terminator(start, BUFSIZE, bom); in maybe_handle_shebang()
1357 * Found line terminator - parse the shebang. in maybe_handle_shebang()
1359 * Strictly, we don't need to handle UTF-16 anf UTF-32, in maybe_handle_shebang()
1363 header_len = (int) (p - start); in maybe_handle_shebang()
1364 switch(bom->code_page) { in maybe_handle_shebang()
1366 nchars = MultiByteToWideChar(bom->code_page, in maybe_handle_shebang()
1373 debug(L"maybe_handle_shebang: UTF-16BE, but an odd number \ in maybe_handle_shebang()
1375 /* nchars = 0; Not needed - initialised to 0. */ in maybe_handle_shebang()
1378 for (i = header_len; i > 0; i -= 2) { in maybe_handle_shebang()
1379 shebang_alias[i - 1] = start[i - 2]; in maybe_handle_shebang()
1380 shebang_alias[i - 2] = start[i - 1]; in maybe_handle_shebang()
1387 debug(L"UTF-16LE, but an odd number of bytes: %d\n", in maybe_handle_shebang()
1389 /* nchars = 0; Not needed - initialised to 0. */ in maybe_handle_shebang()
1399 debug(L"UTF-32BE, but not divisible by 4: %d\n", in maybe_handle_shebang()
1401 /* nchars = 0; Not needed - initialised to 0. */ in maybe_handle_shebang()
1404 for (i = header_len, j = header_len / 2; i > 0; i -= 4, in maybe_handle_shebang()
1405 j -= 2) { in maybe_handle_shebang()
1406 shebang_alias[j - 1] = start[i - 2]; in maybe_handle_shebang()
1407 shebang_alias[j - 2] = start[i - 1]; in maybe_handle_shebang()
1414 debug(L"UTF-32LE, but not divisible by 4: %d\n", in maybe_handle_shebang()
1416 /* nchars = 0; Not needed - initialised to 0. */ in maybe_handle_shebang()
1419 for (i = header_len, j = header_len / 2; i > 0; i -= 4, in maybe_handle_shebang()
1420 j -= 2) { in maybe_handle_shebang()
1421 shebang_alias[j - 1] = start[i - 3]; in maybe_handle_shebang()
1422 shebang_alias[j - 2] = start[i - 4]; in maybe_handle_shebang()
1429 shebang_line[--nchars] = L'\0'; in maybe_handle_shebang()
1445 path '%ls'", command); in maybe_handle_shebang()
1448 /* Command is eligible for path search, and there in maybe_handle_shebang()
1451 debug(L"searching PATH for python executable\n"); in maybe_handle_shebang()
1453 debug(L"Python on path: %ls\n", cmd ? cmd->value : L"<not found>"); in maybe_handle_shebang()
1455 debug(L"located python on PATH: %ls\n", cmd->value); in maybe_handle_shebang()
1456 invoke_child(cmd->value, suffix, cmdline); in maybe_handle_shebang()
1460 /* FALL THROUGH: No python found on PATH, so fall in maybe_handle_shebang()
1476 invoke_child(ip->executable, suffix, cmdline); in maybe_handle_shebang()
1546 %ls [launcher-args] [python-args] [script [script-args]]\n\n", argv[0]); in show_help_text()
1549 -2 : Launch the latest Python 2.x version\n\ in show_help_text()
1550 -3 : Launch the latest Python 3.x version\n\ in show_help_text()
1551 -X.Y : Launch the specified Python version\n", stdout); in show_help_text()
1555 -X.Y-32: Launch the specified 32bit Python version\n\ in show_help_text()
1556 -X-32 : Launch the latest 32bit Python X version\n\ in show_help_text()
1557 -X.Y-64: Launch the specified 64bit Python version\n\ in show_help_text()
1558 -X-64 : Launch the latest 64bit Python X version", stdout); in show_help_text()
1560 fputws(L"\n-0 --list : List the available pythons", stdout); in show_help_text()
1561 fputws(L"\n-0p --list-paths : List with paths", stdout); in show_help_text()
1567 … fputws(L"\n With -2 or -3 flag a matching PY_PYTHON2 or PY_PYTHON3 Environment variable", stdout); in show_help_text()
1579 * Display options -0 in show_python_list()
1586 wchar_t *ver_fmt = L"-%ls-%d"; in show_python_list()
1596 if (!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")) in show_python_list()
1597 fmt = L"\n %-15ls%ls"; /* include path */ in show_python_list()
1608 if (wcscmp(ip->version, L"venv") == 0) { in show_python_list()
1612 swprintf_s(version, BUFSIZ, ver_fmt, ip->version, ip->bits); in show_python_list()
1615 if (ip->exe_display[0]) { in show_python_list()
1616 fwprintf(stdout, fmt, version, ip->exe_display); in show_python_list()
1619 fwprintf(stdout, fmt, version, ip->executable); in show_python_list()
1644 for (int i = 4; i > 0 && *s; --i, ++s); in find_home_value()
1660 *length = (DWORD)((ptrdiff_t)nl - (ptrdiff_t)s); in find_home_value()
1762 /* Get the local appdata folder (non-roaming) */ in process()
1773 debug(L"File '%ls' non-existent\n", appdata_ini_path); in process()
1799 version_high = file_info->dwFileVersionMS; in process()
1800 version_low = file_info->dwFileVersionLS; in process()
1822 debug(L"File '%ls' non-existent\n", venv_cfg_path); in process()
1830 debug(L"File '%ls' non-existent\n", venv_cfg_path); in process()
1853 debug(L"File '%ls' non-existent\n", launcher_ini_path); in process()
1865 /* bpo-35811: The __PYVENV_LAUNCHER__ variable is used to in process()
1866 * override sys.executable and locate the original prefix path. in process()
1867 * However, if it is silently inherited by a non-venv Python in process()
1877 * There should therefore be a Python script named <exename>-script.py in in process()
1882 /* Get the wrapped script name - if the script is not present, this will in process()
1902 /* Returns if no shebang line - pass to default processing */ in process()
1927 error(0, L"Cannot determine memory for home path"); in process()
1934 /* start with a quote - we'll skip this ahead, but want it for the final string */ in process()
1936 cch_actual = MultiByteToWideChar(CP_UTF8, 0, start, len, &executable[1], cch - 1); in process()
1938 error(RC_BAD_VENV_CFG, L"Cannot decode home path in '%ls'", in process()
1943 if (executable[cch_actual - 1] != L'\\') { in process()
1947 if (wcscat_s(&executable[1], cch - 1, PYTHON_EXECUTABLE)) { in process()
1948 error(RC_BAD_VENV_CFG, L"Cannot create executable path from '%ls'", in process()
1957 /* smuggle our original path through */ in process()
1971 (!wcsncmp(p, L"-0", wcslen(L"-0")) || in process()
1972 !wcsncmp(p, L"--list", wcslen(L"--list")))) in process()
1977 valid = valid && (*p == L'-') && validate_version(&p[1]); in process()
1986 installed, use -0 for available pythons", &p[1]); in process()
1988 executable = ip->executable; in process()
1994 if (*argv[index] != L'-') in process()
2006 if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) in process()
2009 (!_wcsicmp(p, L"-0") || !_wcsicmp(p, L"--list") || in process()
2010 !_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths"))) in process()
2019 executable = ip->executable; in process()