From 2c26d3a225c433140fc8a09a1c4423b69df06a9c Mon Sep 17 00:00:00 2001 From: <> Date: Sat, 18 Mar 2017 16:07:09 -0700 Subject: [PATCH] Colors player name- a bit inaccurately and with a few issues. --- includes/colors.c | 17 ++--------------- includes/dbquery.c | 3 ++- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/includes/colors.c b/includes/colors.c index 68acc4b..580e95a 100644 --- a/includes/colors.c +++ b/includes/colors.c @@ -6,19 +6,6 @@ #define ASCII_ZERO 48 #define ASCII_NINE 57 #define MIN_CONTRAST 0.5 - //html = _dec_colors.sub(lambda match: _dec_spans[int(match.group(1))], qstr) - // this is an extremely fancy if not confusing way to say - // the single number that isn't an x, right after a ^ - // is an index to an array of strings. - //html = _hex_colors.sub(hex_repl, html) - // the next 3 letters after after ^x is digits for rgb - // the verdict is: - // regex is not needed - // do the hex replacement first, then do the dec replacement - - // instead of concatenating strings, they will be printed in parts. - -// can either be RGB or HLS void hsl2rgb(struct Rgb *dest, const struct Hls const *src) { if ((src -> h < 0 || 360 < src -> h) || @@ -150,6 +137,7 @@ static void b(char * const str) { #define IS_DIGIT(x) (x >= ASCII_ZERO && x <= ASCII_NINE) char *token = strtok(str, "^"); char c; + printf(""); while (token) { c = token[0]; if (IS_DIGIT(c)) { @@ -163,10 +151,9 @@ static void b(char * const str) { } token = strtok(NULL, "^"); } - printf(""); + printf(""); } -// O(n) void print_plname(const char* str) { //find instance of ^^ //replace with ^ diff --git a/includes/dbquery.c b/includes/dbquery.c index 5518d36..bbdf345 100644 --- a/includes/dbquery.c +++ b/includes/dbquery.c @@ -3,6 +3,7 @@ #include #include #include +#include "colors.h" static inline char *get_filename(const char *c) { char *qout = "queries/mranks.sql"; @@ -85,7 +86,7 @@ static void qresult(sqlite3_stmt * const sp, const char *c) { printf(""); for (i = 0; i < cc; i++) { if ((*c == 'm' && i == 1) || (*c == '\0' && i == 3) || (*c == 'p' && i == 0)) { - printf("%s", sqlite3_column_text(sp, i)); + print_plname(sqlite3_column_text(sp, i)); } else if ((i == 0 && *c == '\0') || (i == 1 && *c == 'p') ) { printf("%s", sqlite3_column_text(sp, i), sqlite3_column_text(sp, i)); } else if (i == 2 && (*c == 'm' || *c == '\0')) {