[parted-devel] [PATCH] do not translate partition names

David Cantrell dcantrell at redhat.com
Mon Apr 23 20:05:39 UTC 2007


commit 6d05a00c0775b5367eb7d2e3aa7c9b5b2e557915
Author: David Cantrell <dcantrel at mortise.boston.redhat.com>
Date:   Mon Apr 23 15:58:03 2007 -0400

    Do not translate partition names in 'parted print' command.  This
causes problems for non-Latin-based character sets.  Also, we don't want
to translate the partition name here as we are just showing what is in
the disklabel, translating it distorts what the value is.
    
    Also added some malloc checks in table.c.

diff --git a/parted/parted.c b/parted/parted.c
index ff72dcd..25fbf5d 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1443,8 +1443,7 @@ do_print (PedDevice** dev)
 
                     if (!(part->type & PED_PARTITION_FREESPACE)) {
                             if (has_extended) {
-                                name = 
-                                    _(ped_partition_type_get_name
(part->type));
+                                name = ped_partition_type_get_name
(part->type);
                                 str_list_append (row, name);
                             }
 
@@ -1452,7 +1451,7 @@ do_print (PedDevice** dev)
                                              part->fs_type->name : "");
 
                             if (has_name) {
-                                    name = _(ped_partition_get_name
(part));
+                                    name = ped_partition_get_name
(part);
                                     str_list_append (row, name);
                             }
 
diff --git a/parted/table.c b/parted/table.c
index 3b89e6d..c44db10 100644
--- a/parted/table.c
+++ b/parted/table.c
@@ -184,14 +184,15 @@ static void table_render_row (Table* t, int
rownum, int ncols, wchar_t** s)
 
         assert(t);
         assert(s != NULL);
-        
+
         for (i = 0; i < ncols; ++i)
                 len += t->widths[i] + wcslen(DELIMITER);
 
         len += wcslen(COLSUFFIX);
 
         newsize = (wcslen(*s) + len + 1) * sizeof(wchar_t);
-        *s = realloc (*s, newsize);
+        *s = (wchar_t *) realloc (*s, newsize);
+        assert(*s != NULL);
 
         for (i = 0; i < ncols; ++i)
         {
@@ -199,6 +200,7 @@ static void table_render_row (Table* t, int rownum,
int ncols, wchar_t** s)
                 int nspaces = max(t->widths[i] - wcswidth(row[i],
MAX_WIDTH),
                                   0);
                 wchar_t* pad = malloc ( (nspaces + 1) *
sizeof(wchar_t) );
+                assert(pad != NULL);
 
                 for (j = 0; j < nspaces; ++j)
                        pad[j] = L' '; 
@@ -211,6 +213,7 @@ static void table_render_row (Table* t, int rownum,
int ncols, wchar_t** s)
                         wcscat (*s, DELIMITER);
 
                 free (pad);
+                pad = NULL;
         }
 
         wcscat (*s, COLSUFFIX);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20070423/6800c24c/attachment.pgp


More information about the parted-devel mailing list