Ticket #34: 0001-Partial-implementation-of-ticket-34-in-the-Delphi.patch

File 0001-Partial-implementation-of-ticket-34-in-the-Delphi.patch, 6.3 KB (added by debrouxl, 3 years ago)

Partial patch for specifying a folder name for compressed programs

  • tigcc-linux/sources/tigcc/src/tigcc.c

    From 70818baf2fc2b1df461b0f92f9e739fb912fae5d Mon Sep 17 00:00:00 2001
    From: Lionel Debroux <lionel_debroux@yahoo.fr>
    Date: Wed, 17 Dec 2008 20:45:15 +0100
    Subject: Partial implementation of ticket #34: in the Delphi IDE, the C tigcc and pstarter.s, make it possible to specify a folder name for compressed programs.
     The price to pay is an increase of about 9 bytes (< 1%) of the size of each pstarter.
    
    ---
     tigcc-linux/sources/tigcc/src/tigcc.c |    4 +-
     tigcc/ide/ParsingUnit.pas             |    2 +-
     tigcc/ide/ProjectOptionsUnit.pas      |   79 +++++++++++++--------------
     tigcc/pstarter/pstarter.s             |    4 +-
     4 files changed, 43 insertions(+), 46 deletions(-)
    
    diff --git a/tigcc-linux/sources/tigcc/src/tigcc.c b/tigcc-linux/sources/tigcc/src/tigcc.c
    index d8c5ec8..0c21b56 100755
    a b short int process_arg(short int arg, char *argv[], int argc) 
    122122        exit(-1); 
    123123      } 
    124124      packfile[0] = 0; 
    125       strncpy(packfile, next_arg, 8); 
     125      strncpy(packfile, next_arg, 17); 
    126126      do_pack = TRUE; 
    127127    } 
    128128  } else if(!strcmp("-bsr", cur_arg)) { 
    static short int parse_pstarter(const char *input, const char *output, 
    697697{ 
    698698  FILE *f; 
    699699  char array[65536]; 
    700   char *token = "tempprog"; 
     700  static const char *token = "tempprog\\tempprog"; 
    701701  unsigned int i, n; 
    702702  unsigned int j, k; 
    703703 
  • tigcc/ide/ParsingUnit.pas

    diff --git a/tigcc/ide/ParsingUnit.pas b/tigcc/ide/ParsingUnit.pas
    index 8f3efdf..86357f9 100644
    a b end; 
    269269 
    270270procedure ParsePStarter(const InputFile: string; const OutputFile: string; const PackVar: string); 
    271271const 
    272         TempProg = 'TEMPPROG'; 
     272        TempProg = 'TEMPPROG\TEMPPROG'; 
    273273var 
    274274        I: Integer; 
    275275        ObjectFile: TMemoryStream; 
  • tigcc/ide/ProjectOptionsUnit.pas

    diff --git a/tigcc/ide/ProjectOptionsUnit.pas b/tigcc/ide/ProjectOptionsUnit.pas
    index 13073a2..a83761c 100644
    a b type 
    9393                procedure BrowseButtonClick(Sender: TObject); 
    9494                procedure ProgramOptionsButtonClick(Sender: TObject); 
    9595        private 
     96                function CheckVarName(S: String): Boolean; 
    9697        public 
    9798                InitialLibOptions: TPredefinedLibOptions; 
    9899                ProgramOptionsForm: TProgramOptionsForm; 
    begin 
    136137        VarEditChange (Sender); 
    137138end; 
    138139 
    139 procedure TProjectOptionsForm.VarEditChange(Sender: TObject); 
     140function TProjectOptionsForm.CheckVarName(S: String): Boolean; 
    140141var 
    141         S: string; 
    142142        I: Integer; 
    143143        OK, 
    144144        HasFolder: Boolean; 
    145145begin 
    146         if PackCheckBox.Checked then begin 
    147                 S := PackVarEdit.Text; 
    148                 OK := (Length (S) > 0) and (Length (S) <= 8) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text)); 
    149                 if OK then 
    150                         for I := Length (S) downto 1 do 
    151                                 if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin 
     146        OK := (Length (S) > 0) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text)); 
     147        if OK then begin 
     148                HasFolder := False; 
     149                for I := Length (S) downto 1 do begin 
     150                        if S [I] = '\' then begin 
     151                                if HasFolder then begin 
    152152                                        OK := False; 
    153153                                        Break; 
    154                                 end; 
    155         end else 
    156                 OK := True; 
    157         if OK then begin 
    158                 if DataVarCheckBox.Checked then begin 
    159                         S := DataVarEdit.Text; 
    160                         if PackCheckBox.Checked and (LowerCase (DataVarEdit.Text) = LowerCase (PackVarEdit.Text)) then 
    161                                 OK := False 
    162                         else begin 
    163                                 OK := (Length (S) > 0) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text)); 
    164                                 if OK then begin 
    165                                         HasFolder := False; 
    166                                         for I := Length (S) downto 1 do begin 
    167                                                 if S [I] = '\' then begin 
    168                                                         if HasFolder then begin 
    169                                                                 OK := False; 
    170                                                                 Break; 
    171                                                         end else 
    172                                                                 HasFolder := True; 
    173                                                 end else if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin 
    174                                                         OK := False; 
    175                                                         Break; 
    176                                                 end; 
    177                                         end; 
    178                                         I := Pos ('\', S); 
    179                                         if I > 0 then begin 
    180                                                 if (I - 1 > MaxNameLength) or (Length (S) - I > MaxNameLength) or (I + 1 > Length (S)) or (not (IsCharAlpha (S [I + 1]) or (S [I + 1] in ['A'..'Z', 'a'..'z']))) then 
    181                                                         OK := False; 
    182                                         end else begin 
    183                                                 if Length (S) > MaxNameLength then 
    184                                                         OK := False; 
    185                                         end; 
    186                                 end; 
     154                                end else 
     155                                        HasFolder := True; 
     156                        end else if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin 
     157                                OK := False; 
     158                                Break; 
    187159                        end; 
    188160                end; 
     161                I := Pos ('\', S); 
     162                if I > 0 then begin 
     163                        if (I - 1 > MaxNameLength) or (Length (S) - I > MaxNameLength) or (I + 1 > Length (S)) or (not (IsCharAlpha (S [I + 1]) or (S [I + 1] in ['A'..'Z', 'a'..'z']))) then 
     164                                OK := False; 
     165                end else begin 
     166                        if Length (S) > MaxNameLength then 
     167                                OK := False; 
     168                end; 
     169        end; 
     170        Result := OK; 
     171end; 
     172 
     173procedure TProjectOptionsForm.VarEditChange(Sender: TObject); 
     174var 
     175        S: string; 
     176        OK: Boolean; 
     177begin 
     178        OK := True; 
     179        if PackCheckBox.Checked then begin 
     180                if DataVarCheckBox.Checked and (LowerCase (DataVarEdit.Text) = LowerCase (PackVarEdit.Text)) then 
     181                        OK := False 
     182                else 
     183                        OK := CheckVarName(PackVarEdit.Text); 
    189184        end; 
     185        if OK then 
     186                OK := CheckVarName(DataVarEdit.Text); 
    190187        OKButton.Enabled := OK; 
    191188end; 
    192189 
  • tigcc/pstarter/pstarter.s

    diff --git a/tigcc/pstarter/pstarter.s b/tigcc/pstarter/pstarter.s
    index 9cfb1a2..6e69a67 100755
    a b  
    1212| decompression routine. (The Lesser General Public License restrictions 
    1313| do apply in other respects; for example, they cover modification of 
    1414| the launcher. Licensing restrictions of the chosen decompression routine 
    15 | also apply.) Merely replacing "tempprog" with the name of your program 
     15| also apply.) Merely replacing "tempprog\\tempprog" with the name of your program 
    1616| shall not be considered a modification for the purposes of this 
    1717| paragraph. This exception notice must be removed on modified copies of 
    1818| this launcher. 
    CompressedHandle: .word 0 | handle to unlock, 0 if no unlocking needed 
    516516 
    517517.byte 0 
    518518ProgramName:      | program name 
    519 .asciz "tempprog" | to be patched in by TIGCC 
     519.asciz "tempprog\\tempprog" | to be patched in by TIGCC