MCPcopy Create free account
hub / github.com/ZDoom/Raze / StripLeftRight

Method StripLeftRight

source/common/utility/zstring.cpp:839–873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839void FString::StripLeftRight ()
840{
841 size_t max = Len(), i, j, k;
842 if (max == 0) return;
843 for (i = 0; i < max; ++i)
844 {
845 if ((signed char)Chars[i] < 0 || !isspace((unsigned char)Chars[i]))
846 break;
847 }
848 for (j = max - 1; j >= i; --j)
849 {
850 if ((signed char)Chars[j] < 0 || !isspace((unsigned char)Chars[j]))
851 break;
852 }
853 if (i == 0 && j == max - 1)
854 { // Nothing to strip.
855 return;
856 }
857 if (Data()->RefCount <= 1)
858 {
859 for (k = 0; i <= j; ++i, ++k)
860 {
861 Chars[k] = Chars[i];
862 }
863 Chars[k] = '\0';
864 ReallocBuffer (k);
865 }
866 else
867 {
868 FStringData *old = Data();
869 AllocBuffer(j - i + 1);
870 StrCopy(Chars, old->Chars() + i, j - i + 1);
871 old->Release();
872 }
873}
874
875void FString::StripLeftRight (const FString &charset)
876{

Callers 4

C_HandleKeyFunction · 0.80
AppendArgsStringMethod · 0.80
ParseLanguageCSVMethod · 0.80
StringStripLeftRightFunction · 0.80

Calls 2

CharsMethod · 0.80
ReleaseMethod · 0.45

Tested by

no test coverage detected