From 8e6617bceebef92d84af289a0b1793e877308a73 Mon Sep 17 00:00:00 2001 From: tudnai Date: Fri, 31 Jul 2020 14:19:31 -0700 Subject: [PATCH] More reliable way to determine if disk image has a .po file extension --- src/dev/disk/dsk2woz.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/dev/disk/dsk2woz.c b/src/dev/disk/dsk2woz.c index c507f6a..ab81cde 100755 --- a/src/dev/disk/dsk2woz.c +++ b/src/dev/disk/dsk2woz.c @@ -65,16 +65,10 @@ int dsk2woz( const char * filename ) { fclose(dsk_file); // Determine from the filename whether to use Pro-DOS sector order. - bool has_p = false; - bool has_dot = false; - const char *extension = filename + strlen(filename); - do { - has_p = *extension == 'p'; - has_dot = *extension == '.'; - --extension; - } while(extension > filename && *extension != '/' && *extension != '.'); - const bool is_prodos = has_p && has_dot; - + const char *extension = filename + strlen(filename) - 3; + // for some reason macos does not have stricmp, so we do it in a not-so-efficient way + const bool is_prodos = (strcmp(extension, ".po") == 0) || (strcmp(extension, ".PO") == 0); + // If the DSK image was too short, announce failure. Some DSK files // seem empirically to be too long, but it's unclear that the extra // bytes actually mean anything — they're usually not many.