summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-09-16 15:35:22 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-09-16 15:35:22 +0000
commit9247164704cd32ef72e3d0f078c5afd679ca3257 (patch)
treef105b5649e9bbc83b9b3f785a5a97ebee6c54543
parent049bb18bd1fc1d69841a6286f9e9008141faac9b (diff)
Check thorn names are valid when running CST
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2363 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--lib/sbin/CST12
-rw-r--r--lib/sbin/CSTUtils.pl45
2 files changed, 56 insertions, 1 deletions
diff --git a/lib/sbin/CST b/lib/sbin/CST
index a9c1ce2d..42781521 100644
--- a/lib/sbin/CST
+++ b/lib/sbin/CST
@@ -6,7 +6,7 @@
# @desc
# Parses the the configuration files for thorns.
# @enddesc
-# @version $Header: /mnt/data2/cvs2svn/cvs-repositories/Cactus/lib/sbin/CST,v 1.46 2001-09-03 21:48:51 allen Exp $
+# @version $Header: /mnt/data2/cvs2svn/cvs-repositories/Cactus/lib/sbin/CST,v 1.47 2001-09-16 15:35:22 allen Exp $
#@@*/
# Global parameter to track the number of errors from the CST
@@ -247,6 +247,16 @@ sub CreateThornList
$package = $1;
$thorn_name = $2;
+
+ # Check valid thornname
+
+ if (!TestName(1,$thorn_name))
+ {
+ $message = "Thorn name $thorn_name is not valid";
+ $hint = "Thorn names must begin with a letter, and can only contain letters, numbers and underscores\n";
+ &CST_error(0,$message,$hint,__LINE__,__FILE__);
+ }
+
# No longer strip thorn_ off the beginning of a thorn name.
# $thorn_name =~ s/thorn_//;
diff --git a/lib/sbin/CSTUtils.pl b/lib/sbin/CSTUtils.pl
index 72dee05b..c54880a7 100644
--- a/lib/sbin/CSTUtils.pl
+++ b/lib/sbin/CSTUtils.pl
@@ -202,5 +202,50 @@ sub WriteFile
}
+#/*@@
+# @routine TestName
+# @date Sat Dec 16 1.48
+# @author Gabrielle Allen
+# @desc
+# Check thorn/arrangement name is valid
+# @enddesc
+# @calls
+# @calledby
+# @history
+#
+# @endhistory
+#@@*/
+
+sub TestName
+{
+ local($thorn,$name) = @_;
+ local($valid);
+
+ $valid = 1;
+
+ if (!$name)
+ {
+ $valid = 0;
+ }
+ elsif ($name !~ /^[a-zA-Z]/)
+ {
+ print STDERR "Name must begin with a letter!\n\n";
+ $valid = 0;
+ }
+ elsif ($name !~ /^[a-zA-Z0-9_]*$/)
+ {
+ print STDERR "Name can only contain letters, numbers or underscores!\n\n";
+ $valid = 0;
+ }
+
+ if ($thorn && $name eq "doc")
+ {
+ print STDERR "Thorn name doc is not allowed!\n\n";
+ $valid = 0;
+ }
+
+ return $valid;
+}
+
1;