From ea7581d40502c80950b2bb908c3838f248051c85 Mon Sep 17 00:00:00 2001 From: Morten Welinder Date: Wed, 10 Jul 2002 18:20:14 +0000 Subject: [PATCH] Use glib 2's g_string_append_len. (calculate_replacement): Ditto. 2002-07-10 Morten Welinder * src/search.c (search_replace_string): Use glib 2's g_string_append_len. (calculate_replacement): Ditto. (cb_order_sheet_col_row, cb_order_sheet_row_col): Make UTF-8 safe. --- ChangeLog | 7 +++++++ OChangeLog-2003-12-23 | 7 +++++++ OChangeLog-2005-11-14 | 7 +++++++ src/search.c | 19 ++++++++----------- src/workbook-control-component.c | 1 - 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89c952135..08eab4481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-07-10 Morten Welinder + + * src/search.c (search_replace_string): Use glib 2's + g_string_append_len. + (calculate_replacement): Ditto. + (cb_order_sheet_col_row, cb_order_sheet_row_col): Make UTF-8 safe. + 2002-07-09 Morten Welinder * src/mathfunc.c (random_poisson): Fix loop (by switching method). diff --git a/OChangeLog-2003-12-23 b/OChangeLog-2003-12-23 index 89c952135..08eab4481 100644 --- a/OChangeLog-2003-12-23 +++ b/OChangeLog-2003-12-23 @@ -1,3 +1,10 @@ +2002-07-10 Morten Welinder + + * src/search.c (search_replace_string): Use glib 2's + g_string_append_len. + (calculate_replacement): Ditto. + (cb_order_sheet_col_row, cb_order_sheet_row_col): Make UTF-8 safe. + 2002-07-09 Morten Welinder * src/mathfunc.c (random_poisson): Fix loop (by switching method). diff --git a/OChangeLog-2005-11-14 b/OChangeLog-2005-11-14 index 89c952135..08eab4481 100644 --- a/OChangeLog-2005-11-14 +++ b/OChangeLog-2005-11-14 @@ -1,3 +1,10 @@ +2002-07-10 Morten Welinder + + * src/search.c (search_replace_string): Use glib 2's + g_string_append_len. + (calculate_replacement): Ditto. + (cb_order_sheet_col_row, cb_order_sheet_row_col): Make UTF-8 safe. + 2002-07-09 Morten Welinder * src/mathfunc.c (random_poisson): Fix loop (by switching method). diff --git a/src/search.c b/src/search.c index 487c69c6d..768dfce97 100644 --- a/src/search.c +++ b/src/search.c @@ -227,13 +227,13 @@ calculate_replacement (SearchReplace *sr, const char *src, const regmatch_t *pm) switch (*s) { case '$': { - int i; int n = s[1] - '0'; s++; g_assert (n > 0 && n <= (int)sr->comp_search->re_nsub); - for (i = pm[n].rm_so; i < pm[n].rm_eo; i++) - g_string_append_c (gres, src[i]); + g_string_append_len (gres, + src + pm[n].rm_so, + pm[n].rm_eo - pm[n].rm_so); break; } case '\\': @@ -383,11 +383,8 @@ search_replace_string (SearchReplace *sr, const char *src) res = g_string_sized_new (size); } - if (pmatch[0].rm_so) { - int i; - /* This is terrible! */ - for (i = 0; i < pmatch[0].rm_so; i++) - g_string_append_c (res, src[i]); + if (pmatch[0].rm_so > 0) { + g_string_append_len (res, src, pmatch[0].rm_so); } if (sr->match_words && !match_is_word (sr, src, pmatch, @@ -444,7 +441,7 @@ cb_order_sheet_row_col (const void *_a, const void *_b) int i; /* By sheet name. FIXME: Any better way than this? */ - i = strcmp (a->sheet->name_unquoted, b->sheet->name_unquoted); + i = g_utf8_collate (a->sheet->name_unquoted, b->sheet->name_unquoted); /* By row number. */ if (!i) i = (a->eval.row - b->eval.row); @@ -463,7 +460,7 @@ cb_order_sheet_col_row (const void *_a, const void *_b) int i; /* By sheet name. FIXME: Any better way than this? */ - i = strcmp (a->sheet->name_unquoted, b->sheet->name_unquoted); + i = g_utf8_collate (a->sheet->name_unquoted, b->sheet->name_unquoted); /* By column number. */ if (!i) i = (a->eval.col - b->eval.col); @@ -476,7 +473,7 @@ cb_order_sheet_col_row (const void *_a, const void *_b) static Value * search_collect_cells_cb (Sheet *sheet, int col, int row, - Cell *cell, GPtrArray *cells) + Cell *cell, GPtrArray *cells) { EvalPos *ep = g_new (EvalPos, 1); diff --git a/src/workbook-control-component.c b/src/workbook-control-component.c index a715f61a7..82b5fdce9 100644 --- a/src/workbook-control-component.c +++ b/src/workbook-control-component.c @@ -244,7 +244,6 @@ cb_edit_copy (GtkWidget *widget, BonoboControl *control) { WorkbookControlGUI *wbcg = bcontrol_get_wbcg (control); WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg); - Sheet *sheet; g_return_if_fail (wbcg != NULL); -- GitLab