Skip to content

Commit a336254

Browse files
committed
gpujpeg_image_get_file_format: refactor
couple "help" code to a single branch
1 parent c2c06df commit a336254

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/gpujpeg_common.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,24 @@ gpujpeg_image_get_file_format(const char* filename)
410410
{ "XXX", GPUJPEG_IMAGE_FILE_RAW},
411411
};
412412

413+
if ( strcmp(filename, "help") == 0 ) {
414+
PRINTF("Recognized extensions:\n");
415+
for ( unsigned i = 0; i < sizeof extensions / sizeof extensions[0]; i++ ) {
416+
PRINTF("\t- %s\n", extensions[i].ext);
417+
}
418+
PRINTF("\nUse \"help.tst\" (eg. `gpujpegtool help.tst null.jpg`) for test image usage).\n");
419+
return GPUJPEG_IMAGE_FILE_UNKNOWN;
420+
}
421+
413422
const char * ext = strrchr(filename, '.');
414423
if ( ext == NULL )
415424
return GPUJPEG_IMAGE_FILE_UNKNOWN;
416425
ext++;
417-
if ( strcmp(ext, "help") == 0 ) {
418-
PRINTF("Recognized extensions:\n");
419-
}
420426
for ( unsigned i = 0; i < sizeof extensions / sizeof extensions[0]; i++ ) {
421-
if ( strcmp(ext, "help") == 0 ) {
422-
PRINTF("\t- %s\n", extensions[i].ext);
423-
}
424427
if ( strcasecmp(ext, extensions[i].ext) == 0 ) {
425428
return extensions[i].format;
426429
}
427430
}
428-
if ( strcmp(ext, "help") == 0 ) {
429-
PRINTF("\nUse \"help.tst\" (eg. `gpujpegtool help.tst null.jpg`) for test image usage).\n");
430-
}
431431
return GPUJPEG_IMAGE_FILE_UNKNOWN;
432432
}
433433

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ main(int argc, char *argv[])
480480
}
481481

482482
if ( argv[0] != NULL && strcmp(argv[0], "exts") == 0 ) {
483-
gpujpeg_image_get_file_format(".help");
483+
gpujpeg_image_get_file_format("help");
484484
return 0;
485485
}
486486

0 commit comments

Comments
 (0)