- Timestamp:
- Jun 8, 2016, 10:36:39 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk/Python/import.c
r391 r779 1303 1303 static struct filedescr fd_package = {"", "", PKG_DIRECTORY}; 1304 1304 char *name; 1305 #if defined(PYOS_OS2)1306 size_t saved_len;1307 size_t saved_namelen;1308 char *saved_buf = NULL;1309 #endif1310 1305 if (p_loader != NULL) 1311 1306 *p_loader = NULL; … … 1514 1509 } 1515 1510 } 1516 #if defined(PYOS_OS2)1517 /* take a snapshot of the module spec for restoration1518 * after the 8 character DLL hackery1519 */1520 saved_buf = strdup(buf);1521 saved_len = len;1522 saved_namelen = namelen;1523 #endif /* PYOS_OS2 */1524 1511 for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { 1525 #if defined(PYOS_OS2) && defined(HAVE_DYNAMIC_LOADING)1526 /* OS/2 limits DLLs to 8 character names (w/o1527 extension)1528 * so if the name is longer than that and its a1529 * dynamically loaded module we're going to try,1530 * truncate the name before trying1531 */1532 if (strlen(subname) > 8) {1533 /* is this an attempt to load a C extension? */1534 const struct filedescr *scan;1535 scan = _PyImport_DynLoadFiletab;1536 while (scan->suffix != NULL) {1537 if (!strcmp(scan->suffix, fdp->suffix))1538 break;1539 else1540 scan++;1541 }1542 if (scan->suffix != NULL) {1543 /* yes, so truncate the name */1544 namelen = 8;1545 len -= strlen(subname) - namelen;1546 buf[len] = '\0';1547 }1548 }1549 #endif /* PYOS_OS2 */1550 1512 strcpy(buf+len, fdp->suffix); 1551 1513 if (Py_VerboseFlag > 1) … … 1563 1525 } 1564 1526 } 1565 #if defined(PYOS_OS2) 1566 /* restore the saved snapshot */ 1567 strcpy(buf, saved_buf); 1568 len = saved_len; 1569 namelen = saved_namelen; 1570 #endif 1571 } 1572 #if defined(PYOS_OS2) 1573 /* don't need/want the module name snapshot anymore */ 1574 if (saved_buf) 1575 { 1576 free(saved_buf); 1577 saved_buf = NULL; 1578 } 1579 #endif 1527 } 1580 1528 Py_XDECREF(copy); 1581 1529 if (fp != NULL) … … 1645 1593 #include <dir.h> 1646 1594 1647 #elif (defined(__MACH__) && defined(__APPLE__) || defined(__ CYGWIN__)) && defined(HAVE_DIRENT_H)1595 #elif (defined(__MACH__) && defined(__APPLE__) || defined(__KLIBC__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H) 1648 1596 #include <sys/types.h> 1649 1597 #include <dirent.h> … … 1705 1653 1706 1654 /* new-fangled macintosh (macosx) or Cygwin */ 1707 #elif (defined(__MACH__) && defined(__APPLE__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H) 1655 /* OS/2 use opendir() because it resolves @unixroot names without resolving symlinks */ 1656 #elif (defined(__MACH__) && defined(__APPLE__) || defined(__KLIBC__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H) 1708 1657 DIR *dirp; 1709 1658 struct dirent *dp; … … 1769 1718 1770 1719 return 0; 1771 1772 /* OS/2 */1773 #elif defined(__KLIBC__)1774 char canon[MAXPATHLEN+1];1775 size_t canonlen;1776 char *p, *p2;1777 1778 if (Py_GETENV("PYTHONCASEOK") != NULL)1779 return 1;1780 1781 /* This resolves case differences and return and native OS/21782 path. Unfortunately, it'll also resolve symbolic links1783 while of course will screw up a bit... */1784 if (!_realrealpath(buf, canon, sizeof(canon)))1785 return 0;1786 canonlen = strlen(canon);1787 if (canonlen < namelen)1788 return 0;1789 p = strrchr(canon, SEP);1790 p2 = strrchr(p ? p : canon, ALTSEP);1791 if (p2)1792 p = p2;1793 1794 return strncmp(p ? p + 1 : canon, name, namelen) == 0;1795 1796 #elif defined(PYOS_OS2)1797 HDIR hdir = 1;1798 ULONG srchcnt = 1;1799 FILEFINDBUF3 ffbuf;1800 APIRET rc;1801 1802 if (Py_GETENV("PYTHONCASEOK") != NULL)1803 return 1;1804 1805 rc = DosFindFirst(buf,1806 &hdir,1807 FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY,1808 &ffbuf, sizeof(ffbuf),1809 &srchcnt,1810 FIL_STANDARD);1811 if (rc != NO_ERROR)1812 return 0;1813 return strncmp(ffbuf.achName, name, namelen) == 0;1814 1720 1815 1721 /* assuming it's a case-sensitive filesystem, so there's nothing to do! */
Note:
See TracChangeset
for help on using the changeset viewer.