rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit a33cdf2c71aec230b14a0e07317e0a38d743089b
parent 4682c96c0bd432f41abb6d83b9edf8bce195ce40
Author: tgoodwin <tgoodwin>
Date:   Wed, 18 Feb 1998 12:30:53 +0000

move rc_readline to rdwr.c

Diffstat:
Mrc.h | 5++++-
Msystem-bsd.c | 24+++++++++++++++++++++++-
Msystem.c | 6++++++
3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/rc.h b/rc.h @@ -366,6 +366,10 @@ extern void initparse(void); extern void writeall(int, char *, size_t); extern int rc_read(int, char *, size_t); +#if READLINE +extern char *rc_readline(char *prompt); +#endif + /* redir.c */ extern void doredirs(void); @@ -396,7 +400,6 @@ extern void treefree(Node *); /* utils.c */ extern bool isabsolute(char *); extern int n2u(char *, unsigned int); -extern int rc_read(int, char *, size_t); extern int mvfd(int, int); extern int starstrcmp(const void *, const void *); extern void pr_error(char *); diff --git a/system-bsd.c b/system-bsd.c @@ -31,7 +31,7 @@ extern void writeall(int fd, char *buf, size_t remain) { } extern int rc_read(int fd, char *buf, size_t n) { - long /*ssize_t*/ r; + ssize_t r; interrupt_happened = FALSE; if (!sigsetjmp(slowbuf.j, 1)) { slow = TRUE; @@ -48,3 +48,25 @@ extern int rc_read(int fd, char *buf, size_t n) { } return r; } + +/* signal-safe readline wrapper */ +#if READLINE +extern char *rc_readline(char *prompt) { + char *r; + + interrupt_happened = FALSE; + if (!sigsetjmp(slowbuf.j, 1)) { + slow = TRUE; + if (!interrupt_happened) + r = readline(prompt); + else + r = NULL; + } else + r = NULL; + slow = FALSE; + if (r == NULL) + errno = EINTR; + sigchk(); + return r; +} +#endif /* READLINE */ diff --git a/system.c b/system.c @@ -12,3 +12,9 @@ extern void writeall(int fd, char *buf, size_t remain) { extern int rc_read(int fd, char *buf, size_t n) { return read(fd, buf, n); } + +#if READLINE +extern char *rc_readline(char *prompt) { + return readline(prompt); +} +#endif