Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -391,14 +391,14 @@
* Thank you to [Jonathan Neuschäfer](https://github.com/neuschaefer) for
reviewing the *entirety* (all 84k LoC at the time) of ObjFW's codebase in
2017!
* Thank you to [Hill Ma](https://github.com/mahiuchun) for donating an M1 Mac
- Mini to the project!
+ Mini to the project in 2022!
Commercial use
If for whatever reason neither the terms of the QPL nor those of the GPL work
for you, a proprietary license for ObjFW including support is available upon
request. Just write a mail to js@nil.im and we can find a reasonable solution
for both parties.
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -1399,11 +1399,16 @@
AC_CHECK_HEADER(netinet/tcp.h, [
AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
[Whether we have netinet/tcp.h])
])
AC_CHECK_HEADERS([arpa/inet.h netdb.h sys/sockio.h])
- AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h])
+ AC_CHECK_HEADERS([net/if.h], [], [], [
+ #ifdef OF_HAVE_SYS_SOCKET_H
+ # include
+ #endif
+ ])
+ AC_CHECK_HEADERS([net/if_arp.h net/if_dl.h net/if_types.h])
AC_CHECK_FUNCS([if_indextoname if_nametoindex if_nameindex])
AC_CHECK_TYPES([struct sockaddr_dl], [], [], [
#ifdef HAVE_SYS_TYPES_H
# include
#endif
@@ -1531,12 +1536,12 @@
AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
[Whether we have netipx/ipx.h])
])
AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [
AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [
- AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_addr.x_port, [
- ], [], [
+ AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_addr.x_port,
+ [], [], [
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
Index: src/OFArray.m
==================================================================
--- src/OFArray.m
+++ src/OFArray.m
@@ -208,14 +208,16 @@
for (size_t i = 1; i < count; i++) {
objects[i] = va_arg(arguments, id);
OFEnsure(objects[i] != nil);
}
- return [self initWithObjects: objects count: count];
+ self = [self initWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
+
+ return self;
}
- (instancetype)initWithArray: (OFArray *)array
{
id *objects;
@@ -231,14 +233,16 @@
[self release];
@throw e;
}
@try {
- return [self initWithObjects: objects count: count];
+ self = [self initWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
+
+ return self;
}
#ifdef __clang__
/* We intentionally don't call into super, so silence the warning. */
# pragma clang diagnostic push
Index: src/OFDictionary.m
==================================================================
--- src/OFDictionary.m
+++ src/OFDictionary.m
@@ -216,16 +216,18 @@
[self release];
@throw e;
}
@try {
- return [self initWithObjects: objects
+ self = [self initWithObjects: objects
forKeys: keys
count: count];
} @finally {
objc_autoreleasePoolPop(pool);
}
+
+ return self;
}
- (instancetype)initWithObject: (id)object forKey: (id)key
{
@try {
@@ -334,17 +336,19 @@
[self release];
@throw e;
}
@try {
- return [self initWithObjects: objects
+ self = [self initWithObjects: objects
forKeys: keys
count: count];
} @finally {
OFFreeMemory(objects);
OFFreeMemory(keys);
}
+
+ return self;
}
- (id)objectForKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
Index: src/OFFileIRIHandler.m
==================================================================
--- src/OFFileIRIHandler.m
+++ src/OFFileIRIHandler.m
@@ -842,17 +842,17 @@
OFTimeInterval modificationTime =
modificationDate.timeIntervalSince1970;
struct timeval times[2] = {
{
.tv_sec = (time_t)lastAccessTime,
- .tv_usec =
- (int)((lastAccessTime - times[0].tv_sec) * 1000000)
+ .tv_usec = (int)((lastAccessTime -
+ (time_t)lastAccessTime) * 1000000)
},
{
.tv_sec = (time_t)modificationTime,
- .tv_usec = (int)((modificationTime - times[1].tv_sec) *
- 1000000)
+ .tv_usec = (int)((modificationTime -
+ (time_t)modificationTime) * 1000000)
},
};
if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0)
@throw [OFSetItemAttributesFailedException
Index: src/OFFileManager.m
==================================================================
--- src/OFFileManager.m
+++ src/OFFileManager.m
@@ -330,19 +330,22 @@
}
#endif
- (void)createDirectoryAtIRI: (OFIRI *)IRI
{
+ void *pool = objc_autoreleasePoolPush();
OFIRIHandler *IRIHandler;
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[IRIHandler createDirectoryAtIRI: IRI];
+
+ objc_autoreleasePoolPop(pool);
}
- (void)createDirectoryAtIRI: (OFIRI *)IRI createParents: (bool)createParents
{
void *pool = objc_autoreleasePoolPush();
@@ -355,10 +358,12 @@
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (!createParents) {
[self createDirectoryAtIRI: IRI];
+
+ objc_autoreleasePoolPop(pool);
return;
}
/*
* Try blindly creating the directory first.
@@ -365,15 +370,20 @@
*
* The reason for this is that we might be sandboxed, so attempting to
* create any of the parent directories will fail, while creating the
* directory itself will work.
*/
- if ([self directoryExistsAtIRI: IRI])
+
+ if ([self directoryExistsAtIRI: IRI]) {
+ objc_autoreleasePoolPop(pool);
return;
+ }
@try {
[self createDirectoryAtIRI: IRI];
+
+ objc_autoreleasePoolPop(pool);
return;
} @catch (OFCreateDirectoryFailedException *e) {
/*
* If we didn't fail because any of the parents is missing,
* there is no point in trying to create the parents.
Index: src/OFSet.m
==================================================================
--- src/OFSet.m
+++ src/OFSet.m
@@ -175,14 +175,16 @@
[self release];
@throw e;
}
@try {
- return [self initWithObjects: objects count: count];
+ self = [self initWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
+
+ return self;
}
- (instancetype)initWithArray: (OFArray *)array
{
void *pool = objc_autoreleasePoolPush();
@@ -256,14 +258,16 @@
for (size_t i = 1; i < count; i++) {
objects[i] = va_arg(arguments, id);
OFEnsure(objects[i] != nil);
}
- return [self initWithObjects: objects count: count];
+ self = [self initWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
+
+ return self;
}
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
Index: src/OFSystemInfo.m
==================================================================
--- src/OFSystemInfo.m
+++ src/OFSystemInfo.m
@@ -57,11 +57,12 @@
#import "OFApplication.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
- #import "OFFile.h"
+# import "OFFile.h"
+# import "OFFileManager.h"
#endif
#import "OFIRI.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFOnce.h"
@@ -448,10 +449,12 @@
return [OFIRI fileIRIWithPath: [OFString stringWithUTF8String: pathC]
isDirectory: true];
# elif defined(OF_AMIGAOS)
return [OFIRI fileIRIWithPath: @"PROGDIR:" isDirectory: true];
+# elif defined(OF_WII) || defined(OF_NINTENDO_3DS)
+ return [[OFFileManager defaultManager] currentDirectoryIRI];
# else
OFDictionary *env = [OFApplication environment];
OFString *var;
OFIRI *IRI;
void *pool;
@@ -538,10 +541,12 @@
return [OFIRI fileIRIWithPath: [OFString stringWithUTF8String: pathC]
isDirectory: true];
# elif defined(OF_AMIGAOS)
return [OFIRI fileIRIWithPath: @"PROGDIR:" isDirectory: true];
+# elif defined(OF_WII) || defined(OF_NINTENDO_3DS)
+ return [[OFFileManager defaultManager] currentDirectoryIRI];
# else
OFDictionary *env = [OFApplication environment];
OFString *var;
if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil &&
@@ -615,10 +620,12 @@
return nil;
return [OFIRI fileIRIWithPath: path isDirectory: true];
# elif defined(OF_MINT)
return [OFIRI fileIRIWithPath: @"u:\\tmp" isDirectory: true];
+# elif defined(OF_WII) || defined(OF_NINTENDO_3DS)
+ return [[OFFileManager defaultManager] currentDirectoryIRI];
# elif defined(OF_NINTENDO_SWITCH)
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, mountTmpFS);
return tmpFSIRI;
Index: src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m
==================================================================
--- src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m
+++ src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m
@@ -68,21 +68,21 @@
@try {
for (size_t i = 0; nameindex[i].if_index != 0; i++) {
OFString *name = [OFString
stringWithCString: nameindex[i].if_name
encoding: encoding];
- OFNumber *index = [OFNumber
+ OFNumber *idx = [OFNumber
numberWithUnsignedInt: nameindex[i].if_index];
OFMutableDictionary *interface =
[ret objectForKey: name];
if (interface == nil) {
interface = [OFMutableDictionary dictionary];
[ret setObject: interface forKey: name];
}
- [interface setObject: index
+ [interface setObject: idx
forKey: OFNetworkInterfaceIndex];
}
} @finally {
if_freenameindex(nameindex);
}