From 09c0b715ee987364ac5921e9ef7ff0e0040f8479 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Tue, 30 Oct 2018 10:30:05 +0900 Subject: [PATCH] Imported Upstream version 3.27.5 --- ChangeLog | 343 +++++++++++++++++++++++++++++ MANIFEST.in | 2 +- NEWS | 9 + PKG-INFO | 2 +- config.guess | 487 ++++++++++++++++++++++-------------------- config.sub | 203 +++++++----------- configure | 24 +-- configure.ac | 2 +- gi/gimodule.c | 6 +- gi/overrides/GLib.py | 4 + gi/overrides/GObject.py | 3 - gi/pygi-array.c | 86 +++++--- gi/pygi-basictype.c | 8 +- gi/pygi-basictype.h | 3 +- gi/pygi-boxed.c | 40 ++-- gi/pygi-boxed.h | 4 +- gi/pygi-cache.h | 13 +- gi/pygi-closure.c | 9 +- gi/pygi-enum-marshal.c | 6 +- gi/pygi-error.c | 5 +- gi/pygi-hashtable.c | 13 +- gi/pygi-info.c | 2 +- gi/pygi-invoke-state-struct.h | 3 + gi/pygi-invoke.c | 17 +- gi/pygi-list.c | 67 ++++-- gi/pygi-marshal-cleanup.c | 13 +- gi/pygi-object.c | 8 +- gi/pygi-property.c | 6 +- gi/pygi-source.c | 6 +- gi/pygi-struct-marshal.c | 147 +++++-------- gi/pygi-type.c | 2 +- gi/pyglib-python-compat.h | 17 ++ gi/pygtype.c | 41 +++- setup.cfg | 7 + tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/compathelper.py | 5 + tests/conftest.py | 31 +++ tests/regressextra.c | 51 +++++ tests/regressextra.h | 7 + tests/test_atoms.py | 2 + tests/test_everything.py | 22 ++ tests/test_glib.py | 13 ++ tests/test_mainloop.py | 28 +-- tests/test_option.py | 18 +- tests/test_source.py | 8 +- 46 files changed, 1163 insertions(+), 632 deletions(-) create mode 100644 tests/conftest.py diff --git a/ChangeLog b/ChangeLog index 91bbad9..6bd8452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,291 @@ +commit 7e571ea62074243eef36110c240e192e5682a687 +Author: Christoph Reiter +Date: Thu Mar 1 17:57:08 2018 +0100 + + release + + NEWS | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit 1138bc7e0aeb8d4e7354c6cfd5a63edaa724d3fb +Author: Christoph Reiter +Date: Tue Feb 27 12:46:11 2018 +0100 + + setup.py: fix distcheck + + MANIFEST.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 79ee93ea667c7a2cdacf9c770c0e60dc624ced0b +Author: Christoph Reiter +Date: Fri Feb 23 18:15:55 2018 +0100 + + coverage: exclude external headers. See #168 + + While we could just pass --no-external we want the coverage of + the gobject-introspection files. + + .gitlab-ci/coverage-docker.sh | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 9ae49b49850dca86566b745966104bdd33914df7 +Author: Christoph Reiter +Date: Fri Feb 23 17:33:55 2018 +0100 + + coverage.py: ignore errors + + not sure where that path is comming from, it worked in the MR.. + + .gitlab-ci/coverage-docker.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2d812a6bc4d0952997a3ed3c63c4b09d8c95c103 +Author: Christoph Reiter +Date: Fri Feb 23 11:02:03 2018 +0100 + + gitlab-ci: Add Windows coverage support. See #168 + + Use coverage.py and cygwin lcov to generate coverage files. + In the report generation step fixup the Windows paths in the coverage + files to match the Linux/Docker ones. + + .gitlab-ci.yml | 42 + +++++++++++++++++++++++++++--------------- + .gitlab-ci/coverage-docker.sh | 3 +++ + .gitlab-ci/fixup-cov-paths.py | 35 +++++++++++++++++++++++++++++++++++ + .gitlab-ci/test-docker.sh | 5 +++++ + .gitlab-ci/test-msys2.sh | 33 +++++++++++++++++++++++++++++++-- + 5 files changed, 101 insertions(+), 17 deletions(-) + +commit 1534289ce5934b73b5c980f8e246192009337776 +Author: Christoph Reiter +Date: Tue Feb 20 16:38:25 2018 +0100 + + gitlab-ci: Add MSYS2 test jobs + + This assumes a gitlab runner with a "win32" tag which has + MSYS2 installed in the default path and uses the "cmd" shell. + + .gitlab-ci.yml | 32 +++++++++++++++++++++++++++----- + .gitlab-ci/test-msys2.sh | 28 ++++++++++++++++++++++++++++ + 2 files changed, 55 insertions(+), 5 deletions(-) + +commit 20fa66387020877a3ae20a6b48bba52153c7bd6c +Author: Christoph Reiter +Date: Tue Feb 20 18:17:15 2018 +0100 + + tests: skip one more GdkAtom test on Windows + + This has started to crash with newer gtk + + tests/test_atoms.py | 2 ++ + 1 file changed, 2 insertions(+) + +commit d3cd49ce8777312cbb91b82bd076c0e4b761c848 +Merge: 5ec1aea8 aab23dbd +Author: Christoph Reiter +Date: Sun Feb 18 08:32:22 2018 +0000 + + Merge branch 'gilabissue123' into 'master' + + Performance improvements to avoid GIL congestion + + See merge request GNOME/pygobject!13 + +commit 5ec1aea8ab4599a7a0945bd5754ce79c7c5cbef3 +Author: Christoph Reiter +Date: Sat Feb 17 18:13:47 2018 +0100 + + coverage: don't just use the major python version number for coverage + files names + + all py3 jobs wrote to the same file, oops.. + + .gitlab-ci/test-docker.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit af7aa11acebd9a34e6aee41dc77c0d7c3000fd47 +Author: Christoph Reiter +Date: Sat Feb 17 15:23:49 2018 +0100 + + gitlab-ci: Add coverage reports + + Use gcov/lcov and coverage.py; merge all results and provide + the final html reports as job artifacts. + + .gitignore | 1 + + .gitlab-ci.yml | 18 ++++++++++++++++++ + .gitlab-ci/Dockerfile | 1 + + .gitlab-ci/coverage-docker.sh | 17 +++++++++++++++++ + .gitlab-ci/test-docker.sh | 20 ++++++++++++++++---- + setup.cfg | 7 +++++++ + 6 files changed, 60 insertions(+), 4 deletions(-) + +commit 8df9570b7f25ceaaa590c8da33952a7bdeade203 +Author: Mathieu Duponchelle +Date: Fri Feb 16 16:54:06 2018 +0100 + + array, list: always run items cleanup funcs + + gi/pygi-array.c | 70 + ++++++++++++++++++++++++++++++++------------------------- + gi/pygi-list.c | 37 +++++++++++++++--------------- + 2 files changed, 58 insertions(+), 49 deletions(-) + +commit 9978b521450d9b2a038d48492550dcab49c7b113 +Author: Mathieu Duponchelle +Date: Fri Feb 16 00:49:25 2018 +0100 + + pygi-struct-marshal: perform boxed copy ... + + when the cleanup marshaller will not be called, that is when + marshalling something that is not actually an argument. + + Fixes #164 + + gi/pygi-struct-marshal.c | 48 + ++++++++++++++++++++++++++++++++---------------- + 1 file changed, 32 insertions(+), 16 deletions(-) + +commit e41dd91e9e62eeaeaa0fee97b50500591a87b249 +Author: Mathieu Duponchelle +Date: Thu Feb 15 23:32:37 2018 +0100 + + Revert "Revert "to python struct marshalling: copy boxed during + cleanup"" + + This reverts commit 10c062001ddd948b0a70545cbf613b38ed6fa46c. + + gi/pygi-struct-marshal.c | 34 +++++++++++++++++++++++++++------- + tests/test_gi.py | 1 - + 2 files changed, 27 insertions(+), 8 deletions(-) + +commit b1d1c8d9d8820fe405bddd8e9dea88b5ec2fcce2 +Author: Mathieu Duponchelle +Date: Thu Feb 15 23:32:20 2018 +0100 + + Revert "Revert "to python marshalling: collect cleanup data"" + + This reverts commit fa555767464fbe551b14cfbc121febc5290b1371. + + gi/pygi-array.c | 24 ++++++++++++++++++------ + gi/pygi-basictype.c | 8 +++++--- + gi/pygi-basictype.h | 3 ++- + gi/pygi-cache.h | 13 ++++++++++--- + gi/pygi-closure.c | 9 +++++++-- + gi/pygi-enum-marshal.c | 6 ++++-- + gi/pygi-error.c | 3 ++- + gi/pygi-hashtable.c | 13 +++++++++---- + gi/pygi-invoke-state-struct.h | 3 +++ + gi/pygi-invoke.c | 17 +++++++++++++---- + gi/pygi-list.c | 38 +++++++++++++++++++++++++++++++------- + gi/pygi-marshal-cleanup.c | 13 ++++++++----- + gi/pygi-object.c | 8 +++++--- + gi/pygi-struct-marshal.c | 5 +++-- + 14 files changed, 120 insertions(+), 43 deletions(-) + +commit 26b7fc3fee55870cc944b0f718da8a75c75f4eae +Author: Mathieu Duponchelle +Date: Fri Feb 16 00:45:40 2018 +0100 + + Revert "Revert "pygi-boxed: make in-place copy safer"" + + This reverts commit 700c785367975995d24a8ffd00b2aa028ccf77e8. + + gi/pygi-boxed.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit d08e244d011121f8ffd5c21437e0f11fe9545bbf +Author: Mathieu Duponchelle +Date: Thu Feb 15 23:32:08 2018 +0100 + + Revert "Revert "Revert "Refactor boxed wrapper memory management + strategy""" + + This reverts commit a506d5e3c64321c43a4ce7c2a72ca8d36e985999. + + gi/gimodule.c | 6 +--- + gi/overrides/GLib.py | 4 +++ + gi/overrides/GObject.py | 3 -- + gi/pygi-boxed.c | 32 +++++--------------- + gi/pygi-boxed.h | 4 +-- + gi/pygi-property.c | 6 +++- + gi/pygi-source.c | 6 ++-- + gi/pygi-struct-marshal.c | 78 + ++++-------------------------------------------- + tests/test_gi.py | 1 + + tests/test_source.py | 8 ++--- + 10 files changed, 29 insertions(+), 119 deletions(-) + +commit c56b4510649dae58519681c1a53aed85d598139e +Author: Christoph Reiter +Date: Fri Feb 16 17:43:00 2018 +0100 + + tests: add tests for boxed in GLists. See !24 + + tests/regressextra.c | 33 +++++++++++++++++++++++++++++++++ + tests/regressextra.h | 4 ++++ + tests/test_everything.py | 16 ++++++++++++++++ + 3 files changed, 53 insertions(+) + +commit 9c3cb6b49c33f53d637e80aad68a67e89d0eb944 +Author: Christoph Reiter +Date: Fri Feb 16 10:12:42 2018 +0100 + + gitlab-ci: use ccache + + .gitlab-ci.yml | 9 +++++++++ + .gitlab-ci/Dockerfile | 3 +++ + .gitlab-ci/run-docker.sh | 6 ++++-- + 3 files changed, 16 insertions(+), 2 deletions(-) + +commit 91a25c2aa1776e5e5757dc317a798615c31b3854 +Author: Christoph Reiter +Date: Fri Feb 16 09:59:31 2018 +0100 + + tests: Add a test for a out transfer-none boxed array + + Makes sure we copy the array items as well. + + tests/regressextra.c | 18 ++++++++++++++++++ + tests/regressextra.h | 3 +++ + tests/test_everything.py | 6 ++++++ + 3 files changed, 27 insertions(+) + +commit e00e38f9c44568f7fab643a069f86c576011ddcc +Author: Christoph Reiter +Date: Fri Feb 16 08:49:38 2018 +0100 + + tests: add a pytest hook for handling unhandled exception in closures + + In PyGObject when an exception is raised in a closure called from + C then + the error gets passed to sys.excepthook (on the main thread at least) + and the error is by default printed to stdout. Since pytest by default + hides stdout, errors can be easily missed now. + + To make these errors more visible add a test wrapper which checks + sys.excepthook for unhandled exceptions and reraises them. + This makes the tests fail and as a bonus also shows the right + stack trace instead of just the error message. + + tests/Makefile.am | 1 + + tests/compathelper.py | 5 +++++ + tests/conftest.py | 31 +++++++++++++++++++++++++++++++ + tests/test_glib.py | 13 +++++++++++++ + tests/test_mainloop.py | 28 ++++++++-------------------- + tests/test_option.py | 18 +++++++----------- + 6 files changed, 65 insertions(+), 31 deletions(-) + +commit aae383cf44ee3eabcc4b4122049ea277524d5001 +Author: Christoph Reiter +Date: Wed Feb 14 02:15:54 2018 +0100 + + version bump + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + commit 9c1d66be67008604206e336a0433c5cdf824b837 Author: Christoph Reiter Date: Wed Feb 14 01:47:12 2018 +0100 @@ -427,6 +715,61 @@ Date: Tue Feb 6 15:24:17 2018 +0100 tests/test_everything.py | 31 +++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 3 deletions(-) +commit aab23dbdb38c5c316c1939410e0301aa8b262143 +Author: Mikhail Fludkov +Date: Wed Feb 7 16:03:42 2018 +0100 + + gi/pygtype.c: avoid GIL congestion in pyg_type_lookup + + https://gitlab.gnome.org/GNOME/pygobject/issues/123 + + GIL congestion can be caused when many threads emit signals with + objects of + boxed type up to Python. The code in pyg_type_lookup imports a + python module + corresponding to gtype, which is expensive and can cause GIL + congestion. What + the proposed patch of pyg_type_lookup does: + + - pygi_type_import_by_g_type is called only once per a gtype + - early NULL return. For example GStreamer types benefit greatly + from it. + Because pyg_register_gtype_custom is not used and pyg_type_lookup + always + returns NULL for such types. + + gi/pygtype.c | 41 ++++++++++++++++++++++++++++++++++++----- + 1 file changed, 36 insertions(+), 5 deletions(-) + +commit 080e1a8e8c130a94b5662770621dea2ad1646b3a +Author: Mikhail Fludkov +Date: Wed Feb 7 16:36:26 2018 +0100 + + Use optimized version of PyImport_ImportModule + + https://gitlab.gnome.org/GNOME/pygobject/issues/123 + + You would expect PyImport_ImportModule to import a module once, store + it's reference to sys.modules and the next time we call it with + the same + argument reuse the reference from sys.module. But it is not what is + happening unfortunately. + + Everytime we call it it releases GIL, grabs global python import lock, + grabs GIL back. The proposed optimization looks at sys.modules + first and + uses the reference from there to avoid GIL congestion. pyg_type_lookup + is + a good example of a function which imports python modules at run + time and + can cause GIL congestion. + + gi/pygi-error.c | 2 +- + gi/pygi-info.c | 2 +- + gi/pygi-type.c | 2 +- + gi/pyglib-python-compat.h | 17 +++++++++++++++++ + 4 files changed, 20 insertions(+), 3 deletions(-) + commit ee79fef18748ad660d3a0471ed9a18ea11410849 Author: Christoph Reiter Date: Wed Feb 7 11:55:54 2018 +0100 diff --git a/MANIFEST.in b/MANIFEST.in index e8aeecb..bddf19a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,4 +16,4 @@ recursive-include gi *.am *.h recursive-include pygtkcompat *.am recursive-include tests *.py *.c *.h *.xml *.supp *.am recursive-include docs *.rst *.svg LICENSE *.ico *.png *.css *.py *.dia Makefile -recursive-include .gitlab-ci *.sh *.rst Dockerfile +recursive-include .gitlab-ci *.sh *.rst *.py Dockerfile diff --git a/NEWS b/NEWS index 6a57419..df7996a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +3.27.5 - 2018-03-01 +------------------- + +* Re-revert transfer-none boxed copy changes (:mr:`23`). Now with more fixes + and tests. :mr:`24` (:user:`Mathieu Duponchelle `) +* Add caching for boxed type lookup and try to avoid the import lock. :mr:`13` + (:user:`Mikhail Fludkov `) + + 3.27.4 - 2018-02-14 ------------------- diff --git a/PKG-INFO b/PKG-INFO index 6e6f47d..b1fb3a4 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: PyGObject -Version: 3.27.4 +Version: 3.27.5 Summary: Python bindings for GObject Introspection Home-page: https://pygobject.readthedocs.io Author: James Henstridge diff --git a/config.guess b/config.guess index 31e01ef..f50dcdb 100755 --- a/config.guess +++ b/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2017-11-07' +timestamp='2018-02-24' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -107,9 +107,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -132,14 +132,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc @@ -149,13 +149,20 @@ Linux|GNU|GNU/*) LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -169,30 +176,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -208,10 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -219,52 +226,55 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "$machine-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) - echo ${UNAME_MACHINE}-unknown-midnightbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix + echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Redox:*:*) - echo ${UNAME_MACHINE}-unknown-redox + echo "$UNAME_MACHINE"-unknown-redox exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -316,7 +326,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 @@ -325,10 +335,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -340,7 +350,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -367,19 +377,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build + eval "$set_cc_for_build" SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. @@ -392,13 +402,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -407,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -436,44 +446,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -494,11 +504,11 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -524,17 +534,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -551,7 +561,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -563,14 +573,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -581,7 +591,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -595,7 +605,7 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc @@ -604,9 +614,9 @@ EOF IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix @@ -615,7 +625,7 @@ EOF echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -630,28 +640,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in + case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in + case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -684,13 +694,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -709,15 +719,15 @@ EOF HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -742,7 +752,7 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; @@ -763,9 +773,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -790,109 +800,109 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + echo "$UNAME_MACHINE"-pc-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -906,63 +916,63 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el @@ -976,70 +986,74 @@ EOF #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + if objdump -f /bin/sh | grep -q elf32-x86-64; then + echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 + else + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + fi exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1053,34 +1067,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1090,12 +1104,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1105,9 +1119,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1127,9 +1141,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1149,9 +1163,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1160,28 +1174,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1192,7 +1206,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1212,23 +1226,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1247,39 +1261,39 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build + eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ @@ -1307,7 +1321,7 @@ EOF # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` @@ -1315,22 +1329,25 @@ EOF UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1339,7 +1356,7 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 @@ -1350,7 +1367,7 @@ EOF else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1371,14 +1388,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1387,16 +1404,16 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs @@ -1405,7 +1422,7 @@ esac echo "$0: unable to guess system type" >&2 -case "${UNAME_MACHINE}:${UNAME_SYSTEM}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 </dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 diff --git a/config.sub b/config.sub index 00f68b8..1d8e98b 100755 --- a/config.sub +++ b/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2017-11-23' +timestamp='2018-02-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -67,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -94,7 +94,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -112,7 +112,7 @@ esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ @@ -120,16 +120,16 @@ case $maybe_os in kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` + basic_machine=`echo "$1" | sed 's/-[^-]*$//'` + if [ "$basic_machine" != "$1" ] + then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac @@ -178,44 +178,44 @@ case $os in ;; -sco6) os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 @@ -227,7 +227,7 @@ case $os in os=-lynxos ;; -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos @@ -296,7 +296,7 @@ case $basic_machine in | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ + | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ @@ -333,7 +333,7 @@ case $basic_machine in basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; ms1) basic_machine=mt-unknown @@ -362,7 +362,7 @@ case $basic_machine in ;; # Object if more than one company name word. *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. @@ -457,7 +457,7 @@ case $basic_machine in # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) - basic_machine=i386-unknown + basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) @@ -491,7 +491,7 @@ case $basic_machine in basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl @@ -536,7 +536,7 @@ case $basic_machine in os=-linux ;; blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) @@ -544,13 +544,13 @@ case $basic_machine in os=-cnk ;; c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray @@ -648,7 +648,7 @@ case $basic_machine in os=$os"spe" ;; e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=$os"spe" ;; ebmon29k) @@ -740,9 +740,6 @@ case $basic_machine in hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; hppaosf) basic_machine=hppa1.1-hp os=-osf @@ -755,26 +752,26 @@ case $basic_machine in basic_machine=i370-ibm ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; - i386-vsta | vsta) + vsta) basic_machine=i386-unknown os=-vsta ;; @@ -793,19 +790,16 @@ case $basic_machine in os=-sysv ;; leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; - m88k-omron*) - basic_machine=m88k-omron - ;; magnum | m3230) basic_machine=mips-mips os=-sysv @@ -837,10 +831,10 @@ case $basic_machine in os=-mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k @@ -859,7 +853,7 @@ case $basic_machine in os=-msdos ;; ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc @@ -946,6 +940,9 @@ case $basic_machine in nsr-tandem) basic_machine=nsr-tandem ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; nsx-tandem) basic_machine=nsx-tandem ;; @@ -981,7 +978,7 @@ case $basic_machine in os=-linux ;; parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) @@ -997,7 +994,7 @@ case $basic_machine in basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc @@ -1012,16 +1009,16 @@ case $basic_machine in basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould @@ -1031,23 +1028,23 @@ case $basic_machine in ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm @@ -1101,17 +1098,10 @@ case $basic_machine in sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; sh5el) basic_machine=sh5le-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -1130,7 +1120,7 @@ case $basic_machine in os=-sysv4 ;; strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun @@ -1244,9 +1234,6 @@ case $basic_machine in basic_machine=a29k-wrs os=-vxworks ;; - wasm32) - basic_machine=wasm32-unknown - ;; w65*) basic_machine=w65-wdc os=-none @@ -1266,20 +1253,12 @@ case $basic_machine in basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; none) basic_machine=none-none os=-none @@ -1308,10 +1287,6 @@ case $basic_machine in vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; @@ -1321,9 +1296,6 @@ case $basic_machine in sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; @@ -1343,7 +1315,7 @@ case $basic_machine in # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac @@ -1351,10 +1323,10 @@ esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1377,15 +1349,16 @@ case $os in -solaris) os=-solaris2 ;; - -svr4*) - os=-sysv4 - ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; + # es1800 is here to avoid being matched by es* (a different OS) + -es1800*) + os=-ose + ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. @@ -1398,7 +1371,7 @@ case $os in | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ @@ -1409,14 +1382,15 @@ case $os in | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ + | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1433,12 +1407,12 @@ case $os in -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + -sim | -xray | -os68k* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc @@ -1447,10 +1421,10 @@ case $os in os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition @@ -1461,12 +1435,6 @@ case $os in -wince*) os=-wince ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; -utek*) os=-bsd ;; @@ -1513,7 +1481,7 @@ case $os in -oss*) os=-sysv3 ;; - -svr4) + -svr4*) os=-sysv4 ;; -svr3) @@ -1528,18 +1496,9 @@ case $os in -ose*) os=-ose ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; - -aros*) - os=-aros - ;; -zvmoe) os=-zvmoe ;; @@ -1568,7 +1527,7 @@ case $os in *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1664,9 +1623,6 @@ case $basic_machine in *-be) os=-beos ;; - *-haiku) - os=-haiku - ;; *-ibm) os=-aix ;; @@ -1721,9 +1677,6 @@ case $basic_machine in i370-*) os=-mvs ;; - *-next) - os=-nextstep3 - ;; *-gould) os=-sysv ;; @@ -1833,11 +1786,11 @@ case $basic_machine in vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$basic_machine$os" exit # Local variables: diff --git a/configure b/configure index 1dc4a67..0ea4390 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for pygobject 3.27.4. +# Generated by GNU Autoconf 2.69 for pygobject 3.27.5. # # Report bugs to . # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pygobject' PACKAGE_TARNAME='pygobject' -PACKAGE_VERSION='3.27.4' -PACKAGE_STRING='pygobject 3.27.4' +PACKAGE_VERSION='3.27.5' +PACKAGE_STRING='pygobject 3.27.5' PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject' PACKAGE_URL='https://wiki.gnome.org/Projects/PyGObject/' @@ -1418,7 +1418,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pygobject 3.27.4 to adapt to many kinds of systems. +\`configure' configures pygobject 3.27.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1489,7 +1489,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pygobject 3.27.4:";; + short | recursive ) echo "Configuration of pygobject 3.27.5:";; esac cat <<\_ACEOF @@ -1634,7 +1634,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pygobject configure 3.27.4 +pygobject configure 3.27.5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1912,7 +1912,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pygobject $as_me 3.27.4, which was +It was created by pygobject $as_me 3.27.5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2290,9 +2290,9 @@ $as_echo "#define PYGOBJECT_MINOR_VERSION 27" >>confdefs.h PYGOBJECT_MINOR_VERSION=27 -$as_echo "#define PYGOBJECT_MICRO_VERSION 4" >>confdefs.h +$as_echo "#define PYGOBJECT_MICRO_VERSION 5" >>confdefs.h -PYGOBJECT_MICRO_VERSION=4 +PYGOBJECT_MICRO_VERSION=5 ac_config_headers="$ac_config_headers config.h" @@ -2812,7 +2812,7 @@ fi # Define the identity of the package. PACKAGE='pygobject' - VERSION='3.27.4' + VERSION='3.27.5' cat >>confdefs.h <<_ACEOF @@ -16931,7 +16931,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pygobject $as_me 3.27.4, which was +This file was extended by pygobject $as_me 3.27.5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16998,7 +16998,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -pygobject config.status 3.27.4 +pygobject config.status 3.27.5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 5c9d3f7..4ab326b 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ m4_define(python3_min_ver, 3.4) dnl the pygobject version number m4_define(pygobject_major_version, 3) m4_define(pygobject_minor_version, 27) -m4_define(pygobject_micro_version, 4) +m4_define(pygobject_micro_version, 5) m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version) dnl versions of packages we require ... diff --git a/gi/gimodule.c b/gi/gimodule.c index 5f8853c..48ddee2 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -535,11 +535,7 @@ _wrap_pyg_variant_type_from_string (PyObject *self, PyObject *args) py_type = _pygi_type_import_by_name ("GLib", "VariantType"); - /* Pass the string directly and force a boxed copy. This works because - * GVariantType is just a char pointer. */ - py_variant = _pygi_boxed_new ( (PyTypeObject *) py_type, type_string, - TRUE, /* copy_boxed */ - 0); /* slice_allocated */ + py_variant = _pygi_boxed_new ( (PyTypeObject *) py_type, type_string, FALSE, 0); return py_variant; } diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py index f47a338..b1ff24f 100644 --- a/gi/overrides/GLib.py +++ b/gi/overrides/GLib.py @@ -522,6 +522,10 @@ class Source(GLib.Source): def __init__(self, *args, **kwargs): return super(Source, self).__init__() + def __del__(self): + if hasattr(self, '__pygi_custom_source'): + self.unref() + def set_callback(self, fn, user_data=None): if hasattr(self, '__pygi_custom_source'): # use our custom pyg_source_set_callback() if for a GSource object diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py index c252bfa..bfcf7cc 100644 --- a/gi/overrides/GObject.py +++ b/gi/overrides/GObject.py @@ -221,9 +221,6 @@ class Value(GObjectModule.Value): if self._free_on_dealloc and self.g_type != TYPE_INVALID: self.unset() - # We must call base class __del__() after unset. - super(Value, self).__del__() - def set_boxed(self, boxed): # Workaround the introspection marshalers inability to know # these methods should be marshaling boxed types. This is because diff --git a/gi/pygi-array.c b/gi/pygi-array.c index e55f9f6..292515a 100644 --- a/gi/pygi-array.c +++ b/gi/pygi-array.c @@ -505,7 +505,8 @@ static PyObject * _pygi_marshal_to_py_array (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { GArray *array_; PyObject *py_obj = NULL; @@ -575,11 +576,14 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state, gsize item_size; PyGIMarshalToPyFunc item_to_py_marshaller; PyGIArgCache *item_arg_cache; + GPtrArray *item_cleanups; py_obj = PyList_New (array_->len); if (py_obj == NULL) goto err; + item_cleanups = g_ptr_array_sized_new (array_->len); + *cleanup_data = item_cleanups; item_arg_cache = seq_cache->item_cache; item_to_py_marshaller = item_arg_cache->to_py_marshaller; @@ -589,6 +593,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state, for (i = 0; i < array_->len; i++) { GIArgument item_arg = {0}; PyObject *py_item; + gpointer item_cleanup_data = NULL; /* If we are receiving an array of pointers, simply assign the pointer * and move on, letting the per-item marshaler deal with the @@ -632,7 +637,10 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state, py_item = item_to_py_marshaller ( state, callable_cache, item_arg_cache, - &item_arg); + &item_arg, + &item_cleanup_data); + + g_ptr_array_index (item_cleanups, i) = item_cleanup_data; if (py_item == NULL) { Py_CLEAR (py_obj); @@ -640,6 +648,8 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state, if (array_cache->array_type == GI_ARRAY_TYPE_C) g_array_unref (array_); + g_ptr_array_unref (item_cleanups); + goto err; } PyList_SET_ITEM (py_obj, i, py_item); @@ -660,7 +670,7 @@ err: /* clean up unprocessed items */ if (seq_cache->item_cache->to_py_cleanup != NULL) { guint j; - PyGIMarshalCleanupFunc cleanup_func = seq_cache->item_cache->to_py_cleanup; + PyGIMarshalToPyCleanupFunc cleanup_func = seq_cache->item_cache->to_py_cleanup; for (j = processed_items; j < array_->len; j++) { cleanup_func (state, seq_cache->item_cache, @@ -711,49 +721,59 @@ _wrap_c_array (PyGIInvokeState *state, static void _pygi_marshal_cleanup_to_py_array (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *dummy, + gpointer cleanup_data, gpointer data, gboolean was_processed) { + GArray *array_ = NULL; + GPtrArray *ptr_array_ = NULL; + PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache; + PyGIArgGArray *array_cache = (PyGIArgGArray *)arg_cache; + gboolean free_array = FALSE; + gboolean free_array_full = TRUE; + if (arg_cache->transfer == GI_TRANSFER_EVERYTHING || arg_cache->transfer == GI_TRANSFER_CONTAINER) { - GArray *array_ = NULL; - GPtrArray *ptr_array_ = NULL; - PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache; - PyGIArgGArray *array_cache = (PyGIArgGArray *)arg_cache; - - /* If this isn't a garray create one to help process variable sized - array elements */ - if (array_cache->array_type == GI_ARRAY_TYPE_C) { - array_ = _wrap_c_array (state, array_cache, data); + free_array = TRUE; + } - if (array_ == NULL) - return; + /* If this isn't a garray create one to help process variable sized + array elements */ + if (array_cache->array_type == GI_ARRAY_TYPE_C) { + array_ = _wrap_c_array (state, array_cache, data); - } else if (array_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY) { - ptr_array_ = (GPtrArray *) data; - } else { - array_ = (GArray *) data; - } + if (array_ == NULL) + return; - if (sequence_cache->item_cache->to_py_cleanup != NULL) { - gsize i; - guint len = (array_ != NULL) ? array_->len : ptr_array_->len; + free_array = TRUE; + free_array_full = FALSE; + } else if (array_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY) { + ptr_array_ = (GPtrArray *) data; + } else { + array_ = (GArray *) data; + } - PyGIMarshalCleanupFunc cleanup_func = sequence_cache->item_cache->to_py_cleanup; - for (i = 0; i < len; i++) { - cleanup_func (state, - sequence_cache->item_cache, - NULL, - (array_ != NULL) ? g_array_index (array_, gpointer, i) : g_ptr_array_index (ptr_array_, i), - was_processed); - } + if (sequence_cache->item_cache->to_py_cleanup != NULL) { + GPtrArray *item_cleanups = (GPtrArray *) cleanup_data; + gsize i; + guint len = (array_ != NULL) ? array_->len : ptr_array_->len; + + PyGIMarshalToPyCleanupFunc cleanup_func = sequence_cache->item_cache->to_py_cleanup; + for (i = 0; i < len; i++) { + cleanup_func (state, + sequence_cache->item_cache, + g_ptr_array_index(item_cleanups, i), + (array_ != NULL) ? g_array_index (array_, gpointer, i) : g_ptr_array_index (ptr_array_, i), + was_processed); } + g_ptr_array_unref (item_cleanups); + } + if (free_array) { if (array_ != NULL) - g_array_free (array_, TRUE); + g_array_free (array_, free_array_full); else - g_ptr_array_free (ptr_array_, TRUE); + g_ptr_array_free (ptr_array_, free_array_full); } } diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c index 6d4e64e..ddb02f9 100644 --- a/gi/pygi-basictype.c +++ b/gi/pygi-basictype.c @@ -684,7 +684,8 @@ static PyObject * _pygi_marshal_to_py_void (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { if (arg_cache->is_pointer) { return PyLong_FromVoidPtr (arg->v_pointer); @@ -828,7 +829,8 @@ PyObject * _pygi_marshal_to_py_basic_type_cache_adapter (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { return _pygi_marshal_to_py_basic_type (arg, arg_cache->type_tag, @@ -838,7 +840,7 @@ _pygi_marshal_to_py_basic_type_cache_adapter (PyGIInvokeState *state, static void _pygi_marshal_cleanup_to_py_utf8 (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *dummy, + gpointer cleanup_data, gpointer data, gboolean was_processed) { diff --git a/gi/pygi-basictype.h b/gi/pygi-basictype.h index 466c7d4..62f11c6 100644 --- a/gi/pygi-basictype.h +++ b/gi/pygi-basictype.h @@ -43,7 +43,8 @@ PyObject *_pygi_marshal_to_py_basic_type (GIArgument *arg, PyObject *_pygi_marshal_to_py_basic_type_cache_adapter (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg); + GIArgument *arg, + gpointer *cleanup_data); PyGIArgCache *pygi_arg_basic_type_new_from_info (GITypeInfo *type_info, GIArgInfo *arg_info, /* may be null */ diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index e9014f2..599d6d3 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -42,6 +42,8 @@ boxed_del (PyGIBoxed *self) if ( ( (PyGBoxed *) self)->free_on_dealloc && boxed != NULL) { if (self->slice_allocated) { g_slice_free1 (self->size, boxed); + self->slice_allocated = FALSE; + self->size = 0; } else { g_type = pyg_type_from_object ( (PyObject *) self); g_boxed_free (g_type, boxed); @@ -113,7 +115,7 @@ _boxed_new (PyTypeObject *type, goto out; } - self = (PyGIBoxed *) _pygi_boxed_new (type, boxed, FALSE, size); + self = (PyGIBoxed *) _pygi_boxed_new (type, boxed, TRUE, size); if (self == NULL) { g_slice_free1 (size, boxed); goto out; @@ -149,48 +151,30 @@ _boxed_init (PyObject *self, PYGLIB_DEFINE_TYPE("gi.Boxed", PyGIBoxed_Type, PyGIBoxed); PyObject * -_pygi_boxed_new (PyTypeObject *pytype, +_pygi_boxed_new (PyTypeObject *type, gpointer boxed, - gboolean copy_boxed, + gboolean free_on_dealloc, gsize allocated_slice) { PyGIBoxed *self; - GType gtype; if (!boxed) { Py_RETURN_NONE; } - if (!PyType_IsSubtype (pytype, &PyGIBoxed_Type)) { + if (!PyType_IsSubtype (type, &PyGIBoxed_Type)) { PyErr_SetString (PyExc_TypeError, "must be a subtype of gi.Boxed"); return NULL; } - gtype = pyg_type_from_object ((PyObject *)pytype); - - /* Boxed objects with slice allocation means they come from caller allocated - * out arguments. In this case copy_boxed does not make sense because we - * already own the slice allocated memory and we should be receiving full - * ownership transfer. */ - if (copy_boxed) { - g_assert (allocated_slice == 0); - boxed = g_boxed_copy (gtype, boxed); - } - - self = (PyGIBoxed *) pytype->tp_alloc (pytype, 0); + self = (PyGIBoxed *) type->tp_alloc (type, 0); if (self == NULL) { return NULL; } - /* We always free on dealloc because we always own the memory due to: - * 1) copy_boxed == TRUE - * 2) allocated_slice > 0 - * 3) otherwise the mode is assumed "transfer everything". - */ - ((PyGBoxed *)self)->free_on_dealloc = TRUE; - ((PyGBoxed *)self)->gtype = gtype; + ( (PyGBoxed *) self)->gtype = pyg_type_from_object ( (PyObject *) type); + ( (PyGBoxed *) self)->free_on_dealloc = free_on_dealloc; pyg_boxed_set_ptr (self, boxed); - if (allocated_slice > 0) { self->size = allocated_slice; self->slice_allocated = TRUE; @@ -221,7 +205,11 @@ void _pygi_boxed_copy_in_place (PyGIBoxed *self) { PyGBoxed *pygboxed = (PyGBoxed *)self; - gpointer copy = g_boxed_copy (pygboxed->gtype, pyg_boxed_get_ptr (self)); + gpointer ptr = pyg_boxed_get_ptr (self); + gpointer copy = NULL; + + if (ptr) + copy = g_boxed_copy (pygboxed->gtype, ptr); boxed_del (self); pyg_boxed_set_ptr (pygboxed, copy); diff --git a/gi/pygi-boxed.h b/gi/pygi-boxed.h index 8679322..5c04b5c 100644 --- a/gi/pygi-boxed.h +++ b/gi/pygi-boxed.h @@ -34,9 +34,9 @@ typedef struct { extern PyTypeObject PyGIBoxed_Type; -PyObject * _pygi_boxed_new (PyTypeObject *pytype, +PyObject * _pygi_boxed_new (PyTypeObject *type, gpointer boxed, - gboolean copy_boxed, + gboolean free_on_dealloc, gsize allocated_slice); void * _pygi_boxed_alloc (GIBaseInfo *info, diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h index 4dfabd8..574563b 100644 --- a/gi/pygi-cache.h +++ b/gi/pygi-cache.h @@ -50,14 +50,21 @@ typedef gboolean (*PyGIMarshalFromPyFunc) (PyGIInvokeState *state, typedef PyObject *(*PyGIMarshalToPyFunc) (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg); + GIArgument *arg, + gpointer *cleanup_data); typedef void (*PyGIMarshalCleanupFunc) (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *py_arg, /* always NULL for to_py cleanup */ + PyObject *py_arg, gpointer data, gboolean was_processed); +typedef void (*PyGIMarshalToPyCleanupFunc) (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer cleanup_data, + gpointer data, + gboolean was_processed); + /* Argument meta types denote how we process the argument: * - PYGI_META_ARG_TYPE_PARENT - parents may or may not have children * but are always processed via the normal marshaller for their @@ -118,7 +125,7 @@ struct _PyGIArgCache PyGIMarshalToPyFunc to_py_marshaller; PyGIMarshalCleanupFunc from_py_cleanup; - PyGIMarshalCleanupFunc to_py_cleanup; + PyGIMarshalToPyCleanupFunc to_py_cleanup; GDestroyNotify destroy_notify; diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c index b51c04c..42144e0 100644 --- a/gi/pygi-closure.c +++ b/gi/pygi-closure.c @@ -393,10 +393,14 @@ _pygi_closure_convert_arguments (PyGIInvokeState *state, } else if (arg_cache->meta_type != PYGI_META_ARG_TYPE_PARENT) { continue; } else { + gpointer cleanup_data = NULL; + value = arg_cache->to_py_marshaller (state, cache, arg_cache, - &state->args[i].arg_value); + &state->args[i].arg_value, + &cleanup_data); + state->args[i].to_py_arg_cleanup_data = cleanup_data; if (value == NULL) { pygi_marshal_cleanup_args_to_py_parameter_fail (state, @@ -800,7 +804,8 @@ static PyObject * _pygi_marshal_to_py_interface_callback (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *arg_cleanup_data) { PyGICallbackCache *callback_cache = (PyGICallbackCache *) arg_cache; gssize user_data_index; diff --git a/gi/pygi-enum-marshal.c b/gi/pygi-enum-marshal.c index 44eb009..fe6c7d7 100644 --- a/gi/pygi-enum-marshal.c +++ b/gi/pygi-enum-marshal.c @@ -225,7 +225,8 @@ static PyObject * _pygi_marshal_to_py_interface_enum (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { PyObject *py_obj = NULL; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; @@ -253,7 +254,8 @@ static PyObject * _pygi_marshal_to_py_interface_flags (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { PyObject *py_obj = NULL; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; diff --git a/gi/pygi-error.c b/gi/pygi-error.c index e3d8838..2639141 100644 --- a/gi/pygi-error.c +++ b/gi/pygi-error.c @@ -275,7 +275,8 @@ static PyObject * _pygi_marshal_to_py_gerror (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { GError *error = arg->v_pointer; PyObject *py_obj = NULL; @@ -375,7 +376,7 @@ pygerror_to_gvalue (GValue *value, PyObject *pyerror) void pygi_error_register_types (PyObject *module) { - PyObject *error_module = PyImport_ImportModule ("gi._error"); + PyObject *error_module = PYGLIB_PyImport_ImportModule ("gi._error"); if (!error_module) { return; } diff --git a/gi/pygi-hashtable.c b/gi/pygi-hashtable.c index 647bf04..f0cda78 100644 --- a/gi/pygi-hashtable.c +++ b/gi/pygi-hashtable.c @@ -220,7 +220,8 @@ static PyObject * _pygi_marshal_to_py_ghash (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { GHashTable *hash_; GHashTableIter hash_table_iter; @@ -259,6 +260,8 @@ _pygi_marshal_to_py_ghash (PyGIInvokeState *state, while (g_hash_table_iter_next (&hash_table_iter, &key_arg.v_pointer, &value_arg.v_pointer)) { + gpointer key_cleanup_data = NULL; + gpointer value_cleanup_data = NULL; PyObject *py_key; PyObject *py_value; int retval; @@ -268,7 +271,8 @@ _pygi_marshal_to_py_ghash (PyGIInvokeState *state, py_key = key_to_py_marshaller ( state, callable_cache, key_arg_cache, - &key_arg); + &key_arg, + &key_cleanup_data); if (py_key == NULL) { Py_CLEAR (py_obj); @@ -279,7 +283,8 @@ _pygi_marshal_to_py_ghash (PyGIInvokeState *state, py_value = value_to_py_marshaller ( state, callable_cache, value_arg_cache, - &value_arg); + &value_arg, + &value_cleanup_data); if (py_value == NULL) { Py_CLEAR (py_obj); @@ -304,7 +309,7 @@ _pygi_marshal_to_py_ghash (PyGIInvokeState *state, static void _pygi_marshal_cleanup_to_py_ghash (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *dummy, + gpointer cleanup_data, gpointer data, gboolean was_processed) { diff --git a/gi/pygi-info.c b/gi/pygi-info.c index 1b33e9a..e46f600 100644 --- a/gi/pygi-info.c +++ b/gi/pygi-info.c @@ -41,7 +41,7 @@ _generate_doc_string(PyGIBaseInfo *self) static PyObject *_py_generate_doc_string = NULL; if (_py_generate_doc_string == NULL) { - PyObject *mod = PyImport_ImportModule ("gi.docstring"); + PyObject *mod = PYGLIB_PyImport_ImportModule ("gi.docstring"); if (!mod) return NULL; diff --git a/gi/pygi-invoke-state-struct.h b/gi/pygi-invoke-state-struct.h index 64711cb..dbf4e66 100644 --- a/gi/pygi-invoke-state-struct.h +++ b/gi/pygi-invoke-state-struct.h @@ -20,6 +20,8 @@ typedef struct _PyGIInvokeArgState /* Holds from_py marshaler cleanup data. */ gpointer arg_cleanup_data; + /* Holds to_py marshaler cleanup data. */ + gpointer to_py_arg_cleanup_data; } PyGIInvokeArgState; @@ -45,6 +47,7 @@ typedef struct _PyGIInvokeState /* Memory to receive the result of the C ffi function call. */ GIArgument return_arg; + gpointer to_py_return_arg_cleanup_data; /* A GError exception which is indirectly bound into the last position of * the "args" array if the callable caches "throws" member is set. diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index fd9e474..fca48ba 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -565,10 +565,13 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGIFunctionCache *function_ca if (cache->return_cache) { if (!cache->return_cache->is_skipped) { + gpointer cleanup_data = NULL; py_return = cache->return_cache->to_py_marshaller ( state, cache, cache->return_cache, - &state->return_arg); + &state->return_arg, + &cleanup_data); + state->to_py_return_arg_cleanup_data = cleanup_data; if (py_return == NULL) { pygi_marshal_cleanup_args_return_fail (state, cache); @@ -576,7 +579,7 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGIFunctionCache *function_ca } } else { if (cache->return_cache->transfer == GI_TRANSFER_EVERYTHING) { - PyGIMarshalCleanupFunc to_py_cleanup = + PyGIMarshalToPyCleanupFunc to_py_cleanup = cache->return_cache->to_py_cleanup; if (to_py_cleanup != NULL) @@ -604,10 +607,13 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGIFunctionCache *function_ca } else if (!cache->has_return && n_out_args == 1) { /* if we get here there is one out arg an no return */ PyGIArgCache *arg_cache = (PyGIArgCache *)cache->to_py_args->data; + gpointer cleanup_data = NULL; py_out = arg_cache->to_py_marshaller (state, cache, arg_cache, - state->args[arg_cache->c_arg_index].arg_pointer.v_pointer); + state->args[arg_cache->c_arg_index].arg_pointer.v_pointer, + &cleanup_data); + state->args[arg_cache->c_arg_index].to_py_arg_cleanup_data = cleanup_data; if (py_out == NULL) { pygi_marshal_cleanup_args_to_py_parameter_fail (state, cache, @@ -637,10 +643,13 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGIFunctionCache *function_ca for (; py_arg_index < tuple_len; py_arg_index++) { PyGIArgCache *arg_cache = (PyGIArgCache *)cache_item->data; + gpointer cleanup_data = NULL; PyObject *py_obj = arg_cache->to_py_marshaller (state, cache, arg_cache, - state->args[arg_cache->c_arg_index].arg_pointer.v_pointer); + state->args[arg_cache->c_arg_index].arg_pointer.v_pointer, + &cleanup_data); + state->args[arg_cache->c_arg_index].to_py_arg_cleanup_data = cleanup_data; if (py_obj == NULL) { if (cache->has_return) diff --git a/gi/pygi-list.c b/gi/pygi-list.c index 72a3d20..e8808fc 100644 --- a/gi/pygi-list.c +++ b/gi/pygi-list.c @@ -234,11 +234,13 @@ static PyObject * _pygi_marshal_to_py_glist (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { GList *list_; gsize length; gsize i; + GPtrArray *item_cleanups; PyGIMarshalToPyFunc item_to_py_marshaller; PyGIArgCache *item_arg_cache; @@ -253,23 +255,31 @@ _pygi_marshal_to_py_glist (PyGIInvokeState *state, if (py_obj == NULL) return NULL; + item_cleanups = g_ptr_array_sized_new (length); + *cleanup_data = item_cleanups; + item_arg_cache = seq_cache->item_cache; item_to_py_marshaller = item_arg_cache->to_py_marshaller; for (i = 0; list_ != NULL; list_ = g_list_next (list_), i++) { GIArgument item_arg; PyObject *py_item; + gpointer item_cleanup_data = NULL; item_arg.v_pointer = list_->data; _pygi_hash_pointer_to_arg (&item_arg, item_arg_cache->type_info); py_item = item_to_py_marshaller (state, callable_cache, item_arg_cache, - &item_arg); + &item_arg, + &item_cleanup_data); + + g_ptr_array_index (item_cleanups, i) = item_cleanup_data; if (py_item == NULL) { Py_CLEAR (py_obj); _PyGI_ERROR_PREFIX ("Item %zu: ", i); + g_ptr_array_unref (item_cleanups); return NULL; } @@ -283,11 +293,13 @@ static PyObject * _pygi_marshal_to_py_gslist (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { GSList *list_; gsize length; gsize i; + GPtrArray *item_cleanups; PyGIMarshalToPyFunc item_to_py_marshaller; PyGIArgCache *item_arg_cache; @@ -302,23 +314,30 @@ _pygi_marshal_to_py_gslist (PyGIInvokeState *state, if (py_obj == NULL) return NULL; + item_cleanups = g_ptr_array_sized_new (length); + *cleanup_data = item_cleanups; + item_arg_cache = seq_cache->item_cache; item_to_py_marshaller = item_arg_cache->to_py_marshaller; for (i = 0; list_ != NULL; list_ = g_slist_next (list_), i++) { GIArgument item_arg; PyObject *py_item; + gpointer item_cleanup_data = NULL; item_arg.v_pointer = list_->data; _pygi_hash_pointer_to_arg (&item_arg, item_arg_cache->type_info); py_item = item_to_py_marshaller (state, callable_cache, item_arg_cache, - &item_arg); + &item_arg, + &item_cleanup_data); + g_ptr_array_index (item_cleanups, i) = item_cleanup_data; if (py_item == NULL) { Py_CLEAR (py_obj); _PyGI_ERROR_PREFIX ("Item %zu: ", i); + g_ptr_array_unref (item_cleanups); return NULL; } @@ -331,29 +350,33 @@ _pygi_marshal_to_py_gslist (PyGIInvokeState *state, static void _pygi_marshal_cleanup_to_py_glist (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *dummy, + gpointer cleanup_data, gpointer data, gboolean was_processed) { + GPtrArray *item_cleanups = (GPtrArray *) cleanup_data; PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache; + GSList *list_ = (GSList *)data; + + if (sequence_cache->item_cache->to_py_cleanup != NULL) { + PyGIMarshalToPyCleanupFunc cleanup_func = + sequence_cache->item_cache->to_py_cleanup; + GSList *node = list_; + guint i = 0; + + while (node != NULL) { + cleanup_func (state, + sequence_cache->item_cache, + g_ptr_array_index(item_cleanups, i), + node->data, + was_processed); + node = node->next; + i++; + } + } + if (arg_cache->transfer == GI_TRANSFER_EVERYTHING || arg_cache->transfer == GI_TRANSFER_CONTAINER) { - GSList *list_ = (GSList *)data; - - if (sequence_cache->item_cache->to_py_cleanup != NULL) { - PyGIMarshalCleanupFunc cleanup_func = - sequence_cache->item_cache->to_py_cleanup; - GSList *node = list_; - - while (node != NULL) { - cleanup_func (state, - sequence_cache->item_cache, - NULL, - node->data, - was_processed); - node = node->next; - } - } if (arg_cache->type_tag == GI_TYPE_TAG_GLIST) { g_list_free ( (GList *)list_); @@ -363,6 +386,8 @@ _pygi_marshal_cleanup_to_py_glist (PyGIInvokeState *state, g_assert_not_reached(); } } + + g_ptr_array_unref (item_cleanups); } static void diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c index 906be58..ddda594 100644 --- a/gi/pygi-marshal-cleanup.c +++ b/gi/pygi-marshal-cleanup.c @@ -119,13 +119,15 @@ pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState *state, PyGICallableCache *cache) { GSList *cache_item; + guint i = 0; + /* clean up the return if available */ if (cache->return_cache != NULL) { - PyGIMarshalCleanupFunc cleanup_func = cache->return_cache->to_py_cleanup; + PyGIMarshalToPyCleanupFunc cleanup_func = cache->return_cache->to_py_cleanup; if (cleanup_func && state->return_arg.v_pointer != NULL) cleanup_func (state, cache->return_cache, - NULL, + state->to_py_return_arg_cleanup_data, state->return_arg.v_pointer, TRUE); } @@ -134,23 +136,24 @@ pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState *state, cache_item = cache->to_py_args; while (cache_item) { PyGIArgCache *arg_cache = (PyGIArgCache *) cache_item->data; - PyGIMarshalCleanupFunc cleanup_func = arg_cache->to_py_cleanup; + PyGIMarshalToPyCleanupFunc cleanup_func = arg_cache->to_py_cleanup; gpointer data = state->args[arg_cache->c_arg_index].arg_value.v_pointer; if (cleanup_func != NULL && data != NULL) cleanup_func (state, arg_cache, - NULL, + state->args[arg_cache->c_arg_index].to_py_arg_cleanup_data, data, TRUE); else if (arg_cache->is_caller_allocates && data != NULL) { _cleanup_caller_allocates (state, arg_cache, - NULL, + state->args[arg_cache->c_arg_index].to_py_arg_cleanup_data, data, TRUE); } + i++; cache_item = cache_item->next; } } diff --git a/gi/pygi-object.c b/gi/pygi-object.c index 8fd8ee0..80c9055 100644 --- a/gi/pygi-object.c +++ b/gi/pygi-object.c @@ -279,7 +279,8 @@ static PyObject * _pygi_marshal_to_py_called_from_c_interface_object_cache_adapter (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { return pygi_arg_gobject_to_py_called_from_c (arg, arg_cache->transfer); } @@ -288,7 +289,8 @@ static PyObject * _pygi_marshal_to_py_called_from_py_interface_object_cache_adapter (PyGIInvokeState *state, PyGICallableCache *callable_cache, PyGIArgCache *arg_cache, - GIArgument *arg) + GIArgument *arg, + gpointer *cleanup_data) { return pygi_arg_gobject_to_py (arg, arg_cache->transfer); } @@ -296,7 +298,7 @@ _pygi_marshal_to_py_called_from_py_interface_object_cache_adapter (PyGIInvokeSta static void _pygi_marshal_cleanup_to_py_interface_object (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *dummy, + gpointer cleanup_data, gpointer data, gboolean was_processed) { diff --git a/gi/pygi-property.c b/gi/pygi-property.c index 9978585..c4f3e4a 100644 --- a/gi/pygi-property.c +++ b/gi/pygi-property.c @@ -160,6 +160,7 @@ pygi_get_property_value (PyGObject *instance, GParamSpec *pspec) GITypeInfo *type_info = NULL; gboolean free_array = FALSE; GIArgument arg = { 0, }; + GITransfer transfer = GI_TRANSFER_NOTHING; type_info = g_property_info_get_type (property_info); arg = _pygi_argument_from_g_value (&value, type_info); @@ -168,9 +169,12 @@ pygi_get_property_value (PyGObject *instance, GParamSpec *pspec) if (g_type_info_get_tag (type_info) == GI_TYPE_TAG_ARRAY) { arg.v_pointer = _pygi_argument_to_array (&arg, NULL, NULL, NULL, type_info, &free_array); + } else if (g_type_is_a (pspec->value_type, G_TYPE_BOXED)) { + arg.v_pointer = g_value_dup_boxed (&value); + transfer = GI_TRANSFER_EVERYTHING; } - py_value = _pygi_argument_to_object (&arg, type_info, GI_TRANSFER_NOTHING); + py_value = _pygi_argument_to_object (&arg, type_info, transfer); if (free_array) { g_array_free (arg.v_pointer, FALSE); diff --git a/gi/pygi-source.c b/gi/pygi-source.c index 5305260..2ed38d3 100644 --- a/gi/pygi-source.c +++ b/gi/pygi-source.c @@ -241,10 +241,8 @@ pyg_source_new (void) source = (PyGRealSource*) g_source_new (&pyg_source_funcs, sizeof (PyGRealSource)); py_type = _pygi_type_import_by_name ("GLib", "Source"); - /* Full ownership transfer of the source, this will be free'd with g_boxed_free. */ - source->obj = _pygi_boxed_new ( (PyTypeObject *) py_type, source, - FALSE, /* copy_boxed */ - 0); /* slice_allocated */ + /* g_source_new uses malloc, not slices */ + source->obj = _pygi_boxed_new ( (PyTypeObject *) py_type, source, FALSE, 0); return source->obj; } diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c index 60d2585..75896a8 100644 --- a/gi/pygi-struct-marshal.c +++ b/gi/pygi-struct-marshal.c @@ -364,15 +364,14 @@ arg_foreign_from_py_cleanup (PyGIInvokeState *state, } } - -PyObject * -pygi_arg_struct_to_py_marshal (GIArgument *arg, - GIInterfaceInfo *interface_info, - GType g_type, - PyObject *py_type, - GITransfer transfer, - gboolean is_allocated, - gboolean is_foreign) +static PyObject * +pygi_arg_struct_to_py_marshaller (GIArgument *arg, + GIInterfaceInfo *interface_info, + GType g_type, + PyObject *py_type, + GITransfer transfer, + gboolean is_allocated, + gboolean is_foreign) { PyObject *py_obj = NULL; @@ -388,11 +387,9 @@ pygi_arg_struct_to_py_marshal (GIArgument *arg, arg->v_pointer); } else if (g_type_is_a (g_type, G_TYPE_BOXED)) { if (py_type) { - /* Force a boxed copy if we are not transfered ownership and the - * memory is not caller allocated. */ py_obj = _pygi_boxed_new ((PyTypeObject *) py_type, arg->v_pointer, - transfer == GI_TRANSFER_NOTHING && !is_allocated, + transfer == GI_TRANSFER_EVERYTHING || is_allocated, is_allocated ? g_struct_info_get_size(interface_info) : 0); } @@ -433,57 +430,50 @@ pygi_arg_struct_to_py_marshal (GIArgument *arg, return py_obj; } -static PyObject * -arg_struct_to_py_marshal_adapter (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +PyObject * +pygi_arg_struct_to_py_marshal (GIArgument *arg, + GIInterfaceInfo *interface_info, + GType g_type, + PyObject *py_type, + GITransfer transfer, + gboolean is_allocated, + gboolean is_foreign) { - PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; + PyObject *ret = pygi_arg_struct_to_py_marshaller (arg, interface_info, g_type, py_type, transfer, is_allocated, is_foreign); - return pygi_arg_struct_to_py_marshal (arg, - iface_cache->interface_info, - iface_cache->g_type, - iface_cache->py_type, - arg_cache->transfer, - arg_cache->is_caller_allocates, - iface_cache->is_foreign); -} + if (ret && PyObject_IsInstance (ret, (PyObject *) &PyGIBoxed_Type) && transfer == GI_TRANSFER_NOTHING) + _pygi_boxed_copy_in_place ((PyGIBoxed *) ret); + + return ret; +}; static PyObject * -arg_boxed_to_py_marshal_pass_by_ref (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +arg_struct_to_py_marshal_adapter (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg, + gpointer *cleanup_data) { - PyObject *py_obj = NULL; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; + PyObject *ret; - if (arg->v_pointer == NULL) { - Py_RETURN_NONE; - } + ret = pygi_arg_struct_to_py_marshaller (arg, + iface_cache->interface_info, + iface_cache->g_type, + iface_cache->py_type, + arg_cache->transfer, + arg_cache->is_caller_allocates, + iface_cache->is_foreign); - if (g_type_is_a (iface_cache->g_type, G_TYPE_BOXED)) { - if (iface_cache->py_type) { - py_obj = _pygi_boxed_new ((PyTypeObject *) iface_cache->py_type, - arg->v_pointer, - FALSE, /* copy_boxed */ - 0); /* slice_alloc */ - ((PyGBoxed *)py_obj)->free_on_dealloc = FALSE; - } - } else { - PyErr_Format (PyExc_NotImplementedError, - "expected boxed type but got %s", - g_type_name (iface_cache->g_type)); - } + *cleanup_data = ret; - return py_obj; + return ret; } static void arg_foreign_to_py_cleanup (PyGIInvokeState *state, PyGIArgCache *arg_cache, - PyObject *dummy, + gpointer cleanup_data, gpointer data, gboolean was_processed) { @@ -494,6 +484,17 @@ arg_foreign_to_py_cleanup (PyGIInvokeState *state, } } +static void +arg_boxed_to_py_cleanup (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer cleanup_data, + gpointer data, + gboolean was_processed) +{ + if (arg_cache->transfer == GI_TRANSFER_NOTHING) + _pygi_boxed_copy_in_place ((PyGIBoxed *) cleanup_data); +} + static gboolean arg_type_class_from_py_marshal (PyGIInvokeState *state, PyGICallableCache *callable_cache, @@ -561,54 +562,22 @@ arg_struct_from_py_setup (PyGIArgCache *arg_cache, static void arg_struct_to_py_setup (PyGIArgCache *arg_cache, GIInterfaceInfo *iface_info, - GITransfer transfer, - GIArgInfo *arg_info) + GITransfer transfer) { PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; - /* HACK to force GtkTreeModel:iter_next() and iter_previous() vfunc implementations - * to receive their Gtk.TreeIter argument as pass-by-reference. We create a new - * PyGIBoxed wrapper which does not copy the memory and also does not free it. - * This is needed to hack the noted vfunc implementations so they can continue - * working with bug https://bugzilla.gnome.org/show_bug.cgi?id=722899 - * being fixed. This hack should be removed once GTK+ has fixed bug - * https://bugzilla.gnome.org/show_bug.cgi?id=734465 - * and we've moved to a new major version. - */ - if (arg_info && g_strcmp0 (iface_cache->type_name, "Gtk.TreeIter") == 0) { - - /* GICallbackInfo */ - GIBaseInfo *info = g_base_info_get_container (arg_info); - if (info && g_base_info_get_type (info) == GI_INFO_TYPE_CALLBACK && - (g_strcmp0 (g_base_info_get_name (info), "iter_next") == 0 || - g_strcmp0 (g_base_info_get_name (info), "iter_previous") == 0)) { - - /* GITypeInfo */ - info = g_base_info_get_container (info); - if (info && g_base_info_get_type (info) == GI_INFO_TYPE_TYPE && - g_type_info_get_tag ((GITypeInfo *)info) == GI_TYPE_TAG_INTERFACE) { - - /* GIFieldInfo */ - info = g_base_info_get_container (info); - if (info && g_base_info_get_type (info) == GI_INFO_TYPE_FIELD) { - - /* GIStructInfo */ - info = g_base_info_get_container (info); - if (info && g_base_info_get_type (info) == GI_INFO_TYPE_STRUCT && - g_strcmp0 (g_base_info_get_name (info), "TreeModelIface") == 0) { - arg_cache->to_py_marshaller = arg_boxed_to_py_marshal_pass_by_ref; - } - } - } - } - } - if (arg_cache->to_py_marshaller == NULL) { arg_cache->to_py_marshaller = arg_struct_to_py_marshal_adapter; } + iface_cache->is_foreign = g_struct_info_is_foreign ( (GIStructInfo*)iface_info); + if (iface_cache->is_foreign) arg_cache->to_py_cleanup = arg_foreign_to_py_cleanup; + else if (!g_type_is_a (iface_cache->g_type, G_TYPE_VALUE) && + iface_cache->py_type && + g_type_is_a (iface_cache->g_type, G_TYPE_BOXED)) + arg_cache->to_py_cleanup = arg_boxed_to_py_cleanup; } PyGIArgCache * @@ -638,7 +607,7 @@ pygi_arg_struct_new_from_info (GITypeInfo *type_info, } if (direction & PYGI_DIRECTION_TO_PYTHON) { - arg_struct_to_py_setup (cache, iface_info, transfer, arg_info); + arg_struct_to_py_setup (cache, iface_info, transfer); } return cache; diff --git a/gi/pygi-type.c b/gi/pygi-type.c index 06d773a..9561c43 100644 --- a/gi/pygi-type.c +++ b/gi/pygi-type.c @@ -35,7 +35,7 @@ _pygi_type_import_by_name (const char *namespace_, module_name = g_strconcat ("gi.repository.", namespace_, NULL); - py_module = PyImport_ImportModule (module_name); + py_module = PYGLIB_PyImport_ImportModule (module_name); g_free (module_name); diff --git a/gi/pyglib-python-compat.h b/gi/pyglib-python-compat.h index d6f7553..b1f4b22 100644 --- a/gi/pyglib-python-compat.h +++ b/gi/pyglib-python-compat.h @@ -115,6 +115,21 @@ PyTypeObject symbol = { \ return; \ PyDict_SetItemString(d, name, (PyObject *)&type); +/* Better alternative to PyImport_ImportModule which tries to import from + * sys.modules first */ +static inline PyObject * +PYGLIB_PyImport_ImportModule(const char *name) +{ + /* see PyImport_ImportModuleNoBlock + * https://github.com/python/cpython/blob/2.7/Python/import.c#L2166-L2206 */ + PyObject *result = PyImport_ImportModuleNoBlock(name); + if (result) + return result; + + PyErr_Clear(); + return PyImport_ImportModule(name); +} + #else #define PYGLIB_MODULE_START(symbol, modname) \ @@ -157,6 +172,8 @@ PyTypeObject symbol = { \ return; \ PyDict_SetItemString(d, name, (PyObject *)&type); +#define PYGLIB_PyImport_ImportModule PyImport_ImportModule + #define PYGLIB_PyBaseString_Check PyUnicode_Check #define PYGLIB_PyUnicode_Check PyUnicode_Check diff --git a/gi/pygtype.c b/gi/pygtype.c index 85a6d82..760af56 100644 --- a/gi/pygtype.c +++ b/gi/pygtype.c @@ -618,6 +618,14 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, guint *val) } static GQuark pyg_type_marshal_key = 0; +static GQuark pyg_type_marshal_helper_key = 0; + +typedef enum _marshal_helper_data_e marshal_helper_data_e; +enum _marshal_helper_data_e { + MARSHAL_HELPER_NONE = 0, + MARSHAL_HELPER_RETURN_NULL, + MARSHAL_HELPER_IMPORT_DONE, +}; PyGTypeMarshal * pyg_type_lookup(GType type) @@ -625,12 +633,33 @@ pyg_type_lookup(GType type) GType ptype = type; PyGTypeMarshal *tm = NULL; - /* recursively lookup types */ - while (ptype) { - pygi_type_import_by_g_type (ptype); + if (type == G_TYPE_INVALID) + return NULL; + + marshal_helper_data_e marshal_helper = GPOINTER_TO_INT ( + g_type_get_qdata(type, pyg_type_marshal_helper_key)); + + /* If we called this function before with @type and nothing was found, + * return NULL early to not spend time in the loop below */ + if (marshal_helper == MARSHAL_HELPER_RETURN_NULL) + return NULL; + + /* Otherwise do recursive type lookup */ + do { + if (marshal_helper == MARSHAL_HELPER_IMPORT_DONE) + pygi_type_import_by_g_type (ptype); + if ((tm = g_type_get_qdata(ptype, pyg_type_marshal_key)) != NULL) break; ptype = g_type_parent(ptype); + } while (ptype); + + if (marshal_helper == MARSHAL_HELPER_NONE) { + marshal_helper = (tm == NULL) ? + MARSHAL_HELPER_RETURN_NULL: + MARSHAL_HELPER_IMPORT_DONE; + g_type_set_qdata(type, pyg_type_marshal_helper_key, + GINT_TO_POINTER(marshal_helper)); } return tm; } @@ -653,8 +682,10 @@ pyg_register_gtype_custom(GType gtype, { PyGTypeMarshal *tm; - if (!pyg_type_marshal_key) - pyg_type_marshal_key = g_quark_from_static_string("PyGType::marshal"); + if (!pyg_type_marshal_key) { + pyg_type_marshal_key = g_quark_from_static_string("PyGType::marshal"); + pyg_type_marshal_helper_key = g_quark_from_static_string("PyGType::marshal-helper"); + } tm = g_new(PyGTypeMarshal, 1); tm->fromvalue = from_func; diff --git a/setup.cfg b/setup.cfg index 5933e6a..f4b4e15 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,10 @@ [flake8] ignore=E501,E123,E124,E402,E731,E722 builtins=long,unicode,basestring + +[coverage:run] +branch=True +include= + gi/* + tests/* + pygtkcompat/* diff --git a/tests/Makefile.am b/tests/Makefile.am index 216aca5..f04610a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -148,6 +148,7 @@ EXTRA_DIST = \ test_resulttuple.py \ test_unknown.py \ test_ossig.py \ + conftest.py \ __init__.py \ gi/__init__.py \ gi/overrides/__init__.py \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 8230e02..16f2ab7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -498,6 +498,7 @@ EXTRA_DIST = \ test_resulttuple.py \ test_unknown.py \ test_ossig.py \ + conftest.py \ __init__.py \ gi/__init__.py \ gi/overrides/__init__.py \ diff --git a/tests/compathelper.py b/tests/compathelper.py index d4f4d27..4ed3894 100644 --- a/tests/compathelper.py +++ b/tests/compathelper.py @@ -33,9 +33,14 @@ if sys.version_info >= (3, 0): from io import StringIO StringIO PY3 = True + + def reraise(tp, value, tb): + raise tp(value).with_traceback(tb) else: _long = long _basestring = basestring from StringIO import StringIO StringIO PY2 = True + + exec("def reraise(tp, value, tb):\n raise tp, value, tb") diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..f69405d --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import sys + +import pytest + +from .compathelper import reraise + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_call(item): + """A pytest hook which takes over sys.excepthook and raises any uncaught + exception (with PyGObject this happesn often when we get called from C, + like any signal handler, vfuncs tc) + """ + + assert sys.excepthook is sys.__excepthook__ + + exceptions = [] + + def on_hook(type_, value, tback): + exceptions.append((type_, value, tback)) + + sys.excepthook = on_hook + try: + yield + finally: + assert sys.excepthook in (on_hook, sys.__excepthook__) + sys.excepthook = sys.__excepthook__ + if exceptions: + reraise(*exceptions[0]) diff --git a/tests/regressextra.c b/tests/regressextra.c index 4df4edd..4c92f33 100644 --- a/tests/regressextra.c +++ b/tests/regressextra.c @@ -49,3 +49,54 @@ regress_test_boxed_c_wrapper_get (RegressTestBoxedCWrapper *self) { return self->cptr; } + +/** + * regress_test_array_fixed_boxed_none_out + * @objs: (out) (array fixed-size=2) (transfer none): An array of #RegressTestBoxedC +**/ +void +regress_test_array_fixed_boxed_none_out (RegressTestBoxedC ***objs) +{ + static RegressTestBoxedC **arr; + + if (arr == NULL) { + arr = g_new0 (RegressTestBoxedC *, 3); + arr[0] = regress_test_boxed_c_new (); + arr[1] = regress_test_boxed_c_new (); + } + + *objs = arr; +} + +/** + * regress_test_glist_boxed_none_return + * Return value: (element-type RegressTestBoxedC) (transfer none): +**/ +GList * +regress_test_glist_boxed_none_return (guint count) +{ + static GList *list = NULL; + if (!list) { + while (count > 0) { + list = g_list_prepend (list, regress_test_boxed_c_new ()); + count--; + } + } + + return list; +} + +/** + * regress_test_glist_boxed_full_return + * Return value: (element-type RegressTestBoxedC) (transfer full): +**/ +GList * +regress_test_glist_boxed_full_return (guint count) +{ + GList *list = NULL; + while (count > 0) { + list = g_list_prepend (list, regress_test_boxed_c_new ()); + count--; + } + return list; +} diff --git a/tests/regressextra.h b/tests/regressextra.h index 0753cdd..d42edbd 100644 --- a/tests/regressextra.h +++ b/tests/regressextra.h @@ -14,4 +14,11 @@ RegressTestBoxedCWrapper * regress_test_boxed_c_wrapper_copy (RegressTestBoxedCW _GI_TEST_EXTERN RegressTestBoxedC *regress_test_boxed_c_wrapper_get (RegressTestBoxedCWrapper *self); +_GI_TEST_EXTERN +void regress_test_array_fixed_boxed_none_out (RegressTestBoxedC ***objs); +_GI_TEST_EXTERN +GList *regress_test_glist_boxed_none_return (guint count); +_GI_TEST_EXTERN +GList *regress_test_glist_boxed_full_return (guint count); + #endif /* REGRESS_EXTRA_H */ diff --git a/tests/test_atoms.py b/tests/test_atoms.py index e1c5a89..cc8dc3c 100644 --- a/tests/test_atoms.py +++ b/tests/test_atoms.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +import os import unittest try: @@ -43,6 +44,7 @@ class TestGdkAtom(unittest.TestCase): self.assertEqual(repr(Gdk.SELECTION_CLIPBOARD), 'Gdk.Atom.intern("CLIPBOARD", False)') + @unittest.skipUnless(os.name != "nt", "not on Windows") def test_in_single(self): a_selection = Gdk.Atom.intern('test_clipboard', False) clipboard = Gtk.Clipboard.get(a_selection) diff --git a/tests/test_everything.py b/tests/test_everything.py index ce79cc2..c8694ad 100644 --- a/tests/test_everything.py +++ b/tests/test_everything.py @@ -1160,6 +1160,28 @@ class TestBoxed(unittest.TestCase): self.assertEqual(obj.refcount, 1) del obj + def test_array_fixed_boxed_none_out(self): + arr = Everything.test_array_fixed_boxed_none_out() + assert len(arr) == 2 + assert arr[0].refcount == 2 + assert arr[1].refcount == 2 + + def test_glist_boxed_none_return(self): + assert len(Everything.test_glist_boxed_none_return(0)) == 0 + + list_ = Everything.test_glist_boxed_none_return(2) + assert len(list_) == 2 + assert list_[0].refcount == 2 + assert list_[1].refcount == 2 + + def test_glist_boxed_full_return(self): + assert len(Everything.test_glist_boxed_full_return(0)) == 0 + + list_ = Everything.test_glist_boxed_full_return(2) + assert len(list_) == 2 + assert list_[0].refcount == 1 + assert list_[1].refcount == 1 + class TestTortureProfile(unittest.TestCase): def test_torture_profile(self): diff --git a/tests/test_glib.py b/tests/test_glib.py index 7a782e9..8f48194 100644 --- a/tests/test_glib.py +++ b/tests/test_glib.py @@ -10,12 +10,25 @@ import os.path import warnings import subprocess +import pytest from gi.repository import GLib from gi import PyGIDeprecationWarning class TestGLib(unittest.TestCase): + @pytest.mark.xfail(strict=True) + def test_pytest_capture_error_in_closure(self): + # this test is supposed to fail + ml = GLib.MainLoop() + + def callback(): + ml.quit() + raise Exception("expected") + + GLib.idle_add(callback) + ml.run() + @unittest.skipIf(os.name == "nt", "no bash on Windows") def test_find_program_in_path(self): bash_path = GLib.find_program_in_path('bash') diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py index 1c1b122..2d9fbd5 100644 --- a/tests/test_mainloop.py +++ b/tests/test_mainloop.py @@ -3,13 +3,14 @@ from __future__ import absolute_import import os -import sys import select import signal import unittest from gi.repository import GLib +from .helper import capture_exceptions + class TestMainLoop(unittest.TestCase): @@ -35,25 +36,12 @@ class TestMainLoop(unittest.TestCase): os.write(pipe_w, b"Y") os.close(pipe_w) - def excepthook(type, value, traceback): - self.assertTrue(type is Exception) - self.assertEqual(value.args[0], "deadbabe") - sys.excepthook = excepthook - try: - got_exception = False - try: - loop.run() - except: - got_exception = True - finally: - sys.excepthook = sys.__excepthook__ - - # - # The exception should be handled (by printing it) - # immediately on return from child_died() rather - # than here. See bug #303573 - # - self.assertFalse(got_exception) + with capture_exceptions() as exc: + loop.run() + + assert len(exc) == 1 + assert exc[0].type is Exception + assert exc[0].value.args[0] == "deadbabe" @unittest.skipUnless(hasattr(os, "fork"), "no os.fork available") def test_sigint(self): diff --git a/tests/test_option.py b/tests/test_option.py index 33a1288..2854508 100644 --- a/tests/test_option.py +++ b/tests/test_option.py @@ -3,7 +3,6 @@ from __future__ import absolute_import import unittest -import sys # py3k has StringIO in a different module try: @@ -14,9 +13,10 @@ except ImportError: from gi.repository import GLib +from .helper import capture_exceptions + class TestOption(unittest.TestCase): - EXCEPTION_MESSAGE = "This callback fails" def setUp(self): self.parser = GLib.option.OptionParser("NAMES...", @@ -30,7 +30,7 @@ class TestOption(unittest.TestCase): def _create_group(self): def option_callback(option, opt, value, parser): - raise Exception(self.EXCEPTION_MESSAGE) + raise Exception("foo") group = GLib.option.OptionGroup( "unittest", "Unit test options", "Show all unittest options", @@ -104,14 +104,10 @@ class TestOption(unittest.TestCase): def test_standard_error(self): self._create_group() - sio = StringIO() - old_stderr = sys.stderr - sys.stderr = sio - try: + + with capture_exceptions() as exc: self.parser.parse_args( ["test_option.py", "--callback-failure-test"]) - finally: - sys.stderr = old_stderr - assert (sio.getvalue().split('\n')[-2] == - "Exception: " + self.EXCEPTION_MESSAGE) + assert len(exc) == 1 + assert exc[0].value.args[0] == "foo" diff --git a/tests/test_source.py b/tests/test_source.py index 5828fa9..64fe5bd 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -3,7 +3,6 @@ from __future__ import absolute_import import sys -import gc import unittest import warnings @@ -129,7 +128,6 @@ class TestSource(unittest.TestCase): return s s = f() - gc.collect() self.assertTrue(s.is_destroyed()) def test_remove(self): @@ -211,9 +209,8 @@ class TestSource(unittest.TestCase): self.finalized = True source = S() - self.assertEqual(source.ref_count, 1) - source.attach() - self.assertEqual(source.ref_count, 2) + id = source.attach() + print('source id:', id) self.assertFalse(self.finalized) self.assertFalse(source.is_destroyed()) @@ -221,7 +218,6 @@ class TestSource(unittest.TestCase): pass source.destroy() - self.assertEqual(source.ref_count, 1) self.assertTrue(self.dispatched) self.assertFalse(self.finalized) self.assertTrue(source.is_destroyed()) -- 2.7.4