Re: signals, handeling the Control-D signal
The control -D character must b prevented from reaching the history
The program must be able to receive a `\n' by itself in order to
function properly.
You can see it at http://www.hurontel.on.ca/~barryp/ed
Here is the code in question!
char *
rl_gets ()
{
register int i = 0;
/* If the buffer has already been allocated, return the memory to
the free pool. */
if (line_read)
{
free (line_read);
line_read = NULL;
} /* Get a line from the user. */
line_read = readline ("");
/* If the line has any text in it, save it on the history.
The control -D must be intercepted here */
if (line_read && *line_read)
add_history (line_read);
/* copy the line so ed can read it as if from stdin */
for (; i <= temp_len; i++)
templine[i] = '\0';
strcpy (templine, line_read); /* so get_tty_line can use the line */
strcat (templine, "\n"); /* for histfilename */
temp_len = strlen (templine);
return line_read;
}
Barry
list.
On Tue, 15 Jul 2003, Matthias Urlichs wrote:
> Hi, Pete Ryland wrote:
>
> > Ctrl-D is not a 'signal' as such, but simply will cause any reads from
> > stdin to report EOF.
>
> ... if you're reading "cooked" standard input. Readline doesn't; for
> readline, ^D is just another character, and what happens when the user
> pressed ^D is a matter of (for the user) keybinding and (for the
> programmer) manual-reading.
>
> --
> Matthias Urlichs | {M:U} IT Design @ m-u-it.de | smurf@smurf.noris.de
> Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
> --
> 'What can I do? I'm only human,' he said aloud.
> Someone said, 'Not all of you.'
> -- Terry Pratchett (Pyramids)
>
>
> --
> To UNSUBSCRIBE, email to debian-mentors-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>
Reply to: