fix comments on #516. Split reader_interrupted into a reader_interrupted and a reader_reading_interrupted

This commit is contained in:
Jan Kanis 2013-01-22 11:00:02 +01:00
parent c58278758c
commit eb1c00c56b
3 changed files with 15 additions and 3 deletions

View file

@ -292,7 +292,7 @@ static int interrupt_handler()
/* /*
Tell the reader an event occured Tell the reader an event occured
*/ */
if (reader_interrupted()) if (reader_reading_interrupted())
{ {
/* /*
Return 3, i.e. the character read by a Control-C. Return 3, i.e. the character read by a Control-C.

View file

@ -657,11 +657,17 @@ void reader_reset_interrupted()
int reader_interrupted() int reader_interrupted()
{ {
int res=interrupted; int res = interrupted;
if (res) if (res)
{ {
interrupted=0; interrupted=0;
} }
return res;
}
int reader_reading_interrupted()
{
int res = reader_interrupted();
if (res && data && data->interruptible) if (res && data && data->interruptible)
{ {
reader_exit(1, 0); reader_exit(1, 0);

View file

@ -111,6 +111,12 @@ void reader_set_buffer(const wcstring &b, size_t p);
*/ */
size_t reader_get_cursor_pos(); size_t reader_get_cursor_pos();
/**
Return the value of the interrupted flag, which is set by the sigint
handler, and clear it if it was set.
*/
int reader_interrupted();
/** /**
Clear the interrupted flag unconditionally without handling anything. The Clear the interrupted flag unconditionally without handling anything. The
flag could have been set e.g. when an interrupt arrived just as we were flag could have been set e.g. when an interrupt arrived just as we were
@ -124,7 +130,7 @@ void reader_reset_interrupted();
handler, and clear it if it was set. If the current reader is interruptible, handler, and clear it if it was set. If the current reader is interruptible,
call \c reader_exit(). call \c reader_exit().
*/ */
int reader_interrupted(); int reader_reading_interrupted();
/** /**
Read one line of input. Before calling this function, reader_push() Read one line of input. Before calling this function, reader_push()