readline (rl_prep_terminal) question - Unix

This is a discussion on readline (rl_prep_terminal) question - Unix ; Hi everyone, I am trying to use readline as follows but I am getting a seg fault when I call rl_prep_terminal(). Is there anything I am missing here? Can somebody give me insight please? Thank you in advance. #include #include ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: readline (rl_prep_terminal) question

  1. readline (rl_prep_terminal) question

    Hi everyone,

    I am trying to use readline as follows but I am getting a seg fault
    when I call rl_prep_terminal().
    Is there anything I am missing here? Can somebody give me insight
    please?
    Thank you in advance.

    #include
    #include
    #include

    int main(int argc, char*argv[])
    {
    char *line;

    rl_prep_terminal(0);
    while (1) {
    line = readline("#");
    if (!line)
    break;
    printf("%s", line);
    free(line);
    }
    rl_deprep_terminal();
    return 0;
    }

  2. Re: readline (rl_prep_terminal) question

    On Jan 10, 1:38*pm, yei...@gmail.com wrote:
    > Hi everyone,
    >
    > I am trying to use readline as follows but I am getting a seg fault
    > when I call rl_prep_terminal().
    > Is there anything I am missing here? Can somebody give me insight
    > please?
    > Thank you in advance.
    >
    > #include
    > #include
    > #include
    >
    > int main(int argc, char*argv[])
    > {
    > * * char *line;
    >
    > * * rl_prep_terminal(0);
    > * * while (1) {
    > * * * * line = readline("#");
    > * * * * if (!line)
    > * * * * * * break;
    > * * * * printf("%s", line);
    > * * * * free(line);
    > * * }
    > * * rl_deprep_terminal();
    > * * return 0;
    >
    >
    >
    > }- Hide quoted text -
    >
    > - Show quoted text -


    There's probably something wrong with calling rll_prep_terminal with 0
    as
    an argtument.

    Without knowing what that function looks like or how it is supposed
    to
    be used, we can't help you.
    --
    Fred Kleinschmidt

  3. Re: readline (rl_prep_terminal) question

    fred.l.kleinschmidt@boeing.com writes:

    > On Jan 10, 1:38*pm, yei...@gmail.com wrote:
    >> Hi everyone,
    >>
    >> I am trying to use readline as follows but I am getting a seg fault
    >> when I call rl_prep_terminal().
    >> Is there anything I am missing here? Can somebody give me insight
    >> please?
    >> Thank you in advance.
    >>
    >> #include
    >> #include
    >> #include
    >>
    >> int main(int argc, char*argv[])
    >> {
    >> * * char *line;
    >>
    >> * * rl_prep_terminal(0);
    >> * * while (1) {
    >> * * * * line = readline("#");
    >> * * * * if (!line)
    >> * * * * * * break;
    >> * * * * printf("%s", line);
    >> * * * * free(line);
    >> * * }
    >> * * rl_deprep_terminal();
    >> * * return 0;
    >>
    >>
    >>
    >> }- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > There's probably something wrong with calling rll_prep_terminal with 0
    > as an argtument.


    I suspected something like that at first but:

    http://tiswww.case.edu/php/chet/readline/readline.html

    Has:

    2.4.9 Terminal Management

    Function: void rl_prep_terminal (int meta_flag)
    Modify the terminal settings for Readline's use, so readline() can
    read a single character at a time from the keyboard. The meta_flag
    argument should be non-zero if Readline should read eight-bit
    input.

    so there is no obvious problem with 0.

    To the OP: what happens if you pass 1 instead?

    --
    Ben.

  4. Re: readline (rl_prep_terminal) question

    Ben Bacarisse writes:
    >fred.l.kleinschmidt@boeing.com writes:
    >


    >>
    >> There's probably something wrong with calling rll_prep_terminal with 0
    >> as an argtument.

    >
    >I suspected something like that at first but:
    >
    >http://tiswww.case.edu/php/chet/readline/readline.html
    >
    >Has:
    >
    > 2.4.9 Terminal Management
    >
    > Function: void rl_prep_terminal (int meta_flag)
    > Modify the terminal settings for Readline's use, so readline() can
    > read a single character at a time from the keyboard. The meta_flag
    > argument should be non-zero if Readline should read eight-bit
    > input.
    >
    >so there is no obvious problem with 0.
    >
    >To the OP: what happens if you pass 1 instead?
    >


    I've found that it is unnecessary to call rl_prep_terminal &c. Simply
    call readline() and if desired, add_history(). (Using Fedora Core 6).

    scott

+ Reply to Thread