Re: Checking user-entered expressions for validity

From: Tom Roberts <tjrob_at_fnal.gov>
Date: Tue, 16 Jan 2007 10:02:05 -0600


Thank you. This looks promising. The program still works with valid expressions, but I get "Limitation: setjmp() not supported" when I try an invalid expression. That implies that my callback did get called (and also it seems to really be longjmp() that is not supported).

So it looks like I need to compile the program, rather than simply loading it as a macro. I had hoped to avoid that, as distributing it as a macro is inherently portable; compiling it is not.

Again, Thanks!

Tom Roberts

WLavrijsen_at_lbl.gov wrote:
> Tom,
>
> not sure whether the following will help, however, since you write:
>

>> Any help would be appreciated

>
> I'll risk it. :) For PyROOT, I use CINT's error message callbacks to take
> control of error messages and what happens afterwards. In my case, that is
> a translation into a python exception, with a somewhat different markup.
> That should alleviate this problem that you mention:
>
>>> This works fine as long as the expressions are valid. Unfortunately, if
>>> any expression is invalid, Cint prints an error message to stderr and
>>> never returns from ProcessLineSync(). To the user this is disconcerting,
>>> as no sensible error message is presented (the user probably won't watch
>>> stderr, which may not be visible in a graphical environment).

>
> You can find my callback code in root/pyroot/src/Utility.cxx, and the function
> name is: void "PyROOT::Utility::ErrMsgCallback( char* msg )". It is installed
> with a call: "G__set_errmsgcallback( (void*)&Utility::ErrMsgCallback );" which
> you'll find in root/pyroot/src/TPyROOTApplication.cxx. I hope that'll work as
> an example.
>
> As for getting out of the context of a function that doesn't seem to return,
> a setjmp/longjmp (see root/include/TException.h) should do the trick.
>
> Best regards,
> Wim
> --
> Wim.Lavrijsen_at_cern.ch -- WLavrijsen_at_lbl.gov -- www.lavrijsen.net
>
> "Stop making excuses for your software." --first step towards quality
> "GIGO is not a valid design pattern." --corollary
Received on Tue Jan 16 2007 - 17:02:44 CET

This archive was generated by hypermail 2.2.0 : Sat Jan 20 2007 - 23:50:00 CET