[Top][All Lists]

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

[Bug-readline] Re: rlwrap: configure.ac and cross_compiling

From: Hans Lub
Subject: [Bug-readline] Re: rlwrap: configure.ac and cross_compiling
Date: Tue, 18 May 2010 20:01:17 +0200

> I'll probably have to come back with questions, as I don't know the
> code.  But you could get me started by providing some info about
> functions and variables I should focus on, as well as about which test
> program I should start with.

You need to get the readline source first (if you haven't done so
already, as there may be no binaries for an exotic platform like
crisv32) compile them and then link the test program with it. Make
sure to put '-g' in CFLAGS, e.g. configuring readline with

        ./configure CFLAGS='-g'

The variables Chet mentioned are in readline-6.1/input.c (search for

If you dont' have a debugger handy, you could also explicitly
initialise pop_index and push_index to 0, changing (in

        static int pop_index,push_index;


        static int pop_index = push_index = 0;

If Chet's hunch is correct, this alone would kill the bug, a compiler
bug in this case, as static variables are guaranteed to be initialised
to 0 by ANSI/ISO

A suitable test program:

/* Simple test program that uses readline in callback mode, using
 *  read() and then rl_stuff_char() Whenever rlwrap misbehaves, please
 *  run this program to make sure it is not a readline problem
 *  compile with gcc -g -orltest5 rltest5.c   -lreadline -lncurses

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <readline/readline.h>

void line_handler(char *line) {
  if (!line) {
    exit (0);
  printf ("You typed: '%s'\n", line);

int main() {
  char c;

  rl_callback_handler_install("Enter a line: ", &line_handler);

  while (read(STDIN_FILENO, &c, 1)) {
    if (! rl_stuff_char(c)) {
      fprintf (stderr, "\nDisappointingly, I couldn't even stuff a single '%c' "
                       "into readline's 512-byte long input queue,
giving up :-(\n", c);
  return 0;

/* Hans :-) */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]