22 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
32 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
33 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
34 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0
45 char const*
const byte_pointer =
reinterpret_cast<char const*
>(&
c);
64 wchar_t* source_it =
buffer;
65 wchar_t* result_it =
buffer;
71 if (*source_it ==
CTRLZ)
80 if (*source_it ==
CR && source_it + 1 <
buffer_end && *(source_it + 1) ==
LF)
88 *result_it++ = *source_it++;
92 return static_cast<int>((result_it -
buffer) *
sizeof(
wchar_t));
97template <
typename Character>
121 Character* source_it =
buffer;
122 Character* result_it =
buffer;
130 if (*source_it ==
CTRLZ)
138 *result_it++ = *source_it++;
145 if (*source_it !=
CR)
147 *result_it++ = *source_it++;
157 if (*(source_it + 1) ==
LF)
164 *result_it++ = *source_it++;
176 if (!
ReadFile(os_handle, &peek,
sizeof(peek), &peek_size,
nullptr) || peek_size == 0)
213 if (peek ==
LF && result_it ==
buffer)
231 return static_cast<int>((result_it -
buffer) *
sizeof(Character));
237static
int __cdecl translate_ansi_or_utf8_nolock(
242 size_t const result_count
248 if (text_mode_translation_result_size == 0)
262 return text_mode_translation_result_size;
270 char* result_it = source_buffer + text_mode_translation_result_size - 1;
284 while (!
_utf8_is_leadbyte(*result_it) && counter <= 4 && result_it >= source_buffer)
294 if (trailbyte_count == 0)
304 if (trailbyte_count + 1 ==
counter)
346 int const characters_translated =
static_cast<int>(__acrt_MultiByteToWideChar(
350 static_cast<DWORD>(result_it - source_buffer),
352 static_cast<DWORD>(result_count)));
354 if (characters_translated == 0)
360 _utf8translations(fh) = (characters_translated !=
static_cast<int>(result_it - source_buffer));
364 return characters_translated *
sizeof(
wchar_t);
392 _ASSERTE((
"Invalid file descriptor. File possibly closed by a different thread",0));
411 unsigned const result_buffer_size
430 __crt_unique_heap_ptr<char> owned_internal_buffer;
432 char* internal_buffer;
433 unsigned internal_buffer_remaining;
457 internal_buffer_remaining = (result_buffer_size / 2) < 4
459 : (result_buffer_size/2);
461 owned_internal_buffer = _malloc_crt_t(
char, internal_buffer_remaining);
462 internal_buffer = owned_internal_buffer.get();
463 if (!internal_buffer)
478 internal_buffer_remaining = result_buffer_size;
484 internal_buffer_remaining = result_buffer_size;
489 wchar_t* wide_internal_buffer =
reinterpret_cast<wchar_t*
>(internal_buffer);
502 internal_buffer_remaining != 0)
506 --internal_buffer_remaining;
513 internal_buffer_remaining != 0)
517 --internal_buffer_remaining;
522 internal_buffer_remaining != 0)
526 --internal_buffer_remaining;
533 bool const from_console =
541 DWORD console_characters_read;
545 internal_buffer_remaining /
sizeof(
wchar_t),
546 &console_characters_read,
555 bytes_read += console_characters_read *
sizeof(
wchar_t);
560 DWORD bytes_read_from_file;
564 internal_buffer_remaining,
565 &bytes_read_from_file,
567 ) || bytes_read_from_file > result_buffer_size)
595 bytes_read += bytes_read_from_file;
610 return translate_ansi_or_utf8_nolock(
615 result_buffer_size /
sizeof(
wchar_t));
620 else if (from_console)
624 wide_internal_buffer,
625 bytes_read /
sizeof(
wchar_t));
633 wide_internal_buffer,
634 bytes_read /
sizeof(
wchar_t));
#define _CHECK_FH_CLEAR_OSSERR_RETURN(handle, errorcode, retexpr)
void __cdecl __acrt_errno_map_os_error(unsigned long)
#define _pipe_lookahead(i)
#define _utf8_is_leadbyte(c)
#define _utf8_is_independent(c)
__inline char _utf8_no_of_trailbytes(const unsigned char c)
#define _utf8translations(i)
_Check_return_opt_ __int64 __cdecl _lseeki64_nolock(_In_ int _FileHandle, _In_ __int64 _Offset, _In_ int _Origin)
void __cdecl __acrt_lowio_lock_fh(_In_ int _FileHandle)
void __cdecl __acrt_lowio_unlock_fh(_In_ int _FileHandle)
result_buffer_count char *const result_buffer
#define ERROR_NOT_ENOUGH_MEMORY
#define ReadFile(a, b, c, d, e)
#define ERROR_ACCESS_DENIED
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
GLuint GLuint GLsizei count
#define _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, retexpr)
#define _Inout_updates_(s)
#define _Pre_writable_size_(s)
#define _Post_readable_byte_size_(s)
_Check_return_ _CRTIMP int __cdecl _isatty(_In_ int _FileHandle)
static int __cdecl translate_text_mode_nolock(_In_ int const fh, _Pre_writable_size_(count) _Post_readable_byte_size_(return) Character *const buffer, _In_ size_t const count)
size_t const size_t const result_count throw()
char _lookuptrailbytes[256]
int __cdecl _read_nolock(int const fh, void *const result_buffer, unsigned const result_buffer_size)
size_t const source_count
static int __cdecl translate_utf16_from_console_nolock(int const fh, _Inout_updates_(count) wchar_t *const buffer, size_t const count)
static void store_lookahead(int const fh, char const c)
int __cdecl _read(int const fh, void *const buffer, unsigned const buffer_size)
wchar_t const *const size_t const buffer_size
DWORD WINAPI GetLastError(void)
#define ERROR_BROKEN_PIPE