Compare commits

..

No commits in common. "0b316efb600e59bb1072683b0064b82551b878f7" and "d748d8972e3c9fe5271566b2129b81a80b309d25" have entirely different histories.

5 changed files with 33 additions and 30 deletions

View File

@ -12,14 +12,14 @@ name: default
steps:
- name: build
image: debian:bullseye-slim
image: pureos/byzantium
commands:
- apt -y update
- apt -y install
build-essential pkg-config autoconf automake libtool
autoconf-archive dejagnu texinfo libreadline-dev librime-dev
autoconf-archive dejagnu texinfo libreadline-dev
- autoreconf -i && mkdir build && cd build
- ../configure --with-readline --with-rime --enable-debug
- ../configure --with-readline --without-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 ERROR.
Default log level is INFO.
.TP
.B ARIF_RIME_MODULES
A whitespace-separated list of Rime modules to load before Rime initialization.

View File

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

View File

@ -60,6 +60,7 @@ 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 *);
@ -76,7 +77,6 @@ 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,6 +105,16 @@ 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,
@ -203,14 +213,14 @@ free_page_list (
if (head == NULL) {
return;
}
struct cand_page *next, *prev = head->prev;
struct cand_page *prev = head->prev;
// free forward
for (struct cand_page *page = head; page != NULL; page = next) {
for (struct cand_page *next, *page = head; page != NULL; page = next) {
next = page->next;
free_page(page);
}
// free backward
for (struct cand_page *page = prev; page != NULL; page = next) {
for (struct cand_page *next, *page = prev; page != NULL; page = next) {
next = page->prev;
free_page(page);
}
@ -388,7 +398,11 @@ arif_query (
char *saved_line = malloc(sizeof(char) * (offset + len));
assert(saved_line != NULL);
set_old_line(ctx, memcpy(saved_line, line, offset + len), offset, len);
free((char *) ctx->old_line);
ctx->old_line = memcpy(saved_line, line, offset + len);
ctx->old_offset = offset;
ctx->old_len = len;
first_candidates(ctx, saved_line, offset, len);
} else {
// same text as old query
@ -412,7 +426,7 @@ arif_query (
ctx->page_num = 1;
ctx->no_more_pages = false;
set_old_line(ctx, NULL, 0, 0);
clear_old_line(ctx);
}
finish:
@ -468,21 +482,8 @@ arif_set_engine (
ctx->page_num = 0;
ctx->no_more_pages = false;
set_old_line(ctx, NULL, 0, 0);
clear_old_line(ctx);
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