PERFORCE change 131828 for review
Garrett Cooper
gcooper at FreeBSD.org
Thu Dec 27 17:01:18 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=131828
Change 131828 by gcooper at shiina-ibook on 2007/12/28 01:00:49
1.
a. [from getopt(3)]: Var is called optind, not optidx.
b. Change other variable to be consistent.
2. Yank out init_action(..) and put into pkg_action.c
Affected files ...
.. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/pkgman/main.c#3 edit
Differences ...
==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/pkgman/main.c#3 (text+ko) ====
@@ -53,12 +53,12 @@
char opt_char;
- int old_optidx;
- int optional_opts_idx;
+ int old_optind;
+ int optional_opts_ind;
int i;
/** Preset the initial counter variables to 0. **/
- old_optidx = optional_opts_idx = 0;
+ old_optind = optional_opts_ind = 0;
/** Don't error out on unknown / non-globally applied flags, yet.. **/
opterr = 0;
@@ -119,12 +119,12 @@
* Copy down all char* pointers to optional_opt_str_p to parse
* later on [in pkg_action_arg_parser->parse_args(..)]..
*/
- for (i = old_optidx; i < optidx; i++) {
- (optional_opt_str_p+optional_opts_idx) = (argv+i);
- optional_opts_idx++;
+ for (i = old_optind; i < optind; i++) {
+ (optional_opt_str_p+optional_opts_ind) = (argv+i);
+ optional_opts_ind++;
}
- old_optidx = optidx;
+ old_optind = optind;
}
/** End global args parse **/
@@ -139,8 +139,8 @@
* If arguments usage was invalid, print usage message for specific command
* and exit..
*/
- if (0 < parsers[action_type]->parse_args(optional_opts_idx+1, optional_opt_str_p)) {
- action->print_use();
+ if (0 < parsers[action_type]->parse_args(optional_opts_ind+1, optional_opt_str_p)) {
+ parsers[action_type]->print_use();
exit(1);
}
@@ -163,42 +163,3 @@
return action_result;
}
-
-/**
- * @brief Initialize the appropriate action as per the action_type provided.
- * @return Object for respective constructor.
- * @return NULL on bad action_type.
- */
-pkg_action
-init_action(int action_type, freebsd_pkg *fpkg)
-{
-
- switch (action_type) {
-
- case add:
- return pkg_action_add_new(fpkg);
- case clean:
- return pkg_action_clean_new(fpkg);
- case check:
- return pkg_action_check_new(fpkg);
- case create:
- return pkg_action_create_new(fpkg);
- case delete:
- return pkg_action_delete_new(fpkg);
- case info:
- return pkg_action_info_new(fpkg);
- case null:
- return pkg_action_new(fpkg);
- case search:
- return pkg_action_search_new(fpkg);
- case sign:
- return pkg_action_sign_new(fpkg);
- case update:
- return pkg_action_update_new(fpkg);
- case version:
- return pkg_action_version_new(fpkg);
-
- }
-
- return NULL;
-}
More information about the p4-projects
mailing list