ObjFW  Check-in [62d1b84b30]

Overview
Comment:Make a few implicit casts explicit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 62d1b84b30d78d0621d99f8d19f080b78726fc435afc1aa4c1e62a2925a24ec3
User & Date: js on 2013-11-06 22:35:55
Other Links: manifest | tags
Context
2013-11-06
22:40
objfw-unzip: Link with ${LDFLAGS_RPATH}. check-in: 04e7ac480f user: js tags: trunk
22:35
Make a few implicit casts explicit. check-in: 62d1b84b30 user: js tags: trunk
21:11
objfw-unzip: Add "never override" mode. check-in: 64f72315cd user: js tags: trunk
Changes

Modified src/OFDeflateStream.m from [4e0c067ee9] to [20af4c93d0].

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
					stream->_savedBits = ret;
					stream->_savedBitsLength = i;
					return false;
				}

				stream->_byte = stream->_buffer[0];
				stream->_bufferIndex = 1;
				stream->_bufferLength = length;
			}

			stream->_bitIndex = 0;
		}

		ret |= ((stream->_byte >> stream->_bitIndex++) & 1) << i;
	}







|







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
					stream->_savedBits = ret;
					stream->_savedBitsLength = i;
					return false;
				}

				stream->_byte = stream->_buffer[0];
				stream->_bufferIndex = 1;
				stream->_bufferLength = (uint_fast16_t)length;
			}

			stream->_bitIndex = 0;
		}

		ret |= ((stream->_byte >> stream->_bitIndex++) & 1) << i;
	}
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
	[super dealloc];
}

- (size_t)lowlevelReadIntoBuffer: (void*)buffer_
			  length: (size_t)length
{
	uint8_t *buffer = buffer_;
	uint_fast16_t bits;
	uint16_t value;
	size_t i, tmp, bytesWritten = 0;
	uint8_t *slidingWindow;
	uint_fast16_t slidingWindowIndex;

	if (_atEndOfStream)
		@throw [OFReadFailedException exceptionWithStream: self
						  requestedLength: length];








|

|







294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
	[super dealloc];
}

- (size_t)lowlevelReadIntoBuffer: (void*)buffer_
			  length: (size_t)length
{
	uint8_t *buffer = buffer_;
	uint_fast16_t bits, i, tmp;
	uint16_t value;
	size_t bytesWritten = 0;
	uint8_t *slidingWindow;
	uint_fast16_t slidingWindowIndex;

	if (_atEndOfStream)
		@throw [OFReadFailedException exceptionWithStream: self
						  requestedLength: length];

385
386
387
388
389
390
391
392
393

394
395
396
397
398
399
400
401
402
#undef CTX
	case UNCOMPRESSED_BLOCK:
#define CTX _context.uncompressed
		if OF_UNLIKELY (length == 0)
			return bytesWritten;

		tmp = (length < CTX.length - CTX.position
		    ? length : CTX.length - CTX.position);


		tmp = [_stream readIntoBuffer: buffer + bytesWritten
				       length: tmp];

		if OF_UNLIKELY (_slidingWindow == NULL) {
			_slidingWindow =
			    [self allocMemoryWithSize: _slidingWindowMask + 1];
			/* Avoid leaking data */
			memset(_slidingWindow, 0, _slidingWindowMask + 1);
		}







|

>
|
|







385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#undef CTX
	case UNCOMPRESSED_BLOCK:
#define CTX _context.uncompressed
		if OF_UNLIKELY (length == 0)
			return bytesWritten;

		tmp = (length < CTX.length - CTX.position
		    ? (uint_fast16_t)length : CTX.length - CTX.position);

		tmp = (uint_fast16_t)[_stream
		    readIntoBuffer: buffer + bytesWritten
			    length: tmp];

		if OF_UNLIKELY (_slidingWindow == NULL) {
			_slidingWindow =
			    [self allocMemoryWithSize: _slidingWindowMask + 1];
			/* Avoid leaking data */
			memset(_slidingWindow, 0, _slidingWindowMask + 1);
		}

Modified utils/objfw-unzip.m from [b335e42d82] to [df6343564c].

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
			size_t length = [stream readIntoBuffer: buffer
							length: BUFFER_SIZE];
			[output writeBuffer: buffer
				     length: length];

			written += length;
			newPercent = (written == size
			    ? 100 : written * 100 / size);

			if (percent != newPercent) {
				percent = newPercent;

				[of_stdout writeFormat:
				    @"\rExtracting %@... %3u%%",
				    fileName, percent];







|







127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
			size_t length = [stream readIntoBuffer: buffer
							length: BUFFER_SIZE];
			[output writeBuffer: buffer
				     length: length];

			written += length;
			newPercent = (written == size
			    ? 100 : (int_fast8_t)(written * 100 / size));

			if (percent != newPercent) {
				percent = newPercent;

				[of_stdout writeFormat:
				    @"\rExtracting %@... %3u%%",
				    fileName, percent];