mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-17 02:00:41 +01:00
parent
72661fd5c1
commit
60c26a11ef
@ -2012,13 +2012,27 @@ end;
|
|||||||
function DelSpace1(const S: string): string;
|
function DelSpace1(const S: string): string;
|
||||||
|
|
||||||
var
|
var
|
||||||
I : SizeInt;
|
I,J: SizeInt;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=S;
|
Result:=S;
|
||||||
for i:=Length(Result) downto 2 do
|
I:=Length(Result);
|
||||||
if (Result[i]=' ') and (Result[I-1]=' ') then
|
While I>0 do
|
||||||
Delete(Result,I,1);
|
begin
|
||||||
|
if Result[I]=#32 then
|
||||||
|
begin
|
||||||
|
J:=I-1;
|
||||||
|
While (J>0) and (Result[J]=#32) do
|
||||||
|
Dec(j);
|
||||||
|
Inc(J);
|
||||||
|
if I<>J then
|
||||||
|
begin
|
||||||
|
Delete(Result,J+1,I-J);
|
||||||
|
I:=J+1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
dec(I);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Tab2Space(const S: string; Numb: Byte): string;
|
function Tab2Space(const S: string; Numb: Byte): string;
|
||||||
|
|||||||
24
tests/test/packages/rtl-objpas/tdelspace1.pp
Normal file
24
tests/test/packages/rtl-objpas/tdelspace1.pp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
uses
|
||||||
|
strutils;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if DelSpace1('asdf')<>'asdf' then
|
||||||
|
halt(1);
|
||||||
|
if DelSpace1(' asdf')<>' asdf' then
|
||||||
|
halt(2);
|
||||||
|
if DelSpace1('asdf ')<>'asdf ' then
|
||||||
|
halt(3);
|
||||||
|
if DelSpace1(' asdf')<>' asdf' then
|
||||||
|
halt(4);
|
||||||
|
if DelSpace1('asdf ')<>'asdf ' then
|
||||||
|
halt(5);
|
||||||
|
if DelSpace1('as df')<>'as df' then
|
||||||
|
halt(6);
|
||||||
|
if DelSpace1('as df')<>'as df' then
|
||||||
|
halt(7);
|
||||||
|
if DelSpace1(' a s d f')<>' a s d f' then
|
||||||
|
halt(8);
|
||||||
|
if DelSpace1(' a b c ')<>' a b c ' then
|
||||||
|
halt(9);
|
||||||
|
writeln('ok')
|
||||||
|
end.
|
||||||
Loading…
Reference in New Issue
Block a user