[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:

Hi,

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++))
        AC_COMPILE_IFELSE(
        AC_LANG_PROGRAM([
        #include <cstdio>
        #if defined(HAVE_GNUREADLINE)
        #include <readline/readline.h>
        #elif defined(HAVE_BSDEDITLINE)
        #include <editline/readline.h>
        #endif
        ],[[[const char null[] = "foo"; readline(null) ]]]),
        dnl action on success
        [AC_MSG_RESULT([yes])
        AC_DEFINE(READLINE_PROMPT_CONST, 1,
                [True if readline's argument is const char*])],
        dnl action on failure
        [AC_MSG_RESULT([no (you suck!)])
        AC_DEFINE(READLINE_PROMPT_CONST, 0,
                [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:

#define LIBEDIT_MAJOR 2
#define LIBEDIT_MINOR 9

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

Cheers,

Fang

[PATCH snipped]


David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
	-- (2400 baud? Netscape 3.0?? lynx??? No problem!)



More information about the GiNaC-list mailing list