From 0a4286455a5ff3158be5a2022d276511ba6f416e Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Wed, 15 Apr 2020 17:25:36 +0200 Subject: [PATCH] Did I say that bool are an horrible thing in C ? --- inc/lektor/net.h | 2 +- src/commands.c | 4 ++-- src/main/lkt.c | 1 - src/net/listen.c | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/inc/lektor/net.h b/inc/lektor/net.h index 7741dba4..0b29e70f 100644 --- a/inc/lektor/net.h +++ b/inc/lektor/net.h @@ -50,7 +50,7 @@ void lkt_state_send(struct lkt_state *srv, size_t c, struct lkt_message *msg); /* Get and set continuation state for a client. */ size_t lkt_remaining_msg(struct lkt_state *srv, size_t c); -bool lkt_get_continuation(struct lkt_state *srv, size_t c); +int lkt_get_continuation(struct lkt_state *srv, size_t c); void lkt_set_continuation(struct lkt_state *srv, size_t c, int i); /* Get the mask to watch for events for a given client, to be used with the `idle` command. diff --git a/src/commands.c b/src/commands.c index 69bbec25..2ed168f5 100644 --- a/src/commands.c +++ b/src/commands.c @@ -958,11 +958,11 @@ only_one: /* The command is used with a range specifier. */ is_a_range: - if (to - from < lkt_remaining_msg(srv, c) - 1) { + if (to - from + 1 < lkt_remaining_msg(srv, c) - 2) { lkt_set_continuation(srv, c, 0); return database_queue_list(srv->db, from, to, &callback); } else { - to = from + lkt_remaining_msg(srv, c) - 2; + to = from + lkt_remaining_msg(srv, c) - 3; lkt_set_continuation(srv, c, to + 1); return database_queue_list(srv->db, from, to, &callback); } diff --git a/src/main/lkt.c b/src/main/lkt.c index db26aea6..834aa483 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -598,7 +598,6 @@ list__(struct lkt_cmd_args *args) FILE *sock = NULL; redo: - printf("%ld:%ld\n", continuation, up); sock = lkt_connect(); if (up != 0) write_socket_format(sock, "playlist %d:%d\n", continuation, up); diff --git a/src/net/listen.c b/src/net/listen.c index 51bb9031..216e1d75 100644 --- a/src/net/listen.c +++ b/src/net/listen.c @@ -63,7 +63,7 @@ lkt_close_client(struct lkt_state *srv, size_t c) return srv->clients[c - 1].request_close = true; } -inline bool +inline int lkt_get_continuation(struct lkt_state *srv, size_t c) { return srv->clients[c - 1].continuation; -- GitLab