Compare commits

..

10 Commits

Author SHA1 Message Date
30e0eee1a8 Update README 2018-06-24 01:05:45 +02:00
9adbb8c897 Update mail address 2018-06-24 01:05:34 +02:00
953789650e CMakeLists.txt: fix variable name 2018-06-24 01:03:40 +02:00
93641a7c98 Update README 2017-06-20 06:36:07 +02:00
ed67424ca7 Put tests in a "namespace" 2017-06-20 06:35:37 +02:00
61095da7c3 Travis CI: brevify notifications 2017-06-20 06:35:23 +02:00
5b05b96ec0 Backport TERMKEY_FLAG_NOSTART and fix two leaks
...that are notably still present in the original library.
2016-12-30 08:30:59 +01:00
a9b41e41b7 Fix use of an uninitialized value 2016-11-03 02:36:40 +01:00
059cb81817 Try to fix terminfo loading
It could lead to crashing the PTY under OpenBSD and ncurses.

Fixed some unibiliums leaks while at it.
2016-11-03 02:36:35 +01:00
c1251f3978 Fix condition in demo-glib.c 2016-11-03 02:24:35 +01:00
8 changed files with 47 additions and 33 deletions

View File

@@ -4,6 +4,12 @@ notifications:
channels: "irc.janouch.name#dev"
use_notice: true
skip_join: true
template:
- "%{repository_name}#%{build_number} on %{branch}: %{message}"
- " %{compare_url}"
- " %{build_url}"
on_success: change
on_failure: always
env:
global:
- secure: "rzavv9NhQeZ3Zn6g9WgabUuTsXG1ncc+dWyXw3ytN15uWa4UelVzjAYvr31XeyXwsqZi3rDRHuz8ooIi1NLeLewozpEdkyakLjZOAnggqCnkF/yw/secuRo8MzweGXAefF+7cR2JYyH/E/PfMfAY8Qb0NnfEV1j7X9GCN2sJcxA="

View File

@@ -1,10 +1,10 @@
project (termo C)
cmake_minimum_required (VERSION 2.8.5)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra")
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
# Version
set (project_VERSION_MAJOR 0)
@@ -156,7 +156,7 @@ if (BUILD_TESTING)
foreach (name ${project_tests})
add_executable (test-${name} tests/${name}.c ${test_common_sources})
target_link_libraries (test-${name} termo-static ${lib_libraries})
add_test (test-${name} test-${name})
add_test (NAME ${PROJECT_NAME}.${name} COMMAND test-${name})
endforeach (name)
endif (BUILD_TESTING)
@@ -174,7 +174,7 @@ install (FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc"
# CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Terminal key input library")
set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p.janouch@gmail.com>")
set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p@janouch.name>")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})

View File

@@ -1,5 +1,5 @@
Copyright (c) 2007-2014 Paul Evans <leonerd@leonerd.org.uk>
Copyright (c) 2014 Přemysl Janouch <p.janouch@gmail.com>
Copyright (c) 2014 Přemysl Janouch <p@janouch.name>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -18,7 +18,7 @@ Building and Installing
Build dependencies: cmake >= 2.8.5, pkg-config +
Optional dependencies: Unibilium (alternative for curses), GLib (for the demos)
$ git clone https://github.com/pjanouch/termo.git
$ git clone https://git.janouch.name/p/termo.git
$ mkdir termo/build
$ cd termo/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
@@ -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
@@ -59,15 +59,17 @@ Oh, and I've deleted the manpages. It needs more Doxygen. :) TBD
Contributing and Support
------------------------
Use this project's GitHub to report any bugs, request features, or submit pull
requests. If you want to discuss this project, or maybe just hang out with
the developer, feel free to join me at irc://irc.janouch.name, channel #dev.
Use https://git.janouch.name/p/termo to report any bugs, request features,
or submit pull requests. `git send-email` is tolerated. If you want to discuss
the project, feel free to join me at ircs://irc.janouch.name, channel #dev.
Bitcoin donations are accepted at: 12r5uEWEgcHC46xd64tt3hHt9EUvYYDHe9
License
-------
'termo' is based on the 'termkey' library, originally written by Paul Evans
<leonerd@leonerd.org.uk>, with additional changes made by Přemysl Janouch
<p.janouch@gmail.com>.
<p@janouch.name>.
You may use the software under the terms of the MIT license, the text of which
is included within the package, see the file LICENSE.

View File

@@ -28,7 +28,7 @@ key_timer (gpointer data)
static gboolean
stdin_io (GIOChannel *source, GIOCondition condition, gpointer data)
{
if (condition && G_IO_IN)
if (condition & G_IO_IN)
{
if (timeout_id)
g_source_remove (timeout_id);

View File

@@ -177,6 +177,7 @@ static bool
load_terminfo (termo_ti_t *ti, const char *term)
{
const char *mouse_report_string = NULL;
bool result = false;
#ifdef HAVE_UNIBILIUM
unibi_term *unibi = unibi_from_term (term);
@@ -191,8 +192,12 @@ load_terminfo (termo_ti_t *ti, const char *term)
// Have to cast away the const. But it's OK - we know terminfo won't
// really modify term
int err;
TERMINAL *saved_term = set_curterm (NULL);
if (setupterm ((char *) term, 1, &err) != OK)
{
set_curterm (saved_term);
return false;
}
for (int i = 0; strfnames[i]; i++)
{
@@ -227,8 +232,7 @@ load_terminfo (termo_ti_t *ti, const char *term)
if (node && !insert_seq (ti, value, node))
{
free (node);
// FIXME: unibi leak
return false;
goto fail;
}
}
@@ -255,14 +259,13 @@ load_terminfo (termo_ti_t *ti, const char *term)
trie_node_t *node = malloc (sizeof *node);
if (!node)
return false;
goto fail;
node->type = TYPE_MOUSE;
if (!insert_seq (ti, mouse_report_string, node))
{
free (node);
// FIXME: unibi leak
return false;
goto fail;
}
}
@@ -305,11 +308,14 @@ load_terminfo (termo_ti_t *ti, const char *term)
else
ti->stop_string = NULL;
result = true;
fail:
#ifdef HAVE_UNIBILIUM
unibi_destroy (unibi);
#else
del_curterm (set_curterm (saved_term));
#endif
return true;
return result;
}
static bool

24
termo.c
View File

@@ -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))
if (!termo_init (tk, term, encoding))
free (tk);
else if (!(flags & TERMO_FLAG_NOSTART) && !termo_start (tk))
termo_free (tk);
else
return tk;
// FIXME: resource leak on termo_start() failure
free (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);
return tk;
else if (!(flags & TERMO_FLAG_NOSTART) && !termo_start (tk))
termo_free (tk);
else
return tk;
return NULL;
}
void
@@ -1013,7 +1012,7 @@ peekkey_simple (termo_t *tk, termo_key_t *key, int flags, size_t *nbytep)
// XXX: this way DEL is never recognised as backspace, even if it is
// specified in the terminfo entry key_backspace. Just because it
// doesn't form an escape sequence.
uint32_t codepoint;
uint32_t codepoint = MULTIBYTE_INVALID;
termo_result_t res = parse_multibyte
(tk, tk->buffer + tk->buffstart, tk->buffcount, &codepoint, nbytep);
@@ -1023,7 +1022,6 @@ peekkey_simple (termo_t *tk, termo_key_t *key, int flags, size_t *nbytep)
// caller demands an answer. About the best thing we can do here
// is eat as many bytes as we have, and emit a MULTIBYTE_INVALID.
// If the remaining bytes arrive later, they'll be invalid too.
codepoint = MULTIBYTE_INVALID;
*nbytep = tk->buffcount;
res = TERMO_RES_KEY;
}

View File

@@ -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