aboutsummaryrefslogtreecommitdiff
path: root/inputstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'inputstr.c')
-rw-r--r--inputstr.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/inputstr.c b/inputstr.c
index 78255fd32fa9..2c7bb7d0f4db 100644
--- a/inputstr.c
+++ b/inputstr.c
@@ -1,9 +1,9 @@
/*
- * $Id: inputstr.c,v 1.88 2018/06/18 22:10:54 tom Exp $
+ * $Id: inputstr.c,v 1.91 2021/01/17 22:19:05 tom Exp $
*
* inputstr.c -- functions for input/display of a string
*
- * Copyright 2000-2017,2018 Thomas E. Dickey
+ * Copyright 2000-2019,2021 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@@ -204,7 +204,6 @@ static CACHE my_cache;
static bool
same_cache2(CACHE * cache, const char *string, unsigned i_len)
{
- unsigned need;
size_t s_len = strlen(string);
bool result = TRUE;
@@ -212,8 +211,8 @@ same_cache2(CACHE * cache, const char *string, unsigned i_len)
|| cache->s_len < s_len
|| cache->list == 0
|| !SAME_CACHE(cache, string, (size_t) s_len)) {
+ unsigned need = (i_len + 1);
- need = (i_len + 1);
if (cache->list == 0) {
cache->list = dlg_malloc(int, need);
} else if (cache->i_len < i_len) {
@@ -322,10 +321,11 @@ dlg_count_wchars(const char *string)
mbstate_t state;
int part = dlg_count_wcbytes(cache->string, len);
char save = cache->string[part];
- size_t code;
wchar_t *temp = dlg_calloc(wchar_t, len + 1);
if (temp != 0) {
+ size_t code;
+
cache->string[part] = '\0';
memset(&state, 0, sizeof(state));
code = mbsrtowcs(temp, &src, (size_t) part, &state);
@@ -353,11 +353,11 @@ const int *
dlg_index_wchars(const char *string)
{
unsigned len = (unsigned) dlg_count_wchars(string);
- unsigned inx;
CACHE *cache = load_cache(cInxWideChars, string);
if (!same_cache2(cache, string, len)) {
const char *current = string;
+ unsigned inx;
cache->list[0] = 0;
for (inx = 1; inx <= len; ++inx) {
@@ -407,25 +407,27 @@ const int *
dlg_index_columns(const char *string)
{
unsigned len = (unsigned) dlg_count_wchars(string);
- unsigned inx;
CACHE *cache = load_cache(cInxCols, string);
if (!same_cache2(cache, string, len)) {
+
cache->list[0] = 0;
#ifdef USE_WIDE_CURSES
if (have_locale()) {
+ unsigned inx;
size_t num_bytes = strlen(string);
const int *inx_wchars = dlg_index_wchars(string);
mbstate_t state;
for (inx = 0; inx < len; ++inx) {
- wchar_t temp[2];
- size_t check;
int result;
if (string[inx_wchars[inx]] == TAB) {
result = ((cache->list[inx] | 7) + 1) - cache->list[inx];
} else {
+ wchar_t temp[2];
+ size_t check;
+
memset(&state, 0, sizeof(state));
memset(temp, 0, sizeof(temp));
check = mbrtowc(temp,
@@ -452,6 +454,8 @@ dlg_index_columns(const char *string)
} else
#endif /* USE_WIDE_CURSES */
{
+ unsigned inx;
+
for (inx = 0; inx < len; ++inx) {
chtype ch = UCH(string[inx]);