Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
0308d508
Commit
0308d508
authored
Oct 12, 2010
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move _checklossrate() above __DATA__ cause we do a defined() on
a coderef of it. Not sure why it does not work yet.
parent
68656b5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
31 deletions
+31
-31
db/emutil.pm.in
db/emutil.pm.in
+31
-31
No files found.
db/emutil.pm.in
View file @
0308d508
...
...
@@ -27,9 +27,39 @@ use vars qw(%DBFieldData $DBFieldErrstr);
%
DBFieldData
=
();
$
DBFieldErrstr
=
""
;
#
#
A
helper
function
for
checking
lossrates
.
Bad
place
for
this
,
I
know
.
#
Needs
to
be
before
the
__DATA__
cause
we
used
defined
()
on
it
.
Sigh
.
#
sub
_checklossrate
($)
{
my
($
token
)
=
@
_
;
return
1
if
(
"$token"
eq
"0"
);
#
floating
point
,
no
exponent
.
Stole
this
out
of
the
perl
tutorial
.
if
(
! ($token =~ /^[+-]?(\d+\.\d+|\d+\.|\.\d+)([eE][+-]?\d+)?$/)) {
$
DBFieldErrstr
=
"Improper floating number"
;
return
0
;
}
if
($
token
>
1.0
)
{
$
DBFieldErrstr
=
"Too big; must be < 1.0"
;
return
0
;
}
if
($
token
<
0.0
)
{
$
DBFieldErrstr
=
"Too small; must be > 0.0"
;
return
0
;
}
if
($
token
>
0.0
&&
$
token
<
0.000001
)
{
$
DBFieldErrstr
=
"Too small; must be >= 0.000001"
;
return
0
;
}
return
1
;
}
#
_Always_
make
sure
that
this
1
is
at
the
end
of
the
file
...
1
;
__DATA__
#
Constants
for
checkslot
code
.
...
...
@@ -207,36 +237,6 @@ sub TBcheck_dbslot($$$;$)
return
0
;
}
#
#
A
helper
function
for
checking
lossrates
.
Bad
place
for
this
,
I
know
.
#
sub
_checklossrate
($)
{
my
($
token
)
=
@
_
;
return
1
if
(
"$token"
eq
"0"
);
#
floating
point
,
no
exponent
.
Stole
this
out
of
the
perl
tutorial
.
if
(
! ($token =~ /^[+-]?(\d+\.\d+|\d+\.|\.\d+)([eE][+-]?\d+)?$/)) {
$
DBFieldErrstr
=
"Improper floating number"
;
return
0
;
}
if
($
token
>
1.0
)
{
$
DBFieldErrstr
=
"Too big; must be < 1.0"
;
return
0
;
}
if
($
token
<
0.0
)
{
$
DBFieldErrstr
=
"Too small; must be > 0.0"
;
return
0
;
}
if
($
token
>
0.0
&&
$
token
<
0.000001
)
{
$
DBFieldErrstr
=
"Too small; must be >= 0.000001"
;
return
0
;
}
return
1
;
}
#
#
Return
a
unique
index
from
emulab_indicies
for
the
indicated
name
.
#
Updates
the
index
to
be
,
well
,
unique
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment