Karim BELABAS on Thu, 21 Feb 2002 22:05:04 +0100 (MET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: flisseq() and filtre()


On Sat, 12 Jan 2002, Iwao KIMURA wrote:
> I am now trying to write a C program, using pari library, evaluating
> some gp-expressions written on a file. These gp-expressions contain some
> comments, spaces, line breaks and line-continuation `\', like
>
> v=[[x^5-x^4-4*x^3+3*x^2+3*x-1,[5,0],[5,1,1],[14641,1],[1,x,x^2,x^3,x^4],[1,[],[],[]],1.635694125589697174263040903,[2,[-1,0,0,0,0]~],[[1,0,-3,0,1]~,[-1,-1,1,0,0]~,[0,1,0,0,0]~,[0,-2,0,1,0]~]],\
> [x^5-5*x^3-x^2+3*x+1,[5,0],[120,-1,1],[24217,1],[1,x,x^2,x^3,x^4],[1,[],[],[]],2.399421131323994137564412027,[2,[-1,0,0,0,0]~],[[-3,1,5,0,-1]~,[-3,-3,9,1,-2]~,[-2,1,5,0,-1]~,[1,4,0,-1,0]~]]];
>
> My program reads whole of the file, constructs single string by
> appending all of lines, and evaluates the string by passing it to
> flisseq().
>
> But the program stops with message `unexpected character...' and
> displays line-continuation `\' as unexpected ones.
>
> I think flisseq() (more precisely, filtre()) should filter out
> `\'. Or, is there any better way to do what I want to do?

There used to be.  I started writing a reply to your post, then thought it
over, esp. since the filtering problem had already come up in a recent
discussion (about readline see pari-dev-1180 and following).

So I have rewritten the filtering code in the cvs unstable branch, so that
filtre() handles the whole of it, removing all pre/postprocessing code from
gp.c [ which used to handle line-continuation items, like braces or '\' ]. In
the process, filtre() has also becom reentrant [ there used to be hidden
static state variables ].

Please, check whether it solves your problems and that you don't run into
anything unexpected.

Cheers, Karim.

P.S: if you want to check this patch, please update to the current snapshot
of pari-2.2.3 via the CVS server.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathematiques, Bat. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas
--
PARI/GP Home Page: http://www.parigp-home.de/