~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to fcl/db/dbase/getstrfromint.inc

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
  if Width <= 0 then
 
2
    exit;
 
3
 
 
4
  NegSign := Val < 0;
 
5
  Val := Abs(Val);
 
6
  // we'll have to store characters backwards first
 
7
  I := 0;
 
8
  repeat
 
9
    Temp[I] := Chr((Val mod 10) + Ord('0'));
 
10
    Val := Val div 10;
 
11
    Inc(I);
 
12
  until (Val = 0) or (I = Width);
 
13
  // add spaces
 
14
  J := Width - I;
 
15
  FillChar(Dst^, J, PadChar);
 
16
  // add sign
 
17
  if NegSign then
 
18
  begin
 
19
    if PadChar = '0' then
 
20
    begin
 
21
      Dst[0] := '-';
 
22
    end else begin
 
23
      if J = 0 then
 
24
      begin
 
25
        // need one character for sign, shorten
 
26
        Inc(J);
 
27
        Dec(I);
 
28
      end;
 
29
      Dst[J - 1] := '-';
 
30
    end;
 
31
  end;
 
32
  // copy value, stored backwards
 
33
  repeat
 
34
    Dec(I);
 
35
    Dst[J] := Temp[I];
 
36
    Inc(J);
 
37
  until I = 0;
 
38
  // done!