diff simtool/writecmd.c @ 83:3055d5c9e7a3

fc-simtool update-rec* commands: check curfile_record_len and error out if it is not set
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 11 Apr 2021 02:38:31 +0000
parents ddd767f6e15b
children
line wrap: on
line diff
--- a/simtool/writecmd.c	Sat Apr 10 23:21:47 2021 +0000
+++ b/simtool/writecmd.c	Sun Apr 11 02:38:31 2021 +0000
@@ -50,6 +50,10 @@
 	u_char data[255];
 	int rc;
 
+	if (!curfile_record_len) {
+		fprintf(stderr, "error: no record-based file selected\n");
+		return(-1);
+	}
 	if (!strcmp(argv[1], "prev")) {
 		recno = 0;
 		mode = 0x03;
@@ -79,6 +83,10 @@
 	u_char data[255];
 	int rc;
 
+	if (!curfile_record_len) {
+		fprintf(stderr, "error: no record-based file selected\n");
+		return(-1);
+	}
 	if (!strcmp(argv[1], "prev")) {
 		recno = 0;
 		mode = 0x03;
@@ -107,6 +115,10 @@
 	unsigned recno, mode, fill_byte;
 	u_char data[255];
 
+	if (!curfile_record_len) {
+		fprintf(stderr, "error: no record-based file selected\n");
+		return(-1);
+	}
 	if (!strcmp(argv[1], "prev")) {
 		recno = 0;
 		mode = 0x03;