diff options
author | Ned Ludd <solar@gentoo.org> | 2005-07-18 00:29:50 +0000 |
---|---|---|
committer | Ned Ludd <solar@gentoo.org> | 2005-07-18 00:29:50 +0000 |
commit | 49210ddd3717bdf8505d5c4900c26d2a8f46ea75 (patch) | |
tree | 8e0affd0f7477d2a0c5fcb734085581e1da1d4ed | |
parent | - improve the human readable format handling a little more by making the fiel... (diff) | |
download | portage-utils-49210ddd3717bdf8505d5c4900c26d2a8f46ea75.tar.gz portage-utils-49210ddd3717bdf8505d5c4900c26d2a8f46ea75.tar.bz2 portage-utils-49210ddd3717bdf8505d5c4900c26d2a8f46ea75.zip |
main.c
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | main.c | 16 | ||||
-rwxr-xr-x | man/mkman.sh | 9 | ||||
-rw-r--r-- | man/q.1 | 47 | ||||
-rw-r--r-- | man/qcheck.1 | 18 | ||||
-rw-r--r-- | man/qdepends.1 | 15 | ||||
-rw-r--r-- | man/qfile.1 | 18 | ||||
-rw-r--r-- | man/qlist.1 | 18 | ||||
-rw-r--r-- | man/qsearch.1 | 25 | ||||
-rw-r--r-- | man/qsize.1 | 15 | ||||
-rw-r--r-- | man/quse.1 | 25 | ||||
-rw-r--r-- | quse.c | 96 |
12 files changed, 193 insertions, 115 deletions
@@ -19,6 +19,6 @@ incr LAST_APPLET. Scroll down the typedef for applets[] and add your applet name following the existing syntax. Please try to keep applet names under 8 chars. -When and where you can please try to use an existing applets and extend -on it's functionality by adding more options vs adding a ton of new -applets. +When and where you can please try to use an existing applet and extend +on it's functionality by adding more options vs adding a bunch of new +little applets. @@ -1,7 +1,7 @@ /* * Copyright 2005 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.51 2005/07/16 17:54:03 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.52 2005/07/18 00:29:50 solar Exp $ * * 2005 Ned Ludd - <solar@gentoo.org> * 2005 Mike Frysinger - <vapier@gentoo.org> @@ -68,9 +68,9 @@ void reinitialize_as_needed(void); #define NORM COLOR("00", "00") #define BLUE COLOR("36", "01") #define DKBLUE COLOR("34", "01") -#define CYAN COLOR("36", "02") +#define CYAN COLOR("00", "36") #define GREEN COLOR("32", "01") -#define MAGENTA COLOR("35", "02") +#define MAGENTA COLOR("00", "35") #define RED COLOR("31", "01") #define YELLOW COLOR("33", "01") @@ -116,7 +116,7 @@ void init_coredumps(void) /* variables to control runtime behavior */ -static const char *rcsid = "$Id: main.c,v 1.51 2005/07/16 17:54:03 solar Exp $"; +static const char *rcsid = "$Id: main.c,v 1.52 2005/07/18 00:29:50 solar Exp $"; static char color = 1; static char exact = 0; @@ -179,16 +179,16 @@ static void usage(int status, const char *flags, struct option const opts[], DKBLUE, applets[blabber].opts, NORM, RED, NORM, applets[blabber].desc); } - printf("\n%sOptions:%s -[%s]\n", GREEN, NORM, flags); for (i = 0; opts[i].name; ++i) { assert(help[i] != NULL); /* this assert is a life saver when adding new applets. */ if (opts[i].has_arg == no_argument) printf(" -%c, --%-13s%s*%s %s\n", opts[i].val, - opts[i].name, RED, NORM, help[i]); + opts[i].name, RED, NORM, help[i]); else printf(" -%c, --%-6s %s<arg>%s %s*%s %s\n", opts[i].val, - opts[i].name, DKBLUE, NORM, RED, NORM, help[i]); + opts[i].name, DKBLUE, NORM, RED, NORM, help[i]); + } } exit(status); } @@ -197,7 +197,7 @@ static void version_barf(void) #ifndef VERSION # define VERSION "cvs" #endif - printf("portage-utils-%s: compiled %s\n%s\n" + printf("portage-utils-%s: compiled on %s\n%s\n" "%s written for Gentoo by <solar and vapier @ gentoo.org>\n", VERSION, __DATE__, rcsid, argv0); exit(EXIT_SUCCESS); diff --git a/man/mkman.sh b/man/mkman.sh index cbbaf807..b67929da 100755 --- a/man/mkman.sh +++ b/man/mkman.sh @@ -14,10 +14,13 @@ export NOCOLOR=1 -APPLETS=$(../q | grep ^' \* '| awk '{print $2}') +APPLETS=$(../q | grep -e ' : ' | awk '{print $1}' | grep ^q) for applet in $APPLETS; do help2man -N -S "Gentoo Foundation" -m ${applet} -s 1 -o ${applet}.1 "../q $applet" - sed -i -e s/'PORTAGE-UTILS-CVS:'/${applet}/g ${applet}.1 -e s/'portage-utils-cvs:'/${applet}/g ${applet}.1 - head -n $(($(cat ${applet}.1 | wc -l)-1)) ${applet}.1 > ${applet}.1~ && mv ${applet}.1~ ${applet}.1 + sed -i -e s/'PORTAGE-UTILS-CVS:'/${applet}/g \ + -e s/'portage-utils-cvs:'/${applet}/g \ + -e s/'> \*'/'>@\.BR@ \*'/g ${applet}.1 + head -n $(($(cat ${applet}.1 | wc -l)-1)) ${applet}.1 \ + | tr '@' '\n' > ${applet}.1~ && mv ${applet}.1~ ${applet}.1 done @@ -1,41 +1,54 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH q "1" "June 2005" "Gentoo Foundation" "q" +.TH q "1" "July 2005" "Gentoo Foundation" "q" .SH NAME -q \- manual page for q main.c compiled Jun 17 2005 +q \- manual page for q compiled on Jul 17 2005 .SH SYNOPSIS .B q \fI<applet> \fR[\fIarguments\fR]... .SH DESCRIPTION .SS "Currently defined applets:" +.IP +q <applet> <args> : virtual applet .TP -- q <applet> <args> -: virtual applet +qcheck <pkgname> +: verify mtimes/digests +.TP +qdepends <pkgname> +: show dependency info .TP -- qfile <filename> +qfile <filename> : list all pkgs owning files .TP -- qlist <pkgname> +qlist <pkgname> : list files owned by pkgname .TP -- qsearch <regex> -: search pkgname/desc +qlop <pkgname> +: emerge log analyzer .TP -- quse <useflag> -: find pkgs using useflag +qsearch <regex> +: search pkgname/desc .TP -- qsize <pkgname> +qsize <pkgname> : calculate size usage .TP -- qcheck <pkgname> -: verify mtimes/digests +qtbz2 <misc args> +: manipulate tbz2 packages .TP -- qdepends <pkgname> -: show dependency info +quse <useflag> +: find pkgs using useflags +.TP +qxpak <misc args> +: manipulate xpak archives .PP -Options: \fB\-[iChV]\fR +Options: \fB\-[irvChV]\fR .TP \fB\-i\fR, \fB\-\-install\fR * Install symlinks for applets +.HP +\fB\-r\fR, \fB\-\-reinitialize\fR * Reinitialize ebuild cache +.TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise .TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color @@ -46,4 +59,4 @@ Options: \fB\-[iChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: q.1,v 1.3 2005/06/17 15:59:17 solar Exp $ +$Id: q.1,v 1.4 2005/07/18 00:29:50 solar Exp $ diff --git a/man/qcheck.1 b/man/qcheck.1 index 57376c1e..8bc736f8 100644 --- a/man/qcheck.1 +++ b/man/qcheck.1 @@ -1,18 +1,22 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH qcheck "1" "June 2005" "Gentoo Foundation" "qcheck" +.TH qcheck "1" "July 2005" "Gentoo Foundation" "qcheck" .SH NAME -qcheck \- manual page for qcheck main.c compiled Jun 17 2005 +qcheck \- manual page for qcheck compiled on Jul 17 2005 .SH SYNOPSIS .B qcheck -\fI<pkgname>\fR +\fI<pkgname> : verify mtimes/digests\fR .SH DESCRIPTION -* qcheck: verify mtimes/digests -.PP -Options: \fB\-[aChV]\fR +Options: \fB\-[ar\fR:vChV] .TP \fB\-a\fR, \fB\-\-all\fR * List all packages .TP +\fB\-r\fR, \fB\-\-root\fR +* Chroot before package verification +.TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise +.TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color .TP @@ -22,4 +26,4 @@ Options: \fB\-[aChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: qcheck.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: qcheck.1,v 1.2 2005/07/18 00:29:50 solar Exp $ diff --git a/man/qdepends.1 b/man/qdepends.1 index f10d7a49..0dedc6b6 100644 --- a/man/qdepends.1 +++ b/man/qdepends.1 @@ -1,14 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH qdepends "1" "June 2005" "Gentoo Foundation" "qdepends" +.TH qdepends "1" "July 2005" "Gentoo Foundation" "qdepends" .SH NAME -qdepends \- manual page for qdepends main.c compiled Jun 17 2005 +qdepends \- manual page for qdepends compiled on Jul 17 2005 .SH SYNOPSIS .B qdepends -\fI<pkgname>\fR +\fI<pkgname> : show dependency info\fR .SH DESCRIPTION -* qdepends: show dependency info -.PP -Options: \fB\-[drpacChV]\fR +Options: \fB\-[drpacvChV]\fR .TP \fB\-d\fR, \fB\-\-depend\fR * Show DEPEND info (default) @@ -25,6 +23,9 @@ Options: \fB\-[drpacChV]\fR \fB\-a\fR, \fB\-\-all\fR * Show all DEPEND info .TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise +.TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color .TP @@ -34,4 +35,4 @@ Options: \fB\-[drpacChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: qdepends.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: qdepends.1,v 1.2 2005/07/18 00:29:50 solar Exp $ diff --git a/man/qfile.1 b/man/qfile.1 index e28bd7f5..a6c91800 100644 --- a/man/qfile.1 +++ b/man/qfile.1 @@ -1,18 +1,22 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH qfile "1" "June 2005" "Gentoo Foundation" "qfile" +.TH qfile "1" "July 2005" "Gentoo Foundation" "qfile" .SH NAME -qfile \- manual page for qfile main.c compiled Jun 17 2005 +qfile \- manual page for qfile compiled on Jul 17 2005 .SH SYNOPSIS .B qfile -\fI<filename>\fR +\fI<filename> : list all pkgs owning files\fR .SH DESCRIPTION -* qfile: list all pkgs owning files -.PP -Options: \fB\-[eChV]\fR +Options: \fB\-[eqvChV]\fR .TP \fB\-e\fR, \fB\-\-exact\fR * Exact match .TP +\fB\-q\fR, \fB\-\-quiet\fR +* Output package only +.TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise +.TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color .TP @@ -22,4 +26,4 @@ Options: \fB\-[eChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: qfile.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: qfile.1,v 1.2 2005/07/18 00:29:50 solar Exp $ diff --git a/man/qlist.1 b/man/qlist.1 index 4b4fb0e4..ff5c19d4 100644 --- a/man/qlist.1 +++ b/man/qlist.1 @@ -1,14 +1,18 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH qlist "1" "June 2005" "Gentoo Foundation" "qlist" +.TH qlist "1" "July 2005" "Gentoo Foundation" "qlist" .SH NAME -qlist \- manual page for qlist main.c compiled Jun 17 2005 +qlist \- manual page for qlist compiled on Jul 17 2005 .SH SYNOPSIS .B qlist -\fI<pkgname>\fR +\fI<pkgname> : list files owned by pkgname\fR .SH DESCRIPTION -* qlist: list files owned by pkgname -.PP -Options: \fB\-[ChV]\fR +Options: \fB\-[IvChV]\fR +.TP +\fB\-I\fR, \fB\-\-installed\fR +* Just show installed packages +.TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise .TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color @@ -19,4 +23,4 @@ Options: \fB\-[ChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: qlist.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: qlist.1,v 1.2 2005/07/18 00:29:50 solar Exp $ diff --git a/man/qsearch.1 b/man/qsearch.1 index 7ded12e8..f4e3b218 100644 --- a/man/qsearch.1 +++ b/man/qsearch.1 @@ -1,14 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH qsearch "1" "June 2005" "Gentoo Foundation" "qsearch" +.TH qsearch "1" "July 2005" "Gentoo Foundation" "qsearch" .SH NAME -qsearch \- manual page for qsearch main.c compiled Jun 17 2005 +qsearch \- manual page for qsearch compiled on Jul 17 2005 .SH SYNOPSIS .B qsearch -\fI<regex>\fR +\fI<regex> : search pkgname/desc\fR .SH DESCRIPTION -* qsearch: search pkgname/desc -.PP -Options: \fB\-[acsSChV]\fR +Options: \fB\-[acsSHvChV]\fR .TP \fB\-a\fR, \fB\-\-all\fR * List the descriptions of every package in the cache @@ -18,8 +16,17 @@ Options: \fB\-[acsSChV]\fR .TP \fB\-s\fR, \fB\-\-search\fR * Regex search package names -.HP -\fB\-S\fR, \fB\-\-searchdesc\fR <arg> * Regex search package descriptions +.TP +\fB\-S\fR, \fB\-\-desc\fR +<arg> +.BR + * Regex search package descriptions +.TP +\fB\-H\fR, \fB\-\-homepage\fR +* Show homepage info +.TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise .TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color @@ -30,4 +37,4 @@ Options: \fB\-[acsSChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: qsearch.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: qsearch.1,v 1.2 2005/07/18 00:29:50 solar Exp $ diff --git a/man/qsize.1 b/man/qsize.1 index b20a7723..6bdf634d 100644 --- a/man/qsize.1 +++ b/man/qsize.1 @@ -1,14 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH qsize "1" "June 2005" "Gentoo Foundation" "qsize" +.TH qsize "1" "July 2005" "Gentoo Foundation" "qsize" .SH NAME -qsize \- manual page for qsize main.c compiled Jun 17 2005 +qsize \- manual page for qsize compiled on Jul 17 2005 .SH SYNOPSIS .B qsize -\fI<pkgname>\fR +\fI<pkgname> : calculate size usage\fR .SH DESCRIPTION -* qsize: calculate size usage -.PP -Options: \fB\-[fasSmkbChV]\fR +Options: \fB\-[fasSmkbvChV]\fR .TP \fB\-f\fR, \fB\-\-filesystem\fR * Show size used on disk @@ -31,6 +29,9 @@ Options: \fB\-[fasSmkbChV]\fR \fB\-b\fR, \fB\-\-bytes\fR * Display size in bytes .TP +\fB\-v\fR, \fB\-\-verbose\fR +* Make a lot of noise +.TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color .TP @@ -40,4 +41,4 @@ Options: \fB\-[fasSmkbChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: qsize.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: qsize.1,v 1.2 2005/07/18 00:29:50 solar Exp $ @@ -1,20 +1,27 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. -.TH quse "1" "June 2005" "Gentoo Foundation" "quse" +.TH quse "1" "July 2005" "Gentoo Foundation" "quse" .SH NAME -quse \- manual page for quse main.c compiled Jun 17 2005 +quse \- manual page for quse compiled on Jul 17 2005 .SH SYNOPSIS .B quse -\fI<useflag>\fR +\fI<useflag> : find pkgs using useflags\fR .SH DESCRIPTION -* quse: find pkgs using useflag -.PP -Options: \fB\-[avChV]\fR +Options: \fB\-[eavKLvChV]\fR +.TP +\fB\-e\fR, \fB\-\-exact\fR +* Show exact non regexp matching using strcmp .TP \fB\-a\fR, \fB\-\-all\fR -* List every package in the cache +* Show annoying things in IUSE +.TP +\fB\-K\fR, \fB\-\-keywords\fR +* Use the KEYWORDS vs IUSE +.TP +\fB\-L\fR, \fB\-\-licence\fR +* Use the LICENSE vs IUSE .TP \fB\-v\fR, \fB\-\-verbose\fR -* Show annoying things in IUSE +* Make a lot of noise .TP \fB\-C\fR, \fB\-\-nocolor\fR * Don't output color @@ -25,4 +32,4 @@ Options: \fB\-[avChV]\fR \fB\-V\fR, \fB\-\-version\fR * Print version and exit .PP -$Id: quse.1,v 1.1 2005/06/17 15:59:17 solar Exp $ +$Id: quse.1,v 1.2 2005/07/18 00:29:50 solar Exp $ @@ -1,7 +1,7 @@ /* * Copyright 2005 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/quse.c,v 1.19 2005/07/07 11:28:31 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/quse.c,v 1.20 2005/07/18 00:29:50 solar Exp $ * * 2005 Ned Ludd - <solar@gentoo.org> * 2005 Mike Frysinger - <vapier@gentoo.org> @@ -26,8 +26,9 @@ -#define QUSE_FLAGS "avKL" COMMON_FLAGS +#define QUSE_FLAGS "eavKL" COMMON_FLAGS static struct option const quse_long_opts[] = { + {"exact", no_argument, NULL, 'e'}, {"all", no_argument, NULL, 'a'}, {"keywords", no_argument, NULL, 'K'}, {"licence", no_argument, NULL, 'L'}, @@ -35,6 +36,7 @@ static struct option const quse_long_opts[] = { COMMON_LONG_OPTS }; static const char *quse_opts_help[] = { + "Show exact non regexp matching using strcmp", "Show annoying things in IUSE", "Use the KEYWORDS vs IUSE", "Use the LICENSE vs IUSE", @@ -81,12 +83,17 @@ int quse_main(int argc, char **argv) { FILE *fp; char *p; - char buf[2][_POSIX_PATH_MAX]; + + char buf0[_POSIX_PATH_MAX]; + char buf1[_POSIX_PATH_MAX]; + char buf2[_POSIX_PATH_MAX]; + char ebuild[_POSIX_PATH_MAX]; + const char *search_var = NULL; const char *search_vars[] = { "IUSE=", "KEYWORDS=", "LICENSE=", search_var }; short all = 0; - int i, idx = 0; + int regexp_matching = 1 , i, idx = 0; size_t search_len; DBG("argc=%d argv[0]=%s argv[1]=%s", @@ -94,6 +101,7 @@ int quse_main(int argc, char **argv) while ((i = GETOPT_LONG(QUSE, quse, "")) != -1) { switch (i) { + case 'e': regexp_matching = 0; break; case 'a': all = 1; break; case 'K': idx = 1; break; case 'L': idx = 2; break; @@ -101,6 +109,9 @@ int quse_main(int argc, char **argv) COMMON_GETOPTS_CASES(quse) } } + if (argc == optind && !all) + quse_usage(EXIT_FAILURE); + if (all) optind = argc; initialize_ebuild_flat(); /* sets our pwd to $PORTDIR */ @@ -114,50 +125,50 @@ int quse_main(int argc, char **argv) *p = 0; if ((newfp = fopen(ebuild, "r")) != NULL) { unsigned int lineno = 0; - while ((fgets(buf[0], sizeof(buf[0]), newfp)) != NULL) { + while ((fgets(buf0, sizeof(buf0), newfp)) != NULL) { int ok = 0; lineno++; - if ((strncmp(buf[0], search_vars[idx], search_len)) != 0) + if ((strncmp(buf0, search_vars[idx], search_len)) != 0) continue; - if ((p = strchr(buf[0], '\n')) != NULL) + if ((p = strchr(buf0, '\n')) != NULL) *p = 0; if (verbose) { - if ((strchr(buf[0], '\t') != NULL) - || (strchr(buf[0], '\\') != NULL) - || (strchr(buf[0], '\'') != NULL) - || (strstr(buf[0], " ") != NULL)) - warn("# Line %d of %s has an annoying %s", lineno, ebuild, buf[0]); + if ((strchr(buf0, '\t') != NULL) + || (strchr(buf0, '\\') != NULL) + || (strchr(buf0, '\'') != NULL) + || (strstr(buf0, " ") != NULL)) + warn("# Line %d of %s has an annoying %s", lineno, ebuild, buf0); } #ifdef THIS_SUCKS - if ((p = strrchr(&buf[0][search_len+1], '\\')) != NULL) { + if ((p = strrchr(&buf0[search_len+1], '\\')) != NULL) { multiline: *p = ' '; - memset(buf[1], 0, sizeof(buf[1])); + memset(buf1, 0, sizeof(buf1)); - if ((fgets(buf[1], sizeof(buf[1]), newfp)) == NULL) + if ((fgets(buf1, sizeof(buf1), newfp)) == NULL) continue; lineno++; - if ((p = strchr(buf[1], '\n')) != NULL) + if ((p = strchr(buf1, '\n')) != NULL) *p = 0; - snprintf(buf[2], sizeof(buf[2]), "%s %s", buf[0], buf[1]); - remove_extra_space(buf[2]); - strcpy(buf[0], buf[2]); - if ((p = strrchr(buf[1], '\\')) != NULL) + snprintf(buf2, sizeof(buf2), "%s %s", buf0, buf1); + remove_extra_space(buf2); + strcpy(buf0, buf2); + if ((p = strrchr(buf1, '\\')) != NULL) goto multiline; } #else - remove_extra_space(buf[0]); + remove_extra_space(buf0); #endif - while ((p = strrchr(&buf[0][search_len+1], '"')) != NULL) *p = 0; - while ((p = strrchr(&buf[0][search_len+1], '\'')) != NULL) *p = 0; - while ((p = strrchr(&buf[0][search_len+1], '\\')) != NULL) *p = ' '; + while ((p = strrchr(&buf0[search_len+1], '"')) != NULL) *p = 0; + while ((p = strrchr(&buf0[search_len+1], '\'')) != NULL) *p = 0; + while ((p = strrchr(&buf0[search_len+1], '\\')) != NULL) *p = ' '; - if ((size_t)strlen(buf[0]) < (size_t)(search_len+1)) { - // warnf("err '%s'/%lu <= %lu; line %d\n", buf[0], (unsigned long)strlen(buf[0]), (unsigned long)(search_len+1), lineno); + if ((size_t)strlen(buf0) < (size_t)(search_len+1)) { + // warnf("err '%s'/%lu <= %lu; line %d\n", buf0, (unsigned long)strlen(buf0), (unsigned long)(search_len+1), lineno); continue; } @@ -165,16 +176,39 @@ int quse_main(int argc, char **argv) ok = 1; } else { ok = 0; - for (i = optind; i < argc; ++i) { - if (rematch(argv[i], &buf[0][search_len+1], REG_NOSUB) == 0) { - ok = 1; - break; + if (regexp_matching) { + for (i = optind; i < argc; ++i) { + if (rematch(argv[i], &buf0[search_len+1], REG_NOSUB) == 0) { + ok = 1; + break; + } + } + } else { + remove_extra_space(buf0); + assert(buf0 != NULL); + strcpy(buf1, buf0); + while ((p = strchr(buf1, ' ')) != NULL) { + *p = 0; + assert(p + 1 != NULL); + for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) { + assert(buf1 != NULL); + assert(argv[i] != NULL); + printf("%s %s %d %d %d %d\n", argv[i], buf1, i, sizeof(buf0), sizeof(buf1), sizeof(buf2)); + if (strcmp(buf1, argv[i]) == 0) { + ok = 1; + break; + } + printf("- %d strcmp(%s, %s) = 0\n", i, argv[i], buf1); + } + assert(p + 1 != NULL); + strcpy(buf2, p + 1); + strcpy(buf1, buf2); } } } if (ok) { printf("%s%s%s ", CYAN, ebuild, NORM); - print_highlighted_use_flags(&buf[0][search_len+1], optind, argc, argv); + print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv); puts(NORM); } break; |