Kaynağa Gözat

+ New needed file

git-svn-id: trunk@627 -
michael 20 yıl önce
ebeveyn
işleme
6e3590ed2a
2 değiştirilmiş dosya ile 39 ekleme ve 0 silme
  1. 1 0
      .gitattributes
  2. 38 0
      fcl/db/dbase/getstrfromint.inc

+ 1 - 0
.gitattributes

@@ -571,6 +571,7 @@ fcl/db/dbase/dbf_struct.inc svneol=native#text/plain
 fcl/db/dbase/dbf_wtil.pas svneol=native#text/plain
 fcl/db/dbase/fpmake.inc svneol=native#text/plain
 fcl/db/dbase/fpmake.pp svneol=native#text/plain
+fcl/db/dbase/getstrfromint.inc svneol=native#text/plain
 fcl/db/dbase/history.txt svneol=native#text/plain
 fcl/db/dbase/package.txt svneol=native#text/plain
 fcl/db/dbase/readme.txt svneol=native#text/plain

+ 38 - 0
fcl/db/dbase/getstrfromint.inc

@@ -0,0 +1,38 @@
+  if Width <= 0 then
+    exit;
+
+  NegSign := Val < 0;
+  Val := Abs(Val);
+  // we'll have to store characters backwards first
+  I := 0;
+  repeat
+    Temp[I] := Chr((Val mod 10) + Ord('0'));
+    Val := Val div 10;
+    Inc(I);
+  until (Val = 0) or (I = Width);
+  // add spaces
+  J := Width - I;
+  FillChar(Dst^, J, PadChar);
+  // add sign
+  if NegSign then
+  begin
+    if PadChar = '0' then
+    begin
+      Dst[0] := '-';
+    end else begin
+      if J = 0 then
+      begin
+        // need one character for sign, shorten
+        Inc(J);
+        Dec(I);
+      end;
+      Dst[J - 1] := '-';
+    end;
+  end;
+  // copy value, stored backwards
+  repeat
+    Dec(I);
+    Dst[J] := Temp[I];
+    Inc(J);
+  until I = 0;
+  // done!