aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-02-23 17:32:19 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-02-26 20:53:23 +0000
commit07d7603b458db6a2a818532661e931093906ac2b (patch)
tree40722146b0d1b610b1708109ce876b90700c1fe0
parent1a9b58fcb2264c942ea56691fd3ad1228ee1fcb0 (diff)
tool: Reworked argument parsing to use --next/-:
Follow up to commit 1a9b58fcb2 to replace the : command line option with --next and -:.
-rw-r--r--src/tool_getparam.c54
-rw-r--r--tests/data/test8152
-rw-r--r--tests/data/test8162
3 files changed, 29 insertions, 29 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index a1033e8b3..e4cc69dd1 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -1814,32 +1814,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
orig_opt = argv[i];
- if(curlx_strequal(":", argv[i]) &&
- (operation->url_list && operation->url_list->url)) {
-
- /* Allocate the next config */
- operation->next = malloc(sizeof(struct OperationConfig));
- if(operation->next) {
- /* Initialise the newly created config */
- config_init(operation->next);
-
- /* Copy the easy handle */
- operation->next->easy = config->easy;
-
- /* Update the last operation pointer */
- config->last = operation->next;
-
- /* Move onto the new config */
- operation->next->prev = operation;
- operation = operation->next;
-
- /* Reset the flag indicator */
- stillflags = TRUE;
- }
- else
- result = PARAM_NO_MEM;
- }
- else if(stillflags && ('-' == argv[i][0])) {
+ if(stillflags && ('-' == argv[i][0])) {
char *nextarg;
bool passarg;
char *flag = argv[i];
@@ -1852,7 +1827,32 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
result = getparameter(flag, nextarg, &passarg, config, operation);
- if(!result && passarg)
+ if(result == PARAM_NEXT_OPERATION) {
+ if(operation->url_list && operation->url_list->url) {
+ /* Allocate the next config */
+ operation->next = malloc(sizeof(struct OperationConfig));
+ if(operation->next) {
+ /* Initialise the newly created config */
+ config_init(operation->next);
+
+ /* Copy the easy handle */
+ operation->next->easy = config->easy;
+
+ /* Update the last operation pointer */
+ config->last = operation->next;
+
+ /* Move onto the new config */
+ operation->next->prev = operation;
+ operation = operation->next;
+ }
+ else
+ result = PARAM_NO_MEM;
+ }
+
+ /* Reset result to continue */
+ result = PARAM_OK;
+ }
+ else if(!result && passarg)
i++; /* we're supposed to skip this */
}
}
diff --git a/tests/data/test815 b/tests/data/test815
index aa9a883d1..c006c6dd6 100644
--- a/tests/data/test815
+++ b/tests/data/test815
@@ -26,7 +26,7 @@ imap
IMAP STORE - delete message (CUSTOMREQUEST)
</name>
<command>
-imap://%HOSTIP:%IMAPPORT/815 -X 'STORE 123 +Flags \Deleted' -u user:secret : imap://%HOSTIP:%IMAPPORT/815 -X CLOSE
+imap://%HOSTIP:%IMAPPORT/815 -X 'STORE 123 +Flags \Deleted' -u user:secret -: imap://%HOSTIP:%IMAPPORT/815 -X CLOSE
</command>
</client>
diff --git a/tests/data/test816 b/tests/data/test816
index d44c5e168..386f87746 100644
--- a/tests/data/test816
+++ b/tests/data/test816
@@ -29,7 +29,7 @@ imap
IMAP STORE - delete message with confirmation (CUSTOMREQUEST)
</name>
<command>
-imap://%HOSTIP:%IMAPPORT/816 -X 'STORE 123 +Flags \Deleted' -u user:secret : imap://%HOSTIP:%IMAPPORT/816 -X EXPUNGE
+imap://%HOSTIP:%IMAPPORT/816 -X 'STORE 123 +Flags \Deleted' -u user:secret -: imap://%HOSTIP:%IMAPPORT/816 -X EXPUNGE
</command>
</client>