lorid

convert chordpro to pdf
git clone git://git.relim.de/lorid.git
Log | Files | Refs | README | LICENSE

commit 533f89e679394a8d5287ce043ff74c9cfe0cfec7
parent f93d5da85c69214eac0c7b9b7a8ecf5771654af7
Author: nibo <nibo@relim.de>
Date:   Fri,  2 Aug 2024 17:00:06 +0200

Complete cho_rgbcolor_parse()

Diffstat:
Mchordpro.c | 46+++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -380,9 +380,49 @@ struct RGBColor *cho_rgbcolor_parse(const char *str) } } } else if (len == 4) { - tmp[1] = 0; - tmp[0] = str[1]; - primary_color = strtol((char *)&tmp, NULL, 16); + tmp[2] = 0; + if (str[1] == '0') { + color->red = 0; + } else { + tmp[0] = str[1]; + tmp[1] = str[1]; + primary_color = strtol((char *)&tmp, NULL, 16); + if (primary_color == 0) { + fprintf(stderr, "ERROR: Invalid primary color in rgb color.\n"); + free(color); + return NULL; + } else { + color->red = primary_color; + } + } + if (str[2] == '0') { + color->green = 0; + } else { + tmp[0] = str[2]; + tmp[1] = str[2]; + primary_color = strtol((char *)&tmp, NULL, 16); + if (primary_color == 0) { + fprintf(stderr, "ERROR: Invalid primary color in rgb color.\n"); + free(color); + return NULL; + } else { + color->green = primary_color; + } + } + if (str[3] == '0') { + color->blue = 0; + } else { + tmp[0] = str[3]; + tmp[1] = str[3]; + primary_color = strtol((char *)&tmp, NULL, 16); + if (primary_color == 0) { + fprintf(stderr, "ERROR: Invalid primary color in rgb color.\n"); + free(color); + return NULL; + } else { + color->blue = primary_color; + } + } } else { fprintf(stderr, "ERROR: Invalid rgb color.\n"); free(color);