Browse Source

Use str_move() where possible.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 7 years ago
parent
commit
2a973f7a46
3 changed files with 4 additions and 8 deletions
  1. 1 3
      lib/widget/input.c
  2. 1 4
      lib/widget/input_complete.c
  3. 2 1
      src/vfs/ftpfs/ftpfs.c

+ 1 - 3
lib/widget/input.c

@@ -155,14 +155,12 @@ delete_region (WInput * in, int x_first, int x_last)
 {
     int first = MIN (x_first, x_last);
     int last = MAX (x_first, x_last);
-    size_t len;
 
     input_mark_cmd (in, FALSE);
     in->point = first;
     last = str_offset_to_pos (in->buffer, last);
     first = str_offset_to_pos (in->buffer, first);
-    len = strlen (&in->buffer[last]) + 1;
-    memmove (&in->buffer[first], &in->buffer[last], len);
+    str_move (in->buffer + first, in->buffer + last);
     in->charpoint = 0;
     in->need_push = TRUE;
 }

+ 1 - 4
lib/widget/input_complete.c

@@ -887,11 +887,8 @@ try_complete_find_start_sign (try_complete_automation_state_t * state)
         /* don't substitute variable in \$ case */
         if (strutils_is_char_escaped (state->word, state->q))
         {
-            size_t qlen;
-
-            qlen = strlen (state->q);
             /* drop '\\' */
-            memmove (state->q - 1, state->q, qlen + 1);
+            str_move (state->q - 1, state->q);
             /* adjust flags */
             state->flags &= ~INPUT_COMPLETE_VARIABLES;
             state->q = NULL;

+ 2 - 1
src/vfs/ftpfs/ftpfs.c

@@ -96,6 +96,7 @@ What to do with this?
 
 #include "lib/global.h"
 #include "lib/util.h"
+#include "lib/strutil.h"        /* str_move() */
 #include "lib/mcconfig.h"
 
 #include "lib/tty/tty.h"        /* enable/disable interrupt key */
@@ -327,7 +328,7 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha
         /* replace first occurrence of ":/" with ":" */
         p = strchr (ret, ':');
         if (p != NULL && IS_PATH_SEP (p[1]))
-            memmove (p + 1, p + 2, strlen (p + 2) + 1);
+            str_move (p + 1, p + 2);
 
         /* strip trailing "/." */
         p = strrchr (ret, PATH_SEP);