]> git.xolatile.top Git - public-libhl.git/commitdiff
Fix all the warnings
authorEmil <emilwilliams@tuta.io>
Mon, 28 Aug 2023 22:19:40 +0000 (16:19 -0600)
committerEmil <emilwilliams@tuta.io>
Mon, 28 Aug 2023 22:19:40 +0000 (16:19 -0600)
include/hl.h
include/terminal_hl.h
source/regex.c

index d5476d7cd85a6612fd94dec39a7ea072f480bcf5..91ced6a2f4c39b683da5c82ab0143eec4cf67f84 100644 (file)
@@ -21,9 +21,9 @@ typedef enum {
        REGION
 } token_type_t;
 
-typedef void (*attribute_callback_t) (const char * const string,
-                                      const int          length,
-                                            void * const attributes);
+typedef void (*attribute_callback_t) (const char * string,
+                                      const int    length,
+                                            void * attributes);
 
 typedef struct {
        char                 * key;
@@ -58,14 +58,19 @@ extern int append_token(token_t * token);
 
 extern token_t * new_symbol_token(const char         * const c,
                                         hl_group_t   * const g);
+
 extern int       new_symbol_tokens(const char       * const *     symbols,
-                            hl_group_t * const             g);
-extern int       new_char_tokens(const char       *       characters,
-                          hl_group_t * const          g);
+                                         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,
-                                  hl_group_t   * const    g);
+                                         hl_group_t   * const    g);
+
 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,
                            const token_type_t            t,
                                  hl_group_t   * const    g);
@@ -146,7 +151,7 @@ int new_symbol_tokens(const char       * const *     symbols,
        return i;
 }
 
-int new_char_tokens(const char       *       characters,
+int new_char_tokens(const char       *              str,
                           hl_group_t * const          g) {
        int i = 0;
 
@@ -154,7 +159,7 @@ int new_char_tokens(const char       *       characters,
        buffer[0] = '\\';
        buffer[2] = '\0';
 
-       for(const char * s = characters; *s != '\0'; s++) {
+       for(const char * s = str; *s != '\0'; s++) {
                buffer[1] = *s;
                if(new_symbol_token(is_magic(*s) ? buffer : buffer + 1, g)) {
                        ++i;
@@ -202,9 +207,9 @@ int new_keyword_tokens(const char       * const * words,
        return i;
 }
 
-token_t * new_region_token(const char       * const * start,
-                           const char       * const *   end,
-                                 hl_group_t * const       g) {
+token_t * new_region_token(const char       * start,
+                           const char       *   end,
+                                 hl_group_t *       g) {
        char buffer[100];
        buffer[0] = '\0';
        strcat(buffer, start);
index 660e6a877de25a8db49b16a7ce1e7748e48942bd..6bbff84b24a0083c8b859809f0c476435f6560f5 100644 (file)
@@ -26,9 +26,9 @@
 #define TERMINAL_STYLE_REVERSE      "\033[7m"
 
 typedef struct {
-       char * attribute;
-       char * foreground_color;
-       char * background_color;
+       const char * attribute;
+       const char * foreground_color;
+       const char * background_color;
 } terminal_hl_t;
 
 extern display_t * cterm;
@@ -47,7 +47,7 @@ display_t * cterm = &(display_t) {
 void cterm_render_callback(const char * const string,
                            const int          length,
                            void       * const attributes) {
-       if(!length){
+       if (!length) {
                fputs(TERMINAL_STYLE_BOLD, stdout);
                putchar(*string);
                fputs(TERMINAL_RESET, stdout);
@@ -68,16 +68,16 @@ void cterm_render_callback(const char * const string,
 }
 
 
-void fun(const char       *   const attribute,
-         const char       *   const     color,
-                      hl_group_t * *          group){
-       terminal_hl_t * t = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
-               t->attribute = attribute;
-               t->foreground_color = color;;
-               t->background_color = NULL;
+void fun(const char       *   attribute,
+         const char       *       color,
+               hl_group_t * *         group){
+       terminal_hl_t * t = (terminal_hl_t *) malloc(sizeof(terminal_hl_t));
+       t->attribute = attribute;
+       t->foreground_color = color;
+       t->background_color = NULL;
        (*group) = (hl_group_t *)malloc(sizeof(hl_group_t));
-               (*group)->link = NULL;
-               (*group)->attributes = (void*)t;
+       (*group)->link = NULL;
+       (*group)->attributes = (void*)t;
 }
 
 int terminal_hl_init(void) {
index d5f63eb3c6fed1ac94bba17b4dddb1927696c60f..32464b63890332489213cd7695de34ae269ee355 100644 (file)
@@ -343,17 +343,17 @@ static int compile_range(const char           * const range,
        return ((s - range) + 1);
 }
 
-void filter_blacklist(const char * const whitelist,
-                      const char * const blacklist,
-                            char * const  filtered) {
-       for (char * black_pointer = blacklist; *black_pointer != '\0'; black_pointer++) {
-               for(char * white_pointer = blacklist; *white_pointer != '\0'; white_pointer++) {
-                       if (*black_pointer == *white_pointer) {
+void filter_blacklist(const char * whitelist,
+                      const char * blacklist,
+                            char *  filtered) {
+       for (; *blacklist != '\0'; blacklist++) {
+               for(; *whitelist != '\0'; whitelist++) {
+                       if (*blacklist == *whitelist) {
                                goto long_continue;
                        }
                }
-               strncat(filtered, black_pointer, 1);
-               long_continue:
+               strncat(filtered, blacklist, 1);
+       long_continue:;
        }
 }