From a2b23b391f93e3a0a464852b5a7459ea8803b6a2 Mon Sep 17 00:00:00 2001 From: Jief L Date: Sun, 10 May 2020 12:41:34 +0300 Subject: [PATCH] Add XStringArray::remove and removeIC tests. Create var for "quiet" and "splash". --- rEFIt_UEFI/Platform/kext_patcher.cpp | 2 +- .../cpp_unit_test/XStringArray_test.cpp | 31 +++++++++++++++++++ rEFIt_UEFI/entry_scan/loader.cpp | 31 ++++++++++--------- rEFIt_UEFI/libeg/XCinema.cpp | 2 +- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/rEFIt_UEFI/Platform/kext_patcher.cpp b/rEFIt_UEFI/Platform/kext_patcher.cpp index f60c24cea..8f06a5128 100644 --- a/rEFIt_UEFI/Platform/kext_patcher.cpp +++ b/rEFIt_UEFI/Platform/kext_patcher.cpp @@ -447,7 +447,7 @@ VOID LOADER_ENTRY::AppleIntelCPUPMPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 SEGMENT *textSeg = (SEGMENT *)&Driver[textName]; Start = textSeg->fileoff; Size = textSeg->filesize; - DBG("found __text [%d,%d]\n",Start, Size); + DBG("found __text [%llu,%llu]\n",Start, Size); if (Start > DriverSize) Start = 0; if (Size > DriverSize) { Size = DriverSize; diff --git a/rEFIt_UEFI/cpp_unit_test/XStringArray_test.cpp b/rEFIt_UEFI/cpp_unit_test/XStringArray_test.cpp index 8d2b903a6..3c8f08f67 100644 --- a/rEFIt_UEFI/cpp_unit_test/XStringArray_test.cpp +++ b/rEFIt_UEFI/cpp_unit_test/XStringArray_test.cpp @@ -155,6 +155,37 @@ int XStringArray_tests() array1.AddID(L"other2"_XSW); if ( array1.size() != 4 ) return 53; } + { + XStringArray array; + array.Add(L"word1"); + array.Add(L"other2"); + array.Add(L"3333"); + array.Add(L"4th_item"); + + array.remove("WOrd1"_XS8); + if ( !array.contains("word1"_XS8) ) return 22; + array.remove("word1"_XS8); + if ( array.contains("word1"_XS8) ) return 22; + array.removeIC("oTHEr2"_XS8); + if ( array.contains("other2"_XS8) ) return 22; + array.removeIC("4th_ITEM"_XS8); + if ( array.contains("4th_item"_XS8) ) return 22; + XString8 c = array.ConcatAll(); +// printf("c=%s\n", c.c_str()); + } + { + XStringArray array; + array.Add(L"splash"); + array.Add(L"quiet"); + + array.remove("splash"_XS8); + if ( array.contains("splash"_XS8) ) return 22; + array.removeIC("quiet"_XS8); + if ( array.contains("quiet"_XS8) ) return 22; + if ( array.size() != 0 ) return 22; + XString8 c = array.ConcatAll(); +// printf("c=%s\n", c.c_str()); + } diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index 92d0f3d13..d17394b2f 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -791,6 +791,9 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) EFI_GUID *Guid = NULL; BOOLEAN KernelIs64BitOnly; UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion); + + constexpr LString8 quietLitteral = "quiet"; + constexpr LString8 splashLitteral = "splash"; if (Entry == NULL) { return; @@ -924,8 +927,8 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) } } else if (Entry->LoaderType == OSTYPE_LINEFI) { - BOOLEAN Quiet = Entry->LoadOptions.contains("quiet"); - BOOLEAN WithSplash = Entry->LoadOptions.contains("splash"); + BOOLEAN Quiet = Entry->LoadOptions.contains(quietLitteral); + BOOLEAN WithSplash = Entry->LoadOptions.contains(splashLitteral); // default entry SubEntry = Entry->getPartiallyDuplicatedEntry(); @@ -938,10 +941,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) if (SubEntry) { if (Quiet) { SubEntry->Title.SWPrintf("%ls verbose", Entry->Title.s()); - SubEntry->LoadOptions.removeIC("quiet"_XS8); + SubEntry->LoadOptions.removeIC(quietLitteral); } else { SubEntry->Title.SWPrintf("%ls quiet", Entry->Title.s()); - SubEntry->LoadOptions.AddID("quiet"_XS8); + SubEntry->LoadOptions.AddID(quietLitteral); } } SubScreen->AddMenuEntry(SubEntry, true); @@ -949,10 +952,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) if (SubEntry) { if (WithSplash) { SubEntry->Title.SWPrintf("%ls without splash", Entry->Title.s()); - SubEntry->LoadOptions.removeIC("splash"_XS8); + SubEntry->LoadOptions.removeIC(splashLitteral); } else { SubEntry->Title.SWPrintf("%ls with splash", Entry->Title.s()); - SubEntry->LoadOptions.AddID("splash"_XS8); + SubEntry->LoadOptions.AddID(splashLitteral); } } SubScreen->AddMenuEntry(SubEntry, true); @@ -961,22 +964,22 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) if (WithSplash) { if (Quiet) { SubEntry->Title.SWPrintf("%ls verbose without splash", Entry->Title.s()); - SubEntry->LoadOptions.removeIC("splash"_XS8); - SubEntry->LoadOptions.removeIC("quiet"_XS8); + SubEntry->LoadOptions.removeIC(splashLitteral); + SubEntry->LoadOptions.removeIC(quietLitteral); } else { SubEntry->Title.SWPrintf("%ls quiet without splash", Entry->Title.s()); - SubEntry->LoadOptions.removeIC("splash"_XS8); - SubEntry->LoadOptions.Add("quiet"_XS8); + SubEntry->LoadOptions.removeIC(splashLitteral); + SubEntry->LoadOptions.Add(quietLitteral); } } else if (Quiet) { -// TempOptions.RemoveIC("quiet"_XS8); +// TempOptions.RemoveIC(quietLitteral); SubEntry->Title.SWPrintf("%ls verbose with splash", Entry->Title.s()); - SubEntry->LoadOptions.AddID("splash"_XS8); + SubEntry->LoadOptions.AddID(splashLitteral); // FreePool(TempOptions); } else { SubEntry->Title.SWPrintf("%ls quiet with splash", Entry->Title.s()); - SubEntry->LoadOptions.AddID("quiet"_XS8); - SubEntry->LoadOptions.AddID("splash"_XS8); + SubEntry->LoadOptions.AddID(quietLitteral); + SubEntry->LoadOptions.AddID(splashLitteral); } } SubScreen->AddMenuEntry(SubEntry, true); diff --git a/rEFIt_UEFI/libeg/XCinema.cpp b/rEFIt_UEFI/libeg/XCinema.cpp index cf1b98b06..42c70fa9b 100644 --- a/rEFIt_UEFI/libeg/XCinema.cpp +++ b/rEFIt_UEFI/libeg/XCinema.cpp @@ -84,7 +84,7 @@ void XCinema::AddFilm(FILM* NewFilm) static XImage NullImage; const XImage& FILM::GetImage(INTN Index) const { - DBG("ask for frame #%lld from total of %lld\n", Index, Frames.size()); + DBG("ask for frame #%lld from total of %zu\n", Index, Frames.size()); for (size_t i = 0; i < Frames.size(); ++i) { if (Frames[i].getIndex() == Index) { DBG("...found\n");