ObjFW  Check-in [615a9f2eba]

Overview
Comment:Fix compilation with GCC
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 615a9f2eba252a180c66396968e47bc0f8a4bbf898f844d3b7167d9ae4e99cff
User & Date: js on 2017-11-19 12:56:14
Other Links: manifest | tags
Context
2017-11-19
13:14
Remove +[OFObject new] check-in: c03aab9c8c user: js tags: trunk
12:56
Fix compilation with GCC check-in: 615a9f2eba user: js tags: trunk
12:05
Fix warnings introduced by OFComparing change check-in: 11f24addd7 user: js tags: trunk
Changes

Modified src/OFData.m from [7aeee7380b] to [744ee14c6a].

432
433
434
435
436
437
438
439

440
441
442
443
444
445

446
447
448
449
450
451
452
432
433
434
435
436
437
438

439
440
441
442
443
444

445
446
447
448
449
450
451
452







-
+





-
+







		return false;
	if (memcmp([data items], _items, _count * _itemSize) != 0)
		return false;

	return true;
}

- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFData *data;
	int comparison;
	size_t count, minCount;

	if (![object isKindOfClass: [OFData class]])
	if (![(id)object isKindOfClass: [OFData class]])
		@throw [OFInvalidArgumentException exception];

	data = (OFData *)object;

	if ([data itemSize] != _itemSize)
		@throw [OFInvalidArgumentException exception];

Modified src/OFDate.m from [da50e80816] to [e550224756].

393
394
395
396
397
398
399
400

401
402
403
404

405
406
407
408
409
410
411
393
394
395
396
397
398
399

400
401
402
403

404
405
406
407
408
409
410
411







-
+



-
+







}

- (id)copy
{
	return [self retain];
}

- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFDate *otherDate;

	if (![object isKindOfClass: [OFDate class]])
	if (![(id)object isKindOfClass: [OFDate class]])
		@throw [OFInvalidArgumentException exception];

	otherDate = (OFDate *)object;

	if (_seconds < otherDate->_seconds)
		return OF_ORDERED_ASCENDING;
	if (_seconds > otherDate->_seconds)

Modified src/OFNumber.m from [64757a4f33] to [266c1e5fc4].

759
760
761
762
763
764
765
766

767
768
769
770

771
772
773
774
775
776
777
759
760
761
762
763
764
765

766
767
768
769

770
771
772
773
774
775
776
777







-
+



-
+







	if (_type & OF_NUMBER_TYPE_SIGNED ||
	    number->_type & OF_NUMBER_TYPE_SIGNED)
		return ([number intMaxValue] == [self intMaxValue]);

	return ([number uIntMaxValue] == [self uIntMaxValue]);
}

- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFNumber *number;

	if (![object isKindOfClass: [OFNumber class]])
	if (![(id)object isKindOfClass: [OFNumber class]])
		@throw [OFInvalidArgumentException exception];

	number = (OFNumber *)object;

	if (_type & OF_NUMBER_TYPE_FLOAT ||
	    number->_type & OF_NUMBER_TYPE_FLOAT) {
		double double1 = [self doubleValue];

Modified src/OFStream.m from [e841a9f1c7] to [32a50ea176].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
21
22
23
24
25
26
27




28
29
30
31
32
33
34







-
-
-
-







#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif

#include "platform.h"

#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
# include <signal.h>
#endif

#import "OFStream.h"
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1633
1634
1635
1636
1637
1638
1639



























































1640

1641
1642
1643
1644
1645
1646
1647







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-







- (bool)isBlocking
{
	return _blocking;
}

- (void)setBlocking: (bool)enable
{
#ifdef HAVE_FCNTL
	bool readImplemented = false, writeImplemented = false;

	@try {
		int readFlags;

		readFlags = fcntl([self fileDescriptorForReading], F_GETFL);

		readImplemented = true;

		if (readFlags == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];

		if (enable)
			readFlags &= ~O_NONBLOCK;
		else
			readFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForReading], F_SETFL,
		    readFlags) == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];
	} @catch (OFNotImplementedException *e) {
	}

	@try {
		int writeFlags;

		writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL);

		writeImplemented = true;

		if (writeFlags == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];

		if (enable)
			writeFlags &= ~O_NONBLOCK;
		else
			writeFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForWriting], F_SETFL,
		    writeFlags) == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];
	} @catch (OFNotImplementedException *e) {
	}

	if (!readImplemented && !writeImplemented)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	_blocking = enable;
#else
	OF_UNRECOGNIZED_SELECTOR
#endif
}

- (int)fileDescriptorForReading
{
	OF_UNRECOGNIZED_SELECTOR
}

1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1682
1683
1684
1685
1686
1687
1688

1689
1690







-



	[self freeMemory: _writeBuffer];
	_writeBuffer = NULL;
	_writeBufferLength = 0;
	_writeBuffered = false;

	_waitingForDelimiter = false;
	_blocking = false;
}
@end

Modified src/OFStreamSocket.m from [c5ebdea8f5] to [de7c76a291].

16
17
18
19
20
21
22




23
24
25
26

27
28
29
30
31
32
33
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38







+
+
+
+




+








#define __NO_EXT_QNX

#include "config.h"

#include <errno.h>
#include <string.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif

#import "OFStreamSocket.h"

#import "OFInitializationFailedException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSetOptionFailedException.h"
#import "OFWriteFailedException.h"

#import "socket_helpers.h"
118
119
120
121
122
123
124
125
126
127















128










































129


130
131
132
133
134
135




136

137
138
139
140
141
142
143
123
124
125
126
127
128
129

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
204
205
206
207
208
209







-


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+





-
+
+
+
+

+







			   bytesWritten: 0
				  errNo: of_socket_errno()];
#endif

	return (size_t)bytesWritten;
}

#ifdef OF_WINDOWS
- (void)setBlocking: (bool)enable
{
#if defined(HAVE_FCNTL)
	bool readImplemented = false, writeImplemented = false;

	@try {
		int readFlags;

		readFlags = fcntl([self fileDescriptorForReading], F_GETFL);

		readImplemented = true;

		if (readFlags == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];

	u_long v = enable;
		if (enable)
			readFlags &= ~O_NONBLOCK;
		else
			readFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForReading], F_SETFL,
		    readFlags) == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];
	} @catch (OFNotImplementedException *e) {
	}

	@try {
		int writeFlags;

		writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL);

		writeImplemented = true;

		if (writeFlags == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];

		if (enable)
			writeFlags &= ~O_NONBLOCK;
		else
			writeFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForWriting], F_SETFL,
		    writeFlags) == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithStream: self
					  errNo: errno];
	} @catch (OFNotImplementedException *e) {
	}

	if (!readImplemented && !writeImplemented)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	_blocking = enable;
#elif defined(OF_WINDOWS)
	u_long v = enable;

	if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException
		    exceptionWithStream: self
				  errNo: of_socket_errno()];
}

	_blocking = enable;
#else
	OF_UNRECOGNIZED_SELECTOR
#endif
}

- (int)fileDescriptorForReading
{
#ifndef OF_WINDOWS
	return _socket;
#else
	if (_socket == INVALID_SOCKET)

Modified src/OFString.m from [27fbf1ebf8] to [6c49aac468].

1548
1549
1550
1551
1552
1553
1554
1555

1556
1557
1558
1559
1560
1561
1562
1563
1564
1565

1566
1567
1568
1569
1570
1571
1572
1548
1549
1550
1551
1552
1553
1554

1555
1556
1557
1558
1559
1560
1561
1562
1563
1564

1565
1566
1567
1568
1569
1570
1571
1572







-
+









-
+







}

- (id)mutableCopy
{
	return [[OFMutableString alloc] initWithString: self];
}

- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	void *pool;
	OFString *otherString;
	const of_unichar_t *characters, *otherCharacters;
	size_t minimumLength;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
	if (![(id)object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];

	otherString = (OFString *)object;
	minimumLength = ([self length] > [otherString length]
	    ? [otherString length] : [self length]);

	pool = objc_autoreleasePoolPush();

Modified src/OFString_UTF8.m from [879030fae2] to [ec9ecd6e22].

804
805
806
807
808
809
810
811

812
813
814
815
816
817
818
819
820

821
822
823
824
825
826
827
804
805
806
807
808
809
810

811
812
813
814
815
816
817
818
819

820
821
822
823
824
825
826
827







-
+








-
+








	if (strcmp(_s->cString, [otherString UTF8String]) != 0)
		return false;

	return true;
}

- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFString *otherString;
	size_t otherCStringLength, minimumCStringLength;
	int compare;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
	if (![(id)object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];

	otherString = (OFString *)object;
	otherCStringLength = [otherString UTF8StringLength];
	minimumCStringLength = (_s->cStringLength > otherCStringLength
	    ? otherCStringLength : _s->cStringLength);

Modified src/OFTimer.m from [7c5e87e7c3] to [e8f4bfafc2].

502
503
504
505
506
507
508
509

510
511
512
513

514
515
516
517
518
519
520
502
503
504
505
506
507
508

509
510
511
512

513
514
515
516
517
518
519
520







-
+



-
+







#ifdef OF_HAVE_THREADS
	[_condition release];
#endif

	[super dealloc];
}

- (of_comparison_result_t)compare: (id <OFObject, OFComparing>)object
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFTimer *timer;

	if (![object isKindOfClass: [OFTimer class]])
	if (![(id)object isKindOfClass: [OFTimer class]])
		@throw [OFInvalidArgumentException exception];

	timer = (OFTimer *)object;

	return [_fireDate compare: timer->_fireDate];
}