Changeset 3364 for trunk


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

In progress...

Location:
trunk/essentials/dev-lang/python
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/essentials/dev-lang/python/Include/osdefs.h

    r3225 r3364  
    2020#define MAXPATHLEN 256
    2121#endif
     22#define DRVSEP ':' /* (bird) */
    2223#define DELIM ';'
    2324#endif
     
    3435#ifndef SEP
    3536#define SEP '/'
     37#endif
     38
     39/* Test if `ch' is a filename separator (bird) */
     40#ifdef ALTSEP
     41#define IS_SEP(ch) ((ch) == SEP || (ch) == ALTSEP)
     42#else
     43#define IS_SEP(ch) ((ch) == SEP)
     44#endif
     45
     46/* Test if `path' has a drive letter or not. (bird) */
     47#ifdef DRVSEP
     48#define HAS_DRV(path) (*(path) && (path)[1] == DRVSEP)
     49#else
     50#define HAS_DRV(path) 0
     51#endif
     52
     53/* Test if `path' is absolute or not. (bird) */
     54#ifdef DRVSEP
     55#define IS_ABSPATH(path) (IS_SEP((path)[0]) || HAS_DRV(path))
     56#else
     57#define IS_ABSPATH(path) (IS_SEP((path)[0]))
     58#endif
     59
     60/* Test if `path' contains any of the path separators including drive letter. (bird) */
     61#ifdef ALTSEP
     62#define HAS_ANYSEP(path) ( strchr((path), SEP) || strchr((path), ALTSEP) || HAS_DRV(path) )
     63#else
     64#define HAS_ANYSEP(path) ( strchr((path), SEP) || HAS_DRV(path) )
    3665#endif
    3766
  • trunk/essentials/dev-lang/python/Lib/tempfile.py

    r3225 r3364  
    437437    return _TemporaryFileWrapper(file, name)
    438438
    439 if _os.name != 'posix' or _os.sys.platform == 'cygwin':
     439if _os.name != 'posix' or _os.sys.platform == 'cygwin' ot _os.sys.platform == 'os2emx':
    440440    # On non-POSIX and Cygwin systems, assume that we cannot unlink a file
    441441    # while it is open.
  • trunk/essentials/dev-lang/python/Makefile.pre.in

    r3225 r3364  
    484484
    485485$(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
     486ifndef BOOTSTRAPPING_PYTHON
    486487        $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
     488endif
    487489
    488490$(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
     491ifndef BOOTSTRAPPING_PYTHON
    489492        $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
     493endif
    490494
    491495Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
  • trunk/essentials/dev-lang/python/Modules/getpath.c

    r3225 r3364  
    136136{
    137137    size_t i = strlen(dir);
    138     while (i > 0 && dir[i] != SEP)
     138    while (i > 0 && !IS_SEP(dir[i]))
    139139        --i;
    140140    dir[i] = '\0';
     
    209209{
    210210    size_t n, k;
    211     if (stuff[0] == SEP)
     211    if (IS_ABSPATH(stuff))
    212212        n = 0;
    213213    else {
    214214        n = strlen(buffer);
    215         if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)
     215        if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN)
    216216            buffer[n++] = SEP;
    217217    }
     
    230230copy_absolute(char *path, char *p)
    231231{
    232     if (p[0] == SEP)
     232    if (IS_ABSPATH(p)) {
    233233        strcpy(path, p);
     234#ifdef ALTSEP
     235        p = path;
     236        while ((p = strchr(p, ALTSEP)))
     237            *p++ = SEP;
     238#endif
     239    }
    234240    else {
    235241        getcwd(path, MAXPATHLEN);
    236         if (p[0] == '.' && p[1] == SEP)
     242        if (p[0] == '.' && IS_SEP(p[1]))
    237243            p += 2;
    238244        joinpath(path, p);
     
    246252    char buffer[MAXPATHLEN + 1];
    247253
    248     if (path[0] == SEP)
     254    if (IS_ABSPATH(path)) {
     255#ifdef ALTSEP
     256        while ((path = strchr(path, ALTSEP)))
     257            *path++ = SEP;
     258#endif
    249259        return;
     260    }
    250261    copy_absolute(buffer, path);
    251262    strcpy(path, buffer);
     
    399410         * $PATH isn't exported, you lose.
    400411         */
    401         if (strchr(prog, SEP))
     412        if (HAS_ANYSEP(prog))
    402413                strncpy(progpath, prog, MAXPATHLEN);
    403414#ifdef __APPLE__
     
    442453        else
    443454                progpath[0] = '\0';
    444         if (progpath[0] != SEP)
     455#ifndef ALTSEP
     456        if (!IS_ABSPATH(progpath))
     457#endif
    445458                absolutize(progpath);
    446459        strncpy(argv0_path, progpath, MAXPATHLEN);
     
    488501            /* It's not null terminated! */
    489502            tmpbuffer[linklen] = '\0';
    490             if (tmpbuffer[0] == SEP)
     503            if (IS_ABSPATH(tmpbuffer))
    491504                /* tmpbuffer should never be longer than MAXPATHLEN,
    492505                   but extra check does not hurt */
     
    553566
    554567    while (1) {
    555         char *delim = strchr(defpath, DELIM);
    556 
    557         if (defpath[0] != SEP)
     568        char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */
     569
     570        if (!IS_ABSPATH(defpath))
    558571            /* Paths are relative to prefix */
    559572            bufsz += prefixsz;
     
    598611        defpath = pythonpath;
    599612        while (1) {
    600             char *delim = strchr(defpath, DELIM);
    601 
    602             if (defpath[0] != SEP) {
     613            char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */
     614
     615            if (!IS_ABSPATH(defpath)) {
    603616                strcat(buf, prefix);
    604617                strcat(buf, separator);
     
    606619
    607620            if (delim) {
    608                 size_t len = delim - defpath + 1;
     621                size_t len = delim - defpath;
    609622                size_t end = strlen(buf) + len;
    610623                strncat(buf, defpath, len);
    611                 *(buf + end) = '\0';
     624                *(buf + end) = DELIM;   /* bird: correct the DELIM char. */
     625                *(buf + end + 1) = '\0';
    612626            }
    613627            else {
  • trunk/essentials/dev-lang/python/Modules/posixmodule.c

    r3225 r3364  
    132132#define fsync _commit
    133133#else
    134 #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
     134#if (defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)) || defined(__VMS)
    135135/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
    136136#else                   /* all other compilers */
  • trunk/essentials/dev-lang/python/Objects/exceptions.c

    r3225 r3364  
    10521052        return "???";
    10531053    while (*cp != '\0') {
    1054         if (*cp == SEP)
     1054        if (IS_SEP(*cp))
    10551055            result = cp + 1;
    10561056        ++cp;
  • trunk/essentials/dev-lang/python/PC/os2emx/Setup.os2emx

    r3343 r3364  
    110110# setup.py script in the root of the Python source tree.
    111111
    112 posix posixmodule.c             # posix (UNIX) system calls
     112os2 posixmodule.c               # os2 / posix (UNIX) system calls
    113113errno errnomodule.c             # posix (UNIX) errno values
    114114pwd pwdmodule.c                 # this is needed to find out the user's home dir
  • 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);
  • trunk/essentials/dev-lang/python/configure.in

    r3225 r3364  
    184184        atheos*) MACHDEP="atheos";;
    185185        irix646) MACHDEP="irix6";;
     186        os2*|emx*) MACHDEP="emx";;
     187
    186188        '')     MACHDEP="unknown";;
    187189        esac
     
    487489    gcc) CC="$CC -D_HAVE_BSDI";;
    488490    esac;;
     491os2*|emx*)
     492    CC="$CC -DPYCC_OS2=1 -DPYCC_GCC=1"
     493    ;;
    489494esac
    490495
     
    519524# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
    520525# systems without shared libraries, LDLIBRARY is the same as LIBRARY
    521 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
    522 # DLLLIBRARY is the shared (i.e., DLL) library.
    523 # 
     526# (defined in the Makefiles). On Cygwin and OS/2 LDLIBRARY is the import
     527# library, DLLLIBRARY is the shared (i.e., DLL) library.
     528#
    524529# RUNSHARED is used to run shared python without installed libraries
    525530#
     
    665670          RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
    666671          ;;
     672    os2*|emx*)
     673      LDLIBRARY='python$(VERSION)_dll.a'
     674          BLDLIBRARY='-L. -lpython$(VERSION)'
     675          RUNSHARED=BEGINLIBPATH="`pwd`;$BEGINLIBPATH"
     676      CONDENSED_VERSION=`echo "$(VERSION)" | tr -d .,"`
     677      DLLLIBRARY='python$(CONDENSED_VERSION).dll'
     678          ;;
    667679  esac
    668680else # shared is disabled
     
    706718                BeOS*) LN="ln -s";;
    707719                CYGWIN*) LN="ln -s";;
     720                os2*|emx*) LN="ln -s";;
    708721                atheos*) LN="ln -s";;
    709722                *) LN=ln;;
     
    13961409AC_SUBST(LINKFORSHARED)
    13971410# SO is the extension of shared libraries `(including the dot!)
    1398 # -- usually .so, .sl on HP-UX, .dll on Cygwin
     1411# -- usually .so, .sl on HP-UX, .dll on Cygwin and OS/2
    13991412AC_MSG_CHECKING(SO)
    14001413if test -z "$SO"
     
    14081421                ;;
    14091422        CYGWIN*)   SO=.dll;;
     1423        os2*|emx*) SO=.dll;;
    14101424        *)         SO=.so;;
    14111425        esac
     
    34023416if test ! -f Modules/Setup
    34033417then
    3404         cp $srcdir/Modules/Setup.dist Modules/Setup
     3418        if test "$MACHDEP" = "emx"; then
     3419        cp $srcdir/PC/os2emx/Modules/Setup.os2emx Modules/Setup
     3420    else
     3421        cp $srcdir/Modules/Setup.dist Modules/Setup
     3422    if
    34053423fi
    34063424
Note: See TracChangeset for help on using the changeset viewer.