From bcec9f35d59427dca2ac4e74a40cc9a6482d7494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 23 Jun 2017 20:12:38 +0200 Subject: [PATCH] util: Wrap g_regex_escape_string() --- src/shell-util.c | 15 +++++++++++++++ src/shell-util.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/shell-util.c b/src/shell-util.c index bedd5869b..7383e8423 100644 --- a/src/shell-util.c +++ b/src/shell-util.c @@ -240,6 +240,21 @@ shell_util_translate_time_string (const char *str) return res; } +/** + * shell_util_regex_escape: + * @str: a UTF-8 string to escape + * + * A wrapper around g_regex_escape_string() that takes its argument as + * \0-terminated string rather than a byte-array the confuses gjs. + * + * Returns: @str with all regex-special characters escaped + */ +char * +shell_util_regex_escape (const char *str) +{ + return g_regex_escape_string (str, -1); +} + /** * shell_write_string_to_stream: * @stream: a #GOutputStream diff --git a/src/shell-util.h b/src/shell-util.h index 532e19ba9..2218594c1 100644 --- a/src/shell-util.h +++ b/src/shell-util.h @@ -24,6 +24,8 @@ char *shell_util_format_date (const char *format, gint64 time_ms); const char *shell_util_translate_time_string (const char *str); +char *shell_util_regex_escape (const char *str); + gboolean shell_write_string_to_stream (GOutputStream *stream, const char *str, GError **error);