changeset 2149:9209858b2f74

Fix a couple of bugs in the TOC file parser
author Michael Pavone <pavone@retrodev.com>
date Sat, 26 Mar 2022 23:05:08 -0700
parents 2da377ea932f
children a418fa599b2e
files cdimage.c
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/cdimage.c	Sat Mar 26 20:14:41 2022 -0700
+++ b/cdimage.c	Sat Mar 26 23:05:08 2022 -0700
@@ -55,12 +55,15 @@
 static uint32_t timecode_to_lba(char *timecode)
 {
 	char *end;
-	int seconds = 0, frames = 0;
-	int minutes = strtol(timecode, &end, 10);
-	if (end) {
+	int seconds = 0, minutes = 0;
+	int frames = strtol(timecode, &end, 10);
+	if (end && *end == ':') {
 		timecode = end + 1;
-		seconds = strtol(timecode, &end, 10);
-		if (end) {
+		seconds = frames;
+		frames = strtol(timecode, &end, 10);
+		if (end && *end == ':') {
+			minutes = seconds;
+			seconds = frames;
 			timecode = end + 1;
 			frames = strtol(timecode, NULL, 10);
 		}
@@ -471,7 +474,7 @@
 									if (isdigit(*cmd)) {
 										uint32_t start = timecode_to_lba(cmd);
 										tracks[track].file_offset += start * tracks[track].sector_bytes;
-										cmd = next_blank(cmd);
+										cmd = cmd_start_sameline(cmd);
 									}
 								}
 								if (isdigit(*cmd)) {