pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files/lib pkg_install-20090610:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f6872a6ada91
branches:  trunk
changeset: 560342:f6872a6ada91
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Wed Jun 10 20:15:11 2009 +0000

description:
pkg_install-20090610:
Improve diagnostic around license handling.

diffstat:

 pkgtools/pkg_install/files/lib/license.c |  45 ++++++++++++++++++++++---------
 pkgtools/pkg_install/files/lib/version.h |   4 +-
 2 files changed, 34 insertions(+), 15 deletions(-)

diffs (143 lines):

diff -r 4c679b1ecac9 -r f6872a6ada91 pkgtools/pkg_install/files/lib/license.c
--- a/pkgtools/pkg_install/files/lib/license.c  Wed Jun 10 17:33:44 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/license.c  Wed Jun 10 20:15:11 2009 +0000
@@ -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@localhost>.
@@ -156,14 +156,16 @@
        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 @@
 
        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 @@
                        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 @@
                        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 @@
 {
        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 -r 4c679b1ecac9 -r f6872a6ada91 pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Wed Jun 10 17:33:44 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Wed Jun 10 20:15:11 2009 +0000
@@ -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_ */



Home | Main Index | Thread Index | Old Index