Compare commits
2 Commits
1c0387ad22
...
7e85ae7fe9
Author | SHA1 | Date | |
---|---|---|---|
7e85ae7fe9 | |||
2d00aa481e |
10
source/hl.c
10
source/hl.c
@ -220,6 +220,9 @@ void render_string(const char * const string,
|
|||||||
token_t * t = *(token_t**)vector_get(&token_table,
|
token_t * t = *(token_t**)vector_get(&token_table,
|
||||||
i);
|
i);
|
||||||
match_t * match = regex_match(t->syntax, string, true);
|
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) {
|
if (match->position == -1) {
|
||||||
free(match);
|
free(match);
|
||||||
continue;
|
continue;
|
||||||
@ -248,16 +251,17 @@ void render_string(const char * const string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max != &sentinel) {
|
if (max != &sentinel) {
|
||||||
const int padding = max->m[max->i].position - (s - string);
|
const match_t * mymatch = &(max->m[max->i]);
|
||||||
|
const int padding = mymatch->position - (s - string);
|
||||||
if (padding) {
|
if (padding) {
|
||||||
display->callback(s,
|
display->callback(s,
|
||||||
padding,
|
padding,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
display->callback(s + padding,
|
display->callback(s + padding,
|
||||||
max->m->width,
|
mymatch->width,
|
||||||
max->t->hl->attributes);
|
max->t->hl->attributes);
|
||||||
s += padding + max->m->width;
|
s += padding + mymatch->width;
|
||||||
} else {
|
} else {
|
||||||
display->callback(s, 1, NULL);
|
display->callback(s, 1, NULL);
|
||||||
++s;
|
++s;
|
||||||
|
@ -43,8 +43,8 @@ get_stdin(void)
|
|||||||
size_t buffer_size = 0;
|
size_t buffer_size = 0;
|
||||||
char * buffer = malloc(ALLOCATION_CHUNK);
|
char * buffer = malloc(ALLOCATION_CHUNK);
|
||||||
do {
|
do {
|
||||||
if (!((buffer_size + 1) | ALLOCATION_CHUNK)) {
|
if (!((buffer_size + 1) % ALLOCATION_CHUNK)) {
|
||||||
buffer = realloc(buffer, (((buffer_size + 1) & ALLOCATION_CHUNK) + 1) * ALLOCATION_CHUNK);
|
buffer = realloc(buffer, (((buffer_size + 1) / ALLOCATION_CHUNK) + 1) * ALLOCATION_CHUNK);
|
||||||
}
|
}
|
||||||
buffer[buffer_size] = '\0';
|
buffer[buffer_size] = '\0';
|
||||||
if (read(STDIN_FILENO, &buffer[buffer_size], sizeof (*buffer)) == -1)
|
if (read(STDIN_FILENO, &buffer[buffer_size], sizeof (*buffer)) == -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user