diff options
-rw-r--r-- | src/doc.c | 3 | ||||
-rw-r--r-- | src/qreg.c | 12 | ||||
-rw-r--r-- | tests/testsuite.at | 9 |
3 files changed, 17 insertions, 7 deletions
@@ -176,7 +176,8 @@ teco_doc_undo_set_string(teco_doc_t *ctx) * @param str Pointer to a variable to hold the return string. * It can be NULL if you are interested only in the string's length. * Strings must be freed via g_free(). - * @param len Where to store the string's length (mandatory). + * @param len Where to store the string's length or NULL + * if that information is not necessary. * @param codepage Where to store the document's codepage or NULL * if that information is not necessary. * @@ -665,9 +665,6 @@ teco_qreg_bufferinfo_append_string(teco_qreg_t *qreg, const gchar *str, gsize le return FALSE; } -/* - * NOTE: The `string` component is currently unused on the "*" register. - */ static gboolean teco_qreg_bufferinfo_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, guint *codepage, GError **error) @@ -684,7 +681,8 @@ teco_qreg_bufferinfo_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, /* * NOTE: teco_file_normalize_path() does not change the size of the string. */ - *len = teco_ring_current->filename ? strlen(teco_ring_current->filename) : 0; + if (len) + *len = teco_ring_current->filename ? strlen(teco_ring_current->filename) : 0; if (codepage) *codepage = teco_default_codepage(); return TRUE; @@ -775,7 +773,8 @@ teco_qreg_workingdir_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, * the return value for str == NULL is still correct. */ gchar *dir = g_get_current_dir(); - *len = strlen(dir); + if (len) + *len = strlen(dir); if (str) *str = teco_file_normalize_path(dir); else @@ -919,11 +918,12 @@ teco_qreg_clipboard_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, &str_converted.len, error) == G_IO_STATUS_ERROR) return FALSE; + if (len) + *len = str_converted.len; if (str) *str = str_converted.data; else teco_string_clear(&str_converted); - *len = str_converted.len; if (codepage) *codepage = teco_default_codepage(); diff --git a/tests/testsuite.at b/tests/testsuite.at index ffb3941..f17a711 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -244,6 +244,15 @@ AT_CHECK([$SCITECO -e '@I/^E@a/'], 0, ignore, ignore) AT_CHECK([$SCITECO -e '@I/^ENa/'], 0, ignore, ignore) AT_CLEANUP +AT_SETUP([Setting special Q-Registers with EU]) +# NOTE: The clipboard registers also suffered from this, but the test suite +# should not influence the clipboard (and it's not in Curses anyway). +# +# Should fail, but not crash +AT_CHECK([$SCITECO -e '@EU*""'], 1, ignore, ignore) +AT_CHECK([$SCITECO -e '@EU$"."'], 0, ignore, ignore) +AT_CLEANUP + AT_SETUP([Empty help topic]) AT_CHECK([$SCITECO -e '@?//'], 1, ignore, ignore) AT_CLEANUP |