[gnumeric] Search/Replace: normalize result to NFC.



commit c0389c55db617738af713a8b4dca50482135b32e
Author: Morten Welinder <terra gnome org>
Date:   Fri Apr 6 15:05:29 2012 -0400

    Search/Replace: normalize result to NFC.
    
    This happens to hide a pango bug.  See #673447.

 ChangeLog    |    2 ++
 NEWS         |    1 +
 src/search.c |   12 +++++++++++-
 3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5589b2d..7edbe41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
 	before search and search/replace.
 	(gnm_search_replace_comment, gnm_search_replace_cell)
 	(gnm_search_replace_value): Use gnm_search_normalize.
+	(gnm_search_replace_cell): Normalize the result to NFC.  Fixes
+	#673447.
 
 2012-03-29  Morten Welinder  <terra gnome org>
 
diff --git a/NEWS b/NEWS
index 8b3f263..535bc98 100644
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,7 @@ Morten:
 	* New function COVARIANCE.S.
 	* Enable MATCH/VLOOKUP/HLOOKUP caches during redraw.
 	* Speed-up some operations on large areas.
+	* Work around pango bug affecting search/replace.  [#673447]
 
 --------------------------------------------------------------------------
 Gnumeric 1.11.2
diff --git a/src/search.c b/src/search.c
index e3a864e..812d5e0 100644
--- a/src/search.c
+++ b/src/search.c
@@ -62,7 +62,13 @@ gnm_search_replace_value (GnmSearchReplace *sr,
 char *
 gnm_search_normalize (const char *txt)
 {
-	return g_utf8_normalize (txt, -1, G_NORMALIZE_DEFAULT);
+	return g_utf8_normalize (txt, -1, G_NORMALIZE_NFD);
+}
+
+static char *
+gnm_search_normalize_result (const char *txt)
+{
+	return g_utf8_normalize (txt, -1, G_NORMALIZE_NFC);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -402,6 +408,10 @@ gnm_search_replace_cell (GnmSearchReplace *sr,
 			res->new_text = go_search_replace_string (GO_SEARCH_REPLACE (sr),
 								  actual_src);
 			if (res->new_text) {
+				char *norm = gnm_search_normalize_result (res->new_text);
+				g_free (res->new_text);
+				res->new_text = norm;
+
 				if (sr->replace_keep_strings && is_string) {
 					/*
 					 * The initial quote was not part of the s-a-r,



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