Fix Ctrl+D on FreeBSD
This was broken by the macOS fix because apparently, editline acts differently on those platforms. I have tested that Linux, macOS, and FreeBSD all work with this one, both SIGWINCH and Ctrl+D. Well, Ctrl+D doesn't work on macOS, but that is actually a limitation I *can't* get around. Signed-off-by: Gavin D. Howard <[email protected]>
This commit is contained in:
parent
c5b7724ee0
commit
fb89733bea
|
@ -120,6 +120,30 @@ typedef struct BcHistory
|
|||
extern const char bc_history_editrc[];
|
||||
extern const size_t bc_history_editrc_len;
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
/**
|
||||
* Returns true if the line is a valid line, false otherwise.
|
||||
* @param line The line.
|
||||
* @param len The length of the line.
|
||||
* @return True if the line is valid, false otherwise.
|
||||
*/
|
||||
#define BC_HISTORY_INVALID_LINE(line, len) \
|
||||
((line) == NULL && ((len) == -1 || errno == EINTR))
|
||||
|
||||
#else // __APPLE__
|
||||
|
||||
/**
|
||||
* Returns true if the line is a valid line, false otherwise.
|
||||
* @param line The line.
|
||||
* @param len The length of the line.
|
||||
* @return True if the line is valid, false otherwise.
|
||||
*/
|
||||
#define BC_HISTORY_INVALID_LINE(line, len) \
|
||||
((line) == NULL && (len) == -1 && errno == EINTR)
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
#else // BC_ENABLE_EDITLINE
|
||||
|
||||
#if BC_ENABLE_READLINE
|
||||
|
|
|
@ -264,7 +264,18 @@ bc_history_line(BcHistory* h, BcVec* vec, const char* prompt)
|
|||
errno = EINTR;
|
||||
|
||||
// Get the line.
|
||||
while (line == NULL && (len == -1 || errno == EINTR))
|
||||
//
|
||||
// XXX: Why have a macro here? Because macOS needs to be special. Honestly,
|
||||
// it's starting to feel special like Windows at this point. Anyway, the
|
||||
// second SIGWINCH signal of multiple will return a valid line length on
|
||||
// macOS, so we need to allow for that on macOS. However, FreeBSD's editline
|
||||
// is different and will mess up the terminal if we do it that way.
|
||||
//
|
||||
// There is one limitation with this, however: Ctrl+D won't work on macOS.
|
||||
// But it's because of macOS that this problem exists, and I can't really do
|
||||
// anything about it. So macOS should fix their broken editline; once they
|
||||
// do, I'll fix Ctrl+D on macOS.
|
||||
while (BC_HISTORY_INVALID_LINE(line, len))
|
||||
{
|
||||
line = el_gets(h->el, &len);
|
||||
bc_history_use_prompt = false;
|
||||
|
|
Loadingâ¦
Reference in New Issue