Browse Source

Fixed bug of visible color code that does not have text to color.

master
5 years ago
parent
commit
fdc0b3f67a
  1. 23
      includes/colors.c

23
includes/colors.c

@ -2,9 +2,8 @@ @@ -2,9 +2,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include "colors.h"
#define ASCII_ZERO 48
#define ASCII_NINE 57
#define MIN_CONTRAST 0.5
void hsl2rgb(struct Rgb *dest, const struct Hls const *src) {
@ -134,24 +133,30 @@ static void hexspan(const char *str) { @@ -134,24 +133,30 @@ static void hexspan(const char *str) {
}
static void b(char * const str) {
#define IS_DIGIT(x) (x >= ASCII_ZERO && x <= ASCII_NINE)
char *token = strtok(str, "^");
char c;
printf("<TD>");
while (token) {
c = token[0];
if (IS_DIGIT(c)) {
if (isdigit(c)) {
decspan(c - ASCII_ZERO);
printf("%s", token + 1);
} else if (c == 'x' && strlen(token) > 4) {
hexspan(token + 1); //exclude x
printf("%s", token + 4);
if (strlen(token) > 1) {
printf("%s", token + 1);
}
} else if (c == 'x' && strlen(token) > 3) {
if (isxdigit(token[1]) && isxdigit(token[2]) && isxdigit(token[3])) {
hexspan(token + 1); //exclude x
if (strlen(token) > 4){
printf("%s", token + 4);
}
printf("</span>");
}
} else {
printf("%s", token);
}
token = strtok(NULL, "^");
}
printf("</span></TD>");
printf("</TD>");
}
void print_plname(const char* str) {

Loading…
Cancel
Save