Explorar o código

Rebase to revision 17236

git-svn-id: branches/svenbarth/classhelpers@17241 -
svenbarth %!s(int64=14) %!d(string=hai) anos
pai
achega
d0705a1779
Modificáronse 100 ficheiros con 7361 adicións e 1207 borrados
  1. 53 1
      .gitattributes
  2. 1 1
      compiler/aasmbase.pas
  3. 21 8
      compiler/cgobj.pas
  4. 123 0
      compiler/cwindirs.pp
  5. 3 1
      compiler/defcmp.pas
  6. 2 14
      compiler/fmodule.pas
  7. 13 80
      compiler/globals.pas
  8. 3 0
      compiler/link.pas
  9. 1 1
      compiler/msg/errorct.msg
  10. 153 153
      compiler/msg/errord.msg
  11. 1 1
      compiler/msg/errorda.msg
  12. 1 1
      compiler/msg/errordu.msg
  13. 1 1
      compiler/msg/errore.msg
  14. 1 1
      compiler/msg/errores.msg
  15. 1 1
      compiler/msg/errorf.msg
  16. 1 1
      compiler/msg/errorfi.msg
  17. 1 1
      compiler/msg/errorhe.msg
  18. 1 1
      compiler/msg/errorheu.msg
  19. 1 1
      compiler/msg/errorid.msg
  20. 1 1
      compiler/msg/errorn.msg
  21. 1 1
      compiler/msg/errorpl.msg
  22. 1 1
      compiler/msg/errorpli.msg
  23. 1 1
      compiler/msg/errorpt.msg
  24. 1 1
      compiler/msg/errorptu.msg
  25. 1 1
      compiler/msg/errorr.msg
  26. 1 1
      compiler/msg/errorru.msg
  27. 1 1
      compiler/msg/errorues.msg
  28. 1 1
      compiler/msgidx.inc
  29. 68 68
      compiler/msgtxt.inc
  30. 21 1
      compiler/ncal.pas
  31. 10 1
      compiler/ncgcal.pas
  32. 56 141
      compiler/ncgmem.pas
  33. 5 0
      compiler/nset.pas
  34. 7 1
      compiler/ogbase.pas
  35. 1484 0
      compiler/ognlm.pas
  36. 4 2
      compiler/paramgr.pas
  37. 4 3
      compiler/pdecl.pas
  38. 2 1
      compiler/pdecobj.pas
  39. 2 2
      compiler/pdecsub.pas
  40. 6 6
      compiler/pexpr.pas
  41. 65 0
      compiler/procinfo.pas
  42. 6 19
      compiler/psub.pas
  43. 97 48
      compiler/ptype.pas
  44. 1 1
      compiler/regvars.pas
  45. 18 9
      compiler/symdef.pas
  46. 1 0
      compiler/symtable.pas
  47. 7 4
      compiler/symtype.pas
  48. 1 0
      compiler/systems.pas
  49. 5 5
      compiler/systems/i_nwm.pas
  50. 384 1
      compiler/systems/t_nwm.pas
  51. 27 521
      compiler/utils/samplecfg
  52. 45 10
      packages/cdrom/src/cdromlin.inc
  53. 64 0
      packages/cdrom/src/lincd.pp
  54. 2 1
      packages/cocoaint/utils/uikit-skel/src/uikit/UIKit.inc
  55. 11 2
      packages/fcl-base/src/eventlog.pp
  56. 5 1
      packages/fcl-base/src/inifiles.pp
  57. 14 11
      packages/fcl-db/src/base/fields.inc
  58. 1 0
      packages/fcl-db/src/sqldb/mysql/mysql50conn.pas
  59. 2 0
      packages/fcl-db/src/sqldb/mysql/mysql51conn.pas
  60. 3 7
      packages/fcl-db/src/sqldb/mysql/mysqlconn.inc
  61. 1 1
      packages/fcl-db/src/sqldb/postgres/pqconnection.pp
  62. 4 6
      packages/fcl-db/tests/sqldbtoolsunit.pas
  63. 10 2
      packages/fcl-db/tests/testfieldtypes.pas
  64. 33 3
      packages/fcl-image/Makefile
  65. 1 0
      packages/fcl-image/Makefile.fpc
  66. 69 0
      packages/fcl-image/src/fpcanvas.inc
  67. 20 1
      packages/fcl-image/src/fpcanvas.pp
  68. 11 0
      packages/fcl-image/src/fpfont.inc
  69. 21 4
      packages/fcl-json/Makefile
  70. 3 3
      packages/fcl-passrc/src/pastree.pp
  71. 90 8
      packages/fcl-process/Makefile
  72. 34 14
      packages/fcl-registry/src/regini.inc
  73. 5 2
      packages/fcl-registry/src/registry.pp
  74. 18 16
      packages/fcl-registry/src/xmlreg.pp
  75. 39 4
      packages/fcl-registry/tests/testbasics.pp
  76. 2427 0
      packages/fcl-stl/Makefile
  77. 23 0
      packages/fcl-stl/Makefile.fpc
  78. 47 0
      packages/fcl-stl/doc/arrayutils.tex
  79. 81 0
      packages/fcl-stl/doc/deque.tex
  80. 24 0
      packages/fcl-stl/doc/dequeexample.pp
  81. 63 0
      packages/fcl-stl/doc/main.tex
  82. 263 0
      packages/fcl-stl/doc/makra.tex
  83. 87 0
      packages/fcl-stl/doc/map.tex
  84. 24 0
      packages/fcl-stl/doc/mapexample.pp
  85. 44 0
      packages/fcl-stl/doc/priorityqueue.tex
  86. 30 0
      packages/fcl-stl/doc/priorityqueueexample.pp
  87. 39 0
      packages/fcl-stl/doc/queue.tex
  88. 17 0
      packages/fcl-stl/doc/queueexample.pp
  89. 76 0
      packages/fcl-stl/doc/set.tex
  90. 24 0
      packages/fcl-stl/doc/setexample.pp
  91. 20 0
      packages/fcl-stl/doc/sortingexample.pp
  92. 39 0
      packages/fcl-stl/doc/stack.tex
  93. 17 0
      packages/fcl-stl/doc/stackexample.pp
  94. 9 0
      packages/fcl-stl/doc/util.tex
  95. 73 0
      packages/fcl-stl/doc/vector.tex
  96. 21 0
      packages/fcl-stl/doc/vectorexample.pp
  97. 227 0
      packages/fcl-stl/src/garrayutils.pp
  98. 204 0
      packages/fcl-stl/src/gdeque.pp
  99. 163 0
      packages/fcl-stl/src/gmap.pp
  100. 141 0
      packages/fcl-stl/src/gpriorityqueue.pp

+ 53 - 1
.gitattributes

@@ -132,6 +132,7 @@ compiler/crefs.pas svneol=native#text/plain
 compiler/cresstr.pas svneol=native#text/plain
 compiler/cresstr.pas svneol=native#text/plain
 compiler/cstreams.pas svneol=native#text/plain
 compiler/cstreams.pas svneol=native#text/plain
 compiler/cutils.pas svneol=native#text/plain
 compiler/cutils.pas svneol=native#text/plain
+compiler/cwindirs.pp svneol=native#text/plain
 compiler/dbgbase.pas svneol=native#text/plain
 compiler/dbgbase.pas svneol=native#text/plain
 compiler/dbgdwarf.pas svneol=native#text/plain
 compiler/dbgdwarf.pas svneol=native#text/plain
 compiler/dbgstabs.pas svneol=native#text/plain
 compiler/dbgstabs.pas svneol=native#text/plain
@@ -335,6 +336,7 @@ compiler/ogelf.pas svneol=native#text/plain
 compiler/oglx.pas svneol=native#text/plain
 compiler/oglx.pas svneol=native#text/plain
 compiler/ogmacho.pas svneol=native#text/plain
 compiler/ogmacho.pas svneol=native#text/plain
 compiler/ogmap.pas svneol=native#text/plain
 compiler/ogmap.pas svneol=native#text/plain
+compiler/ognlm.pas svneol=native#text/plain
 compiler/optbase.pas svneol=native#text/plain
 compiler/optbase.pas svneol=native#text/plain
 compiler/optcse.pas svneol=native#text/plain
 compiler/optcse.pas svneol=native#text/plain
 compiler/optdead.pas svneol=native#text/plain
 compiler/optdead.pas svneol=native#text/plain
@@ -2293,8 +2295,53 @@ packages/fcl-res/xml/versionconsts.xml svneol=native#text/plain
 packages/fcl-res/xml/versionresource.xml svneol=native#text/plain
 packages/fcl-res/xml/versionresource.xml svneol=native#text/plain
 packages/fcl-res/xml/versiontypes.xml svneol=native#text/plain
 packages/fcl-res/xml/versiontypes.xml svneol=native#text/plain
 packages/fcl-res/xml/winpeimagereader.xml svneol=native#text/plain
 packages/fcl-res/xml/winpeimagereader.xml svneol=native#text/plain
+packages/fcl-stl/Makefile svneol=native#text/plain
+packages/fcl-stl/Makefile.fpc svneol=native#text/plain
+packages/fcl-stl/doc/arrayutils.tex svneol=native#text/plain
+packages/fcl-stl/doc/deque.tex svneol=native#text/plain
+packages/fcl-stl/doc/dequeexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/main.tex svneol=native#text/plain
+packages/fcl-stl/doc/makra.tex svneol=native#text/plain
+packages/fcl-stl/doc/map.tex svneol=native#text/plain
+packages/fcl-stl/doc/mapexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/priorityqueue.tex svneol=native#text/plain
+packages/fcl-stl/doc/priorityqueueexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/queue.tex svneol=native#text/plain
+packages/fcl-stl/doc/queueexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/set.tex svneol=native#text/plain
+packages/fcl-stl/doc/setexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/sortingexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/stack.tex svneol=native#text/plain
+packages/fcl-stl/doc/stackexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/util.tex svneol=native#text/plain
+packages/fcl-stl/doc/vector.tex svneol=native#text/plain
+packages/fcl-stl/doc/vectorexample.pp svneol=native#text/plain
+packages/fcl-stl/src/garrayutils.pp svneol=native#text/plain
+packages/fcl-stl/src/gdeque.pp svneol=native#text/plain
+packages/fcl-stl/src/gmap.pp svneol=native#text/plain
+packages/fcl-stl/src/gpriorityqueue.pp svneol=native#text/plain
+packages/fcl-stl/src/gqueue.pp svneol=native#text/plain
+packages/fcl-stl/src/gset.pp svneol=native#text/plain
+packages/fcl-stl/src/gstack.pp svneol=native#text/plain
+packages/fcl-stl/src/gutil.pp svneol=native#text/plain
+packages/fcl-stl/src/gvector.pp svneol=native#text/plain
+packages/fcl-stl/tests/clean svneol=native#text/plain
+packages/fcl-stl/tests/gdequetest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gmaptest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gmaptestzal.pp svneol=native#text/plain
+packages/fcl-stl/tests/gpriorityqueuetest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gqueuetest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gsetrefcounttest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gsettest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gsorttest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gstacktest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gvectortest.pp svneol=native#text/plain
+packages/fcl-stl/tests/run-all-tests svneol=native#text/plain
+packages/fcl-stl/tests/suiteconfig.pp svneol=native#text/plain
+packages/fcl-stl/tests/testrunner.pp svneol=native#text/plain
 packages/fcl-web/Makefile svneol=native#text/plain
 packages/fcl-web/Makefile svneol=native#text/plain
 packages/fcl-web/Makefile.fpc svneol=native#text/plain
 packages/fcl-web/Makefile.fpc svneol=native#text/plain
+packages/fcl-web/Makefile.org svneol=native#text/plain
 packages/fcl-web/Makefile_fpmake.fpc svneol=native#text/plain
 packages/fcl-web/Makefile_fpmake.fpc svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/README.txt svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/README.txt svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/demo.lpi svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/demo.lpi svneol=native#text/plain
@@ -7380,6 +7427,7 @@ rtl/netware/npackon.inc svneol=native#text/plain
 rtl/netware/nwcalls.pp svneol=native#text/plain
 rtl/netware/nwcalls.pp svneol=native#text/plain
 rtl/netware/nwnit.pp svneol=native#text/plain
 rtl/netware/nwnit.pp svneol=native#text/plain
 rtl/netware/nwpre.as svneol=native#text/plain
 rtl/netware/nwpre.as svneol=native#text/plain
+rtl/netware/nwpre.imp svneol=native#text/plain
 rtl/netware/nwpre.pp svneol=native#text/plain
 rtl/netware/nwpre.pp svneol=native#text/plain
 rtl/netware/nwprot.pp svneol=native#text/plain
 rtl/netware/nwprot.pp svneol=native#text/plain
 rtl/netware/nwpsrv.imp -text
 rtl/netware/nwpsrv.imp -text
@@ -7885,6 +7933,7 @@ rtl/win/syswin.inc svneol=native#text/plain
 rtl/win/tthread.inc svneol=native#text/plain
 rtl/win/tthread.inc svneol=native#text/plain
 rtl/win/varutils.pp svneol=native#text/plain
 rtl/win/varutils.pp svneol=native#text/plain
 rtl/win/video.pp svneol=native#text/plain
 rtl/win/video.pp svneol=native#text/plain
+rtl/win/windirs.pp svneol=native#text/plain
 rtl/win/winevent.pp svneol=native#text/plain
 rtl/win/winevent.pp svneol=native#text/plain
 rtl/win/wininc/Makefile svneol=native#text/plain
 rtl/win/wininc/Makefile svneol=native#text/plain
 rtl/win/wininc/ascdef.inc svneol=native#text/plain
 rtl/win/wininc/ascdef.inc svneol=native#text/plain
@@ -9456,6 +9505,7 @@ tests/test/tarray5.pp svneol=native#text/plain
 tests/test/tarray6.pp svneol=native#text/plain
 tests/test/tarray6.pp svneol=native#text/plain
 tests/test/tarray7.pp svneol=native#text/plain
 tests/test/tarray7.pp svneol=native#text/plain
 tests/test/tarray8.pp svneol=native#text/plain
 tests/test/tarray8.pp svneol=native#text/plain
+tests/test/tarray9.pp svneol=native#text/plain
 tests/test/tasmread.pp svneol=native#text/plain
 tests/test/tasmread.pp svneol=native#text/plain
 tests/test/tasout.pp svneol=native#text/plain
 tests/test/tasout.pp svneol=native#text/plain
 tests/test/tassignmentoperator1.pp svneol=native#text/pascal
 tests/test/tassignmentoperator1.pp svneol=native#text/pascal
@@ -9584,6 +9634,8 @@ tests/test/tclass12b.pp svneol=native#text/pascal
 tests/test/tclass12c.pp svneol=native#text/pascal
 tests/test/tclass12c.pp svneol=native#text/pascal
 tests/test/tclass12d.pp svneol=native#text/plain
 tests/test/tclass12d.pp svneol=native#text/plain
 tests/test/tclass13.pp svneol=native#text/pascal
 tests/test/tclass13.pp svneol=native#text/pascal
+tests/test/tclass13a.pp svneol=native#text/plain
+tests/test/tclass13b.pp svneol=native#text/plain
 tests/test/tclass14a.pp svneol=native#text/pascal
 tests/test/tclass14a.pp svneol=native#text/pascal
 tests/test/tclass14b.pp svneol=native#text/pascal
 tests/test/tclass14b.pp svneol=native#text/pascal
 tests/test/tclass2.pp svneol=native#text/plain
 tests/test/tclass2.pp svneol=native#text/plain
@@ -11343,7 +11395,7 @@ tests/webtbs/tw1850.pp svneol=native#text/plain
 tests/webtbs/tw1851.pp svneol=native#text/plain
 tests/webtbs/tw1851.pp svneol=native#text/plain
 tests/webtbs/tw18512.pp svneol=native#text/pascal
 tests/webtbs/tw18512.pp svneol=native#text/pascal
 tests/webtbs/tw1856.pp svneol=native#text/plain
 tests/webtbs/tw1856.pp svneol=native#text/plain
-tests/webtbs/tw18567 svneol=native#text/pascal
+tests/webtbs/tw18567.pp svneol=native#text/pascal
 tests/webtbs/tw18610.pp svneol=native#text/pascal
 tests/webtbs/tw18610.pp svneol=native#text/pascal
 tests/webtbs/tw1862.pp svneol=native#text/plain
 tests/webtbs/tw1862.pp svneol=native#text/plain
 tests/webtbs/tw18620.pp svneol=native#text/pascal
 tests/webtbs/tw18620.pp svneol=native#text/pascal

+ 1 - 1
compiler/aasmbase.pas

@@ -40,7 +40,7 @@ interface
        TAsmsymbind=(
        TAsmsymbind=(
          AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
          AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
          { global in the current program/library, but not visible outside it }
          { global in the current program/library, but not visible outside it }
-         AB_PRIVATE_EXTERN,AB_LAZY);
+         AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
 
 
        TAsmsymtype=(
        TAsmsymtype=(
          AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
          AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,

+ 21 - 8
compiler/cgobj.pas

@@ -3504,6 +3504,8 @@ implementation
           end
           end
          else
          else
           begin
           begin
+            if is_open_array(t) then
+              InternalError(201103054);
             reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
             reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
             a_loadaddr_ref_cgpara(list,href,cgpara2);
             a_loadaddr_ref_cgpara(list,href,cgpara2);
             a_loadaddr_ref_cgpara(list,ref,cgpara1);
             a_loadaddr_ref_cgpara(list,ref,cgpara1);
@@ -3569,6 +3571,8 @@ implementation
           end
           end
          else
          else
           begin
           begin
+            if is_open_array(t) then
+              InternalError(201103053);
             reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
             reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
             a_loadaddr_ref_cgpara(list,href,cgpara2);
             a_loadaddr_ref_cgpara(list,href,cgpara2);
             a_loadaddr_ref_cgpara(list,ref,cgpara1);
             a_loadaddr_ref_cgpara(list,ref,cgpara1);
@@ -3596,18 +3600,23 @@ implementation
         paramanager.getintparaloc(pocall_default,3,cgpara3);
         paramanager.getintparaloc(pocall_default,3,cgpara3);
 
 
         reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
         reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
-        if highloc.loc in [LOC_REGISTER,LOC_CREGISTER] then
-          hreg:=highloc.register
+        if highloc.loc=LOC_CONSTANT then
+          a_load_const_cgpara(list,OS_INT,highloc.value+1,cgpara3)
         else
         else
           begin
           begin
-            hreg:=getintregister(list,OS_INT);
-            a_load_loc_reg(list,OS_INT,highloc,hreg);
+            if highloc.loc in [LOC_REGISTER,LOC_CREGISTER] then
+              hreg:=highloc.register
+            else
+              begin
+                hreg:=getintregister(list,OS_INT);
+                a_load_loc_reg(list,OS_INT,highloc,hreg);
+              end;
+            { increment, converts high(x) to length(x) }
+            lenreg:=getintregister(list,OS_INT);
+            a_op_const_reg_reg(list,OP_ADD,OS_INT,1,hreg,lenreg);
+            a_load_reg_cgpara(list,OS_INT,lenreg,cgpara3);
           end;
           end;
-        { increment, converts high(x) to length(x) }
-        lenreg:=getintregister(list,OS_INT);
-        a_op_const_reg_reg(list,OP_ADD,OS_INT,1,hreg,lenreg);
 
 
-        a_load_reg_cgpara(list,OS_INT,lenreg,cgpara3);
         a_loadaddr_ref_cgpara(list,href,cgpara2);
         a_loadaddr_ref_cgpara(list,href,cgpara2);
         a_loadaddr_ref_cgpara(list,ref,cgpara1);
         a_loadaddr_ref_cgpara(list,ref,cgpara1);
         paramanager.freecgpara(list,cgpara1);
         paramanager.freecgpara(list,cgpara1);
@@ -3639,6 +3648,8 @@ implementation
            a_load_const_ref(list,OS_ADDR,0,ref)
            a_load_const_ref(list,OS_ADDR,0,ref)
          else
          else
            begin
            begin
+              if is_open_array(t) then
+                InternalError(201103052);
               reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
               reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
               a_loadaddr_ref_cgpara(list,href,cgpara2);
               a_loadaddr_ref_cgpara(list,href,cgpara2);
               a_loadaddr_ref_cgpara(list,ref,cgpara1);
               a_loadaddr_ref_cgpara(list,ref,cgpara1);
@@ -3672,6 +3683,8 @@ implementation
             end
             end
          else
          else
            begin
            begin
+              if is_open_array(t) then
+                InternalError(201103051);
               reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
               reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
               a_loadaddr_ref_cgpara(list,href,cgpara2);
               a_loadaddr_ref_cgpara(list,href,cgpara2);
               a_loadaddr_ref_cgpara(list,ref,cgpara1);
               a_loadaddr_ref_cgpara(list,ref,cgpara1);

+ 123 - 0
compiler/cwindirs.pp

@@ -0,0 +1,123 @@
+{ this unit is temporarily included in the compiler sources till stable releases with
+  windirs from the rtl are shipped
+}
+unit cwindirs;
+
+{$mode objfpc}
+{$H+}
+
+interface
+
+uses
+  windows,
+  strings;
+
+Const
+  CSIDL_PROGRAMS                = $0002; { %SYSTEMDRIVE%\Program Files                                      }
+  CSIDL_PERSONAL                = $0005; { %USERPROFILE%\My Documents                                       }
+  CSIDL_FAVORITES               = $0006; { %USERPROFILE%\Favorites                                          }
+  CSIDL_STARTUP                 = $0007; { %USERPROFILE%\Start menu\Programs\Startup                        }
+  CSIDL_RECENT                  = $0008; { %USERPROFILE%\Recent                                             }
+  CSIDL_SENDTO                  = $0009; { %USERPROFILE%\Sendto                                             }
+  CSIDL_STARTMENU               = $000B; { %USERPROFILE%\Start menu                                         }
+  CSIDL_MYMUSIC                 = $000D; { %USERPROFILE%\Documents\My Music                                 }
+  CSIDL_MYVIDEO                 = $000E; { %USERPROFILE%\Documents\My Videos                                }
+  CSIDL_DESKTOPDIRECTORY        = $0010; { %USERPROFILE%\Desktop                                            }
+  CSIDL_NETHOOD                 = $0013; { %USERPROFILE%\NetHood                                            }
+  CSIDL_TEMPLATES               = $0015; { %USERPROFILE%\Templates                                          }
+  CSIDL_COMMON_STARTMENU        = $0016; { %PROFILEPATH%\All users\Start menu                               }
+  CSIDL_COMMON_PROGRAMS         = $0017; { %PROFILEPATH%\All users\Start menu\Programs                      }
+  CSIDL_COMMON_STARTUP          = $0018; { %PROFILEPATH%\All users\Start menu\Programs\Startup              }
+  CSIDL_COMMON_DESKTOPDIRECTORY = $0019; { %PROFILEPATH%\All users\Desktop                                  }
+  CSIDL_APPDATA                 = $001A; { %USERPROFILE%\Application Data (roaming)                         }
+  CSIDL_PRINTHOOD               = $001B; { %USERPROFILE%\Printhood                                          }
+  CSIDL_LOCAL_APPDATA           = $001C; { %USERPROFILE%\Local Settings\Application Data (non roaming)      }
+  CSIDL_COMMON_FAVORITES        = $001F; { %PROFILEPATH%\All users\Favorites                                }
+  CSIDL_INTERNET_CACHE          = $0020; { %USERPROFILE%\Local Settings\Temporary Internet Files            }
+  CSIDL_COOKIES                 = $0021; { %USERPROFILE%\Cookies                                            }
+  CSIDL_HISTORY                 = $0022; { %USERPROFILE%\Local settings\History                             }
+  CSIDL_COMMON_APPDATA          = $0023; { %PROFILESPATH%\All Users\Application Data                        }
+  CSIDL_WINDOWS                 = $0024; { %SYSTEMROOT%                                                     }
+  CSIDL_SYSTEM                  = $0025; { %SYSTEMROOT%\SYSTEM32 (may be system on 95/98/ME)                }
+  CSIDL_PROGRAM_FILES           = $0026; { %SYSTEMDRIVE%\Program Files                                      }
+  CSIDL_MYPICTURES              = $0027; { %USERPROFILE%\My Documents\My Pictures                           }
+  CSIDL_PROFILE                 = $0028; { %USERPROFILE%                                                    }
+  CSIDL_PROGRAM_FILES_COMMON    = $002B; { %SYSTEMDRIVE%\Program Files\Common                               }
+  CSIDL_COMMON_TEMPLATES        = $002D; { %PROFILEPATH%\All Users\Templates                                }
+  CSIDL_COMMON_DOCUMENTS        = $002E; { %PROFILEPATH%\All Users\Documents                                }
+  CSIDL_COMMON_ADMINTOOLS       = $002F; { %PROFILEPATH%\All Users\Start Menu\Programs\Administrative Tools }
+  CSIDL_ADMINTOOLS              = $0030; { %USERPROFILE%\Start Menu\Programs\Administrative Tools           }
+  CSIDL_COMMON_MUSIC            = $0035; { %PROFILEPATH%\All Users\Documents\my music                       }
+  CSIDL_COMMON_PICTURES         = $0036; { %PROFILEPATH%\All Users\Documents\my pictures                    }
+  CSIDL_COMMON_VIDEO            = $0037; { %PROFILEPATH%\All Users\Documents\my videos                      }
+  CSIDL_CDBURN_AREA             = $003B; { %USERPROFILE%\Local Settings\Application Data\Microsoft\CD Burning }
+  CSIDL_PROFILES                = $003E; { %PROFILEPATH%                                                    }
+
+  CSIDL_FLAG_CREATE             = $8000; { (force creation of requested folder if it doesn't exist yet)     }
+
+Function GetWindowsSpecialDir(ID :  Integer) : String;
+
+implementation
+
+uses
+  sysutils;
+
+Type
+  PFNSHGetFolderPath = Function(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: PChar): HRESULT; stdcall;
+
+
+var
+  SHGetFolderPath : PFNSHGetFolderPath = Nil;
+  CFGDLLHandle : THandle = 0;
+
+Procedure InitDLL;
+
+Var
+  pathBuf: array[0..MAX_PATH-1] of char;
+  pathLength: Integer;
+begin
+  { Load shfolder.dll using a full path, in order to prevent spoofing (Mantis #18185)
+    Don't bother loading shell32.dll because shfolder.dll itself redirects SHGetFolderPath
+    to shell32.dll whenever possible. }
+  pathLength:=GetSystemDirectory(pathBuf, MAX_PATH);
+  if (pathLength>0) and (pathLength<MAX_PATH-14) then { 14=length('\shfolder.dll'#0) }
+  begin
+    StrLCopy(@pathBuf[pathLength],'\shfolder.dll',MAX_PATH-pathLength-1);
+    CFGDLLHandle:=LoadLibrary(pathBuf);
+
+    if (CFGDLLHandle<>0) then
+    begin
+      Pointer(ShGetFolderPath):=GetProcAddress(CFGDLLHandle,'SHGetFolderPathA');
+      If @ShGetFolderPath=nil then
+      begin
+        FreeLibrary(CFGDLLHandle);
+        CFGDllHandle:=0;
+      end;
+    end;
+  end;
+  If (@ShGetFolderPath=Nil) then
+    Raise Exception.Create('Could not determine SHGetFolderPath Function');
+end;
+
+Function GetWindowsSpecialDir(ID :  Integer) : String;
+
+Var
+  APath : Array[0..MAX_PATH] of char;
+
+begin
+  Result:='';
+  if (CFGDLLHandle=0) then
+    InitDLL;
+  If (SHGetFolderPath<>Nil) then
+    begin
+    if SHGetFolderPath(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0])=S_OK then
+      Result:=IncludeTrailingPathDelimiter(StrPas(@APath[0]));
+    end;
+end;
+
+Initialization
+Finalization
+  if CFGDLLHandle<>0 then
+   FreeLibrary(CFGDllHandle);
+end.
+

+ 3 - 1
compiler/defcmp.pas

@@ -1260,7 +1260,9 @@ implementation
                    find_real_objcclass_definition(tobjectdef(def_to),false)) then
                    find_real_objcclass_definition(tobjectdef(def_to),false)) then
                  begin
                  begin
                    doconv:=tc_equal;
                    doconv:=tc_equal;
-                   eq:=te_equal;
+                   { exact, not equal, because can change between interface
+                     and implementation }
+                   eq:=te_exact;
                  end
                  end
                { object pascal objects }
                { object pascal objects }
                else if (def_from.typ=objectdef) and
                else if (def_from.typ=objectdef) and

+ 2 - 14
compiler/fmodule.pas

@@ -550,7 +550,6 @@ implementation
     destructor tmodule.Destroy;
     destructor tmodule.Destroy;
       var
       var
         i : longint;
         i : longint;
-        hpi : tprocinfo;
       begin
       begin
         if assigned(unitmap) then
         if assigned(unitmap) then
           freemem(unitmap);
           freemem(unitmap);
@@ -588,12 +587,7 @@ implementation
                 current_specializedef:=nil;
                 current_specializedef:=nil;
               end;
               end;
             { release procinfo tree }
             { release procinfo tree }
-            while assigned(procinfo) do
-             begin
-               hpi:=tprocinfo(procinfo).parent;
-               tprocinfo(procinfo).free;
-               procinfo:=hpi;
-             end;
+            tprocinfo(procinfo).destroy_tree;
           end;
           end;
         DoneDebugInfo(self);
         DoneDebugInfo(self);
         used_units.free;
         used_units.free;
@@ -649,7 +643,6 @@ implementation
 
 
     procedure tmodule.reset;
     procedure tmodule.reset;
       var
       var
-        hpi : tprocinfo;
         i   : longint;
         i   : longint;
       begin
       begin
         if assigned(scanner) then
         if assigned(scanner) then
@@ -671,12 +664,7 @@ implementation
                 current_specializedef:=nil;
                 current_specializedef:=nil;
               end;
               end;
             { release procinfo tree }
             { release procinfo tree }
-            while assigned(procinfo) do
-             begin
-               hpi:=tprocinfo(procinfo).parent;
-               tprocinfo(procinfo).free;
-               procinfo:=hpi;
-             end;
+            tprocinfo(procinfo).destroy_tree;
           end;
           end;
         if assigned(asmdata) then
         if assigned(asmdata) then
           begin
           begin

+ 13 - 80
compiler/globals.pas

@@ -26,7 +26,7 @@ unit globals;
 interface
 interface
 
 
     uses
     uses
-{$ifdef win32}
+{$ifdef windows}
       windows,
       windows,
 {$endif}
 {$endif}
 {$ifdef os2}
 {$ifdef os2}
@@ -476,6 +476,13 @@ implementation
     uses
     uses
 {$ifdef macos}
 {$ifdef macos}
       macutils,
       macutils,
+{$endif}
+{$ifdef mswindows}
+{$ifdef VER2_4}
+      cwindirs,
+{$else VER2_4}
+      windirs,
+{$endif VER2_4}
 {$endif}
 {$endif}
       comphook;
       comphook;
 
 
@@ -718,86 +725,18 @@ implementation
                           Default Macro Handling
                           Default Macro Handling
 ****************************************************************************}
 ****************************************************************************}
 
 
-{$ifdef windows}
-{
-  This code is copied from sysutils.pp
-}
-     Type
-       PFNSHGetFolderPath = Function(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: PChar): HRESULT; stdcall;
-
-     var
-       SHGetFolderPath : PFNSHGetFolderPath = Nil;
-       CFGDLLHandle : THandle = 0;
-
-     const
-       CSIDL_PERSONAL                = $0005; { %USERPROFILE%\My Documents                                       }
-       CSIDL_APPDATA                 = $001A; { %USERPROFILE%\Application Data (roaming)                         }
-       CSIDL_LOCAL_APPDATA           = $001C; { %USERPROFILE%\Local Settings\Application Data (non roaming)      }
-       CSIDL_COMMON_APPDATA          = $0023; { %PROFILESPATH%\All Users\Application Data                        }
-       CSIDL_PROGRAM_FILES           = $0026; { %SYSTEMDRIVE%\Program Files                                      }
-       CSIDL_PROFILE                 = $0028; { %USERPROFILE%                                                    }
-       CSIDL_PROGRAM_FILES_COMMON    = $002B; { %SYSTEMDRIVE%\Program Files\Common                               }
-
-       CSIDL_FLAG_CREATE             = $8000; { (force creation of requested folder if it doesn't exist yet)     }
-
-
-     Procedure InitDLL;
-       Var
-         pathBuf: array[0..MAX_PATH-1] of char;
-         pathLength: Integer;
-       begin
-         { Load shfolder.dll using a full path, in order to prevent spoofing (Mantis #18185)
-           Don't bother loading shell32.dll because shfolder.dll itself redirects SHGetFolderPath
-           to shell32.dll whenever possible. }
-         pathLength:=GetSystemDirectory(pathBuf, MAX_PATH);
-         if (pathLength>0) and (pathLength<MAX_PATH-14) then { 14=length('\shfolder.dll'#0) }
-           begin
-             StrLCopy(@pathBuf[pathLength],'\shfolder.dll',MAX_PATH-pathLength-1);
-             CFGDLLHandle:=LoadLibrary(pathBuf);
-             if (CFGDLLHandle<>0) then
-               begin
-                 Pointer(ShGetFolderPath):=GetProcAddress(CFGDLLHandle,'SHGetFolderPathA');
-                 If @ShGetFolderPath=nil then
-                   begin
-                     FreeLibrary(CFGDLLHandle);
-                     CFGDllHandle:=0;
-                   end;
-               end;
-           end;
-         If (@ShGetFolderPath=Nil) then
-           Raise Exception.Create('Could not determine SHGetFolderPath Function');
-       end;
-
-
-     Function GetSpecialDir(ID :  Integer) : String;
-
-       Var
-         APath : Array[0..MAX_PATH] of char;
-
-       begin
-         Result:='';
-         if (CFGDLLHandle=0) then
-           InitDLL;
-         If (SHGetFolderPath<>Nil) then
-           begin
-             if SHGetFolderPath(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0])=S_OK then
-               Result:=IncludeTrailingPathDelimiter(StrPas(@APath[0]));
-           end;
-       end;
-{$endif windows}
-
 
 
      procedure DefaultReplacements(var s:ansistring);
      procedure DefaultReplacements(var s:ansistring);
-       {$ifdef windows}
+{$ifdef mswindows}
        procedure ReplaceSpecialFolder(const MacroName: string; const ID: integer);
        procedure ReplaceSpecialFolder(const MacroName: string; const ID: integer);
          begin
          begin
            // Only try to receive the special folders (and thus dynamically
            // Only try to receive the special folders (and thus dynamically
            // load shfolder.dll) when that's needed.
            // load shfolder.dll) when that's needed.
            if pos(MacroName,s)>0 then
            if pos(MacroName,s)>0 then
-             Replace(s,MacroName,GetSpecialDir(ID));
+             Replace(s,MacroName,GetWindowsSpecialDir(ID));
          end;
          end;
 
 
-       {$endif windows}
+{$endif mswindows}
        var
        var
          envstr: string;
          envstr: string;
          envvalue: pchar;
          envvalue: pchar;
@@ -813,7 +752,7 @@ implementation
            Replace(s,'$FPCTARGET',target_os_string)
            Replace(s,'$FPCTARGET',target_os_string)
          else
          else
            Replace(s,'$FPCTARGET',target_full_string);
            Replace(s,'$FPCTARGET',target_full_string);
-{$ifdef windows}
+{$ifdef mswindows}
          ReplaceSpecialFolder('$LOCAL_APPDATA',CSIDL_LOCAL_APPDATA);
          ReplaceSpecialFolder('$LOCAL_APPDATA',CSIDL_LOCAL_APPDATA);
          ReplaceSpecialFolder('$APPDATA',CSIDL_APPDATA);
          ReplaceSpecialFolder('$APPDATA',CSIDL_APPDATA);
          ReplaceSpecialFolder('$COMMON_APPDATA',CSIDL_COMMON_APPDATA);
          ReplaceSpecialFolder('$COMMON_APPDATA',CSIDL_COMMON_APPDATA);
@@ -821,7 +760,7 @@ implementation
          ReplaceSpecialFolder('$PROGRAM_FILES',CSIDL_PROGRAM_FILES);
          ReplaceSpecialFolder('$PROGRAM_FILES',CSIDL_PROGRAM_FILES);
          ReplaceSpecialFolder('$PROGRAM_FILES_COMMON',CSIDL_PROGRAM_FILES_COMMON);
          ReplaceSpecialFolder('$PROGRAM_FILES_COMMON',CSIDL_PROGRAM_FILES_COMMON);
          ReplaceSpecialFolder('$PROFILE',CSIDL_PROFILE);
          ReplaceSpecialFolder('$PROFILE',CSIDL_PROFILE);
-{$endif windows}
+{$endif mswindows}
          { Replace environment variables between dollar signs }
          { Replace environment variables between dollar signs }
          i := pos('$',s);
          i := pos('$',s);
          while i>0 do
          while i>0 do
@@ -1581,10 +1520,4 @@ implementation
         features:=[low(Tfeature)..high(Tfeature)];
         features:=[low(Tfeature)..high(Tfeature)];
      end;
      end;
 
 
-{$ifdef windows}
-initialization
-finalization
-  if CFGDLLHandle<>0 then
-    FreeLibrary(CFGDllHandle);
-{$endif windows}
 end.
 end.

+ 3 - 0
compiler/link.pas

@@ -1051,6 +1051,9 @@ Implementation
         if ErrorCount>0 then
         if ErrorCount>0 then
           goto myexit;
           goto myexit;
 
 
+        { parse linker options specific for output format }
+        exeoutput.ParseScript (linkscript);
+
         { Create .exe sections and add .o sections }
         { Create .exe sections and add .o sections }
         ParseScript_Order;
         ParseScript_Order;
         exeoutput.RemoveUnreferencedSections;
         exeoutput.RemoveUnreferencedSections;

+ 1 - 1
compiler/msg/errorct.msg

@@ -2100,7 +2100,7 @@ option_code_page_not_available=11039_E_La p
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler versió $FPCFULLVERSION [$FPCDATE] per $FPCCPU
 Free Pascal Compiler versió $FPCFULLVERSION [$FPCDATE] per $FPCCPU
-Copyright (c) 1993-2010 per Florian Klaempfl
+Copyright (c) 1993-2011 per Florian Klaempfl
 ]
 ]
 
 
 #
 #

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 153 - 153
compiler/msg/errord.msg


+ 1 - 1
compiler/msg/errorda.msg

@@ -2207,7 +2207,7 @@ option_config_is_dir=11040_F_Konfigurationsfilen $1 er et directory
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] til $FPCTARGET
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] til $FPCTARGET
-Copyright (c) 1993-2010 Florian Klaempfl
+Copyright (c) 1993-2011 Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errordu.msg

@@ -2991,7 +2991,7 @@ wpo_cant_create_feedback_file=12019_E_Die angegebene Feedback-Eingabe-Datei "$1"
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler Version $FPCFULLVERSION [$FPCDATE] für $FPCTARGET
 Free Pascal Compiler Version $FPCFULLVERSION [$FPCDATE] für $FPCTARGET
-Copyright (c) 1993-2010 Florian Klämpfl
+Copyright (c) 1993-2011 Florian Klämpfl und andere
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errore.msg

@@ -2989,7 +2989,7 @@ wpo_cant_create_feedback_file=12019_E_Cannot create specified whole program opti
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl and others
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errores.msg

@@ -2111,7 +2111,7 @@ option_code_page_not_available=11039_E_C
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorf.msg

@@ -1712,7 +1712,7 @@ option_asm_forced=11022_W_"$1" assembler use forced
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Compilateur Free Pascal version $FPCFULLVERSION [$FPCDATE] pour $FPCTARGET
 Compilateur Free Pascal version $FPCFULLVERSION [$FPCDATE] pour $FPCTARGET
-Copyright (c) 1998-2009 by Florian Klaempfl
+Copyright (c) 1998-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorfi.msg

@@ -2258,7 +2258,7 @@ option_config_is_dir=11040_F_Le fichier de configuration $1 est un r
 # Logo (option -l)
 # Logo (option -l)
 #
 #
 option_logo=11023_[ Compilateur Free Pascal version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
 option_logo=11023_[ Compilateur Free Pascal version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010, Florian Klaempfl ]
+Copyright (c) 1993-2011, Florian Klaempfl ]
 #
 #
 # Info (option -i)
 # Info (option -i)
 #
 #

+ 1 - 1
compiler/msg/errorhe.msg

@@ -2404,7 +2404,7 @@ option_confict_asm_debug=11041_W_
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorheu.msg

@@ -2404,7 +2404,7 @@ option_confict_asm_debug=11041_W_סוג הפלט של המאסף שנבחר "$1"
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorid.msg

@@ -2421,7 +2421,7 @@ option_confict_asm_debug=11041_W_Output assembler yang dipilih "$1" tidak bisa m
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler versi $FPCFULLVERSION [$FPCDATE] untuk $FPCCPU
 Free Pascal Compiler versi $FPCFULLVERSION [$FPCDATE] untuk $FPCCPU
-Hak Cipta (c) 1993-2010 oleh Florian Klaempfl
+Hak Cipta (c) 1993-2011 oleh Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorn.msg

@@ -2183,7 +2183,7 @@ option_config_is_dir=11040_F_Config bestand $1 is een directorie
 %\end{description}
 %\end{description}
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler versie $FPCFULLVERSION [$FPCDATE] voor $FPCTARGET
 Free Pascal Compiler versie $FPCFULLVERSION [$FPCDATE] voor $FPCTARGET
-Copyright (c) 1998-2009 door Florian Klaempfl en anderen
+Copyright (c) 1998-2011 door Florian Klaempfl en anderen
 ]
 ]
 #
 #
 # Info (option -i)
 # Info (option -i)

+ 1 - 1
compiler/msg/errorpl.msg

@@ -2116,7 +2116,7 @@ option_code_page_not_available=11039_E_Nieznana strona kodowa
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler wersja $FPCFULLVERSION [$FPCDATE] dla $FPCCPU
 Free Pascal Compiler wersja $FPCFULLVERSION [$FPCDATE] dla $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorpli.msg

@@ -2116,7 +2116,7 @@ option_code_page_not_available=11039_E_Nieznana strona kodowa
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler wersja $FPCFULLVERSION [$FPCDATE] dla $FPCCPU
 Free Pascal Compiler wersja $FPCFULLVERSION [$FPCDATE] dla $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorpt.msg

@@ -2905,7 +2905,7 @@ wpo_cant_create_feedback_file=12019_E_Imposs
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Compilador Free Pascal versÆo $FPCFULLVERSION [$FPCDATE] para $FPCCPU
 Compilador Free Pascal versÆo $FPCFULLVERSION [$FPCDATE] para $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorptu.msg

@@ -2905,7 +2905,7 @@ wpo_cant_create_feedback_file=12019_E_Impossível criar arquivo retorno otimiza
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Compilador Free Pascal versão $FPCFULLVERSION [$FPCDATE] para $FPCCPU
 Compilador Free Pascal versão $FPCFULLVERSION [$FPCDATE] para $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorr.msg

@@ -2503,7 +2503,7 @@ wpo_cant_create_feedback_file=12019_E_
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Š®¬¯¨«ïâ®à Free Pascal ¢¥àᨨ $FPCFULLVERSION [$FPCDATE] ¤«ï $FPCCPU
 Š®¬¯¨«ïâ®à Free Pascal ¢¥àᨨ $FPCFULLVERSION [$FPCDATE] ¤«ï $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorru.msg

@@ -2503,7 +2503,7 @@ wpo_cant_create_feedback_file=12019_E_Невозможно создать фай
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Компилятор Free Pascal версии $FPCFULLVERSION [$FPCDATE] для $FPCCPU
 Компилятор Free Pascal версии $FPCFULLVERSION [$FPCDATE] для $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msg/errorues.msg

@@ -2105,7 +2105,7 @@ option_code_page_not_available=11039_E_Código de página desconocido
 #
 #
 option_logo=11023_[
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 ]
 
 
 #
 #

+ 1 - 1
compiler/msgidx.inc

@@ -889,7 +889,7 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 59095;
+  MsgTxtSize = 59106;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
     24,88,308,103,84,54,111,22,202,63,
     24,88,308,103,84,54,111,22,202,63,

+ 68 - 68
compiler/msgtxt.inc

@@ -1053,7 +1053,7 @@ const msgtxt : array[0..000246,1..240] of char=(
   'le "$1"'#000+
   'le "$1"'#000+
   '11023_Free Pascal Compiler version $FPCFULLVER','SION [$FPCDATE] for $F'+
   '11023_Free Pascal Compiler version $FPCFULLVER','SION [$FPCDATE] for $F'+
   'PCCPU'#010+
   'PCCPU'#010+
-  'Copyright (c) 1993-2010 by Florian Klaempfl'#000+
+  'Copyright (c) 1993-2011 by Florian Klaempfl and others'#000+
   '11024_Free Pascal Compiler version $FPCVERSION'#010+
   '11024_Free Pascal Compiler version $FPCVERSION'#010+
   #010+
   #010+
   'Compiler Date      : $FPCDATE'#010+
   'Compiler Date      : $FPCDATE'#010+
@@ -1062,7 +1062,7 @@ const msgtxt : array[0..000246,1..240] of char=(
   'Supported targets:'#010+
   'Supported targets:'#010+
   '  $OSTARGETS'#010+
   '  $OSTARGETS'#010+
   #010+
   #010+
-  'Supported CPU instruction s','ets:'#010+
+  'Supported CPU in','struction sets:'#010+
   '  $INSTRUCTIONSETS'#010+
   '  $INSTRUCTIONSETS'#010+
   #010+
   #010+
   'Supported FPU instruction sets:'#010+
   'Supported FPU instruction sets:'#010+
@@ -1078,7 +1078,7 @@ const msgtxt : array[0..000246,1..240] of char=(
   '  All'#010+
   '  All'#010+
   '  $WPOPTIMIZATIONS'#010+
   '  $WPOPTIMIZATIONS'#010+
   #010+
   #010+
-  'Supported Micr','ocontroller types:'#010+
+  'Sup','ported Microcontroller types:'#010+
   '  $CONTROLLERTYPES'#010+
   '  $CONTROLLERTYPES'#010+
   #010+
   #010+
   'This program comes under the GNU General Public Licence'#010+
   'This program comes under the GNU General Public Licence'#010+
@@ -1087,66 +1087,66 @@ const msgtxt : array[0..000246,1..240] of char=(
   'Report bugs, suggestions, etc. to:'#010+
   'Report bugs, suggestions, etc. to:'#010+
   '                 http://bugs.freepascal.org'#010+
   '                 http://bugs.freepascal.org'#010+
   'or'#010+
   'or'#010+
-  '                 bugs@fr','eepascal.org'#000+
+  '             ','    [email protected]'#000+
   '11025_**0*_Put + after a boolean switch option to enable it, - to disa'+
   '11025_**0*_Put + after a boolean switch option to enable it, - to disa'+
   'ble it'#010+
   'ble it'#010+
   '**1a_The compiler doesn'#039't delete the generated assembler file'#010+
   '**1a_The compiler doesn'#039't delete the generated assembler file'#010+
   '**2al_List sourcecode lines in assembler file'#010+
   '**2al_List sourcecode lines in assembler file'#010+
-  '**2an_List node info in assembler file'#010+
-  '*L2','ap_Use pipes instead of creating temporary assembler files'#010+
+  '**2an_List node info in assembl','er file'#010+
+  '*L2ap_Use pipes instead of creating temporary assembler files'#010+
   '**2ar_List register allocation/release info in assembler file'#010+
   '**2ar_List register allocation/release info in assembler file'#010+
   '**2at_List temp allocation/release info in assembler file'#010+
   '**2at_List temp allocation/release info in assembler file'#010+
   '**1A<x>_Output format:'#010+
   '**1A<x>_Output format:'#010+
-  '**2Adefault_Use default assembler'#010+
-  '3*2A','as_Assemble using GNU AS'#010+
+  '**2Adefault_Use default ass','embler'#010+
+  '3*2Aas_Assemble using GNU AS'#010+
   '3*2Amacho_Mach-O (Darwin, Intel 32 bit) using internal writer'#010+
   '3*2Amacho_Mach-O (Darwin, Intel 32 bit) using internal writer'#010+
   '3*2Anasmcoff_COFF (Go32v2) file using Nasm'#010+
   '3*2Anasmcoff_COFF (Go32v2) file using Nasm'#010+
   '3*2Anasmelf_ELF32 (Linux) file using Nasm'#010+
   '3*2Anasmelf_ELF32 (Linux) file using Nasm'#010+
   '3*2Anasmwin32_Win32 object file using Nasm'#010+
   '3*2Anasmwin32_Win32 object file using Nasm'#010+
-  '3*2Anasmwdosx_Win32/WDOSX',' object file using Nasm'#010+
+  '3*2Anasmwdosx_','Win32/WDOSX object file using Nasm'#010+
   '3*2Awasm_Obj file using Wasm (Watcom)'#010+
   '3*2Awasm_Obj file using Wasm (Watcom)'#010+
   '3*2Anasmobj_Obj file using Nasm'#010+
   '3*2Anasmobj_Obj file using Nasm'#010+
   '3*2Amasm_Obj file using Masm (Microsoft)'#010+
   '3*2Amasm_Obj file using Masm (Microsoft)'#010+
   '3*2Atasm_Obj file using Tasm (Borland)'#010+
   '3*2Atasm_Obj file using Tasm (Borland)'#010+
   '3*2Aelf_ELF (Linux) using internal writer'#010+
   '3*2Aelf_ELF (Linux) using internal writer'#010+
-  '3*2Acoff_COFF (Go32v2) u','sing internal writer'#010+
+  '3*2Acoff_COFF',' (Go32v2) using internal writer'#010+
   '3*2Apecoff_PE-COFF (Win32) using internal writer'#010+
   '3*2Apecoff_PE-COFF (Win32) using internal writer'#010+
   '4*2Aas_Assemble using GNU AS'#010+
   '4*2Aas_Assemble using GNU AS'#010+
   '6*2Aas_Unix o-file using GNU AS'#010+
   '6*2Aas_Unix o-file using GNU AS'#010+
   '6*2Agas_GNU Motorola assembler'#010+
   '6*2Agas_GNU Motorola assembler'#010+
   '6*2Amit_MIT Syntax (old GAS)'#010+
   '6*2Amit_MIT Syntax (old GAS)'#010+
   '6*2Amot_Standard Motorola assembler'#010+
   '6*2Amot_Standard Motorola assembler'#010+
-  'A*2Aas_Assemb','le using GNU AS'#010+
+  'A*','2Aas_Assemble using GNU AS'#010+
   'P*2Aas_Assemble using GNU AS'#010+
   'P*2Aas_Assemble using GNU AS'#010+
   'S*2Aas_Assemble using GNU AS'#010+
   'S*2Aas_Assemble using GNU AS'#010+
   '**1b_Generate browser info'#010+
   '**1b_Generate browser info'#010+
   '**2bl_Generate local symbol info'#010+
   '**2bl_Generate local symbol info'#010+
   '**1B_Build all modules'#010+
   '**1B_Build all modules'#010+
   '**1C<x>_Code generation options:'#010+
   '**1C<x>_Code generation options:'#010+
-  '**2C3<x>_Turn on ieee error checking for constants',#010+
+  '**2C3<x>_Turn on ieee error checking fo','r constants'#010+
   '**2Ca<x>_Select ABI, see fpc -i for possible values'#010+
   '**2Ca<x>_Select ABI, see fpc -i for possible values'#010+
   '**2Cb_Generate big-endian code'#010+
   '**2Cb_Generate big-endian code'#010+
   '**2Cc<x>_Set default calling convention to <x>'#010+
   '**2Cc<x>_Set default calling convention to <x>'#010+
   '**2CD_Create also dynamic library (not supported)'#010+
   '**2CD_Create also dynamic library (not supported)'#010+
-  '**2Ce_Compilation with emulated floating point opcodes'#010+
-  '**2C','f<x>_Select fpu instruction set to use, see fpc -i for possible '+
-  'values'#010+
+  '**2Ce_Compilation with emulated floating point o','pcodes'#010+
+  '**2Cf<x>_Select fpu instruction set to use, see fpc -i for possible va'+
+  'lues'#010+
   '**2CF<x>_Minimal floating point constant precision (default, 32, 64)'#010+
   '**2CF<x>_Minimal floating point constant precision (default, 32, 64)'#010+
   '**2Cg_Generate PIC code'#010+
   '**2Cg_Generate PIC code'#010+
   '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#010+
   '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#010+
-  '**2Ci_IO-checking'#010+
-  '**2Cn_','Omit linking stage'#010+
+  '**2Ci_IO-chec','king'#010+
+  '**2Cn_Omit linking stage'#010+
   '**2Co_Check overflow of integer operations'#010+
   '**2Co_Check overflow of integer operations'#010+
   '**2CO_Check for possible overflow of integer operations'#010+
   '**2CO_Check for possible overflow of integer operations'#010+
   '**2Cp<x>_Select instruction set, see fpc -i for possible values'#010+
   '**2Cp<x>_Select instruction set, see fpc -i for possible values'#010+
   '**2CP<x>=<y>_ packing settings'#010+
   '**2CP<x>=<y>_ packing settings'#010+
-  '**3CPPACKSET=<y>_ <y> set a','llocation: 0, 1 or DEFAULT or NORMAL, 2, '+
+  '**3CPPACKSET=<y>','_ <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, '+
   '4 and 8'#010+
   '4 and 8'#010+
   '**2Cr_Range checking'#010+
   '**2Cr_Range checking'#010+
   '**2CR_Verify object method call validity'#010+
   '**2CR_Verify object method call validity'#010+
   '**2Cs<n>_Set stack checking size to <n>'#010+
   '**2Cs<n>_Set stack checking size to <n>'#010+
   '**2Ct_Stack checking (for testing only, see manual)'#010+
   '**2Ct_Stack checking (for testing only, see manual)'#010+
-  '**2CX_Create also smartlinked library',#010+
+  '**2CX_Create also smartlin','ked library'#010+
   '**1d<x>_Defines the symbol <x>'#010+
   '**1d<x>_Defines the symbol <x>'#010+
   '**1D_Generate a DEF file'#010+
   '**1D_Generate a DEF file'#010+
   '**2Dd<x>_Set description to <x>'#010+
   '**2Dd<x>_Set description to <x>'#010+
@@ -1155,53 +1155,53 @@ const msgtxt : array[0..000246,1..240] of char=(
   '**1e<x>_Set path to executable'#010+
   '**1e<x>_Set path to executable'#010+
   '**1E_Same as -Cn'#010+
   '**1E_Same as -Cn'#010+
   '**1fPIC_Same as -Cg'#010+
   '**1fPIC_Same as -Cg'#010+
-  '**1F<x>_Set file names and pat','hs:'#010+
+  '**1F<x>_Set file na','mes and paths:'#010+
   '**2Fa<x>[,y]_(for a program) load units <x> and [y] before uses is par'+
   '**2Fa<x>[,y]_(for a program) load units <x> and [y] before uses is par'+
   'sed'#010+
   'sed'#010+
   '**2Fc<x>_Set input codepage to <x>'#010+
   '**2Fc<x>_Set input codepage to <x>'#010+
   '**2FC<x>_Set RC compiler binary name to <x>'#010+
   '**2FC<x>_Set RC compiler binary name to <x>'#010+
   '**2Fd_Disable the compiler'#039's internal directory cache'#010+
   '**2Fd_Disable the compiler'#039's internal directory cache'#010+
-  '**2FD<x>_Set the directory wh','ere to search for compiler utilities'#010+
+  '**2FD<x>_Set the d','irectory where to search for compiler utilities'#010+
   '**2Fe<x>_Redirect error output to <x>'#010+
   '**2Fe<x>_Redirect error output to <x>'#010+
   '**2Ff<x>_Add <x> to framework path (Darwin only)'#010+
   '**2Ff<x>_Add <x> to framework path (Darwin only)'#010+
   '**2FE<x>_Set exe/unit output path to <x>'#010+
   '**2FE<x>_Set exe/unit output path to <x>'#010+
   '**2Fi<x>_Add <x> to include path'#010+
   '**2Fi<x>_Add <x> to include path'#010+
-  '**2Fl<x>_Add <x> to library path'#010+
-  '**2FL<x>_','Use <x> as dynamic linker'#010+
+  '**2Fl<x>_Add <x> to library pat','h'#010+
+  '**2FL<x>_Use <x> as dynamic linker'#010+
   '**2Fm<x>_Load unicode conversion table from <x>.txt in the compiler di'+
   '**2Fm<x>_Load unicode conversion table from <x>.txt in the compiler di'+
   'r'#010+
   'r'#010+
   '**2Fo<x>_Add <x> to object path'#010+
   '**2Fo<x>_Add <x> to object path'#010+
   '**2Fr<x>_Load error message file <x>'#010+
   '**2Fr<x>_Load error message file <x>'#010+
   '**2FR<x>_Set resource (.res) linker to <x>'#010+
   '**2FR<x>_Set resource (.res) linker to <x>'#010+
-  '**2Fu<x>_Add <x> to unit path'#010,
+  '**2Fu<x>_Add <x> to',' unit path'#010+
   '**2FU<x>_Set unit output path to <x>, overrides -FE'#010+
   '**2FU<x>_Set unit output path to <x>, overrides -FE'#010+
   '**2FW<x>_Store generated whole-program optimization feedback in <x>'#010+
   '**2FW<x>_Store generated whole-program optimization feedback in <x>'#010+
   '**2Fw<x>_Load previously stored whole-program optimization feedback fr'+
   '**2Fw<x>_Load previously stored whole-program optimization feedback fr'+
   'om <x>'#010+
   'om <x>'#010+
-  '*g1g_Generate debug information (default fo','rmat for target)'#010+
+  '*g1g_Generate debug information ','(default format for target)'#010+
   '*g2gc_Generate checks for pointers'#010+
   '*g2gc_Generate checks for pointers'#010+
   '*g2gh_Use heaptrace unit (for memory leak/corruption debugging)'#010+
   '*g2gh_Use heaptrace unit (for memory leak/corruption debugging)'#010+
   '*g2gl_Use line info unit (show more info with backtraces)'#010+
   '*g2gl_Use line info unit (show more info with backtraces)'#010+
   '*g2go<x>_Set debug information options'#010+
   '*g2go<x>_Set debug information options'#010+
-  '*g3godwarfsets_ Enable DWAR','F '#039'set'#039' type debug information (b'+
+  '*g3godwarfsets_ ','Enable DWARF '#039'set'#039' type debug information (b'+
   'reaks gdb < 6.5)'#010+
   'reaks gdb < 6.5)'#010+
   '*g3gostabsabsincludes_ Store absolute/full include file paths in Stabs'+
   '*g3gostabsabsincludes_ Store absolute/full include file paths in Stabs'+
   #010+
   #010+
   '*g3godwarfmethodclassprefix_ Prefix method names in DWARF with class n'+
   '*g3godwarfmethodclassprefix_ Prefix method names in DWARF with class n'+
   'ame'#010+
   'ame'#010+
-  '*g2gp_Preserve case in stabs symbol names'#010+
-  '*g2','gs_Generate Stabs debug information'#010+
+  '*g2gp_Preserve case in stabs symbo','l names'#010+
+  '*g2gs_Generate Stabs debug information'#010+
   '*g2gt_Trash local variables (to detect uninitialized uses)'#010+
   '*g2gt_Trash local variables (to detect uninitialized uses)'#010+
   '*g2gv_Generates programs traceable with Valgrind'#010+
   '*g2gv_Generates programs traceable with Valgrind'#010+
   '*g2gw_Generate DWARFv2 debug information (same as -gw2)'#010+
   '*g2gw_Generate DWARFv2 debug information (same as -gw2)'#010+
-  '*g2gw2_Generate DWARFv2 debug informatio','n'#010+
+  '*g2gw2_Generate DWARFv2 debug',' information'#010+
   '*g2gw3_Generate DWARFv3 debug information'#010+
   '*g2gw3_Generate DWARFv3 debug information'#010+
   '*g2gw4_Generate DWARFv4 debug information (experimental)'#010+
   '*g2gw4_Generate DWARFv4 debug information (experimental)'#010+
   '**1i_Information'#010+
   '**1i_Information'#010+
   '**2iD_Return compiler date'#010+
   '**2iD_Return compiler date'#010+
   '**2iV_Return short compiler version'#010+
   '**2iV_Return short compiler version'#010+
   '**2iW_Return full compiler version'#010+
   '**2iW_Return full compiler version'#010+
-  '**2iSO_Return compiler O','S'#010+
+  '**2iSO_Return',' compiler OS'#010+
   '**2iSP_Return compiler host processor'#010+
   '**2iSP_Return compiler host processor'#010+
   '**2iTO_Return target OS'#010+
   '**2iTO_Return target OS'#010+
   '**2iTP_Return target processor'#010+
   '**2iTP_Return target processor'#010+
@@ -1209,72 +1209,72 @@ const msgtxt : array[0..000246,1..240] of char=(
   '**1k<x>_Pass <x> to the linker'#010+
   '**1k<x>_Pass <x> to the linker'#010+
   '**1l_Write logo'#010+
   '**1l_Write logo'#010+
   '**1M<x>_Set language mode to <x>'#010+
   '**1M<x>_Set language mode to <x>'#010+
-  '**2Mfpc_Free Pascal dialect (defa','ult)'#010+
+  '**2Mfpc_Free Pascal di','alect (default)'#010+
   '**2Mobjfpc_FPC mode with Object Pascal support'#010+
   '**2Mobjfpc_FPC mode with Object Pascal support'#010+
   '**2Mdelphi_Delphi 7 compatibility mode'#010+
   '**2Mdelphi_Delphi 7 compatibility mode'#010+
   '**2Mtp_TP/BP 7.0 compatibility mode'#010+
   '**2Mtp_TP/BP 7.0 compatibility mode'#010+
   '**2Mmacpas_Macintosh Pascal dialects compatibility mode'#010+
   '**2Mmacpas_Macintosh Pascal dialects compatibility mode'#010+
   '**1n_Do not read the default config files'#010+
   '**1n_Do not read the default config files'#010+
-  '**1N<x>_Node tr','ee optimizations'#010+
+  '**1N','<x>_Node tree optimizations'#010+
   '**2Nu_Unroll loops'#010+
   '**2Nu_Unroll loops'#010+
   '**1o<x>_Change the name of the executable produced to <x>'#010+
   '**1o<x>_Change the name of the executable produced to <x>'#010+
   '**1O<x>_Optimizations:'#010+
   '**1O<x>_Optimizations:'#010+
   '**2O-_Disable optimizations'#010+
   '**2O-_Disable optimizations'#010+
   '**2O1_Level 1 optimizations (quick and debugger friendly)'#010+
   '**2O1_Level 1 optimizations (quick and debugger friendly)'#010+
-  '**2O2_Level 2 optimizations (-O1 + qu','ick optimizations)'#010+
+  '**2O2_Level 2 optimization','s (-O1 + quick optimizations)'#010+
   '**2O3_Level 3 optimizations (-O2 + slow optimizations)'#010+
   '**2O3_Level 3 optimizations (-O2 + slow optimizations)'#010+
   '**2Oa<x>=<y>_Set alignment'#010+
   '**2Oa<x>=<y>_Set alignment'#010+
   '**2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possible '+
   '**2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possible '+
   'values'#010+
   'values'#010+
-  '**2Op<x>_Set target cpu for optimizing, see fpc -i for possibl','e valu'+
+  '**2Op<x>_Set target cpu for optimizing, see fpc -i ','for possible valu'+
   'es'#010+
   'es'#010+
   '**2OW<x>_Generate whole-program optimization feedback for optimization'+
   '**2OW<x>_Generate whole-program optimization feedback for optimization'+
   ' <x>, see fpc -i for possible values'#010+
   ' <x>, see fpc -i for possible values'#010+
   '**2Ow<x>_Perform whole-program optimization <x>, see fpc -i for possib'+
   '**2Ow<x>_Perform whole-program optimization <x>, see fpc -i for possib'+
   'le values'#010+
   'le values'#010+
-  '**2Os_Optimize for size rather than speed'#010+
-  '**','1pg_Generate profile code for gprof (defines FPC_PROFILE)'#010+
+  '**2Os_Optimize for size rather th','an speed'#010+
+  '**1pg_Generate profile code for gprof (defines FPC_PROFILE)'#010+
   '**1R<x>_Assembler reading style:'#010+
   '**1R<x>_Assembler reading style:'#010+
   '**2Rdefault_Use default assembler for target'#010+
   '**2Rdefault_Use default assembler for target'#010+
   '3*2Ratt_Read AT&T style assembler'#010+
   '3*2Ratt_Read AT&T style assembler'#010+
   '3*2Rintel_Read Intel style assembler'#010+
   '3*2Rintel_Read Intel style assembler'#010+
-  '6*2RMOT_Read motorola style assem','bler'#010+
+  '6*2RMOT_Read motorola ','style assembler'#010+
   '**1S<x>_Syntax options:'#010+
   '**1S<x>_Syntax options:'#010+
   '**2S2_Same as -Mobjfpc'#010+
   '**2S2_Same as -Mobjfpc'#010+
   '**2Sc_Support operators like C (*=,+=,/= and -=)'#010+
   '**2Sc_Support operators like C (*=,+=,/= and -=)'#010+
   '**2Sa_Turn on assertions'#010+
   '**2Sa_Turn on assertions'#010+
   '**2Sd_Same as -Mdelphi'#010+
   '**2Sd_Same as -Mdelphi'#010+
   '**2Se<x>_Error options. <x> is a combination of the following:'#010+
   '**2Se<x>_Error options. <x> is a combination of the following:'#010+
-  '**3*_<n> : Compiler halts af','ter the <n> errors (default is 1)'#010+
+  '**3*_<n> : Compil','er halts after the <n> errors (default is 1)'#010+
   '**3*_w : Compiler also halts after warnings'#010+
   '**3*_w : Compiler also halts after warnings'#010+
   '**3*_n : Compiler also halts after notes'#010+
   '**3*_n : Compiler also halts after notes'#010+
   '**3*_h : Compiler also halts after hints'#010+
   '**3*_h : Compiler also halts after hints'#010+
   '**2Sg_Enable LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+
   '**2Sg_Enable LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+
-  '**2Sh_Use ansistrings',' by default instead of shortstrings'#010+
+  '**2Sh_Use ','ansistrings by default instead of shortstrings'#010+
   '**2Si_Turn on inlining of procedures/functions declared as "inline"'#010+
   '**2Si_Turn on inlining of procedures/functions declared as "inline"'#010+
   '**2Sk_Load fpcylix unit'#010+
   '**2Sk_Load fpcylix unit'#010+
   '**2SI<x>_Set interface style to <x>'#010+
   '**2SI<x>_Set interface style to <x>'#010+
   '**3SIcom_COM compatible interface (default)'#010+
   '**3SIcom_COM compatible interface (default)'#010+
-  '**3SIcorba_CORBA compatible inte','rface'#010+
+  '**3SIcorba_CORBA comp','atible interface'#010+
   '**2Sm_Support macros like C (global)'#010+
   '**2Sm_Support macros like C (global)'#010+
   '**2So_Same as -Mtp'#010+
   '**2So_Same as -Mtp'#010+
   '**2Ss_Constructor name must be init (destructor must be done)'#010+
   '**2Ss_Constructor name must be init (destructor must be done)'#010+
   '**2Sx_Enable exception keywords (default in Delphi/ObjFPC modes)'#010+
   '**2Sx_Enable exception keywords (default in Delphi/ObjFPC modes)'#010+
   '**1s_Do not call assembler and linker'#010+
   '**1s_Do not call assembler and linker'#010+
-  '**2sh_Generat','e script to link on host'#010+
+  '**','2sh_Generate script to link on host'#010+
   '**2st_Generate script to link on target'#010+
   '**2st_Generate script to link on target'#010+
   '**2sr_Skip register allocation phase (use with -alr)'#010+
   '**2sr_Skip register allocation phase (use with -alr)'#010+
   '**1T<x>_Target operating system:'#010+
   '**1T<x>_Target operating system:'#010+
   '3*2Tdarwin_Darwin/Mac OS X'#010+
   '3*2Tdarwin_Darwin/Mac OS X'#010+
   '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
   '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
-  '3*2Tfreebsd_','FreeBSD'#010+
+  '3','*2Tfreebsd_FreeBSD'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tiphonesim_ iPhoneSimulator from iOS SDK 3.2+ (older versions: -Tda'+
   '3*2Tiphonesim_ iPhoneSimulator from iOS SDK 3.2+ (older versions: -Tda'+
   'rwin)'#010+
   'rwin)'#010+
   '3*2Tlinux_Linux'#010+
   '3*2Tlinux_Linux'#010+
   '3*2Tnetbsd_NetBSD'#010+
   '3*2Tnetbsd_NetBSD'#010+
   '3*2Tnetware_Novell Netware Module (clib)'#010+
   '3*2Tnetware_Novell Netware Module (clib)'#010+
-  '3*2Tnetwlibc_Novell Netware Modul','e (libc)'#010+
+  '3*2Tnetwlibc_Novell Ne','tware Module (libc)'#010+
   '3*2Topenbsd_OpenBSD'#010+
   '3*2Topenbsd_OpenBSD'#010+
   '3*2Tos2_OS/2 / eComStation'#010+
   '3*2Tos2_OS/2 / eComStation'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
@@ -1283,7 +1283,7 @@ const msgtxt : array[0..000246,1..240] of char=(
   '3*2Twatcom_Watcom compatible DOS extender'#010+
   '3*2Twatcom_Watcom compatible DOS extender'#010+
   '3*2Twdosx_WDOSX DOS extender'#010+
   '3*2Twdosx_WDOSX DOS extender'#010+
   '3*2Twin32_Windows 32 Bit'#010+
   '3*2Twin32_Windows 32 Bit'#010+
-  '3*2Twince_Windows CE'#010,
+  '3*2Twince_','Windows CE'#010+
   '4*2Tdarwin_Darwin/Mac OS X'#010+
   '4*2Tdarwin_Darwin/Mac OS X'#010+
   '4*2Tlinux_Linux'#010+
   '4*2Tlinux_Linux'#010+
   '4*2Twin64_Win64 (64 bit Windows systems)'#010+
   '4*2Twin64_Win64 (64 bit Windows systems)'#010+
@@ -1293,8 +1293,8 @@ const msgtxt : array[0..000246,1..240] of char=(
   '6*2Tpalmos_PalmOS'#010+
   '6*2Tpalmos_PalmOS'#010+
   'A*2Tdarwin_Darwin/iPhoneOS/iOS'#010+
   'A*2Tdarwin_Darwin/iPhoneOS/iOS'#010+
   'A*2Tlinux_Linux'#010+
   'A*2Tlinux_Linux'#010+
-  'A*2Twince_Windows CE'#010+
-  'P*','2Tamiga_AmigaOS'#010+
+  'A*2Twince_Wi','ndows CE'#010+
+  'P*2Tamiga_AmigaOS'#010+
   'P*2Tdarwin_Darwin/Mac OS X'#010+
   'P*2Tdarwin_Darwin/Mac OS X'#010+
   'P*2Tlinux_Linux'#010+
   'P*2Tlinux_Linux'#010+
   'P*2Tmacos_Mac OS (classic)'#010+
   'P*2Tmacos_Mac OS (classic)'#010+
@@ -1303,82 +1303,82 @@ const msgtxt : array[0..000246,1..240] of char=(
   'S*2Tlinux_Linux'#010+
   'S*2Tlinux_Linux'#010+
   '**1u<x>_Undefines the symbol <x>'#010+
   '**1u<x>_Undefines the symbol <x>'#010+
   '**1U_Unit options:'#010+
   '**1U_Unit options:'#010+
-  '**2Un_Do not check where the unit name matches',' the file name'#010+
+  '**2Un_Do not check where the unit n','ame matches the file name'#010+
   '**2Ur_Generate release unit files (never automatically recompiled)'#010+
   '**2Ur_Generate release unit files (never automatically recompiled)'#010+
   '**2Us_Compile a system unit'#010+
   '**2Us_Compile a system unit'#010+
   '**1v<x>_Be verbose. <x> is a combination of the following letters:'#010+
   '**1v<x>_Be verbose. <x> is a combination of the following letters:'#010+
-  '**2*_e : Show errors (default)       0 : Show nothing (except e','rrors'+
+  '**2*_e : Show errors (default)       0 : Show nothin','g (except errors'+
   ')'#010+
   ')'#010+
   '**2*_w : Show warnings               u : Show unit info'#010+
   '**2*_w : Show warnings               u : Show unit info'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
   '**2*_h : Show hints                  c : Show conditionals'#010+
   '**2*_h : Show hints                  c : Show conditionals'#010+
-  '**2*_i : Show general info           d : Show debug inf','o'#010+
+  '**2*_i : Show general info           d : Sho','w debug info'#010+
   '**2*_l : Show linenumbers            r : Rhide/GCC compatibility mode'#010+
   '**2*_l : Show linenumbers            r : Rhide/GCC compatibility mode'#010+
   '**2*_s : Show time stamps            q : Show message numbers'#010+
   '**2*_s : Show time stamps            q : Show message numbers'#010+
   '**2*_a : Show everything             x : Executable info (Win32 only)'#010+
   '**2*_a : Show everything             x : Executable info (Win32 only)'#010+
-  '**2*_b : Write file names messages  ',' p : Write tree.log with parse t'+
+  '**2*_b : Write file names',' messages   p : Write tree.log with parse t'+
   'ree'#010+
   'ree'#010+
   '**2*_    with full path              v : Write fpcdebug.txt with'#010+
   '**2*_    with full path              v : Write fpcdebug.txt with'#010+
   '**2*_                                    lots of debugging info'#010+
   '**2*_                                    lots of debugging info'#010+
   '**2*_m<x>,<y> : Don'#039't show messages numbered <x> and <y>'#010+
   '**2*_m<x>,<y> : Don'#039't show messages numbered <x> and <y>'#010+
-  '3*1W<x>_Target-spe','cific options (targets)'#010+
+  '3*1W<x>','_Target-specific options (targets)'#010+
   'A*1W<x>_Target-specific options (targets)'#010+
   'A*1W<x>_Target-specific options (targets)'#010+
   'P*1W<x>_Target-specific options (targets)'#010+
   'P*1W<x>_Target-specific options (targets)'#010+
   'p*1W<x>_Target-specific options (targets)'#010+
   'p*1W<x>_Target-specific options (targets)'#010+
   '3*2Wb_Create a bundle instead of a library (Darwin)'#010+
   '3*2Wb_Create a bundle instead of a library (Darwin)'#010+
-  'P*2Wb_Create a bundle instead of a lib','rary (Darwin)'#010+
+  'P*2Wb_Create a bundle inste','ad of a library (Darwin)'#010+
   'p*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'p*2Wb_Create a bundle instead of a library (Darwin)'#010+
   '3*2WB_Create a relocatable image (Windows)'#010+
   '3*2WB_Create a relocatable image (Windows)'#010+
   'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
   'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
   '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
   '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
-  'A*2WC_Specify conso','le type application (Windows)'#010+
+  'A*2WC_Sp','ecify console type application (Windows)'#010+
   'P*2WC_Specify console type application (Classic Mac OS)'#010+
   'P*2WC_Specify console type application (Classic Mac OS)'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
-  '3*2We_Use external resources (','Darwin)'#010+
+  '3*2We_Use external ','resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
   'A*2We_Use external resources (Darwin)'#010+
   'A*2We_Use external resources (Darwin)'#010+
   'P*2We_Use external resources (Darwin)'#010+
   'P*2We_Use external resources (Darwin)'#010+
   'p*2We_Use external resources (Darwin)'#010+
   'p*2We_Use external resources (Darwin)'#010+
   '3*2WF_Specify full-screen type application (EMX, OS/2)'#010+
   '3*2WF_Specify full-screen type application (EMX, OS/2)'#010+
-  '3*2WG_Specify graphic typ','e application (EMX, OS/2, Windows)'#010+
+  '3*2WG_Specify ','graphic type application (EMX, OS/2, Windows)'#010+
   'A*2WG_Specify graphic type application (Windows)'#010+
   'A*2WG_Specify graphic type application (Windows)'#010+
   'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
   'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
   '3*2Wi_Use internal resources (Darwin)'#010+
   '3*2Wi_Use internal resources (Darwin)'#010+
   'P*2Wi_Use internal resources (Darwin)'#010+
   'P*2Wi_Use internal resources (Darwin)'#010+
-  'p*2Wi_Use internal resou','rces (Darwin)'#010+
+  'p*2Wi_Use int','ernal resources (Darwin)'#010+
   '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   '3*2WR_Generate relocation code (Windows)'#010+
   '3*2WR_Generate relocation code (Windows)'#010+
-  'A*2WR_Generate relocation code (Windows)'#010+
-  'P*2W','T_Specify MPW tool type application (Classic Mac OS)'#010+
+  'A*2WR_Generate relocation code (Wi','ndows)'#010+
+  'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+
   '3*2WX_Enable executable stack (Linux)'#010+
   '3*2WX_Enable executable stack (Linux)'#010+
   'A*2WX_Enable executable stack (Linux)'#010+
   'A*2WX_Enable executable stack (Linux)'#010+
   'p*2WX_Enable executable stack (Linux)'#010+
   'p*2WX_Enable executable stack (Linux)'#010+
   'P*2WX_Enable executable stack (Linux)'#010+
   'P*2WX_Enable executable stack (Linux)'#010+
-  '**1X_Executable options:'#010+
-  '**2Xc_Pass',' --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, L'+
-  'inux)'#010+
+  '**1X_Executable options:',#010+
+  '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin'+
+  'ux)'#010+
   '**2Xd_Do not use standard library search path (needed for cross compil'+
   '**2Xd_Do not use standard library search path (needed for cross compil'+
   'e)'#010+
   'e)'#010+
   '**2Xe_Use external linker'#010+
   '**2Xe_Use external linker'#010+
-  '**2Xg_Create debuginfo in a separate file and add a debuglink section '+
-  'to exec','utable'#010+
+  '**2Xg_Create debuginfo in a separate file and add a debuglink sect','io'+
+  'n to executable'#010+
   '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
   '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
   '**2Xi_Use internal linker'#010+
   '**2Xi_Use internal linker'#010+
   '**2Xm_Generate link map'#010+
   '**2Xm_Generate link map'#010+
   '**2XM<x>_Set the name of the '#039'main'#039' program routine (default i'+
   '**2XM<x>_Set the name of the '#039'main'#039' program routine (default i'+
   's '#039'main'#039')'#010+
   's '#039'main'#039')'#010+
-  '**2XP<x>_Prepend the binutils names with th','e prefix <x>'#010+
+  '**2XP<x>_Prepend the binutils na','mes with the prefix <x>'#010+
   '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
   '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
   'ile, see the ld manual for more information) (BeOS, Linux)'#010+
   'ile, see the ld manual for more information) (BeOS, Linux)'#010+
   '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD'+
   '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD'+
-  ', Linux, Mac OS, Solaris)'#010+
-  '**2Xs_','Strip all symbols from executable'#010+
+  ', Linux, Mac OS, Sola','ris)'#010+
+  '**2Xs_Strip all symbols from executable'#010+
   '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
   '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
   '**2Xt_Link with static libraries (-static is passed to linker)'#010+
   '**2Xt_Link with static libraries (-static is passed to linker)'#010+
-  '**2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
+  '**2XX_Try to smartlink units             (defines FPC_LINK_SMA','RT)'#010+
   '**1*_'#010+
   '**1*_'#010+
-  '*','*1?_Show this help'#010+
+  '**1?_Show this help'#010+
   '**1h_Shows this help without waiting'
   '**1h_Shows this help without waiting'
 );
 );

+ 21 - 1
compiler/ncal.pas

@@ -201,6 +201,9 @@ interface
           function can_be_inlined: boolean;
           function can_be_inlined: boolean;
 
 
           property nextpara : tnode read right write right;
           property nextpara : tnode read right write right;
+          { third is reused to store the parameter name (only while parsing
+            vardispatch calls, never in real node tree) and copy of 'high'
+            parameter tree when the parameter is an open array of managed type }
           property parametername : tnode read third write third;
           property parametername : tnode read third write third;
 
 
           { returns whether the evaluation of this parameter involves a
           { returns whether the evaluation of this parameter involves a
@@ -620,6 +623,8 @@ implementation
          old_array_constructor:=allow_array_constructor;
          old_array_constructor:=allow_array_constructor;
          allow_array_constructor:=true;
          allow_array_constructor:=true;
          typecheckpass(left);
          typecheckpass(left);
+         if assigned(third) then
+           typecheckpass(third);
          allow_array_constructor:=old_array_constructor;
          allow_array_constructor:=old_array_constructor;
          if codegenerror then
          if codegenerror then
           resultdef:=generrordef
           resultdef:=generrordef
@@ -635,6 +640,8 @@ implementation
         if not assigned(left.resultdef) then
         if not assigned(left.resultdef) then
           get_paratype;
           get_paratype;
         firstpass(left);
         firstpass(left);
+        if assigned(third) then
+          firstpass(third);
         expectloc:=left.expectloc;
         expectloc:=left.expectloc;
       end;
       end;
 
 
@@ -2492,6 +2499,7 @@ implementation
         varargspara,
         varargspara,
         currpara : tparavarsym;
         currpara : tparavarsym;
         hiddentree : tnode;
         hiddentree : tnode;
+        paradef  : tdef;
       begin
       begin
         pt:=tcallparanode(left);
         pt:=tcallparanode(left);
         oldppt:=pcallparanode(@left);
         oldppt:=pcallparanode(@left);
@@ -2527,7 +2535,19 @@ implementation
                   if not assigned(pt) or (i=0) then
                   if not assigned(pt) or (i=0) then
                     internalerror(200304081);
                     internalerror(200304081);
                   { we need the information of the previous parameter }
                   { we need the information of the previous parameter }
-                  hiddentree:=gen_high_tree(pt.left,tparavarsym(procdefinition.paras[i-1]).vardef);
+                  paradef:=tparavarsym(procdefinition.paras[i-1]).vardef;
+                  hiddentree:=gen_high_tree(pt.left,paradef);
+                  { for open array of managed type, a copy of high parameter is
+                    necessary to properly initialize before the call }
+                  if is_open_array(paradef) and
+                    (tparavarsym(procdefinition.paras[i-1]).varspez=vs_out) and
+                     is_managed_type(tarraydef(paradef).elementdef) then
+                    begin
+                      typecheckpass(hiddentree);
+                      {this eliminates double call to fpc_dynarray_high, if any}
+                      maybe_load_in_temp(hiddentree);
+                      oldppt^.third:=hiddentree.getcopy;
+                    end;
                 end
                 end
               else
               else
                 if vo_is_typinfo_para in currpara.varoptions then
                 if vo_is_typinfo_para in currpara.varoptions then

+ 10 - 1
compiler/ncgcal.pas

@@ -167,7 +167,16 @@ implementation
                 is_managed_type(left.resultdef) then
                 is_managed_type(left.resultdef) then
                begin
                begin
                  location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
                  location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
-                 cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
+                 if is_open_array(resultdef) then
+                   begin
+                     if third=nil then
+                       InternalError(201103063);
+                     secondpass(third);
+                     cg.g_array_rtti_helper(current_asmdata.CurrAsmList,tarraydef(resultdef).elementdef,
+                       href,third.location,'FPC_DECREF_ARRAY');
+                   end
+                 else
+                   cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
                end;
                end;
 
 
              paramanager.createtempparaloc(current_asmdata.CurrAsmList,aktcallnode.procdefinition.proccalloption,parasym,not followed_by_stack_tainting_call_cached,tempcgpara);
              paramanager.createtempparaloc(current_asmdata.CurrAsmList,aktcallnode.procdefinition.proccalloption,parasym,not followed_by_stack_tainting_call_cached,tempcgpara);

+ 56 - 141
compiler/ncgmem.pas

@@ -59,6 +59,7 @@ interface
          function get_mul_size : aint;
          function get_mul_size : aint;
        private
        private
          procedure rangecheck_array;
          procedure rangecheck_array;
+         procedure rangecheck_string;
        protected
        protected
          {# This routine is used to calculate the address of the reference.
          {# This routine is used to calculate the address of the reference.
             On entry reg contains the index in the array,
             On entry reg contains the index in the array,
@@ -635,6 +636,10 @@ implementation
          hreg : tregister;
          hreg : tregister;
          paraloc1,paraloc2 : tcgpara;
          paraloc1,paraloc2 : tcgpara;
        begin
        begin
+         { omit range checking when this is an array access to a pointer which has been
+           typecasted from an array }
+         if (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions) then
+           exit;
          paraloc1.init;
          paraloc1.init;
          paraloc2.init;
          paraloc2.init;
          if is_open_array(left.resultdef) or
          if is_open_array(left.resultdef) or
@@ -690,6 +695,45 @@ implementation
          paraloc2.done;
          paraloc2.done;
        end;
        end;
 
 
+    procedure tcgvecnode.rangecheck_string;
+      var
+        paraloc1,
+        paraloc2: tcgpara;
+      begin
+        paraloc1.init;
+        paraloc2.init;
+        case tstringdef(left.resultdef).stringtype of
+          { it's the same for ansi- and wide strings }
+          st_unicodestring,
+          st_widestring,
+          st_ansistring:
+            begin
+              paramanager.getintparaloc(pocall_default,1,paraloc1);
+              paramanager.getintparaloc(pocall_default,2,paraloc2);
+              cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
+              cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
+
+              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
+              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
+              cg.allocallcpuregisters(current_asmdata.CurrAsmList);
+              cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_RANGECHECK',false);
+              cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
+            end;
+
+          st_shortstring:
+            begin
+              {!!!!!!!!!!!!!!!!!}
+              { if this one is implemented making use of the high parameter for openshortstrings, update ncgutils.do_get_used_regvars() too (JM) }
+            end;
+
+          st_longstring:
+            begin
+              {!!!!!!!!!!!!!!!!!}
+            end;
+        end;
+        paraloc1.done;
+        paraloc2.done;
+      end;
 
 
     procedure tcgvecnode.pass_generate_code;
     procedure tcgvecnode.pass_generate_code;
 
 
@@ -697,7 +741,6 @@ implementation
          offsetdec,
          offsetdec,
          extraoffset : aint;
          extraoffset : aint;
          t        : tnode;
          t        : tnode;
-         href     : treference;
          otl,ofl  : tasmlabel;
          otl,ofl  : tasmlabel;
          newsize  : tcgsize;
          newsize  : tcgsize;
          mulsize,
          mulsize,
@@ -726,8 +769,7 @@ implementation
 
 
          { an ansistring needs to be dereferenced }
          { an ansistring needs to be dereferenced }
          if is_ansistring(left.resultdef) or
          if is_ansistring(left.resultdef) or
-            is_widestring(left.resultdef) or
-            is_unicodestring(left.resultdef) then
+            is_wide_or_unicode_string(left.resultdef) then
            begin
            begin
               if nf_callunique in flags then
               if nf_callunique in flags then
                 internalerror(200304236);
                 internalerror(200304236);
@@ -754,18 +796,6 @@ implementation
                   internalerror(2002032218);
                   internalerror(2002032218);
               end;
               end;
 
 
-              { check for a zero length string,
-                we can use the ansistring routine here }
-              if (cs_check_range in current_settings.localswitches) then
-                begin
-                   paramanager.getintparaloc(pocall_default,1,paraloc1);
-                   cg.a_load_reg_cgpara(current_asmdata.CurrAsmList,OS_ADDR,location.reference.base,paraloc1);
-                   paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                   cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                   cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_CHECKZERO',false);
-                   cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-                end;
-
               { in ansistrings/widestrings S[1] is p<w>char(S)[0] !! }
               { in ansistrings/widestrings S[1] is p<w>char(S)[0] !! }
               if is_ansistring(left.resultdef) then
               if is_ansistring(left.resultdef) then
                 offsetdec:=1
                 offsetdec:=1
@@ -828,84 +858,16 @@ implementation
          if right.nodetype=ordconstn then
          if right.nodetype=ordconstn then
            begin
            begin
               { offset can only differ from 0 if arraydef }
               { offset can only differ from 0 if arraydef }
-              case left.resultdef.typ of
-                arraydef :
-                  begin
-		     { do not do any range checking when this is an array access to a pointer which has been
-		       typecasted from an array }
-		     if (not (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions)) then
-		       begin
-                     	if not(is_open_array(left.resultdef)) and
-                           not(is_array_of_const(left.resultdef)) and
-                           not(is_dynamic_array(left.resultdef)) then
-                          begin
-                            if (tordconstnode(right).value.svalue>tarraydef(left.resultdef).highrange) or
-                               (tordconstnode(right).value.svalue<tarraydef(left.resultdef).lowrange) then
-                              begin
-                                { this should be caught in the typecheckpass! (JM) }
-                                if (cs_check_range in current_settings.localswitches) then
-                                  CGMessage(parser_e_range_check_error)
-                                else
-                                  CGMessage(parser_w_range_check_error);
-                              end;
-                           end
-                         else
-                           begin
-                              { range checking for open and dynamic arrays needs
-                                runtime code }
-                              secondpass(right);
-                              if (cs_check_range in current_settings.localswitches) then
-                                rangecheck_array;
-                           end;
-		       end;
+              if cs_check_range in current_settings.localswitches then
+                begin
+                  secondpass(right);
+                  case left.resultdef.typ of
+                    arraydef :
+                      rangecheck_array;
+                    stringdef :
+                      rangecheck_string;
                   end;
                   end;
-                stringdef :
-                  begin
-                    if (cs_check_range in current_settings.localswitches) then
-                     begin
-                       case tstringdef(left.resultdef).stringtype of
-                         { it's the same for ansi- and wide strings }
-                         st_unicodestring,
-                         st_widestring,
-                         st_ansistring:
-                           begin
-                              paramanager.getintparaloc(pocall_default,1,paraloc1);
-                              paramanager.getintparaloc(pocall_default,2,paraloc2);
-                              cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_INT,tordconstnode(right).value.svalue,paraloc2);
-                              href:=location.reference;
-                              if not(tf_winlikewidestring in target_info.flags) or
-                                 (tstringdef(left.resultdef).stringtype<>st_widestring) then
-                                begin
-                                  dec(href.offset,sizeof(pint)-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_ADDR,href,paraloc1);
-                                end
-                              else
-                                begin
-                                  { winlike widestrings have a 4 byte length }
-                                  dec(href.offset,4-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_32,href,paraloc1);
-                                end;
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
-                              cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                              cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_RANGECHECK',false);
-                              cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-                           end;
-
-                         st_shortstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                              { if this one is implemented making use of the high parameter for openshortstrings, update ncgutils.do_get_used_regvars() too (JM) }
-                           end;
-
-                         st_longstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                           end;
-                       end;
-                     end;
-                   end;
-              end;
+                end;
               if not(is_packed_array(left.resultdef)) or
               if not(is_packed_array(left.resultdef)) or
                  ((mulsize mod 8 = 0) and
                  ((mulsize mod 8 = 0) and
                   (ispowerof2(mulsize div 8,temp) or
                   (ispowerof2(mulsize div 8,temp) or
@@ -1015,56 +977,9 @@ implementation
               if cs_check_range in current_settings.localswitches then
               if cs_check_range in current_settings.localswitches then
                begin
                begin
                  if left.resultdef.typ=arraydef then
                  if left.resultdef.typ=arraydef then
-                   begin
-		     { do not do any range checking when this is an array access to a pointer which has been
-		       typecasted from an array }
-		     if (not (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions)) then
-                       rangecheck_array
-                   end
+                   rangecheck_array
                  else if (left.resultdef.typ=stringdef) then
                  else if (left.resultdef.typ=stringdef) then
-                   begin
-                      case tstringdef(left.resultdef).stringtype of
-                         { it's the same for ansi- and wide strings }
-                         st_unicodestring,
-                         st_widestring,
-                         st_ansistring:
-                           begin
-                              paramanager.getintparaloc(pocall_default,1,paraloc1);
-                              paramanager.getintparaloc(pocall_default,2,paraloc2);
-                              cg.a_load_reg_cgpara(current_asmdata.CurrAsmList,OS_INT,right.location.register,paraloc2);
-                              href:=location.reference;
-                              dec(href.offset,sizeof(pint)-offsetdec);
-
-                              href:=location.reference;
-                              if not(tf_winlikewidestring in target_info.flags) or
-                                 (tstringdef(left.resultdef).stringtype<>st_widestring) then
-                                begin
-                                  dec(href.offset,sizeof(pint)-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_ADDR,href,paraloc1);
-                                end
-                              else
-                                begin
-                                  { winlike widestrings have a 4 byte length }
-                                  dec(href.offset,4-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_32,href,paraloc1);
-                                end;
-
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
-                              cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                              cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_RANGECHECK',false);
-                              cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-                           end;
-                         st_shortstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                           end;
-                         st_longstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                           end;
-                      end;
-                   end;
+                   rangecheck_string;
                end;
                end;
 
 
               { insert the register and the multiplication factor in the
               { insert the register and the multiplication factor in the

+ 5 - 0
compiler/nset.pas

@@ -231,6 +231,11 @@ implementation
 
 
          if (right.nodetype=typen) then
          if (right.nodetype=typen) then
            begin
            begin
+             if right.resultdef.typ<>setdef then
+               begin
+                 CGMessage(sym_e_set_expected);
+                 exit;
+               end;
              { we need to create a setconstn }
              { we need to create a setconstn }
              pst:=createsetconst(tsetdef(ttypenode(right).resultdef));
              pst:=createsetconst(tsetdef(ttypenode(right).resultdef));
              t:=csetconstnode.create(pst,ttypenode(right).resultdef);
              t:=csetconstnode.create(pst,ttypenode(right).resultdef);

+ 7 - 1
compiler/ogbase.pas

@@ -482,6 +482,7 @@ interface
         procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);virtual;
         procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);virtual;
         procedure GenerateDebugLink(const dbgname:string;dbgcrc:cardinal);
         procedure GenerateDebugLink(const dbgname:string;dbgcrc:cardinal);
         function WriteExeFile(const fn:string):boolean;
         function WriteExeFile(const fn:string):boolean;
+        procedure ParseScript (linkscript:TCmdStrList); virtual;
         property Writer:TObjectWriter read FWriter;
         property Writer:TObjectWriter read FWriter;
         property ExeSectionList:TFPHashObjectList read FExeSectionList;
         property ExeSectionList:TFPHashObjectList read FExeSectionList;
         property ObjDataList:TFPObjectList read FObjDataList;
         property ObjDataList:TFPObjectList read FObjDataList;
@@ -544,7 +545,7 @@ implementation
 
 
     procedure TObjSymbol.SetAddress(apass:byte;aobjsec:TObjSection;abind:TAsmsymbind;atyp:Tasmsymtype);
     procedure TObjSymbol.SetAddress(apass:byte;aobjsec:TObjSection;abind:TAsmsymbind;atyp:Tasmsymtype);
       begin
       begin
-        if not(abind in [AB_GLOBAL,AB_LOCAL,AB_COMMON]) then
+        if not(abind in [AB_GLOBAL,AB_LOCAL,AB_COMMON,AB_IMPORT]) then
           internalerror(200603016);
           internalerror(200603016);
         if not assigned(aobjsec) then
         if not assigned(aobjsec) then
           internalerror(200603017);
           internalerror(200603017);
@@ -1549,6 +1550,11 @@ implementation
       end;
       end;
 
 
 
 
+    procedure TExeOutput.ParseScript (linkscript:TCmdStrList);
+      begin
+      end;
+
+
     function  TExeOutput.FindExeSection(const aname:string):TExeSection;
     function  TExeOutput.FindExeSection(const aname:string):TExeSection;
       begin
       begin
         result:=TExeSection(ExeSectionList.Find(aname));
         result:=TExeSection(ExeSectionList.Find(aname));

+ 1484 - 0
compiler/ognlm.pas

@@ -0,0 +1,1484 @@
+{
+    Copyright (c) 1998-2006 by Peter Vreman
+    Copyright (c) 2011 by Armin Diehl
+
+    Contains the binary netware nlm executable writer
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit ognlm;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+       { common }
+       cclasses,globtype,
+       { target }
+       systems,
+       aasmbase,assemble,link,
+       { output }
+       ogbase,
+       owbase,
+       ogcoff;
+
+{*****************************************************************************
+                    NLM File structures and constants
+*****************************************************************************}
+
+{
+
+LString0 -> 1 byte Length, Text, #0
+LString  -> 1 byte length, Text
+
+Basic NLM File Structure:
+
+FixedHeader
+  nlm32_i386_external_fixed_header     130 bytes
+
+VarHdr1
+  NLM Description: LString0              2+n bytes
+  Stacksize                              4 bytes
+  reserved = 0                           4 bytes
+  ' LONG'                                5 bytes
+  NLM screen name: LString0              2+n bytes
+  NLM thread name: LString0              2+n bytes
+
+Optional Headers beginning with stamp (without '')
+'VeRsIoN#':   nlm32_i386_external_version_header     32 bytes
+'CoPyRiGhT=': LString0                              2+n bytes
+'MeSsAgEs':   nlm32_i386_external_extended_header   124 bytes
+'CuStHeAd':   nlm32_i386_external_custom_header
+'CyGnUsEx':   nlm32_i386_external_cygnus_ext_header 16 bytes
+
+.text
+.data
+.relocs=
+  addr(32),addr(32),...
+  addr and $80000000 > 0 -> FixupToSeg=.text else .data
+  addr and $40000000 > 0 -> FixupInSeg=.text else .data
+.importedSymbols
+  name   LString                                   1+n bytes
+  number of references r                             4 bytes
+  addresses                                        r*4 bytes
+.exportedSymbols
+  name   LString                                   1+n bytes
+  addr                                               4 bytes
+    addr and $80000000 > 0 -> .text else .data
+  ...
+.modules
+
+.nlmdebugrecs
+  type (0=.data,1=.code,2,..=????)                   1 byte
+  addr                                               4 bytes
+  name LString                                     1+n bytes
+  ...
+
+}
+
+
+const NLM_MAX_DESCRIPTION_LENGTH = 127;
+      NLM_MAX_SCREEN_NAME_LENGTH = 71;
+      NLM_MAX_THREAD_NAME_LENGTH = 71;   // some netware docs limit this to 12 ?
+      NLM_OLD_THREAD_NAME_LENGTH = 5;
+      NLM_HEADER_VERSION         = 4;
+      NLM_DEFAULT_STACKSIZE      = (32 * 1024);
+      NLM_VERSION_STAMP          = 'VeRsIoN#';
+      NLM_COPYRIGHT_STAMP        = 'CoPyRiGhT=';
+      NLM_CYGNUS_STAMP           = 'CyGnUsEx';
+      NLM_MESSAGES_STAMP         = 'MeSsAgEs';
+      NLM_CUSTOM_STAMP           = 'CuStHeAd';
+      NLM_SIGNATURE              = 'NetWare Loadable Module'#$1A;
+      NLM_FLAGS_REENTRANT        = 1;
+      NLM_FLAGS_MULTILOAD        = 2;
+      NLM_FLAGS_SYNCHRONIZE      = 4;
+      NLM_FLAGS_PSEUDOPREEMPTION = 8;
+      NLM_FLAGS_OSDOMAIN         = $10;
+      NLM_FLAGS_AUTOUNLOAD       = $40;
+
+
+  type
+    uint32 = longword;
+
+    nlm32_i386_external_fixed_header = packed record
+        signature                  : array[0..23] of char;
+        version                    : uint32;
+        (* The name of the module, which must be a DOS name (1-8 characters followed
+           by a period and a 1-3 character extension).  The first byte is the byte
+           length of the name and the last byte is a null terminator byte.  This
+           field is fixed length, and any unused bytes should be null bytes.  The
+           value is set by the OUTPUT keyword to NLMLINK. *)
+        moduleName                 : string[13]; //array[0..13] of byte;
+        codeImageOffset            : uint32;     // The byte offset of the code image from the start of the file.
+        codeImageSize              : uint32;     // The size of the code image, in bytes.
+        dataImageOffset            : uint32;     // The byte offset of the data image from the start of the file.
+        dataImageSize              : uint32;     // The size of the data image, in bytes.
+        uninitializedDataSize      : uint32;     // The size of the uninitialized data region that the loader has to be
+                                                 // allocated at load time.  Uninitialized data follows the initialized
+                                                 // data in the NLM address space.
+        customDataOffset           : uint32;     // The byte offset of the custom data from the start of the file.  The
+                                                 // custom data is set by the CUSTOM keyword to NLMLINK.  It is possible
+                                                 // for this to be EOF if there is no custom data.
+        customDataSize             : uint32;     // The size of the custom data, in bytes.
+        moduleDependencyOffset     : uint32;     // The byte offset of the module dependencies from the start of the file.
+                                                 // The module dependencies are determined by the MODULE keyword in NLMLINK.
+        numberOfModuleDependencies : uint32;     // he number of module dependencies at the moduleDependencyOffset.
+        relocationFixupOffset      : uint32;     // The byte offset of the relocation fixup data from the start of the file
+        numberOfRelocationFixups   : uint32;
+        externalReferencesOffset   : uint32;
+        numberOfExternalReferences : uint32;
+        publicsOffset              : uint32;
+        numberOfPublics            : uint32;
+        debugInfoOffset            : uint32;     // The byte offset of the internal debug info from the start of the file.
+                                                 // It is possible for this to be EOF if there is no debug info.
+        numberOfDebugRecords       : uint32;
+        codeStartOffset            : uint32;
+        exitProcedureOffset        : uint32;
+        checkUnloadProcedureOffset : uint32;
+        moduleType                 : uint32;
+        flags                      : uint32;
+      end;
+
+
+  { The version header is one of the optional auxiliary headers and
+     follows the fixed length and variable length NLM headers.  }
+  { The header is recognized by "VeRsIoN#" in the stamp field.  }
+
+     nlm32_i386_external_version_header = packed record
+          stamp           : array[0..7] of char;  // VeRsIoN#
+          majorVersion,
+          minorVersion,
+          revision,
+          year,
+          month,
+          day             : uint32;
+       end;
+  { The header is recognized by "MeSsAgEs" in the stamp field.  }
+
+     nlm32_i386_external_extended_header = packed record
+          stamp                        : array[0..7] of char;  // MeSsAgEs
+          languageID                   : uint32;
+          messageFileOffset            : uint32;
+          messageFileLength            : uint32;
+          messageCount                 : uint32;
+          helpFileOffset               : uint32;
+          helpFileLength               : uint32;
+          RPCDataOffset                : uint32;
+          RPCDataLength                : uint32;
+          sharedCodeOffset             : uint32;
+          sharedCodeLength             : uint32;
+          sharedDataOffset             : uint32;
+          sharedDataLength             : uint32;
+          sharedRelocationFixupOffset  : uint32;
+          sharedRelocationFixupCount   : uint32;
+          sharedExternalReferenceOffset: uint32;
+          sharedExternalReferenceCount : uint32;
+          sharedPublicsOffset          : uint32;
+          sharedPublicsCount           : uint32;
+          sharedDebugRecordOffset      : uint32;
+          sharedDebugRecordCount       : uint32;
+          SharedInitializationOffset   : uint32;
+          SharedExitProcedureOffset    : uint32;
+          productID : longint;
+          reserved0 : longint;
+          reserved1 : longint;
+          reserved2 : longint;
+          reserved3 : longint;
+          reserved4 : longint;
+          reserved5 : longint;
+       end;
+
+     nlm32_i386_external_custom_header = packed record
+          stamp       : array[0..7] of char;  // CuStHeAd
+          hdrLength   : uint32;
+          dataOffset  : uint32;
+          dataLength  : uint32;
+          //dataStamp   : array[0..7] of char;
+          //hdr         : uint32;
+       end;
+  { The internal Cygnus header is written out externally as a custom
+     header.  We don't try to replicate that structure here.   }
+  { The header is recognized by "CyGnUsEx" in the stamp field.  }
+  { File location of debugging information.   }
+  { Length of debugging information.   }
+
+     nlm32_i386_external_cygnus_ext_header = packed record
+          stamp       : array[0..7] of char;  // CyGnUsEx
+          offset      : uint32;
+          length      : uint32;
+       end;
+
+
+//------------------
+
+
+       TNLMExeSection = class(TExeSection)
+       public
+         constructor createnw(AList:TFPHashObjectList;const n:string);
+       end;
+
+       TsecType = (Section_text,Section_data,Section_other);
+
+       TNLMexeoutput = class(texeoutput)
+       private
+         FRelocsGenerated,FImportsGenerated : boolean;
+         FNumRelocs         : longword;
+         FNumExternals      : longword;
+         FNumModules        : longword;
+         FNumDebugSymbols   : longword;
+         fSizeWoDebugSyms   : longword;
+         FnumExports        : longword;
+         NlmSymbols         : TDynamicArray;
+         ExeSecsListSize    : longint;
+         nlmImpNames,                            // name of import. module name as import
+         nlmImports         : TFPHashObjectList; // name of import, list of relocs as object
+         headerAlignBytes   : longint;
+         FexportFunctionOffsets:TFPList;    // offsets in .exports for function addresses, an offset of $80000000 is needed
+
+         nlmHeader          : nlm32_i386_external_fixed_header;
+         nlmVersionHeader   : nlm32_i386_external_version_header;
+         nlmExtHeader       : nlm32_i386_external_extended_header;
+         nlmCustHeader      : nlm32_i386_external_custom_header;
+         nlmHelpFileName    : TCmdStr;
+         nlmMessagesFileName: TCmdStr;
+         nlmXdcFileName     : TCmdStr;
+         nlmCopyright       : string;
+         nlmThreadname      : string;
+         nlmScreenname      : string;
+         nlmDescription     : string;
+
+         function  totalheadersize:longword;
+         procedure createNlm_symbol(const name:shortstring;value:longword;secType:TSecType);
+         procedure globalsyms_create_symbol(p:TObject;arg:pointer);
+         procedure ExeSectionList_write_header(p:TObject;arg:pointer);
+         procedure ExeSectionList_calc_size(p:TObject;arg:pointer);
+         procedure ExeSectionList_write_data(p:TObject;arg:pointer);
+         procedure GenerateImports;
+         procedure GenerateExports;
+         procedure GenerateRelocs;
+         procedure ExeSectionList_pass2_header(p:TObject;arg:pointer);
+       protected
+         function writedata:boolean;override;
+       public
+         constructor create; override;
+         destructor destroy; override;
+         procedure MemPos_Header;override;
+         procedure DataPos_Header;override;
+         procedure fillNlmVersionHeader;
+         procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);override;
+         procedure Order_End;override;
+         procedure MemPos_ExeSection(const aname:string);override;
+         procedure DataPos_ExeSection(const aname:string);override;
+         procedure NLMwriteString (const s : string; terminateWithZero : boolean);
+         procedure objNLMwriteString (const s : string; terminateWithZero : boolean);
+         procedure ParseScript (linkscript:TCmdStrList); override;
+       end;
+
+
+
+    type
+
+      TNLMCoffObjInput = class(TCoffObjInput)
+         constructor create;override;
+       end;
+
+       TNLMCoffassembler = class(tinternalassembler)
+         constructor create(smart:boolean);override;
+       end;
+
+      TNLMCoffObjData = class(TCoffObjData)
+         constructor create(const n:string);override;
+       end;
+
+      TNLMCoffObjOutput = class(TCoffObjOutput)
+         constructor create(AWriter:TObjectWriter);override;
+       end;
+
+      TNLMCoffObjSection = class(TCoffObjSection)
+         constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
+       end;
+
+implementation
+
+    uses
+{$ifdef win32}
+       Windows,
+{$endif win32}
+       SysUtils,
+       cutils,verbose,globals,
+       fmodule,aasmdata,
+       ogmap,export
+       ;
+
+
+{****************************************************************************
+                                 Helpers
+****************************************************************************}
+type
+  TStringObj = class (TObject)
+     fValue : string;
+     constructor create (value:string);
+     property value : string read fValue write fValue;
+  end;
+
+  constructor TStringObj.create(value:string);
+  begin
+    inherited create;
+    fValue := value;
+  end;
+
+
+
+function SectionType (aName : string) : TSecType;
+var s : string;
+begin
+  s := copy(aName,1,5);
+  if s = '.text' then result := Section_text else
+    if (s = '.data') or (copy(s,1,4)='.bss') then result := Section_data else
+      result := Section_other;
+end;
+
+{****************************************************************************
+                              TNLMexesection
+****************************************************************************}
+
+
+    constructor TNLMExeSection.createnw(AList:TFPHashObjectList;const n:string);
+      begin
+        inherited create(AList,n);
+      end;
+
+
+{****************************************************************************
+                              TNLMexeoutput
+****************************************************************************}
+
+    constructor TNLMexeoutput.create;
+      begin
+        inherited create;
+        CExeSection:=TNLMExeSection;
+        CObjData:=TNLMCoffObjData;
+        MaxMemPos:=$7FFFFFFF;
+        SectionMemAlign:=$0;
+        SectionDataAlign:=0;
+        RelocSection := true;  // always needed for NLM's
+        nlmImports := TFPHashObjectList.create(true);
+        nlmImpNames := TFPHashObjectList.create(false);
+        NlmSymbols := TDynamicArray.create(4096);
+        FexportFunctionOffsets := TFPList.Create;
+      end;
+
+    destructor TNLMexeoutput.destroy;
+      begin
+        if assigned(nlmImports) then
+          nlmImports.Free;
+        if assigned(nlmImpNames) then
+          nlmImpNames.Free;
+        if assigned(nlmSymbols) then
+          nlmSymbols.Free;
+        if assigned(FexportFunctionOffsets) then
+          FexportFunctionOffsets.Free;
+        inherited destroy;
+      end;
+
+    procedure TNLMexeoutput.createNlm_symbol(const name:shortstring;value:longword;secType:TSecType);
+      var
+        b:byte;
+      begin
+        //Comment (V_Debug,'TNLMexeoutput.write_symbol '+name);
+        {  type (0=.data,1=.code,2,..=????)                   1 byte
+           addr                                               4 bytes
+           name LString                                     1+n bytes }
+        case secType of
+          Section_Text : b := 1;
+          Section_Data : b := 0
+        else
+          exit;
+        end;
+        nlmSymbols.write(b,sizeof(b));
+        assert (sizeof(value)<>4);
+        nlmSymbols.write(value,sizeof(value));
+        nlmSymbols.write(name[0],length(name)+1);
+        inc(FNumDebugSymbols);
+      end;
+
+
+    procedure TNLMexeoutput.globalsyms_create_symbol(p:TObject;arg:pointer);
+      var
+        value  : longword;
+        exesec : TExeSection;
+        i : integer;
+        secType : TsecType;
+      begin
+        if not assigned(texesymbol(p).objsymbol) then
+          internalerror(200603053);
+        with texesymbol(p).objsymbol do
+          begin
+            exesec:=TExeSection(objsection.exesection);
+            { There is no exesection defined for special internal symbols
+              like __image_base__ }
+            if assigned(exesec) then
+              begin
+                //secval:=exesec.secsymidx;
+                value:=address-exesec.mempos;
+              end
+            else
+              begin
+                value:=address;
+              end;
+            { reloctype address to the section in the executable }
+            secType := SectionType(objsection.Name);
+            if (secType = Section_Text) or (secType = Section_Data) then
+              begin
+                i := nlmImports.FindIndexOf(texesymbol(p).name);
+                if i < 0 then
+                  createNlm_symbol(name,value,secType);
+              end;
+          end;
+      end;
+
+
+
+(*
+function SecOpts(SecOptions:TObjSectionOptions):string;
+    begin
+      result := '[';
+      if oso_Data in SecOptions then result := result + 'oso_Data ';
+       { Is loaded into memory }
+      if oso_load in SecOptions then result := result + 'oso_load ';
+       { Not loaded into memory }
+      if oso_noload in SecOptions then result := result + 'oso_noload ';
+       { Read only }
+      if oso_readonly in SecOptions then result := result + 'oso_readonly ';
+       { Read/Write }
+      if oso_write in SecOptions then result := result + 'oso_write ';
+       { Contains executable instructions }
+      if oso_executable in SecOptions then result := result + 'oso_executable ';
+       { Never discard section }
+      if oso_keep in SecOptions then result := result + 'oso_keep ';
+       { Special common symbols }
+      if oso_common in SecOptions then result := result + 'oso_common ';
+       { Contains debug info and can be stripped }
+      if oso_debug in SecOptions then result := result + 'oso_debug ';
+       { Contains only strings }
+      if oso_strings in SecOptions then result := result + 'oso_strings ';
+      result := result + ']';
+    end;
+*)
+
+    procedure TNLMexeoutput.ExeSectionList_calc_size(p:TObject;arg:pointer);
+      var
+        objsec : TObjSection;
+        i    : longint;
+      begin
+        with texesection(p) do
+          begin
+            { don't write normal section if writing only debug info }
+            if (ExeWriteMode=ewm_dbgonly) and
+               not(oso_debug in SecOptions) then
+              exit;
+
+            if oso_data in secoptions then
+              begin
+                inc (fSizeWoDebugSyms,(Align(fSizeWoDebugSyms,SectionDataAlign)-fSizeWoDebugSyms));
+                for i:=0 to ObjSectionList.Count-1 do
+                  begin
+                    objsec:=TObjSection(ObjSectionList[i]);
+                    if oso_data in objsec.secoptions then
+                      begin
+                        inc(fSizeWoDebugSyms,objsec.size);
+                        inc(fSizeWoDebugSyms,objsec.dataalignbytes);
+                      end;
+                  end;
+              end;
+          end;
+      end;
+
+
+
+    procedure TNLMexeoutput.ExeSectionList_write_Data(p:TObject;arg:pointer);
+      var
+        objsec : TObjSection;
+        i      : longint;
+      begin
+
+        with texesection(p) do
+          begin
+            { don't write normal section if writing only debug info }
+            if (ExeWriteMode=ewm_dbgonly) and
+               not(oso_debug in SecOptions) then
+              exit;
+
+            if oso_data in secoptions then
+              begin
+                //if Align(FWriter.Size,SectionDataAlign)-FWriter.Size>0 then
+                //  writeln (name,' align ',Align(FWriter.Size,SectionDataAlign)-FWriter.Size,' SectionDataAlign:',SectionDataAlign);
+                FWriter.Writezeros(Align(FWriter.Size,SectionDataAlign)-FWriter.Size);
+                for i:=0 to ObjSectionList.Count-1 do
+                  begin
+                    objsec:=TObjSection(ObjSectionList[i]);
+                    if oso_data in objsec.secoptions then
+                      begin
+                        if assigned(exemap) then
+                          exemap.Add(' nlm file offset $'+hexstr(objsec.DataPos,8)+': '+objsec.name);
+                        //writeln ('   ',objsec.name,'  size:',objsec.size,'  relocs:',objsec.ObjRelocations.count,'  DataPos:',objsec.DataPos,' MemPos:',objsec.MemPos);
+                        {for j := 0 to objsec.ObjRelocations.count-1 do
+                          begin
+                            objreloc := TObjRelocation(objsec.ObjRelocations[j]);
+                            with objreloc do
+                            begin
+                              write('        reloc DataOffset: ',DataOffset,'  OrgSize:',OrgSize,' typ:',typ);
+                              if assigned(symbol) then
+                                write(' Name: '#39,symbol.Name,#39' bind:',symbol.bind,' address:',symbol.address,' Size:',symbol.size);
+                              writeln;
+                            end;
+                          end;}
+                        if not assigned(objsec.data) then
+                          internalerror(200603042);
+                        FWriter.writezeros(objsec.dataalignbytes);
+                        //if objsec.dataalignbytes>0 then
+                        //  writeln ('  ',name,'  alignbytes: ',objsec.dataalignbytes);
+                        if objsec.DataPos<>FWriter.Size then
+                            internalerror(200602251);
+                        FWriter.writearray(objsec.data);
+                      end else
+                      begin
+                        if assigned(exemap) then //TExeMap
+                          exemap.Add('                  skipping: '+objsec.name);
+                      end;
+                  end;
+              end;
+          end;
+      end;
+
+
+    function TNLMexeoutput.totalheadersize:longword;
+      var
+        varHdrSize,
+        optHdrSize,
+        hdrSize: longword;
+      begin
+        optHdrSize := 0;
+        inc(optHdrSize,2+length(nlmDescription));
+        inc(optHdrSize,8); // Stacksize+reserved
+        inc(optHdrSize,NLM_OLD_THREAD_NAME_LENGTH);
+        inc(optHdrSize,2+length(nlmScreenname));
+        inc(optHdrSize,2+length(nlmThreadname));
+
+        varHdrSize := 0;
+        if nwcopyright <> '' then
+          inc(varHdrSize,sizeof(NLM_COPYRIGHT_STAMP)+2+length(nlmCopyright));
+        hdrSize := sizeof(nlm32_i386_external_fixed_header)+
+                   sizeof(nlm32_i386_external_extended_header)+
+                   sizeof(nlm32_i386_external_custom_header)+
+                   sizeof(nlm32_i386_external_version_header)+     // always
+                   sizeof(nlm32_i386_external_cygnus_ext_header)+  // CyGnUsEx
+                   varHdrSize+optHdrSize+
+                   8;  // empty stamp
+        result := hdrSize;
+      end;
+
+
+    procedure TNLMexeoutput.MemPos_Header;
+      begin
+        { calculate start positions after the headers }
+        currmempos:=0;
+      end;
+
+
+  procedure TNLMexeoutput.ExeSectionList_write_header(p:TObject;arg:pointer);
+  var
+    nam : string;
+    u32,al : longword;
+    alignAmount:longint;
+      begin
+        with tExeSection(p) do
+          begin
+            //comment (v_debug,'ExeSectionList_write_header: '+name);
+            nam := name;
+            alignAmount := 4 - ((length (nam) + 1) MOD 4);
+            FWriter.write(nam[1],length(nam));
+            FWriter.WriteZeros(1+alignAmount);
+            al := 0;
+            // for .stab we have to ignore leading zeros due to alignment in file
+            if nam='.stab' then
+              if assigned(ObjSectionList[0]) then
+                al := TObjSection(ObjSectionList[0]).dataalignbytes;
+            u32 := dataPos+al; FWriter.write(u32,sizeof(u32));
+            u32 := size-al; FWriter.write(u32,sizeof(u32));
+          end;
+      end;
+
+
+
+    procedure TNLMexeoutput.ExeSectionList_pass2_header(p:TObject;arg:pointer);
+    var len,alignAmount:longint;
+      begin
+        {list of sections, extension of binutils,CuStHeAd points to this list
+          The format of the section information is:
+           null terminated section name
+           zeroes to adjust to 4 byte boundary
+           4 byte section data file pointer
+           4 byte section size }
+
+        with TExeSection(p) do
+          begin
+            alignAmount := 4 - ((length (Name) + 1) MOD 4);
+            len := length(name) + 1 + alignAmount + 8;
+            if ObjSectionList.Count>0 then
+              inc(len,TObjSection(ObjSectionList[0]).dataalignbytes);
+            inc(plongint(arg)^,len);
+          end;
+      end;
+
+    procedure TNLMexeoutput.DataPos_Header;
+      begin
+        ExeSecsListSize:=0;
+        ExeSectionList.ForEachCall(@ExeSectionList_pass2_header,@ExeSecsListSize);
+
+        headerAlignBytes := align(totalheadersize+ExeSecsListSize,16)-(totalheadersize+ExeSecsListSize);  // align as in TObjData.sectiontype2align
+        currdatapos:=totalheadersize+ExeSecsListSize+headerAlignBytes;
+      end;
+
+
+    procedure TNLMexeoutput.fillNlmVersionHeader;
+    var
+        hour,min,sec,hsec,Year,Month,Day : word;
+    begin
+      DecodeTime(Time,hour,min,sec,hsec);
+      DecodeDate(Date,year,month,day);
+      nlmVersionHeader.stamp := NLM_VERSION_STAMP;
+      if nlmVersionHeader.year = 0 then
+        begin
+          nlmVersionHeader.year := Year;
+          nlmVersionHeader.month := Month;
+          nlmVersionHeader.day := Day;
+        end;
+    end;
+
+
+
+    function TNLMexeoutput.writedata:boolean;
+      var
+        dummyLong       : array[0..4] of char;
+        textExeSec,
+        dataExeSec,
+        bssExeSec,
+        relocsExeSec,
+        exportsExeSec,
+        importsExeSec,
+        xdcExeSec,
+        messagesExeSec,
+        helpExeSec,
+        customExeSec    : TExeSection;
+        hassymbols      : boolean;
+        nlmCygnusHeader : nlm32_i386_external_cygnus_ext_header;
+        ModuleName      : string;
+        exesym          : TExeSymbol;
+        expOffset       : PtrUInt;
+        expAddr         : longword;
+        i               : integer;
+
+      begin
+        result:=false;
+        textExeSec:=FindExeSection('.text');
+        dataExeSec:=FindExeSection('.data');
+        bssExeSec:=FindExeSection('.bss');
+        relocsExeSec:=FindExeSection('.reloc');
+        importsExeSec:=FindExeSection('.imports');
+        exportsExeSec:=FindExeSection('.exports');
+        xdcExeSec:=FindExeSection('.xdc');
+        messagesExeSec:=FindExeSection('.messages');
+        helpExeSec:=FindExeSection('.help');
+        customExeSec:=FindExeSection('.custom');
+
+        // exported function need the upper bit in the address
+        // to be set (=CODE), do this here to avoid another
+        // reloc type. The ExportFunctionOffsets list was
+        // filled in GenerateExports
+        if FexportFunctionOffsets.Count>0 then
+          begin
+            if not assigned(exportsExeSec) then
+              internalerror(201103201);   // we have to have a .export section
+            if not assigned(exportsExeSec.ObjSectionList[0]) then
+              internalerror(201103202);   // nothing in the .exports section but we have data in FexportFunctionOffsets
+            for i := 0 to FexportFunctionOffsets.Count-1 do
+              begin
+                expOffset := PtrUint(FexportFunctionOffsets[i]);
+                if TObjSection(exportsExeSec.ObjSectionList[0]).Data.size < expOffset+3 then
+                  internalerror(201103203);  // offset in FexportFunctionOffsets out of range
+                with TObjSection(exportsExeSec.ObjSectionList[0]) do
+                begin  // set the upper bit of address to indicate .text
+                  Data.seek(expOffset);
+                  Data.read(expAddr,4);
+                  Data.seek(expOffset);
+                  expAddr := expAddr or $80000000;
+                  Data.write(expAddr,4);
+                end;
+              end;
+           end;
+
+        if not assigned(TextExeSec) or
+           not assigned(RelocsExeSec) or
+           not assigned(DataExeSec) then
+          internalerror(200602231);   // we have to have .data, .text and .reloc
+        { do we need to write symbols? }
+        hassymbols:=(ExeWriteMode=ewm_dbgonly) or
+                    (
+                     (ExeWriteMode=ewm_exefull) and
+                     not(cs_link_strip in current_settings.globalswitches)
+                    );
+
+        { Initial header, will be updated later }
+        nlmHeader.signature := NLM_SIGNATURE;
+        nlmHeader.version := NLM_HEADER_VERSION;
+        moduleName := upperCase(current_module.exefilename^);
+        nlmHeader.moduleName := moduleName;
+        nlmHeader.codeImageOffset := TextExeSec.DataPos+TObjSection(TextExeSec.ObjSectionList[0]).dataalignbytes; // ??? may be that align has to be moved to fixups/imports
+        nlmHeader.codeImageSize := TextExeSec.Size;
+        nlmHeader.dataImageOffset := DataExeSec.DataPos;
+        nlmHeader.dataImageSize := DataExeSec.Size;
+        if assigned(BSSExeSec) then
+          nlmHeader.uninitializedDataSize:=BSSExeSec.Size;
+        if assigned(customExeSec) then
+          begin
+            nlmHeader.customDataOffset := customExeSec.DataPos;
+            nlmHeader.customDataSize := customExeSec.Size;
+          end;
+        if FNumModules > 0 then
+          begin
+            nlmHeader.moduleDependencyOffset := FindExeSection('.modules').DataPos+4;  // 4 bytes dummy
+            nlmHeader.numberOfModuleDependencies := FNumModules;
+          end;
+        nlmHeader.relocationFixupOffset := relocsExeSec.DataPos;
+        nlmHeader.numberOfRelocationFixups := FNumRelocs;
+        nlmHeader.externalReferencesOffset := importsExeSec.DataPos+4;  // 4 bytes dummy
+        nlmHeader.numberOfExternalReferences := FNumExternals;
+        if assigned(exportsExeSec) then
+          if exportsExeSec.Size>0 then
+          begin
+            nlmHeader.publicsOffset := exportsExeSec.dataPos;
+            nlmHeader.numberOfPublics := FnumExports;
+          end;
+        nlmHeader.codeStartOffset := EntrySym.Address;
+
+        {exit function}
+        exesym:=texesymbol(ExeSymbolList.Find('_Stop'));
+        if assigned(exesym) then
+          nlmHeader.exitProcedureOffset := exesym.ObjSymbol.address;
+
+        {check exit function}
+        exesym:=texesymbol(ExeSymbolList.Find('FPC_NW_CHECKFUNCTION'));
+        if assigned(exesym) then
+          nlmHeader.checkUnloadProcedureOffset := exesym.ObjSymbol.address;
+
+        // calc file pos after all exesections
+        fSizeWoDebugSyms := totalheadersize + ExeSecsListSize + headerAlignBytes;
+        ExeSectionList.ForEachCall(@ExeSectionList_calc_size,nil);
+
+        nlmExtHeader.stamp := NLM_MESSAGES_STAMP;
+        //extHeader.languageID    // TODO: where to get this from ?
+        if assigned(messagesExeSec) then
+          begin
+           nlmExtHeader.messageFileOffset := messagesExeSec.DataPos;
+           nlmExtHeader.messageFileLength := messagesExeSec.Size;
+          end;
+        //nlmExtHeader.messageCount  // TODO: how is messageCount set ?
+        if assigned(helpExeSec) then
+          begin
+           nlmExtHeader.helpFileOffset := helpExeSec.DataPos;
+           nlmExtHeader.helpFileLength := helpExeSec.Size;
+          end;
+        //nlmExtHeader.productID     // TODO: were does this came from ?
+        if assigned(xdcExeSec) then
+          begin
+            nlmExtHeader.RPCDataOffset  := xdcExeSec.DataPos;
+            nlmExtHeader.RPCDataLength  := xdcExeSec.Size;
+          end;
+
+        if hassymbols then
+        begin
+          nlmHeader.debugInfoOffset := fSizeWoDebugSyms;
+          ExeSymbolList.ForEachCall(@globalsyms_create_symbol,nil);
+          nlmHeader.numberOfDebugRecords := FNumDebugSymbols;
+        end;
+
+        fillNlmVersionHeader;
+        FWriter.write(nlmHeader,sizeof(nlmHeader));
+
+        { variable header }
+        NLMWriteString(nlmDescription,true);
+        if stacksize < NLM_DEFAULT_STACKSIZE then stacksize := NLM_DEFAULT_STACKSIZE;
+        FWriter.Write(stacksize,4);
+        FWriter.writezeros(4);
+        dummyLong := ' LONG';
+        FWriter.Write(dummyLong,sizeof(dummyLong));  // old thread name
+        NLMWriteString(nlmScreenname,true);
+        NLMWriteString(nlmThreadname,true);
+
+        {version}
+        FWriter.Write(nlmVersionHeader,sizeof(nlmVersionHeader));
+        {copyright}
+        if nlmCopyright <> '' then
+        begin
+          FWriter.write(NLM_COPYRIGHT_STAMP,sizeof(NLM_COPYRIGHT_STAMP));
+          NLMWriteString(nlmCopyright,true);
+        end;
+        {messages}
+        FWriter.write(nlmExtHeader,sizeof(nlmExtHeader));
+
+        {custhead}
+        nlmCustHeader.stamp := NLM_CUSTOM_STAMP;
+        nlmCustHeader.dataLength := ExeSecsListSize;
+        nlmCustHeader.dataOffset := totalheadersize;
+        nlmCustHeader.hdrLength := $10;               // why 16 ?, this is what binutils write
+        FWriter.write(nlmCustHeader,sizeof(nlmCustHeader));
+
+        {CyGnUsEx}
+        // bfd has a strange way to read the sections:
+        // the section directory is written under CuStHeAd
+        // when bfd finds the neader "CyGnUsEx", it uses the
+        // offset and size from CuStHeAd to read the section table
+
+        nlmCygnusHeader.stamp  := NLM_CYGNUS_STAMP;  // CyGnUsEx
+        // ld writes some unknown values here, bfd irgnores the values at all
+        // lets write the offset and length of the segment table
+        nlmCygnusHeader.offset := nlmCustHeader.dataLength;
+        nlmCygnusHeader.length := nlmCustHeader.dataOffset;
+        FWriter.write(nlmCygnusHeader,sizeof(nlmCygnusHeader));
+        FWriter.WriteZeros(8);   // empty stamp + align next to 16 bytes
+
+        if FWriter.Size<>totalheadersize then
+          internalerror(201103061);               // headersize <> header written
+
+        { Section headers, CuStHeAd points to this section, not needed by
+          netware. Can be used to find the section in the nlm file, binutils
+          will use this section }
+        ExeSectionList.ForEachCall(@ExeSectionList_write_header,nil);
+        FWriter.WriteZeros(headerAlignBytes);
+        if FWriter.Size<>totalheadersize+ExeSecsListSize+headerAlignBytes then
+          internalerror(201103062);
+        { Section data }
+        ExeSectionList.ForEachCall(@ExeSectionList_write_data,nil);
+
+        if hassymbols then
+          FWriter.writearray(NlmSymbols);  // specific symbols for the internal netware debugger
+
+        result:=true;
+      end;
+
+
+
+    procedure TNLMexeoutput.GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);
+      var
+        idata5objsection : TObjSection;
+        basedllname : string;
+
+        function AddImport(const afuncname,amangledname:string; isvar:boolean):TObjSymbol;
+        var
+          secname:string;
+        begin
+          //Comment (V_Debug,'TNLMexeoutput.GenerateLibraryImports.AddImport '+afuncName);
+          result:=nil;
+          if assigned(exemap) then
+            exemap.Add(' Importing Function '+afuncname);
+
+          if not isvar then
+            with internalobjdata do
+            begin
+              secname:=basedllname+'_i_'+amangledname;
+              idata5objsection:=createsection(sec_idata5, secname);
+              internalobjdata.SetSection(idata5objsection);
+              result:=internalobjdata.SymbolDefine('_'+amangledname,AB_IMPORT,AT_FUNCTION);
+            end;
+        end;
+
+      var
+        i,j           : longint;
+        ImportLibrary : TImportLibrary;
+        ImportSymbol  : TImportSymbol;
+        exesym        : TExeSymbol;
+        importAddressList : TFPObjectList;
+      begin
+        if ImportLibraryList.Count > 0 then
+          begin
+            {objsec:=}internalObjData.createsection('.imports',0,[oso_data,oso_keep]);
+            i := 0;
+            internalobjdata.writebytes(i,4);  // dummy to avoid deletion
+            {objsec:=}internalObjData.createsection('.modules',0,[oso_data,oso_keep]);
+            internalobjdata.writebytes(i,4);  // dummy to avoid deletion
+          end;
+        for i:=0 to ImportLibraryList.Count-1 do
+          begin
+            ImportLibrary:=TImportLibrary(ImportLibraryList[i]);
+            idata5objsection:=nil;
+            for j:=0 to ImportLibrary.ImportSymbolList.Count-1 do
+              begin
+                ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
+                exesym:=TExeSymbol(ExeSymbolList.Find(ImportSymbol.MangledName));
+                if assigned(exesym) and
+                   (exesym.State<>symstate_defined) then
+                  begin
+                    basedllname:=ExtractFileName(ImportLibrary.Name);
+                    exesym.objsymbol:=AddImport(ImportSymbol.Name,ImportSymbol.MangledName,ImportSymbol.IsVar);
+                    exesym.State:=symstate_defined;
+                    importAddressList := TFPObjectList.create(false);
+                    nlmImports.Add(ImportSymbol.Name,importAddressList);
+                    if pos('.',basedllname) = 0 then
+                      basedllname := basedllname + '.nlm';
+                    nlmImpNames.Add(ImportSymbol.Name,TStringObj.create(lower(basedllname)));
+                  end;
+              end;
+          end;
+
+        PackUnresolvedExeSymbols('after DLL imports');
+        GenerateExports;
+      end;
+
+
+
+    procedure TNLMexeoutput.GenerateImports;
+    var
+        exesec,
+        impexesec  : TExeSection;
+        objsec     : TObjSection;
+        objreloc   : TObjRelocation;
+        i,j,k      : integer;
+        importAddressList : TFPObjectList;
+        name,mName : string;
+        b          : byte;
+        modules    : string;
+        modName    : TStringObj;
+    begin
+      if FImportsGenerated then exit;
+      FImportsGenerated := true;
+      impexesec:=FindExeSection('.imports');
+      if impexesec=nil then exit;
+
+      for i:=0 to ExeSectionList.Count-1 do
+        begin
+          exesec:=TExeSection(ExeSectionList[i]);
+          for j:=0 to exesec.ObjSectionList.count-1 do
+            begin
+              objsec:=TObjSection(exesec.ObjSectionList[j]);
+              if j=0 then
+                begin
+                  exesec.DataPos:=objSec.DataPos;
+                  exesec.MemPos:=objSec.MemPos;
+                end;
+              if (copy(objsec.name,1,5) <> '.text') and (copy(objsec.name,1,4) <> '.bss') and (copy(objsec.name,1,5) <> '.data') then
+                  continue;
+              for k:=0 to objsec.ObjRelocations.Count-1 do
+                begin
+                  objreloc := TObjRelocation(objsec.ObjRelocations[k]);
+                  if assigned(objreloc.symbol) then
+                    begin
+                      //writeln (objreloc.symbol.name,' ',objreloc.symbol.bind);
+                      if objreloc.symbol.bind = AB_IMPORT then
+                        begin
+                          importAddressList := TFPObjectList(nlmImports.Find(objreloc.symbol.name));
+                          if assigned(importAddressList) then
+                            begin
+                              objreloc.objsection := objsec;   // points to idata5
+                              importAddressList.Add(objreloc);
+                            end else
+                            begin
+                              comment(v_error,objreloc.symbol.name+' is external but not defined in nlm imports');
+                            end;
+                        end;
+                    end
+                end;
+            end;
+        end;
+
+      modules := '';
+      for i := 0 to nlmImports.count-1 do
+        begin
+          importAddressList := TFPObjectList(nlmImports.Items[i]);
+          if importAddressList.Count > 0 then
+            begin
+              name := nlmImports.NameOfIndex(i);
+
+              // find the module to be imported and add it to the list
+              // of modules to be auto loaded
+              modName := TStringObj(nlmImpNames.Find(name));
+              if assigned(modName) then
+                begin
+                  mName := modName.Value;
+                  if mName <> '' then
+                    if copy(mName,1,1) <> '!' then  // special, with ! only the imp will be included but no module is autoloaded, needed i.e. for netware.imp
+                      begin
+                        if pos(mName+';',modules) < 1 then
+                          begin
+                            modules := modules + mName + ';';
+                            inc(FNumModules);
+                          end;
+                      end;
+                end;
+              internalobjdata.SetSection(TObjSection(impexesec.ObjSectionList[0]));
+              objNLMwriteString (name,false);           // name of symbol
+              k := importAddressList.Count;
+              internalobjdata.writebytes(k,sizeof(k));    // number of references
+              inc(FNumExternals);
+              for j := 0 to importAddressList.Count-1 do
+                begin
+                  objreloc := TObjRelocation(importAddressList[j]);
+                  objsec := objreloc.objsection;
+                  if oso_executable in objreloc.objsection.SecOptions then
+                    begin
+                      if objreloc.typ <> RELOC_RELATIVE then comment(v_error,'reference to external symbols must be RELOC_RELATIVE');
+                      // TODO: how to check if size is 4 ????
+
+                      k := objsec.MemPos + objreloc.DataOffset;
+                      k := k or $40000000;
+                      // TODO: data|code
+                      internalobjdata.writebytes(k,sizeof(k));    // address
+
+                      // the netware loader requires an offset at the import address
+                      // for call = E8 this is -4
+                      // TODO: how can we check the needed offset ??
+                      if objreloc.DataOffset > 0 then
+                        begin
+                          objsec.Data.seek(objreloc.DataOffset-1);
+                          objsec.data.read(b,1);
+                          if b <> $E8 then
+                            comment(v_error,'no rcall (E8) before imported symbol target address');
+                          k := -4;
+                          objsec.Data.write(k,sizeof(k));
+                        end else
+                        begin
+                          objsec.Data.seek(objreloc.DataOffset);
+                          k := 0;
+                          objsec.Data.write(k,sizeof(k));
+                        end;
+                        objreloc.typ := RELOC_NONE;  // to avoid that TCoffObjSection.fixuprelocs changes the address again
+                    end else
+                      comment(v_error,'Importing of symbols only supported for .text');
+                end;
+            end;
+        end;
+
+      exesec := FindExeSection('.modules');
+      if not assigned(exesec) then internalerror(201103272);  // exe section .modules does not exist ???
+      internalobjdata.SetSection(TObjSection(exesec.ObjSectionList[0]));
+      for i := 1 to FNumModules do
+        begin
+          name := GetToken(modules,';');
+          objNLMwriteString (name,false);
+        end;
+    end;
+
+
+    procedure TNLMexeoutput.GenerateExports;
+    var
+        hp  : texported_item;  { for exports }
+        len : byte;
+        addr: longword;
+        exesym : texesymbol;
+    begin
+      internalObjData.createsection('.exports',0,[oso_data,oso_keep]);
+      {name   LString                                   1+n bytes
+      addr                                               4 bytes
+      addr and $80000000 > 0 -> .text else .data}
+      hp:=texported_item(current_module._exports.first);
+      if assigned(hp) then
+        if assigned(exemap) then
+           exemap.Add('');
+      while assigned(hp) do
+        begin
+          { Export the Symbol }
+          if assigned(exemap) then
+            exemap.Add(' Exporting Function '+hp.sym.prettyname+' as '+hp.name^);
+          len := length(hp.name^);
+          internalobjdata.writebytes(len,1);
+          internalobjdata.writebytes(hp.name^[1],len);
+          exesym:=texesymbol(ExeSymbolList.Find(hp.sym.prettyname));
+          if not assigned(exesym) then
+          begin
+            comment(v_error,'exported symbol '+hp.sym.prettyname+' not found');
+            exit;
+          end;
+          // for exported functions we have to set the upper bit
+          // this will be done in .writedata
+          if not hp.is_var then
+            FexportFunctionOffsets.Add(pointer(PtrUInt(internalobjdata.CurrObjSec.Size)));
+          internalobjdata.writereloc(0,4,exesym.ObjSymbol,RELOC_ABSOLUTE32);
+
+          addr := 0;
+          internalobjdata.writebytes(addr,4);
+          inc(FnumExports);
+          hp:=texported_item(hp.next);
+        end;
+    end;
+
+    procedure TNLMexeoutput.GenerateRelocs;
+
+      var
+        exesec : TExeSection;
+        objsec : TObjSection;
+        objreloc : TObjRelocation;
+        i,j,k : longint;
+        offset : longword;
+        inSec,toSec : TsecType;
+        targetSectionName : string;
+
+      begin
+        if not RelocSection or FRelocsGenerated then
+          exit;
+        exesec:=FindExeSection('.reloc');
+        if exesec=nil then
+          exit;
+        objsec:=internalObjData.createsection('.reloc',0,exesec.SecOptions+[oso_data]);
+        exesec.AddObjSection(objsec);
+        for i:=0 to ExeSectionList.Count-1 do
+          begin
+            exesec:=TExeSection(ExeSectionList[i]);
+            for j:=0 to exesec.ObjSectionList.count-1 do
+              begin
+                objsec:=TObjSection(exesec.ObjSectionList[j]);
+                //writeln ('Relocs for ',exesec.name,' - ',objsec.name);
+                { create relocs only for sections which are loaded in memory }
+                if not (oso_load in objsec.SecOptions) then
+                  continue;
+                { create relocs only for .text and .data }
+                inSec := SectionType (objsec.name);
+                if (inSec <> Section_Text) and (inSec <> Section_Data) then
+                  continue;
+
+                for k:=0 to objsec.ObjRelocations.Count-1 do
+                  begin
+                    objreloc:=TObjRelocation(objsec.ObjRelocations[k]);
+                    if objreloc.typ <> RELOC_ABSOLUTE then
+                      continue;
+                    offset:=objsec.MemPos+objreloc.dataoffset;
+                    targetSectionName := '';
+                    if objreloc.symbol <> nil then
+                    begin
+                      //writeln ('  MemPos',objsec.MemPos,' dataOfs:',objreloc.dataoffset,' ',objsec.name,'   objreloc.symbol: ',objreloc.symbol.name,'  objreloc.symbol.objsection.name: ',objreloc.symbol.objsection.name,' ',objreloc.symbol.Typ,' ',objreloc.symbol.bind,' ',objreloc.Typ);
+                      targetSectionName := copy(objreloc.symbol.objsection.name,1,5);
+                    end else
+                      internalerror(2011030603);
+
+                    toSec := SectionType(targetSectionName);
+
+                    if (toSec = Section_Text) or (toSec = Section_Data) then
+                    begin
+                      if (inSec = Section_text) then offset := offset or $40000000;
+                      if (toSec = Section_text) then offset := offset or $80000000;
+                      internalObjData.writebytes(offset,4);
+                      inc(FNumRelocs);
+                    end;
+                  end;
+              end;
+          end;
+        FRelocsGenerated:=true;
+      end;
+
+
+    procedure TNLMexeoutput.Order_End;
+      var
+        exesec : TExeSection;
+      begin
+        inherited;
+        exesec:=FindExeSection('.reloc');
+        if exesec=nil then
+          exit;
+        exesec.SecOptions:=exesec.SecOptions + [oso_Data,oso_keep,oso_load];
+      end;
+
+
+      procedure TNLMexeoutput.MemPos_ExeSection(const aname:string);
+        begin
+          if aname='.reloc' then
+            GenerateRelocs;
+          if aname='.imports' then
+            GenerateImports;
+          if aname='.data' then
+            currMemPos := 0;  // both, data and code in the nlm have a start offset of 0
+          inherited;
+        end;
+
+
+      procedure TNLMexeoutput.DataPos_ExeSection(const aname:string);
+        begin
+          inherited;
+        end;
+
+
+      procedure TNLMexeoutput.NLMwriteString (const s : string; terminateWithZero : boolean);
+      var len : byte;
+        begin
+          if length(s) > 254 then len := 254 else len := length(s);
+          FWriter.Write(len,1);
+          if len > 0 then
+            FWriter.write(s[1],len);
+          if terminateWithZero then
+            FWriter.writeZeros(1);
+        end;
+
+
+      procedure TNLMexeoutput.objNLMwriteString (const s : string; terminateWithZero : boolean);
+      var len : byte;
+        begin
+          if length(s) > 254 then len := 254 else len := length(s);
+          Internalobjdata.writebytes(len,1);
+          if len > 0 then
+            Internalobjdata.writebytes(s[1],len);
+          if terminateWithZero then
+          begin
+            len := 0;
+            Internalobjdata.writebytes(s[1],len);
+          end;
+        end;
+
+      { parse netware specific linker options }
+      procedure TNLMexeoutput.ParseScript (linkscript:TCmdStrList);
+      var
+        hp : TCmdStrListItem;
+        opt,keyword,s : string;
+        i : integer;
+
+          function toInteger(s:string; min,max:integer; var res:integer):boolean;
+          var
+            code:word;
+          begin
+            result := false;
+            val (s,res,code);
+            if code<>0 then exit;
+            if (res < min) or (res > max) then exit;
+            result := true;
+          end;
+
+
+          procedure loadFile (const secName, fileName, Desc : string);
+          var
+            fileBuf : array [0..4095] of char;
+            bytesRead : longint;
+            fileH : THandle;
+            fn : TCmdStr;
+
+            begin
+              fn := fileName;
+              if not fileExists(fn) then
+               if not unitsearchpath.FindFile(fileName,true,fn) then
+                 begin
+                   comment(v_error,'can not find '+desc+' file '+fileName);
+                   exit;
+                 end;
+               fileH := fileOpen (fn,fmOpenRead);
+               if fileH = -1 then
+                 begin
+                   comment(v_error,'can not open '+desc+' file '+fn);
+                   exit;
+                  end;
+               { load file into section  }
+               internalObjData.createsection(secName,0,[oso_data,oso_keep]);
+               repeat
+                 bytesRead := fileRead(fileH,fileBuf,sizeof(fileBuf));
+                 if bytesRead > 0 then
+                   internalobjdata.writebytes(fileBuf,bytesRead);
+               until bytesRead < sizeof(fileBuf);
+               fileClose(fileH);
+            end;
+
+        begin
+          hp:=TCmdStrListItem(linkscript.first);
+          while assigned(hp) do
+            begin
+              opt:=hp.str;
+              if (opt='') or (opt[1]='#') then
+                continue;
+              keyword:=Upper(GetToken(opt,' '));
+              if keyword = 'AUTOUNLOAD' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_AUTOUNLOAD;
+                end else
+              if keyword = 'COPYRIGHT' then
+                begin
+                  nlmCopyright := GetToken(opt,' ');
+                end else
+              if keyword = 'CUSTOM' then
+                begin
+                  loadFile ('.custom',GetToken(opt,' '),'custom data');
+                end;
+              if keyword = 'DATE' then  // month day 4-digit-year
+              begin
+                if not toInteger(GetToken(opt,' '),1,12,i) then comment(v_error,'DATE: invalid month')
+                  else nlmVersionHeader.month := i;
+                if not toInteger(GetToken(opt,' '),1,31,i) then comment(v_error,'DATE: invalid day')
+                  else nlmVersionHeader.day := i;
+                if not toInteger(GetToken(opt,' '),1900,3000,i) then comment(v_error,'DATE: invalid year')
+                  else nlmVersionHeader.year := i;
+              end else
+              if keyword = 'DEBUG' then
+              begin
+                // ignore
+              end else
+              if keyword = 'DESCRIPTION' then
+                begin
+                  nlmDescription := GetToken(opt,' ');
+                  if length (nlmDescription) > NLM_MAX_DESCRIPTION_LENGTH then
+                    nlmDescription := copy (nlmDescription,1,NLM_MAX_DESCRIPTION_LENGTH);
+                end else
+              if keyword = 'FLAG' then
+                begin
+                  s := upper(GetToken(opt,' '));
+                  if (not toInteger(GetToken(opt,' '),1,$FFFFFFF,i)) or ((s <> 'ON') and (S <> 'OFF')) then comment(v_error,'FLAG: invalid') else
+                    if (s='ON') then
+                      nlmHeader.flags:=nlmHeader.flags or i else
+                    nlmHeader.flags:=nlmHeader.flags and ($FFFFFFF-i);
+                end else
+              if keyword = 'HELP' then
+                begin
+                  loadFile ('.help',GetToken(opt,' '),'help');
+                end else
+              if keyword = 'MESSAGES' then
+                begin
+                  loadFile ('.messages',GetToken(opt,' '),'message');
+                end else
+              if keyword = 'MULTIPLE' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_MULTILOAD;
+                end else
+              if keyword = 'OS_DOMAIN' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_OSDOMAIN;
+                end else
+              if keyword = 'PSEUDOPREEMPTION' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_PSEUDOPREEMPTION;
+                end else
+              if keyword = 'REENTRANT' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_REENTRANT;
+                end else
+              if keyword = 'SCREENNAME' then
+                begin
+                  nlmScreenname := GetToken(opt,' ');
+                  if length(nlmScreenname) > NLM_MAX_SCREEN_NAME_LENGTH then
+                   nlmScreenName := copy (nlmScreenName,1,NLM_MAX_SCREEN_NAME_LENGTH);
+                end else
+              if (keyword = 'STACK') or (keyword = 'STACKSIZE') then
+                begin
+                   if (not toInteger(GetToken(opt,' '),1,$FFFFFFF,i)) then comment(v_error,'invalid stacksize') else
+                     stacksize := i;
+                end else
+              if keyword = 'SYNCHRONIZE' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_SYNCHRONIZE;
+                end else
+              if keyword = 'THREADNAME' then
+                begin
+                  nlmThreadname := GetToken(opt,' ');
+                  if length(nlmThreadname) > NLM_MAX_THREAD_NAME_LENGTH then
+                    nlmThreadname := copy (nlmThreadname,1,NLM_MAX_THREAD_NAME_LENGTH);
+                end else
+              if keyword = 'TYPE' then
+                begin
+                   if (not toInteger(GetToken(opt,' '),1,16,i)) then comment(v_error,'invalid TYPE') else
+                     nlmHeader.moduleType := i;  // TODO: set executable extension (.DSK, .LAN, ...)
+                end else
+              if keyword = 'VERSION' then
+                begin
+                   if (not toInteger(GetToken(opt,' '),0,$FFFFFFF,i)) then comment(v_error,'invalid major version') else
+                     nlmVersionHeader.majorVersion := i;
+                   if (not toInteger(GetToken(opt,' '),0,99,i)) then comment(v_error,'invalid minor version') else
+                     nlmVersionHeader.minorVersion := i;
+                   if (not toInteger(GetToken(opt,' '),0,$FFFFFFF,i)) then comment(v_error,'invalid minor version') else
+                     if i > 26 then
+                       nlmVersionHeader.revision := 0 else
+                       nlmVersionHeader.revision := i;
+                end else
+              if keyword = 'XDCDATA' then
+                begin
+                  loadFile ('.xdc',GetToken(opt,' '),'xdc');
+                end;
+                { TODO: check for unknown options. This means all handled option
+                  (also in link.pas) have to be flagged if processed }
+              hp:=TCmdStrListItem(hp.next);
+            end;
+        end;
+
+{****************************************************************************
+                                TNLMCoffObjData
+****************************************************************************}
+
+    constructor TNLMCoffObjData.create(const n:string);
+      begin
+        inherited createcoff(n,true,TNLMCoffObjSection);
+      end;
+
+
+{****************************************************************************
+                               TNLMoffObjSection
+****************************************************************************}
+
+    constructor TNLMCoffObjSection.create(AList:TFPHashObjectList;const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
+      begin
+        inherited create(alist,aname,aalign,aoptions);
+      end;
+
+
+    constructor TNLMCoffObjOutput.create(AWriter:TObjectWriter);
+      begin
+        // ??????
+        // if win32=false, .stabs and .stabstr will be written without oso_debug
+        // Without oso_debug the sections will be removed by the linker
+        inherited createcoff(AWriter,{win32}true);
+        cobjdata:=TNLMCoffObjData;
+      end;
+
+{****************************************************************************
+                                 TDJCoffAssembler
+****************************************************************************}
+
+    constructor TNLMCoffAssembler.Create(smart:boolean);
+      begin
+        inherited Create(smart);
+        CObjOutput:=TNLMCoffObjOutput;
+      end;
+
+    constructor TNLMCoffObjInput.create;
+      begin
+        inherited createcoff(true);
+        cobjdata:=TNLMCoffObjData;
+      end;
+
+{*****************************************************************************
+                                  Initialize
+*****************************************************************************}
+const
+    as_i386_nlmcoff_info : tasminfo =
+          (
+            id     : as_i386_nlmcoff;
+            idtxt  : 'NLMCOFF';
+            asmbin : '';
+            asmcmd : '';
+            supported_targets : [system_i386_Netware,system_i386_netwlibc];
+            flags : [af_outputbinary,af_smartlink_sections];
+            labelprefix : '.L';
+            comment : '';
+          );
+
+
+
+initialization
+{$ifdef i386}
+  RegisterAssembler(as_i386_nlmcoff_info,TNLMCoffAssembler);
+{$endif i386}
+end.

+ 4 - 2
compiler/paramgr.pas

@@ -366,7 +366,8 @@ implementation
               i386 isn't affected anyways because it uses the stack to push parameters
               i386 isn't affected anyways because it uses the stack to push parameters
               on arm it reduces executable size of the compiler by 2.1 per cent (FK) }
               on arm it reduces executable size of the compiler by 2.1 per cent (FK) }
             { Does it fit a register? }
             { Does it fit a register? }
-            if (not can_use_final_stack_loc or
+            if ((not can_use_final_stack_loc and
+                 use_fixed_stack) or
                 not is_stack_paraloc(paraloc)) and
                 not is_stack_paraloc(paraloc)) and
                (len<=sizeof(pint)) and
                (len<=sizeof(pint)) and
                (paraloc^.size in [OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128]) then
                (paraloc^.size in [OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128]) then
@@ -382,7 +383,8 @@ implementation
                 newparaloc^.register:=cg.getmmregister(list,paraloc^.size);
                 newparaloc^.register:=cg.getmmregister(list,paraloc^.size);
               LOC_REFERENCE :
               LOC_REFERENCE :
                 begin
                 begin
-                  if can_use_final_stack_loc and
+                  if (can_use_final_stack_loc or
+                      not use_fixed_stack) and
                      is_stack_paraloc(paraloc) then
                      is_stack_paraloc(paraloc) then
                     duplicatecgparaloc(paraloc,newparaloc)
                     duplicatecgparaloc(paraloc,newparaloc)
                   else
                   else

+ 4 - 3
compiler/pdecl.pas

@@ -397,7 +397,6 @@ implementation
          typename,orgtypename : TIDString;
          typename,orgtypename : TIDString;
          newtype  : ttypesym;
          newtype  : ttypesym;
          sym      : tsym;
          sym      : tsym;
-         srsymtable : TSymtable;
          hdef     : tdef;
          hdef     : tdef;
          defpos,storetokenpos : tfileposinfo;
          defpos,storetokenpos : tfileposinfo;
          old_block_type : tblock_type;
          old_block_type : tblock_type;
@@ -462,8 +461,10 @@ implementation
                current_scanner.startrecordtokens(generictokenbuf);
                current_scanner.startrecordtokens(generictokenbuf);
              end;
              end;
 
 
-           { is the type already defined? }
-           searchsym(typename,sym,srsymtable);
+           { is the type already defined? -- must be in the current symtable,
+             not in a nested symtable or one higher up the stack -> don't
+             use searchsym & frinds! }
+           sym:=tsym(symtablestack.top.find(typename));
            newtype:=nil;
            newtype:=nil;
            { found a symbol with this name? }
            { found a symbol with this name? }
            if assigned(sym) then
            if assigned(sym) then

+ 2 - 1
compiler/pdecobj.pas

@@ -280,12 +280,13 @@ implementation
 
 
     procedure handleImplementedProtocol(intfdef : tobjectdef);
     procedure handleImplementedProtocol(intfdef : tobjectdef);
       begin
       begin
+        intfdef:=find_real_objcclass_definition(intfdef,false);
         if not is_objcprotocol(intfdef) then
         if not is_objcprotocol(intfdef) then
           begin
           begin
              Message1(type_e_protocol_type_expected,intfdef.typename);
              Message1(type_e_protocol_type_expected,intfdef.typename);
              exit;
              exit;
           end;
           end;
-        if (oo_is_forward in intfdef.objectoptions) then
+        if ([oo_is_forward,oo_is_formal] * intfdef.objectoptions <> []) then
           begin
           begin
              Message1(parser_e_forward_protocol_declaration_must_be_resolved,intfdef.objrealname^);
              Message1(parser_e_forward_protocol_declaration_must_be_resolved,intfdef.objrealname^);
              exit;
              exit;

+ 2 - 2
compiler/pdecsub.pas

@@ -3123,7 +3123,7 @@ const
                 can be in a different location because of the calling convention, eg. L-R vs. R-L order (PFV) }
                 can be in a different location because of the calling convention, eg. L-R vs. R-L order (PFV) }
               (
               (
                (compare_paras(currpd.paras,fwpd.paras,cp_none,[cpo_comparedefaultvalue,cpo_ignorehidden,cpo_openequalisexact,cpo_ignoreuniv])=te_exact) and
                (compare_paras(currpd.paras,fwpd.paras,cp_none,[cpo_comparedefaultvalue,cpo_ignorehidden,cpo_openequalisexact,cpo_ignoreuniv])=te_exact) and
-               (fwpd.returndef=currpd.returndef)
+               (compare_defs(fwpd.returndef,currpd.returndef,nothingn)=te_exact)
               ) then
               ) then
              begin
              begin
                { Check if we've found the forwarddef, if found then
                { Check if we've found the forwarddef, if found then
@@ -3194,7 +3194,7 @@ const
                    if ((m_repeat_forward in current_settings.modeswitches) or
                    if ((m_repeat_forward in current_settings.modeswitches) or
                        not is_bareprocdef(currpd)) and
                        not is_bareprocdef(currpd)) and
                       ((compare_paras(currpd.paras,fwpd.paras,cp_all,paracompopt)<>te_exact) or
                       ((compare_paras(currpd.paras,fwpd.paras,cp_all,paracompopt)<>te_exact) or
-                       (fwpd.returndef<>currpd.returndef)) then
+                       (compare_defs(fwpd.returndef,currpd.returndef,nothingn)<>te_exact)) then
                      begin
                      begin
                        MessagePos1(currpd.fileinfo,parser_e_header_dont_match_forward,
                        MessagePos1(currpd.fileinfo,parser_e_header_dont_match_forward,
                                    fwpd.fullprocname(false));
                                    fwpd.fullprocname(false));

+ 6 - 6
compiler/pexpr.pas

@@ -1455,7 +1455,7 @@ implementation
                         {  e.g., "with classinstance do field := 5"), then    }
                         {  e.g., "with classinstance do field := 5"), then    }
                         { let do_member_read handle it                        }
                         { let do_member_read handle it                        }
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-                          do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[])
+                          do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[])
                         else
                         else
                           { otherwise it's a regular record subscript }
                           { otherwise it's a regular record subscript }
                           p1:=csubscriptnode.create(srsym,p1);
                           p1:=csubscriptnode.create(srsym,p1);
@@ -1516,7 +1516,7 @@ implementation
                                if assigned(srsym) then
                                if assigned(srsym) then
                                  check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                  check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                consume(_ID);
                                consume(_ID);
-                               do_member_read(tobjectdef(hdef),false,srsym,p1,again,[]);
+                               do_member_read(tabstractrecorddef(hdef),false,srsym,p1,again,[]);
                              end
                              end
                            else
                            else
                             begin
                             begin
@@ -1531,7 +1531,7 @@ implementation
                                 begin
                                 begin
                                   check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                   check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                       consume(_ID);
                                       consume(_ID);
-                                      do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[]);
+                                      do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[]);
                                 end
                                 end
                               else
                               else
                                 Message1(sym_e_id_no_member,orgpattern);
                                 Message1(sym_e_id_no_member,orgpattern);
@@ -1565,7 +1565,7 @@ implementation
                                  begin
                                  begin
                                    check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                    check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                    consume(_ID);
                                    consume(_ID);
-                                   do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[]);
+                                   do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[]);
                                  end
                                  end
                                 else
                                 else
                                  begin
                                  begin
@@ -1615,7 +1615,7 @@ implementation
                         { not srsymtable.symtabletype since that can be }
                         { not srsymtable.symtabletype since that can be }
                         { withsymtable as well                          }
                         { withsymtable as well                          }
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-                          do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[])
+                          do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[])
                         else
                         else
                           { no procsyms in records (yet) }
                           { no procsyms in records (yet) }
                           internalerror(2007012006);
                           internalerror(2007012006);
@@ -1648,7 +1648,7 @@ implementation
                         { not srsymtable.symtabletype since that can be }
                         { not srsymtable.symtabletype since that can be }
                         { withsymtable as well                          }
                         { withsymtable as well                          }
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-                          do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[])
+                          do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[])
                         else
                         else
                           { no propertysyms in records (yet) }
                           { no propertysyms in records (yet) }
                           internalerror(2009111510);
                           internalerror(2009111510);

+ 65 - 0
compiler/procinfo.pas

@@ -47,10 +47,17 @@ unit procinfo;
 
 
 
 
     type
     type
+       tsavedlabels = array[Boolean] of TAsmLabel;
+
        {# This object gives information on the current routine being
        {# This object gives information on the current routine being
           compiled.
           compiled.
        }
        }
        tprocinfo = class(tlinkedlistitem)
        tprocinfo = class(tlinkedlistitem)
+       private
+          { list to store the procinfo's of the nested procedures }
+          nestedprocs : tlinkedlist;
+          procedure addnestedproc(child: tprocinfo);
+       public
           { pointer to parent in nested procedures }
           { pointer to parent in nested procedures }
           parent : tprocinfo;
           parent : tprocinfo;
           {# the definition of the routine itself }
           {# the definition of the routine itself }
@@ -123,6 +130,18 @@ unit procinfo;
 
 
           { Allocate got register }
           { Allocate got register }
           procedure allocate_got_register(list: TAsmList);virtual;
           procedure allocate_got_register(list: TAsmList);virtual;
+
+          { Destroy the entire procinfo tree, starting from the outermost parent }
+          procedure destroy_tree;
+
+          { Store CurrTrueLabel and CurrFalseLabel to saved and generate new ones }
+          procedure save_jump_labels(out saved: tsavedlabels);
+
+          { Restore CurrTrueLabel and CurrFalseLabel from saved }
+          procedure restore_jump_labels(const saved: tsavedlabels);
+
+          function get_first_nestedproc: tprocinfo;
+          function has_nestedprocs: boolean;
        end;
        end;
        tcprocinfo = class of tprocinfo;
        tcprocinfo = class of tprocinfo;
 
 
@@ -165,15 +184,61 @@ implementation
         CurrTrueLabel:=nil;
         CurrTrueLabel:=nil;
         CurrFalseLabel:=nil;
         CurrFalseLabel:=nil;
         maxpushedparasize:=0;
         maxpushedparasize:=0;
+        if Assigned(parent) and (parent.procdef.parast.symtablelevel>=normal_function_level) then
+          parent.addnestedproc(Self);
       end;
       end;
 
 
 
 
     destructor tprocinfo.destroy;
     destructor tprocinfo.destroy;
       begin
       begin
+         nestedprocs.free;
          aktproccode.free;
          aktproccode.free;
          aktlocaldata.free;
          aktlocaldata.free;
       end;
       end;
 
 
+    procedure tprocinfo.destroy_tree;
+      var
+        hp: tprocinfo;
+      begin
+        hp:=Self;
+        while Assigned(hp.parent) do
+          hp:=hp.parent;
+        hp.Free;
+      end;
+
+    procedure tprocinfo.addnestedproc(child: tprocinfo);
+      begin
+        if nestedprocs=nil then
+          nestedprocs:=TLinkedList.Create;
+        nestedprocs.insert(child);
+      end;
+
+    function tprocinfo.get_first_nestedproc: tprocinfo;
+      begin
+        if assigned(nestedprocs) then
+          result:=tprocinfo(nestedprocs.first)
+        else
+          result:=nil;
+      end;
+
+    function tprocinfo.has_nestedprocs: boolean;
+      begin
+        result:=assigned(nestedprocs) and (nestedprocs.count>0);
+      end;
+
+    procedure tprocinfo.save_jump_labels(out saved: tsavedlabels);
+      begin
+        saved[false]:=CurrFalseLabel;
+        saved[true]:=CurrTrueLabel;
+        current_asmdata.getjumplabel(CurrTrueLabel);
+        current_asmdata.getjumplabel(CurrFalseLabel);
+      end;
+
+    procedure tprocinfo.restore_jump_labels(const saved: tsavedlabels);
+      begin
+        CurrFalseLabel:=saved[false];
+        CurrTrueLabel:=saved[true];
+      end;
 
 
     procedure tprocinfo.allocate_push_parasize(size:longint);
     procedure tprocinfo.allocate_push_parasize(size:longint);
       begin
       begin

+ 6 - 19
compiler/psub.pas

@@ -45,10 +45,7 @@ interface
         stackcheck_asmnode,
         stackcheck_asmnode,
         init_asmnode,
         init_asmnode,
         final_asmnode : tasmnode;
         final_asmnode : tasmnode;
-        { list to store the procinfo's of the nested procedures }
-        nestedprocs : tlinkedlist;
         dfabuilder : TDFABuilder;
         dfabuilder : TDFABuilder;
-        constructor create(aparent:tprocinfo);override;
         destructor  destroy;override;
         destructor  destroy;override;
         procedure printproc(pass:string);
         procedure printproc(pass:string);
         procedure generate_code;
         procedure generate_code;
@@ -555,16 +552,8 @@ implementation
                                   TCGProcInfo
                                   TCGProcInfo
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tcgprocinfo.create(aparent:tprocinfo);
-      begin
-        inherited Create(aparent);
-        nestedprocs:=tlinkedlist.create;
-      end;
-
-
      destructor tcgprocinfo.destroy;
      destructor tcgprocinfo.destroy;
        begin
        begin
-         nestedprocs.free;
          if assigned(code) then
          if assigned(code) then
            code.free;
            code.free;
          inherited destroy;
          inherited destroy;
@@ -794,10 +783,10 @@ implementation
 
 
     function tcgprocinfo.has_assembler_child : boolean;
     function tcgprocinfo.has_assembler_child : boolean;
       var
       var
-        hp : tcgprocinfo;
+        hp : tprocinfo;
       begin
       begin
         result:=false;
         result:=false;
-        hp:=tcgprocinfo(nestedprocs.first);
+        hp:=get_first_nestedproc;
         while assigned(hp) do
         while assigned(hp) do
           begin
           begin
             if (hp.flags*[pi_has_assembler_block,pi_is_assembler])<>[] then
             if (hp.flags*[pi_has_assembler_block,pi_is_assembler])<>[] then
@@ -805,7 +794,7 @@ implementation
                 result:=true;
                 result:=true;
                 exit;
                 exit;
               end;
               end;
-            hp:=tcgprocinfo(hp.next);
+            hp:=tprocinfo(hp.next);
           end;
           end;
       end;
       end;
 
 
@@ -1549,7 +1538,7 @@ implementation
           { generate code for this procedure }
           { generate code for this procedure }
           pi.generate_code;
           pi.generate_code;
           { process nested procs }
           { process nested procs }
-          hpi:=tcgprocinfo(pi.nestedprocs.first);
+          hpi:=tcgprocinfo(pi.get_first_nestedproc);
           while assigned(hpi) do
           while assigned(hpi) do
            begin
            begin
              do_generate_code(hpi);
              do_generate_code(hpi);
@@ -1602,7 +1591,7 @@ implementation
         { We can't support inlining for procedures that have nested
         { We can't support inlining for procedures that have nested
           procedures because the nested procedures use a fixed offset
           procedures because the nested procedures use a fixed offset
           for accessing locals in the parent procedure (PFV) }
           for accessing locals in the parent procedure (PFV) }
-        if (tcgprocinfo(current_procinfo).nestedprocs.count>0) then
+        if current_procinfo.has_nestedprocs then
           begin
           begin
             if (df_generic in current_procinfo.procdef.defoptions) then
             if (df_generic in current_procinfo.procdef.defoptions) then
               Comment(V_Error,'Generic methods cannot have nested procedures')
               Comment(V_Error,'Generic methods cannot have nested procedures')
@@ -1618,9 +1607,7 @@ implementation
         { When it's a nested procedure then defer the code generation,
         { When it's a nested procedure then defer the code generation,
           when back at normal function level then generate the code
           when back at normal function level then generate the code
           for all defered nested procedures and the current procedure }
           for all defered nested procedures and the current procedure }
-        if isnestedproc then
-          tcgprocinfo(current_procinfo.parent).nestedprocs.insert(current_procinfo)
-        else
+        if not isnestedproc then
           begin
           begin
             if not(df_generic in current_procinfo.procdef.defoptions) then
             if not(df_generic in current_procinfo.procdef.defoptions) then
               do_generate_code(tcgprocinfo(current_procinfo));
               do_generate_code(tcgprocinfo(current_procinfo));

+ 97 - 48
compiler/ptype.pas

@@ -40,9 +40,6 @@ interface
 
 
     procedure resolve_forward_types;
     procedure resolve_forward_types;
 
 
-    { reads a type identifier }
-    procedure id_type(var def : tdef;isforwarddef:boolean);
-
     { reads a string, file type or a type identifier }
     { reads a string, file type or a type identifier }
     procedure single_type(var def:tdef;options:TSingleTypeOptions);
     procedure single_type(var def:tdef;options:TSingleTypeOptions);
 
 
@@ -402,7 +399,96 @@ implementation
       end;
       end;
 
 
 
 
-    procedure id_type(var def : tdef;isforwarddef:boolean);
+    procedure id_type(var def : tdef;isforwarddef,checkcurrentrecdef:boolean); forward;
+
+    { def is the outermost type in which other types have to be searched
+
+      isforward indicates whether the current definition can be a forward definition
+
+      if assigned, currentstructstack is a list of tabstractrecorddefs that, from
+      last to first, are child types of def that are not yet visible via the
+      normal symtable searching routines because they are types that are currently
+      being parsed (so using id_type on them after pushing def on the
+      symtablestack would result in errors because they'd come back as errordef)
+    }
+    procedure parse_nested_types(var def: tdef; isforwarddef: boolean; currentstructstack: tfpobjectlist);
+      var
+        t2: tdef;
+        structstackindex: longint;
+      begin
+        if assigned(currentstructstack) then
+          structstackindex:=currentstructstack.count-1
+        else
+          structstackindex:=-1;
+        { handle types inside classes, e.g. TNode.TLongint }
+        while (token=_POINT) do
+          begin
+            if parse_generic then
+              begin
+                 consume(_POINT);
+                 consume(_ID);
+              end
+             else if is_class_or_object(def) or is_record(def) then
+               begin
+                 consume(_POINT);
+                 if (structstackindex>=0) and
+                    (tabstractrecorddef(currentstructstack[structstackindex]).objname^=pattern) then
+                   begin
+                     def:=tdef(currentstructstack[structstackindex]);
+                     dec(structstackindex);
+                     consume(_ID);
+                   end
+                 else
+                   begin
+                     structstackindex:=-1;
+                     symtablestack.push(tabstractrecorddef(def).symtable);
+                     t2:=generrordef;
+                     id_type(t2,isforwarddef,false);
+                     symtablestack.pop(tabstractrecorddef(def).symtable);
+                     def:=t2;
+                   end;
+               end
+             else
+               break;
+          end;
+      end;
+
+
+    function try_parse_structdef_nested_type(out def: tdef; basedef: tabstractrecorddef; isfowarddef: boolean): boolean;
+      var
+        structdef : tdef;
+        structdefstack : tfpobjectlist;
+      begin
+         { use of current parsed object:
+           classes, objects, records can be used also in themself }
+         structdef:=basedef;
+         structdefstack:=nil;
+         while assigned(structdef) and (structdef.typ in [objectdef,recorddef]) do
+           begin
+             if (tabstractrecorddef(structdef).objname^=pattern) then
+               begin
+                 consume(_ID);
+                 def:=structdef;
+                 { we found the top-most match, now check how far down we can
+                   follow }
+                 structdefstack:=tfpobjectlist.create(false);
+                 structdef:=basedef;
+                 while (structdef<>def) do
+                   begin
+                     structdefstack.add(structdef);
+                     structdef:=tabstractrecorddef(structdef.owner.defowner);
+                   end;
+                 parse_nested_types(def,isfowarddef,structdefstack);
+                 structdefstack.free;
+                 result:=true;
+                 exit;
+               end;
+             structdef:=tdef(tabstractrecorddef(structdef).owner.defowner);
+           end;
+         result:=false;
+      end;
+
+    procedure id_type(var def : tdef;isforwarddef,checkcurrentrecdef:boolean);
     { reads a type definition }
     { reads a type definition }
     { to a appropriating tdef, s gets the name of   }
     { to a appropriating tdef, s gets the name of   }
     { the type to allow name mangling          }
     { the type to allow name mangling          }
@@ -420,17 +506,9 @@ implementation
          pos:=current_tokenpos;
          pos:=current_tokenpos;
          { use of current parsed object:
          { use of current parsed object:
            classes, objects, records can be used also in themself }
            classes, objects, records can be used also in themself }
-         structdef:=current_structdef;
-         while assigned(structdef) and (structdef.typ in [objectdef,recorddef]) do
-           begin
-             if (structdef.objname^=pattern) then
-               begin
-                 consume(_ID);
-                 def:=structdef;
-                 exit;
-               end;
-             structdef:=tabstractrecorddef(structdef.owner.defowner);
-           end;
+         if checkcurrentrecdef and
+            try_parse_structdef_nested_type(def,current_structdef,isforwarddef) then
+           exit;
          { Use the special searchsym_type that search only types }
          { Use the special searchsym_type that search only types }
          searchsym_type(s,srsym,srsymtable);
          searchsym_type(s,srsym,srsymtable);
          { handle unit specification like System.Writeln }
          { handle unit specification like System.Writeln }
@@ -531,26 +609,8 @@ implementation
                      end
                      end
                    else
                    else
                      begin
                      begin
-                       id_type(def,stoIsForwardDef in options);
-                       { handle types inside classes, e.g. TNode.TLongint }
-                       while (token=_POINT) do
-                         begin
-                           if parse_generic then
-                             begin
-                                consume(_POINT);
-                                consume(_ID);
-                             end
-                            else if is_class_or_object(def) or is_record(def) then
-                              begin
-                                symtablestack.push(tabstractrecorddef(def).symtable);
-                                consume(_POINT);
-                                id_type(t2,stoIsForwardDef in options);
-                                symtablestack.pop(tabstractrecorddef(def).symtable);
-                                def:=t2;
-                              end
-                            else
-                              break;
-                         end;
+                       id_type(def,stoIsForwardDef in options,true);
+                       parse_nested_types(def,stoIsForwardDef in options,nil);
                      end;
                      end;
                  end;
                  end;
 
 
@@ -957,19 +1017,8 @@ implementation
            { use of current parsed object:
            { use of current parsed object:
              classes, objects, records can be used also in themself }
              classes, objects, records can be used also in themself }
            if (token=_ID) then
            if (token=_ID) then
-             begin
-               structdef:=current_structdef;
-               while assigned(structdef) and (structdef.typ in [objectdef,recorddef]) do
-                 begin
-                   if (tabstractrecorddef(structdef).objname^=pattern) then
-                     begin
-                       consume(_ID);
-                       def:=structdef;
-                       exit;
-                     end;
-                   structdef:=tdef(structdef.owner.defowner);
-                 end;
-             end;
+             if try_parse_structdef_nested_type(def,current_structdef,false) then
+               exit;
            { Generate a specialization in FPC mode? }
            { Generate a specialization in FPC mode? }
            dospecialize:=not(m_delphi in current_settings.modeswitches) and try_to_consume(_SPECIALIZE);
            dospecialize:=not(m_delphi in current_settings.modeswitches) and try_to_consume(_SPECIALIZE);
            { we can't accept a equal in type }
            { we can't accept a equal in type }

+ 1 - 1
compiler/regvars.pas

@@ -148,7 +148,7 @@ implementation
       if (cs_opt_regvar in current_settings.optimizerswitches) and
       if (cs_opt_regvar in current_settings.optimizerswitches) and
         { we have to store regvars back to memory in this case (the nested }
         { we have to store regvars back to memory in this case (the nested }
         { procedures can access the variables of the parent)               }
         { procedures can access the variables of the parent)               }
-        (tcgprocinfo(current_procinfo).nestedprocs.count = 0) and
+        (not current_procinfo.has_nestedprocs) and
          not(pi_has_assembler_block in current_procinfo.flags) and
          not(pi_has_assembler_block in current_procinfo.flags) and
          not(pi_uses_exceptions in current_procinfo.flags) then
          not(pi_uses_exceptions in current_procinfo.flags) then
         begin
         begin

+ 18 - 9
compiler/symdef.pas

@@ -76,6 +76,7 @@ interface
           function  is_publishable : boolean;override;
           function  is_publishable : boolean;override;
           function  needs_inittable : boolean;override;
           function  needs_inittable : boolean;override;
           function  rtti_mangledname(rt:trttitype):string;override;
           function  rtti_mangledname(rt:trttitype):string;override;
+          function  OwnerHierarchyName: string; override;
           function  in_currentunit: boolean;
           function  in_currentunit: boolean;
           { regvars }
           { regvars }
           function is_intregable : boolean;
           function is_intregable : boolean;
@@ -1133,6 +1134,22 @@ implementation
       end;
       end;
 
 
 
 
+    function tstoreddef.OwnerHierarchyName: string;
+      var
+        tmp: tdef;
+      begin
+        tmp:=self;
+        result:='';
+        repeat
+          if tmp.owner.symtabletype in [ObjectSymtable,recordsymtable] then
+            tmp:=tdef(tmp.owner.defowner)
+          else
+            break;
+          result:=tabstractrecorddef(tmp).objrealname^+'.'+result;
+        until tmp=nil;
+      end;
+
+
     function tstoreddef.in_currentunit: boolean;
     function tstoreddef.in_currentunit: boolean;
       var
       var
         st: tsymtable;
         st: tsymtable;
@@ -2788,15 +2805,7 @@ implementation
       var
       var
         tmp: tabstractrecorddef;
         tmp: tabstractrecorddef;
       begin
       begin
-        Result:=objrealname^;
-        tmp:=self;
-        repeat
-          if tmp.owner.symtabletype in [ObjectSymtable,recordsymtable] then
-            tmp:=tabstractrecorddef(tmp.owner.defowner)
-          else
-            break;
-          Result:=tmp.objrealname^+'.'+Result;
-        until tmp=nil;
+        Result:=OwnerHierarchyName+objrealname^;
       end;
       end;
 
 
     function tabstractrecorddef.search_enumerator_get: tprocdef;
     function tabstractrecorddef.search_enumerator_get: tprocdef;

+ 1 - 0
compiler/symtable.pas

@@ -2248,6 +2248,7 @@ implementation
       var
       var
         hashedid : THashedIDString;
         hashedid : THashedIDString;
       begin
       begin
+        result:=false;
         hashedid.id:=s;
         hashedid.id:=s;
         { search for a record helper method first }
         { search for a record helper method first }
         result:=search_objectpascal_helper(recordh,recordh,s,srsym,srsymtable);
         result:=search_objectpascal_helper(recordh,recordh,s,srsym,srsymtable);

+ 7 - 4
compiler/symtype.pas

@@ -73,6 +73,7 @@ interface
          function  mangledparaname:string;
          function  mangledparaname:string;
          function  getmangledparaname:string;virtual;
          function  getmangledparaname:string;virtual;
          function  rtti_mangledname(rt:trttitype):string;virtual;abstract;
          function  rtti_mangledname(rt:trttitype):string;virtual;abstract;
+         function  OwnerHierarchyName: string; virtual; abstract;
          function  size:asizeint;virtual;abstract;
          function  size:asizeint;virtual;abstract;
          function  packedbitsize:asizeint;virtual;
          function  packedbitsize:asizeint;virtual;
          function  alignment:shortint;virtual;abstract;
          function  alignment:shortint;virtual;abstract;
@@ -258,12 +259,13 @@ implementation
 
 
     function tdef.typename:string;
     function tdef.typename:string;
       begin
       begin
+        result:=OwnerHierarchyName;
         if assigned(typesym) and
         if assigned(typesym) and
            not(typ in [procvardef,procdef]) and
            not(typ in [procvardef,procdef]) and
            (typesym.realname[1]<>'$') then
            (typesym.realname[1]<>'$') then
-          result:=typesym.realname
+          result:=result+typesym.realname
         else
         else
-          result:=GetTypeName;
+          result:=result+GetTypeName;
       end;
       end;
 
 
 
 
@@ -275,10 +277,11 @@ implementation
 
 
     function tdef.typesymbolprettyname:string;
     function tdef.typesymbolprettyname:string;
       begin
       begin
+        result:=OwnerHierarchyName;
         if assigned(typesym) then
         if assigned(typesym) then
-          result:=typesym.prettyname
+          result:=result+typesym.prettyname
         else
         else
-          result:='<no type symbol>'
+          result:=result+'<no type symbol>'
       end;
       end;
 
 
     function tdef.mangledparaname:string;
     function tdef.mangledparaname:string;

+ 1 - 0
compiler/systems.pas

@@ -185,6 +185,7 @@ interface
              ,as_ggas                  { gnu assembler called "gas" instead of "as" }
              ,as_ggas                  { gnu assembler called "gas" instead of "as" }
              ,as_i386_nasmhaiku
              ,as_i386_nasmhaiku
              ,as_powerpc_vasm
              ,as_powerpc_vasm
+             ,as_i386_nlmcoff
        );
        );
 
 
        tar = (ar_none
        tar = (ar_none

+ 5 - 5
compiler/systems/i_nwm.pas

@@ -34,7 +34,7 @@ unit i_nwm;
             system       : system_i386_netware;
             system       : system_i386_netware;
             name         : 'Netware for i386(clib)';
             name         : 'Netware for i386(clib)';
             shortname    : 'Netware';
             shortname    : 'Netware';
-            flags        : [tf_smartlink_library];
+            flags        : [tf_smartlink_library,tf_smartlink_sections,tf_dwarf_only_local_labels];
             cpu          : cpu_i386;
             cpu          : cpu_i386;
             unit_env     : 'NETWAREUNITS';
             unit_env     : 'NETWAREUNITS';
             extradefines : 'NETWARE_CLIB';
             extradefines : 'NETWARE_CLIB';
@@ -50,18 +50,18 @@ unit i_nwm;
             resobjext    : '.or';
             resobjext    : '.or';
             sharedlibext : '.nlm';
             sharedlibext : '.nlm';
             staticlibext : '.a';
             staticlibext : '.a';
-            staticlibprefix : '';
+            staticlibprefix : 'libp';
             sharedlibprefix : '';
             sharedlibprefix : '';
             sharedClibext : '.nlm';
             sharedClibext : '.nlm';
             staticClibext : '.a';
             staticClibext : '.a';
-            staticClibprefix : '';
+            staticClibprefix : 'lib';
             sharedClibprefix : '';
             sharedClibprefix : '';
-            importlibprefix : 'imp';
+            importlibprefix : 'libimp';
             importlibext : '.a';
             importlibext : '.a';
             Cprefix      : '';
             Cprefix      : '';
             newline      : #13#10;
             newline      : #13#10;
             dirsep       : '/';
             dirsep       : '/';
-            assem        : as_i386_elf32;
+            assem        : as_i386_nlmcoff; // as_i386_elf32;
             assemextern  : as_gas;
             assemextern  : as_gas;
             link         : nil;
             link         : nil;
             linkextern   : nil;
             linkextern   : nil;

+ 384 - 1
compiler/systems/t_nwm.pas

@@ -97,7 +97,7 @@ implementation
     verbose,systems,globtype,globals,
     verbose,systems,globtype,globals,
     symconst,script,
     symconst,script,
     fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
     fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
-    import,export,link,i_nwm,ogbase
+    import,export,link,i_nwm,ogbase, ogcoff, ognlm
     {$ifdef netware} ,dos {$endif}
     {$ifdef netware} ,dos {$endif}
     ;
     ;
 
 
@@ -123,6 +123,15 @@ implementation
       function  MakeExecutable:boolean;override;
       function  MakeExecutable:boolean;override;
     end;
     end;
 
 
+    TInternalLinkerNetware = class(TInternalLinker)
+        prelude : string;
+        constructor create;override;
+        procedure DefaultLinkScript;override;
+        procedure InitSysInitUnitName;override;
+        procedure ConcatEntryName; virtual;
+        Function  MakeSharedLibrary:boolean;override;
+      end;
+
 Const tmpLinkFileName = 'link~tmp._o_';
 Const tmpLinkFileName = 'link~tmp._o_';
       minStackSize = 32768;
       minStackSize = 32768;
 
 
@@ -549,6 +558,379 @@ begin
 end;
 end;
 
 
 
 
+{****************************************************************************
+                            TInternalLinkerNetware
+****************************************************************************}
+
+    constructor TInternalLinkerNetware.Create;
+      begin
+        inherited Create;
+        CExeoutput:=TNLMexeoutput;
+        CObjInput:=TNLMCoffObjInput;
+      end;
+
+
+    procedure TInternalLinkerNetware.DefaultLinkScript;
+      var
+        s,s2 : TCmdStr;
+        secname,
+        secnames : string;
+        hasCopyright,
+        hasScreenname,
+        hasThreadname,
+        hasVersion,
+        hasDescription,
+        hasStacksize: boolean;
+        t : text;
+
+
+
+        procedure addLinkerOption(s : string);
+        var op : string;
+        begin
+          if s = '' then exit;
+          if s[1]  = '#' then exit;
+          LinkScript.Concat(s);
+          op := upper(GetToken(s,' '));
+          {check for options via -k that can also be specified vie
+           compiler directives in source, -k options will override
+           options in source}
+          if op = 'COPYRIGHT' then hasCopyright := true else
+          if op = 'SCREENNAME' then hasScreenname := true else
+          if op = 'THREADNAME' then hasThreadname := true else
+          if op = 'VERSION' then hasVersion := true else
+          if op = 'DESCRIPTION' then hasDescription := true else
+          if (op = 'STACK') or (op = 'STACKSIZE') then hasStacksize := true;
+        end;
+
+        { add linker scropt specified by -k@FileName }
+        procedure addLinkerOptionsFile (fileName : string);
+        var
+          t : text;
+          option : string;
+          fn : TCmdStr;
+        begin
+          fn := fileName;
+          if not sysutils.fileExists(fn) then
+            if not includesearchpath.FindFile(fileName,true,fn) then
+            begin
+              comment(v_error,'linker options file "'+fileName+'" not found');
+              exit;
+            end;
+          assign(t,fn); reset(t);
+          while not eof(t) do
+            begin
+              readln(t,option);
+              addLinkerOption(option);
+            end;
+          close(t);
+        end;
+
+        { add  linker options specified by command line parameter -k }
+        procedure addLinkerOptions;
+        var
+          s,option : string;
+          p : integer;
+        begin
+          s := ParaLinkOptions;
+          option := GetToken(s,';');
+          while option <> '' do
+          begin
+            if copy(option,1,1)='@' then
+            begin
+              delete(option,1,1);
+              addLinkerOptionsFile(option);
+            end else
+              addLinkerOption(option);
+            option := GetToken(s,';');
+          end;
+        end;
+
+        { default: nwpre but can be specified via linker options
+          bacuse this has to be the first object, we have to scan
+          linker options before adding other options }
+
+        function findPreludeInFile (fileName : string):string;
+        var
+          t : text;
+          option,s : string;
+          fn : TCmdStr;
+        begin
+          result := '';
+          fn := fileName;
+          if not sysutils.fileExists(fn) then
+            if not includesearchpath.FindFile(fileName,true,fn) then
+            begin
+              comment(v_error,'linker options file "'+fileName+'" not found');
+              exit;
+            end;
+          assign(t,fn); reset(t);
+          while not eof(t) do
+            begin
+              readln(t,option);
+              option := upper(GetToken(s,' '));
+              if option='PRELUDE' then
+                begin
+                  result := getToken(s,' ');
+                  close(t);
+                  exit;
+                end;
+            end;
+          close(t);
+        end;
+
+        function findPrelude : string;
+        var
+          s,option,keyword : string;
+          p : integer;
+        begin
+          s := ParaLinkOptions;
+          option := GetToken(s,';');
+          while option <> '' do
+          begin
+            if copy(option,1,1)='@' then
+            begin
+              delete(option,1,1);
+              result := findPreludeInFile(option);
+              if result <> '' then exit;
+            end else
+            begin
+              keyword := GetToken(option,' ');
+              if keyword = 'PRELUDE' then
+                begin
+                  result := GetToken(option,' ');
+                  exit;
+                end;
+            end;
+            option := GetToken(s,';');
+          end;
+          result := 'nwpre';
+        end;
+
+      begin
+        with LinkScript do
+          begin
+            prelude := findPrelude;  // needs to be first object, can be specified by -k"PRELUDE ObjFileName"
+            if prelude = '' then internalerror(201103271);
+            if pos ('.',prelude) = 0 then prelude := prelude + '.o';
+            s2 := FindObjectFile(prelude,'',false);
+            Comment (V_Debug,'adding init Object File '+s2);
+            Concat('READOBJECT '+MaybeQuoted(s2));
+            while not ObjectFiles.Empty do
+              begin
+                s:=ObjectFiles.GetFirst;
+                if s<>'' then
+                begin
+                  Concat('READOBJECT '+MaybeQuoted(s));
+                  Comment (V_Debug,'adding Object File '+s);
+                end;
+              end;
+            while not StaticLibFiles.Empty do
+              begin
+                s:=StaticLibFiles.GetFirst;
+                if s<>'' then
+                begin
+                  Comment (V_Debug,'adding StaticLibFile '+s);
+                  Concat('READSTATICLIBRARY '+MaybeQuoted(s));
+                end;
+              end;
+           { While not SharedLibFiles.Empty do
+              begin
+                S:=SharedLibFiles.GetFirst;
+                if FindLibraryFile(s,target_info.staticClibprefix,target_info.importlibext,s2) then
+                begin
+                  Comment (V_Debug,'adding LibraryFile '+s);
+                  Concat('READSTATICLIBRARY '+MaybeQuoted(s2));
+                end else
+                  Comment(V_Error,'Import library not found for '+S);
+              end;}
+            if IsSharedLibrary then
+              Concat('ISSHAREDLIBRARY');
+            ConcatEntryName;
+            Concat('IMAGEBASE $' + hexStr(0, SizeOf(imagebase)*2));
+            Concat('HEADER');
+            Concat('EXESECTION .text');
+            Concat('  SYMBOL __text_start__');
+            Concat('  OBJSECTION .text*');
+            Concat('  SYMBOL ___CTOR_LIST__');
+            Concat('  SYMBOL __CTOR_LIST__');
+            Concat('  LONG -1');
+            Concat('  OBJSECTION .ctor*');
+            Concat('  LONG 0');
+            Concat('  SYMBOL ___DTOR_LIST__');
+            Concat('  SYMBOL __DTOR_LIST__');
+            Concat('  LONG -1');
+            Concat('  OBJSECTION .dtor*');
+            Concat('  LONG 0');
+            Concat('  SYMBOL etext');
+            Concat('ENDEXESECTION');
+            Concat('EXESECTION .data');
+            Concat('  SYMBOL __data_start__');
+            Concat('  OBJSECTION .data*');
+            Concat('  OBJSECTION .fpc*');
+            Concat('  SYMBOL edata');
+            Concat('  SYMBOL __data_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .bss');
+            Concat('  SYMBOL __bss_start__');
+            Concat('  OBJSECTION .bss*');
+            Concat('  SYMBOL __bss_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .imports');
+            Concat('  SYMBOL __imports_start__');
+            Concat('  OBJSECTION .imports*');
+            Concat('  SYMBOL __imports_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .modules');
+            Concat('  SYMBOL __modules_start__');
+            Concat('  OBJSECTION .modules*');
+            Concat('  SYMBOL __modules_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .exports');
+            Concat('  SYMBOL __exports_start__');
+            Concat('  OBJSECTION .exports*');
+            Concat('  SYMBOL __exports_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .reloc');
+            Concat('  SYMBOL __reloc_start__');
+            Concat('  OBJSECTION .reloc*');
+            Concat('  SYMBOL __reloc_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .xdc');
+            Concat('  OBJSECTION .xdc*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .custom');
+            Concat('  OBJSECTION .custom*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .messages');
+            Concat('  OBJSECTION .messages*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .help');
+            Concat('  OBJSECTION .help*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .rdata');
+            Concat('  SYMBOL ___RUNTIME_PSEUDO_RELOC_LIST__');
+            Concat('  SYMBOL __RUNTIME_PSEUDO_RELOC_LIST__');
+            Concat('  OBJSECTION .rdata_runtime_pseudo_reloc');
+            Concat('  SYMBOL ___RUNTIME_PSEUDO_RELOC_LIST_END__');
+            Concat('  SYMBOL __RUNTIME_PSEUDO_RELOC_LIST_END__');
+            Concat('  OBJSECTION .rdata*');
+            Concat('  OBJSECTION .rodata*');
+            Concat('ENDEXESECTION');
+            Concat('EXESECTION .pdata');
+            Concat('  OBJSECTION .pdata');
+            Concat('ENDEXESECTION');
+            secnames:='.edata,.rsrc,.gnu_debuglink,'+
+                      '.debug_aranges,.debug_pubnames,.debug_info,.debug_abbrev,.debug_line,.debug_frame,.debug_str,.debug_loc,'+
+                      '.debug_macinfo,.debug_weaknames,.debug_funcnames,.debug_typenames,.debug_varnames,.debug_ranges';
+            repeat
+              secname:=gettoken(secnames,',');
+              if secname='' then
+                break;
+              Concat('EXESECTION '+secname);
+              Concat('  OBJSECTION '+secname+'*');
+              Concat('ENDEXESECTION');
+            until false;
+            { Can't use the generic rules, because that will add also .stabstr to .stab }
+            Concat('EXESECTION .stab');
+            Concat('  OBJSECTION .stab');
+            Concat('ENDEXESECTION');
+            Concat('EXESECTION .stabstr');
+            Concat('  OBJSECTION .stabstr');
+            Concat('ENDEXESECTION');
+            Concat('STABS');
+            Concat('SYMBOLS');
+            Concat('');
+
+            hasCopyright := false;
+            hasScreenname := false;
+            hasThreadname := false;
+            hasVersion := false;
+            hasDescription := false;
+            hasStacksize := false;
+            addLinkerOptions;
+            if not hasCopyright then
+              if nwcopyright <> '' then
+                Concat('COPYRIGHT "'+nwCopyright+'"');
+            if not hasScreenname then
+              if nwscreenname <> '' then
+                Concat('SCREENNAME "'+nwscreenname+'"');
+            if not hasThreadname then
+              if nwthreadname <> '' then
+                Concat('THREADNAME "'+nwthreadname+'"');
+            if not hasVersion then
+              Concat('VERSION '+tostr(dllmajor)+' '+tostr(dllminor)+' '+tostr(dllrevision));
+            if not hasDescription then
+              if description <> '' then
+                Concat ('DESCRIPTION "'+description+'"');
+            if not hasStacksize then
+              if MaxStackSizeSetExplicity then
+              begin
+                if stacksize < minStackSize then stacksize := minStackSize;
+                Concat ('STACKSIZE '+tostr(stacksize));
+              end else
+                Concat ('STACKSIZE '+tostr(minStackSize));
+          end;
+
+        // add symbols needed by nwpre. We have not loaded the ppu,
+        // therefore we do not know the externals so read it from nwpre.imp
+        s := ChangeFileExt(prelude,'.imp');  // nwpre.imp
+        if not librarysearchpath.FindFile(s,true,s2) then
+          begin
+            comment(v_error,s+' not found');
+            exit;
+          end;
+        assign(t,s2); reset(t);
+        while not eof(t) do
+          begin
+            readln(t,s);
+            s := trimspace(s);
+            if (length(s) > 0) then
+              if copy(s,1,1) <> '#' then
+                AddImportSymbol('!clib',s,0,false);
+          end;
+        close(t);
+      end;
+
+
+    procedure TInternalLinkerNetware.InitSysInitUnitName;
+      begin
+        //if target_info.system=system_i386_netware then
+        //  GlobalInitSysInitUnitName(self);
+      end;
+
+    procedure TInternalLinkerNetware.ConcatEntryName;
+      begin
+        with LinkScript do
+          begin
+            if IsSharedLibrary then
+              begin
+                Concat('ISSHAREDLIBRARY');
+                Concat('ENTRYNAME _Prelude')
+              end
+            else
+              begin
+                Concat('ENTRYNAME _Prelude')
+              end;
+          end;
+      end;
+
+
+    Function  TInternalLinkerNetware.MakeSharedLibrary:boolean;
+    begin
+      Comment(V_Error,'Make shared library not supported for netware');
+    end;
+
 {*****************************************************************************
 {*****************************************************************************
                                      Initialize
                                      Initialize
 *****************************************************************************}
 *****************************************************************************}
@@ -556,6 +938,7 @@ end;
 
 
 initialization
 initialization
   RegisterExternalLinker(system_i386_netware_info,TLinkerNetware);
   RegisterExternalLinker(system_i386_netware_info,TLinkerNetware);
+  RegisterInternalLinker(system_i386_netware_info,TInternalLinkerNetware);
   RegisterImport(system_i386_netware,TImportLibNetware);
   RegisterImport(system_i386_netware,TImportLibNetware);
   RegisterExport(system_i386_netware,TExportLibNetware);
   RegisterExport(system_i386_netware,TExportLibNetware);
   RegisterTarget(system_i386_netware_info);
   RegisterTarget(system_i386_netware_info);

+ 27 - 521
compiler/utils/samplecfg

@@ -5,30 +5,6 @@
 #  Generate Sample Free Pascal configuration file
 #  Generate Sample Free Pascal configuration file
 #
 #
 
 
-setgccdir() {
-# Find path to libgcc.a
-GCCSPEC=`(gcc -v $@ 2>&1)| head -n 1| awk '{ print $4 } '`
-if [ -z "$GCCSPEC" ] ; then
-  GCCSPEC=`gcc -print-libgcc-file-name $@ 2>/dev/null`
-fi
-GCCDIR=`dirname "$GCCSPEC"`
-}
-
-
-setgccdirarch() {
-# First argument is fpc define for CPU type; remaining args are passed to gcc to set corresponding architecture
-FPCDEFINE=$1
-shift
-setgccdir $@
-
-if [ -z "$GCCDIR" ] ; then
-  return
-fi
-GCCDIR="#ifdef $FPCDEFINE
--Fl$GCCDIR
-#endif"
-}
-
 HOSTOS=`uname -s | tr A-Z a-z`
 HOSTOS=`uname -s | tr A-Z a-z`
 echo Running on $HOSTOS
 echo Running on $HOSTOS
 
 
@@ -47,18 +23,23 @@ else
 fi
 fi
 FPCBIN=`dirname "$1"`/../../bin/fpc
 FPCBIN=`dirname "$1"`/../../bin/fpc
 FPBIN=`dirname "$1"`/../../bin/fp
 FPBIN=`dirname "$1"`/../../bin/fp
+FPPKGBIN=`dirname "$1"`/../../bin/fppkg
 sysfpdirbase=`dirname "$1"`/`"$FPCBIN" -iV`
 sysfpdirbase=`dirname "$1"`/`"$FPCBIN" -iV`
 sysfpdirbase2=$sysfpdirbase/ide
 sysfpdirbase2=$sysfpdirbase/ide
 sysfpdir=$sysfpdirbase2/text
 sysfpdir=$sysfpdirbase2/text
-fpctargetos=`"$FPCBIN" -iTO`
 
 
 # Detect if we have write permission in sysdir.
 # Detect if we have write permission in sysdir.
 if [ -w "$sysdir" ] ; then
 if [ -w "$sysdir" ] ; then
   echo Write permission in $sysdir.
   echo Write permission in $sysdir.
   fpccfgfile="$sysdir"/fpc.cfg
   fpccfgfile="$sysdir"/fpc.cfg
+  fppkgfile="$sysdir"/fppkg.cfg
+  defaultfile="$sysdir"/fppkg/default
+  compilerconfigdir="-d CompilerConfigDir=$sysdir/fppkg"
 else
 else
   echo No write premission in $sysdir.
   echo No write premission in $sysdir.
   fpccfgfile="$HOME"/.fpc.cfg
   fpccfgfile="$HOME"/.fpc.cfg
+  fppkgfile="$HOME"/.config/fppkg.cfg
+  defaultfile="$HOME"/.fppkg/config/default
 fi
 fi
 #
 #
 
 
@@ -69,388 +50,24 @@ if [ -f "$FPBIN" ] ; then
   fpinifile="$HOME"/.fp/fp.ini
   fpinifile="$HOME"/.fp/fp.ini
   fpcfgfile="$HOME"/.fp/fp.cfg
   fpcfgfile="$HOME"/.fp/fp.cfg
 
 
-# Detect if we have write permission in sysfpdirbase.
-  if [ -w "$sysfpdirbase" ] ; then
-    echo Write permission in $sysfpdirbase.
-    if ! [ -d "$sysfpdirbase2" ] ; then
-      echo Directory $sysfpdirbase2 did not exist, attempting to create it now
-      mkdir $sysfpdirbase2  >/dev/null 2>&1
-      echo Attempting to create directory $sysfpdir
-      mkdir $sysfpdir  >/dev/null 2>&1
-    elif ! [ -d "$sysfpdir" ] ; then
-      echo Directory $sysfpdir did not exist, attempting to create it now
-      mkdir $sysfpdir  >/dev/null 2>&1
-    fi
-    if [ -w "$sysfpdir" ] ; then
-      fpinifile="$sysfpdir"/fp.ini
-      fpcfgfile="$sysfpdir"/fp.cfg
-    fi
+# Detect if we have write permission in sysfpdir, or that the directory can be made
+  if ( [ -d "$sysfpdirbase" ] && [ -w "$sysfpdirbase" ] && ! [ -d "$sysfpdirbase2" ] ) ||
+     ( [ -d "$sysfpdirbase2" ] && [ -w "$sysfpdirbase2" ] && ! [ -d "$sysfpdir" ] ) ||
+     ( [ -d "$sysfpdir" ] && [ -w "$sysfpdir" ] ) ; then
+    fpinifile="$sysfpdir"/fp.ini
+    fpcfgfile="$sysfpdir"/fp.cfg
   fi
   fi
 #
 #
-
-# When the local FP IDE configuration is used, check if the directory exists
-  if [ $fpcfgfile = "$HOME"/.fp/fp.cfg -a ! -d "$HOME"/.fp ] ; then
-    echo Directory $HOME/.fp did not exist, attempting to create it now
-    mkdir "$HOME"/.fp >/dev/null 2>&1     
-  fi
-fi
-#
-
-if [ -f "$fpccfgfile" ] ; then
-  mv "$fpccfgfile" "$fpccfgfile.orig"  >/dev/null 2>&1
-  if [ $? = 0 ]; then
-    echo Saved old compiler config to $fpccfgfile.orig
-  else
-    echo Could not save old compiler config. Bailing out...
-    exit
-  fi
 fi
 fi
 
 
-if [ -f "$FPBIN" ] ; then
-  if [ -f "$fpinifile" ] ; then
-    mv "$fpinifile" "$fpinifile.orig"  >/dev/null 2>&1
-    if [ $? = 0 ]; then
-      echo Saved old fp.ini to $fpinifile.orig
-    else
-      echo Could not save old fp.ini. Bailing out...
-      exit
-    fi
-  fi
-
-  if [ -f "$fpcfgfile" ] ; then
-    mv "$fpcfgfile" "$fpcfgfile.orig"  >/dev/null 2>&1
-    if [ $? = 0 ]; then
-      echo Saved old fp.cfg to $fpcfgfile.orig
-    else
-      echo Could not save old fp.cfg. Bailing out...
-      exit
-    fi
-  fi
-fi
-
-setgccdir
-GCCDIR2=""
-GCCDIR3=""
-GCCDIR4=""
-
-singlearch() {
-  if [ -d "$GCCDIR" ]; then	
-    echo Found libgcc.a in "$GCCDIR"
-    GCCDIR=-Fl$GCCDIR
-  fi
-}
-
-# include ports tree dir for FreeBSDers.
-case "$HOSTOS" in
- freebsd)
-    GCCDIR=-Fl/usr/local/lib
-     ;;
- openbsd)
-    GCCDIR=-Fl/usr/local/lib
-     ;;
- netbsd)
-   GCCDIR=-Fl/usr/pkg/lib
-     ;;
- darwin)
-   setgccdirarch cpupowerpc -arch ppc
-   GCCDIR2="$GCCDIR"
-   setgccdirarch cpupowerpc64 -arch ppc64
-   GCCDIR3="$GCCDIR"
-   setgccdirarch cpui386 -arch i386
-   GCCDIR4="$GCCDIR"
-   setgccdirarch cpux86_64 -arch x86_64
-     ;;
-  linux)
-    case `"$FPCBIN" -PP` in
-      i?86|x86_64|amd64)
-      # Allow for the possibility of both 32 and 64 bit compilation on same system
-        setgccdirarch cpui386 -m32
-        GCCDIR4="$GCCDIR"
-        setgccdirarch cpux86_64 -m64
-        ;;
-      powerpc|powerpc64)
-      # Allow for the possibility of both 32 and 64 bit compilation on same system
-        setgccdirarch cpupowerpc -m32
-	GCCDIR4="$GCCDIR"
-	setgccdirarch cpupowerpc64 -m64
-	;;
-      # Add cases for other linux dual architectures here
-      *) singlearch # Default          
-        ;;
-    esac
-    ;;
-
- *) singlearch
-    ;;
-   
-esac
-
-CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
-CPUCROSSIFDEF2=""
-
-case `"$FPCBIN" -PP` in
-  i?86|x86_64|amd64)
-    # Cross-binutils are not needed to compile for i386 on an x86_64 system
-    CPUCROSSIFDEF1="
-#IFNDEF CPUI386
-#IFNDEF CPUAMD64
-#DEFINE NEEDCROSSBINUTILS
-#ENDIF
-#ENDIF
-"
-    CPUCROSSIFDEF2="
-#IFNDEF $HOSTOS
-#DEFINE NEEDCROSSBINUTILS
-#ENDIF
-"
-  ;;
-  *)
-    CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
-    CPUCROSSIFDEF2=""
-  ;;
-esac
-
-# darwin->darwin does not need cross binutils
-case "$HOSTOS" in
-  darwin)
-    CPUCROSSIFDEF2="
-#ifdef darwin
-#undef NEEDCROSSBINUTILS
-#endif
-"
-  ;;
-esac
-
-
 # set right path to FPC with $fpcversion
 # set right path to FPC with $fpcversion
 FPCPATH=`dirname "$1"`/\$fpcversion
 FPCPATH=`dirname "$1"`/\$fpcversion
+# set right prefix to FPC
+FPCGLOBALPREFIX=`dirname "$1"`/../../
 
 
 # Write (.)fpc.cfg
 # Write (.)fpc.cfg
 echo Writing sample configuration file to $fpccfgfile
 echo Writing sample configuration file to $fpccfgfile
-cat <<EOFCFG > $fpccfgfile
-#
-# Example fpc.cfg for Free Pascal Compiler
-#
-
-# ----------------------
-# Defines (preprocessor)
-# ----------------------
-
-#
-# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
-#
-# -d is the same as #DEFINE
-# -u is the same as #UNDEF
-#
-
-#
-# Some examples (for switches see below, and the -? helppages)
-#
-# Try compiling with the -dRELEASE or -dDEBUG on the commandline
-#
-
-# For a release compile with optimizes and strip debuginfo
-#IFDEF RELEASE
-  -O2
-  -Xs
-  #WRITE Compiling Release Version
-#ENDIF
-
-# For a debug version compile with debuginfo and all codegeneration checks on
-#IFDEF DEBUG
-  -g
-  -Crtoi
-  #WRITE Compiling Debug Version
-#ENDIF
-
-# set binutils prefix
-$CPUCROSSIFDEF1
-$CPUCROSSIFDEF2
-
-#IFDEF FPC_CROSSCOMPILING
-#IFDEF NEEDCROSSBINUTILS
-  -XP\$fpctarget-
-#ENDIF NEEDCROSSBINUTILS
-#ENDIF
-
-# assembling
-#ifdef darwin
-# use pipes instead of temporary files for assembling
--ap
-#endif
-
-# ----------------
-# Parsing switches
-# ----------------
-
-# Pascal language mode
-#      -Mfpc      free pascal dialect (default)
-#      -Mobjfpc   switch some Delphi 2 extensions on
-#      -Mdelphi   tries to be Delphi compatible
-#      -Mtp       tries to be TP/BP 7.0 compatible
-#      -Mgpc      tries to be gpc compatible
-#      -Mmacpas   tries to be compatible to the macintosh pascal dialects
-#
-# Turn on Object Pascal extensions by default
-#-Mobjfpc
-
-# Assembler reader mode
-#      -Rdefault  use default assembler
-#      -Ratt      read AT&T style assembler
-#      -Rintel    read Intel style assembler
-#
-# All assembler blocks are AT&T styled by default
-#-Ratt
-
-# Semantic checking
-#      -S2        same as -Mobjfpc
-#      -Sc        supports operators like C (*=,+=,/= and -=)
-#      -Sa        include assertion code.
-#      -Sd        same as -Mdelphi
-#      -Se<x>     error options. <x> is a combination of the following:
-#         <n> : compiler stops after the <n> errors (default is 1)
-#         w : compiler stops also after warnings
-#         n : compiler stops also after notes
-#         h : compiler stops also after hints
-#      -Sg        allow LABEL and GOTO
-#      -Sh        Use ansistrings
-#      -Si        support C++ styled INLINE
-#      -Sk        load fpcylix unit
-#      -SI<x>     set interface style to <x>
-#         -SIcom     COM compatible interface (default)
-#         -SIcorba   CORBA compatible interface
-#      -Sm        support macros like C (global)
-#      -So        same as -Mtp
-#      -Sp        same as -Mgpc
-#      -Ss        constructor name must be init (destructor must be done)
-#      -Sx        enable exception keywords (default in Delphi/ObjFPC modes)
-#
-# Allow goto, inline, C-operators, C-vars
--Sgic
-
-# ---------------
-# Code generation
-# ---------------
-
-# Uncomment the next line if you always want static/dynamic units by default
-# (can be overruled with -CD, -CS at the commandline)
-#-CS
-#-CD
-
-# Set the default heapsize to 8Mb
-#-Ch8000000
-
-# Set default codegeneration checks (iocheck, overflow, range, stack)
-#-Ci
-#-Co
-#-Cr
-#-Ct
-
-# Optimizer switches
-# -Os        generate smaller code
-# -O1        level 1 optimizations (quick optimizations, debuggable)
-# -O2        level 2 optimizations (-O1 + optimizations which make debugging more difficult)
-# -O3        level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
-# -Op<x>     set target cpu for optimizing, see fpc -i for possible values
-#
-# See "fpc -i" also for more fine-grained control over which optimizations
-# to perform
-
-#ifdef darwin
-#ifdef cpui386
--Cppentiumm
--Oppentiumm
-#endif
-#endif
-
-# -----------------------
-# Set Filenames and Paths
-# -----------------------
-
-# Slashes are also allowed under dos
-
-# path to the messagefile, not necessary anymore but can be used to override
-# the default language
-#-Fr$FPCPATH/msg/errore.msg
-#-Fr$FPCPATH/msg/errorn.msg
-
-# searchpath for units and other system dependent things
--Fu$FPCPATH/units/\$fpctarget
--Fu$FPCPATH/units/\$fpctarget/*
--Fu$FPCPATH/units/\$fpctarget/rtl
-#-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
-
-#IFDEF FPCAPACHE_1_3
--Fu$FPCPATH/units/\$fpctarget/httpd13/
-#ELSE
-#IFDEF FPCAPACHE_2_0
--Fu$FPCPATH/units/\$fpctarget/httpd20
-#ELSE
--Fu$FPCPATH/units/\$fpctarget/httpd22
-#ENDIF
-#ENDIF
-
-# searchpath for libraries
-$GCCDIR
-$GCCDIR2
-$GCCDIR3
-$GCCDIR4
-#-Fl/pp/lib
-#-Fl/lib;/usr/lib
-
-
-# -------------
-# Linking
-# -------------
-
-# generate always debugging information for GDB (slows down the compiling
-# process)
-#      -gc        generate checks for pointers
-#      -gd        use dbx
-#      -gg        use gsym
-#      -gh        use heap trace unit (for memory leak debugging)
-#      -gl        use line info unit to show more info for backtraces
-#      -gv        generates programs tracable with valgrind
-#      -gw        generate dwarf debugging info
-#
-# Enable debuginfo and use the line info unit by default
-#-gl
-
-# always pass an option to the linker
-#-k-s
-
-# Always strip debuginfo from the executable
--Xs
-
-
-# -------------
-# Miscellaneous
-# -------------
-
-# Write always a nice FPC logo ;)
--l
-
-# Verbosity
-#      e : Show errors (default)       d : Show debug info
-#      w : Show warnings               u : Show unit info
-#      n : Show notes                  t : Show tried/used files
-#      h : Show hints                  c : Show conditionals
-#      i : Show general info           d : Show debug info
-#      l : Show linenumbers            r : Rhide/GCC compatibility mode
-#      a : Show everything             x : Executable info (Win32 only)
-#      b : Write file names messages with full path
-#      v : write fpcdebug.txt with     p : Write tree.log with parse tree
-#          lots of debugging info
-#
-# Display Info, Warnings and Notes
--viwn
-# If you don't want so much verbosity use
-#-vw
-
-#
-# That's all folks
-#
-EOFCFG
+fpcmkcfg -d "basepath=$FPCPATH" -o $fpccfgfile
 
 
 if ! [ -f "$FPBIN" ] ; then
 if ! [ -f "$FPBIN" ] ; then
   exit
   exit
@@ -458,132 +75,21 @@ fi
 
 
 # Write fp.cfg
 # Write fp.cfg
 echo Writing sample configuration file to $fpcfgfile
 echo Writing sample configuration file to $fpcfgfile
-cat <<EOFFPCFG > $fpcfgfile
-#IFDEF NORMAL
- -Ci
- -XS
- -T$fpctargetos
- -Sg
- -O1
- -Fu$FPCPATH/units/\$fpctarget
- -Fu$FPCPATH/units/\$fpctarget\*
- -Fu$FPCPATH/units/\$fpctarget\rtl
- $GCCDIR
- $GCCDIR2
- $GCCDIR3
- $GCCDIR4
- -g-
- -p-
- -b-
-#ENDIF
-
-#IFDEF DEBUG
- -Ci
- -XS
- -T$fpctargetos
- -Sg
- -Cr
- -Co
- -Fu$FPCPATH/units/\$fpctarget
- -Fu$FPCPATH/units/\$fpctarget\*
- -Fu$FPCPATH/units/\$fpctarget\rtl
- $GCCDIR
- $GCCDIR2
- $GCCDIR3
- $GCCDIR4
- -g
- -p-
- -b-
-#ENDIF
-
-#IFDEF RELEASE
- -XS
- -T$fpctargetos
- -Sg
- -O2
- -Fu$FPCPATH/units/\$fpctarget
- -Fu$FPCPATH/units/\$fpctarget\*
- -Fu$FPCPATH/units/\$fpctarget\rtl
- $GCCDIR
- $GCCDIR2
- $GCCDIR3
- $GCCDIR4
- -g-
- -p-
- -b-
-#ENDIF
-EOFFPCFG
+fpcmkcfg -p -1 -d "basepath=$FPCPATH" -o $fpcfgfile
 
 
 # Write fp.ini
 # Write fp.ini
 echo Writing sample configuration file to $fpinifile
 echo Writing sample configuration file to $fpinifile
-cat <<EOFFPINI > $fpinifile
-[Compile]
-CompileMode=DEBUG
-
-[Editor]
-DefaultTabSize=8
-DefaultFlags=20599
-DefaultSaveExt=.pas
-DefaultIndentSize=1
-
-[Highlight]
-Exts="*.pas;*.pp;*.inc"
-NeedsTabs="make*;make*.*"
-
-[SourcePath]
-SourceList=""
-
-[Mouse]
-DoubleDelay=8
-ReverseButtons=0
-AltClickAction=6
-CtrlClickAction=1
-
-[Search]
-FindFlags=4
+fpcmkcfg -p -2 -o $fpinifile
 
 
-[Breakpoints]
-Count=0
-
-[Watches]
-Count=0
-
-[Preferences]
-DesktopFileFlags=209
-CenterCurrentLineWhileDebugging=1
-AutoSaveFlags=7
-MiscOptions=6
-DesktopLocation=1
-
-[Misc]
-ShowReadme=1
+# Do not write fppkg configuration when fppkg is not available
+if ! [ -f "$FPPKGBIN" ] ; then
+  exit
+fi
 
 
-[Files]
-OpenExts="*.pas;*.pp;*.inc"
+# Write fppkg.cfg
+echo Writing sample configuration file to $fppkgfile
+fpcmkcfg -p -3 $compilerconfigdir -o $fppkgfile
 
 
-[Tools]
-Title1="svn ~u~p (curr. dir)"
-Program1="svn"
-Params1="up \$CAP_MSG()"
-HotKey1=23296
-Title2="svn c~i~ (curr. dir)"
-Program2="svn"
-Params2="ci \$CAP_MSG()"
-HotKey2=23552
-Title3="svn ~d~iff"
-Program3="svn"
-Params3="diff \$CAP_MSG() \$EDNAME"
-HotKey3=23808
-Title4="svn ~l~og"
-Program4="svn"
-Params4="log \$CAP_MSG() \$EDNAME"
-HotKey4=34560
-Title5="svn ~b~lame"
-Program5="svn"
-Params5="blame \$CAP_MSG() \$EDNAME"
-HotKey5=34816
-Title6="svn ~a~dd"
-Program6="svn"
-Params6="add \$CAP_MSG() \$EDNAME"
-HotKey6=0'
-EOFFPINI
+# Write default
+echo Writing sample configuration file to $defaultfile
+fpcmkcfg -p -4 -d "GlobalPrefix=$FPCGLOBALPREFIX" -o $defaultfile

+ 45 - 10
packages/cdrom/src/cdromlin.inc

@@ -117,20 +117,55 @@ end;
 
 
 Function GetCDRomDevices(Var Devices : Array of string) : Integer;
 Function GetCDRomDevices(Var Devices : Array of string) : Integer;
 
 
-Var
-  S : String;
 
 
-begin
-  Result:=TestFSTab(Devices);
-  If (Result<1) then
+  Function AlreadyAdded(AName: String; AMax: Integer): Boolean;
+  var
+    I: Integer;
+  begin
+    Result := False;
+    for I := 0 to AMax do
+      if Devices[I] = AName then
+        Exit(True);
+  end;
+
+  // Resolves name if it's a symlink and adds it ensuring no dups
+  Function AddCdrom(ACDRom: String; I: Integer): Integer;
+  var
+    SInfo : stat;
+    RealName: String;
+  begin
+    Result := I;
+    if fpStat(PChar(ACDRom), SInfo) <> -1 then
     begin
     begin
-    S:=DetectCD;
-    If (S<>'') then
+      RealName := ACDRom;
+      if SInfo.st_mode and S_IFMT = S_IFLNK then
+        RealName := fpReadLink(ACDRom);
+
+      if not AlreadyAdded(RealName, I-1) then
       begin
       begin
-      Devices[0]:=S;
-      Result:=1;
+        Devices[I] := RealName;
+        Result := I+1;
       end;
       end;
-    end
+    end;
+  end;
+
+var
+  I,J: Integer;
+  CDRec: TCDSearchRec;
+  FSTab: array[0..10] of String;
+
+begin
+  I := 0;
+  // First Add Entries From FSTab
+  for J := 0 to TestFSTab(FSTab)-1 do
+    I := AddCdrom(FSTab[J], I);
+
+  //Now Do A Search
+  if FindFirstCD(CDRec) then
+  repeat
+    I := AddCdrom(CDRec.Name, I);
+  until FindNextCD(CDRec) = False;
+  Result := I;
 end;
 end;
 
 
 
 

+ 64 - 0
packages/cdrom/src/lincd.pp

@@ -708,8 +708,15 @@ procedure set_sense_key(var a : Trequest_sense; __sense_key : Tu8);
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
     Utility functions
     Utility functions
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
+type
+  TCDSearchRec = record
+    Name: String;
+    i,j: Integer;
+  end;
 
 
 Function IsCDDevice(Device : String) : Boolean;
 Function IsCDDevice(Device : String) : Boolean;
+Function FindFirstCD(var ACDSearchRec: TCDSearchRec): Boolean;
+Function FindNextCD(var ACDSearchRec: TCDSearchRec): Boolean;
 Function DetectCd : String;
 Function DetectCd : String;
 
 
 implementation
 implementation
@@ -1098,6 +1105,61 @@ Const
   '/dev/sr?',
   '/dev/sr?',
   '/dev/optcd');
   '/dev/optcd');
 
 
+function FindFirstCD(var ACDSearchRec: TCDSearchRec): Boolean;
+begin
+  Result := False;
+  With ACDSearchRec do
+  begin
+    I := 1;
+    J := 0;
+    Name := '';
+  end;
+  Result := FindNextCD(ACDSearchRec);
+end;
+
+function FindNextCD(var ACDSearchRec: TCDSearchRec): Boolean;
+var
+  L: integer;
+  S: String;
+  FoundDev: String;
+begin
+
+  Result := False;
+  FoundDev := '';
+  with ACDSearchRec do
+  begin
+    While (FoundDev='') and (I<NrDevices) do
+    begin
+      S:=Devices[i];
+      L:=Length(S);
+      If S[l]='?' then
+      begin
+        S:=Copy(S,1,L-1);
+        if j >= 3 then
+          j := 0;
+        while (j <= 3) and (Length(FoundDev)=0) do
+        begin
+          If IsCdDevice(S+Chr(Ord('0')+J)) then
+            FoundDev:=S+Chr(Ord('0')+J)
+          else If IsCdDevice(S+Chr(Ord('a')+J)) then
+            FoundDev:=S+Chr(Ord('a')+J);
+          Inc(j);
+        end;
+        if J >= 3 then
+          Inc(i);
+      end
+      else
+      begin
+        If IsCdDevice(S) then
+          FoundDev:=S;
+        Inc(i);
+      end;
+    end;
+  end;
+  Result := Length(FoundDev) > 0;
+  ACDSearchRec.Name:=FoundDev;
+end;
+
 Function DetectCD : String;
 Function DetectCD : String;
 
 
 Var
 Var
@@ -1163,7 +1225,9 @@ begin
   If fpStat(Device,info)<>0 then
   If fpStat(Device,info)<>0 then
     exit;
     exit;
   DeviceMajor:=info.st_rdev shr 8;
   DeviceMajor:=info.st_rdev shr 8;
+  {$ifdef debug}
   Writeln('Device major : ',DeviceMajor);
   Writeln('Device major : ',DeviceMajor);
+  {$endif}
   If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
   If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
     Result:=TestCDRomIOCTL(Device)
     Result:=TestCDRomIOCTL(Device)
   else 
   else 

+ 2 - 1
packages/cocoaint/utils/uikit-skel/src/uikit/UIKit.inc

@@ -78,4 +78,5 @@
 {$ifdef IOS_SDK_4_2_OR_HIGHER}
 {$ifdef IOS_SDK_4_2_OR_HIGHER}
 {$include UIActionSheet.inc}
 {$include UIActionSheet.inc}
 {$include UILocalNotification.inc}
 {$include UILocalNotification.inc}
-{$endif}
+{$include UIAlertView.inc}
+{$endif}

+ 11 - 2
packages/fcl-base/src/eventlog.pp

@@ -29,6 +29,7 @@ Type
 
 
   TEventLog = Class(TComponent)
   TEventLog = Class(TComponent)
   Private
   Private
+    fAppendContent : Boolean;
     FEventIDOffset : DWord;
     FEventIDOffset : DWord;
     FLogHandle : Pointer;
     FLogHandle : Pointer;
     FStream : TFileStream;
     FStream : TFileStream;
@@ -84,6 +85,7 @@ Type
     Procedure Info (const Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
   Published
   Published
+    Property AppendContent : Boolean Read fAppendContent Write fAppendContent;
     Property Identification : String Read FIdentification Write SetIdentification;
     Property Identification : String Read FIdentification Write SetIdentification;
     Property LogType : TLogType Read Flogtype Write SetlogType;
     Property LogType : TLogType Read Flogtype Write SetlogType;
     Property Active : Boolean Read FActive write SetActive;
     Property Active : Boolean Read FActive write SetActive;
@@ -240,12 +242,19 @@ begin
 end;
 end;
 
 
 Procedure TEventLog.ActivateFileLog;
 Procedure TEventLog.ActivateFileLog;
-
+var
+  fFileFlags : Word;
 begin
 begin
   If (FFileName='') then
   If (FFileName='') then
     FFileName:=DefaultFileName;
     FFileName:=DefaultFileName;
   // This will raise an exception if the file cannot be opened for writing !
   // This will raise an exception if the file cannot be opened for writing !
-  FStream:=TFileStream.Create(FFileName,fmCreate or fmShareDenyWrite);
+  if fAppendContent and FileExists(FFileName) then
+    fFileFlags := fmOpenWrite
+  else
+    fFileFlags := fmCreate;
+
+  fFileFlags := fFileFlags or fmShareDenyWrite;
+  FStream:=TFileStream.Create(FFileName,fFileFlags);
 end;
 end;
 
 
 Procedure TEventLog.DeActivateFileLog;
 Procedure TEventLog.DeActivateFileLog;

+ 5 - 1
packages/fcl-base/src/inifiles.pp

@@ -657,7 +657,11 @@ end;
 destructor TIniFile.destroy;
 destructor TIniFile.destroy;
 begin
 begin
   If FDirty and FCacheUpdates then
   If FDirty and FCacheUpdates then
-    UpdateFile;
+    try
+      UpdateFile;
+    except
+      // Eat exception. Compatible to D7 behaviour, see comments to bug 19046
+    end;  
   inherited destroy;
   inherited destroy;
 end;
 end;
 
 

+ 14 - 11
packages/fcl-db/src/base/fields.inc

@@ -819,8 +819,16 @@ procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean);
 
 
 begin
 begin
   If Not Assigned(FDataset) then
   If Not Assigned(FDataset) then
-    EDatabaseError.CreateFmt(SNoDataset,[FieldName]);
+    DatabaseErrorFmt(SNoDataset,[FieldName]);
+  if (FieldNo>0) and not (FDataSet.State in [dsSetKey, dsFilter]) then
+    begin
+    if ReadOnly then 
+      DatabaseErrorFmt(SReadOnlyField, [DisplayName], Self); 
+    Validate(Buffer);
+    end;
   FDataSet.SetFieldData(Self,Buffer, NativeFormat);
   FDataSet.SetFieldData(Self,Buffer, NativeFormat);
+  if not (FDataSet.State in [dsCalcFields, dsFilter, dsNewValue]) then
+    DataChanged;
 end;
 end;
 
 
 Procedure TField.SetDataset (AValue : TDataset);
 Procedure TField.SetDataset (AValue : TDataset);
@@ -2475,28 +2483,23 @@ end;
 procedure TFMTBCDField.GetText(var TheText: string; ADisplayText: Boolean);
 procedure TFMTBCDField.GetText(var TheText: string; ADisplayText: Boolean);
 var
 var
   bcd: TBCD;
   bcd: TBCD;
-  E: double; //remove when formatBCD,BCDToStrF in fmtbcd.pp will be implemented
   fmt: String;
   fmt: String;
 begin
 begin
   if GetData(@bcd) then begin
   if GetData(@bcd) then begin
-    E:=BCDToDouble(bcd);
     if aDisplayText or (FEditFormat='') then
     if aDisplayText or (FEditFormat='') then
       fmt := FDisplayFormat
       fmt := FDisplayFormat
     else
     else
       fmt := FEditFormat;
       fmt := FEditFormat;
     if fmt<>'' then
     if fmt<>'' then
-      TheText := FormatFloat(fmt,E)
-      //TheText := FormatBCD(fmt,bcd)
+      TheText := BCDToStr(bcd)
+      //TheText := FormatBCD(fmt,bcd) //uncomment when formatBCD in fmtbcd.pp will be implemented
     else if fCurrency then begin
     else if fCurrency then begin
       if aDisplayText then
       if aDisplayText then
-        TheText := FloatToStrF(E, ffCurrency, FPrecision, 2{digits?})
-        //TheText := BcdToStrF(bcd, ffCurrency, FPrecision, 2{digits?})
+        TheText := BcdToStrF(bcd, ffCurrency, FPrecision, 2)
       else
       else
-        TheText := FloatToStrF(E, ffFixed, FPrecision, 2{digits?});
-        //TheText := BcdToStrF(bcd, ffFixed, FPrecision, 2{digits?});
+        TheText := BcdToStrF(bcd, ffFixed, FPrecision, 2);
     end else
     end else
-      TheText := BcdToStr(bcd);
-      //TheText := BcdToStrF(bcd, ffGeneral, FPrecision, FSize);
+      TheText := BcdToStrF(bcd, ffGeneral, FPrecision, FSize);
   end else
   end else
     TheText := '';
     TheText := '';
 end;
 end;

+ 1 - 0
packages/fcl-db/src/sqldb/mysql/mysql50conn.pas

@@ -4,6 +4,7 @@
 
 
 unit mysql50conn;
 unit mysql50conn;
 
 
+{$DEFINE MYSQL50_up}
 {$DEFINE MYSQL50}
 {$DEFINE MYSQL50}
 
 
 {$i mysqlconn.inc}
 {$i mysqlconn.inc}

+ 2 - 0
packages/fcl-db/src/sqldb/mysql/mysql51conn.pas

@@ -4,6 +4,8 @@
 
 
 unit mysql51conn;
 unit mysql51conn;
 
 
+{$DEFINE MYSQL50_UP}
+{$DEFINE MYSQL51_UP}
 {$DEFINE MYSQL51}
 {$DEFINE MYSQL51}
 
 
 {$i mysqlconn.inc}
 {$i mysqlconn.inc}

+ 3 - 7
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -188,12 +188,8 @@ const
      'MYSQL_OPT_USE_REMOTE_CONNECTION','MYSQL_OPT_USE_EMBEDDED_CONNECTION',
      'MYSQL_OPT_USE_REMOTE_CONNECTION','MYSQL_OPT_USE_EMBEDDED_CONNECTION',
      'MYSQL_OPT_GUESS_CONNECTION','MYSQL_SET_CLIENT_IP',
      'MYSQL_OPT_GUESS_CONNECTION','MYSQL_SET_CLIENT_IP',
      'MYSQL_SECURE_AUTH'
      'MYSQL_SECURE_AUTH'
-{$IFDEF MYSQL50}
+{$IFDEF MYSQL50_UP}
      ,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
      ,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
-{$ELSE}     
-  {$IFDEF MYSQL51}
-     ,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
-  {$ENDIF}     
 {$ENDIF}
 {$ENDIF}
      );
      );
 
 
@@ -559,7 +555,7 @@ begin
       NewType := ftInteger;
       NewType := ftInteger;
       NewSize := 0;
       NewSize := 0;
       end;
       end;
-{$if defined(mysql51) or defined(mysql50)}
+{$ifdef mysql50_up}
     FIELD_TYPE_NEWDECIMAL,
     FIELD_TYPE_NEWDECIMAL,
 {$endif}
 {$endif}
     FIELD_TYPE_DECIMAL: if ADecimals < 5 then
     FIELD_TYPE_DECIMAL: if ADecimals < 5 then
@@ -867,7 +863,7 @@ begin
         VL := 0;
         VL := 0;
       Move(VL, Dest^, SizeOf(LargeInt));
       Move(VL, Dest^, SizeOf(LargeInt));
       end;
       end;
-{$if defined(mysql51) or defined(mysql50)}
+{$ifdef mysql50_up}
     FIELD_TYPE_NEWDECIMAL,
     FIELD_TYPE_NEWDECIMAL,
 {$endif}      
 {$endif}      
     FIELD_TYPE_DECIMAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:
     FIELD_TYPE_DECIMAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:

+ 1 - 1
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -546,7 +546,7 @@ begin
       FPrepared := True;
       FPrepared := True;
       end
       end
     else
     else
-      statement := buf;
+      statement := AParams.ParseSQL(buf,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psPostgreSQL);
     end;
     end;
 end;
 end;
 
 

+ 4 - 6
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -7,13 +7,13 @@ interface
 uses
 uses
   Classes, SysUtils, toolsunit,
   Classes, SysUtils, toolsunit,
   db,
   db,
-  sqldb, ibconnection, mysql40conn, mysql41conn, mysql50conn, pqconnection,odbcconn,oracleconnection,sqlite3conn;
+  sqldb, ibconnection, mysql40conn, mysql41conn, mysql50conn, mysql51conn, pqconnection,odbcconn,oracleconnection,sqlite3conn;
 
 
-type TSQLDBTypes = (mysql40,mysql41,mysql50,postgresql,interbase,odbc,oracle,sqlite3);
+type TSQLDBTypes = (mysql40,mysql41,mysql50,mysql51,postgresql,interbase,odbc,oracle,sqlite3);
 
 
 const MySQLdbTypes = [mysql40,mysql41,mysql50];
 const MySQLdbTypes = [mysql40,mysql41,mysql50];
       DBTypesNames : Array [TSQLDBTypes] of String[19] =
       DBTypesNames : Array [TSQLDBTypes] of String[19] =
-             ('MYSQL40','MYSQL41','MYSQL50','POSTGRESQL','INTERBASE','ODBC','ORACLE','SQLITE3');
+             ('MYSQL40','MYSQL41','MYSQL50','MYSQL51','POSTGRESQL','INTERBASE','ODBC','ORACLE','SQLITE3');
              
              
       FieldtypeDefinitionsConst : Array [TFieldType] of String[15] =
       FieldtypeDefinitionsConst : Array [TFieldType] of String[15] =
         (
         (
@@ -115,8 +115,7 @@ begin
       testStringValues[t] := TrimRight(testStringValues[t]);
       testStringValues[t] := TrimRight(testStringValues[t]);
     end;
     end;
   if SQLDbType = MYSQL50 then Fconnection := tMySQL50Connection.Create(nil);
   if SQLDbType = MYSQL50 then Fconnection := tMySQL50Connection.Create(nil);
-  if SQLDbType in MySQLdbTypes then
-    FieldtypeDefinitions[ftLargeint] := 'BIGINT';
+  if SQLDbType = MYSQL51 then Fconnection := tMySQL51Connection.Create(nil);
   if SQLDbType = sqlite3 then
   if SQLDbType = sqlite3 then
     begin
     begin
     Fconnection := TSQLite3Connection.Create(nil);
     Fconnection := TSQLite3Connection.Create(nil);
@@ -134,7 +133,6 @@ begin
   if SQLDbType = INTERBASE then
   if SQLDbType = INTERBASE then
     begin
     begin
     Fconnection := tIBConnection.Create(nil);
     Fconnection := tIBConnection.Create(nil);
-    FieldtypeDefinitions[ftLargeint] := 'BIGINT';
     end;
     end;
   if SQLDbType = ODBC then Fconnection := tODBCConnection.Create(nil);
   if SQLDbType = ODBC then Fconnection := tODBCConnection.Create(nil);
   if SQLDbType = ORACLE then Fconnection := TOracleConnection.Create(nil);
   if SQLDbType = ORACLE then Fconnection := TOracleConnection.Create(nil);

+ 10 - 2
packages/fcl-db/tests/testfieldtypes.pas

@@ -1391,7 +1391,10 @@ begin
     begin
     begin
     with query do
     with query do
       begin
       begin
-      SQL.Text:='select NAME from FPDEV where NAME=''TestName21'' limit 1';
+      if (sqlDBtype=interbase) then
+        SQL.Text:='select first 1 NAME from FPDEV where NAME=''TestName21'''
+      else
+        SQL.Text:='select NAME from FPDEV where NAME=''TestName21'' limit 1';
       Open;
       Open;
       close;
       close;
       ServerFilter:='ID=21';
       ServerFilter:='ID=21';
@@ -1626,6 +1629,8 @@ procedure TTestFieldTypes.TestSQLClob;
     AssertEquals(testStringValues[a],AField.AsString);
     AssertEquals(testStringValues[a],AField.AsString);
   end;
   end;
 begin
 begin
+  if SQLDbType=interbase then
+      Ignore('This test does not apply to Interbase/Firebird, since it does not support CLOB fields');
   TestSQLFieldType(ftMemo, 'CLOB', 0, @TestSQLClob_GetSQLText, @CheckFieldValue);
   TestSQLFieldType(ftMemo, 'CLOB', 0, @TestSQLClob_GetSQLText, @CheckFieldValue);
 end;
 end;
 
 
@@ -1641,7 +1646,10 @@ procedure TTestFieldTypes.TestSQLLargeint;
     AssertEquals(testLargeIntValues[a],AField.AsLargeInt);
     AssertEquals(testLargeIntValues[a],AField.AsLargeInt);
   end;
   end;
 begin
 begin
-  TestSQLFieldType(ftLargeint, 'LARGEINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue);
+  if sqlDBType=interbase then
+    TestSQLFieldType(ftLargeint, 'BIGINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue)
+  else
+    TestSQLFieldType(ftLargeint, 'LARGEINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue);
 end;
 end;
 
 
 
 

+ 33 - 3
packages/fcl-image/Makefile

@@ -1,8 +1,8 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/03/21]
 #
 #
 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 i386-nativent i386-iphonesim 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-solaris 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 mipsel-linux
+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 i386-nativent i386-iphonesim 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 powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris 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 mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
@@ -377,6 +377,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 endif
 endif
@@ -402,7 +405,7 @@ ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
+override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
@@ -563,6 +566,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_RSTS+=pscanvas
 override TARGET_RSTS+=pscanvas
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_RSTS+=pscanvas
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_RSTS+=pscanvas
 override TARGET_RSTS+=pscanvas
 endif
 endif
@@ -749,6 +755,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_EXAMPLEDIRS+=examples
 override TARGET_EXAMPLEDIRS+=examples
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_EXAMPLEDIRS+=examples
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_EXAMPLEDIRS+=examples
 override TARGET_EXAMPLEDIRS+=examples
 endif
 endif
@@ -936,6 +945,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_OPTIONS+=-S2h
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
@@ -1122,6 +1134,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override COMPILER_SOURCEDIR+=src
 override COMPILER_SOURCEDIR+=src
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_SOURCEDIR+=src
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 override COMPILER_SOURCEDIR+=src
 override COMPILER_SOURCEDIR+=src
 endif
 endif
@@ -1543,6 +1558,11 @@ ifeq ($(OS_TARGET),NativeNT)
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=nativent
 SHORTSUFFIX=nativent
 endif
 endif
+ifeq ($(OS_TARGET),wii)
+EXEEXT=.dol
+SHAREDLIBEXT=.so
+SHORTSUFFIX=wii
+endif
 else
 else
 ifeq ($(OS_TARGET),go32v1)
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
 PPUEXT=.pp1
@@ -2230,6 +2250,13 @@ REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASJPEG=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-BASE=1
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_PASJPEG=1
@@ -3268,6 +3295,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 TARGET_EXAMPLEDIRS_EXAMPLES=1
 TARGET_EXAMPLEDIRS_EXAMPLES=1
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 TARGET_EXAMPLEDIRS_EXAMPLES=1
 TARGET_EXAMPLEDIRS_EXAMPLES=1
 endif
 endif

+ 1 - 0
packages/fcl-image/Makefile.fpc

@@ -14,6 +14,7 @@ units=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm \
       targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer \ 
       targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer \ 
       extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
       extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
 units_win32=freetypeh freetype ftfont
 units_win32=freetypeh freetype ftfont
+units_win64=freetypeh freetype ftfont
 units_beos=freetypeh freetype ftfont
 units_beos=freetypeh freetype ftfont
 units_haiku=freetypeh freetype ftfont
 units_haiku=freetypeh freetype ftfont
 units_linux=freetypeh freetype ftfont
 units_linux=freetypeh freetype ftfont

+ 69 - 0
packages/fcl-image/src/fpcanvas.inc

@@ -402,6 +402,56 @@ begin
   FPenPos := points[high(points)];
   FPenPos := points[high(points)];
 end;
 end;
 
 
+procedure TFPCustomCanvas.RadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer);
+
+begin
+  DoRadialPie(X1, y1, x2, y2, StartAngle16Deg, Angle16DegLength);
+end;
+
+procedure TFPCustomCanvas.DoRadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer);
+
+begin
+  // To be implemented
+end;
+
+procedure TFPCustomCanvas.DoPolyBezier(Points: PPoint; NumPts: Integer;
+                           Filled: boolean = False;
+                           Continuous: boolean = False);
+
+begin
+ // To be implemented
+end;
+
+procedure TFPCustomCanvas.PolyBezier(Points: PPoint; NumPts: Integer;
+                     Filled: boolean = False;
+                     Continuous: boolean = False);
+begin
+  DoPolyBezier(Points,NumPts,Filled,Continuous);
+end;
+                     
+procedure TFPCustomCanvas.PolyBezier(const Points: array of TPoint;  
+                     Filled: boolean = False;
+                     Continuous: boolean = False);
+var 
+  NPoints{, i}: integer;
+//  PointArray: ^TPoint;
+begin
+  NPoints:=High(Points)-Low(Points)+1;
+  if NPoints>0 then
+    DoPolyBezier(@Points[Low(Points)],NPoints,Filled,Continuous);
+{
+  NPoints:=High(Points)-Low(Points)+1;
+  if NPoints<=0 then exit;
+    GetMem(PointArray,SizeOf(TPoint)*NPoints);
+  try  
+    for i:=0 to NPoints-1 do
+      PointArray[i]:=Points[i+Low(Points)];
+    DoPolyBezier(PointArray, NPoints, Filled, Continuous);
+  finally
+    FreeMem(PointArray);
+  end;}
+end;
+
 procedure TFPCustomCanvas.Clear;
 procedure TFPCustomCanvas.Clear;
 var r : TRect;
 var r : TRect;
 begin
 begin
@@ -500,6 +550,25 @@ begin
   Rectangle (Rect(left,top,right,bottom));
   Rectangle (Rect(left,top,right,bottom));
 end;
 end;
 
 
+procedure TFPCustomCanvas.FillRect(const ARect: TRect);
+
+begin
+  if (Brush.style <> bsClear) then
+    begin
+    if not (brush is TFPCustomDrawBrush) then
+      DoRectangleFill (ARect)
+    else 
+      with ARect do
+        TFPCustomDrawBrush(Brush).Rectangle (left,top,right,bottom);
+    end;
+end;
+
+procedure TFPCustomCanvas.FillRect(X1,Y1,X2,Y2: Integer);
+
+begin
+  FillRect (Rect(X1,Y1,X2,Y2));
+end;
+        
 procedure TFPCustomCanvas.Rectangle (const Bounds:TRect);
 procedure TFPCustomCanvas.Rectangle (const Bounds:TRect);
 var np,nb,dp,db,pb : boolean;
 var np,nb,dp,db,pb : boolean;
 begin
 begin

+ 20 - 1
packages/fcl-image/src/fpcanvas.pp

@@ -24,6 +24,7 @@ const
 
 
 type
 type
 
 
+  PPoint = ^TPoint;
   TFPCanvasException = class (Exception);
   TFPCanvasException = class (Exception);
   TFPPenException = class (TFPCanvasException);
   TFPPenException = class (TFPCanvasException);
   TFPBrushException = class (TFPCanvasException);
   TFPBrushException = class (TFPCanvasException);
@@ -82,11 +83,14 @@ type
   TFPCustomFont = class (TFPCanvasHelper)
   TFPCustomFont = class (TFPCanvasHelper)
   private
   private
     FName : string;
     FName : string;
+    FOrientation,
     FSize : integer;
     FSize : integer;
   protected
   protected
     procedure DoCopyProps (From:TFPCanvasHelper); override;
     procedure DoCopyProps (From:TFPCanvasHelper); override;
     procedure SetName (AValue:string); virtual;
     procedure SetName (AValue:string); virtual;
     procedure SetSize (AValue:integer); virtual;
     procedure SetSize (AValue:integer); virtual;
+    procedure SetOrientation (AValue:integer); virtual;
+    function GetOrientation : Integer;
   public
   public
     function CopyFont : TFPCustomFont;
     function CopyFont : TFPCustomFont;
     // Creates a copy of the font with all properties the same, but not allocated
     // Creates a copy of the font with all properties the same, but not allocated
@@ -99,6 +103,8 @@ type
     property Italic : boolean index 6 read GetFlags write SetFlags;
     property Italic : boolean index 6 read GetFlags write SetFlags;
     property Underline : boolean index 7 read GetFlags write SetFlags;
     property Underline : boolean index 7 read GetFlags write SetFlags;
     property StrikeTrough : boolean index 8 read GetFlags write SetFlags;
     property StrikeTrough : boolean index 8 read GetFlags write SetFlags;
+    property Orientation: Integer read GetOrientation write SetOrientation default 0;
+        
   end;
   end;
   TFPCustomFontClass = class of TFPCustomFont;
   TFPCustomFontClass = class of TFPCustomFont;
 
 
@@ -255,6 +261,10 @@ type
     procedure DoLine (x1,y1,x2,y2:integer); virtual; abstract;
     procedure DoLine (x1,y1,x2,y2:integer); virtual; abstract;
     procedure DoCopyRect (x,y:integer; canvas:TFPCustomCanvas; Const SourceRect:TRect); virtual; abstract;
     procedure DoCopyRect (x,y:integer; canvas:TFPCustomCanvas; Const SourceRect:TRect); virtual; abstract;
     procedure DoDraw (x,y:integer; Const image:TFPCustomImage); virtual; abstract;
     procedure DoDraw (x,y:integer; Const image:TFPCustomImage); virtual; abstract;
+    procedure DoRadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer); virtual;
+    procedure DoPolyBezier(Points: PPoint; NumPts: Integer;
+                           Filled: boolean = False;
+                           Continuous: boolean = False); virtual;
     procedure CheckHelper (AHelper:TFPCanvasHelper); virtual;
     procedure CheckHelper (AHelper:TFPCanvasHelper); virtual;
     procedure AddHelper (AHelper:TFPCanvasHelper);
     procedure AddHelper (AHelper:TFPCanvasHelper);
   public
   public
@@ -277,8 +287,17 @@ type
     procedure EllipseC (x,y:integer; rx,ry:longword);
     procedure EllipseC (x,y:integer; rx,ry:longword);
     procedure Polygon (Const points:array of TPoint);
     procedure Polygon (Const points:array of TPoint);
     procedure Polyline (Const points:array of TPoint);
     procedure Polyline (Const points:array of TPoint);
-    procedure Rectangle (Const Bounds:TRect);
+    procedure RadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer);
+    procedure PolyBezier(Points: PPoint; NumPts: Integer;
+                         Filled: boolean = False;
+                         Continuous: boolean = False); 
+    procedure PolyBezier(const Points: array of TPoint;  
+                         Filled: boolean = False;
+                         Continuous: boolean = False);
+    procedure Rectangle (Const Bounds : TRect);
     procedure Rectangle (left,top,right,bottom:integer);
     procedure Rectangle (left,top,right,bottom:integer);
+    procedure FillRect(const ARect: TRect); 
+    procedure FillRect(X1,Y1,X2,Y2: Integer);
     // using brush
     // using brush
     procedure FloodFill (x,y:integer);
     procedure FloodFill (x,y:integer);
     procedure Clear;
     procedure Clear;

+ 11 - 0
packages/fcl-image/src/fpfont.inc

@@ -24,6 +24,17 @@ begin
   FSize := AValue;
   FSize := AValue;
 end;
 end;
 
 
+procedure TFPCustomFont.SetOrientation (AValue:integer);
+begin
+  FOrientation := AValue;
+end;
+
+function TFPCustomFont.GetOrientation : Integer;
+begin
+  Result := FOrientation;
+end;
+
+
 procedure TFPCustomFont.DoCopyProps (From:TFPCanvasHelper);
 procedure TFPCustomFont.DoCopyProps (From:TFPCanvasHelper);
 begin
 begin
   with from as TFPCustomFont do
   with from as TFPCustomFont do

+ 21 - 4
packages/fcl-json/Makefile

@@ -1,8 +1,8 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/20]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/10/20]
 #
 #
 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 i386-nativent 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-solaris 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 mipsel-linux
+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 i386-nativent i386-iphonesim 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-solaris 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 mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
@@ -245,7 +245,7 @@ endif
 ifndef CROSSBINDIR
 ifndef CROSSBINDIR
 CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
 CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
 endif
 endif
-ifeq ($(OS_TARGET),darwin)
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
 ifeq ($(OS_SOURCE),darwin)
 ifeq ($(OS_SOURCE),darwin)
 DARWIN2DARWIN=1
 DARWIN2DARWIN=1
 endif
 endif
@@ -329,6 +329,9 @@ endif
 ifeq ($(FULL_TARGET),i386-nativent)
 ifeq ($(FULL_TARGET),i386-nativent)
 override TARGET_UNITS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 override TARGET_UNITS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 endif
 endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override TARGET_UNITS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override TARGET_UNITS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 override TARGET_UNITS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 endif
 endif
@@ -512,6 +515,9 @@ endif
 ifeq ($(FULL_TARGET),i386-nativent)
 ifeq ($(FULL_TARGET),i386-nativent)
 override TARGET_RSTS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 override TARGET_RSTS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 endif
 endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override TARGET_RSTS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override TARGET_RSTS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 override TARGET_RSTS+=fpjson jsonscanner jsonparser jsonconf fpjsonrtti
 endif
 endif
@@ -696,6 +702,9 @@ endif
 ifeq ($(FULL_TARGET),i386-nativent)
 ifeq ($(FULL_TARGET),i386-nativent)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_OPTIONS+=-S2h
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
@@ -879,6 +888,9 @@ endif
 ifeq ($(FULL_TARGET),i386-nativent)
 ifeq ($(FULL_TARGET),i386-nativent)
 override COMPILER_SOURCEDIR+=src
 override COMPILER_SOURCEDIR+=src
 endif
 endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_SOURCEDIR+=src
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_SOURCEDIR+=src
 override COMPILER_SOURCEDIR+=src
 endif
 endif
@@ -1326,7 +1338,7 @@ DEBUGSYMEXT=.xcoff
 SHORTSUFFIX=mac
 SHORTSUFFIX=mac
 IMPORTLIBPREFIX=imp
 IMPORTLIBPREFIX=imp
 endif
 endif
-ifeq ($(OS_TARGET),darwin)
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
 BATCHEXT=.sh
 BATCHEXT=.sh
 EXEEXT=
 EXEEXT=
 HASSHAREDLIB=1
 HASSHAREDLIB=1
@@ -1855,6 +1867,11 @@ ifeq ($(FULL_TARGET),i386-nativent)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 endif
 endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_UNIVINT=1
+REQUIRE_PACKAGES_FCL-BASE=1
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1

+ 3 - 3
packages/fcl-passrc/src/pastree.pp

@@ -2609,7 +2609,7 @@ Var
   I : Integer;
   I : Integer;
 
 
 begin
 begin
-  For I:=0 to Length(Params) do
+  For I:=0 to High(Params) do
     begin
     begin
     If (Result<>'')  then
     If (Result<>'')  then
       Result:=Result+', ';
       Result:=Result+', ';
@@ -2647,7 +2647,7 @@ Function TRecordValues.GetDeclaration(Full : Boolean):AnsiString;
 Var
 Var
   I : Integer;
   I : Integer;
 begin
 begin
-  For I:=0 to Length(Fields) do
+  For I:=0 to High(Fields) do
     begin
     begin
     If Result='' then
     If Result='' then
       Result:=Result+'; ';
       Result:=Result+'; ';
@@ -2708,7 +2708,7 @@ Var
   I : Integer;
   I : Integer;
 
 
 begin
 begin
-  For I:=0 to Length(Values) do
+  For I:=0 to High(Values) do
     begin
     begin
     If Result='' then
     If Result='' then
       Result:=Result+', ';
       Result:=Result+', ';

+ 90 - 8
packages/fcl-process/Makefile

@@ -1,8 +1,8 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/05/05]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/10/20]
 #
 #
 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 i386-nativent i386-iphonesim 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-solaris 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 mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
@@ -245,7 +245,7 @@ endif
 ifndef CROSSBINDIR
 ifndef CROSSBINDIR
 CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
 CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
 endif
 endif
-ifeq ($(OS_TARGET),darwin)
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
 ifeq ($(OS_SOURCE),darwin)
 ifeq ($(OS_SOURCE),darwin)
 DARWIN2DARWIN=1
 DARWIN2DARWIN=1
 endif
 endif
@@ -326,6 +326,12 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 override TARGET_UNITS+=pipes process
 override TARGET_UNITS+=pipes process
 endif
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override TARGET_UNITS+=pipes process
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
 override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
 endif
 endif
@@ -389,6 +395,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
 override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
 override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
 endif
 endif
@@ -440,6 +449,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_UNITS+=pipes process
 override TARGET_UNITS+=pipes process
 endif
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_UNITS+=pipes process  simpleipc dbugmsg dbugintf
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_RSTS+=process simpleipc
 override TARGET_RSTS+=process simpleipc
 endif
 endif
@@ -500,6 +512,12 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 override TARGET_RSTS+=process simpleipc
 override TARGET_RSTS+=process simpleipc
 endif
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override TARGET_RSTS+=process simpleipc
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override TARGET_RSTS+=process simpleipc
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override TARGET_RSTS+=process simpleipc
 override TARGET_RSTS+=process simpleipc
 endif
 endif
@@ -563,6 +581,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_RSTS+=process simpleipc
 override TARGET_RSTS+=process simpleipc
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_RSTS+=process simpleipc
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_RSTS+=process simpleipc
 override TARGET_RSTS+=process simpleipc
 endif
 endif
@@ -614,6 +635,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_RSTS+=process simpleipc
 override TARGET_RSTS+=process simpleipc
 endif
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_RSTS+=process simpleipc
+endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
@@ -675,6 +699,12 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_OPTIONS+=-S2h
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
@@ -738,6 +768,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
@@ -789,6 +822,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_OPTIONS+=-S2h
 override COMPILER_OPTIONS+=-S2h
 endif
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 endif
 endif
@@ -849,6 +885,12 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src
 endif
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 endif
 endif
@@ -912,6 +954,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
 endif
 endif
@@ -963,6 +1008,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src
 override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src
 endif
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_INCLUDEDIR+=src/$(OS_TARGET) src  src/unix src/dummy
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 endif
 endif
@@ -1023,6 +1071,12 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 endif
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 endif
 endif
@@ -1086,6 +1140,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 endif
 endif
@@ -1137,6 +1194,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
 endif
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_SOURCEDIR+=src/$(OS_TARGET) src
+endif
 ifdef REQUIRE_UNITSDIR
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
 endif
@@ -1464,7 +1524,7 @@ DEBUGSYMEXT=.xcoff
 SHORTSUFFIX=mac
 SHORTSUFFIX=mac
 IMPORTLIBPREFIX=imp
 IMPORTLIBPREFIX=imp
 endif
 endif
-ifeq ($(OS_TARGET),darwin)
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
 BATCHEXT=.sh
 BATCHEXT=.sh
 EXEEXT=
 EXEEXT=
 HASSHAREDLIB=1
 HASSHAREDLIB=1
@@ -1479,6 +1539,10 @@ ifeq ($(OS_TARGET),symbian)
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=symbian
 SHORTSUFFIX=symbian
 endif
 endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
 else
 else
 ifeq ($(OS_TARGET),go32v1)
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
 PPUEXT=.pp1
@@ -1964,6 +2028,12 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),i386-nativent)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -2027,6 +2097,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -2078,6 +2151,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifdef REQUIRE_PACKAGES_RTL
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
 ifneq ($(PACKAGEDIR_RTL),)
@@ -2087,9 +2163,9 @@ else
 UNITDIR_RTL=$(PACKAGEDIR_RTL)
 UNITDIR_RTL=$(PACKAGEDIR_RTL)
 endif
 endif
 ifdef CHECKDEPEND
 ifdef CHECKDEPEND
-$(PACKAGEDIR_RTL)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
-override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE)
 endif
 endif
 else
 else
 PACKAGEDIR_RTL=
 PACKAGEDIR_RTL=
@@ -2459,7 +2535,7 @@ ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
 ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
 ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
 ifdef USETAR
 ifdef USETAR
 ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
 ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
-ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+ZIPCMD_ZIP:=$(TARPROG) c$(TAROPT)f $(ZIPDESTFILE) *
 else
 else
 ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
 ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
 ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
 ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
@@ -2504,6 +2580,9 @@ fpc_zipdistinstall:
 ifdef EXEFILES
 ifdef EXEFILES
 override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
 override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
 endif
 endif
+ifdef CLEAN_PROGRAMS
+override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+endif
 ifdef CLEAN_UNITS
 ifdef CLEAN_UNITS
 override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
 override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
 endif
 endif
@@ -2550,6 +2629,9 @@ endif
 ifdef CLEANRSTFILES
 ifdef CLEANRSTFILES
 	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
 	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
 endif
 endif
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
 endif
 endif
 	-$(DELTREE) units
 	-$(DELTREE) units
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)

+ 34 - 14
packages/fcl-registry/src/regini.inc

@@ -83,30 +83,44 @@ procedure TRegIniFile.WriteBool(const Section, Ident: string; Value: Boolean);
 begin
 begin
 	if not OpenKey(fPath+Section,true) then Exit;
 	if not OpenKey(fPath+Section,true) then Exit;
 	try
 	try
-	 inherited WriteBool(Ident,Value);
-	finally
-	 CloseKey;
+    if not fPreferStringValues then
+  	  inherited WriteBool(Ident,Value)
+    else begin
+      if ValueExists(Ident) and (GetDataType(Ident)=rdInteger) then
+    	  inherited WriteBool(Ident,Value)
+      else
+        inherited WriteString(Ident,BoolToStr(Value));
+    end;
+  finally
+	  CloseKey;
 	end;
 	end;
 end;
 end;
 
 
 procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
 procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
 begin
 begin
   if not OpenKey(fPath+Section,true) then Exit;
   if not OpenKey(fPath+Section,true) then Exit;
- try
-  inherited WriteInteger(Ident,Value);
- finally
-  CloseKey;
- end;
+  try
+    if not fPreferStringValues then
+      inherited WriteInteger(Ident,Value)
+    else begin
+      if ValueExists(Ident) and (GetDataType(Ident)=rdInteger) then
+    	  inherited WriteInteger(Ident,Value)
+      else
+        inherited WriteString(Ident,IntToStr(Value));
+    end;
+  finally
+    CloseKey;
+  end;
 end;
 end;
 
 
 procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
 procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
 begin
 begin
-   if not OpenKey(fPath+Section,true) then Exit;
- try
+  if not OpenKey(fPath+Section,true) then Exit;
+  try
    inherited WriteString(Ident,Value);
    inherited WriteString(Ident,Value);
- finally
+  finally
    CloseKey;
    CloseKey;
- end;
+  end;
 end;
 end;
 
 
 function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
 function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
@@ -115,7 +129,10 @@ begin
 	if not OpenKey(fPath+Section,false) then Exit;
 	if not OpenKey(fPath+Section,false) then Exit;
 	try
 	try
     if ValueExists(Ident) then
     if ValueExists(Ident) then
-	    Result := inherited ReadBool(Ident);
+      if (not fPreferStringValues) or (GetDataType(Ident)=rdInteger) then
+  	    Result := inherited ReadBool(Ident)
+      else
+        Result := StrToBool(inherited ReadString(Ident));
 	finally
 	finally
 	  CloseKey;
 	  CloseKey;
 	end;
 	end;
@@ -127,7 +144,10 @@ begin
   if not OpenKey(fPath+Section,false) then Exit;
   if not OpenKey(fPath+Section,false) then Exit;
   try
   try
     if ValueExists(Ident) then
     if ValueExists(Ident) then
-      Result := inherited ReadInteger(Ident);
+      if (not fPreferStringValues) or (GetDataType(Ident)=rdInteger) then
+        Result := inherited ReadInteger(Ident)
+      else
+        Result := StrToInt(inherited ReadString(Ident));
   finally
   finally
     CloseKey;
     CloseKey;
   end;
   end;

+ 5 - 2
packages/fcl-registry/src/registry.pp

@@ -130,8 +130,9 @@ type
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
   TRegIniFile = class(TRegistry)
   TRegIniFile = class(TRegistry)
   private
   private
-    fFileName: String;
-    fPath    : String;
+    fFileName          : String;
+    fPath              : String;
+    fPreferStringValues: Boolean;
   public
   public
     constructor Create(const FN: string); overload;
     constructor Create(const FN: string); overload;
     constructor Create(const FN: string;aaccess:longword); overload;
     constructor Create(const FN: string;aaccess:longword); overload;
@@ -150,6 +151,8 @@ type
     procedure DeleteKey(const Section, Ident: String);
     procedure DeleteKey(const Section, Ident: String);
 
 
     property FileName: String read fFileName;
     property FileName: String read fFileName;
+    property PreferStringValues: Boolean read fPreferStringValues
+                write fPreferStringValues;
   end;
   end;
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------

+ 18 - 16
packages/fcl-registry/src/xmlreg.pp

@@ -352,22 +352,24 @@ begin
     begin
     begin
     Node[SType]:=IntToStr(Ord(DataType));
     Node[SType]:=IntToStr(Ord(DataType));
     DataNode:=Node.FirstChild;
     DataNode:=Node.FirstChild;
-    Result:=DataNode<>Nil;  // Bug 9879. Create child here?
-    If Result Then
-      begin 
-        Case DataType of
-          dtDWORD : DataNode.NodeValue:=IntToStr(PCardinal(@Data)^);
-          dtString : begin
-                     SetLength(S,DataSize);
-                     If (DataSize>0) then
-                       Move(Data,S[1],DataSize);
-                     DataNode.NodeValue:=S;
-                     end;
-          dtBinary : begin
-                     S:=BufToHex(Data,DataSize);
-                     DataNode.NodeValue:=S;
-                     end;
-        end;
+    // Reading <value></value> results in <value/>, i.e. no subkey exists any more. Create textnode.
+    if (DataNode=nil) then
+      begin
+      DataNode:=FDocument.CreateTextNode('');
+      Node.AppendChild(DataNode);
+      end;
+    Case DataType of
+      dtDWORD : DataNode.NodeValue:=IntToStr(PCardinal(@Data)^);
+      dtString : begin
+                 SetLength(S,DataSize);
+                 If (DataSize>0) then
+                   Move(Data,S[1],DataSize);
+                 DataNode.NodeValue:=S;
+                 end;
+      dtBinary : begin
+                 S:=BufToHex(Data,DataSize);
+                 DataNode.NodeValue:=S;
+                 end;
       end;
       end;
     end;
     end;
   If Result then
   If Result then

+ 39 - 4
packages/fcl-registry/tests/testbasics.pp

@@ -19,6 +19,7 @@ type
   protected
   protected
   published
   published
     procedure TestSimpleWinRegistry;
     procedure TestSimpleWinRegistry;
+    procedure TestDoubleWrite;
   end;
   end;
 
 
 implementation
 implementation
@@ -37,15 +38,49 @@ begin
 
 
   // use a hopefully non existing key
   // use a hopefully non existing key
   AssertFalse(Registry.KeyExists('FPC1234'));
   AssertFalse(Registry.KeyExists('FPC1234'));
-
+{$ifdef windows}
   AssertTrue(Registry.KeyExists('SOFTWARE'));
   AssertTrue(Registry.KeyExists('SOFTWARE'));
-
-  // Registry.OpenKey('FPC', False);
-  // Result:=Registry.ReadString('VALUE1');
+{$endif}  
 
 
   Registry.Free;
   Registry.Free;
 end;
 end;
 
 
+procedure TTestBasics.TestDoubleWrite;
+
+{$ifndef windows}
+Var
+  FN : String;
+{$endif}
+
+begin
+{$ifndef windows}
+  FN:=includetrailingpathdelimiter(GetAppConfigDir(False))+'reg.xml';
+  if FileExists(FN) then
+    AssertTrue(DeleteFile(FN));
+{$endif}
+  with TRegistry.Create do
+    try
+      OpenKey('test', true);
+      WriteString('LAYOUT', '');
+      CloseKey;
+    finally
+      Free;
+    end;
+  with TRegistry.Create do
+    try
+      OpenKey('test', true);
+      WriteString('LAYOUT', '');
+      CloseKey;
+    finally
+      Free;
+    end;
+{$ifndef windows}
+  FN:=includetrailingpathdelimiter(GetAppConfigDir(False))+'reg.xml';
+  if FileExists(FN) then
+    AssertTrue(DeleteFile(FN));
+{$endif}
+end;
+
 initialization
 initialization
   RegisterTest(TTestBasics);
   RegisterTest(TTestBasics);
 end.
 end.

+ 2427 - 0
packages/fcl-stl/Makefile

@@ -0,0 +1,2427 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/03/21]
+#
+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 i386-nativent i386-iphonesim 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 powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris 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 mipsel-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx haiku
+LIMIT83fs = go32v2 os2 emx watcom
+OSNeedsComspecToRunBatch = go32v2 watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef COMSPEC
+ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
+ifndef RUNBATCH
+RUNBATCH=$(COMSPEC) /C
+endif
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+ifneq ($(CPU_TARGET),)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+else
+FPC:=$(shell $(FPCPROG) -PB)
+endif
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+else
+ifeq ($(strip $(wildcard $(FPC))),)
+FPC:=$(firstword $(FPCPROG))
+endif
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifeq ($(CPU_TARGET),armeb)
+ARCH=arm
+override FPCOPT+=-Cb
+else
+ifeq ($(CPU_TARGET),armel)
+ARCH=arm
+override FPCOPT+=-CaEABI
+else
+ARCH=$(CPU_TARGET)
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE ARCH CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+ifeq ($(OS_SOURCE),darwin)
+DARWIN2DARWIN=1
+endif
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+ifndef DARWIN2DARWIN
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=fcl-stl
+override PACKAGE_VERSION=2.5.1
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+override INSTALL_FPCPACKAGE=y
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),haiku)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=hai
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+IMPORTLIBPREFIX=imp
+endif
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+ifeq ($(OS_TARGET),symbian)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=symbian
+endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
+ifeq ($(OS_TARGET),wii)
+EXEEXT=.dol
+SHAREDLIBEXT=.so
+SHORTSUFFIX=wii
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+IMPORTLIBPREFIX=imp
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(ARCH)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(ARCH)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX)
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O2
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifeq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),linux)
+ifeq ($(CPU_TARGET),x86_64)
+override FPCOPT+=-Cg
+endif
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+ifdef RUNBATCH
+EXECPPAS:=@$(RUNBATCH) $(PPAS)
+else
+EXECPPAS:=@$(PPAS)
+endif
+endif
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.inc $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) c$(TAROPT)f $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+ifdef RUNBATCH
+	$(RUNBATCH) $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_PROGRAMS
+override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+.NOTPARALLEL:

+ 23 - 0
packages/fcl-stl/Makefile.fpc

@@ -0,0 +1,23 @@
+#
+#   Makefile.fpc for Free Component Library
+#
+
+[package]
+name=fcl-stl
+version=2.5.1
+
+[target]
+units=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../..
+
+[compiler]
+options=-S2h
+sourcedir=src
+
+[rules]
+.NOTPARALLEL:

+ 47 - 0
packages/fcl-stl/doc/arrayutils.tex

@@ -0,0 +1,47 @@
+\chapter{TArrayUtils}
+
+Set of utilities for manipulating arrays data.
+
+Takes 3 arguements for specialization. First one is type of array (can be anything, which is
+accesible by [] operator, e. g. ordinary array, vector, ...), second one is type of array element.
+
+%Usage example for sorting:
+
+%\lstinputlisting[language=Pascal]{sortingexample.pp}
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!procedure RandomShuffle(arr: TArr, size:SizeUint)! &
+O(N)\\ \hline
+\multicolumn{2}{|m{15cm}|}{Shuffles elements in array in random way} \\\hline\hline
+
+\end{longtable}\chapter{TOrderingArrayUtils}
+
+Set of utilities for manipulating arrays data.
+
+Takes 3 arguements for specialization. First one is type of array (can be anything, which is
+accesible by [] operator, e. g. ordinary array, vector, ...), second one is type of array element,
+third one is comparator class (see TPriorityQueue for definition of comparator class).
+
+Usage example for sorting:
+
+\lstinputlisting[language=Pascal]{sortingexample.pp}
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!procedure Sort(arr: TArr, size:SizeUint)! &
+O(N log N) average and worst case. Uses QuickSort, backed up by HeapSort, when QuickSort ends up in
+using too much recursion.\\ \hline
+\multicolumn{2}{|m{15cm}|}{Sort array arr, with specified size. Array indexing should be 0 based.} \\\hline\hline
+
+\end{longtable}

+ 81 - 0
packages/fcl-stl/doc/deque.tex

@@ -0,0 +1,81 @@
+\chapter{TDeque}
+
+Implements selfresizing array. Indexing is 0-based.
+Also implement constant time insertion from front.
+
+Usage example:
+
+\lstinputlisting[language=Pascal]{dequeexample.pp}
+
+Memory complexity:
+Uses at most 3times bigger memory than maximal array size (this is only case during reallocation).
+Normal consumption is at most twice as maximal array size.
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty array.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns size of array.} \\\hline\hline
+
+\verb!procedure PushBack(value: T)! &  Amortized
+O(1), some operations might take O(N) time, when array needs to be reallocated, but sequence of N
+operations takes O(N) time. \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts at the end of array (increases size by 1)} \\\hline\hline
+
+\verb!procedure PopBack()! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Removes element from the end of array (decreases size by 1). When array
+is empty, does nothing.} \\\hline\hline
+
+\verb!procedure PushFront(value: T)! &  Same as PushBack. \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts at the beginning of array (increases size by 1)} \\\hline\hline
+
+\verb!procedure PopFront()! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Removes element from the beginning of array (decreases size by 1). When array
+is empty, does nothing.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when array is empty} \\\hline\hline
+
+\verb!procedure Insert(position: SizeUInt; value: T)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Inserts value at position. When position is greater than size, puts value
+at the end of array.} \\\hline\hline
+
+\verb!procedure Erase(positine: SizeUInt; value: T)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Erases element from position. When position is outside of array does
+nothing.} \\\hline\hline
+
+\verb!procedure Clear! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Clears array (set size to zero). But doesn't free memory used by array.}
+\\\hline\hline
+
+\verb!function Front: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns first element from array.} \\\hline\hline
+
+\verb!function Back: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns last element from array.} \\\hline\hline
+
+\verb!procedure Resize(num: SizeUInt)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Changes size of array to num. Doesn't guarantte anything about value of
+newly alocated elements.} \\\hline\hline
+
+\verb!procedure Reserve(num: SizeUInt)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Alocates at least num elements for array. Usefull when you want to
+pushback big number of elements and want to avoid frequent reallocation.} \\\hline\hline
+
+\verb!property item[i: SizeUInt]: T; default;! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Property for accessing i-th element in array. Can be used just by square
+brackets (its default property).} \\\hline\hline
+
+\verb!property mutable[i: SizeUInt]: T;! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns pointer to i-th element in array. Usefull when you store records.} \\\hline
+
+
+
+\end{longtable}

+ 24 - 0
packages/fcl-stl/doc/dequeexample.pp

@@ -0,0 +1,24 @@
+uses gdeque;
+
+type TDequelli = specialize TDeque<longint>;
+
+var Buffer:TDequelli; i:longint;
+
+begin
+  Buffer := TDequelli.Create;
+  {Push 5 elements at the end of array}
+  for i:=1 to 5 do
+    Buffer.PushBack(i);
+  {change 3rd element to 47}
+  Buffer[2] := 47;
+  {pop last element}
+  Buffer.PopBack;
+  {push 3 element to front}
+  for i:=1 to 3 do
+    Buffer.PushFront(i*10);
+  {print all elements}
+  for i:=0 to Buffer.Size-1 do
+    writeln(Buffer[i]);
+
+  Buffer.Destroy;
+end.

+ 63 - 0
packages/fcl-stl/doc/main.tex

@@ -0,0 +1,63 @@
+
+%% Template by Michal Forisek
+
+
+\documentclass[a4paper]{report}
+\usepackage[utf8]{inputenc}
+\usepackage{a4wide}
+\usepackage{tabularx}
+\usepackage{amsfonts}
+\usepackage{amssymb}
+\usepackage{amsmath}
+\usepackage{epsfig}
+\usepackage{color}
+\usepackage{mathrsfs}
+\usepackage{verbatim}
+\usepackage{hyperref}
+\usepackage{subfigure}
+\usepackage{float}
+\usepackage{listings}
+\usepackage{longtable}
+\input{makra.tex}
+
+\renewcommand{\chaptername}{}
+\renewcommand{\thechapter}{}
+
+\begin{document}
+
+\thispagestyle{empty}
+\vfill
+\vfill
+\begin{center}
+\begin{minipage}{0.8\textwidth}
+\hrule
+\bigskip\bigskip
+\centerline{\LARGE\sc FreePascal generic container library}
+\smallskip
+\centerline{(manual)}
+\smallskip
+\centerline{\url{http://code.google.com/p/stlpascal}}
+\bigskip
+\bigskip
+\bigskip\bigskip
+\hrule
+\end{minipage}
+\end{center}
+\vfill
+{~}
+\hfill version 1.0
+\eject % EOP i
+
+\tableofcontents
+
+\input{vector.tex}
+\input{stack.tex}
+\input{deque.tex}
+\input{queue.tex}
+\input{util.tex}
+\input{priorityqueue.tex}
+\input{arrayutils.tex}
+\input{set.tex}
+\input{map.tex}
+
+\end{document}

+ 263 - 0
packages/fcl-stl/doc/makra.tex

@@ -0,0 +1,263 @@
+% vim: set fdm=marker:
+%% Original by Michal Forisek
+
+
+%% zakladne definicie
+\newcommand{\quoteme}[1]{\clqq#1\crqq}
+\def\todo#1{[{\color{red} TODO:} {\bf  #1}]}
+\def\fixme#1{[{\color{red} FIXME:} {\bf  #1}]}
+\def\verify#1{\todo{verify: #1}}
+
+\def\xor{\oplus}
+\def\concat{\|}
+%\def\inr{\in_{R}}
+\def\toa #1 {\overset{#1}{\rightarrow}}
+\def\inr{\overset{\$}{\leftarrow}}
+\def\assign{\leftarrow}
+\def\send{\rightarrow}
+\def\isomorph{\cong}
+\def\nsd{NSD}
+\def\union{\cup}
+\newcommand{\unit}[1]{\ensuremath{\, \mathrm{#1}}}
+\DeclareMathOperator{\dlog}{dlog}
+
+\def\compactlist{
+  \setlength{\itemsep}{1pt}
+  \setlength{\parskip}{0pt}
+  \setlength{\parsep}{0pt}
+}
+\def\mod{\,{\rm mod}\,}
+
+%%% original od Misofa:
+%% {{{
+
+\catcode`\@=11
+
+\def\R{{\cal R}}
+\def\cent{{c\kern-0.3em|\kern0.1em}}
+\def\N{{N}} % FIXME FIXME 
+
+\let\eps=\varepsilon
+
+\def\relupdown#1#2#3{\mathrel{\mathop{#1}\limits^{#2}_{#3}} }
+
+\let\then=\Rightarrow
+\let\neht=\Leftarrow
+
+\def\krok#1{\relupdown{\Longrightarrow}{}{#1}}
+\def\thenrm{\relupdown{\Longrightarrow}{}{rm}}
+
+\def\bicik{\upharpoonright}
+\def\B{{\mathbf B}}
+\def\kodTS#1{{\tt <}#1{\tt >}}
+
+\newtheorem{definicia}{Definícia}[section]
+\newtheorem{HLPpoznamka}{Poznámka}[section]
+\newtheorem{HLPpriklad}{Príklad}[section]
+\newtheorem{HLPcvicenie}[HLPpriklad]{Cvičenie}
+\newtheorem{zadanie}{Úloha}[section]
+\newenvironment{poznamka}{\begin{HLPpoznamka}\rm}{\end{HLPpoznamka}}
+\newenvironment{priklad}{\begin{HLPpriklad}\rm}{\end{HLPpriklad}}
+\newenvironment{cvicenie}{\begin{HLPcvicenie}\rm}{\end{HLPcvicenie}}
+\newtheorem{veta}{Veta}[section]
+\newtheorem{lema}[veta]{Lema}
+\newtheorem{dosledok}[veta]{Dôsledok}
+\newtheorem{teza}[veta]{Téza}
+% \newtheorem{dokaz}{Dôkaz}[section]
+
+\long\def\odsadene#1{
+\leftskip=\parindent
+\parindent=0pt
+\vskip-5pt
+
+\parskip=5pt
+#1
+\parskip=0pt
+
+\parindent=\leftskip
+\leftskip=0pt
+
+} % end \odsadene
+
+
+
+
+%%%%%%%%%%% PROSTREDIE PRE PISANIE KOMENTAROV
+
+%\newenvironment{komentar}{%
+%\vskip\baselineskip
+%\tabularx{0.95\textwidth}{|X|}
+%\sl
+%}
+%{\endtabularx
+%\vskip\baselineskip
+%}
+
+\newenvironment{komentar}{%
+\vskip\baselineskip\noindent
+\tabularx{\textwidth}{>{\hsize=.2\hsize}X>{\hsize=1.8\hsize}X}
+\sl ~ & \sl
+}
+{\endtabularx
+\vskip\baselineskip
+}
+
+%\newenvironment{komentar}{%
+%\vskip\baselineskip
+%\trivlist\vspace{-4pt}\raggedleft\item\relax\tabularx{0.9\textwidth}{X}\sl}
+%{\endtabularx\vspace{-4pt}\endtrivlist
+%\vskip\baselineskip
+%}
+
+\newenvironment{dokaz}{\trivlist
+  \item[\hskip \labelsep{\bfseries Dôkaz.}]}{\endtrivlist}
+  
+%\newenvironment{dokaz}{%
+%\vskip\baselineskip\noindent
+%\tabularx{\textwidth}{||X||}
+%\sl
+%}
+%{\endtabularx
+%\vskip\baselineskip
+%}
+
+%%%%%%%%%%% PROSTREDIE PRE MOJE ITEMIZE 
+
+\newenvironment{myitemize}{%
+\begin{itemize}
+\itemsep-3pt
+}
+{\end{itemize}
+}
+
+%%%%%%%%%%% MATICKE MAKRA
+
+\font\tenrm=csr10
+
+\def\eps{\varepsilon}
+% \def\R{{\mathbb R}}
+\def\lvec#1{\overrightarrow{#1}}
+\def\uhol{{\measuredangle}}
+\def\then{\Rightarrow}
+% \def\lg{{\rm lg}}
+\def\lg{\log_2}
+%\def\div{\mathbin{\rm div}}
+\def\div{{\rm div}}
+
+%%%%%%%%%%% PDF
+
+\newif\ifpdf
+\ifx\pdfoutput\undefined
+  \pdffalse
+\else
+  \pdfoutput=1 \pdftrue
+\fi
+
+%%%%%%%%%%% OBRAZKY 
+
+\newcommand{\myincludegraphics}[2][]{\includegraphics[#1]{images/#2}}
+
+%%%%%%%%%%% SLOVNICEK
+
+\openout2=\jobname.slo
+
+\newcommand{\definuj}[3][]{%
+\def\tmpvoid{}\def\tmpfirst{#1}%
+\ifx\tmpvoid\tmpfirst%
+  {\sl #2}\label{definicia:#2}\write2{#2 & #3 & \pageref{definicia:#2} \cr}%
+\else%
+  {\sl #2}\label{definicia:#2}\write2{#1 & #3 & \pageref{definicia:#2} \cr}%
+\fi}
+
+\newcommand{\definujsilent}[2]{%
+\label{definicia:#1}\write2{#1 & #2 & \pageref{definicia:#1} \cr}%
+}
+
+\newcommand\myglossary{
+  \immediate\closeout2 
+  %\if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi
+  \chapter{Slovníček pojmov}
+  \begin{tabular}{|l|l|r|}
+  \hline
+  {\bfseries slovenský pojem} & {\bfseries anglický preklad} & {\bfseries str.} \\ 
+  \hline
+  \InputIfFileExists{\jobname.srs}{}{~ & ~ & ~ \\}
+  \hline
+  \end{tabular}
+  %\if@restonecol\twocolumn\fi
+}
+
+%%%%%%%%%%% UVODZOVKY
+
+\catcode`\"=13
+\def "{\begingroup\clqq\def "{\endgroup\crqq}}
+\def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&%
+  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~\do\"}
+
+%%%%%%%%%%% DANGER BENDS 
+
+\font\manual=manfnt % font used for the METAFONT logo, etc.
+\def\dbend{{\manual\char127}} % dangerous bend sign
+
+\newlength{\bendwidth}   \settowidth{\bendwidth}{\dbend}    \newlength{\hangwidth}
+
+\def\hangone{%
+  \hangwidth=\bendwidth%
+  \advance\hangwidth 5pt%
+  \hangindent\hangwidth%
+}
+\def\hangtwo{%
+  \hangwidth=\bendwidth%
+  \multiply\hangwidth 2%
+  \advance\hangwidth 6pt% 
+  \hangindent\hangwidth%
+}
+
+\def\medbreak{\par\ifdim\lastskip<\medskipamount \removelastskip\penalty-100\medskip\fi}
+\let\endgraf=\par
+
+\def\d@nger{\medbreak\begingroup\clubpenalty=10000
+%\def\d@nger{\begingroup\clubpenalty=10000
+%  \def\par{\endgraf\endgroup\medbreak} \noindent\hangone\hangafter=-2
+  \def\par{\endgraf\endgroup} \noindent\hangone\hangafter=-2
+  \hbox to0pt{\hskip-\hangindent\dbend\hfill}}
+\outer\def\danger{\d@nger}
+
+\def\dd@nger{\medbreak\begingroup\clubpenalty=10000
+%  \def\par{\endgraf\endgroup\medbreak} \noindent\hangtwo\hangafter=-2
+  \def\par{\endgraf\endgroup} \noindent\hangtwo\hangafter=-2
+  \hbox to0pt{\hskip-\hangindent\dbend\kern1pt\dbend\hfill}}
+\outer\def\ddanger{\dd@nger}
+
+\def\enddanger{\endgraf\endgroup} % omits the \medbreak
+\def\enddangerhop{\endgraf\endgroup\medbreak}
+
+
+
+
+\def\@nakedcite#1#2{{#1\if@tempswa , #2\fi}}
+\DeclareRobustCommand\nakedcite{%
+  \@ifnextchar [{\@tempswatrue\@nakedcitex}{\@tempswafalse\@nakedcitex[]}}
+\def\@nakedcitex[#1]#2{%
+  \let\@citea\@empty
+  \@nakedcite{\@for\@citeb:=#2\do
+    {\@citea\def\@citea{,\penalty\@m\ }%
+     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
+     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
+     \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
+       \G@refundefinedtrue
+       \@latex@warning
+         {Citation `\@citeb' on page \thepage \space undefined}}%
+       {\hbox{\csname b@\@citeb\endcsname}} }}{#1}}
+
+\long\def\FIXME#1{
+  \begin{center}
+  \begin{minipage}{0.8\textwidth}
+  {\bf FIXME:~}\sl #1
+  \end{minipage}
+  \end{center}
+}
+
+
+\catcode`\@=12
+%% }}}

+ 87 - 0
packages/fcl-stl/doc/map.tex

@@ -0,0 +1,87 @@
+\chapter{TMap}
+
+Implements container for ordered associative array with unique keys.
+Takes 3 arguments for specialization, first one is type of keys, second one is type of values, third
+one is comparator class for keys.
+Usage example:
+
+\lstinputlisting[language=Pascal]{mapexample.pp}
+
+Some methods return type TMSet.PNode. Usefull fields are Data.Key, Data.Value, for retrieving
+actual Key and Value from node. This node can be also used for navigation between elements by methods of set class.
+You can also change value in node (but not key).
+(But don't do anything else with it, you can lose data integrity.)
+
+Memory complexity:
+Size of stored base + constant overhead for each stored element (3 pointers + one boolean).
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty map.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns number of elements in map.} \\\hline\hline
+
+\verb!procedure Insert(key: TKey; value: TValue)! &
+O(lg N), N is number of elements in map \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts key value pair into map. If key was already there, it will have
+new value assigned.} \\\hline\hline
+
+\verb!procedure Delete(key: TKey)! &
+O(lg N) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Deletes key (and associated value) from map. If element is not in map, nothing happens.} \\\hline\hline
+
+\verb!function Find(key: T):TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for key in map. If value is not there returns nil. Otherwise
+returns pointer to tree node (type TMSet.PNode), which can be used for retrieving data from map.} \\\hline\hline
+
+\verb!function FindLess(key: T):TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for greatest element less than key in map. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type TMSet.PNode), which can be used for retrieving data from map.} \\\hline\hline
+
+\verb!function FindLessEqual(key: T):TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for greatest element less or equal than key in map. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type TMSet.PNode), which can be used for retrieving data from map.} \\\hline\hline
+
+\verb!function FindGreater(key: T):TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for smallest element greater than key in map. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type TMSet.PNode), which can be used for retrieving data from map.} \\\hline\hline
+
+\verb!function FindGreaterEqual(key: T):TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for smallest element greater or equal than key in map. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type TMSet.PNode), which can be used for retrieving data from map.} \\\hline\hline
+
+\verb!function Min:TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns node containing smallest key of map. If map is empty returns
+nil.} \\\hline\hline
+
+\verb!function Max:TMSet.PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns node containing largest key of map. If map is empty returns
+nil.} \\\hline\hline
+
+\verb!function Next(x:TMSet.PNode):TMSet.PNode! & O(lg N) worst case, but traversal from smallest element to
+largest takes O(N) time \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns successor of x. If x is largest key of map, returns nil.} \\\hline\hline
+
+\verb!function Prev(x:TMSet.PNode):TMSet.PNode! & O(lg N) worst case, but traversal from largest element to
+smallest takes O(N) time \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns predecessor of x. If x is smallest key of map, returns nil.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when map is empty.} \\\hline
+
+\verb!function GetValue(key:TKey):TValue! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns value associated with key. Is key isn't in map crashes.} \\\hline
+
+\verb!property item[i: Key]: TValue; default;! & O(ln N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Property for accessing key i in map. Can be used just by square
+brackets (its default property).} \\\hline\hline
+
+
+\end{longtable}

+ 24 - 0
packages/fcl-stl/doc/mapexample.pp

@@ -0,0 +1,24 @@
+uses gmap, gutil;
+
+type lesslli=specialize TLess<longint>;
+     maplli=specialize TMap<longint, longint, lesslli>;
+
+var data:maplli; i:longint; iterator:maplli.TMSet.PNode;
+
+begin
+  data:=maplli.Create;
+
+  for i:=0 to 10 do
+    data[i]:=10*i;
+
+  {Iteration through elements}
+  iterator:=data.Min;
+  while iterator<>nil do begin
+    writeln(iterator^.Data.Key, ' ', iterator^.Data.Value);
+    iterator:=data.next(iterator);
+  end;
+
+  writeln(data.FindLess(7)^.Data.Value);
+
+  data.Destroy;
+end.

+ 44 - 0
packages/fcl-stl/doc/priorityqueue.tex

@@ -0,0 +1,44 @@
+\chapter{TPriorityQueue}
+
+Implements priority queue. It's container which allow insertions of elements and then retrieval of
+the biggest one.
+
+For specialization it needs two arguements. First is the type T of stored element. Second one is type
+comparator class, which should have class function \verb!c(a,b: T):boolean! which return true, when
+a is stricly less then b (or in other words, a should be poped out after b).
+
+Usage example:
+
+\lstinputlisting[language=Pascal]{priorityqueueexample.pp}
+
+Memory complexity:
+Since underlaying structure is TVector, memory complexity is same.
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty priority queue.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns number of elements in priority queue.} \\\hline\hline
+
+\verb!procedure Push(value: T)! &  Amortized
+O(lg N), some operations might take O(N) time, when underlaying array needs to be reallocated, but sequence of N
+operations takes O(N lg N) time. \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts element at the back of queue.} \\\hline\hline
+
+\verb!procedure Pop()! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Removes the biggest element from queue. If queue is empty does nothing.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when queue is empty.} \\\hline\hline
+
+\verb!function Top: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns the biggest element from queue.} \\\hline
+
+\end{longtable}

+ 30 - 0
packages/fcl-stl/doc/priorityqueueexample.pp

@@ -0,0 +1,30 @@
+{$mode objfpc}
+
+uses gpriorityqueue;
+
+type
+  lesslli = class
+    public
+    class function c(a,b: longint):boolean;inline;
+  end;
+
+class function lesslli.c(a,b: longint):boolean;inline;
+begin
+  c:=a<b;
+end;
+
+type priorityqueuelli = specialize TPriorityQueue<longint, lesslli>;
+
+var data:priorityqueuelli; i:longint;
+
+begin
+  data:=priorityqueuelli.Create;
+  for i:=1 to 10 do
+    data.Push(random(1000));
+  while not data.IsEmpty do begin
+    writeln(data.Top);
+    data.Pop;
+  end;
+
+  data.Destroy;
+end.

+ 39 - 0
packages/fcl-stl/doc/queue.tex

@@ -0,0 +1,39 @@
+\chapter{TQueue}
+
+Implements queue.
+
+Usage example:
+
+\lstinputlisting[language=Pascal]{queueexample.pp}
+
+Memory complexity:
+Since underlaying structure is TDeque, memory complexity is same.
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty queue.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns number of elements in queue.} \\\hline\hline
+
+\verb!procedure Push(value: T)! &  Amortized
+O(1), some operations might take O(N) time, when array needs to be reallocated, but sequence of N
+operations takes O(N) time \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts element at the back of queue.} \\\hline\hline
+
+\verb!procedure Pop()! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Removes element from the beginning of queue. If queue is empty does nothing.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when queue is empty.} \\\hline\hline
+
+\verb!function Front: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns the first element from queue.} \\\hline
+
+\end{longtable}

+ 17 - 0
packages/fcl-stl/doc/queueexample.pp

@@ -0,0 +1,17 @@
+uses gqueue;
+
+type queuelli = specialize TQueue<longint>;
+
+var data:queuelli; i:longint;
+
+begin
+  data:=queuelli.Create;
+  for i:=1 to 10 do
+    data.Push(10*i);
+  while not data.IsEmpty do begin
+    writeln(data.Front);
+    data.Pop;
+  end;
+
+  data.Destroy;
+end.

+ 76 - 0
packages/fcl-stl/doc/set.tex

@@ -0,0 +1,76 @@
+\chapter{TSet}
+
+Implements container for storing ordered set of unique elements.
+Takes 2 arguments for specialization, first one is type of elements, second one is comparator class.
+Usage example:
+
+\lstinputlisting[language=Pascal]{setexample.pp}
+
+Some methods return type of PNode. It has field Data, which can be used for retrieving data from
+that node. This node can be also used for navigation between elements by methods of set class.
+(But don't do anything else with it, you can lose data integrity.)
+
+Memory complexity:
+Size of stored base + constant overhead for each stored element (3 pointers + one boolean).
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty set.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns number of elements in set.} \\\hline\hline
+
+\verb!procedure Insert(value: T)! &
+O(lg N), N is number of elements in set \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts element into set.} \\\hline\hline
+
+\verb!procedure Delete(value: T)! &
+O(lg N), N is number of elements in set \\ \hline
+\multicolumn{2}{|m{15cm}|}{Deletes value from set. If element is not in set, nothing happens.} \\\hline\hline
+
+\verb!function Find(value: T):PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for value in set. If value is not there returns nil. Otherwise
+returns pointer to tree node (type PNode), which can be used for retrieving data from set.} \\\hline\hline
+
+\verb!function FindLess(value: T):PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for greatest element less than value in set. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type PNode), which can be used for retrieving data from set.} \\\hline\hline
+
+\verb!function FindLessEqual(value: T):PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for greatest element less or equal than value in set. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type PNode), which can be used for retrieving data from set.} \\\hline\hline
+
+\verb!function FindGreater(value: T):PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for smallest element greater than value in set. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type PNode), which can be used for retrieving data from set.} \\\hline\hline
+
+\verb!function FindGreaterEqual(value: T):PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Searches for smallest element greater or equal than value in set. If such element is not there returns nil. Otherwise
+returns pointer to tree node (type PNode), which can be used for retrieving data from set.} \\\hline\hline
+
+\verb!function Min:PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns node containing smallest element of set. If set is empty returns
+nil.} \\\hline\hline
+
+\verb!function Max:PNode! & O(lg N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns node containing largest element of set. If set is empty returns
+nil.} \\\hline\hline
+
+\verb!function Next(x:PNode):PNode! & O(lg N) worst case, but traversal from smallest element to
+largest takes O(N) time \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns successor of x. If x is largest element of set, returns nil.} \\\hline\hline
+
+\verb!function Prev(x:PNode):PNode! & O(lg N) worst case, but traversal from largest element to
+smallest takes O(N) time \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns predecessor of x. If x is smallest element of set, returns nil.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when set is empty.} \\\hline
+
+\end{longtable}

+ 24 - 0
packages/fcl-stl/doc/setexample.pp

@@ -0,0 +1,24 @@
+uses gset, gutil;
+
+type lesslli=specialize TLess<longint>;
+     setlli=specialize TSet<longint, lesslli>;
+
+var data:setlli; i:longint; iterator:setlli.PNode;
+
+begin
+  data:=setlli.Create;
+
+  for i:=0 to 10 do
+    data.insert(i);
+
+  {Iteration through elements}
+  iterator:=data.Min;
+  while iterator<>nil do begin
+    writeln(iterator^.Data);
+    iterator:=data.next(iterator);
+  end;
+
+  writeln(data.FindLess(7)^.Data);
+
+  data.Destroy;
+end.

+ 20 - 0
packages/fcl-stl/doc/sortingexample.pp

@@ -0,0 +1,20 @@
+uses garrayutils, gutil, gvector;
+
+type vectorlli = specialize TVector<longint>;
+     lesslli = specialize TLess<longint>;
+     sortlli = specialize TOrderingArrayUtils<vectorlli, longint, lesslli>;
+
+var data:vectorlli; n,i:longint;
+
+begin
+  randomize;
+  data:=vectorlli.Create;
+  read(n);
+  for i:=1 to n do
+    data.pushback(random(1000000000));
+  sortlli.sort(data, data.size());
+  for i:=1 to n do
+    writeln(data[i-1]);
+
+  data.Destroy;
+end.

+ 39 - 0
packages/fcl-stl/doc/stack.tex

@@ -0,0 +1,39 @@
+\chapter{TStack}
+
+Implements stack.
+
+Usage example:
+
+\lstinputlisting[language=Pascal]{stackexample.pp}
+
+Memory complexity:
+Since underlaying structure is TVector, memory complexity is same.
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty stack.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns number of elements in stack.} \\\hline\hline
+
+\verb!procedure Push(value: T)! &  Amortized
+O(1), some operations might take O(N) time, when array needs to be reallocated, but sequence of N
+operations takes O(N) time \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts element on the top of stack.} \\\hline\hline
+
+\verb!procedure Pop()! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Removes element from the top of stack. If stack is empty does nothing.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when stack is empty} \\\hline\hline
+
+\verb!function Top: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns top element from stack.} \\\hline
+
+\end{longtable}

+ 17 - 0
packages/fcl-stl/doc/stackexample.pp

@@ -0,0 +1,17 @@
+uses gstack;
+
+type stacklli = specialize TStack<longint>;
+
+var data:stacklli; i:longint;
+
+begin
+  data:=stacklli.Create;
+  for i:=1 to 10 do
+    data.Push(10*i);
+  while not data.IsEmpty do begin
+    writeln(data.Top);
+    data.Pop;
+  end;
+
+  data.Destroy;
+end.

+ 9 - 0
packages/fcl-stl/doc/util.tex

@@ -0,0 +1,9 @@
+\chapter{TLess, TGreater}
+
+Comparators classes. Can be used in PriorityQueue and Sorting as comparator functions.
+TLess is used for ordering from smallest element to largest, TGreater is used for oposite ordering.
+
+%Usage example:
+
+%\lstinputlisting[language=Pascal]{queueexample.pp}
+

+ 73 - 0
packages/fcl-stl/doc/vector.tex

@@ -0,0 +1,73 @@
+\chapter{TVector}
+
+Implements selfresizing array. Indexing is 0-based.
+
+Usage example:
+
+\lstinputlisting[language=Pascal]{vectorexample.pp}
+
+Memory complexity:
+Uses at most 3times bigger memory than maximal array size (this is only case during reallocation).
+Normal consumption is at most twice as maximal array size.
+
+Members list:
+
+\begin{longtable}{|m{10cm}|m{5cm}|}
+\hline
+Method & Complexity guarantees \\ \hline
+\multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
+
+\verb!Create! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Constructor. Creates empty array.} \\ \hline\hline
+
+\verb!function Size(): SizeUInt! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns size of array.} \\\hline\hline
+
+\verb!procedure PushBack(value: T)! &  Amortized
+O(1), some operations might take O(N) time, when array needs to be reallocated, but sequence of N
+operations takes O(N) time \\ \hline
+\multicolumn{2}{|m{15cm}|}{Inserts at the end of array (increases size by 1)} \\\hline\hline
+
+\verb!procedure PopBack()! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Removes element from the end of array (decreases size by 1). When array
+is empty, does nothing.} \\\hline\hline
+
+\verb!function IsEmpty(): boolean! & O(1) \\ \hline
+\multicolumn{2}{|m{15cm}|}{Returns true when array is empty} \\\hline\hline
+
+\verb!procedure Insert(position: SizeUInt; value: T)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Inserts value at position. When position is greater than size, puts value
+at the end of array.} \\\hline\hline
+
+\verb!procedure Erase(positine: SizeUInt; value: T)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Erases element from position. When position is outside of array does
+nothing.} \\\hline\hline
+
+\verb!procedure Clear! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Clears array (set size to zero). But doesn't free memory used by array.}
+\\\hline\hline
+
+\verb!function Front: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns first element from array.} \\\hline\hline
+
+\verb!function Back: T! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns last element from array.} \\\hline\hline
+
+\verb!procedure Resize(num: SizeUInt)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Changes size of array to num. Doesn't guarantte anything about value of
+newly alocated elements.} \\\hline\hline
+
+\verb!procedure Reserve(num: SizeUInt)! & O(N) \\\hline
+\multicolumn{2}{|m{15cm}|}{Alocates at least num elements for array. Usefull when you want to
+pushback big number of elements and want to avoid frequent reallocation.} \\\hline\hline
+
+\verb!property item[i: SizeUInt]: T; default;! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Property for accessing i-th element in array. Can be used just by square
+brackets (its default property).} \\\hline\hline
+
+\verb!property mutable[i: SizeUInt]: T;! & O(1) \\\hline
+\multicolumn{2}{|m{15cm}|}{Returns pointer to i-th element in array. Usefull when you store records.} \\\hline
+
+
+
+\end{longtable}

+ 21 - 0
packages/fcl-stl/doc/vectorexample.pp

@@ -0,0 +1,21 @@
+uses gvector;
+
+type TVectorlli = specialize TVector<longint>;
+
+var Buffer:TVectorlli; i:longint;
+
+begin
+  Buffer := TVectorlli.Create;
+  {Push 5 elements at the end of array}
+  for i:=1 to 5 do
+    Buffer.PushBack(i);
+  {change 3rd element to 47}
+  Buffer[2] := 47;
+  {pop last element}
+  Buffer.PopBack;
+  {print all elements}
+  for i:=0 to Buffer.Size-1 do
+    writeln(Buffer[i]);
+
+  Buffer.Destroy;
+end.

+ 227 - 0
packages/fcl-stl/src/garrayutils.pp

@@ -0,0 +1,227 @@
+{
+   This file is part of the Free Pascal FCL library.
+   BSD parts (c) 2011 Vlado Boza
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY;without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+**********************************************************************}
+{$mode objfpc}
+
+unit garrayutils;
+
+interface
+
+const MaxDepth=60;
+const InsertSortThreshold=16;
+
+{TCompare is comparing class, which should have class method c(a,b:TValue):boolean, which returns true if a is less than b}
+type
+  generic TOrderingArrayUtils<TArr, Tvalue, TCompare>=class
+  private
+    class procedure Sortrange(var Arr:TArr; Start,Fin,d:SizeUInt);
+    class procedure HeapSort(var Arr:TArr; Start,Fin:SizeUInt);
+    class procedure InsertSort(var Arr:TArr; Start,Fin:SizeUInt);
+    class function Left(a:SizeUInt):SizeUInt;inline;
+    class function Right(a:SizeUInt):SizeUInt;inline;
+    class procedure Heapify(var Arr: TArr; Position:SizeUInt; Start,Fin:SizeUInt);
+    class function Parent(a:SizeUInt):SizeUInt;inline;
+  public
+    class procedure Sort(var Arr: TArr; size:SizeUInt);
+  end;
+
+  generic TArrayUtils<TArr, Tvalue>=class
+  public
+    class procedure RandomShuffle(Arr: TArr; size: SizeUInt);
+  end;
+
+implementation
+
+class function TOrderingArrayUtils.Left(a:SizeUInt):SizeUInt;inline;
+begin
+  Left:=((a+1)shl 1)-1;
+end;
+
+class function TOrderingArrayUtils.Right(a:SizeUInt):SizeUInt;inline;
+begin
+  Right:=(a+1) shl 1;
+end;
+
+class function TOrderingArrayUtils.Parent(a:SizeUInt):SizeUInt;inline;
+begin
+  Parent:=(a-1)shr 1;
+end;
+
+class procedure TOrderingArrayUtils.Heapify(var Arr: TArr; Position:SizeUInt; Start,Fin:SizeUInt);
+var mpos,l,r:SizeUInt; temp:TValue;
+begin
+  while(true) do 
+  begin
+    mpos:=Position;
+    l:=Left(Position-Start)+Start;
+    r:=Right(Position-Start)+Start;
+    if (l<Fin) AND (TCompare.c(Arr[mpos],Arr[l])) then
+      mpos:=l;
+    if (r<Fin) AND (TCompare.c(Arr[mpos],Arr[r])) then
+      mpos:=r;
+    if mpos = Position then break;
+    
+    temp:=Arr[Position];
+    Arr[Position]:=Arr[mpos];
+    Arr[mpos]:=temp;
+    Position:=mpos;
+  end;
+end;
+
+class procedure TOrderingArrayUtils.Sort(var Arr:TArr; size:SizeUInt);inline;
+begin
+  Sortrange(Arr,0,size,0);
+  InsertSort(Arr,0,size);
+end;
+
+class procedure TOrderingArrayUtils.Sortrange(var Arr:TArr; Start,Fin,d:SizeUInt);
+var pivot,temp:Tvalue; i,j,k,l:SizeUInt;
+begin
+  if (Fin-Start) <= InsertSortThreshold then
+  begin
+    InsertSort(Arr,Start,Fin);
+    exit;
+  end;
+  if d>=maxdepth then
+  begin
+    HeapSort(Arr, Start, Fin);
+    exit;
+  end;
+{median of 3} 
+  j:=Start;
+  k:=Fin-1;
+  l:=(Start+Fin)div 2;
+  if(TCompare.c(Arr[j],Arr[k])) and (TCompare.c(Arr[j],Arr[l])) then
+  begin
+    if(TCompare.c(Arr[k],Arr[l])) then
+    begin
+      temp:=Arr[k];
+      Arr[k]:=Arr[j];
+      Arr[j]:=temp;
+    end else 
+    begin
+      temp:=Arr[l];
+      Arr[l]:=Arr[j];
+      Arr[j]:=temp;
+    end;
+  end
+  else if(TCompare.c(Arr[k],Arr[j])) and (TCompare.c(Arr[l],Arr[j])) then
+  begin
+    if(TCompare.c(Arr[l],Arr[k])) then
+    begin
+      temp:=Arr[k];
+      Arr[k]:=Arr[j];
+      Arr[j]:=temp;
+    end else
+    begin
+      temp:=Arr[l];
+      Arr[l]:=Arr[j];
+      Arr[j]:=temp;
+    end;
+  end;
+
+{partition} 
+  pivot:=Arr[Start];
+
+  i:=Start-1;
+  j:=Fin;
+  repeat 
+    repeat
+      dec(j);
+    until (not (TCompare.c(pivot,Arr[j])));
+   
+    
+    repeat
+      inc(i);
+    until (not (TCompare.c(Arr[i],pivot)));
+    if(i < j) then
+    begin
+      temp:=Arr[i];
+      Arr[i]:=Arr[j];
+      Arr[j]:=temp;
+    end;
+  until (i>=j);
+
+  Sortrange(Arr, Start, j+1, d+1);
+  Sortrange(Arr, j+1, Fin, d+1);
+end;
+
+class procedure TOrderingArrayUtils.InsertSort(var Arr:TArr; Start,Fin:SizeUInt);inline;
+var i,j:SizeUInt; temp:Tvalue;
+begin
+  for i:=Start+1 to Fin-1 do
+  begin
+    j:=i;
+    temp:=Arr[i];
+    while (j>0) and (TCompare.c(temp,Arr[j-1])) do
+    begin
+      Arr[j]:=Arr[j-1];
+      dec(j);
+    end;
+    Arr[j]:=temp;
+  end;
+end;
+
+class procedure TOrderingArrayUtils.HeapSort(var Arr: TArr; Start,Fin:SizeUInt);
+var i,cur,next,l,r,size:SizeUInt; temp:Tvalue;
+begin
+{buildHeap}
+  size:=Fin-Start;
+  for i:=((size div 2)-1) downto 0 do 
+    Heapify(Arr, i+Start, Start, Fin);
+{bottomup HeapSort}
+  for i:=size-1 downto 1 do
+  begin
+    Fin:=Fin-1;
+    cur:=Start;
+    temp:=Arr[Start];
+    while(true) do
+    begin
+      l:=Left(cur-Start)+Start;
+      if l>=Fin then 
+        break;
+      next:=l;
+      r:=Right(cur-Start)+Start;
+      if (r<Fin) AND (TCompare.c(Arr[l],Arr[r])) then
+        next:=r;
+      Arr[cur]:=Arr[next];
+      cur:=next;
+    end;
+    Arr[cur]:=temp;
+    temp:=Arr[i+Start];
+    Arr[i+Start]:=Arr[cur];
+    Arr[cur]:=temp;
+    l:=Parent(cur-Start)+Start;
+    while (cur <> 0) AND (TCompare.c(Arr[l],Arr[cur])) do
+    begin
+      temp:=Arr[cur];
+      Arr[cur]:=Arr[l];
+      Arr[l]:=temp;
+      cur:=l;
+      l:=Parent(cur-Start)+Start;
+    end;
+  end;
+end;
+
+class procedure TArrayUtils.RandomShuffle(Arr: TArr; size: SizeUInt);
+var i,r:SizeUInt; temp:Tvalue;
+begin
+  for i:=size-1 downto 1 do begin
+    r:=random(Int64(i));
+    temp:=Arr[r];
+    Arr[r]:=Arr[i];
+    Arr[i]:=temp;
+  end;
+end;
+
+
+end.

+ 204 - 0
packages/fcl-stl/src/gdeque.pp

@@ -0,0 +1,204 @@
+{
+   This file is part of the Free Pascal FCL library.
+   BSD parts (c) 2011 Vlado Boza
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY;without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+**********************************************************************}
+{$mode objfpc}
+
+unit gdeque;
+
+interface
+
+type
+  generic TDeque<T>=class
+  private
+  type 
+    PT=^T;
+    TArr=array of T;
+  var 
+    FData:TArr;
+    FDataSize:SizeUInt;
+    FCapacity:SizeUInt;
+    FStart:SizeUInt;
+    procedure SetValue(position:SizeUInt; value:T);inline;
+    function GetValue(position:SizeUInt):T;inline;
+    function GetMutable(position:SizeUInt):PT;inline;
+    procedure IncreaseCapacity();inline;
+  public
+    function Size():SizeUInt;inline;
+    constructor Create();
+    procedure PushBack(value:T);inline;
+    procedure PushFront(value:T);inline;
+    procedure PopBack();inline;
+    procedure PopFront();inline;
+    function Front():T;inline;
+    function Back():T;inline;
+    function IsEmpty():boolean;inline;
+    procedure Reserve(cap:SizeUInt);inline;
+    procedure Resize(cap:SizeUInt);inline;
+    procedure Insert(Position:SizeUInt; Value:T);inline;
+    procedure Erase(Position:SIzeUInt);inline;
+    property Items[i : SizeUInt]: T read GetValue write SetValue; default;
+    property Mutable[i : SizeUInt]:PT read GetMutable;
+end;
+
+implementation
+
+constructor TDeque.Create();
+begin
+  FDataSize:=0;
+  FCapacity:=0;
+  FStart:=0;
+end;
+
+function TDeque.Size():SizeUInt;inline;
+begin
+  Size:=FDataSize;
+end;
+
+function TDeque.IsEmpty():boolean;inline;
+begin
+  if Size()=0 then 
+    IsEmpty:=true
+  else 
+    IsEmpty:=false;
+end;
+
+procedure TDeque.PushBack(value:T);inline;
+begin
+  if(FDataSize=FCapacity) then 
+    IncreaseCapacity;
+  FData[(FStart+FDataSize)mod FCapacity]:=value;
+  inc(FDataSize);
+end;
+
+procedure TDeque.PopFront();inline;
+begin
+  if(FDataSize>0) then 
+  begin
+    inc(FStart);
+    dec(FDataSize);
+    if(FStart=FCapacity) then 
+      FStart:=0;
+  end;
+end;
+
+procedure TDeque.PopBack();inline;
+begin
+  if(FDataSize>0) then
+    dec(FDataSize);
+end;
+
+procedure TDeque.PushFront(value:T);inline;
+begin
+  if(FDataSize=FCapacity) then
+    IncreaseCapacity;
+  if(FStart=0) then
+    FStart:=FCapacity-1
+  else
+    dec(FStart);
+  FData[FStart]:=value;
+  inc(FDataSize);
+end;
+
+function TDeque.Front():T;inline;
+begin
+  Assert(size > 0, 'Accessing empty deque');
+  Front:=FData[FStart];
+end;
+
+function TDeque.Back():T;inline;
+begin
+  Assert(size > 0, 'Accessing empty deque');
+  Back:=FData[(FStart+FDataSize-1)mod FCapacity];
+end;
+
+procedure TDeque.SetValue(position:SizeUInt; value:T);inline;
+begin
+  Assert(position < size, 'Deque access out of range');
+  FData[(FStart+position)mod FCapacity]:=value;
+end;
+
+function TDeque.GetValue(position:SizeUInt):T;inline;
+begin
+  Assert(position < size, 'Deque access out of range');
+  GetValue:=FData[(FStart+position) mod FCapacity];
+end;
+
+function TDeque.GetMutable(position:SizeUInt):PT;inline;
+begin
+  Assert(position < size, 'Deque access out of range');
+  GetMutable:=@FData[(FStart+position) mod FCapacity];
+end;
+
+procedure TDeque.IncreaseCapacity;inline;
+var i,OldEnd:SizeUInt;
+begin
+  OldEnd:=FCapacity;
+  if(FCapacity=0) then
+    FCapacity:=1
+  else
+    FCapacity:=FCapacity*2;
+  SetLength(FData, FCapacity);
+  if (FStart>0) then 
+    for i:=0 to FStart-1 do
+      FData[OldEnd+i]:=FData[i];
+end;
+
+procedure TDeque.Reserve(cap:SizeUInt);inline;
+var i,OldEnd:SizeUInt;
+begin
+  if(cap<FCapacity) then 
+    exit
+  else if(cap<=2*FCapacity) then 
+    IncreaseCapacity
+  else 
+  begin
+    OldEnd:=FCapacity;
+    FCapacity:=cap;
+    SetLength(FData, FCapacity);
+    if FStart > 0 then
+      for i:=0 to FStart-1 do
+        FData[OldEnd+i]:=FData[i];
+  end;
+end;
+
+procedure TDeque.Resize(cap:SizeUInt);inline;
+begin
+  Reserve(cap);
+  FDataSize:=cap;
+end;
+
+procedure TDeque.Insert(Position:SizeUInt; Value: T);inline;
+var i:SizeUInt;
+begin
+  pushBack(Value);
+  for i:=Size-1 downto Position+1 do 
+  begin
+    Items[i]:=Items[i-1];
+  end;
+  Items[Position]:=Value;
+end;
+
+procedure TDeque.Erase(Position:SizeUInt);inline;
+var i:SizeUInt;
+begin
+  if Position <= Size then 
+  begin
+    for i:=Position to Size-2 do
+    begin
+      Items[i]:=Items[i+1];
+    end;
+    popBack();
+  end;
+end;
+
+
+end.

+ 163 - 0
packages/fcl-stl/src/gmap.pp

@@ -0,0 +1,163 @@
+{
+   This file is part of the Free Pascal FCL library.
+   BSD parts (c) 2011 Vlado Boza
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY;without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+**********************************************************************}
+{$mode objfpc}
+
+unit gmap;
+
+interface
+
+uses gset;
+
+type
+  generic TMapCompare<TPair, TKeyCompare>=class
+    class function c(a,b :TPair):boolean;
+  end;
+
+  generic TMap<TKey, TValue, TCompare>=class
+  public
+  type
+    TPair=record
+      Key:TKey;
+      Value:TValue;
+    end;
+    TMCompare = specialize TMapCompare<TPair, TCompare>;
+    TMSet = specialize TSet<TPair, TMCompare>;
+    PTValue = ^TValue;
+    PTPair = ^TPair;
+  var
+  private
+    FSet:TMSet;
+  public
+    function Find(key:TKey):TMSet.PNode;inline;
+    function FindLess(key:TKey):TMSet.PNode;inline;
+    function FindLessEqual(key:TKey):TMSet.PNode;inline;
+    function FindGreater(key:TKey):TMSet.PNode;inline;
+    function FindGreaterEqual(key:TKey):TMSet.PNode;inline;
+    function GetValue(key:TKey):TValue;inline;
+    procedure Insert(key:TKey; value:TValue);inline;
+    function Min:TMSet.PNode;inline;
+    function Max:TMSet.PNode;inline;
+    function Next(x:TMSet.PNode):TMSet.PNode;inline;
+    function Prev(x:TMSet.PNode):TMSet.PNode;inline;
+    procedure Delete(key:TKey);inline;
+    function Size:SizeUInt;inline;
+    function IsEmpty:boolean;inline;
+    constructor Create;
+    destructor Destroy;override;
+    property Items[i : TKey]: TValue read GetValue write Insert; default;
+  end;
+
+implementation
+
+class function TMapCompare.c(a,b: TPair):boolean;
+begin
+  c:= TKeyCompare.c(a.Key, b.Key);
+end;
+
+constructor TMap.Create;
+begin
+  FSet:=TMSet.Create;
+end;
+
+destructor TMap.Destroy;
+begin
+  FSet.Destroy;
+end;
+
+procedure TMap.Delete(key:TKey);inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  FSet.Delete(Pair);
+end;
+
+function TMap.Find(key:TKey):TMSet.PNode;inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  Find:=FSet.Find(Pair);
+end;
+
+function TMap.FindLess(key:TKey):TMSet.PNode;inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  FindLess:=FSet.FindLess(Pair);
+end;
+
+function TMap.FindLessEqual(key:TKey):TMSet.PNode;inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  FindLessEqual:=FSet.FindLessEqual(Pair);
+end;
+
+function TMap.FindGreater(key:TKey):TMSet.PNode;inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  FindGreater:=FSet.FindGreater(Pair);
+end;
+
+function TMap.FindGreaterEqual(key:TKey):TMSet.PNode;inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  FindGreaterEqual:=FSet.FindGreaterEqual(Pair);
+end;
+
+function TMap.GetValue(key:TKey):TValue;inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  GetValue:=FSet.Find(Pair)^.Data.Value;
+end;
+
+procedure TMap.Insert(key:TKey; value:TValue);inline;
+var Pair:TPair;
+begin
+  Pair.Key:=key;
+  FSet.Insert(Pair)^.Data.Value := value;
+end;
+
+function TMap.Min:TMSet.PNode;inline;
+begin
+  Min:=FSet.Min;
+end;
+
+function TMap.Max:TMSet.PNode;inline;
+begin
+  Max:=FSet.Max;
+end;
+
+function TMap.Next(x:TMSet.PNode):TMSet.PNode;inline;
+begin
+  Next:=FSet.Next(x);
+end;
+
+function TMap.Prev(x:TMSet.PNode):TMSet.PNode;inline;
+begin
+  Prev:=FSet.Prev(x);
+end;
+
+function TMap.Size:SizeUInt;inline;
+begin
+  Size:=FSet.Size;
+end;
+
+function TMap.IsEmpty:boolean;inline;
+begin
+  IsEmpty:=FSet.IsEmpty;
+end;
+
+end.

+ 141 - 0
packages/fcl-stl/src/gpriorityqueue.pp

@@ -0,0 +1,141 @@
+{
+   This file is part of the Free Pascal FCL library.
+   BSD parts (c) 2011 Vlado Boza
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY;without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+**********************************************************************}
+{$mode objfpc}
+
+unit gpriorityqueue;
+
+interface 
+
+uses gvector;
+
+{TCompare is comparing class, which should have class method c(a,b:T):boolean, which returns true is a is less than b}
+
+type 
+  generic TPriorityQueue<T, TCompare>=class
+  private
+  type 
+    TContainer=specialize TVector<T>;
+  var
+    FData:TContainer;
+    
+    procedure PushUp(position:SizeUInt);
+    function Left(a:SizeUInt):SizeUInt;inline;
+    function Right(a:SizeUInt):SizeUInt;inline;
+    procedure Heapify(position:SizeUInt);
+    function Parent(a:SizeUInt):SizeUInt;inline;
+  public
+    constructor Create;
+    destructor Destroy;override;
+    function Top:T;inline;
+    procedure Pop;inline;
+    procedure Push(value:T);inline;
+    function Size:SizeUInt;inline;
+    function IsEmpty:boolean;inline;
+  end;
+
+implementation
+
+constructor TPriorityQueue.Create;
+begin
+  FData:=TContainer.Create;
+end;
+
+destructor TPriorityQueue.Destroy;
+begin;
+  FData.Destroy;
+end;
+
+function TPriorityQueue.Size:SizeUInt;inline;
+begin
+  Size:=FData.Size;
+end;
+
+function TPriorityQueue.IsEmpty:boolean;inline;
+begin
+  IsEmpty:=FData.Size=0;
+end;
+
+function TPriorityQueue.Top:T;inline;
+begin
+  Top:=FData[0];
+end;
+
+procedure TPriorityQueue.Pop;inline;
+begin
+  if not IsEmpty then begin
+    FData[0]:=FData.back;
+    FData.PopBack;
+    Heapify(0);
+  end;
+end;
+
+procedure TPriorityQueue.PushUp(position:SizeUInt);
+var np:SizeUInt; temp:T;
+begin
+  while(position>0) do
+  begin
+    np := Parent(position);
+    if(TCompare.c(FData[np],FData[position])) then
+    begin
+      temp:=FData[np];
+      FData[np]:=FData[position];
+      FData[position]:=temp;
+      position:=np;
+    end else
+      break;
+  end;
+end;
+
+procedure TPriorityQueue.Push(value:T);inline;
+begin
+  FData.PushBack(value);
+  PushUp(FData.Size-1);
+end;
+
+function TPriorityQueue.Left(a:SizeUInt):SizeUInt;inline;
+begin
+  Left:=((a+1)shl 1)-1;
+end;
+
+function TPriorityQueue.Right(a:SizeUInt):SizeUInt;inline;
+begin
+  Right:=(a+1) shl 1;
+end;
+
+function TPriorityQueue.Parent(a:SizeUInt):SizeUInt;inline;
+begin
+  Parent:=(a-1)shr 1;
+end;
+
+procedure TPriorityQueue.Heapify(position:SizeUInt);
+var mpos,l,r:SizeUInt; temp:T;
+begin
+  while(true) do
+  begin
+    mpos:=position;
+    l:=Left(position);
+    r:=Right(position);
+    if (l<FData.Size) AND (TCompare.c(FData[mpos],FData[l])) then
+      mpos:=l;
+    if (r<FData.Size) AND (TCompare.c(FData[mpos],FData[r])) then
+      mpos:=r;
+    if mpos = position then break;
+
+    temp:=FData[position];
+    FData[position]:=FData[mpos];
+    FData[mpos]:=temp;
+    position:=mpos;
+  end;
+end;
+
+end.

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio