changeset 1570:04769fa39dd4

Instead of specifying forced input format (-f) as a number in 64vw, use format extension like it is done in gfxconv.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 May 2018 08:22:56 +0300
parents 7e6af32c8032
children ad771e94af25
files tools/64vw.c
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/tools/64vw.c	Sun May 13 07:56:47 2018 +0300
+++ b/tools/64vw.c	Sun May 13 08:22:56 2018 +0300
@@ -53,8 +53,8 @@
     {
         const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
         char buf[64];
-        printf("%3d | %-5s | %-15s | %s\n",
-            i, fmt->fext,
+        printf(" %-5s | %-15s | %s\n",
+            fmt->fext,
             dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE),
             fmt->name);
     }
@@ -100,22 +100,22 @@
             break;
 
         case 4:
+            optForcedFormat = -1;
+            for (int i = 0; i < ndmC64ImageFormats; i++)
             {
-                int i;
-                if (sscanf(optArg, "%d", &i) == 1)
+                const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
+                if (fmt->fext != NULL &&
+                    strcasecmp(optArg, fmt->fext) == 0)
                 {
-                    if (i < 0 || i >= ndmC64ImageFormats)
-                    {
-                        dmErrorMsg("Invalid image format index %d, see help for valid values.\n", i);
-                        return FALSE;
-                    }
                     optForcedFormat = i;
+                    break;
                 }
-                else
-                {
-                    dmErrorMsg("Invalid image format argument '%s'.\n", optArg);
-                    return FALSE;
-                }
+            }
+
+            if (optForcedFormat < 0)
+            {
+                dmErrorMsg("Invalid image format argument '%s'.\n", optArg);
+                return FALSE;
             }
             break;