more miscellaneous minor fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2541 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-05-26 03:32:41 +00:00
parent 8b3266e83c
commit 16f88134f7
3 changed files with 17 additions and 6 deletions

View File

@ -52,6 +52,9 @@ CVS code -
do_browser() do_browser()
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for - Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
consistency. (DLR) consistency. (DLR)
- When displaying "(dir)" in the available screen space, make
sure that the string it's stored in is always null-terminated.
(DLR)
save_history() save_history()
- Properly save history when in view mode. (DLR) - Properly save history when in view mode. (DLR)
- global.c: - global.c:
@ -81,6 +84,9 @@ CVS code -
since the first line in the file is 1. (DLR) since the first line in the file is 1. (DLR)
- Start the search for a line from fileage instead of current - Start the search for a line from fileage instead of current
(again). (DLR) (again). (DLR)
replace_line()
- Make new_line_size and search_match_count size_t's, for
consistency. (DLR)
- utils.c: - utils.c:
num_of_digits() num_of_digits()
- Use a size_t instead of an int, and rename to digits(). (DLR) - Use a size_t instead of an int, and rename to digits(). (DLR)

View File

@ -2204,6 +2204,7 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
if (num_matches == 1 && is_dir(mzero)) { if (num_matches == 1 && is_dir(mzero)) {
mzero[common_len] = '/'; mzero[common_len] = '/';
common_len++; common_len++;
assert(common_len > *place); assert(common_len > *place);
} }
@ -2266,8 +2267,9 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
wmove(edit, editline, (longest_name + 2) * wmove(edit, editline, (longest_name + 2) *
(match % columns)); (match % columns));
if (match % columns == 0 && editline == editwinrows - 1 if (match % columns == 0 &&
&& num_matches - match > columns) { editline == editwinrows - 1 &&
num_matches - match > columns) {
waddstr(edit, _("(more)")); waddstr(edit, _("(more)"));
break; break;
} }
@ -2321,6 +2323,7 @@ void free_charptrarray(char **array, size_t len)
{ {
for (; len > 0; len--) for (; len > 0; len--)
free(array[len - 1]); free(array[len - 1]);
free(array); free(array);
} }
@ -2332,6 +2335,7 @@ void striponedir(char *path)
assert(path != NULL); assert(path != NULL);
tmp = strrchr(path, '/'); tmp = strrchr(path, '/');
if (tmp != NULL) if (tmp != NULL)
*tmp = '\0'; *tmp = '\0';
} }
@ -2718,9 +2722,10 @@ char *do_browser(char *path, DIR *dir)
foo[foo_len] = '\0'; foo[foo_len] = '\0';
} else } else
strcpy(foo, "--"); strcpy(foo, "--");
} else if (S_ISDIR(st.st_mode)) } else if (S_ISDIR(st.st_mode)) {
strncpy(foo, _("(dir)"), foo_len); strncpy(foo, _("(dir)"), foo_len);
else if (st.st_size < (1 << 10)) /* less than 1 k. */ foo[foo_len] = '\0';
} else if (st.st_size < (1 << 10)) /* less than 1 k. */
sprintf(foo, "%4u B", (unsigned int)st.st_size); sprintf(foo, "%4u B", (unsigned int)st.st_size);
else if (st.st_size < (1 << 20)) /* less than 1 meg. */ else if (st.st_size < (1 << 20)) /* less than 1 meg. */
sprintf(foo, "%4u KB", sprintf(foo, "%4u KB",

View File

@ -628,8 +628,7 @@ int replace_regexp(char *string, bool create_flag)
char *replace_line(const char *needle) char *replace_line(const char *needle)
{ {
char *copy; char *copy;
int new_line_size; size_t new_line_size, search_match_count;
int search_match_count;
/* Calculate the size of the new line. */ /* Calculate the size of the new line. */
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
@ -661,6 +660,7 @@ char *replace_line(const char *needle)
/* The tail of the original line. */ /* The tail of the original line. */
assert(current_x + search_match_count <= strlen(current->data)); assert(current_x + search_match_count <= strlen(current->data));
strcat(copy, current->data + current_x + search_match_count); strcat(copy, current->data + current_x + search_match_count);
return copy; return copy;