Repository: neovim/neovim
File: src/nvim/ex_docmd.c (C)

Code before:
        // zero means not set, one is verbose == 0, etc.
        cmod->cmod_verbose = atoi(eap->cmd) + 1;
      } else {
        cmod->cmod_verbose = 2;  // default: verbose == 1
      }
      eap->cmd = p;
      continue;
    }
    break;
  }

  if (has_visual_range) {
    if (eap->cmd > cmd_start) {
      // Move the '<,'> range to after the modifiers and insert a colon.
      // Since the modifiers have been parsed put the colon on top of the
      // space: "'<,'>mod cmd" -> "mod:'<,'>cmd
      // Put eap->cmd after the colon.
      if (use_plus_cmd) {
        size_t len = strlen(cmd_start);

        // Special case: empty command uses "+":
        //  "'<,'>mods" -> "mods *+
        //  Use "*" instead of "'<,'>" to avoid the command getting
        //  longer, in case is was allocated.
        memmove(orig_cmd, cmd_start, len);
        xmemcpyz(orig_cmd + len, " *+", 3);
      } else {
        memmove(cmd_start - 5, cmd_start, (size_t)(eap->cmd - cmd_start));
        eap->cmd -= 5;
        memmove(eap->cmd - 1, ":'<,'>", 6);
      }
    } else {
      // No modifiers, move the pointer back.
      // Special case: change empty command to "+".
      if (use_plus_cmd) {
        eap->cmd = "'<,'>+";
      } else {
        eap->cmd = orig_cmd;
      }
    }
  } else if (use_plus_cmd) {
    eap->cmd = exmode_plus;
  }

  return OK;
}

/// Apply the command modifiers.  Saves current state in "cmdmod", call
/// undo_cmdmod() later.
void apply_cmdmod(cmdmod_T *cmod)
{

Review comment (bug):
memcpy should suffice here but wasn't sure if it should `NUL` terminate. Thought a test would crash due to early termination.
Maybe porting a Vim test to Lua screen would crash?

Code after:
        // zero means not set, one is verbose == 0, etc.
        cmod->cmod_verbose = atoi(eap->cmd) + 1;
      } else {
        cmod->cmod_verbose = 2;  // default: verbose == 1
      }
      eap->cmd = p;
      continue;
    }
    break;
  }

  if (has_visual_range) {
    if (eap->cmd > cmd_start) {
      // Move the '<,'> range to after the modifiers and insert a colon.
      // Since the modifiers have been parsed put the colon on top of the
      // space: "'<,'>mod cmd" -> "mod:'<,'>cmd
      // Put eap->cmd after the colon.
      if (use_plus_cmd) {
        size_t len = strlen(cmd_start);

        // Special case: empty command uses "+":
        //  "'<,'>mods" -> "mods *+
        //  Use "*" instead of "'<,'>" to avoid the command getting
        //  longer, in case is was allocated.
        memmove(orig_cmd, cmd_start, len);
        xmemcpyz(orig_cmd + len, S_LEN(" *+"));
      } else {
        memmove(cmd_start - 5, cmd_start, (size_t)(eap->cmd - cmd_start));
        eap->cmd -= 5;
        memmove(eap->cmd - 1, ":'<,'>", 6);
      }
    } else {
      // No modifiers, move the pointer back.
      // Special case: change empty command to "+".
      if (use_plus_cmd) {
        eap->cmd = "'<,'>+";
      } else {
        eap->cmd = orig_cmd;
      }
    }
  } else if (use_plus_cmd) {
    eap->cmd = exmode_plus;
  }

  return OK;
}

/// Apply the command modifiers.  Saves current state in "cmdmod", call
/// undo_cmdmod() later.
void apply_cmdmod(cmdmod_T *cmod)
{