aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-10-28 10:29:38 +0000
committerMike Frysinger <vapier@gentoo.org>2012-10-28 10:29:38 +0000
commit9d10d6a655874907160c7fa83cb92daf30d718de (patch)
treebf6ebb33566b90be5525e1d03a3c614017a56d9d
parentfix variable name length calculation when expanding later vars #417457 by ste... (diff)
downloadportage-utils-9d10d6a655874907160c7fa83cb92daf30d718de.tar.gz
portage-utils-9d10d6a655874907160c7fa83cb92daf30d718de.tar.bz2
portage-utils-9d10d6a655874907160c7fa83cb92daf30d718de.zip
improve trimming of quotes/whitespace when loading env filesv0.20
-rw-r--r--main.c17
-rwxr-xr-xtests/profile/dotest2
-rw-r--r--tests/profile/profile1/etc/portage/make.conf8
3 files changed, 18 insertions, 9 deletions
diff --git a/main.c b/main.c
index 33107f3..98809c1 100644
--- a/main.c
+++ b/main.c
@@ -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.224 2012/10/28 10:11:47 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.225 2012/10/28 10:29:38 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -581,25 +581,30 @@ _q_static void read_portage_env_file(const char *configroot, const char *file, e
abuf = NULL;
while (getline(&abuf, &abuflen, fp) != -1) {
buf = xrealloc(buf, buflen + abuflen);
+ endq = strchr(abuf, q);
+ if (endq)
+ *endq = '\0';
+
strcat(buf, abuf);
buflen += abuflen;
- endq = strchr(abuf, q);
- if (endq) {
- *endq = '\0';
+ if (endq)
break;
- }
}
free(abuf);
if (!endq)
warn("%s:%zu: %s: quote mismatch", file, line, vars[i].name);
- s = buf + vars[i].name_len + 1;
+ s = buf + vars[i].name_len + 2;
} else {
*endq = '\0';
++s;
}
+ } else {
+ /* no quotes, so chop the spacing/comments ourselves */
+ size_t off = strcspn(s, "# \t\n");
+ s[off] = '\0';
}
set_portage_env_var(&vars[i], s);
diff --git a/tests/profile/dotest b/tests/profile/dotest
index 705fb73..e6b4af0 100755
--- a/tests/profile/dotest
+++ b/tests/profile/dotest
@@ -39,7 +39,7 @@ tenv inv ARCH
# this validates simple stuff
tenv 1 ARCH x86
-tenv 1 INSTALL_MASK imask
+tenv 1 INSTALL_MASK "imask x b"
# this validates -* behavior
tenv 1 CONFIG_PROTECT
diff --git a/tests/profile/profile1/etc/portage/make.conf b/tests/profile/profile1/etc/portage/make.conf
index 8a97976..fc26522 100644
--- a/tests/profile/profile1/etc/portage/make.conf
+++ b/tests/profile/profile1/etc/portage/make.conf
@@ -1,7 +1,7 @@
-ARCH=x86
+ARCH=x86 # comment
#395629
-CONFIG_PROTECT=-*
+CONFIG_PROTECT=-* #fkajdsf
source this.level.conf
@@ -10,6 +10,10 @@ source ../parent.conf
source subdir/file.conf
INSTALL_MASK=" imask "
+INSTALL_MASK="${INSTALL_MASK} x "
+INSTALL_MASK="$INSTALL_MASK
+ b
+" #fj
PORTAGE_BINHOST="http://someurl/" # this is a comment
NOCOLOR=1 # this is a comment