Ignore:
Timestamp:
May 21, 2007, 2:27:53 AM (18 years ago)
Author:
bird
Message:

In progress...

Location:
trunk/essentials/dev-lang/python/Python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/essentials/dev-lang/python/Python/dynload_shlib.c

    r3225 r3364  
    2121#else
    2222#if defined(PYOS_OS2) && defined(PYCC_GCC)
     23#ifdef __KLIBC__
     24#error "kLIBC has dlfcn.h and shouldn't get here!"
     25#endif
    2326#include "dlfcn.h"
    2427#endif
    2528#endif
    2629
    27 #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)
     30#if ((defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)) \
     31    || (defined(__OS2__) && defined(__KLIBC__))
    2832#define LEAD_UNDERSCORE "_"
    2933#else
     
    3741        {"module.dll", "rb", C_EXTENSION},
    3842#else
    39 #if defined(PYOS_OS2) && defined(PYCC_GCC)
     43#if (defined(PYOS_OS2) && defined(PYCC_GCC)) || (defined(__OS2__) && defined(__KLIBC__))
    4044        {".pyd", "rb", C_EXTENSION},
    4145        {".dll", "rb", C_EXTENSION},
     
    8286        }
    8387
    84         PyOS_snprintf(funcname, sizeof(funcname), 
     88        PyOS_snprintf(funcname, sizeof(funcname),
    8589                      LEAD_UNDERSCORE "init%.200s", shortname);
    8690
     
    114118
    115119        if (Py_VerboseFlag)
    116                 PySys_WriteStderr("dlopen(\"%s\", %x);\n", pathname, 
     120                PySys_WriteStderr("dlopen(\"%s\", %x);\n", pathname,
    117121                                  dlopenflags);
    118122
     
    123127        /* As C module use only one name space this is probably not a */
    124128        /* important limitation */
    125         PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s", 
     129        PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s",
    126130                      shortname);
    127131        pathname = pathbuf;
  • trunk/essentials/dev-lang/python/Python/import.c

    r3225 r3364  
    14751475#include <dirent.h>
    14761476
     1477#elif defined(__KLIBC__)
     1478#include <stdlib.h>
     1479
    14771480#elif defined(PYOS_OS2)
    14781481#define INCL_DOS
     
    15941597
    15951598/* OS/2 */
     1599#elif defined(__KLIBC__)
     1600        char canon[MAXPATHLEN+1];
     1601        size_t canonlen;
     1602        char *p, *p2;
     1603
     1604        if (Py_GETENV("PYTHONCASEOK") != NULL)
     1605                return 1;
     1606
     1607        /* This resolves case differences and return and native OS/2
     1608           path. Unfortunately, it'll also resolve symbolic links
     1609           while of course will screw up a bit... */
     1610        if (!_realrealpath(buf, canon, sizeof(canon)))
     1611                return 0;
     1612        canonlen = strlen(canon);
     1613        if (canonlen < namelen)
     1614                return 0;
     1615        p = strrchr(canon, SEP);
     1616        p2 = strrchr(p ? p : canon, ALTSEP);
     1617        if (p2)
     1618                p = p2;
     1619
     1620        return strncmp(p ? p + 1 : canon, name, namelen) == 0;
     1621
    15961622#elif defined(PYOS_OS2)
    15971623        HDIR hdir = 1;
  • trunk/essentials/dev-lang/python/Python/sysmodule.c

    r3225 r3364  
    13191319                        /* It's a symlink */
    13201320                        link[nr] = '\0';
    1321                         if (link[0] == SEP)
     1321                        if (IS_ABSPATH(link))
    13221322                                argv0 = link; /* Link to absolute path */
    1323                         else if (strchr(link, SEP) == NULL)
     1323                        else if (!HAS_ANYSEP(link))
    13241324                                ; /* Link without path */
    13251325                        else {
    13261326                                /* Must join(dirname(argv0), link) */
    13271327                                char *q = strrchr(argv0, SEP);
     1328#ifdef ALTSEP
     1329                                char *q2 = strrchr(q ? q : argv0, ALTSEP);
     1330                                if (q2)
     1331                                        q = q2;
     1332#endif
     1333#ifdef DRVSEP
     1334                                if (!q && HAS_DRV(argv0))
     1335                                        q = strchr(argv0, DRVSEP);
     1336#endif
     1337
    13281338                                if (q == NULL)
    13291339                                        argv0 = link; /* argv0 without path */
     
    13311341                                        /* Must make a copy */
    13321342                                        strcpy(argv0copy, argv0);
    1333                                         q = strrchr(argv0copy, SEP);
     1343                                        q = &argv0copy[q - argv0];
    13341344                                        strcpy(q+1, link);
    13351345                                        argv0 = argv0copy;
     
    13691379#endif
    13701380                        p = strrchr(argv0, SEP);
     1381#ifdef ALTSEP
     1382                        {
     1383                                char *p2 = strrchr(p ? p : argv0, ALTSEP);
     1384                                if (p2 != NULL)
     1385                                        p = p2;
     1386                        }
     1387#endif
     1388#ifdef DRVSEP
     1389                        if (p == NULL && HAS_DRV(argv0))
     1390                                p = strchr(argv0, DRVSEP);
     1391#endif
    13711392                }
    13721393                if (p != NULL) {
  • trunk/essentials/dev-lang/python/Python/traceback.c

    r3225 r3364  
    140140                PyObject *path;
    141141                char *tail = strrchr(filename, SEP);
     142#ifdef ALTSEP
     143                char *tail2 = strrchr(filename, ALTSEP);
     144                if (!tail || tail2 > tail)
     145                        tail = tail2;
     146#endif
     147#ifdef DRVSEP
     148                if (!tail && HAS_DRV(filename))
     149                        tail = strchr(filename, DRVSEP);
     150#endif
    142151                if (tail == NULL)
    143152                        tail = filename;
     
    164173                                        if (strlen(namebuf) != len)
    165174                                                continue; /* v contains '\0' */
    166                                         if (len > 0 && namebuf[len-1] != SEP)
     175                                        if (len > 0 && IS_SEP(namebuf[len-1]))
    167176                                                namebuf[len++] = SEP;
    168177                                        strcpy(namebuf+len, tail);
Note: See TracChangeset for help on using the changeset viewer.