From 7dc5ad1c5c1e186538d32d7c9a585283062210c8 Mon Sep 17 00:00:00 2001 From: CismonX Date: Fri, 1 Dec 2023 20:10:15 +0800 Subject: [PATCH] chore: rename candidate length vars --- doc/arif_ctx_create.3 | 2 +- doc/arif_fetch.3 | 2 +- examples/arif_rime.c | 4 ++-- include/arif.h | 4 ++-- src/arif.c | 4 ++-- src/arif_rl.c | 6 +++--- tests/arif_dummy_engine.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/arif_ctx_create.3 b/doc/arif_ctx_create.3 index ada77a8..04239b6 100644 --- a/doc/arif_ctx_create.3 +++ b/doc/arif_ctx_create.3 @@ -54,7 +54,7 @@ type is defined as: .EX typedef char *(arif_cand_disp_func) ( char const *text, - int len, + int text_len, char const *comment, int comment_len, int idx, diff --git a/doc/arif_fetch.3 b/doc/arif_fetch.3 index 7819b1f..62af723 100644 --- a/doc/arif_fetch.3 +++ b/doc/arif_fetch.3 @@ -38,7 +38,7 @@ type is defined as: .EX struct arif_cand { char const *text; - int len; + int text_len; int replace_start; int replace_len; char const *transform; diff --git a/examples/arif_rime.c b/examples/arif_rime.c index f8b245b..1e306f2 100644 --- a/examples/arif_rime.c +++ b/examples/arif_rime.c @@ -240,7 +240,7 @@ arif_rime_query ( *cand = (struct arif_cand) { .text = prefix, - .len = prefix_len, + .text_len = prefix_len, .replace_len = len, }; idx = 1; @@ -301,7 +301,7 @@ copy_candidate ( } *dest = (struct arif_cand) { .text = buf, - .len = text_len, + .text_len = text_len, .replace_start = prefix_len + composition->sel_start, .replace_len = composition->sel_end - composition->sel_start, .transform = buf + text_len, diff --git a/include/arif.h b/include/arif.h index c7905ec..6e146fd 100644 --- a/include/arif.h +++ b/include/arif.h @@ -32,7 +32,7 @@ struct arif_ctx; typedef char *(arif_cand_disp_func) ( char const *text, - int len, + int text_len, char const *comment, int comment_len, int idx, @@ -65,7 +65,7 @@ typedef int (arif_engine_query_func) ( struct arif_cand { char const *text; - int len; + int text_len; int replace_start; int replace_len; char const *transform; diff --git a/src/arif.c b/src/arif.c index 40bdcf4..a2ff141 100644 --- a/src/arif.c +++ b/src/arif.c @@ -127,12 +127,12 @@ copy_candidate ( arif_cand_disp_func *disp_cand ) { int display_len; - char *display = disp_cand(src->text, src->len, + char *display = disp_cand(src->text, src->text_len, src->display, src->display_len, idx + 1, &display_len); *dest = (struct arif_cand) { .text = src->text, - .len = src->len, + .text_len = src->text_len, .replace_start = src->replace_start, .replace_len = src->replace_len, .transform = src->transform, diff --git a/src/arif_rl.c b/src/arif_rl.c index f9d22a1..3bf86e5 100644 --- a/src/arif_rl.c +++ b/src/arif_rl.c @@ -83,7 +83,7 @@ arif_rl_complete( line_len = end; } - int len = line_len - cand->replace_len + cand->len + skip; + int len = line_len - cand->replace_len + cand->text_len + skip; char *match = malloc(sizeof(char) * (len + 1)); assert(match != NULL); @@ -94,9 +94,9 @@ arif_rl_complete( memcpy(match + offset, line, cand->replace_start); offset += cand->replace_start; - memcpy(match + offset, cand->text, cand->len); + memcpy(match + offset, cand->text, cand->text_len); - offset += cand->len; + offset += cand->text_len; memcpy(match + offset, line + cand->replace_start + cand->replace_len, len - offset); diff --git a/tests/arif_dummy_engine.c b/tests/arif_dummy_engine.c index d0bdd54..b586a28 100644 --- a/tests/arif_dummy_engine.c +++ b/tests/arif_dummy_engine.c @@ -181,7 +181,7 @@ generate_candidate ( *cand = (struct arif_cand) { .text = text, - .len = len, + .text_len = len, .replace_len = len, }; }