ladybird/AK
Sam Atkins a0d44026fc AK+Tests: Correct off-by-one error when right-trimming text
If the entire string you want to right-trim consists of characters you
want to remove, we previously would incorrectly leave the first
character there.

For example: `trim("aaaaa", "a")` would return "a" instead of "".

We can't use `i >= 0` in the loop since that would fail to detect
underflow, so instead we keep `i` in the range `size .. 1` and then
subtract 1 from it when reading the character.

Added some trim() tests while I was at it. (And to confirm that this was
the issue.)
2022-10-11 17:49:32 +02:00
..
.clang-tidy
AllOf.h
AnyOf.h
ArbitrarySizedEnum.h
Array.h
Assertions.cpp
Assertions.h
Atomic.h
AtomicRefCounted.h
Badge.h
Base64.cpp
Base64.h
BinaryBufferWriter.h
BinaryHeap.h
BinarySearch.h
BitCast.h
Bitmap.h
BitmapView.h
BitStream.h
Buffered.h
BuiltinWrappers.h
BumpAllocator.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
ByteBuffer.h
ByteReader.h
CharacterTypes.h
Checked.h
CheckedFormatString.h
CircularDeque.h
CircularDuplexStream.h
CircularQueue.h
CMakeLists.txt
Complex.h
Concepts.h
DateConstants.h
DateTimeLexer.h
Debug.h.in
Demangle.h
DisjointChunks.h
DistinctNumeric.h
DoublyLinkedList.h
Endian.h
EnumBits.h
Error.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
ExtraMathConstants.h
FileStream.h
Find.h
FixedArray.h
FixedPoint.h
FloatingPoint.h
FlyString.cpp
FlyString.h
Format.cpp Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
Format.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
Forward.h
FPControl.h
Function.h
FuzzyMatch.cpp
FuzzyMatch.h
GenericLexer.cpp
GenericLexer.h
GenericShorthands.h
HashFunctions.h
HashMap.h
HashTable.h
Hex.cpp
Hex.h
IDAllocator.h
IntegralMath.h
IntrusiveDetails.h
IntrusiveList.h
IntrusiveListRelaxedConst.h
IntrusiveRedBlackTree.h
IPv4Address.h
IPv6Address.h
IterationDecision.h
Iterator.h
JsonArray.h
JsonArraySerializer.h
JsonObject.h
JsonObjectSerializer.h
JsonParser.cpp
JsonParser.h
JsonPath.cpp
JsonPath.h
JsonValue.cpp
JsonValue.h
kmalloc.cpp Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
kmalloc.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
kstdio.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
LEB128.h
LexicalPath.cpp
LexicalPath.h
MACAddress.h
Math.h
MemMem.h
Memory.h
MemoryStream.h
NeverDestroyed.h
NoAllocationGuard.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
Noncopyable.h
NonnullOwnPtr.h
NonnullOwnPtrVector.h
NonnullPtrVector.h
NonnullRefPtr.h
NonnullRefPtrVector.h
NumberFormat.h
NumericLimits.h
Optional.h
OwnPtr.h
Platform.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
PrintfImplementation.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
Ptr32.h
Queue.h
QuickSort.h
Random.cpp
Random.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
RecursionDecision.h
RedBlackTree.h
RefCounted.h
RefCountForwarder.h
RefPtr.h
Result.h
ReverseIterator.h
ScopedValueRollback.h
ScopeGuard.h
ScopeLogger.h
SIMD.h
SIMDExtras.h
SIMDMath.h
Singleton.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
SinglyLinkedList.h
SinglyLinkedListWithCount.h
SourceGenerator.h
SourceLocation.h
Span.h
Stack.h
StackInfo.cpp AK+Userland: Replace Linux, macOS, and *BSD macros with platform defines 2022-10-10 12:23:12 +02:00
StackInfo.h
Statistics.h
StdLibExtraDetails.h
StdLibExtras.h
Stream.h
String.cpp
String.h
StringBuilder.cpp
StringBuilder.h
StringHash.h
StringImpl.cpp
StringImpl.h
StringUtils.cpp AK+Tests: Correct off-by-one error when right-trimming text 2022-10-11 17:49:32 +02:00
StringUtils.h
StringView.cpp AK+Everywhere: Fix data corruption due to code-point-to-char conversion 2022-10-09 10:37:20 -06:00
StringView.h AK+Everywhere: Fix data corruption due to code-point-to-char conversion 2022-10-09 10:37:20 -06:00
TemporaryChange.h
Time.cpp
Time.h
Traits.h
Trie.h
Try.h
Tuple.h
TypeCasts.h
TypedTransfer.h
TypeList.h
Types.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
UBSanitizer.h
UFixedBigInt.h
UnicodeUtils.h
URL.cpp AK+Everywhere: Fix data corruption due to code-point-to-char conversion 2022-10-09 10:37:20 -06:00
URL.h
URLParser.cpp AK: Fix 'constexpr' attribute on non-constexpr function 2022-10-09 10:37:20 -06:00
URLParser.h
Userspace.h
Utf8View.cpp AK+Tests: Avoid creating invalid code points from malformed UTF-8 2022-10-09 10:37:20 -06:00
Utf8View.h
Utf16View.cpp
Utf16View.h
Utf32View.h
UUID.cpp
UUID.h
Variant.h
Vector.h
Weakable.h
WeakPtr.h