Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bug: optimized strings concatenation with a inner updated
Message
From
18/10/2004 13:56:12
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Title:
Bug: optimized strings concatenation with a inner updated
Miscellaneous
Thread ID:
00952371
Message ID:
00952371
Views:
72
Previous issue Thread #951952

Bug/Issue : 4 of 27

TITLE: Bug: optimized strings concatenation with a inner updated

VERSION: 09.00.0000.1720 and previous

STEPS TO REPRODUCE:
* this example uses a call by reference, 
*but same result occurs with public/private vars direct updated 
* into the called procedure
CLEAR
ON ERROR ? m.k,MESSAGE()

? "***** ABRACADABRA DON'T CHANGE THE LEN: left addendum is ignored"
FOR k=1 TO 103
	AA=SPACE(m.k)

	AA = m.AA + ABRACADABRA0(@m.AA)
	IF LEN(m.AA)#m.k+1
		? m.k,'This line is not printed'
	ENDIF
NEXT
? AA
?

? "***** ABRACADABRA RETURN NULL => left addendum and NULL are ignored"
FOR k=1 TO 103
	AA=SPACE(m.k)
	AA = m.AA + ABRACADABRA1(@m.AA)
	IF  m.k<101 && copy concatenation : Result is NULL
		IF !ISNULL(m.AA)
			? m.k,'This line is not printed'
		ENDIF
	ELSE && ON PLACE concatenation : Result is 'NEW SET'+REPLICATE('Z',m.k)
		IF LEN(m.AA)#7+m.k
			? m.k,'This line is not printed'
		ENDIF
	ENDIF
NEXT
? AA
?
? "***** ABRACADABRA CHANGE THE LEN OF THE STRING : when on place concatenation is used a error is fired"

FOR k=1 TO 103
	AA=SPACE(m.k)
	AA = m.AA + ABRACADABRA2(@m.AA)

NEXT
?
FOR k=1 TO 103
	AA=SPACE(m.k)
	AA = m.AA + ABRACADABRA3(@m.AA)
NEXT

PROCEDURE ABRACADABRA0(ZZ)
	ZZ = REPLICATE('Z',LEN(ZZ)-1)+'?'
	RETURN '!'

PROCEDURE ABRACADABRA1(ZZ)
	ZZ = 'NEW SET'+REPLICATE('Z',LEN(ZZ))
	RETURN NULL
	
PROCEDURE ABRACADABRA2(ZZ)
	ZZ = REPLICATE('Z',MAX(0,LEN(ZZ)-2))
	RETURN '#'

PROCEDURE ABRACADABRA3(ZZ)
	ZZ = REPLICATE('Z',LEN(ZZ))+'?!'
	RETURN ''
OBSERVED BEHAVIOR:
VFP return not deterministic results.
VFP uses a optimized on place concatenation when the RW string have more of 100 character,
if you uses a code that change the string lenght, internal pointers go in panic.

EXPECTED BEHAVIOR:

Not deterministic results they are not acceptable,
VFP have to return a deterministic result.

Like:
- or intercept the RW variable post overwrite, for example VFPT can put a READONLY flag into the variable descriptor, when ZZ=... is done a Read Only Error is fired.
- or VFP have to use the optimization code for all len lower to 101,
without check it and implement next expected result with a report into the Help documentation.

Example:
AA=REPLICATE('A',200)
* Case 1
*AA = m.AA + ABRACADABRA(@m.AA,100)+m.AA
? 'expected AA=',STUFF(m.AA,1,100,REPLICATE('Z',100))+'123456'+STUFF(m.AA,1,100,REPLICATE('Z',100))
* Case 2
*AA = m.AA + ABRACADABRA(@m.AA,250)+m.AA
? 'expected AA=',STUFF(m.AA,1,250,REPLICATE('Z',250))+'123456'+STUFF(m.AA,1,250,REPLICATE('Z',250))

PROCEDURE ABRACADABRA(ZZ,N)
	ZZ = REPLICATE('Z',N)
	RETURN '123456'
Next
Reply
Map
View

Click here to load this message in the networking platform