- Timestamp:
- Sep 3, 2010, 5:33:06 PM (15 years ago)
- Location:
- python/trunk
- Files:
-
- 1 added
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk/Include/osdefs.h
r2 r10 20 20 #define MAXPATHLEN 256 21 21 #endif 22 #define DRVSEP ':' /* (bird) */ 22 23 #define DELIM ';' 23 24 #endif … … 34 35 #ifndef SEP 35 36 #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) ) 36 65 #endif 37 66 -
python/trunk/Include/pyport.h
r2 r10 550 550 551 551 BeOS and cygwin are the only other autoconf platform requiring special 552 linkage handling and both of these use __declspec(). 552 linkage handling and both of these use __declspec(). Ditto for OS/2. 553 553 */ 554 #if defined(__CYGWIN__) || defined(__BEOS__) 554 #if defined(__CYGWIN__) || defined(__BEOS__) || defined(__OS2__) 555 555 # define HAVE_DECLSPEC_DLL 556 556 #endif … … 564 564 /* module init functions inside the core need no external linkage */ 565 565 /* except for Cygwin to handle embedding (FIXME: BeOS too?) */ 566 # if defined(__CYGWIN__) 566 # if defined(__CYGWIN__) || defined(__OS2__) 567 567 # define PyMODINIT_FUNC __declspec(dllexport) void 568 568 # else /* __CYGWIN__ */ … … 574 574 /* Under Cygwin, auto-import functions to prevent compilation */ 575 575 /* failures similar to http://python.org/doc/FAQ.html#3.24 */ 576 # if !defined(__CYGWIN__) 576 # if !defined(__CYGWIN__) && !defined(__OS2__) 577 577 # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE 578 578 # endif /* !__CYGWIN__ */ 579 # if !defined(__OS2__) 579 580 # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE 581 # endif /* !__OS2__ */ 580 582 /* module init functions outside the core must be exported */ 581 583 # if defined(__cplusplus) -
python/trunk/Lib/bsddb/dbshelve.py
r2 r10 1 #!/ bin/env python1 #!/usr/bin/env python 2 2 #------------------------------------------------------------------------ 3 3 # Copyright (c) 1997-2001 by Total Control Software -
python/trunk/Lib/cgi.py
r2 r10 1 #! /usr/local/bin/python1 #!/usr/bin/python 2 2 3 3 # NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is -
python/trunk/Lib/distutils/ccompiler.py
r2 r10 983 983 # compiler 984 984 ('cygwin.*', 'unix'), 985 ('os2knix', 'emx'), 985 986 ('os2emx', 'emx'), 986 987 -
python/trunk/Lib/distutils/command/bdist_rpm.py
r2 r10 200 200 "--python and --fix-python are mutually exclusive options" 201 201 202 if os.name != 'posix' :202 if os.name != 'posix' and os.name != 'os2': 203 203 raise DistutilsPlatformError, \ 204 204 ("don't know how to create RPM " … … 323 323 rpm_cmd = ['rpm'] 324 324 if os.path.exists('/usr/bin/rpmbuild') or \ 325 os.path.exists('/usr/bin/rpmbuild.exe') or \ 325 326 os.path.exists('/bin/rpmbuild'): 326 327 rpm_cmd = ['rpmbuild'] … … 346 347 q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % ( 347 348 src_rpm, non_src_rpm, spec_path) 349 if os.name == 'os2': 350 q_cmd = q_cmd.replace( '%{', '%%{') 348 351 349 352 out = os.popen(q_cmd) -
python/trunk/Lib/distutils/command/install.py
r2 r10 284 284 285 285 # Next, stuff that's wrong (or dubious) only on certain platforms. 286 if os.name != "posix" :286 if os.name != "posix" and os.name != "os2": 287 287 if self.exec_prefix: 288 288 self.warn("exec-prefix option ignored on this platform") … … 299 299 self.dump_dirs("pre-finalize_{unix,other}") 300 300 301 if os.name == 'posix' :301 if os.name == 'posix' or os.name == "os2": 302 302 self.finalize_unix() 303 303 else: -
python/trunk/Lib/distutils/emxccompiler.py
r2 r10 64 64 # Hard-code GCC because that's what this is all about. 65 65 # XXX optimization, warnings etc. should be customizable. 66 self.set_executables(compiler='gcc - Zomf -Zmt -O3 -fomit-frame-pointer -mprobe-Wall',67 compiler_so='gcc - Zomf -Zmt -O3 -fomit-frame-pointer -mprobe-Wall',68 linker_exe='gcc -Zomf -Z mt -Zcrtdll',69 linker_so='gcc -Zomf -Z mt -Zcrtdll -Zdll')66 self.set_executables(compiler='gcc -g -O2 -march=i386 -mtune=i686 -fomit-frame-pointer -Wall', 67 compiler_so='gcc -g -O2 -march=i386 -mtune=i686 -fomit-frame-pointer -Wall', 68 linker_exe='gcc -Zomf -Zexe', 69 linker_so='gcc -Zomf -Zdll') 70 70 71 71 # want the gcc library statically linked (so that we don't have … … 139 139 "EXPORTS"] 140 140 for sym in export_symbols: 141 contents.append(' " %s"' % sym)141 contents.append(' "_%s"' % sym) 142 142 self.execute(write_file, (def_file, contents), 143 143 "writing %s" % def_file) … … 209 209 # to deal with file naming/searching differences 210 210 def find_library_file(self, dirs, lib, debug=0): 211 shortlib = '%s.lib' % lib 212 longlib = 'lib%s.lib' % lib # this form very rare 211 try_names = [lib + ".lib", lib + ".a", "lib" + lib + ".lib", "lib" + lib + ".a"] 213 212 214 213 # get EMX's default library directory search path … … 218 217 emx_dirs = [] 219 218 219 #print "dirs:",dirs 220 220 for dir in dirs + emx_dirs: 221 shortlibp = os.path.join(dir, shortlib) 222 longlibp = os.path.join(dir, longlib) 223 if os.path.exists(shortlibp): 224 return shortlibp 225 elif os.path.exists(longlibp): 226 return longlibp 221 for name in try_names: 222 libfile = os.path.join(dir, name) 223 #print "libfile:",libfile 224 if os.path.exists(libfile): 225 return libfile 227 226 228 227 # Oops, didn't find it in *any* of 'dirs' -
python/trunk/Lib/distutils/sysconfig.py
r2 r10 91 91 return os.path.join(prefix, "Include") 92 92 elif os.name == "os2": 93 return os.path.join(prefix, "Include") 93 if python_build: 94 base = os.path.dirname(os.path.abspath(sys.executable)) 95 if plat_specific: 96 inc_dir = base 97 else: 98 inc_dir = os.path.join(base, "Include") 99 if not os.path.exists(inc_dir): 100 inc_dir = os.path.join(os.path.dirname(base), "Include") 101 return inc_dir 102 return os.path.join(prefix, "include", "python" + get_python_version()) 94 103 else: 95 104 raise DistutilsPlatformError( … … 145 154 146 155 elif os.name == "os2": 156 libpython = os.path.join(prefix, 157 "lib", "python" + get_python_version()) 147 158 if standard_lib: 148 return os.path.join(prefix, "Lib")149 else: 150 return os.path.join( prefix, "Lib", "site-packages")159 return libpython 160 else: 161 return os.path.join(libpython, "site-packages") 151 162 152 163 else: … … 491 502 """Initialize the module as appropriate for OS/2""" 492 503 g = {} 504 # load the installed Makefile: 505 try: 506 filename = get_makefile_filename() 507 parse_makefile(filename, g) 508 except IOError, msg: 509 my_msg = "invalid Python installation: unable to open %s" % filename 510 if hasattr(msg, "strerror"): 511 my_msg = my_msg + " (%s)" % msg.strerror 512 513 raise DistutilsPlatformError(my_msg) 514 515 # load the installed pyconfig.h: 516 try: 517 filename = get_config_h_filename() 518 parse_config_h(file(filename), g) 519 except IOError, msg: 520 my_msg = "invalid Python installation: unable to open %s" % filename 521 if hasattr(msg, "strerror"): 522 my_msg = my_msg + " (%s)" % msg.strerror 523 524 raise DistutilsPlatformError(my_msg) 525 526 # On AIX, there are wrong paths to the linker scripts in the Makefile 527 # -- these paths are relative to the Python source, but when installed 528 # the scripts are in another directory. 529 if python_build: 530 g['LDSHARED'] = g['BLDSHARED'] 531 532 # OS/2 module 533 493 534 # set basic install directories 494 535 g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) -
python/trunk/Lib/distutils/unixccompiler.py
r2 r10 140 140 dylib_lib_extension = ".dylib" 141 141 static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s" 142 if sys.platform == "cygwin" :142 if sys.platform == "cygwin" or sys.platform == "os2emx" or sys.platform == "os2knix": 143 143 exe_extension = ".exe" 144 144 … … 284 284 # we use this hack. 285 285 compiler = os.path.basename(sysconfig.get_config_var("CC")) 286 if sys.platform[:6] == "darwin" :286 if sys.platform[:6] == "darwin" or sys.platform[:7] == "os2knix": 287 287 # MacOSX's linker doesn't understand the -R flag at all 288 288 return "-L" + dir -
python/trunk/Lib/os.py
r2 r10 75 75 except ImportError: 76 76 pass 77 if sys.version.find('EMX GCC') == -1: 77 if sys.platform == 'os2knix': 78 import os2knixpath as path 79 elif sys.version.find('EMX GCC') == -1: 78 80 import ntpath as path 79 81 else: -
python/trunk/Lib/popen2.py
r2 r10 135 135 136 136 137 if sys.platform[:3] == "win" or sys.platform == "os2emx" :137 if sys.platform[:3] == "win" or sys.platform == "os2emx" or sys.platform == "os2knix": 138 138 # Some things don't make sense on non-Unix platforms. 139 139 del Popen3, Popen4 -
python/trunk/Lib/site.py
r2 r10 232 232 return os.path.expanduser(os.path.join(*args)) 233 233 234 #if sys.platform in ('os2emx', ' riscos'):234 #if sys.platform in ('os2emx', 'os2knix', 'riscos'): 235 235 # # Don't know what to put here 236 236 # USER_BASE = '' … … 263 263 seen.append(prefix) 264 264 265 if sys.platform in ('os2emx', ' riscos'):265 if sys.platform in ('os2emx', 'os2knix', 'riscos'): 266 266 sitedirs.append(os.path.join(prefix, "Lib", "site-packages")) 267 267 elif os.sep == '/': … … 495 495 known_paths = addusersitepackages(known_paths) 496 496 known_paths = addsitepackages(known_paths) 497 if sys.platform == 'os2emx': 497 if sys.platform == 'os2emx' or sys.platform == 'os2knix': 498 if (sys.path and os.path.basename(sys.path[-1]) == "Modules"): 499 addbuilddir() 498 500 setBEGINLIBPATH() 499 501 setquit() -
python/trunk/Lib/tempfile.py
r2 r10 388 388 # the wrapper to do anything special. We still use it so that 389 389 # file.name is useful (i.e. not "(fdopen)") with NamedTemporaryFile. 390 if _os.name != 'nt' :390 if _os.name != 'nt' and _os.name != 'os2': 391 391 # Cache the unlinker so we don't get spurious errors at 392 392 # shutdown when the module-level "os" is None'd out. Note … … 446 446 return _TemporaryFileWrapper(file, name, delete) 447 447 448 if _os.name != 'posix' or _os.sys.platform == 'cygwin' :448 if _os.name != 'posix' or _os.sys.platform == 'cygwin' or _os.sys.platform == 'os2emx' or _os.sys.platform == 'os2knix': 449 449 # On non-POSIX and Cygwin systems, assume that we cannot unlink a file 450 450 # while it is open. -
python/trunk/Lib/test/regrtest.py
r2 r10 1037 1037 test_signal 1038 1038 """, 1039 'os2knix': 1040 """ 1041 test_al 1042 test_applesingle 1043 test_audioop 1044 test_bsddb185 1045 test_bsddb3 1046 test_cd 1047 test_cl 1048 test_commands 1049 test_dl 1050 test_gl 1051 test_imgfile 1052 test_linuxaudiodev 1053 test_mhlib 1054 test_mmap 1055 test_nis 1056 test_openpty 1057 test_ossaudiodev 1058 test_pty 1059 test_resource 1060 test_sqlite 1061 test_startfile 1062 test_sunaudiodev 1063 """, 1039 1064 'freebsd4': 1040 1065 """ -
python/trunk/Lib/test/test_tempfile.py
r2 r10 260 260 mode = stat.S_IMODE(os.stat(file.name).st_mode) 261 261 expected = 0600 262 if sys.platform in ('win32', 'os2emx', ' mac'):262 if sys.platform in ('win32', 'os2emx', 'os2knix', 'mac'): 263 263 # There's no distinction among 'user', 'group' and 'world'; 264 264 # replicate the 'user' bits. … … 479 479 mode &= 0777 # Mask off sticky bits inherited from /tmp 480 480 expected = 0700 481 if sys.platform in ('win32', 'os2emx', ' mac'):481 if sys.platform in ('win32', 'os2emx', 'os2knix', 'mac'): 482 482 # There's no distinction among 'user', 'group' and 'world'; 483 483 # replicate the 'user' bits. -
python/trunk/Lib/test/test_unicodedata.py
r2 r10 72 72 # but the other test cases will still be run 73 73 import unicodedata 74 self.db = unicodedata75 74 76 75 def tearDown(self): -
python/trunk/Lib/urllib2.py
r2 r10 1275 1275 host = req.get_host() 1276 1276 file = req.get_selector() 1277 1278 # YD hack: add again drive name 1279 if os.name == 'os2' and len(host)>2 and host[1] == ':': 1280 file = host + file 1281 host = "" 1282 1277 1283 localfile = url2pathname(file) 1278 1284 try: -
python/trunk/Makefile.pre.in
r2 r10 158 158 LDLIBRARYDIR= @LDLIBRARYDIR@ 159 159 INSTSONAME= @INSTSONAME@ 160 CONDENSED_VERSION= @CONDENSED_VERSION@ 160 161 161 162 … … 454 455 $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources 455 456 457 ifneq ($(filter os2emx os2knix,$(MACHDEP)),) # bird hack! 458 $(DLLLIBRARY) $(LDLIBRARY): $(LIBRARY_OBJS) 459 $(LDSHARED) -o $(DLLLIBRARY) $^ $(LIBS) $(MODLIBS) $(SYSLIBS) 460 emximp -o $(LDLIBRARY) $(DLLLIBRARY) 461 462 else # CYGWIN 456 463 # This rule builds the Cygwin Python DLL and import library if configured 457 464 # for a shared core library; otherwise, this rule is a noop. … … 462 469 else true; \ 463 470 fi 471 endif # end bird hack! 464 472 465 473 … … 533 541 534 542 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES) 543 ifndef BOOTSTRAPPING_PYTHON 535 544 $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL) 545 endif 536 546 537 547 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES) 548 ifndef BOOTSTRAPPING_PYTHON 538 549 $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL) 550 endif 539 551 540 552 Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H) … … 764 776 -rm -f $(DESTDIR)$(BINDIR)/python-config 765 777 (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config) 778 rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \ 779 $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/$(PYTHON); \ 780 $(INSTALL_DATA) $(LDLIBRARY) $(DLLLIBRARY) $(DESTDIR)$(LIBDIR); \ 766 781 767 782 # Install the interpreter with $(VERSION) affixed … … 906 921 ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" 907 922 923 ifneq ($(filter os2emx os2knix,$(MACHDEP)),) # bird hack! 924 PATH_SEPARATOR = ; 925 else 926 PATH_SEPARATOR = : 927 endif 928 908 929 # Create the PLATDIR source directory, if one wasn't distributed.. 909 930 $(srcdir)/Lib/$(PLATDIR): 910 931 mkdir $(srcdir)/Lib/$(PLATDIR) 911 932 cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen 912 export PATH; PATH="`pwd` :$$PATH"; \933 export PATH; PATH="`pwd`$(PATH_SEPARATOR)$$PATH"; \ 913 934 export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ 914 935 export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ … … 1006 1027 --install-scripts=$(BINDIR) \ 1007 1028 --install-platlib=$(DESTSHARED) \ 1008 --root= /$(DESTDIR)1029 --root=$(DESTDIR) 1009 1030 1010 1031 # Here are a couple of targets for MacOSX again, to install a full -
python/trunk/Misc/python-config.in
r2 r10 45 45 elif opt in ('--libs', '--ldflags'): 46 46 libs = getvar('LIBS').split() + getvar('SYSLIBS').split() 47 # YD ignore libs 48 libs = getvar('SYSLIBS').split() 47 49 libs.append('-lpython'+pyver) 48 50 # add the prefix/lib/pythonX.Y/config dir, but only if there is no -
python/trunk/Modules/Setup.dist
r2 r10 113 113 # setup.py script in the root of the Python source tree. 114 114 115 posixposixmodule.c # posix (UNIX) system calls115 os2 posixmodule.c # posix (UNIX) system calls 116 116 errno errnomodule.c # posix (UNIX) errno values 117 117 pwd pwdmodule.c # this is needed to find out the user's home dir -
python/trunk/Modules/_hotshot.c
r2 r10 1605 1605 1606 1606 1607 #ifdef __OS2__ 1608 PyMODINIT_FUNC 1609 #else 1607 1610 void 1611 #endif 1608 1612 init_hotshot(void) 1609 1613 { -
python/trunk/Modules/_multiprocessing/multiprocessing.c
r2 r10 87 87 #else /* !MS_WINDOWS */ 88 88 89 #if HAVE_FD_TRANSFER89 #if defined(HAVE_FD_TRANSFER) 90 90 91 91 /* Functions for transferring file descriptors between processes. -
python/trunk/Modules/_multiprocessing/multiprocessing.h
r2 r10 28 28 # include <sys/uio.h> 29 29 # include <arpa/inet.h> /* htonl() and ntohl() */ 30 #ifndef __EMX__ 30 31 # if HAVE_SEM_OPEN 31 32 # include <semaphore.h> 32 33 typedef sem_t *SEM_HANDLE; 33 34 # endif 35 #else 36 # define SEM_HANDLE HANDLE 37 #endif 34 38 # define HANDLE int 35 39 # define SOCKET int -
python/trunk/Modules/cjkcodecs/cjkcodecs.h
r2 r10 387 387 #endif 388 388 389 #ifdef __OS2__ 390 #define I_AM_A_MODULE_FOR(loc) \ 391 PyMODINIT_FUNC \ 392 init_codecs_##loc(void) \ 393 { \ 394 PyObject *m = Py_InitModule("_codecs_" #loc, __methods);\ 395 if (m != NULL) \ 396 (void)register_maps(m); \ 397 } 398 #else 389 399 #define I_AM_A_MODULE_FOR(loc) \ 390 400 void \ … … 395 405 (void)register_maps(m); \ 396 406 } 397 398 #endif 407 #endif 408 409 #endif -
python/trunk/Modules/fcntlmodule.c
r2 r10 316 316 return NULL; 317 317 318 #if defined(PYOS_OS2) && defined(PYCC_GCC) 318 #if defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__) 319 319 PyErr_SetString(PyExc_NotImplementedError, 320 320 "lockf not supported on OS/2 (EMX)"); … … 374 374 Py_INCREF(Py_None); 375 375 return Py_None; 376 #endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */376 #endif /* defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)*/ 377 377 } 378 378 -
python/trunk/Modules/getpath.c
r2 r10 117 117 #endif 118 118 119 #ifndef __EMX__ 119 120 #ifndef PYTHONPATH 120 121 #define PYTHONPATH PREFIX "/lib/python" VERSION ":" \ 121 122 EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" 123 #endif 124 #else 125 //#define PYTHONPATH "./Lib;./Lib/plat-" PLATFORM \ 126 // ";./Lib/lib-dynload;./Lib/site-packages" 127 // force unixroot 128 #define PYTHONPATH PREFIX "/lib/python" VERSION ";" \ 129 EXEC_PREFIX "/lib/python" VERSION "/lib-" PLATFORM ";" \ 130 EXEC_PREFIX "/lib/python" VERSION "/site-packages" ";" \ 131 EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" ";" \ 132 /* now local (for building) */ \ 133 "./lib" ";" \ 134 "./lib/plat-" PLATFORM ";" \ 135 "./lib/site-packages" ";" \ 136 "./lib/lib-dynload" 122 137 #endif 123 138 … … 136 151 { 137 152 size_t i = strlen(dir); 138 while (i > 0 && dir[i] != SEP)153 while (i > 0 && !IS_SEP(dir[i])) 139 154 --i; 140 155 dir[i] = '\0'; … … 209 224 { 210 225 size_t n, k; 211 if ( stuff[0] == SEP)226 if (IS_ABSPATH(stuff)) 212 227 n = 0; 213 228 else { 214 229 n = strlen(buffer); 215 if (n > 0 && buffer[n-1] != SEP&& n < MAXPATHLEN)230 if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN) 216 231 buffer[n++] = SEP; 217 232 } … … 230 245 copy_absolute(char *path, char *p) 231 246 { 232 if ( p[0] == SEP)247 if (IS_ABSPATH(p)) { 233 248 strcpy(path, p); 249 #ifdef ALTSEP 250 p = path; 251 while ((p = strchr(p, ALTSEP))) 252 *p++ = SEP; 253 #endif 254 } 234 255 else { 235 256 getcwd(path, MAXPATHLEN); 236 if (p[0] == '.' && p[1] == SEP)257 if (p[0] == '.' && IS_SEP(p[1])) 237 258 p += 2; 238 259 joinpath(path, p); … … 246 267 char buffer[MAXPATHLEN + 1]; 247 268 248 if (path[0] == SEP) 269 if (IS_ABSPATH(path)) { 270 #ifdef ALTSEP 271 while ((path = strchr(path, ALTSEP))) 272 *path++ = SEP; 273 #endif 249 274 return; 275 } 250 276 copy_absolute(buffer, path); 251 277 strcpy(path, buffer); … … 399 425 * $PATH isn't exported, you lose. 400 426 */ 401 if ( strchr(prog, SEP))427 if (HAS_ANYSEP(prog)) 402 428 strncpy(progpath, prog, MAXPATHLEN); 403 429 #ifdef __APPLE__ … … 442 468 else 443 469 progpath[0] = '\0'; 444 if (progpath[0] != SEP) 470 #ifndef ALTSEP 471 if (!IS_ABSPATH(progpath)) 472 #endif 445 473 absolutize(progpath); 446 474 strncpy(argv0_path, progpath, MAXPATHLEN); … … 488 516 /* It's not null terminated! */ 489 517 tmpbuffer[linklen] = '\0'; 490 if ( tmpbuffer[0] == SEP)518 if (IS_ABSPATH(tmpbuffer)) 491 519 /* tmpbuffer should never be longer than MAXPATHLEN, 492 520 but extra check does not hurt */ … … 553 581 554 582 while (1) { 555 char *delim = strchr(defpath, DELIM);556 557 if ( defpath[0] != SEP)583 char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */ 584 585 if (!IS_ABSPATH(defpath)) 558 586 /* Paths are relative to prefix */ 559 587 bufsz += prefixsz; … … 598 626 defpath = pythonpath; 599 627 while (1) { 600 char *delim = strchr(defpath, DELIM);601 602 if ( defpath[0] != SEP) {628 char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */ 629 630 if (!IS_ABSPATH(defpath)) { 603 631 strcat(buf, prefix); 604 632 strcat(buf, separator); … … 606 634 607 635 if (delim) { 608 size_t len = delim - defpath + 1;636 size_t len = delim - defpath; 609 637 size_t end = strlen(buf) + len; 610 638 strncat(buf, defpath, len); 611 *(buf + end) = '\0'; 639 *(buf + end) = DELIM; /* bird: correct the DELIM char. */ 640 *(buf + end + 1) = '\0'; 612 641 } 613 642 else { -
python/trunk/Modules/posixmodule.c
r2 r10 34 34 # include <unixio.h> 35 35 #endif /* defined(__VMS) */ 36 37 #if defined(__KLIBC__) 38 #include <sys/socket.h> 39 #endif 36 40 37 41 #ifdef __cplusplus … … 132 136 #define fsync _commit 133 137 #else 134 #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)138 #if (defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)) || defined(__VMS) 135 139 /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */ 136 140 #else /* all other compilers */ … … 428 432 Py_DECREF(v); 429 433 } 434 #ifdef LIBPATHSTRICT 435 buffer[0] = buffer[1] = buffer[2] = buffer[3] = '\0'; 436 rc = DosQueryExtLIBPATH(buffer, LIBPATHSTRICT); 437 if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'LIBPATH_STRICT') */ 438 PyObject *v = PyString_FromString(buffer); 439 PyDict_SetItemString(d, "LIBPATHSTRICT", v); 440 Py_DECREF(v); 441 } 442 #endif 430 443 } 431 444 #endif … … 1650 1663 #ifdef MS_WINDOWS 1651 1664 return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir); 1652 #elif defined(PYOS_OS2) && defined(PYCC_GCC)1653 return posix_1str(args, "et:chdir", _chdir2);1654 1665 #elif defined(__VMS) 1655 1666 return posix_1str(args, "et:chdir", (int (*)(const char *))chdir); … … 1987 1998 break; 1988 1999 } 1989 #if defined(PYOS_OS2) && defined(PYCC_GCC)1990 res = _getcwd2(tmpbuf, bufsize);1991 #else1992 2000 res = getcwd(tmpbuf, bufsize); 1993 #endif1994 2001 1995 2002 if (res == NULL) { … … 2051 2058 2052 2059 Py_BEGIN_ALLOW_THREADS 2053 #if defined(PYOS_OS2) && defined(PYCC_GCC)2054 res = _getcwd2(buf, sizeof buf);2055 #else2056 2060 res = getcwd(buf, sizeof buf); 2057 #endif2058 2061 Py_END_ALLOW_THREADS 2059 2062 if (res == NULL) … … 2245 2248 return d; 2246 2249 2247 #elif defined(PYOS_OS2 )2250 #elif defined(PYOS_OS2_00) // YD os2 api does not support path rewriting 2248 2251 2249 2252 #ifndef MAX_PATH … … 3117 3120 #if defined(PYOS_OS2) 3118 3121 /* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */ 3119 if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) { 3122 if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0 3123 && stricmp(k, "LIBPATHSTRICT") != 0) { 3120 3124 #endif 3121 3125 len = PyString_Size(key) + PyString_Size(val) + 2; … … 4216 4220 char *mode = "r"; 4217 4221 int bufsize = -1; 4222 int unset_emxshell = 0; 4218 4223 FILE *fp; 4219 4224 PyObject *f; 4220 4225 if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) 4221 4226 return NULL; 4227 /* a little hack for making sure commands.getstatusoutput works 4228 * (ASSUMES that COMSPEC isn't a posix shell.) */ 4229 if (name[0] == '{' && !getenv("EMXSHELL")) { 4230 char path[512]; 4231 _searchenv("sh.exe", "PATH", path); 4232 if (!path[0]) 4233 _searchenv("ash.exe", "PATH", path); 4234 if (!path[0]) 4235 _searchenv("bash.exe", "PATH", path); 4236 if (path[0]) 4237 unset_emxshell = setenv("EMXSHELL", path, 0) == 0; 4238 } 4222 4239 Py_BEGIN_ALLOW_THREADS 4223 4240 fp = popen(name, mode); 4224 4241 Py_END_ALLOW_THREADS 4242 if (unset_emxshell) 4243 unsetenv("EMXSHELL"); 4225 4244 if (fp == NULL) 4226 4245 return posix_error(); … … 4372 4391 FILE *p_s[3]; 4373 4392 int file_count, i, pipe_err; 4374 pid_t pipe_pid ;4393 pid_t pipe_pid = -1; 4375 4394 char *shell, *sh_name, *opt, *rd_mode, *wr_mode; 4376 4395 PyObject *f, *p_f[3]; … … 4391 4410 if ((shell = getenv("EMXSHELL")) == NULL) 4392 4411 if ((shell = getenv("COMSPEC")) == NULL) 4412 if ((shell = getenv("SHELL")) == NULL) 4413 if ((shell = getenv("OS2_SHELL")) == NULL) 4393 4414 { 4394 4415 errno = ENOENT; … … 4429 4450 i = pipe_err = 0; 4430 4451 while ((pipe_err == 0) && (i < file_count)) 4452 #ifndef __KLIBC__ 4431 4453 pipe_err = pipe((int *)&p_fd[i++]); 4454 #else 4455 pipe_err = socketpair(AF_UNIX, SOCK_STREAM,0,(int *)&p_fd[i++]); 4456 #endif 4432 4457 if (pipe_err < 0) 4433 4458 { … … 6590 6615 posix_pipe(PyObject *self, PyObject *noargs) 6591 6616 { 6592 #if defined(PYOS_OS2) 6617 #if defined(PYOS_OS2) && !defined(__KLIBC__) 6593 6618 HFILE read, write; 6594 6619 APIRET rc; … … 6606 6631 int res; 6607 6632 Py_BEGIN_ALLOW_THREADS 6633 #ifndef __KLIBC__ 6608 6634 res = pipe(fds); 6635 #else 6636 res = socketpair(AF_UNIX, SOCK_STREAM,0, fds); 6637 #endif 6609 6638 Py_END_ALLOW_THREADS 6610 6639 if (res != 0) … … 6796 6825 if (rc != NO_ERROR) 6797 6826 return os2_error(rc); 6827 #ifdef LIBPATHSTRICT 6828 } else if (stricmp(s1, "LIBPATHSTRICT") == 0) { 6829 APIRET rc; 6830 6831 rc = DosSetExtLIBPATH(s2, LIBPATHSTRICT); 6832 if (rc != NO_ERROR) 6833 return os2_error(rc); 6834 #endif 6798 6835 } else { 6799 #endif 6836 #endif /* OS2 */ 6800 6837 6801 6838 /* XXX This can leak memory -- not easy to fix :-( */ … … 8429 8466 } 8430 8467 #endif 8468 8469 #ifdef __EMX__ 8470 /* Use openssl random routine */ 8471 #include <openssl/rand.h> 8472 PyDoc_STRVAR(os2_urandom__doc__, 8473 "urandom(n) -> str\n\n\ 8474 Return a string of n random bytes suitable for cryptographic use."); 8475 8476 static PyObject* 8477 os2_urandom(PyObject *self, PyObject *args) 8478 { 8479 int howMany; 8480 PyObject* result; 8481 8482 /* Read arguments */ 8483 if (! PyArg_ParseTuple(args, "i:urandom", &howMany)) 8484 return NULL; 8485 if (howMany < 0) 8486 return PyErr_Format(PyExc_ValueError, 8487 "negative argument not allowed"); 8488 8489 /* Allocate bytes */ 8490 result = PyString_FromStringAndSize(NULL, howMany); 8491 if (result != NULL) { 8492 /* Get random data */ 8493 if (RAND_pseudo_bytes((unsigned char*) 8494 PyString_AS_STRING(result), 8495 howMany) < 0) { 8496 Py_DECREF(result); 8497 return PyErr_Format(PyExc_ValueError, 8498 "RAND_pseudo_bytes"); 8499 } 8500 } 8501 return result; 8502 } 8503 #endif 8504 8431 8505 8432 8506 static PyMethodDef posix_methods[] = { … … 8740 8814 {"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__}, 8741 8815 #endif 8816 #ifdef __EMX__ 8817 {"urandom", os2_urandom, METH_VARARGS, os2_urandom__doc__}, 8818 #endif 8742 8819 {NULL, NULL} /* Sentinel */ 8743 8820 }; … … 8756 8833 APIRET rc; 8757 8834 ULONG values[QSV_MAX+1]; 8758 PyObject *v;8759 8835 char *ver, tmp[50]; 8760 8836 … … 8785 8861 default: 8786 8862 PyOS_snprintf(tmp, sizeof(tmp), 8787 "% d-%d", values[QSV_VERSION_MAJOR],8863 "%ld-%ld", values[QSV_VERSION_MAJOR], 8788 8864 values[QSV_VERSION_MINOR]); 8789 8865 ver = &tmp[0]; -
python/trunk/Modules/resource.c
r2 r10 69 69 return NULL; 70 70 71 #ifndef __OS2__ 71 72 if (getrusage(who, &ru) == -1) { 72 73 if (errno == EINVAL) { … … 78 79 return NULL; 79 80 } 80 81 #endif 81 82 result = PyStructSequence_New(&StructRUsageType); 82 83 if (!result) -
python/trunk/Objects/exceptions.c
r2 r10 1147 1147 return "???"; 1148 1148 while (*cp != '\0') { 1149 if ( *cp == SEP)1149 if (IS_SEP(*cp)) 1150 1150 result = cp + 1; 1151 1151 ++cp; -
python/trunk/Python/dynload_shlib.c
r2 r10 21 21 #else 22 22 #if defined(PYOS_OS2) && defined(PYCC_GCC) 23 #ifdef __KLIBC__ 24 #error "kLIBC has dlfcn.h and shouldn't get here!" 25 #endif 23 26 #include "dlfcn.h" 24 27 #endif 25 28 #endif 26 29 27 #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__) 30 #if ((defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)) \ 31 || (defined(__OS2__) && defined(__KLIBC__)) 28 32 #define LEAD_UNDERSCORE "_" 29 33 #else … … 37 41 {"module.dll", "rb", C_EXTENSION}, 38 42 #else 39 #if defined(PYOS_OS2) && defined(PYCC_GCC)43 #if (defined(PYOS_OS2) && defined(PYCC_GCC)) || (defined(__OS2__) && defined(__KLIBC__)) 40 44 {".pyd", "rb", C_EXTENSION}, 41 45 {".dll", "rb", C_EXTENSION}, … … 128 132 #endif 129 133 134 #if (defined(PYOS_OS2) && defined(PYCC_GCC)) 135 // resolve unixroot 136 if (_realrealpath( pathname, pathbuf, sizeof(pathbuf))!=0) 137 pathname = pathbuf; 138 #endif 139 130 140 handle = dlopen(pathname, dlopenflags); 131 141 -
python/trunk/Python/import.c
r2 r10 1564 1564 #include <dirent.h> 1565 1565 1566 #elif defined(__KLIBC__) 1567 #include <stdlib.h> 1568 1566 1569 #elif defined(PYOS_OS2) 1567 1570 #define INCL_DOS … … 1683 1686 1684 1687 /* OS/2 */ 1688 #elif defined(__KLIBC__) 1689 char canon[MAXPATHLEN+1]; 1690 size_t canonlen; 1691 char *p, *p2; 1692 1693 if (Py_GETENV("PYTHONCASEOK") != NULL) 1694 return 1; 1695 1696 /* This resolves case differences and return and native OS/2 1697 path. Unfortunately, it'll also resolve symbolic links 1698 while of course will screw up a bit... */ 1699 if (!_realrealpath(buf, canon, sizeof(canon))) 1700 return 0; 1701 canonlen = strlen(canon); 1702 if (canonlen < namelen) 1703 return 0; 1704 p = strrchr(canon, SEP); 1705 p2 = strrchr(p ? p : canon, ALTSEP); 1706 if (p2) 1707 p = p2; 1708 1709 return strncmp(p ? p + 1 : canon, name, namelen) == 0; 1710 1685 1711 #elif defined(PYOS_OS2) 1686 1712 HDIR hdir = 1; -
python/trunk/Python/pystrtod.c
r2 r10 3 3 #include <Python.h> 4 4 #include <locale.h> 5 #ifdef __EMX__ 6 #include <float.h> 7 #endif 8 5 9 6 10 /* ascii character tests (as opposed to locale tests) */ … … 41 45 PyOS_ascii_strtod(const char *nptr, char **endptr) 42 46 { 47 #ifdef __EMX__ 48 _control87(MCW_EM, MCW_EM); 49 #endif 43 50 char *fail_pos; 44 51 double val = -1.0; … … 173 180 } 174 181 else { 182 //sigfpe here 175 183 val = strtod(digits_pos, &fail_pos); 176 184 } -
python/trunk/Python/sysmodule.c
r2 r10 1556 1556 /* It's a symlink */ 1557 1557 link[nr] = '\0'; 1558 if ( link[0] == SEP)1558 if (IS_ABSPATH(link)) 1559 1559 argv0 = link; /* Link to absolute path */ 1560 else if ( strchr(link, SEP) == NULL)1560 else if (!HAS_ANYSEP(link)) 1561 1561 ; /* Link without path */ 1562 1562 else { 1563 1563 /* Must join(dirname(argv0), link) */ 1564 1564 char *q = strrchr(argv0, SEP); 1565 #ifdef ALTSEP 1566 char *q2 = strrchr(q ? q : argv0, ALTSEP); 1567 if (q2) 1568 q = q2; 1569 #endif 1570 #ifdef DRVSEP 1571 if (!q && HAS_DRV(argv0)) 1572 q = strchr(argv0, DRVSEP); 1573 #endif 1574 1565 1575 if (q == NULL) 1566 1576 argv0 = link; /* argv0 without path */ … … 1568 1578 /* Must make a copy */ 1569 1579 strcpy(argv0copy, argv0); 1570 q = strrchr(argv0copy, SEP);1580 q = &argv0copy[q - argv0]; 1571 1581 strcpy(q+1, link); 1572 1582 argv0 = argv0copy; … … 1609 1619 #endif 1610 1620 p = strrchr(argv0, SEP); 1621 #ifdef ALTSEP 1622 { 1623 char *p2 = strrchr(p ? p : argv0, ALTSEP); 1624 if (p2 != NULL) 1625 p = p2; 1626 } 1627 #endif 1628 #ifdef DRVSEP 1629 if (p == NULL && HAS_DRV(argv0)) 1630 p = strchr(argv0, DRVSEP); 1631 #endif 1611 1632 } 1612 1633 if (p != NULL) { -
python/trunk/Python/traceback.c
r2 r10 158 158 if (strlen(namebuf) != len) 159 159 continue; /* v contains '\0' */ 160 if (len > 0 && namebuf[len-1] != SEP)160 if (len > 0 && IS_SEP(namebuf[len-1])) 161 161 namebuf[len++] = SEP; 162 162 strcpy(namebuf+len, tail); -
python/trunk/configure
r2 r10 698 698 LDLIBRARYDIR 699 699 INSTSONAME 700 CONDENSED_VERSION 700 701 RUNSHARED 701 702 LINKCC … … 2106 2107 atheos*) MACHDEP="atheos";; 2107 2108 irix646) MACHDEP="irix6";; 2109 os2*|OS/2*|emx*) MACHDEP="os2knix";; 2108 2110 '') MACHDEP="unknown";; 2109 2111 esac … … 4013 4015 LDLIBRARYDIR='' 4014 4016 RUNSHARED='' 4017 CONDENSED_VERSION=`echo "${VERSION}" | tr -d .,"` 4015 4018 4016 4019 # LINKCC is the command that links the python executable -- default is $(CC). … … 4056 4059 then 4057 4060 case $ac_sys_system in 4058 CYGWIN* | atheos* )4061 CYGWIN* | atheos* | *OS/2* | *emx* | *os2*) 4059 4062 enable_shared="yes";; 4060 4063 *) … … 4205 4208 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' 4206 4209 ;; 4210 OS/2*|os2*|*emx*) 4211 LDLIBRARY='python$(VERSION)_dll.a' 4212 BLDLIBRARY='-L. -lpython$(VERSION)' 4213 RUNSHARED=BEGINLIBPATH="'`pwd`;$BEGINLIBPATH'" 4214 DLLLIBRARY='python${CONDENSED_VERSION}.dll' 4215 ;; 4207 4216 4208 4217 esac … … 4533 4542 CYGWIN*) LN="ln -s";; 4534 4543 atheos*) LN="ln -s";; 4544 OS/2*|os2*|*emx*) LN="ln -s";; 4535 4545 *) LN=ln;; 4536 4546 esac … … 13192 13202 ;; 13193 13203 CYGWIN*) SO=.dll;; 13204 OS/2*|os2*|*emx*) SO=.dll;; 13194 13205 *) SO=.so;; 13195 13206 esac … … 13322 13333 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; 13323 13334 atheos*) LDSHARED="gcc -shared";; 13335 OS/2*|os2*|*emx*) LDSHARED="gcc -Zdll -Zomf";; 13324 13336 *) LDSHARED="ld";; 13325 13337 esac … … 25911 25923 INSTSONAME!$INSTSONAME$ac_delim 25912 25924 RUNSHARED!$RUNSHARED$ac_delim 25925 CONDENSED_VERSION!$CONDENSED_VERSION$ac_delim 25913 25926 LINKCC!$LINKCC$ac_delim 25914 25927 RANLIB!$RANLIB$ac_delim … … 25928 25941 _ACEOF 25929 25942 25930 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9 7; then25943 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 98; then 25931 25944 break 25932 25945 elif $ac_last_try; then -
python/trunk/pyconfig.h.in
r2 r10 1092 1092 #endif 1093 1093 1094 #if defined(__EMX__) 1095 #define PLATFORM "os2knix" 1096 #define PYOS_OS2 1 1097 #define PYCC_GCC 1 1098 #undef HAVE_LINK // YD not working but available 1099 #endif 1100 1094 1101 #endif /*Py_PYCONFIG_H*/ 1095 1102 -
python/trunk/setup.py
r2 r10 383 383 inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) 384 384 385 # Check for OS/2 which may have libraries in non-standard locations 386 if platform == 'os2knix': 387 lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) 388 inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) 385 389 # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) 386 390 if platform in ['osf1', 'unixware7', 'openunix8']: … … 517 521 518 522 # Memory-mapped files (also works on Win32). 519 if platform not in ['atheos', 'mac' ]:523 if platform not in ['atheos', 'mac', 'os2knix']: 520 524 exts.append( Extension('mmap', ['mmapmodule.c']) ) 521 525 else: … … 868 872 db_incs = [db_incdir] 869 873 dblibs = [dblib] 874 # YD add required libs 875 if os.name == "os2": 876 dblibs += ["mmap", "pthread"] 870 877 # We add the runtime_library_dirs argument because the 871 878 # BerkeleyDB lib we're linking against often isn't in the … … 1069 1076 1070 1077 # Sun yellow pages. Some systems have the functions in libc. 1071 if (platform not in ['cygwin', 'atheos', 'qnx6' ] and1078 if (platform not in ['cygwin', 'atheos', 'qnx6', 'os2knix'] and 1072 1079 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): 1073 1080 if (self.compiler.find_library_file(lib_dirs, 'nsl')): … … 1288 1295 libraries = [] 1289 1296 1297 elif platform in ('os2knix'): 1298 # FreeBSD's P1003.1b semaphore support is very experimental 1299 # and has many known problems. (as of June 2008) 1300 macros = dict( # FreeBSD 1301 HAVE_SEM_OPEN=0, 1302 HAVE_SEM_TIMEDWAIT=0, 1303 ) 1304 libraries = [] 1290 1305 elif platform.startswith('openbsd'): 1291 1306 macros = dict( # OpenBSD
Note:
See TracChangeset
for help on using the changeset viewer.