From 69b2e6d8eee098cf070e9797dd9d9bfde933d21f Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 11 Oct 2001 16:17:41 +0000 Subject: Use e_strdup_append_strings here instead of g_strdup_printf because 2001-10-11 Christopher James Lahey * gal/e-text/e-table-text-model.c (e_table_text_model_insert, e_table_text_model_insert_length, e_table_text_model_delete), gal/e-text/e-text-model.c (e_text_model_real_insert, e_text_model_real_insert_length): Use e_strdup_append_strings here instead of g_strdup_printf because printf("%.*s") is locale dependent on some systems. * gal/util/e-util.c (e_strdup_append_strings): New function to append a bunch of strings with optional lengths. svn path=/trunk/; revision=13581 --- widgets/text/e-table-text-model.c | 21 ++++++++++++++++++--- widgets/text/e-text-model.c | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'widgets/text') diff --git a/widgets/text/e-table-text-model.c b/widgets/text/e-table-text-model.c index daf0456110..f7b7dc1400 100644 --- a/widgets/text/e-table-text-model.c +++ b/widgets/text/e-table-text-model.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "e-table-text-model.h" static void e_table_text_model_class_init (ETableTextModelClass *class); @@ -151,7 +152,12 @@ e_table_text_model_insert (ETextModel *text_model, gint position, const gchar *t ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model){ gchar *temp = (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); - temp = g_strdup_printf ("%.*s%s%s", position, temp, text, temp + position); + /* Can't use g_strdup_printf here because on some + systems printf ("%.*s"); is locale dependent. */ + temp = e_strdup_append_strings (temp, position, + text, -1, + temp + position, -1, + NULL); e_table_model_set_value_at (model->model, model->model_col, model->row, temp); g_free (temp); } @@ -163,7 +169,12 @@ e_table_text_model_insert_length (ETextModel *text_model, gint position, const g ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model){ gchar *temp = (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); - temp = g_strdup_printf ("%.*s%.*s%s", position, temp, length, text, temp + position); + /* Can't use g_strdup_printf here because on some + systems printf ("%.*s"); is locale dependent. */ + temp = e_strdup_append_strings (temp, position, + text, length, + temp + position, -1, + NULL); e_table_model_set_value_at (model->model, model->model_col, model->row, temp); g_free (temp); } @@ -175,7 +186,11 @@ e_table_text_model_delete (ETextModel *text_model, gint position, gint length) ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model){ gchar *temp = (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); - temp = g_strdup_printf ("%.*s%s", position, temp, temp + position + length); + /* Can't use g_strdup_printf here because on some + systems printf ("%.*s"); is locale dependent. */ + temp = e_strdup_append_strings (temp, position, + temp + position + length, -1, + NULL); e_table_model_set_value_at (model->model, model->model_col, model->row, temp); g_free (temp); } diff --git a/widgets/text/e-text-model.c b/widgets/text/e-text-model.c index 97eb2a9a86..929247ed4e 100644 --- a/widgets/text/e-text-model.c +++ b/widgets/text/e-text-model.c @@ -268,7 +268,12 @@ e_text_model_real_insert (ETextModel *model, gint position, const gchar *text) if (length <= 0) return; - new_text = g_strdup_printf ("%.*s%.*s%s", position, model->priv->text, length, text, model->priv->text + position); + /* Can't use g_strdup_printf here because on some systems + printf ("%.*s"); is locale dependent. */ + new_text = e_strdup_append_strings (model->priv->text, position, + text, length, + model->priv->text + position, -1, + NULL); if (model->priv->text) g_free (model->priv->text); @@ -301,7 +306,12 @@ e_text_model_real_insert_length (ETextModel *model, gint position, const gchar * if (length <= 0) return; - new_text = g_strdup_printf ("%.*s%.*s%s", position, model->priv->text, length, text, model->priv->text + position); + /* Can't use g_strdup_printf here because on some systems + printf ("%.*s"); is locale dependent. */ + new_text = e_strdup_append_strings (model->priv->text, position, + text, length, + model->priv->text + position, -1, + NULL); if (model->priv->text) g_free (model->priv->text); -- cgit v1.2.3