Compare commits

...

3 Commits

Author SHA1 Message Date
CismonX 0b316efb60
chore: update ci script
continuous-integration/drone Build is failing Details
* change runner container image to debian
* build with librime
2023-02-20 13:45:46 +08:00
CismonX 70843c6670
chore: change arif_rime default log level to ERROR 2023-02-20 13:45:32 +08:00
CismonX 787f487b19
chore: minor refactor 2023-02-20 13:44:27 +08:00
5 changed files with 30 additions and 33 deletions

View File

@ -12,14 +12,14 @@ name: default
steps:
- name: build
image: pureos/byzantium
image: debian:bullseye-slim
commands:
- apt -y update
- apt -y install
build-essential pkg-config autoconf automake libtool
autoconf-archive dejagnu texinfo libreadline-dev
autoconf-archive dejagnu texinfo libreadline-dev librime-dev
- autoreconf -i && mkdir build && cd build
- ../configure --with-readline --without-rime --enable-debug
- ../configure --with-readline --with-rime --enable-debug
CFLAGS='-O0 -g -std=c99 -Wall -Wextra -Wpedantic -Wshadow'
CPPFLAGS='-D_POSIX_C_SOURCE=200112L'
- make

View File

@ -48,7 +48,7 @@ Defaults to "/tmp".
Rime minimum log level.
Should be one of INFO, WARNING, ERROR or FATAL (case insensitive).
.IP
Default log level is INFO.
Default log level is ERROR.
.TP
.B ARIF_RIME_MODULES
A whitespace-separated list of Rime modules to load before Rime initialization.

View File

@ -104,9 +104,7 @@ arif_rime_finalize (
free_candidates(ctx);
if (rime_api != NULL) {
if (ctx->session != 0) {
rime_api->destroy_session(ctx->session);
}
rime_api->destroy_session(ctx->session);
}
free(ctx);
@ -140,7 +138,7 @@ arif_rime_init (
assert(ctx != NULL);
*ctx = (struct engine_ctx) {
.session = rime_api->create_session(),
.session = 0,
};
*engine_data_ptr = ctx;
return 0;
@ -356,7 +354,7 @@ get_log_level (
if (0 == strcasecmp("FATAL", log_level)) {
return 3;
}
return 0;
return 2;
}
static char const **

View File

@ -60,7 +60,6 @@ struct arif_ctx {
// Forward declaration start
static struct cand_page *
choose_candidate (struct cand_page *, int);
static void clear_old_line (struct arif_ctx *);
static int compare_text (char const *, int, char const *, int);
static void copy_candidate (struct arif_cand *, struct arif_cand const *,
int, arif_cand_disp_func *);
@ -77,6 +76,7 @@ static struct cand_page *
static void new_pages (struct arif_cand const *, int, int,
arif_cand_disp_func *, struct cand_page **,
struct cand_page **);
static void set_old_line (struct arif_ctx *, char const *, int, int);
// Forward declaration end
static struct cand_page *
@ -105,16 +105,6 @@ choose_candidate (
return new_page;
}
static inline void
clear_old_line (
struct arif_ctx *ctx
) {
free((char *) ctx->old_line);
ctx->old_line = NULL;
ctx->old_offset = 0;
ctx->old_len = 0;
}
static inline int
compare_text (
char const *text1,
@ -213,14 +203,14 @@ free_page_list (
if (head == NULL) {
return;
}
struct cand_page *prev = head->prev;
struct cand_page *next, *prev = head->prev;
// free forward
for (struct cand_page *next, *page = head; page != NULL; page = next) {
for (struct cand_page *page = head; page != NULL; page = next) {
next = page->next;
free_page(page);
}
// free backward
for (struct cand_page *next, *page = prev; page != NULL; page = next) {
for (struct cand_page *page = prev; page != NULL; page = next) {
next = page->prev;
free_page(page);
}
@ -398,11 +388,7 @@ arif_query (
char *saved_line = malloc(sizeof(char) * (offset + len));
assert(saved_line != NULL);
free((char *) ctx->old_line);
ctx->old_line = memcpy(saved_line, line, offset + len);
ctx->old_offset = offset;
ctx->old_len = len;
set_old_line(ctx, memcpy(saved_line, line, offset + len), offset, len);
first_candidates(ctx, saved_line, offset, len);
} else {
// same text as old query
@ -426,7 +412,7 @@ arif_query (
ctx->page_num = 1;
ctx->no_more_pages = false;
clear_old_line(ctx);
set_old_line(ctx, NULL, 0, 0);
}
finish:
@ -482,8 +468,21 @@ arif_set_engine (
ctx->page_num = 0;
ctx->no_more_pages = false;
clear_old_line(ctx);
set_old_line(ctx, NULL, 0, 0);
ctx->engine = engine;
ctx->engine_data = engine_data;
}
static inline void
set_old_line (
struct arif_ctx *ctx,
char const *old_line,
int old_offset,
int old_len
) {
free((char *) ctx->old_line);
ctx->old_line = old_line;
ctx->old_offset = old_offset;
ctx->old_len = old_len;
}

View File

@ -20,9 +20,9 @@ arif_test_SOURCES = arif_test.c arif_dummy_engine.c
libarifdummy_la_CPPFLAGS = -I$(top_srcdir)/include
libarifdummy_la_SOURCES = arif_dummy_engine.c
EXTRA_DIST = lib/arif.exp \
arif/000-query.exp \
arif/001-select-page.exp \
EXTRA_DIST = lib/arif.exp \
arif/000-query.exp \
arif/001-select-page.exp \
arif/002-fetch.exp
RUNTESTFLAGS = ARIF_TEST_BIN=$(builddir)/arif-test