* fix for bug web bug #7276: the code to read '*' format specifiers failed errorneously on Int64 and QWord input values. Based on code by mftq75

* test program for above changes

git-svn-id: trunk@4434 -
This commit is contained in:
tom_at_work 2006-08-17 21:37:06 +00:00
parent 50c3ba5310
commit 73d9beecff
3 changed files with 29 additions and 5 deletions

1
.gitattributes vendored
View File

@ -7263,6 +7263,7 @@ tests/webtbs/tw7143.pp -text
tests/webtbs/tw7161.pp svneol=native#text/plain tests/webtbs/tw7161.pp svneol=native#text/plain
tests/webtbs/tw7195.pp svneol=native#text/plain tests/webtbs/tw7195.pp svneol=native#text/plain
tests/webtbs/tw7227.pp svneol=native#text/plain tests/webtbs/tw7227.pp svneol=native#text/plain
tests/webtbs/tw7276.pp svneol=native#text/plain
tests/webtbs/ub1873.pp svneol=native#text/plain tests/webtbs/ub1873.pp svneol=native#text/plain
tests/webtbs/ub1883.pp svneol=native#text/plain tests/webtbs/ub1883.pp svneol=native#text/plain
tests/webtbs/uw0555.pp svneol=native#text/plain tests/webtbs/uw0555.pp svneol=native#text/plain

View File

@ -19,7 +19,7 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;
Procedure ReadInteger; Procedure ReadInteger;
var Code: word; var Code: Word;
begin begin
If Value<>-1 then exit; // Was already read. If Value<>-1 then exit; // Was already read.
@ -30,10 +30,15 @@ var Code: word;
DoFormatError(feInvalidFormat); DoFormatError(feInvalidFormat);
If Fmt[Chpos]='*' then If Fmt[Chpos]='*' then
begin begin
If (Chpos>OldPos) or (ArgPos>High(Args)) If (Chpos>OldPos) or (ArgPos>High(Args)) then
or (Args[ArgPos].Vtype<>vtInteger) then
DoFormatError(feInvalidFormat); DoFormatError(feInvalidFormat);
Value:=Args[ArgPos].VInteger; case Args[ArgPos].Vtype of
vtInteger: Value := Args[ArgPos].VInteger;
vtInt64: Value := Args[ArgPos].VInt64^;
vtQWord: Value := Args[ArgPos].VQWord^;
else
DoFormatError(feInvalidFormat);
end;
Inc(ArgPos); Inc(ArgPos);
Inc(chPos); Inc(chPos);
end end
@ -101,7 +106,7 @@ var Code: word;
If Fmt[chpos]='.' then If Fmt[chpos]='.' then
begin begin
inc(chpos); inc(chpos);
ReadInteger; ReadInteger;
If Value=-1 then If Value=-1 then
Value:=0; Value:=0;
prec:=Value; prec:=Value;

18
tests/webtbs/tw7276.pp Normal file
View File

@ -0,0 +1,18 @@
uses Sysutils;
var
s : AnsiString;
begin
s := 'Hello';
// tests whether the * in the format specifier allows all
// kind of integers; note that the * in the format specifier here
// is an incomplete format specification, i.e. it does not change
// the length of the result string
Format('%*s', [Integer(length(s)), s]);
// this is only seemingly equivalent to above, but on 64 bit
// machines the default integer type is Int64
Format('%*s', [length(s), s])
// also test QWord
Format('%*s', [QWord(length(s)), s]);
end.