Fix all the warnings

This commit is contained in:
Emil 2023-08-28 16:19:40 -06:00
parent 08c9f81f4d
commit 9a5bd3be42
No known key found for this signature in database
GPG Key ID: 5432DB986FDBCF8A
3 changed files with 39 additions and 34 deletions

View File

@ -21,9 +21,9 @@ typedef enum {
REGION REGION
} token_type_t; } token_type_t;
typedef void (*attribute_callback_t) (const char * const string, typedef void (*attribute_callback_t) (const char * string,
const int length, const int length,
void * const attributes); void * attributes);
typedef struct { typedef struct {
char * key; char * key;
@ -58,14 +58,19 @@ extern int append_token(token_t * token);
extern token_t * new_symbol_token(const char * const c, extern token_t * new_symbol_token(const char * const c,
hl_group_t * const g); hl_group_t * const g);
extern int new_symbol_tokens(const char * const * symbols, extern int new_symbol_tokens(const char * const * symbols,
hl_group_t * const g); hl_group_t * const g);
extern int new_char_tokens(const char * characters,
hl_group_t * const g); extern int new_char_tokens(const char * str,
hl_group_t * const g);
extern token_t * new_keyword_token(const char * const word, extern token_t * new_keyword_token(const char * const word,
hl_group_t * const g); hl_group_t * const g);
extern int new_keyword_tokens(const char * const * words, extern int new_keyword_tokens(const char * const * words,
hl_group_t * const g); hl_group_t * const g);
extern token_t * new_token(const char * const word, extern token_t * new_token(const char * const word,
const token_type_t t, const token_type_t t,
hl_group_t * const g); hl_group_t * const g);
@ -146,7 +151,7 @@ int new_symbol_tokens(const char * const * symbols,
return i; return i;
} }
int new_char_tokens(const char * characters, int new_char_tokens(const char * str,
hl_group_t * const g) { hl_group_t * const g) {
int i = 0; int i = 0;
@ -154,7 +159,7 @@ int new_char_tokens(const char * characters,
buffer[0] = '\\'; buffer[0] = '\\';
buffer[2] = '\0'; buffer[2] = '\0';
for(const char * s = characters; *s != '\0'; s++) { for(const char * s = str; *s != '\0'; s++) {
buffer[1] = *s; buffer[1] = *s;
if(new_symbol_token(is_magic(*s) ? buffer : buffer + 1, g)) { if(new_symbol_token(is_magic(*s) ? buffer : buffer + 1, g)) {
++i; ++i;
@ -202,9 +207,9 @@ int new_keyword_tokens(const char * const * words,
return i; return i;
} }
token_t * new_region_token(const char * const * start, token_t * new_region_token(const char * start,
const char * const * end, const char * end,
hl_group_t * const g) { hl_group_t * g) {
char buffer[100]; char buffer[100];
buffer[0] = '\0'; buffer[0] = '\0';
strcat(buffer, start); strcat(buffer, start);

View File

@ -26,9 +26,9 @@
#define TERMINAL_STYLE_REVERSE "\033[7m" #define TERMINAL_STYLE_REVERSE "\033[7m"
typedef struct { typedef struct {
char * attribute; const char * attribute;
char * foreground_color; const char * foreground_color;
char * background_color; const char * background_color;
} terminal_hl_t; } terminal_hl_t;
extern display_t * cterm; extern display_t * cterm;
@ -47,7 +47,7 @@ display_t * cterm = &(display_t) {
void cterm_render_callback(const char * const string, void cterm_render_callback(const char * const string,
const int length, const int length,
void * const attributes) { void * const attributes) {
if(!length){ if (!length) {
fputs(TERMINAL_STYLE_BOLD, stdout); fputs(TERMINAL_STYLE_BOLD, stdout);
putchar(*string); putchar(*string);
fputs(TERMINAL_RESET, stdout); fputs(TERMINAL_RESET, stdout);
@ -68,16 +68,16 @@ void cterm_render_callback(const char * const string,
} }
void fun(const char * const attribute, void fun(const char * attribute,
const char * const color, const char * color,
hl_group_t * * group){ hl_group_t * * group){
terminal_hl_t * t = (terminal_hl_t *)malloc(sizeof(terminal_hl_t)); terminal_hl_t * t = (terminal_hl_t *) malloc(sizeof(terminal_hl_t));
t->attribute = attribute; t->attribute = attribute;
t->foreground_color = color;; t->foreground_color = color;
t->background_color = NULL; t->background_color = NULL;
(*group) = (hl_group_t *)malloc(sizeof(hl_group_t)); (*group) = (hl_group_t *)malloc(sizeof(hl_group_t));
(*group)->link = NULL; (*group)->link = NULL;
(*group)->attributes = (void*)t; (*group)->attributes = (void*)t;
} }
int terminal_hl_init(void) { int terminal_hl_init(void) {

View File

@ -343,17 +343,17 @@ static int compile_range(const char * const range,
return ((s - range) + 1); return ((s - range) + 1);
} }
void filter_blacklist(const char * const whitelist, void filter_blacklist(const char * whitelist,
const char * const blacklist, const char * blacklist,
char * const filtered) { char * filtered) {
for (char * black_pointer = blacklist; *black_pointer != '\0'; black_pointer++) { for (; *blacklist != '\0'; blacklist++) {
for(char * white_pointer = blacklist; *white_pointer != '\0'; white_pointer++) { for(; *whitelist != '\0'; whitelist++) {
if (*black_pointer == *white_pointer) { if (*blacklist == *whitelist) {
goto long_continue; goto long_continue;
} }
} }
strncat(filtered, black_pointer, 1); strncat(filtered, blacklist, 1);
long_continue: long_continue:;
} }
} }