Browse Source

--- Merging r14065 into '.':
U packages/fcl-db/src/base/db.pas
U packages/fcl-db/src/base/fields.inc
--- Merging r14073 into '.':
U compiler/systems/t_go32v2.pas
--- Merging r14082 into '.':
U rtl/wince/Makefile.fpc
U rtl/wince/Makefile
--- Merging r14091 into '.':
U rtl/objpas/dateutil.inc
--- Merging r14110 into '.':
U rtl/objpas/sysutils/dati.inc
--- Merging r14116 into '.':
G rtl/objpas/sysutils/dati.inc
U rtl/objpas/sysutils/datih.inc
--- Merging r14127 into '.':
U packages/libxml/examples/tree2.pas
U packages/libxml/examples/reader1.pas
U packages/libxml/examples/io2.pas
--- Merging r14150 into '.':
U packages/libgd/src/gd.pas
--- Merging r14151 into '.':
G packages/libgd/src/gd.pas
--- Merging r14162 into '.':
U rtl/objpas/sysutils/sysstr.inc
U rtl/objpas/sysutils/sysstrh.inc
--- Merging r14163 into '.':
U rtl/objpas/types.pp
--- Merging r14166 into '.':
A tests/webtbs/tw14798.pp
--- Merging r14167 into '.':
U utils/fpdoc/dwlinear.pp
U utils/fpdoc/dw_latex.pp
U utils/fpdoc/dwriter.pp
U utils/fpdoc/dglobals.pp
U utils/fpdoc/dw_html.pp
U utils/fpdoc/fpdoc.lpi
--- Merging r14198 into '.':
U packages/iconvenc/src/iconvenc_dyn.pas
--- Merging r14200 into '.':
U rtl/objpas/classes/writer.inc
U rtl/objpas/classes/reader.inc
U rtl/objpas/classes/classesh.inc
--- Merging r14201 into '.':
U rtl/win/syswin.inc
--- Merging r14204 into '.':
U packages/fcl-db/src/datadict/fpdatadict.pp
--- Merging r14205 into '.':
G packages/fcl-db/src/datadict/fpdatadict.pp
--- Merging r14210 into '.':
U packages/libxml/src/xmlxsd.pas

# revisions: 14065,14073,14082,14091,14110,14116,14127,14150,14151,14162,14163,14166,14167,14198,14200,14201,14204,14205,14210
------------------------------------------------------------------------
r14065 | paul | 2009-11-05 08:09:10 +0100 (Thu, 05 Nov 2009) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/base/db.pas
M /trunk/packages/fcl-db/src/base/fields.inc

packages: add enumerator for TFields class
------------------------------------------------------------------------
------------------------------------------------------------------------
r14073 | pierre | 2009-11-06 01:13:42 +0100 (Fri, 06 Nov 2009) | 1 line
Changed paths:
M /trunk/compiler/systems/t_go32v2.pas

* Adapt script to DJGPP 2.04
------------------------------------------------------------------------
------------------------------------------------------------------------
r14082 | marco | 2009-11-06 14:17:43 +0100 (Fri, 06 Nov 2009) | 2 lines
Changed paths:
M /trunk/rtl/wince/Makefile
M /trunk/rtl/wince/Makefile.fpc

* fix for 14986, unit dependancies.

------------------------------------------------------------------------
------------------------------------------------------------------------
r14091 | pierre | 2009-11-07 01:30:32 +0100 (Sat, 07 Nov 2009) | 1 line
Changed paths:
M /trunk/rtl/objpas/dateutil.inc

MaybeSkipTimeWrap function: Change NewDate var_type to var to suppress warnings
------------------------------------------------------------------------
------------------------------------------------------------------------
r14110 | marco | 2009-11-08 12:43:01 +0100 (Sun, 08 Nov 2009) | 2 lines
Changed paths:
M /trunk/rtl/objpas/sysutils/dati.inc

* replace encodedate/time by try variants mantis 14969

------------------------------------------------------------------------
------------------------------------------------------------------------
r14116 | marco | 2009-11-08 16:07:00 +0100 (Sun, 08 Nov 2009) | 15 lines
Changed paths:
M /trunk/rtl/objpas/sysutils/dati.inc
M /trunk/rtl/objpas/sysutils/datih.inc

* improvements to sysuitls date/time formatting routines: (Mantis 14905,Sergei)
- Adds threadsafe (Delphi-compatible) versions of DateToStr,
TimeToStr, DateTimeToStr, FormatDateTime.
- Core functionality moved to DateTimeToString, which directly
uses 'out' parameter in order to avoid unnecessary result copying.
- Modified the code so no temporary AnsiStrings are used (speed).
- Fixes a bug which would cause infinite recursion if
(Short|Long)DateFormat variable would contain 'd' character or,
likewise, (Short|Long)TimeFormat would contain 't'.
- Fixes numerous small Delphi compatibility issues, like: empty format
string has the same effect as 'C'; overlong tokens treated as the
longest possible ones (e.g. 'ddddddddd' is the same as 'dddddd');
'AM/PM' is output preserving its case, etc.
- minor reformating

------------------------------------------------------------------------
------------------------------------------------------------------------
r14127 | ivost | 2009-11-09 22:16:25 +0100 (Mon, 09 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/libxml/examples/io2.pas
M /trunk/packages/libxml/examples/reader1.pas
M /trunk/packages/libxml/examples/tree2.pas

* fixed libxml2 examples (removed BAD_CAST)

------------------------------------------------------------------------
------------------------------------------------------------------------
r14150 | ivost | 2009-11-12 01:41:06 +0100 (Thu, 12 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/libgd/src/gd.pas

* renamed GDCALL to EXTCALL. Now it works with lazarus codetools

------------------------------------------------------------------------
------------------------------------------------------------------------
r14151 | ivost | 2009-11-12 01:59:53 +0100 (Thu, 12 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/libgd/src/gd.pas

* prepeared libgd for dynamic loading support

------------------------------------------------------------------------
------------------------------------------------------------------------
r14162 | marco | 2009-11-13 10:10:24 +0100 (Fri, 13 Nov 2009) | 2 lines
Changed paths:
M /trunk/rtl/objpas/sysutils/sysstr.inc
M /trunk/rtl/objpas/sysutils/sysstrh.inc

* Patch for "formatsettings" overloads of currency functions, mantis 15067

------------------------------------------------------------------------
------------------------------------------------------------------------
r14163 | marco | 2009-11-13 15:09:50 +0100 (Fri, 13 Nov 2009) | 2 lines
Changed paths:
M /trunk/rtl/objpas/types.pp

* move constants out of ifndef wince, bug #15057.

------------------------------------------------------------------------
------------------------------------------------------------------------
r14166 | marco | 2009-11-13 16:46:42 +0100 (Fri, 13 Nov 2009) | 2 lines
Changed paths:
A /trunk/tests/webtbs/tw14798.pp

* Test for mantis 14798

------------------------------------------------------------------------
------------------------------------------------------------------------
r14167 | michael | 2009-11-13 16:58:45 +0100 (Fri, 13 Nov 2009) | 1 line
Changed paths:
M /trunk/utils/fpdoc/dglobals.pp
M /trunk/utils/fpdoc/dw_html.pp
M /trunk/utils/fpdoc/dw_latex.pp
M /trunk/utils/fpdoc/dwlinear.pp
M /trunk/utils/fpdoc/dwriter.pp
M /trunk/utils/fpdoc/fpdoc.lpi

* Added support for the url tag to include arbitrary links
------------------------------------------------------------------------
------------------------------------------------------------------------
r14198 | marco | 2009-11-16 11:40:55 +0100 (Mon, 16 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/iconvenc/src/iconvenc_dyn.pas

* patch from taka_jp that fixes a bug in the detection sequence (mantis 15093)

------------------------------------------------------------------------
------------------------------------------------------------------------
r14200 | marco | 2009-11-16 13:50:18 +0100 (Mon, 16 Nov 2009) | 2 lines
Changed paths:
M /trunk/rtl/objpas/classes/classesh.inc
M /trunk/rtl/objpas/classes/reader.inc
M /trunk/rtl/objpas/classes/writer.inc

* writer.writeset, reader.readset as per mantis 10501

------------------------------------------------------------------------
------------------------------------------------------------------------
r14201 | florian | 2009-11-16 20:36:32 +0100 (Mon, 16 Nov 2009) | 1 line
Changed paths:
M /trunk/rtl/win/syswin.inc

* deallocate thread variables for the main thread as well, as described in #15002
------------------------------------------------------------------------
------------------------------------------------------------------------
r14204 | michael | 2009-11-17 21:24:21 +0100 (Tue, 17 Nov 2009) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/datadict/fpdatadict.pp

* Implemented GetDisplayName for fielddef
------------------------------------------------------------------------
------------------------------------------------------------------------
r14205 | michael | 2009-11-17 21:30:53 +0100 (Tue, 17 Nov 2009) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/datadict/fpdatadict.pp

* Item class is now a class function in TDDFieldDefs
------------------------------------------------------------------------
------------------------------------------------------------------------
r14210 | ivost | 2009-11-18 12:47:31 +0100 (Wed, 18 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/libxml/src/xmlxsd.pas

* fixed bug in float parser

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@14687 -

marco 15 years ago
parent
commit
de0ec4cf3c

+ 1 - 0
.gitattributes

@@ -9380,6 +9380,7 @@ tests/webtbs/tw1472.pp svneol=native#text/plain
 tests/webtbs/tw14743.pp svneol=native#text/pascal
 tests/webtbs/tw14743.pp svneol=native#text/pascal
 tests/webtbs/tw1477.pp svneol=native#text/plain
 tests/webtbs/tw1477.pp svneol=native#text/plain
 tests/webtbs/tw1479.pp svneol=native#text/plain
 tests/webtbs/tw1479.pp svneol=native#text/plain
+tests/webtbs/tw14798.pp svneol=native#text/plain
 tests/webtbs/tw1485.pp svneol=native#text/plain
 tests/webtbs/tw1485.pp svneol=native#text/plain
 tests/webtbs/tw1489.pp svneol=native#text/plain
 tests/webtbs/tw1489.pp svneol=native#text/plain
 tests/webtbs/tw1501.pp svneol=native#text/plain
 tests/webtbs/tw1501.pp svneol=native#text/plain

+ 7 - 3
compiler/systems/t_go32v2.pas

@@ -103,7 +103,7 @@ begin
 
 
   { Open link.res file }
   { Open link.res file }
   LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
   LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
-  
+
   { Add all options to link.res instead of passing them via command line:
   { Add all options to link.res instead of passing them via command line:
     DOS command line is limited to 126 characters! }
     DOS command line is limited to 126 characters! }
   LinkRes.Add('--script='+maybequoted(outputexedir+Info.ScriptName));
   LinkRes.Add('--script='+maybequoted(outputexedir+Info.ScriptName));
@@ -189,7 +189,8 @@ begin
        end;
        end;
    end;
    end;
   ScriptRes.Add('    *(.text)');
   ScriptRes.Add('    *(.text)');
-  ScriptRes.Add('    etext  =  . ; _etext = .;');
+  ScriptRes.Add('    etext  =  . ;');
+  ScriptRes.Add('    PROVIDE(_etext  =  .);');
   ScriptRes.Add('    . = ALIGN(0x200);');
   ScriptRes.Add('    . = ALIGN(0x200);');
   ScriptRes.Add('  }');
   ScriptRes.Add('  }');
   ScriptRes.Add('    .data  ALIGN(0x200) : {');
   ScriptRes.Add('    .data  ALIGN(0x200) : {');
@@ -203,6 +204,9 @@ begin
   ScriptRes.Add('      *(.dtor)');
   ScriptRes.Add('      *(.dtor)');
   ScriptRes.Add('      *(.dtors)');
   ScriptRes.Add('      *(.dtors)');
   ScriptRes.Add('      djgpp_last_dtor = . ;');
   ScriptRes.Add('      djgpp_last_dtor = . ;');
+  ScriptRes.Add('      __environ = . ;');
+  ScriptRes.Add('      PROVIDE(_environ = .);');
+  ScriptRes.Add('      LONG(0)');
   ScriptRes.Add('      *(.data)');
   ScriptRes.Add('      *(.data)');
   ScriptRes.Add('      *(.fpc*)');
   ScriptRes.Add('      *(.fpc*)');
   ScriptRes.Add('      *(.gcc_exc)');
   ScriptRes.Add('      *(.gcc_exc)');
@@ -216,7 +220,7 @@ begin
   ScriptRes.Add('    .bss  SIZEOF(.data) + ADDR(.data) :');
   ScriptRes.Add('    .bss  SIZEOF(.data) + ADDR(.data) :');
   ScriptRes.Add('    {');
   ScriptRes.Add('    {');
   ScriptRes.Add('      _object.2 = . ;');
   ScriptRes.Add('      _object.2 = . ;');
-  ScriptRes.Add('      . += 24 ;');
+  ScriptRes.Add('      . += 32 ;');
   ScriptRes.Add('      *(.bss)');
   ScriptRes.Add('      *(.bss)');
   ScriptRes.Add('      *(COMMON)');
   ScriptRes.Add('      *(COMMON)');
   ScriptRes.Add('       end = . ; _end = .;');
   ScriptRes.Add('       end = . ; _end = .;');

+ 14 - 0
packages/fcl-db/src/base/db.pas

@@ -992,6 +992,19 @@ type
     property Items[Index: Longint]: TCheckConstraint read GetItem write SetItem; default;
     property Items[Index: Longint]: TCheckConstraint read GetItem write SetItem; default;
   end;
   end;
 
 
+  { TFieldsEnumerator }
+
+  TFieldsEnumerator = class
+  private
+    FPosition: Integer;
+    FFields: TFields;
+    function GetCurrent: TField;
+  public
+    constructor Create(AFields: TFields);
+    function MoveNext: Boolean;
+    property Current: TField read GetCurrent;
+  end;
+
 { TFields }
 { TFields }
 
 
   Tfields = Class(TObject)
   Tfields = Class(TObject)
@@ -1019,6 +1032,7 @@ type
       Function FindField (Const Value : String) : TField;
       Function FindField (Const Value : String) : TField;
       Function FieldByName (Const Value : String) : TField;
       Function FieldByName (Const Value : String) : TField;
       Function FieldByNumber(FieldNo : Integer) : TField;
       Function FieldByNumber(FieldNo : Integer) : TField;
+      Function GetEnumerator: TFieldsEnumerator;
       Procedure GetFieldNames (Values : TStrings);
       Procedure GetFieldNames (Values : TStrings);
       Function IndexOf(Field : TField) : Longint;
       Function IndexOf(Field : TField) : Longint;
       procedure Remove(Value : TField);
       procedure Remove(Value : TField);

+ 25 - 0
packages/fcl-db/src/base/fields.inc

@@ -2796,6 +2796,25 @@ begin
   SetData(@aValue);
   SetData(@aValue);
 end;
 end;
 
 
+{ TFieldsEnumerator }
+
+function TFieldsEnumerator.GetCurrent: TField;
+begin
+  Result := FFields[FPosition];
+end;
+
+constructor TFieldsEnumerator.Create(AFields: TFields);
+begin
+  inherited Create;
+  FFields := AFields;
+  FPosition := -1;
+end;
+
+function TFieldsEnumerator.MoveNext: Boolean;
+begin
+  inc(FPosition);
+  Result := FPosition < FFields.Count;
+end;
 
 
 { TFields }
 { TFields }
 
 
@@ -2955,6 +2974,12 @@ begin
       end;
       end;
 end;
 end;
 
 
+Function TFields.GetEnumerator: TFieldsEnumerator;
+
+begin
+  Result:=TFieldsEnumerator.Create(Self);
+end;
+
 Procedure TFields.GetFieldNames (Values : TStrings);
 Procedure TFields.GetFieldNames (Values : TStrings);
 
 
 Var i : longint;
 Var i : longint;

+ 19 - 2
packages/fcl-db/src/datadict/fpdatadict.pp

@@ -74,6 +74,7 @@ Type
   protected
   protected
     function GetSectionName: String; override;
     function GetSectionName: String; override;
     procedure SetSectionName(const Value: String); override;
     procedure SetSectionName(const Value: String); override;
+    function GetDisplayName: string; override;
   Public
   Public
     Constructor Create(ACollection : TCollection); override;
     Constructor Create(ACollection : TCollection); override;
     Function FieldDefs : TDDFieldDefs;
     Function FieldDefs : TDDFieldDefs;
@@ -107,6 +108,7 @@ Type
     Property Hint : String Read FHint Write FHint;
     Property Hint : String Read FHint Write FHint;
     Property ProviderFlags : TProviderFlags Read FProviderFlags Write FProviderFlags;
     Property ProviderFlags : TProviderFlags Read FProviderFlags Write FProviderFlags;
   end;
   end;
+  TDDFieldDefClass = Class of TDDFieldDef;
 
 
   { TDDTableCollection }
   { TDDTableCollection }
   TDDTableCollection = Class(TIniCollection)
   TDDTableCollection = Class(TIniCollection)
@@ -134,6 +136,7 @@ Type
   Public
   Public
     Constructor Create(ATableDef : TDDTableDef);
     Constructor Create(ATableDef : TDDTableDef);
     Constructor Create(ATableName : string);
     Constructor Create(ATableName : string);
+    Class Function FieldDefClass : TDDFieldDefClass; virtual;
     Property TableDef : TDDTableDef Read FTableDef;
     Property TableDef : TDDTableDef Read FTableDef;
     Property TableName : String Read GetTableName Write SetTableName;
     Property TableName : String Read GetTableName Write SetTableName;
     Function AddField(AFieldName: String = '') : TDDFieldDef;
     Function AddField(AFieldName: String = '') : TDDFieldDef;
@@ -1013,6 +1016,14 @@ begin
   FFieldName:=Value;
   FFieldName:=Value;
 end;
 end;
 
 
+function TDDFieldDef.GetDisplayName: string;
+begin
+  If (FieldName<>'') then
+    Result:=FieldName
+  else
+    Result:=inherited GetDisplayName;
+end;
+
 constructor TDDFieldDef.Create(ACollection: TCollection);
 constructor TDDFieldDef.Create(ACollection: TCollection);
 begin
 begin
   Inherited;
   Inherited;
@@ -1233,24 +1244,30 @@ end;
 
 
 constructor TDDFieldDefs.Create(ATableDef: TDDTableDef);
 constructor TDDFieldDefs.Create(ATableDef: TDDTableDef);
 begin
 begin
-  Inherited Create(TDDFieldDef);
+  Inherited Create(FieldDefClass);
   FPrefix:='Field';
   FPrefix:='Field';
   SetTableDef(ATableDef);
   SetTableDef(ATableDef);
 end;
 end;
 
 
 constructor TDDFieldDefs.Create(ATableName: String);
 constructor TDDFieldDefs.Create(ATableName: String);
 begin
 begin
-  Inherited Create(TDDFieldDef);
+  Inherited Create(FieldDefClass);
   FPrefix:='Field';
   FPrefix:='Field';
   TableName:=ATableName;
   TableName:=ATableName;
 end;
 end;
 
 
+class function TDDFieldDefs.FieldDefClass: TDDFieldDefClass;
+begin
+  Result:=TDDFieldDef
+end;
+
 function TDDFieldDefs.GetField(Index : Integer): TDDFieldDef;
 function TDDFieldDefs.GetField(Index : Integer): TDDFieldDef;
 begin
 begin
   Result:=TDDFieldDef(Items[Index]);
   Result:=TDDFieldDef(Items[Index]);
 end;
 end;
 
 
 
 
+
 procedure TDDFieldDefs.SetField(Index : Integer; const AValue: TDDFieldDef);
 procedure TDDFieldDefs.SetField(Index : Integer; const AValue: TDDFieldDef);
 begin
 begin
   Items[Index]:=AValue;
   Items[Index]:=AValue;

+ 1 - 1
packages/iconvenc/src/iconvenc_dyn.pas

@@ -44,7 +44,7 @@ var
   iconv_open: Ticonv_open;
   iconv_open: Ticonv_open;
   iconv: Ticonv;
   iconv: Ticonv;
   iconv_close: Ticonv_close;
   iconv_close: Ticonv_close;
-  IconvLibFound: boolean = true;
+  IconvLibFound: boolean = False;
 
 
 function TryLoadLib(LibName: string; var error: string): boolean; // can be used to load non standard libname
 function TryLoadLib(LibName: string; var error: string): boolean; // can be used to load non standard libname
 function Iconvert(s: string; var res: string; FromEncoding, ToEncoding: string): cint;
 function Iconvert(s: string; var res: string; FromEncoding, ToEncoding: string): cint;

+ 178 - 190
packages/libgd/src/gd.pas

@@ -5,50 +5,38 @@
 
 
 unit gd;
 unit gd;
 
 
-{$mode objfpc}
-{$macro on}
-{$h+}
+{$MODE objfpc}
+{$MACRO on}
+{$H+}
 {$MINENUMSIZE 4}
 {$MINENUMSIZE 4}
 
 
 interface
 interface
 
 
 uses
 uses
   Classes,
   Classes,
+  dynlibs,
   ctypes;
   ctypes;
 
 
-//{$if defined(FPC_HAS_FEATURE_DYNLIBS) and (not defined(go32v2))}
-//  {$define DYNLINK}
-//{$endif}
-
+{$IFDEF UNIX}
+  {$DEFINE EXTDECL := cdecl}
+  const
+    gdlib = 'libgd.'+sharedsuffix;
+    clib = 'libc.'+sharedsuffix;
+{$ENDIF}
 {$IFDEF WINDOWS}
 {$IFDEF WINDOWS}
-  {$DEFINE DYNLINK}
+  {$DEFINE EXTDECL := stdcall}
+  const
+    gdlib = 'bgd.dll';
+    clib = 'msvcrt.dll';
 {$ENDIF}
 {$ENDIF}
 
 
-{$IFDEF DYNLINK}
-const
-{$IF Defined(WINDOWS)}
-  gdlib = 'bgd.dll';
-  clib = 'msvcrt.dll';
-{$ELSEIF Defined(UNIX)}
-  gdlib = 'libgd.so';
-  clib = 'libc.so';
-{$ELSE}
-  {$MESSAGE ERROR 'DYNLINK not supported'}
-{$IFEND}
-{$ELSE}
-  {$LINKLIB gd}
-  {$LINKLIB c}
+{$IFNDEF LOAD_DYNAMICALLY}
+  {$IFDEF darwin}
+    {$linklib c}
+    {$linklib gd}
+  {$ENDIF}
 {$ENDIF}
 {$ENDIF}
 
 
-{$DEFINE BGD_DECLARE := external {$IFDEF DYNLINK}gdlib{$ENDIF}}
-{$DEFINE BGD_DECLARE_CLIB := external {$IFDEF DYNLINK}clib{$ENDIF}}
-
-{$IF Defined(WINDOWS)}
-  {$DEFINE GDCALL := stdcall}
-{$ELSE}
-  {$DEFINE GDCALL := cdecl}
-{$IFEND}
-
 type
 type
   ppcint = ^pcint;
   ppcint = ^pcint;
   ppbyte = ^pbyte;
   ppbyte = ^pbyte;
@@ -79,18 +67,18 @@ const
 type
 type
   gdIOCtxPtr = ^gdIOCtx;
   gdIOCtxPtr = ^gdIOCtx;
   gdIOCtx = record
   gdIOCtx = record
-    getC    : function(ctx: gdIOCtxPtr): cint; GDCALL;
-    getBuf  : function(ctx: gdIOCtxPtr; buf: pointer; len: cint): cint; GDCALL;
-    putC    : procedure(ctx: gdIOCtxPtr; len: cint); GDCALL;
-    putBuf  : procedure(ctx: gdIOCtxPtr; buf: pointer; len: cint); GDCALL;
+    getC    : function(ctx: gdIOCtxPtr): cint; EXTDECL;
+    getBuf  : function(ctx: gdIOCtxPtr; buf: pointer; len: cint): cint; EXTDECL;
+    putC    : procedure(ctx: gdIOCtxPtr; len: cint); EXTDECL;
+    putBuf  : procedure(ctx: gdIOCtxPtr; buf: pointer; len: cint); EXTDECL;
     (* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! *)
     (* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! *)
-    seek    : function(ctx: gdIOCtxPtr; pos: cint): cint; GDCALL;
-    tell    : function(ctx: gdIOCtxPtr): clong; GDCALL;
-    gd_free : procedure(ctx: gdIOCtxPtr); GDCALL;
+    seek    : function(ctx: gdIOCtxPtr; pos: cint): cint; EXTDECL;
+    tell    : function(ctx: gdIOCtxPtr): clong; EXTDECL;
+    gd_free : procedure(ctx: gdIOCtxPtr); EXTDECL;
   end;
   end;
 
 
-function fopen(filename, rights: pchar): PFile; GDCALL; BGD_DECLARE_CLIB;
-procedure fclose(f: PFile); GDCALL; BGD_DECLARE_CLIB;
+function fopen(filename, rights: pchar): PFile; EXTDECL; external clib;
+procedure fclose(f: PFile); EXTDECL; external clib;
 
 
 (* The maximum number of palette entries in palette-based images.
 (* The maximum number of palette entries in palette-based images.
   In the wonderful new world of gd 2.0, you can of course have
   In the wonderful new world of gd 2.0, you can of course have
@@ -138,7 +126,7 @@ function gdTrueColorGetBlue(c: cint): cint; inline;
   based on the alpha channel value of the source color.
   based on the alpha channel value of the source color.
   The resulting color is opaque. *)
   The resulting color is opaque. *)
 
 
-function gdAlphaBlend(dest: cint; src: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdAlphaBlend@8'{$ENDIF};
+function gdAlphaBlend(dest: cint; src: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdAlphaBlend@8'{$ENDIF};
 
 
 type
 type
   gdImagePtr = ^gdImage;
   gdImagePtr = ^gdImage;
@@ -260,33 +248,33 @@ const
 (* Functions to manipulate images. *)
 (* Functions to manipulate images. *)
 
 
 (* Creates a palette-based image(up to 256 colors). *)
 (* Creates a palette-based image(up to 256 colors). *)
-function gdImageCreate(sx: cint; sy: cint): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreate@8'{$ENDIF};
+function gdImageCreate(sx: cint; sy: cint): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreate@8'{$ENDIF};
 
 
 (* An alternate name for the above(2.0). *)
 (* An alternate name for the above(2.0). *)
 function gdImageCreatePalette(sx: cint; sy: cint): gdImagePtr;
 function gdImageCreatePalette(sx: cint; sy: cint): gdImagePtr;
 
 
 (* Creates a truecolor image(millions of colors). *)
 (* Creates a truecolor image(millions of colors). *)
-function gdImageCreateTrueColor(sx: cint; sy: cint): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateTrueColor@8'{$ENDIF};
+function gdImageCreateTrueColor(sx: cint; sy: cint): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateTrueColor@8'{$ENDIF};
 
 
 (* Creates an image from various file types. These functions
 (* Creates an image from various file types. These functions
   return a palette or truecolor image based on the
   return a palette or truecolor image based on the
   nature of the file being loaded. Truecolor PNG
   nature of the file being loaded. Truecolor PNG
   stays truecolor; palette PNG stays palette-based;
   stays truecolor; palette PNG stays palette-based;
   JPEG is always truecolor. *)
   JPEG is always truecolor. *)
-function gdImageCreateFromPng(fd: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromPng@4'{$ENDIF};
-function gdImageCreateFromPngCtx(_in: gdIOCtxPtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromPngCtx@4'{$ENDIF};
-function gdImageCreateFromPngPtr(size: cint; data: pointer): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromPngPtr@8'{$ENDIF};
+function gdImageCreateFromPng(fd: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromPng@4'{$ENDIF};
+function gdImageCreateFromPngCtx(_in: gdIOCtxPtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromPngCtx@4'{$ENDIF};
+function gdImageCreateFromPngPtr(size: cint; data: pointer): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromPngPtr@8'{$ENDIF};
 
 
 (* These read the first frame only *)
 (* These read the first frame only *)
-function gdImageCreateFromGif(fd: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGif@4'{$ENDIF};
-function gdImageCreateFromGifCtx(_in: gdIOCtxPtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGifCtx@4'{$ENDIF};
-function gdImageCreateFromGifPtr(size: cint; data: pointer): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGifPtr@8'{$ENDIF};
-function gdImageCreateFromWBMP(fd: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromWBMP@4'{$ENDIF};
-function gdImageCreateFromWBMPCtx(_in: gdIOCtxPtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromWBMPCtx@4'{$ENDIF};
-function gdImageCreateFromWBMPPtr(size: cint; data: pointer): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromWBMPPtr@8'{$ENDIF};
-function gdImageCreateFromJpeg(fd: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromJpeg@4'{$ENDIF};
-function gdImageCreateFromJpegCtx(_in: gdIOCtxPtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromJpegCtx@4'{$ENDIF};
-function gdImageCreateFromJpegPtr(size: cint; data: pointer): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromJpegPtr@8'{$ENDIF};
+function gdImageCreateFromGif(fd: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGif@4'{$ENDIF};
+function gdImageCreateFromGifCtx(_in: gdIOCtxPtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGifCtx@4'{$ENDIF};
+function gdImageCreateFromGifPtr(size: cint; data: pointer): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGifPtr@8'{$ENDIF};
+function gdImageCreateFromWBMP(fd: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromWBMP@4'{$ENDIF};
+function gdImageCreateFromWBMPCtx(_in: gdIOCtxPtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromWBMPCtx@4'{$ENDIF};
+function gdImageCreateFromWBMPPtr(size: cint; data: pointer): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromWBMPPtr@8'{$ENDIF};
+function gdImageCreateFromJpeg(fd: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromJpeg@4'{$ENDIF};
+function gdImageCreateFromJpegCtx(_in: gdIOCtxPtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromJpegCtx@4'{$ENDIF};
+function gdImageCreateFromJpegPtr(size: cint; data: pointer): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromJpegPtr@8'{$ENDIF};
 
 
 (* A custom data source. *)
 (* A custom data source. *)
 (* The source function must return -1 on error, otherwise the number
 (* The source function must return -1 on error, otherwise the number
@@ -296,31 +284,31 @@ function gdImageCreateFromJpegPtr(size: cint; data: pointer): gdImagePtr; GDCALL
 type
 type
   gdSourcePtr = ^gdSource;
   gdSourcePtr = ^gdSource;
   gdSource = record
   gdSource = record
-    source  : function(context: pointer; buffer: pchar; len: cint): cint; GDCALL;
+    source  : function(context: pointer; buffer: pchar; len: cint): cint; EXTDECL;
     context : pointer;
     context : pointer;
   end;
   end;
 
 
   (* Deprecated in favor of gdImageCreateFromPngCtx *)
   (* Deprecated in favor of gdImageCreateFromPngCtx *)
-function gdImageCreateFromPngSource(_in: gdSourcePtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromPngSource@4'{$ENDIF};
+function gdImageCreateFromPngSource(_in: gdSourcePtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromPngSource@4'{$ENDIF};
 
 
-function gdImageCreateFromGd(_in: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd@4'{$ENDIF};
-function gdImageCreateFromGdCtx(_in: gdIOCtxPtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGdCtx@4'{$ENDIF};
-function gdImageCreateFromGdPtr(size: cint; data: pointer): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGdPtr@8'{$ENDIF};
+function gdImageCreateFromGd(_in: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd@4'{$ENDIF};
+function gdImageCreateFromGdCtx(_in: gdIOCtxPtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGdCtx@4'{$ENDIF};
+function gdImageCreateFromGdPtr(size: cint; data: pointer): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGdPtr@8'{$ENDIF};
 
 
-function gdImageCreateFromGd2(_in: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd2@4'{$ENDIF};
-function gdImageCreateFromGd2Ctx(_in: gdIOCtxPtr): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd2Ctx@4'{$ENDIF};
-function gdImageCreateFromGd2Ptr(size: cint; data: pointer): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd2Ptr@8'{$ENDIF};
+function gdImageCreateFromGd2(_in: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd2@4'{$ENDIF};
+function gdImageCreateFromGd2Ctx(_in: gdIOCtxPtr): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd2Ctx@4'{$ENDIF};
+function gdImageCreateFromGd2Ptr(size: cint; data: pointer): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd2Ptr@8'{$ENDIF};
 
 
-function gdImageCreateFromGd2Part(_in: PFILE; srcx: cint; srcy: cint; w: cint; h: cint): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd2Part@20'{$ENDIF};
-function gdImageCreateFromGd2PartCtx(_in: gdIOCtxPtr; srcx: cint; srcy: cint; w: cint; h: cint): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd2PartCtx@20'{$ENDIF};
-function gdImageCreateFromGd2PartPtr(size: cint; data: pointer; srcx: cint; srcy: cint; w: cint; h: cint): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromGd2PartCtx@24'{$ENDIF};
+function gdImageCreateFromGd2Part(_in: PFILE; srcx: cint; srcy: cint; w: cint; h: cint): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd2Part@20'{$ENDIF};
+function gdImageCreateFromGd2PartCtx(_in: gdIOCtxPtr; srcx: cint; srcy: cint; w: cint; h: cint): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd2PartCtx@20'{$ENDIF};
+function gdImageCreateFromGd2PartPtr(size: cint; data: pointer; srcx: cint; srcy: cint; w: cint; h: cint): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromGd2PartCtx@24'{$ENDIF};
  (* 2.0.10: prototype was missing *)
  (* 2.0.10: prototype was missing *)
-function gdImageCreateFromXbm(_in: PFILE): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromXbm@4'{$ENDIF};
+function gdImageCreateFromXbm(_in: PFILE): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromXbm@4'{$ENDIF};
 
 
  (* NOTE: filename, not FILE *)
  (* NOTE: filename, not FILE *)
-function gdImageCreateFromXpm(filename: pchar): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreateFromXpm@4'{$ENDIF};
+function gdImageCreateFromXpm(filename: pchar): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreateFromXpm@4'{$ENDIF};
 
 
-procedure gdImageDestroy(im: gdImagePtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageDestroy@4'{$ENDIF};
+procedure gdImageDestroy(im: gdImagePtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageDestroy@4'{$ENDIF};
 
 
 (* Replaces or blends with the background depending on the
 (* Replaces or blends with the background depending on the
   most recent call to gdImageAlphaBlending and the
   most recent call to gdImageAlphaBlending and the
@@ -329,54 +317,54 @@ procedure gdImageDestroy(im: gdImagePtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}na
   here. All other gd drawing functions pass through this call, 
   here. All other gd drawing functions pass through this call, 
   allowing for many useful effects. *)
   allowing for many useful effects. *)
 
 
-procedure gdImageSetPixel(im: gdImagePtr; x: cint; y: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetPixel@16'{$ENDIF};
+procedure gdImageSetPixel(im: gdImagePtr; x: cint; y: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetPixel@16'{$ENDIF};
 (* FreeType 2 text output with hook to extra flags *)
 (* FreeType 2 text output with hook to extra flags *)
 
 
-function gdImageGetPixel(im: gdImagePtr; x: cint; y: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGetPixel@12'{$ENDIF};
-function gdImageGetTrueColorPixel(im: gdImagePtr; x: cint; y: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGetTrueColorPixel@12'{$ENDIF};
+function gdImageGetPixel(im: gdImagePtr; x: cint; y: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGetPixel@12'{$ENDIF};
+function gdImageGetTrueColorPixel(im: gdImagePtr; x: cint; y: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGetTrueColorPixel@12'{$ENDIF};
 
 
-procedure gdImageAABlend(im: gdImagePtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageAABlend@4'{$ENDIF};
+procedure gdImageAABlend(im: gdImagePtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageAABlend@4'{$ENDIF};
 
 
-procedure gdImageLine(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageLine@24'{$ENDIF};
+procedure gdImageLine(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageLine@24'{$ENDIF};
 
 
 (* For backwards compatibility only. Use gdImageSetStyle()
 (* For backwards compatibility only. Use gdImageSetStyle()
   for much more flexible line drawing. *)
   for much more flexible line drawing. *)
-procedure gdImageDashedLine(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageDashedLine@24'{$ENDIF};
+procedure gdImageDashedLine(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageDashedLine@24'{$ENDIF};
 (* Corners specified(not width and height). Upper left first, lower right
 (* Corners specified(not width and height). Upper left first, lower right
   second. *)
   second. *)
-procedure gdImageRectangle(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageRectangle@24'{$ENDIF};
+procedure gdImageRectangle(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageRectangle@24'{$ENDIF};
 (* Solid bar. Upper left corner first, lower right corner second. *)
 (* Solid bar. Upper left corner first, lower right corner second. *)
-procedure gdImageFilledRectangle(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageFilledRectangle@24'{$ENDIF};
-procedure gdImageSetClip(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetClip@20'{$ENDIF};
-procedure gdImageGetClip(im: gdImagePtr; var x1: cint; var y1: cint; var x2: cint; var y2: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGetClip@20'{$ENDIF};
-function gdImageBoundsSafe(im: gdImagePtr; x: cint; y: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageBoundsSafe@12'{$ENDIF};
-procedure gdImageChar(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; c: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageChar@24'{$ENDIF};
-procedure gdImageCharUp(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; c: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCharUp@24'{$ENDIF};
-procedure gdImageString(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pchar; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageString@24'{$ENDIF};
-procedure gdImageStringUp(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pchar; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageStringUp@24'{$ENDIF};
-procedure gdImageString16(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pwidechar; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageString16@24'{$ENDIF};
-procedure gdImageStringUp16(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pwidechar; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageStringUp16@24'{$ENDIF};
+procedure gdImageFilledRectangle(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageFilledRectangle@24'{$ENDIF};
+procedure gdImageSetClip(im: gdImagePtr; x1: cint; y1: cint; x2: cint; y2: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetClip@20'{$ENDIF};
+procedure gdImageGetClip(im: gdImagePtr; var x1: cint; var y1: cint; var x2: cint; var y2: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGetClip@20'{$ENDIF};
+function gdImageBoundsSafe(im: gdImagePtr; x: cint; y: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageBoundsSafe@12'{$ENDIF};
+procedure gdImageChar(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; c: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageChar@24'{$ENDIF};
+procedure gdImageCharUp(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; c: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCharUp@24'{$ENDIF};
+procedure gdImageString(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pchar; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageString@24'{$ENDIF};
+procedure gdImageStringUp(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pchar; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageStringUp@24'{$ENDIF};
+procedure gdImageString16(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pwidechar; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageString16@24'{$ENDIF};
+procedure gdImageStringUp16(im: gdImagePtr; f: gdFontPtr; x: cint; y: cint; s: pwidechar; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageStringUp16@24'{$ENDIF};
 
 
 (* 2.0.16: for thread-safe use of gdImageStringFT and friends,
 (* 2.0.16: for thread-safe use of gdImageStringFT and friends,
   call this before allowing any thread to call gdImageStringFT. 
   call this before allowing any thread to call gdImageStringFT. 
   Otherwise it is invoked by the first thread to invoke
   Otherwise it is invoked by the first thread to invoke
   gdImageStringFT, with a very small but real risk of a race condition. 
   gdImageStringFT, with a very small but real risk of a race condition. 
   Return 0 on success, nonzero on failure to initialize freetype. *)
   Return 0 on success, nonzero on failure to initialize freetype. *)
-function gdFontCacheSetup(): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontCacheSetup@0'{$ENDIF};
+function gdFontCacheSetup(): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontCacheSetup@0'{$ENDIF};
 
 
 (* Optional: clean up after application is done using fonts in 
 (* Optional: clean up after application is done using fonts in 
 BGD_DECLARE( ) gdImageStringFT(). *)
 BGD_DECLARE( ) gdImageStringFT(). *)
-procedure gdFontCacheShutdown(); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontCacheShutdown@0'{$ENDIF};
+procedure gdFontCacheShutdown(); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontCacheShutdown@0'{$ENDIF};
 (* 2.0.20: for backwards compatibility. A few applications did start calling
 (* 2.0.20: for backwards compatibility. A few applications did start calling
  this function when it first appeared although it was never documented. 
  this function when it first appeared although it was never documented. 
  Simply invokes gdFontCacheShutdown. *)
  Simply invokes gdFontCacheShutdown. *)
-procedure gdFreeFontCache(); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFreeFontCache@0'{$ENDIF};
+procedure gdFreeFontCache(); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFreeFontCache@0'{$ENDIF};
 
 
 (* Calls gdImageStringFT. Provided for backwards compatibility only. *)
 (* Calls gdImageStringFT. Provided for backwards compatibility only. *)
-function gdImageStringTTF(im: gdImagePtr; brect: pcint; fg: cint; fontlist: pchar; ptsize: double; angle: double; x: cint; y: cint; str: pchar): pchar; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageStringTTF@36'{$ENDIF};
+function gdImageStringTTF(im: gdImagePtr; brect: pcint; fg: cint; fontlist: pchar; ptsize: double; angle: double; x: cint; y: cint; str: pchar): pchar; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageStringTTF@36'{$ENDIF};
 
 
 (* FreeType 2 text output *)
 (* FreeType 2 text output *)
-function gdImageStringFT(im: gdImagePtr; brect: pcint; fg: cint; fontlist: pchar; ptsize: double; angle: double; x: cint; y: cint; str: pchar): pchar; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageStringFT@36'{$ENDIF};
+function gdImageStringFT(im: gdImagePtr; brect: pcint; fg: cint; fontlist: pchar; ptsize: double; angle: double; x: cint; y: cint; str: pchar): pchar; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageStringFT@36'{$ENDIF};
 
 
 (* 2.0.5: provides an extensible way to pass additional parameters.
 (* 2.0.5: provides an extensible way to pass additional parameters.
   Thanks to Wez Furlong, sorry for the delay. *)
   Thanks to Wez Furlong, sorry for the delay. *)
@@ -439,7 +427,7 @@ const
   and gdImageStringFTEx shall be assumed to be a fontconfig font pattern
   and gdImageStringFTEx shall be assumed to be a fontconfig font pattern
   if fontconfig was compiled into gd. This function returns zero
   if fontconfig was compiled into gd. This function returns zero
   if fontconfig is not available, nonzero otherwise. *)
   if fontconfig is not available, nonzero otherwise. *)
-function gdFTUseFontConfig(flag: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFTUseFontConfig@4'{$ENDIF};
+function gdFTUseFontConfig(flag: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFTUseFontConfig@4'{$ENDIF};
 
 
 (* These are NOT flags; set one in 'charmap' if you set the
 (* These are NOT flags; set one in 'charmap' if you set the
   gdFTEX_CHARMAP bit in 'flags'. *)
   gdFTEX_CHARMAP bit in 'flags'. *)
@@ -449,7 +437,7 @@ const
   gdFTEX_Big5 = 2;
   gdFTEX_Big5 = 2;
   gdFTEX_Adobe_Custom = 3;
   gdFTEX_Adobe_Custom = 3;
 
 
-function gdImageStringFTEx(im: gdImagePtr; brect: pcint; fg: cint; fontlist: pchar; ptsize: double; angle: double; x: cint; y: cint; str: pchar; strex: gdFTStringExtraPtr): pchar; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageStringFTEx@40'{$ENDIF};
+function gdImageStringFTEx(im: gdImagePtr; brect: pcint; fg: cint; fontlist: pchar; ptsize: double; angle: double; x: cint; y: cint; str: pchar; strex: gdFTStringExtraPtr): pchar; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageStringFTEx@40'{$ENDIF};
 
 
 (* Point type for use in polygon drawing. *)
 (* Point type for use in polygon drawing. *)
 type
 type
@@ -458,32 +446,32 @@ type
     x, y: cint;
     x, y: cint;
   end;
   end;
 
 
-procedure gdImagePolygon(im: gdImagePtr; p: gdPointPtr; n: cint; c: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePolygon@16'{$ENDIF};
-procedure gdImageOpenPolygon(im: gdImagePtr; p: gdPointPtr; n: cint; c: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageOpenPolygon@16'{$ENDIF};
-procedure gdImageFilledPolygon(im: gdImagePtr; p: gdPointPtr; n: cint; c: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageFilledPolygon@16'{$ENDIF};
+procedure gdImagePolygon(im: gdImagePtr; p: gdPointPtr; n: cint; c: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePolygon@16'{$ENDIF};
+procedure gdImageOpenPolygon(im: gdImagePtr; p: gdPointPtr; n: cint; c: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageOpenPolygon@16'{$ENDIF};
+procedure gdImageFilledPolygon(im: gdImagePtr; p: gdPointPtr; n: cint; c: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageFilledPolygon@16'{$ENDIF};
 
 
 (* These functions still work with truecolor images, 
 (* These functions still work with truecolor images, 
   for which they never return error. *)
   for which they never return error. *)
-function gdImageColorAllocate(im: gdImagePtr; r: cint; g: cint; b: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorAllocate@16'{$ENDIF};
+function gdImageColorAllocate(im: gdImagePtr; r: cint; g: cint; b: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorAllocate@16'{$ENDIF};
 (* gd 2.0: palette entries with non-opaque transparency are permitted. *)
 (* gd 2.0: palette entries with non-opaque transparency are permitted. *)
-function gdImageColorAllocateAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorAllocateAlpha@20'{$ENDIF};
+function gdImageColorAllocateAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorAllocateAlpha@20'{$ENDIF};
 (* Assumes opaque is the preferred alpha channel value *)
 (* Assumes opaque is the preferred alpha channel value *)
-function gdImageColorClosest(im: gdImagePtr; r: cint; g: cint; b: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorClosest@16'{$ENDIF};
+function gdImageColorClosest(im: gdImagePtr; r: cint; g: cint; b: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorClosest@16'{$ENDIF};
 (* Closest match taking all four parameters into account.
 (* Closest match taking all four parameters into account.
   A slightly different color with the same transparency
   A slightly different color with the same transparency
   beats the exact same color with radically different
   beats the exact same color with radically different
   transparency *)
   transparency *)
-function gdImageColorClosestAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorClosestAlpha@20'{$ENDIF};
+function gdImageColorClosestAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorClosestAlpha@20'{$ENDIF};
 (* An alternate method *)
 (* An alternate method *)
-function gdImageColorClosestHWB(im: gdImagePtr; r: cint; g: cint; b: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorClosestHWB@16'{$ENDIF};
+function gdImageColorClosestHWB(im: gdImagePtr; r: cint; g: cint; b: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorClosestHWB@16'{$ENDIF};
 (* Returns exact, 100% opaque matches only *)
 (* Returns exact, 100% opaque matches only *)
-function gdImageColorExact(im: gdImagePtr; r: cint; g: cint; b: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorExact@16'{$ENDIF};
+function gdImageColorExact(im: gdImagePtr; r: cint; g: cint; b: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorExact@16'{$ENDIF};
 (* Returns an exact match only, including alpha *)
 (* Returns an exact match only, including alpha *)
-function gdImageColorExactAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorExactAlpha@20'{$ENDIF};
+function gdImageColorExactAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorExactAlpha@20'{$ENDIF};
 (* Opaque only *)
 (* Opaque only *)
-function gdImageColorResolve(im: gdImagePtr; r: cint; g: cint; b: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorResolve@16'{$ENDIF};
+function gdImageColorResolve(im: gdImagePtr; r: cint; g: cint; b: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorResolve@16'{$ENDIF};
 (* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha *)
 (* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha *)
-function gdImageColorResolveAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorResolveAlpha@20'{$ENDIF};
+function gdImageColorResolveAlpha(im: gdImagePtr; r: cint; g: cint; b: cint; a: cint): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorResolveAlpha@20'{$ENDIF};
 
 
 (* A simpler way to obtain an opaque truecolor value for drawing on a
 (* A simpler way to obtain an opaque truecolor value for drawing on a
   truecolor image. Not for use with palette images! *)
   truecolor image. Not for use with palette images! *)
@@ -494,7 +482,7 @@ function gdTrueColor(r: cint; g: cint; b: cint): cint;
   opaque. *)
   opaque. *)
 function gdTrueColorAlpha(r: cint; g: cint; b: cint; a: cint): cint;
 function gdTrueColorAlpha(r: cint; g: cint; b: cint; a: cint): cint;
 
 
-procedure gdImageColorDeallocate(im: gdImagePtr; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorDeallocate@8'{$ENDIF};
+procedure gdImageColorDeallocate(im: gdImagePtr; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorDeallocate@8'{$ENDIF};
 
 
 (* Converts a truecolor image to a palette-based image,
 (* Converts a truecolor image to a palette-based image,
   using a high-quality two-pass quantization routine
   using a high-quality two-pass quantization routine
@@ -516,9 +504,9 @@ procedure gdImageColorDeallocate(im: gdImagePtr; color: cint); GDCALL; BGD_DECLA
   returns a new image. gdImageTrueColorToPalette modifies 
   returns a new image. gdImageTrueColorToPalette modifies 
   an existing image, and the truecolor pixels are discarded. *)
   an existing image, and the truecolor pixels are discarded. *)
 
 
-function gdImageCreatePaletteFromTrueColor(im: gdImagePtr; ditherFlag: cint; colorsWanted: cint): gdImagePtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCreatePaletteFromTrueColor@16'{$ENDIF};
+function gdImageCreatePaletteFromTrueColor(im: gdImagePtr; ditherFlag: cint; colorsWanted: cint): gdImagePtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCreatePaletteFromTrueColor@16'{$ENDIF};
 
 
-procedure gdImageTrueColorToPalette(im: gdImagePtr; ditherFlag: cint; colorsWanted: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageTrueColorToPalette@16'{$ENDIF};
+procedure gdImageTrueColorToPalette(im: gdImagePtr; ditherFlag: cint; colorsWanted: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageTrueColorToPalette@16'{$ENDIF};
 
 
 (* Specifies a color index(if a palette image) or an
 (* Specifies a color index(if a palette image) or an
   RGB color(if a truecolor image) which should be
   RGB color(if a truecolor image) which should be
@@ -529,38 +517,38 @@ procedure gdImageTrueColorToPalette(im: gdImagePtr; ditherFlag: cint; colorsWant
   a truecolor image. Note that gdImageColorTransparent
   a truecolor image. Note that gdImageColorTransparent
   is usually compatible with older browsers that
   is usually compatible with older browsers that
   do not understand full alpha channels well. TBB *)
   do not understand full alpha channels well. TBB *)
-procedure gdImageColorTransparent(im: gdImagePtr; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageColorTransparent@8'{$ENDIF};
+procedure gdImageColorTransparent(im: gdImagePtr; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageColorTransparent@8'{$ENDIF};
 
 
-procedure gdImagePaletteCopy(dst: gdImagePtr; src: gdImagePtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePaletteCopy@8'{$ENDIF};
-procedure gdImageGif(im: gdImagePtr; _out: PFILE); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGif@8'{$ENDIF};
-procedure gdImagePng(im: gdImagePtr; _out: PFILE); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePng@8'{$ENDIF};
-procedure gdImagePngCtx(im: gdImagePtr; _out: gdIOCtxPtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePngCtx@8'{$ENDIF};
-procedure gdImageGifCtx(im: gdImagePtr; _out: gdIOCtxPtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGifCtx@8'{$ENDIF};
+procedure gdImagePaletteCopy(dst: gdImagePtr; src: gdImagePtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePaletteCopy@8'{$ENDIF};
+procedure gdImageGif(im: gdImagePtr; _out: PFILE); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGif@8'{$ENDIF};
+procedure gdImagePng(im: gdImagePtr; _out: PFILE); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePng@8'{$ENDIF};
+procedure gdImagePngCtx(im: gdImagePtr; _out: gdIOCtxPtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePngCtx@8'{$ENDIF};
+procedure gdImageGifCtx(im: gdImagePtr; _out: gdIOCtxPtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGifCtx@8'{$ENDIF};
 
 
 (* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
 (* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
   1 is FASTEST but produces larger files, 9 provides the best
   1 is FASTEST but produces larger files, 9 provides the best
   compression(smallest files) but takes a long time to compress, and
   compression(smallest files) but takes a long time to compress, and
   -1 selects the default compiled into the zlib library. *)
   -1 selects the default compiled into the zlib library. *)
-procedure gdImagePngEx(im: gdImagePtr; _out: PFILE; level: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePngEx@12'{$ENDIF};
-procedure gdImagePngCtxEx(im: gdImagePtr; _out: gdIOCtxPtr; level: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePngCtxEx@12'{$ENDIF};
+procedure gdImagePngEx(im: gdImagePtr; _out: PFILE; level: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePngEx@12'{$ENDIF};
+procedure gdImagePngCtxEx(im: gdImagePtr; _out: gdIOCtxPtr; level: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePngCtxEx@12'{$ENDIF};
 
 
-procedure gdImageWBMP(image: gdImagePtr; fg: cint; _out: PFILE); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageWBMP@12'{$ENDIF};
-procedure gdImageWBMPCtx(image: gdImagePtr; fg: cint; _out: gdIOCtxPtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageWBMPCtx@12'{$ENDIF};
+procedure gdImageWBMP(image: gdImagePtr; fg: cint; _out: PFILE); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageWBMP@12'{$ENDIF};
+procedure gdImageWBMPCtx(image: gdImagePtr; fg: cint; _out: gdIOCtxPtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageWBMPCtx@12'{$ENDIF};
 
 
 (* Guaranteed to correctly free memory returned
 (* Guaranteed to correctly free memory returned
   by the gdImage*Ptr functions *)
   by the gdImage*Ptr functions *)
-procedure gdFree(m: pointer); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFree@4'{$ENDIF};
+procedure gdFree(m: pointer); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFree@4'{$ENDIF};
 
 
 (* Best to free this memory with gdFree(), not free() *)
 (* Best to free this memory with gdFree(), not free() *)
-function gdImageWBMPPtr(im: gdImagePtr; size: pcint; fg: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageWBMPPtr@12'{$ENDIF};
+function gdImageWBMPPtr(im: gdImagePtr; size: pcint; fg: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageWBMPPtr@12'{$ENDIF};
 
 
 (* 100 is highest quality(there is always a little loss with JPEG).
 (* 100 is highest quality(there is always a little loss with JPEG).
   0 is lowest. 10 is about the lowest useful setting. *)
   0 is lowest. 10 is about the lowest useful setting. *)
-procedure gdImageJpeg(im: gdImagePtr; _out: PFILE; quality: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageJpeg@12'{$ENDIF};
-procedure gdImageJpegCtx(im: gdImagePtr; _out: gdIOCtxPtr; quality: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageJpegCtx@12'{$ENDIF};
+procedure gdImageJpeg(im: gdImagePtr; _out: PFILE; quality: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageJpeg@12'{$ENDIF};
+procedure gdImageJpegCtx(im: gdImagePtr; _out: gdIOCtxPtr; quality: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageJpegCtx@12'{$ENDIF};
 
 
 (* Best to free this memory with gdFree(), not free() *)
 (* Best to free this memory with gdFree(), not free() *)
-function gdImageJpegPtr(im: gdImagePtr; size: pcint; quality: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageJpegPtr@12'{$ENDIF};
+function gdImageJpegPtr(im: gdImagePtr; size: pcint; quality: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageJpegPtr@12'{$ENDIF};
 
 
 (* Legal values for Disposal. gdDisposalNone is always used by
 (* Legal values for Disposal. gdDisposalNone is always used by
   the built-in optimizer if previm is passed. *)
   the built-in optimizer if previm is passed. *)
@@ -573,15 +561,15 @@ enum {
   gdDisposalRestorePrevious
   gdDisposalRestorePrevious
 };
 };
 
 
-procedure gdImageGifAnimBegin(im: gdImagePtr; _outFile: PFILE; int GlobalCM, int Loops); GDCALL; BGD_DECLARE;
-procedure gdImageGifAnimAdd(im: gdImagePtr; _outFile: PFILE; int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); GDCALL; BGD_DECLARE;
-procedure gdImageGifAnimEnd(_outFile: PFILE); GDCALL; BGD_DECLARE;
-procedure gdImageGifAnimBeginCtx(im: gdImagePtr; gdIOCtx *out, int GlobalCM, int Loops); GDCALL; BGD_DECLARE;
-procedure gdImageGifAnimAddCtx(im: gdImagePtr; gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); GDCALL; BGD_DECLARE;
-procedure gdImageGifAnimEndCtx(gdIOCtx *out); GDCALL; BGD_DECLARE;
-function gdImageGifAnimBeginPtr(im: gdImagePtr; int *size, int GlobalCM, int Loops): pointer; GDCALL; BGD_DECLARE;
-function gdImageGifAnimAddPtr(im: gdImagePtr; int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm): pointer; GDCALL; BGD_DECLARE;
-function gdImageGifAnimEndPtr(int *size): pointer; GDCALL; BGD_DECLARE;
+procedure gdImageGifAnimBegin(im: gdImagePtr; _outFile: PFILE; int GlobalCM, int Loops); EXTDECL; BGD_DECLARE;
+procedure gdImageGifAnimAdd(im: gdImagePtr; _outFile: PFILE; int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); EXTDECL; BGD_DECLARE;
+procedure gdImageGifAnimEnd(_outFile: PFILE); EXTDECL; BGD_DECLARE;
+procedure gdImageGifAnimBeginCtx(im: gdImagePtr; gdIOCtx *out, int GlobalCM, int Loops); EXTDECL; BGD_DECLARE;
+procedure gdImageGifAnimAddCtx(im: gdImagePtr; gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); EXTDECL; BGD_DECLARE;
+procedure gdImageGifAnimEndCtx(gdIOCtx *out); EXTDECL; BGD_DECLARE;
+function gdImageGifAnimBeginPtr(im: gdImagePtr; int *size, int GlobalCM, int Loops): pointer; EXTDECL; BGD_DECLARE;
+function gdImageGifAnimAddPtr(im: gdImagePtr; int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm): pointer; EXTDECL; BGD_DECLARE;
+function gdImageGifAnimEndPtr(int *size): pointer; EXTDECL; BGD_DECLARE;
 *)
 *)
 {$warning TODO}
 {$warning TODO}
 
 
@@ -593,27 +581,27 @@ function gdImageGifAnimEndPtr(int *size): pointer; GDCALL; BGD_DECLARE;
 type
 type
   gdSinkPtr = ^gdSink;
   gdSinkPtr = ^gdSink;
   gdSink = record
   gdSink = record
-    sink    : function(context: pointer; buffer: pchar; len: cint): cint; GDCALL;
+    sink    : function(context: pointer; buffer: pchar; len: cint): cint; EXTDECL;
     context : pointer;
     context : pointer;
   end;
   end;
 
 
-procedure gdImagePngToSink(im: gdImagePtr; _out: gdSinkPtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePngToSink@8'{$ENDIF};
+procedure gdImagePngToSink(im: gdImagePtr; _out: gdSinkPtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePngToSink@8'{$ENDIF};
 
 
-procedure gdImageGd(im: gdImagePtr; _out: PFILE); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGd@8'{$ENDIF};
-procedure gdImageGd2(im: gdImagePtr; _out: PFILE; cs: cint; fmt: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGd2@16'{$ENDIF};
+procedure gdImageGd(im: gdImagePtr; _out: PFILE); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGd@8'{$ENDIF};
+procedure gdImageGd2(im: gdImagePtr; _out: PFILE; cs: cint; fmt: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGd2@16'{$ENDIF};
 
 
 (* Best to free this memory with gdFree(), not free() *)
 (* Best to free this memory with gdFree(), not free() *)
-function gdImageGifPtr(im: gdImagePtr; var size: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGifPtr@8'{$ENDIF};
+function gdImageGifPtr(im: gdImagePtr; var size: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGifPtr@8'{$ENDIF};
 
 
 (* Best to free this memory with gdFree(), not free() *)
 (* Best to free this memory with gdFree(), not free() *)
-function gdImagePngPtr(im: gdImagePtr; var size: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePngPtr@8'{$ENDIF};
-function gdImagePngPtrEx(im: gdImagePtr; var size: cint; level: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImagePngPtrEx@12'{$ENDIF};
+function gdImagePngPtr(im: gdImagePtr; var size: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePngPtr@8'{$ENDIF};
+function gdImagePngPtrEx(im: gdImagePtr; var size: cint; level: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImagePngPtrEx@12'{$ENDIF};
 
 
 (* Best to free this memory with gdFree(), not free() *)
 (* Best to free this memory with gdFree(), not free() *)
-function gdImageGdPtr(im: gdImagePtr; var size: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGdPtr@8'{$ENDIF};
+function gdImageGdPtr(im: gdImagePtr; var size: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGdPtr@8'{$ENDIF};
 
 
 (* Best to free this memory with gdFree(), not free() *)
 (* Best to free this memory with gdFree(), not free() *)
-function gdImageGd2Ptr(im: gdImagePtr; cs: cint; fmt: cint; var size: cint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageGd2Ptr@16'{$ENDIF};
+function gdImageGd2Ptr(im: gdImagePtr; cs: cint; fmt: cint; var size: cint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageGd2Ptr@16'{$ENDIF};
 
 
 
 
 (* Style is a bitwise OR( | operator ) of these.
 (* Style is a bitwise OR( | operator ) of these.
@@ -634,20 +622,20 @@ const
   gdNoFill = 2;
   gdNoFill = 2;
   gdEdged  = 4;
   gdEdged  = 4;
 
 
-procedure gdImageFilledArc(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; s: cint; e: cint; color: cint; style: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageFilledArc@36'{$ENDIF};
-procedure gdImageArc(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; s: cint; e: cint; color: cint; style: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageArc@36'{$ENDIF};
-procedure gdImageEllipse(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageEllipse@24'{$ENDIF};
-procedure gdImageFilledEllipse(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageFilledEllipse@24'{$ENDIF};
-procedure gdImageFillToBorder(im: gdImagePtr; cx: cint; cy: cint; border: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageFillToBorder@20'{$ENDIF};
-procedure gdImageFill(im: gdImagePtr; x: cint; y: cint; color: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageFill@16'{$ENDIF};
-procedure gdImageCopy(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; w: cint; h: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCopy@32'{$ENDIF};
-procedure gdImageCopyMerge(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; w: cint; h: cint; pct: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCopyMerge@36'{$ENDIF};
-procedure gdImageCopyMergeGray(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; w: cint; h: cint; pct: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCopyMergeGray@36'{$ENDIF};
+procedure gdImageFilledArc(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; s: cint; e: cint; color: cint; style: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageFilledArc@36'{$ENDIF};
+procedure gdImageArc(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; s: cint; e: cint; color: cint; style: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageArc@36'{$ENDIF};
+procedure gdImageEllipse(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageEllipse@24'{$ENDIF};
+procedure gdImageFilledEllipse(im: gdImagePtr; cx: cint; cy: cint; w: cint; h: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageFilledEllipse@24'{$ENDIF};
+procedure gdImageFillToBorder(im: gdImagePtr; cx: cint; cy: cint; border: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageFillToBorder@20'{$ENDIF};
+procedure gdImageFill(im: gdImagePtr; x: cint; y: cint; color: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageFill@16'{$ENDIF};
+procedure gdImageCopy(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; w: cint; h: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCopy@32'{$ENDIF};
+procedure gdImageCopyMerge(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; w: cint; h: cint; pct: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCopyMerge@36'{$ENDIF};
+procedure gdImageCopyMergeGray(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; w: cint; h: cint; pct: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCopyMergeGray@36'{$ENDIF};
 
 
 (* Stretches or shrinks to fit, as needed. Does NOT attempt
 (* Stretches or shrinks to fit, as needed. Does NOT attempt
   to average the entire set of source pixels that scale down onto the
   to average the entire set of source pixels that scale down onto the
   destination pixel. *)
   destination pixel. *)
-procedure gdImageCopyResized(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; dstW: cint; dstH: cint; srcW: cint; srcH: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCopyResized@40'{$ENDIF};
+procedure gdImageCopyResized(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; dstW: cint; dstH: cint; srcW: cint; srcH: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCopyResized@40'{$ENDIF};
 
 
 (* gd 2.0: stretches or shrinks to fit, as needed. When called with a
 (* gd 2.0: stretches or shrinks to fit, as needed. When called with a
   truecolor destination image, this function averages the
   truecolor destination image, this function averages the
@@ -658,7 +646,7 @@ procedure gdImageCopyResized(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY:
   on modern hardware, except for some embedded devices. If the 
   on modern hardware, except for some embedded devices. If the 
   destination is a palette image, gdImageCopyResized is 
   destination is a palette image, gdImageCopyResized is 
   substituted automatically. *)
   substituted automatically. *)
-procedure gdImageCopyResampled(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; dstW: cint; dstH: cint; srcW: cint; srcH: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCopyResampled@40'{$ENDIF};
+procedure gdImageCopyResampled(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dstY: cint; srcX: cint; srcY: cint; dstW: cint; dstH: cint; srcW: cint; srcH: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCopyResampled@40'{$ENDIF};
 
 
 (* gd 2.0.8: gdImageCopyRotated is added. Source
 (* gd 2.0.8: gdImageCopyRotated is added. Source
         is a rectangle, with its upper left corner at
         is a rectangle, with its upper left corner at
@@ -667,20 +655,20 @@ procedure gdImageCopyResampled(dst: gdImagePtr; src: gdImagePtr; dstX: cint; dst
         gdImageArc. Floating point destination center
         gdImageArc. Floating point destination center
         coordinates allow accurate rotation of
         coordinates allow accurate rotation of
         objects of odd-numbered width or height. *)
         objects of odd-numbered width or height. *)
-procedure gdImageCopyRotated(dst: gdImagePtr; src: gdImagePtr; dstX: double; dstY: double; srcX: cint; srcY: cint; srcWidth: cint; srcHeight: cint; angle: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCopyRotated@36'{$ENDIF};
+procedure gdImageCopyRotated(dst: gdImagePtr; src: gdImagePtr; dstX: double; dstY: double; srcX: cint; srcY: cint; srcWidth: cint; srcHeight: cint; angle: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCopyRotated@36'{$ENDIF};
 
 
-procedure gdImageSetBrush(im: gdImagePtr; brush: gdImagePtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetBrush@8'{$ENDIF};
-procedure gdImageSetTile(im: gdImagePtr; tile: gdImagePtr); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetTile@8'{$ENDIF};
-procedure gdImageSetAntiAliased(im: gdImagePtr; c: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetAntiAliased@8'{$ENDIF};
-procedure gdImageSetAntiAliasedDontBlend(im: gdImagePtr; c: cint; dont_blend: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetAntiAliasedDontBlend@12'{$ENDIF};
-procedure gdImageSetStyle(im: gdImagePtr; style: pcint; noOfPixels: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetStyle@12'{$ENDIF};
+procedure gdImageSetBrush(im: gdImagePtr; brush: gdImagePtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetBrush@8'{$ENDIF};
+procedure gdImageSetTile(im: gdImagePtr; tile: gdImagePtr); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetTile@8'{$ENDIF};
+procedure gdImageSetAntiAliased(im: gdImagePtr; c: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetAntiAliased@8'{$ENDIF};
+procedure gdImageSetAntiAliasedDontBlend(im: gdImagePtr; c: cint; dont_blend: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetAntiAliasedDontBlend@12'{$ENDIF};
+procedure gdImageSetStyle(im: gdImagePtr; style: pcint; noOfPixels: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetStyle@12'{$ENDIF};
 (* Line thickness(defaults to 1). Affects lines, ellipses, 
 (* Line thickness(defaults to 1). Affects lines, ellipses, 
   rectangles, polygons and so forth. *)
   rectangles, polygons and so forth. *)
-procedure gdImageSetThickness(im: gdImagePtr; thickness: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSetThickness@8'{$ENDIF};
+procedure gdImageSetThickness(im: gdImagePtr; thickness: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSetThickness@8'{$ENDIF};
 (* On or off(1 or 0) for all three of these. *)
 (* On or off(1 or 0) for all three of these. *)
-procedure gdImageInterlace(im: gdImagePtr; interlaceArg: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageInterlace@8'{$ENDIF};
-procedure gdImageAlphaBlending(im: gdImagePtr; alphaBlendingArg: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageAlphaBlending@8'{$ENDIF};
-procedure gdImageSaveAlpha(im: gdImagePtr; saveAlphaArg: cint); GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageSaveAlpha@8'{$ENDIF};
+procedure gdImageInterlace(im: gdImagePtr; interlaceArg: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageInterlace@8'{$ENDIF};
+procedure gdImageAlphaBlending(im: gdImagePtr; alphaBlendingArg: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageAlphaBlending@8'{$ENDIF};
+procedure gdImageSaveAlpha(im: gdImagePtr; saveAlphaArg: cint); EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageSaveAlpha@8'{$ENDIF};
 
 
 (* Macros to access information about images. *)
 (* Macros to access information about images. *)
 
 
@@ -708,14 +696,14 @@ function gdImageTrueColorPixel(im: gdImagePtr; x, y: cint): cint; inline;
 
 
 (* I/O Support routines. *)
 (* I/O Support routines. *)
 
 
-function gdNewFileCtx(p: PFILE): gdIOCtxPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdNewFileCtx@4'{$ENDIF};
+function gdNewFileCtx(p: PFILE): gdIOCtxPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdNewFileCtx@4'{$ENDIF};
  (* If data is null, size is ignored and an initial data buffer is
  (* If data is null, size is ignored and an initial data buffer is
     allocated automatically. NOTE: this function assumes gd has the right 
     allocated automatically. NOTE: this function assumes gd has the right 
     to free or reallocate "data" at will! Also note that gd will free 
     to free or reallocate "data" at will! Also note that gd will free 
     "data" when the IO context is freed. If data is not null, it must point
     "data" when the IO context is freed. If data is not null, it must point
     to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.
     to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.
     If not, see gdNewDynamicCtxEx for an alternative. *)
     If not, see gdNewDynamicCtxEx for an alternative. *)
-function gdNewDynamicCtx(size: cint; data: pointer): gdIOCtxPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdNewDynamicCtx@8'{$ENDIF};
+function gdNewDynamicCtx(size: cint; data: pointer): gdIOCtxPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdNewDynamicCtx@8'{$ENDIF};
  (* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as
  (* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as
     needed as described above. If freeFlag is zero, gd will never free 
     needed as described above. If freeFlag is zero, gd will never free 
     or reallocate "data," which means that the context should only be used
     or reallocate "data," which means that the context should only be used
@@ -724,9 +712,9 @@ function gdNewDynamicCtx(size: cint; data: pointer): gdIOCtxPtr; GDCALL; BGD_DEC
     not large enough and an image write is attempted, the write operation
     not large enough and an image write is attempted, the write operation
     will fail. Those wishing to write an image to a buffer in memory have
     will fail. Those wishing to write an image to a buffer in memory have
     a much simpler alternative in the gdImage[something]Ptr functions. *)
     a much simpler alternative in the gdImage[something]Ptr functions. *)
-function gdNewDynamicCtxEx(size: cint; data: pointer; freeFlag: cint): gdIOCtxPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdNewDynamicCtxEx@12'{$ENDIF};
-function gdNewSSCtx(_in: gdSourcePtr; _out: gdSinkPtr): gdIOCtxPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdNewSSCtx@8'{$ENDIF};
-function gdDPExtractData(ctx: gdIOCtxPtr; size: pcint): pointer; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdDPExtractData@8'{$ENDIF};
+function gdNewDynamicCtxEx(size: cint; data: pointer; freeFlag: cint): gdIOCtxPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdNewDynamicCtxEx@12'{$ENDIF};
+function gdNewSSCtx(_in: gdSourcePtr; _out: gdSinkPtr): gdIOCtxPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdNewSSCtx@8'{$ENDIF};
+function gdDPExtractData(ctx: gdIOCtxPtr; size: pcint): pointer; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdDPExtractData@8'{$ENDIF};
 
 
 function gdNewStreamCtx(Stream: TStream; free: boolean): gdIOCtxPtr;
 function gdNewStreamCtx(Stream: TStream; free: boolean): gdIOCtxPtr;
 // NOTE: don't forget to call ctx^.gd_free(ctx)
 // NOTE: don't forget to call ctx^.gd_free(ctx)
@@ -743,7 +731,7 @@ const
   GD2_FMT_COMPRESSED      = 2;
   GD2_FMT_COMPRESSED      = 2;
 
 
 (* Image comparison definitions *)
 (* Image comparison definitions *)
-function gdImageCompare(im1: gdImagePtr; im2: gdImagePtr): cint; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdImageCompare@8'{$ENDIF};
+function gdImageCompare(im1: gdImagePtr; im2: gdImagePtr): cint; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdImageCompare@8'{$ENDIF};
 
 
 const
 const
   GD_CMP_IMAGE        = 1; (* Actual image IS different *)
   GD_CMP_IMAGE        = 1; (* Actual image IS different *)
@@ -762,11 +750,11 @@ const
 (* newfangled special effects *)
 (* newfangled special effects *)
 //#include "gdfx.h"
 //#include "gdfx.h"
 
 
-function gdFontGetLarge(): gdFontPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontGetLarge@0'{$ENDIF};
-function gdFontGetSmall(): gdFontPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontGetSmall@0'{$ENDIF};
-function gdFontGetGiant(): gdFontPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontGetGiant@0'{$ENDIF};
-function gdFontGetMediumBold(): gdFontPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontGetMediumBold@0'{$ENDIF};
-function gdFontGetTiny(): gdFontPtr; GDCALL; BGD_DECLARE {$IFDEF WINDOWS}name '_gdFontGetTiny@0'{$ENDIF};
+function gdFontGetLarge(): gdFontPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontGetLarge@0'{$ENDIF};
+function gdFontGetSmall(): gdFontPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontGetSmall@0'{$ENDIF};
+function gdFontGetGiant(): gdFontPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontGetGiant@0'{$ENDIF};
+function gdFontGetMediumBold(): gdFontPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontGetMediumBold@0'{$ENDIF};
+function gdFontGetTiny(): gdFontPtr; EXTDECL; external gdlib {$IFDEF WINDOWS}name '_gdFontGetTiny@0'{$ENDIF};
 
 
 {$ifdef windows}
 {$ifdef windows}
 function gdFontLarge(): gdFontPtr; inline;
 function gdFontLarge(): gdFontPtr; inline;
@@ -777,17 +765,17 @@ function gdFontTiny(): gdFontPtr; inline;
 {$else}
 {$else}
 var
 var
 {$ifndef darwin}
 {$ifndef darwin}
-  gdFontLarge      : gdFontPtr; cvar; BGD_DECLARE;
-  gdFontSmall      : gdFontPtr; cvar; BGD_DECLARE;
-  gdFontGiant      : gdFontPtr; cvar; BGD_DECLARE;
-  gdFontMediumBold : gdFontPtr; cvar; BGD_DECLARE;
-  gdFontTiny       : gdFontPtr; cvar; BGD_DECLARE;
+  gdFontLarge      : gdFontPtr; cvar; external gdlib;
+  gdFontSmall      : gdFontPtr; cvar; external gdlib;
+  gdFontGiant      : gdFontPtr; cvar; external gdlib;
+  gdFontMediumBold : gdFontPtr; cvar; external gdlib;
+  gdFontTiny       : gdFontPtr; cvar; external gdlib;
 {$else darwin}
 {$else darwin}
-  gdFontLarge      : gdFontPtr; BGD_DECLARE name 'gdFontLarge';
-  gdFontSmall      : gdFontPtr; BGD_DECLARE name 'gdFontSmall';
-  gdFontGiant      : gdFontPtr; BGD_DECLARE name 'gdFontGiant';
-  gdFontMediumBold : gdFontPtr; BGD_DECLARE name 'gdFontMediumBold';
-  gdFontTiny       : gdFontPtr; BGD_DECLARE name 'gdFontTiny';
+  gdFontLarge      : gdFontPtr; external gdlib name 'gdFontLarge';
+  gdFontSmall      : gdFontPtr; external gdlib name 'gdFontSmall';
+  gdFontGiant      : gdFontPtr; external gdlib name 'gdFontGiant';
+  gdFontMediumBold : gdFontPtr; external gdlib name 'gdFontMediumBold';
+  gdFontTiny       : gdFontPtr; external gdlib name 'gdFontTiny';
 {$endif darwin}
 {$endif darwin}
 {$endif}
 {$endif}
 
 
@@ -980,7 +968,7 @@ type
     free: Boolean;
     free: Boolean;
   end;
   end;
 
 
-function stream_getC(ctx: gdIOCtxPtr): cint; GDCALL;
+function stream_getC(ctx: gdIOCtxPtr): cint; EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin
@@ -988,42 +976,42 @@ begin
   s^.strm.read(result, 1);
   s^.strm.read(result, 1);
 end;
 end;
 
 
-function stream_getBuf(ctx: gdIOCtxPtr; buf: pointer; len: cint): cint; GDCALL;
+function stream_getBuf(ctx: gdIOCtxPtr; buf: pointer; len: cint): cint; EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin
   result := s^.strm.read(buf^, len);
   result := s^.strm.read(buf^, len);
 end;
 end;
 
 
-procedure stream_putC(ctx: gdIOCtxPtr; len: cint); GDCALL;
+procedure stream_putC(ctx: gdIOCtxPtr; len: cint); EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin
   s^.strm.write(len, 1);
   s^.strm.write(len, 1);
 end;
 end;
 
 
-procedure stream_putBuf(ctx: gdIOCtxPtr; buf: pointer; len: cint); GDCALL;
+procedure stream_putBuf(ctx: gdIOCtxPtr; buf: pointer; len: cint); EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin
   s^.strm.write(buf^, len);
   s^.strm.write(buf^, len);
 end;
 end;
 
 
-function stream_seek(ctx: gdIOCtxPtr; pos: cint): cint; GDCALL;
+function stream_seek(ctx: gdIOCtxPtr; pos: cint): cint; EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin
   result := s^.strm.seek(soFromBeginning, pos);
   result := s^.strm.seek(soFromBeginning, pos);
 end;
 end;
 
 
-function stream_tell(ctx: gdIOCtxPtr): clong; GDCALL;
+function stream_tell(ctx: gdIOCtxPtr): clong; EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin
   result := s^.strm.position;
   result := s^.strm.position;
 end;
 end;
 
 
-procedure stream_gd_free(ctx: gdIOCtxPtr); GDCALL;
+procedure stream_gd_free(ctx: gdIOCtxPtr); EXTDECL;
 var
 var
   s: stream_gdIOCtxPtr absolute ctx;
   s: stream_gdIOCtxPtr absolute ctx;
 begin
 begin

+ 3 - 3
packages/libxml/examples/io2.pas

@@ -29,9 +29,9 @@ begin
   (*
   (*
    * Create the document.
    * Create the document.
    *)
    *)
-  doc := xmlNewDoc(BAD_CAST('1.0'));
-  n := xmlNewNode(nil, BAD_CAST('root'));
-  xmlNodeSetContent(n, BAD_CAST('content'));
+  doc := xmlNewDoc('1.0');
+  n := xmlNewNode(nil, 'root');
+  xmlNodeSetContent(n, 'content');
   xmlDocSetRootElement(doc, n);
   xmlDocSetRootElement(doc, n);
 
 
   (*
   (*

+ 1 - 1
packages/libxml/examples/reader1.pas

@@ -32,7 +32,7 @@ var
 begin
 begin
   name := xmlTextReaderConstName(reader);
   name := xmlTextReaderConstName(reader);
   if not assigned(name) then
   if not assigned(name) then
-    name := BAD_CAST('--');
+    name := '--';
 
 
   value := xmlTextReaderConstValue(reader);
   value := xmlTextReaderConstValue(reader);
 
 

+ 14 - 14
packages/libxml/examples/tree2.pas

@@ -31,41 +31,41 @@ begin
   (*
   (*
    * Creates a new document, a node and set it as a root node
    * Creates a new document, a node and set it as a root node
    *)
    *)
-  doc := xmlNewDoc(BAD_CAST('1.0'));
-  root_node := xmlNewNode(nil, BAD_CAST('root'));
+  doc := xmlNewDoc('1.0');
+  root_node := xmlNewNode(nil, 'root');
   xmlDocSetRootElement(doc, root_node);
   xmlDocSetRootElement(doc, root_node);
 
 
   (*
   (*
    * Creates a DTD declaration. Isn't mandatory.
    * Creates a DTD declaration. Isn't mandatory.
    *)
    *)
-  dtd := xmlCreateIntSubset(doc, BAD_CAST('root'), nil, BAD_CAST('tree2.dtd'));
+  dtd := xmlCreateIntSubset(doc, 'root', nil, 'tree2.dtd');
 
 
   (*
   (*
    * xmlNewChild() creates a new node, which is "attached" as child node
    * xmlNewChild() creates a new node, which is "attached" as child node
    * of root_node node.
    * of root_node node.
    *)
    *)
-  xmlNewChild(root_node, nil, BAD_CAST('node1'), BAD_CAST('content of node 1'));
+  xmlNewChild(root_node, nil, 'node1', 'content of node 1');
 
 
   (*
   (*
    * The same as above, but the new child node doesn't have a content
    * The same as above, but the new child node doesn't have a content
    *)
    *)
-  xmlNewChild(root_node, nil, BAD_CAST('node2'), nil);
+  xmlNewChild(root_node, nil, 'node2', nil);
 
 
   (*
   (*
    * xmlNewProp() creates attributes, which is "attached" to an node.
    * xmlNewProp() creates attributes, which is "attached" to an node.
    * It returns xmlAttrPtr, which isn't used here.
    * It returns xmlAttrPtr, which isn't used here.
    *)
    *)
-  node := xmlNewChild(root_node, nil, BAD_CAST('node3'), BAD_CAST('this node has attributes'));
-  xmlNewProp(node, BAD_CAST('attribute'), BAD_CAST('yes'));
-  xmlNewProp(node, BAD_CAST('foo'), BAD_CAST('bar'));
+  node := xmlNewChild(root_node, nil, 'node3', 'this node has attributes');
+  xmlNewProp(node, 'attribute', 'yes');
+  xmlNewProp(node, 'foo', 'bar');
 
 
   (*
   (*
    * Here goes another way to create nodes. xmlNewNode() and xmlNewText
    * Here goes another way to create nodes. xmlNewNode() and xmlNewText
    * creates a node and a text node separately. They are "attached"
    * creates a node and a text node separately. They are "attached"
    * by xmlAddChild()
    * by xmlAddChild()
    *)
    *)
-  node := xmlNewNode(nil, BAD_CAST('node4'));
-  node1 := xmlNewText(BAD_CAST('other way to create content (which is also a node)'));
+  node := xmlNewNode(nil, 'node4');
+  node1 := xmlNewText('other way to create content (which is also a node)');
   xmlAddChild(node, node1);
   xmlAddChild(node, node1);
   xmlAddChild(root_node, node);
   xmlAddChild(root_node, node);
 
 
@@ -75,16 +75,16 @@ begin
   for i := 5 to 6 do
   for i := 5 to 6 do
   begin
   begin
     buff := 'node'+inttostr(i);
     buff := 'node'+inttostr(i);
-    node := xmlNewChild(root_node, nil, BAD_CAST(buff), nil);
+    node := xmlNewChild(root_node, nil, buff, nil);
 
 
     for j := 1 to 3 do
     for j := 1 to 3 do
     begin
     begin
       buff := 'node'+inttostr(i)+inttostr(j);
       buff := 'node'+inttostr(i)+inttostr(j);
-      node1 := xmlNewChild(node, nil, BAD_CAST(buff), nil);
+      node1 := xmlNewChild(node, nil, buff, nil);
       if j mod 2 = 0 then
       if j mod 2 = 0 then
-        xmlNewProp(node1, BAD_CAST('odd'), BAD_CAST('no'))
+        xmlNewProp(node1, 'odd', 'no')
       else
       else
-        xmlNewProp(node1, BAD_CAST('odd'), BAD_CAST('yes'));
+        xmlNewProp(node1, 'odd', 'yes');
     end;
     end;
   end;
   end;
 
 

+ 3 - 2
packages/libxml/src/xmlxsd.pas

@@ -630,8 +630,6 @@ begin
     Inc(P);
     Inc(P);
   end;
   end;
   Value := Int;
   Value := Int;
-  if N then
-    Value := -Value;
 
 
   { allow '.' }
   { allow '.' }
   if (P < L) and (P^ = '.') then
   if (P < L) and (P^ = '.') then
@@ -672,6 +670,9 @@ begin
     end;
     end;
   end;
   end;
 
 
+  if N then
+    Value := -Value;
+
   Result := True;
   Result := True;
 end;
 end;
 
 

+ 2 - 0
rtl/objpas/classes/classesh.inc

@@ -1137,6 +1137,7 @@ type
     function ReadIdent: string;
     function ReadIdent: string;
     function ReadInteger: Longint;
     function ReadInteger: Longint;
     function ReadInt64: Int64;
     function ReadInt64: Int64;
+    function ReadSet(EnumType: Pointer): Integer; 
     procedure ReadListBegin;
     procedure ReadListBegin;
     procedure ReadListEnd;
     procedure ReadListEnd;
     function ReadRootComponent(ARoot: TComponent): TComponent;
     function ReadRootComponent(ARoot: TComponent): TComponent;
@@ -1315,6 +1316,7 @@ type
     procedure WriteIdent(const Ident: string);
     procedure WriteIdent(const Ident: string);
     procedure WriteInteger(Value: Longint); overload;
     procedure WriteInteger(Value: Longint); overload;
     procedure WriteInteger(Value: Int64); overload;
     procedure WriteInteger(Value: Int64); overload;
+    procedure WriteSet(Value: LongInt; SetType: Pointer); 
     procedure WriteListBegin;
     procedure WriteListBegin;
     procedure WriteListEnd;
     procedure WriteListEnd;
     procedure WriteRootComponent(ARoot: TComponent);
     procedure WriteRootComponent(ARoot: TComponent);

+ 11 - 0
rtl/objpas/classes/reader.inc

@@ -1065,6 +1065,17 @@ begin
     Result := ReadInteger;
     Result := ReadInteger;
 end;
 end;
 
 
+function TReader.ReadSet(EnumType: Pointer): Integer; 
+begin
+  if FDriver.NextValue = vaSet then
+    begin
+      FDriver.ReadValue;
+      Result := FDriver.ReadSet(enumtype);
+    end 
+  else
+    Result := ReadInteger;
+end;
+
 procedure TReader.ReadListBegin;
 procedure TReader.ReadListBegin;
 begin
 begin
   CheckValue(vaList);
   CheckValue(vaList);

+ 6 - 0
rtl/objpas/classes/writer.inc

@@ -804,6 +804,12 @@ begin
   Driver.WriteInteger(Value);
   Driver.WriteInteger(Value);
 end;
 end;
 
 
+procedure TWriter.WriteSet(Value: LongInt; SetType: Pointer); 
+
+begin
+  Driver.WriteSet(Value,SetType);
+end;
+
 procedure TWriter.WriteVariant(const VarValue: Variant);
 procedure TWriter.WriteVariant(const VarValue: Variant);
 begin
 begin
   Driver.WriteVariant(VarValue);
   Driver.WriteVariant(VarValue);

+ 1 - 1
rtl/objpas/dateutil.inc

@@ -1410,7 +1410,7 @@ end;
     Increment/decrement functions.
     Increment/decrement functions.
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
 
 
-Procedure MaybeSkipTimeWarp(OldDate: TDateTime; out NewDate: TDateTime);
+Procedure MaybeSkipTimeWarp(OldDate: TDateTime; var NewDate: TDateTime);
 begin
 begin
   if (OldDate>0) and (NewDate<0) then
   if (OldDate>0) and (NewDate<0) then
     NewDate:=NewDate-0.5
     NewDate:=NewDate-0.5

+ 251 - 194
rtl/objpas/sysutils/dati.inc

@@ -305,23 +305,38 @@ end;
 
 
 function DateToStr(Date: TDateTime): string;
 function DateToStr(Date: TDateTime): string;
 begin
 begin
-  result := FormatDateTime('ddddd', Date);
+  DateTimeToString(Result, 'ddddd', Date);
 end ;
 end ;
 
 
+function DateToStr(Date: TDateTime; const FormatSettings: TFormatSettings): string;
+begin
+  DateTimeToString(result, FormatSettings.ShortDateFormat, Date, FormatSettings);
+end;
+
 {  TimeToStr returns a string representation of Time using LongTimeFormat   }
 {  TimeToStr returns a string representation of Time using LongTimeFormat   }
 
 
 function TimeToStr(Time: TDateTime): string;
 function TimeToStr(Time: TDateTime): string;
 begin
 begin
-  result := FormatDateTime('tt', Time);
+  DateTimeToString(Result, 'tt', Time);
 end ;
 end ;
 
 
+function TimeToStr(Time: TDateTime; const FormatSettings: TFormatSettings): string;
+begin
+  DateTimeToString(Result, FormatSettings.LongTimeFormat, Time, FormatSettings);
+end;
+
 {   DateTimeToStr returns a string representation of DateTime using LongDateTimeFormat   }
 {   DateTimeToStr returns a string representation of DateTime using LongDateTimeFormat   }
 
 
 function DateTimeToStr(DateTime: TDateTime): string;
 function DateTimeToStr(DateTime: TDateTime): string;
 begin
 begin
-  result := FormatDateTime('c', DateTime);
+  DateTimeToString(Result, 'c', DateTime);
 end ;
 end ;
 
 
+function DateTimeToStr(DateTime: TDateTime; const FormatSettings: TFormatSettings): string;
+begin
+  DateTimeToString(Result, 'c', DateTime ,FormatSettings);
+end;
+
 {   StrToDate converts the string S to a TDateTime value
 {   StrToDate converts the string S to a TDateTime value
     if S does not represent a valid date value
     if S does not represent a valid date value
     an EConvertError will be raised   }
     an EConvertError will be raised   }
@@ -469,7 +484,8 @@ begin
     if (defs.TwoDigitYearCenturyWindow > 0) and (Y < ly) then
     if (defs.TwoDigitYearCenturyWindow > 0) and (Y < ly) then
       Inc(Y, 100);
       Inc(Y, 100);
     end;
     end;
-  Result := EncodeDate(y, m, d);
+  if not TryEncodeDate(y, m, d, result) then
+    errormsg:='Invalid date';
 end;
 end;
 
 
 function StrToDate(const S: PChar; Len : integer; const useformat : string; separator : char = #0): TDateTime;
 function StrToDate(const S: PChar; Len : integer; const useformat : string; separator : char = #0): TDateTime;
@@ -600,7 +616,9 @@ begin
       if (pm=1) and ((TimeValues[0]=12)) then
       if (pm=1) and ((TimeValues[0]=12)) then
         TimeValues[0]:=0;
         TimeValues[0]:=0;
     end;
     end;
-  result := EncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3]);
+
+  if not TryEncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3],result) Then
+    errormsg:='Invalid time.';
 end ;
 end ;
 
 
 function StrToTime(const S: PChar; Len : integer; separator : char = #0): TDateTime;
 function StrToTime(const S: PChar; Len : integer; separator : char = #0): TDateTime;
@@ -696,221 +714,259 @@ end;
 
 
 {   FormatDateTime formats DateTime to the given format string FormatStr   }
 {   FormatDateTime formats DateTime to the given format string FormatStr   }
 
 
-function FormatDateTime(FormatStr: string; DateTime: TDateTime): string;
+function FormatDateTime(const FormatStr: string; DateTime: TDateTime): string;
+begin
+  DateTimeToString(Result, FormatStr, DateTime, DefaultFormatSettings);
+end;
+
+function FormatDateTime(const FormatStr: string; DateTime: TDateTime; const FormatSettings: TFormatSettings): string;
+begin
+  DateTimeToString(Result, FormatStr, DateTime, FormatSettings);
+end;
+
+{   DateTimeToString formats DateTime to the given format in FormatStr   }
+
+procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime);
+begin
+  DateTimeToString(Result, FormatStr, DateTime, DefaultFormatSettings);
+end;
+
+procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime; const FormatSettings: TFormatSettings);
 var
 var
-   ResultLen: integer;
-   ResultBuffer: array[0..255] of char;
-   ResultCurrent: pchar;
+  ResultLen: integer;
+  ResultBuffer: array[0..255] of char;
+  ResultCurrent: pchar;
 
 
-   procedure StoreStr(Str: pchar; Len: integer);
-   begin
-   if ResultLen + Len < SizeOf(ResultBuffer) then begin
+  procedure StoreStr(Str: PChar; Len: Integer);
+  begin
+    if ResultLen + Len < SizeOf(ResultBuffer) then
+    begin
       StrMove(ResultCurrent, Str, Len);
       StrMove(ResultCurrent, Str, Len);
       ResultCurrent := ResultCurrent + Len;
       ResultCurrent := ResultCurrent + Len;
       ResultLen := ResultLen + Len;
       ResultLen := ResultLen + Len;
-      end ;
-   end ;
+    end;
+  end;
 
 
-   procedure StoreString(const Str: string);
-   var Len: integer;
-   begin
+  procedure StoreString(const Str: string);
+  var Len: integer;
+  begin
    Len := Length(Str);
    Len := Length(Str);
-   if ResultLen + Len < SizeOf(ResultBuffer) then begin // strmove not safe
-      StrMove(ResultCurrent, pchar(Str), Len);
-      ResultCurrent := ResultCurrent + Len;
-      ResultLen := ResultLen + Len;
-      end;
-   end;
+   if ResultLen + Len < SizeOf(ResultBuffer) then 
+     begin
+       StrMove(ResultCurrent, pchar(Str), Len);
+       ResultCurrent := ResultCurrent + Len;
+       ResultLen := ResultLen + Len;
+     end;
+  end;
 
 
-   procedure StoreInt(Value, Digits: integer);
-   var S: string; Len: integer;
-   begin
-   S := IntToStr(Value);
-   Len := Length(S);
-   if Len < Digits then begin
-      S := copy('0000', 1, Digits - Len) + S;
-      Len := Digits;
-      end ;
-   StoreStr(pchar(@S[1]), Len);
-   end ;
+  procedure StoreInt(Value, Digits: Integer);
+  var
+    S: string[16];
+    Len: integer;
+  begin
+    System.Str(Value:Digits, S);
+    for Len := 1 to Length(S) do
+    begin
+      if S[Len] = ' ' then
+        S[Len] := '0'
+      else
+        Break;
+    end;
+    StoreStr(pchar(@S[1]), Length(S));
+  end ;
 
 
 var
 var
-   Year, Month, Day, DayOfWeek, Hour, Minute, Second, MilliSecond: word;
+  Year, Month, Day, DayOfWeek, Hour, Minute, Second, MilliSecond: word;
+
+  procedure StoreFormat(const FormatStr: string; Nesting: Integer; TimeFlag: Boolean);
+  var
+    Token, lastformattoken: char;
+    FormatCurrent: pchar;
+    FormatEnd: pchar;
+    Count: integer;
+    Clock12: boolean;
+    P: pchar;
+    tmp: integer;
 
 
-   procedure StoreFormat(const FormatStr: string);
-   var
-      Token,lastformattoken: char;
-      FormatCurrent: pchar;
-      FormatEnd: pchar;
-      Count: integer;
-      Clock12: boolean;
-      P: pchar;
-      tmp:integer;
-
-   begin
-   FormatCurrent := Pchar(pointer(FormatStr));
-   FormatEnd := FormatCurrent + Length(FormatStr);
-   Clock12 := false;
-   P := FormatCurrent;
-   while P < FormatEnd do begin
-      Token := UpCase(P^);
-      if Token in ['"', ''''] then begin
-         P := P + 1;
-         while (P < FormatEnd) and (P^ <> Token) do
-            P := P + 1;
-         end
-      else if Token = 'A' then begin
-         if (StrLIComp(P, 'A/P', 3) = 0) or
-            (StrLIComp(P, 'AMPM', 4) = 0) or
-            (StrLIComp(P, 'AM/PM', 5) = 0) then begin
+  begin
+    if Nesting > 1 then  // 0 is original string, 1 is included FormatString
+      Exit;
+    FormatCurrent := PChar(FormatStr);
+    FormatEnd := FormatCurrent + Length(FormatStr);
+    Clock12 := false;
+    P := FormatCurrent;
+    // look for unquoted 12-hour clock token
+    while P < FormatEnd do
+    begin
+      Token := P^;
+      case Token of
+        '''', '"':
+        begin
+          Inc(P);
+          while (P < FormatEnd) and (P^ <> Token) do
+            Inc(P);
+        end;
+        'A', 'a':
+        begin
+          if (StrLIComp(P, 'A/P', 3) = 0) or
+             (StrLIComp(P, 'AMPM', 4) = 0) or
+             (StrLIComp(P, 'AM/PM', 5) = 0) then
+          begin
             Clock12 := true;
             Clock12 := true;
             break;
             break;
-            end ;
-         end ;
-      P := P + 1;
-      end ;
-   token:=#255;
-   lastformattoken:=' ';
-   while FormatCurrent < FormatEnd do
-     begin
+          end;
+        end;
+      end;  // case
+      Inc(P);
+    end ;
+    token := #255;
+    lastformattoken := ' ';
+    while FormatCurrent < FormatEnd do
+    begin
       Token := UpCase(FormatCurrent^);
       Token := UpCase(FormatCurrent^);
       Count := 1;
       Count := 1;
       P := FormatCurrent + 1;
       P := FormatCurrent + 1;
-         case Token of
-            '''', '"': begin
-               while (P < FormatEnd) and (p^ <> Token) do
-                  P := P + 1;
-               P := P + 1;
-               Count := P - FormatCurrent;
-               StoreStr(FormatCurrent + 1, Count - 2);
-               end ;
-            'A': begin
-               if StrLIComp(FormatCurrent, 'AMPM', 4) = 0 then begin
-                  Count := 4;
-                  if Hour < 12 then StoreString(TimeAMString)
-                  else StoreString(TimePMString);
-                  end
-               else if StrLIComp(FormatCurrent, 'AM/PM', 5) = 0 then begin
-                  Count := 5;
-                  if Hour < 12 then StoreStr('am', 2)
-                  else StoreStr('pm', 2);
-                  end
-               else if StrLIComp(FormatCurrent, 'A/P', 3) = 0 then begin
-                  Count := 3;
-                  if Hour < 12 then StoreStr('a', 1)
-                  else StoreStr('p', 1);
-                  end
-               else
-                 Raise EConvertError.Create('Illegal character in format string');
-               end ;
-            '/': StoreStr(@DateSeparator, 1);
-            ':': StoreStr(@TimeSeparator, 1);
-            ' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y','Z' :
+      case Token of
+        '''', '"':
+        begin
+          while (P < FormatEnd) and (p^ <> Token) do
+            Inc(P);
+          Inc(P);
+          Count := P - FormatCurrent;
+          StoreStr(FormatCurrent + 1, Count - 2);
+        end ;
+        'A':
+        begin
+          if StrLIComp(FormatCurrent, 'AMPM', 4) = 0 then
+          begin
+            Count := 4;
+            if Hour < 12 then
+              StoreString(FormatSettings.TimeAMString)
+            else
+              StoreString(FormatSettings.TimePMString);
+          end
+          else if StrLIComp(FormatCurrent, 'AM/PM', 5) = 0 then
+          begin
+            Count := 5;
+            if Hour < 12 then StoreStr(FormatCurrent, 2)
+                         else StoreStr(FormatCurrent+3, 2);
+          end
+          else if StrLIComp(FormatCurrent, 'A/P', 3) = 0 then
+          begin
+            Count := 3;
+            if Hour < 12 then StoreStr(FormatCurrent, 1)
+                         else StoreStr(FormatCurrent+2, 1);
+          end
+          else
+            raise EConvertError.Create('Illegal character in format string');
+        end ;
+        '/': StoreStr(@FormatSettings.DateSeparator, 1);
+        ':': StoreStr(@FormatSettings.TimeSeparator, 1);
+        ' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y','Z' :
+        begin
+          while (P < FormatEnd) and (UpCase(P^) = Token) do
+            Inc(P);
+          Count := P - FormatCurrent;
+          case Token of
+            ' ': StoreStr(FormatCurrent, Count);
+            'Y': begin
+              if Count > 2 then
+                StoreInt(Year, 4)
+              else
+                StoreInt(Year mod 100, 2);
+            end;
+            'M': begin
+              if (lastformattoken = 'H') or TimeFlag then
               begin
               begin
-                while (P < FormatEnd) and (UpCase(P^) = Token) do
-                  P := P + 1;
-                Count := P - FormatCurrent;
-                case Token of
-                   ' ': StoreStr(FormatCurrent, Count);
-                   'Y': begin
-                         if Count>2 then
-                           StoreInt(Year, 4)
-                         else
-                           StoreInt(Year mod 100, 2);
-                        end;
-                   'M': begin
-                         if lastformattoken='H' then
-                           begin
-                             if Count = 1 then
-                               StoreInt(Minute, 0)
-                             else
-                               StoreInt(Minute, 2);
-
-                           end
-                         else
-                           begin
-                             case Count of
-                                1: StoreInt(Month, 0);
-                                2: StoreInt(Month, 2);
-                                3: StoreString(ShortMonthNames[Month]);
-                                4: StoreString(LongMonthNames[Month]);
-                             end;
-                           end;
-                      end;
-                   'D': begin
-                         case Count of
-                            1: StoreInt(Day, 0);
-                            2: StoreInt(Day, 2);
-                            3: StoreString(ShortDayNames[DayOfWeek]);
-                            4: StoreString(LongDayNames[DayOfWeek]);
-                            5: StoreFormat(ShortDateFormat);
-                            6: StoreFormat(LongDateFormat);
-                         end ;
-                      end ;
-                   'H': begin
-                      if Clock12 then begin
-                         tmp:=hour mod 12;
-                         if tmp=0 then tmp:=12;
-                         if Count = 1 then StoreInt(tmp, 0)
-                         else StoreInt(tmp, 2);
-                         end
-                      else begin
-                         if Count = 1 then StoreInt(Hour, 0)
-                         else StoreInt(Hour, 2);
-                         end ;
-                      end ;
-                   'N': begin
-                      if Count = 1 then StoreInt(Minute, 0)
-                      else StoreInt(Minute, 2);
-                      end ;
-                   'S': begin
-                      if Count = 1 then StoreInt(Second, 0)
-                      else StoreInt(Second, 2);
-                      end ;
-                   'Z': begin
-                      if Count = 1 then StoreInt(MilliSecond, 0)
-                      else StoreInt(MilliSecond, 3);
-                      end ;
-                   'T': begin
-                      if Count = 1 then StoreFormat(ShortTimeFormat)
-                      else StoreFormat(LongTimeFormat);
-                      end ;
-                   'C':
-                     begin
-                       StoreFormat(ShortDateFormat);
-                       if (Hour<>0) or (Minute<>0) or (Second<>0) then
-                        begin
-                          StoreString(' ');
-                          StoreFormat(LongTimeFormat);
-                        end;
-                     end;
+                if Count = 1 then
+                  StoreInt(Minute, 0)
+                else
+                  StoreInt(Minute, 2);
+              end
+              else
+              begin
+                case Count of
+                  1: StoreInt(Month, 0);
+                  2: StoreInt(Month, 2);
+                  3: StoreString(FormatSettings.ShortMonthNames[Month]);
+                else  
+                  StoreString(FormatSettings.LongMonthNames[Month]);
                 end;
                 end;
-                lastformattoken:=token;
               end;
               end;
-            else
-              StoreStr(@Token, 1);
-         end ;
-      FormatCurrent := FormatCurrent + Count;
+            end;
+            'D': begin
+              case Count of
+                1: StoreInt(Day, 0);
+                2: StoreInt(Day, 2);
+                3: StoreString(FormatSettings.ShortDayNames[DayOfWeek]);
+                4: StoreString(FormatSettings.LongDayNames[DayOfWeek]);
+                5: StoreFormat(FormatSettings.ShortDateFormat, Nesting+1, False);
+              else  
+                StoreFormat(FormatSettings.LongDateFormat, Nesting+1, False);
+              end ;
+            end ;
+            'H': if Clock12 then
+              begin
+                tmp := hour mod 12;
+                if tmp=0 then tmp:=12;
+                if Count = 1 then 
+                  StoreInt(tmp, 0)
+                else 
+                  StoreInt(tmp, 2);
+              end
+              else begin
+                if Count = 1 then 
+		  StoreInt(Hour, 0)
+                else 
+                  StoreInt(Hour, 2);
+              end;
+            'N': if Count = 1 then 
+                   StoreInt(Minute, 0)
+                 else 
+                   StoreInt(Minute, 2);
+            'S': if Count = 1 then 
+                   StoreInt(Second, 0)
+                 else 
+                   StoreInt(Second, 2);
+            'Z': if Count = 1 then 
+                   StoreInt(MilliSecond, 0)
+                 else 
+		   StoreInt(MilliSecond, 3);
+            'T': if Count = 1 then 
+		   StoreFormat(FormatSettings.ShortTimeFormat, Nesting+1, True)
+                 else 
+	           StoreFormat(FormatSettings.LongTimeFormat, Nesting+1, True);
+            'C': begin
+                   StoreFormat(FormatSettings.ShortDateFormat, Nesting+1, False);
+                   if (Hour<>0) or (Minute<>0) or (Second<>0) then
+                     begin
+                      StoreString(' ');
+                      StoreFormat(FormatSettings.LongTimeFormat, Nesting+1, True);
+                 end;
+            end;
+          end;
+          lastformattoken := token;
+        end;
+        else
+          StoreStr(@Token, 1);
       end ;
       end ;
-   end ;
+      Inc(FormatCurrent, Count);
+    end;
+  end;
 
 
 begin
 begin
   DecodeDateFully(DateTime, Year, Month, Day, DayOfWeek);
   DecodeDateFully(DateTime, Year, Month, Day, DayOfWeek);
   DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);
   DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);
   ResultLen := 0;
   ResultLen := 0;
   ResultCurrent := @ResultBuffer[0];
   ResultCurrent := @ResultBuffer[0];
-  StoreFormat(FormatStr);
+  if FormatStr <> '' then
+    StoreFormat(FormatStr, 0, False)
+  else
+    StoreFormat('C', 0, False);  
   ResultBuffer[ResultLen] := #0;
   ResultBuffer[ResultLen] := #0;
   result := StrPas(@ResultBuffer[0]);
   result := StrPas(@ResultBuffer[0]);
 end ;
 end ;
 
 
-{   DateTimeToString formats DateTime to the given format in FormatStr   }
-
-procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime);
-begin
-  Result := FormatDateTime(FormatStr, DateTime);
-end ;
-
 
 
 Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
 Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
 
 
@@ -932,11 +988,12 @@ begin
 {$endif unix}
 {$endif unix}
 end;
 end;
 
 
-function CurrentYear:Word;
-var yy,mm,dd : word;
+function CurrentYear: Word;
+var
+  SysTime: TSystemTime;
 begin
 begin
-  Decodedate(now,yy,mm,dd);
-  Result:=yy;
+  GetLocalTime(SysTime);
+  Result := SysTime.Year;
 end;
 end;
 
 
 Function FileDateToDateTime (Filedate : Longint) : TDateTime;
 Function FileDateToDateTime (Filedate : Longint) : TDateTime;

+ 6 - 1
rtl/objpas/sysutils/datih.inc

@@ -122,8 +122,11 @@ function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer = 1 ): TDat
 procedure IncAMonth(var Year, Month, Day: Word; NumberOfMonths: Integer = 1);
 procedure IncAMonth(var Year, Month, Day: Word; NumberOfMonths: Integer = 1);
 function IsLeapYear(Year: Word): boolean;
 function IsLeapYear(Year: Word): boolean;
 function DateToStr(Date: TDateTime): string;
 function DateToStr(Date: TDateTime): string;
+function DateToStr(Date: TDateTime; const FormatSettings: TFormatSettings): string;
 function TimeToStr(Time: TDateTime): string;
 function TimeToStr(Time: TDateTime): string;
+function TimeToStr(Time: TDateTime; const FormatSettings: TFormatSettings): string;
 function DateTimeToStr(DateTime: TDateTime): string;
 function DateTimeToStr(DateTime: TDateTime): string;
+function DateTimeToStr(DateTime: TDateTime; const FormatSettings: TFormatSettings): string;
 function StrToDate(const S: ShortString): TDateTime;                  {$ifdef SYSUTILSINLINE}inline;{$endif}
 function StrToDate(const S: ShortString): TDateTime;                  {$ifdef SYSUTILSINLINE}inline;{$endif}
 function StrToDate(const S: Ansistring): TDateTime;                   {$ifdef SYSUTILSINLINE}inline;{$endif}
 function StrToDate(const S: Ansistring): TDateTime;                   {$ifdef SYSUTILSINLINE}inline;{$endif}
 function StrToDate(const S: ShortString; separator : char): TDateTime;{$ifdef SYSUTILSINLINE}inline;{$endif}
 function StrToDate(const S: ShortString; separator : char): TDateTime;{$ifdef SYSUTILSINLINE}inline;{$endif}
@@ -139,8 +142,10 @@ function StrToDate(const S: PChar; Len : integer; const useformat : string; sepa
 function StrToDateTime(const S: string): TDateTime;
 function StrToDateTime(const S: string): TDateTime;
 function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings): TDateTime;
 function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings): TDateTime;
 function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime;
 function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings): TDateTime;
-function FormatDateTime(FormatStr: string; DateTime: TDateTime):string;
+function FormatDateTime(const FormatStr: string; DateTime: TDateTime):string;
+function FormatDateTime(const FormatStr: string; DateTime: TDateTime; const FormatSettings: TFormatSettings): string;
 procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime);
 procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime);
+procedure DateTimeToString(out Result: string; const FormatStr: string; const DateTime: TDateTime; const FormatSettings: TFormatSettings);
 Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
 Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
 Function FileDateToDateTime (Filedate : Longint) :TDateTime;
 Function FileDateToDateTime (Filedate : Longint) :TDateTime;
 function TryStrToDate(const S: ShortString; out Value: TDateTime): Boolean;                         {$ifdef SYSUTILSINLINE}inline;{$endif}
 function TryStrToDate(const S: ShortString; out Value: TDateTime): Boolean;                         {$ifdef SYSUTILSINLINE}inline;{$endif}

+ 25 - 0
rtl/objpas/sysutils/sysstr.inc

@@ -1691,6 +1691,13 @@ begin
   Result:=FloatToStrF(Value,ffGeneral,-1,0);
   Result:=FloatToStrF(Value,ffGeneral,-1,0);
 end;
 end;
 
 
+
+Function CurrToStr(Value: Currency; Const FormatSettings: TFormatSettings): string;
+begin
+  Result:=FloatToStrF(Value,ffGeneral,-1,0,FormatSettings);
+end;  
+
+
 function StrToCurr(const S: string): Currency;
 function StrToCurr(const S: string): Currency;
 begin
 begin
   if not TextToFloat(PChar(pointer(S)), Result, fvCurrency) then
   if not TextToFloat(PChar(pointer(S)), Result, fvCurrency) then
@@ -1698,18 +1705,36 @@ begin
 end;
 end;
 
 
 
 
+function StrToCurr(const S: string; Const FormatSettings: TFormatSettings): Currency; 
+begin
+  if not TextToFloat(PChar(pointer(S)), Result, fvCurrency,FormatSettings) then
+    Raise EConvertError.createfmt(SInValidFLoat,[S]);
+end;
+
+
 Function TryStrToCurr(Const S : String; Out Value: Currency): Boolean;
 Function TryStrToCurr(Const S : String; Out Value: Currency): Boolean;
 Begin
 Begin
   Result := TextToFloat(PChar(pointer(S)), Value, fvCurrency);
   Result := TextToFloat(PChar(pointer(S)), Value, fvCurrency);
 End;
 End;
 
 
 
 
+function TryStrToCurr(const S: string;Out Value : Currency; Const FormatSettings: TFormatSettings): Boolean;       
+Begin
+  Result := TextToFloat(PChar(pointer(S)), Value, fvCurrency,FormatSettings);
+End;  
+
+
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 begin
 begin
   if not TextToFloat(PChar(pointer(S)), Result, fvCurrency) then
   if not TextToFloat(PChar(pointer(S)), Result, fvCurrency) then
     Result:=Default;
     Result:=Default;
 end;
 end;
 
 
+function StrToCurrDef(const S: string; Default : Currency; Const FormatSettings: TFormatSettings): Currency;  
+begin
+  if not TextToFloat(PChar(pointer(S)), Result, fvCurrency,FormatSettings) then
+    Result:=Default;
+end; 
 {$endif FPUNONE}
 {$endif FPUNONE}
 
 
 function AnsiDequotedStr(const S: string; AQuote: Char): string;
 function AnsiDequotedStr(const S: string; AQuote: Char): string;

+ 4 - 0
rtl/objpas/sysutils/sysstrh.inc

@@ -195,9 +195,13 @@ Function FloattoCurr (Const Value : Extended) : Currency;
 function TryFloatToCurr(const Value: Extended; var AResult: Currency): Boolean;
 function TryFloatToCurr(const Value: Extended; var AResult: Currency): Boolean;
 
 
 Function CurrToStr(Value: Currency): string;
 Function CurrToStr(Value: Currency): string;
+Function CurrToStr(Value: Currency; Const FormatSettings: TFormatSettings): string;
 function StrToCurr(const S: string): Currency;
 function StrToCurr(const S: string): Currency;
+function StrToCurr(const S: string; Const FormatSettings: TFormatSettings): Currency;  
 function TryStrToCurr(const S: string;Out Value : Currency): Boolean;
 function TryStrToCurr(const S: string;Out Value : Currency): Boolean;
+function TryStrToCurr(const S: string;Out Value : Currency; Const FormatSettings: TFormatSettings): Boolean;       
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 function StrToCurrDef(const S: string; Default : Currency): Currency;
+function StrToCurrDef(const S: string; Default : Currency; Const FormatSettings: TFormatSettings): Currency;  
 
 
 Function FloatToTextFmt(Buffer: PChar; Value: Extended; format: PChar; FormatSettings : TFormatSettings): Integer;
 Function FloatToTextFmt(Buffer: PChar; Value: Extended; format: PChar; FormatSettings : TFormatSettings): Integer;
 Function FloatToTextFmt(Buffer: PChar; Value: Extended; format: PChar): Integer;
 Function FloatToTextFmt(Buffer: PChar; Value: Extended; format: PChar): Integer;

+ 9 - 7
rtl/objpas/types.pp

@@ -134,9 +134,6 @@ type
 const
 const
   GUID_NULL: TGUID  = '{00000000-0000-0000-0000-000000000000}';
   GUID_NULL: TGUID  = '{00000000-0000-0000-0000-000000000000}';
 
 
-{$ifndef Wince}
-  // in Wince these are in unit windows. Under 32/64 in ActiveX.
-  // for now duplicate them. Not that bad for untyped constants.
   STGTY_STORAGE   = 1;
   STGTY_STORAGE   = 1;
   STGTY_STREAM    = 2;
   STGTY_STREAM    = 2;
   STGTY_LOCKBYTES = 3;
   STGTY_LOCKBYTES = 3;
@@ -150,6 +147,14 @@ const
   LOCK_EXCLUSIVE = 2;
   LOCK_EXCLUSIVE = 2;
   LOCK_ONLYONCE  = 4;
   LOCK_ONLYONCE  = 4;
 
 
+  STATFLAG_DEFAULT   	      = 0;
+  STATFLAG_NONAME    	      = 1;
+  STATFLAG_NOOPEN    	      = 2; 
+
+{$ifndef Wince}
+  // in Wince these are in unit windows. Under 32/64 in ActiveX.
+  // for now duplicate them. Not that bad for untyped constants.
+
   E_FAIL 		      = HRESULT($80004005);
   E_FAIL 		      = HRESULT($80004005);
   E_INVALIDARG                = HRESULT($80070057);
   E_INVALIDARG                = HRESULT($80070057);
 
 
@@ -195,11 +200,8 @@ const
   STG_S_BLOCK                 = $00030201;
   STG_S_BLOCK                 = $00030201;
   STG_S_RETRYNOW              = $00030202;
   STG_S_RETRYNOW              = $00030202;
   STG_S_MONITORING            = $00030203;
   STG_S_MONITORING            = $00030203;
-
-  STATFLAG_DEFAULT   	      = 0;
-  STATFLAG_NONAME    	      = 1;
-  STATFLAG_NOOPEN    	      = 2; 
 {$endif}
 {$endif}
+
 {$ifndef Windows}
 {$ifndef Windows}
 type
 type
   PCLSID = PGUID;
   PCLSID = PGUID;

+ 2 - 1
rtl/win/syswin.inc

@@ -62,7 +62,7 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
        DLL_THREAD_ATTACH :
        DLL_THREAD_ATTACH :
          begin
          begin
            inclocked(Thread_count);
            inclocked(Thread_count);
-           
+
            WinEnterCriticalSection(AttachingThread);
            WinEnterCriticalSection(AttachingThread);
            if (Win32GetCurrentThreadId <> MainThreadIdWin32) then
            if (Win32GetCurrentThreadId <> MainThreadIdWin32) then
            begin
            begin
@@ -97,6 +97,7 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
            if assigned(Dll_Process_Detach_Hook) then
            if assigned(Dll_Process_Detach_Hook) then
              Dll_Process_Detach_Hook(DllParam);
              Dll_Process_Detach_Hook(DllParam);
 
 
+           DoneThread;
            { Free TLS resources used by ThreadVars }
            { Free TLS resources used by ThreadVars }
            SysFiniMultiThreading;
            SysFiniMultiThreading;
            WinDoneCriticalSection(AttachingThread);
            WinDoneCriticalSection(AttachingThread);

+ 2 - 2
rtl/wince/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/08/02]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/10/30]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@@ -2274,7 +2274,7 @@ messages$(PPUEXT): messages.pp $(WININC)/messages.inc windows$(PPUEXT) $(SYSTEMU
 winsock$(PPUEXT) : winsock.pp windows$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 winsock$(PPUEXT) : winsock.pp windows$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 sockets$(PPUEXT) : sockets.pp windows$(PPUEXT) winsock$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
 sockets$(PPUEXT) : sockets.pp windows$(PPUEXT) winsock$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
 		   $(INC)/sockets.inc $(INC)/socketsh.inc
 		   $(INC)/sockets.inc $(INC)/socketsh.inc
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas windows$(PPUEXT)
+dynlibs$(PPUEXT) : $(INC)/dynlibs.pas windows$(PPUEXT) rtlconsts$(PPUEXT) sysconst$(PPUEXT) sysutils$(PPUEXT)
 dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) windows$(PPUEXT)
 dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) windows$(PPUEXT)
 objects$(PPUEXT) : $(INC)/objects.pp $(SYSTEMUNIT)$(PPUEXT)
 objects$(PPUEXT) : $(INC)/objects.pp $(SYSTEMUNIT)$(PPUEXT)
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \

+ 1 - 1
rtl/wince/Makefile.fpc

@@ -131,7 +131,7 @@ sockets$(PPUEXT) : sockets.pp windows$(PPUEXT) winsock$(PPUEXT) $(SYSTEMUNIT)$(P
 
 
 #winmouse$(PPUEXT) : winmouse.pp $(SYSTEMUNIT)$(PPUEXT) windows$(PPUEXT) graph$(PPUEXT)
 #winmouse$(PPUEXT) : winmouse.pp $(SYSTEMUNIT)$(PPUEXT) windows$(PPUEXT) graph$(PPUEXT)
 
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas windows$(PPUEXT)
+dynlibs$(PPUEXT) : $(INC)/dynlibs.pas windows$(PPUEXT) rtlconsts$(PPUEXT) sysconst$(PPUEXT) sysutils$(PPUEXT)
 
 
 #
 #
 # TP7 Compatible RTL Units
 # TP7 Compatible RTL Units

+ 133 - 0
tests/webtbs/tw14798.pp

@@ -0,0 +1,133 @@
+{ Source provided for Free Pascal Bug Report 14708 }
+{ Submitted by "Anton Kavalenka" on  2009-11-11 }
+{ e-mail:  }
+program tw14709;
+
+{$mode delphi}{$H+}
+{$apptype console}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+  cthreads,
+  {$ENDIF}{$ENDIF}
+  Classes,Sysutils
+  { you can add units after this };
+
+var ok : boolean = true;
+
+type
+  TIntComponent=class(TComponent)
+  public
+    procedure DoChange(Sender:TObject);
+  end;
+
+  TTestComponent=class(TComponent)
+  private
+    fButton,
+    fEdit:TIntComponent;
+    fOnChangeButton,fOnChangeEdit:TNotifyEvent;
+    fStr:string;
+  public
+    constructor Create(AnOwner:TComponent);override;
+    procedure GetChildren(Proc: TGetChildProc; Root: TComponent);override;
+    procedure Change;
+  published
+    property Str:string read fStr write fStr;
+    property OnChangeButton:TNotifyEvent read fOnChangeButton write fOnChangeButton;
+    property OnChangeEdit:TNotifyEvent read fOnChangeEdit write fOnChangeEdit;
+  end;
+
+procedure TIntComponent.DoChange(Sender:TObject);
+begin
+  writeln(Self.className+' reports that '+Sender.ClassName+' changed');
+end;
+
+constructor TTestComponent.Create(AnOwner:TComponent);
+begin
+  inherited Create(AnOwner);
+  fStr:='Test string';
+  fButton:=TIntComponent.Create(Self);
+  fOnChangeButton:=fButton.DoChange;
+
+  fEdit:=TIntComponent.Create(Self);
+  fOnChangeEdit:=fEdit.DoChange;
+end;
+
+procedure TTestComponent.GetChildren(Proc: TGetChildProc; Root: TComponent);
+var
+  i:integer;
+begin
+ { for i:=0 to Componentcount-1 do
+  Proc(Components[i]);
+  }
+end;
+
+procedure TTestComponent.Change;
+begin
+  writeln(format('OnChangeButton code=%x data=%x',
+    [ptruint(TMethod(fOnChangeButton).Code),
+     ptruint(TMethod(fOnChangeButton).Data)]));
+  writeln(format('OnChangeEdit code=%x data=%x',
+    [ptruint(TMethod(fOnChangeEdit).Code),
+     ptruint(TMethod(fOnChangeEdit).Data)]));
+
+  if Assigned(OnChangeButton) then
+    OnChangeButton(Self)
+  else
+    begin
+
+      writeln('OnChangeButton handler is clear');
+      ok:=false;
+    end;
+  if Assigned(OnChangeEdit) then
+    OnChangeEdit(Self)
+  else
+    begin
+
+      writeln('OnChangeEdit handler is clear');
+      ok:=false;
+    end;
+end;
+
+var
+  tc:TTestComponent;
+  ms,os,f:TStream;
+begin
+  RegisterClasses([TTestComponent,TIntComponent]);
+  tc:=TTestComponent.Create(nil);
+  writeln('Testing....');
+  tc.Change;
+  ms:=TmemoryStream.Create;
+  ms.WriteComponent(tc);
+  writeln('Cleanup...');
+  tc.free;
+  ms.Position:=0;
+
+  writeln('Dumping streamed object as text:');
+  
+  f:=TFileStream.Create('dump.bin',fmCreate);
+  f.CopyFrom(ms,ms.size);
+  f.free;
+  
+  
+  ms.Position:=0;
+  os:=TMemoryStream.Create;
+  ObjectBinaryToText(ms,os);
+  os.Position:=0;
+  repeat
+    write(char(os.ReadByte));
+  until os.Position>=os.Size;
+  writeln();
+
+  ms.Position:=0;
+  tc:=TTestComponent(ms.ReadComponent(nil));
+  writeln('Just read, testing ...');
+  tc.Change;
+
+  tc.free;
+  ms.free;
+  os.Free;
+  if not ok then 
+    halt(1);
+end.
+

+ 1 - 0
utils/fpdoc/dglobals.pp

@@ -154,6 +154,7 @@ resourcestring
   SDone                       = 'Done.';
   SDone                       = 'Done.';
   SErrCouldNotCreateOutputDir = 'Could not create output directory "%s"';
   SErrCouldNotCreateOutputDir = 'Could not create output directory "%s"';
   SErrCouldNotCreateFile      = 'Could not create file "%s": %s';
   SErrCouldNotCreateFile      = 'Could not create file "%s": %s';
+  SSeeURL                     = '(See %s)';      // For lineair text writers.
 
 
 Const
 Const
   SVisibility: array[TPasMemberVisibility] of string =
   SVisibility: array[TPasMemberVisibility] of string =

+ 12 - 0
utils/fpdoc/dw_html.pp

@@ -149,6 +149,8 @@ type
     procedure DescrWriteVarEl(const AText: DOMString); override;
     procedure DescrWriteVarEl(const AText: DOMString); override;
     procedure DescrBeginLink(const AId: DOMString); override;
     procedure DescrBeginLink(const AId: DOMString); override;
     procedure DescrEndLink; override;
     procedure DescrEndLink; override;
+    procedure DescrBeginURL(const AURL: DOMString); override;
+    procedure DescrEndURL; override;
     procedure DescrWriteLinebreak; override;
     procedure DescrWriteLinebreak; override;
     procedure DescrBeginParagraph; override;
     procedure DescrBeginParagraph; override;
     procedure DescrEndParagraph; override;
     procedure DescrEndParagraph; override;
@@ -1088,6 +1090,16 @@ begin
   PopOutputNode;
   PopOutputNode;
 end;
 end;
 
 
+procedure THTMLWriter.DescrBeginURL(const AURL: DOMString);
+begin
+  PushOutputNode(CreateLink(CurOutputNode, AURL));
+end;
+
+procedure THTMLWriter.DescrEndURL;
+begin
+  PopOutputNode;
+end;
+
 procedure THTMLWriter.DescrWriteLinebreak;
 procedure THTMLWriter.DescrWriteLinebreak;
 begin
 begin
   CreateEl(CurOutputNode, 'br');
   CreateEl(CurOutputNode, 'br');

+ 14 - 0
utils/fpdoc/dw_latex.pp

@@ -92,6 +92,8 @@ Type
     procedure DescrWriteVarEl(const AText: DOMString); override;
     procedure DescrWriteVarEl(const AText: DOMString); override;
     procedure DescrBeginLink(const AId: DOMString); override;
     procedure DescrBeginLink(const AId: DOMString); override;
     procedure DescrEndLink; override;
     procedure DescrEndLink; override;
+    procedure DescrBeginURL(const AURL: DOMString); override; // Provides a default implementation
+    procedure DescrEndURL; override;
     procedure DescrWriteLinebreak; override;
     procedure DescrWriteLinebreak; override;
     procedure DescrBeginParagraph; override;
     procedure DescrBeginParagraph; override;
     procedure DescrBeginCode(HasBorder: Boolean; const AHighlighterName: String); override;
     procedure DescrBeginCode(HasBorder: Boolean; const AHighlighterName: String); override;
@@ -273,6 +275,18 @@ begin
   WriteF(' (\pageref{%s})',[StripText(Flink)]);
   WriteF(' (\pageref{%s})',[StripText(Flink)]);
 end;
 end;
 
 
+procedure TLaTeXWriter.DescrBeginURL(const AURL: DOMString);
+begin
+  Inherited; //  Save link
+  Write('\htmladdnormallink{');
+end;
+
+procedure TLaTeXWriter.DescrEndURL;
+begin
+  WriteF('}{%s}',[LastURL]);
+  LastURL:='';
+end;
+
 procedure TLaTeXWriter.DescrWriteLinebreak;
 procedure TLaTeXWriter.DescrWriteLinebreak;
 begin
 begin
   WriteLn('\\');
   WriteLn('\\');

+ 16 - 1
utils/fpdoc/dwlinear.pp

@@ -15,8 +15,8 @@ Type
     PackageName: String;
     PackageName: String;
     Module: TPasModule;
     Module: TPasModule;
     ModuleName: String;
     ModuleName: String;
+    FLastURL : DomString;
   Protected
   Protected
-
     // Writing support.
     // Writing support.
     procedure Write(const s: String); virtual;
     procedure Write(const s: String); virtual;
     procedure WriteLn(const s: String); virtual;
     procedure WriteLn(const s: String); virtual;
@@ -27,6 +27,8 @@ Type
     procedure WriteLabel(El: TPasElement);
     procedure WriteLabel(El: TPasElement);
     procedure WriteIndex(El: TPasElement);
     procedure WriteIndex(El: TPasElement);
     // Auxiliary routines
     // Auxiliary routines
+    procedure DescrBeginURL(const AURL: DOMString); override; // Provides a default implementation
+    procedure DescrEndURL; override;
     procedure SortElementList(List : TList);
     procedure SortElementList(List : TList);
     procedure StartListing(Frames: Boolean);
     procedure StartListing(Frames: Boolean);
     Function  ShowMember(M : TPasElement) : boolean;
     Function  ShowMember(M : TPasElement) : boolean;
@@ -75,6 +77,7 @@ Type
     procedure WriteUnitEntry(UnitRef : TPasType);virtual; Abstract;
     procedure WriteUnitEntry(UnitRef : TPasType);virtual; Abstract;
     procedure EndUnitOverview; virtual; Abstract;
     procedure EndUnitOverview; virtual; Abstract;
     Class Function FileNameExtension : String;virtual; Abstract;
     Class Function FileNameExtension : String;virtual; Abstract;
+    Property LastURL : DomString Read FLastURL Write FLastURL;
   Public
   Public
     Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
     Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
     procedure WriteDoc; override;
     procedure WriteDoc; override;
@@ -196,6 +199,18 @@ begin
   WriteIndex(EL.Name);
   WriteIndex(EL.Name);
 end;
 end;
 
 
+procedure TLinearWriter.DescrBeginURL(const AURL: DOMString);
+begin
+  FLastURL:=AURL;
+end;
+
+procedure TLinearWriter.DescrEndURL;
+begin
+  If (FLastURL<>'') then
+    Writeln(Format(SSeeURL,[EscapeText(FLastURL)]));
+  FLastURL:='';
+end;
+
 procedure TLinearWriter.StartListing(Frames: Boolean);
 procedure TLinearWriter.StartListing(Frames: Boolean);
 begin
 begin
   StartListing(Frames,'');
   StartListing(Frames,'');

+ 18 - 0
utils/fpdoc/dwriter.pp

@@ -71,6 +71,7 @@ type
     FPackage : TPasPackage;
     FPackage : TPasPackage;
     FTopics  : TList;
     FTopics  : TList;
     FImgExt : String;
     FImgExt : String;
+    procedure ConvertURL(AContext: TPasElement; El: TDOMElement);
     
     
   protected
   protected
     procedure Warning(AContext: TPasElement; const AMsg: String);
     procedure Warning(AContext: TPasElement; const AMsg: String);
@@ -111,6 +112,8 @@ type
     procedure DescrWriteVarEl(const AText: DOMString); virtual; abstract;
     procedure DescrWriteVarEl(const AText: DOMString); virtual; abstract;
     procedure DescrBeginLink(const AId: DOMString); virtual; abstract;
     procedure DescrBeginLink(const AId: DOMString); virtual; abstract;
     procedure DescrEndLink; virtual; abstract;
     procedure DescrEndLink; virtual; abstract;
+    procedure DescrBeginURL(const AURL: DOMString); virtual; abstract;
+    procedure DescrEndURL; virtual; abstract;
     procedure DescrWriteLinebreak; virtual; abstract;
     procedure DescrWriteLinebreak; virtual; abstract;
     procedure DescrBeginParagraph; virtual; abstract;
     procedure DescrBeginParagraph; virtual; abstract;
     procedure DescrEndParagraph; virtual; abstract;
     procedure DescrEndParagraph; virtual; abstract;
@@ -428,6 +431,7 @@ begin
     if Node.NodeType = ELEMENT_NODE then
     if Node.NodeType = ELEMENT_NODE then
       if (Node.NodeName <> 'br') and
       if (Node.NodeName <> 'br') and
          (Node.NodeName <> 'link') and
          (Node.NodeName <> 'link') and
+         (Node.NodeName <> 'url') and
          (Node.NodeName <> 'b') and
          (Node.NodeName <> 'b') and
          (Node.NodeName <> 'file') and
          (Node.NodeName <> 'file') and
          (Node.NodeName <> 'i') and
          (Node.NodeName <> 'i') and
@@ -457,6 +461,8 @@ begin
   begin
   begin
     if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link') then
     if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link') then
       ConvertLink(AContext, TDOMElement(Node))
       ConvertLink(AContext, TDOMElement(Node))
+    else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'url') then
+      ConvertURL(AContext, TDOMElement(Node))
     else
     else
       if not ConvertBaseShort(AContext, Node) then
       if not ConvertBaseShort(AContext, Node) then
         exit;
         exit;
@@ -596,6 +602,16 @@ begin
   DescrEndLink;
   DescrEndLink;
 end;
 end;
 
 
+procedure TFPDocWriter.ConvertURL(AContext: TPasElement; El: TDOMElement);
+begin
+  DescrBeginURL(El['href']);
+  if not IsDescrNodeEmpty(El) then
+    ConvertBaseShortList(AContext, El, True)
+  else
+    DescrWriteText(El['href']);
+  DescrEndURL;
+end;
+
 function TFPDocWriter.ConvertExtShort(AContext: TPasElement;
 function TFPDocWriter.ConvertExtShort(AContext: TPasElement;
   Node: TDOMNode): Boolean;
   Node: TDOMNode): Boolean;
 begin
 begin
@@ -605,6 +621,8 @@ begin
   begin
   begin
     if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link') then
     if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link') then
       ConvertLink(AContext, TDOMElement(Node))
       ConvertLink(AContext, TDOMElement(Node))
+    else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'url') then
+      ConvertURL(AContext, TDOMElement(Node))
     else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'br') then
     else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'br') then
       DescrWriteLinebreak
       DescrWriteLinebreak
     else
     else

+ 3 - 3
utils/fpdoc/fpdoc.lpi

@@ -1,18 +1,18 @@
 <?xml version="1.0"?>
 <?xml version="1.0"?>
 <CONFIG>
 <CONFIG>
   <ProjectOptions>
   <ProjectOptions>
-    <PathDelim Value="/"/>
-    <Version Value="6"/>
+    <Version Value="7"/>
     <General>
     <General>
       <Flags>
       <Flags>
+        <SaveClosedFiles Value="False"/>
         <SaveOnlyProjectUnits Value="True"/>
         <SaveOnlyProjectUnits Value="True"/>
         <MainUnitHasUsesSectionForAllUnits Value="False"/>
         <MainUnitHasUsesSectionForAllUnits Value="False"/>
         <MainUnitHasCreateFormStatements Value="False"/>
         <MainUnitHasCreateFormStatements Value="False"/>
         <MainUnitHasTitleStatement Value="False"/>
         <MainUnitHasTitleStatement Value="False"/>
+        <LRSInOutputDirectory Value="False"/>
       </Flags>
       </Flags>
       <SessionStorage Value="InProjectDir"/>
       <SessionStorage Value="InProjectDir"/>
       <MainUnit Value="0"/>
       <MainUnit Value="0"/>
-      <IconPath Value="./"/>
       <TargetFileExt Value=""/>
       <TargetFileExt Value=""/>
     </General>
     </General>
     <VersionInfo>
     <VersionInfo>