commit 256bf5225a6d2b502cee6773996de24951ebfa9c
parent ab320e67862f49a4ab4497046e4a903fe4e646fb
Author: nibo <nibo@relim.de>
Date: Sat, 3 Aug 2024 12:57:07 +0200
Add version 0.1.0 and some refactoring
Diffstat:
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,7 +1,14 @@
+VERSION = 0.1.0
+
+CFLAGS = -pedantic -Wall -Wextra -DVERSION=\"${VERSION}\"
+LDFLAGS = -lpdfio -ltoml -lfontconfig
+
+SRC = util.c fontconfig.c config.c chordpro.c out_pdf.c lorid.c
+
all:
- $(CC) -pedantic -Wall -Wextra -O2 util.c fontconfig.c config.c chordpro.c out_pdf.c lorid.c -o lorid -lpdfio -ltoml -lfontconfig
+ $(CC) ${CFLAGS} -O2 ${SRC} -o lorid ${LDFLAGS}
debug:
- $(CC) -g -pedantic -Wall -Wextra util.c fontconfig.c config.c chordpro.c out_pdf.c lorid.c -o lorid -lpdfio -ltoml -lfontconfig
+ $(CC) ${CFLAGS} -g ${SRC} -o lorid ${LDFLAGS}
fontconfig:
$(CC) -g chordpro.c fontconfig.c -o fontconfig -lfontconfig
.PHONY: all debug fontconfig
diff --git a/chordpro.c b/chordpro.c
@@ -951,7 +951,7 @@ struct Style *cho_style_get(const char *tag_name, struct Attr **attrs, struct St
fprintf(stderr, "INFO: Invalid percentage in attribute 'size'.\n");
}
} else if (isdigit(attrs[a]->value[0]) != 0) {
- float size = strtof(attrs[a]->value, NULL);
+ double size = strtod(attrs[a]->value, NULL);
if (size != 0.0)
style->font->size = size;
else
@@ -1067,7 +1067,7 @@ struct Style *cho_style_get(const char *tag_name, struct Attr **attrs, struct St
}
}
} else if (isdigit(attrs[a]->value[1]) != 0) {
- float rise = strtof(attrs[a]->value, NULL);
+ double rise = strtod(attrs[a]->value, NULL);
if (rise != 0.0)
style->rise = rise;
else
@@ -1082,14 +1082,14 @@ struct Style *cho_style_get(const char *tag_name, struct Attr **attrs, struct St
int percentage = atoi(attrs[a]->value);
if (percentage != 0 && percentage <= 100) {
// TODO: Test if that's right
- float more = style->font->size / 2.0 * percentage / 100.0;
+ double more = style->font->size / 2.0 * percentage / 100.0;
style->rise += more;
} else {
fprintf(stderr, "INFO: Invalid percentage in attribute 'rise'.\n");
}
}
} else if (isdigit(attrs[a]->value[1]) != 0) {
- float rise = strtof(attrs[a]->value, NULL);
+ double rise = strtod(attrs[a]->value, NULL);
if (rise != 0.0)
style->rise = rise;
else
diff --git a/lorid.c b/lorid.c
@@ -15,13 +15,15 @@ int main(int argc, char *argv[])
{ "print-default-config", no_argument, 0, 'p' },
{ "config", required_argument, 0, 'c' },
{ "output", required_argument, 0, 'o' },
+ { "version", no_argument, 0, 'v' },
+ { "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 }
};
int o, option_index;
char *config_filepath = NULL;
char *output = NULL;
FILE *fp;
- while ((o = getopt_long(argc, argv, "pc:o:", long_options, &option_index)) != -1) {
+ while ((o = getopt_long(argc, argv, "pc:o:vh", long_options, &option_index)) != -1) {
switch(o) {
case 'p':
config_print_default();
@@ -34,6 +36,12 @@ int main(int argc, char *argv[])
output = realloc(output, (strlen(optarg)+1) * sizeof(char));
strcpy(output, optarg);
break;
+ case 'v':
+ printf(VERSION"\n");
+ return 0;
+ case 'h':
+ printf("Help.\n");
+ return 0;
}
}
struct Config *config = config_load(config_filepath);