ObjFW  Diff

Differences From Artifact [52d54dbd3b]:

To Artifact [794f92fbed]:


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	char *buffer = buffer_;
	OFChar16 *UTF16;
	size_t j = 0;

	if (length > UINT32_MAX)
		@throw [OFOutOfRangeException exception];

	UTF16 = of_alloc(length, sizeof(OFChar16));
	@try {
		DWORD UTF16Len;
		OFMutableData *rest = nil;
		size_t i = 0;

		if ([OFSystemInfo isWindowsNT]) {
			if (!ReadConsoleW(_handle, UTF16, (DWORD)length,







|







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	char *buffer = buffer_;
	OFChar16 *UTF16;
	size_t j = 0;

	if (length > UINT32_MAX)
		@throw [OFOutOfRangeException exception];

	UTF16 = OFAllocMemory(length, sizeof(OFChar16));
	@try {
		DWORD UTF16Len;
		OFMutableData *rest = nil;
		size_t i = 0;

		if ([OFSystemInfo isWindowsNT]) {
			if (!ReadConsoleW(_handle, UTF16, (DWORD)length,
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
				[rest addItems: UTF8 count: UTF8Len];
			}
		}

		if (rest != nil)
			[self unreadFromBuffer: rest.items length: rest.count];
	} @finally {
		free(UTF16);
	}

	objc_autoreleasePoolPop(pool);

	return j;
}








|







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
				[rest addItems: UTF8 count: UTF8Len];
			}
		}

		if (rest != nil)
			[self unreadFromBuffer: rest.items length: rest.count];
	} @finally {
		OFFreeMemory(UTF16);
	}

	objc_autoreleasePoolPop(pool);

	return j;
}

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
				   bytesWritten: bytesWritten * 2
					  errNo: 0];

		_incompleteUTF8SurrogateLen = 0;
		i += toCopy;
	}

	tmp = of_alloc(length * 2, sizeof(OFChar16));
	@try {
		DWORD bytesWritten;

		while (i < length) {
			OFUnichar c;
			ssize_t UTF8Len;








|







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
				   bytesWritten: bytesWritten * 2
					  errNo: 0];

		_incompleteUTF8SurrogateLen = 0;
		i += toCopy;
	}

	tmp = OFAllocMemory(length * 2, sizeof(OFChar16));
	@try {
		DWORD bytesWritten;

		while (i < length) {
			OFUnichar c;
			ssize_t UTF8Len;

432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
		if (bytesWritten != j)
			@throw [OFWriteFailedException
			    exceptionWithObject: self
				requestedLength: j * 2
				   bytesWritten: bytesWritten * 2
					  errNo: 0];
	} @finally {
		free(tmp);
	}

	/*
	 * We do not count in bytes when writing to the Win32 console. But
	 * since any incomplete write is an exception here anyway, we can just
	 * return length.
	 */







|







432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
		if (bytesWritten != j)
			@throw [OFWriteFailedException
			    exceptionWithObject: self
				requestedLength: j * 2
				   bytesWritten: bytesWritten * 2
					  errNo: 0];
	} @finally {
		OFFreeMemory(tmp);
	}

	/*
	 * We do not count in bytes when writing to the Win32 console. But
	 * since any incomplete write is an exception here anyway, we can just
	 * return length.
	 */