[gnome-shell/uiTweaks2: 6/11] util: Wrap g_regex_escape_string()
- From: Rares Visalom <raresvisalom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/uiTweaks2: 6/11] util: Wrap g_regex_escape_string()
- Date: Wed, 5 Jul 2017 20:58:31 +0000 (UTC)
commit 50114894cbe0daaf146c73d17e22073ee8ddbf88
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]