From 6a0d5b8fec45c008cf7fb9cdb66b103be6eeeda4 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 13 Jun 2005 14:00:22 +0000 Subject: [PATCH] miscellaneous minor fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2649 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/chars.c | 5 +++-- src/files.c | 1 + src/nano.c | 5 +++-- src/proto.h | 4 ++-- src/utils.c | 8 ++++---- src/winio.c | 2 ++ 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f781c1d..dc8cb0ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -197,6 +197,8 @@ CVS code - - utils.c: num_of_digits() - Use a size_t instead of an int, and rename to digits(). (DLR) + align() + - Rename variable strp to str for consistency. (DLR) - winio.c: do_statusbar_output() - Don't set answer_len until after it's been asserted that @@ -206,6 +208,7 @@ CVS code - for len plus a trailing multibyte character and/or tab. (DLR) - Don't check for multicolumn characters if the NO_UTF8 flag isn't set. (DLR) + - Free buf_mb when we're done using it. (DLR) nanogetstr() - Rename variable def to curranswer to avoid confusion. (DLR) - Only declare and use the tabbed variable if DISABLE_TABCOMP diff --git a/src/chars.c b/src/chars.c index ccc8748a..74f534f1 100644 --- a/src/chars.c +++ b/src/chars.c @@ -265,11 +265,12 @@ char *make_mbchar(int chr, int *chr_mb_len) wctomb(NULL, 0); *chr_mb_len = 0; } + + align(&chr_mb); } else { #endif *chr_mb_len = 1; - chr_mb = charalloc(1); - *chr_mb = (char)chr; + chr_mb = mallocstrncpy(NULL, (char *)&chr, 1); #ifdef NANO_WIDE } #endif diff --git a/src/files.c b/src/files.c index 7261a398..a3f94821 100644 --- a/src/files.c +++ b/src/files.c @@ -2801,6 +2801,7 @@ char *do_browser(char *path, DIR *dir) if (width == 0) width = filecols; } + wmove(edit, editline, col); } diff --git a/src/nano.c b/src/nano.c index fb3f523f..c5cd9a64 100644 --- a/src/nano.c +++ b/src/nano.c @@ -561,6 +561,7 @@ void help_init(void) free(help_ptr); } + ptr += sprintf(ptr, "\n"); } @@ -1470,10 +1471,10 @@ bool do_next_word(bool allow_update) * line. */ if (!is_word_mbchar(char_mb)) break; + /* If we haven't found it, then we've started on a word, so set * started_on_word to TRUE. */ - else - started_on_word = TRUE; + started_on_word = TRUE; current_x += char_mb_len; } diff --git a/src/proto.h b/src/proto.h index cf7d2e5f..38d186cc 100644 --- a/src/proto.h +++ b/src/proto.h @@ -181,7 +181,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len); int mbwidth(const char *c); int mb_cur_max(void); char *make_mbchar(int chr, int *chr_mb_len); -#if defined(ENABLE_NANORC) || defined(ENABLE_EXTRA) +#if defined(ENABLE_NANORC) || defined(NANO_EXTRA) char *make_mbstring(const char *str); #endif int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t @@ -549,7 +549,7 @@ int digits(size_t n); void get_homedir(void); bool parse_num(const char *str, ssize_t *val); bool parse_line_column(const char *str, int *line, ssize_t *column); -void align(char **strp); +void align(char **str); void null_at(char **data, size_t index); void unsunder(char *str, size_t true_len); void sunder(char *str); diff --git a/src/utils.c b/src/utils.c index a2b7f756..2069e1f5 100644 --- a/src/utils.c +++ b/src/utils.c @@ -139,12 +139,12 @@ bool parse_line_column(const char *str, int *line, ssize_t *column) } /* Fix the memory allocation for a string. */ -void align(char **strp) +void align(char **str) { - assert(strp != NULL); + assert(str != NULL); - if (*strp != NULL) - *strp = charealloc(*strp, strlen(*strp) + 1); + if (*str != NULL) + *str = charealloc(*str, strlen(*str) + 1); } /* Null a string at a certain index and align it. */ diff --git a/src/winio.c b/src/winio.c index 8f2d690b..83a4632d 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2380,6 +2380,8 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool start_index += buf_mb_len; } + free(buf_mb); + if (index < alloc_len - 1) converted[index] = '\0'; -- 2.39.5