mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-06-24 11:51:35 +02:00
Minor
This commit is contained in:
parent
8ee70e735e
commit
6dc8bf1e7a
@ -16,7 +16,7 @@ setup_fifo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exists() {
|
exists() {
|
||||||
command -v "$1" > /dev/null
|
command -v "$1" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
send_image() {
|
send_image() {
|
||||||
|
20
src/lexer.c
20
src/lexer.c
@ -154,10 +154,8 @@ Lexer *lexer_init(FILE *f)
|
|||||||
|
|
||||||
init_input_buf(&ctx->input_buf, f);
|
init_input_buf(&ctx->input_buf, f);
|
||||||
ctx->text_buf = ulist_new(sizeof(char), 1024);
|
ctx->text_buf = ulist_new(sizeof(char), 1024);
|
||||||
ctx->line = 1;
|
ctx->line = ctx->col = 1;
|
||||||
ctx->col = 1;
|
ctx->tok_queue.back = ctx->tok_queue.front = 0;
|
||||||
ctx->tok_queue.back = 0;
|
|
||||||
ctx->tok_queue.front = 0;
|
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
@ -170,8 +168,8 @@ void lexer_free(Lexer *ctx)
|
|||||||
|
|
||||||
static int cmp_nextn(Lexer *ctx, int n, char *s)
|
static int cmp_nextn(Lexer *ctx, int n, char *s)
|
||||||
{
|
{
|
||||||
int i = 0;
|
|
||||||
char c;
|
char c;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
c = peekn_char(ctx, i);
|
c = peekn_char(ctx, i);
|
||||||
@ -182,10 +180,7 @@ static int cmp_nextn(Lexer *ctx, int n, char *s)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == n)
|
return i == n ? 0 : ((unsigned char)c - *(unsigned char *)s);
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return ((unsigned char)c - *(unsigned char *)s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ignore_comments(Lexer *ctx)
|
static void ignore_comments(Lexer *ctx)
|
||||||
@ -203,12 +198,7 @@ static void read_while(Lexer *ctx, Predicate p, int add)
|
|||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while (1) {
|
while ((c = peek_char(ctx)) >= 0 && p(c)) {
|
||||||
c = peek_char(ctx);
|
|
||||||
|
|
||||||
if (c < 0 || !p(c))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (add)
|
if (add)
|
||||||
add_text_buf(ctx, c);
|
add_text_buf(ctx, c);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#define ULIST_NODE_SIZE(cap, size) \
|
#define ULIST_NODE_SIZE(cap, size) \
|
||||||
(sizeof(struct UListNode) - sizeof(void *) + (cap * size))
|
(sizeof(struct UListNode) - sizeof(void *) + (cap * size))
|
||||||
|
|
||||||
#define ULIST_BUF(list) ((void *)&(list).buf)
|
#define ULIST_BUF(node) ((void *)&(node).buf)
|
||||||
|
|
||||||
struct UList {
|
struct UList {
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -62,8 +62,7 @@ UList *ulist_new(size_t size, size_t cap)
|
|||||||
|
|
||||||
l->size = size;
|
l->size = size;
|
||||||
l->lock_i = NO_LOCK;
|
l->lock_i = NO_LOCK;
|
||||||
l->head = ulist_node_new(l, cap);
|
l->head = l->tail = ulist_node_new(l, cap);
|
||||||
l->tail = l->head;
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user