1 |
vapier 14/02/25 21:30:50 |
2 |
|
3 |
Modified: main.c q.c |
4 |
Log: |
5 |
add support for setting ROOT via cmdline --root flag http://crbug.com/336871 |
6 |
|
7 |
Revision Changes Path |
8 |
1.232 portage-utils/main.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.232&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.232&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.231&r2=1.232 |
13 |
|
14 |
Index: main.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v |
17 |
retrieving revision 1.231 |
18 |
retrieving revision 1.232 |
19 |
diff -u -r1.231 -r1.232 |
20 |
--- main.c 18 Feb 2014 07:31:33 -0000 1.231 |
21 |
+++ main.c 25 Feb 2014 21:30:50 -0000 1.232 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2005-2013 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.231 2014/02/18 07:31:33 vapier Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.232 2014/02/25 21:30:50 vapier Exp $ |
28 |
* |
29 |
* Copyright 2005-2008 Ned Ludd - <solar@g.o> |
30 |
* Copyright 2005-2013 Mike Frysinger - <vapier@g.o> |
31 |
@@ -83,6 +83,7 @@ |
32 |
/* Common usage for all applets */ |
33 |
#define COMMON_FLAGS "vqChV" |
34 |
#define COMMON_LONG_OPTS \ |
35 |
+ {"root", a_argument, NULL, 0x1}, \ |
36 |
{"verbose", no_argument, NULL, 'v'}, \ |
37 |
{"quiet", no_argument, NULL, 'q'}, \ |
38 |
{"nocolor", no_argument, NULL, 'C'}, \ |
39 |
@@ -90,6 +91,7 @@ |
40 |
{"version", no_argument, NULL, 'V'}, \ |
41 |
{NULL, no_argument, NULL, 0x0} |
42 |
#define COMMON_OPTS_HELP \ |
43 |
+ "Set the ROOT env var", \ |
44 |
"Make a lot of noise", \ |
45 |
"Tighter output; suppress warnings", \ |
46 |
"Don't output color", \ |
47 |
@@ -97,6 +99,7 @@ |
48 |
"Print version and exit", \ |
49 |
NULL |
50 |
#define COMMON_GETOPTS_CASES(applet) \ |
51 |
+ case 0x1: portroot = optarg; break; \ |
52 |
case 'v': ++verbose; break; \ |
53 |
case 'q': ++quiet; if (freopen("/dev/null", "w", stderr)) { /* ignore errors */ } break; \ |
54 |
case 'V': version_barf( applet ## _rcsid ); break; \ |
55 |
@@ -137,7 +140,7 @@ |
56 |
assert(help[i] != NULL); |
57 |
|
58 |
/* first output the short flag if it has one */ |
59 |
- if (opts[i].val > '~') |
60 |
+ if (opts[i].val > '~' || opts[i].val < ' ') |
61 |
printf(" "); |
62 |
else |
63 |
printf(" -%c, ", opts[i].val); |
64 |
|
65 |
|
66 |
|
67 |
1.53 portage-utils/q.c |
68 |
|
69 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/q.c?rev=1.53&view=markup |
70 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/q.c?rev=1.53&content-type=text/plain |
71 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/q.c?r1=1.52&r2=1.53 |
72 |
|
73 |
Index: q.c |
74 |
=================================================================== |
75 |
RCS file: /var/cvsroot/gentoo-projects/portage-utils/q.c,v |
76 |
retrieving revision 1.52 |
77 |
retrieving revision 1.53 |
78 |
diff -u -r1.52 -r1.53 |
79 |
--- q.c 17 Mar 2011 03:32:51 -0000 1.52 |
80 |
+++ q.c 25 Feb 2014 21:30:50 -0000 1.53 |
81 |
@@ -1,7 +1,7 @@ |
82 |
/* |
83 |
* Copyright 2005-2010 Gentoo Foundation |
84 |
* Distributed under the terms of the GNU General Public License v2 |
85 |
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/q.c,v 1.52 2011/03/17 03:32:51 vapier Exp $ |
86 |
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/q.c,v 1.53 2014/02/25 21:30:50 vapier Exp $ |
87 |
* |
88 |
* Copyright 2005-2010 Ned Ludd - <solar@g.o> |
89 |
* Copyright 2005-2010 Mike Frysinger - <vapier@g.o> |
90 |
@@ -22,7 +22,7 @@ |
91 |
"Module path", |
92 |
COMMON_OPTS_HELP |
93 |
}; |
94 |
-static const char q_rcsid[] = "$Id: q.c,v 1.52 2011/03/17 03:32:51 vapier Exp $"; |
95 |
+static const char q_rcsid[] = "$Id: q.c,v 1.53 2014/02/25 21:30:50 vapier Exp $"; |
96 |
#define q_usage(ret) usage(ret, Q_FLAGS, q_long_opts, q_opts_help, lookup_applet_idx("q")) |
97 |
|
98 |
static APPLET lookup_applet(const char *applet) |
99 |
@@ -145,16 +145,17 @@ |
100 |
return 1; |
101 |
|
102 |
/* In case of "q --option ... appletname ...", remove appletname from the |
103 |
- * applet's args, exchange "appletname" and "--option". */ |
104 |
+ * applet's args. */ |
105 |
if (optind > 1) { |
106 |
- char* appletname = argv[optind]; |
107 |
- argv[optind] = argv[1]; |
108 |
- argv[1] = appletname; |
109 |
- } |
110 |
+ argv[0] = argv[optind]; |
111 |
+ for (i = optind; i < argc; ++i) |
112 |
+ argv[i] = argv[i + 1]; |
113 |
+ } else |
114 |
+ ++argv; |
115 |
|
116 |
optind = 0; /* reset so the applets can call getopt */ |
117 |
|
118 |
- return (func)(argc - 1, ++argv); |
119 |
+ return (func)(argc - 1, argv); |
120 |
} |
121 |
|
122 |
static int run_applet_l(const char *arg, ...) |