changeset 57:10030acba82f

fc-simtool *-erase-range commands: allow "end" keyword for the last record to be erased
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 20:28:44 +0000
parents d4b5a6e547ca
children 1861d9fb7751
files simtool/pberase.c simtool/smserase.c simtool/smsp_erase.c
diffstat 3 files changed, 39 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/pberase.c	Sat Feb 13 19:45:04 2021 +0000
+++ b/simtool/pberase.c	Sat Feb 13 20:28:44 2021 +0000
@@ -64,15 +64,20 @@
 			"error: specified starting record number is invalid\n");
 		return(-1);
 	}
-	endrec = strtoul(argv[3], 0, 0);
-	if (endrec < 1 || endrec > curfile_record_count) {
-		fprintf(stderr,
+	if (!strcmp(argv[3], "end"))
+		endrec = curfile_record_count;
+	else {
+		endrec = strtoul(argv[3], 0, 0);
+		if (endrec < 1 || endrec > curfile_record_count) {
+			fprintf(stderr,
 			"error: specified final record number is invalid\n");
-		return(-1);
-	}
-	if (startrec > endrec) {
-		fprintf(stderr, "error: reverse record range specified\n");
-		return(-1);
+			return(-1);
+		}
+		if (startrec > endrec) {
+			fprintf(stderr,
+				"error: reverse record range specified\n");
+			return(-1);
+		}
 	}
 	memset(record, 0xFF, curfile_record_len);
 	for (recno = startrec; recno <= endrec; recno++) {
--- a/simtool/smserase.c	Sat Feb 13 19:45:04 2021 +0000
+++ b/simtool/smserase.c	Sat Feb 13 20:28:44 2021 +0000
@@ -95,15 +95,20 @@
 			"error: specified starting record number is invalid\n");
 		return(-1);
 	}
-	endrec = strtoul(argv[2], 0, 0);
-	if (endrec < 1 || endrec > curfile_record_count) {
-		fprintf(stderr,
+	if (!strcmp(argv[2], "end"))
+		endrec = curfile_record_count;
+	else {
+		endrec = strtoul(argv[2], 0, 0);
+		if (endrec < 1 || endrec > curfile_record_count) {
+			fprintf(stderr,
 			"error: specified final record number is invalid\n");
-		return(-1);
-	}
-	if (startrec > endrec) {
-		fprintf(stderr, "error: reverse record range specified\n");
-		return(-1);
+			return(-1);
+		}
+		if (startrec > endrec) {
+			fprintf(stderr,
+				"error: reverse record range specified\n");
+			return(-1);
+		}
 	}
 	memset(record, 0xFF, SMS_RECORD_LEN);
 	record[0] = 0;
--- a/simtool/smsp_erase.c	Sat Feb 13 19:45:04 2021 +0000
+++ b/simtool/smsp_erase.c	Sat Feb 13 20:28:44 2021 +0000
@@ -63,15 +63,20 @@
 			"error: specified starting record number is invalid\n");
 		return(-1);
 	}
-	endrec = strtoul(argv[2], 0, 0);
-	if (endrec < 1 || endrec > curfile_record_count) {
-		fprintf(stderr,
+	if (!strcmp(argv[2], "end"))
+		endrec = curfile_record_count;
+	else {
+		endrec = strtoul(argv[2], 0, 0);
+		if (endrec < 1 || endrec > curfile_record_count) {
+			fprintf(stderr,
 			"error: specified final record number is invalid\n");
-		return(-1);
-	}
-	if (startrec > endrec) {
-		fprintf(stderr, "error: reverse record range specified\n");
-		return(-1);
+			return(-1);
+		}
+		if (startrec > endrec) {
+			fprintf(stderr,
+				"error: reverse record range specified\n");
+			return(-1);
+		}
 	}
 	memset(record, 0xFF, curfile_record_len);
 	for (recno = startrec; recno <= endrec; recno++) {