From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Puh8y-0008QJ-Pz for garchives@archives.gentoo.org; Wed, 02 Mar 2011 08:10:49 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1A23F1C025; Wed, 2 Mar 2011 08:10:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id CF89E1C025 for ; Wed, 2 Mar 2011 08:10:41 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0ECE21BC0DE for ; Wed, 2 Mar 2011 08:10:41 +0000 (UTC) Received: by flycatcher.gentoo.org (Postfix, from userid 559) id A9C782004F; Wed, 2 Mar 2011 08:10:39 +0000 (UTC) From: "Mike Frysinger (vapier)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, vapier@gentoo.org Subject: [gentoo-commits] gentoo-projects commit in portage-utils: main.c X-VCS-Repository: gentoo-projects X-VCS-Files: main.c X-VCS-Directories: portage-utils X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger Content-Type: text/plain; charset=utf8 Message-Id: <20110302081039.A9C782004F@flycatcher.gentoo.org> Date: Wed, 2 Mar 2011 08:10:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: e6e85fba660cbc86b2a9ecde6e5564ec vapier 11/03/02 08:10:39 Modified: main.c Log: restore & simplify the ROOT slash append check Revision Changes Path 1.190 portage-utils/main.c file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils= /main.c?rev=3D1.190&view=3Dmarkup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils= /main.c?rev=3D1.190&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils= /main.c?r1=3D1.189&r2=3D1.190 Index: main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v retrieving revision 1.189 retrieving revision 1.190 diff -u -r1.189 -r1.190 --- main.c 2 Mar 2011 07:55:57 -0000 1.189 +++ main.c 2 Mar 2011 08:10:39 -0000 1.190 @@ -1,7 +1,7 @@ /* * Copyright 2005-2008 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.189 20= 11/03/02 07:55:57 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.190 20= 11/03/02 08:10:39 vapier Exp $ * * Copyright 2005-2008 Ned Ludd - * Copyright 2005-2008 Mike Frysinger - @@ -542,7 +542,7 @@ break; case _Q_STR: free(*var->value.s); - *var->value.s =3D xstrdup(value); + *var->value.s =3D xstrdup_len(value, &var->value_len); break; case _Q_ISTR: strincr_var(var->name, value, var->value.s, &var->value_len); @@ -678,6 +678,7 @@ }; bool nocolor =3D 0; =20 + env_vars *var; env_vars vars_to_read[] =3D { #define _Q_EV(t, V, set, lset, d) \ { \ @@ -691,6 +692,7 @@ #define _Q_EVS(t, V, v, d) _Q_EV(t, V, .value.s =3D &v, .value_len =3D s= trlen(d), d) #define _Q_EVB(t, V, v, d) _Q_EV(t, V, .value.b =3D &v, .value_len =3D 0= , d) =20 + _Q_EVS(STR, ROOT, portroot, "/") _Q_EVS(STR, ACCEPT_LICENSE, accept_license, "") _Q_EVS(ISTR, INSTALL_MASK, install_mask, "") _Q_EVS(STR, ARCH, portarch, "") @@ -702,7 +704,6 @@ _Q_EVS(STR, PORTAGE_BINHOST, binhost, DEFAULT_PORTAGE= _BINHOST) _Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "/var/t= mp/portage/") _Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "/usr/p= ortage/packages/") - _Q_EVS(STR, ROOT, portroot, "/") /* XXX: This needs to not have a leading slash since some of the q * utils use chdir(root) && chdir(portvdb). Once those are * fixed, we can add a proper leading slash here. */ @@ -713,9 +714,11 @@ }; =20 /* initialize all the strings with their default value */ - for (i =3D 0; vars_to_read[i].name; ++i) - if (vars_to_read[i].type !=3D _Q_BOOL) - *vars_to_read[i].value.s =3D xstrdup(vars_to_read[i].default_value); + for (i =3D 0; vars_to_read[i].name; ++i) { + var =3D &vars_to_read[i]; + if (var->type !=3D _Q_BOOL) + *var->value.s =3D xstrdup(var->default_value); + } =20 /* walk all the stacked profiles */ read_portage_profile(EPREFIX "/etc/make.profile", vars_to_read); @@ -727,19 +730,28 @@ =20 /* finally, check the env */ for (i =3D 0; vars_to_read[i].name; ++i) { - s =3D getenv(vars_to_read[i].name); + var =3D &vars_to_read[i]; + s =3D getenv(var->name); if (s !=3D NULL) - set_portage_env_var(&vars_to_read[i], s); + set_portage_env_var(var, s); if (getenv("DEBUG") IF_DEBUG(|| 1)) { - fprintf(stderr, "%s =3D ", vars_to_read[i].name); + fprintf(stderr, "%s =3D ", var->name); switch (vars_to_read[i].type) { - case _Q_BOOL: fprintf(stderr, "%i\n", *vars_to_read[i].value.b); brea= k; + case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break; case _Q_STR: - case _Q_ISTR: fprintf(stderr, "%s\n", *vars_to_read[i].value.s); brea= k; + case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break; } } } =20 + /* Make sure ROOT always ends in a slash */ + var =3D &vars_to_read[0]; + if ((*var->value.s)[var->value_len - 1] !=3D '/') { + portroot =3D xrealloc(portroot, var->value_len + 2); + portroot[var->value_len] =3D '/'; + portroot[var->value_len + 1] =3D '\0'; + } + if (getenv("PORTAGE_QUIET") !=3D NULL) quiet =3D 1; =20