From 24ad244ee52ed76b609a1c3236edc3da73439ee1 Mon Sep 17 00:00:00 2001
From: Vit Rosin <vit_r@list.ru>
Date: Thu, 4 Mar 2010 11:34:56 +0000
Subject: [PATCH] edit.c replacing g_string_sprintf by g_strdup_printf
---
src/editor/edit.c | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/src/editor/edit.c b/src/editor/edit.c
index b88e294..c805737 100644
a
|
b
|
edit_load_file_fast (WEdit *edit, const char *filename) |
296 | 296 | buf2 = edit->curs2 >> S_EDIT_BUF_SIZE; |
297 | 297 | edit->utf8 = 0; |
298 | 298 | if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) { |
299 | | GString *errmsg = g_string_new(NULL); |
300 | | g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename); |
301 | | edit_error_dialog (_("Error"), get_sys_error (errmsg->str)); |
302 | | g_string_free (errmsg, TRUE); |
| 299 | gchar *errmsg; |
| 300 | |
| 301 | errmsg = g_strdup_printf (_(" Cannot open %s for reading "), filename); |
| 302 | edit_error_dialog (_("Error"), errmsg); |
| 303 | g_free (errmsg); |
303 | 304 | return 1; |
304 | 305 | } |
305 | 306 | |
… |
… |
static int |
555 | 556 | check_file_access (WEdit *edit, const char *filename, struct stat *st) |
556 | 557 | { |
557 | 558 | int file; |
558 | | GString *errmsg = (GString *) 0; |
| 559 | gchar *errmsg = NULL; |
559 | 560 | |
560 | 561 | /* Try opening an existing file */ |
561 | 562 | file = mc_open (filename, O_NONBLOCK | O_RDONLY | O_BINARY, 0666); |
… |
… |
check_file_access (WEdit *edit, const char *filename, struct stat *st) |
570 | 571 | O_NONBLOCK | O_RDONLY | O_BINARY | O_CREAT | O_EXCL, |
571 | 572 | 0666); |
572 | 573 | if (file < 0) { |
573 | | g_string_sprintf (errmsg = g_string_new (NULL), |
574 | | _(" Cannot open %s for reading "), filename); |
| 574 | errmsg = g_strdup_printf (_(" Cannot open %s for reading "), filename); |
575 | 575 | goto cleanup; |
576 | 576 | } else { |
577 | 577 | /* New file, delete it if it's not modified or saved */ |
… |
… |
check_file_access (WEdit *edit, const char *filename, struct stat *st) |
581 | 581 | |
582 | 582 | /* Check what we have opened */ |
583 | 583 | if (mc_fstat (file, st) < 0) { |
584 | | g_string_sprintf (errmsg = g_string_new (NULL), |
585 | | _(" Cannot get size/permissions for %s "), filename); |
| 584 | errmsg = g_strdup_printf (_(" Cannot get size/permissions for %s "), filename); |
586 | 585 | goto cleanup; |
587 | 586 | } |
588 | 587 | |
589 | 588 | /* We want to open regular files only */ |
590 | 589 | if (!S_ISREG (st->st_mode)) { |
591 | | g_string_sprintf (errmsg = g_string_new (NULL), |
592 | | _(" %s is not a regular file "), filename); |
| 590 | errmsg = g_strdup_printf (_(" %s is not a regular file "), filename); |
593 | 591 | goto cleanup; |
594 | 592 | } |
595 | 593 | |
… |
… |
check_file_access (WEdit *edit, const char *filename, struct stat *st) |
601 | 599 | edit->delete_file = 0; |
602 | 600 | } |
603 | 601 | |
604 | | if (st->st_size >= SIZE_LIMIT) { |
605 | | g_string_sprintf (errmsg = g_string_new (NULL), |
606 | | _(" File %s is too large "), filename); |
607 | | } |
| 602 | if (st->st_size >= SIZE_LIMIT) |
| 603 | errmsg = g_strdup_printf (_(" File %s is too large "), filename); |
608 | 604 | |
609 | 605 | cleanup: |
610 | 606 | (void) mc_close (file); |
611 | | if (errmsg) { |
612 | | edit_error_dialog (_("Error"), errmsg->str); |
613 | | g_string_free (errmsg, TRUE); |
| 607 | if (errmsg != NULL) { |
| 608 | edit_error_dialog (_("Error"), errmsg); |
| 609 | g_free (errmsg); |
614 | 610 | return 1; |
615 | 611 | } |
616 | 612 | return 0; |