mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 11:53:42 +01:00 
			
		
		
		
	* 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:
		
							parent
							
								
									50c3ba5310
								
							
						
					
					
						commit
						73d9beecff
					
				
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -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 | ||||||
|  | |||||||
| @ -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
									
								
							
							
						
						
									
										18
									
								
								tests/webtbs/tw7276.pp
									
									
									
									
									
										Normal 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. | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 tom_at_work
						tom_at_work