Backport TERMKEY_FLAG_NOSTART and fix two leaks
...that are notably still present in the original library.
This commit is contained in:
parent
a9b41e41b7
commit
5b05b96ec0
|
@ -39,7 +39,7 @@ statically linked against the library, and hence they can be run as they are:
|
|||
|
||||
What's Different From the Original termkey?
|
||||
-------------------------------------------
|
||||
The main change is throwing away any UTF-8 dependent code, making the library
|
||||
The main change is throwing out any UTF-8 dependent code, making the library
|
||||
capable of handling all unibyte and multibyte encodings supported by iconv on
|
||||
your system. The characters are still presented as Unicode in the end, however,
|
||||
as the other sensible option is wchar_t and that doesn't really work well, see
|
||||
|
|
19
termo.c
19
termo.c
|
@ -425,12 +425,12 @@ termo_new (int fd, const char *encoding, int flags)
|
|||
termo_set_flags (tk, flags);
|
||||
|
||||
const char *term = getenv ("TERM");
|
||||
if (termo_init (tk, term, encoding)
|
||||
&& termo_start (tk))
|
||||
return tk;
|
||||
|
||||
// FIXME: resource leak on termo_start() failure
|
||||
if (!termo_init (tk, term, encoding))
|
||||
free (tk);
|
||||
else if (!(flags & TERMO_FLAG_NOSTART) && !termo_start (tk))
|
||||
termo_free (tk);
|
||||
else
|
||||
return tk;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -445,13 +445,12 @@ termo_new_abstract (const char *term, const char *encoding, int flags)
|
|||
termo_set_flags (tk, flags);
|
||||
|
||||
if (!termo_init (tk, term, encoding))
|
||||
{
|
||||
free (tk);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
termo_start (tk);
|
||||
else if (!(flags & TERMO_FLAG_NOSTART) && !termo_start (tk))
|
||||
termo_free (tk);
|
||||
else
|
||||
return tk;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
4
termo.h
4
termo.h
|
@ -192,7 +192,9 @@ enum
|
|||
// Allow Ctrl-C to be read as normal, disabling SIGINT
|
||||
TERMO_FLAG_CTRLC = 1 << 6,
|
||||
// Return ERROR on signal (EINTR) rather than retry
|
||||
TERMO_FLAG_EINTR = 1 << 7
|
||||
TERMO_FLAG_EINTR = 1 << 7,
|
||||
// Do not call termkey_start() in constructor
|
||||
TERMO_FLAG_NOSTART = 1 << 8
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in New Issue