diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-10-12 00:17:41 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-10-12 00:17:41 +0800 |
commit | 69b2e6d8eee098cf070e9797dd9d9bfde933d21f (patch) | |
tree | 819983f4074e2b418733dcd90b7493205e4ec188 /e-util/e-util.c | |
parent | ae61b9ce6897122308ec0224daec94182467ce23 (diff) | |
download | gsoc2013-evolution-69b2e6d8eee098cf070e9797dd9d9bfde933d21f.tar.gz 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/e-util.c')
-rw-r--r-- | e-util/e-util.c | 53 |
1 files changed, 53 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; +} |