version 1.26, 2011/06/03 06:10:33 |
version 1.27, 2011/08/03 08:48:19 |
|
|
#include <signal.h> |
#include <signal.h> |
#include <stdbool.h> |
#include <stdbool.h> |
#include <string.h> |
#include <string.h> |
|
#include <termios.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "extern.h" |
#include "extern.h" |
|
|
static bool dot_seen; |
static bool dot_seen; |
static int use_el; |
static int use_el; |
static volatile sig_atomic_t skipchars; |
static volatile sig_atomic_t skipchars; |
|
struct termios ttysaved, ttyedit; |
|
|
static void init_strbuf(void); |
static void init_strbuf(void); |
static void add_str(const char *); |
static void add_str(const char *); |
|
|
errno = save_errno; |
errno = save_errno; |
} |
} |
|
|
|
int |
|
settty(struct termios *t) |
|
{ |
|
int ret; |
|
|
|
while ((ret = tcsetattr(0, TCSADRAIN, t) == -1) && errno == EINTR) |
|
continue; |
|
return ret; |
|
} |
|
|
|
int |
|
gettty(struct termios *t) |
|
{ |
|
int ret; |
|
|
|
while ((ret = tcgetattr(0, t) == -1) && errno == EINTR) |
|
continue; |
|
return ret; |
|
} |
|
|
|
/* ARGSUSED */ |
|
void |
|
tstpcont(int sig) |
|
{ |
|
int save_errno = errno; |
|
|
|
if (sig == SIGTSTP) { |
|
signal(SIGCONT, tstpcont); |
|
gettty(&ttyedit); |
|
settty(&ttysaved); |
|
} else { |
|
signal(SIGTSTP, tstpcont); |
|
settty(&ttyedit); |
|
} |
|
signal(sig, SIG_DFL); |
|
kill(0, sig); |
|
errno = save_errno; |
|
} |
|
|
/* |
/* |
* Avoid the echo of ^D by the default code of editline and take |
* Avoid the echo of ^D by the default code of editline and take |
* into account skipchars to make ^D work when the cursor is at start of |
* into account skipchars to make ^D work when the cursor is at start of |
|
|
} else if (fileindex == sargc) { |
} else if (fileindex == sargc) { |
fileindex++; |
fileindex++; |
yyin = stdin; |
yyin = stdin; |
if (interactive) |
if (interactive) { |
signal(SIGINT, abort_line); |
signal(SIGINT, abort_line); |
|
signal(SIGTSTP, tstpcont); |
|
} |
lineno = 1; |
lineno = 1; |
filename = "stdin"; |
filename = "stdin"; |
return (0); |
return (0); |