[GiNaC-list] GiNaC vs readline [Was: Problems]

David Fang fang at csl.cornell.edu
Wed Jan 31 17:58:11 CET 2007

> > #if defined(READLINE_4_DOT_2_PLUS) || (RL_VERSION_MAJOR >= 5) || (RL_VERSION_MAJOR == 4 && RL_VERSION_MINOR >= 2)
> > #define filename_completion_function rl_filename_completion_function
> > #define username_completion_function rl_username_completion_function
> > #define completion_matches rl_completion_matches
> > #endif

> GiNaC already has proper hack for this (your solution is not good enough
> for C++ anyway: one need also to const_cast<char *> the arguments and
> convert pointers to functions so that compiler is happy about them).
> Thus, ginsh can be compiled with old (GNU) libreadline (or compatible
> non-GNU libraries). The only problem is how to decide if we got such
> an old  version. This is especially difficult if the library do not
> provide any meaningful version information ("EditLine wrapper" is not
> really helpful). OK, let's forget about library versions and check for
> function/variables declarations themselves:


The the above #define hackery wasn't proposed as a permanent solution so
much as a workaround for a user to move on as quickly as possible.  :)
I'm aware of the const-incorrectness of older readline, and here's an
excerpt of my autoconf macro that conditionally applies the
const_cast<char*>, specifically for the readline() prototype:

(wrapped by AC_LANG_PUSH/POP(C++))
        #include <cstdio>
        #if defined(HAVE_GNUREADLINE)
        #include <readline/readline.h>
        #elif defined(HAVE_BSDEDITLINE)
        #include <editline/readline.h>
        ],[[[const char null[] = "foo"; readline(null) ]]]),
        dnl action on success
                [True if readline's argument is const char*])],
        dnl action on failure
        [AC_MSG_RESULT([no (you suck!)])
                [True if readline's argument is const char*])

But I see in your patch and m4 file, that you test for const-correctness
on the "basic_word_break" string, but it is also needed in other
prototypes as well.  It looks like all the same isues covered by
CONFIG_OLD_READLINE, where old is <= 4.1.  Since you use it more
extensively, I'm sure you've covered more bases.  :) In your experience,
does testing for one or two const-incorrectnesses or readline indicate
that mmuch/most of the rest of readline uses require const_cast<>?  In
other words, that one does not need to test different library symbols
individually to "do the right thing"?

FYI, if one really wanted to get the version of the underlying histedit
library (around which the readline interface is wrapped by editline), one
could check for:


(for example) in <histedit.h>.  I never bothered to do this, as there
are too many more important problems to tackle.  :)



[PATCH snipped]

David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
	-- (2400 baud? Netscape 3.0?? lynx??? No problem!)

More information about the GiNaC-list mailing list