Serge D. Mechveliani wrote:
>
> On Sat, Jan 07, 2012 at 08:45:08PM +0100, Waldek Hebisch wrote:
> > Serge D. Mechveliani wrote:
> > >
> > > > [..]
> > > > OTOH it seems that code which simply writes and reads lines
> > > > does not work due to bug in sbcl (in version used for release,
> > > > seems to be fixed in newer versions).
> > > >
> > > [..]
> >
> > [..]
> >
> > Look at:
> >
> > http://www.math.uni.wroc.pl/~hebisch/fricas/fifoToAxiom.c
> >
> > and
> >
> > http://www.math.uni.wroc.pl/~hebisch/fricas/fifoToC.input
> >
> > When using clisp based FriCAS they "almost" work (there
> > is message at the end:
> >
> > >> Error detected within library code:
> > End of file
> >
> > but otherwise it seem be what you expect.
> >
>
> But I managed to break this IO on
> http://www.math.uni.wroc.pl/~hebisch/fricas/fifoToAxiom.c,
> fifoToC.input.
>
> Remove from there all the intermediate print-outs,
> remove also parsing-evaluation,
> so that fifoToAxiom and fifoToC.input only push each line to and
> from.
> Then, for n = 1000, is runs correct,
> and n = 2000 leads to Segmentation fault
>
> (FriCAS-1.1.5 made from source with GNU CLisp, Linux Debian).
>
> I do not know, where is an error here: in the C code or in FriCAS.
> The files are:
>
Try the following version of fifoToC.input:
toA: TextFile := open("toA", "input")
fromA: TextFile := open("fromA", "output")
cnt : Integer := 0
repeat
iStr := readLineIfCan! toA -- read the argument string
if iStr case "failed" then (output ""; output "input -> failed"; break)
iForm := parse(iStr::String)$InputForm -- if error?
oForm := interpret iForm
resIForm := oForm :: InputForm
resStr := unparse(resIForm)$InputForm
writeLine!(fromA, resStr)
flush(fromA)
cnt := cnt + 1
if cnt rem 1000 = 0 then
output "resStr is output"
output(cnt)
> ** fifoToAxiom.c *****************************************************
>
> #include <stdio.h>
> #include <string.h>
> #define LBND 64
> static const int lineBound = LBND;
>
> FILE *toA, *fromA;
>
> char *cAxiom(char *line, char *res)
> // the pipes are called "toA", "fromA",
> // their pointers are called toA, fromA.
> {
> toA = fopen("toA", "w");
^^^^^^^^^^^^^^^^^^^^^^^^
This line is wrong, it was responsible for segfault. To fix
just remove it.
> if (fputs(line, toA) == EOF) {
> perror("fputs(line, toA) failed: "); return(NULL);
<snip>
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.