Fix #120 by stripping comments from the end of lines.
The debug printing is also moved after variable substitution. Now it prints: foo/template: _var foo foo/template: pkgname foo It used to print: foo/template: _var foo foo/template: pkgname ${_var}
This commit is contained in:
parent
1ed8551c08
commit
b4ef9954e7
@ -399,7 +399,7 @@ rcv_get_pkgver(rcv_t *rcv)
|
||||
size_t klen, vlen;
|
||||
map_item_t _item;
|
||||
map_item_t *item = NULL;
|
||||
char c, *ptr = rcv->ptr, *e, *p, *k, *v;
|
||||
char c, *ptr = rcv->ptr, *e, *p, *k, *v, *comment;
|
||||
uint8_t vars = 0;
|
||||
|
||||
while ((c = *ptr) != '\0') {
|
||||
@ -439,18 +439,22 @@ rcv_get_pkgver(rcv_t *rcv)
|
||||
if (v[vlen-1] == '"') {
|
||||
vlen--;
|
||||
}
|
||||
comment = strchr(v, '#');
|
||||
if (comment && comment < p) {
|
||||
while (v[vlen-1] != '#') {
|
||||
vlen--;
|
||||
}
|
||||
vlen--;
|
||||
while (isspace(v[vlen-1])) {
|
||||
vlen--;
|
||||
}
|
||||
}
|
||||
if (vlen == 0) {
|
||||
goto nextline;
|
||||
}
|
||||
_item = map_add_n(rcv->env, k, klen, v, vlen);
|
||||
item = &rcv->env->items[_item.i];
|
||||
|
||||
if (rcv->xhp.flags & XBPS_FLAG_DEBUG) {
|
||||
printf("%s: %.*s %.*s\n", rcv->fname,
|
||||
(int)item->k.len, item->k.s,
|
||||
(int)item->v.len, item->v.s);
|
||||
}
|
||||
|
||||
if (strchr(v, '$')) {
|
||||
assert(item);
|
||||
assert(item->v.s);
|
||||
@ -462,6 +466,11 @@ rcv_get_pkgver(rcv_t *rcv)
|
||||
} else {
|
||||
item->v.vmalloc = 0;
|
||||
}
|
||||
if (rcv->xhp.flags & XBPS_FLAG_DEBUG) {
|
||||
printf("%s: %.*s %.*s\n", rcv->fname,
|
||||
(int)item->k.len, item->k.s,
|
||||
(int)item->v.len, item->v.s);
|
||||
}
|
||||
if (strncmp("pkgname", k, klen) == 0) {
|
||||
rcv->have_vars |= GOT_PKGNAME_VAR;
|
||||
vars++;
|
||||
|
@ -305,7 +305,6 @@ srcpkg_with_a_ref_and_comment_head() {
|
||||
atf_set "descr" "xbps-checkvers(8): test when srcpkg does set a ref in pkgname/version/revision with a comment"
|
||||
}
|
||||
srcpkg_with_a_ref_and_comment_body() {
|
||||
atf_expect_death "Known bug: see https://github.com/voidlinux/xbps/issues/120"
|
||||
mkdir -p some_repo pkg_A void-packages/srcpkgs/foo
|
||||
cat > void-packages/srcpkgs/foo/template <<EOF
|
||||
pkgname=foo #kajskajskajskajskajskjaksjaksjaks
|
||||
|
Loading…
Reference in New Issue
Block a user