]> git.xolatile.top Git - public-libhl.git/commitdiff
so. close.
authoranon <anon@anon.anon>
Thu, 21 Sep 2023 07:06:40 +0000 (09:06 +0200)
committeranon <anon@anon.anon>
Thu, 21 Sep 2023 07:06:40 +0000 (09:06 +0200)
source/hl.c

index 5c415d9e1af8981fed8aeced71fc33dca9ace82e..8237ee1a0a841b2711a007e1a4f06e58687057a0 100644 (file)
@@ -97,20 +97,18 @@ int new_char_tokens(const char       *              str,
 
 token_t * new_keyword_token(const char         * const word,
                                   hl_group_t   * const    g) {
-       //char   * new_word = strdup(word);
-       //size_t   word_length = strlen(word);
-       //char   * new_word    = (char*)malloc(word_length + 4 + 1);
+       size_t   word_length = strlen(word);
+       char   * new_word    = (char*)malloc(word_length + 4 + 1);
 
-       //memcpy(new_word, "\\<", 2);
-       //memcpy(new_word + 2, word, word_length);
-       //strcpy(new_word + 2 + word_length, "\\>");
+       memcpy(new_word, "\\<", 2);
+       memcpy(new_word + 2, word, word_length);
+       strcpy(new_word + 2 + word_length, "\\>");
 
        token_t * mt = (token_t*)malloc(sizeof(token_t));
 
        mt->hl     = g;
        mt->t      = KEYWORD;
-       //mt->syntax = regex_compile(new_word);
-       mt->syntax = regex_compile(word);
+       mt->syntax = regex_compile(new_word);
 
        append_token(mt);
 
@@ -178,29 +176,6 @@ token_t * new_token(const char         * const word,
 // --------------------
 // ### Highlighting ###
 // --------------------
-
-int token_fits(const token_t * const            token,
-               const char    * const               to,
-               const int                string_offset,
-               const bool            is_start_of_line,
-                     int     *           match_offset) {
-       return 0;
-       UNUSED(match_offset);
-
-       match_t * matches = regex_match(token->syntax, to, is_start_of_line);
-
-       if (matches->position == -1) {
-               return 0;
-       }
-
-       const int r  = matches->width;
-       match_offset = matches->position;
-
-       free(matches);
-
-       return r;
-}
-
 void render_string(const char * const string,
                    const char * const   mode) {
        display_t * display;
@@ -220,9 +195,6 @@ void render_string(const char * const string,
                token_t * t = *(token_t**)vector_get(&token_table,
                                                     i);
                match_t * match = regex_match(t->syntax, string, true);
-               for(match_t * m = match; m->position != -1; m++){
-                       printf("%s: %d %d\n", t->syntax->str, m->position, m->width);
-               }
                if (match->position == -1) {
                        free(match);
                        continue;