Mercurial > forge
changeset 1274:e2daebed2db7 octave-forge
Better hack for broken system function
author | pkienzle |
---|---|
date | Fri, 06 Feb 2004 20:34:57 +0000 |
parents | 9c2f1e3afc2e |
children | 9108c6729d60 |
files | extra/testfun/test.m |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/extra/testfun/test.m Fri Feb 06 19:41:23 2004 +0000 +++ b/extra/testfun/test.m Fri Feb 06 20:34:57 2004 +0000 @@ -287,13 +287,16 @@ endif ## grab the test code from the file - __body = system([ "sed -n 's/^%!//p' '", __file, "'"]); - ## XXX FIXME XXX quick hack --- try sed a few times - __attempt = 0; - while isempty(__body) && __attempt < 6 - __body = system([ "sed -n 's/^%!//p' '", __file, "'"]); - __attempt++; - endwhile + ## XXX FIXME XXX why doesn't the following work? + ## __body = system(["sed -n 's/^%!//p' '", __file, "'"]); + __tmp = tmpnam(); + unwind_protect + system(["sed -n 's/^%!//p' '", __file, "' > '", __tmp, "'"]); + fid = fopen(__tmp,"r"); + __body = setstr(fread(fid,Inf,'char')'); + unwind_protect_cleanup + unlink(__tmp); + end_unwind_protect if (isempty (__body)) if (__grabdemo)