BrianGarland / vscode-rpgfree

Visual Studio Code extension to convert fixed format RPGLE to free format
MIT License
18 stars 11 forks source link

End-DS Output Too Early if Last Subfield of DS uses LIKE and No Additional D-Specs to Convert #89

Closed BrianGodsend closed 1 year ago

BrianGodsend commented 1 year ago

The End-DS is output before the last subfield of a DS. This seems to only happen if the DS is the last D-Spec and is followed only by a C/FREE and free form C-Spec lines of code.

Fixed format RPG:

     D MYFLD1          S              3a
     D MYDS            DS                  QUALIFIED 
     D  MYFLD4                        3a    
     D  MYFLD5                       +3    LIKE(MYFLD1)
     C/FREE
       *inLR = *ON;
       return;

Wrong output:

**FREE
       Dcl-S MYFLD1       Char(3);
       Dcl-DS MYDS  QUALIFIED;
         MYFLD4         Char(3);
        End-DS;
         MYFLD5         Char(+3)   LIKE(MYFLD1);
       *inLR = *ON;
       return;

Expected output:

**FREE
       Dcl-S MYFLD1       Char(3);
       Dcl-DS MYDS  QUALIFIED;
         MYFLD4         Char(3);
         MYFLD5                    LIKE(MYFLD1: +3);
       End-DS;
       *inLR = *ON;
       return;