Przeglądaj źródła

Check for duplicate [ISSigKeys] names at compile time. (Other sections which use names don't have such a check so that's why this is "new" code.)

Martijn Laan 4 miesięcy temu
rodzic
commit
89f067a1c6

+ 1 - 0
Projects/Src/Compiler.Messages.pas

@@ -249,6 +249,7 @@ const
   SCompilerComponentsInvalidLevel = 'Component cannot be more than one level below the preceding component';
   SCompilerComponentsInvalidLevel = 'Component cannot be more than one level below the preceding component';
   SCompilerTasksInvalidLevel = 'Task cannot be more than one level below the preceding task';
   SCompilerTasksInvalidLevel = 'Task cannot be more than one level below the preceding task';
   SCompilerLanguagesOrISSigKeysBadName = 'Parameter "Name" includes invalid characters.' + SNewLine2 + 'It may only include alphanumeric characters and/or underscores, and may not start with a number. Names ''not'', ''and'' and ''or'' are reserved';
   SCompilerLanguagesOrISSigKeysBadName = 'Parameter "Name" includes invalid characters.' + SNewLine2 + 'It may only include alphanumeric characters and/or underscores, and may not start with a number. Names ''not'', ''and'' and ''or'' are reserved';
+  SCompilerISSigKeysNameDuplicated = 'Cannot have multiple entries named "%s"';
   SCompilerISSigKeysKeyNotSpecified = 'Required parameter(s) "KeyFile" or "PublicX"/"PublicY" not specified';
   SCompilerISSigKeysKeyNotSpecified = 'Required parameter(s) "KeyFile" or "PublicX"/"PublicY" not specified';
   SCompilerISSigKeysBadKeyID = 'Value of parameter "KeyID" is not valid for given "KeyFile" or "PublicX"/"PublicY" values.';
   SCompilerISSigKeysBadKeyID = 'Value of parameter "KeyID" is not valid for given "KeyFile" or "PublicX"/"PublicY" values.';
   SCompilerISSigKeysBadKeyFile = 'Key file is malformed';
   SCompilerISSigKeysBadKeyFile = 'Key file is malformed';

+ 7 - 0
Projects/Src/Compiler.SetupCompiler.pas

@@ -89,6 +89,7 @@ type
 
 
     FileLocationEntryFilenames: THashStringList;
     FileLocationEntryFilenames: THashStringList;
     FileLocationEntryExtraInfos: TList;
     FileLocationEntryExtraInfos: TList;
+    ISSigKeysNames: THashStringList;
     WarningsList: THashStringList;
     WarningsList: THashStringList;
     ExpectedCustomMessageNames: TStringList;
     ExpectedCustomMessageNames: TStringList;
     MissingMessagesWarning, MissingRunOnceIdsWarning, MissingRunOnceIds, NotRecognizedMessagesWarning, UsedUserAreasWarning: Boolean;
     MissingMessagesWarning, MissingRunOnceIdsWarning, MissingRunOnceIds, NotRecognizedMessagesWarning, UsedUserAreasWarning: Boolean;
@@ -376,6 +377,8 @@ begin
   UninstallRunEntries := TLowFragList.Create;
   UninstallRunEntries := TLowFragList.Create;
   FileLocationEntryFilenames := THashStringList.Create;
   FileLocationEntryFilenames := THashStringList.Create;
   FileLocationEntryExtraInfos := TLowFragList.Create;
   FileLocationEntryExtraInfos := TLowFragList.Create;
+  ISSigKeysNames := THashStringList.Create;
+  ISSigKeysNames.IgnoreDuplicates := True;
   WarningsList := THashStringList.Create;
   WarningsList := THashStringList.Create;
   WarningsList.IgnoreDuplicates := True;
   WarningsList.IgnoreDuplicates := True;
   ExpectedCustomMessageNames := TStringList.Create;
   ExpectedCustomMessageNames := TStringList.Create;
@@ -423,6 +426,7 @@ begin
   UsedUserAreas.Free;
   UsedUserAreas.Free;
   ExpectedCustomMessageNames.Free;
   ExpectedCustomMessageNames.Free;
   WarningsList.Free;
   WarningsList.Free;
+  ISSigKeysNames.Free;
   FileLocationEntryExtraInfos.Free;
   FileLocationEntryExtraInfos.Free;
   FileLocationEntryFilenames.Free;
   FileLocationEntryFilenames.Free;
   UninstallRunEntries.Free;
   UninstallRunEntries.Free;
@@ -4495,6 +4499,8 @@ begin
       if not IsValidIdentString(Values[paName].Data, False, False) then
       if not IsValidIdentString(Values[paName].Data, False, False) then
         AbortCompile(SCompilerLanguagesOrISSigKeysBadName);
         AbortCompile(SCompilerLanguagesOrISSigKeysBadName);
       Name := LowerCase(Values[paName].Data);
       Name := LowerCase(Values[paName].Data);
+      if ISSigKeysNames.Add(Name) = -1 then
+        AbortCompileFmt(SCompilerISSigKeysNameDuplicated, [Name]);
 
 
       { KeyFile & PublicX & PublicY }
       { KeyFile & PublicX & PublicY }
       var KeyFile := PrependSourceDirName(Values[paKeyFile].Data);
       var KeyFile := PrependSourceDirName(Values[paKeyFile].Data);
@@ -8179,6 +8185,7 @@ begin
     CallPreprocessorCleanupProc;
     CallPreprocessorCleanupProc;
     UsedUserAreas.Clear;
     UsedUserAreas.Clear;
     WarningsList.Clear;
     WarningsList.Clear;
+    ISSigKeysNames.Clear;
     { Free all the data }
     { Free all the data }
     DecompressorDLL.Free;
     DecompressorDLL.Free;
     SetupE32.Free;
     SetupE32.Free;