From 5cd94a0982e4a910ee33ec58f7678429ec067b6f Mon Sep 17 00:00:00 2001
From: Aleksei Rybalkin <aleksei@rybalkin.org>
Date: Thu, 14 Jul 2022 13:14:31 +0000
Subject: [PATCH] gregex: use %s format specifier for localized error message

Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/5cd94a0982e4a910ee33ec58f7678429ec067b6f

---
 glib/gregex.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/glib/gregex.c b/glib/gregex.c
index 55672249cb..5fc7b16bc8 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1661,6 +1661,7 @@ regex_compile (const gchar *pattern,
   if (re == NULL)
     {
       GError *tmp_error;
+      gchar *offset_str;
 
       /* Translate the PCRE error code to GRegexError and use a translated
        * error message if possible */
@@ -1669,11 +1670,13 @@ regex_compile (const gchar *pattern,
       /* PCRE uses byte offsets but we want to show character offsets */
       erroffset = g_utf8_pointer_to_offset (pattern, &pattern[erroffset]);
 
+      offset_str = g_strdup_printf ("%" G_GSIZE_FORMAT, erroffset);
       tmp_error = g_error_new (G_REGEX_ERROR, errcode,
-                               _("Error while compiling regular "
-                                 "expression %s at char %" G_GSIZE_FORMAT ": %s"),
-                               pattern, erroffset, errmsg);
+                               _("Error while compiling regular expression ‘%s’ "
+                                 "at char %s: %s"),
+                               pattern, offset_str, errmsg);
       g_propagate_error (error, tmp_error);
+      g_free (offset_str);
 
       return NULL;
     }
-- 
GitLab

