1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvm: move hyphen mangling code

Relocate hyphen code from lvm main into lvm_run_command()
so all command and library user will have it.

Update WHATS_NEW with missing changes.
This commit is contained in:
Zdenek Kabelac 2015-06-19 09:44:14 +02:00
parent 438a65dfdb
commit 3173442984
3 changed files with 25 additions and 25 deletions

View File

@ -5,6 +5,8 @@ Version 2.02.122 -
Allow to extend reduced thin volumes with external origins.
Consider snapshot and origin LV as unusable if its component is suspended.
Fix lvmconfig segfault on settings with undefined default value (2.02.120).
Add explicit 's' (shared) activation mode.
Ignore hyphens in long options names (i.e. --long-option == --longoption).
Version 2.02.121 - 12th June 2015
=================================

View File

@ -16,33 +16,8 @@
#include "tools.h"
#include "lvm2cmdline.h"
#define MAX_ARG_LEN 64
int main(int argc, char **argv)
{
char arg_new[MAX_ARG_LEN];
char *arg;
int i, j, j_new;
for (i = 1; i < argc; i++) {
arg = argv[i];
if (arg[0] == '-' && arg[1] == '-' && strlen(arg) < MAX_ARG_LEN) {
memset(arg_new, 0, sizeof(arg_new));
arg_new[0] = '-';
arg_new[1] = '-';
for (j = 2, j_new = 2; j < strlen(arg) + 1; j++) {
if (arg[j] == '-')
continue;
arg_new[j_new] = arg[j];
j_new++;
}
memcpy(argv[i], arg_new, strlen(arg_new) + 1);
}
}
return lvm2_main(argc, argv);
}

View File

@ -1414,12 +1414,35 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
int ret = 0;
int locking_type;
int monitoring;
char *arg_new, *arg;
int i;
init_error_message_produced(0);
/* each command should start out with sigint flag cleared */
sigint_clear();
/* eliminate '-' from all options starting with -- */
for (i = 1; i < argc; ++i) {
if (argv[i][0] != '-' || argv[i][1] != '-')
continue;
arg_new = arg = argv[i] + 2;
while (*arg) {
if (*arg != '-') {
if (arg_new != arg)
*arg_new = *arg;
++arg_new;
}
++arg;
}
if (arg_new != arg)
*arg_new = 0;
}
if (!(cmd->cmd_line = _copy_command_line(cmd, argc, argv)))
return_ECMD_FAILED;