diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2000-12-16 13:24:13 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2000-12-16 13:24:13 +0000 |
commit | 10c77e0740239bbb62b0ea612042f2482fd7a2db (patch) | |
tree | cc3615ca1d0bee6e0fba8f75c5268d885507bc96 /lib/make/new_thorn.pl | |
parent | 16b775ad5e47c3e6f4b2f086116a258c6f5c8840 (diff) |
Check names for thorns and arrangements
git-svn-id: http://svn.cactuscode.org/flesh/trunk@1959 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/make/new_thorn.pl')
-rwxr-xr-x | lib/make/new_thorn.pl | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/lib/make/new_thorn.pl b/lib/make/new_thorn.pl index 7dc40cd5..2c385a12 100755 --- a/lib/make/new_thorn.pl +++ b/lib/make/new_thorn.pl @@ -13,7 +13,7 @@ $package_dir = "arrangements"; $thorn_name = shift(@ARGV); -if(!$thorn_name) +while(&TestName(1,$thorn_name)==0) { $thorn_name = &prompt("Thorn name"); } @@ -28,7 +28,10 @@ if(!$package) print "$package\n"; } print "Pick one, or create a new one.\n"; - $package = &prompt("Arrangement"); + while (&TestName(0,$package)==0) + { + $package = &prompt("arrangement"); + } } chdir $package_dir; @@ -212,3 +215,48 @@ sub GetToolkits return @arrangements; } + +#/*@@ +# @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; +} |