Date: Mon, 14 Jan 2008 04:29:47 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 133217 for review Message-ID: <200801140429.m0E4TlaE018386@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=133217 Change 133217 by gcooper@shiina-ibook on 2008/01/14 04:29:00 Yanking out arg-parsing code; will yank out stage code sometime within the next couple weeks.. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_add/main.c#4 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_delete/main.c#4 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/main.c#4 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/match.c#3 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/pkg_info.h#3 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/show.c#3 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_sign/main.c#4 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_version/main.c#4 edit Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_add/main.c#4 (text+ko) ==== @@ -77,59 +77,6 @@ add.chroot[0] = '\0'; add.base_prefix = NULL; add.prefix = NULL; - while ((ch = getopt(argc, argv, options)) != -1) { - switch(ch) { - case 'C': - strlcpy(add.chroot, optarg, PATH_MAX); - break; - case 'f': - add.flags |= force_flag; - break; - case 'I': - add.flags |= no_run_script_flag; - break; - case 'K': - /* Save the package file in . or ${PKGDIR} */ - add.flags |= keep_file_flag; - break; - case 'M': - errx(1, "Unsupported argument"); - break; - case 'n': - add.flags |= no_run_flag; - break; - case 'P': - add.base_prefix = optarg; - add.prefix = optarg; - break; - case 'p': - add.base_prefix = optarg; - add.prefix = NULL; - break; - case 'R': - add.flags |= no_record_install_flag; - break; - case 'r': - remote = 1; - break; - case 'S': - errx(1, "Unsupported argument"); - break; - case 't': - errx(1, "The -t argument is unneeded as the staging area is unused"); - break; - case 'v': - add.flags |= verbosity_flag; - break; - case 'h': - case '?': - default: - usage(); - break; - } - } - argc -= optind; - argv += optind; /* * Get package from remote source. ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_delete/main.c#4 (text+ko) ==== @@ -65,54 +65,8 @@ delete.flags = 0; delete.match_type = PKG_DB_MATCH_GLOB; delete.prefix = NULL; - while ((ch = getopt(argc, argv, options)) != -1) { - switch(ch) { - case 'a': - delete.match_type = PKG_DB_MATCH_ALL; - break; - case 'd': - delete.flags |= remove_empty_dirs_flag; - break; - case 'D': - delete.flags |= no_run_script_flag; - break; - case 'f': - delete.flags |= force_flag; - break; - case 'G': - delete.match_type = PKG_DB_MATCH_EXACT; - break; - case 'i': - delete.flags |= interactive_flag; - break; - case 'n': - delete.flags |= no_run_flag; - break; - case 'p': - delete.prefix = optarg; - errx(1, "Unsupported argument"); - break; - case 'r': - delete.flags |= recursive_flag; - break; - case 'v': - delete.flags |= verbosity_flag; - break; - case 'x': - delete.match_type = PKG_DB_MATCH_REGEX; - break; - case 'X': - delete.match_type = PKG_DB_MATCH_EREGEX; - break; - case 'h': - case '?': - default: - usage(); - break; - } - } - argc -= optind; - argv += optind; + + /** Parse args here **/ if (delete.db == NULL) { delete.db = pkg_db_open_freebsd("/"); ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/main.c#4 (text+ko) ==== @@ -64,130 +64,15 @@ info.match_type = MATCH_ALL; info.flags = SHOW_INDEX; } else { - int ch; - int i; - while ((ch = getopt(argc, argv, options)) != -1) { - switch (ch) { - case 'a': - info.match_type = MATCH_ALL; - break; - case 'b': - info.use_blocksize = 1; - break; - case 'c': - info.flags |= SHOW_COMMENT; - break; - case 'd': - info.flags |= SHOW_DESC; - break; - case 'D': - info.flags |= SHOW_DISPLAY; - break; - case 'e': - info.check_package = optarg; - break; - case 'E': - info.flags |= SHOW_PKGNAME; - break; - case 'f': - info.flags |= SHOW_PLIST; - break; - case 'g': - info.flags |= SHOW_CKSUM; - break; - case 'G': - info.match_type = MATCH_EXACT; - break; - case 'i': - info.flags |= SHOW_INSTALL; - break; - case 'I': - info.flags |= SHOW_INDEX; - break; - case 'j': - info.flags |= SHOW_REQUIRE; - break; - case 'k': - info.flags |= SHOW_DEINSTALL; - break; - case 'l': - info.separator = optarg; - break; - case 'L': - info.flags |= SHOW_FILES; - break; - case 'm': - info.flags |= SHOW_MTREE; - break; - case 'o': - info.flags |= SHOW_ORIGIN; - break; - case 'O': - info.origin = optarg; - break; - case 'p': - info.flags |= SHOW_PREFIX; - break; - case 'P': - info.flags |= SHOW_PTREV; - break; - case 'q': - info.quiet = 1; - break; - case 'Q': - info.quiet = 2; - break; - case 'r': - info.flags |= SHOW_DEPEND; - break; - case 'R': - info.flags |= SHOW_REQBY; - break; - case 's': - info.flags |= SHOW_SIZE; - break; - case 't': - errx(1, "Unsupported argument"); - break; - case 'v': - info.flags = SHOW_COMMENT | SHOW_DESC | - SHOW_PLIST | SHOW_INSTALL | - SHOW_DEINSTALL | SHOW_REQUIRE | - SHOW_DISPLAY | SHOW_MTREE; - break; - case 'V': - info.flags |= SHOW_FMTREV; - break; - case 'W': - /* If package list is empty, create a new one */ - if (SLIST_EMPTY(&w_package_names)) { - /* Create the head of the slist */ - SLIST_HEAD(top_package, char *) - w_package_names = SLIST_HEAD_INITIALIZER(w_packages); - } - /* Insert found argument at head of list */ - SLIST_INSERT_HEAD(); - break; - case 'x': - info.match_type = MATCH_REGEX; - break; - case 'X': - info.match_type = MATCH_EREGEX; - break; - case 'h': - default: - usage(); - break; - } - } - argc -= optind; - argv += optind; + + /** Parse args **/ info.pkgs = malloc(sizeof(char *) * (argc + 1)); for (i=0; i < argc; i++) { info.pkgs[i] = argv[i]; } info.pkgs[i] = NULL; + } /* Set the default flags */ @@ -297,7 +182,7 @@ /* Sort the packages and display them */ if (pkgs == NULL) { - /* XXX Error message */ + errx("You must provide at least one package.."); return 1; } for (cur = 0; pkgs[cur] != NULL; cur++) ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/match.c#3 (text+ko) ==== ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/pkg_info.h#3 (text+ko) ==== ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_info/show.c#3 (text+ko) ==== ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_sign/main.c#4 (text+ko) ==== @@ -67,11 +67,7 @@ /* wrapper for the check_signature function (open file if needed) */ static int -check(filename, type, userid, envp) - /*@observer@*/const char *filename; - int type; - /*@null@*/const char *userid; - char *envp[]; +check(const char *filename, int type, const char *userid, char *envp[]) { int result; FILE *file; @@ -85,12 +81,10 @@ } result = check_signature(file, userid, envp, filename); if (fclose(file) == 0) { - if (result == PKG_BADSIG || result == PKG_SIGERROR) - return 0; - else + if (!(result == PKG_BADSIG || result == PKG_SIGERROR)) return 1; - } else - return 0; + } + return 0; } int @@ -124,48 +118,8 @@ mode = CHECK; #endif - while ((ch = getopt(argc, argv, "t:u:k:qscv")) != -1) { - switch(ch) { - case 't': - if (strcmp(optarg, "pgp") == 0) - type = TAG_PGP; - else if (strcmp(optarg, "sha1") == 0) - type = TAG_SHA1; - else if (strcmp(optarg, "x509") == 0) - type = TAG_X509; - else - usage(); - break; - case 'u': - userid = strdup(optarg); - break; - - case 'k': - userkey = optarg; - break; - - case 'q': - quiet = 1; - break; - -#ifndef CHECKER_ONLY - case 's': - mode = SIGN; - break; -#endif - case 'c': - mode = CHECK; - break; + /** Parse **/ - case 'v': - verbose = 1; - break; - default: - usage(); - } - } - argc -= optind; - argv += optind; if (argc == 0) { if (mode == CHECK) success &= check("-", 0, userid, envp); @@ -182,4 +136,5 @@ for (i = 0; i < argc; i++) success &= (mode == SIGN ? sign : check)(argv[i], type, userid, envp); exit(success == 1 ? EXIT_SUCCESS : EXIT_FAILURE); + } ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/trunk/tools/pkg_version/main.c#4 (text+ko) ==== @@ -68,69 +68,9 @@ cmp = pkg_version_match(argv[3], argv[2]); exit(cmp == 1 ? 0 : 1); } - else while ((ch = getopt(argc, argv, options)) != -1) { - switch(ch) { - case 'v': - Verbose++; - break; - /* - * Use /usr/ports/INDEX* instead of the Makefiles for version - * comparison bases. - */ - case 'I': - version.flags |= VERSION_USE_INDEX_ONLY; - break; - - /* Look only for the specified installed statuses */ - case 'l': - LimitChars = optarg; - break; - - /* Avoid looking for package installed statuses */ - case 'L': - PreventChars = optarg; - break; - - case 'q': - version.flags |= QUIET; - break; - - case 's': - MatchName = optarg; - break; + /**Else parse**/ - case 'O': - LookUpOrigin = optarg; - break; - - case 'o': - version.flags |= VERSION_SHOW_PKG_ORIGIN; - break; - - case 't': - errx(2, "Invalid -t usage."); - break; - - case 'T': - errx(2, "Invalid -T usage."); - break; - - case 'X': - version.match_type = MATCH_EREGEX; - break; - - case 'h': - case '?': - default: - usage(); - break; - } - } - - argc -= optind; - argv += optind; - return pkg_version(version); } @@ -141,5 +81,4 @@ "usage: pkg_version [-hIoqv] [-l limchar] [-L limchar] [[-X] -s string] [-O origin] [index]", " pkg_version -t v1 v2", " pkg_version -T name pattern"); - exit(1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801140429.m0E4TlaE018386>