Use g_strdup_printf, not asprintf.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2912 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-09-20 21:38:54 +00:00
parent 0ba828f12f
commit 02e44a16e5
2 changed files with 51 additions and 35 deletions

View File

@ -230,7 +230,7 @@ gnc_ui_qif_import_load_file_cb(GtkButton * button, gpointer user_data) {
char * path_to_load;
char * qif_account;
char * currency;
char * error_string = NULL;
char * error_string;
struct timeval start, end;
@ -321,19 +321,21 @@ gnc_ui_qif_import_load_file_cb(GtkButton * button, gpointer user_data) {
* (#t error-message) for a warning */
if(gh_list_p(load_return) &&
(gh_car(load_return) == SCM_BOOL_T)) {
asprintf(&error_string,
QIF_LOAD_WARNING_FORMAT_MSG,
gh_scm2newstr(gh_cadr(load_return), NULL));
error_string = g_strdup_printf(QIF_LOAD_WARNING_FORMAT_MSG,
gh_scm2newstr(gh_cadr(load_return),
NULL));
gnc_warning_dialog_parented(GTK_WIDGET(wind->dialog), error_string);
g_free(error_string);
}
if((load_return != SCM_BOOL_T) &&
(!gh_list_p(load_return) ||
(gh_car(load_return) != SCM_BOOL_T))) {
asprintf(&error_string,
QIF_LOAD_FAILED_FORMAT_MSG,
gh_scm2newstr(gh_cadr(load_return), NULL));
error_string = g_strdup_printf(QIF_LOAD_FAILED_FORMAT_MSG,
gh_scm2newstr(gh_cadr(load_return),
NULL));
gnc_error_dialog_parented(GTK_WINDOW(wind->dialog), error_string);
g_free(error_string);
imported_files =
gh_call2(unload_qif_file, scm_filename, imported_files);
@ -343,18 +345,21 @@ gnc_ui_qif_import_load_file_cb(GtkButton * button, gpointer user_data) {
if(gh_list_p(parse_return) &&
(gh_car(parse_return) == SCM_BOOL_T)) {
asprintf(&error_string,
QIF_PARSE_WARNING_FORMAT_MSG,
gh_scm2newstr(gh_cadr(parse_return), NULL));
error_string = g_strdup_printf(QIF_PARSE_WARNING_FORMAT_MSG,
gh_scm2newstr(gh_cadr(parse_return),
NULL));
gnc_warning_dialog_parented(GTK_WIDGET(wind->dialog), error_string);
g_free(error_string);
}
if((parse_return != SCM_BOOL_T) &&
(!gh_list_p(parse_return) ||
(gh_car(parse_return) != SCM_BOOL_T))) {
asprintf(&error_string,
QIF_PARSE_FAILED_FORMAT_MSG,
gh_scm2newstr(gh_cadr(parse_return), NULL));
error_string = g_strdup_printf(QIF_PARSE_FAILED_FORMAT_MSG,
gh_scm2newstr(gh_cadr(parse_return),
NULL));
gnc_error_dialog_parented(GTK_WINDOW(wind->dialog), error_string);
g_free(error_string);
imported_files =
gh_call2(unload_qif_file, scm_filename, imported_files);
}
@ -722,7 +727,7 @@ update_accounts_page(QIFImportWindow * wind) {
row_text[0] = gh_scm2newstr(gh_caar(strings_left), &scheme_strlen);
xtn_count = gh_scm2int(gh_list_ref(gh_car(strings_left),
gh_int2scm(4)));
asprintf(&xtn_count_string, "%d", xtn_count);
xtn_count_string = g_strdup_printf("%d", xtn_count);
row_text[1] = xtn_count_string;
row_text[2] = gh_scm2newstr(gh_cadr(gh_car(strings_left)),
&scheme_strlen);
@ -739,8 +744,11 @@ update_accounts_page(QIFImportWindow * wind) {
strings_left = gh_cdr(strings_left);
row++;
}
free(row_text[0]);
g_free(row_text[1]);
free(row_text[2]);
}
gtk_clist_thaw(GTK_CLIST(wind->acct_list));
}
@ -819,7 +827,7 @@ update_categories_page(QIFImportWindow * wind) {
row_text[0] = gh_scm2newstr(gh_caar(strings_left), &scheme_strlen);
xtn_count = gh_scm2int(gh_list_ref(gh_car(strings_left),
gh_int2scm(4)));
asprintf(&xtn_count_string, "%d", xtn_count);
xtn_count_string = g_strdup_printf("%d", xtn_count);
row_text[1] = xtn_count_string;
row_text[2] = gh_scm2newstr(gh_cadr(gh_car(strings_left)),
&scheme_strlen);
@ -832,6 +840,10 @@ update_categories_page(QIFImportWindow * wind) {
scm_protect_object(gh_car(strings_left));
strings_left = gh_cdr(strings_left);
row++;
free(row_text[0]);
g_free(row_text[1]);
free(row_text[2]);
}
gtk_clist_thaw(GTK_CLIST(wind->cat_list));

View File

@ -100,21 +100,24 @@ gnc_ui_print_dialog_create(PrintSession * ps) {
if(ps->printer->driver) {
if(ps->printer->filename) {
asprintf(&printer_string, "(%s) %s",
ps->printer->driver, ps->printer->filename);
printer_string = g_strdup_printf("(%s) %s",
ps->printer->driver,
ps->printer->filename);
}
else {
printer_string = ps->printer->driver;
printer_string = g_strdup(ps->printer->driver);
}
}
else {
printer_string = _("(none)");
printer_string = g_strdup(_("(none)"));
}
gtk_entry_set_text(GTK_ENTRY(pcd->paper_entry), ps->paper);
gtk_entry_set_text(GTK_ENTRY(pcd->printer_entry), printer_string);
gtk_widget_show_all(pcd->toplevel);
g_free(printer_string);
return pcd;
}
@ -188,19 +191,20 @@ gnc_ui_print_dialog_select_printer_cb(GtkButton * button, gpointer user_data) {
if(pcd->session->printer->driver) {
if(pcd->session->printer->filename) {
asprintf(&printer_string, "(%s) %s",
printer_string = g_strdup_printf("(%s) %s",
pcd->session->printer->driver,
pcd->session->printer->filename);
}
else {
printer_string = pcd->session->printer->driver;
printer_string = g_strdup(pcd->session->printer->driver);
}
}
else {
printer_string = _("(none)");
printer_string = g_strdup(_("(none)"));
}
gtk_entry_set_text(GTK_ENTRY(pcd->printer_entry), printer_string);
g_free(printer_string);
}
}
}