all our memmove() function calls work on char*'s, so we can use the

charmove() macro for them instead


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1554 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2003-09-16 02:04:00 +00:00
parent da8fd8f894
commit 9eff7465d9
4 changed files with 13 additions and 11 deletions

View File

@ -52,6 +52,8 @@ CVS code -
for a backwards search in the refactored code, and enclose for a backwards search in the refactored code, and enclose
dump_buffer() and dump_buffer_reverse() in one ENABLE_DEBUG dump_buffer() and dump_buffer_reverse() in one ENABLE_DEBUG
#ifdef instead of two. #ifdef instead of two.
- Convert memmove() function calls to charmove() macro calls, as
the former all work on char*'s. (DLR)
- files.c: - files.c:
do_browser() do_browser()
- Some of the Pico compatibility options in the file browser - Some of the Pico compatibility options in the file browser

View File

@ -117,7 +117,7 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
/* Make the first cut line manually. */ /* Make the first cut line manually. */
tmp = copy_node(top); tmp = copy_node(top);
newsize = (top == bot ? bot_x - top_x : strlen(top->data + top_x)); newsize = (top == bot ? bot_x - top_x : strlen(top->data + top_x));
memmove(tmp->data, top->data + top_x, newsize); charmove(tmp->data, top->data + top_x, newsize);
null_at(&tmp->data, newsize); null_at(&tmp->data, newsize);
add_to_cutbuffer(tmp); add_to_cutbuffer(tmp);
@ -131,7 +131,7 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
if (top == bot) { if (top == bot) {
/* In this case, the remainder line is shorter, so we must /* In this case, the remainder line is shorter, so we must
move text from the end forward first. */ move text from the end forward first. */
memmove(top->data + top_x, bot->data + bot_x, charmove(top->data + top_x, bot->data + bot_x,
newsize - top_x); newsize - top_x);
top->data = charealloc(top->data, newsize); top->data = charealloc(top->data, newsize);
} else { } else {
@ -140,7 +140,7 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
/* Here, the remainder line might get longer, so we /* Here, the remainder line might get longer, so we
realloc() it first. */ realloc() it first. */
top->data = charealloc(top->data, newsize); top->data = charealloc(top->data, newsize);
memmove(top->data + top_x, bot->data + bot_x, charmove(top->data + top_x, bot->data + bot_x,
newsize - top_x); newsize - top_x);
} }
} }
@ -364,7 +364,7 @@ int do_uncut_text(void)
size_t cur_len = strlen(current->data); size_t cur_len = strlen(current->data);
current->data = charealloc(current->data, cur_len + buf_len + 1); current->data = charealloc(current->data, cur_len + buf_len + 1);
memmove(current->data + current_x + buf_len, charmove(current->data + current_x + buf_len,
current->data + current_x, cur_len - current_x + 1); current->data + current_x, cur_len - current_x + 1);
strncpy(current->data + current_x, cutbuffer->data, buf_len); strncpy(current->data + current_x, cutbuffer->data, buf_len);
/* Use strncpy() to not copy the terminal '\0'. */ /* Use strncpy() to not copy the terminal '\0'. */

View File

@ -990,7 +990,7 @@ void do_char(char ch)
/* more dangerousness fun =) */ /* more dangerousness fun =) */
current->data = charealloc(current->data, current_len + 2); current->data = charealloc(current->data, current_len + 2);
assert(current_x <= current_len); assert(current_x <= current_len);
memmove(&current->data[current_x + 1], charmove(&current->data[current_x + 1],
&current->data[current_x], &current->data[current_x],
current_len - current_x + 1); current_len - current_x + 1);
current->data[current_x] = ch; current->data[current_x] = ch;
@ -1043,7 +1043,7 @@ int do_delete(void)
if (current_x != strlen(current->data)) { if (current_x != strlen(current->data)) {
/* Let's get dangerous */ /* Let's get dangerous */
memmove(&current->data[current_x], &current->data[current_x + 1], charmove(&current->data[current_x], &current->data[current_x + 1],
strlen(current->data) - current_x); strlen(current->data) - current_x);
align(&current->data); align(&current->data);
@ -2463,7 +2463,7 @@ int do_para_operation(int operation)
current->next->data = charealloc(current->next->data, current->next->data = charealloc(current->next->data,
next_line_len + line_len - break_pos + 1); next_line_len + line_len - break_pos + 1);
memmove(current->next->data + indent_len + line_len - break_pos, charmove(current->next->data + indent_len + line_len - break_pos,
current->next->data + indent_len, current->next->data + indent_len,
next_line_len - indent_len + 1); next_line_len - indent_len + 1);
strcpy(current->next->data + indent_len, strcpy(current->next->data + indent_len,
@ -2537,7 +2537,7 @@ int do_para_operation(int operation)
totsize -= indent_len; totsize -= indent_len;
current_y--; current_y--;
} else { } else {
memmove(current->next->data + indent_len, charmove(current->next->data + indent_len,
current->next->data + indent_len + break_pos + 1, current->next->data + indent_len + break_pos + 1,
next_line_len - break_pos - indent_len); next_line_len - break_pos - indent_len);
null_at(&current->next->data, null_at(&current->next->data,

View File

@ -635,7 +635,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
break; break;
case NANO_DELETE_KEY: case NANO_DELETE_KEY:
if (x < xend) { if (x < xend) {
memmove(answer + x, answer + x + 1, xend - x); charmove(answer + x, answer + x + 1, xend - x);
xend--; xend--;
} }
break; break;
@ -647,7 +647,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
break; break;
case NANO_BACKSPACE_KEY: case NANO_BACKSPACE_KEY:
if (x > 0) { if (x > 0) {
memmove(answer + x - 1, answer + x, xend - x + 1); charmove(answer + x - 1, answer + x, xend - x + 1);
x--; x--;
xend--; xend--;
} }
@ -791,7 +791,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
if (kbinput < 32 || kbinput == 127) if (kbinput < 32 || kbinput == 127)
break; break;
answer = charealloc(answer, xend + 2); answer = charealloc(answer, xend + 2);
memmove(answer + x + 1, answer + x, xend - x + 1); charmove(answer + x + 1, answer + x, xend - x + 1);
xend++; xend++;
answer[x] = kbinput; answer[x] = kbinput;
x++; x++;