[moving this to bug-parted]

Andrew Clausen wrote:

> Well, you have to type "libtoolize".  I guess we could put a shell
> script in CVS that runs aclocal, libtoolize, autoconf and automake
> as necessary.
If you want to go on that track, we might as well remove
'configure' and 'Makefile.in' (recursively) from CVS.
We might also just stick to 'libtoolize' -- the 'libtool' script seems
to be the only one that is system-dependent.


> In the comment, you might want to mention "In particular, this affects
> how locations inside error messages (exceptions) are displayed."
Okay.

> There's still something wrong with the indentation here..
Fixed. Sorry I did not do this earlier, but there was also a (more obvious)
problem with the second line and I think I asked you which one you meant
- guess either you forgot to answer that question or I forgot to send it.

>>      PedSector cyl_size = dev->bios_geom.heads * dev->bios_geom.sectors;
> This (cyl_size) should be moved inside "if is_chs"?
Fixed.

> if (!ped_geometry_test_sector_inside (*range, *sector))
Why is this necessary?


> [local variables and line length problems]
Fixed.
I tried to put the local variable stuff into a separate function,
but this way we'd end up passing all ped_unit_parse_custom arguments
to it.


> This arithmetic looks complicated.  I think a helper function to do
> rounding is in order.
Done.


Proposal: change the signature of

ped_unit_format_custom (PedSector sector, PedDevice* dev, PedUnit unit)

to

ped_unit_format_custom (PedDevice* dev, PedSector sector, PedUnit unit)


I hope with this version of the patch we can move to the testing stage
and release soon. I feel quite pressed ATM.
Of course I do not wish anyone to accept this if something's still
not right!


Regards,

Leslie
Index: include/parted/unit.h
===================================================================
RCS file: /cvsroot/parted/stable/include/parted/unit.h,v
retrieving revision 1.2
diff -a -p -u -r1.2 unit.h
--- include/parted/unit.h	20 Mar 2005 07:32:45 -0000	1.2
+++ include/parted/unit.h	27 Jun 2005 23:44:56 -0000
@@ -31,6 +31,7 @@
 #define PED_GIGABYTE_SIZE 1000000000LL
 #define PED_TERABYTE_SIZE 1000000000000LL
 
+
 typedef enum {
 	PED_UNIT_SECTOR,
 	PED_UNIT_BYTE,
@@ -57,8 +58,13 @@ extern char* ped_unit_format (PedSector 
 extern char* ped_unit_format_custom (PedSector sector, PedDevice* dev,
 				     PedUnit unit);
 
-extern int ped_unit_parse (const char* str, PedDevice* dev, PedSector *sector);
+extern int ped_unit_parse (const char* str, PedDevice* dev, PedSector *sector,
+			   PedGeometry** range);
 extern int ped_unit_parse_custom (const char* str, PedDevice* dev,
-				  PedUnit unit, PedSector *sector);
+				  PedUnit unit, PedSector* sector,
+				  PedGeometry** range);
+
+extern long long ped_unit_get_size (PedDevice* dev, PedUnit unit);
+
 
 #endif /* PED_UNIT_H_INCLUDED */
Index: libparted/unit.c
===================================================================
RCS file: /cvsroot/parted/stable/libparted/unit.c,v
retrieving revision 1.5
diff -a -p -u -r1.5 unit.c
--- libparted/unit.c	27 Mar 2005 09:53:21 -0000	1.5
+++ libparted/unit.c	27 Jun 2005 23:44:59 -0000
@@ -32,6 +32,7 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
+
 static PedUnit default_unit = PED_UNIT_COMPACT;
 static const char* unit_names[] = {
 	"s",
@@ -46,24 +47,43 @@ static const char* unit_names[] = {
 	"%"
 };
 
+
+/**
+ * Set the default unit used by subsequent calls to the PedUnit API.
+ * In particular, this affects how locations inside error messages
+ * (exceptions) are displayed.
+ */
 void
 ped_unit_set_default (PedUnit unit)
 {
 	default_unit = unit;
 }
 
+
+/**
+ * Get the current default unit.
+ */
 PedUnit
 ped_unit_get_default ()
 {
 	return default_unit;
 }
 
+
+/**
+ * Returns a textual (non-internationalized) representation of a unit.
+ */
 const char*
 ped_unit_get_name (PedUnit unit)
 {
 	return unit_names[unit];
 }
 
+
+/*
+ * Returns a unit based on its textual representation.
+ * For example, ped_unit_get_by_name("Mb") returns PED_UNIT_MEGABYTE.
+ */
 PedUnit
 ped_unit_get_by_name (const char* unit_name)
 {
@@ -75,6 +95,12 @@ ped_unit_get_by_name (const char* unit_n
 	return -1;
 }
 
+/**
+ * Returns a string that describes the location "sector" on device "dev".
+ * The string is described with the default unit, which is set
+ * by ped_unit_set_default().
+ * The returned string must be freed with ped_free().
+ */
 char*
 ped_unit_format (PedSector sector, PedDevice* dev)
 {
@@ -93,6 +119,11 @@ ped_strdup (const char *str)
 	return result;
 }
 
+/**
+ * Returns a string that describes the location "sector" on device "dev".
+ * The string is described with the desired unit.
+ * The returned string must be freed with ped_free().
+ */
 char*
 ped_unit_format_custom (PedSector sector, PedDevice* dev, PedUnit unit)
 {
@@ -169,12 +200,22 @@ ped_unit_format_custom (PedSector sector
 	return ped_strdup (buf);
 }
 
+
+/**
+ * If str contains a valid description of a location on dev, then *sector
+ * is modified to describe the location.  If no units are specified, then
+ * the default unit is assumed.  This function returns 1 if str is
+ * a valid location description, 0 otherwise.
+ */
 int
-ped_unit_parse (const char* str, PedDevice* dev, PedSector *sector)
+ped_unit_parse (const char* str, PedDevice* dev, PedSector *sector,
+		PedGeometry** range)
 {
-	return ped_unit_parse_custom (str, dev, default_unit, sector);
+    return ped_unit_parse_custom (str, dev, default_unit, sector,
+				  range);
 }
 
+
 /* Inefficiently removes all spaces from a string, in-place. */
 static void
 strip_string (char* str)
@@ -190,6 +231,7 @@ strip_string (char* str)
 	}
 }
 
+
 /* Find non-number suffix.  Eg: find_suffix("32Mb") returns a pointer to
  * "Mb". */
 static char*
@@ -222,13 +264,43 @@ remove_punct (char* str)
 	}
 }
 
+
+static PedSector
+clip (PedDevice* dev, PedSector sector)
+{
+	if (sector < 0)
+		return 0;
+
+	if (sector > dev->length - 1)
+		return dev->length - 1;
+
+	return sector;
+}
+
+
+static PedGeometry*
+geometry_from_centre_radius (PedDevice* dev, PedSector sector, PedSector radius)
+{
+	PedSector start = clip (dev, sector - radius);
+	PedSector end = clip (dev, sector + radius);
+
+	return ped_geometry_new (dev, start, end - start + 1);
+}
+
+
+/**
+ * If str contains a valid description of a location on dev, then *sector
+ * is modified to describe the location.  If no units are specified, then
+ * the desired unit is assumed.  This function returns 1 if str is
+ * a valid location description, 0 otherwise.
+ */
 int
 ped_unit_parse_custom (const char* str, PedDevice* dev, PedUnit unit,
-		       PedSector *sector)
+		       PedSector *sector, PedGeometry** range)
 {
-	char *copy;
-	char *suffix;
-	PedSector cyl_size = dev->bios_geom.heads * dev->bios_geom.sectors;
+	char*     copy;
+	char*     suffix;
+	double    num;
 
 	copy = ped_strdup (str);
 	if (!copy)
@@ -238,11 +310,14 @@ ped_unit_parse_custom (const char* str, 
 
 	/* deal with CHS separately */
 	if (is_chs (copy)) {
-		PedCHSGeometry	chs;
+               PedSector cyl_size = dev->bios_geom.heads * dev->bios_geom.sectors;
+	        PedCHSGeometry chs;
+
 		remove_punct (copy);
 		if (sscanf (copy, "%d %d %d",
 			    &chs.cylinders, &chs.heads, &chs.sectors) != 3)
 			return 0;
+
 		if (chs.heads >= dev->bios_geom.heads) {
 			ped_exception_throw (
 				PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
@@ -257,9 +332,13 @@ ped_unit_parse_custom (const char* str, 
 				dev->bios_geom.sectors - 1);
 			return 0;
 		}
+
 		*sector = 1LL * chs.cylinders * cyl_size
 			  + chs.heads * dev->bios_geom.sectors
 			  + chs.sectors;
+
+		*range = geometry_from_centre_radius(dev, *sector, 1);
+
 		return 1;
 	}
 
@@ -287,114 +366,30 @@ ped_unit_parse_custom (const char* str, 
 			unit = default_unit;
 	}
 
-	if (strchr (str, '.') || strchr (str, ',')) {
-		double num;
-		if (sscanf (copy, "%lf", &num) != 1) {
-			ped_exception_throw (
-				PED_EXCEPTION_ERROR,
-				PED_EXCEPTION_CANCEL,
-				_("Invalid number."));
-			return 0;
-		}
+	
+	if (sscanf (copy, "%lf", &num) != 1) {
+		ped_exception_throw (
+			PED_EXCEPTION_ERROR,
+			PED_EXCEPTION_CANCEL,
+			_("Invalid number."));
+		return 0;
+	}
 
-		switch (unit) {
-			case PED_UNIT_SECTOR:
-				*sector = num;
-				break;
-
-			case PED_UNIT_BYTE:
-				*sector = ped_div_round_up (num,
-						PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_KILOBYTE:
-				*sector = ped_div_round_up (
-						num * PED_KILOBYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_MEGABYTE:
-				*sector = ped_div_round_up (
-						num * PED_MEGABYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_GIGABYTE:
-				*sector = ped_div_round_up (
-						num * PED_GIGABYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_TERABYTE:
-				*sector = ped_div_round_up (
-						num * PED_TERABYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_CYLINDER:
-				*sector = num * cyl_size;
-				break;
-
-			case PED_UNIT_PERCENT:
-				*sector = num / 100.0 * (dev->length - 1) + 0.5;
-				break;
-		}
-	} else {
-		signed long long num;
-		if (sscanf (copy, "%lld", &num) != 1) {
-			ped_exception_throw (
-				PED_EXCEPTION_ERROR,
-				PED_EXCEPTION_CANCEL,
-				_("Invalid number."));
-			return 0;
-		}
 
-		/* This code is the same as above, but the C compiler will
-		 * interpret it differently, due to the different type of
-		 * "num".
-		 */
-		switch (unit) {
-			case PED_UNIT_SECTOR:
-				*sector = num;
-				break;
-
-			case PED_UNIT_BYTE:
-				*sector = ped_div_round_up (num,
-						PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_KILOBYTE:
-				*sector = ped_div_round_up (
-						num * PED_KILOBYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_MEGABYTE:
-				*sector = ped_div_round_up (
-						num * PED_MEGABYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_GIGABYTE:
-				*sector = ped_div_round_up (
-						num * PED_GIGABYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_TERABYTE:
-				*sector = ped_div_round_up (
-						num * PED_TERABYTE_SIZE,
-					  	PED_SECTOR_SIZE);
-				break;
-
-			case PED_UNIT_CYLINDER:
-				*sector = num * cyl_size;
-				break;
-
-			case PED_UNIT_PERCENT:
-				*sector = num / 100.0 * (dev->length - 1) + 0.5;
-				break;
-		}
+	{
+	    long long unit_size = ped_unit_get_size (dev, unit);
+	    PedSector unit_sectors = ped_div_round_up (unit_size, PED_SECTOR_SIZE);
+
+	    *sector = ped_div_round_up (num * unit_size, PED_SECTOR_SIZE);
+	    *range = geometry_from_centre_radius (dev, *sector, unit_sectors);
+
+	    if (!ped_geometry_test_sector_inside (*range, *sector))
+	    {
+		ped_exception_throw (
+			PED_EXCEPTION_ERROR,
+			PED_EXCEPTION_CANCEL,
+			_("Sector outside of device"));
+	    }
 	}
 
 	/* negative numbers count from the end */
@@ -404,3 +399,61 @@ ped_unit_parse_custom (const char* str, 
 	return 1;
 }
 
+
+static long long
+get_sectors_per_cent (PedDevice* dev)
+{
+    return (long long)( 1 / (100.0 * (dev->length - 1) + 0.5) );
+}
+
+
+/**
+ * Returns the byte size of a given unit.
+ */
+long long
+ped_unit_get_size (PedDevice* dev, PedUnit unit)
+{
+    switch (unit)
+    {
+	case PED_UNIT_SECTOR:
+	    return PED_SECTOR_SIZE;
+
+	case PED_UNIT_BYTE:
+	    return 1;
+
+	case PED_UNIT_KILOBYTE:
+	    return PED_KILOBYTE_SIZE;
+
+	case PED_UNIT_MEGABYTE:
+	    return PED_MEGABYTE_SIZE;
+
+	case PED_UNIT_GIGABYTE:
+	    return PED_GIGABYTE_SIZE;
+
+	case PED_UNIT_TERABYTE:
+	    return PED_TERABYTE_SIZE;
+
+	case PED_UNIT_CYLINDER:
+	    {
+		PedSector cyl_size = dev->bios_geom.heads * dev->bios_geom.sectors;
+		return ( cyl_size * PED_SECTOR_SIZE );
+	    }
+
+	case PED_UNIT_PERCENT:
+	    return ( get_sectors_per_cent (dev) * PED_SECTOR_SIZE );
+
+	case PED_UNIT_CHS:
+	    return PED_SECTOR_SIZE;
+
+	case PED_UNIT_COMPACT:
+	    ped_exception_throw (
+			PED_EXCEPTION_ERROR,
+			PED_EXCEPTION_CANCEL,
+			_("Cannot get unit size for special unit 'COMPACT'.") );
+	    return 0;
+    }
+
+    /* never reached */
+    PED_ASSERT(0, return 0);
+    return 0;
+}
Index: parted/parted.c
===================================================================
RCS file: /cvsroot/parted/stable/parted/parted.c,v
retrieving revision 1.13
diff -a -p -u -r1.13 parted.c
--- parted/parted.c	20 Apr 2005 13:38:44 -0000	1.13
+++ parted/parted.c	27 Jun 2005 23:45:02 -0000
@@ -289,20 +289,11 @@ _grow_over_small_freespace (PedGeometry*
  * start.
  */
 static PedConstraint*
-constraint_from_start_end (PedDevice* dev, PedSector start, int is_start_exact,
-			   PedSector end, int is_end_exact)
+constraint_from_start_end (PedDevice* dev, PedGeometry* range_start,
+                           PedGeometry* range_end)
 {
-	PedGeometry start_geom, end_geom;
-	if (is_start_exact)
-		ped_geometry_init (&start_geom, dev, start, 1);
-	else
-		ped_geometry_init (&start_geom, dev, 0, dev->length);
-	if (is_end_exact)
-		ped_geometry_init (&end_geom, dev, end, 1);
-	else
-		ped_geometry_init (&end_geom, dev, 0, dev->length);
 	return ped_constraint_new (ped_alignment_any, ped_alignment_any,
-		&start_geom, &end_geom, 1, dev->length);
+		range_start, range_end, 1, dev->length);
 }
 
 static PedConstraint*
@@ -546,14 +537,14 @@ error:
 static int
 do_mkpart (PedDevice** dev)
 {
-	PedDisk*		disk;
-	PedPartition*		part;
-	PedPartitionType	part_type;
+	PedDisk*	  	 disk;
+	PedPartition* 		 part;
+	PedPartitionType	 part_type;
 	const PedFileSystemType* fs_type = ped_file_system_type_get ("ext2");
-	PedSector		start = 0, end = 0;
-	int			is_start_exact, is_end_exact;
-	PedConstraint*		constraint;
-	char*			peek_word;
+	PedSector		 start = 0, end = 0;
+	PedGeometry 		 *range_start, *range_end;
+	PedConstraint*		 constraint;
+	char*			 peek_word;
 
 	disk = ped_disk_new (*dev);
 	if (!disk)
@@ -575,17 +566,16 @@ do_mkpart (PedDevice** dev)
 	if (peek_word)
 		ped_free (peek_word);
 
-	if (!command_line_get_sector (_("Start?"), *dev, &start, &is_start_exact))
+	if (!command_line_get_sector (_("Start?"), *dev, &start, &range_start))
 		goto error_destroy_disk;
-	if (!command_line_get_sector (_("End?"), *dev, &end, &is_end_exact))
+	if (!command_line_get_sector (_("End?"), *dev, &end, &range_end))
 		goto error_destroy_disk;
 	part = ped_partition_new (disk, part_type, fs_type, start, end);
 	if (!part)
 		goto error_destroy_disk;
 	if (!_grow_over_small_freespace (&part->geom, disk))
 		goto error_destroy_part;
-	constraint = constraint_from_start_end (*dev, start, is_start_exact,
-			end, is_end_exact);
+	constraint = constraint_from_start_end (*dev, range_start, range_end);
 	if (!constraint)
 		goto error_destroy_part;
 	if (!ped_disk_add_partition (disk, part, constraint))
@@ -618,14 +608,14 @@ error:
 static int
 do_mkpartfs (PedDevice** dev)
 {
-	PedDisk*		disk;
-	PedPartition*		part;
-	PedPartitionType	part_type;
+	PedDisk*            disk;
+	PedPartition*       part;
+	PedPartitionType    part_type;
 	const PedFileSystemType* fs_type = ped_file_system_type_get ("ext2");
-	PedSector		start = 0, end = 0;
-	int			is_start_exact, is_end_exact;
-	PedConstraint*		constraint;
-	PedFileSystem*		fs;
+	PedSector           start = 0, end = 0;
+	PedGeometry         *range_start, *range_end;
+	PedConstraint*      constraint;
+	PedFileSystem*      fs;
 
 	disk = ped_disk_new (*dev);
 	if (!disk)
@@ -645,9 +635,9 @@ do_mkpartfs (PedDevice** dev)
 	if (!command_line_get_fs_type (_("File system type?"), &fs_type))
 		goto error_destroy_disk;
 	if (!command_line_get_sector (_("Start?"), *dev, &start,
-				      &is_start_exact))
+				      &range_start))
 		goto error_destroy_disk;
-	if (!command_line_get_sector (_("End?"), *dev, &end, &is_end_exact))
+	if (!command_line_get_sector (_("End?"), *dev, &end, &range_end))
 		goto error_destroy_disk;
 	part = ped_partition_new (disk, part_type, fs_type, start, end);
 	if (!part)
@@ -656,8 +646,7 @@ do_mkpartfs (PedDevice** dev)
 		goto error_destroy_part;
 	constraint = constraint_intersect_and_destroy (
 			ped_file_system_get_create_constraint (fs_type, *dev),
-			constraint_from_start_end (*dev, start, is_start_exact,
-						   end, is_end_exact));
+			constraint_from_start_end (*dev, range_start, range_end));
 	if (!ped_disk_add_partition (disk, part, constraint))
 		goto error_destroy_constraint;
 	ped_constraint_destroy (constraint);
@@ -694,14 +683,14 @@ error:
 static int
 do_move (PedDevice** dev)
 {
-	PedDisk*		disk;
-	PedPartition*		part = NULL;
-	PedFileSystem*		fs;
-	PedFileSystem*		fs_copy;
-	PedConstraint*		constraint;
-	PedSector		start = 0, end = 0;
-	int			is_start_exact, is_end_exact;
-	PedGeometry		old_geom, new_geom;
+	PedDisk*	disk;
+	PedPartition*	part = NULL;
+	PedFileSystem*	fs;
+	PedFileSystem*	fs_copy;
+	PedConstraint*	constraint;
+	PedSector	start = 0, end = 0;
+	PedGeometry     *range_start, *range_end;
+	PedGeometry	old_geom, new_geom;
 
 	disk = ped_disk_new (*dev);
 	if (!disk)
@@ -722,11 +711,10 @@ do_move (PedDevice** dev)
 		goto error_destroy_disk;
 
 	/* get new target */
-	if (!command_line_get_sector (_("Start?"), *dev, &start,
-				      &is_start_exact))
+	if (!command_line_get_sector (_("Start?"), *dev, &start, &range_start))
 		goto error_close_fs;
 	end = start + old_geom.length - 1;
-	if (!command_line_get_sector (_("End?"), *dev, &end, &is_end_exact))
+	if (!command_line_get_sector (_("End?"), *dev, &end, &range_end))
 		goto error_close_fs;
 
 	/* set / test on "disk" */
@@ -737,8 +725,7 @@ do_move (PedDevice** dev)
 
 	constraint = constraint_intersect_and_destroy (
 			ped_file_system_get_copy_constraint (fs, *dev),
-			constraint_from_start_end (*dev, start, is_start_exact,
-						   end, is_end_exact));
+			constraint_from_start_end (*dev, range_start, range_end));
 	if (!ped_disk_set_partition_geom (disk, part, constraint,
 					  new_geom.start, new_geom.end))
 		goto error_destroy_constraint;
@@ -1197,7 +1184,7 @@ do_resize (PedDevice** dev)
 	PedFileSystem*		fs;
 	PedConstraint*		constraint;
 	PedSector		start, end;
-	int			is_start_exact, is_end_exact;
+	PedGeometry     *range_start, *range_end;
 	PedGeometry		new_geom;
 
 	disk = ped_disk_new (*dev);
@@ -1213,10 +1200,9 @@ do_resize (PedDevice** dev)
 
 	start = part->geom.start;
 	end = part->geom.end;
-	if (!command_line_get_sector (_("Start?"), *dev, &start,
-				      &is_start_exact))
+	if (!command_line_get_sector (_("Start?"), *dev, &start, &range_start))
 		goto error_destroy_disk;
-	if (!command_line_get_sector (_("End?"), *dev, &end, &is_end_exact))
+	if (!command_line_get_sector (_("End?"), *dev, &end, &range_end))
 		goto error_destroy_disk;
 
 	if (!ped_geometry_init (&new_geom, *dev, start, end - start + 1))
@@ -1226,7 +1212,7 @@ do_resize (PedDevice** dev)
 
 	if (part->type == PED_PARTITION_EXTENDED) {
 		constraint = constraint_from_start_end (*dev,
-				start, is_start_exact, end, is_end_exact);
+				range_start, range_end);
 		if (!ped_disk_set_partition_geom (disk, part, constraint,
 						  new_geom.start, new_geom.end))
 			goto error_destroy_constraint;
@@ -1243,8 +1229,7 @@ do_resize (PedDevice** dev)
 		constraint = constraint_intersect_and_destroy (
 				ped_file_system_get_resize_constraint (fs),
 				constraint_from_start_end (
-					*dev, start, is_start_exact,
-					end, is_end_exact));
+					*dev, range_start, range_end));
 		if (!ped_disk_set_partition_geom (disk, part, constraint,
 						  new_geom.start, new_geom.end))
 			goto error_close_fs;
Index: parted/ui.c
===================================================================
RCS file: /cvsroot/parted/stable/parted/ui.c,v
retrieving revision 1.6
diff -a -p -u -r1.6 ui.c
--- parted/ui.c	27 Mar 2005 09:53:21 -0000	1.6
+++ parted/ui.c	27 Jun 2005 23:45:03 -0000
@@ -526,11 +526,11 @@ command_line_get_integer (const char* pr
 
 int
 command_line_get_sector (const char* prompt, PedDevice* dev, PedSector* value,
-			 int* is_exact)
+			 PedGeometry** range)
 {
-	char*		def_str;
-	char*		input;
-	int		valid;
+	char*	def_str;
+	char*	input;
+	int	valid;
 
 	def_str = ped_unit_format (*value, dev);
 	input = command_line_get_word (prompt, *value ? def_str : NULL,
@@ -542,7 +542,6 @@ command_line_get_sector (const char* pro
 	 */
 	if (input && *value && !strcmp (input, def_str)) {
 		ped_free (def_str);
-		*is_exact = 0;
 		return 1;
 	}
 
@@ -550,19 +549,7 @@ command_line_get_sector (const char* pro
 	if (!input)
 		return 0;
 
-	if (input[0] == '=') {
-		if (is_exact != NULL)
-			*is_exact = 1;
-		valid = ped_unit_parse (input + 1, dev, value);
-	} else {
-		if (is_exact != NULL)
-			*is_exact = 0;
-		valid = ped_unit_parse (input, dev, value);
-
-		/* don't be too pedantic about "outside disk" errors */
-		if (*value > dev->length - 1 && *value < dev->length * 1.01)
-			*value = dev->length - 1;
-	}
+	valid = ped_unit_parse (input, dev, value, range);
 
 	free (input);
 	return valid;
Index: parted/ui.h
===================================================================
RCS file: /cvsroot/parted/stable/parted/ui.h,v
retrieving revision 1.3
diff -a -p -u -r1.3 ui.h
--- parted/ui.h	27 Mar 2005 09:53:21 -0000	1.3
+++ parted/ui.h	27 Jun 2005 23:45:03 -0000
@@ -46,7 +46,7 @@ extern char* command_line_get_word (cons
 				    int multi_word);
 extern int command_line_get_integer (const char* prompt, int* value);
 extern int command_line_get_sector (const char* prompt, PedDevice* dev,
-				    PedSector* value, int* is_exact);
+				    PedSector* value, PedGeometry** range);
 extern int command_line_get_state (const char* prompt, int* value);
 extern int command_line_get_device (const char* prompt, PedDevice** value);
 extern int command_line_get_disk (const char* prompt, PedDisk** value);

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Bug-parted mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to