🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #905

setting up and using the GNU readline library, please help!

#905
From: Edward J. Hartnett
Date: Thu, 28 Jan 1993 15:58
97 lines
3657 bytes
I have gotten the readline library which will allow me to have
tcsh-like tab completion of filenames and commands in my C programs,
but I'm having a hard time setting it up and getting it to work. If
anyone could answer any or all of these questions, I sure would
appreciate it!

1 - I went into the doc section and there's a makefile there that will
make the info files for the emacs info system. Here's the relevant
lines from the makefile:

readline.info: rlman.texinfo rluser.texinfo rltech.texinfo
	makeinfo rlman.texinfo


Only problem is that I don't have makeinfo and I don't have rlman.
What are these things? Are they GNU products? Do I need to get them
and install them to use readline?

2 - In the makefile that makes the proper .o files, cc is used instead
of gcc. I have both. Is there any benifit in using one over the other?
It seemed to work fine with cc so I'm assuming that's OK.

3 - I tried to run one of the examples in my readline directory
(actually I made up my own test program) and I got trouble because all
the includes referenced readline/SOMETHING, for example:

#include <readline/readline.h>

So I moved the readline stuff into a subdirectory of my home
directory, and called the subdirectory readline, then I moved the test
program to my home directory and tried it and it didn't work! I can
(and will) go thru all the .h files and substitute in the complete
path to the readline files, but I'm wondering why this didn't work.
Any ideas?


4 - I tried to put together a little test program, but ran into
trouble. I'm a little rusty at C and there's no one around here that
can help, so I throw myself on your mercy. The only part I wrote was
the main which just calls do_gets. I just want to see the tab
completion at work. Here's the program:

#include <stdio.h>
#include </home/khonshu/ejh/subs/readline/readline.h>


/* A static variable for holding the line. */
static char *line_read = (char *)NULL;
char *do_gets ()

main()
{
  do_gets();
}
    

/*This is the function do_gets which came with the readline library*/
/* Read a string, and return a pointer to it.  Returns NULL on EOF. */
char *do_gets ()
{
  /* If the buffer has already been allocated, return the memory
     to the free pool. */
  if (line_read != (char *)NULL)
    {
      free (line_read);
      line_read = (char *)NULL;
    }
  
  /* Get a line from the user. */
  line_read = readline ("");
  
  /* If the line has any text in it, save it on the history. */
  if (line_read && *line_read)
    add_history (line_read);
  
  return (line_read);
}


Here's the errors I get doing the compile:

make
gcc test_rl.c /home/khonshu/ejh/subs/readline/libreadline.a
test_rl.c:9: parse error before `main'
test_rl.c:18: warning: type mismatch with previous implicit declaration
test_rl.c:11: warning: previous implicit declaration of `do_gets'
test_rl.c:18: warning: `do_gets' was previously implicitly declared to return `int'
*** Error code 1
make: Fatal error: Command failed for target `test_rl'


Can anyone out there help me?
--
	Don't blame me, I voted against Amendment 2!

Edward Hartnett				ejh@khonshu.colorado.edu
Technical Details
Message-ID: <EJH.93Jan28155841@khonshu.colorado.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!boulder!colorado.edu!ejh

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.help,comp.lang.c
Path: arc1-ca.pugleaf.net!sparky!uunet!boulder!colorado.edu!ejh
From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
Subject: setting up and using the GNU readline library, please help!
Message-ID: <EJH.93Jan28155841@khonshu.colorado.edu>
Sender: news@colorado.edu (The Daily Planet)
Nntp-Posting-Host: khonshu.colorado.edu
Organization: CIRES, University of Colorado
Date: 28 Jan 93 15:58:41
Lines: 98