summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick 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)
commitf0351693ac1558505cf15c61c3ea4a1f12c3d67b (patch)
treeb0e82273776e0ec9db8a904e4a9f2b1c7d529b00
parent0b9687372282752f586af875f688d634648a5fda (diff)
text_*(), font_*(), sgr(): Convert to unsigned char
-rw-r--r--src/font.c2
-rw-r--r--src/font.h2
-rw-r--r--src/sgr.c10
-rw-r--r--src/sgr.h2
-rw-r--r--src/text.c37
5 files changed, 27 insertions, 26 deletions
diff --git a/src/font.c b/src/font.c
index 92988a3..c351857 100644
--- a/src/font.c
+++ b/src/font.c
@@ -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;
diff --git a/src/font.h b/src/font.h
index ee3942e..f82f2a0 100644
--- a/src/font.h
+++ b/src/font.h
@@ -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_ */
diff --git a/src/sgr.c b/src/sgr.c
index 9e77f18..9faa117 100644
--- a/src/sgr.c
+++ b/src/sgr.c
@@ -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;
}
diff --git a/src/sgr.h b/src/sgr.h
index 3b2362e..6f5346a 100644
--- a/src/sgr.h
+++ b/src/sgr.h
@@ -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_ */
diff --git a/src/text.c b/src/text.c
index dda6de1..fedbd3f 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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;