add a few more missing blank lines, and fix two instances where totsize

is miscalculated in multibyte/wide character mode


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2336 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-03-04 17:09:41 +00:00
parent 9adace8c76
commit 5f9acfeee5
2 changed files with 32 additions and 17 deletions

View File

@ -111,13 +111,14 @@ CVS code -
chars.c), move_right() (renamed move_mbright() and moved to chars.c), move_right() (renamed move_mbright() and moved to
chars.c), do_home(), do_verbatim_input(), do_delete(), chars.c), do_home(), do_verbatim_input(), do_delete(),
do_tab(), do_enter(), indent_length(), do_next_word(), do_tab(), do_enter(), indent_length(), do_next_word(),
do_prev_word(), do_input(), do_output(), is_whole_word(), do_prev_word(), do_wrap(), do_input(), do_output(),
strstrwrapper(), get_buffer(), unget_input(), unget_kbinput(), is_whole_word(), strstrwrapper(), get_buffer(), unget_input(),
get_input(), parse_kbinput(), unparse_kbinput(), unget_kbinput(), get_input(), parse_kbinput(),
parse_verbatim_kbinput(), do_statusbar_input(), unparse_kbinput(), parse_verbatim_kbinput(),
do_statusbar_home(), do_statusbar_verbatim_kbinput(), do_statusbar_input(), do_statusbar_home(),
do_statusbar_output(), and display_string(); removal of do_statusbar_verbatim_kbinput(), do_statusbar_output(), and
buffer_to_keys() and keys_to_buffer(). (DLR) display_string(); removal of buffer_to_keys() and
keys_to_buffer(). (DLR)
- Add -O/--morespace command line option, plus a corresponding - Add -O/--morespace command line option, plus a corresponding
Meta-O toggle and a "morespace" rcfile option. When these are Meta-O toggle and a "morespace" rcfile option. When these are
used, the normally-unused blank line below the titlebar will used, the normally-unused blank line below the titlebar will

View File

@ -521,7 +521,9 @@ void help_init(void)
/* And the toggles... */ /* And the toggles... */
if (currshortcut == main_list) { if (currshortcut == main_list) {
for (t = toggles; t != NULL; t = t->next) { for (t = toggles; t != NULL; t = t->next) {
assert(t->desc != NULL); assert(t->desc != NULL);
ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", toupper(t->val), ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", toupper(t->val),
t->desc, _("enable/disable")); t->desc, _("enable/disable"));
} }
@ -554,12 +556,17 @@ filestruct *make_new_node(filestruct *prevnode)
/* Make a copy of a filestruct node. */ /* Make a copy of a filestruct node. */
filestruct *copy_node(const filestruct *src) filestruct *copy_node(const filestruct *src)
{ {
filestruct *dst = (filestruct *)nmalloc(sizeof(filestruct)); filestruct *dst;
assert(src != NULL); assert(src != NULL);
dst = (filestruct *)nmalloc(sizeof(filestruct));
dst->data = mallocstrcpy(NULL, src->data); dst->data = mallocstrcpy(NULL, src->data);
dst->next = src->next; dst->next = src->next;
dst->prev = src->prev; dst->prev = src->prev;
dst->lineno = src->lineno; dst->lineno = src->lineno;
return dst; return dst;
} }
@ -568,6 +575,7 @@ void splice_node(filestruct *begin, filestruct *newnode, filestruct
*end) *end)
{ {
assert(newnode != NULL && begin != NULL); assert(newnode != NULL && begin != NULL);
newnode->next = end; newnode->next = end;
newnode->prev = begin; newnode->prev = begin;
begin->next = newnode; begin->next = newnode;
@ -579,6 +587,7 @@ void splice_node(filestruct *begin, filestruct *newnode, filestruct
void unlink_node(const filestruct *fileptr) void unlink_node(const filestruct *fileptr)
{ {
assert(fileptr != NULL); assert(fileptr != NULL);
if (fileptr->prev != NULL) if (fileptr->prev != NULL)
fileptr->prev->next = fileptr->next; fileptr->prev->next = fileptr->next;
if (fileptr->next != NULL) if (fileptr->next != NULL)
@ -589,6 +598,7 @@ void unlink_node(const filestruct *fileptr)
void delete_node(filestruct *fileptr) void delete_node(filestruct *fileptr)
{ {
assert(fileptr != NULL && fileptr->data != NULL); assert(fileptr != NULL && fileptr->data != NULL);
if (fileptr->data != NULL) if (fileptr->data != NULL)
free(fileptr->data); free(fileptr->data);
free(fileptr); free(fileptr);
@ -636,6 +646,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x) filestruct *bot, size_t bot_x)
{ {
partition *p; partition *p;
assert(top != NULL && bot != NULL && fileage != NULL && filebot != NULL); assert(top != NULL && bot != NULL && fileage != NULL && filebot != NULL);
/* Initialize the partition. */ /* Initialize the partition. */
@ -687,6 +698,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
void unpartition_filestruct(partition **p) void unpartition_filestruct(partition **p)
{ {
char *tmp; char *tmp;
assert(p != NULL && fileage != NULL && filebot != NULL); assert(p != NULL && fileage != NULL && filebot != NULL);
/* Reattach the line above the top of the partition, and restore the /* Reattach the line above the top of the partition, and restore the
@ -895,6 +907,7 @@ void renumber_all(void)
int i = 1; int i = 1;
assert(fileage == NULL || fileage != fileage->next); assert(fileage == NULL || fileage != fileage->next);
for (temp = fileage; temp != NULL; temp = temp->next) for (temp = fileage; temp != NULL; temp = temp->next)
temp->lineno = i++; temp->lineno = i++;
} }
@ -907,6 +920,7 @@ void renumber(filestruct *fileptr)
int lineno = fileptr->prev->lineno; int lineno = fileptr->prev->lineno;
assert(fileptr != fileptr->next); assert(fileptr != fileptr->next);
for (; fileptr != NULL; fileptr = fileptr->next) for (; fileptr != NULL; fileptr = fileptr->next)
fileptr->lineno = ++lineno; fileptr->lineno = ++lineno;
} }
@ -1222,8 +1236,7 @@ void do_delete(void)
/* Do we have to call edit_refresh(), or can we get away with /* Do we have to call edit_refresh(), or can we get away with
* update_line()? */ * update_line()? */
assert(current != NULL && current->data != NULL && assert(current != NULL && current->data != NULL && current_x <= strlen(current->data));
current_x <= strlen(current->data));
placewewant = xplustabs(); placewewant = xplustabs();
@ -1320,15 +1333,16 @@ void do_enter(void)
extra = indent_length(current->data); extra = indent_length(current->data);
if (extra > current_x) if (extra > current_x)
extra = current_x; extra = current_x;
totsize += extra;
} }
#endif #endif
newnode->data = charalloc(strlen(current->data + current_x) + newnode->data = charalloc(strlen(current->data + current_x) +
extra + 1); extra + 1);
strcpy(&newnode->data[extra], current->data + current_x); strcpy(&newnode->data[extra], current->data + current_x);
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(AUTOINDENT)) if (ISSET(AUTOINDENT)) {
strncpy(newnode->data, current->data, extra); strncpy(newnode->data, current->data, extra);
totsize += mbstrlen(newnode->data);
}
#endif #endif
null_at(&current->data, current_x); null_at(&current->data, current_x);
#ifndef NANO_SMALL #ifndef NANO_SMALL
@ -1669,6 +1683,7 @@ bool do_wrap(filestruct *inptr)
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
strncpy(newline, indentation, indent_len); strncpy(newline, indentation, indent_len);
newline[indent_len] = '\0'; newline[indent_len] = '\0';
totsize += mbstrlen(newline);
new_line_len = indent_len; new_line_len = indent_len;
} }
#endif #endif
@ -1694,11 +1709,6 @@ bool do_wrap(filestruct *inptr)
} else { } else {
filestruct *temp = (filestruct *)nmalloc(sizeof(filestruct)); filestruct *temp = (filestruct *)nmalloc(sizeof(filestruct));
/* In this case, the file size changes by +1 for the new line,
* and +indent_len for the new indentation. */
#ifndef NANO_SMALL
totsize += indent_len;
#endif
totlines++; totlines++;
temp->data = newline; temp->data = newline;
temp->prev = inptr; temp->prev = inptr;
@ -2839,6 +2849,7 @@ bool do_para_search(size_t *const quote, size_t *const par)
/* Save the values of quote_len and par_len. */ /* Save the values of quote_len and par_len. */
assert(quote != NULL && par != NULL); assert(quote != NULL && par != NULL);
*quote = quote_len; *quote = quote_len;
*par = par_len; *par = par_len;
@ -2976,8 +2987,10 @@ void do_justify(bool full_justify)
indent_len); indent_len);
strcpy(current->next->data + indent_len, strcpy(current->next->data + indent_len,
current->data + break_pos + 1); current->data + break_pos + 1);
assert(strlen(current->next->data) == assert(strlen(current->next->data) ==
indent_len + line_len - break_pos - 1); indent_len + line_len - break_pos - 1);
totlines++; totlines++;
totsize += indent_len; totsize += indent_len;
par_len++; par_len++;
@ -4386,5 +4399,6 @@ int main(int argc, char **argv)
do_input(&meta_key, &func_key, &s_or_t, &ran_func, &finished, do_input(&meta_key, &func_key, &s_or_t, &ran_func, &finished,
TRUE); TRUE);
} }
assert(FALSE); assert(FALSE);
} }