~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/rtl/objpas/classes/util.inc

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
    This file is part of the Free Component Library (FCL)
 
3
    Copyright (c) 1999-2000 by Michael Van Canneyt and Florian Klaempfl
 
4
 
 
5
    See the file COPYING.FPC, included in this distribution,
 
6
    for details about the copyright.
 
7
 
 
8
    This program is distributed in the hope that it will be useful,
 
9
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
11
 
 
12
 **********************************************************************}
 
13
 
 
14
procedure BinToHex(BinValue, HexValue: PChar; BinBufSize: Integer);
 
15
Const
 
16
  HexDigits='0123456789ABCDEF';
 
17
var
 
18
  i : longint;
 
19
begin
 
20
  for i:=0 to binbufsize-1 do
 
21
    begin
 
22
    HexValue[0]:=hexdigits[1+((ord(binvalue^) shr 4))];
 
23
    HexValue[1]:=hexdigits[1+((ord(binvalue^) and 15))];
 
24
    inc(hexvalue,2);
 
25
    inc(binvalue);
 
26
    end;
 
27
end;
 
28
 
 
29
 
 
30
function HexToBin(HexValue, BinValue: PChar; BinBufSize: Integer): Integer;
 
31
// more complex, have to accept more than bintohex
 
32
// A..F    1000001
 
33
// a..f    1100001
 
34
// 0..9     110000
 
35
var i,j,h,l : integer;
 
36
 
 
37
begin
 
38
  i:=binbufsize;
 
39
  while (i>0) do
 
40
    begin
 
41
    if hexvalue^ IN ['A'..'F','a'..'f'] then
 
42
      h:=((ord(hexvalue^)+9) and 15)
 
43
    else if hexvalue^ IN ['0'..'9'] then
 
44
      h:=((ord(hexvalue^)) and 15)
 
45
    else
 
46
      break;
 
47
    inc(hexvalue);
 
48
    if hexvalue^ IN ['A'..'F','a'..'f'] then
 
49
      l:=(ord(hexvalue^)+9) and 15
 
50
    else if hexvalue^ IN ['0'..'9'] then
 
51
      l:=(ord(hexvalue^)) and 15
 
52
    else
 
53
      break;
 
54
    j := l + (h shl 4);
 
55
    inc(hexvalue);
 
56
    binvalue^:=chr(j);
 
57
    inc(binvalue);
 
58
    dec(i);
 
59
    end;
 
60
  result:=binbufsize-i;
 
61
end;                  
 
62