dvd-sector-copy.c: Include file-relative information in bad-blocks file.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 19 Feb 2022 02:01:26 +0000 (02:01 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 19 Feb 2022 02:01:26 +0000 (02:01 +0000)
Also, tolerate these comments when reading them back in.

dvd-sector-copy.c

index 2c461e1..36b5425 100644 (file)
@@ -504,7 +504,15 @@ static void recovered(secaddr bad_lo, secaddr bad_hi)
        bad_hi - bad_lo, bad_lo, bad_hi);
   if (mapfile) {
     open_file_on_demand(mapfile, &mapfp, "bad-sector region map");
-    fprintf(mapfp, "%"PRIuSEC" %"PRIuSEC"\n", bad_lo, bad_hi);
+    fprintf(mapfp, "%"PRIuSEC" %"PRIuSEC"", bad_lo, bad_hi);
+    if (file)
+      fprintf(mapfp, " # %s #%d %"PRIuSEC"..%"PRIuSEC" of %"PRIuSEC" (%.1f%%)",
+             id_part(file->id) ? "title" : "menu",
+             id_title(file->id),
+             bad_lo - file->start, bad_hi - file->start,
+             file->end - file->start,
+             (bad_lo - file->start)*100.0/(file->end - file->start));
+    fputc('\n', mapfp);
     check_write(mapfp, "bad-sector region map");
   }
   if (lseek(outfd, (off_t)(bad_hi - bad_lo)*SECTORSZ, SEEK_CUR) < 0)
@@ -908,7 +916,7 @@ static int parse_range(const char *p, unsigned f,
     { rc = -1; goto end; }
 
   if (!(f&PRF_HYPHEN)) while (ISSPACE(*p)) p++;
-  if (*p) { rc = -1; goto end; }
+  if (*p && ((f&PRF_HYPHEN) || *p != '=')) { rc = -1; goto end; }
 
   rc = 0;
 end: