Browse Source

Use StrToUInt64 to convert "qword" [Registry] ValueData.

i.e., hold off on supporting "_" for now at least.

StrToInteger64 is slated for removal in the future, to be replaced with
a compiler-specific routine. And I'm not sure it makes sense to support
digit separators or other special syntaxes at *run-time* (e.g., when
ValueData specifies a constant).
Jordan Russell 1 month ago
parent
commit
6e0c169a9b
4 changed files with 6 additions and 10 deletions
  1. 1 1
      ISHelp/isetup.xml
  2. 3 4
      Projects/Src/Compiler.SetupCompiler.pas
  3. 1 3
      Projects/Src/Setup.Install.pas
  4. 1 2
      whatsnew.htm

+ 1 - 1
ISHelp/isetup.xml

@@ -2519,7 +2519,7 @@ If <tt>binary</tt> is specified, Setup will create a binary (REG_BINARY) value.<
 </param>
 </param>
 
 
 <param name="ValueData">
 <param name="ValueData">
-<p>The data for the value. If the <tt>ValueType</tt> parameter is <tt>string</tt>, <tt>expandsz</tt>, or <tt>multisz</tt>, this is a string that can include constants. If the data type is <tt>dword</tt> or <tt>qword</tt>, this can be a decimal integer (e.g. "123"), a hexadecimal integer (e.g. "$7B"), or a constant which resolves to an integer. Supports digit separators if the data type is <tt>qword</tt>. If the data type is <tt>binary</tt>, this is a sequence of hexadecimal bytes in the form: "00 ff 12 34". If the data type is <tt>none</tt>, this is ignored.</p>
+<p>The data for the value. If the <tt>ValueType</tt> parameter is <tt>string</tt>, <tt>expandsz</tt>, or <tt>multisz</tt>, this is a string that can include constants. If the data type is <tt>dword</tt> or <tt>qword</tt>, this can be a decimal integer (e.g. "123"), a hexadecimal integer (e.g. "$7B"), or a constant which resolves to an integer. If the data type is <tt>binary</tt>, this is a sequence of hexadecimal bytes in the form: "00 ff 12 34". If the data type is <tt>none</tt>, this is ignored.</p>
 <p>On a <tt>string</tt>, <tt>expandsz</tt>, or <tt>multisz</tt> type value, you may use a special constant called <tt>{olddata}</tt> in this parameter. <tt>{olddata}</tt> is replaced with the previous data of the registry value. The <tt>{olddata}</tt> constant can be useful if you need to append a string to an existing value, for example, <tt>{olddata};{app}</tt>. If the value does not exist or the existing value isn't a string type, the {olddata} constant is silently removed. {olddata} will also be silently removed if the value being created is a <tt>multisz</tt> type but the existing value is not a multi-string type (i.e. it's REG_SZ or REG_EXPAND_SZ), and vice versa.</p>
 <p>On a <tt>string</tt>, <tt>expandsz</tt>, or <tt>multisz</tt> type value, you may use a special constant called <tt>{olddata}</tt> in this parameter. <tt>{olddata}</tt> is replaced with the previous data of the registry value. The <tt>{olddata}</tt> constant can be useful if you need to append a string to an existing value, for example, <tt>{olddata};{app}</tt>. If the value does not exist or the existing value isn't a string type, the {olddata} constant is silently removed. {olddata} will also be silently removed if the value being created is a <tt>multisz</tt> type but the existing value is not a multi-string type (i.e. it's REG_SZ or REG_EXPAND_SZ), and vice versa.</p>
 <p>On a <tt>multisz</tt> type value, you may use a special constant called <tt>{break}</tt> in this parameter to embed line breaks (nulls).</p>
 <p>On a <tt>multisz</tt> type value, you may use a special constant called <tt>{break}</tt> in this parameter to embed line breaks (nulls).</p>
 <example>
 <example>

+ 3 - 4
Projects/Src/Compiler.SetupCompiler.pas

@@ -4287,16 +4287,15 @@ const
   end;
   end;
 
 
   function ConvertQWordString(const S: String): String;
   function ConvertQWordString(const S: String): String;
-  var
-    QW: Integer64;
   begin
   begin
     Result := Trim(S);
     Result := Trim(S);
     { Only check if it doesn't start with a constant }
     { Only check if it doesn't start with a constant }
     if (Result = '') or (Result[1] <> '{') then begin
     if (Result = '') or (Result[1] <> '{') then begin
-      if not StrToInteger64(Result, QW) then
+      var QW: UInt64;
+      if not TryStrToUInt64(Result, QW) then
         AbortCompileParamError(SCompilerParamInvalid2, ParamRegistryValueData);
         AbortCompileParamError(SCompilerParamInvalid2, ParamRegistryValueData);
       { Not really necessary, but sanitize the value }
       { Not really necessary, but sanitize the value }
-      Result := Integer64ToStr(QW);
+      Result := Format('$%x', [QW]);
     end;
     end;
   end;
   end;
 
 

+ 1 - 3
Projects/Src/Setup.Install.pas

@@ -2581,7 +2581,6 @@ var
     CurRegNumber: Integer;
     CurRegNumber: Integer;
     NeedToRetry, DidDeleteKey: Boolean;
     NeedToRetry, DidDeleteKey: Boolean;
     ErrorCode: Longint;
     ErrorCode: Longint;
-    QV: Integer64;
     I: Integer;
     I: Integer;
     AnsiS: AnsiString;
     AnsiS: AnsiString;
   begin
   begin
@@ -2746,8 +2745,7 @@ var
                             RegError(reRegSetValueEx, RK, S, ErrorCode);
                             RegError(reRegSetValueEx, RK, S, ErrorCode);
                         end;
                         end;
                       rtQWord: begin
                       rtQWord: begin
-                          if not StrToInteger64(ExpandConst(ValueData), QV) then
-                            InternalError('Failed to parse "qword" value');
+                          const QV: UInt64 = StrToUInt64(ExpandConst(ValueData));
                           ErrorCode := RegSetValueEx(K, PChar(N), 0, REG_QWORD,
                           ErrorCode := RegSetValueEx(K, PChar(N), 0, REG_QWORD,
                             @QV, SizeOf(QV));
                             @QV, SizeOf(QV));
                           if (ErrorCode <> ERROR_SUCCESS) and
                           if (ErrorCode <> ERROR_SUCCESS) and

+ 1 - 2
whatsnew.htm

@@ -214,8 +214,7 @@ issigtool --key-file="MyKey.ispublickey" verify "MyProg.dll"</code></pre>
   </li>
   </li>
   <li><tt>[Files]</tt> section parameter <tt>Excludes</tt> can now be combined with the <tt>external</tt> flag.</li>
   <li><tt>[Files]</tt> section parameter <tt>Excludes</tt> can now be combined with the <tt>external</tt> flag.</li>
   <li>Increased the maximum value of <tt>[Setup]</tt> section directive <tt>LZMANumBlockThreads</tt> from 32 to 256.</li>
   <li>Increased the maximum value of <tt>[Setup]</tt> section directive <tt>LZMANumBlockThreads</tt> from 32 to 256.</li>
-  <li>Parameters <tt>ExternalSize</tt>, <tt>ExtraDiskSpaceRequired</tt>, and <tt>UninstallDisplaySize</tt> now support digit separators. Example: <tt>UninstallDisplaySize=1_073_741_824</tt>.<br/>
-      The same applies to <tt>[Registry]</tt> parameter <tt>ValueData</tt> if <tt>ValueType</tt> is set to <tt>qword</tt>.</li>
+  <li>Parameters <tt>ExternalSize</tt>, <tt>ExtraDiskSpaceRequired</tt>, and <tt>UninstallDisplaySize</tt> now support digit separators. Example: <tt>UninstallDisplaySize=1_073_741_824</tt>.</li>
   <li>ISPP changes:
   <li>ISPP changes:
     <ul>
     <ul>
       <li>Added predefined variable <tt>__DIR__</tt>. Returns the directory of the current include file.</li>
       <li>Added predefined variable <tt>__DIR__</tt>. Returns the directory of the current include file.</li>