View Issue Details

IDProjectCategoryView StatusLast Update
0006491FPCRTLpublic2006-06-22 15:55
ReporterFPC core team Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSWin32 
Product Version2.0.2 
Fixed in Version2.2.0 
Summary0006491: SysUtils.ExtractFileDrive inconsistent with Delphi
DescriptionRunning the following unit test under Lazarus & Delphi produces different results! It fails under Free Pascal. I traced the difference to the ExtractFileDrive call. Under Delphi it returns 'c:' and under FPC it returns ''.


CheckEquals( '', tiUtils.tiRemoveDrive('c:'), 'Failed on 1' );
Additional InformationReporter: Graeme Geldenhuys
EMail: graeme at mastermaths dot co dot za
TagsNo tags attached.
Fixed in Revision3560
FPCOldBugId4585
FPCTarget
Attached Files

Activities

2005-12-12 12:00

 

code.pp (657 bytes)   
--------------  CUT  --------------------
function tiRemoveDrive( pStrPath : string ) : string ;
var
  sDrive : string ;
begin
  sDrive := extractFileDrive( pStrPath ) ;
  if sDrive <> '' then begin
    result := copy( pStrPath, length( sDrive )+1, length( pStrPath ) -
                    length( sDrive )) ;
  end else begin
    result := pStrPath ;
  end ;
end ;
--------------  CUT  --------------------


I think the first if statement of [fina.inc] ExtractFileDrive should be change to test 

if (Length(FileName) >= 2) and ...

instead of

if (Length(FileName) >= 3) and ...

code.pp (657 bytes)   

Graeme Geldenhuys

2006-05-18 14:35

reporter   ~0007777

Sorry, I never gave a complete test application in the original bug report. Please see the attached TestExtractDrive.lpr file for an example showing the bug.

------------ Under FPC 2.0.2 on Linux ----------------
graemeg@porky:~/Programming/Tests/ExtractDrive$ ./TestExtractDrive
Start tests...
Failed on 1: Expected <> but found <c:>
...test passed.
...test passed.
...test passed.
Failed on 5: Expected <c:> but found <>
...test passed.
...test passed.
...test passed.
Done.
---------------------- END --------------------------


------------ Under Delphi 7 on Win2000 ---------------
c:\Programming\Tests\extractdrive>testextractdrive
Start tests...
...test passed.
...test passed.
...test passed.
...test passed.
...test passed.
...test passed.
...test passed.
...test passed.
Done.
---------------------- END --------------------------

To fix the problem I believe the following needs to be done.
The first if statement of [fina.inc] ExtractFileDrive should be change to test

  if (Length(FileName) >= 2) and [....]

instead of

  if (Length(FileName) >= 3) and [....]

2006-05-18 14:36

 

TestExtractDrive.lpr (1,439 bytes)

Michael Van Canneyt

2006-05-18 14:48

administrator   ~0007778

Fixed, reworked procedure so it is more efficient. Please test again.

Issue History

Date Modified Username Field Change
2006-05-18 09:39 Michael Van Canneyt Status new => assigned
2006-05-18 09:39 Michael Van Canneyt Assigned To => Michael Van Canneyt
2006-05-18 14:35 Graeme Geldenhuys Note Added: 0007777
2006-05-18 14:36 Graeme Geldenhuys File Added: TestExtractDrive.lpr
2006-05-18 14:48 Michael Van Canneyt Fixed in Revision => 3560
2006-05-18 14:48 Michael Van Canneyt Status assigned => resolved
2006-05-18 14:48 Michael Van Canneyt Fixed in Version => 2.1.1
2006-05-18 14:48 Michael Van Canneyt Resolution open => fixed
2006-05-18 14:48 Michael Van Canneyt Note Added: 0007778
2006-06-22 15:55 Florian Status resolved => closed