This commit is contained in:
Nikita Ivanov 2022-06-11 13:39:19 +05:00
parent 8ee70e735e
commit 6dc8bf1e7a
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
3 changed files with 8 additions and 19 deletions

View File

@ -16,7 +16,7 @@ setup_fifo() {
}
exists() {
command -v "$1" > /dev/null
command -v "$1" >/dev/null
}
send_image() {

View File

@ -154,10 +154,8 @@ Lexer *lexer_init(FILE *f)
init_input_buf(&ctx->input_buf, f);
ctx->text_buf = ulist_new(sizeof(char), 1024);
ctx->line = 1;
ctx->col = 1;
ctx->tok_queue.back = 0;
ctx->tok_queue.front = 0;
ctx->line = ctx->col = 1;
ctx->tok_queue.back = ctx->tok_queue.front = 0;
return ctx;
}
@ -170,8 +168,8 @@ void lexer_free(Lexer *ctx)
static int cmp_nextn(Lexer *ctx, int n, char *s)
{
int i = 0;
char c;
int i = 0;
while (1) {
c = peekn_char(ctx, i);
@ -182,10 +180,7 @@ static int cmp_nextn(Lexer *ctx, int n, char *s)
i++;
}
if (i == n)
return 0;
else
return ((unsigned char)c - *(unsigned char *)s);
return i == n ? 0 : ((unsigned char)c - *(unsigned char *)s);
}
static void ignore_comments(Lexer *ctx)
@ -203,12 +198,7 @@ static void read_while(Lexer *ctx, Predicate p, int add)
{
char c;
while (1) {
c = peek_char(ctx);
if (c < 0 || !p(c))
break;
while ((c = peek_char(ctx)) >= 0 && p(c)) {
if (add)
add_text_buf(ctx, c);

View File

@ -13,7 +13,7 @@
#define ULIST_NODE_SIZE(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 {
size_t size;
@ -62,8 +62,7 @@ UList *ulist_new(size_t size, size_t cap)
l->size = size;
l->lock_i = NO_LOCK;
l->head = ulist_node_new(l, cap);
l->tail = l->head;
l->head = l->tail = ulist_node_new(l, cap);
return l;
}