ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 12c5fa1076a116d044dbe26d119ed0bf33e99613
parent 62d71af7422ef2551904b708931fc42772e4a7a6
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 14 Feb 2020 18:28:53 +0100

Stop hardcoding types array size, define and use an enumeration constant.

Diffstat:
Msrc/ansilove.c | 4++--
Msrc/config.h | 4++++
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ansilove.c b/src/ansilove.c @@ -235,7 +235,7 @@ main(int argc, char *argv[]) /* if type was specified, attempt to find a loader */ if (type) { - for (size_t loop = 0; loop < 7; loop++) { + for (size_t loop = 0; loop < TYPES; loop++) { if (!strcmp(types[loop], type)) { loader = loaders[loop]; filetype = filetypes[loop]; @@ -246,7 +246,7 @@ main(int argc, char *argv[]) /* fall back on file extension if no loader was found */ if (!loader) { - for (size_t loop = 0; loop < 7; loop++) { + for (size_t loop = 0; loop < TYPES; loop++) { if (!strcmp(types[loop], fext)) { loader = loaders[loop]; filetype = filetypes[loop]; diff --git a/src/config.h b/src/config.h @@ -18,4 +18,8 @@ /* configuration defines */ #define VERSION "4.0.7" +enum { + TYPES = 7 +}; + #endif /* CONFIG_H */