Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -1,10 +1,10 @@
There are three ways you are probably reading this right now:
- * On [ObjFW](https://objfw.nil.im/)'s homepage, via Fossil
+ * On [ObjFW](https://objfw.nil.im/)'s homepage, via Fossil's web interface
* On [GitHub](https://github.com/ObjFW/ObjFW)
- * Via an editor or pager, by opening `README.md` from a checkout or tarball
+ * Via an editor or pager, by opening `README.md` from a clone or tarball
ObjFW is developed using Fossil, so if you are reading this on GitHub or any
other place, you are most likely using a mirror.
@@ -19,12 +19,11 @@
* [Building as a framework](#building-framework)
* [Using the macOS or iOS framework in Xcode](#framework-in-xcode)
* [Broken Xcode versions](#broken-xcode-versions)
* [Windows](#windows)
* [Getting MSYS2](#getting-msys2)
- * [Updating MSYS2](#updating-msys2)
- * [Installing MinGW-w64 using MSYS2](#installing-mingw-w64)
+ * [Setting up MSYS2](#setting-up-msys2)
* [Getting, building and installing ObjFW](#steps-windows)
* [Nintendo DS, Nintendo 3DS and Wii](#nintendo)
* [Nintendo DS](#nintendo-ds)
* [Nintendo 3DS](#nintendo-3ds)
* [Wii](#wii)
@@ -106,17 +105,16 @@
Fossil
Clone the Fossil repository like this:
- $ fossil clone https://objfw.nil.im objfw.fossil
- $ mkdir objfw && cd objfw
- $ fossil open ../objfw.fossil
+ $ fossil clone https://objfw.nil.im
You can then use Fossil's web interface to browse the timeline, tickets,
wiki pages, etc.:
+ $ cd objfw
$ fossil ui
It's also possible to open the same local repository multiple times, so that
you have multiple working directories all backed by the same local
repository.
@@ -209,73 +207,61 @@
Getting MSYS2
The first thing to install is [MSYS2](https://www.msys2.org) to provide a
basic UNIX-like environment for Windows. Unfortunately, the binaries are not
- signed and there is no way to verify their integrity, so only download this
- from a trusted connection. Everything else you will download using MSYS2
- later will be cryptographically signed.
-
-Updating MSYS2
-
- The first thing to do is updating MSYS2. It is important to update things in
- a certain order, as `pacman` (the package manager MSYS2 uses, which comes
- from Arch Linux) does not know about a few things that are special on
- Windows.
-
- First, update the mirror list:
-
- $ pacman -Sy pacman-mirrors
-
- Then proceed to update the `msys2-runtime` itself, `bash` and `pacman`:
-
- $ pacman -S msys2-runtime bash pacman mintty
-
- Now close the current window and restart MSYS2, as the current window is now
- defunct. In a new MSYS2 window, update the rest of MSYS2:
-
- $ pacman -Su
-
- Now you have a fully updated MSYS2. Whenever you want to update MSYS2,
- proceed in this order. Notice that the first `pacman` invocation includes
- `-y` to actually fetch a new list of packages.
-
-Installing MinGW-w64 using MSYS2
-
- Now it's time to install MinGW-w64. If you want to build 32 bit binaries:
-
- $ pacman -S mingw-w64-i686-clang mingw-w64-i686-gcc-objc
-
- For 64 bit binaries:
-
- $ pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-gcc-objc
-
- There is nothing wrong with installing them both, as MSYS2 has created two
- entries in your start menu: `MinGW-w64 Win32 Shell` and
- `MinGW-w64 Win64 Shell`. So if you want to build for 32 or 64 bit, you just
- start the correct shell.
-
- Finally, install a few more things needed to build ObjFW:
-
- $ pacman -S autoconf automake fossil make
+ signed, so make sure you download it via HTTPS. However, packages you
+ download and install via MSYS2 are cryptographically signed.
+
+Setting up MSYS2
+
+ MSYS2 currently supports 5 different
+ [environments](https://www.msys2.org/docs/environments/). All of them except
+ for the one called just "MSYS" are supported, but which packages you need to
+ install depends on the environment(s) you want to use.
+
+ For MINGW64, use:
+
+ $ pacman -Syu mingw-w64-x86_64-clang mingw-w64-x86_64-fossil
+
+ For UCRT64, use:
+
+ $ pacman -Syu mingw-w64-ucrt-x86_64-clang mingw-w64-ucrt-x86_64-fossil
+
+ For CLANG64, use:
+
+ $ pacman -Syu mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-fossil
+
+ For MINGW32, use:
+
+ $ pacman -Syu mingw-w64-i686-clang mingw-w64-i686-fossil
+
+ When using `pacman` to install the packages, `pacman` might tell you to close
+ the window. If it does so, close the window, restart MSYS2 and execute the
+ `pacman` command again.
+
+ There is nothing wrong with installing multiple environments, as MSYS2 has
+ created shortcuts for each of them in your start menu. Just make sure to use
+ the correct shortcut for the environment you want to use.
+
+ Finally, install a few more things that are common between all environments:
+
+ $ pacman -S autoconf automake make
Getting, building and installing ObjFW
- Start the MinGW-w64 Win32 or Win64 Shell (depening on what version you want
- to build - do *not* use the MSYS2 Shell shortcut, but use the MinGW-w64 Win32
- or Win64 Shell shortcut instead!) and check out ObjFW:
-
- $ fossil clone https://objfw.nil.im objfw.fossil
- $ mkdir objfw && cd objfw
- $ fossil open ../objfw.fossil
-
- You can also download a release tarball if you want. Now go to the newly
+ Start the MSYS2 using the shortcut for the environment you want to use and
+ check out ObjFW:
+
+ $ fossil clone https://objfw.nil.im
+
+ You can also download a release tarball if you want. Now `cd` to the newly
checked out repository and build and install it:
$ ./autogen.sh && ./configure && make -j16 install
- If everything was successfully, you can now build projects using ObjFW for
+ If everything was successful, you can now build projects using ObjFW for
Windows using the normal `objfw-compile` and friends.
Nintendo DS, Nintendo 3DS and Wii
Download and install [devkitPro](https://devkitpro.org/wiki/Getting_Started).
Index: build-aux/m4/buildsys.m4
==================================================================
--- build-aux/m4/buildsys.m4
+++ build-aux/m4/buildsys.m4
@@ -20,10 +20,13 @@
dnl CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
dnl ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dnl POSSIBILITY OF SUCH DAMAGE.
dnl
+AC_ARG_ENABLE(rpath,
+ AS_HELP_STRING([--disable-rpath], [do not use rpath]))
+
AC_DEFUN([BUILDSYS_INIT], [
AC_REQUIRE([AC_CANONICAL_BUILD])
AC_REQUIRE([AC_CANONICAL_HOST])
case "$build_os" in
@@ -180,11 +183,13 @@
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib'
LIB_PREFIX='lib'
LIB_SUFFIX='.dylib'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
PLUGIN_SUFFIX='.bundle'
AS_IF([test x"$host_is_ios" = x"yes"], [
LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
@@ -202,11 +207,10 @@
LIB_CFLAGS=''
LIB_LDFLAGS='-shared -Wl,--export-all-symbols,--out-implib,lib$${out%${LIB_SUFFIX}}.a'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX=''
LIB_SUFFIX='${LIB_MAJOR}.dll'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
PLUGIN_CFLAGS=''
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.dll'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$${i%${LIB_SUFFIX}}.a ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.a'
@@ -220,11 +224,13 @@
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
@@ -238,11 +244,13 @@
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}.${LIB_MINOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
@@ -256,11 +264,10 @@
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
- LDFLAGS_RPATH=''
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
@@ -275,11 +282,13 @@
LIB_LDFLAGS='-shared -Wl,+h,$$out'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl'
- LDFLAGS_RPATH='-Wl,+b,${libdir}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,+b,${libdir}'
+ ])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.sl'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
@@ -294,11 +303,13 @@
LIB_LDFLAGS='-shared -Wl,+h,$$out'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so'
- LDFLAGS_RPATH='-Wl,+b,${libdir}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,+b,${libdir}'
+ ])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.so'
@@ -312,11 +323,13 @@
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -264,19 +264,10 @@
;;
i?86-*-darwin* | x86_64-*-darwin*)
dnl Don't use -no-integrated-as on Darwin. It breaks building
dnl for the iOS simulator.
;;
- i?86-*-* | x86_64-*-*)
- dnl Many older Clang versions don't support jmp short.
- ASFLAGS="$ASFLAGS -no-integrated-as"
- ;;
- *-*-mingw*)
- dnl Clang's assembler on Windows is not complete yet and cannot
- dnl compile all .S files.
- ASFLAGS="$ASFLAGS -no-integrated-as"
- ;;
sparc64-*-*openbsd*)
dnl Clang generates assembly output on SPARC64 that OpenBSD's
dnl assembler does not accept.
flag="-integrated-as"
OBJCFLAGS="$OBJCFLAGS $flag"
@@ -1392,10 +1383,13 @@
#endif
], [
AC_DEFINE(OF_HAVE_IPV6, 1, [Whether we have IPv6])
])
], [
+ dnl Work around a bug in autoconf 2.61 that creates a broken
+ dnl configure if this branch is empty.
+ :
], [
#ifdef _WIN32
typedef int BOOL;
#endif
@@ -1853,10 +1847,15 @@
__attribute__((__objc_root_class__))
# endif
#endif
@interface Test
@end
+
+ /**
+ * @struct Foo conftest.m conftest.m
+ */
+ typedef struct {} Foo;
])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
@@ -1936,11 +1935,10 @@
AC_CHECK_PROG(WINE, wine64, wine64)
;;
esac
AS_IF([test x"$WINE" != x""], [
- AC_SUBST(RUN_TESTS, "run")
AC_SUBST(WRAPPER, "$WINE")
])
AS_IF([test x"$with_wii" = x"yes"], [
dnl Keep this lowercase, as WIILOAD is a variable used by
@@ -1950,12 +1948,10 @@
AS_IF([test x"$wiiload" != x""], [
AC_SUBST(WRAPPER, "$wiiload")
])
])
-], [
- AC_SUBST(RUN_TESTS, "run")
])
AC_ARG_WITH(fish_completions,
AS_HELP_STRING([--with-fish-completions],
[install completions for the fish shell]))
Index: extra.mk.in
==================================================================
--- extra.mk.in
+++ extra.mk.in
@@ -1,18 +1,18 @@
OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@
OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@
OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@
OBJFW_AMIGA_LIB = @OBJFW_AMIGA_LIB@
-OBJFW_LIB_MAJOR = 1
+OBJFW_LIB_MAJOR = 0
OBJFW_LIB_MINOR = 0
OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}
OBJFWRT_SHARED_LIB = @OBJFWRT_SHARED_LIB@
OBJFWRT_STATIC_LIB = @OBJFWRT_STATIC_LIB@
OBJFWRT_FRAMEWORK = @OBJFWRT_FRAMEWORK@
OBJFWRT_AMIGA_LIB = @OBJFWRT_AMIGA_LIB@
-OBJFWRT_LIB_MAJOR = 1
+OBJFWRT_LIB_MAJOR = 0
OBJFWRT_LIB_MINOR = 0
OBJFWRT_LIB_MAJOR_MINOR = ${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR}
OBJFWBRIDGE_SHARED_LIB = @OBJFWBRIDGE_SHARED_LIB@
OBJFWBRIDGE_STATIC_LIB = @OBJFWBRIDGE_STATIC_LIB@
@@ -60,11 +60,10 @@
RUNTIME_ARC_TESTS_M = @RUNTIME_ARC_TESTS_M@
RUNTIME_AUTORELEASE_M = @RUNTIME_AUTORELEASE_M@
RUNTIME_FRAMEWORK_LIBS = @RUNTIME_FRAMEWORK_LIBS@
RUNTIME_INSTANCE_M = @RUNTIME_INSTANCE_M@
RUNTIME_LIBS = @RUNTIME_LIBS@
-RUN_TESTS = @RUN_TESTS@
SFDC_INLINE_H = @SFDC_INLINE_H@
SFDC_TARGET = @SFDC_TARGET@
SFD_FILE = @SFD_FILE@
TESTPLUGIN = @TESTPLUGIN@
TESTPLUGIN_LIBS = @TESTPLUGIN_LIBS@
Index: generators/library/Makefile
==================================================================
--- generators/library/Makefile
+++ generators/library/Makefile
@@ -4,10 +4,12 @@
SRCS = FuncArrayGenerator.m \
GlueGenerator.m \
LibraryGenerator.m \
LinkLibGenerator.m
+include ../../buildsys.mk
+
.PHONY: run
run: all
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
@@ -66,10 +68,8 @@
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
exit $$EXIT
-include ../../buildsys.mk
-
CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../..
LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS}
LD = ${OBJC}
Index: generators/unicode/Makefile
==================================================================
--- generators/unicode/Makefile
+++ generators/unicode/Makefile
@@ -1,10 +1,12 @@
include ../../extra.mk
PROG_NOINST = gen_tables${PROG_SUFFIX}
SRCS = TableGenerator.m
+include ../../buildsys.mk
+
.PHONY: run
run: all
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
@@ -63,10 +65,8 @@
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
exit $$EXIT
-include ../../buildsys.mk
-
CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../..
LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS}
LD = ${OBJC}
ADDED objfw.spec
Index: objfw.spec
==================================================================
--- objfw.spec
+++ objfw.spec
@@ -0,0 +1,422 @@
+%global libobjfw_major 0
+%global libobjfw_minor 0
+%global libobjfwrt_major 0
+%global libobjfwrt_minor 0
+%if 0%{?suse_version}
+%global libobjfw_pkgname libobjfw%{libobjfw_major}
+%global libobjfwrt_pkgname libobjfwrt%{libobjfwrt_major}
+%else
+%global libobjfw_pkgname libobjfw
+%global libobjfwrt_pkgname libobjfwrt
+%endif
+
+Name: objfw
+Version: 1.1dev
+Release: 1%{?dist}
+Summary: Portable, lightweight framework for the Objective-C language
+
+%if 0%{?suse_version}
+License: QPL-1.0 or GPL-3.0 or GPL-2.0
+Group: Development/Languages/C and C++
+%else
+License: QPL or GPLv3 or GPLv2
+%endif
+URL: https://objfw.nil.im
+Source0: objfw-%{version}.tar.gz
+
+BuildRequires: autoconf
+BuildRequires: automake
+BuildRequires: clang
+BuildRequires: make
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfw_pkgname}-devel = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}-devel = %{version}-%{release}
+Requires: ofarc%{_isa} = %{version}-%{release}
+Requires: ofdns%{_isa} = %{version}-%{release}
+Requires: ofhash%{_isa} = %{version}-%{release}
+Requires: ofhttp%{_isa} = %{version}-%{release}
+
+%description
+ObjFW is a portable, lightweight framework for the Objective-C language. It
+enables you to write an application in Objective-C that will run on any
+platform supported by ObjFW without having to worry about differences between
+operating systems or various frameworks you would otherwise need if you want to
+be portable.
+
+It supports all modern Objective-C features when using Clang, but is also
+compatible with GCC ≥ 4.6 to allow maximum portability.
+
+ObjFW also comes with its own lightweight and extremely fast Objective-C
+runtime, which in real world use cases was found to be significantly faster
+than both GNU's and Apple's runtime.
+
+%package -n %{libobjfw_pkgname}
+Summary: ObjFW library
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n %{libobjfw_pkgname}
+The %{libobjfw_pkgname} package contains the library needed by programs using
+ObjFW.
+
+%package -n %{libobjfw_pkgname}-devel
+Summary: Header files and tools for %{libobjfw_pkgname}
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}-devel = %{version}-%{release}
+
+%description -n %{libobjfw_pkgname}-devel
+The %{libobjfw_pkgname}-devel package contains the header files and tools to
+develop programs using ObjFW.
+
+%package -n %{libobjfwrt_pkgname}
+Summary: ObjFW Objective-C runtime library
+
+%description -n %{libobjfwrt_pkgname}
+The %{libobjfwrt_pkgname} package contains ObjFW's Objective-C runtime library.
+
+%package -n %{libobjfwrt_pkgname}-devel
+Summary: Header files for %{libobjfwrt_pkgname}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n %{libobjfwrt_pkgname}-devel
+The %{libobjfwrt_pkgname}-devel package contains header files for ObjFW's
+Objective-C runtime library.
+
+%package -n ofarc
+Summary: Utility for handling ZIP, Tar and LHA archives
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofarc
+ofarc is a multi-format archive utility that allows creating, listing,
+extracting and modifying ZIP, Tar and LHA archives using ObjFW's classes for
+various archive types.
+
+%package -n ofdns
+Summary: Utility for performing DNS requests on the command line
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofdns
+ofdns is an utility for performing DNS requests on the command line using
+ObjFW's DNS resolver.
+
+%package -n ofhash
+Summary: Utility to hash files with various cryptographic hash functions
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofhash
+ofhash is an utility to hash files with various cryptographic hash functions
+(even using different algorithms at once) using ObjFW's classes for various
+cryptographic hashes.
+
+%package -n ofhttp
+Summary: Command line downloader for HTTP(S)
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofhttp
+ofhttp is a command line downloader for HTTP and HTTPS (via ObjOpenSSL) using
+ObjFW's OFHTTPClient class. It supports all features one would expect from a
+modern command line downloader such as resuming of downloads, using a SOCKS5
+proxy, a modern terminal-based UI, etc.
+
+%prep
+%autosetup
+./autogen.sh
+
+%build
+%configure --disable-rpath
+%make_build
+
+%install
+%make_install
+
+%check
+make -C tests run
+
+%if 0%{?suse_version}
+%post -n %{libobjfw_pkgname} -p /sbin/ldconfig
+%postun -n %{libobjfw_pkgname} -p /sbin/ldconfig
+%post -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
+%postun -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
+%endif
+
+%files
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfw_pkgname}
+%{_libdir}/libobjfw.so.%{libobjfw_major}
+%{_libdir}/libobjfw.so.%{libobjfw_major}.%{libobjfw_minor}.0
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfw_pkgname}-devel
+%{_libdir}/libobjfw.so
+%{_includedir}/ObjFW/OFASPrintF.h
+%{_includedir}/ObjFW/OFAcceptFailedException.h
+%{_includedir}/ObjFW/OFAllocFailedException.h
+%{_includedir}/ObjFW/OFAlreadyConnectedException.h
+%{_includedir}/ObjFW/OFApplication.h
+%{_includedir}/ObjFW/OFArray.h
+%{_includedir}/ObjFW/OFAtomic.h
+%{_includedir}/ObjFW/OFBase64.h
+%{_includedir}/ObjFW/OFBindFailedException.h
+%{_includedir}/ObjFW/OFBlock.h
+%{_includedir}/ObjFW/OFCRC16.h
+%{_includedir}/ObjFW/OFCRC32.h
+%{_includedir}/ObjFW/OFChangeCurrentDirectoryPathFailedException.h
+%{_includedir}/ObjFW/OFCharacterSet.h
+%{_includedir}/ObjFW/OFChecksumMismatchException.h
+%{_includedir}/ObjFW/OFCollection.h
+%{_includedir}/ObjFW/OFColor.h
+%{_includedir}/ObjFW/OFCondition.h
+%{_includedir}/ObjFW/OFConditionBroadcastFailedException.h
+%{_includedir}/ObjFW/OFConditionSignalFailedException.h
+%{_includedir}/ObjFW/OFConditionStillWaitingException.h
+%{_includedir}/ObjFW/OFConditionWaitFailedException.h
+%{_includedir}/ObjFW/OFConnectionFailedException.h
+%{_includedir}/ObjFW/OFConstantString.h
+%{_includedir}/ObjFW/OFCopyItemFailedException.h
+%{_includedir}/ObjFW/OFCountedSet.h
+%{_includedir}/ObjFW/OFCreateDirectoryFailedException.h
+%{_includedir}/ObjFW/OFCreateSymbolicLinkFailedException.h
+%{_includedir}/ObjFW/OFCryptographicHash.h
+%{_includedir}/ObjFW/OFDNSQuery.h
+%{_includedir}/ObjFW/OFDNSQueryFailedException.h
+%{_includedir}/ObjFW/OFDNSResolver.h
+%{_includedir}/ObjFW/OFDNSResourceRecord.h
+%{_includedir}/ObjFW/OFDNSResponse.h
+%{_includedir}/ObjFW/OFData+CryptographicHashing.h
+%{_includedir}/ObjFW/OFData+MessagePackParsing.h
+%{_includedir}/ObjFW/OFData.h
+%{_includedir}/ObjFW/OFDatagramSocket.h
+%{_includedir}/ObjFW/OFDate.h
+%{_includedir}/ObjFW/OFDictionary.h
+%{_includedir}/ObjFW/OFEnumerationMutationException.h
+%{_includedir}/ObjFW/OFEnumerator.h
+%{_includedir}/ObjFW/OFException.h
+%{_includedir}/ObjFW/OFFile.h
+%{_includedir}/ObjFW/OFFileManager.h
+%{_includedir}/ObjFW/OFGZIPStream.h
+%{_includedir}/ObjFW/OFGetCurrentDirectoryPathFailedException.h
+%{_includedir}/ObjFW/OFGetOptionFailedException.h
+%{_includedir}/ObjFW/OFHMAC.h
+%{_includedir}/ObjFW/OFHTTPClient.h
+%{_includedir}/ObjFW/OFHTTPCookie.h
+%{_includedir}/ObjFW/OFHTTPCookieManager.h
+%{_includedir}/ObjFW/OFHTTPRequest.h
+%{_includedir}/ObjFW/OFHTTPRequestFailedException.h
+%{_includedir}/ObjFW/OFHTTPResponse.h
+%{_includedir}/ObjFW/OFHTTPServer.h
+%{_includedir}/ObjFW/OFHashAlreadyCalculatedException.h
+%{_includedir}/ObjFW/OFHuffmanTree.h
+%{_includedir}/ObjFW/OFINICategory.h
+%{_includedir}/ObjFW/OFINIFile.h
+%{_includedir}/ObjFW/OFIPXSocket.h
+%{_includedir}/ObjFW/OFInflate64Stream.h
+%{_includedir}/ObjFW/OFInflateStream.h
+%{_includedir}/ObjFW/OFInitializationFailedException.h
+%{_includedir}/ObjFW/OFInvalidArgumentException.h
+%{_includedir}/ObjFW/OFInvalidEncodingException.h
+%{_includedir}/ObjFW/OFInvalidFormatException.h
+%{_includedir}/ObjFW/OFInvalidJSONException.h
+%{_includedir}/ObjFW/OFInvalidServerReplyException.h
+%{_includedir}/ObjFW/OFInvocation.h
+%{_includedir}/ObjFW/OFJSONRepresentation.h
+%{_includedir}/ObjFW/OFKernelEventObserver.h
+%{_includedir}/ObjFW/OFKeyValueCoding.h
+%{_includedir}/ObjFW/OFLHAArchive.h
+%{_includedir}/ObjFW/OFLHAArchiveEntry.h
+%{_includedir}/ObjFW/OFLinkFailedException.h
+%{_includedir}/ObjFW/OFList.h
+%{_includedir}/ObjFW/OFListenFailedException.h
+%{_includedir}/ObjFW/OFLoadPluginFailedException.h
+%{_includedir}/ObjFW/OFLocale.h
+%{_includedir}/ObjFW/OFLockFailedException.h
+%{_includedir}/ObjFW/OFLocking.h
+%{_includedir}/ObjFW/OFMD5Hash.h
+%{_includedir}/ObjFW/OFMalformedXMLException.h
+%{_includedir}/ObjFW/OFMapTable.h
+%{_includedir}/ObjFW/OFMemoryNotPartOfObjectException.h
+%{_includedir}/ObjFW/OFMessagePackExtension.h
+%{_includedir}/ObjFW/OFMessagePackRepresentation.h
+%{_includedir}/ObjFW/OFMethodSignature.h
+%{_includedir}/ObjFW/OFMoveItemFailedException.h
+%{_includedir}/ObjFW/OFMutableArray.h
+%{_includedir}/ObjFW/OFMutableData.h
+%{_includedir}/ObjFW/OFMutableDictionary.h
+%{_includedir}/ObjFW/OFMutableLHAArchiveEntry.h
+%{_includedir}/ObjFW/OFMutablePair.h
+%{_includedir}/ObjFW/OFMutableSet.h
+%{_includedir}/ObjFW/OFMutableString.h
+%{_includedir}/ObjFW/OFMutableTarArchiveEntry.h
+%{_includedir}/ObjFW/OFMutableTriple.h
+%{_includedir}/ObjFW/OFMutableURL.h
+%{_includedir}/ObjFW/OFMutableZIPArchiveEntry.h
+%{_includedir}/ObjFW/OFMutex.h
+%{_includedir}/ObjFW/OFNotImplementedException.h
+%{_includedir}/ObjFW/OFNotOpenException.h
+%{_includedir}/ObjFW/OFNull.h
+%{_includedir}/ObjFW/OFNumber.h
+%{_includedir}/ObjFW/OFObject+KeyValueCoding.h
+%{_includedir}/ObjFW/OFObject+Serialization.h
+%{_includedir}/ObjFW/OFObject.h
+%{_includedir}/ObjFW/OFObserveFailedException.h
+%{_includedir}/ObjFW/OFOnce.h
+%{_includedir}/ObjFW/OFOpenItemFailedException.h
+%{_includedir}/ObjFW/OFOptionsParser.h
+%{_includedir}/ObjFW/OFOutOfMemoryException.h
+%{_includedir}/ObjFW/OFOutOfRangeException.h
+%{_includedir}/ObjFW/OFPBKDF2.h
+%{_includedir}/ObjFW/OFPair.h
+%{_includedir}/ObjFW/OFPlainCondition.h
+%{_includedir}/ObjFW/OFPlainMutex.h
+%{_includedir}/ObjFW/OFPlainThread.h
+%{_includedir}/ObjFW/OFPlugin.h
+%{_includedir}/ObjFW/OFRIPEMD160Hash.h
+%{_includedir}/ObjFW/OFReadFailedException.h
+%{_includedir}/ObjFW/OFReadOrWriteFailedException.h
+%{_includedir}/ObjFW/OFRecursiveMutex.h
+%{_includedir}/ObjFW/OFRemoveItemFailedException.h
+%{_includedir}/ObjFW/OFResolveHostFailedException.h
+%{_includedir}/ObjFW/OFRetrieveItemAttributesFailedException.h
+%{_includedir}/ObjFW/OFRunLoop.h
+%{_includedir}/ObjFW/OFSHA1Hash.h
+%{_includedir}/ObjFW/OFSHA224Hash.h
+%{_includedir}/ObjFW/OFSHA224Or256Hash.h
+%{_includedir}/ObjFW/OFSHA256Hash.h
+%{_includedir}/ObjFW/OFSHA384Hash.h
+%{_includedir}/ObjFW/OFSHA384Or512Hash.h
+%{_includedir}/ObjFW/OFSHA512Hash.h
+%{_includedir}/ObjFW/OFSPXSocket.h
+%{_includedir}/ObjFW/OFSPXStreamSocket.h
+%{_includedir}/ObjFW/OFScrypt.h
+%{_includedir}/ObjFW/OFSecureData.h
+%{_includedir}/ObjFW/OFSeekFailedException.h
+%{_includedir}/ObjFW/OFSeekableStream.h
+%{_includedir}/ObjFW/OFSequencedPacketSocket.h
+%{_includedir}/ObjFW/OFSerialization.h
+%{_includedir}/ObjFW/OFSet.h
+%{_includedir}/ObjFW/OFSetItemAttributesFailedException.h
+%{_includedir}/ObjFW/OFSetOptionFailedException.h
+%{_includedir}/ObjFW/OFSettings.h
+%{_includedir}/ObjFW/OFSocket.h
+%{_includedir}/ObjFW/OFSortedList.h
+%{_includedir}/ObjFW/OFStdIOStream.h
+%{_includedir}/ObjFW/OFStillLockedException.h
+%{_includedir}/ObjFW/OFStrPTime.h
+%{_includedir}/ObjFW/OFStream.h
+%{_includedir}/ObjFW/OFStreamSocket.h
+%{_includedir}/ObjFW/OFString+CryptographicHashing.h
+%{_includedir}/ObjFW/OFString+JSONParsing.h
+%{_includedir}/ObjFW/OFString+PathAdditions.h
+%{_includedir}/ObjFW/OFString+PropertyListParsing.h
+%{_includedir}/ObjFW/OFString+Serialization.h
+%{_includedir}/ObjFW/OFString+URLEncoding.h
+%{_includedir}/ObjFW/OFString+XMLEscaping.h
+%{_includedir}/ObjFW/OFString+XMLUnescaping.h
+%{_includedir}/ObjFW/OFString.h
+%{_includedir}/ObjFW/OFSystemInfo.h
+%{_includedir}/ObjFW/OFTCPSocket.h
+%{_includedir}/ObjFW/OFTLSKey.h
+%{_includedir}/ObjFW/OFTLSSocket.h
+%{_includedir}/ObjFW/OFTarArchive.h
+%{_includedir}/ObjFW/OFTarArchiveEntry.h
+%{_includedir}/ObjFW/OFThread.h
+%{_includedir}/ObjFW/OFThreadJoinFailedException.h
+%{_includedir}/ObjFW/OFThreadPool.h
+%{_includedir}/ObjFW/OFThreadStartFailedException.h
+%{_includedir}/ObjFW/OFThreadStillRunningException.h
+%{_includedir}/ObjFW/OFTimer.h
+%{_includedir}/ObjFW/OFTriple.h
+%{_includedir}/ObjFW/OFTruncatedDataException.h
+%{_includedir}/ObjFW/OFUDPSocket.h
+%{_includedir}/ObjFW/OFURL.h
+%{_includedir}/ObjFW/OFURLHandler.h
+%{_includedir}/ObjFW/OFUnboundNamespaceException.h
+%{_includedir}/ObjFW/OFUnboundPrefixException.h
+%{_includedir}/ObjFW/OFUndefinedKeyException.h
+%{_includedir}/ObjFW/OFUnknownXMLEntityException.h
+%{_includedir}/ObjFW/OFUnlockFailedException.h
+%{_includedir}/ObjFW/OFUnsupportedProtocolException.h
+%{_includedir}/ObjFW/OFUnsupportedVersionException.h
+%{_includedir}/ObjFW/OFValue.h
+%{_includedir}/ObjFW/OFWriteFailedException.h
+%{_includedir}/ObjFW/OFXMLAttribute.h
+%{_includedir}/ObjFW/OFXMLCDATA.h
+%{_includedir}/ObjFW/OFXMLCharacters.h
+%{_includedir}/ObjFW/OFXMLComment.h
+%{_includedir}/ObjFW/OFXMLElement+Serialization.h
+%{_includedir}/ObjFW/OFXMLElement.h
+%{_includedir}/ObjFW/OFXMLElementBuilder.h
+%{_includedir}/ObjFW/OFXMLNode.h
+%{_includedir}/ObjFW/OFXMLParser.h
+%{_includedir}/ObjFW/OFXMLProcessingInstruction.h
+%{_includedir}/ObjFW/OFZIPArchive.h
+%{_includedir}/ObjFW/OFZIPArchiveEntry.h
+%{_includedir}/ObjFW/ObjFW.h
+%{_includedir}/ObjFW/macros.h
+%{_includedir}/ObjFW/objfw-defs.h
+%{_includedir}/ObjFW/platform.h
+%{_includedir}/ObjFW/platform/GCC4.7/OFAtomic.h
+%{_includedir}/ObjFW/platform/GCC4/OFAtomic.h
+%{_includedir}/ObjFW/platform/PowerPC/OFAtomic.h
+%{_includedir}/ObjFW/platform/macOS/OFAtomic.h
+%{_includedir}/ObjFW/platform/x86/OFAtomic.h
+%{_bindir}/objfw-compile
+%{_bindir}/objfw-config
+%{_bindir}/objfw-new
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfwrt_pkgname}
+%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}
+%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}.%{libobjfwrt_minor}.0
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfwrt_pkgname}-devel
+%{_libdir}/libobjfwrt.so
+%{_includedir}/ObjFWRT/ObjFWRT.h
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofarc
+%{_bindir}/ofarc
+%{_datadir}/ofarc/lang/de.json
+%{_datadir}/ofarc/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofdns
+%{_bindir}/ofdns
+%{_datadir}/ofdns/lang/de.json
+%{_datadir}/ofdns/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofhash
+%{_bindir}/ofhash
+%{_datadir}/ofhash/lang/de.json
+%{_datadir}/ofhash/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofhttp
+%{_bindir}/ofhttp
+%{_datadir}/ofhttp/lang/de.json
+%{_datadir}/ofhttp/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
Index: src/OFArray.m
==================================================================
--- src/OFArray.m
+++ src/OFArray.m
@@ -237,22 +237,25 @@
- (id const *)objects
{
size_t count = self.count;
id *buffer = OFAllocMemory(count, sizeof(id));
+ id const *ret;
@try {
[self getObjects: buffer inRange: OFRangeMake(0, count)];
- return [[OFData dataWithItemsNoCopy: buffer
- count: count
- itemSize: sizeof(id)
- freeWhenDone: true] items];
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: count
+ itemSize: sizeof(id)
+ freeWhenDone: true] items];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
+
+ return ret;
}
- (id)copy
{
return [self retain];
Index: src/OFDNSResolverSettings.m
==================================================================
--- src/OFDNSResolverSettings.m
+++ src/OFDNSResolverSettings.m
@@ -69,10 +69,12 @@
#ifndef OF_WII
static OFString *
domainFromHostname(OFString *hostname)
{
+ OFString *ret;
+
if (hostname == nil)
return nil;
@try {
OFSocketAddressParseIP(hostname, 0);
@@ -79,20 +81,22 @@
/*
* If we are still here, the host name is a valid IP address.
* We can't use that as local domain.
*/
- return nil;
+ ret = nil;
} @catch (OFInvalidFormatException *e) {
/* Not an IP address -> we can use it if it contains a dot. */
size_t pos = [hostname rangeOfString: @"."].location;
- if (pos == OFNotFound)
- return nil;
-
- return [hostname substringFromIndex: pos + 1];
+ if (pos != OFNotFound)
+ ret = [hostname substringFromIndex: pos + 1];
+ else
+ ret = nil;
}
+
+ return ret;
}
#endif
#if !defined(OF_WII) && !defined(OF_MORPHOS)
static OFString *
Index: src/OFData.h
==================================================================
--- src/OFData.h
+++ src/OFData.h
@@ -118,10 +118,13 @@
itemSize: (size_t)itemSize;
/**
* @brief Creates a new OFData with the specified `count` items of size 1 by
* taking over ownership of the specified items pointer.
+ *
+ * If initialization fails for whatever reason, the passed memory is *not*
+ * free'd if `freeWhenDone` is true.
*
* @param items The items to store in the OFData
* @param count The number of items
* @param freeWhenDone Whether to free the pointer when it is no longer needed
* by the OFData
@@ -132,10 +135,13 @@
freeWhenDone: (bool)freeWhenDone;
/**
* @brief Creates a new OFData with the specified `count` items of the
* specified size by taking ownership of the specified items pointer.
+ *
+ * If initialization fails for whatever reason, the passed memory is *not*
+ * free'd if `freeWhenDone` is true.
*
* @param items The items to store in the OFData
* @param count The number of items
* @param itemSize The item size of a single item in bytes
* @param freeWhenDone Whether to free the pointer when it is no longer needed
@@ -210,10 +216,13 @@
/**
* @brief Initializes an already allocated OFData with the specified `count`
* items of size 1 by taking over ownership of the specified items
* pointer.
+ *
+ * If initialization fails for whatever reason, the passed memory is *not*
+ * free'd if `freeWhenDone` is true.
*
* @param items The items to store in the OFData
* @param count The number of items
* @param freeWhenDone Whether to free the pointer when it is no longer needed
* by the OFData
@@ -225,10 +234,13 @@
/**
* @brief Initializes an already allocated OFData with the specified `count`
* items of the specified size by taking ownership of the specified
* items pointer.
+ *
+ * If initialization fails for whatever reason, the passed memory is *not*
+ * free'd if `freeWhenDone` is true.
*
* @param items The items to store in the OFData
* @param count The number of items
* @param itemSize The item size of a single item in bytes
* @param freeWhenDone Whether to free the pointer when it is no longer needed
Index: src/OFHTTPServer.m
==================================================================
--- src/OFHTTPServer.m
+++ src/OFHTTPServer.m
@@ -114,16 +114,17 @@
@interface OFHTTPServerThread: OFThread
- (void)stop;
@end
#endif
-static OF_INLINE OFString *
+static OFString *
normalizedKey(OFString *key)
{
char *cString = OFStrDup(key.UTF8String);
unsigned char *tmp = (unsigned char *)cString;
bool firstLetter = true;
+ OFString *ret;
while (*tmp != '\0') {
if (!OFASCIIIsAlpha(*tmp)) {
firstLetter = true;
tmp++;
@@ -136,16 +137,18 @@
firstLetter = false;
tmp++;
}
@try {
- return [OFString stringWithUTF8StringNoCopy: cString
- freeWhenDone: true];
+ ret = [OFString stringWithUTF8StringNoCopy: cString
+ freeWhenDone: true];
} @catch (id e) {
OFFreeMemory(cString);
@throw e;
}
+
+ return ret;
}
@implementation OFHTTPServerResponse
- (instancetype)initWithSocket: (OFStreamSocket *)sock
server: (OFHTTPServer *)server
Index: src/OFString+URLEncoding.m
==================================================================
--- src/OFString+URLEncoding.m
+++ src/OFString+URLEncoding.m
@@ -82,10 +82,11 @@
size_t length = self.UTF8StringLength;
char *retCString;
char byte = 0;
int state = 0;
size_t i = 0;
+ OFString *ret;
retCString = OFAllocMemory(length + 1, 1);
while (length--) {
char c = *string++;
@@ -135,14 +136,16 @@
} @catch (OFOutOfMemoryException *e) {
/* We don't care if it fails, as we only made it smaller. */
}
@try {
- return [OFString stringWithUTF8StringNoCopy: retCString
- length: i
- freeWhenDone: true];
+ ret = [OFString stringWithUTF8StringNoCopy: retCString
+ length: i
+ freeWhenDone: true];
} @catch (id e) {
OFFreeMemory(retCString);
@throw e;
}
+
+ return ret;
}
@end
Index: src/OFString.h
==================================================================
--- src/OFString.h
+++ src/OFString.h
@@ -324,12 +324,12 @@
/**
* @brief Creates a new OFString from a UTF-8 encoded C string without copying
* the string, if possible.
*
- * If initialization fails for whatever reason, the passed C string is free'd
- * if `freeWhenDone` is true.
+ * If initialization fails for whatever reason, the passed C string is *not*
+ * free'd if `freeWhenDone` is true.
*
* @note OFMutableString always creates a copy!
*
* @param UTF8String A UTF-8 encoded C string to initialize the OFString with
* @param freeWhenDone Whether to free the C string when the OFString gets
@@ -341,12 +341,12 @@
/**
* @brief Creates a new OFString from a UTF-8 encoded C string with the
* specified length without copying the string, if possible.
*
- * If initialization fails for whatever reason, the passed C string is free'd
- * if `freeWhenDone` is true.
+ * If initialization fails for whatever reason, the passed C string is *not*
+ * free'd if `freeWhenDone` is true.
*
* @note OFMutableString always creates a copy!
*
* @param UTF8String A UTF-8 encoded C string to initialize the OFString with
* @param UTF8StringLength The length of the UTF-8 encoded C string
@@ -579,12 +579,12 @@
/**
* @brief Initializes an already allocated OFString from an UTF-8 encoded C
* string without copying the string, if possible.
*
- * If initialization fails for whatever reason, the passed C string is free'd
- * if `freeWhenDone` is true.
+ * If initialization fails for whatever reason, the passed C string is *not*
+ * free'd if `freeWhenDone` is true.
*
* @note OFMutableString always creates a copy!
*
* @param UTF8String A UTF-8 encoded C string to initialize the OFString with
* @param freeWhenDone Whether to free the C string when it is not needed
@@ -597,12 +597,12 @@
/**
* @brief Initializes an already allocated OFString from an UTF-8 encoded C
* string with the specified length without copying the string, if
* possible.
*
- * If initialization fails for whatever reason, the passed C string is free'd
- * if `freeWhenDone` is true.
+ * If initialization fails for whatever reason, the passed C string is *not*
+ * free'd if `freeWhenDone` is true.
*
* @note OFMutableString always creates a copy!
*
* @param UTF8String A UTF-8 encoded C string to initialize the OFString with
* @param UTF8StringLength The length of the UTF-8 encoded C string
Index: src/OFString.m
==================================================================
--- src/OFString.m
+++ src/OFString.m
@@ -1378,10 +1378,11 @@
lossy: (bool)lossy
{
size_t length = self.length;
char *cString;
size_t cStringLength;
+ const char *ret;
switch (encoding) {
case OFStringEncodingUTF8:
cString = OFAllocMemory((length * 4) + 1, 1);
@@ -1432,17 +1433,19 @@
default:
@throw [OFInvalidEncodingException exception];
}
@try {
- return [[OFData dataWithItemsNoCopy: cString
- count: cStringLength + 1
- freeWhenDone: true] items];
+ ret = [[OFData dataWithItemsNoCopy: cString
+ count: cStringLength + 1
+ freeWhenDone: true] items];
} @catch (id e) {
OFFreeMemory(cString);
@throw e;
}
+
+ return ret;
}
- (const char *)cStringWithEncoding: (OFStringEncoding)encoding
{
return [self of_cStringWithEncoding: encoding lossy: false];
@@ -2537,23 +2540,26 @@
- (const OFUnichar *)characters
{
size_t length = self.length;
OFUnichar *buffer;
+ const OFUnichar *ret;
buffer = OFAllocMemory(length, sizeof(OFUnichar));
@try {
[self getCharacters: buffer inRange: OFRangeMake(0, length)];
- return [[OFData dataWithItemsNoCopy: buffer
- count: length
- itemSize: sizeof(OFUnichar)
- freeWhenDone: true] items];
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: length
+ itemSize: sizeof(OFUnichar)
+ freeWhenDone: true] items];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
+
+ return ret;
}
- (const OFChar16 *)UTF16String
{
return [self UTF16StringWithByteOrder: OFByteOrderNative];
@@ -2565,10 +2571,11 @@
const OFUnichar *characters = self.characters;
size_t length = self.length;
OFChar16 *buffer;
size_t j;
bool swap = (byteOrder != OFByteOrderNative);
+ const OFChar16 *ret;
/* Allocate memory for the worst case */
buffer = OFAllocMemory((length + 1) * 2, sizeof(OFChar16));
j = 0;
@@ -2606,18 +2613,20 @@
}
objc_autoreleasePoolPop(pool);
@try {
- return [[OFData dataWithItemsNoCopy: buffer
- count: j + 1
- itemSize: sizeof(OFChar16)
- freeWhenDone: true] items];
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: j + 1
+ itemSize: sizeof(OFChar16)
+ freeWhenDone: true] items];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
+
+ return ret;
}
- (size_t)UTF16StringLength
{
const OFUnichar *characters = self.characters;
@@ -2639,10 +2648,11 @@
- (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder
{
size_t length = self.length;
OFChar32 *buffer;
+ const OFChar32 *ret;
buffer = OFAllocMemory(length + 1, sizeof(OFChar32));
@try {
[self getCharacters: buffer inRange: OFRangeMake(0, length)];
buffer[length] = 0;
@@ -2649,18 +2659,20 @@
if (byteOrder != OFByteOrderNative)
for (size_t i = 0; i < length; i++)
buffer[i] = OFByteSwap32(buffer[i]);
- return [[OFData dataWithItemsNoCopy: buffer
- count: length + 1
- itemSize: sizeof(OFChar32)
- freeWhenDone: true] items];
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: length + 1
+ itemSize: sizeof(OFChar32)
+ freeWhenDone: true] items];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
+
+ return ret;
}
- (OFData *)dataWithEncoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
Index: src/OFSystemInfo.m
==================================================================
--- src/OFSystemInfo.m
+++ src/OFSystemInfo.m
@@ -352,12 +352,11 @@
# if defined(OF_MACOS) || defined(OF_IOS)
char pathC[PATH_MAX];
OFMutableString *path;
# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION
- /* (1) to disable dead code warning when it is not a weak symbol */
- if ((1) && &sysdir_start_search_path_enumeration != NULL) {
+ if (@available(macOS 10.12, iOS 10, *)) {
sysdir_search_path_enumeration_state state;
state = sysdir_start_search_path_enumeration(
SYSDIR_DIRECTORY_APPLICATION_SUPPORT,
SYSDIR_DOMAIN_MASK_USER);
@@ -445,12 +444,11 @@
# if defined(OF_MACOS) || defined(OF_IOS)
char pathC[PATH_MAX];
OFMutableString *path;
# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION
- /* (1) to disable dead code warning when it is not a weak symbol */
- if ((1) && &sysdir_start_search_path_enumeration != NULL) {
+ if (@available(macOS 10.12, iOS 10, *)) {
sysdir_search_path_enumeration_state state;
state = sysdir_start_search_path_enumeration(
SYSDIR_DIRECTORY_LIBRARY, SYSDIR_DOMAIN_MASK_USER);
if (sysdir_get_next_search_path_enumeration(state, pathC) == 0)
Index: src/OFUTF8String.m
==================================================================
--- src/OFUTF8String.m
+++ src/OFUTF8String.m
@@ -1155,10 +1155,11 @@
- (const OFUnichar *)characters
{
OFUnichar *buffer = OFAllocMemory(_s->length, sizeof(OFUnichar));
size_t i = 0, j = 0;
+ const OFUnichar *ret;
while (i < _s->cStringLength) {
OFUnichar c;
ssize_t cLen;
@@ -1172,20 +1173,28 @@
buffer[j++] = c;
i += cLen;
}
- return [[OFData dataWithItemsNoCopy: buffer
- count: _s->length
- itemSize: sizeof(OFUnichar)
- freeWhenDone: true] items];
+ @try {
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: _s->length
+ itemSize: sizeof(OFUnichar)
+ freeWhenDone: true] items];
+ } @catch (id e) {
+ OFFreeMemory(buffer);
+ @throw e;
+ }
+
+ return ret;
}
- (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder
{
OFChar32 *buffer = OFAllocMemory(_s->length + 1, sizeof(OFChar32));
size_t i = 0, j = 0;
+ const OFChar32 *ret;
while (i < _s->cStringLength) {
OFChar32 c;
ssize_t cLen;
@@ -1204,14 +1213,21 @@
i += cLen;
}
buffer[j] = 0;
- return [[OFData dataWithItemsNoCopy: buffer
- count: _s->length + 1
- itemSize: sizeof(OFChar32)
- freeWhenDone: true] items];
+ @try {
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: _s->length + 1
+ itemSize: sizeof(OFChar32)
+ freeWhenDone: true] items];
+ } @catch (id e) {
+ OFFreeMemory(buffer);
+ @throw e;
+ }
+
+ return ret;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block
{
Index: src/runtime/autorelease.m
==================================================================
--- src/runtime/autorelease.m
+++ src/runtime/autorelease.m
@@ -33,10 +33,15 @@
#ifndef OF_OBJFW_RUNTIME
@interface DummyObject
- (void)release;
@end
#endif
+
+#ifndef OBJC_ERROR
+/* This is also used with old Apple runtimes that lack autorelease pools. */
+# define OBJC_ERROR(...) abort()
+#endif
#if defined(OF_HAVE_COMPILER_TLS)
static thread_local id *objects = NULL;
static thread_local uintptr_t count = 0;
static thread_local uintptr_t size = 0;
Index: src/runtime/lookup-asm/lookup-asm.S
==================================================================
--- src/runtime/lookup-asm/lookup-asm.S
+++ src/runtime/lookup-asm/lookup-asm.S
@@ -24,13 +24,13 @@
# include "lookup-asm-x86-elf.S"
# elif defined(OF_ARM64)
# include "lookup-asm-arm64-elf.S"
# elif defined(OF_ARM)
# include "lookup-asm-arm-elf.S"
-# elif defined(OF_POWERPC64)
+# elif defined(OF_POWERPC64) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
# include "lookup-asm-powerpc64-elf.S"
-# elif defined(OF_POWERPC)
+# elif defined(OF_POWERPC) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
# include "lookup-asm-powerpc-elf.S"
# elif defined(OF_MIPS64_N64)
# include "lookup-asm-mips64-n64-elf.S"
# elif defined(OF_MIPS)
# include "lookup-asm-mips-elf.S"
Index: src/runtime/private.h
==================================================================
--- src/runtime/private.h
+++ src/runtime/private.h
@@ -357,15 +357,19 @@
objc_error("ObjFWRT @ " __FILE__ ":" OF_STRINGIFY(__LINE__), \
__VA_ARGS__)
#if defined(OF_ELF)
# if defined(OF_X86_64) || defined(OF_X86) || \
- defined(OF_POWERPC64) || defined(OF_POWERPC) || \
defined(OF_ARM64) || defined(OF_ARM) || \
defined(OF_MIPS64_N64) || defined(OF_MIPS) || \
defined(OF_SPARC64) || defined(OF_SPARC)
# define OF_ASM_LOOKUP
+# endif
+# if defined(OF_POWERPC64) || defined(OF_POWERPC)
+# if !defined(_CALL_ELF) || _CALL_ELF == 1
+# define OF_ASM_LOOKUP
+# endif
# endif
#elif defined(OF_MACH_O)
# if defined(OF_X86_64)
# define OF_ASM_LOOKUP
# endif
Index: tests/Makefile
==================================================================
--- tests/Makefile
+++ tests/Makefile
@@ -1,8 +1,10 @@
include ../extra.mk
-SUBDIRS = ${TESTPLUGIN}
+SUBDIRS = ${TESTPLUGIN} \
+ objc_sync \
+ terminal
CLEAN = EBOOT.PBP \
boot.dol \
${PROG_NOINST}.arm9 \
${PROG_NOINST}.nds
@@ -73,12 +75,10 @@
IOS_USER ?= mobile
IOS_TMP ?= /tmp/objfw-test
include ../buildsys.mk
-post-all: ${RUN_TESTS}
-
.PHONY: run run-on-ios run-on-android
run:
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
Index: tests/OFBlockTests.m
==================================================================
--- tests/OFBlockTests.m
+++ tests/OFBlockTests.m
@@ -56,11 +56,14 @@
@implementation TestsAppDelegate (OFBlockTests)
- (void)blockTests
{
void *pool = objc_autoreleasePoolPush();
__block int x;
- void (^stackBlock)(void) = ^ { x = 0; };
+ void (^stackBlock)(void) = ^ {
+ x = 0;
+ (void)x;
+ };
void (^mallocBlock)(void);
int (^voidBlock)(void);
TEST(@"Class of stack block",
(Class)&_NSConcreteStackBlock == objc_getClass("OFStackBlock") &&
Index: tests/OFStreamTests.m
==================================================================
--- tests/OFStreamTests.m
+++ tests/OFStreamTests.m
@@ -70,14 +70,17 @@
cString = OFAllocMemory(pageSize - 2, 1);
memset(cString, 'X', pageSize - 3);
cString[pageSize - 3] = '\0';
- TEST(@"-[readLine]", [[test readLine] isEqual: @"foo"] &&
- (string = [test readLine]).length == pageSize - 3 &&
+ TEST(@"-[readLine] #1", [[test readLine] isEqual: @"foo"])
+
+ string = [test readLine];
+ TEST(@"-[readLine] #2", string != nil &&
+ string.length == pageSize - 3 &&
!strcmp(string.UTF8String, cString))
OFFreeMemory(cString);
objc_autoreleasePoolPop(pool);
}
@end
Index: tests/objc_sync/Makefile
==================================================================
--- tests/objc_sync/Makefile
+++ tests/objc_sync/Makefile
@@ -3,12 +3,10 @@
PROG_NOINST = objc_sync${PROG_SUFFIX}
SRCS = test.m
include ../../buildsys.mk
-post-all: ${RUN_TESTS}
-
.PHONY: run
run:
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
Index: tests/terminal/Makefile
==================================================================
--- tests/terminal/Makefile
+++ tests/terminal/Makefile
@@ -3,12 +3,10 @@
PROG_NOINST = terminal_tests${PROG_SUFFIX}
SRCS = TerminalTests.m
include ../../buildsys.mk
-post-all: ${RUN_TESTS}
-
.PHONY: run
run:
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib