After finally getting my cup of coffee, I think I'm actually wrong on this
change. This change allows this signature:
xmldb:create-user($name as xs:string, $pass as xs:string,
$primary-group as xs:string, $groups as xs:string*)
to accept
xmldb:create-user("user", "pass", "users")
which on second reading of the spec I think is not allowed. Instead, I
think it should have to be called in this fashion:
xmldb:create-user("user", "pass", "users", ())
In that case, this patch is not correct. The spec is here:
http://www.w3.org/TR/xquery-operators/#func-signatures
I think I was actually wrong on this one. :-( I think a function always
has a fixed number of arguments; it's just that some of them can be empty
sequences.
On Thu, 23 Sep 2004, Wolfgang Meier wrote:
Seems reasonable. Can you check this in?
Wolfgang
This checks under- and over-flow of arguments to a function. Instead of
trying to determine how many arguments a signature allows (not always
possible), instead Function asks Signature if a certain number are
allowed.
Index: src/org/exist/xquery/FunctionSignature.java
===================================================================
RCS file:
/cvsroot/exist/eXist-1.0/src/org/exist/xquery/FunctionSignature.java,v
retrieving revision 1.1
diff -r1.1 FunctionSignature.java
88,89c88,113
< return arguments != null ? arguments.length : 0;
< }
---
if (arguments == null || arguments.length == 0)
return 0;
int len = arguments.length;
if ((arguments[len - 1].getCardinality() & Cardinality.ZERO) ==
Cardinality.ZERO) return len - 1;
else
return len;
}
public boolean isUnlimitedArguments() {
if (arguments == null || arguments.length == 0)
return false;
int len = arguments.length;
return ((arguments[len - 1].getCardinality() & Cardinality.MANY)
== Cardinality.MANY); }
public boolean isArgumentCountAllowed(int count) {
int minArgs = getArgumentCount();
if (count < minArgs)
return false;
if (count == minArgs)
return true;
return isUnlimitedArguments();
}
Index: src/org/exist/xquery/Function.java
===================================================================
RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/Function.java,v
retrieving revision 1.6
diff -r1.6 Function.java
162,163c162
< if ((!mySignature.isOverloaded())
< && arguments.size() !=
mySignature.getArgumentCount()) ---
if ((!mySignature.isOverloaded()) &&
(!mySignature.isArgumentCountAllowed(arguments.size())))
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Exist-open mailing list
Exist-open@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/exist-open
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Exist-open mailing list
Exist-open@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/exist-open
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here:
http://sf.net/ppc_contest.php