After fun2string(foo) removal, [o,i,t]=string(foo) t output is wrong when foo() has "if" without "else" (Regression)
Reported by Samuel GOUGEON (@sgougeon)
BUG DESCRIPTION:
----------------
Let
function test()
if 2>1
disp("The %truth will win! :)")
end
a = "nothing lost"
endfunction
Then:
Scilab 5:
=========
-->fun2string(test)
ans =
!function []=ans() !
! !
! if 2 > 1 then !
! !
! disp('The %truth will win! :)') !
! !
! end, !
! !
! a = 'nothing lost' !
! !
!endfunction !
was OK
Scilab 6 equivalence/workaround after fun2string() has been removed:
====================
--> [o,i,t] = string(test); mprintf("%s\n", t)
// Heading comment as embedded help
if (2 > 1) then
disp("The %truth will win! :)")
else
//No else !!end
a = "nothing lost"
SO:
* OK for the missing function and endfunction lines: they can be rebuilt from o and i separated outputs
* ~OK to indicate that there is no else. But it is useless.
* NOK about the missing \n after //No else!! => This corrupts the code, since "!!end"~="end" and "end" is in the comment.
ERROR LOG:
----------
None. Wrong output
HOW TO REPRODUCE THE BUG:
-------------------------
function test()
if 2>1
disp("The %truth will win! :)")
end
a = "nothing lost"
endfunction
[o,i,t] = string(test); mprintf("%s\n", t)