2
0
Эх сурвалжийг харах

* PosSet(Ex)

git-svn-id: trunk@2076 -
marco 19 жил өмнө
parent
commit
51297c3d7b
1 өөрчлөгдсөн 58 нэмэгдсэн , 0 устгасан
  1. 58 0
      rtl/objpas/strutils.pp

+ 58 - 0
rtl/objpas/strutils.pp

@@ -176,6 +176,11 @@ const
   StdWordDelims = [#0..' ',',','.',';','/','\',':','''','"','`'] + Brackets;
   StdSwitchChars = ['-','/'];
 
+function PosSet (const c:TSysCharSet;const s : ansistring ):Integer;
+function PosSet (const c:string;const s : ansistring ):Integer;
+function PosSetEx (const c:TSysCharSet;const s : ansistring;count:Integer ):Integer;
+function PosSetEx (const c:string;const s : ansistring;count:Integer ):Integer;
+
 implementation
 
 { ---------------------------------------------------------------------
@@ -1614,4 +1619,57 @@ begin
   result:=binbufsize-i;
 end;
 
+function possetex (const c:TSysCharSet;const s : ansistring;count:Integer ):Integer;
+
+var i,j:Integer;
+
+begin
+ if pchar(s)=nil then
+  j:=0
+ else
+  begin
+   i:=length(s);
+   j:=count;
+   if j>i then
+    begin
+     result:=0;
+     exit;
+    end;
+   while (j<=i) and (not (s[j] in c)) do inc(j);
+   if (j>i) then
+    j:=0;                                         // not found.
+  end;
+ result:=j;
+end;
+
+function posset (const c:TSysCharSet;const s : ansistring ):Integer;
+
+begin
+  result:=possetex(c,s,1);
+end;
+
+function possetex (const c:string;const s : ansistring;count:Integer ):Integer;
+
+var cset : TSysCharSet;
+    i    : integer;
+begin
+  cset:=[];
+  if length(c)>0 then
+  for i:=1 to length(c) do
+    include(cset,c[i]);
+  result:=possetex(cset,s,count);
+end;
+
+function posset (const c:string;const s : ansistring ):Integer;
+
+var cset : TSysCharSet;
+    i    : integer;
+begin
+  cset:=[];
+  if length(c)>0 then
+    for i:=1 to length(c) do
+      include(cset,c[i]);
+  result:=possetex(cset,s,1);
+end;
+
 end.