Browse Source

+ char support for sscanf

git-svn-id: trunk@605 -
florian 20 years ago
parent
commit
4258bee1c5
1 changed files with 24 additions and 5 deletions
  1. 24 5
      rtl/objpas/sysutils/sysstr.inc

+ 24 - 5
rtl/objpas/sysutils/sysstr.inc

@@ -2120,8 +2120,9 @@ function sscanf(const s: string; const fmt : string;const Pointers : array of Po
 
   function ScanStr(c : Char) : Boolean;
     begin
-      while (s[n] <> c) and (Length(s) > n) do inc(n);
+      while (s[n] <> c) and (Length(s) > n) do
         inc(n);
+      inc(n);
       If (n <= Length(s)) then
         Result := True
       else
@@ -2145,9 +2146,14 @@ function sscanf(const s: string; const fmt : string;const Pointers : array of Po
             begin
               inc(m);
               case fmt[m] of
-                'd': Result := vtInteger;
-                'f': Result := vtExtended;
-                's': Result := vtString;
+                'd':
+                  Result:=vtInteger;
+                'f':
+                  Result:=vtExtended;
+                's':
+                  Result:=vtString;
+                'c':
+                  Result:=vtChar;
                 else
                   raise EFormatError.CreateFmt(SInvalidFormat,[fmt]);
               end;
@@ -2173,7 +2179,7 @@ function sscanf(const s: string; const fmt : string;const Pointers : array of Po
         case j of
           vtInteger :
             begin
-              if GetInt > 0 then
+              if GetInt>0 then
                 begin
                   plongint(Pointers[i])^:=StrToInt(s1);
                   inc(Result);
@@ -2183,6 +2189,19 @@ function sscanf(const s: string; const fmt : string;const Pointers : array of Po
 
             end;
 
+          vtchar :
+            begin
+              if Length(s)>n then
+                begin
+                  pchar(Pointers[i])^:=s[n];
+                  inc(n);
+                  inc(Result);
+                end
+              else
+                break;
+
+            end;
+
           vtExtended :
             begin
               if GetFloat>0 then