[Parted-commits] GNU Parted Official Repository: Changes to 'stable-1.8.x'

Otavio Salvador otavio at alioth.debian.org
Wed May 30 02:25:17 UTC 2007


 include/parted/fdasd.h     |    1 
 include/parted/vtoc.h      |    1 
 libparted/labels/fdasd.c   |   89 +++++++++++++++++++++------------------------
 libparted/labels/vtoc.c    |   46 +++++++++++------------
 parted/parted.c            |   23 ++++++-----
 parted/table.c             |    5 ++
 tests/Makefile.am          |    1 
 tests/t0000-basic.sh       |    5 +-
 tests/t0100-print.sh       |   58 +++++++++++++++++++++++++++++
 tests/t3000-constraints.sh |    8 ----
 tests/test-lib.sh          |    7 +++
 11 files changed, 150 insertions(+), 94 deletions(-)

New commits:
commit 94a98e078645a7bca60c95d63b2102a60d7bad53
Author: Benno Schulenberg <bensberg at justemail.net>
Date:   Tue May 29 20:02:25 2007 +0200

    fdasd label: Move formatting out of translatable strings.
    
    Also gettextize several missed messages, and simplify some of them.
    
    Signed-off-by: Otavio Salvador <otavio at ossystems.com.br>
    (cherry picked from commit 2d8ef535c5d0ac783fca0220c9e677e44250711b)

diff --git a/include/parted/fdasd.h b/include/parted/fdasd.h
index f6b1e33..283191e 100644
--- a/include/parted/fdasd.h
+++ b/include/parted/fdasd.h
@@ -143,7 +143,6 @@ struct fdasd_hd_geometry {
 #define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
 
 #define FDASD_VERSION "1.05"
-#define FDASD_ERROR "fdasd error: "
 #define DEVICE "device"
 #define DISC   "disc"
 #define PART   "part"
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 198bce2..e4ecf52 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -100,58 +100,59 @@ fdasd_error (fdasd_anchor_t *anc, enum fdasd_failure why, char * str)
 
 	switch (why) {
 		case unable_to_open_disk:
-			sprintf(error, _("%s open error\n%s\n"), 
-			FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n", _("open error"), str);
 			break;
 		case unable_to_seek_disk:
-			sprintf(error, _("%s seek error\n%s\n"), FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n", _("seek error"), str);
 			break;
 		case unable_to_read_disk:
-			sprintf(error, _("%s read error\n%s\n"), FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n", _("read error"), str);
 			break;
 		case read_only_disk:
-			sprintf(error, _("%s write error\n%s\n"), FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n", _("write error"), str);
 			break;
 		case unable_to_ioctl:
-			sprintf(error, _("%s IOCTL error\n%s\n"), FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n", _("ioctl() error"), str);
 			break;
 		case api_version_mismatch:
-			sprintf(error, _("%s API version mismatch\n%s\n"), FDASD_ERROR,str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("API version mismatch"), str);
 			break;     
 		case wrong_disk_type:
-			sprintf(error, _("%s Unsupported disk type\n%s\n"),
-			        FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Unsupported disk type"), str);
 			break; 
 		case wrong_disk_format:
-			sprintf(error, _("%s Unsupported disk format\n%s\n"),
-			        FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Unsupported disk format"), str);
 			break;   
 		case disk_in_use:
-			sprintf(error, _("%s Disk in use\n%s\n"), FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Disk is in use"), str);
 			break;      
 		case config_syntax_error:
-			sprintf(error, _("%s Config file syntax error\n%s\n"),
-			        FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Syntax error in config file"), str);
 			break;       
 		case vlabel_corrupted:
-			sprintf(error, _("%s Volume label is corrupted.\n%s\n"), 
-			        FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Volume label is corrupted"), str);
 			break;
 		case dsname_corrupted:
-			sprintf(error, _("%s a data set name is corrupted.\n%s\n"), 
-			        FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("A data set name is corrupted"), str);
 			break;
 		case malloc_failed:
-			sprintf(error, _("%s space allocation\n%s\n"),
-			        FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Memory allocation failed"), str);
 			break;
 		case device_verification_failed:
-			sprintf(error, _("%s device verification failed\n" \
-			        "The specified device is not a valid DASD device\n"),
-			        FDASD_ERROR);
+			sprintf(error, "fdasd: %s -- %s\n",
+				_("Device verification failed"),
+				_("The specified device is not a valid DASD device"));,
 			break;
 		default: 
-			sprintf(error, _("%s Fatal error\n%s\n"), FDASD_ERROR, str);
+			sprintf(error, "fdasd: %s: %s\n", _("Fatal error"), str);
 	}
 
 	ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, message);
@@ -210,18 +211,15 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc)
 
 	anc->f4 = malloc(sizeof(format4_label_t));
 	if (anc->f4 == NULL) 
-		fdasd_error(anc, malloc_failed, 
-			    "FMT4 DSCB memory allocation failed.");
+		fdasd_error(anc, malloc_failed, "FMT4 DSCB.");
 
 	anc->f5 = malloc(sizeof(format5_label_t));
 	if (anc->f5 == NULL) 
-		fdasd_error(anc, malloc_failed,
-			    "FMT5 DSCB memory allocation failed.");
+		fdasd_error(anc, malloc_failed, "FMT5 DSCB.");
 
 	anc->f7 = malloc(sizeof(format7_label_t));
 	if (anc->f7 == NULL) 
-		fdasd_error(anc, malloc_failed,
-			    "FMT7 DSCB memory allocation failed.");
+		fdasd_error(anc, malloc_failed, "FMT7 DSCB.");
 
 	bzero(anc->f4, sizeof(format4_label_t));
 	bzero(anc->f5, sizeof(format5_label_t));
@@ -230,7 +228,7 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc)
 	v = malloc(sizeof(volume_label_t));
 	if (v == NULL) 
 		fdasd_error(anc, malloc_failed,
-			    "Volume label memory allocation failed.");
+			    _("No room for volume label."));
 	bzero(v, sizeof(volume_label_t));
 	anc->vlabel = v;
 
@@ -238,7 +236,7 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc)
         p = malloc(sizeof(partition_info_t));
 		if (p == NULL) 
 			fdasd_error(anc, malloc_failed,
-				   "Partition info memory allocation failed.");
+				    _("No room for partition info."));
 		p->used       = 0x00;
 		p->len_trk    = 0;
 		p->start_trk  = 0;
@@ -261,8 +259,7 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc)
 
 		p->f1 = malloc(sizeof(format1_label_t));
 		if (p->f1 == NULL) 
-			fdasd_error(anc, malloc_failed,
-			    "FMT1 DSCB memory allocation failed.");
+			fdasd_error(anc, malloc_failed, "FMT1 DSCB.");
 		bzero(p->f1, sizeof(format1_label_t));
 		
 		q = p;
@@ -709,7 +706,7 @@ fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
 	if (anc->f4->DS4IDFMT != 0xf4) {
 		if (strncmp(anc->vlabel->volkey,vtoc_ebcdic_enc("LNX1",str,4),4) == 0)
 			return 0;
-		fdasd_error(anc, wrong_disk_format, "Invalid VTOC");
+		fdasd_error(anc, wrong_disk_format, _("Invalid VTOC."));
 	} else {
 		fdasd_process_valid_vtoc (anc, b, fd);
 	}
@@ -763,12 +760,13 @@ fdasd_check_api_version (fdasd_anchor_t *anc, int f)
 	char s[LINE_LENGTH];
  
 	if (ioctl(f, DASDAPIVER, &api) != 0)
-		fdasd_error(anc, unable_to_ioctl, "Could not retrieve API version.");
+		fdasd_error(anc, unable_to_ioctl,
+			    _("Could not retrieve API version."));
  
 	if (api != DASD_MIN_API_VERSION) {
-		sprintf(s, "The current API version '%d' doesn't " \
+		sprintf(s, _("The current API version '%d' doesn't " \
 				"match dasd driver API version " \
-				"'%d'!", api, DASD_MIN_API_VERSION);
+				"'%d'!"), api, DASD_MIN_API_VERSION);
 		fdasd_error(anc, api_version_mismatch, s);
 	}
 }                                      
@@ -786,22 +784,21 @@ fdasd_get_geometry (fdasd_anchor_t *anc, int f)
 
 	if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0) 
 		fdasd_error(anc, unable_to_ioctl,
-					"Could not retrieve disk geometry information.");
+			    _("Could not retrieve disk geometry information."));
 
 	if (ioctl(f, BLKSSZGET, &blksize) != 0)
 		fdasd_error(anc, unable_to_ioctl,
-					"Could not retrieve blocksize information.");
+			    _("Could not retrieve blocksize information."));
 
 	/* get disk type */
 	if (ioctl(f, BIODASDINFO, &dasd_info) != 0) 
 		fdasd_error(anc, unable_to_ioctl, 
-					"Could not retrieve disk information.");
+			    _("Could not retrieve disk information."));
 
-	if (strncmp(dasd_info.type, "ECKD", 4) != 0) {
-		sprintf(s, "This is not an ECKD disk! This disk type " \
-				"is not supported!");
-		fdasd_error(anc,wrong_disk_type, s);
-	}
+	if (strncmp(dasd_info.type, "ECKD", 4) != 0)
+		fdasd_error(anc, wrong_disk_type,
+			    _("This is not an ECKD disk!  " \
+			      "This disk type is not supported!"));
 
 	anc->dev_type   = dasd_info.dev_type;
 	anc->blksize    = blksize;

commit 3d6585b885a4b1c3c825222037a5f8851e538dc3
Author: Benno Schulenberg <bensberg at justemail.net>
Date:   Tue May 29 19:55:52 2007 +0200

    vtoc label: Move formatting out of translatable strings.
    
    Also gettextize a few missed messages, and remove some whitespace.
    
    Signed-off-by: Otavio Salvador <otavio at ossystems.com.br>
    (cherry picked from commit 0b91e19b6dd46cab0a9b907dd8e70a4e5d2c6a71)

diff --git a/include/parted/vtoc.h b/include/parted/vtoc.h
index 3e79478..2e09caa 100644
--- a/include/parted/vtoc.h
+++ b/include/parted/vtoc.h
@@ -43,7 +43,6 @@
 #define VOLSER_LENGTH 6
 #define BIG_DISK_SIZE 0x10000
 
-#define VTOC_ERROR "VTOC error:"
 
 typedef struct ttr              ttr_t;
 typedef struct cchhb            cchhb_t;
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index bd2c905..e81bf08 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -160,23 +160,23 @@ vtoc_error (enum failure why, char *s1, char *s2)
 
 	switch (why) {
 		case unable_to_open:
-			sprintf(error, _("%s opening device '%s' failed.\n%s\n"),
-					VTOC_ERROR, s1, s2);
+			sprintf(error, "VTOC: %s -- %s\n%s\n",
+				_("opening of device failed"), s1, s2);
 			break;
 		case unable_to_seek:
-			sprintf(error, _("%s seeking device '%s' failed.\n%s\n"),
-					VTOC_ERROR, s1, s2);
+			sprintf(error, "VTOC: %s -- %s\n%s\n",
+				_("seeking on device failed"), s1, s2);
 			break;
 		case unable_to_write:
-			sprintf(error, _("%s writing to device '%s' failed,\n%s\n"),
-					VTOC_ERROR, s1, s2);
+			sprintf(error, "VTOC: %s -- %s\n%s\n",
+				_("writing to device failed"), s1, s2);
 			break;
 		case unable_to_read:
-			sprintf(error, _("%s reading from device '%s' failed.\n%s\n"),
-					VTOC_ERROR, s1, s2);
+			sprintf(error, "VTOC: %s -- %s\n%s\n",
+				_("reading from device failed"), s1, s2);
 			break;
 		default:
-			sprintf(error, _("Fatal error\n"));
+			sprintf(error, "VTOC: %s\n", _("Fatal error"));
 	}
 
 	ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, error);
@@ -278,14 +278,14 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start,
 
 	if (lseek(f, vlabel_start, SEEK_SET) == -1) {
 		vtoc_error(unable_to_seek, "vtoc_read_volume_label",
-				   "Could not read volume label.");
+			   _("Could not read volume label."));
 		return 1;
 	}
 
 	rc = read(f, vlabel, sizeof(volume_label_t));
 	if (rc != sizeof(volume_label_t)) {
 		vtoc_error(unable_to_read, "vtoc_read_volume_label",
-				   "Could not read volume label.");
+			   _("Could not read volume label."));
 		return 1;
 	}
 
@@ -304,12 +304,12 @@ vtoc_write_volume_label (int f, unsigned long vlabel_start,
 
 	if (lseek(f, vlabel_start, SEEK_SET) == -1)
 		vtoc_error(unable_to_seek, "vtoc_write_volume_label",
-				   "Could not write volume label.");
+			   _("Could not write volume label."));
 
 	rc = write(f, vlabel, sizeof(volume_label_t)); 
 	if (rc != sizeof(volume_label_t)) 
 		vtoc_error(unable_to_write, "vtoc_write_volume_label",
-				   "Could not write volume label.");
+			   _("Could not write volume label."));
 
 	return 0;
 }
@@ -415,34 +415,34 @@ vtoc_read_label (int f, unsigned long position, format1_label_t *f1,
 
 	if (lseek(f, position, SEEK_SET) == -1) 
 		vtoc_error(unable_to_seek, "vtoc_read_label",
-				   _("Could not read VTOC labels."));
+			   _("Could not read VTOC labels."));
 
 	if (f1 != NULL) {
 		t = sizeof(format1_label_t);
 		if (read(f, f1, t) != t) 
 			vtoc_error(unable_to_read, "vtoc_read_label",
-					   _("Could not read VTOC FMT1 DSCB."));
+				   _("Could not read VTOC FMT1 DSCB."));
 	}
 
 	if (f4 != NULL) {
 		t = sizeof(format4_label_t);
 		if (read(f, f4, t) != t) 
 			vtoc_error(unable_to_read, "vtoc_read_label",
-					   _("Could not read VTOC FMT4 DSCB."));
+				   _("Could not read VTOC FMT4 DSCB."));
 	}
 
 	if (f5 != NULL) {
 		t = sizeof(format5_label_t);
 		if (read(f, f5, t) != t)
 			vtoc_error(unable_to_read, "vtoc_read_label",
-					   _("Could not read VTOC FMT5 DSCB."));
+				   _("Could not read VTOC FMT5 DSCB."));
 	}
 
 	if (f7 != NULL) {
 		t = sizeof(format7_label_t);
 		if (read(f, f7, t) != t) 
 			vtoc_error(unable_to_read, "vtoc_read_label",
-					   _("Could not read VTOC FMT7 DSCB."));
+				   _("Could not read VTOC FMT7 DSCB."));
 	}
 }
 
@@ -459,34 +459,34 @@ vtoc_write_label (int f, unsigned long position, format1_label_t *f1,
 
 	if (lseek(f, position, SEEK_SET) == -1) 
 		vtoc_error(unable_to_seek, "vtoc_write_label",
-				   _("Could not write VTOC labels."));
+			   _("Could not write VTOC labels."));
 
 	if (f1 != NULL) {
 		t = sizeof(format1_label_t);
 		if (write(f, f1, t) != t) 
 			vtoc_error(unable_to_write, "vtoc_write_label",
-					   _("Could not write VTOC FMT1 DSCB."));
+				   _("Could not write VTOC FMT1 DSCB."));
 	}
 
 	if (f4 != NULL) {
 		t = sizeof(format4_label_t);
 		if (write(f, f4, t) != t) 
 			vtoc_error(unable_to_write, "vtoc_write_label",
-					   _("Could not write VTOC FMT4 DSCB."));
+				   _("Could not write VTOC FMT4 DSCB."));
 	}
 
 	if (f5 != NULL) {
 		t = sizeof(format5_label_t);
 		if (write(f, f5, t) != t) 
 			vtoc_error(unable_to_write, "vtoc_write_label",
-					   _("Could not write VTOC FMT5 DSCB."));
+				   _("Could not write VTOC FMT5 DSCB."));
 	}
 
 	if (f7 != NULL) {
 		t = sizeof(format7_label_t);
 		if (write(f, f7, t) != t) 
 			vtoc_error(unable_to_write, "vtoc_write_label",
-					   _("Could not write VTOC FMT7 DSCB."));
+				   _("Could not write VTOC FMT7 DSCB."));
 	}
 }
 

commit f056f65d36de80d50322245890bc3d1b1f2605a8
Author: Jim Meyering <jim at meyering.net>
Date:   Tue May 29 20:29:47 2007 +0200

    Move a test/utility function into test-lib.sh.
    
    * tests/t3000-constraints.sh (emit_superuser_warning): Move this
    function to...
    * tests/test-lib.sh (emit_superuser_warning): ...here.
    * tests/t0000-basic.sh: Use the function instead of open-coding it.
    
    Signed-off-by: Jim Meyering <jim at meyering.net>
    (cherry picked from commit f1fbf278ba03388242b7adf5dcba90918bac78c9)

diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index 5f651b3..1a11121 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -57,10 +57,9 @@ test_expect_success \
     'run parted mklabel (without -s) on a blank disk' \
     'parted $dev mklabel msdos > out 2>&1'
 
-warning_msg='WARNING: You are not superuser.  Watch out for permissions.'
 test_expect_success \
     'create expected output file' \
-    'test "$uid" = 0 && : > exp || echo "$warning_msg" > exp'
+    'emit_superuser_warning > exp'
 
 test_expect_success \
     'check its "interactive" output' \
@@ -82,7 +81,7 @@ test_expect_success \
 
 # Create expected output file.
 fail=0
-{ test "$uid" = 0 && : > exp || echo "$warning_msg" > exp; } || fail=1
+{ emit_superuser_warning > exp; } || fail=1
 cat <<EOF >> exp || fail=1
 Warning: The existing disk label on DEVICE will be destroyed and all\
  data on this disk will be lost. Do you want to continue?
diff --git a/tests/t3000-constraints.sh b/tests/t3000-constraints.sh
index 07fe1b3..179a33c 100755
--- a/tests/t3000-constraints.sh
+++ b/tests/t3000-constraints.sh
@@ -21,14 +21,6 @@ test_description="exercise Parted's constraint-management code"
 
 . ./init.sh
 
-# FIXME: move this to test-lib.sh, and use it in t0000*.sh
-emit_superuser_warning()
-{
-  uid=`id -u` || uid=1
-  test "$uid" != 0 &&
-    echo 'WARNING: You are not superuser.  Watch out for permissions.'
-}
-
 dev=loop-file
 N=2
 t=ext2
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 050b967..29a2be1 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -201,6 +201,13 @@ if test "$privileges_required_" != ''; then
     fi
 fi
 
+emit_superuser_warning()
+{
+  uid=`id -u` || uid=1
+  test "$uid" != 0 &&
+    echo 'WARNING: You are not superuser.  Watch out for permissions.'
+}
+
 # Test the binaries we have just built.
 pwd_=`pwd`
 parted_="$pwd_/../parted/parted"

commit f8fb7f9836910d8ad625503d982bbc157818298f
Author: Jim Meyering <jim at meyering.net>
Date:   Tue May 29 21:30:40 2007 +0200

    Avoid a leak.
    
    * parted/parted.c (do_print): Use separate variables for the header
    and for individual rows.  Free each when done.
    * parted/table.c (table_add_row_from_strlist): Insert a newly
    allocated copy of each string, so that the caller can free
    the argument corresponding to the "list" parameter.
    * tests/t0100-print.sh: New test for this.
    * tests/Makefile.am (TESTS): Add t0100-print.sh.
    (cherry picked from commit a7e4e516d537e914e76094dd76b94caf900f3b2a)

diff --git a/parted/parted.c b/parted/parted.c
index 202558a..92e820d 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1258,7 +1258,6 @@ do_print (PedDevice** dev)
         PedUnit         default_unit;
         PedDisk*        disk;
         Table*          table;
-        StrList*        row;
         int             has_extended;
         int             has_name;
         int             has_devices_arg = 0;
@@ -1404,30 +1403,30 @@ do_print (PedDevice** dev)
         
         PedPartition* part;
         if (!opt_machine_mode) {
+            StrList *row1;
 
             if (ped_unit_get_default() == PED_UNIT_CHS) {
-                    row = str_list_create (_("Number"), _("Start"),
+                    row1 = str_list_create (_("Number"), _("Start"),
                                                _("End"), NULL);
             } else {
-                    row = str_list_create (_("Number"), _("Start"),
+                    row1 = str_list_create (_("Number"), _("Start"),
                                                _("End"), _("Size"), NULL);
             }
 
             if (has_extended)
-                    str_list_append (row, _("Type"));
+                    str_list_append (row1, _("Type"));
 
-            str_list_append (row, _("File system"));
+            str_list_append (row1, _("File system"));
 
             if (has_name)
-                    str_list_append (row, _("Name"));
+                    str_list_append (row1, _("Name"));
 
-            str_list_append (row, _("Flags"));
+            str_list_append (row1, _("Flags"));
 
 
-            table = table_new (str_list_length(row));
-
-            table_add_row_from_strlist (table, row);
+            table = table_new (str_list_length(row1));
 
+            table_add_row_from_strlist (table, row1);
 
             for (part = ped_disk_next_partition (disk, NULL); part;
                  part = ped_disk_next_partition (disk, part)) {
@@ -1443,7 +1442,7 @@ do_print (PedDevice** dev)
                     else
                             sprintf (tmp, "%2s ", "");
 
-                    row = str_list_create (tmp, NULL);
+                    StrList *row = str_list_create (tmp, NULL);
 
                     start = ped_unit_format (*dev, part->geom.start);
                     end = ped_unit_format_byte (
@@ -1485,6 +1484,7 @@ do_print (PedDevice** dev)
 
                     //PED_ASSERT (row.cols == caption.cols)
                     table_add_row_from_strlist (table, row);
+                    str_list_destroy (row);
             }
 
             table_rendered = table_render (table); 
@@ -1495,6 +1495,7 @@ do_print (PedDevice** dev)
 #endif
             ped_free (table_rendered);
             table_destroy (table);
+            str_list_destroy (row1);
 
         } else {
     
diff --git a/parted/table.c b/parted/table.c
index 23976a9..befb045 100644
--- a/parted/table.c
+++ b/parted/table.c
@@ -164,7 +164,10 @@ void table_add_row_from_strlist (Table* t, StrList* list)
 
         while (list)
         {
-                row[i] = (wchar_t*)list->str;
+                row[i] = wcsdup (list->str);
+                if (row[i] == NULL)
+                        xalloc_die ();
+
 
                 list = list->next;
                 ++i;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 27689c9..ecce727 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,6 @@
 TESTS = \
   t0000-basic.sh \
+  t0100-print.sh \
   t1000-mkpartfs.sh \
   t1100-busy-label.sh \
   t1500-small-ext2.sh \
diff --git a/tests/t0100-print.sh b/tests/t0100-print.sh
new file mode 100755
index 0000000..74c478e
--- /dev/null
+++ b/tests/t0100-print.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+test_description="the most basic 'print' test"
+
+. ./init.sh
+
+dev=loop-file
+
+msdos_magic='\x55\xaa'
+
+test_expect_success \
+    "setup: create the most basic partition table, manually" \
+    '{ dd if=/dev/zero bs=510 count=1; printf "$msdos_magic"; } > $dev'
+
+test_expect_success \
+    'print the empty table' \
+    'parted -s $dev print >out 2>&1'
+
+pwd=`pwd`
+
+fail=0
+{
+  cat <<EOF
+Model:  (file)
+Disk .../$dev: 512B
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+
+Number  Start  End  Size  Type  File system  Flags
+
+EOF
+} > exp || fail=1
+
+test_expect_success \
+    'prepare actual and expected output' \
+    'test $fail = 0 &&
+     mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'
+
+test_expect_success 'check for expected output' '$compare out exp'
+
+test_done



More information about the Parted-commits mailing list