Index: ChangeLog =================================================================== RCS file: /var/cvs/parted/ChangeLog,v retrieving revision 1.1.1.3 retrieving revision 1.5 diff -u -r1.1.1.3 -r1.5 --- ChangeLog 13 Mar 2002 06:48:06 -0000 1.1.1.3 +++ ChangeLog 13 Mar 2002 12:47:41 -0000 1.5 @@ -8,6 +8,11 @@ 1.5.x ----------------------------------------------------------------------------- +2002-03-13 Timshel Knoll +* parted/ui.c (command_line_get_sector): allow the user to specify partition + start/end relative to the end of the device, this is done by specifying a + negative value as the start/end of the partition. + 2002-03-11 Andrew Clausen * libparted/linux.c (_flush_cache): only flush partition devices if they aren't mounted. Index: parted/ui.c =================================================================== RCS file: /var/cvs/parted/parted/ui.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- parted/ui.c 13 Mar 2002 06:45:34 -0000 1.1.1.2 +++ parted/ui.c 13 Mar 2002 07:00:37 -0000 1.2 @@ -506,14 +506,25 @@ char def_str [16]; char* input; long double input_double; - int valid; + int valid, i, negate = 0; snprintf (def_str, 16, "%.4f", (float) def / MEGABYTE_SECTORS); input = command_line_get_word (prompt, def ? def_str : NULL, NULL, 1); if (!input) return 0; - valid = sscanf (input, "%Lf", &input_double); + for (i = 0; input[i] != '\0' && isspace (input[i]); i++) + ; + if (input[i] == '-') + negate = 1; + + valid = sscanf (input + i, "%Lf", &input_double); *result = (PedSector) (input_double * MEGABYTE_SECTORS); + + /* Unfortunately, we can't simply use "if (*result < 0)" here, since + * result may have been entered as "-0". It would save some kludge + * if there was another way to do this ... */ + if (negate) + *result += dev->length; /* don't be too pedantic about "outside disk" errors */ if (*result > dev->length - 1 && *result < dev->length * 1.01)