[fpc-pascal] Re: DOSbox issues
From: Reinier Olislagers > Just for interest: are you trying out FPC for DOS for fun or do you need > to create/support DOS (not Windows) programs? I think I'm trying it just for fun. Actually I was angry because my Allegro.pas wrapper doesn't work (well, version 4.4 almost do but version 5 only does on "debug" mode), so I was wondering to write an actual port of the library instead of a wrapper. I did wrote a simple DOS game library in C a lot of years ago so I think it's a good place to start with, and also because I liked DOS a lot and Allegro dropped out it some time ago. Also I think that Pascal deserves its own "game library" instead of use those "C style" ones as SDL and Allegro. I think I'll try FreeDOS in a VM. I hope I can remember how to mount a FAT32 image on Linux... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
On 8/20/12, michael.vancann...@wisa.be wrote: > There is no such function. Thanks for the quick response. I ended up with this: function IsRootPath(APath: String): Boolean; //crude function, it maybe needs support for UNC drives var D: String; Len: Integer; begin D := ExtractFileDrive(APath); Len := Length(D); System.Delete(APath, 1, Len); Result := (Length(APath) = 1) and (APath[1] in AllowDirectorySeparators); end; Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
Am 2012-08-20 00:17, schrieb Bart: > Does fpc have a function that determines if a given paths is the root > (e.g. '/' in Linux, 'F:\' in Windows)? The question is: For what reason is this function needed? If you use "subst" on Windows you can make every path to a root path if you want. > The Delphi converter from Lazarus needs such a function, Why? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like anIsRootPath() function?
> I ended up with this: > > function IsRootPath(APath: String): Boolean; > //crude function, it maybe needs support for UNC drives > var > D: String; > Len: Integer; > begin > D := ExtractFileDrive(APath); > Len := Length(D); > System.Delete(APath, 1, Len); > Result := (Length(APath) = 1) and (APath[1] in > AllowDirectorySeparators); > end; > That doesn't work for // and c:\.\ and many more combinations that all end up at the root. It doesn't work for relative paths either. Ludo ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
Am 20.08.2012 14:05, schrieb Jürgen Hestermann: Am 2012-08-20 00:17, schrieb Bart: > Does fpc have a function that determines if a given paths is the root > (e.g. '/' in Linux, 'F:\' in Windows)? The question is: For what reason is this function needed? If you use "subst" on Windows you can make every path to a root path if you want. Maybe because he wants to determine whether a path is absolute or not? So that he can e.g. convert an absolute path to a relative one so he can save this in a configuration in a more "portable" way. "subst" (or adding the path to DosDevices in the registry which is the way I prefer for persistent substing ;) ) might be a completely wrong solution or a solution where you shoot cannonballs on little birds... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
Am 2012-08-20 14:38, schrieb Sven Barth: > Am 20.08.2012 14:05, schrieb Jürgen Hestermann: >> The question is: For what reason is this function needed? If you use >> "subst" on Windows you can make every path to a root path if you want. > > Maybe because he wants to determine whether a path is absolute or not? Absolute? You mean in contrast to relative? Then you only need to look for . or .. in parts of the path. If you mean that it is the root of a disk then you cannot be sure by looking at the path because as mentioned with subst you can make any path to be a root path. If Z:\ points to c:\data\whatever then of what use is it to know that Z:\ is a root path? > So that he can e.g. convert an absolute path to a relative one so he can save this in a configuration in a more "portable" way. For this purpose functions already exist (ExpandPath). But there is no need to know about root or not if you use them. > "subst" (or adding the path to DosDevices in the registry which is the way I prefer for persistent substing ;) ) might be a completely wrong solution or a > solution where you shoot cannonballs on little birds... I did not write that subst should be a solution to anything. It was just an example that any path can be made a root path with subst. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] EControlC instead of EZeroDivide when using SSE instructions
Hello all, I'm using FreePascal 2.6.0 under Win32 here and I'm seeing a very weird behavior as I'm not getting EZeroDivide when doing float divisions, but a rather surprising EControlC. As I was writing the code in assembly, I also tried with plain Pascal code, but I get the same result. Here is the code: program test; uses classes, sysutils; procedure DirectTestExcept; const A: Double = 5; B: Double = 0; asm movsd xmm0, A divsd xmm0, B end; procedure MyTestExcept; var Tmp: Double; begin Tmp := 0.0; Tmp := 5.0 / Tmp; end; begin try MyTestExcept; except on E: Exception do WriteLn(E.ClassName + ': ' + E.Message); end; try DirectTestExcept; except on E: Exception do WriteLn(E.ClassName + ': ' + E.Message); end; end. When I first saw the EControlC, I thought that maybe the initial exception was eaten up, but it seems it's not the case because the above program gives this output: EControlC: Control-C hit EControlC: Control-C hit The command line used to compile is the following: ppc386.exe -alt -gl -CF64 -Cfsse2 -Mdelphi test.dpr Looking at the generated assembly, the pure pascal one uses the same operands that my assembly, so it makes sense it behaves similarly. Does any of you have any suggestion as to explain this behavior, and best of all, how to fix it? Regards Olivier ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
On Mon, 20 Aug 2012 14:38:05 +0200 Sven Barth wrote: > Am 20.08.2012 14:05, schrieb Jürgen Hestermann: > > Am 2012-08-20 00:17, schrieb Bart: > > > Does fpc have a function that determines if a given paths is the root > > > (e.g. '/' in Linux, 'F:\' in Windows)? > > > > The question is: For what reason is this function needed? If you use > > "subst" on Windows you can make every path to a root path if you want. > > Maybe because he wants to determine whether a path is absolute or not? No, for this there is FilenameIsAbsolute in LazUtils. It is about scanning the directory. Juha needs a simple heuristic if the converter should search the parent directory for related files. Apparently it is a bad idea to scan a root directory. See http://bugs.freepascal.org/view.php?id=22630 > So that he can e.g. convert an absolute path to a relative one so he can > save this in a configuration in a more "portable" way. "subst" (or > adding the path to DosDevices in the registry which is the way I prefer > for persistent substing ;) ) might be a completely wrong solution or a > solution where you shoot cannonballs on little birds... Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Searching for files all over the disk
Am 2012-08-20 16:28, schrieb Mattias Gaertner: Apparently it is a bad idea to scan a root directory. See http://bugs.freepascal.org/view.php?id=22630 Well, it is a bad idea to wildly scan directory branches "just in case" at all. That's fooling so many people and there is no good reason for doing so. Only paths specified by the user (i.e. in config) should be searched. This bug reports makes it totaly obvious. Beeing too smart is never a good idea (for a program). The only outcome of such things is that users don't understand what is happening. I would not want any program to heavily scan my disk(s) and pick up any file that seems to fit for whatever then doing things to (or with) it I cannot control anymore. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Searching for files all over the disk
On 20-8-2012 16:47, Jürgen Hestermann wrote: > > Am 2012-08-20 16:28, schrieb Mattias Gaertner: >> Apparently it is a bad idea to scan a root directory. See >> http://bugs.freepascal.org/view.php?id=22630 > > Well, it is a bad idea to wildly scan directory branches "just in case" > at all. > That's fooling so many people and there is no good reason for doing so. > Only paths specified by the user (i.e. in config) should be searched. > This bug reports makes it totaly obvious. > Beeing too smart is never a good idea (for a program). > The only outcome of such things is that users don't understand what is > happening. > I would not want any program to heavily scan my disk(s) and pick up any > file that seems > to fit for whatever then doing things to (or with) it I cannot control > anymore. Then it is perhaps time for you to put your money where your mouth is and submit a "proper" patch? I myself have been quite happy with the Delphi converter... and I would love to see it improved. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
On Mon, August 20, 2012 16:28, Mattias Gaertner wrote: > On Mon, 20 Aug 2012 14:38:05 +0200 > Sven Barth wrote: > >> Am 20.08.2012 14:05, schrieb JĂźrgen Hestermann: >> > Am 2012-08-20 00:17, schrieb Bart: >> > > Does fpc have a function that determines if a given paths is the >> root >> > > (e.g. '/' in Linux, 'F:\' in Windows)? >> > >> > The question is: For what reason is this function needed? If you use >> > "subst" on Windows you can make every path to a root path if you want. >> >> Maybe because he wants to determine whether a path is absolute or not? > > No, for this there is FilenameIsAbsolute in LazUtils. > > It is about scanning the directory. Juha needs a simple > heuristic if the converter should search the parent directory for > related files. > Apparently it is a bad idea to scan a root directory. > > See > http://bugs.freepascal.org/view.php?id=22630 If that is the original problem, you could use the following check: if ExpandFileName (APath+'..'+DirectorySeparator) <> ExpandFileName (APath) then ... This is because MS Windows API happily accepts paths containing references to supposed parent directory of a root directory and silently ignores that part of the path specification. We do the same in ExpandFileName in order to remain Delphi compatible (because Delphi apparently relies on a Win32 API call for ExpandFileName whereas FPC has its own cross-platform implementation). DirectoryExists for 'c:\..\' returns true under Win32 for the same reason. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible RTFM question: is there something like an IsRootPath() function?
On 8/20/12, Tomas Hajny wrote: > If that is the original problem, you could use the following check: > > if ExpandFileName (APath+'..'+DirectorySeparator) <> ExpandFileName > (APath) then ... [snip] > implementation). DirectoryExists for 'c:\..\' returns true under Win32 for > the same reason. The supplied path in this scenario (Delphi converter) already is processed for any .. in it by TrimFileName() (FileProcs unit from Lazarus CodeTools). And yes, it will not detect a substituted drive or a network drive, but in the context of the original problem, this is not really a problem. [quote] Your program is in directory C:\Bug4, right? Could you try moving it one level down in directory hierarchy, for example to C:\SW\Bug4 or whatever. The converter scans in a background thread all directories under the converted project's parent directory, searching for pascal source files. Many projects have library sources organized that way. Obviously it creates a problem if your project is just under C:\ root. [/quote] For this the current solution will do for now. Both Juha and me were just wondering if any such function already existed. Given your comments, I can see it's unlikely we will have such a general function, given all the possible exceptions mentioned above. Thanks everybody for your input. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On 8/20/12, Jürgen Hestermann wrote: > Well, it is a bad idea to wildly scan directory branches "just in case" at > all. In the context of the converter it is not a "just in case" scenario. My Delphi projects are located like this: F:\Delphi Projecten //all my projects reside in a subfolder of this F:\Delphi Projecten\Mijn Lib //general prupose units F:\Delphi Projecten\PasParser F:\Delphi Projecten\Endurance Calculator F:\Delphi Projecten\HtmlEdit F:\Delphi Projecten\etc. So in order to find the nldlg32 unit that the PasParser project uses, the converter has to look in my "Mijn Lib" folder. As Juha has pointed out, this is a general way projects are organized. Hence this particular search strategy. Obviously it needed some limitation, and we have implemented that (crude as it may be). > That's fooling so many people and there is no good reason for doing so. As explained above, there is. > Only paths specified by the user (i.e. in config) should be searched. A valid suggestion on how to improve the converter! Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On 20/08/2012 23:00, Bart wrote: On 8/20/12, Jürgen Hestermann wrote: Well, it is a bad idea to wildly scan directory branches "just in case" at all. In the context of the converter it is not a "just in case" scenario. My Delphi projects are located like this: F:\Delphi Projecten //all my projects reside in a subfolder of this F:\Delphi Projecten\Mijn Lib //general prupose units F:\Delphi Projecten\PasParser F:\Delphi Projecten\Endurance Calculator F:\Delphi Projecten\HtmlEdit F:\Delphi Projecten\etc. So in order to find the nldlg32 unit that the PasParser project uses, the converter has to look in my "Mijn Lib" folder. As Juha has pointed out, this is a general way projects are organized. Hence this particular search strategy. Well I am not myself a user of the converter. But even if files are organized like this, then there may be several versions of the "Mijn Lib" (or one of the units that should be found there, is also in another folder). Then the converter can't know... IMHO, if should ask which additional path to scan, for required units. The parent dir can be set in the options, then it can be configured once and for all. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On Mon, Aug 20, 2012 at 5:47 PM, Jürgen Hestermann < juergen.hesterm...@gmx.de> wrote: > Well, it is a bad idea to wildly scan directory branches "just in case" at > all. > That's fooling so many people and there is no good reason for doing so. > Only paths specified by the user (i.e. in config) should be searched. > This bug reports makes it totaly obvious. > Beeing too smart is never a good idea (for a program). > The only outcome of such things is that users don't understand what is > happening. > I would not want any program to heavily scan my disk(s) and pick up any > file that seems > to fit for whatever then doing things to (or with) it I cannot control > anymore. > Which people exactly are getting fooled? Lots of heuristics and guessing is involved when converting a random Delphi project. Most projects still cannot be fully converted but the success rate can be increased with many tricks. Scanning the parent directory improves it a lot! The converter is not "too smart", it is rather still "too dummy" as it cannot convert all projects. About scanning "only paths specified by the user", do you really mean the user should search for pascal sources in a to-be-converted Delphi project directories, then type the directory names into a config file and then feed that file to the converter's GUI? IMO that is a job for the converter because its whole purpose is to automate the task. You can still do it manually if you like of course. Did you ever try converting a non-trivial Delphi project? Try it and you get an idea of the challenges. Regards, Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On Tue, Aug 21, 2012 at 1:28 AM, Martin wrote: > Well I am not myself a user of the converter. > But even if files are organized like this, then there may be several > versions of the "Mijn Lib" (or one of the units that should be found > there, is also in another folder). Then the converter can't know... > > IMHO, if should ask which additional path to scan, for required units. The > parent dir can be set in the options, then it can be configured once and > for all. > The converter is clever enough to ask from user what to do with an unknown unit name. It can be commented out or the user can search and select its location. However, scanning the parent directory makes the number of "stupid" questions lower as the obvious locations are already found. Lazarus source editor and debugger must work accurately but Delphi conversion is all about heuristics. :) Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On 20/08/2012 23:55, Juha Manninen wrote: About scanning "only paths specified by the user", do you really mean the user should search for pascal sources in a to-be-converted Delphi project directories, then type the directory names into a config file and then feed that file to the converter's GUI? IMO that is a job for the converter because its whole purpose is to automate the task. You can still do it manually if you like of course. But it could ask about certain assumptions. Like "Should I scan the parent dir", No, yes this time, yes always Checking the root path may not be good enough. On linux you have symbolic links. On Win you have NTFS mount-points: Any partition can have zero or more drive letters, and zero or more mount points. That means that C:\ may also be found under N:\Projects\DriveC\. And then Projects could be in N:\Projects. Searching N:\Projects would obviously be to much again. So it is very hard to tell how data is organized. Further, I have not tested, but it may well be possible to create circular mounts ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On 21/08/2012 00:09, Juha Manninen wrote: The converter is clever enough to ask from user what to do with an unknown unit name. It can be commented out or the user can search and select its location. However, scanning the parent directory makes the number of "stupid" questions lower as the obvious locations are already found. If the user can answer "Yes always" then this is a one time ask question. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Searching for files all over the disk
On Tue, Aug 21, 2012 at 2:11 AM, Martin wrote: > On 21/08/2012 00:09, Juha Manninen wrote: > >> The converter is clever enough to ask from user what to do with an >> unknown unit name. >> It can be commented out or the user can search and select its location. >> However, scanning the parent directory makes the number of "stupid" >> questions lower as the obvious locations are already found. >> > > If the user can answer "Yes always" then this is a one time ask question. > True. It can also be a persistent option (checkbox) in the settings form which always opens before conversion. I will add it. Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal