diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-07-18 02:37:53 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-07-18 02:37:53 (EDT) |
commit | f0351693ac1558505cf15c61c3ea4a1f12c3d67b (patch) | |
tree | b0e82273776e0ec9db8a904e4a9f2b1c7d529b00 | |
parent | 0b9687372282752f586af875f688d634648a5fda (diff) |
text_*(), font_*(), sgr(): Convert to unsigned char
-rw-r--r-- | src/font.c | 2 | ||||
-rw-r--r-- | src/font.h | 2 | ||||
-rw-r--r-- | src/sgr.c | 10 | ||||
-rw-r--r-- | src/sgr.h | 2 | ||||
-rw-r--r-- | src/text.c | 37 |
5 files changed, 27 insertions, 26 deletions
@@ -78,7 +78,7 @@ font_get_height(struct font *font) void font_render(struct font *font, png_const_colorp fg, png_const_colorp bg, - char ch, png_bytepp rows, int row, int col) + unsigned char ch, png_bytepp rows, int row, int col) { size_t y; size_t r; @@ -37,6 +37,6 @@ font_get_height(struct font *font) __attribute__((pure)); void font_render(struct font *font, png_const_colorp fg, png_const_colorp bg, - char ch, png_bytepp rows, int row, int col); + unsigned char ch, png_bytepp rows, int row, int col); #endif /* FONT_H_ */ @@ -48,11 +48,11 @@ static png_color _4bit[] = { /* TODO: Add 8-bit and 24-bit modes. */ void -sgr(char *param, png_colorp fg, png_colorp bg) +sgr(unsigned char *param, png_colorp fg, png_colorp bg) { - int end; - char *p; - int i; + int end; + unsigned char *p; + int i; end = 0; for (p = param; param; ++param) { @@ -62,7 +62,7 @@ sgr(char *param, png_colorp fg, png_colorp bg) } *param = '\0'; if (*p) { - i = atoi(p); + i = atoi((char *) p); } else { i = 0; } @@ -25,6 +25,6 @@ #include <png.h> void -sgr(char *param, png_colorp fg, png_colorp bg); +sgr(unsigned char *param, png_colorp fg, png_colorp bg); #endif /* SGR_H_ */ @@ -33,15 +33,15 @@ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) struct text { - size_t size; - size_t read; - char *string; - size_t width; - size_t height; + size_t size; + size_t read; + unsigned char *string; + size_t width; + size_t height; }; -static char -_getc(struct text *text, FILE *stream, char *c) +static unsigned char +_getc(struct text *text, FILE *stream, unsigned char *c) { int i_c; @@ -60,10 +60,10 @@ _getc(struct text *text, FILE *stream, char *c) struct text * text_new(FILE *stream) { - struct text *text; - size_t width; - int eol; - char c; + struct text *text; + size_t width; + int eol; + unsigned char c; if (!stream) { return NULL; @@ -131,19 +131,20 @@ text_set_height(struct text *text, size_t height) void text_render(struct text *text, struct font *font, png_bytepp rows) { - char *string_start; - char *string; - size_t row; - size_t col; - char *parameter; + unsigned char *string_start; + unsigned char *string; + size_t row; + size_t col; + unsigned char *parameter; png_color fg = {170, 170, 170}; png_color bg = { 0, 0, 0}; - string_start = calloc(strlen(text->string) + 1, sizeof(*text->string)); + string_start = calloc(strlen((char *) text->string) + 1, + sizeof(*text->string)); if (!string_start) { return; } - memcpy(string_start, text->string, strlen(text->string) + 1); + memcpy(string_start, text->string, strlen((char *) text->string) + 1); string = string_start; row = 0; |