[fpc-pascal] download site and mixed http

2024-04-25 Thread Mattias Gaertner via fpc-pascal

Hi,

On
https://www.freepascal.org/down/x86_64/linux-hungary.html

are links without "https://;, causing the browser to bark:

"File not downloaded: Potential security risk".

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] class constructor exception

2024-04-23 Thread Mattias Gaertner via fpc-pascal




On 23.04.24 09:32, Andrey Zubarev via fpc-pascal wrote:

Hi,

Set ExceptProc to your handler in unit initialization section in unit
usesed before the problematic one?


It is set by lcl TApplication.

Just found out: It works with other exceptions, but not with EAbort.
And that indeed creates a silent exception.

I will talk to the lib developers...

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] class constructor exception

2024-04-22 Thread Mattias Gaertner via fpc-pascal

Hi,

When an exception is raised in a class constructor the application 
aborts without any error.


How can I get an error?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc-pascal Digest, Vol 236, Issue 35

2024-03-01 Thread Mattias Gaertner via fpc-pascal




On 29.02.24 19:21, Jos Wegman via fpc-pascal wrote:

The packages for the Lazarus mac OS x86-64  Lazarus 3.2 on sourceforge are
not correct. There is no compiler package. Instead there are two fpc src
packages. Just a heads-up.


Thanks for the hint. I uploaded the package.

Mattias





Op do 29 feb 2024 12:00 schreef :


Send fpc-pascal mailing list submissions to
 fpc-pascal@lists.freepascal.org

To subscribe or unsubscribe via the World Wide Web, visit
 https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
or, via email, send a message with subject or body 'help' to
 fpc-pascal-requ...@lists.freepascal.org

You can reach the person managing the list at
 fpc-pascal-ow...@lists.freepascal.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fpc-pascal digest..."


Today's Topics:

1.  Lazarus Bugfix Release 3.2 (Mattias Gaertner)


--

Message: 1
Date: Wed, 28 Feb 2024 16:33:11 +0100
From: Mattias Gaertner 
To: fpc-pascal@lists.freepascal.org
Subject: [fpc-pascal] Lazarus Bugfix Release 3.2
Message-ID: 
Content-Type: text/plain; charset=UTF-8; format=flowed

The Lazarus team is glad to announce the release of Lazarus 3.2.

This is a bugfix release and was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_3.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 3.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_3_0/

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 3.2" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#3_2

Minimum requirements:

Windows:
2k, 32 or 64bit, Qt, Qt5, Qt6 (64bit only)

FreeBSD/Linux:
gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, Qt6.2 for qt6, 32 or
64bit.

Mac OS X:
Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, Qt and Qt5 (32 or
64bit), Qt6 (64bit only).

Note: Since Macos Sonoma 14 debugging takes some time to start the
application, especially on first start.


Mattias


--

Subject: Digest Footer

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


--

End of fpc-pascal Digest, Vol 236, Issue 35
***




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Bugfix Release 3.2

2024-02-28 Thread Mattias Gaertner via fpc-pascal

The Lazarus team is glad to announce the release of Lazarus 3.2.

This is a bugfix release and was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_3.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 3.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_3_0/

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 3.2" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#3_2

Minimum requirements:

Windows:
  2k, 32 or 64bit, Qt, Qt5, Qt6 (64bit only)

FreeBSD/Linux:
  gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, Qt6.2 for qt6, 32 or 
64bit.


Mac OS X:
  Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, Qt and Qt5 (32 or 
64bit), Qt6 (64bit only).


Note: Since Macos Sonoma 14 debugging takes some time to start the 
application, especially on first start.



Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 3.0

2023-12-21 Thread Mattias Gaertner via fpc-pascal

The Lazarus team is glad to announce the release of Lazarus 3.0.

This release was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_3.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 3.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_3_0/

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 3.0" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#3_0

Minimum requirements:

Windows:
  2k, 32 or 64bit, Qt, Qt5, Qt6 (64bit only)

FreeBSD/Linux:
  gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, Qt6.2 for qt6, 32 or 
64bit.


Mac OS X:
  Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, Qt and Qt5 (32 or 
64bit), Qt6 (64bit only).


There is a problem on Macos. When upgrading from Ventura to Sonoma 13.6, 
debugging in the IDE often does not work, the app does not start. 
Running the app without debugging and debugging in the Terminal using 
lldb does work.

Once a solution is found I will upload a new Lazarus pkg for Macos.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] method-definition

2023-12-15 Thread Mattias Gaertner via fpc-pascal



On 15.12.23 16:00, Martin Frb via fpc-pascal wrote:
[...] 
However, a method can be reintroduced, and be virtual/abstract.


type
   TFoo = class
     procedure Bar; virtual; abstract;
   end;

   TFoo2 = class(TFoo)
     procedure Bar; reintroduce; virtual; abstract;
   end;


Can that make sense?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-pdf custom font from memstream

2023-11-02 Thread Mattias Gaertner via fpc-pascal



On 02.11.23 16:42, Mattias Gaertner via fpc-pascal wrote:



On 02.11.23 14:00, Michael Van Canneyt via fpc-pascal wrote:



On Thu, 2 Nov 2023, Alexey Torgashin via fpc-pascal wrote:




How to load a custom font from a stream instead of from a file?


Currently no way to my knowledge,


But fpparsettf.pp has this:

 TTFFileInfo = class(TObject)
 ...
 public
   // Load a TTF file from file or stream.
   Procedure LoadFromFile(const AFileName : String);
   Procedure LoadFromStream(AStream: TStream); virtual;


Yes, but the font cache/manager in fpttf does not support this, and 
all font access happens
through the font cache. (at least that is how I understood Mattias' 
request)


Yes. I added two functions and extended the example.

To my surprise it turns out that a ttf file is loaded up to 3 times:
Once for AddFont, once for gTTFontCache and once in SaveDocument.

SaveDocument now uses the TPDFFont stream if available, so only 2 times.


s/SaveDocument/TPDFDictionary.WriteDictionary/



Wouldn't it be better if TPDFDocument.Fonts and gTTFontCache share the 
stream?



Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-pdf custom font from memstream

2023-11-02 Thread Mattias Gaertner via fpc-pascal




On 02.11.23 16:58, Michael Van Canneyt via fpc-pascal wrote:

[...]
Yes, absolutely.

But we may need a ref. counting mechanism then. Or at least we need to
decide who 'owns' the streams; At first sight it seems to me the 
gTTFontCache should own all font streams.


Yes.
On second thought, maybe better share the TTFFileInfo?

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-pdf custom font from memstream

2023-11-02 Thread Mattias Gaertner via fpc-pascal



On 02.11.23 14:00, Michael Van Canneyt via fpc-pascal wrote:



On Thu, 2 Nov 2023, Alexey Torgashin via fpc-pascal wrote:




How to load a custom font from a stream instead of from a file?


Currently no way to my knowledge,


But fpparsettf.pp has this:

 TTFFileInfo = class(TObject)
 ...
 public
   // Load a TTF file from file or stream.
   Procedure LoadFromFile(const AFileName : String);
   Procedure LoadFromStream(AStream: TStream); virtual;


Yes, but the font cache/manager in fpttf does not support this, and all 
font access happens
through the font cache. (at least that is how I understood Mattias' 
request)


Yes. I added two functions and extended the example.

To my surprise it turns out that a ttf file is loaded up to 3 times:
Once for AddFont, once for gTTFontCache and once in SaveDocument.

SaveDocument now uses the TPDFFont stream if available, so only 2 times.

Wouldn't it be better if TPDFDocument.Fonts and gTTFontCache share the 
stream?



Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-pdf custom font from memstream

2023-11-02 Thread Mattias Gaertner via fpc-pascal



On 02.11.23 13:38, Alexey Torgashin via fpc-pascal wrote:



How to load a custom font from a stream instead of from a file?


Currently no way to my knowledge,


But fpparsettf.pp has this:

   TTFFileInfo = class(TObject)
   ...
   public
     // Load a TTF file from file or stream.
     Procedure LoadFromFile(const AFileName : String);
     Procedure LoadFromStream(AStream: TStream); virtual;


Yes, but that is only one piece of the puzzle.

I will add the rest.

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] fcl-pdf custom font from memstream

2023-11-02 Thread Mattias Gaertner via fpc-pascal

Hi,

How to load a custom font from a stream instead of from a file?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release Candidate 2 of 3.0

2023-10-16 Thread Mattias Gaertner via fpc-pascal



The Lazarus team is glad to announce the second release candidate of 
Lazarus 3.0.


This release was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_3.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 3.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_3_0/

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 3.0RC2" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#3_0RC2

Minimum requirements:

Windows:
  2k, 32 or 64bit, Qt, Qt5, Qt6 (64bit only)

FreeBSD/Linux:
  gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, Qt6.2 for qt6, 32 or 
64bit.


Mac OS X:
  Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, Qt and Qt5 (32 or 
64bit), Qt6 (64bit only).


There is a problem on Macos. When upgrading from Ventura to Sonoma 13.6, 
debugging in the IDE often does not work, the app does not start. 
Running the app without debugging and debugging in the Terminal using 
lldb does work.

Once a solution is found I will upload a new Lazarus pkg for Macos.

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-03 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 17:18:56 +0700
Hairy Pixels via fpc-pascal  wrote:

>[...]
> > First of all: Is it valid UTF-8 or do you have to check for broken
> > or malicious sequences?  
> 
> If they give the parser broken files that's their problem they need
> to fix? the user has control over the file so it's there
> responsibility I think.

Users responsibility?
 - I recommend to check for malicious codes. ;)


> >> Right now I've just read the file into an AnsiString and indexing
> >> assuming a fixed character size, which breaks of course if non-1
> >> byte characters exist  
> > 
> > Sounds like UTF8CodepointToUnicode in unit LazUTF8 could be useful:
> > 
> > function UTF8CodepointToUnicode(p: PChar; out CodepointLen:
> > integer): Cardinal;  
> 
> Not sure how this works. You need to advance by character so there
> return value should be the byte location of the next character or
> something like that.

function ReadUTF8(p: PChar; ByteCount: PtrInt): PtrInt;
// returns the number of codepoints
var
  CodePointLen: longint;
  CodePoint: longword;
begin
  Result:=0;
  while (ByteCount>0) do begin
inc(Result);
CodePoint:=UTF8CodepointToUnicode(p,CodePointLen);
...do something with the CodePoint...
inc(p,CodePointLen);
dec(ByteCount,CodePointLen);
  end;
end;


> >> I also need to know if I come across something like \u1F496 I need
> >> to convert that to a unicode character.  
> > 
> > I guess you know how to convert a hex to a dword.  
> 
> Is there anything better than StrToInt?

Good start.

> I wouldn't be able to do it
> myself though without that function.

Hex to dword. That's easy enough for ChatGPT.


> > function UnicodeToUTF8(CodePoint: cardinal): string; // UTF32 to
> > UTF8 function UnicodeToUTF8(CodePoint: cardinal; Buf: PChar):
> > integer; // UTF32 to UTF8 
> 
> Ok I think this is basically what the other programmer submitted and
> what ChatGPT tried to do.

Yes, no need to reinvent the wheel.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release Candidate 1 of 3.0

2023-07-03 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the first release candidate of
Lazarus 3.0.

This release was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_3.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 3.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_3_0/

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 3.0RC1" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#3_0RC1

Minimum requirements:

Windows:
   2k, 32 or 64bit.

FreeBSD/Linux:
   gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
   Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, qt and
   qt5 (32 or 64bit).

The gitlab page:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/tree/lazarus_3_0_RC1

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at:ftp://ftp.freepascal.org/pub/lazarus/releases/

== Why should everybody (including you) test the release candidate? ==

In the past weeks the Lazarus team has stabilized the 3.0 fixes branch.
The resulting 3.0RC1 is now stable enough to be used by any one for
test purposes.

However many of the fixes and new features that were committed since
the release of 2.2.6 required changes to the code of existing features
too. While we have tested those ourselves, there may still be problems
that only occur with very specific configurations or one project in a
million.

Yes, it may be that you are the only person with a project, that will
not work in the new IDE. So if you do not test, we can not fix it.

Please do not wait for the final release, in order to test. It may be
too late. Once the release is out we will have to be more selective
about which fixes can be merged for further 3.x releases. So it may be,
that we can not merge the fix you require. And then you will miss out
on all the new features.

== How to test ==

Download and install the 3.0 RC1.
- On Windows you can install as a 2ndary install, that will not affect
  your current install:
  
http://wiki.lazarus.freepascal.org/Multiple_Lazarus#Installation_of_multiple_Lazarus
- On other platforms, if you install to a new location you need to use
--primary-config-path

In either case you should make backups. (including your primary config)

Open your project in the current Lazarus (3.0), and use "Publish
Project" from the project menu. This creates a clean copy of your
project.

You can then open that copy in the RC1. Please test:
- If you can edit forms in the designer
   - rename components / change properties in Object inspector / Add
 new events
   - Add components to form / Move components on form
   - Frames, if you use them
- If you can navigate the source code (e.g. jump to implementation)
- Auto completion in source code
- Compile, debug and run
- Anything else you use in your daily work


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-03 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 15:27:10 +0700
Hairy Pixels via fpc-pascal  wrote:

>[...]
> I was just curious how ChatGPTs implementation compared to other
> programmer.

Apparently the quality is often terrible. But it can be useful.

 
> What I'm really trying to do is improve a parser so it can read UTF-8
> files and decode unicode literals in the grammar.

First of all: Is it valid UTF-8 or do you have to check for broken or
malicious sequences?

 
> Right now I've just read the file into an AnsiString and indexing
> assuming a fixed character size, which breaks of course if non-1 byte
> characters exist

Sounds like UTF8CodepointToUnicode in unit LazUTF8 could be useful:

function UTF8CodepointToUnicode(p: PChar; out CodepointLen: integer): Cardinal;

 
>  I also need to know if I come across something like \u1F496 I need
> to convert that to a unicode character.

I guess you know how to convert a hex to a dword. Then

function UnicodeToUTF8(CodePoint: cardinal): string; // UTF32 to UTF8
function UnicodeToUTF8(CodePoint: cardinal; Buf: PChar): integer; // UTF32 to 
UTF8

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-03 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 12:01:11 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Jul 3, 2023, at 11:36 AM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > Useless array of.
> > And it does not return the bytecount.  
> 
> it's an open array so what's the problem?
>[...]
> > Wrong for byteCount=1  
> 
> really? How so? 
>
> ChatGPT is risky because it will give wrong information with perfect
> confidence and there's no way for the ignorant person to know.

I wonder, is this thread about testing ChatGPT or do you want to
implement something useful?
There are already plenty of optimized UTF-8 functions in the FPC and
Lazarus sources. Maybe too many, and you have trouble finding the right
one? Just ask what your function needs to do.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-03 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 14:12:03 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Jul 3, 2023, at 2:04 PM, Tomas Hajny via fpc-pascal
> >  wrote:
> > 
> > No - in this case, the "header" is the highest bit of that byte
> > being 0.  
> 
> Oh it's the header BIT. Admittedly I don't understand how this
> function returns the highest bit using that case, which I think he
> was suggesting.

A first byte of an UTF-8 codepoint is 0..127,192..247.
The second, third, fourth byte are between 128..191, so you can easily
detect where a codepoint starts.
And from the first byte you can derive the length of the codepoint.
If you just want to skip over n codepoints, then the below function does
the job:

 
> function UTF8CodepointSizeFast(p: PChar): integer;
> begin
>  case p^ of
>#0..#191   : Result := 1;
>#192..#223 : Result := 2;
>#224..#239 : Result := 3;
>#240..#247 : Result := 4;
>else Result := 1; // An optimization + prevents compiler warning
> about uninitialized Result. end;
> end;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-02 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 11:58:33 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Jul 3, 2023, at 11:43 AM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > There is a header byte.
> > 
> > It depends, if you want to check for invalid UTF-8 sequences.
> > 
> > From LazUTF8:
> > 
> > function UTF8CodepointSizeFast(p: PChar): integer;
> > begin
> >  case p^ of
> >#0..#191   : Result := 1;
> >#192..#223 : Result := 2;
> >#224..#239 : Result := 3;
> >#240..#247 : Result := 4;
> >else Result := 1; // An optimization + prevents compiler warning
> > about uninitialized Result. end;
> > end;  
> 
> This is a header for the file?

No, the header of a codepoint to figure out the length.

> Does that mean the file itself must
> have uniform character sizes?

No.

> I though the idea was to read the file
> one byte at a time but I don't understand how you would know if a 1
> byte character (like ascii) was part of a 4 byte character or not.

ASCII is #0..#127, which is the same character in UTF-8.

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-02 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 08:29:11 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Jul 2, 2023, at 11:16 PM, Jer Haan  wrote:
> > 
> > This table is copied from Wikipedia.Hope it’s useful
> > for you. If you improve the code pls let me know. 
> 
> This is perfect, thanks! Much more complicated than I thought.
> 
> I'm curious now, if you were going the other direction and parsing a
> string of different unicode characters with different code point
> sequence lengths how would you know which length it was? For example
> I started off know which unicode scalar to use by looking at a table
> but if I had to find the character is stream of text?
> 
> I think UTF8 can have 1-4 byte characters so you could encounter 1
> byte character followed by 4 byte characters interleaved and there's
> no header or terminator for each character. How is this solved?

There is a header byte.

It depends, if you want to check for invalid UTF-8 sequences.

From LazUTF8:

function UTF8CodepointSizeFast(p: PChar): integer;
begin
  case p^ of
#0..#191   : Result := 1;
#192..#223 : Result := 2;
#224..#239 : Result := 3;
#240..#247 : Result := 4;
else Result := 1; // An optimization + prevents compiler warning about 
uninitialized Result.
  end;
end;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parse unicode scalar

2023-07-02 Thread Mattias Gaertner via fpc-pascal
On Mon, 3 Jul 2023 09:34:10 +0700
Hairy Pixels via fpc-pascal  wrote:

>[...]
> Ok today I I just tried to ask ChatGPT and got an answer. I must have
> asked the wrong thing yesterday but it got it right today (with one
> syntax error using an inline "var" in the code section  for some
> reason).
> 
> How does this look?
> 
> procedure SplitUTF8Bytes(unicodeScalar: Integer; var bytes: array of
> Byte);

Useless array of.
And it does not return the bytecount.

> var
>   i: Integer;
>   byteCount: Integer;
> begin
>   // Number of bytes required to represent the Unicode scalar
>   if unicodeScalar < $80 then
> byteCount := 1
>   else if unicodeScalar < $800 then
> byteCount := 2
>   else if unicodeScalar < $1 then
> byteCount := 3
>   else if unicodeScalar < $11 then
> byteCount := 4
>   else
> raise Exception.Create('Invalid Unicode scalar');
> 
>   // Extract the individual bytes using bitwise operations
>   for i := byteCount - 1 downto 0 do
>   begin
> bytes[i] := $80 or (unicodeScalar and $3F);

Wrong for byteCount=1

> unicodeScalar := unicodeScalar shr 6;
>   end;
> 
>   // Set the leading bits of each byte
>   case byteCount of
> 2:
>   bytes[0] := $C0 or bytes[0];
> 3:
>   bytes[0] := $E0 or bytes[0];
> 4:
>   bytes[0] := $F0 or bytes[0];
>   end;
> end;

Well, it got the basic idea of UTF-8 multibytes right and it compiles,
so maybe half the points?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pchar from constant string

2023-06-29 Thread Mattias Gaertner via fpc-pascal
On Thu, 29 Jun 2023 21:18:44 +0700
Hairy Pixels via fpc-pascal  wrote:

> What is really happening in this snippet? I think it must be
> implicitly taking the address of the constant string but is it also
> adding the null terminator automatically? The string prints with
> writeln so it must be null terminated right?
> 
> var
>   p: Pchar;
> begin
>   p := '123';
>   writeln(p);

AFAIK the trailing #0 is already stored in the binary.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] 3123 inherited not supported inside inline

2023-06-24 Thread Mattias Gaertner via fpc-pascal
Hi,

With development fpc I get a lot of messages like:

fgl.pp(1112,1) Note: (3123) "inherited" not yet supported inside inline
procedure/function

Since most users can't do anything about the fgl inline modifier, this
message dilutes the output.

IMO such a message should be off by default.

What do you think?


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Legitimate use of for and break

2023-06-16 Thread Mattias Gaertner via fpc-pascal
On Fri, 16 Jun 2023 20:51:42 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Jun 16, 2023, at 6:23 PM, Thomas Kurz via fpc-pascal
> >  wrote:
> > 
> > Whether it's elegant is a different question. In my opinion YES
> > because it often gives better readable code than nested "if"
> > statements inside the loop. But I've also read that using "break"
> > is discouraged because it shows a bad choice of the loop range.  
> 
> This is highly suspect. Doing an early break in loops is the essence
> of how to do linear searching. No idea who thinks that's a bad idea.

20 years ago there were some programmers, claiming a loop condition
must only be at start or end, but not in the middle.

Gladfully, most programmers came to their senses.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] What is -CO ?

2023-06-15 Thread Mattias Gaertner via fpc-pascal
On Thu, 15 Jun 2023 22:00:03 +0200
Jonas Maebe via fpc-pascal  wrote:

> On 09/06/2023 12:03, Mattias Gaertner via fpc-pascal wrote:
> > What is -CO?
> > 
> > In the docs I can only find this sentence:
> > "Check for possible overflow of integer operations"  
> 
> It prints a warning whenever the compiler inserts an implicit type 
> conversion to a type that cannot represent every value of the source
> type.

Thanks!

Maybe this can be added to the docs?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] What is -CO ?

2023-06-09 Thread Mattias Gaertner via fpc-pascal
Hi,

What is -CO?

In the docs I can only find this sentence:
"Check for possible overflow of integer operations"


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Error: Argument cannot be assigned to

2023-06-04 Thread Mattias Gaertner via fpc-pascal
On Sun, 4 Jun 2023 16:04:48 +0300
Juha Manninen via fpc-pascal  wrote:

> Why the following code fails to compile?
> 
> type
>   TMyRec = record
> ss: String;
> ii: Integer;
>   end;
>   TMyClass = class
>   private
> fName: String;
> fRecInstance: TMyRec;
>   property
> RecInstance: TMyRec read fRecInstance;// write fRecInstance;
>   end;
> var
>   MyObj : TMyClass;
> begin
>   MyObj := TMyClass.Create;
>   MyObj.RecInstance.ii := 123;
>   MyObj.Free;
> end.
> 
> Access through property seems to be the problem. Accessing
> fRecInstance directly works.

Correct. Property RecInstance is read only.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Mattias Gaertner via fpc-pascal
On Thu, 25 May 2023 07:55:39 +0200
Sven Barth via fpc-pascal  wrote:

>[...]
> But this is what "managed type" *means*: that the compiler and RTL
> will make sure that it's correctly freed as long as nothing
> unexpected happens.

... and exceptions are expected.

Maybe better: As long as the user does not break the rules.

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Size of set.

2023-05-23 Thread Mattias Gaertner via fpc-pascal
On Tue, 23 May 2023 06:50:08 -0400
James Richters via fpc-pascal  wrote:

> >You can transverse a set with
> > for ... in  

An even better:

for e in TEnum do ; // traverse every possible enum

for e in aSet do ; // traverse only enums in aSet

 
> Interesting, I learned something new, I did now know I could do this
> with FreePascal.  It says it works for Strings and Arrays as well,
> does it also work for StringLists?

Yes

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-30 Thread Mattias Gaertner via fpc-pascal
On Thu, 30 Mar 2023 13:03:52 +0200
Tomas Hajny via fpc-pascal  wrote:

>[...]
> I don't know where it is configured in Lazarus, but you need to use
> the -Xe parameter when using command-line compilation.

Project / Project Options / Compiler Options / All Options

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 2.2.6

2023-03-09 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the release of Lazarus 2.2.6.

This is a bugfix release and was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 2.2.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_2_2

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.2.6" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#2_2_6

Minimum requirements:

Windows:
   2k, 32 or 64bit.

FreeBSD/Linux:
   gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
   Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, qt and
   qt5 (32 or 64bit).

The gitlab page:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/tree/lazarus_2_2_6

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at: ftp://ftp.freepascal.org/pub/lazarus/releases/

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] CalDAV

2023-02-20 Thread Mattias Gaertner via fpc-pascal
Hi,

How to connect to nextcloud CalDAV using fpc?

I need to connect to one calendar, list dates, delete dates, create
dates.

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] aligned?

2023-01-30 Thread Mattias Gaertner via fpc-pascal
On Mon, 30 Jan 2023 18:45:48 +0100
Florian Klämpfl via fpc-pascal  wrote:

> > Am 30.01.2023 um 14:03 schrieb Mattias Gaertner via fpc-pascal
> > :
> > 
> > Hi,
> > 
> > What does the fpc built-in function aligned?
> > 
> > For example in FloatToStrFIntl:
> > 
> >  Str(Double(Extended(Aligned(Value))):precision+7, Result);  
> 
> It tells the compiler that the argument is properly aligned according
> to its type.

Thanks!

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] aligned?

2023-01-30 Thread Mattias Gaertner via fpc-pascal
Hi,

What does the fpc built-in function aligned?

For example in FloatToStrFIntl:

  Str(Double(Extended(Aligned(Value))):precision+7, Result);



Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why in {$mode delphi} it works and in {$mode objfpc} it doesn't?

2023-01-16 Thread Mattias Gaertner via fpc-pascal
On Mon, 16 Jan 2023 22:12:52 +0100
Mattias Gaertner via fpc-pascal  wrote:

> On Mon, 16 Jan 2023 19:50:34 +0100
> Giuliano Colla via fpc-pascal  wrote:
> 
> > I stumbled into a problem I don't understand.
> > 
> > I'm developing a little program for an ftp client. In order to
> > connect to the site I need the site address from the site name, and
> > the libc gethostbyname() provides the required information.
> > 
> > gethostbyname returns a PHostEnt type which is declared as:

Btw, gethostbyname is obsolete. Applications should use getaddrinfo,
getnameinfo, and gai_strerror instead.


> > > THostEnt = packed record
> > >     h_name: PChar;  { Official name of host. }
> > >     h_aliases: PPChar;  { Alias list.  }
> > >     h_addrtype: Integer;    { Host address type.  }
> > >     h_length: socklen_t;    { Length of address.  }
> > >     case Byte of
> > >   0: (h_addr_list: PPChar); { List of addresses from name 
> > > server.  }
> > >   1: (h_addr: PPChar);  { Address, for backward 
> > > compatibility.  }
> > >   end;
> > >   PHostEnt = ^THostEnt; 
> > Actually the chars h_addr points to are /hlength/ bytes to be 
> > interpreted as an /in_addr/  
> [...]

Ah, I just saw gethostbyname returns a PHostEnt and Addr is Pin_addr.

Then for the first address:
  Addr := Pin_addr(HostEnt^.h_addr[0]);


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why in {$mode delphi} it works and in {$mode objfpc} it doesn't?

2023-01-16 Thread Mattias Gaertner via fpc-pascal
On Mon, 16 Jan 2023 19:50:34 +0100
Giuliano Colla via fpc-pascal  wrote:

> I stumbled into a problem I don't understand.
> 
> I'm developing a little program for an ftp client. In order to
> connect to the site I need the site address from the site name, and
> the libc gethostbyname() provides the required information.
> 
> gethostbyname returns a PHostEnt type which is declared as:
> 
> > THostEnt = packed record
> >     h_name: PChar;  { Official name of host. }
> >     h_aliases: PPChar;  { Alias list.  }
> >     h_addrtype: Integer;    { Host address type.  }
> >     h_length: socklen_t;    { Length of address.  }
> >     case Byte of
> >   0: (h_addr_list: PPChar); { List of addresses from name 
> > server.  }
> >   1: (h_addr: PPChar);  { Address, for backward 
> > compatibility.  }
> >   end;
> >   PHostEnt = ^THostEnt;   
> Actually the chars h_addr points to are /hlength/ bytes to be 
> interpreted as an /in_addr/

Then either

Addr := Pin_addr(HostEnt.h_addr)^;

or

Addr := Pin_addr(HostEnt.h_addr^)^;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPHttpClient & TFPHttpServer

2023-01-03 Thread Mattias Gaertner via fpc-pascal
On Tue, 3 Jan 2023 23:58:42 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:

>[...]
> > Q4: TFPHTTPServer has property Address. I reckon it will be set to
> > 'localhost' here. Is it correct?  
> 
> It depends on what you want. Best is to leave it empty.

That will use 0.0.0.0, which is every interface. For security
reasons the default should be more limited, like 127.0.0.1, should it
not?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Open array in object constructor gives error

2022-12-31 Thread Mattias Gaertner via fpc-pascal
On Sat, 31 Dec 2022 10:35:52 +0700
Hairy Pixels via fpc-pascal  wrote:

> Why is using the open array parameter illegal using the Object type?
> 
> 
> 
> {$mode objfpc}
> 
> program test;
> 
> type
>   TMyObject = object
> constructor Create(text: array of String);
>   end;
> 
> constructor TMyObject.Create(text: array of String);
> begin
> end;
> 
> begin
>   TMyObject.Create...

Not supported. Has nothing to do with the parameter list.

> end.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Exploring block statements with CodeTools not working

2022-10-17 Thread Mattias Gaertner via fpc-pascal
On Mon, 17 Oct 2022 08:41:23 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Oct 16, 2022, at 9:53 PM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > Blocks like WHILE and TRY.
> > 
> > Codetools are optimized for finding declarations of a few
> > expressions between edits. To find the parameters, call for each
> > identifier followed by ( the FindCodeContext function.  
> 
> So inlay hints need to be computed with a document range so we don’t
> know a single X,Y position we could use to call FindCodeContext. If I
> had a list of identifiers which were function calls in begin blocks I
> could call FindCodeContext based on those. Is that possible?

Yes

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Exploring block statements with CodeTools not working

2022-10-16 Thread Mattias Gaertner via fpc-pascal
On Sun, 16 Oct 2022 21:05:23 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Oct 16, 2022, at 4:17 PM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > That's correct. There are no nodes for simple statements like
> > "a:=1".  
> 
> Really? I was going to use this to find unknown identifiers (for LSP
> diagnostics) and try to implement LSP’s new inlay parameter hints
> feature. I didn’t see function calls appear as nodes either. Is there
> anything at all that’s captured in code blocks?

Blocks like WHILE and TRY.

Codetools are optimized for finding declarations of a few expressions
between edits. To find the parameters, call for each identifier
followed by ( the FindCodeContext function.

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Exploring block statements with CodeTools not working

2022-10-16 Thread Mattias Gaertner via fpc-pascal
On Sun, 16 Oct 2022 09:19:56 +0700
Hairy Pixels via fpc-pascal  wrote:

> I’m trying to look at the code in a the begin..end section of this
> sample program but for some reason when it gets to the BeginBlock
> node child count is always 0 (other nodes are as expected though).

That's correct. There are no nodes for simple statements like "a:=1".

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] CodeTools complete code

2022-10-04 Thread Mattias Gaertner via fpc-pascal
On Tue, 4 Oct 2022 14:47:29 +0700
Hairy Pixels via fpc-pascal  wrote:

> > On Oct 4, 2022, at 2:40 PM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > If you don't want the comment above the class, use
> > 
> > with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do 
> > begin
> >  ClassHeaderComments:=false;
> >  ClassImplementationComments:=false;
> > end;
> >   
> Great thanks.
> 
> > New procedure bodies are added behind global variables, so they can
> > access them.  
> 
> Ok so this must apply to program files only.

You can define private classes in unit implementations as well.

> I can live with that I guess. It’s maybe best to make it an option. What do 
> you think?

A separate option where to start new classes is a good idea.

> Just
> because it’s an assumption the global variable will be used at all.

Codetools can't know that, so it needs manual help here.
In a unit implementation usually all global variables are at the
beginning and the classes follow. 


> There can also be many global variable sections so that confuses the
> concept some also.

That is a confusing concept anyway. Aka bad coding style?

 
Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] CodeTools complete code

2022-10-04 Thread Mattias Gaertner via fpc-pascal
On Tue, 4 Oct 2022 14:10:29 +0700
Hairy Pixels via fpc-pascal  wrote:

> I’m trying to use the CompleteCode function in the CodeTools library
> and doing some formatting I don’t want.
> 
> Calling it over the “MyProcedure” method in the class it added a
> comment and moved the declaration under the variable section instead
> of directly under the class declaration like I would have expected.
> Basically I would just like the most minimal amount of changes to
> implement the method instead of reformatting things.
> 
> I see there is a beautifier class but it could it be used for this
> and if so how may that look?

If you don't want the comment above the class, use

with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do 
begin
  ClassHeaderComments:=false;
  ClassImplementationComments:=false;
end;

New procedure bodies are added behind global variables, so they can
access them.
At the moment when a class has no method body yet, codetools uses the
setting for the procedures. (It would be better, if this has a separate
setting).

ForwardProcBodyInsertPolicy

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 2.2.4

2022-09-28 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the release of Lazarus 2.2.4.

This is a bugfix release and was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 2.2.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_2_2

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.2.4" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#2_2_4

Minimum requirements:

Windows:
   2k, 32 or 64bit.

FreeBSD/Linux:
   gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
   Cocoa (64bit) 10.12, Carbon (32bit) 10.5 to 10.14, qt and
   qt5 (32 or 64bit).

The gitlab page:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/tree/lazarus_2_2_4

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at: ftp://ftp.freepascal.org/pub/lazarus/releases/

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Mattias Gaertner via fpc-pascal
On Mon, 20 Jun 2022 20:32:44 +0700
Hairy Pixels via fpc-pascal  wrote:

> Can anyone explain why this works? TProc is a normal function pointer
> so how did it capture gVar?

gVar is global. No need to capture it. Only stack vars needs capture.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature Announcement: Function References and Anonymous Functions

2022-05-26 Thread Mattias Gaertner via fpc-pascal
On Thu, 26 May 2022 21:47:06 +0200
Sven Barth via fpc-pascal  wrote:

>[...]
> The Free Pascal Developer team is pleased to finally announce the 
> addition of a long awaited feature, though to be precise it's two 
> different, but very much related features: Function References and 
> Anonymous Functions.

\O/


>[...]

> As these two features are rather complicated there might still be a
> huge bundle of bugs lurking around so I ask you to test them to year
> heart's content and report found bugs

First!

>[...]

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 2.2.2

2022-05-19 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the release of Lazarus 2.2.2.

This is a bugfix release and was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 2.2.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_2_2

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.2.2" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#2_2_2

Minimum requirements:

Windows:
   2k, XP, Vista, 7, 8, 8.1 and 10, 32 or 64bit.

FreeBSD/Linux:
   gtk 2.24 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
   Cocoa (64bit) 10.12 to 12.3, Carbon (32bit) 10.5 to 10.14, qt and
   qt5 (32 or 64bit).

The gitlab page:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/tree/lazarus_2_2_2

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at:ftp://ftp.freepascal.org/pub/lazarus/releases/


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Element type of set at compile time

2022-05-15 Thread Mattias Gaertner via fpc-pascal
On Sun, 15 May 2022 09:03:58 +0200 (CEST)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Sun, 15 May 2022, Hairy Pixels via fpc-pascal wrote:
> 
> > Is there a compiler intrinsic to get the element type of a set at
> > compile time? So if you have “set of T” it should return T.  
> 
> I don't think you can make such an intrinsic.
> This type does not always exist, since  you can define
> 
> Type
>TMySet = set of (one,two,three);
> 
> The element type does not exist as a separate type.

The RTTI supports it, so it always exists.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-30 Thread Mattias Gaertner via fpc-pascal
On Sat, 30 Apr 2022 18:17:25 +0700
Hairy Pixels via fpc-pascal  wrote:

>[...]
> So I wonder if the shorthand:
> 
>   generic THelper = class helper for TMyClass

AFAIK it is planned for mode objfpc to support distinguishing types via
template count as in mode delphi:

type
  TMyClass = class
  end;
  generic TMyClass = class
  end;
  generic TMyClass = class
  end;

So you would need something similar for helpers:

  THelper = class helper for TMyClass
  end;
  generic THelper = class helper for specialize TMyClass 
  end;
  generic THelper = class helper for specialize TMyClass 
  end;


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Correct way for using TThread.ForceQueue?

2022-04-25 Thread Mattias Gaertner via fpc-pascal
On Mon, 25 Apr 2022 15:47:57 +0200
Thomas Kurz via fpc-pascal  wrote:

>[...]
> As far as I have seen so far, the common solution is to use a
> variable inside the class to cache the parameters, then to use a
> DoCallSync procedure which takes no parameters but can use the cached
> values inside, and finally to call TThread.Synchronize(NIL,
> @DoCallSync). I have stick to this concept when using Synchronize,
> too.

Or some small class:

type
  TMyData = class 
a: whatever;
procedure Run;
  end;

MyData:=TMyData.Create;
MyData.a:=...;
TThread.Synchronize(NIL, @MyData.Run).

Free MyData when done and/or in the destructor.

 
>[...]

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-25 Thread Mattias Gaertner via fpc-pascal
On Mon, 25 Apr 2022 10:15:26 +0700
Hairy Pixels via fpc-pascal  wrote:

>[...]
> For the case of types I understand we must specialize because we’re
> creating a new type each time and there is nothing to infer from the
> context, but for functions it’s backwards, that is we know the types
> being used, we just need to choose the right function based on those
> types.

IMO the important difference is that alias types already safes most
inline specializations.
There is no alias for generic functions, which is why implicit function
specialization is so handy.

 
>[...]
> type
>   generic TArrayHelper = type helper for array of T
> procedure Add(value: T);
>   end;
> 
> var
>   a: array of integer;
> begin
>   a.Add(1);  // specialize TArrayHelper since the compiler
> clearly knows the type used is Integer. end.

IMO that is only useful with modeswitch multihelpers.

All these modeswitches makes it harder to learn Pascal.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-22 Thread Mattias Gaertner via fpc-pascal
On Fri, 22 Apr 2022 20:51:56 +0200
Martin Frb via fpc-pascal  wrote:

>[...]
> Well, I tested: It uses the type of the first Param. So it calls a 
> function for both param of type Byte. The cardinal argument is 
> converted. (potentially truncated).

I agree that Delphi should have used a better algorithm, like checking
the var/out arguments first and otherwise use the smallest
integer that fits all related params. Same for strings and boolean.
pas2js uses a similar algorithm. 

In $mode Delphi fpc must use the Delphi algorithm. In other modes it
could use a better algorithm.
If fpc would use the above algorithm in mode objfpc, the Add would work
like FPC's add:

generic function Add(a,b: T): T;
begin
  Result:=a+b;
end;

Add(aByte,aCardinal) -> cardinal


And you don't need to put a var/out param leftmost:

generic procedure Adding(a,b: T; out c: T);
begin
  c:=a+b;
end;

Adding(3,4,aWord);


Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-22 Thread Mattias Gaertner via fpc-pascal
On Fri, 22 Apr 2022 20:51:56 +0200
Martin Frb via fpc-pascal  wrote:

>[...]
> I did explore what happens if I throw different types at it, and see
> how the current implementation deals with this (what I call) lack of
> type safety.
> And also asked the question, how should it act?  (Because the current 
> behaviour is new, expected to need fixes, and can obviously be fixed).

See Sven's first mail. 

 
>[...]
> So what happens if:
> 
> var
>    b: Byte;
>    c: Cardinal;
> begin
>    Add(b, c);
> 
> Well, I tested: It uses the type of the first Param. So it calls a 
> function for both param of type Byte. The cardinal argument is 
> converted. (potentially truncated).

Yes, as explained by Sven.

 
> If you use numeric constants:
>    writeln('   0', Add(0, 0) );  // ShortInt
>    writeln('1000', Add(1000, 1000) );  // SmallInt
>    writeln('100K', Add(10, 10) );  // Integer
> 
> So then, if you try to fix   " Add(b, c)" by checking that b and c
> have the same type => "Add(c, 0)" will fail => because 0 is ShortInt
> and not cardinal.

Why is that a fail?

 
> 
> I created a little test program (see bottom of mail).
> 
> And it gives a strange warning:
> 
> Compile Project, Target: 
> C:\Users\martin\AppData\Local\Temp\project1.exe: Success, Warnings:
> 1, Hints: 3
> project1.lpr(67,52) Warning: Range check error while evaluating 
> constants (10 must be between -128 and 127)

Add(0, 10)
Correct range error.


> project1.lpr(41,18) Hint: Local proc "Add$1" is not used
> 72 lines compiled, 0.2 sec, 105136 bytes code, 5476 bytes data
> Line 41 is the declaration of the generic
>     generic function Add(aArg1, aArg2: T): T;

Maybe related to
https://gitlab.com/freepascal.org/fpc/source/-/issues/39675


>[...]

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-21 Thread Mattias Gaertner via fpc-pascal
On Thu, 21 Apr 2022 10:00:46 +0200 (CEST)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Thu, 21 Apr 2022, Hairy Pixels via fpc-pascal wrote:
> 
> >
> >  
> >> On Apr 21, 2022, at 3:48 AM, Mattias Gaertner via fpc-pascal
> >>  wrote: 
> >>> Writeln(Apply(@StrFunc, 'Foobar')); // will write FOOBAR
> >>> Writeln(Apply(@NegFunc, 42)); // will write -42
> >>> end.  
> >> 
> >> Mind boggling. :)  
> >
> > This was actually your idea if I remember correctly. :) I think you
> > said even Delphi doesn’t do this so I challenged myself to get it
> > done.  
> 
> Delphi does it, but only for methods of a class.
> 
> AFAIK delphi does not support generic "plain" functions.

Delphi has generic methods and still no generic "plain" functions.

Delphi 11 still does not support *nested* implicit specializations. 
For example the Apply with methods gives in Delphi:

E2010 Incompatible types 'T' and 'String'
F2084 Internal Error: AV10D0B8D2(10CB)-R8-0

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-20 Thread Mattias Gaertner via fpc-pascal
On Wed, 20 Apr 2022 19:15:15 +0200
Sven Barth via fpc-pascal  wrote:

>[...]
> This feature is enabled with the modeswitch 
> ImplicitFunctionSpecialization and is for now not enabled by default
> as this has the potential to break existing code.

Sad. This feature really makes generic functions shine.

 
>[...]
> generic function ArrayFunc(aArg: specialize TArray): T;
>[...]
> type
>    generic TTest = function(aArg: T): T;
> 
> generic function Apply(aFunc: specialize TTest; aArg: T): T;
>[...]
> begin
>    Writeln(ArrayFunc([1, 2, 3])); // will write 6
>    Writeln(ArrayFunc(['Hello', 'FPC', 'World'])); // will write 
> HelloFPCWorld
> 
>    Writeln(Apply(@StrFunc, 'Foobar')); // will write FOOBAR
>    Writeln(Apply(@NegFunc, 42)); // will write -42
> end.

Mind boggling. :)

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] RTLEventWaitFor

2022-04-05 Thread Mattias Gaertner via fpc-pascal
On Tue, 5 Apr 2022 10:23:45 +0200 (CEST)
Michael Van Canneyt via fpc-pascal 
wrote:

>[...]
> RTLEventWaitFor uses WaitForSingleObject internally.
> 
> According to this:
> 
> https://docs.microsoft.com/en-gb/windows/win32/sync/wait-functions
> 
> The system clock (and not some high-performance counter) is used to
> determine resolution of the timeout. You could call timeGetDevCaps to
> check the resolution.

It gives min 1, max 100.
I tried setting with timeBeginPeriod without effect.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] RTLEventWaitFor

2022-04-04 Thread Mattias Gaertner via fpc-pascal
Hi Michael,

Under Linux a RTLEventWaitFor(e,1) usually waits at most 1ms. But under
Windows it usually waits at least 15ms. It seems to round to nearest
1/64 of a second.

Googling this lead me to question the sanity of some bloggers.

Has anyone an idea if this is normal on Windows and if there is an
alternative?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] converting to UTF8

2022-03-23 Thread Mattias Gaertner via fpc-pascal
On Tue, 22 Mar 2022 04:47:50 -0400
cibersvaa--- via fpc-pascal  wrote:

> Lazarus 2.012
> FPC: 3.2.0
> SVN: 64642
> OS: Windows 10 Pro/win64
> 
> I'm reading from a file with character set win1252, I want to convert
> it to utf8, but I can't.
> 
> procedure TestString;
> var
>Original:string;
>Converted:string;
> begin
>original:='ESPA'#209'A'; //ESPAÑA WIN1252

FPC does not yet understand comments, so maybe it does not know this
literal is cp1252. Add {$codepage cp1252} somewhere at the start of
the unit.

If this is part of a Lazarus application, then String is by
default UTF-8, so your "original" is already converted to UTF-8.

>Converted:=ansiToUtf8(original);  // converts to
> 'ESPA'#239#191#189'A' // converted Should be 'ESPA'#195#145'A'

If you want to load a string encoded in CP1252, then you
can use from unit lconvencoding:

s:=CP1252ToUTF8(StringFromFile);


> end;
> 
> I've tried playing with strings types, string, rawstring,ansistring,  
> utf8string. No way. Any hint?


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Just out of curiosity: Compiling FPC trunk and fpcmake

2022-03-22 Thread Mattias Gaertner via fpc-pascal
On Tue, 22 Mar 2022 09:31:19 +0100
Victor Campillo via fpc-pascal  wrote:

>[...]
> OPT="-O- -O1 -gl" 

Is this paranoid or useful?
-O- -O1

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Bit manipulation helpers

2022-02-21 Thread Mattias Gaertner via fpc-pascal
On Mon, 21 Feb 2022 13:34:29 +0100
gabor via fpc-pascal  wrote:

> W dniu 2022-02-21 o 13:18, Ryan Joseph via fpc-pascal pisze:
> > Oh my, I was confusing my terms I think. I wanted to do bit masking
> > (I think it's called). I was expecting there to be something like
> > TestFlag in the RTL since I can never remember the syntax "Value =
> > (Value or Index)" function TestFlag(Value: QWord; Index: Byte):
> > Boolean; begin result := Value = (Value or Index);
> > end;  
> 
> Should you use the "AND" operator instead of "OR" for bit testing?
> 
> result := Value = (Value AND Index);

No.

result := (Byte(Value) AND Index)>0;

result := Index = (Byte(Value) AND Index);

result := Byte(Value) = (Byte(Value) OR Index);

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Mattias Gaertner via fpc-pascal
On Sat, 12 Feb 2022 12:14:14 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:
> 
> > Hi,
> >
> > This can't be right, can it?
> >
> > type
> >  TBird = class
> >procedure Fly;
> >  end;
> >  TEagle = TBird; // alias
> >
> > procedure TEagle.Fly;
> > begin
> > end;  
> 
> Personally, I would not allow this. 
> But Delphi compiles and runs it...

... and Delphi's class completion no longer works in the unit giving a
useless error "expected ';' but '.' found". So it is one of those
Delphi "features" compiling but not usable.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Mattias Gaertner via fpc-pascal
On Sat, 12 Feb 2022 17:58:27 +0100
Jonas Maebe via fpc-pascal  wrote:

>[...]
> >> I wouldn't consider this to be working by design, but rather
> >> because of implementation limitations.  

+1
pas2js complained. That's how I found out. Someone renamed a class,
added an alias for compatibility, forgot to rename the
implementation, and fpc did not complain.

 
> > Why do you consider it a limitation ?
> > 
> > Because the compiler currently has no way to distinguish the types
> > when resolving the
> > name "T" (as used in my example)?  
> 
> Indeed.
> 
> > Then it is a strange coincidence that Delphi has it too :-)  
> 
> The simplest way to implement alias types is to just have them refer
> to the original type...

Actually pas2js did an even simpler approach here: Look up the
identifier without resolving the original type ;)

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] bug or feature?

2022-02-12 Thread Mattias Gaertner via fpc-pascal
Hi,

This can't be right, can it?

type
  TBird = class
procedure Fly;
  end;
  TEagle = TBird; // alias

procedure TEagle.Fly;
begin
end;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 2.2

2022-01-05 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the release of Lazarus 2.2.

This release was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 2.2.x:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commits/fixes_2_2

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.2.0" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#2_2_0

Minimum requirements:

Windows:
   2k, XP, Vista, 7, 8, 8.1 and 10, 32 or 64bit.

FreeBSD/Linux:
   gtk 2.8 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
   Cocoa (64bit) 10.12 to 11.4, Carbon (32bit) 10.5 to 10.14, qt and
   qt5 (32 or 64bit).

The gitlab page:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/tree/lazarus_2_2_0

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at:ftp://ftp.freepascal.org/pub/lazarus/releases/


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN

2022-01-05 Thread Mattias Gaertner via fpc-pascal
On Wed, 5 Jan 2022 09:40:49 +0200
"Dimitrios Chr. Ioannidis via fpc-pascal"
 wrote:

> Hi,
> 
> Στις 5/1/2022 2:00 π.μ., ο/η Rainer Stratmann via fpc-pascal έγραψε:
> > https://freepascal.org/  
> 
> the certificate issued for www.freepascal.org and not for
> freepascal.org .
> 
> It seems that the let's encrypt script was run with -d freepascal.org 
> instead of -d *.freepascal.org .

or

-d freepascal.org,www.freepascal.org 

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Improved FPC JSON-RPC support

2021-12-28 Thread Mattias Gaertner via fpc-pascal
On Tue, 28 Dec 2021 23:11:42 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:

>[...]
> > Slightly off topic, and my Object Pascal is getting a bit rusty as
> > the years go by.  ;-) In your factory above, is the "as
> > IInterface" part needed.

No.

> Can't the FPC compiler automatically cast
> > the return type based on the function return type, and the fact
> > that the compiler should know that TIntf2Impl type implements
> > TInterfacedObject?  

Yes.

> No, theoretically it probably could, but type inference is not
> implemented in Pascal.

This is not type inference.
It compiles with fpc and pas2js:

Function GetMyOtherInterface(Const aName : string) : IInterface;
begin
  Result:=TIntf2Impl.Create;
end;


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Named optional arguments

2021-11-28 Thread Mattias Gaertner via fpc-pascal

On 26.11.21 04:10, Ryan Joseph via fpc-pascal wrote:

[...]The majority of the infrastructure is already there so it needs to merely 
be extended.


What do you mean? Is there already some call by arg names in some 
mode(switch)?


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazbuild error on Windows

2021-10-29 Thread Mattias Gaertner via fpc-pascal
On Fri, 29 Oct 2021 10:07:58 +0700
Ryan Joseph via fpc-pascal  wrote:

> Sorry I didn't look up high enough in the output to see this before.
> It looks like lazbuild can't find the correct version of the compiler
> that is packaged. I can confirm that path exists but I think the
> variable $Lazarusdir may be wrong.

Lazarus uses macros of the form $(LazarusDir) .

Did you check the fpc path in Lazarus? 
Tools / Options / Environment
 
> What could be wrong here? I got Lazarus via an installer so I don't
> know how else to set it up.

Maybe it uses some old config?
lazbuild --verbose pasls.lpi

Mattias
 
> PS C:\Users\Ryan Joseph\Desktop\Developer\pascal-language-server>
> C:\lazarus\lazbuild.exe pasls.lpi SetupCompilerFilename: The compiler
> path "$Lazarusdir\fpc\3.2.0\bin\i386-win32\fpc.exe" =>
> "C:\lazarus\$Lazarusdir\fpc\3.2.0\bin\i386-win32\fpc.exe" is invalid
> (Error: file not found) Searching a proper one ...
> SearchCompilerCandidates
> Value=$Lazarusdir\fpc\3.2.0\bin\i386-win32\fpc.exe
> File=C:\lazarus\$Lazarusdir\fpc\3.2.0\bin\i386-win32\fpc.exe
> SearchCompilerCandidates
> Value=$Lazarusdir\fpc\3.2.0\bin\i386-win32\\fpc.exe
> File=C:\lazarus\$Lazarusdir\fpc\3.2.0\bin\i386-win32\fpc.exe
> SearchCompilerCandidates
> Value=$Lazarusdir\fpc\3.2.0\bin\i386-win32\\fpc.exe
> File=C:\lazarus\$Lazarusdir\fpc\3.2.0\bin\i386-win32\fpc.exe
> SearchCompilerCandidates Value=fpc.exe
> File=C:\FPC\3.2.2\bin\i386-Win32\fpc.exe
> 
> > On Oct 29, 2021, at 9:46 AM, Ryan Joseph 
> > wrote:
> > 
> > I think I may have downloaded the 32 bit version of the compiler
> > and then the 64 bit Lazarus! That would make sense it would fail
> > then. Let me try downloading the correct version and I'll report
> > back.  
> 
> Regards,
>   Ryan Joseph
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release Candidate 1 of 2.2.0

2021-07-12 Thread Mattias Gaertner via fpc-pascal

The Lazarus team is glad to announce the first release candidate of
Lazarus 2.2.

This release was built with FPC 3.2.2.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.2

Here is the list of fixes for Lazarus 2.2.x:
http://wiki.freepascal.org/Lazarus_2.2_fixes_branch

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.2RC1" directory.

Checksums for the SourceForge files:
https://www.lazarus-ide.org/index.php?page=checksums#2_2_0RC1

Minimum requirements:

Windows:
  2k, XP, Vista, 7, 8, 8.1 and 10, 32 or 64bit.

FreeBSD/Linux:
  gtk 2.8 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
  Cocoa (64bit) 10.12 to 11.4, Carbon (32bit) 10.5 to 10.14, qt and
  qt5 (32 or 64bit).

The svn tag is
http://svn.freepascal.org/svn/lazarus/tags/lazarus_2_2_0_RC1

Last trunk svn revision was r65398.

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at:ftp://ftp.freepascal.org/pub/lazarus/releases/

== Why should everybody (including you) test the release candidate? ==

In the past weeks the Lazarus team has stabilized the 2.2 fixes branch.
The resulting 2.2RC1 is now stable enough to be used by any one for
test purposes.

However many of the fixes and new features that where committed since
the release of 2.0 required changes to the code of existing features
too. While we have tested those ourselves, there may still be problems
that only occur with very specific configurations or one project in a
million.

Yes, it may be that you are the only person with a project, that will
not work in the new IDE. So if you do not test, we can not fix it.

Please do not wait for the final release, in order to test. It may be
too late. Once the release is out we will have to be more selective
about which fixes can be merged for further 2.2.x releases. So it may
be, that we can not merge the fix you require. And then you will miss
out on all the new features.

== How to test ==

Download and install the 2.2 RC1.
- On Windows you can install as a 2ndary install, that will not affect your 
current install:
http://wiki.lazarus.freepascal.org/Multiple_Lazarus#Installation_of_multiple_Lazarus
- On other platforms, if you install to a new location you need to use
--primary-config-path

In either case you should make backups. (including your primary config)

Open your project in the current Lazarus (2.0.x), and use "Publish Project" 
from the project menu. This creates a clean copy of your project.

You can then open that copy in the RC1. Please test:
- If you can edit forms in the designer
  - rename components / change properties in Object inspector / Add new events
  - Add components to form / Move components on form
  - Frames, if you use them
- If you can navigate the source code (e.g. jump to implementation)
- Auto completion in source code
- Compile, debug and run
- Anything else you use in your daily work


Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Will the size of an executable depend on the uses clause

2021-06-16 Thread Mattias Gaertner via fpc-pascal
On Wed, 16 Jun 2021 12:26:54 +0200
Bo Berglund via fpc-pascal  wrote:

> On Wed, 16 Jun 2021 12:08:26 +0200 (CEST), Michael Van Canneyt via
> fpc-pascal  wrote:
> 
> >FPC/lazarus tell you which units are unused, and in the Lazarus IDE
> >you can use the quick actions of the message dialog to quickly
> >remove all unused units. I use it all the time.  
> 
> Thanks, I will have a look and see what happens if you tell me where
> in Lazarus to look.

Compile. When the compiler gives the message unit not used. Right click
on the message.


> Since the final binary size after using strip -s on the exe file is
> 271 kb it seems a bit big!
> Or is there a lot behind the scenes I have missed?

Classes is a hog.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Will the size of an executable depend on the uses clause

2021-06-16 Thread Mattias Gaertner via fpc-pascal
On Wed, 16 Jun 2021 08:57:13 +0200
Bo Berglund via fpc-pascal  wrote:

> If I by habit add a bunch of often used units to the uses clause will
> that affects the size of the compiled application even if they are
> not in fact used?

Yes, if they have e.g. initialization sections.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] -FNsystem

2021-05-27 Thread Mattias Gaertner via fpc-pascal
Hi,

There are some dotted units in fpc, e.g. system.uitypes.
So it would be nice to have -FNsystem in the default fpc.cfg (Delphi
compatible).

What do you think?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to find where my app consumes CPU?

2021-05-19 Thread Mattias Gaertner via fpc-pascal
On Wed, 19 May 2021 19:46:43 +0100
Martin Wynne via fpc-pascal  wrote:

>[...]
> I found that the problem is in the Lazarus Application.OnIdle event, 
> which fails to honour the Done parameter and runs continuously:

How do you know, it is a bug in OnIdle, and not something continuously
emitting events?
Have you tested in a small test application?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to find where my app consumes CPU?

2021-05-19 Thread Mattias Gaertner via fpc-pascal
On Tue, 18 May 2021 18:37:38 -0400
Travis Siegel via fpc-pascal  wrote:

> Apparently, you can release cpu cycles, but it's with the sched_yield 
> (section 2 in the man pages), not the sleep command on linux.

What sleep command are you referring to?
What do you mean with cpu cycles?

Sleep works pretty well under Linux:

uses sysutils;
var i: integer;
begin
  for i:=1 to 1 do sleep(1);
end.

time ./test1 

real0m10,791s
user0m0,021s
sys 0m0,018s

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [fpc-devel] Nested function closures

2021-04-29 Thread Mattias Gaertner via fpc-pascal
On Thu, 29 Apr 2021 07:52:19 +0200
Sven Barth via fpc-pascal  wrote:

>[...]
> You completely ignored my first point, which in this case is the much
> more significant one: Pascal does not support type inference.

FPC does not.
Delphi does:
http://docwiki.embarcadero.com/RADStudio/Sydney/en/Inline_Variable_Declaration

begin
  var MyDictionary := TDictionary.Create;
  for var I:=1 to 10 do ;
end.

> It is impossible to implement a syntax like you're suggesting without
> major rework of the parser. 

Indeed.


Mattias


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Mattias Gaertner via fpc-pascal
On Tue, 9 Mar 2021 08:04:54 +0100
Sven Barth via fpc-pascal  wrote:

>[...]
> FPC is not Java. In FPC you have more fine-grained control over the
> resulting binary than "install big, fat runtime". Not to mention that
> FPC can target resource constrained systems as well.

Optional is good.

Maybe the defaults can be changed. For example the macOS dmg and
Linux-x86-64 debs/rpms could install an fpc.cfg containing

#ifndef FPNonUnicode
-Facwstring
-Fcutf-8
#endif

For minimal programs pass -dFPNonUnicode

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Why has the tkFloat default value changed?

2021-02-28 Thread Mattias Gaertner via fpc-pascal
Hi,

In FPC 3.2.0 the default "Default" value of a single/double property
has changed from $8000 (fpc 3.0.4) to 0.

This breaks TWriter.
The $8000 means the property has no default value.
Now FPC 3.2.0 no longer writes a property if the value is 0.0, no
matter what the stored function says.

For example:
property S: Single read FSingle write FSingle stored IsSStored;

FPC 3.0.4 TWriter does write S if S=0.0 and IsSStored returns true.
FPC 3.2.0 does not.

I can't find this change in
https://wiki.lazarus.freepascal.org/User_Changes_3.2.0

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 2.0.12

2021-02-25 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the release of Lazarus 2.0.12.

This release was built with FPC 3.2.0.

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.0.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.0

Windows users should be careful with -O3 or higher optimization, due to
bug https://bugs.freepascal.org/view.php?id=37305.

Here is the list of fixes for Lazarus 2.0.x:
http://wiki.freepascal.org/Lazarus_2.0_fixes_branch

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.0.12" directory.

Checksums for the SourceForge files:
http://www.lazarus-ide.org/index.php?page=checksums#2_0_12

Minimum requirements:

Windows:
  2k, XP, Vista, 7, 8, 8.1 and 10, 32 or 64bit.

FreeBSD/Linux:
  gtk 2.8 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
  Cocoa (64bit) 10.12 to 10.15, Carbon (32bit) 10.5 to 10.14, qt and
  qt5 (32 or 64bit).

The svn tag is
http://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_12

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at: ftp://ftp.freepascal.org/pub/lazarus/releases/


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Traits Proposal

2021-02-19 Thread Mattias Gaertner via fpc-pascal
On Fri, 19 Feb 2021 15:37:03 -0700
Ryan Joseph via fpc-pascal  wrote:

> > On Feb 19, 2021, at 3:14 PM, Sven Barth via fpc-pascal
> >  wrote:
> > 
> > TObject *is* always the root, but the first entry of the
> > inheritance list of a class *must* be a class as well.  
> 
> I'm testing interface delegation now in ObjFPC mode and I don't see
> that including TObject is required. 

In Delphi the first must be a class. FPC allows to omit the class
and uses TObject as default.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] self corrupted after jump to overridden method

2021-02-17 Thread Mattias Gaertner via fpc-pascal
On Wed, 17 Feb 2021 15:27:40 +0100
Mattias Gaertner via fpc-pascal  wrote:

> Hi,
> 
> I have a strange bug, that suddenly Self becomes a random value when
> calling an overridden virtual method. It happens when activating a
> TCustomSQLQuery.
> Below is a gdb stacktrace with fpc 3.3.1, where Self became 0. On
> other runs I saw various other values.

My patch turns the crash into a normal Exception:
https://bugs.freepascal.org/view.php?id=38503

 
> Where to start looking?
> It happens in Lazarus at designtime, so maybe some vmt issue?

Turns out it was an evil combination of optimization and misleading gdb
output.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] self corrupted after jump to overridden method

2021-02-17 Thread Mattias Gaertner via fpc-pascal
Hi,

I have a strange bug, that suddenly Self becomes a random value when
calling an overridden virtual method. It happens when activating a
TCustomSQLQuery.
Below is a gdb stacktrace with fpc 3.3.1, where Self became 0. On other
runs I saw various other values.

Where to start looking?
It happens in Lazarus at designtime, so maybe some vmt issue?


#0  0x013cba40 in INTERNALOPEN (this=0x0) at
fcl-db/src/sqldb/sqldb.pp:3140 

#1  0x01250f1d in DOINTERNALOPEN
(this=0x7fffc5c0) at fcl-db/src/base/dataset.inc:410 

#2
0x012520f1 in OPENCURSOR (this=0x752aab50, INFOQUERY=184)
at fcl-db/src/base/dataset.inc:958 

#3  0x013cac53 in OPENCURSOR
(this=0x752aab50, INFOQUERY=false) at
fcl-db/src/sqldb/sqldb.pp:2824 

#4  0x01252518 in SETACTIVE
(this=0x752aab50, VALUE=true) at fcl-db/src/base/dataset.inc:1093

#5  0x0057a662 in SETORDPROP (INSTANCE=0x7fffd001,
PROPINFO=0x752aab50, VALUE=1) at ../objpas/typinfo.pp:1898 

#6
0x00a7a239 in SETORDVALUE (this=0x7fffc47155e0, NEWVALUE=1) at
propedits.pp:3315


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] bug or feature

2021-01-01 Thread Mattias Gaertner via fpc-pascal
Hi,

library test;
procedure Test; begin end;
exports
  Test name 3 'abc';
  //^^^
end.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get the current translation of a resource string?

2020-12-02 Thread Mattias Gaertner via fpc-pascal
On Wed, 2 Dec 2020 13:48:35 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Wed, 2 Dec 2020, Mattias Gaertner via fpc-pascal wrote:
>[...]
> > What about the simple explanation, that there are two
> > resourcestrings with the same name in RTLConsts and LCLStrConsts and
> > Luca is looking at the wrong one?  
> 
> Also an option. :-)
> The question is then why there are 2 copies of a string ? :-)

That's the stupidity.


> > See Hanlon's razor.  
> 
> What's wrong with Occam's razor ? Too old ?

Occam is about most simple. Hanlon specifies that stupidity is more
simple than malice.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get the current translation of a resource string?

2020-12-02 Thread Mattias Gaertner via fpc-pascal
On Wed, 2 Dec 2020 13:30:13 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Wed, 2 Dec 2020, Luca Olivetti via fpc-pascal wrote:
> 
>[...]
> > but it doesn't work (sCannotFocus holds the original, not the 
> > translated, string).  
> 
> Seems like Lazarus is not using the regular resourcestrings then,
> because the whole point of using resourcestrings is that their value
> is the translated value...

Sounds like a conspiracy theory.

What about the simple explanation, that there are two
resourcestrings with the same name in RTLConsts and LCLStrConsts and
Luca is looking at the wrong one?

See Hanlon's razor.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] fppdf textwidth

2020-11-09 Thread Mattias Gaertner via fpc-pascal
Hi all,

This has probably been asked before but I can't find the answer.

How to get the text width of a string?

I see code for the standard pdf fonts, but all these functions are
private.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] uses in '' relative paths

2020-10-08 Thread Mattias Gaertner via fpc-pascal
On Thu, 8 Oct 2020 09:37:06 -0300
"Marcos Douglas B. Santos via fpc-pascal"
 wrote:

>[...]
> > > unit TOML;
> > > interface
> > > uses
> > >   TOMLParser in '/sources',
> > >   TOMLTypes in '/sources';  
> >
> > uses
> >   TOMLParser in 'sources/TOMLParser.pas',
> >   TOMLTypes in 'sources/TOMLTypes.pas';
> >
> > Not Delphi compatible.  
> 
> I think this works even on Delphi 7...

Delphi allows it only in program, not in unit.

Mattis

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] uses in '' relative paths

2020-10-07 Thread Mattias Gaertner via fpc-pascal
On Wed, 7 Oct 2020 10:53:16 -0600
Ryan Joseph via fpc-pascal  wrote:

> I'm trying "uses in" which I never knew existed before.
> 
> The idea is that I provide a path to TOML.pas using -Fu then use the
> "in" syntax to reference the units which are in a subdirectory. This
> makes it safe from the project importing the unit so any private
> units in the subdirectory don't override units from the importing
> project.
> 
> unit TOML;
> interface
> uses
>   TOMLParser in '/sources',
>   TOMLTypes in '/sources';

uses
  TOMLParser in 'sources/TOMLParser.pas',
  TOMLTypes in 'sources/TOMLTypes.pas';

Not Delphi compatible.
 
> This doesn't seem to be working however. I was hoping that I could
> then omit an extra -Fu flag to the subdirectory "/sources" thus
> making it easier to include the main unit but maybe that's not how
> the "uses in" syntax works. 

Only in FPC:

{$unitpath sources}
interface
uses
  TOMLParser, TOMLTypes;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPGMapObject duplicate errors

2020-10-03 Thread Mattias Gaertner via fpc-pascal
On Sat, 3 Oct 2020 15:53:58 +0200 (CEST)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Fri, 2 Oct 2020, Ryan Joseph via fpc-pascal wrote:
>[...]
> > Thanks. Sneaky that sorted had to be set to true. Not sure why that
> > would be.  
> 
> Because otherwise it would take a linear search to do IndexOf
> whenever you insert/append an element in the list.

Insert element is linear anyway.

Why not set Duplicate to dupAccept as default?
 
> It is in fact documented, so you know:
> https://www.freepascal.org/docs-html/current/rtl/fgl/tfpsmap.duplicates.html

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String literals and code page of .pas source file

2020-09-09 Thread Mattias Gaertner via fpc-pascal
On Wed, 09 Sep 2020 17:44:11 +0200
Tomas Hajny via fpc-pascal  wrote:

> On 2020-09-09 17:37, Mattias Gaertner via fpc-pascal wrote:
> > On Wed, 09 Sep 2020 17:25:09 +0200
> > Tomas Hajny via fpc-pascal  wrote:
> >   
> >> On 2020-09-09 13:51, LacaK via fpc-pascal wrote:
> >> [...]
> >> A simple question - is TLabel.Caption declared as Utf8String (I
> >> don't use Lazarus)? _Then_ it should work without any issues
> >> and/or special attention from users.  
> > 
> > Declaring as UTF8String would insert implicit conversion code for
> > all String (CP_ACP), so basically everywhere.  
> 
> Everywhere except when used with other Utf8string variables and 
> constants. 

True.

> The implicit conversion is explicitly expected by the user
> in this case if I understand it correctly (source in CP1250), right?

If you mean the "non implicit conversion" requires explicit
conversion by the user, then yes.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String literals and code page of .pas source file

2020-09-09 Thread Mattias Gaertner via fpc-pascal
On Wed, 09 Sep 2020 17:25:09 +0200
Tomas Hajny via fpc-pascal  wrote:

> On 2020-09-09 13:51, LacaK via fpc-pascal wrote:
>[...]
> A simple question - is TLabel.Caption declared as Utf8String (I don't 
> use Lazarus)? _Then_ it should work without any issues and/or special 
> attention from users.

Declaring as UTF8String would insert implicit conversion code for all
String (CP_ACP), so basically everywhere.


Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String literals and code page of .pas source file

2020-09-08 Thread Mattias Gaertner via fpc-pascal
On Tue, 8 Sep 2020 20:27:20 +0200
Jonas Maebe via fpc-pascal  wrote:

> On 07/09/2020 08:51, LacaK via fpc-pascal wrote:
> 
> > attached simple Lazarus compilable project (one Form).
> > 
> > ...
> > type
> >   String1250 = type AnsiString(1250);
> > 
> > const
> >   c2: AnsiString = 'áéíóčž';
> >   c3: WideString = 'áéíóčž';
> >   c4: String1250 = 'áéíóčž';
> > 
> > { TForm1 }
> > 
> > procedure TForm1.FormShow(Sender: TObject);
> > begin
> >   label1.Caption:='áéíóčž'; // FAIL
> >   label2.Caption:=c2;   // FAIL

label2.Caption:='a'+c2; // OK

> >   label3.Caption:=c3;   // OK
> >   label4.Caption:=c4;   // FAIL
> > end;  

Reason is that LCL TLabel.Caption expects UTF-8.
You can use 

label2.Caption:=WinCPToUTF8(c2); // from unit LazUTF8

Maybe SetCaption could check if passed string is not CP_ACP and do a
conversion.

 
Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpmake addlibrary

2020-08-30 Thread Mattias Gaertner via fpc-pascal
On Sun, 30 Aug 2020 16:22:58 +0200 (CEST)
Michael Van Canneyt  wrote:

> On Sun, 30 Aug 2020, Mattias Gaertner wrote:
> 
> > On Sun, 30 Aug 2020 14:30:11 +0200 (CEST)
> > Michael Van Canneyt  wrote:
> >  
> >> [...]  
> >>> Is there a workaround for fpc 3.2.0?  
> >>
> >> Yes:
> >>
> >> AddLibrary('libbla.pp').Options.Add('-obla.so')  
> >
> > Do you mean:
> >
> > {$IFDEF Linux}
> > AddLibrary('libbla.pp').Options.Add('-obla.so')
> > {$ENDIF}  
> 
> Will be ok unless you want to crosscompile. In the latter case you
> must check the installer targetOS.

How?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpmake addlibrary

2020-08-30 Thread Mattias Gaertner via fpc-pascal
On Sun, 30 Aug 2020 14:16:14 +0200 (CEST)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Sun, 30 Aug 2020, Mattias Gaertner via fpc-pascal wrote:
> 
> > On Sun, 30 Aug 2020 13:38:12 +0200 (CEST)
> > Michael Van Canneyt via fpc-pascal 
> > wrote:
> >  
> >> On Sun, 30 Aug 2020, Mattias Gaertner via fpc-pascal wrote:
> >>   
> >> > Hi,
> >> >
> >> > AddLibrary('libbla.pp') creates under Linux "blalib.so".
> >> > I want "bla.so".
> >> >
> >> > How to do that?   
> >> 
> >> AddLibrary('libbla.pp').SetExeName('bla');  
> >
> > Creates "bla", not "bla.so".  
> 
> I had a look at the code, it indeed cuts off the extension.
> That does not seem logical.
> 
> Maybe we need to add OutputFileName : string which simply sets the -o
> option, SetExeName() can then just set OutputFileName.

Is there a workaround for fpc 3.2.0?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpmake addlibrary

2020-08-30 Thread Mattias Gaertner via fpc-pascal
On Sun, 30 Aug 2020 13:38:12 +0200 (CEST)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Sun, 30 Aug 2020, Mattias Gaertner via fpc-pascal wrote:
> 
> > Hi,
> >
> > AddLibrary('libbla.pp') creates under Linux "blalib.so".
> > I want "bla.so".
> >
> > How to do that?  
> 
> AddLibrary('libbla.pp').SetExeName('bla');

Creates "bla", not "bla.so".


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] fpmake addlibrary

2020-08-30 Thread Mattias Gaertner via fpc-pascal
Hi,

AddLibrary('libbla.pp') creates under Linux "blalib.so".
I want "bla.so".

How to do that?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus start problem after power outage on RPi4

2020-08-24 Thread Mattias Gaertner via fpc-pascal
On Mon, 24 Aug 2020 09:12:19 +0200
Bo Berglund via fpc-pascal  wrote:

> Tonight there was a power outage in my home where I have a RaspberryPi
> 4B development system with Lazarus 2.0.8 and Fpc 3.0.4.
> 
> When it happened the system was running including Lazarus.
> Now when I start Lazarus I get to a dialog saying:
> 
> -
> Upgrade configuration
> THere is already a configuration from version prior to 2.0.8 in
> /home/pi/.lazarus_2.0.8
> The old configuration will be upgraded.
> If you want to use two different Lazarus versions you must
> start the second Lazarus with the command line parameter
> primary-config-path or pcp
> 
> 
> [Abort]  [Upgrade]
> -
> 
> Obviously my start desktop file for Lazarus specifies to use pcp as I
> have several versions of Lazarus installed.
> 
> In order not to break anything I used Abort and started checking the
> content of my config dir and comparing to another 2.0.8 version.
> 
> What I found is that there are 3 files in the problem dir that have
> suspicious timestamps/sizes:
> 
> -rw-r--r--  1 pi pi306 Aug 24 03:59 EditorMacros.xml
> -rw-r--r--  1 pi pi  0 Jan  1  1970 environmentoptions.xml
> -rw-r--r--  1 pi pi   2883 Aug 24 03:59 inputhistory.xml
> 
> In the other Lazarus 2.0.8 config dir (set to use fpc 3.2) these files
> are as follows:
> 
> -rw-r--r--  1 pi pi   9735 Jun 21 17:13 environmentoptions.xml
> -rw-r--r--  1 pi pi712 Jun 21 17:13 inputhistory.xml
> 
> EditorMacros.xml is missing in the other dir.
> 
> 
> What to do? It seems like the environmentoptions.xml got hosed in the
> power outage...
> 
> Can I copy this file from an RPi3B where I have installed the same
> versions of Lazarus and Fpc in the same file locations (I use the same
> install scripts on all RPi:s)?

Yes.
After start fix the paths in Tools / Options / Env. / Files to point to
the right fpc.

 
> I really do not want to lose any of what I worked on last night before
> I stopped at 00:31 after finally fixing a persistent bug.


Mattias
 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus Release 2.0.10

2020-07-11 Thread Mattias Gaertner via fpc-pascal
The Lazarus team is glad to announce the release of Lazarus 2.0.10.

This release was built with FPC 3.2.0.
The previous release Lazarus 2.0.8 was built with FPC 3.0.4. 

Here is the list of changes for Lazarus and Free Pascal:
http://wiki.lazarus.freepascal.org/Lazarus_2.0.0_release_notes
http://wiki.lazarus.freepascal.org/User_Changes_3.2.0

Windows users should be careful with -O3 or higher optimization, due to
bug https://bugs.freepascal.org/view.php?id=37305.

Here is the list of fixes for Lazarus 2.0.x:
http://wiki.freepascal.org/Lazarus_2.0_fixes_branch

The release is available for download on SourceForge:
http://sourceforge.net/projects/lazarus/files/

Choose your CPU, OS, distro and then the "Lazarus 2.0.10" directory.

Checksums for the SourceForge files:
http://www.lazarus-ide.org/index.php?page=checksums#2_0_10

Minimum requirements:

Windows:
  2k, XP, Vista, 7, 8, 8.1 and 10, 32 or 64bit.

FreeBSD/Linux:
  gtk 2.8 for gtk2, qt4.5 for qt, qt5.6 for qt5, 32 or 64bit.

Mac OS X:
  Cocoa (64bit) 10.12 to 10.15, Carbon (32bit) 10.5 to 10.14, qt and
  qt5 (32 or 64bit).

The svn tag is
http://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10

For people who are blocked by SF, the Lazarus releases from SourceForge
are mirrored at: ftp://ftp.freepascal.org/pub/lazarus/releases/


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Codetools, identity nodes from includes

2020-07-07 Thread Mattias Gaertner via fpc-pascal
On Tue, 7 Jul 2020 14:09:09 +0700
Ryan Joseph via fpc-pascal  wrote:

> > On Jul 7, 2020, at 4:57 AM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > Something like this:
> > 
> > Node:=AItem.Node;
> > if Node<>nil then
> > begin
> >  Scanner:=Tool.Scanner;

Scanner:=AItem.Tool.Scanner;

> >  LinkIndex:=Scanner.LinkIndexAtCleanPos(Node.StartPos);
> >  if LinkIndex<0 then
> >// dangling node, e.g. syntax error
> >  else
> >InIncludeFile:=Scanner.LinkP[LinkIndex]^.Code<>Scanner.MainCode;
> > end else
> >  ; // artificial node, e.g. intrinsic  

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Codetools, identity nodes from includes

2020-07-06 Thread Mattias Gaertner via fpc-pascal
On Mon, 6 Jul 2020 10:27:55 +0700
Ryan Joseph via fpc-pascal  wrote:

> Currently I walk the node tree for a given unit and collect all the
> relevant symbols into a list which represents the symbols in the
> current document. I'm running into problems with include files
> because I'm getting symbols which technically belong to another file
> which should not be displayed according to the LSP.
> 
> Given a TCodeTreeNode can I identity if the node came from an include
> file or not so I can ignore it?

Something like this:

Node:=AItem.Node;
if Node<>nil then
begin
  Scanner:=Tool.Scanner;
  LinkIndex:=Scanner.LinkIndexAtCleanPos(Node.StartPos);
  if LinkIndex<0 then
// dangling node, e.g. syntax error
  else
InIncludeFile:=Scanner.LinkP[LinkIndex]^.Code<>Scanner.MainCode;
end else
  ; // artificial node, e.g. intrinsic

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] CodeTools reduce number of completions

2020-07-02 Thread Mattias Gaertner via fpc-pascal
On Thu, 2 Jul 2020 12:55:24 +0700
Ryan Joseph via fpc-pascal  wrote:

>[...]What would be more helpful is knowing which identifiers are
> from those large units and opting out of additional processing. Is
> that something which can be quickly known?

Maybe something like this:

List:=CodeToolBoss.IdentifierList;
for i:=0 to List.GetFilteredCountCnt-1 do
begin
  Item:=List.FilteredItems[i];
  if (Item.Tool<>nil) then begin
if
RightStr(Item.Tool.MainFilename,33)='packages/univint/src/MacOSAll.pas'
then continue;

if Item.Tool.Scanner.CleanedLen>100 then 
  continue;
  end;
end;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


  1   2   3   4   5   6   7   8   9   10   >