ObjFW  Diff

Differences From Artifact [815f2dd728]:

To Artifact [9e8fe0a5ac]:


657
658
659
660
661
662
663
664
665
666




667
668
669
670
671
672
673
657
658
659
660
661
662
663



664
665
666
667
668
669
670
671
672
673
674







-
-
-
+
+
+
+







			if OF_UNLIKELY (_readBuffer[i] == '\n' ||
			    _readBuffer[i] == '\0') {
				retLength = i;

				if (i > 0 && _readBuffer[i - 1] == '\r')
					retLength--;

				ret = [OFString stringWithCString: _readBuffer
							 encoding: encoding
							   length: retLength];
				ret = [OFString
				    stringWithCString: (char *)_readBuffer
					     encoding: encoding
					       length: retLength];

				_readBuffer += i + 1;
				_readBufferLength -= i + 1;

				_waitingForDelimiter = false;
				return ret;
			}
686
687
688
689
690
691
692
693

694
695
696
697
698
699
700
687
688
689
690
691
692
693

694
695
696
697
698
699
700
701







-
+







			}

			retLength = _readBufferLength;

			if (retLength > 0 && _readBuffer[retLength - 1] == '\r')
				retLength--;

			ret = [OFString stringWithCString: _readBuffer
			ret = [OFString stringWithCString: (char *)_readBuffer
						 encoding: encoding
						   length: retLength];

			[self freeMemory: _readBufferMemory];
			_readBuffer = _readBufferMemory = NULL;
			_readBufferLength = 0;

881
882
883
884
885
886
887
888

889
890
891
892
893
894
895
882
883
884
885
886
887
888

889
890
891
892
893
894
895
896







-
+







				j = 0;

			if (j == delimiterLength || _readBuffer[i] == '\0') {
				if (_readBuffer[i] == '\0')
					delimiterLength = 1;

				ret = [OFString
				    stringWithCString: _readBuffer
				    stringWithCString: (char *)_readBuffer
					     encoding: encoding
					      length: i + 1 - delimiterLength];

				_readBuffer += i + 1;
				_readBufferLength -= i + 1;

				_waitingForDelimiter = false;
905
906
907
908
909
910
911
912

913
914
915
916
917
918
919
906
907
908
909
910
911
912

913
914
915
916
917
918
919
920







-
+







	@try {
		if ([self lowlevelIsAtEndOfStream]) {
			if (_readBuffer == NULL) {
				_waitingForDelimiter = false;
				return nil;
			}

			ret = [OFString stringWithCString: _readBuffer
			ret = [OFString stringWithCString: (char *)_readBuffer
						 encoding: encoding
						   length: _readBufferLength];

			[self freeMemory: _readBufferMemory];
			_readBuffer = _readBufferMemory = NULL;
			_readBufferLength = 0;

1035
1036
1037
1038
1039
1040
1041
1042

1043
1044
1045
1046
1047
1048
1049
1036
1037
1038
1039
1040
1041
1042

1043
1044
1045
1046
1047
1048
1049
1050







-
+







}

- (void)flushWriteBuffer
{
	if (_writeBuffer == NULL)
		return;

	[self lowlevelWriteBuffer: _writeBuffer
	[self lowlevelWriteBuffer: (char *)_writeBuffer
			   length: _writeBufferLength];

	[self freeMemory: _writeBuffer];
	_writeBuffer = NULL;
	_writeBufferLength = 0;
}