ObjFW  Check-in [a0b63a8df4]

Overview
Comment:Port to DOS/DJGPP.

The port was much easier than expected. The only changes that were
required were defining the missing lrint() and useconds_t, the rest was
optional (like using backslashes for paths, even though slashes work
fine).

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a0b63a8df43fe39d6b86685d92b4da9472698bc74f25311ef421a7792b6ef538
User & Date: js on 2013-12-01 02:08:43
Other Links: manifest | tags
Context
2013-12-01
11:50
Clean up the path delimiter mess. check-in: 00dbb47969 user: js tags: trunk
02:08
Port to DOS/DJGPP. check-in: a0b63a8df4 user: js tags: trunk
00:07
.gitignore: Add utils/ofzip.exe. check-in: 8b0c20a78c user: js tags: trunk
Changes

Modified PLATFORMS.md from [47f74d0f11] to [2e582093b2].

10
11
12
13
14
15
16










17
18
19
20
21
22
23

  * OS versions: 4.0.4, 4.1.2
  * Architectures: ARMv6, ARMv7
  * Compilers: Clang 3.3
  * Runtimes: ObjFW
  * Limitations: Does not work as a shared library












DragonFlyBSD
------------

  * OS versions: 3.0, 3.3-DEVELOPMENT
  * Architectures: x86, x86_64
  * Compilers: GCC 4.4.7







>
>
>
>
>
>
>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

  * OS versions: 4.0.4, 4.1.2
  * Architectures: ARMv6, ARMv7
  * Compilers: Clang 3.3
  * Runtimes: ObjFW
  * Limitations: Does not work as a shared library


DOS
---

  * OS versions: Windows XP DOS Emulation, DOSBox
  * Architectures: x86
  * Compilers: DJGPP GCC 4.7.3 (djdev204)
  * Runtimes: ObjFW
  * Limitations: No threads, no sockets


DragonFlyBSD
------------

  * OS versions: 3.0, 3.3-DEVELOPMENT
  * Architectures: x86, x86_64
  * Compilers: GCC 4.4.7

Modified src/OFString.m from [cca222946b] to [95256ec388].

1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
	if (length == 0)
		return ret;

	pool = objc_autoreleasePoolPush();

	characters = [self characters];

#ifndef _WIN32
	if (characters[length - 1] == OF_PATH_DELIMITER)
#else
	if (characters[length - 1] == '/' || characters[length - 1] == '\\')
#endif
		length--;

	for (i = 0; i < length; i++) {
#ifndef _WIN32
		if (characters[i] == OF_PATH_DELIMITER) {
#else
		if (characters[i] == '/' || characters[i] == '\\') {
#endif
			[ret addObject: [self substringWithRange:
			    of_range(last, i - last)]];








|







|







1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
	if (length == 0)
		return ret;

	pool = objc_autoreleasePoolPush();

	characters = [self characters];

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (characters[length - 1] == OF_PATH_DELIMITER)
#else
	if (characters[length - 1] == '/' || characters[length - 1] == '\\')
#endif
		length--;

	for (i = 0; i < length; i++) {
#if !defined(_WIN32) && !defined(__DJGPP__)
		if (characters[i] == OF_PATH_DELIMITER) {
#else
		if (characters[i] == '/' || characters[i] == '\\') {
#endif
			[ret addObject: [self substringWithRange:
			    of_range(last, i - last)]];

2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
	if (length == 0)
		return @"";

	pool = objc_autoreleasePoolPush();

	characters = [self characters];

#ifndef _WIN32
	if (characters[length - 1] == OF_PATH_DELIMITER)
#else
	if (characters[length - 1] == '/' || characters[length - 1] == '\\')
#endif
		length--;

	for (i = length - 1; i >= 0; i--) {
#ifndef _WIN32
		if (characters[i] == OF_PATH_DELIMITER) {
#else
		if (characters[i] == '/' || characters[i] == '\\') {
#endif
			i++;
			break;
		}







|







|







2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
	if (length == 0)
		return @"";

	pool = objc_autoreleasePoolPush();

	characters = [self characters];

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (characters[length - 1] == OF_PATH_DELIMITER)
#else
	if (characters[length - 1] == '/' || characters[length - 1] == '\\')
#endif
		length--;

	for (i = length - 1; i >= 0; i--) {
#if !defined(_WIN32) && !defined(__DJGPP__)
		if (characters[i] == OF_PATH_DELIMITER) {
#else
		if (characters[i] == '/' || characters[i] == '\\') {
#endif
			i++;
			break;
		}
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
	if (length == 0)
		return @"";

	pool = objc_autoreleasePoolPush();

	characters = [self characters];

#ifndef _WIN32
	if (characters[length - 1] == OF_PATH_DELIMITER)
#else
	if (characters[length - 1] == '/' || characters[length - 1] == '\\')
#endif
		length--;

	if (length == 0) {
		objc_autoreleasePoolPop(pool);
		return [self substringWithRange: of_range(0, 1)];
	}

	for (i = length - 1; i >= 1; i--) {
#ifndef _WIN32
		if (characters[i] == OF_PATH_DELIMITER) {
#else
		if (characters[i] == '/' || characters[i] == '\\') {
#endif
			objc_autoreleasePoolPop(pool);
			return [self substringWithRange: of_range(0, i)];
		}
	}

#ifndef _WIN32
	if (characters[0] == OF_PATH_DELIMITER) {
#else
	if (characters[0] == '/' || characters[0] == '\\') {
#endif
		objc_autoreleasePoolPop(pool);
		return [self substringWithRange: of_range(0, 1)];
	}







|












|









|







2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
	if (length == 0)
		return @"";

	pool = objc_autoreleasePoolPush();

	characters = [self characters];

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (characters[length - 1] == OF_PATH_DELIMITER)
#else
	if (characters[length - 1] == '/' || characters[length - 1] == '\\')
#endif
		length--;

	if (length == 0) {
		objc_autoreleasePoolPop(pool);
		return [self substringWithRange: of_range(0, 1)];
	}

	for (i = length - 1; i >= 1; i--) {
#if !defined(_WIN32) && !defined(__DJGPP__)
		if (characters[i] == OF_PATH_DELIMITER) {
#else
		if (characters[i] == '/' || characters[i] == '\\') {
#endif
			objc_autoreleasePoolPop(pool);
			return [self substringWithRange: of_range(0, i)];
		}
	}

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (characters[0] == OF_PATH_DELIMITER) {
#else
	if (characters[0] == '/' || characters[0] == '\\') {
#endif
		objc_autoreleasePoolPop(pool);
		return [self substringWithRange: of_range(0, 1)];
	}

Modified src/OFString_UTF8.m from [7fb4904a02] to [458af69b3f].

1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
	ret = [OFMutableArray array];

	if (pathCStringLength == 0)
		return ret;

	pool = objc_autoreleasePoolPush();

#ifndef _WIN32
	if (_s->cString[pathCStringLength - 1] == OF_PATH_DELIMITER)
#else
	if (_s->cString[pathCStringLength - 1] == '/' ||
	    _s->cString[pathCStringLength - 1] == '\\')
#endif
		pathCStringLength--;

	for (i = 0; i < pathCStringLength; i++) {
#ifndef _WIN32
		if (_s->cString[i] == OF_PATH_DELIMITER) {
#else
		if (_s->cString[i] == '/' || _s->cString[i] == '\\') {
#endif
			[ret addObject:
			    [OFString stringWithUTF8String: _s->cString + last
						    length: i - last]];







|








|







1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
	ret = [OFMutableArray array];

	if (pathCStringLength == 0)
		return ret;

	pool = objc_autoreleasePoolPush();

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (_s->cString[pathCStringLength - 1] == OF_PATH_DELIMITER)
#else
	if (_s->cString[pathCStringLength - 1] == '/' ||
	    _s->cString[pathCStringLength - 1] == '\\')
#endif
		pathCStringLength--;

	for (i = 0; i < pathCStringLength; i++) {
#if !defined(_WIN32) && !defined(__DJGPP__)
		if (_s->cString[i] == OF_PATH_DELIMITER) {
#else
		if (_s->cString[i] == '/' || _s->cString[i] == '\\') {
#endif
			[ret addObject:
			    [OFString stringWithUTF8String: _s->cString + last
						    length: i - last]];
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
{
	size_t pathCStringLength = _s->cStringLength;
	ssize_t i;

	if (pathCStringLength == 0)
		return @"";

#ifndef _WIN32
	if (_s->cString[pathCStringLength - 1] == OF_PATH_DELIMITER)
#else
	if (_s->cString[pathCStringLength - 1] == '/' ||
	    _s->cString[pathCStringLength - 1] == '\\')
#endif
		pathCStringLength--;

	for (i = pathCStringLength - 1; i >= 0; i--) {
#ifndef _WIN32
		if (_s->cString[i] == OF_PATH_DELIMITER) {
#else
		if (_s->cString[i] == '/' || _s->cString[i] == '\\') {
#endif
			i++;
			break;
		}







|








|







1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
{
	size_t pathCStringLength = _s->cStringLength;
	ssize_t i;

	if (pathCStringLength == 0)
		return @"";

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (_s->cString[pathCStringLength - 1] == OF_PATH_DELIMITER)
#else
	if (_s->cString[pathCStringLength - 1] == '/' ||
	    _s->cString[pathCStringLength - 1] == '\\')
#endif
		pathCStringLength--;

	for (i = pathCStringLength - 1; i >= 0; i--) {
#if !defined(_WIN32) && !defined(__DJGPP__)
		if (_s->cString[i] == OF_PATH_DELIMITER) {
#else
		if (_s->cString[i] == '/' || _s->cString[i] == '\\') {
#endif
			i++;
			break;
		}
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
- (OFString*)stringByDeletingLastPathComponent
{
	size_t i, pathCStringLength = _s->cStringLength;

	if (pathCStringLength == 0)
		return @"";

#ifndef _WIN32
	if (_s->cString[pathCStringLength - 1] == OF_PATH_DELIMITER)
#else
	if (_s->cString[pathCStringLength - 1] == '/' ||
	    _s->cString[pathCStringLength - 1] == '\\')
#endif
		pathCStringLength--;

	if (pathCStringLength == 0)
		return [OFString stringWithUTF8String: _s->cString
					       length: 1];

	for (i = pathCStringLength - 1; i >= 1; i--)
#ifndef _WIN32
		if (_s->cString[i] == OF_PATH_DELIMITER)
#else
		if (_s->cString[i] == '/' || _s->cString[i] == '\\')
#endif
			return [OFString stringWithUTF8String: _s->cString
						       length: i];

#ifndef _WIN32
	if (_s->cString[0] == OF_PATH_DELIMITER)
#else
	if (_s->cString[0] == '/' || _s->cString[0] == '\\')
#endif
		return [OFString stringWithUTF8String: _s->cString
					       length: 1];








|












|







|







1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
- (OFString*)stringByDeletingLastPathComponent
{
	size_t i, pathCStringLength = _s->cStringLength;

	if (pathCStringLength == 0)
		return @"";

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (_s->cString[pathCStringLength - 1] == OF_PATH_DELIMITER)
#else
	if (_s->cString[pathCStringLength - 1] == '/' ||
	    _s->cString[pathCStringLength - 1] == '\\')
#endif
		pathCStringLength--;

	if (pathCStringLength == 0)
		return [OFString stringWithUTF8String: _s->cString
					       length: 1];

	for (i = pathCStringLength - 1; i >= 1; i--)
#if !defined(_WIN32) && !defined(__DJGPP__)
		if (_s->cString[i] == OF_PATH_DELIMITER)
#else
		if (_s->cString[i] == '/' || _s->cString[i] == '\\')
#endif
			return [OFString stringWithUTF8String: _s->cString
						       length: i];

#if !defined(_WIN32) && !defined(__DJGPP__)
	if (_s->cString[0] == OF_PATH_DELIMITER)
#else
	if (_s->cString[0] == '/' || _s->cString[0] == '\\')
#endif
		return [OFString stringWithUTF8String: _s->cString
					       length: 1];

Modified src/OFThread+Private.h from [b0ccbc3e19] to [5fe8f6ca74].

14
15
16
17
18
19
20

21
22
23

 * file.
 */

#import "OFThread.h"

#import "macros.h"


@interface OFThread (OF_PRIVATE_CATEGORY)
+ (void)OF_createMainThread;
@end








>



>
14
15
16
17
18
19
20
21
22
23
24
25
 * file.
 */

#import "OFThread.h"

#import "macros.h"

#ifdef OF_HAVE_THREADS
@interface OFThread (OF_PRIVATE_CATEGORY)
+ (void)OF_createMainThread;
@end
#endif

Modified src/OFThread.m from [b5e162fd36] to [d3db130196].

61
62
63
64
65
66
67





68
69
70
71
72
73
74
#endif

#ifdef OF_HAVE_ATOMIC_OPS
# import "atomic.h"
#endif
#import "autorelease.h"
#import "macros.h"






#ifdef OF_HAVE_THREADS
# import "threading.h"

static of_tlskey_t threadSelfKey;
static OFThread *mainThread;








>
>
>
>
>







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#endif

#ifdef OF_HAVE_ATOMIC_OPS
# import "atomic.h"
#endif
#import "autorelease.h"
#import "macros.h"

#ifdef __DJGPP__
# define lrint(x) rint(x)
# define useconds_t unsigned int
#endif

#ifdef OF_HAVE_THREADS
# import "threading.h"

static of_tlskey_t threadSelfKey;
static OFThread *mainThread;

Modified src/macros.h from [1065db52e2] to [dcc14d0966].

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#define OF_ENSURE(cond)							\
	if (!(cond)) {							\
		fprintf(stderr, "Failed to ensure condition in "	\
		    __FILE__ ":%d:\n" #cond "\n", __LINE__);		\
		abort();						\
	}

#ifndef _WIN32
# define OF_PATH_DELIMITER '/'
# define OF_PATH_DELIMITER_STRING @"/"
#else
# define OF_PATH_DELIMITER '\\'
# define OF_PATH_DELIMITER_STRING @"\\"
#endif
#define OF_PATH_CURRENT_DIRECTORY @"."







|







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#define OF_ENSURE(cond)							\
	if (!(cond)) {							\
		fprintf(stderr, "Failed to ensure condition in "	\
		    __FILE__ ":%d:\n" #cond "\n", __LINE__);		\
		abort();						\
	}

#if !defined(_WIN32) && !defined(__DJGPP__)
# define OF_PATH_DELIMITER '/'
# define OF_PATH_DELIMITER_STRING @"/"
#else
# define OF_PATH_DELIMITER '\\'
# define OF_PATH_DELIMITER_STRING @"\\"
#endif
#define OF_PATH_CURRENT_DIRECTORY @"."

Modified tests/OFStringTests.m from [fe0644a99a] to [14295c4581].

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
	    [[a objectAtIndex: i++] isEqual: @"foo"] &&
	    [[a objectAtIndex: i++] isEqual: @"bar"] &&
	    [[a objectAtIndex: i++] isEqual: @"baz"])

	TEST(@"+[pathWithComponents:]",
	    (is = [OFString pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]]) &&
#ifndef _WIN32
	    [is isEqual: @"foo/bar/baz"] &&
#else
	    [is isEqual: @"foo\\bar\\baz"] &&
#endif
	    (is = [OFString pathWithComponents:
	    [OFArray arrayWithObjects: @"foo", nil]]) &&
	    [is isEqual: @"foo"])







|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
	    [[a objectAtIndex: i++] isEqual: @"foo"] &&
	    [[a objectAtIndex: i++] isEqual: @"bar"] &&
	    [[a objectAtIndex: i++] isEqual: @"baz"])

	TEST(@"+[pathWithComponents:]",
	    (is = [OFString pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]]) &&
#if !defined(_WIN32) && !defined(__DJGPP__)
	    [is isEqual: @"foo/bar/baz"] &&
#else
	    [is isEqual: @"foo\\bar\\baz"] &&
#endif
	    (is = [OFString pathWithComponents:
	    [OFArray arrayWithObjects: @"foo", nil]]) &&
	    [is isEqual: @"foo"])
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
	    [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."])

	TEST(@"-[stringByDeletingPathExtension]",
	    [[@"foo.bar" stringByDeletingPathExtension] isEqual: @"foo"] &&
	    [[@"foo..bar" stringByDeletingPathExtension] isEqual: @"foo."] &&
	    [[@"/foo./bar" stringByDeletingPathExtension]
	    isEqual: @"/foo./bar"] &&
#ifndef _WIN32
	    [[@"/foo./bar.baz" stringByDeletingPathExtension]
	    isEqual: @"/foo./bar"] &&
#else
	    [[@"/foo./bar.baz" stringByDeletingPathExtension]
	    isEqual: @"\\foo.\\bar"] &&
#endif
	    [[@"foo.bar/" stringByDeletingPathExtension] isEqual: @"foo"] &&







|







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
	    [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."])

	TEST(@"-[stringByDeletingPathExtension]",
	    [[@"foo.bar" stringByDeletingPathExtension] isEqual: @"foo"] &&
	    [[@"foo..bar" stringByDeletingPathExtension] isEqual: @"foo."] &&
	    [[@"/foo./bar" stringByDeletingPathExtension]
	    isEqual: @"/foo./bar"] &&
#if !defined(_WIN32) && !defined(__DJGPP__)
	    [[@"/foo./bar.baz" stringByDeletingPathExtension]
	    isEqual: @"/foo./bar"] &&
#else
	    [[@"/foo./bar.baz" stringByDeletingPathExtension]
	    isEqual: @"\\foo.\\bar"] &&
#endif
	    [[@"foo.bar/" stringByDeletingPathExtension] isEqual: @"foo"] &&
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
	 */
	TEST(@"-[floatValue]",
	    [@"\t-0.25 " floatValue] == -0.25 &&
	    [@"\r-INFINITY\n" floatValue] == -INFINITY &&
	    isnan([@"   NAN\t\t" floatValue]))

	TEST(@"-[doubleValue]",
#ifndef __ANDROID__
	    [@"\t-0x1.FFFFFFFFFFFFFP-1020 " doubleValue] ==
	    -0x1.FFFFFFFFFFFFFP-1020 &&
#else
	    /* strtod() does not accept 0x on Android */
	    [@"\t-0.123456789 " doubleValue] == -0.123456789 &&
#endif
	    [@"\r-INFINITY\n" doubleValue] == -INFINITY &&
	    isnan([@"   NAN\t\t" doubleValue]))

	EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #1",
	    OFInvalidFormatException, [@"abc" decimalValue])







|



|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
	 */
	TEST(@"-[floatValue]",
	    [@"\t-0.25 " floatValue] == -0.25 &&
	    [@"\r-INFINITY\n" floatValue] == -INFINITY &&
	    isnan([@"   NAN\t\t" floatValue]))

	TEST(@"-[doubleValue]",
#if !defined(__ANDROID__) && !defined(__DJGPP__)
	    [@"\t-0x1.FFFFFFFFFFFFFP-1020 " doubleValue] ==
	    -0x1.FFFFFFFFFFFFFP-1020 &&
#else
	    /* Android and DJGPPP do not accept 0x for strtod() */
	    [@"\t-0.123456789 " doubleValue] == -0.123456789 &&
#endif
	    [@"\r-INFINITY\n" doubleValue] == -INFINITY &&
	    isnan([@"   NAN\t\t" doubleValue]))

	EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #1",
	    OFInvalidFormatException, [@"abc" decimalValue])

Modified tests/TestsAppDelegate.m from [b829b6aa4c] to [c3595a97f9].

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import "OFFile.h"
#import "OFAutoreleasePool.h"

#import "OFException.h"

#import "TestsAppDelegate.h"

#if defined(_WIN32) && defined(STDOUT)
# undef STDOUT
# define STDOUT_SIMPLE
#endif

#ifdef _PSP
# include <pspmoduleinfo.h>
# include <pspkernel.h>







|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import "OFFile.h"
#import "OFAutoreleasePool.h"

#import "OFException.h"

#import "TestsAppDelegate.h"

#if defined(STDOUT) && (defined(_WIN32) || defined(__DJGPP__))
# undef STDOUT
# define STDOUT_SIMPLE
#endif

#ifdef _PSP
# include <pspmoduleinfo.h>
# include <pspkernel.h>