View Issue Details

IDProjectCategoryView StatusLast Update
0031007FPCUtilitiespublic2016-11-26 14:33
ReporterMichalis KamburelisAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86-64OSDebian GNU/LinuxOS Version(testing)
Product Version3.1.1Product Build34959 
Target Version3.2.0Fixed in Version3.1.1 
Summary0031007: [patch] ppdep doesn't handle {$else} correctly
DescriptionIf you use a construction like this:

{$ifdef SOMEDEF}
uses AlwaysUsed, Foo;
{$else}
uses AlwaysUsed, Bar;
{$endif}

then "ppdep" utility should either list "AlwaysUsed, Foo" when SOMEDEF is defined, or "AlwaysUsed, Bar" when it's not defined. But currently it doesn't, as the "{$else}" is not correctly understood:

---------------
$ ppdep a.pas
a.ppu: a.pas

$ ppdep -dSOMEDEF a.pas
a.ppu: a.pas \
    alwaysused.ppu \
    foo.ppu \
    alwaysused.ppu \
    bar.ppu

alwaysused.ppu: alwaysused.pas

foo.ppu: foo.pas

bar.ppu: bar.pas
---------------

Fixing it with the attached patch results in correct output:

---------------
$ ./ppdep-mod a.pas
a.ppu: a.pas \
    alwaysused.ppu \
    bar.ppu

alwaysused.ppu: alwaysused.pas

bar.ppu: bar.pas

$ ./ppdep-mod -dSOMEDEF a.pas
a.ppu: a.pas \
    alwaysused.ppu \
    foo.ppu

alwaysused.ppu: alwaysused.pas

foo.ppu: foo.pas
---------------

I did this patch in response to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=845504 . See the bugreport there for more comments.
Tagspatch
Fixed in Revision34965
FPCOldBugId
FPCTarget
Attached Files
  • ppdep-fix-else-handling.patch (454 bytes)
    --- ppdep.pp	2016-11-25 06:25:52.521343605 +0100
    +++ ppdep-mod.pp	2016-11-25 06:18:52.156981295 +0100
    @@ -344,7 +344,7 @@
                             hs^:='';
                           end
                         else
    -                     if (Copy(hs^,2,6)='$ELSE') then
    +                     if (Copy(hs^,2,5)='$ELSE') then
                           begin
                             skip[level]:=skip[level-1] or (not skip[level]);
                             hs^:='';
    
  • a.pas (119 bytes)
    unit A;
    
    interface
    
    {$ifdef SOMEDEF}
    uses AlwaysUsed, Foo;
    {$else}
    uses AlwaysUsed, Bar;
    {$endif}
    
    implementation
    
    end.
    a.pas (119 bytes)
  • alwaysused.pas (46 bytes)
    unit AlwaysUsed;
    interface
    implementation
    end.
    alwaysused.pas (46 bytes)
  • bar.pas (39 bytes)
    unit Bar;
    interface
    implementation
    end.
    bar.pas (39 bytes)
  • foo.pas (39 bytes)
    unit Foo;
    interface
    implementation
    end.
    foo.pas (39 bytes)

Activities

Michalis Kamburelis

2016-11-25 06:48

reporter  

ppdep-fix-else-handling.patch (454 bytes)
--- ppdep.pp	2016-11-25 06:25:52.521343605 +0100
+++ ppdep-mod.pp	2016-11-25 06:18:52.156981295 +0100
@@ -344,7 +344,7 @@
                         hs^:='';
                       end
                     else
-                     if (Copy(hs^,2,6)='$ELSE') then
+                     if (Copy(hs^,2,5)='$ELSE') then
                       begin
                         skip[level]:=skip[level-1] or (not skip[level]);
                         hs^:='';

Michalis Kamburelis

2016-11-25 06:53

reporter  

a.pas (119 bytes)
unit A;

interface

{$ifdef SOMEDEF}
uses AlwaysUsed, Foo;
{$else}
uses AlwaysUsed, Bar;
{$endif}

implementation

end.
a.pas (119 bytes)

Michalis Kamburelis

2016-11-25 06:53

reporter  

alwaysused.pas (46 bytes)
unit AlwaysUsed;
interface
implementation
end.
alwaysused.pas (46 bytes)

Michalis Kamburelis

2016-11-25 06:53

reporter  

bar.pas (39 bytes)
unit Bar;
interface
implementation
end.
bar.pas (39 bytes)

Michalis Kamburelis

2016-11-25 06:53

reporter  

foo.pas (39 bytes)
unit Foo;
interface
implementation
end.
foo.pas (39 bytes)

Michalis Kamburelis

2016-11-25 06:53

reporter   ~0096218

The testcase is comprised of several trivial files:

- a.pas
- alwaysused.pas
- bar.pas
- foo.pas

ppdep needs to find the units to work correctly, as far as I see. Attaching them all. The only one really relevant is the "a.pas".

Michael Van Canneyt

2016-11-26 14:33

administrator   ~0096247

Checked and applied. Thanks for the patch!

Issue History

Date Modified Username Field Change
2016-11-25 06:48 Michalis Kamburelis New Issue
2016-11-25 06:48 Michalis Kamburelis File Added: ppdep-fix-else-handling.patch
2016-11-25 06:53 Michalis Kamburelis File Added: a.pas
2016-11-25 06:53 Michalis Kamburelis File Added: alwaysused.pas
2016-11-25 06:53 Michalis Kamburelis File Added: bar.pas
2016-11-25 06:53 Michalis Kamburelis File Added: foo.pas
2016-11-25 06:53 Michalis Kamburelis Note Added: 0096218
2016-11-25 06:54 Michalis Kamburelis Tag Attached: patch
2016-11-25 10:21 Michael Van Canneyt Assigned To => Michael Van Canneyt
2016-11-25 10:21 Michael Van Canneyt Status new => assigned
2016-11-26 14:33 Michael Van Canneyt Fixed in Revision => 34965
2016-11-26 14:33 Michael Van Canneyt Note Added: 0096247
2016-11-26 14:33 Michael Van Canneyt Status assigned => resolved
2016-11-26 14:33 Michael Van Canneyt Fixed in Version => 3.1.1
2016-11-26 14:33 Michael Van Canneyt Resolution open => fixed
2016-11-26 14:33 Michael Van Canneyt Target Version => 3.2.0