summaryrefslogtreecommitdiff
path: root/Mac/Tools
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-09 15:52:27 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-09 15:52:27 +0000
commit567b94adaaceb622c33f9be1998735dfb95f1707 (patch)
tree435e6e81b103b098c38ca2d5cfc20c27d4e17b54 /Mac/Tools
parent043c1cd9525013647c193ccf8686635f09eb4cbf (diff)
downloadcpython-567b94adaaceb622c33f9be1998735dfb95f1707.tar.gz
Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
Diffstat (limited to 'Mac/Tools')
-rw-r--r--Mac/Tools/pythonw.c172
1 files changed, 86 insertions, 86 deletions
diff --git a/Mac/Tools/pythonw.c b/Mac/Tools/pythonw.c
index 1f3e0ce55f..8da6f47d3a 100644
--- a/Mac/Tools/pythonw.c
+++ b/Mac/Tools/pythonw.c
@@ -39,8 +39,8 @@ extern char** environ;
* In a regular framework the structure is:
*
* Python.framework/Versions/2.7
- * /Python
- * /Resources/Python.app/Contents/MacOS/Python
+ * /Python
+ * /Resources/Python.app/Contents/MacOS/Python
*
* In a virtualenv style structure the expected
* structure is:
@@ -50,121 +50,121 @@ extern char** environ;
* /.Python <- the dylib
* /.Resources/Python.app/Contents/MacOS/Python
*
- * NOTE: virtualenv's are not an officially supported
+ * NOTE: virtualenv's are not an officially supported
* feature, support for that structure is provided as
* a convenience.
*/
static char* get_python_path(void)
{
- size_t len;
- Dl_info info;
- char* end;
- char* g_path;
-
- if (dladdr(Py_Initialize, &info) == 0) {
- return NULL;
- }
-
- len = strlen(info.dli_fname);
-
- g_path = malloc(len+60);
- if (g_path == NULL) {
- return NULL;
- }
-
- strcpy(g_path, info.dli_fname);
- end = g_path + len - 1;
- while (end != g_path && *end != '/') {
- end --;
- }
- end++;
- if (*end == '.') {
- end++;
- }
- strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK);
-
- return g_path;
+ size_t len;
+ Dl_info info;
+ char* end;
+ char* g_path;
+
+ if (dladdr(Py_Initialize, &info) == 0) {
+ return NULL;
+ }
+
+ len = strlen(info.dli_fname);
+
+ g_path = malloc(len+60);
+ if (g_path == NULL) {
+ return NULL;
+ }
+
+ strcpy(g_path, info.dli_fname);
+ end = g_path + len - 1;
+ while (end != g_path && *end != '/') {
+ end --;
+ }
+ end++;
+ if (*end == '.') {
+ end++;
+ }
+ strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK);
+
+ return g_path;
}
#ifdef HAVE_SPAWN_H
static void
setup_spawnattr(posix_spawnattr_t* spawnattr)
{
- size_t ocount;
- size_t count;
- cpu_type_t cpu_types[1];
- short flags = 0;
+ size_t ocount;
+ size_t count;
+ cpu_type_t cpu_types[1];
+ short flags = 0;
#ifdef __LP64__
- int ch;
+ int ch;
#endif
- if ((errno = posix_spawnattr_init(spawnattr)) != 0) {
- err(2, "posix_spawnattr_int");
- /* NOTREACHTED */
- }
+ if ((errno = posix_spawnattr_init(spawnattr)) != 0) {
+ err(2, "posix_spawnattr_int");
+ /* NOTREACHTED */
+ }
- count = 1;
+ count = 1;
- /* Run the real python executable using the same architure as this
- * executable, this allows users to controle the architecture using
- * "arch -ppc python"
- */
+ /* Run the real python executable using the same architure as this
+ * executable, this allows users to controle the architecture using
+ * "arch -ppc python"
+ */
#if defined(__ppc64__)
- cpu_types[0] = CPU_TYPE_POWERPC64;
+ cpu_types[0] = CPU_TYPE_POWERPC64;
#elif defined(__x86_64__)
- cpu_types[0] = CPU_TYPE_X86_64;
+ cpu_types[0] = CPU_TYPE_X86_64;
#elif defined(__ppc__)
- cpu_types[0] = CPU_TYPE_POWERPC;
+ cpu_types[0] = CPU_TYPE_POWERPC;
#elif defined(__i386__)
- cpu_types[0] = CPU_TYPE_X86;
+ cpu_types[0] = CPU_TYPE_X86;
#else
-# error "Unknown CPU"
+# error "Unknown CPU"
#endif
- if (posix_spawnattr_setbinpref_np(spawnattr, count,
- cpu_types, &ocount) == -1) {
- err(1, "posix_spawnattr_setbinpref");
- /* NOTREACHTED */
- }
- if (count != ocount) {
- fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n");
- exit(1);
- /* NOTREACHTED */
- }
-
-
- /*
- * Set flag that causes posix_spawn to behave like execv
- */
- flags |= POSIX_SPAWN_SETEXEC;
- if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) {
- err(1, "posix_spawnattr_setflags");
- /* NOTREACHTED */
- }
+ if (posix_spawnattr_setbinpref_np(spawnattr, count,
+ cpu_types, &ocount) == -1) {
+ err(1, "posix_spawnattr_setbinpref");
+ /* NOTREACHTED */
+ }
+ if (count != ocount) {
+ fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n");
+ exit(1);
+ /* NOTREACHTED */
+ }
+
+
+ /*
+ * Set flag that causes posix_spawn to behave like execv
+ */
+ flags |= POSIX_SPAWN_SETEXEC;
+ if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) {
+ err(1, "posix_spawnattr_setflags");
+ /* NOTREACHTED */
+ }
}
#endif
-int
+int
main(int argc, char **argv) {
- char* exec_path = get_python_path();
+ char* exec_path = get_python_path();
#ifdef HAVE_SPAWN_H
- /* We're weak-linking to posix-spawnv to ensure that
- * an executable build on 10.5 can work on 10.4.
- */
- if (posix_spawn != NULL) {
- posix_spawnattr_t spawnattr = NULL;
-
- setup_spawnattr(&spawnattr);
- posix_spawn(NULL, exec_path, NULL,
- &spawnattr, argv, environ);
- err(1, "posix_spawn: %s", exec_path);
- }
+ /* We're weak-linking to posix-spawnv to ensure that
+ * an executable build on 10.5 can work on 10.4.
+ */
+ if (posix_spawn != NULL) {
+ posix_spawnattr_t spawnattr = NULL;
+
+ setup_spawnattr(&spawnattr);
+ posix_spawn(NULL, exec_path, NULL,
+ &spawnattr, argv, environ);
+ err(1, "posix_spawn: %s", exec_path);
+ }
#endif
- execve(exec_path, argv, environ);
- err(1, "execve: %s", argv[0]);
- /* NOTREACHED */
+ execve(exec_path, argv, environ);
+ err(1, "execve: %s", argv[0]);
+ /* NOTREACHED */
}