From d887ff42ebdb76914b854a40cbd2ae4dc54faf12 Mon Sep 17 00:00:00 2001 From: Marco Barisione Date: Mon, 19 Nov 2007 11:27:43 +0000 Subject: [PATCH] When the compilation of a pattern fails in the error message use the 2007-11-19 Marco Barisione * glib/gregex.c: When the compilation of a pattern fails in the error message use the character offset and not the byte offset. svn path=/trunk/; revision=5867 --- ChangeLog | 5 +++++ glib/gregex.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b67d1d8..e33086c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-11-19 Marco Barisione + + * glib/gregex.c: When the compilation of a pattern fails in the error + message use the character offset and not the byte offset. + 2007-11-19 10:30:33 Tim Janik * configure.in: updated version number to 2.15.0 for development. diff --git a/glib/gregex.c b/glib/gregex.c index 9485daed..d0acc8b4 100644 --- a/glib/gregex.c +++ b/glib/gregex.c @@ -924,11 +924,16 @@ g_regex_new (const gchar *pattern, * immediately */ if (re == NULL) { - GError *tmp_error = g_error_new (G_REGEX_ERROR, - G_REGEX_ERROR_COMPILE, - _("Error while compiling regular " - "expression %s at char %d: %s"), - pattern, erroffset, errmsg); + GError *tmp_error; + + /* PCRE uses byte offsets but we want to show character offsets */ + erroffset = g_utf8_pointer_to_offset (pattern, &pattern[erroffset]); + + tmp_error = g_error_new (G_REGEX_ERROR, + G_REGEX_ERROR_COMPILE, + _("Error while compiling regular " + "expression %s at char %d: %s"), + pattern, erroffset, errmsg); g_propagate_error (error, tmp_error); return NULL; -- 2.34.1