Skip to content

Commit

Permalink
fixed input checking in newPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Aug 1, 2024
1 parent 719cb4f commit d2a41ec
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions M2/Macaulay2/m2/packages.m2
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,14 @@ newPackage String := opts -> pkgname -> (
then warning("newPackage: use the Contributors or Acknowledgement keywords to acknowledge contributors in the package documentation");
-- optional package values
scan({
(Keywords, List),
(Date, String),
(Headline, String),
(HomePage, String)}, (name, type) -> if opts#name =!= null and not instance(opts#name, type) then
error("newPackage: expected ", toString name, " option of class ", toString type));
if opts.?Keywords then (
if class opts.Keywords =!= List then error "expected Keywords value to be a list";
if not all(opts.Keywords, k -> class k === String) then error "expected Keywords value to be a list of strings";
);
if #opts.Headline > 100 then error "newPackage: Headline should be less than 100 characters";
if opts.Keywords =!= null and any(opts.Keywords,
keyword -> not instance(keyword, String)) then error "newPackage: expected Keywords to be a list of strings";
if opts.Headline =!= null and #opts.Headline > 100 then error "newPackage: expected Headline to be less than 100 characters";
-- the options coming from loadPackage are stored here
loadOptions := if loadPackageOptions#?pkgname then loadPackageOptions#pkgname else loadPackageOptions#"default";
-- the options are stored for readPackage
Expand Down

0 comments on commit d2a41ec

Please sign in to comment.