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);