Ver código fonte

Fix help messages when the current argument is last unfinished optional arg.

git-svn-id: https://klish.googlecode.com/svn/trunk@399 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 anos atrás
pai
commit
ea071416f6
2 arquivos alterados com 8 adições e 2 exclusões
  1. 1 1
      clish/command/command.c
  2. 7 1
      clish/pargv/pargv.c

+ 1 - 1
clish/command/command.c

@@ -250,7 +250,7 @@ int clish_command_help(const clish_command_t * this, help_argv_t *help,
 			clen = strlen(name);
 		if (clen > longest)
 			longest = clen;
-		clish_param_help(clish_pargv__get_param(last, i), help);
+		clish_param_help(param, help);
 	}
 	clish_pargv_delete(last);
 	lub_argv_delete(argv);

+ 7 - 1
clish/pargv/pargv.c

@@ -185,7 +185,7 @@ clish_pargv_status_t clish_pargv_parse(clish_pargv_t * this,
 		}
 
 		/* Set parameter value */
-		if (NULL != param) {
+		if (param) {
 			char *validated = NULL;
 			clish_paramv_t *rec_paramv =
 			    clish_param__get_paramv(param);
@@ -244,6 +244,12 @@ clish_pargv_status_t clish_pargv_parse(clish_pargv_t * this,
 				lub_string_free(validated);
 
 				/* Next command line argument */
+				/* Don't change idx if this is the last
+				   unfinished optional argument.
+				 */
+				if (!(clish_param__get_optional(param) &&
+					(*idx == need_index) &&
+					(need_index == (argc - 1))))
 				(*idx)++;
 
 				/* Walk through the nested parameters */