From 4cc6dc518d5d841ac36b0ebb8852f59735f825af Mon Sep 17 00:00:00 2001
From: John <no@email.com.invalid>
Date: Fri, 27 Sep 2013 21:50:38 +0200
Subject: [PATCH 1/3] Added include file for FPC.

---
 jcl/source/include/jclfpc.inc | 141 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 141 insertions(+)
 create mode 100644 jcl/source/include/jclfpc.inc

diff --git a/jcl/source/include/jclfpc.inc b/jcl/source/include/jclfpc.inc
new file mode 100644
index 0000000..d84301c
--- /dev/null
+++ b/jcl/source/include/jclfpc.inc
@@ -0,0 +1,141 @@
+{**************************************************************************************************}
+{                                                                                                  }
+{ Project JEDI Code Library (JCL)                                                                  }
+{                                                                                                  }
+{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
+{ you may not use this file except in compliance with the License. You may obtain a copy of the    }
+{ License at http://www.mozilla.org/MPL/                                                           }
+{                                                                                                  }
+{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF   }
+{ ANY KIND, either express or implied. See the License for the specific language governing rights  }
+{ and limitations under the License.                                                               }
+{                                                                                                  }
+{ The Original Code is jcl.inc                                                                     }
+{                                                                                                  }
+{ The Initial Developer of the Original Code is Marcel van Brakel.                                 }
+{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel.                       }
+{                                                                                                  }
+{ Contributors:                                                                                    }
+{   Marcel van Brakel                                                                              }
+{   Matthias Thoma (mthoma)                                                                        }
+{   Petr Vones                                                                                     }
+{   Robert Marquardt (marquardt)                                                                   }
+{   Robert Rossmair (rrossmair)                                                                    }
+{   Florent Ouchet (outchy)                                                                        }
+{                                                                                                  }
+{**************************************************************************************************}
+{                                                                                                  }
+{ This include file defines various JCL specific defines.                                          }
+{ The more generic JCL defines are defined in jcl.inc and the generic defines in the jedi.inc file }
+{ which is shared with the JEDI VCL.                                                               }
+{                                                                                                  }
+{**************************************************************************************************}
+{                                                                                                  }
+{ This file is filled by the JCL installer, all the changes made in its content will be lost the   }
+{ next time the JCL is installed.                                                                  }
+{                                                                                                  }
+{**************************************************************************************************}
+
+// $Id: jcl.template.inc 3855 2012-09-02 22:25:26Z outchy $
+
+// Math precision selection, mutually exclusive
+// FPC does not support EXTENDED when targetting x86_64, MATH_DOUBLE_PRECISION is the default in this situation
+{.$DEFINE MATH_EXTENDED_PRECISION} // default
+{.$DEFINE MATH_DOUBLE_PRECISION}
+{.$DEFINE MATH_SINGLE_PRECISION}
+
+
+// Math functions takes care of infinites and NaN
+{.$DEFINE MATH_EXT_EXTREMEVALUES}
+
+
+// JclHookExcept support for hooking exceptions from DLLs
+{.$DEFINE HOOK_DLL_EXCEPTIONS}
+
+
+//Threadsafe directive
+{.$DEFINE THREADSAFE}
+
+
+// To exclude obsolete code from compilation, remove the point from the line below
+{.$DEFINE DROP_OBSOLETE_CODE}
+
+
+//Support for JclUnitVersioning.pas, not supported by Delphi 2005 (automatically disabled afterward)
+{.$DEFINE UNITVERSIONING}
+
+
+// debug sources
+// defining these symbols will the debug source to be automatically registered
+{.$DEFINE DEBUG_NO_BINARY}
+{.$DEFINE DEBUG_NO_TD32}     // automatically defined for FPC
+{.$DEFINE DEBUG_NO_MAP}
+{.$DEFINE DEBUG_NO_EXPORTS}
+{.$DEFINE DEBUG_NO_SYMBOLS}
+
+
+// PCRE options, mutually exclusive
+// IMPORTANT: The static link works only for Delphi 2005 and newer
+//            (an internal error is raised on other compilers)
+// Only one of the following defines can be defined at a time
+//   static link: PCRE_STATICLINK
+//   static dll import: PCRE_LINKDLL
+//   dynamic dll import: PCRE_LINKONREQUEST
+//   RTL's RegularExpressionsAPI: PCRE_RTL
+
+{.$DEFINE PCRE_STATICLINK}
+{.$DEFINE PCRE_LINKDLL}
+{.$DEFINE PCRE_LINKONREQUEST} // default
+{.$DEFINE PCRE_RTL} // DXE and newer
+
+// ANSI/UTF8 PCRE
+{$DEFINE PCRE_8}
+// UCS2/UTF16 enabled PCRE
+{$DEFINE PCRE_16} // only valid when PCRE_STATICLINK is enabled, the RTL does not support it and the DLL found over the internet are completly outdated.
+
+// use PCRE16 when available rather than good old PCRE8
+{$DEFINE PCRE_PREFER_16}
+
+// BZIP2 options, mutually exclusive
+
+{.$DEFINE BZIP2_STATICLINK} // default
+{.$DEFINE BZIP2_LINKDLL}
+{$DEFINE BZIP2_LINKONREQUEST}
+
+
+// ZLIB options, mutually exclusive
+
+{.$DEFINE ZLIB_STATICLINK} // default
+{.$DEFINE ZLIB_LINKDLL}
+{$DEFINE ZLIB_LINKONREQUEST}
+{.$DEFINE ZLIB_RTL} // DXE2 and newer only
+
+
+// Unicode options
+// use RTL Character Database rather than JCL one, less accurate but reduce executable size
+{.$DEFINE UNICODE_RTL_DATABASE}
+
+// insert a replacement character if sequence is corrupted rather than raising an exception
+{.$DEFINE UNICODE_SILENT_FAILURE}
+
+// defines resource compression (uncompressed, compressed with ZLib, compressed with BZip2), mutually exclusive
+{.$DEFINE UNICODE_RAW_DATA} // default
+{.$DEFINE UNICODE_ZLIB_DATA}
+{.$DEFINE UNICODE_BZIP2_DATA}
+
+
+// container options
+// define mapping of TJclStr* containers to TJclAnsiStr* or TJclWideStr* (mutually exclusive)
+{.$DEFINE CONTAINER_ANSISTR} // default for D2007 and older
+{.$DEFINE CONTAINER_WIDESTR}
+{.$DEFINE CONTAINER_UNICODESTR} // default for D2009 and newer, not supported for Delphi 2007 and older
+{.$DEFINE CONTAINER_NOSTR}
+
+
+// 7Zip options, mutually exclusive
+// IMPORTANT: The static link is not supported yet
+
+{.$DEFINE 7ZIP_STATICLINK} // not supported yet
+{.$DEFINE 7ZIP_LINKDLL}
+{.$DEFINE 7ZIP_LINKONREQUEST} // default
+
-- 
1.8.3.msysgit.0


From 9a057d7c846e0ae5eaf045d3e75fc11bdcb67c5a Mon Sep 17 00:00:00 2001
From: John <no@email.com.invalid>
Date: Sat, 28 Sep 2013 01:15:32 +0200
Subject: [PATCH 2/3] Updated files for FPC trunk.

---
 jcl/packages/fpc/Jcl.lpk             | 25 +++++++++++++------------
 jcl/source/common/JclAnsiStrings.pas |  4 ++--
 jcl/source/common/JclDateTime.pas    |  2 +-
 jcl/source/common/JclMIDI.pas        |  8 ++++++++
 jcl/source/common/JclRTTI.pas        |  4 ++--
 jcl/source/common/JclStrings.pas     |  4 ++--
 6 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/jcl/packages/fpc/Jcl.lpk b/jcl/packages/fpc/Jcl.lpk
index ac82ee0..e88a192 100644
--- a/jcl/packages/fpc/Jcl.lpk
+++ b/jcl/packages/fpc/Jcl.lpk
@@ -1,17 +1,16 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
-  <Package Version="3">
+  <Package Version="4">
     <PathDelim Value="\"/>
     <Name Value="Jcl"/>
-    <AddToProjectUsesSection Value="False"/>
     <Author Value="Project JEDI"/>
     <AutoUpdate Value="OnRebuildingAll"/>
     <CompilerOptions>
-      <Version Value="9"/>
+      <Version Value="11"/>
       <PathDelim Value="\"/>
       <SearchPaths>
-        <IncludeFiles Value="..\..\source\include\"/>
-        <OtherUnitFiles Value=".;..\..\source\common;..\..\source\windows;;..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
+        <IncludeFiles Value="..\..\source\include"/>
+        <OtherUnitFiles Value=".;..\..\source\common;..\..\source\windows;..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
         <UnitOutputDirectory Value="..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
       </SearchPaths>
       <Parsing>
@@ -24,22 +23,24 @@
       </Parsing>
       <CodeGeneration>
         <Optimizations>
+          <OptimizationLevel Value="0"/>
           <VariablesInRegisters Value="True"/>
-          <OptimizationLevel Value="3"/>
         </Optimizations>
       </CodeGeneration>
       <Linking>
         <Debugging>
+          <DebugInfoType Value="dsDwarf2Set"/>
           <UseLineInfoUnit Value="False"/>
         </Debugging>
       </Linking>
       <Other>
+        <CustomOptions Value="$(IDEBuildOptions)"/>
         <CompilerPath Value="$(CompPath)"/>
       </Other>
     </CompilerOptions>
     <Description Value="JEDI Code Library RTL package"/>
     <License Value="Copyright (C) 1999, 2013 Project JEDI"/>
-    <Version Major="2" Minor="5" Release="0" Build="4572"/>
+    <Version Major="2" Minor="5" Build="4572"/>
     <Files Count="74">
       <Item1>
         <Filename Value="..\..\source\common\bzip2.pas"/>
@@ -344,10 +345,10 @@
       </Item1>
     </RequiredPkgs>
     <UsageOptions>
-      <IncludePath Value="..\..\source\include\"/>
-      <LibraryPath Value="$(PkgOutDir)\"/>
-      <ObjectPath Value="..\..\lib\fpc\$(TargetCPU)-$(TargetOS)\"/>
-      <UnitPath Value="$(PkgOutDir)\"/>
+      <IncludePath Value="..\..\source\include"/>
+      <LibraryPath Value="$(PkgOutDir)"/>
+      <ObjectPath Value="..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
+      <UnitPath Value="$(PkgOutDir)"/>
     </UsageOptions>
     <PublishOptions>
       <Version Value="2"/>
diff --git a/jcl/source/common/JclAnsiStrings.pas b/jcl/source/common/JclAnsiStrings.pas
index 4995ba8..2458d13 100644
--- a/jcl/source/common/JclAnsiStrings.pas
+++ b/jcl/source/common/JclAnsiStrings.pas
@@ -518,8 +518,8 @@ procedure StrNormIndex(const StrLen: SizeInt; var Index: SizeInt; var Count: Siz
 
 function ArrayOf(List: TJclAnsiStrings): TDynStringArray; overload;
 
-function AnsiCompareNaturalStr(const S1, S2: AnsiString): SizeInt;
-function AnsiCompareNaturalText(const S1, S2: AnsiString): SizeInt;
+function AnsiCompareNaturalStr(const S1, S2: AnsiString): SizeInt;overload;
+function AnsiCompareNaturalText(const S1, S2: AnsiString): SizeInt;overload;
 
 // Explicit ANSI version of former/deprecated SysUtils PAnsiChar functions
 {$IFNDEF DEPRECATED_SYSUTILS_ANSISTRINGS}
diff --git a/jcl/source/common/JclDateTime.pas b/jcl/source/common/JclDateTime.pas
index d65951b..7971b3f 100644
--- a/jcl/source/common/JclDateTime.pas
+++ b/jcl/source/common/JclDateTime.pas
@@ -87,7 +87,7 @@ const
 
 { Encode / Decode functions }
 
-function EncodeDate(const Year: Integer; Month, Day: Word): TDateTime;
+function EncodeDate(const Year: Integer; Month, Day: Word): TDateTime;overload;
 procedure DecodeDate(Date: TDateTime; out Year, Month, Day: Word); overload;
 procedure DecodeDate(Date: TDateTime; out Year: Integer; out Month, Day: Word); overload;
 procedure DecodeDate(Date: TDateTime; out Year, Month, Day: Integer); overload;
diff --git a/jcl/source/common/JclMIDI.pas b/jcl/source/common/JclMIDI.pas
index 52f8cb6..7877e9e 100644
--- a/jcl/source/common/JclMIDI.pas
+++ b/jcl/source/common/JclMIDI.pas
@@ -595,8 +595,16 @@ end;
 
 procedure TJclMIDIOut.SetRunningStatusEnabled(const Value: Boolean);
 begin
+  {$IFOPT R+}
+    {$DEFINE RANGE_CHECK_OFF}
+    {$R-}
+  {$ENDIF}
   FMIDIStatus := MIDIInvalidStatus;
   FRunningStatusEnabled := Value;
+  {$IFDEF RANGE_CHECK_OFF}
+     {$UNDEF RANGE_CHECK_OFF}
+     {$R+}
+  {$ENDIF}
 end;
 
 procedure TJclMIDIOut.SendSingleNoteTuningChange(const TargetDeviceID, TuningProgramNum: TMidiDataByte;
diff --git a/jcl/source/common/JclRTTI.pas b/jcl/source/common/JclRTTI.pas
index 9fa98f8..3a31a40 100644
--- a/jcl/source/common/JclRTTI.pas
+++ b/jcl/source/common/JclRTTI.pas
@@ -2223,12 +2223,12 @@ begin
   if TypeData.elType = nil then
   begin
     if TypeData.elType2 <> nil then
-      Result := JclTypeInfo(TypeData.elType2^)
+      Result := JclTypeInfo(TypeData.elType2{$IFNDEF FPC}^{$ENDIF})
     else
       Result := nil;
   end
   else
-    Result := JclTypeInfo(TypeData.elType^);
+    Result := JclTypeInfo(TypeData.elType{$IFNDEF FPC}^{$ENDIF});
 end;
 
 function TJclDynArrayTypeInfo.GetElementsNeedCleanup: Boolean;
diff --git a/jcl/source/common/JclStrings.pas b/jcl/source/common/JclStrings.pas
index 5ac85a8..99c8ec4 100644
--- a/jcl/source/common/JclStrings.pas
+++ b/jcl/source/common/JclStrings.pas
@@ -604,8 +604,8 @@ procedure StrResetLength(var S: UnicodeString); overload;
 {$ENDIF SUPPORTS_UNICODE_STRING}
 
 // natural comparison functions
-function CompareNaturalStr(const S1, S2: string): SizeInt;
-function CompareNaturalText(const S1, S2: string): SizeInt;
+function CompareNaturalStr(const S1, S2: string): SizeInt;overload;
+function CompareNaturalText(const S1, S2: string): SizeInt;overload;
 
 {$IFNDEF UNICODE_RTL_DATABASE}
 // internal structures published to make function inlining working
-- 
1.8.3.msysgit.0


From deb83a50c5dff661668a9d1aa16572856eadc269 Mon Sep 17 00:00:00 2001
From: John <no@email.com.invalid>
Date: Sat, 28 Sep 2013 01:23:56 +0200
Subject: [PATCH 3/3] More updates.

---
 .gitignore                                  |  2 ++
 jcl/packages/fpc/JclContainers.lpk          | 25 +++++++++++++------------
 jcl/source/common/JclAbstractContainers.pas |  8 ++++----
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3bafce3..bf1702d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,3 +48,5 @@ jcl/source/include/jclwin32.inc
 # InnoSetup installer
 thirdparty/InnoSetup/setupbuild/*
 thirdparty/InnoSetup/Settings.iss
+/jcl/lib/fpc/i386-win32
+*.bak
diff --git a/jcl/packages/fpc/JclContainers.lpk b/jcl/packages/fpc/JclContainers.lpk
index d90153b..af6046b 100644
--- a/jcl/packages/fpc/JclContainers.lpk
+++ b/jcl/packages/fpc/JclContainers.lpk
@@ -1,17 +1,16 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
-  <Package Version="3">
+  <Package Version="4">
     <PathDelim Value="\"/>
     <Name Value="JclContainers"/>
-    <AddToProjectUsesSection Value="False"/>
     <Author Value="Project JEDI"/>
     <AutoUpdate Value="OnRebuildingAll"/>
     <CompilerOptions>
-      <Version Value="9"/>
+      <Version Value="11"/>
       <PathDelim Value="\"/>
       <SearchPaths>
-        <IncludeFiles Value="..\..\source\include\"/>
-        <OtherUnitFiles Value=".;..\..\source\common;;..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
+        <IncludeFiles Value="..\..\source\include"/>
+        <OtherUnitFiles Value=".;..\..\source\common;..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
         <UnitOutputDirectory Value="..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
       </SearchPaths>
       <Parsing>
@@ -24,22 +23,24 @@
       </Parsing>
       <CodeGeneration>
         <Optimizations>
+          <OptimizationLevel Value="0"/>
           <VariablesInRegisters Value="True"/>
-          <OptimizationLevel Value="3"/>
         </Optimizations>
       </CodeGeneration>
       <Linking>
         <Debugging>
+          <DebugInfoType Value="dsDwarf2Set"/>
           <UseLineInfoUnit Value="False"/>
         </Debugging>
       </Linking>
       <Other>
+        <CustomOptions Value="$(IDEBuildOptions)"/>
         <CompilerPath Value="$(CompPath)"/>
       </Other>
     </CompilerOptions>
     <Description Value="JEDI Code Library Containers package"/>
     <License Value="Copyright (C) 1999, 2013 Project JEDI"/>
-    <Version Major="2" Minor="5" Release="0" Build="4572"/>
+    <Version Major="2" Minor="5" Build="4572"/>
     <Files Count="15">
       <Item1>
         <Filename Value="..\..\source\common\JclAbstractContainers.pas"/>
@@ -111,10 +112,10 @@
       </Item2>
     </RequiredPkgs>
     <UsageOptions>
-      <IncludePath Value="..\..\source\include\"/>
-      <LibraryPath Value="$(PkgOutDir)\"/>
-      <ObjectPath Value="..\..\lib\fpc\$(TargetCPU)-$(TargetOS)\"/>
-      <UnitPath Value="$(PkgOutDir)\"/>
+      <IncludePath Value="..\..\source\include"/>
+      <LibraryPath Value="$(PkgOutDir)"/>
+      <ObjectPath Value="..\..\lib\fpc\$(TargetCPU)-$(TargetOS)"/>
+      <UnitPath Value="$(PkgOutDir)"/>
     </UsageOptions>
     <PublishOptions>
       <Version Value="2"/>
diff --git a/jcl/source/common/JclAbstractContainers.pas b/jcl/source/common/JclAbstractContainers.pas
index 817bc0a..0979728 100644
--- a/jcl/source/common/JclAbstractContainers.pas
+++ b/jcl/source/common/JclAbstractContainers.pas
@@ -1374,12 +1374,12 @@ begin
   else
   begin
     case FEncoding of
-      seISO:
+      JclContainerIntf.seISO:
         if FCaseSensitive then
           Result := AnsiStrSimpleHashConvert(AString)
         else
           Result := AnsiStrSimpleHashConvertI(AString);
-      seUTF8:
+      JclContainerIntf.seUTF8:
         if FCaseSensitive then
           Result := AnsiStrSimpleHashConvertU(AString)
         else
@@ -1397,7 +1397,7 @@ begin
   else
   begin
     case FEncoding of
-      seISO, seUTF8:
+      JclContainerIntf.seISO, JclContainerIntf.seUTF8:
         if FCaseSensitive then
           Result := AnsiStrSimpleCompare(A, B)
         else
@@ -1418,7 +1418,7 @@ begin
   else
   begin
     case FEncoding of
-      seISO, seUTF8:
+      JclContainerIntf.seISO, JclContainerIntf.seUTF8:
         if FCaseSensitive then
           Result := AnsiStrSimpleEqualityCompare(A, B)
         else
-- 
1.8.3.msysgit.0

