aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-10-12 00:17:41 +0800
committerChris Lahey <clahey@src.gnome.org>2001-10-12 00:17:41 +0800
commit69b2e6d8eee098cf070e9797dd9d9bfde933d21f (patch)
tree819983f4074e2b418733dcd90b7493205e4ec188 /e-util
parentae61b9ce6897122308ec0224daec94182467ce23 (diff)
downloadgsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar
gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar.gz
gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar.bz2
gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar.lz
gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar.xz
gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar.zst
gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.zip
Use e_strdup_append_strings here instead of g_strdup_printf because
2001-10-11 Christopher James Lahey <clahey@ximian.com> * 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
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c53
-rw-r--r--e-util/e-util.h4
2 files changed, 57 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 345fd39bf4..b8fab82b25 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1402,3 +1402,56 @@ e_ascii_dtostr (gchar *buffer,
return buffer;
}
+
+gchar *
+e_strdup_append_strings (gchar *first_string, ...)
+{
+ gchar *buffer;
+ gchar *current;
+ gint length;
+ va_list args1;
+ va_list args2;
+ char *v_string;
+ int v_int;
+
+ va_start (args1, first_string);
+ G_VA_COPY (args2, args1);
+
+ length = 0;
+
+ v_string = first_string;
+ while (v_string) {
+ v_int = va_arg (args1, int);
+ if (v_int >= 0)
+ length += v_int;
+ else
+ length += strlen (v_string);
+ v_string = va_arg (args1, char *);
+ }
+
+ buffer = g_new (char, length + 1);
+ current = buffer;
+
+ v_string = first_string;
+ while (v_string) {
+ v_int = va_arg (args2, int);
+ if (v_int < 0) {
+ int i;
+ for (i = 0; v_string[i]; i++) {
+ *(current++) = v_string[i];
+ }
+ } else {
+ int i;
+ for (i = 0; v_string[i] && i < v_int; i++) {
+ *(current++) = v_string[i];
+ }
+ }
+ v_string = va_arg (args2, char *);
+ }
+ *(current++) = 0;
+
+ va_end (args1);
+ va_end (args2);
+
+ return buffer;
+}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index e9eb07ffa8..f7b2bf7a3c 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -129,6 +129,10 @@ gchar *e_ascii_dtostr (gcha
const gchar *format,
gdouble d);
+/* Alternating char * and int arguments with a NULL char * to end.
+ Less than 0 for the int means copy the whole string. */
+gchar *e_strdup_append_strings (gchar *first_string,
+ ...);
/* Marshallers */
void e_marshal_INT__INT_INT_POINTER (GtkObject *object,