equal
deleted
inserted
replaced
604 |
604 |
605 |
605 |
606 return EXCEPTION_EXECUTE_HANDLER; |
606 return EXCEPTION_EXECUTE_HANDLER; |
607 } |
607 } |
608 |
608 |
|
609 #ifdef _M_AMD64 |
|
610 extern "C" void *_get_save_esp(void); |
|
611 #endif |
|
612 |
609 static void Win32InitializeExceptions(void) |
613 static void Win32InitializeExceptions(void) |
610 { |
614 { |
611 #ifdef _M_AMD64 |
615 #ifdef _M_AMD64 |
612 extern void *_get_save_esp(void); |
|
613 _safe_esp = _get_save_esp(); |
616 _safe_esp = _get_save_esp(); |
614 #else |
617 #else |
615 _asm { |
618 _asm { |
616 mov _safe_esp, esp |
619 mov _safe_esp, esp |
617 } |
620 } |
663 |
666 |
664 if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) { |
667 if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) { |
665 d = dir_calloc(); |
668 d = dir_calloc(); |
666 if (d != NULL) { |
669 if (d != NULL) { |
667 wchar_t search_path[MAX_PATH]; |
670 wchar_t search_path[MAX_PATH]; |
668 /* build search path for FindFirstFile */ |
671 bool slash = path[wcslen(path) - 1] == L'\\'; |
669 _snwprintf(search_path, lengthof(search_path), L"%s\\*", path); |
672 |
|
673 /* build search path for FindFirstFile, try not to append additional slashes |
|
674 * as it throws Win9x off its groove for root directories */ |
|
675 _snwprintf(search_path, lengthof(search_path), L"%s%s*", path, slash ? L"" : L"\\"); |
670 *lastof(search_path) = '\0'; |
676 *lastof(search_path) = '\0'; |
671 d->hFind = FindFirstFileW(search_path, &d->fd); |
677 d->hFind = FindFirstFileW(search_path, &d->fd); |
672 |
678 |
673 if (d->hFind != INVALID_HANDLE_VALUE || |
679 if (d->hFind != INVALID_HANDLE_VALUE || |
674 GetLastError() == ERROR_NO_MORE_FILES) { // the directory is empty |
680 GetLastError() == ERROR_NO_MORE_FILES) { // the directory is empty |
1009 } |
1015 } |
1010 |
1016 |
1011 width = length = 0; |
1017 width = length = 0; |
1012 |
1018 |
1013 for (ptr = utf8_buf; (c = Utf8Consume(&ptr)) != '\0';) { |
1019 for (ptr = utf8_buf; (c = Utf8Consume(&ptr)) != '\0';) { |
1014 byte charwidth; |
|
1015 |
|
1016 if (!IsPrintable(c)) break; |
1020 if (!IsPrintable(c)) break; |
1017 if (tb->length + length >= tb->maxlength - 1) break; |
1021 |
1018 charwidth = GetCharacterWidth(FS_NORMAL, c); |
1022 size_t len = Utf8CharLen(c); |
1019 |
1023 if (tb->length + length >= tb->maxlength - (uint16)len) break; |
|
1024 |
|
1025 byte charwidth = GetCharacterWidth(FS_NORMAL, c); |
1020 if (tb->maxwidth != 0 && width + tb->width + charwidth > tb->maxwidth) break; |
1026 if (tb->maxwidth != 0 && width + tb->width + charwidth > tb->maxwidth) break; |
1021 |
1027 |
1022 width += charwidth; |
1028 width += charwidth; |
1023 length += Utf8CharLen(c); |
1029 length += len; |
1024 } |
1030 } |
1025 |
1031 |
1026 if (length == 0) return false; |
1032 if (length == 0) return false; |
1027 |
1033 |
1028 memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->length - tb->caretpos); |
1034 memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->length - tb->caretpos); |
1030 tb->width += width; |
1036 tb->width += width; |
1031 tb->caretxoffs += width; |
1037 tb->caretxoffs += width; |
1032 |
1038 |
1033 tb->length += length; |
1039 tb->length += length; |
1034 tb->caretpos += length; |
1040 tb->caretpos += length; |
|
1041 assert(tb->length < tb->maxlength); |
1035 tb->buf[tb->length] = '\0'; // terminating zero |
1042 tb->buf[tb->length] = '\0'; // terminating zero |
1036 |
1043 |
1037 return true; |
1044 return true; |
1038 } |
1045 } |
1039 |
1046 |