summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2009-06-10 20:15:11 +0000
committerjoerg <joerg@pkgsrc.org>2009-06-10 20:15:11 +0000
commitba9c59e3bfc8be935502308de9fd2a4904a99aeb (patch)
tree89c0bc23929eebe6acc079b4bf83876572ee1bd4 /pkgtools
parent47e74157b8b7674b25647d9d702be13b59bef6d8 (diff)
downloadpkgsrc-ba9c59e3bfc8be935502308de9fd2a4904a99aeb.tar.gz
pkg_install-20090610:
Improve diagnostic around license handling.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/lib/license.c45
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
2 files changed, 34 insertions, 15 deletions
diff --git a/pkgtools/pkg_install/files/lib/license.c b/pkgtools/pkg_install/files/lib/license.c
index c88415614a6..d408bb4a815 100644
--- a/pkgtools/pkg_install/files/lib/license.c
+++ b/pkgtools/pkg_install/files/lib/license.c
@@ -1,4 +1,4 @@
-/* $NetBSD: license.c,v 1.4 2009/06/03 16:45:17 ahoka Exp $ */
+/* $NetBSD: license.c,v 1.5 2009/06/10 20:15:11 joerg Exp $ */
/*-
* Copyright (c) 2009 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -156,14 +156,16 @@ acceptable_license(const char *license)
size_t len;
len = strlen(license);
- if (strspn(license, license_chars) != len)
+ if (strspn(license, license_chars) != len) {
+ warnx("Invalid character in license name at position %zu", len);
return -1;
+ }
return acceptable_license_internal(license, len);
}
static int
-acceptable_pkg_license_internal(const char **licensep, int toplevel)
+acceptable_pkg_license_internal(const char **licensep, int toplevel, const char *start)
{
const char *license = *licensep;
int need_parenthesis, is_true = 0;
@@ -182,7 +184,7 @@ acceptable_pkg_license_internal(const char **licensep, int toplevel)
for (;;) {
if (*license == '(') {
- switch (acceptable_pkg_license_internal(&license, 0)) {
+ switch (acceptable_pkg_license_internal(&license, 0, start)) {
case -1:
return -1;
case 0:
@@ -196,8 +198,10 @@ acceptable_pkg_license_internal(const char **licensep, int toplevel)
license += strspn(license, license_spaces);
} else {
len = strspn(license, license_chars);
- if (len == 0)
+ if (len == 0) {
+ warnx("Invalid character in license name at position %zu", license - start + 1);
return -1;
+ }
if (acceptable_license_internal(license, len)) {
if (expr_type != 2)
@@ -209,40 +213,53 @@ acceptable_pkg_license_internal(const char **licensep, int toplevel)
license += len;
len = strspn(license, license_spaces);
- if (len == 0 && *license && *license != ')')
+ if (len == 0 && *license && *license != ')') {
+ warnx("Missing space at position %zu", license - start + 1);
return -1;
+ }
license += len;
}
if (*license == ')') {
- if (!need_parenthesis)
+ if (!need_parenthesis) {
+ warnx("Missing open parenthesis at position %zu", license - start + 1);
return -1;
+ }
*licensep = license + 1;
return is_true;
}
if (*license == '\0') {
- if (need_parenthesis)
+ if (need_parenthesis) {
+ warnx("Unbalanced parenthesis at position %zu", license - start + 1);
return -1;
+ }
*licensep = license;
return is_true;
}
if (strncmp(license, "AND", 3) == 0) {
- if (expr_type == 1)
+ if (expr_type == 1) {
+ warnx("Invalid operator in OR expression at position %zu", license - start + 1);
return -1;
+ }
expr_type = 2;
license += 3;
} else if (strncmp(license, "OR", 2) == 0) {
- if (expr_type == 2)
+ if (expr_type == 2) {
+ warnx("Invalid operator in AND expression at position %zu", license - start + 1);
return -1;
+ }
expr_type = 1;
license += 2;
} else {
+ warnx("Invalid operator at position %zu", license - start + 1);
return -1;
}
len = strspn(license, license_spaces);
- if (len == 0 && *license != '(')
+ if (len == 0 && *license != '(') {
+ warnx("Missing space at position %zu", license - start + 1);
return -1;
+ }
license += len;
}
@@ -254,12 +271,14 @@ acceptable_pkg_license(const char *license)
{
int ret;
- ret = acceptable_pkg_license_internal(&license, 1);
+ ret = acceptable_pkg_license_internal(&license, 1, license);
if (ret == -1)
return -1;
license += strspn(license, license_spaces);
- if (*license)
+ if (*license) {
+ warnx("Trailing garbage in license specification");
return -1;
+ }
return ret;
}
diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index 69034757ca1..7668fff2875 100644
--- a/pkgtools/pkg_install/files/lib/version.h
+++ b/pkgtools/pkg_install/files/lib/version.h
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.130 2009/05/28 08:59:59 joerg Exp $ */
+/* $NetBSD: version.h,v 1.131 2009/06/10 20:15:11 joerg Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@@ -27,6 +27,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
-#define PKGTOOLS_VERSION "20090528"
+#define PKGTOOLS_VERSION "20090610"
#endif /* _INST_LIB_VERSION_H_ */