[gnome-shell/wip/raresv/uiTweaks: 22/26] util: Wrap g_regex_escape_string()



commit 04ad2b24d82e889a8845d0b445121eee10b14a6b
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jun 23 20:12:38 2017 +0200

    util: Wrap g_regex_escape_string()

 src/shell-util.c |   15 +++++++++++++++
 src/shell-util.h |    2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-util.c b/src/shell-util.c
index f72645c..a454e4d 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -241,6 +241,21 @@ shell_util_translate_time_string (const char *str)
 }
 
 /**
+ * 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
  * @str: a UTF-8 string to write to @stream
diff --git a/src/shell-util.h b/src/shell-util.h
index 532e19b..2218594 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]